How to export the generated waveform as an audio file? #34
Unanswered
JossPabloPC
asked this question in
Q&A
Replies: 2 comments 7 replies
-
|
This is an example code to export the waveform as a WAV file. Note that you need NAudio to compile this code. meltysynth/Workspace/Examples.cs Line 153 in 092cf25 |
Beta Was this translation helpful? Give feedback.
7 replies
-
|
If you are using Unity, there is a SavWav gist (one of many forks) that can be used to add the wav header from an AudioClip and avoid adding all of NAudio. sequencer.RenderInterleaved(buffer);
var clip = AudioClip.Create(trackName, lenSamples, channels, sampleRate, false);
clip.SetData(buffer, 0);
SavWav.Save(wavPath, clip); |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Once I have my sequencer rendered, how can I tranform it to a Wav file ? I am using this example:
// Create the synthesizer.
var sampleRate = 44100;
var synthesizer = new Synthesizer("TimGM6mb.sf2", sampleRate);
// Read the MIDI file.
var midiFile = new MidiFile("flourish.mid");
var sequencer = new MidiFileSequencer(synthesizer);
sequencer.Play(midiFile, false);
// The output buffer.
var left = new float[(int)(sampleRate * midiFile.Length.TotalSeconds)];
var right = new float[(int)(sampleRate * midiFile.Length.TotalSeconds)];
// Render the waveform.
sequencer.Render(left, right);
Beta Was this translation helpful? Give feedback.
All reactions