Fix compilation errors with MA_NO_DEVICE_IO.

This commit is contained in:
David Reid
2023-05-22 18:09:04 +10:00
parent 563e1c52cb
commit a8f3cb857e
5 changed files with 426 additions and 447 deletions
-17
View File
@@ -37,20 +37,3 @@ ma_result ma_register_test(const char* pName, ma_test_entry_proc onEntry)
return MA_SUCCESS;
}
drwav_data_format drwav_data_format_from_minaudio_format(ma_format format, ma_uint32 channels, ma_uint32 sampleRate)
{
drwav_data_format wavFormat;
wavFormat.container = drwav_container_riff;
wavFormat.channels = channels;
wavFormat.sampleRate = sampleRate;
wavFormat.bitsPerSample = ma_get_bytes_per_sample(format) * 8;
if (format == ma_format_f32) {
wavFormat.format = DR_WAVE_FORMAT_IEEE_FLOAT;
} else {
wavFormat.format = DR_WAVE_FORMAT_PCM;
}
return wavFormat;
}
@@ -11,12 +11,12 @@ ma_result test_noise__by_format_and_type(ma_format format, ma_noise_type type, c
printf(" %s\n", pFileName);
noiseConfig = ma_noise_config_init(format, 1, type, 0, 0.1);
result = ma_noise_init(&noiseConfig, &noise);
result = ma_noise_init(&noiseConfig, NULL, &noise);
if (result != MA_SUCCESS) {
return result;
}
encoderConfig = ma_encoder_config_init(ma_resource_format_wav, format, noiseConfig.channels, 48000);
encoderConfig = ma_encoder_config_init(ma_encoding_format_wav, format, noiseConfig.channels, 48000);
result = ma_encoder_init_file(pFileName, &encoderConfig, &encoder);
if (result != MA_SUCCESS) {
return result;
@@ -25,8 +25,8 @@ ma_result test_noise__by_format_and_type(ma_format format, ma_noise_type type, c
/* We'll do a few seconds of data. */
for (iFrame = 0; iFrame < encoder.config.sampleRate * 10; iFrame += 1) {
ma_uint8 temp[1024];
ma_noise_read_pcm_frames(&noise, temp, 1);
ma_encoder_write_pcm_frames(&encoder, temp, 1);
ma_noise_read_pcm_frames(&noise, temp, 1, NULL);
ma_encoder_write_pcm_frames(&encoder, temp, 1, NULL);
}
ma_encoder_uninit(&encoder);
@@ -1,18 +1,11 @@
static drwav_data_format drwav_data_format_from_waveform_config(const ma_waveform_config* pWaveformConfig)
{
MA_ASSERT(pWaveformConfig != NULL);
return drwav_data_format_from_minaudio_format(pWaveformConfig->format, pWaveformConfig->channels, pWaveformConfig->sampleRate);
}
ma_result test_waveform__by_format_and_type(ma_format format, ma_waveform_type type, double amplitude, const char* pFileName)
{
ma_result result;
ma_waveform_config waveformConfig;
ma_waveform waveform;
drwav_data_format wavFormat;
drwav wav;
ma_encoder_config encoderConfig;
ma_encoder encoder;
ma_uint32 iFrame;
printf(" %s\n", pFileName);
@@ -23,19 +16,22 @@ ma_result test_waveform__by_format_and_type(ma_format format, ma_waveform_type t
return result;
}
wavFormat = drwav_data_format_from_waveform_config(&waveformConfig);
if (!drwav_init_file_write(&wav, pFileName, &wavFormat, NULL)) {
return MA_ERROR; /* Could not open file for writing. */
encoderConfig = ma_encoder_config_init(ma_encoding_format_wav, waveformConfig.format, waveformConfig.channels, waveformConfig.sampleRate);
result = ma_encoder_init_file(pFileName, &encoderConfig, &encoder);
if (result != MA_SUCCESS) {
return result; /* Failed to initialize encoder. */
}
/* We'll do a few seconds of data. */
for (iFrame = 0; iFrame < wavFormat.sampleRate * 10; iFrame += 1) {
for (iFrame = 0; iFrame < waveformConfig.sampleRate * 10; iFrame += 1) {
float temp[MA_MAX_CHANNELS];
ma_waveform_read_pcm_frames(&waveform, temp, 1);
drwav_write_pcm_frames(&wav, 1, temp);
ma_waveform_read_pcm_frames(&waveform, temp, 1, NULL);
ma_encoder_write_pcm_frames(&encoder, temp, 1, NULL);
}
drwav_uninit(&wav);
ma_encoder_uninit(&encoder);
ma_waveform_uninit(&waveform);
return MA_SUCCESS;
}