use of javax.sound.midi.Receiver in project jdk8u_jdk by JetBrains.
the class SoftSynthesizer method openStream.
public AudioInputStream openStream(AudioFormat targetFormat, Map<String, Object> info) throws MidiUnavailableException {
if (isOpen())
throw new MidiUnavailableException("Synthesizer is already open");
synchronized (control_mutex) {
gmmode = 0;
voice_allocation_mode = 0;
processPropertyInfo(info);
open = true;
implicitOpen = false;
if (targetFormat != null)
setFormat(targetFormat);
if (load_default_soundbank) {
Soundbank defbank = getDefaultSoundbank();
if (defbank != null) {
loadAllInstruments(defbank);
}
}
voices = new SoftVoice[maxpoly];
for (int i = 0; i < maxpoly; i++) voices[i] = new SoftVoice(this);
mainmixer = new SoftMainMixer(this);
channels = new SoftChannel[number_of_midi_channels];
for (int i = 0; i < channels.length; i++) channels[i] = new SoftChannel(this, i);
if (external_channels == null) {
// when the synhtesizer is closed.
if (channels.length < 16)
external_channels = new SoftChannelProxy[16];
else
external_channels = new SoftChannelProxy[channels.length];
for (int i = 0; i < external_channels.length; i++) external_channels[i] = new SoftChannelProxy();
} else {
// into the new one
if (channels.length > external_channels.length) {
SoftChannelProxy[] new_external_channels = new SoftChannelProxy[channels.length];
for (int i = 0; i < external_channels.length; i++) new_external_channels[i] = external_channels[i];
for (int i = external_channels.length; i < new_external_channels.length; i++) {
new_external_channels[i] = new SoftChannelProxy();
}
}
}
for (int i = 0; i < channels.length; i++) external_channels[i].setChannel(channels[i]);
for (SoftVoice voice : getVoices()) voice.resampler = resampler.openStreamer();
for (Receiver recv : getReceivers()) {
SoftReceiver srecv = ((SoftReceiver) recv);
srecv.open = open;
srecv.mainmixer = mainmixer;
srecv.midimessages = mainmixer.midimessages;
}
return mainmixer.getInputStream();
}
}
Aggregations