summaryrefslogtreecommitdiff
path: root/muse2/muse/app.cpp
diff options
context:
space:
mode:
authorFlorian Jung <flo@windfisch.org>2011-06-27 18:23:39 +0000
committerFlorian Jung <flo@windfisch.org>2011-06-27 18:23:39 +0000
commit933aeb536f3d90eb38bc96308de628eeedd81755 (patch)
tree471aba95c16c939c696a4301ce2be45a7e583789 /muse2/muse/app.cpp
parentd1b2d6ec4fe4206182e0cead1e734adfc3ae6df6 (diff)
parent637498c87bf1ac780d8527d0596936fcdd2c6dfc (diff)
merged stuff from experimental back to trunk:
- massively speeded up muse by using operation groups - changed behaviour of mid-click to "delete" in all canvases
Diffstat (limited to 'muse2/muse/app.cpp')
-rw-r--r--muse2/muse/app.cpp515
1 files changed, 31 insertions, 484 deletions
diff --git a/muse2/muse/app.cpp b/muse2/muse/app.cpp
index 89947102..fb07955f 100644
--- a/muse2/muse/app.cpp
+++ b/muse2/muse/app.cpp
@@ -54,6 +54,7 @@
#include "tools.h"
#include "visibletracks.h"
#include "widgets/unusedwavefiles.h"
+#include "functions.h"
#ifdef DSSI_SUPPORT
#include "dssihost.h"
@@ -105,13 +106,6 @@ int watchAudio, watchAudioPrefetch, watchMidi;
pthread_t splashThread;
-//PyScript *pyscript;
-// void MusE::runPythonScript()
-// {
-// QString script("test.py");
-// // pyscript->runPythonScript(script);
-// }
-
void MusE::clearScoreMenuMappers()
{
@@ -137,127 +131,12 @@ void microSleep(long msleep)
sleepOk=usleep(msleep);
}
-// Removed p3.3.17
-/*
-//---------------------------------------------------------
-// watchdog thread
-//---------------------------------------------------------
-
-static void* watchdog(void*)
- {
- doSetuid();
-
- struct sched_param rt_param;
- memset(&rt_param, 0, sizeof(rt_param));
- rt_param.sched_priority = sched_get_priority_max(SCHED_FIFO);
- int rv = pthread_setschedparam(pthread_self(), SCHED_FIFO, &rt_param);
- if (rv != 0)
- perror("Set realtime scheduler");
-
- int policy;
- if (pthread_getschedparam(pthread_self(), &policy, &rt_param)!= 0) {
- printf("Cannot get current client scheduler: %s\n", strerror(errno));
- }
- if (policy != SCHED_FIFO)
- printf("watchdog process %d _NOT_ running SCHED_FIFO\n", getpid());
- else if (debugMsg)
- printf("watchdog set to SCHED_FIFO priority %d\n",
- sched_get_priority_max(SCHED_FIFO));
-
- undoSetuid();
- int fatal = 0;
- for (;;) {
- watchAudio = 0;
- watchMidi = 0;
- static const int WD_TIMEOUT = 3;
-
- // sleep can be interrpted by signals:
- int to = WD_TIMEOUT;
- while (to > 0)
- to = sleep(to);
-
- bool timeout = false;
- if (midiSeqRunning && watchMidi == 0)
- {
- printf("midiSeqRunning = %i watchMidi %i\n", midiSeqRunning, watchMidi);
- timeout = true;
- }
- if (watchAudio == 0)
- timeout = true;
- if (watchAudio > 500000)
- timeout = true;
- if (timeout)
- ++fatal;
- else
- fatal = 0;
- if (fatal >= 3) {
- printf("WatchDog: fatal error, realtime task timeout\n");
- printf(" (%d,%d-%d) - stopping all services\n",
- watchMidi, watchAudio, fatal);
- break;
- }
-// printf("wd %d %d %d\n", watchMidi, watchAudio, fatal);
- }
- audio->stop(true);
- audioPrefetch->stop(true);
- printf("watchdog exit\n");
- exit(-1);
- }
-*/
-
//---------------------------------------------------------
// seqStart
//---------------------------------------------------------
bool MusE::seqStart()
{
- // Changed by Tim. p3.3.17
-
- /*
- if (audio->isRunning()) {
- printf("seqStart(): already running\n");
- return true;
- }
-
- if (realTimeScheduling) {
- //
- // create watchdog thread with max priority
- //
- doSetuid();
- struct sched_param rt_param;
- memset(&rt_param, 0, sizeof(rt_param));
- rt_param.sched_priority = realTimePriority +1;//sched_get_priority_max(SCHED_FIFO);
-
- pthread_attr_t* attributes = (pthread_attr_t*) malloc(sizeof(pthread_attr_t));
- pthread_attr_init(attributes);
-
-// if (pthread_attr_setschedpolicy(attributes, SCHED_FIFO)) {
-// printf("MusE: cannot set FIFO scheduling class for RT thread\n");
-// }
-// if (pthread_attr_setschedparam (attributes, &rt_param)) {
-// // printf("Cannot set scheduling priority for RT thread (%s)\n", strerror(errno));
-// }
-// if (pthread_attr_setscope (attributes, PTHREAD_SCOPE_SYSTEM)) {
-// printf("MusE: Cannot set scheduling scope for RT thread\n");
-// }
- if (pthread_create(&watchdogThread, attributes, ::watchdog, 0))
- perror("MusE: creating watchdog thread failed:");
- pthread_attr_destroy(attributes);
- undoSetuid();
- }
- audioPrefetch->start();
- audioPrefetch->msgSeek(0, true); // force
- midiSeqRunning = !midiSeq->start();
-
- if (!audio->start()) {
- QMessageBox::critical( muse, tr(QString("Failed to start audio!")),
- tr(QString("Was not able to start audio, check if jack is running.\n")));
- return false;
- }
-
- return true;
- */
-
if (audio->isRunning()) {
printf("seqStart(): already running\n");
return true;
@@ -274,12 +153,10 @@ bool MusE::seqStart()
//
for(int i = 0; i < 60; ++i)
{
- //if (audioState == AUDIO_START2)
if(audio->isRunning())
break;
sleep(1);
}
- //if (audioState != AUDIO_START2) {
if(!audio->isRunning())
{
QMessageBox::critical( muse, tr("Failed to start audio!"),
@@ -293,66 +170,6 @@ bool MusE::seqStart()
if(debugMsg)
printf("MusE::seqStart: getting audio driver realTimePriority:%d\n", realTimePriority);
- // Disabled by Tim. p3.3.22
- /*
- if(realTimeScheduling)
- {
- //
- // create watchdog thread with max priority
- //
- doSetuid();
- struct sched_param rt_param;
- memset(&rt_param, 0, sizeof(rt_param));
- rt_param.sched_priority = realTimePriority + 1;//sched_get_priority_max(SCHED_FIFO);
-
- pthread_attr_t* attributes = (pthread_attr_t*) malloc(sizeof(pthread_attr_t));
- pthread_attr_init(attributes);
-
-// if (pthread_attr_setschedpolicy(attributes, SCHED_FIFO)) {
-// printf("MusE: cannot set FIFO scheduling class for RT thread\n");
-// }
-// if (pthread_attr_setschedparam (attributes, &rt_param)) {
-// // printf("Cannot set scheduling priority for RT thread (%s)\n", strerror(errno));
-// }
-// if (pthread_attr_setscope (attributes, PTHREAD_SCOPE_SYSTEM)) {
-// printf("MusE: Cannot set scheduling scope for RT thread\n");
-// }
- if (pthread_create(&watchdogThread, attributes, ::watchdog, 0))
- perror("MusE: creating watchdog thread failed");
- pthread_attr_destroy(attributes);
- undoSetuid();
- }
- */
-
- //int policy;
- //if ((policy = sched_getscheduler (0)) < 0) {
- // printf("Cannot get current client scheduler: %s\n", strerror(errno));
- // }
- //if (policy != SCHED_FIFO)
- // printf("midi thread %d _NOT_ running SCHED_FIFO\n", getpid());
-
-
- //audioState = AUDIO_RUNNING;
- // Changed by Tim. p3.3.22
- /*
- //if(realTimePriority)
- if(realTimeScheduling)
- {
- int pr = realTimePriority;
- if(pr > 5)
- pr -= 5;
- else
- pr = 0;
- audioPrefetch->start(pr);
- //audioWriteback->start(realTimePriority - 5);
- }
- else
- {
- audioPrefetch->start(0);
- //audioWriteback->start(0);
- }
- */
-
int pfprio = 0;
int midiprio = 0;
@@ -362,52 +179,6 @@ bool MusE::seqStart()
// in JackAudioDevice::realtimePriority() which is a bit flawed - it reports there's no RT...
if(realTimeScheduling)
{
- //if(realTimePriority < 5)
- // printf("MusE: WARNING: Recommend setting audio realtime priority to a higher value!\n");
- /*
- if(realTimePriority == 0)
- {
- pfprio = 1;
- midiprio = 2;
- }
- else
- if(realTimePriority == 1)
- {
- pfprio = 2;
- midiprio = 3;
- }
- else
- if(realTimePriority == 2)
- {
- pfprio = 1;
- midiprio = 3;
- }
- else
- if(realTimePriority == 3)
- {
- pfprio = 1;
- //midiprio = 2;
- // p3.3.37
- midiprio = 4;
- }
- else
- if(realTimePriority == 4)
- {
- pfprio = 1;
- //midiprio = 3;
- // p3.3.37
- midiprio = 5;
- }
- else
- if(realTimePriority == 5)
- {
- pfprio = 1;
- //midiprio = 3;
- // p3.3.37
- midiprio = 6;
- }
- else
- */
{
//pfprio = realTimePriority - 5;
// p3.3.40
@@ -536,16 +307,6 @@ void addProject(const QString& name)
// populateAddSynth
//---------------------------------------------------------
-/*
-struct addSynth_cmp_str
-{
- bool operator()(std::string a, std::string b)
- {
- return (a < b);
- }
-};
-*/
-
// ORCAN - CHECK
QMenu* populateAddSynth(QWidget* parent)
{
@@ -977,6 +738,10 @@ MusE::MusE(int argc, char** argv) : QMainWindow()
editPaste2TrackAction = new QAction(QIcon(*editpaste2TrackIconSet), tr("Paste to &track"), this);
editPasteC2TAction = new QAction(QIcon(*editpasteClone2TrackIconSet), tr("Paste clone to trac&k"), this);
editDeleteSelectedAction = new QAction(QIcon(*edit_track_delIcon), tr("Delete Selected Tracks"), this);
+
+ editShrinkPartsAction = new QAction(tr("Shrink selected parts"), this); //FINDMICH TODO tooltips!
+ editExpandPartsAction = new QAction(tr("Expand selected parts"), this);
+ editCleanPartsAction = new QAction(tr("Clean selected parts"), this);
addTrack = new QMenu(tr("Add Track"), this);
@@ -1127,6 +892,10 @@ MusE::MusE(int argc, char** argv) : QMainWindow()
connect(editPasteC2TAction, SIGNAL(triggered()), editSignalMapper, SLOT(map()));
connect(editDeleteSelectedAction, SIGNAL(triggered()), editSignalMapper, SLOT(map()));
+ connect(editShrinkPartsAction, SIGNAL(triggered()), editSignalMapper, SLOT(map()));
+ connect(editExpandPartsAction, SIGNAL(triggered()), editSignalMapper, SLOT(map()));
+ connect(editCleanPartsAction, SIGNAL(triggered()), editSignalMapper, SLOT(map()));
+
connect(editSelectAllAction, SIGNAL(triggered()), editSignalMapper, SLOT(map()));
connect(editDeselectAllAction, SIGNAL(triggered()), editSignalMapper, SLOT(map()));
connect(editInvertSelectionAction, SIGNAL(triggered()), editSignalMapper, SLOT(map()));
@@ -1143,6 +912,9 @@ MusE::MusE(int argc, char** argv) : QMainWindow()
editSignalMapper->setMapping(editPasteC2TAction, CMD_PASTE_CLONE_TO_TRACK);
editSignalMapper->setMapping(editInsertEMAction, CMD_INSERTMEAS);
editSignalMapper->setMapping(editDeleteSelectedAction, CMD_DELETE_TRACK);
+ editSignalMapper->setMapping(editShrinkPartsAction, CMD_SHRINK_PART);
+ editSignalMapper->setMapping(editExpandPartsAction, CMD_EXPAND_PART);
+ editSignalMapper->setMapping(editCleanPartsAction, CMD_CLEAN_PART);
editSignalMapper->setMapping(editSelectAllAction, CMD_SELECT_ALL);
editSignalMapper->setMapping(editDeselectAllAction, CMD_SELECT_NONE);
editSignalMapper->setMapping(editInvertSelectionAction, CMD_SELECT_INVERT);
@@ -1314,12 +1086,6 @@ MusE::MusE(int argc, char** argv) : QMainWindow()
// Popups
//---------------------------------------------------
-// QPopupMenu *foo = new QPopupMenu(this);
-// testAction = new QAction(foo,"testPython");
-// testAction->addTo(foo);
-// menuBar()->insertItem(tr("&testpython"), foo);
-// connect(testAction, SIGNAL(activated()), this, SLOT(runPythonScript()));
-
//-------------------------------------------------------------
// popup File
@@ -1361,6 +1127,10 @@ MusE::MusE(int argc, char** argv) : QMainWindow()
menuEdit->addAction(editPaste2TrackAction);
menuEdit->addAction(editPasteC2TAction);
menuEdit->addSeparator();
+ menuEdit->addAction(editShrinkPartsAction);
+ menuEdit->addAction(editExpandPartsAction);
+ menuEdit->addAction(editCleanPartsAction);
+ menuEdit->addSeparator();
menuEdit->addAction(editDeleteSelectedAction);
// Moved below. Have to wait until synths are available...
@@ -1389,20 +1159,14 @@ MusE::MusE(int argc, char** argv) : QMainWindow()
menuEdit->addMenu(midiEdit);
-#if 0 // TODO
- midiEdit->insertItem(tr("Modify Gate Time"), this, SLOT(modifyGateTime()));
- midiEdit->insertItem(tr("Modify Velocity"), this, SLOT(modifyVelocity()));
- midiEdit->insertItem(tr("Crescendo"), this, SLOT(crescendo()));
- midiEdit->insertItem(tr("Thin Out"), this, SLOT(thinOut()));
- midiEdit->insertItem(tr("Erase Event"), this, SLOT(eraseEvent()));
- midiEdit->insertItem(tr("Note Shift"), this, SLOT(noteShift()));
- midiEdit->insertItem(tr("Move Clock"), this, SLOT(moveClock()));
- midiEdit->insertItem(tr("Copy Measure"), this, SLOT(copyMeasure()));
+/* commented out by flo: these are not implemented,
+ but maybe will be in future (state: revision 988)
+ midiEdit->insertItem(tr("Copy Measure"), this, SLOT(copyMeasure()));
midiEdit->insertItem(tr("Erase Measure"), this, SLOT(eraseMeasure()));
midiEdit->insertItem(tr("Delete Measure"), this, SLOT(deleteMeasure()));
midiEdit->insertItem(tr("Create Measure"), this, SLOT(createMeasure()));
midiEdit->insertItem(tr("Mix Track"), this, SLOT(mixTrack()));
-#endif
+*/
midiEdit->addAction(midiTransformerAction);
menuEdit->addAction(editSongInfoAction);
@@ -1622,9 +1386,6 @@ MusE::MusE(int argc, char** argv) : QMainWindow()
MusE::~MusE()
{
- //printf("MusE::~MusE\n");
- //if(transport)
- // delete transport;
}
//---------------------------------------------------------
@@ -1948,37 +1709,6 @@ void MusE::setUntitledProject()
void MusE::setConfigDefaults()
{
readConfiguration(); // used for reading midi files
-#if 0
- if (readConfiguration()) {
- //
- // failed to load config file
- // set buildin defaults
- //
- configTransportVisible = false;
- configBigTimeVisible = false;
-
- for (int channel = 0; channel < 2; ++channel)
- song->addTrack(Track::AUDIO_GROUP);
- AudioTrack* out = (AudioTrack*)song->addTrack(Track::AUDIO_OUTPUT);
- AudioTrack* in = (AudioTrack*)song->addTrack(Track::AUDIO_INPUT);
-
- // set some default routes
- std::list<QString> il = audioDevice->inputPorts();
- int channel = 0;
- for (std::list<QString>::iterator i = il.begin(); i != il.end(); ++i, ++channel) {
- if (channel == 2)
- break;
- audio->msgAddRoute(Route(out,channel), Route(*i,channel));
- }
- channel = 0;
- std::list<QString> ol = audioDevice->outputPorts();
- for (std::list<QString>::iterator i = ol.begin(); i != ol.end(); ++i, ++channel) {
- if (channel == 2)
- break;
- audio->msgAddRoute(Route(*i, channel), Route(in,channel));
- }
- }
-#endif
song->dirty = false;
}
@@ -2971,14 +2701,13 @@ void MusE::cmd(int cmd)
arranger->cmd(Arranger::CMD_INSERT_EMPTYMEAS);
break;
case CMD_DELETE:
- song->startUndo();
- if (song->msgRemoveParts()) {
- song->endUndo(SC_PART_REMOVED);
- break;
- }
- else
- audio->msgRemoveTracks();
- song->endUndo(SC_TRACK_REMOVED);
+ if (!song->msgRemoveParts()) //automatically does undo if neccessary and returns true then
+ {
+ //msgRemoveParts() returned false -> no parts to remove?
+ song->startUndo();
+ audio->msgRemoveTracks(); //TODO FINDME this could still be speeded up!
+ song->endUndo(SC_TRACK_REMOVED);
+ }
break;
case CMD_DELETE_TRACK:
song->startUndo();
@@ -3047,6 +2776,10 @@ void MusE::cmd(int cmd)
song->setFollow(Song::CONTINUOUS);
setFollow();
break;
+
+ case CMD_SHRINK_PART: shrink_parts(); break;
+ case CMD_EXPAND_PART: expand_parts(); break;
+ case CMD_CLEAN_PART: clean_parts(); break;
}
}
@@ -3056,37 +2789,12 @@ void MusE::cmd(int cmd)
void MusE::clipboardChanged()
{
-/*
- //Q3CString subtype("partlist");
- //QString subtype("partlist");
- QMimeSource* ms = QApplication::clipboard()->data(QClipboard::Clipboard);
- if (ms == 0)
- return;
- bool flag = false;
- for (int i = 0; ms->format(i); ++i) {
-// printf("Format <%s\n", ms->format(i));
- if ((strncmp(ms->format(i), "text/midipartlist", 17) == 0)
- || (strncmp(ms->format(i), "text/wavepartlist", 17) == 0)
- // Added by T356. Support mixed .mpt files.
- || (strncmp(ms->format(i), "text/mixedpartlist", 18) == 0)) {
- flag = true;
- break;
- }
- }
-*/
-
bool flag = false;
if(QApplication::clipboard()->mimeData()->hasFormat(QString("text/x-muse-midipartlist")) ||
QApplication::clipboard()->mimeData()->hasFormat(QString("text/x-muse-wavepartlist")) ||
QApplication::clipboard()->mimeData()->hasFormat(QString("text/x-muse-mixedpartlist")))
flag = true;
- //bool flag = false;
- //if(!QApplication::clipboard()->text(QString("x-muse-midipartlist"), QClipboard::Clipboard).isEmpty() ||
- // !QApplication::clipboard()->text(QString("x-muse-wavepartlist"), QClipboard::Clipboard).isEmpty() ||
- // !QApplication::clipboard()->text(QString("x-muse-mixedpartlist"), QClipboard::Clipboard).isEmpty())
- // flag = true;
-
editPasteAction->setEnabled(flag);
editInsertAction->setEnabled(flag);
editPasteCloneAction->setEnabled(flag);
@@ -3107,113 +2815,6 @@ void MusE::selectionChanged()
}
-//---------------------------------------------------------
-// modifyGateTime
-//---------------------------------------------------------
-
-void MusE::modifyGateTime()
- {
- printf("not implemented\n");
- }
-
-//---------------------------------------------------------
-// modifyVelocity
-//---------------------------------------------------------
-
-void MusE::modifyVelocity()
- {
- printf("not implemented\n");
- }
-
-//---------------------------------------------------------
-// crescendo
-//---------------------------------------------------------
-
-void MusE::crescendo()
- {
- printf("not implemented\n");
- }
-
-//---------------------------------------------------------
-// thinOut
-//---------------------------------------------------------
-
-void MusE::thinOut()
- {
- printf("not implemented\n");
- }
-
-//---------------------------------------------------------
-// eraseEvent
-//---------------------------------------------------------
-
-void MusE::eraseEvent()
- {
- printf("not implemented\n");
- }
-
-//---------------------------------------------------------
-// noteShift
-//---------------------------------------------------------
-
-void MusE::noteShift()
- {
- printf("not implemented\n");
- }
-
-//---------------------------------------------------------
-// moveClock
-//---------------------------------------------------------
-
-void MusE::moveClock()
- {
- printf("not implemented\n");
- }
-
-//---------------------------------------------------------
-// copyMeasure
-//---------------------------------------------------------
-
-void MusE::copyMeasure()
- {
- printf("not implemented\n");
- }
-
-//---------------------------------------------------------
-// eraseMeasure
-//---------------------------------------------------------
-
-void MusE::eraseMeasure()
- {
- printf("not implemented\n");
- }
-
-//---------------------------------------------------------
-// deleteMeasure
-//---------------------------------------------------------
-
-void MusE::deleteMeasure()
- {
- printf("not implemented\n");
- }
-
-//---------------------------------------------------------
-// createMeasure
-//---------------------------------------------------------
-
-void MusE::createMeasure()
- {
- printf("not implemented\n");
- }
-
-//---------------------------------------------------------
-// mixTrack
-//---------------------------------------------------------
-
-void MusE::mixTrack()
- {
- printf("not implemented\n");
- }
//---------------------------------------------------------
// configAppearance
@@ -3813,19 +3414,6 @@ void MusE::updateConfiguration()
//menuSettings->setAccel(shortcuts[SHRT_CONFIG_AUDIO_PORTS].key, menu_ids[CMD_CONFIG_AUDIO_PORTS]);
//menu_help->setAccel(menu_ids[CMD_START_WHATSTHIS], shortcuts[SHRT_START_WHATSTHIS].key);
- // Just in case, but no, app kb handler takes care of these.
- /*
- loopAction->setShortcut(shortcuts[].key);
- punchinAction->setShortcut(shortcuts[].key);
- punchoutAction->setShortcut(shortcuts[].key);
- startAction->setShortcut(shortcuts[].key);
- rewindAction->setShortcut(shortcuts[].key);
- forwardAction->setShortcut(shortcuts[].key);
- stopAction->setShortcut(shortcuts[].key);
- playAction->setShortcut(shortcuts[].key);
- recordAction->setShortcut(shortcuts[].key);
- panicAction->setShortcut(shortcuts[].key);
- */
}
//---------------------------------------------------------
@@ -3866,24 +3454,6 @@ void MusE::bigtimeClosed()
viewBigtimeAction->setChecked(false);
}
-//---------------------------------------------------------
-// showMixer
-//---------------------------------------------------------
-
-/*
-void MusE::showMixer(bool on)
- {
- if (on && audioMixer == 0) {
- audioMixer = new AudioMixerApp(this);
- connect(audioMixer, SIGNAL(closed()), SLOT(mixerClosed()));
- audioMixer->resize(config.geometryMixer.size());
- audioMixer->move(config.geometryMixer.topLeft());
- }
- if (audioMixer)
- audioMixer->setVisible(on);
- menuView->setItemChecked(aid1, on);
- }
-*/
//---------------------------------------------------------
// showMixer1
@@ -3920,17 +3490,6 @@ void MusE::showMixer2(bool on)
}
//---------------------------------------------------------
-// toggleMixer
-//---------------------------------------------------------
-
-/*
-void MusE::toggleMixer()
- {
- showMixer(!menuView->isItemChecked(aid1));
- }
-*/
-
-//---------------------------------------------------------
// toggleMixer1
//---------------------------------------------------------
@@ -3949,17 +3508,6 @@ void MusE::toggleMixer2(bool checked)
}
//---------------------------------------------------------
-// mixerClosed
-//---------------------------------------------------------
-
-/*
-void MusE::mixerClosed()
- {
- menuView->setItemChecked(aid1, false);
- }
-*/
-
-//---------------------------------------------------------
// mixer1Closed
//---------------------------------------------------------
@@ -3978,7 +3526,6 @@ void MusE::mixer2Closed()
}
-//QWidget* MusE::mixerWindow() { return audioMixer; }
QWidget* MusE::mixer1Window() { return mixer1; }
QWidget* MusE::mixer2Window() { return mixer2; }