Exemple #1
0
        public void CalculateTubeCoefficients(IntonationModel model, ThroatModelParameters parameters)
        {
            /*  CALCULATE COEFFICIENTS FOR THE Oropharynx  */
            for (int i = 0; i < OropharynxCoefficients.Count(); i++)
            {
                var lastSegment = i + 1 == OropharynxCoefficients.Count();
                var radA2       = Square(model.RadiusSegments.ElementAt(i));
                var radB2       = lastSegment ? Square(parameters.AperatureScalingRadius) : Square(model.RadiusSegments.ElementAt(i + 1));
                OropharynxCoefficients[i] = (radA2 - radB2) / (radA2 + radB2);
            }

            /*  CALCULATE ALPHA COEFFICIENTS FOR 3-WAY JUNCTION  */
            var sides = Square(model.RadiusSegments.ElementAt(3));
            var velum = Square(model.Velum);
            var sum   = 2.0 / (sides + sides + velum);

            Alpha.Left  = sum * sides;
            Alpha.Right = sum * sides;
            Alpha.Upper = sum * velum;

            /*  AND 1ST NASAL PASSAGE COEFFICIENT  */
            var nose = Square(parameters.NoseRadius.ElementAt(1));

            NasalCoefficients[0] = (velum - nose) / (velum + nose);
        }
Exemple #2
0
        private void InitializeThroat(ThroatModelParameters parameters, double sampleRate)
        {
            ta0 = (parameters.ThroatFreqCutoff * 2.0) / sampleRate;
            tb1 = 1.0 - ta0;

            throatGain = WaveHelper.CalculateAmplitude(parameters.ThroatVolume);
        }
Exemple #3
0
 public VocalTract(ThroatModelParameters parameters, double nyquist, double sampleRate)
 {
     Oropharynx             = Enumerable.Range(0, 10).Select(x => new TubeSection()).ToArray();
     Nasal                  = Enumerable.Range(0, 6).Select(x => new TubeSection()).ToArray();
     OropharynxCoefficients = new double[8];
     NasalCoefficients      = new double[6];
     FricationTap           = new double[8];
     Alpha                  = new Junction();
     InitializeMouthCoefficients((nyquist - parameters.MouthAperatureCoefficient) / nyquist);
     InitializeNasalFilterCoefficients((nyquist - parameters.NoseAperatureCoefficient) / nyquist);
     InitializeNasalCavity(parameters);
     InitializeThroat(parameters, sampleRate);
 }
Exemple #4
0
        public WaveTable(double sampleRate, ThroatModelParameters parameters)
        {
            Wavetable = new double[TABLE_LENGTH];

            /*  CALCULATE WAVE TABLE PARAMETERS  */
            _risePortion    = (int)Math.Round(TABLE_LENGTH * (parameters.GlotPulseRiseTime / parameters.SectionLength));
            _fallPortion    = (int)Math.Round(TABLE_LENGTH * ((parameters.GlotPulseRiseTime + parameters.GlotPulseFallTimeMax) / parameters.SectionLength));
            tnLength        = _fallPortion - _risePortion;
            tnDelta         = Math.Round(TABLE_LENGTH * ((parameters.GlotPulseFallTimeMax - parameters.GlotPulseFallTimeMin) / parameters.SectionLength));
            _basicIncrement = (double)TABLE_LENGTH / sampleRate;
            CurrentPosition = 0;

            int i, j;

            if (parameters.GlotSrcType == GlotSrcType.Pulse)
            {
                /*  CALCULATE RISE PORTION OF WAVE TABLE  */
                for (i = 0; i < _risePortion; i++)
                {
                    double x  = (double)i / (double)_risePortion;
                    double x2 = x * x;
                    double x3 = x2 * x;
                    Wavetable[i] = (3.0 * x2) - (2.0 * x3);
                }

                /*  CALCULATE FALL PORTION OF WAVE TABLE  */
                for (i = _risePortion, j = 0; i < _fallPortion; i++, j++)
                {
                    double x = (double)j / tnLength;
                    Wavetable[i] = 1.0 - (x * x);
                }

                /*  SET CLOSED PORTION OF WAVE TABLE  */
                for (i = _fallPortion; i < TABLE_LENGTH; i++)
                {
                    Wavetable[i] = 0.0;
                }
            }
            else
            {
                /*  SINE WAVE  */
                for (i = 0; i < TABLE_LENGTH; i++)
                {
                    Wavetable[i] = Math.Sin(((double)i / (double)TABLE_LENGTH) * 2.0 * Math.PI);
                }
            }
        }
Exemple #5
0
        private void InitializeNasalCavity(ThroatModelParameters parameters)
        {
            double radA2, radB2;

            /*  CALCULATE COEFFICIENTS FOR INTERNAL FIXED SECTIONS OF NASAL CAVITY  */
            for (int i = 0, j = 1; i < 4; i++, j++)
            {
                radA2 = Square(parameters.NoseRadius.ElementAt(i));
                radB2 = Square(parameters.NoseRadius.ElementAt(i + 1));
                NasalCoefficients[j] = (radA2 - radB2) / (radA2 + radB2);
            }

            /*  CALCULATE THE FIXED COEFFICIENT FOR THE NOSE APERTURE  */
            radA2 = Square(parameters.NoseRadius.ElementAt(4));
            radB2 = parameters.AperatureScalingRadius;
            NasalCoefficients[5] = (radA2 - radB2) / (radA2 + radB2);
        }