Mercurial > hg > sonic-visualiser
comparison main/OSCHandler.cpp @ 1150:5e6e1e074080 3.0-plus-imaf
Merge branches 3.0-integration and imaf_enc to 3.0-plus-imaf
author | Chris Cannam |
---|---|
date | Wed, 20 Apr 2016 12:06:28 +0100 |
parents | 28ccb621d1af bfd68cc71a25 |
children |
comparison
equal
deleted
inserted
replaced
1149:3ba5bee2ace0 | 1150:5e6e1e074080 |
---|---|
3 /* | 3 /* |
4 Sonic Visualiser | 4 Sonic Visualiser |
5 An audio file viewer and annotation editor. | 5 An audio file viewer and annotation editor. |
6 Centre for Digital Music, Queen Mary, University of London. | 6 Centre for Digital Music, Queen Mary, University of London. |
7 This file copyright 2006-2007 Chris Cannam and QMUL. | 7 This file copyright 2006-2007 Chris Cannam and QMUL. |
8 | 8 |
9 This program is free software; you can redistribute it and/or | 9 This program is free software; you can redistribute it and/or |
10 modify it under the terms of the GNU General Public License as | 10 modify it under the terms of the GNU General Public License as |
11 published by the Free Software Foundation; either version 2 of the | 11 published by the Free Software Foundation; either version 2 of the |
12 License, or (at your option) any later version. See the file | 12 License, or (at your option) any later version. See the file |
13 COPYING included with this distribution for more information. | 13 COPYING included with this distribution for more information. |
34 #include <QFileInfo> | 34 #include <QFileInfo> |
35 | 35 |
36 void | 36 void |
37 MainWindow::handleOSCMessage(const OSCMessage &message) | 37 MainWindow::handleOSCMessage(const OSCMessage &message) |
38 { | 38 { |
39 SVDEBUG << "MainWindow::handleOSCMessage: thread id = " | 39 SVDEBUG << "MainWindow::handleOSCMessage: thread id = " |
40 << QThread::currentThreadId() << endl; | 40 << QThread::currentThreadId() << endl; |
41 | 41 |
42 // This large function should really be abstracted out. | 42 // This large function should really be abstracted out. |
43 | 43 |
44 if (message.getMethod() == "open") { | 44 if (message.getMethod() == "open") { |
153 frame = getMainModel()->getEndFrame(); | 153 frame = getMainModel()->getEndFrame(); |
154 } | 154 } |
155 | 155 |
156 if (play) { | 156 if (play) { |
157 m_viewManager->setPlaySelectionMode(selection); | 157 m_viewManager->setPlaySelectionMode(selection); |
158 } | 158 } |
159 | 159 |
160 if (selection) { | 160 if (selection) { |
161 MultiSelection::SelectionList sl = m_viewManager->getSelections(); | 161 MultiSelection::SelectionList sl = m_viewManager->getSelections(); |
162 if (!sl.empty()) { | 162 if (!sl.empty()) { |
163 frame = sl.begin()->getStartFrame(); | 163 frame = sl.begin()->getStartFrame(); |
198 | 198 |
199 rewind(); | 199 rewind(); |
200 } | 200 } |
201 | 201 |
202 } else if (message.getMethod() == "stop") { | 202 } else if (message.getMethod() == "stop") { |
203 | 203 |
204 if (m_playSource->isPlaying()) m_playSource->stop(); | 204 if (m_playSource->isPlaying()) m_playSource->stop(); |
205 | 205 |
206 } else if (message.getMethod() == "loop") { | 206 } else if (message.getMethod() == "loop") { |
207 | 207 |
208 if (message.getArgCount() == 1 && | 208 if (message.getArgCount() == 1 && |
240 bool done = false; | 240 bool done = false; |
241 | 241 |
242 if (message.getArgCount() == 2 && | 242 if (message.getArgCount() == 2 && |
243 message.getArg(0).canConvert(QVariant::Double) && | 243 message.getArg(0).canConvert(QVariant::Double) && |
244 message.getArg(1).canConvert(QVariant::Double)) { | 244 message.getArg(1).canConvert(QVariant::Double)) { |
245 | 245 |
246 double t0 = message.getArg(0).toDouble(); | 246 double t0 = message.getArg(0).toDouble(); |
247 double t1 = message.getArg(1).toDouble(); | 247 double t1 = message.getArg(1).toDouble(); |
248 if (t1 < t0) { double temp = t0; t0 = t1; t1 = temp; } | 248 if (t1 < t0) { double temp = t0; t0 = t1; t1 = temp; } |
249 if (t0 < 0.0) t0 = 0.0; | 249 if (t0 < 0.0) t0 = 0.0; |
250 if (t1 < 0.0) t1 = 0.0; | 250 if (t1 < 0.0) t1 = 0.0; |
251 | 251 |
252 f0 = lrint(t0 * getMainModel()->getSampleRate()); | 252 f0 = lrint(t0 * getMainModel()->getSampleRate()); |
253 f1 = lrint(t1 * getMainModel()->getSampleRate()); | 253 f1 = lrint(t1 * getMainModel()->getSampleRate()); |
254 | 254 |
255 Pane *pane = m_paneStack->getCurrentPane(); | 255 Pane *pane = m_paneStack->getCurrentPane(); |
256 Layer *layer = 0; | 256 Layer *layer = 0; |
257 if (pane) layer = pane->getSelectedLayer(); | 257 if (pane) layer = pane->getSelectedLayer(); |
258 if (layer) { | 258 if (layer) { |
259 int resolution; | 259 int resolution; |
300 channel = -1; | 300 channel = -1; |
301 } | 301 } |
302 } | 302 } |
303 | 303 |
304 QString str = message.getArg(0).toString(); | 304 QString str = message.getArg(0).toString(); |
305 | 305 |
306 LayerFactory::LayerType type = | 306 LayerFactory::LayerType type = |
307 LayerFactory::getInstance()->getLayerTypeForName(str); | 307 LayerFactory::getInstance()->getLayerTypeForName(str); |
308 | 308 |
309 if (type == LayerFactory::UnknownLayer) { | 309 if (type == LayerFactory::UnknownLayer) { |
310 cerr << "WARNING: MainWindow::handleOSCMessage: unknown layer " | 310 cerr << "WARNING: MainWindow::handleOSCMessage: unknown layer " |
312 } else { | 312 } else { |
313 | 313 |
314 LayerConfiguration configuration(type, | 314 LayerConfiguration configuration(type, |
315 getMainModel(), | 315 getMainModel(), |
316 channel); | 316 channel); |
317 | 317 |
318 addPane(configuration, | 318 addPane(configuration, |
319 tr("Add %1 Pane") | 319 tr("Add %1 Pane") |
320 .arg(LayerFactory::getInstance()-> | 320 .arg(LayerFactory::getInstance()-> |
321 getLayerPresentationName(type))); | 321 getLayerPresentationName(type))); |
322 } | 322 } |
351 m_viewManager->setOverlayMode(ViewManager::NoOverlays); | 351 m_viewManager->setOverlayMode(ViewManager::NoOverlays); |
352 } else if (value < 1.5) { | 352 } else if (value < 1.5) { |
353 m_viewManager->setOverlayMode(ViewManager::StandardOverlays); | 353 m_viewManager->setOverlayMode(ViewManager::StandardOverlays); |
354 } else { | 354 } else { |
355 m_viewManager->setOverlayMode(ViewManager::AllOverlays); | 355 m_viewManager->setOverlayMode(ViewManager::AllOverlays); |
356 } | 356 } |
357 } else if (property == "zoomwheels") { | 357 } else if (property == "zoomwheels") { |
358 m_viewManager->setZoomWheelsEnabled(value > 0.5); | 358 m_viewManager->setZoomWheelsEnabled(value > 0.5); |
359 } else if (property == "propertyboxes") { | 359 } else if (property == "propertyboxes") { |
360 bool toggle = ((value < 0.5) != | 360 bool toggle = ((value < 0.5) != |
361 (m_paneStack->getLayoutStyle() == PaneStack::NoPropertyStacks)); | 361 (m_paneStack->getLayoutStyle() == PaneStack::NoPropertyStacks)); |
362 if (toggle) togglePropertyBoxes(); | 362 if (toggle) togglePropertyBoxes(); |
363 } | 363 } |
364 | 364 |
365 } else { | 365 } else { |
366 PropertyContainer *container = 0; | 366 PropertyContainer *container = 0; |
367 Pane *pane = m_paneStack->getCurrentPane(); | 367 Pane *pane = m_paneStack->getCurrentPane(); |
368 if (pane && | 368 if (pane && |
369 message.getArgCount() == 3 && | 369 message.getArgCount() == 3 && |
415 | 415 |
416 } else if (message.getMethod() == "delete") { | 416 } else if (message.getMethod() == "delete") { |
417 | 417 |
418 if (message.getArgCount() == 1 && | 418 if (message.getArgCount() == 1 && |
419 message.getArg(0).canConvert(QVariant::String)) { | 419 message.getArg(0).canConvert(QVariant::String)) { |
420 | 420 |
421 QString target = message.getArg(0).toString(); | 421 QString target = message.getArg(0).toString(); |
422 | 422 |
423 if (target == "pane") { | 423 if (target == "pane") { |
424 | 424 |
425 deleteCurrentPane(); | 425 deleteCurrentPane(); |
490 } | 490 } |
491 } | 491 } |
492 } | 492 } |
493 | 493 |
494 } else if (message.getMethod() == "quit") { | 494 } else if (message.getMethod() == "quit") { |
495 | 495 |
496 m_abandoning = true; | 496 m_abandoning = true; |
497 close(); | 497 close(); |
498 | 498 |
499 } else if (message.getMethod() == "resize") { | 499 } else if (message.getMethod() == "resize") { |
500 | 500 |
501 if (message.getArgCount() == 2) { | 501 if (message.getArgCount() == 2) { |
502 | 502 |
503 int width = 0, height = 0; | 503 int width = 0, height = 0; |
504 | 504 |
505 if (message.getArg(1).canConvert(QVariant::Int)) { | 505 if (message.getArg(1).canConvert(QVariant::Int)) { |
529 message.getArgCount() == 1 && | 529 message.getArgCount() == 1 && |
530 message.getArg(0).canConvert(QVariant::String)) { | 530 message.getArg(0).canConvert(QVariant::String)) { |
531 | 531 |
532 TransformId transformId = message.getArg(0).toString(); | 532 TransformId transformId = message.getArg(0).toString(); |
533 | 533 |
534 Transform transform = TransformFactory::getInstance()-> | 534 Transform transform = TransformFactory::getInstance()-> |
535 getDefaultTransformFor(transformId); | 535 getDefaultTransformFor(transformId); |
536 | 536 |
537 Layer *newLayer = m_document->createDerivedLayer | 537 Layer *newLayer = m_document->createDerivedLayer |
538 (transform, getMainModel()); | 538 (transform, getMainModel()); |
539 | 539 |
540 if (newLayer) { | 540 if (newLayer) { |
541 m_document->addLayerToView(pane, newLayer); | 541 m_document->addLayerToView(pane, newLayer); |
547 } else { | 547 } else { |
548 cerr << "WARNING: MainWindow::handleOSCMessage: Unknown or unsupported " | 548 cerr << "WARNING: MainWindow::handleOSCMessage: Unknown or unsupported " |
549 << "method \"" << message.getMethod() | 549 << "method \"" << message.getMethod() |
550 << "\"" << endl; | 550 << "\"" << endl; |
551 } | 551 } |
552 | 552 |
553 } | 553 } |