Esempio n. 1
0
 public void Configure(int channel, int note, int velocity, Patch patch, SynthParameters synthParams)
 {
     VoiceParams.Reset();
     VoiceParams.Channel     = channel;
     VoiceParams.Note        = note;
     VoiceParams.Velocity    = velocity;
     VoiceParams.SynthParams = synthParams;
     Patch = patch;
 }
Esempio n. 2
0
        public Synthesizer(int sampleRate, int audioChannels, int bufferSize, int bufferCount, int polyphony)
        {
            var MinSampleRate = 8000;
            var MaxSampleRate = 96000;

            //
            // Setup synth parameters
            MasterVolume = 1;

            SampleRate       = SynthHelper.ClampI(sampleRate, MinSampleRate, MaxSampleRate);
            MicroBufferSize  = SynthHelper.ClampI(bufferSize, (int)(SynthConstants.MinBufferSize * sampleRate), (int)(SynthConstants.MaxBufferSize * sampleRate));
            MicroBufferSize  = (int)(Math.Ceiling(MicroBufferSize / (double)SynthConstants.DefaultBlockSize) * SynthConstants.DefaultBlockSize); //ensure multiple of block size
            MicroBufferCount = (Math.Max(1, bufferCount));
            SampleBuffer     = new SampleArray((MicroBufferSize * MicroBufferCount * audioChannels));

            // Setup Controllers
            _synthChannels = new SynthParameters[SynthConstants.DefaultChannelCount];
            for (int x = 0; x < _synthChannels.Length; x++)
            {
                _synthChannels[x] = new SynthParameters(this);
            }

            // setup metronome channel
            _metronomeChannel = _synthChannels.Length - 1;

            // Create synth voices
            _voiceManager = new VoiceManager(SynthHelper.ClampI(polyphony, SynthConstants.MinPolyphony, SynthConstants.MaxPolyphony));

            // Create midi containers
            _midiEventQueue  = new LinkedList <SynthEvent>();
            _midiEventCounts = new int[MicroBufferCount];
            _layerList       = new Patch[15];

            _mutedChannels = new FastDictionary <int, bool>();
            _soloChannels  = new FastDictionary <int, bool>();

            ResetSynthControls();
        }