Skip to content

Commit

Permalink
Recoded sound systems
Browse files Browse the repository at this point in the history
  • Loading branch information
Lenni0451 committed May 8, 2024
1 parent 6153578 commit fc6debf
Show file tree
Hide file tree
Showing 8 changed files with 503 additions and 489 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
import net.raphimc.noteblocktool.audio.SoundMap;
import net.raphimc.noteblocktool.audio.export.AudioExporter;
import net.raphimc.noteblocktool.audio.export.AudioMerger;
import net.raphimc.noteblocktool.audio.soundsystem.JavaxSoundSystem;
import net.raphimc.noteblocktool.audio.soundsystem.impl.JavaxSoundSystem;
import net.raphimc.noteblocktool.util.SoundSampleUtil;

import javax.sound.sampled.AudioFormat;
Expand Down Expand Up @@ -88,7 +88,7 @@ private Map<Instrument, int[]> loadSounds(final AudioFormat format) {
try {
Map<Instrument, int[]> sounds = new HashMap<>();
for (Map.Entry<Instrument, String> entry : SoundMap.SOUNDS.entrySet()) {
sounds.put(entry.getKey(), readSound(format, JavaxSoundSystem.class.getResourceAsStream(entry.getValue())));
sounds.put(entry.getKey(), this.readSound(format, JavaxSoundSystem.class.getResourceAsStream(entry.getValue())));
}
return sounds;
} catch (Throwable e) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,33 @@
import net.raphimc.noteblocklib.model.SongView;
import net.raphimc.noteblocklib.util.Instrument;
import net.raphimc.noteblocktool.audio.export.AudioExporter;
import net.raphimc.noteblocktool.audio.soundsystem.OpenALSoundSystem;
import net.raphimc.noteblocktool.audio.soundsystem.impl.OpenALSoundSystem;

import javax.sound.sampled.AudioFormat;
import java.util.function.Consumer;

public class OpenALAudioExporter extends AudioExporter {

public OpenALAudioExporter(final SongView<?> songView, final AudioFormat format, final Consumer<Float> progressConsumer) {
private final OpenALSoundSystem soundSystem;

public OpenALAudioExporter(final OpenALSoundSystem soundSystem, final SongView<?> songView, final AudioFormat format, final Consumer<Float> progressConsumer) {
super(songView, format, progressConsumer);
this.soundSystem = soundSystem;
}

@Override
protected void processNote(Instrument instrument, float volume, float pitch, float panning) {
OpenALSoundSystem.playNote(instrument, volume, pitch, panning);
this.soundSystem.playNote(instrument, volume, pitch, panning);
}

@Override
protected void writeSamples() {
OpenALSoundSystem.renderSamples(this.sampleOutputStream, this.samplesPerTick);
this.soundSystem.renderSamples(this.sampleOutputStream, this.samplesPerTick);
}

@Override
protected void finish() {
OpenALSoundSystem.stopAllSources();
this.soundSystem.stopSounds();
}

}

This file was deleted.

Loading

0 comments on commit fc6debf

Please sign in to comment.