public VocalSampler(Synthesizer synth, Phoneme vowel) : base(synth) { bands = new[] { // open-mid back unrounded vowel //new BandPassFilter(2600, 2700, synth.SampleRate, HighResonance, HighResonance) {Volume = LEVEL_F3}, //new BandPassFilter(1170, 1170, synth.SampleRate, HighResonance, HighResonance) {Volume = LEVEL_F2}, //new BandPassFilter(600, 600, synth.SampleRate, LowResonance, LowResonance) {Volume = LEVEL_F1}, // open-mid front unrounded vowel new BandPassFilter(3500, 3600, synth.SampleRate, HighResonance, HighResonance) {Volume = LEVEL_F4}, new BandPassFilter(2600, 2700, synth.SampleRate, HighResonance, HighResonance) {Volume = LEVEL_F3}, new BandPassFilter(1800, 1900, synth.SampleRate, HighResonance, HighResonance) {Volume = LEVEL_F2}, new BandPassFilter(650, 800, synth.SampleRate, HighResonance, HighResonance) {Volume = LEVEL_F1}, // close front rounded vowel //new BandPassFilter(3200, 3300, synth.SampleRate, HighResonance, HighResonance) {Volume = LEVEL_F4}, //new BandPassFilter(2100, 2200, synth.SampleRate, HighResonance, HighResonance) {Volume = LEVEL_F3}, //new BandPassFilter(1800, 1900, synth.SampleRate, HighResonance, HighResonance) {Volume = LEVEL_F2}, //new BandPassFilter(200, 300, synth.SampleRate, LowResonance, LowResonance) {Volume = LEVEL_F1}, // near-open front unrounded vowel //new BandPassFilter(2900, 3000, synth.SampleRate, HighResonance, HighResonance) {Volume = LEVEL_F3}, //new BandPassFilter(1700, 1800, synth.SampleRate, HighResonance, HighResonance) {Volume = LEVEL_F2}, //new BandPassFilter(800, 900, synth.SampleRate, HighResonance, HighResonance) {Volume = LEVEL_F1}, // postalveolar approximant //new BandPassFilter(3000, 3000, synth.SampleRate, HighResonance, HighResonance) {Volume = LEVEL_F3}, //new BandPassFilter(1400, 1400, synth.SampleRate, HighResonance, HighResonance) {Volume = LEVEL_F2}, //new BandPassFilter(350, 350, synth.SampleRate, HighResonance, HighResonance) {Volume = LEVEL_F1}, // close-mid front unrounded vowel //new BandPassFilter(3600, 3700, synth.SampleRate, HighResonance, HighResonance) {Volume = LEVEL_F4}, //new BandPassFilter(2500, 2600, synth.SampleRate, HighResonance, HighResonance) {Volume = LEVEL_F3}, //new BandPassFilter(2200, 2300, synth.SampleRate, HighResonance, HighResonance) {Volume = LEVEL_F2}, //new BandPassFilter(450, 500, synth.SampleRate, HighResonance, HighResonance) {Volume = LEVEL_F1}, // close front unrounded vowel //new BandPassFilter(3000, 3000, synth.SampleRate, HighResonance, HighResonance) {Volume = LEVEL_F3}, //new BandPassFilter(2250, 2250, synth.SampleRate, HighResonance, HighResonance) {Volume = LEVEL_F2}, //new BandPassFilter(250, 250, synth.SampleRate, HighResonance, HighResonance) {Volume = LEVEL_F1}, // voiceless palatal-alveolar sibilant fricative //new BandPassFilter(200, 1200, synth.SampleRate, 1.0f, 1.0f) { Volume = 0.075f }, //new BandPassFilter(1900, 5500, synth.SampleRate, .35f, .35f) { Volume = 0.01f }, //new BandPassFilter(2100, 2500, synth.SampleRate, .2f, .2f) { Volume = 0.1f }, //new BandPassFilter(3700, 4100, synth.SampleRate, .2f, .2f) { Volume = 0.050f }, //new BandPassFilter(4600, 5400, synth.SampleRate, .18f, .18f) { Volume = 0.060f }, //new BandPassFilter(6700, 7200, synth.SampleRate, .1f, .1f) { Volume = 0.0060f }, }; lowPass = new ButterworthFilter(500, synth.SampleRate, PassFilterType.LowPass, .1f); highPass = new ButterworthFilter(6000, synth.SampleRate, PassFilterType.HighPass, .4f); numBands = bands.Length; }
public ArticulatorLayer(Synthesizer synth) : base(synth) { bpf1 = new BandPassFilter(0, 0, synth.SampleRate, RES_F1, RES_F1); bpf2 = new BandPassFilter(0, 0, synth.SampleRate, RES_F2, RES_F2); bpf3 = new BandPassFilter(0, 0, synth.SampleRate, RES_F3, RES_F3); bpf4 = new BandPassFilter(0, 0, synth.SampleRate, RES_F4, RES_F4); bpf5 = new BandPassFilter(0, 0, synth.SampleRate, RES_F5, RES_F5); lpNoise = new ButterworthFilter(FREQ_LPNOISE, synth.SampleRate, PassFilterType.LowPass, RES_LPNOISE); hpOverlay = new ButterworthFilter(FREQ_HPO, synth.SampleRate, PassFilterType.HighPass, RES_HPO); lpOverlay = new ButterworthFilter(1, synth.SampleRate, PassFilterType.LowPass, RES_LPO); UpdateLowerBandwidths(); UpdateLowerFormants(); UpdateHigherFormants(); }
static void RunTest(int numberOfVectors, int lengthOfVectors) { // Assemble the jagged array of vectors to filter. double[][] vectorsToFilter = new double[numberOfVectors][]; for (int vectorNumber = 0; vectorNumber < vectorsToFilter.Length; vectorNumber++) { vectorsToFilter[vectorNumber] = new double[lengthOfVectors]; double[] vector = vectorsToFilter[vectorNumber]; for (int vectorIndex = 0; vectorIndex < vector.Length; vectorIndex++) { vector[vectorIndex] = vectorIndex; } } // Run a single threaded test. Stopwatch sw = new Stopwatch(); sw.Start(); double[][] filteredVectors = ButterworthFilter.FourthOrder(250, vectorsToFilter); sw.Stop(); Debug.WriteLine(string.Format("Filter (vectors={0}, length={1}) Time: {2}", numberOfVectors, lengthOfVectors, sw.ElapsedMilliseconds)); System.GC.Collect(); Thread.Sleep(5000); // Run a parallel test. sw.Reset(); sw.Start(); double[][] filteredVectors2 = ButterworthFilter.ParallelFourthOrder(250, vectorsToFilter); sw.Stop(); Debug.WriteLine(string.Format("Parallel Filter (vectors={0}, length={1}) Time: {2}", numberOfVectors, lengthOfVectors, sw.ElapsedMilliseconds)); // Now validate that each result is the same between the 2 different filtering method calls. for (int vectorNumber = 0; vectorNumber < filteredVectors.Length; vectorNumber++) { double[] vector = filteredVectors[vectorNumber]; double[] vector2 = filteredVectors2[vectorNumber]; for (int vectorIndex = 0; vectorIndex < vector.Length; vectorIndex++) { Debug.Assert(vector[vectorIndex] == vector2[vectorIndex], "Mismatch"); } } System.GC.Collect(); Thread.Sleep(5000); // Run a parallel test. sw.Reset(); sw.Start(); double[][] filteredVectors3 = ButterworthFilter.ParallelFourthOrder(250, vectorsToFilter); sw.Stop(); Debug.WriteLine(string.Format("Parallel Filter (vectors={0}, length={1}) Time: {2}", numberOfVectors, lengthOfVectors, sw.ElapsedMilliseconds)); System.GC.Collect(); Thread.Sleep(5000); // Run a single threaded test. sw.Reset(); sw.Start(); double[][] filteredVectors4 = ButterworthFilter.FourthOrder(250, vectorsToFilter); sw.Stop(); Debug.WriteLine(string.Format("Filter (vectors={0}, length={1}) Time: {2}", numberOfVectors, lengthOfVectors, sw.ElapsedMilliseconds)); // Now validate that each result is the same between the 2 different filtering method calls. for (int vectorNumber = 0; vectorNumber < filteredVectors3.Length; vectorNumber++) { double[] vector = filteredVectors3[vectorNumber]; double[] vector2 = filteredVectors4[vectorNumber]; for (int vectorIndex = 0; vectorIndex < vector.Length; vectorIndex++) { Debug.Assert(vector[vectorIndex] == vector2[vectorIndex], "Mismatch"); } } }