| 67 |
67 |
#include "base/UnitDatabase.h"
|
| 68 |
68 |
#include "layer/ColourDatabase.h"
|
| 69 |
69 |
#include "data/osc/OSCQueue.h"
|
|
70 |
#include "rdf/PluginRDFDescription.h"
|
| 70 |
71 |
|
| 71 |
72 |
//!!!
|
| 72 |
73 |
#include "data/model/AggregateWaveModel.h"
|
| ... | ... | |
| 122 |
123 |
m_recentFilesMenu(0),
|
| 123 |
124 |
m_rightButtonMenu(0),
|
| 124 |
125 |
m_rightButtonPlaybackMenu(0),
|
|
126 |
m_segmentersMenu(0),
|
| 125 |
127 |
m_deleteSelectedAction(0),
|
| 126 |
128 |
m_ffwdAction(0),
|
| 127 |
129 |
m_rwdAction(0),
|
| ... | ... | |
| 165 |
167 |
|
| 166 |
168 |
settings.setValue("waveform",
|
| 167 |
169 |
QString("<layer scale=\"%1\" channelMode=\"%2\"/>")
|
| 168 |
|
.arg(int(WaveformLayer::MeterScale))
|
| 169 |
|
// .arg(int(WaveformLayer::LinearScale))
|
|
170 |
// .arg(int(WaveformLayer::MeterScale))
|
|
171 |
.arg(int(WaveformLayer::LinearScale))
|
| 170 |
172 |
.arg(int(WaveformLayer::MergeChannels)));
|
| 171 |
173 |
|
| 172 |
174 |
settings.setValue("timevalues",
|
| 173 |
175 |
QString("<layer plotStyle=\"%1\"/>")
|
| 174 |
|
.arg(int(TimeValueLayer::PlotStems)));
|
|
176 |
// .arg(int(TimeValueLayer::PlotStems)));
|
|
177 |
.arg(int(TimeValueLayer::PlotCurve)));
|
| 175 |
178 |
|
| 176 |
179 |
settings.setValue("spectrogram",
|
| 177 |
180 |
QString("<layer channel=\"-1\" windowSize=\"2048\" windowHopLevel=\"2\"/>"));
|
| ... | ... | |
| 185 |
188 |
settings.setValue("showstatusbar", false);
|
| 186 |
189 |
settings.endGroup();
|
| 187 |
190 |
|
| 188 |
|
m_viewManager->setAlignMode(true);
|
| 189 |
|
m_viewManager->setPlaySoloMode(true);
|
|
191 |
// m_viewManager->setAlignMode(true);
|
|
192 |
// m_viewManager->setPlaySoloMode(true);
|
| 190 |
193 |
m_viewManager->setToolMode(ViewManager::NavigateMode);
|
| 191 |
194 |
m_viewManager->setZoomWheelsEnabled(false);
|
| 192 |
195 |
m_viewManager->setIlluminateLocalFeatures(false);
|
| ... | ... | |
| 319 |
322 |
|
| 320 |
323 |
frame->setLayout(layout);
|
| 321 |
324 |
|
|
325 |
findSegmentationTransforms();
|
|
326 |
|
| 322 |
327 |
setupMenus();
|
| 323 |
328 |
setupToolbars();
|
| 324 |
329 |
setupHelpMenu();
|
| ... | ... | |
| 359 |
364 |
setupFileMenu();
|
| 360 |
365 |
// setupEditMenu();
|
| 361 |
366 |
setupViewMenu();
|
|
367 |
setupSegmentersMenu();
|
| 362 |
368 |
|
| 363 |
369 |
m_mainMenusCreated = true;
|
| 364 |
370 |
}
|
| ... | ... | |
| 611 |
617 |
}
|
| 612 |
618 |
|
| 613 |
619 |
void
|
|
620 |
MainWindow::setupSegmentersMenu()
|
|
621 |
{
|
|
622 |
if (m_segmentersMenu) {
|
|
623 |
m_segmenterActions.clear();
|
|
624 |
m_segmentersMenu->clear();
|
|
625 |
} else {
|
|
626 |
m_segmentersMenu = menuBar()->addMenu(tr("&Segmenters"));
|
|
627 |
m_segmentersMenu->setTearOffEnabled(true);
|
|
628 |
m_segmentersMenu->setSeparatorsCollapsible(true);
|
|
629 |
}
|
|
630 |
|
|
631 |
std::set<QString> seenNames, duplicateNames, seenPluginNames, duplicatePluginNames;
|
|
632 |
for (unsigned int i = 0; i < m_segmentationTransforms.size(); ++i) {
|
|
633 |
QString name = m_segmentationTransforms[i].name;
|
|
634 |
QString pluginName = name.section(": ", 0, 0);
|
|
635 |
if (seenNames.find(name) != seenNames.end()) {
|
|
636 |
duplicateNames.insert(name);
|
|
637 |
} else {
|
|
638 |
seenNames.insert(name);
|
|
639 |
}
|
|
640 |
if (seenPluginNames.find(pluginName) != seenPluginNames.end()) {
|
|
641 |
duplicatePluginNames.insert(pluginName);
|
|
642 |
} else {
|
|
643 |
seenPluginNames.insert(pluginName);
|
|
644 |
}
|
|
645 |
}
|
|
646 |
|
|
647 |
for (unsigned int i = 0; i < m_segmentationTransforms.size(); ++i) {
|
|
648 |
|
|
649 |
QString name = m_segmentationTransforms[i].name;
|
|
650 |
if (name == "") name = m_segmentationTransforms[i].identifier;
|
|
651 |
|
|
652 |
QString maker = m_segmentationTransforms[i].maker;
|
|
653 |
if (maker == "") maker = tr("Unknown");
|
|
654 |
maker.replace(QRegExp(tr(" [\\(<].*$")), "");
|
|
655 |
|
|
656 |
QString pluginName = name.section(": ", 0, 0);
|
|
657 |
QString output = name.section(": ", 1);
|
|
658 |
|
|
659 |
if (duplicateNames.find(pluginName) != duplicateNames.end()) {
|
|
660 |
pluginName = QString("%1 <%2>")
|
|
661 |
.arg(pluginName)
|
|
662 |
.arg(m_segmentationTransforms[i].identifier.section(':', 1, 1));
|
|
663 |
if (output == "") {
|
|
664 |
name = pluginName;
|
|
665 |
} else {
|
|
666 |
name = QString("%1: %2")
|
|
667 |
.arg(pluginName)
|
|
668 |
.arg(output);
|
|
669 |
}
|
|
670 |
} else if (duplicatePluginNames.find(pluginName) ==
|
|
671 |
duplicatePluginNames.end()) {
|
|
672 |
name = pluginName;
|
|
673 |
}
|
|
674 |
|
|
675 |
QAction *action = new QAction(tr("%1...").arg(name), this);
|
|
676 |
connect(action, SIGNAL(triggered()), this, SLOT(addSegmentation()));
|
|
677 |
m_segmenterActions[action] = m_segmentationTransforms[i].identifier;
|
|
678 |
connect(this, SIGNAL(canAddLayer(bool)), action, SLOT(setEnabled(bool)));
|
|
679 |
action->setStatusTip(m_segmentationTransforms[i].longDescription);
|
|
680 |
|
|
681 |
m_segmentersMenu->addAction(action);
|
|
682 |
}
|
|
683 |
}
|
|
684 |
|
|
685 |
void
|
| 614 |
686 |
MainWindow::setupHelpMenu()
|
| 615 |
687 |
{
|
| 616 |
688 |
QMenu *menu = menuBar()->addMenu(tr("&Help"));
|
| ... | ... | |
| 928 |
1000 |
createDocument();
|
| 929 |
1001 |
m_document->setAutoAlignment(true);
|
| 930 |
1002 |
|
| 931 |
|
Pane *pane = m_paneStack->addPane();
|
|
1003 |
Pane *pane;
|
|
1004 |
Layer *waveform;
|
| 932 |
1005 |
|
| 933 |
|
connect(pane, SIGNAL(contextHelpChanged(const QString &)),
|
| 934 |
|
this, SLOT(contextHelpChanged(const QString &)));
|
| 935 |
|
|
| 936 |
|
Layer *waveform = m_document->createMainModelLayer(LayerFactory::Waveform);
|
| 937 |
|
m_document->addLayerToView(pane, waveform);
|
| 938 |
|
|
| 939 |
|
m_overview->registerView(pane);
|
|
1006 |
for (int i = 0; i < 2; ++i) {
|
|
1007 |
pane = m_paneStack->addPane();
|
|
1008 |
pane->setFollowGlobalPan(false);
|
|
1009 |
connect(pane, SIGNAL(contextHelpChanged(const QString &)),
|
|
1010 |
this, SLOT(contextHelpChanged(const QString &)));
|
|
1011 |
waveform = m_document->createMainModelLayer(LayerFactory::Waveform);
|
|
1012 |
m_document->addLayerToView(pane, waveform);
|
|
1013 |
m_overview->registerView(pane);
|
|
1014 |
}
|
| 940 |
1015 |
|
| 941 |
1016 |
CommandHistory::getInstance()->clear();
|
| 942 |
1017 |
CommandHistory::getInstance()->documentSaved();
|
| ... | ... | |
| 1073 |
1148 |
}
|
| 1074 |
1149 |
}
|
| 1075 |
1150 |
|
| 1076 |
|
Model *
|
|
1151 |
bool
|
| 1077 |
1152 |
MainWindow::selectExistingModeLayer(Pane *pane, QString name)
|
| 1078 |
1153 |
{
|
| 1079 |
|
Model *model = 0;
|
|
1154 |
// return false if we do not need to go on and create a new layer
|
|
1155 |
// -- either because a suitable hidden one has been dredged up, or
|
|
1156 |
// because no layer that needed replacing was found in this pane
|
| 1080 |
1157 |
|
| 1081 |
|
bool have = false;
|
|
1158 |
if (!m_document) return false;
|
|
1159 |
|
|
1160 |
bool required = false;
|
| 1082 |
1161 |
|
| 1083 |
1162 |
for (int i = 0; i < pane->getLayerCount(); ++i) {
|
| 1084 |
1163 |
|
| ... | ... | |
| 1087 |
1166 |
|
| 1088 |
1167 |
Model *lm = layer->getModel();
|
| 1089 |
1168 |
while (lm && lm->getSourceModel()) lm = lm->getSourceModel();
|
| 1090 |
|
if (dynamic_cast<WaveFileModel *>(lm)) model = lm;
|
|
1169 |
if (dynamic_cast<WaveFileModel *>(lm)) {
|
|
1170 |
if (lm == m_document->getMainModel()) {
|
|
1171 |
required = true;
|
|
1172 |
break;
|
|
1173 |
}
|
|
1174 |
}
|
|
1175 |
}
|
|
1176 |
|
|
1177 |
if (!required) return false;
|
|
1178 |
|
|
1179 |
for (int i = 0; i < pane->getLayerCount(); ++i) {
|
|
1180 |
|
|
1181 |
Layer *layer = pane->getLayer(i);
|
|
1182 |
if (!layer) continue;
|
| 1091 |
1183 |
|
| 1092 |
1184 |
QString ln = layer->objectName();
|
| 1093 |
1185 |
if (ln != name) {
|
| ... | ... | |
| 1095 |
1187 |
m_document->removeLayerFromView(pane, layer);
|
| 1096 |
1188 |
continue;
|
| 1097 |
1189 |
}
|
| 1098 |
|
|
| 1099 |
|
have = true;
|
| 1100 |
1190 |
}
|
| 1101 |
|
|
| 1102 |
|
if (have) return 0;
|
| 1103 |
1191 |
|
| 1104 |
1192 |
LayerSet &ls = m_hiddenLayers[pane];
|
| 1105 |
1193 |
bool found = false;
|
| ... | ... | |
| 1112 |
1200 |
}
|
| 1113 |
1201 |
}
|
| 1114 |
1202 |
|
| 1115 |
|
if (found) return 0;
|
|
1203 |
return !found;
|
|
1204 |
}
|
| 1116 |
1205 |
|
| 1117 |
|
return model;
|
|
1206 |
void
|
|
1207 |
MainWindow::addSegmentation()
|
|
1208 |
{
|
|
1209 |
QObject *s = sender();
|
|
1210 |
QAction *action = dynamic_cast<QAction *>(s);
|
|
1211 |
|
|
1212 |
if (!action) {
|
|
1213 |
std::cerr << "WARNING: MainWindow::addSegmentation: sender is not an action"
|
|
1214 |
<< std::endl;
|
|
1215 |
return;
|
|
1216 |
}
|
|
1217 |
|
|
1218 |
TransformActionMap::iterator i = m_segmenterActions.find(action);
|
|
1219 |
if (i == m_segmenterActions.end()) return;
|
|
1220 |
|
|
1221 |
// We always ask for configuration, even if the plugin isn't
|
|
1222 |
// supposed to be configurable, because we need to let the user
|
|
1223 |
// change the execution context (block size etc).
|
|
1224 |
|
|
1225 |
QString transformId = i->second;
|
|
1226 |
|
|
1227 |
Transform transform = TransformFactory::getInstance()->
|
|
1228 |
getDefaultTransformFor(transformId);
|
|
1229 |
|
|
1230 |
Model *defaultInputModel = m_document->getMainModel();
|
|
1231 |
std::vector<Model *> candidateInputModels;
|
|
1232 |
candidateInputModels.push_back(defaultInputModel);
|
|
1233 |
|
|
1234 |
ModelTransformer::Input input = ModelTransformerFactory::getInstance()->
|
|
1235 |
getConfigurationForTransform
|
|
1236 |
(transform,
|
|
1237 |
candidateInputModels,
|
|
1238 |
defaultInputModel,
|
|
1239 |
m_playSource,
|
|
1240 |
0,
|
|
1241 |
0);
|
|
1242 |
|
|
1243 |
if (!input.getModel()) return;
|
|
1244 |
|
|
1245 |
// std::cerr << "MainWindow::addLayer: Input model is " << input.getModel() << " \"" << input.getModel()->objectName().toStdString() << "\"" << std::endl << "transform:" << std::endl << transform.toXmlString().toStdString() << std::endl;
|
|
1246 |
|
|
1247 |
Layer *newLayer = m_document->createDerivedLayer(transform, input);
|
|
1248 |
|
|
1249 |
if (newLayer) {
|
|
1250 |
|
|
1251 |
AddPaneCommand *command = new AddPaneCommand(this);
|
|
1252 |
CommandHistory::getInstance()->addCommand(command);
|
|
1253 |
|
|
1254 |
Pane *pane = command->getPane();
|
|
1255 |
if (!pane) return;
|
|
1256 |
|
|
1257 |
// Set the source model to NULL to avoid us treating it as a
|
|
1258 |
// different visualisation for the main model and replacing it
|
|
1259 |
// when one of the visualisation mode toggles is activated
|
|
1260 |
newLayer->getModel()->setSourceModel(0);
|
|
1261 |
|
|
1262 |
m_document->addLayerToView(pane, newLayer);
|
|
1263 |
m_document->setChannel(newLayer, input.getChannel());
|
|
1264 |
// m_paneStack->setCurrentLayer(pane, newLayer);
|
|
1265 |
}
|
|
1266 |
|
|
1267 |
updateMenuStates();
|
|
1268 |
}
|
|
1269 |
|
|
1270 |
void
|
|
1271 |
MainWindow::findSegmentationTransforms()
|
|
1272 |
{
|
|
1273 |
m_segmentationTransforms.clear();
|
|
1274 |
TransformList all =
|
|
1275 |
TransformFactory::getInstance()->getAllTransformDescriptions();
|
|
1276 |
for (TransformList::iterator i = all.begin(); i != all.end(); ++i) {
|
|
1277 |
if (i->type != Transform::FeatureExtraction) continue;
|
|
1278 |
Transform t;
|
|
1279 |
t.setIdentifier(i->identifier);
|
|
1280 |
QString pluginId = t.getPluginIdentifier();
|
|
1281 |
QString outputId = t.getOutput();
|
|
1282 |
PluginRDFDescription desc(pluginId);
|
|
1283 |
if (!desc.haveDescription()) continue;
|
|
1284 |
QString feature = desc.getOutputEventTypeURI(outputId);
|
|
1285 |
if (feature == "") continue;
|
|
1286 |
std::cerr << "Feature: " << feature.toStdString() << std::endl;
|
|
1287 |
//!!! This is grotesque
|
|
1288 |
if (feature.endsWith("Segment") || feature.endsWith("Change")) {
|
|
1289 |
m_segmentationTransforms.push_back(*i);
|
|
1290 |
}
|
|
1291 |
}
|
|
1292 |
std::cerr << "MainWindow::findSegmentationTransforms: Found "
|
|
1293 |
<< m_segmentationTransforms.size() << " transforms" << std::endl;
|
| 1118 |
1294 |
}
|
| 1119 |
1295 |
|
| 1120 |
1296 |
void
|
| ... | ... | |
| 1127 |
1303 |
Pane *pane = m_paneStack->getPane(i);
|
| 1128 |
1304 |
if (!pane) continue;
|
| 1129 |
1305 |
|
| 1130 |
|
Model *model = selectExistingModeLayer(pane, name);
|
|
1306 |
if (!selectExistingModeLayer(pane, name)) continue;
|
|
1307 |
Model *model = m_document->getMainModel();
|
| 1131 |
1308 |
if (!model) continue;
|
| 1132 |
1309 |
|
| 1133 |
1310 |
TransformId id = "vamp:qm-vamp-plugins:qm-onsetdetector:detection_fn";
|
| ... | ... | |
| 1145 |
1322 |
|
| 1146 |
1323 |
//!!! no equivalent for this yet context.updates = false;
|
| 1147 |
1324 |
|
| 1148 |
|
Layer *newLayer = m_document->createDerivedLayer(transform, model);
|
|
1325 |
Layer *newLayer = m_document->createDerivedLayer
|
|
1326 |
(transform, model);
|
| 1149 |
1327 |
|
| 1150 |
1328 |
if (newLayer) {
|
| 1151 |
1329 |
newLayer->setObjectName(name);
|
| ... | ... | |
| 1154 |
1332 |
}
|
| 1155 |
1333 |
|
| 1156 |
1334 |
} else {
|
| 1157 |
|
std::cerr << "No Aubio onset detector plugin available" << std::endl;
|
|
1335 |
std::cerr << "No QM onset detector plugin available" << std::endl;
|
| 1158 |
1336 |
}
|
| 1159 |
1337 |
}
|
| 1160 |
1338 |
|
| ... | ... | |
| 1171 |
1349 |
Pane *pane = m_paneStack->getPane(i);
|
| 1172 |
1350 |
if (!pane) continue;
|
| 1173 |
1351 |
|
| 1174 |
|
Model *model = selectExistingModeLayer(pane, name);
|
|
1352 |
if (!selectExistingModeLayer(pane, name)) continue;
|
|
1353 |
Model *model = m_document->getMainModel();
|
| 1175 |
1354 |
if (!model) continue;
|
| 1176 |
1355 |
|
| 1177 |
1356 |
Layer *newLayer = m_document->createLayer(LayerFactory::Waveform);
|
| ... | ... | |
| 1194 |
1373 |
Pane *pane = m_paneStack->getPane(i);
|
| 1195 |
1374 |
if (!pane) continue;
|
| 1196 |
1375 |
|
| 1197 |
|
Model *model = selectExistingModeLayer(pane, name);
|
|
1376 |
if (!selectExistingModeLayer(pane, name)) continue;
|
|
1377 |
Model *model = m_document->getMainModel();
|
| 1198 |
1378 |
if (!model) continue;
|
| 1199 |
1379 |
|
| 1200 |
1380 |
Layer *newLayer = m_document->createLayer(LayerFactory::Spectrogram);
|
| ... | ... | |
| 1217 |
1397 |
Pane *pane = m_paneStack->getPane(i);
|
| 1218 |
1398 |
if (!pane) continue;
|
| 1219 |
1399 |
|
| 1220 |
|
Model *model = selectExistingModeLayer(pane, name);
|
|
1400 |
if (!selectExistingModeLayer(pane, name)) continue;
|
|
1401 |
Model *model = m_document->getMainModel();
|
| 1221 |
1402 |
if (!model) continue;
|
| 1222 |
1403 |
|
| 1223 |
1404 |
Layer *newLayer = m_document->createLayer
|