Skip to content

Commit

Permalink
PCM : fix audio slicing
Browse files Browse the repository at this point in the history
  • Loading branch information
exch-bms2 committed Mar 6, 2018
1 parent fa67604 commit 77a6385
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/bms/player/beatoraja/audio/AbstractAudioDriver.java
Original file line number Diff line number Diff line change
Expand Up @@ -484,7 +484,7 @@ protected T load(AudioKey key) {
path = key.path;
try {
final PCM slicewav = wav.slice(key.start, key.duration);
return getKeySound(slicewav);
return slicewav != null ? getKeySound(slicewav) : null;
// System.out.println("WAV slicing - Name:"
// + name + " ID:" + note.getWav() +
// " start:" + note.getStarttime() +
Expand Down
8 changes: 6 additions & 2 deletions src/bms/player/beatoraja/audio/PCM.java
Original file line number Diff line number Diff line change
Expand Up @@ -334,8 +334,12 @@ public PCM slice(long starttime, long duration) {
// }

pcm.sample = new short[length];
System.arraycopy(this.sample, start, pcm.sample, 0, length);
return pcm;
// System.out.println(this.sample.length + " , " + start + ", " + pcm.sample.length + " , 0, " + length);
if(length > 0) {
System.arraycopy(this.sample, start, pcm.sample, 0, length);
return pcm;
}
return null;
}

public InputStream getInputStream() {
Expand Down

0 comments on commit 77a6385

Please sign in to comment.