Search in sources :

Example 1 with ModelAbstractChannelMixer

use of com.sun.media.sound.ModelAbstractChannelMixer in project jdk8u_jdk by JetBrains.

the class TestPreciseTimestampRendering method createTestSoundbankWithChannelMixer.

public static Soundbank createTestSoundbankWithChannelMixer() {
    SF2Soundbank soundbank = createTestSoundbank();
    SimpleSoundbank simplesoundbank = new SimpleSoundbank();
    SimpleInstrument simpleinstrument = new SimpleInstrument() {

        public ModelChannelMixer getChannelMixer(MidiChannel channel, AudioFormat format) {
            return new ModelAbstractChannelMixer() {

                boolean active = true;

                public boolean process(float[][] buffer, int offset, int len) {
                    for (int i = 0; i < buffer.length; i++) {
                        float[] cbuffer = buffer[i];
                        for (int j = 0; j < cbuffer.length; j++) {
                            cbuffer[j] = -cbuffer[j];
                        }
                    }
                    return active;
                }

                public void stop() {
                    active = false;
                }
            };
        }
    };
    simpleinstrument.add(soundbank.getInstruments()[0]);
    simplesoundbank.addInstrument(simpleinstrument);
    return simplesoundbank;
}
Also used : SF2Soundbank(com.sun.media.sound.SF2Soundbank) MidiChannel(javax.sound.midi.MidiChannel) SimpleSoundbank(com.sun.media.sound.SimpleSoundbank) AudioFormat(javax.sound.sampled.AudioFormat) ModelAbstractChannelMixer(com.sun.media.sound.ModelAbstractChannelMixer) SimpleInstrument(com.sun.media.sound.SimpleInstrument)

Aggregations

ModelAbstractChannelMixer (com.sun.media.sound.ModelAbstractChannelMixer)1 SF2Soundbank (com.sun.media.sound.SF2Soundbank)1 SimpleInstrument (com.sun.media.sound.SimpleInstrument)1 SimpleSoundbank (com.sun.media.sound.SimpleSoundbank)1 MidiChannel (javax.sound.midi.MidiChannel)1 AudioFormat (javax.sound.sampled.AudioFormat)1