return NULL;
}
FILE *stream = fopen(path, "w+b");
+ if (stream == NULL) {
+ fprintf(stderr, "fopen %s failed errno %d\n", path, errno);
+ return NULL;
+ }
unsigned char wav[58];
memset(wav, 0, sizeof(wav));
memcpy(wav, "RIFF", 4);
break;
case SF_FORMAT_FLOAT:
handle->temp = realloc(handle->temp, desiredBytes);
- memcpy_to_float_from_i16((float *) handle->temp, ptr, desiredFrames);
+ memcpy_to_float_from_i16((float *) handle->temp, ptr,
+ desiredFrames * handle->info.channels);
actualBytes = fwrite(handle->temp, sizeof(char), desiredBytes, handle->stream);
break;
default:
break;
case SF_FORMAT_PCM_16:
handle->temp = realloc(handle->temp, desiredBytes);
- memcpy_to_i16_from_float((short *) handle->temp, ptr, desiredFrames);
+ memcpy_to_i16_from_float((short *) handle->temp, ptr,
+ desiredFrames * handle->info.channels);
actualBytes = fwrite(handle->temp, sizeof(char), desiredBytes, handle->stream);
break;
case SF_FORMAT_PCM_U8: // transcoding from float to byte not yet implemented