comparison framework/MainWindowBase.cpp @ 654:4f53620962d9 osc-script

Toward running an OSC script in batch
author Chris Cannam
date Mon, 25 Mar 2019 15:49:23 +0000
parents b63dfd7e2780
children 94f518af106c
comparison
equal deleted inserted replaced
653:365c61ac7680 654:4f53620962d9
69 #include "base/Exceptions.h" 69 #include "base/Exceptions.h"
70 #include "base/ResourceFinder.h" 70 #include "base/ResourceFinder.h"
71 71
72 #include "data/osc/OSCQueue.h" 72 #include "data/osc/OSCQueue.h"
73 #include "data/midi/MIDIInput.h" 73 #include "data/midi/MIDIInput.h"
74 #include "OSCScript.h"
74 75
75 #include "system/System.h" 76 #include "system/System.h"
76 77
77 #include <bqaudioio/SystemPlaybackTarget.h> 78 #include <bqaudioio/SystemPlaybackTarget.h>
78 #include <bqaudioio/SystemAudioIO.h> 79 #include <bqaudioio/SystemAudioIO.h>
146 m_resamplerWrapper(nullptr), 147 m_resamplerWrapper(nullptr),
147 m_playTarget(nullptr), 148 m_playTarget(nullptr),
148 m_audioIO(nullptr), 149 m_audioIO(nullptr),
149 m_oscQueue(nullptr), 150 m_oscQueue(nullptr),
150 m_oscQueueStarter(nullptr), 151 m_oscQueueStarter(nullptr),
152 m_oscScript(nullptr),
151 m_midiInput(nullptr), 153 m_midiInput(nullptr),
152 m_recentFiles("RecentFiles", 20), 154 m_recentFiles("RecentFiles", 20),
153 m_recentTransforms("RecentTransforms", 20), 155 m_recentTransforms("RecentTransforms", 20),
154 m_documentModified(false), 156 m_documentModified(false),
155 m_openingAudioFile(false), 157 m_openingAudioFile(false),
324 delete m_playSource; 326 delete m_playSource;
325 delete m_recordTarget; 327 delete m_recordTarget;
326 328
327 delete m_viewManager; 329 delete m_viewManager;
328 delete m_midiInput; 330 delete m_midiInput;
331
332 if (m_oscScript) {
333 disconnect(m_oscScript, nullptr, nullptr, nullptr);
334 m_oscScript->abandon();
335 m_oscScript->wait(1000);
336 if (m_oscScript->isRunning()) {
337 m_oscScript->terminate();
338 m_oscScript->wait(1000);
339 }
340 delete m_oscScript;
341 }
329 342
330 if (m_oscQueueStarter) { 343 if (m_oscQueueStarter) {
331 disconnect(m_oscQueueStarter, nullptr, nullptr, nullptr); 344 disconnect(m_oscQueueStarter, nullptr, nullptr, nullptr);
332 m_oscQueueStarter->wait(1000); 345 m_oscQueueStarter->wait(1000);
333 if (m_oscQueueStarter->isRunning()) { 346 if (m_oscQueueStarter->isRunning()) {
514 connect(m_oscQueue, SIGNAL(messagesAvailable()), this, SLOT(pollOSC())); 527 connect(m_oscQueue, SIGNAL(messagesAvailable()), this, SLOT(pollOSC()));
515 QTimer *oscTimer = new QTimer(this); 528 QTimer *oscTimer = new QTimer(this);
516 connect(oscTimer, SIGNAL(timeout()), this, SLOT(pollOSC())); 529 connect(oscTimer, SIGNAL(timeout()), this, SLOT(pollOSC()));
517 oscTimer->start(1000); 530 oscTimer->start(1000);
518 SVCERR << "Finished setting up OSC interface" << endl; 531 SVCERR << "Finished setting up OSC interface" << endl;
519 } 532
533 if (m_oscScriptFile != QString()) {
534 startOSCScript();
535 }
536 }
537 }
538
539 void
540 MainWindowBase::startOSCScript()
541 {
542 m_oscScript = new OSCScript(m_oscScriptFile, m_oscQueue);
543 connect(m_oscScript, SIGNAL(finished()),
544 this, SLOT(oscScriptFinished()));
545 m_oscScriptFile = QString();
546 m_oscScript->start();
547 }
548
549 void
550 MainWindowBase::cueOSCScript(QString fileName)
551 {
552 m_oscScriptFile = fileName;
553 if (m_oscQueue && m_oscQueue->isOK()) {
554 startOSCScript();
555 }
556 }
557
558 void
559 MainWindowBase::oscScriptFinished()
560 {
561 delete m_oscScript;
562 m_oscScript = 0;
520 } 563 }
521 564
522 QString 565 QString
523 MainWindowBase::getOpenFileName(FileFinder::FileType type) 566 MainWindowBase::getOpenFileName(FileFinder::FileType type)
524 { 567 {