예제 #1
0
        public PitchShifter(AutoTuneSettings settings)
        {
            this.settings = settings;
            numshifts = 5000;
            shifts = new Queue<PitchShift>(numshifts);

            currPitch = 0;
            attack = 0;
            numElapsed = 0;
            vibRate = 4.0;
            vibDepth = 0.00;
            g_time = 0.0;
        }
예제 #2
0
        public AutoTuneWaveProvider(IWaveProvider source, AutoTuneSettings autoTuneSettings)
        {
            this.autoTuneSettings = autoTuneSettings;
            if (source.WaveFormat.SampleRate != 44100)
                throw new ArgumentException("AutoTune only works at 44.1kHz");
            if (source.WaveFormat.Encoding != WaveFormatEncoding.IeeeFloat)
                throw new ArgumentException("AutoTune only works on IEEE floating point audio data");
            if (source.WaveFormat.Channels != 1)
                throw new ArgumentException("AutoTune only works on mono input sources");

            this.source = source;
            this.pitchDetector = new AutoCorrelator(source.WaveFormat.SampleRate);
            this.pitchShifter = new SmbPitchShifter(Settings);
            this.waveBuffer = new WaveBuffer(8192);
        }
 public static void ApplyAutoTune(string fileToProcess, string tempFile, AutoTuneSettings autotuneSettings)
 {
     using (var reader = new WaveFileReader(fileToProcess))
     {
         IWaveProvider stream32 = new Wave16ToFloatProvider(reader);
         IWaveProvider streamEffect = new AutoTuneWaveProvider(stream32, autotuneSettings);
         IWaveProvider stream16 = new WaveFloatTo16Provider(streamEffect);
         using (var 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)
             var buffer = new byte[8192];
             int bytesRead;
             do
             {
                 bytesRead = stream16.Read(buffer, 0, buffer.Length);
                 converted.Write(buffer, 0, bytesRead);
             } while (bytesRead != 0 && converted.Length < reader.Length);
         }
     }
 }
예제 #4
0
 public SmbPitchShifter(AutoTuneSettings settings, float sampleRate)
     : base(settings, sampleRate)
 {
 }
예제 #5
0
 public SmbPitchShifter(AutoTuneSettings settings) : base(settings) { }
예제 #6
0
 public VoiceRecorderState(string recordingFileName, string effectedFileName)
 {
     this.RecordingFileName = recordingFileName;
     this.EffectedFileName = effectedFileName;
     this.autoTuneSettings = new AutoTuneSettings();
 }
예제 #7
0
 public SmbPitchShifter(AutoTuneSettings settings, float sampleRate) : base(settings, sampleRate)
 {
 }