comparison framework/MainWindowBase.cpp @ 554:4be200469a9c 3.0-integration

Merge from branch bqresample
author Chris Cannam
date Fri, 09 Dec 2016 18:01:55 +0000
parents 8c11ca1ebc39
children 21e3aab6e3e7
comparison
equal deleted inserted replaced
546:4de547a5905c 554:4be200469a9c
74 #include "data/midi/MIDIInput.h" 74 #include "data/midi/MIDIInput.h"
75 75
76 #include <bqaudioio/SystemPlaybackTarget.h> 76 #include <bqaudioio/SystemPlaybackTarget.h>
77 #include <bqaudioio/SystemAudioIO.h> 77 #include <bqaudioio/SystemAudioIO.h>
78 #include <bqaudioio/AudioFactory.h> 78 #include <bqaudioio/AudioFactory.h>
79 #include <bqaudioio/ResamplerWrapper.h>
79 80
80 #include <QApplication> 81 #include <QApplication>
81 #include <QMessageBox> 82 #include <QMessageBox>
82 #include <QGridLayout> 83 #include <QGridLayout>
83 #include <QLabel> 84 #include <QLabel>
139 m_viewManager(0), 140 m_viewManager(0),
140 m_timeRulerLayer(0), 141 m_timeRulerLayer(0),
141 m_soundOptions(options), 142 m_soundOptions(options),
142 m_playSource(0), 143 m_playSource(0),
143 m_recordTarget(0), 144 m_recordTarget(0),
145 m_resamplerWrapper(0),
144 m_playTarget(0), 146 m_playTarget(0),
145 m_audioIO(0), 147 m_audioIO(0),
146 m_oscQueue(0), 148 m_oscQueue(0),
147 m_oscQueueStarter(0), 149 m_oscQueueStarter(0),
148 m_midiInput(0), 150 m_midiInput(0),
301 // Only one of these two exists! 303 // Only one of these two exists!
302 delete m_audioIO; 304 delete m_audioIO;
303 delete m_playTarget; 305 delete m_playTarget;
304 306
305 // Then delete the Application objects. 307 // Then delete the Application objects.
308 delete m_resamplerWrapper;
306 delete m_playSource; 309 delete m_playSource;
307 delete m_recordTarget; 310 delete m_recordTarget;
308 311
309 delete m_viewManager; 312 delete m_viewManager;
310 delete m_oscQueue; 313 delete m_oscQueue;
1397 sv_samplerate_t rate = 0; 1400 sv_samplerate_t rate = 0;
1398 1401
1399 if (Preferences::getInstance()->getFixedSampleRate() != 0) { 1402 if (Preferences::getInstance()->getFixedSampleRate() != 0) {
1400 rate = Preferences::getInstance()->getFixedSampleRate(); 1403 rate = Preferences::getInstance()->getFixedSampleRate();
1401 } else if (Preferences::getInstance()->getResampleOnLoad()) { 1404 } else if (Preferences::getInstance()->getResampleOnLoad()) {
1402 rate = m_playSource->getSourceSampleRate(); 1405 if (getMainModel()) {
1406 rate = getMainModel()->getSampleRate();
1407 }
1403 } 1408 }
1404 1409
1405 ReadOnlyWaveFileModel *newModel = new ReadOnlyWaveFileModel(source, rate); 1410 ReadOnlyWaveFileModel *newModel = new ReadOnlyWaveFileModel(source, rate);
1406 1411
1407 if (!newModel->isOK()) { 1412 if (!newModel->isOK()) {
2156 connect(&dialog, SIGNAL(showing()), this, SIGNAL(hideSplash())); 2161 connect(&dialog, SIGNAL(showing()), this, SIGNAL(hideSplash()));
2157 2162
2158 if (getMainModel()) { 2163 if (getMainModel()) {
2159 rate = getMainModel()->getSampleRate(); 2164 rate = getMainModel()->getSampleRate();
2160 } else if (Preferences::getInstance()->getResampleOnLoad()) { 2165 } else if (Preferences::getInstance()->getResampleOnLoad()) {
2161 rate = m_playSource->getSourceSampleRate(); 2166 if (getMainModel()) {
2167 rate = getMainModel()->getSampleRate();
2168 }
2162 } 2169 }
2163 2170
2164 RDFImporter importer 2171 RDFImporter importer
2165 (QUrl::fromLocalFile(source.getLocalFilename()).toString(), rate); 2172 (QUrl::fromLocalFile(source.getLocalFilename()).toString(), rate);
2166 2173
2298 { 2305 {
2299 if (m_playTarget || m_audioIO) return; 2306 if (m_playTarget || m_audioIO) return;
2300 2307
2301 if (!(m_soundOptions & WithAudioOutput)) return; 2308 if (!(m_soundOptions & WithAudioOutput)) return;
2302 2309
2303 //!!! how to handle preferences
2304 /*
2305 QSettings settings; 2310 QSettings settings;
2306 settings.beginGroup("Preferences"); 2311 settings.beginGroup("Preferences");
2307 QString targetName = settings.value("audio-target", "").toString(); 2312 QString implementation = settings.value
2313 ("audio-target", "").toString();
2314 QString suffix;
2315 if (implementation != "") suffix = "-" + implementation;
2316 QString recordDevice = settings.value
2317 ("audio-record-device" + suffix, "").toString();
2318 QString playbackDevice = settings.value
2319 ("audio-playback-device" + suffix, "").toString();
2308 settings.endGroup(); 2320 settings.endGroup();
2309 AudioTargetFactory *factory = AudioTargetFactory::getInstance(); 2321
2310 2322 if (implementation == "auto") {
2311 factory->setDefaultCallbackTarget(targetName); 2323 implementation = "";
2312 */ 2324 }
2313 2325
2326 breakfastquay::AudioFactory::Preference preference;
2327 preference.implementation = implementation.toStdString();
2328 preference.recordDevice = recordDevice.toStdString();
2329 preference.playbackDevice = playbackDevice.toStdString();
2330
2331 SVCERR << "createAudioIO: Preferred implementation = \""
2332 << preference.implementation << "\"" << endl;
2333 SVCERR << "createAudioIO: Preferred playback device = \""
2334 << preference.playbackDevice << "\"" << endl;
2335 SVCERR << "createAudioIO: Preferred record device = \""
2336 << preference.recordDevice << "\"" << endl;
2337
2338 if (!m_resamplerWrapper) {
2339 m_resamplerWrapper = new breakfastquay::ResamplerWrapper(m_playSource);
2340 m_playSource->setResamplerWrapper(m_resamplerWrapper);
2341 }
2342
2314 if (m_soundOptions & WithAudioInput) { 2343 if (m_soundOptions & WithAudioInput) {
2315 m_audioIO = breakfastquay::AudioFactory:: 2344 m_audioIO = breakfastquay::AudioFactory::
2316 createCallbackIO(m_recordTarget, m_playSource); 2345 createCallbackIO(m_recordTarget, m_resamplerWrapper, preference);
2317 if (m_audioIO) { 2346 if (m_audioIO) {
2318 m_audioIO->suspend(); // start in suspended state 2347 m_audioIO->suspend(); // start in suspended state
2319 m_playSource->setSystemPlaybackTarget(m_audioIO); 2348 m_playSource->setSystemPlaybackTarget(m_audioIO);
2320 } 2349 }
2321 } else { 2350 } else {
2322 m_playTarget = breakfastquay::AudioFactory:: 2351 m_playTarget = breakfastquay::AudioFactory::
2323 createCallbackPlayTarget(m_playSource); 2352 createCallbackPlayTarget(m_resamplerWrapper, preference);
2324 if (m_playTarget) { 2353 if (m_playTarget) {
2325 m_playTarget->suspend(); // start in suspended state 2354 m_playTarget->suspend(); // start in suspended state
2326 m_playSource->setSystemPlaybackTarget(m_playTarget); 2355 m_playSource->setSystemPlaybackTarget(m_playTarget);
2327 } 2356 }
2328 } 2357 }
2329 2358
2330 if (!m_playTarget && !m_audioIO) { 2359 if (!m_playTarget && !m_audioIO) {
2331 emit hideSplash(); 2360 emit hideSplash();
2332 2361 if (implementation == "") {
2333 // if (factory->isAutoCallbackTarget(targetName)) {
2334 QMessageBox::warning 2362 QMessageBox::warning
2335 (this, tr("Couldn't open audio device"), 2363 (this, tr("Couldn't open audio device"),
2336 tr("<b>No audio available</b><p>Could not open an audio device for playback.<p>Automatic audio device detection failed. Audio playback will not be available during this session.</p>"), 2364 tr("<b>No audio available</b><p>Could not open an audio device for playback.<p>Automatic audio device detection failed. Audio playback will not be available during this session.</p>"),
2337 QMessageBox::Ok); 2365 QMessageBox::Ok);
2338 /*
2339 } else { 2366 } else {
2340 QMessageBox::warning 2367 QMessageBox::warning
2341 (this, tr("Couldn't open audio device"), 2368 (this, tr("Couldn't open audio device"),
2342 tr("<b>No audio available</b><p>Failed to open your preferred audio device (\"%1\").<p>Audio playback will not be available during this session.</p>") 2369 tr("<b>No audio available</b><p>Failed to open your preferred audio device (\"%1\").<p>Audio playback will not be available during this session.</p>")
2343 .arg(factory->getCallbackTargetDescription(targetName)), 2370 .arg(breakfastquay::AudioFactory::
2371 getImplementationDescription(implementation.toStdString())
2372 .c_str()),
2344 QMessageBox::Ok); 2373 QMessageBox::Ok);
2345 } 2374 }
2346 */
2347 return;
2348 } 2375 }
2349 } 2376 }
2350 2377
2351 WaveFileModel * 2378 WaveFileModel *
2352 MainWindowBase::getMainModel() 2379 MainWindowBase::getMainModel()