diff options
author | Max Kellermann <max@duempel.org> | 2013-07-29 23:18:55 +0200 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2013-07-30 00:04:16 +0200 |
commit | a9d2dc614496a8eee4269f4032457eb8a7fb6102 (patch) | |
tree | c208413095ee17dafd1a6280f3bf594357015e42 /src/pcm/PcmConvert.cxx | |
parent | 46b9388bb0c867b1c80d9e8f037af56b862f5fd4 (diff) |
pcm_resample: convert to C++
Diffstat (limited to 'src/pcm/PcmConvert.cxx')
-rw-r--r-- | src/pcm/PcmConvert.cxx | 44 |
1 files changed, 18 insertions, 26 deletions
diff --git a/src/pcm/PcmConvert.cxx b/src/pcm/PcmConvert.cxx index 0a3fa6816..d280101b5 100644 --- a/src/pcm/PcmConvert.cxx +++ b/src/pcm/PcmConvert.cxx @@ -34,16 +34,12 @@ PcmConvert::PcmConvert() { - pcm_resample_init(&resample); - pcm_buffer_init(&format_buffer); pcm_buffer_init(&channels_buffer); } PcmConvert::~PcmConvert() { - pcm_resample_deinit(&resample); - pcm_buffer_deinit(&format_buffer); pcm_buffer_deinit(&channels_buffer); } @@ -52,7 +48,7 @@ void PcmConvert::Reset() { dsd.Reset(); - pcm_resample_reset(&resample); + resampler.Reset(); } inline const int16_t * @@ -93,11 +89,10 @@ PcmConvert::Convert16(const audio_format *src_format, } if (src_format->sample_rate != dest_format->sample_rate) { - buf = pcm_resample_16(&resample, - dest_format->channels, - src_format->sample_rate, buf, len, - dest_format->sample_rate, &len, - error_r); + buf = resampler.Resample16(dest_format->channels, + src_format->sample_rate, buf, len, + dest_format->sample_rate, &len, + error_r); if (buf == NULL) return NULL; } @@ -143,11 +138,10 @@ PcmConvert::Convert24(const audio_format *src_format, } if (src_format->sample_rate != dest_format->sample_rate) { - buf = pcm_resample_24(&resample, - dest_format->channels, - src_format->sample_rate, buf, len, - dest_format->sample_rate, &len, - error_r); + buf = resampler.Resample24(dest_format->channels, + src_format->sample_rate, buf, len, + dest_format->sample_rate, &len, + error_r); if (buf == NULL) return NULL; } @@ -193,11 +187,10 @@ PcmConvert::Convert32(const audio_format *src_format, } if (src_format->sample_rate != dest_format->sample_rate) { - buf = pcm_resample_32(&resample, - dest_format->channels, - src_format->sample_rate, buf, len, - dest_format->sample_rate, &len, - error_r); + buf = resampler.Resample32(dest_format->channels, + src_format->sample_rate, buf, len, + dest_format->sample_rate, &len, + error_r); if (buf == NULL) return buf; } @@ -250,12 +243,11 @@ PcmConvert::ConvertFloat(const audio_format *src_format, libsamplerate */ if (src_format->sample_rate != dest_format->sample_rate) { - buffer = pcm_resample_float(&resample, - dest_format->channels, - src_format->sample_rate, - buffer, size, - dest_format->sample_rate, &size, - error_r); + buffer = resampler.ResampleFloat(dest_format->channels, + src_format->sample_rate, + buffer, size, + dest_format->sample_rate, + &size, error_r); if (buffer == NULL) return NULL; } |