Exemple #1
0
 protected void drawPlots(double[] a1, double[] a2, double[] a3, double[] a4)
 {
     if (sPlotDir == null)
     {
         return;
     }
     ConstructionUtil.plotArray(a1, sPlotDir + "\\data1.js", -1, true);
     ConstructionUtil.plotArray(a2, sPlotDir + "\\data3.js", -1, false);
     ConstructionUtil.plotArray(a3, sPlotDir + "\\data2.js", -1, true);
     ConstructionUtil.plotArray(a4, sPlotDir + "\\data4.js", -1, false);
 }
Exemple #2
0
            public WaveAudio doModify(WaveAudio src, int bufsize)
            {
                WaveAudio wout = new WaveAudio(src.getSampleRate(), 1);

                wout.LengthInSamples = src.LengthInSamples;

                //reuse the buffers.
                double[] ffreqmaghalfout = new double[bufsize / 2], ffreqanghalfout = new double[bufsize / 2];
                double[] ffreqmaghalfin  = new double[bufsize / 2], ffreqanghalfin = new double[bufsize / 2];
                double[] fbuffertime     = new double[bufsize];

                for (int index = 0; index < src.LengthInSamples - bufsize; index += bufsize / overlap)
                {
                    //copy into buffer.
                    Array.Copy(src.data[0], index, fbuffertime, 0, bufsize);
                    double[] ffreqreal, ffreqimag;
                    Fourier.RawSamplesToFrequency(fbuffertime, out ffreqreal, out ffreqimag);
                    //we only care about the first half of these results.
                    for (int i = 0; i < bufsize / 2; i++)
                    {
                        ffreqmaghalfin[i] = Math.Sqrt(ffreqreal[i] * ffreqreal[i] + ffreqimag[i] * ffreqimag[i]);
                        ffreqanghalfin[i] = Math.Atan2(ffreqimag[i], ffreqreal[i]);
                    }
                    this.modifyAngular(ffreqmaghalfin, ffreqanghalfin, ffreqmaghalfout, ffreqanghalfout);
                    for (int i = 0; i < ffreqreal.Length / 2; i++)
                    {
                        ffreqreal[i] = ffreqmaghalfout[i] * Math.Sin(ffreqanghalfout[i]);
                        ffreqimag[i] = ffreqmaghalfout[i] * Math.Cos(ffreqanghalfout[i]);
                    }
                    for (int i = ffreqreal.Length / 2; i < ffreqreal.Length; i++)
                    {
                        ffreqreal[i] = ffreqimag[i] = 0;
                    }
                    double[] fbufout;
                    Fourier.RawFrequencyToSamples(out fbufout, ffreqreal, ffreqimag);
                    WaveAudio ww = new WaveAudio(44100, 1);
                    ww.data[0] = fbufout;
                    //Array.Copy(fbufout, 0, wout.data[0], partnum*bufsize, bufsize);
                    ConstructionUtil.placeAudioRamp(wout, ww, index, (bufsize / overlapRamp));
                }
                return(wout);
            }