Mercurial > hg > svapp
comparison framework/MainWindowBase.cpp @ 578:702272b78bbe 3.0-integration
Merge
author | Chris Cannam |
---|---|
date | Wed, 04 Jan 2017 19:10:32 +0000 |
parents | 58354f2934ec b3c35447ef31 |
children | 1a8a8980f39a |
comparison
equal
deleted
inserted
replaced
577:58354f2934ec | 578:702272b78bbe |
---|---|
46 #include "widgets/CSVFormatDialog.h" | 46 #include "widgets/CSVFormatDialog.h" |
47 #include "widgets/ModelDataTableDialog.h" | 47 #include "widgets/ModelDataTableDialog.h" |
48 #include "widgets/InteractiveFileFinder.h" | 48 #include "widgets/InteractiveFileFinder.h" |
49 | 49 |
50 #include "audio/AudioCallbackPlaySource.h" | 50 #include "audio/AudioCallbackPlaySource.h" |
51 #include "audio/AudioRecordTarget.h" | 51 #include "audio/AudioCallbackRecordTarget.h" |
52 #include "audio/PlaySpeedRangeMapper.h" | 52 #include "audio/PlaySpeedRangeMapper.h" |
53 | 53 |
54 #include "data/fileio/DataFileReaderFactory.h" | 54 #include "data/fileio/DataFileReaderFactory.h" |
55 #include "data/fileio/PlaylistFileReader.h" | 55 #include "data/fileio/PlaylistFileReader.h" |
56 #include "data/fileio/WavFileWriter.h" | 56 #include "data/fileio/WavFileWriter.h" |
228 this, SLOT(paneDropAccepted(Pane *, QStringList))); | 228 this, SLOT(paneDropAccepted(Pane *, QStringList))); |
229 connect(m_paneStack, SIGNAL(dropAccepted(Pane *, QString)), | 229 connect(m_paneStack, SIGNAL(dropAccepted(Pane *, QString)), |
230 this, SLOT(paneDropAccepted(Pane *, QString))); | 230 this, SLOT(paneDropAccepted(Pane *, QString))); |
231 connect(m_paneStack, SIGNAL(paneDeleteButtonClicked(Pane *)), | 231 connect(m_paneStack, SIGNAL(paneDeleteButtonClicked(Pane *)), |
232 this, SLOT(paneDeleteButtonClicked(Pane *))); | 232 this, SLOT(paneDeleteButtonClicked(Pane *))); |
233 | 233 |
234 m_playSource = new AudioCallbackPlaySource(m_viewManager, | 234 m_playSource = new AudioCallbackPlaySource |
235 QApplication::applicationName()); | 235 (m_viewManager, QApplication::applicationName()); |
236 | |
236 if (m_soundOptions & WithAudioInput) { | 237 if (m_soundOptions & WithAudioInput) { |
237 m_recordTarget = new AudioRecordTarget(m_viewManager, | 238 m_recordTarget = new AudioCallbackRecordTarget |
238 QApplication::applicationName()); | 239 (m_viewManager, QApplication::applicationName()); |
239 connect(m_recordTarget, SIGNAL(recordDurationChanged(sv_frame_t, sv_samplerate_t)), | 240 connect(m_recordTarget, |
240 this, SLOT(recordDurationChanged(sv_frame_t, sv_samplerate_t))); | 241 SIGNAL(recordDurationChanged(sv_frame_t, sv_samplerate_t)), |
242 this, | |
243 SLOT(recordDurationChanged(sv_frame_t, sv_samplerate_t))); | |
241 } | 244 } |
242 | 245 |
243 connect(m_playSource, SIGNAL(sampleRateMismatch(sv_samplerate_t, sv_samplerate_t, bool)), | 246 connect(m_playSource, SIGNAL(sampleRateMismatch(sv_samplerate_t, sv_samplerate_t, bool)), |
244 this, SLOT(sampleRateMismatch(sv_samplerate_t, sv_samplerate_t, bool))); | 247 this, SLOT(sampleRateMismatch(sv_samplerate_t, sv_samplerate_t, bool))); |
245 connect(m_playSource, SIGNAL(channelCountIncreased()), | 248 connect(m_playSource, SIGNAL(channelCountIncreased(int)), |
246 this, SLOT(recreateAudioIO())); | 249 this, SLOT(audioChannelCountIncreased(int))); |
247 connect(m_playSource, SIGNAL(audioOverloadPluginDisabled()), | 250 connect(m_playSource, SIGNAL(audioOverloadPluginDisabled()), |
248 this, SLOT(audioOverloadPluginDisabled())); | 251 this, SLOT(audioOverloadPluginDisabled())); |
249 connect(m_playSource, SIGNAL(audioTimeStretchMultiChannelDisabled()), | 252 connect(m_playSource, SIGNAL(audioTimeStretchMultiChannelDisabled()), |
250 this, SLOT(audioTimeStretchMultiChannelDisabled())); | 253 this, SLOT(audioTimeStretchMultiChannelDisabled())); |
251 | 254 |
252 connect(m_viewManager, SIGNAL(outputLevelsChanged(float, float)), | 255 connect(m_viewManager, SIGNAL(monitoringLevelsChanged(float, float)), |
253 this, SLOT(outputLevelsChanged(float, float))); | 256 this, SLOT(monitoringLevelsChanged(float, float))); |
254 | 257 |
255 connect(m_viewManager, SIGNAL(playbackFrameChanged(sv_frame_t)), | 258 connect(m_viewManager, SIGNAL(playbackFrameChanged(sv_frame_t)), |
256 this, SLOT(playbackFrameChanged(sv_frame_t))); | 259 this, SLOT(playbackFrameChanged(sv_frame_t))); |
257 | 260 |
258 connect(m_viewManager, SIGNAL(globalCentreFrameChanged(sv_frame_t)), | 261 connect(m_viewManager, SIGNAL(globalCentreFrameChanged(sv_frame_t)), |
478 if (m_oscQueue && m_oscQueue->isOK()) { | 481 if (m_oscQueue && m_oscQueue->isOK()) { |
479 connect(m_oscQueue, SIGNAL(messagesAvailable()), this, SLOT(pollOSC())); | 482 connect(m_oscQueue, SIGNAL(messagesAvailable()), this, SLOT(pollOSC())); |
480 QTimer *oscTimer = new QTimer(this); | 483 QTimer *oscTimer = new QTimer(this); |
481 connect(oscTimer, SIGNAL(timeout()), this, SLOT(pollOSC())); | 484 connect(oscTimer, SIGNAL(timeout()), this, SLOT(pollOSC())); |
482 oscTimer->start(1000); | 485 oscTimer->start(1000); |
483 cerr << "Finished setting up OSC interface" << endl; | 486 SVCERR << "Finished setting up OSC interface" << endl; |
484 } | 487 } |
485 } | 488 } |
486 | 489 |
487 QString | 490 QString |
488 MainWindowBase::getOpenFileName(FileFinder::FileType type) | 491 MainWindowBase::getOpenFileName(FileFinder::FileType type) |
2341 | 2344 |
2342 if (!m_resamplerWrapper) { | 2345 if (!m_resamplerWrapper) { |
2343 m_resamplerWrapper = new breakfastquay::ResamplerWrapper(m_playSource); | 2346 m_resamplerWrapper = new breakfastquay::ResamplerWrapper(m_playSource); |
2344 m_playSource->setResamplerWrapper(m_resamplerWrapper); | 2347 m_playSource->setResamplerWrapper(m_resamplerWrapper); |
2345 } | 2348 } |
2349 | |
2350 std::string errorString; | |
2346 | 2351 |
2347 if (m_soundOptions & WithAudioInput) { | 2352 if (m_soundOptions & WithAudioInput) { |
2348 m_audioIO = breakfastquay::AudioFactory:: | 2353 m_audioIO = breakfastquay::AudioFactory:: |
2349 createCallbackIO(m_recordTarget, m_resamplerWrapper, preference); | 2354 createCallbackIO(m_recordTarget, m_resamplerWrapper, |
2355 preference, errorString); | |
2350 if (m_audioIO) { | 2356 if (m_audioIO) { |
2351 m_audioIO->suspend(); // start in suspended state | 2357 m_audioIO->suspend(); // start in suspended state |
2352 m_playSource->setSystemPlaybackTarget(m_audioIO); | 2358 m_playSource->setSystemPlaybackTarget(m_audioIO); |
2353 } | 2359 } |
2354 } else { | 2360 } else { |
2355 m_playTarget = breakfastquay::AudioFactory:: | 2361 m_playTarget = breakfastquay::AudioFactory:: |
2356 createCallbackPlayTarget(m_resamplerWrapper, preference); | 2362 createCallbackPlayTarget(m_resamplerWrapper, |
2363 preference, errorString); | |
2357 if (m_playTarget) { | 2364 if (m_playTarget) { |
2358 m_playTarget->suspend(); // start in suspended state | 2365 m_playTarget->suspend(); // start in suspended state |
2359 m_playSource->setSystemPlaybackTarget(m_playTarget); | 2366 m_playSource->setSystemPlaybackTarget(m_playTarget); |
2360 } | 2367 } |
2361 } | 2368 } |
2362 | 2369 |
2363 if (!m_playTarget && !m_audioIO) { | 2370 if (!m_playTarget && !m_audioIO) { |
2364 emit hideSplash(); | 2371 emit hideSplash(); |
2372 QString message; | |
2373 QString error = errorString.c_str(); | |
2374 QString firstBit, secondBit; | |
2365 if (implementation == "") { | 2375 if (implementation == "") { |
2366 QMessageBox::warning | 2376 if (error == "") { |
2367 (this, tr("Couldn't open audio device"), | 2377 firstBit = tr("<b>No audio available</b><p>Could not open an audio device.</p>"); |
2368 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>"), | 2378 } else { |
2369 QMessageBox::Ok); | 2379 firstBit = tr("<b>No audio available</b><p>Could not open audio device: %1</p>").arg(error); |
2380 } | |
2381 if (m_soundOptions & WithAudioInput) { | |
2382 secondBit = tr("<p>Automatic audio device detection failed. Audio playback and recording will not be available during this session.</p>"); | |
2383 } else { | |
2384 secondBit = tr("<p>Automatic audio device detection failed. Audio playback will not be available during this session.</p>"); | |
2385 } | |
2370 } else { | 2386 } else { |
2371 QMessageBox::warning | 2387 QString driverName = breakfastquay::AudioFactory:: |
2372 (this, tr("Couldn't open audio device"), | 2388 getImplementationDescription(implementation.toStdString()) |
2373 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>") | 2389 .c_str(); |
2374 .arg(breakfastquay::AudioFactory:: | 2390 if (error == "") { |
2375 getImplementationDescription(implementation.toStdString()) | 2391 firstBit = tr("<b>No audio available</b><p>Failed to open your preferred audio driver (\"%1\").</p>").arg(driverName); |
2376 .c_str()), | 2392 } else { |
2377 QMessageBox::Ok); | 2393 firstBit = tr("<b>No audio available</b><p>Failed to open your preferred audio driver (\"%1\"): %2.</p>").arg(driverName).arg(error); |
2378 } | 2394 } |
2395 if (m_soundOptions & WithAudioInput) { | |
2396 secondBit = tr("<p>Audio playback and recording will not be available during this session.</p>"); | |
2397 } else { | |
2398 secondBit = tr("<p>Audio playback will not be available during this session.</p>"); | |
2399 } | |
2400 } | |
2401 SVDEBUG << "createAudioIO: ERROR: Failed to open audio device \"" | |
2402 << implementation << "\": error is: " << error << endl; | |
2403 QMessageBox::warning(this, tr("Couldn't open audio device"), | |
2404 firstBit + secondBit, QMessageBox::Ok); | |
2379 } | 2405 } |
2380 } | 2406 } |
2381 | 2407 |
2382 void | 2408 void |
2383 MainWindowBase::deleteAudioIO() | 2409 MainWindowBase::deleteAudioIO() |
2406 void | 2432 void |
2407 MainWindowBase::recreateAudioIO() | 2433 MainWindowBase::recreateAudioIO() |
2408 { | 2434 { |
2409 deleteAudioIO(); | 2435 deleteAudioIO(); |
2410 createAudioIO(); | 2436 createAudioIO(); |
2437 } | |
2438 | |
2439 void | |
2440 MainWindowBase::audioChannelCountIncreased(int) | |
2441 { | |
2442 recreateAudioIO(); | |
2411 } | 2443 } |
2412 | 2444 |
2413 WaveFileModel * | 2445 WaveFileModel * |
2414 MainWindowBase::getMainModel() | 2446 MainWindowBase::getMainModel() |
2415 { | 2447 { |
2884 //!!! report | 2916 //!!! report |
2885 return; | 2917 return; |
2886 } | 2918 } |
2887 | 2919 |
2888 if (!m_audioIO) { | 2920 if (!m_audioIO) { |
2921 cerr << "MainWindowBase::record: about to create audio IO" << endl; | |
2889 createAudioIO(); | 2922 createAudioIO(); |
2890 } | 2923 } |
2891 | 2924 |
2892 if (!m_audioIO) { | 2925 if (!m_audioIO) { |
2893 //!!! report | 2926 // don't need to report this, createAudioIO already should have |
2894 return; | 2927 return; |
2895 } | 2928 } |
2896 | 2929 |
2897 if (m_recordTarget->isRecording()) { | 2930 if (m_recordTarget->isRecording()) { |
2898 stop(); | 2931 stop(); |
2908 } | 2941 } |
2909 } | 2942 } |
2910 | 2943 |
2911 if (m_viewManager) m_viewManager->setGlobalCentreFrame(0); | 2944 if (m_viewManager) m_viewManager->setGlobalCentreFrame(0); |
2912 | 2945 |
2946 cerr << "MainWindowBase::record: about to resume" << endl; | |
2913 m_audioIO->resume(); | 2947 m_audioIO->resume(); |
2914 | 2948 |
2915 WritableWaveFileModel *model = m_recordTarget->startRecording(); | 2949 WritableWaveFileModel *model = m_recordTarget->startRecording(); |
2916 if (!model) { | 2950 if (!model) { |
2917 cerr << "ERROR: MainWindowBase::record: Recording failed" << endl; | 2951 cerr << "ERROR: MainWindowBase::record: Recording failed" << endl; |