superpoweredSDK / Low-Latency-Android-iOS-Linux-Windows-tvOS-macOS-Interactive-Audio-Platform

🇸Superpowered Audio, Networking and Cryptographics SDKs. High performance and cross platform on Android, iOS, macOS, tvOS, Linux, Windows and modern web browsers.
https://superpowered.com
1.34k stars 285 forks source link

Recorder doesn't close temp file, fails to write to wav #169

Closed EverlastEngineering closed 8 years ago

EverlastEngineering commented 8 years ago

I'm using the recorder to dump the mic to disk in my Android project. Here's my routine:

I init the recorder : audioRecorder = new SuperpoweredRecorder(temppath, sampleRate); // temppath ends with .tmp

Inside the main process() loop I dump the input to a micBuffer (which I use later) and process it by the recorder

SuperpoweredShortIntToFloat(output,micBuffer,numberOfSamples);
audioRecorder->process(micBuffer,NULL,numberOfSamples);

Then when I'm ready, I start my recording: audioRecorder->start(recordPath); // recordpath is the same as temppath, but ends in .wav

When I'm done, I stop it: audioRecorder->stop();

I'm left with two files: the .tmp which has a size, and the .wav which is always 0 bytes. The .tmp file can be opened at played as if it was a .wav in Audacity.

Have I missed a step, or is this a bug?

As a footnote, I do the audioRecorder->process() all the time, but I tried skipping that if I hadn't issued audioRecorder->start(), but it made no difference.

superpoweredSDK commented 8 years ago

The recorder does disk operations on a separate thread. When you call stop() it signals that thread to close the temp file and rename it to the final location. Perhaps you have a .wav from a previous run which can not be overwritten. Check your permissions and paths.

romanbsd commented 7 years ago

There's a undocumented feature" The SuperpoweredRecorder adds ".wav" suffix to the recordPath, so your file ends up being "somefile.wav.wav".