/// <summary> /// Initializes a new instance of the <see cref="SoundTouchWaveProvider"/> class. /// </summary> /// <param name="sourceProvider">The source provider.</param> /// <param name="processor">The processor for changing tempo, pitch and rate. When not specified, a new instance of <see cref="SoundTouchProcessor"/> is used.</param> public SoundTouchWaveProvider(IWaveProvider sourceProvider, SoundTouchProcessor?processor = null) { _sourceProvider = sourceProvider ?? throw new ArgumentNullException(nameof(sourceProvider)); if (sourceProvider.WaveFormat.Encoding != WaveFormatEncoding.IeeeFloat) { throw new ArgumentException(Strings.Argument_WaveFormatIeeeFloat, nameof(sourceProvider)); } if (sourceProvider.WaveFormat.BitsPerSample != 32) { throw new ArgumentException(Strings.Argument_WaveFormat32BitsPerSample, nameof(sourceProvider)); } int sampleRate = sourceProvider.WaveFormat.SampleRate; int channels = sourceProvider.WaveFormat.Channels; _processor = processor ?? new SoundTouchProcessor(); _processor.SampleRate = sampleRate; _processor.Channels = channels; if (processor is null) { _processor.Tempo = 1.0; _processor.Pitch = 1.0; _processor.Rate = 1.0; } }
public static int Main(string[] args) { Console.Error.WriteLine(HELLO_TEXT, SoundTouchProcessor.VersionString); try { var parameters = new RunParameters(args); var processor = new SoundTouchProcessor(); OpenFiles(out var inputFile, out var outputFile, parameters); using (inputFile) using (outputFile) { if (parameters.DetectBpm) { DetectBpm(inputFile, parameters); } // Setup the 'SoundTouch' object for processing the sound. Setup(processor, inputFile, parameters); var stopwatch = Stopwatch.StartNew(); // Process the sound. Process(processor, inputFile, outputFile); Debug.WriteLine("Duration: {0}", stopwatch.Elapsed); Console.Error.WriteLine("Done!"); } } catch (Exception exception) { Console.WriteLine(exception.Message); return(-1); } return(0); }