void DemoApp::SetupScore() { TTValue args, out; TTObject xmlHandler("XmlHandler"); TTLogMessage("\n*** Initialisation of Score environnement ***\n"); ///////////////////////////////////////////////////////////////////// // Init the Score library (passing the folder path where all the dylibs are) TTScoreInit("/usr/local/jamoma"); TTLogMessage("\n*** Reading of an interactive scenario file ***\n"); ///////////////////////////////////////////////////////////////////// // Create an empty Scenario mScenario = TTObject("Scenario"); // Read DemoScenario1.score file to fill mScenario xmlHandler.set("object", mScenario); xmlHandler.send("Read", "../DemoScenario.score", out); TTLogMessage("\n*** Prepare scenario observation ***\n"); ///////////////////////////////////////////////////////////////////// // Create a callback for the "EventStatusChanged" notification sent by each event mEventStatusChangedCallback = TTObject("callback"); mEventStatusChangedCallback.set("baton", TTPtr(this)); mEventStatusChangedCallback.set("function", TTPtr(&DemoAppEventStatusChangedCallback)); mEventStatusChangedCallback.set("notification", TTSymbol("EventStatusChanged")); // Get all events of the scenario and attach a callback to them TTValue timeEvents; mScenario.get("timeEvents", timeEvents); for (TTElementIter it = timeEvents.begin() ; it != timeEvents.end() ; it++) { TTObject event = TTElement(*it); event.registerObserverForNotifications(mEventStatusChangedCallback); } TTLogMessage("\n*** Start scenario execution ***\n"); ///////////////////////////////////////////////////////////////////// // Set the execution speed of the scenario mScenario.set("speed", 2.); // Start the scenario mScenario.send("Start"); // Poll Scenario information mPollingThread = new TTThread(TTThreadCallbackType(DemoAppScenarioPollingThread), this); }
TTErr MIDIInput::setRunning(TTBoolean running) { if (running != mRunning) { mRunning = running; if (mRunning) { mPollingThread = new TTThread(TTThreadCallbackType(MIDIInputPoll), this); } else { if (mPollingThread) mPollingThread->wait(); delete mPollingThread; } } return kTTErrNone; }