Skip to content

Commit 333bd30

Browse files
committed
Cleaned up code in MultithreadedAudioMixerSoundSystem
1 parent 1fcfa0a commit 333bd30

File tree

3 files changed

+5
-24
lines changed

3 files changed

+5
-24
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ repositories {
2929

3030
dependencies {
3131
include "net.raphimc:NoteBlockLib:2.1.3"
32-
include "net.raphimc:audio-mixer:1.0.0"
32+
include "net.raphimc:audio-mixer:1.0.1-SNAPSHOT"
3333
include "com.formdev:flatlaf:3.5.1"
3434
include "net.lenni0451.commons:swing:1.6.0"
3535
include "org.lwjgl:lwjgl:3.3.4"

src/main/java/net/raphimc/noteblocktool/audio/export/impl/AudioMixerAudioExporter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,8 @@
3535

3636
public class AudioMixerAudioExporter extends AudioExporter {
3737

38-
private final Map<String, int[]> sounds;
39-
private final AudioMixer audioMixer;
38+
protected final Map<String, int[]> sounds;
39+
protected final AudioMixer audioMixer;
4040

4141
public AudioMixerAudioExporter(final SongView<?> songView, final AudioFormat format, final float masterVolume, final Consumer<Float> progressConsumer) {
4242
super(songView, format, masterVolume, progressConsumer);

src/main/java/net/raphimc/noteblocktool/audio/soundsystem/impl/MultithreadedAudioMixerSoundSystem.java

Lines changed: 2 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,9 @@
1818
package net.raphimc.noteblocktool.audio.soundsystem.impl;
1919

2020
import net.raphimc.audiomixer.AudioMixer;
21-
import net.raphimc.audiomixer.sound.Sound;
2221
import net.raphimc.audiomixer.sound.source.MonoSound;
22+
import net.raphimc.audiomixer.sound.source.StaticStereoSound;
2323

24-
import javax.sound.sampled.AudioFormat;
2524
import java.util.Map;
2625
import java.util.concurrent.BrokenBarrierException;
2726
import java.util.concurrent.CyclicBarrier;
@@ -76,7 +75,7 @@ public synchronized void postTick() {
7675
throw new RuntimeException(e);
7776
}
7877
for (int[] threadSamples : this.threadSamples) {
79-
this.audioMixer.playSound(new StaticSound(threadSamples));
78+
this.audioMixer.playSound(new StaticStereoSound(threadSamples));
8079
}
8180
super.postTick();
8281
if (this.audioMixer.getActiveSounds() != 0) {
@@ -99,22 +98,4 @@ public synchronized String getStatusLine() {
9998
return "Sounds: " + mixedSounds + " / " + this.maxSounds + ", " + this.threadPool.getActiveCount() + " threads";
10099
}
101100

102-
private record StaticSound(int[] samples) implements Sound {
103-
104-
@Override
105-
public void render(final AudioFormat audioFormat, final int[] renderedSamples, final int renderedSamplesLength) {
106-
if (renderedSamplesLength != renderedSamples.length) {
107-
throw new IllegalArgumentException("Rendered samples length must match the length of the rendered samples array");
108-
}
109-
110-
System.arraycopy(this.samples, 0, renderedSamples, 0, renderedSamplesLength);
111-
}
112-
113-
@Override
114-
public boolean isFinished() {
115-
return true;
116-
}
117-
118-
}
119-
120101
}

0 commit comments

Comments
 (0)