Hallo!
While I was working on the implementation of the capture device selection I noticed something that's a little weird. If you try to save an empty
sf::SoundBuffer you'll get a confusion error message.
When you run this code:
#include <SFML\Audio.cpp>
int main()
{
sf::SoundBuffer buffer;
buffer.saveToFile("example.wav");
}
You will get this console output:
Failed to create sound file "example.wav" (Format not recogized)I tryed different formats (.wav, .ogg, ...) but they all failed. If there are sampled in the buffer the program runs as expected.
I fired up my debugger and saw that the error message is caused by the failure of
sf_open() in
sf::SoundFile::openWrite(). I checked the
format that is passed to sf_open (fileInfos struct) and it matches the one for signed 16-bit WAV. I also noticed that
channels and
sampleRate are set to 0. So what I'm thinking is that sf_open fails with the error message "Format not recognized" eventhough the format is correct, but when the channel count and the sample rate is still at zero.
Wouldn't it be a good idea to check if the buffer contains samples before saving it? That way there could be a more discribtiv error message (i.e. "Nothing to record").