Starts a new recording session from a sound contained inside a memory buffer.
The sound contained inside the memory buffer can be in any of the sound formats supported by the StartFromFile method.
Sound files in various RAW formats can be loaded using the StartFromMemoryRaw method.
During the recording sessions the container application is notified through the CallbackForRecordersEvents delegate which is invoked with the nEvent parameter set to EV_REC_START at the beginning and to EV_REC_STOP at the end. The current percentage of advancement is notified through the EV_REC_PERC event.
For details about recording from files see the How to record from files, memory or clipboard section.
Below you can find a couple of samples that demonstrate how to record from a sound stored in memory in Visual Basic.NET and Visual C# : in these samples the file is taken from a file and its contents are stored inside a memory buffer.
' declare the memory buffer (cannot be a local variable)
Dim m_byteBuffer() As Byte
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
Dim openFileDialog1 As New OpenFileDialog
If openFileDialog1.ShowDialog() <> DialogResult.OK Then
' put the song file into a stream
Dim streamFile As FileStream
streamFile = New FileStream(openFileDialog1.FileName, FileMode.Open)
Dim binReader As BinaryReader
binReader = New BinaryReader(streamFile)
' reallocate the memory buffer space and store the song
binReader.Read(m_byteBuffer, 0, streamFile.Length)
' record sound from memory buffer and resample its contents using the first available format (index '0' is usually 11025, mono, 8 bits)
If AudioSoundRecorder1.RecorderStartFromMemory(0, "c:\output.wav", m_byteBuffer, streamFile.Length) = AudioDjStudio.enumErrorCodes.ERR_NOERROR Then
' do domething
// declare the memory buffer (cannot be a local variable)
byte m_byteBuffer = null;
private void buttonLoad1_Click(object sender, System.EventArgs e)
OpenFileDialog openFileDialog1 = new OpenFileDialog();
if (openFileDialog1.ShowDialog() != DialogResult.OK)
// put the song file into a stream
FileStream streamFile = new FileStream (openFileDialog1.FileName, FileMode.Open);
BinaryReader binReader = new BinaryReader (streamFile);
// allocate the memory buffer space and store the song
m_byteBuffer = new byte[streamFile.Length];
binReader.Read (m_byteBuffer, 0, (int) streamFile.Length);
// record sound from memory buffer and resample its contents using the first available format (index '0' is usually 11025, mono, 8 bits)
if (AudioSoundRecorder1.RecorderStartFromMemory(0, "c:\output.wav", m_byteBuffer, (Int32) streamFile.Length) == enumErrorCodes.ERR_NOERROR)
// do something