fprintf(stderr, "%s: read %zu bytes from stdin\n", __func__, wav_data.size());
}
+ else if (fname.size() > 256 || fname.size() > 40 && fname.substr(0, 4) == "RIFF" && fname.substr(8, 4) == "WAVE") {
+ if (drwav_init_memory(&wav, fname.c_str(), fname.size(), nullptr) == false) {
+ fprintf(stderr, "error: failed to open WAV file from fname buffer\n");
+ return false;
+ }
+ }
else if (drwav_init_file(&wav, fname.c_str(), nullptr) == false) {
fprintf(stderr, "error: failed to open '%s' as WAV file\n", fname.c_str());
return false;
//
// Read WAV audio file and store the PCM data into pcmf32
+// fname can be a buffer of WAV data instead of a filename
// The sample rate of the audio must be equal to COMMON_SAMPLE_RATE
// If stereo flag is set and the audio has 2 channels, the pcmf32s will contain 2 channel PCM
bool read_wav(