# HG changeset patch # User Chris Cannam # Date 1539096916 -3600 # Node ID 51ecc3e2d71c7c7f6c35384dd2f7c3eaa3989085 # Parent 9e15607531b2bc048d51e7060fdb9e5d99f0dc8b Don't resample an incoming audio file to match the main model's rate, if the aim of importing is to replace the main model anyway diff -r 9e15607531b2 -r 51ecc3e2d71c framework/MainWindowBase.cpp --- a/framework/MainWindowBase.cpp Wed Sep 12 15:58:35 2018 +0100 +++ b/framework/MainWindowBase.cpp Tue Oct 09 15:55:16 2018 +0100 @@ -1452,7 +1452,8 @@ } MainWindowBase::FileOpenStatus -MainWindowBase::openAudio(FileSource source, AudioFileOpenMode mode, +MainWindowBase::openAudio(FileSource source, + AudioFileOpenMode mode, QString templateName) { SVDEBUG << "MainWindowBase::openAudio(" << source.getLocation() << ") with mode " << mode << " and template " << templateName << endl; @@ -1478,14 +1479,27 @@ sv_samplerate_t rate = 0; + SVDEBUG << "Checking whether to preserve incoming audio file's sample rate" + << endl; + if (Preferences::getInstance()->getFixedSampleRate() != 0) { rate = Preferences::getInstance()->getFixedSampleRate(); + SVDEBUG << "No: preferences specify fixed rate of " << rate << endl; } else if (Preferences::getInstance()->getResampleOnLoad()) { if (getMainModel()) { - rate = getMainModel()->getSampleRate(); + if (mode == ReplaceSession || mode == ReplaceMainModel) { + SVDEBUG << "Preferences specify resampling additional models to match main model, but we are opening this file to replace the main model according to the open mode: therefore..." << endl; + } else { + rate = getMainModel()->getSampleRate(); + SVDEBUG << "No: preferences specify resampling to match main model, whose rate is currently " << rate << endl; + } } } + if (rate == 0) { + SVDEBUG << "Yes, preserving incoming file rate" << endl; + } + ReadOnlyWaveFileModel *newModel = new ReadOnlyWaveFileModel(source, rate); if (!newModel->isOK()) {