/** Sets up an oscillator section of the synthesizer. */ private SignalProvider[] setupOscillator( Setting glideSetting, Setting coarseSetting, Setting fineSetting, Setting vibratoSetting, Setting waveformSetting, Setting blendSetting, Setting stretchSetting, Setting excitementSetting, FrequencyProvider[] pitch, SignalProvider[] vibrato, boolean includeOrgan, SoundFontReader sampleLibrary, double sampleRateInHz) { SynthesizerInput glide = new SynthesizerInput(0.0, 0.0, 1.0); SynthesizerInput coarse = new SynthesizerInput(0.0, -1.0, 1.0); SynthesizerInput fine = new SynthesizerInput(0.0, -0.0833333333, 0.0833333333); SynthesizerInput vibratoDepth = new SynthesizerInput(0.0, 0.0, 0.1666666667); WaveformInput waveform = new WaveformInput(WaveformInput.SINE); // Register all of the inputs. synthesizerInputs_.put(glideSetting, glide); synthesizerInputs_.put(coarseSetting, coarse); synthesizerInputs_.put(fineSetting, fine); synthesizerInputs_.put(vibratoSetting, vibratoDepth); waveformInputs_.put(waveformSetting, waveform); // Create a KarplusStrong module. SignalProvider[] karplusStrong = setupKarplusStrong(blendSetting, stretchSetting, excitementSetting, pitch, sampleRateInHz); // Create an organ module. SignalProvider[] organ = null; if (includeOrgan) { organ = setupDrawbarOrgan(pitch); } // Create a drum module. SignalProvider[] drums = null; if (sampleLibrary != null) { drums = setupDrums(pitch, sampleRateInHz, sampleLibrary); } SignalProvider[] response = new SignalProvider[FINGERS]; for (int finger = 0; finger < FINGERS; ++finger) { // Apply all of the layers that can control pitch; FrequencyProvider adjustedPitch = new Glide(pitch[finger], glide); adjustedPitch = new Tuner(adjustedPitch, coarse); adjustedPitch = new Tuner(adjustedPitch, fine); adjustedPitch = new Tuner(adjustedPitch, new Amplifier(vibrato[finger], vibratoDepth)); // Create the waveform. WaveformSelector selector = new WaveformSelector(waveform); selector.addDefaultWaveforms(adjustedPitch); selector.addWaveform(WaveformInput.KARPLUS_STRONG, karplusStrong[finger]); if (organ != null) { selector.addWaveform(WaveformInput.DRAWBAR_ORGAN, organ[finger]); } if (drums != null) { selector.addWaveform(WaveformInput.DRUMS, drums[finger]); } response[finger] = selector; } return response; }