static void Main(string[] args) { Console.Write("Enter path to MIDI: "); string inputMidi = Console.ReadLine(); Console.Write("Enter WAV output path: "); string outputWav = Console.ReadLine(); Console.WriteLine("Starting..."); using (var stream = File.OpenRead(inputMidi)) { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); // Parse the provided MIDI file. var interpretation = new MidiInterpretation(stream, new DefaultNoteSegmentProvider()); // Create a new synthesizer with default providers. var synth = new BasicSynth(interpretation, new DefaultAdsrEnvelopeProvider(AdsrParameters.Short), new DefaultBalanceProvider()); // Listen for progress updates synth.ProgressChanged += Synth_ProgressChanged; // Generate the WAV file MemoryStream result = synth.GenerateWAV(); stopwatch.Stop(); Console.WriteLine("Rendered in: " + stopwatch.Elapsed); // Write WAV file to disk using (var outputStream = File.OpenWrite(outputWav)) { result.CopyTo(outputStream); } result.Dispose(); } Console.WriteLine("Done"); Console.ReadLine(); }
public MidiSynth(MidiInterpretation interpretation) { Interpretation = interpretation; }
public BasicSynth(MidiInterpretation interpretation, IAdsrEnvelopeProvider adsrEnvelopeProvider = null, IBalanceProvider balanceProvider = null) : base(interpretation) { AdsrEnvelopeProvider = adsrEnvelopeProvider ?? new DefaultAdsrEnvelopeProvider(AdsrParameters.Short); BalanceProvider = balanceProvider ?? new DefaultBalanceProvider(); }