Exemplo n.º 1
0
        public void DisposeTest()
        {
            var r = new SoxResampler(1.0, 1.0, 1);

            r.Dispose();
            r.Dispose(); // call a second time to check for repeated calls working
        }
Exemplo n.º 2
0
        private void SetupResampler()
        {
            if (soxr != null)
            {
                soxr.Dispose(); // delete previous resampler instance
            }

            Soxr.QualityRecipe qr = QualityRecipe.SOXR_HQ;
            Soxr.QualityFlags  qf = QualityFlags.SOXR_ROLLOFF_SMALL;

            switch (quality)
            {
            case ResamplingQuality.VeryLow:
                qr = QualityRecipe.SOXR_QQ; break;

            case ResamplingQuality.Low:
                qr = QualityRecipe.SOXR_LQ; break;

            case ResamplingQuality.Medium:
                qr = QualityRecipe.SOXR_MQ; break;

            case ResamplingQuality.High:
                qr = QualityRecipe.SOXR_HQ; break;

            case ResamplingQuality.VeryHigh:
                qr = QualityRecipe.SOXR_VHQ; break;

            case ResamplingQuality.VariableRate:
                qr = QualityRecipe.SOXR_HQ; qf = QualityFlags.SOXR_VR; break;
            }

            double inputRate  = sourceStream.Properties.SampleRate;
            double outputRate = properties.SampleRate;

            if (qf == QualityFlags.SOXR_VR)
            {
                // set max variable rate
                inputRate  = 10.0;
                outputRate = 1.0;
            }

            soxr = new SoxResampler(inputRate, outputRate, properties.Channels, qr, qf);
        }