const uint32_t ResampledImportableSource::blocksize = 4096U;
-ResampledImportableSource::ResampledImportableSource (SNDFILE* sf, SF_INFO* info, nframes_t rate)
- : ImportableSource (sf, info)
+ResampledImportableSource::ResampledImportableSource (const std::string& path,
+ nframes_t rate, SrcQuality srcq)
+ : ImportableSource (path)
{
int err;
- sf_seek (in, 0, SEEK_SET) ;
+ sf_seek (in.get(), 0, SEEK_SET) ;
/* Initialize the sample rate converter. */
- if ((src_state = src_new (SRC_SINC_BEST_QUALITY, sf_info->channels, &err)) == 0) {
+ int src_type;
+
+ switch (srcq) {
+ case SrcBest:
+ src_type = SRC_SINC_BEST_QUALITY;
+ break;
+ case SrcGood:
+ src_type = SRC_SINC_MEDIUM_QUALITY;
+ break;
+ case SrcQuick:
+ src_type = SRC_SINC_FASTEST;
+ break;
+ case SrcFast:
+ src_type = SRC_ZERO_ORDER_HOLD;
+ break;
+ case SrcFastest:
+ src_type = SRC_LINEAR;
+ break;
+ }
+
+ if ((src_state = src_new (src_type, sf_info.channels, &err)) == 0) {
error << string_compose(_("Import: src_new() failed : %1"), src_strerror (err)) << endmsg ;
throw failed_constructor ();
}
src_data.input_frames = 0 ;
src_data.data_in = input ;
- src_data.src_ratio = ((float) rate) / sf_info->samplerate ;
+ src_data.src_ratio = ((float) rate) / sf_info.samplerate ;
input = new float[blocksize];
}
src_data.end_of_input = SF_TRUE ;
}
- src_data.input_frames /= sf_info->channels;
+ src_data.input_frames /= sf_info.channels;
src_data.data_in = input ;
}
src_data.data_out = output;
if (!src_data.end_of_input) {
- src_data.output_frames = nframes / sf_info->channels ;
+ src_data.output_frames = nframes / sf_info.channels ;
} else {
src_data.output_frames = src_data.input_frames;
}
return 0;
}
- src_data.data_in += src_data.input_frames_used * sf_info->channels ;
+ src_data.data_in += src_data.input_frames_used * sf_info.channels ;
src_data.input_frames -= src_data.input_frames_used ;
- return src_data.output_frames_gen * sf_info->channels;
+ return src_data.output_frames_gen * sf_info.channels;
}