StartFromMemory method |
|
Remarks
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.
A successful call to this method will fire the RecordingStarted event followed by a number of RecordingPerc events and finally by the RecordingStopped event.
For details about recording from files see the How to record from files, memory or clipboard section.
Syntax
Return value
Samples
Below you can find a couple of samples that demonstrate how to record a sound store inside a memory buffer in Visual Basic 6 and Visual C++ 6: the sound has been taken from a .RES resource file using the "identifier" variable.
Visual Basic 6
' the memory buffer must be declared as global Dim bytSound() As Byte
Private Sub Command1_Click() Dim length As Long bytSound = LoadResData(identifier, 10) length = UBound(bytSound)
' record sound from memory buffer and resample its contents using the first available format (index '0' is usually 11025, mono, 8 bits) ActiveSoundRecorder1.RecorderStartFromMemory 0, "c:\output.wav", VarPtr(bytSound(0)), length End Sub
Visual C++ 6 with MFC
void CMyDialog::OnButton1() { HINSTANCE hInst = AfxGetResourceHandle(); HRSRC hrsrc = ::FindResource(hInst, MAKEINTRESOURCE (identifier), RT_RCDATA); if (!hrsrc) return;
HGLOBAL hg = LoadResource(hInst, hrsrc); if (!hg) return;
BYTE *pRes = (BYTE*) LockResource(hg); ASSERT(pRes); int iSize = ::SizeofResource(hInst, hrsrc);
VARIANT va; VariantInit (&va); va.vt = VT_BYREF | VT_UI1; va.pbVal = (BYTE *) pRes;
// record sound from memory buffer and resample its contents using the first available format (index '0' is usually 11025, mono, 8 bits) m_ctrlActiveRecorder.RecorderStartFromMemory (0, "c:\\output.wav", va, iSize); }
|