BB FlashBack SDK: FBRecorder

InitCustomSoundTrack

Description

Initialises the name, sample size, stereo/mono and frequency for the sound track that will be added by calls to AddSoundBlockByPointer during recording.

This method should only be called before recording starts.

To enable adding a custom sound track, the UseCustomSoundTrack property should be set to true before recording starts.

Syntax

[C#/C++]
Public Bool InitCustomSoundTrack (BSTR trackname, long samplesize, bool stereo, long frequency);

[VB.NET]
public Function InitCustomSoundTrack (ByVal trackname As String, ByVal samplesize As Integer, ByVal stereo As Boolean, ByVal frequency As Integer) as Boolean

Parameters

trackname (in): the name of the new track

samplesize (in): should have value 8 or 16, indicating the number of bits in each sample

stereo (in): True or False to indicate whether the track is stereo or mono

frequency (in): frequency of the samples, in KHz. e.g. 22050, 44100

Remarks

Samples are added via the AddSoundBlockByPointer method. The samplesize and stereo parameters affect the number of bytes in each sample.

8 bit mono = 1 byte per sample
8 bit stereo = 2 bytes per sample
16 bit mono = 2 bytes per sample
16 bit stereo = 4 bytes per sample

Sample Code

Setup the custom sound track before recording starts.

recorder.InitCustomSoundTrack(L"testtrack", sample_size, false, frequency); recorder.UseCustomSoundTrack = true;

Then Start recording.

When recording is in progress, sound is added with AddSoundBlockByPointer:


short *sbuffer = (short*)malloc(sample_size/8 * samples);

// generate example sound data - a sine wave
for(int i=0; i<samples; i++)
{
 sbuffer[i] = (int)(sin((double)i) * 10000);
}

// add it to the recording
recorder.AddSoundBlockByPointer((unsigned char*)sbuffer, samples);

free(sbuffer);

Return Values

True if successful, False if not.

See Also

FBRecorder::AddSoundBlockByPointer  FBRecorder::UseCustomSoundTrack