예제 #1
0
 public static void ApplyAutoTune(string fileToProcess, string tempFile, AutoTuneSettings autotuneSettings)
 {
     using (WaveFileReader reader = new WaveFileReader(fileToProcess))
     {
         IWaveProvider stream32 = new Wave16toIeeeProvider(reader);
         IWaveProvider streamEffect = new AutoTuneWaveProvider(stream32, autotuneSettings);
         IWaveProvider stream16 = new WaveIeeeTo16Provider(streamEffect);
         using (WaveFileWriter converted = new WaveFileWriter(tempFile, stream16.WaveFormat))
         {
             // buffer length needs to be a power of 2 for FFT to work nicely
             // however, make the buffer too long and pitches aren't detected fast enough
             // successful buffer sizes: 8192, 4096, 2048, 1024
             // (some pitch detection algorithms need at least 2048)
             byte[] buffer = new byte[8192]; 
             int bytesRead;
             do
             {
                 bytesRead = stream16.Read(buffer, 0, buffer.Length);
                 converted.WriteData(buffer, 0, bytesRead);
             } while (bytesRead != 0 && converted.Length < reader.Length);
         }
     }
 }
예제 #2
0
        public static void Main(string[] args)
        {
            Oscillator oscillator = new Oscillator();

            oscillator.SetOscillators(false, Oscillator.OscillatorIndex.Secondary);

            Mixer.Instance.PlayWave(oscillator.PreparePlay(500.0));
            Mixer.Instance.StopWave(oscillator.PrepareStop());

            Oscillator oscillator2 = new Oscillator();

            oscillator.SetOscillators(true, Oscillator.OscillatorIndex.Secondary);

            Mixer.Instance.PlayWave(oscillator2.PreparePlay(700.0));
            Mixer.Instance.StopWave(oscillator2.PrepareStop());

            Console.WriteLine("Press Any Key To Iterate Frequencies");


            List <double> frequencies = new List <double>
            {
                2000.0, 500.0, 550.0, 600.0, 650.0, 700.0, 750.0, 800.0, 850.0, 900.0, 950.0, 1000.0, 1050.0, 1100.0
            };
            int             index  = 0;
            bool            active = true;
            PercussionModel model  = new PercussionModel();

            WaveFileReader input = new WaveFileReader(Host_Alpha.Properties.Resources.Ab2closedhh);

            Wave16toIeeeProvider ieeeprovider = new Wave16toIeeeProvider(input.ToSampleProvider().ToWaveProvider16());

            while (true)
            {
                if (index == 0)
                {
                    Mixer.Instance.PlaySample(ieeeprovider.ToSampleProvider());
                    input.Position = 0;

                    //Mixer.Instance.PlaySample(PercussionManager.Instance.
                    //SupplyDoublePad(PercussionManager.DoublePadType.PadOne, PercussionManager.DoublePadVelocityType.Low));
                    index++;
                }
                if (index == 1)
                {
                    //Mixer.Instance.PlaySample(PercussionManager.Instance.
                    //SupplyDoublePad(PercussionManager.DoublePadType.PadOne, PercussionManager.DoublePadVelocityType.Middle));
                    //index++;
                    index++;
                }
                if (index == 2)
                {
                    //Mixer.Instance.PlaySample(PercussionManager.Instance.
                    //SupplyDoublePad(PercussionManager.DoublePadType.PadOne, PercussionManager.DoublePadVelocityType.High));
                    //index = 0;
                    index++;
                }


                //Mixer.Instance.PlaySample(PercussionManager.Instance.SupplyShaker(PercussionManager.ShakerType.Forward));
                //Mixer.Instance.StopWave(oscillator.PrepareStop());
                //Mixer.Instance.StopWave(oscillator2.PrepareStop());

                //Mixer.Instance.PlayWave(oscillator.PreparePlay(frequencies[index]));
                //if (index + 1 < frequencies.ToArray().Length)
                //    Mixer.Instance.PlayWave(oscillator2.PreparePlay(frequencies[index + 1]));
                //index++;
                //if (index == frequencies.Count)
                //{
                //    index = 0;
                //    frequencies.Reverse();
                //}
                //active = !active;
                //oscillator.SetOscillators(active, Oscillator.OscillatorIndex.LFO);
                Console.WriteLine("# of Inputs: " + Mixer.Instance.GetInputs());
                Console.ReadLine();
            }
        }