private void setupSynth() { //initialize variables sampleBuffer = new float[audioChannels, samplesperBuffer]; rawBufferLength = audioChannels * samplesperBuffer * 2; //Assuming 16 bit data // Create voice structures voicePool = new Voice[polyphony]; for (int i = 0; i < polyphony; ++i) voicePool[i] = new Voice(this); freeVoices = new Stack<Voice>(voicePool); activeVoices = new LinkedList<Voice>(); keyRegistry = new Dictionary<NoteRegistryKey, List<Voice>>(); //Setup Channel Data panPositions_ = new float[16]; volPositions_ = new float[16]; for (int x = 0; x < volPositions_.Length; x++) volPositions_[x] = 1.00f; tunePositions_ = new double[16]; //create effect list effects = new List<BasicAudioEffect>(); }
private void setupSynth() { //checks if (sampleRate < 8000 || sampleRate > 48000) { sampleRate = 44100; this.samplesperBuffer = (sampleRate / 1000) * 50; //UnitySynth Debug.Log("-----> Invalid Sample Rate! Changed to---->" + sampleRate); Debug.Log("-----> Invalid Buffer Size! Changed to---->" + 50 + "ms"); } if (polyphony < 1 || polyphony > 500) { polyphony = 40; Debug.Log("-----> Invalid Max Poly! Changed to---->" + polyphony); } if (maxnotepoly < 1 || maxnotepoly > polyphony) { maxnotepoly = 2; Debug.Log("-----> Invalid Max Note Poly! Changed to---->" + maxnotepoly); } if (samplesperBuffer < 100 || samplesperBuffer > 500000) { this.samplesperBuffer = (int)((sampleRate / 1000.0) * 50.0); Debug.Log("-----> Invalid Buffer Size! Changed to---->" + 50 + "ms"); } if (audioChannels < 1 || audioChannels > 2) { audioChannels = 1; Debug.Log("-----> Invalid Audio Channels! Changed to---->" + audioChannels); } //initialize variables sampleBuffer = new float[audioChannels, samplesperBuffer]; rawBufferLength = audioChannels * samplesperBuffer * 2; //Assuming 16 bit data // Create voice structures voicePool = new Voice[polyphony]; for (int i = 0; i < polyphony; ++i) voicePool[i] = new Voice(this); freeVoices = new Stack<Voice>(voicePool); activeVoices = new LinkedList<Voice>(); keyRegistry = new Dictionary<NoteRegistryKey, List<Voice>>(); //Setup Channel Data panPositions_ = new float[16]; volPositions_ = new float[16]; for (int x = 0; x < volPositions_.Length; x++) volPositions_[x] = 1.00f; tunePositions_ = new double[16]; //create effect list effects = new List<BasicAudioEffect>(); }