comparison framework/MainWindowBase.cpp @ 627:7eafe977a1fc zoom

Merge from default branch
author Chris Cannam
date Tue, 09 Oct 2018 15:55:26 +0100
parents 15a566f26114 51ecc3e2d71c
children 29bef008588e
comparison
equal deleted inserted replaced
625:5bc9f9144505 627:7eafe977a1fc
1450 return FileOpenFailed; 1450 return FileOpenFailed;
1451 } 1451 }
1452 } 1452 }
1453 1453
1454 MainWindowBase::FileOpenStatus 1454 MainWindowBase::FileOpenStatus
1455 MainWindowBase::openAudio(FileSource source, AudioFileOpenMode mode, 1455 MainWindowBase::openAudio(FileSource source,
1456 AudioFileOpenMode mode,
1456 QString templateName) 1457 QString templateName)
1457 { 1458 {
1458 SVDEBUG << "MainWindowBase::openAudio(" << source.getLocation() << ") with mode " << mode << " and template " << templateName << endl; 1459 SVDEBUG << "MainWindowBase::openAudio(" << source.getLocation() << ") with mode " << mode << " and template " << templateName << endl;
1459 1460
1460 if (templateName == "") { 1461 if (templateName == "") {
1476 1477
1477 m_openingAudioFile = true; 1478 m_openingAudioFile = true;
1478 1479
1479 sv_samplerate_t rate = 0; 1480 sv_samplerate_t rate = 0;
1480 1481
1482 SVDEBUG << "Checking whether to preserve incoming audio file's sample rate"
1483 << endl;
1484
1481 if (Preferences::getInstance()->getFixedSampleRate() != 0) { 1485 if (Preferences::getInstance()->getFixedSampleRate() != 0) {
1482 rate = Preferences::getInstance()->getFixedSampleRate(); 1486 rate = Preferences::getInstance()->getFixedSampleRate();
1487 SVDEBUG << "No: preferences specify fixed rate of " << rate << endl;
1483 } else if (Preferences::getInstance()->getResampleOnLoad()) { 1488 } else if (Preferences::getInstance()->getResampleOnLoad()) {
1484 if (getMainModel()) { 1489 if (getMainModel()) {
1485 rate = getMainModel()->getSampleRate(); 1490 if (mode == ReplaceSession || mode == ReplaceMainModel) {
1486 } 1491 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;
1487 } 1492 } else {
1488 1493 rate = getMainModel()->getSampleRate();
1494 SVDEBUG << "No: preferences specify resampling to match main model, whose rate is currently " << rate << endl;
1495 }
1496 }
1497 }
1498
1499 if (rate == 0) {
1500 SVDEBUG << "Yes, preserving incoming file rate" << endl;
1501 }
1502
1489 ReadOnlyWaveFileModel *newModel = new ReadOnlyWaveFileModel(source, rate); 1503 ReadOnlyWaveFileModel *newModel = new ReadOnlyWaveFileModel(source, rate);
1490 1504
1491 if (!newModel->isOK()) { 1505 if (!newModel->isOK()) {
1492 delete newModel; 1506 delete newModel;
1493 m_openingAudioFile = false; 1507 m_openingAudioFile = false;