I am creating a simple modeless dialog box that deals with the recording and playback of audio and has UI controls for record and playback. In the dialog box's procedure I am trying to manage the SFML audio functions but when I try to access the buffer contents after recording, they appear to be empty. The saved .wav file is consistently only 44kb.
Here's the basics of the audio handling within the procedure. I'd appreciate a steer as to what I'm missing regarding accessing the buffer's contents.
INT_PTR CALLBACK VJWindowProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam)
{
//declare these outside the switch statement handling button messages so they're available to the buttons
sf::Sound sound;
sf::SoundBufferRecorder recorder;
switch (Message)
{
case WM_COMMAND:
switch (LOWORD(wParam))
{
case IDC_STOP: //this is the dialog box's End Recording button
recorder.stop();
//Now the capture has ended we can get the buffer. Test saving the file and also playing it.
const sf::SoundBuffer& buffer = recorder.getBuffer();
buffer.saveToFile("TESTRECORDING.wav");
sound.setBuffer(buffer);
sound.play();
break;
case IDC_RECORD: //this is the dialog box's Start Recording button
recorder.start();
break;
}
}
}