summaryrefslogtreecommitdiff
path: root/muse2/muse
diff options
context:
space:
mode:
authorFlorian Jung <flo@windfisch.org>2012-03-15 18:21:23 +0000
committerFlorian Jung <flo@windfisch.org>2012-03-15 18:21:23 +0000
commit27b7bf6815cda7abb67026c37b3e44daee1803cb (patch)
tree0b9d1c0bc84ac7ff8032e707f2b5fb4e0aaabb5c /muse2/muse
parent2d6f113a10eb485694e20a78500f650776d701e3 (diff)
merged with trunk
Diffstat (limited to 'muse2/muse')
-rw-r--r--muse2/muse/app.cpp375
-rw-r--r--muse2/muse/app.h23
-rw-r--r--muse2/muse/appearance.cpp193
-rw-r--r--muse2/muse/appearance.h1
-rw-r--r--muse2/muse/arranger/alayout.cpp26
-rw-r--r--muse2/muse/arranger/alayout.h9
-rw-r--r--muse2/muse/arranger/arranger.cpp158
-rw-r--r--muse2/muse/arranger/arranger.h43
-rw-r--r--muse2/muse/arranger/arrangerview.cpp10
-rw-r--r--muse2/muse/arranger/pcanvas.cpp164
-rw-r--r--muse2/muse/arranger/pcanvas.h5
-rw-r--r--muse2/muse/arranger/tlist.cpp225
-rw-r--r--muse2/muse/arranger/tlist.h6
-rw-r--r--muse2/muse/audio.cpp145
-rw-r--r--muse2/muse/audio.h26
-rw-r--r--muse2/muse/audioconvert.cpp102
-rw-r--r--muse2/muse/audioconvert.h27
-rw-r--r--muse2/muse/audioprefetch.cpp39
-rw-r--r--muse2/muse/audioprefetch.h4
-rw-r--r--muse2/muse/audiotrack.cpp121
-rw-r--r--muse2/muse/cliplist/cliplist.cpp15
-rw-r--r--muse2/muse/cobject.cpp24
-rw-r--r--muse2/muse/cobject.h4
-rw-r--r--muse2/muse/conf.cpp179
-rw-r--r--muse2/muse/confmport.cpp445
-rw-r--r--muse2/muse/confmport.h1
-rw-r--r--muse2/muse/controlfifo.cpp3
-rw-r--r--muse2/muse/ctrl.cpp85
-rw-r--r--muse2/muse/ctrl.h5
-rw-r--r--muse2/muse/ctrl/ctrlcanvas.cpp149
-rw-r--r--muse2/muse/ctrl/ctrlcanvas.h20
-rw-r--r--muse2/muse/ctrl/ctrledit.cpp20
-rw-r--r--muse2/muse/ctrl/ctrledit.h2
-rw-r--r--muse2/muse/ctrl/ctrlpanel.cpp63
-rw-r--r--muse2/muse/ctrl/ctrlpanel.h2
-rw-r--r--muse2/muse/driver/alsamidi.cpp373
-rw-r--r--muse2/muse/driver/alsamidi.h14
-rw-r--r--muse2/muse/driver/alsatimer.cpp2
-rw-r--r--muse2/muse/driver/jack.cpp720
-rw-r--r--muse2/muse/driver/jackaudio.h12
-rw-r--r--muse2/muse/driver/jackmidi.cpp444
-rw-r--r--muse2/muse/driver/jackmidi.h4
-rw-r--r--muse2/muse/driver/rtctimer.cpp4
-rw-r--r--muse2/muse/driver/rtctimer.h22
-rw-r--r--muse2/muse/dssihost.cpp234
-rw-r--r--muse2/muse/dssihost.h64
-rw-r--r--muse2/muse/evdata.h1
-rw-r--r--muse2/muse/event.cpp5
-rw-r--r--muse2/muse/event.h4
-rw-r--r--muse2/muse/eventbase.h9
-rw-r--r--muse2/muse/eventlist.cpp3
-rw-r--r--muse2/muse/exportmidi.cpp29
-rw-r--r--muse2/muse/functions.cpp2
-rw-r--r--muse2/muse/gconfig.cpp6
-rw-r--r--muse2/muse/gconfig.h8
-rw-r--r--muse2/muse/globals.cpp33
-rw-r--r--muse2/muse/globals.h5
-rw-r--r--muse2/muse/gui.h21
-rw-r--r--muse2/muse/help.cpp1
-rw-r--r--muse2/muse/helper.cpp101
-rw-r--r--muse2/muse/importmidi.cpp32
-rw-r--r--muse2/muse/instruments/editinstrument.cpp708
-rw-r--r--muse2/muse/instruments/editinstrument.h5
-rw-r--r--muse2/muse/instruments/midictrledit.cpp34
-rw-r--r--muse2/muse/instruments/minstrument.cpp201
-rw-r--r--muse2/muse/instruments/minstrument.h3
-rw-r--r--muse2/muse/liste/editevent.cpp31
-rw-r--r--muse2/muse/liste/editevent.h5
-rw-r--r--muse2/muse/liste/listedit.cpp15
-rw-r--r--muse2/muse/main.cpp71
-rw-r--r--muse2/muse/marker/marker.cpp1
-rw-r--r--muse2/muse/marker/markerview.cpp28
-rw-r--r--muse2/muse/marker/markerview.h2
-rw-r--r--muse2/muse/master/lmaster.cpp71
-rw-r--r--muse2/muse/master/lmaster.h4
-rw-r--r--muse2/muse/master/master.cpp2
-rw-r--r--muse2/muse/master/masteredit.cpp88
-rw-r--r--muse2/muse/master/masteredit.h4
-rw-r--r--muse2/muse/master/tscale.cpp4
-rw-r--r--muse2/muse/memory.cpp5
-rw-r--r--muse2/muse/midi.cpp31
-rw-r--r--muse2/muse/midi.h3
-rw-r--r--muse2/muse/midictrl.cpp63
-rw-r--r--muse2/muse/midictrl.h14
-rw-r--r--muse2/muse/mididev.cpp173
-rw-r--r--muse2/muse/mididev.h13
-rw-r--r--muse2/muse/midiedit/dcanvas.cpp18
-rw-r--r--muse2/muse/midiedit/dlist.cpp10
-rw-r--r--muse2/muse/midiedit/dlist.h2
-rw-r--r--muse2/muse/midiedit/drumedit.cpp82
-rw-r--r--muse2/muse/midiedit/drumedit.h2
-rw-r--r--muse2/muse/midiedit/drummap.cpp94
-rw-r--r--muse2/muse/midiedit/drummap.h1
-rw-r--r--muse2/muse/midiedit/ecanvas.cpp12
-rw-r--r--muse2/muse/midiedit/ecanvas.h1
-rw-r--r--muse2/muse/midiedit/piano.cpp8
-rw-r--r--muse2/muse/midiedit/pianoroll.cpp95
-rw-r--r--muse2/muse/midiedit/pianoroll.h9
-rw-r--r--muse2/muse/midiedit/prcanvas.cpp62
-rw-r--r--muse2/muse/midiedit/scoreedit.cpp142
-rw-r--r--muse2/muse/midiedit/scoreedit.h9
-rw-r--r--muse2/muse/midieditor.h5
-rw-r--r--muse2/muse/midievent.cpp7
-rw-r--r--muse2/muse/midievent.h1
-rw-r--r--muse2/muse/midifile.cpp11
-rw-r--r--muse2/muse/midiport.cpp328
-rw-r--r--muse2/muse/midiport.h3
-rw-r--r--muse2/muse/midiseq.cpp201
-rw-r--r--muse2/muse/midiseq.h17
-rw-r--r--muse2/muse/miditransform.cpp9
-rw-r--r--muse2/muse/miditransform.h1
-rw-r--r--muse2/muse/mixer/astrip.cpp10
-rw-r--r--muse2/muse/mixer/mstrip.cpp45
-rw-r--r--muse2/muse/mixer/rack.cpp3
-rw-r--r--muse2/muse/mpevent.cpp8
-rw-r--r--muse2/muse/mpevent.h14
-rw-r--r--muse2/muse/node.cpp159
-rw-r--r--muse2/muse/node.h3
-rw-r--r--muse2/muse/osc.cpp226
-rw-r--r--muse2/muse/osc.h27
-rw-r--r--muse2/muse/part.cpp365
-rw-r--r--muse2/muse/plugin.cpp629
-rw-r--r--muse2/muse/plugin.h79
-rw-r--r--muse2/muse/pos.cpp6
-rw-r--r--muse2/muse/remote/pyapi.cpp3
-rw-r--r--muse2/muse/route.cpp91
-rw-r--r--muse2/muse/route.h12
-rw-r--r--muse2/muse/seqmsg.cpp66
-rw-r--r--muse2/muse/shortcuts.h2
-rw-r--r--muse2/muse/sig.cpp11
-rw-r--r--muse2/muse/sig.h6
-rw-r--r--muse2/muse/song.cpp443
-rw-r--r--muse2/muse/song.h6
-rw-r--r--muse2/muse/songfile.cpp161
-rw-r--r--muse2/muse/stringparam.h12
-rw-r--r--muse2/muse/structure.cpp3
-rw-r--r--muse2/muse/style.qss4
-rw-r--r--muse2/muse/sync.cpp146
-rw-r--r--muse2/muse/sync.h20
-rw-r--r--muse2/muse/synth.cpp137
-rw-r--r--muse2/muse/synth.h50
-rw-r--r--muse2/muse/tempo.cpp17
-rw-r--r--muse2/muse/tempo.h1
-rw-r--r--muse2/muse/thread.cpp38
-rw-r--r--muse2/muse/thread.h5
-rw-r--r--muse2/muse/ticksynth.cpp13
-rw-r--r--muse2/muse/track.cpp83
-rw-r--r--muse2/muse/track.h39
-rw-r--r--muse2/muse/transport.cpp24
-rw-r--r--muse2/muse/transport.h1
-rw-r--r--muse2/muse/undo.cpp60
-rw-r--r--muse2/muse/vst.cpp7
-rw-r--r--muse2/muse/vst.h4
-rw-r--r--muse2/muse/wave.cpp46
-rw-r--r--muse2/muse/wave.h2
-rw-r--r--muse2/muse/waveedit/waveedit.cpp8
-rw-r--r--muse2/muse/waveevent.cpp28
-rw-r--r--muse2/muse/waveevent.h15
-rw-r--r--muse2/muse/wavetrack.cpp55
-rw-r--r--muse2/muse/widgets/CMakeLists.txt2
-rw-r--r--muse2/muse/widgets/doublespinbox.cpp102
-rw-r--r--muse2/muse/widgets/doublespinbox.h73
-rw-r--r--muse2/muse/widgets/fdialogbuttons.ui25
-rw-r--r--muse2/muse/widgets/filedialog.cpp11
-rw-r--r--muse2/muse/widgets/filedialog.h2
-rw-r--r--muse2/muse/widgets/genset.cpp145
-rw-r--r--muse2/muse/widgets/gensetbase.ui43
-rw-r--r--muse2/muse/widgets/knob.cpp1
-rw-r--r--muse2/muse/widgets/midisync.ui2
-rw-r--r--muse2/muse/widgets/mtrackinfo.cpp67
-rw-r--r--muse2/muse/widgets/mtrackinfo.h4
-rw-r--r--muse2/muse/widgets/mtrackinfobase.ui12
-rw-r--r--muse2/muse/widgets/musewidgetsplug.cpp3
-rw-r--r--muse2/muse/widgets/noteinfo.cpp28
-rw-r--r--muse2/muse/widgets/noteinfo.h15
-rw-r--r--muse2/muse/widgets/pitchedit.cpp2
-rw-r--r--muse2/muse/widgets/pitchedit.h4
-rw-r--r--muse2/muse/widgets/projectcreate.ui321
-rw-r--r--muse2/muse/widgets/projectcreateimpl.cpp19
-rw-r--r--muse2/muse/widgets/projectcreateimpl.h5
-rw-r--r--muse2/muse/widgets/routepopup.cpp4
-rw-r--r--muse2/muse/widgets/spinbox.cpp109
-rw-r--r--muse2/muse/widgets/spinbox.h45
-rw-r--r--muse2/muse/widgets/tb1.cpp3
-rw-r--r--muse2/muse/widgets/tempolabel.cpp2
-rw-r--r--muse2/muse/widgets/tempolabel.h4
-rw-r--r--muse2/muse/xml.cpp28
187 files changed, 3747 insertions, 8108 deletions
diff --git a/muse2/muse/app.cpp b/muse2/muse/app.cpp
index 7e412c25..d9d5a1d9 100644
--- a/muse2/muse/app.cpp
+++ b/muse2/muse/app.cpp
@@ -36,6 +36,7 @@
#include <QMdiSubWindow>
#include <QSocketNotifier>
#include <QString>
+#include <QStyleFactory>
#include <iostream>
@@ -52,6 +53,7 @@
#include "bigtime.h"
#include "cliplist/cliplist.h"
#include "conf.h"
+#include "config.h"
#include "debug.h"
#include "didyouknow.h"
#include "drumedit.h"
@@ -109,12 +111,10 @@ static QString* projectList[PROJECT_LIST_LEN];
#ifdef HAVE_LASH
#include <lash/lash.h>
-#include <lo/lo_osc_types.h>
lash_client_t * lash_client = 0;
-extern snd_seq_t * alsaSeq;
#endif /* HAVE_LASH */
-int watchAudio, watchAudioPrefetch, watchMidi;
+int watchAudioPrefetch, watchMidi;
pthread_t splashThread;
@@ -190,12 +190,6 @@ bool MusE::seqStart()
midiprio = MusEGlobal::midiRTPrioOverride;
// FIXME FIXME: The MusEGlobal::realTimePriority of the Jack thread seems to always be 5 less than the value passed to jackd command.
- //if(midiprio == MusEGlobal::realTimePriority)
- // printf("MusE: WARNING: Midi realtime priority %d is the same as audio realtime priority %d. Try a different setting.\n",
- // midiprio, MusEGlobal::realTimePriority);
- //if(midiprio == pfprio)
- // printf("MusE: WARNING: Midi realtime priority %d is the same as audio prefetch realtime priority %d. Try a different setting.\n",
- // midiprio, pfprio);
MusEGlobal::audioPrefetch->start(pfprio);
@@ -205,7 +199,6 @@ bool MusE::seqStart()
int counter=0;
while (++counter) {
- //if (counter > 10) {
if (counter > 1000) {
fprintf(stderr,"midi sequencer thread does not start!? Exiting...\n");
exit(33);
@@ -299,14 +292,10 @@ void addProject(const QString& name)
// MusE
//---------------------------------------------------------
-//MusE::MusE(int argc, char** argv) : QMainWindow(0, "mainwindow")
MusE::MusE(int /*argc*/, char** /*argv*/) : QMainWindow()
{
- // By T356. For LADSPA plugins in plugin.cpp
- // QWidgetFactory::addWidgetFactory( new PluginWidgetFactory ); ddskrjo
setIconSize(ICON_SIZE);
- setFocusPolicy(Qt::WheelFocus);
- //setFocusPolicy(Qt::NoFocus);
+ setFocusPolicy(Qt::NoFocus);
MusEGlobal::muse = this; // hack
clipListEdit = 0;
midiSyncConfig = 0;
@@ -428,7 +417,7 @@ MusE::MusE(int /*argc*/, char** /*argv*/) : QMainWindow()
connect(MusEGlobal::rewindAction, SIGNAL(activated()), MusEGlobal::song, SLOT(rewind()));
MusEGlobal::forwardAction = new QAction(QIcon(*MusEGui::fforwardIcon),
- tr("Forward"), MusEGlobal::transportAction);
+ tr("Forward"), MusEGlobal::transportAction);
MusEGlobal::forwardAction->setWhatsThis(tr("move current position"));
connect(MusEGlobal::forwardAction, SIGNAL(activated()), MusEGlobal::song, SLOT(forward()));
@@ -723,9 +712,7 @@ MusE::MusE(int /*argc*/, char** /*argv*/) : QMainWindow()
optionalToolbars.push_back(transportToolbar);
optionalToolbars.push_back(panicToolbar);
-
- //rlimit lim;
- //getrlimit(RLIMIT_RTPRIO, &lim);
+ //rlimit lim; getrlimit(RLIMIT_RTPRIO, &lim);
//printf("RLIMIT_RTPRIO soft:%d hard:%d\n", lim.rlim_cur, lim.rlim_max); // Reported 80, 80 even with non-RT kernel.
if (MusEGlobal::realTimePriority < sched_get_priority_min(SCHED_FIFO))
@@ -834,10 +821,6 @@ MusE::MusE(int /*argc*/, char** /*argv*/) : QMainWindow()
menu_functions->addAction(midiResetInstAction);
menu_functions->addAction(midiInitInstActions);
menu_functions->addAction(midiLocalOffAction);
- /*
- ** mpid4 = midiInputPlugins->insertItem(
- ** QIconSet(*midi_inputplugins_random_rhythm_generatorIcon), tr("Random Rhythm Generator"), 4);
- */
//-------------------------------------------------------------
// popup Audio
@@ -917,10 +900,7 @@ MusE::MusE(int /*argc*/, char** /*argv*/) : QMainWindow()
menu_help->addSeparator();
menu_help->addAction(helpAboutAction);
- //menu_help->insertItem(tr("About&Qt"), this, SLOT(aboutQt()));
- //menu_help->addSeparator();
- //menu_ids[CMD_START_WHATSTHIS] = menu_help->insertItem(tr("What's &This?"), this, SLOT(whatsThis()), 0);
-
+ menu_help->addAction(tr("About &Qt"), qApp, SLOT(aboutQt()));
//---------------------------------------------------
// Central Widget
@@ -982,8 +962,6 @@ MusE::MusE(int /*argc*/, char** /*argv*/) : QMainWindow()
MusEGlobal::song->blockSignals(false);
- // Load start song moved to main.cpp p4.0.41 REMOVE Tim.
-
changeConfig(false);
QSettings settings("MusE", "MusE-qt");
restoreGeometry(settings.value("MusE/geometry").toByteArray());
@@ -991,7 +969,7 @@ MusE::MusE(int /*argc*/, char** /*argv*/) : QMainWindow()
MusEGlobal::song->update();
updateWindowMenu();
- // Load start song moved to main.cpp p4.0.41 REMOVE Tim.
+ // Load start song now in main.cpp
}
@@ -1024,8 +1002,7 @@ void MusE::loadDefaultSong(int argc, char** argv)
name = argv[0];
else if (MusEGlobal::config.startMode == 0) {
if (argc < 2)
- //name = projectList[0] ? *projectList[0] : QString("untitled");
- name = projectList[0] ? *projectList[0] : MusEGui::getUniqueUntitledName(); // p4.0.40
+ name = projectList[0] ? *projectList[0] : MusEGui::getUniqueUntitledName();
else
name = argv[0];
printf("starting with selected song %s\n", MusEGlobal::config.startSong.toLatin1().constData());
@@ -1039,11 +1016,7 @@ void MusE::loadDefaultSong(int argc, char** argv)
printf("starting with pre configured song %s\n", MusEGlobal::config.startSong.toLatin1().constData());
name = MusEGlobal::config.startSong;
}
- //loadProjectFile(name, useTemplate, true);
loadProjectFile(name, useTemplate, !useTemplate);
-
- //MusEGlobal::song->update();
- //updateWindowMenu();
}
//---------------------------------------------------------
@@ -1061,12 +1034,9 @@ void MusE::resetMidiDevices()
void MusE::initMidiDevices()
{
- // Added by T356
- //MusEGlobal::audio->msgIdle(true);
-
+ //MusEGlobal::audio->msgIdle(true);
MusEGlobal::audio->msgInitMidiDevices();
-
- //MusEGlobal::audio->msgIdle(false);
+ //MusEGlobal::audio->msgIdle(false);
}
//---------------------------------------------------------
@@ -1122,7 +1092,7 @@ void MusE::loadProjectFile(const QString& name, bool songTemplate, bool doReadMi
progress->setCancelButton(0);
if (!songTemplate)
progress->setMinimumDuration(0); // if we are loading a template it will probably be fast and we can wait before showing the dialog
- //progress->show();
+
//
// stop audio threads if running
//
@@ -1167,15 +1137,12 @@ void MusE::loadProjectFile(const QString& name, bool songTemplate, bool doReadMi
void MusE::loadProjectFile1(const QString& name, bool songTemplate, bool doReadMidiPorts)
{
- //if (audioMixer)
- // audioMixer->clear();
if (mixer1)
mixer1->clear();
if (mixer2)
mixer2->clear();
_arranger->clear(); // clear track info
- //if (clearSong())
- if (clearSong(doReadMidiPorts)) // Allow not touching things like midi ports. p4.0.17 TESTING: Maybe some problems...
+ if (clearSong(doReadMidiPorts)) // Allow not touching things like midi ports.
return;
progress->setValue(20);
@@ -1187,8 +1154,7 @@ void MusE::loadProjectFile1(const QString& name, bool songTemplate, bool doReadM
QApplication::restoreOverrideCursor();
return;
}
- //project.setFile("untitled");
- project.setFile(MusEGui::getUniqueUntitledName()); // p4.0.40
+ project.setFile(MusEGui::getUniqueUntitledName());
MusEGlobal::museProject = MusEGlobal::museProjectInitPath;
}
else {
@@ -1196,11 +1162,6 @@ void MusE::loadProjectFile1(const QString& name, bool songTemplate, bool doReadM
MusEGlobal::museProject = fi.absolutePath();
project.setFile(name);
}
- // Changed by T356. 01/19/2010. We want the complete extension here.
- //QString ex = fi.extension(false).toLower();
- //if (ex.length() == 3)
- // ex += ".";
- //ex = ex.left(4);
QString ex = fi.completeSuffix().toLower();
QString mex = ex.section('.', -1, -1);
if((mex == "gz") || (mex == "bz2"))
@@ -1245,7 +1206,6 @@ void MusE::loadProjectFile1(const QString& name, bool songTemplate, bool doReadM
}
if (!songTemplate) {
addProject(project.absoluteFilePath());
- //setWindowTitle(QString("MusE: Song: ") + project.completeBaseName());
setWindowTitle(QString("MusE: Song: ") + MusEGui::projectTitleFromFilename(project.absoluteFilePath()));
}
MusEGlobal::song->dirty = false;
@@ -1258,41 +1218,37 @@ void MusE::loadProjectFile1(const QString& name, bool songTemplate, bool doReadM
autoMixerAction->setChecked(MusEGlobal::automation);
- //FINDMICHJETZT does this work?
+ showBigtime(MusEGlobal::config.bigTimeVisible);
+ showMixer1(MusEGlobal::config.mixer1Visible);
+ showMixer2(MusEGlobal::config.mixer2Visible);
+
+ // Added p3.3.43 Make sure the geometry is correct because showMixerX() will NOT
+ // set the geometry if the mixer has already been created.
+ if(mixer1)
{
- showBigtime(MusEGlobal::config.bigTimeVisible);
- //showMixer(MusEGlobal::config.mixerVisible);
- showMixer1(MusEGlobal::config.mixer1Visible);
- showMixer2(MusEGlobal::config.mixer2Visible);
-
- // Added p3.3.43 Make sure the geometry is correct because showMixerX() will NOT
- // set the geometry if the mixer has already been created.
- if(mixer1)
- {
- //if(mixer1->geometry().size() != MusEGlobal::config.mixer1.geometry.size()) // Moved below
- // mixer1->resize(MusEGlobal::config.mixer1.geometry.size());
-
- if(mixer1->geometry().topLeft() != MusEGlobal::config.mixer1.geometry.topLeft())
- mixer1->move(MusEGlobal::config.mixer1.geometry.topLeft());
- }
- if(mixer2)
- {
- //if(mixer2->geometry().size() != MusEGlobal::config.mixer2.geometry.size()) // Moved below
- // mixer2->resize(MusEGlobal::config.mixer2.geometry.size());
-
- if(mixer2->geometry().topLeft() != MusEGlobal::config.mixer2.geometry.topLeft())
- mixer2->move(MusEGlobal::config.mixer2.geometry.topLeft());
- }
-
- //showMarker(MusEGlobal::config.markerVisible); // Moved below. Tim.
- resize(MusEGlobal::config.geometryMain.size());
- move(MusEGlobal::config.geometryMain.topLeft());
-
- if (MusEGlobal::config.transportVisible)
- transport->show();
- transport->move(MusEGlobal::config.geometryTransport.topLeft());
- showTransport(MusEGlobal::config.transportVisible);
+ //if(mixer1->geometry().size() != MusEGlobal::config.mixer1.geometry.size()) // Moved below
+ // mixer1->resize(MusEGlobal::config.mixer1.geometry.size());
+
+ if(mixer1->geometry().topLeft() != MusEGlobal::config.mixer1.geometry.topLeft())
+ mixer1->move(MusEGlobal::config.mixer1.geometry.topLeft());
}
+ if(mixer2)
+ {
+ //if(mixer2->geometry().size() != MusEGlobal::config.mixer2.geometry.size()) // Moved below
+ // mixer2->resize(MusEGlobal::config.mixer2.geometry.size());
+
+ if(mixer2->geometry().topLeft() != MusEGlobal::config.mixer2.geometry.topLeft())
+ mixer2->move(MusEGlobal::config.mixer2.geometry.topLeft());
+ }
+
+ //showMarker(MusEGlobal::config.markerVisible); // Moved below. Tim.
+ resize(MusEGlobal::config.geometryMain.size());
+ move(MusEGlobal::config.geometryMain.topLeft());
+
+ if (MusEGlobal::config.transportVisible)
+ transport->show();
+ transport->move(MusEGlobal::config.geometryTransport.topLeft());
+ showTransport(MusEGlobal::config.transportVisible);
progress->setValue(40);
@@ -1308,37 +1264,20 @@ void MusE::loadProjectFile1(const QString& name, bool songTemplate, bool doReadM
progress->setValue(50);
// Try this AFTER the song update above which does a mixer update... Tested OK - mixers resize properly now.
- //FINDMICHJETZT does this work?
+ if(mixer1)
{
- if(mixer1)
- {
- if(mixer1->geometry().size() != MusEGlobal::config.mixer1.geometry.size())
- {
- //printf("MusE::loadProjectFile1 resizing mixer1 x:%d y:%d w:%d h:%d\n", MusEGlobal::config.mixer1.geometry.x(),
- // MusEGlobal::config.mixer1.geometry.y(),
- // MusEGlobal::config.mixer1.geometry.width(),
- // MusEGlobal::config.mixer1.geometry.height()
- // );
- mixer1->resize(MusEGlobal::config.mixer1.geometry.size());
- }
- }
- if(mixer2)
- {
- if(mixer2->geometry().size() != MusEGlobal::config.mixer2.geometry.size())
- {
- //printf("MusE::loadProjectFile1 resizing mixer2 x:%d y:%d w:%d h:%d\n", MusEGlobal::config.mixer2.geometry.x(),
- // MusEGlobal::config.mixer2.geometry.y(),
- // MusEGlobal::config.mixer2.geometry.width(),
- // MusEGlobal::config.mixer2.geometry.height()
- // );
- mixer2->resize(MusEGlobal::config.mixer2.geometry.size());
- }
- }
-
- // Moved here from above due to crash with a song loaded and then File->New.
- // Marker view list was not updated, had non-existent items from marker list (cleared in ::clear()).
- showMarker(MusEGlobal::config.markerVisible);
- }
+ if(mixer1->geometry().size() != MusEGlobal::config.mixer1.geometry.size())
+ mixer1->resize(MusEGlobal::config.mixer1.geometry.size());
+ }
+ if(mixer2)
+ {
+ if(mixer2->geometry().size() != MusEGlobal::config.mixer2.geometry.size())
+ mixer2->resize(MusEGlobal::config.mixer2.geometry.size());
+ }
+
+ // Moved here from above due to crash with a song loaded and then File->New.
+ // Marker view list was not updated, had non-existent items from marker list (cleared in ::clear()).
+ showMarker(MusEGlobal::config.markerVisible);
if (songTemplate)
{
@@ -1370,13 +1309,11 @@ void MusE::loadProjectFile1(const QString& name, bool songTemplate, bool doReadM
void MusE::setUntitledProject()
{
setConfigDefaults();
- //QString name("untitled");
- QString name(MusEGui::getUniqueUntitledName()); // p4.0.40
-
- MusEGlobal::museProject = "./"; //QFileInfo(name).absolutePath();
+ QString name(MusEGui::getUniqueUntitledName());
+ MusEGlobal::museProject = "./";
project.setFile(name);
- //setWindowTitle(tr("MusE: Song: %1").arg(project.completeBaseName()));
setWindowTitle(tr("MusE: Song: %1").arg(MusEGui::projectTitleFromFilename(name)));
+ writeTopwinState=true;
}
//---------------------------------------------------------
@@ -1426,15 +1363,10 @@ void MusE::loadTemplate()
QString fn = MusEGui::getOpenFileName(QString("templates"), MusEGlobal::med_file_pattern, this,
tr("MusE: load template"), 0, MusEGui::MFileDialog::GLOBAL_VIEW);
if (!fn.isEmpty()) {
- // MusEGlobal::museProject = QFileInfo(fn).absolutePath();
-
- //loadProjectFile(fn, true, true);
// With templates, don't clear midi ports.
- // Any named ports in the template file are useless since they likely
- // would not be found on other users' machines.
- // So keep whatever the user currently has set up for ports.
- // Note that this will also keep the current window configurations etc.
- // but actually that's also probably a good thing. p4.0.17 Tim. TESTING: Maybe some problems...
+ // Any named ports in the template file are useless (Hm, not true...) since they likely would not be found on other users' machines.
+ // Keep whatever the user currently has set up for ports. This will also keep the current window configurations etc.
+ // but actually that's also probably a good thing.
loadProjectFile(fn, true, false);
setUntitledProject();
@@ -1447,29 +1379,20 @@ void MusE::loadTemplate()
bool MusE::save()
{
- //if (project.completeBaseName() == "untitled") // p4.0.40 Must catch "untitled 1" "untitled 2" etc
- //if (MusEGui::projectTitleFromFilename(project.absoluteFilePath()) == "untitled")
- //if (MusEGui::projectTitleFromFilename(project.absoluteFilePath()) == MusEGui::getUniqueUntitledName())
- ///if (project.absoluteFilePath() == MusEGui::getUniqueUntitledName())
if (MusEGlobal::museProject == MusEGlobal::museProjectInitPath )
return saveAs();
else
- return save(project.filePath(), false);
+ return save(project.filePath(), false, writeTopwinState);
}
//---------------------------------------------------------
// save
//---------------------------------------------------------
-bool MusE::save(const QString& name, bool overwriteWarn)
+bool MusE::save(const QString& name, bool overwriteWarn, bool writeTopwins)
{
QString backupCommand;
- // By T356. Cache the jack in/out route names BEFORE saving.
- // Because jack often shuts down during save, causing the routes to be lost in the file.
- // Not required any more...
- //cacheJackRouteNames();
-
if (QFile::exists(name)) {
backupCommand.sprintf("cp \"%s\" \"%s.backup\"", name.toLatin1().constData(), name.toLatin1().constData());
}
@@ -1484,10 +1407,9 @@ bool MusE::save(const QString& name, bool overwriteWarn)
if (f == 0)
return false;
MusECore::Xml xml(f);
- write(xml);
+ write(xml, writeTopwins);
if (ferror(f)) {
QString s = "Write File\n" + name + "\nfailed: "
- //+ strerror(errno);
+ QString(strerror(errno));
QMessageBox::critical(this,
tr("MusE: Write File failed"), s);
@@ -1558,7 +1480,6 @@ void MusE::closeEvent(QCloseEvent* event)
QSettings settings("MusE", "MusE-qt");
settings.setValue("MusE/geometry", saveGeometry());
- //settings.setValue("MusE/windowState", saveState());
writeGlobalConfiguration();
@@ -1642,7 +1563,6 @@ void MusE::toggleMarker(bool checked)
void MusE::showMarker(bool flag)
{
- //printf("showMarker %d\n",flag);
if (markerView == 0) {
markerView = new MusEGui::MarkerView(this);
@@ -1752,21 +1672,6 @@ void MusE::showTransport(bool flag)
viewTransportAction->setChecked(flag);
}
-/*
-//---------------------------------------------------------
-// getRoutingPopupMenu
-// Get the special common routing popup menu. Used (so far)
-// by audio strip, midi strip, and midi trackinfo.
-//---------------------------------------------------------
-
-MusEGui::RoutePopupMenu* MusE::()
-{
- if(!routingPopupMenu)
- routingPopupMenu = new MusEGui::RoutePopupMenu(this);
- return routingPopupMenu;
-}
-*/
-
//---------------------------------------------------------
// saveAs
//---------------------------------------------------------
@@ -1774,17 +1679,18 @@ MusEGui::RoutePopupMenu* MusE::()
bool MusE::saveAs()
{
QString name;
- //if (MusEGlobal::museProject == MusEGlobal::museProjectInitPath ) // Use project dialog always now.
if (MusEGlobal::config.useProjectSaveDialog) {
MusEGui::ProjectCreateImpl pci(MusEGlobal::muse);
+ pci.setWriteTopwins(writeTopwinState);
if (pci.exec() == QDialog::Rejected) {
return false;
}
MusEGlobal::song->setSongInfo(pci.getSongInfo(), true);
name = pci.getProjectPath();
+ writeTopwinState=pci.getWriteTopwins();
} else {
- name = MusEGui::getSaveFileName(QString(""), MusEGlobal::med_file_save_pattern, this, tr("MusE: Save As"));
+ name = MusEGui::getSaveFileName(QString(""), MusEGlobal::med_file_save_pattern, this, tr("MusE: Save As"), &writeTopwinState);
if (name.isEmpty())
return false;
}
@@ -1795,19 +1701,14 @@ bool MusE::saveAs()
QMessageBox::warning(this,"Path error","Can't create project path", QMessageBox::Ok);
return false;
}
- //}
- //else {
- // name = MusEGui::getSaveFileName(QString(""), MusEGlobal::med_file_save_pattern, this, tr("MusE: Save As"));
- //}
bool ok = false;
if (!name.isEmpty()) {
QString tempOldProj = MusEGlobal::museProject;
MusEGlobal::museProject = QFileInfo(name).absolutePath();
- ok = save(name, true);
+ ok = save(name, true, writeTopwinState);
if (ok) {
project.setFile(name);
- //setWindowTitle(tr("MusE: Song: %1").arg(project.completeBaseName()));
setWindowTitle(tr("MusE: Song: %1").arg(MusEGui::projectTitleFromFilename(name)));
addProject(name);
}
@@ -1829,7 +1730,6 @@ void MusE::startEditor(MusECore::PartList* pl, int type)
case 1: startListEditor(pl); break;
case 3: startDrumEditor(pl, true); break;
case 4: startWaveEditor(pl); break;
- //case 5: startScoreEdit(pl, true); break;
}
}
@@ -2065,9 +1965,8 @@ void MusE::showDidYouKnowDialog()
dyk.show();
if( dyk.exec()) {
if (dyk.dontShowCheckBox->isChecked()) {
- //printf("disables dialog!\n");
MusEGlobal::config.showDidYouKnow=false;
- MusEGlobal::muse->changeConfig(true); // save settings
+ MusEGlobal::muse->changeConfig(true); // save settings
}
}
}
@@ -2084,7 +1983,6 @@ void MusE::showDidYouKnowDialog()
void MusE::startClipList(bool checked)
{
if (clipListEdit == 0) {
- //clipListEdit = new ClipListEdit();
clipListEdit = new MusEGui::ClipListEdit(this);
toplevels.push_back(clipListEdit);
connect(clipListEdit, SIGNAL(isDeleting(MusEGui::TopWin*)), SLOT(toplevelDeleting(MusEGui::TopWin*)));
@@ -2174,14 +2072,11 @@ void MusE::toplevelDeleting(MusEGui::TopWin* tl)
case MusEGui::TopWin::ARRANGER:
break;
case MusEGui::TopWin::CLIPLIST:
- // ORCAN: This needs to be verified. aid2 used to correspond to Cliplist:
- //menu_audio->setItemChecked(aid2, false);
viewCliplistAction->setChecked(false);
if (currentMenuSharingTopwin == clipListEdit)
setCurrentMenuSharingTopwin(NULL);
updateWindowMenu();
return;
- //break;
// the following editors can exist in more than
// one instantiation:
@@ -2219,7 +2114,6 @@ void MusE::kbAccel(int key)
}
else if (key == MusEGui::shortcuts[MusEGui::SHRT_PLAY_TOGGLE].key) {
if (MusEGlobal::audio->isPlaying())
- //MusEGlobal::song->setStopPlay(false);
MusEGlobal::song->setStop(true);
else if (!MusEGlobal::config.useOldStyleStopShortCut)
MusEGlobal::song->setPlay(true);
@@ -2231,7 +2125,6 @@ void MusE::kbAccel(int key)
}
}
else if (key == MusEGui::shortcuts[MusEGui::SHRT_STOP].key) {
- //MusEGlobal::song->setPlay(false);
MusEGlobal::song->setStop(true);
}
else if (key == MusEGui::shortcuts[MusEGui::SHRT_GOTO_START].key) {
@@ -2306,9 +2199,6 @@ void MusE::kbAccel(int key)
else if (key == MusEGui::shortcuts[MusEGui::SHRT_OPEN_BIGTIME].key) {
toggleBigTime(!viewBigtimeAction->isChecked());
}
- //else if (key == MusEGui::shortcuts[MusEGui::SHRT_OPEN_MIXER].key) {
- // toggleMixer();
- // }
else if (key == MusEGui::shortcuts[MusEGui::SHRT_OPEN_MIXER].key) {
toggleMixer1(!viewMixerAAction->isChecked());
}
@@ -2329,12 +2219,14 @@ void MusE::kbAccel(int key)
}
}
+#if 0
//---------------------------------------------------------
// catchSignal
// only for debugging
//---------------------------------------------------------
-#if 0
+// if enabling this code, also enable the line containing
+// "catchSignal" in main.cpp
static void catchSignal(int sig)
{
if (MusEGlobal::debugMsg)
@@ -2404,7 +2296,15 @@ void MusE::configAppearance()
void MusE::loadTheme(const QString& s)
{
- if (style()->objectName() != s)
+ QStringList sl = QStyleFactory::keys();
+ if (sl.indexOf(s) == -1) {
+ if(MusEGlobal::debugMsg)
+ printf("Set style does not exist, setting default.");
+ QApplication::setStyle(Appearance::defaultStyle);
+ style()->setObjectName(Appearance::defaultStyle);
+
+ }
+ else if (style()->objectName() != s)
{
QApplication::setStyle(s);
style()->setObjectName(s); // p4.0.45
@@ -2446,7 +2346,6 @@ void MusE::changeConfig(bool writeFlag)
if (writeFlag)
writeGlobalConfiguration();
- //loadStyleSheetFile(MusEGlobal::config.styleSheetFile);
loadTheme(MusEGlobal::config.style);
QApplication::setFont(MusEGlobal::config.fonts[0]);
if(!MusEGlobal::config.styleSheetFile.isEmpty())
@@ -2488,19 +2387,6 @@ void MusE::configShortCuts()
}
-#if 0
-//---------------------------------------------------------
-// openAudioFileManagement
-//---------------------------------------------------------
-void MusE::openAudioFileManagement()
- {
- if (!audioFileManager) {
- audioFileManager = new AudioFileManager(this, "audiofilemanager", false);
- audioFileManager->show();
- }
- audioFileManager->setVisible(true);
- }
-#endif
//---------------------------------------------------------
// bounceToTrack
//---------------------------------------------------------
@@ -2673,9 +2559,8 @@ void MusE::bounceToFile(MusECore::AudioOutput* ao)
MusEGlobal::song->setPos(0,MusEGlobal::song->lPos(),0,true,true);
MusEGlobal::song->bounceOutput = ao;
ao->setRecFile(sf);
- //willfoobar-2011-02-13
- //old code//printf("ao->setRecFile %d\n", sf);
- printf("ao->setRecFile %ld\n", (unsigned long)sf);
+ if(MusEGlobal::debugMsg)
+ printf("ao->setRecFile %p\n", sf);
MusEGlobal::song->setRecord(true, false);
MusEGlobal::song->setRecordFlag(ao, true);
ao->prepareRecording();
@@ -2724,10 +2609,9 @@ MusE::lash_idle_cb ()
{
/* save file */
QString ss = QString(lash_event_get_string(event)) + QString("/lash-project-muse.med");
- int ok = save (ss.toAscii(), false);
+ int ok = save (ss.toAscii(), false, true);
if (ok) {
project.setFile(ss.toAscii());
- //setWindowTitle(tr("MusE: Song: %1").arg(project.completeBaseName()));
setWindowTitle(tr("MusE: Song: %1").arg(MusEGui::projectTitleFromFilename(project.absoluteFilePath())));
addProject(ss.toAscii());
MusEGlobal::museProject = QFileInfo(ss.toAscii()).absolutePath();
@@ -2867,8 +2751,6 @@ void MusE::switchMixerAutomation()
MusEGlobal::automation = ! MusEGlobal::automation;
// Clear all pressed and touched and rec event lists.
MusEGlobal::song->clearRecAutomation(true);
-
-// printf("automation = %d\n", automation);
autoMixerAction->setChecked(MusEGlobal::automation);
}
@@ -2972,12 +2854,7 @@ void MusE::updateConfiguration()
helpManualAction->setShortcut(MusEGui::shortcuts[MusEGui::SHRT_OPEN_HELP].key);
fullscreenAction->setShortcut(MusEGui::shortcuts[MusEGui::SHRT_FULLSCREEN].key);
- // Orcan: Old stuff, needs to be converted. These aren't used anywhere so I commented them out
- //menuSettings->setAccel(MusEGui::shortcuts[MusEGui::SHRT_CONFIG_AUDIO_PORTS].key, menu_ids[CMD_CONFIG_AUDIO_PORTS]);
- //menu_help->setAccel(menu_ids[CMD_START_WHATSTHIS], MusEGui::shortcuts[MusEGui::SHRT_START_WHATSTHIS].key);
-
//arrangerView->updateMusEGui::Shortcuts(); //commented out by flo: is done via signal
-
}
//---------------------------------------------------------
@@ -3097,27 +2974,10 @@ QWidget* MusE::transportWindow() { return transport; }
QWidget* MusE::bigtimeWindow() { return bigtime; }
//---------------------------------------------------------
-// focusInEvent
-//---------------------------------------------------------
-
-void MusE::focusInEvent(QFocusEvent* ev)
- {
- //if (mixer1) // Removed p4.0.45
- // mixer1->raise();
- //if (mixer2)
- // mixer2->raise();
- //raise();
- QMainWindow::focusInEvent(ev);
- }
-
-
-
-//---------------------------------------------------------
// execDeliveredScript
//---------------------------------------------------------
void MusE::execDeliveredScript(int id)
{
- //QString scriptfile = QString(INSTPREFIX) + SCRIPTSSUFFIX + deliveredScriptNames[id];
MusEGlobal::song->executeScript(MusEGlobal::song->getScriptPath(id, true).toLatin1().constData(), MusEGlobal::song->getSelectedMidiParts(), 0, false); // TODO: get quant from arranger
}
@@ -3138,8 +2998,69 @@ void MusE::findUnusedWaveFiles()
unused.exec();
}
-void MusE::focusChanged(QWidget*, QWidget* now)
+void MusE::focusChanged(QWidget* old, QWidget* now)
{
+ if(MusEGlobal::heavyDebugMsg)
+ {
+ printf("\n");
+ printf("focusChanged: old:%p now:%p activeWindow:%p\n", old, now, qApp->activeWindow());
+ if(old)
+ printf(" old type: %s\n", typeid(*old).name());
+ if(now)
+ printf(" now type: %s\n", typeid(*now).name());
+ if(qApp->activeWindow())
+ printf(" activeWindow type: %s\n", typeid(*qApp->activeWindow()).name());
+ printf("\n");
+ }
+
+ // NOTE: FYI: This is what is required if, for 'Smart Focus', we try simply calling clearFocus from each relevant control
+ // upon Return/Enter/Escape or whatever.
+ // It's nice to be able to do that, but this was crash-prone and I don't like it. Instead each relevant control connects
+ // signals to slots in the editors which set focus on the canvases AND activate their top windows.
+ // Who knows, this code might be needed in some way. Informational, please keep. Tim.
+ //
+ /*
+ // Allow focus proxy to do its job (if set).
+ if(now == this)
+ {
+ if(mdiArea)
+ {
+ QMdiSubWindow* mw = mdiArea->activeSubWindow();
+ if(mw && mw->widget()->focusProxy()) // Did we set a focus proxy on the window?
+ //mw->widget()->setFocus(); // Give focus to the window so proxy gets it.
+ mw->widget()->focusProxy()->setFocus(); // Give focus directly to the proxy.
+ }
+ }
+ else
+ if(!now)
+ {
+ QWidget* aw = qApp->activeWindow();
+ if(aw)
+ {
+ if(aw == this) // Active top-level window is MusE?
+ {
+ if(mdiArea)
+ {
+ QMdiSubWindow* mw = mdiArea->activeSubWindow();
+ if(mw && mw->widget()->focusProxy()) // Did we set a focus proxy on the window?
+ //mw->widget()->setFocus(); // Give focus to the window so proxy gets it.
+ mw->widget()->focusProxy()->setFocus(); // Give focus directly to the proxy.
+ }
+ }
+ else // Active top-level window is outside the MusE mdi window.
+ {
+ if(aw->focusProxy()) // Did we set a focus proxy on the window?
+ {
+ //aw->setFocus(); // Give focus to the window so proxy gets it.
+ aw->focusProxy()->setFocus(); // Give focus directly to the proxy.
+ if(!aw->focusProxy()->isActiveWindow())
+ aw->focusProxy()->activateWindow();
+ }
+ }
+ }
+ }
+ */
+
QWidget* ptr=now;
if (activeTopWin)
@@ -3162,7 +3083,7 @@ void MusE::focusChanged(QWidget*, QWidget* now)
printf("focusChanged: at widget %p with type %s\n",ptr, typeid(*ptr).name());
if ( (dynamic_cast<MusEGui::TopWin*>(ptr)!=0) || // *ptr is a TopWin or a derived class
- (ptr==this) ) // the main window is selected
+ (ptr==this) ) // the main window is selected
break;
ptr=dynamic_cast<QWidget*>(ptr->parent()); //in the unlikely case that ptr is a QObject, this returns NULL, which stops the loop
}
diff --git a/muse2/muse/app.h b/muse2/muse/app.h
index 7b2c1431..2976708b 100644
--- a/muse2/muse/app.h
+++ b/muse2/muse/app.h
@@ -31,7 +31,6 @@
#include <list>
class QCloseEvent;
-class QFocusEvent;
class QMainWindow;
class QMenu;
class QPoint;
@@ -211,14 +210,16 @@ class MusE : public QMainWindow
MidiTransformerDialog* midiTransformerDialog;
QMenu* openRecent;
+ bool writeTopwinState;
+
bool readMidi(FILE*);
void read(MusECore::Xml& xml, bool doReadMidiPorts, bool isTemplate);
void processTrack(MusECore::MidiTrack* track);
- void write(MusECore::Xml& xml) const;
+ void write(MusECore::Xml& xml, bool writeTopwins) const;
// If clear_all is false, it will not touch things like midi ports.
bool clearSong(bool clear_all = true);
- bool save(const QString&, bool);
+ bool save(const QString&, bool overwriteWarn, bool writeTopwins);
void setUntitledProject();
void setConfigDefaults();
@@ -236,8 +237,6 @@ class MusE : public QMainWindow
void writeConfiguration(int level, MusECore::Xml&) const;
void updateConfiguration();
- virtual void focusInEvent(QFocusEvent*);
-
QSignalMapper *midiPluginSignalMapper;
QSignalMapper *followSignalMapper;
QSignalMapper *windowsMapper;
@@ -279,18 +278,12 @@ class MusE : public QMainWindow
void startSongInfo(bool editable=true);
void writeGlobalConfiguration() const;
- //void startEditInstrument();
void startClipList(bool);
void openRecentMenu();
void selectProject(QAction* act);
void cmd(int);
-/* void copyMeasure(); // commented out by flo: these are not implemented,
- void eraseMeasure(); // but maybe will be in future (state: revision 988)
- void deleteMeasure();
- void createMeasure();
- void mixTrack();
-*/
+
void startMidiInputPlugin(int);
void hideMitPluginTranspose();
void hideMidiInputTransform();
@@ -325,8 +318,6 @@ class MusE : public QMainWindow
void arrangeSubWindowsColumns();
void tileSubWindows();
- //void hackishSongOpenTimerTimeout();
-
public slots:
bool saveAs();
void bounceToFile(MusECore::AudioOutput* ao = 0);
@@ -351,7 +342,7 @@ class MusE : public QMainWindow
void startEditor(MusECore::PartList*, int);
void startScoreQuickly();
void startPianoroll();
- void startPianoroll(MusECore::PartList* /*pl*/, bool /*showDefaultCtrls*/ = false);
+ void startPianoroll(MusECore::PartList* pl, bool showDefaultCtrls = false);
void startWaveEditor();
void startWaveEditor(MusECore::PartList*);
void openInScoreEdit(ScoreEdit* destination, MusECore::PartList* pl, bool allInOne=false);
@@ -363,7 +354,7 @@ class MusE : public QMainWindow
void startListEditor();
void startListEditor(MusECore::PartList*);
void startDrumEditor();
- void startDrumEditor(MusECore::PartList* /*pl*/, bool /*showDefaultCtrls*/ = false);
+ void startDrumEditor(MusECore::PartList* pl, bool showDefaultCtrls = false);
void startEditor(MusECore::Track*);
void startMidiTransformer();
diff --git a/muse2/muse/appearance.cpp b/muse2/muse/appearance.cpp
index e60db239..319a8826 100644
--- a/muse2/muse/appearance.cpp
+++ b/muse2/muse/appearance.cpp
@@ -49,6 +49,7 @@
namespace MusEGui {
+QString Appearance::defaultStyle="";
int BG_ITEM_HEIGHT = 30;
class BgPreviewWidget : public QWidget {
@@ -145,25 +146,9 @@ Appearance::Appearance(Arranger* a, QWidget* parent)
global_bg->setFlags(Qt::ItemIsEnabled);
user_bg = new QTreeWidgetItem(backgroundTree, QStringList(tr("Custom")), 0);
user_bg->setFlags(Qt::ItemIsEnabled);
- /*
- partShownames->setChecked(config->canvasShowPartType & 1);
- partShowevents->setChecked(config->canvasShowPartType & 2);
- partShowCakes->setChecked(!(config->canvasShowPartType & 2));
-
- eventNoteon->setChecked(config->canvasShowPartEvent & (1 << 0));
- eventPolypressure->setChecked(config->canvasShowPartEvent & (1 << 1));
- eventController->setChecked(config->canvasShowPartEvent & (1 << 2));
- eventProgramchange->setChecked(config->canvasShowPartEvent & (1 << 3));
- eventAftertouch->setChecked(config->canvasShowPartEvent & (1 << 4));
- eventPitchbend->setChecked(config->canvasShowPartEvent & (1 << 5));
- eventSpecial->setChecked(config->canvasShowPartEvent & (1 << 6));
- eventButtonGroup->setEnabled(config->canvasShowPartType == 2);
- arrGrid->setChecked(config->canvasShowGrid);
- */
colorframe->setAutoFillBackground(true);
aPalette = new QButtonGroup(aPaletteBox);
- // There must be an easier way to do this by a for loop. No? :
aPalette->addButton(palette0, 0);
aPalette->addButton(palette1, 1);
aPalette->addButton(palette2, 2);
@@ -188,26 +173,7 @@ Appearance::Appearance(Arranger* a, QWidget* parent)
itemList->clear();
aid = new IdListViewItem(0, itemList, "Arranger");
id = new IdListViewItem(0, aid, "PartColors");
- // Names moved into global config by Tim.
- /*
- new IdListViewItem(0x400, id, "Default");
- new IdListViewItem(0x401, id, "Refrain");
- new IdListViewItem(0x402, id, "Bridge");
- new IdListViewItem(0x403, id, "Intro");
- new IdListViewItem(0x404, id, "Coda");
- new IdListViewItem(0x405, id, "Chorus");
- new IdListViewItem(0x406, id, "Solo");
- new IdListViewItem(0x407, id, "Brass");
- new IdListViewItem(0x408, id, "Percussion");
- new IdListViewItem(0x409, id, "Drums");
- new IdListViewItem(0x40a, id, "Guitar");
- new IdListViewItem(0x40b, id, "Bass");
- new IdListViewItem(0x40c, id, "Flute");
- new IdListViewItem(0x40d, id, "Strings");
- new IdListViewItem(0x40e, id, "Keyboard");
- new IdListViewItem(0x40f, id, "Piano");
- new IdListViewItem(0x410, id, "Saxophon");
- */
+
for(int i = 0; i < NUM_PARTCOLORS; ++i)
new IdListViewItem(0x400 + i, id, MusEGlobal::config.partColorNames[i]);
@@ -274,20 +240,6 @@ Appearance::Appearance(Arranger* a, QWidget* parent)
//---------------------------------------------------
// STYLE
//---------------------------------------------------
-
- /*
- themeComboBox->clear();
- QString cs = MusEGlobal::muse->style().name();
- cs = cs.lower();
-
- themeComboBox->insertStringList(QStyleFactory::keys());
- for (int i = 0; i < themeComboBox->count(); ++i) {
- if (themeComboBox->text(i).lower() == cs) {
- themeComboBox->setCurrentItem(i);
- }
- }
- */
-
openStyleSheet->setIcon(*openIcon);
connect(openStyleSheet, SIGNAL(clicked()), SLOT(browseStyleSheet()));
defaultStyleSheet->setIcon(*undoIcon);
@@ -334,111 +286,6 @@ void Appearance::resetValues()
QPalette pal;
- /*
- pal.setColor(palette0->backgroundRole(), config->palette[0]);
- palette0->setPalette(pal);
- pal.setColor(palette1->backgroundRole(), config->palette[1]);
- palette1->setPalette(pal);
- pal.setColor(palette2->backgroundRole(), config->palette[2]);
- palette2->setPalette(pal);
- pal.setColor(palette3->backgroundRole(), config->palette[3]);
- palette3->setPalette(pal);
- pal.setColor(palette4->backgroundRole(), config->palette[4]);
- palette4->setPalette(pal);
- pal.setColor(palette5->backgroundRole(), config->palette[5]);
- palette5->setPalette(pal);
- pal.setColor(palette6->backgroundRole(), config->palette[6]);
- palette6->setPalette(pal);
- pal.setColor(palette7->backgroundRole(), config->palette[7]);
- palette7->setPalette(pal);
- pal.setColor(palette8->backgroundRole(), config->palette[8]);
- palette8->setPalette(pal);
- pal.setColor(palette9->backgroundRole(), config->palette[9]);
- palette9->setPalette(pal);
- pal.setColor(palette10->backgroundRole(), config->palette[10]);
- palette10->setPalette(pal);
- pal.setColor(palette11->backgroundRole(), config->palette[11]);
- palette11->setPalette(pal);
- pal.setColor(palette12->backgroundRole(), config->palette[12]);
- palette12->setPalette(pal);
- pal.setColor(palette13->backgroundRole(), config->palette[13]);
- palette13->setPalette(pal);
- pal.setColor(palette14->backgroundRole(), config->palette[14]);
- palette14->setPalette(pal);
- pal.setColor(palette15->backgroundRole(), config->palette[15]);
- palette15->setPalette(pal);
- */
-
- /*
- pal.setColor(QPalette::Window, config->palette[0]);
- palette0->setPalette(pal);
- pal.setColor(QPalette::Window, config->palette[1]);
- palette1->setPalette(pal);
- pal.setColor(QPalette::Window, config->palette[2]);
- palette2->setPalette(pal);
- pal.setColor(QPalette::Window, config->palette[3]);
- palette3->setPalette(pal);
- pal.setColor(QPalette::Window, config->palette[4]);
- palette4->setPalette(pal);
- pal.setColor(QPalette::Window, config->palette[5]);
- palette5->setPalette(pal);
- pal.setColor(QPalette::Window, config->palette[6]);
- palette6->setPalette(pal);
- pal.setColor(QPalette::Window, config->palette[7]);
- palette7->setPalette(pal);
- pal.setColor(QPalette::Window, config->palette[8]);
- palette8->setPalette(pal);
- pal.setColor(QPalette::Window, config->palette[9]);
- palette9->setPalette(pal);
- pal.setColor(QPalette::Window, config->palette[10]);
- palette10->setPalette(pal);
- pal.setColor(QPalette::Window, config->palette[11]);
- palette11->setPalette(pal);
- pal.setColor(QPalette::Window, config->palette[12]);
- palette12->setPalette(pal);
- pal.setColor(QPalette::Window, config->palette[13]);
- palette13->setPalette(pal);
- pal.setColor(QPalette::Window, config->palette[14]);
- palette14->setPalette(pal);
- pal.setColor(QPalette::Window, config->palette[15]);
- palette15->setPalette(pal);
- */
-
- /*
- pal.setColor(QPalette::Button, config->palette[0]);
- palette0->setPalette(pal);
- pal.setColor(QPalette::Button, config->palette[1]);
- palette1->setPalette(pal);
- pal.setColor(QPalette::Button, config->palette[2]);
- palette2->setPalette(pal);
- pal.setColor(QPalette::Button, config->palette[3]);
- palette3->setPalette(pal);
- pal.setColor(QPalette::Button, config->palette[4]);
- palette4->setPalette(pal);
- pal.setColor(QPalette::Button, config->palette[5]);
- palette5->setPalette(pal);
- pal.setColor(QPalette::Button, config->palette[6]);
- palette6->setPalette(pal);
- pal.setColor(QPalette::Button, config->palette[7]);
- palette7->setPalette(pal);
- pal.setColor(QPalette::Button, config->palette[8]);
- palette8->setPalette(pal);
- pal.setColor(QPalette::Button, config->palette[9]);
- palette9->setPalette(pal);
- pal.setColor(QPalette::Button, config->palette[10]);
- palette10->setPalette(pal);
- pal.setColor(QPalette::Button, config->palette[11]);
- palette11->setPalette(pal);
- pal.setColor(QPalette::Button, config->palette[12]);
- palette12->setPalette(pal);
- pal.setColor(QPalette::Button, config->palette[13]);
- palette13->setPalette(pal);
- pal.setColor(QPalette::Button, config->palette[14]);
- palette14->setPalette(pal);
- pal.setColor(QPalette::Button, config->palette[15]);
- palette15->setPalette(pal);
- */
-
palette0->setStyleSheet(QString("background-color: ") + config->palette[0].name());
palette1->setStyleSheet(QString("background-color: ") + config->palette[1].name());
palette2->setStyleSheet(QString("background-color: ") + config->palette[2].name());
@@ -506,23 +353,25 @@ void Appearance::resetValues()
eventAftertouch->setChecked(config->canvasShowPartEvent & (1 << 4));
eventPitchbend->setChecked(config->canvasShowPartEvent & (1 << 5));
eventSpecial->setChecked(config->canvasShowPartEvent & (1 << 6));
- //eventButtonGroup->setEnabled(config->canvasShowPartType == 2);
eventButtonGroup->setEnabled(config->canvasShowPartType & 2);
arrGrid->setChecked(config->canvasShowGrid);
themeComboBox->clear();
QString cs = MusEGlobal::muse->style()->objectName();
- //printf("Appearance::resetValues style:%s\n", cs.toAscii().data());
- //printf("Appearance::resetValues App styleSheet:%s\n", qApp->styleSheet().toAscii().data());
cs = cs.toLower();
- themeComboBox->insertItems(0, QStyleFactory::keys());
- for (int i = 0; i < themeComboBox->count(); ++i) {
- if (themeComboBox->itemText(i).toLower() == cs) {
- themeComboBox->setCurrentIndex(i);
- }
- }
+ themeComboBox->insertItem(0,tr("Keep Qt system style"));
+ themeComboBox->insertItems(1, QStyleFactory::keys());
+ if (QStyleFactory::keys().indexOf(config->style) == -1)
+ themeComboBox->setCurrentIndex(0); // if none is found use the default
+ else {
+ for (int i = 0; i < themeComboBox->count(); ++i) {
+ if (themeComboBox->itemText(i).toLower() == cs) {
+ themeComboBox->setCurrentIndex(i);
+ }
+ }
+ }
globalAlphaSlider->blockSignals(true);
globalAlphaVal->blockSignals(true);
globalAlphaSlider->setValue(config->globalAlphaBlend);
@@ -887,14 +736,12 @@ void Appearance::colorItemSelectionChanged()
void Appearance::updateColor()
{
int r, g, b, h, s, v;
- //globalAlphaSlider->setEnabled(color);
rslider->setEnabled(color);
gslider->setEnabled(color);
bslider->setEnabled(color);
hslider->setEnabled(color);
sslider->setEnabled(color);
vslider->setEnabled(color);
- //globalAlphaVal->setEnabled(color);
rval->setEnabled(color);
gval->setEnabled(color);
bval->setEnabled(color);
@@ -906,15 +753,10 @@ void Appearance::updateColor()
QPalette pal;
QColor cfc(*color);
- // Oops can't do this - affects all colour items. Need to filter.
- ///cfc.setAlpha(globalAlphaVal->value());
-
pal.setColor(colorframe->backgroundRole(), cfc);
colorframe->setPalette(pal);
color->getRgb(&r, &g, &b);
color->getHsv(&h, &s, &v);
- //a = color->alpha();
- //a = config->globalAlphaBlend;
rslider->blockSignals(true);
gslider->blockSignals(true);
@@ -1056,7 +898,6 @@ void Appearance::addToPaletteClicked()
if (r == 0xff && g == 0xff && b == 0xff) {
// found empty slot
aPalette->button(i)->toggle();
- //aPalette->moveFocus(i); ddskrjo
button = (QAbstractButton*)aPalette->button(i); // ddskrjo
break;
}
@@ -1065,11 +906,6 @@ void Appearance::addToPaletteClicked()
if (button) {
int id = aPalette->id(button);
config->palette[id] = *color;
- //QPalette pal;
- //pal.setColor(button->backgroundRole(), *color);
- //pal.setColor(QPalette::Window, *color);
- //pal.setColor(QPalette::Button, *color);
- //button->setPalette(pal);
button->setStyleSheet(QString("background-color: ") + color->name());
button->update(); //??
}
@@ -1085,8 +921,7 @@ void Appearance::paletteClicked(int id)
return;
QAbstractButton* button = (QAbstractButton*)aPalette->button(id); // ddskrjo
if (button) {
- QColor c = button->palette().color(QPalette::Window);
- //QColor c = button->palette().color(button->backgroundRole());
+ QColor c = button->palette().color(QPalette::Window);
int r, g, b;
c.getRgb(&r, &g, &b);
if (r == 0xff && g == 0xff && b == 0xff)
diff --git a/muse2/muse/appearance.h b/muse2/muse/appearance.h
index ecefeae0..8b746cfd 100644
--- a/muse2/muse/appearance.h
+++ b/muse2/muse/appearance.h
@@ -93,6 +93,7 @@ class Appearance : public QDialog, public Ui::AppearanceDialogBase {
Appearance(Arranger*, QWidget* parent=0);
~Appearance();
void resetValues();
+ static QString defaultStyle;
};
} // namespace MusEGui
diff --git a/muse2/muse/arranger/alayout.cpp b/muse2/muse/arranger/alayout.cpp
index 84923f12..509c84ac 100644
--- a/muse2/muse/arranger/alayout.cpp
+++ b/muse2/muse/arranger/alayout.cpp
@@ -41,12 +41,12 @@ void TLLayout::wadd(int idx, QWidget* w)
addItem(li[idx]);
}
-#if 0
+#if 0 // DELETETHIS 36
//---------------------------------------------------------
// TLLayoutIterator
//---------------------------------------------------------
-class TLLayoutIterator // : public QGLayoutIterator ddskrjo
+class TLLayoutIterator
{
int idx;
QList<QLayoutItem*> list;
@@ -64,7 +64,7 @@ class TLLayoutIterator // : public QGLayoutIterator ddskrjo
QLayoutIterator TLLayout::iterator()
{
- return QLayoutIterator(0); //new TLLayoutIterator(&ilist)); ddskrjo
+ return QLayoutIterator(0);
}
void TLLayout::addItem(QLayoutItem *item)
@@ -99,10 +99,6 @@ TLLayout::~TLLayout()
void TLLayout::setGeometry(const QRect &rect)
{
- //if(_inSetGeometry) // p4.0.11 Tim
- // return;
- //_inSetGeometry = true;
-
int w = rect.width();
int h = rect.height();
@@ -117,7 +113,7 @@ void TLLayout::setGeometry(const QRect &rect)
QSize s1 = li[1]->sizeHint();
QSize s2 = li[2]->sizeHint();
- //QSize s3 = li[3]->sizeHint();
+ //QSize s3 = li[3]->sizeHint(); DELETETHIS huh?
QSize s4 = li[4]->sizeHint();
QSize s5 = li[5]->sizeHint();
@@ -136,15 +132,11 @@ void TLLayout::setGeometry(const QRect &rect)
int range = s0.height() - y2;
if (range < 0)
range = 0;
- // Note this appears to cause a single recursive call to this function - jumps to beginning,
- // because now the scroll bar wants to be put in the layout.
- // Moved below. p4.0.44
- ///sb->setVisible(range != 0);
+
if (range)
sb->setMaximum(range);
if (widget) {
- //QSize r(s0.width(), y2);
QSize r(s0.width(), y2 < s0.height() ? s0.height() : y2); // p4.0.11 Tim
widget->setGeometry(0, 0, r.width(), r.height());
}
@@ -155,10 +147,8 @@ void TLLayout::setGeometry(const QRect &rect)
li[4]->setGeometry(QRect(0, y2, w, s4.height()));
li[5]->setGeometry(QRect(3, y3, s5.width(), s5.height()));
- /// Fix for non-appearing scrollbar. Yes, we must allow the recursive call, but try it here, not above. p4.0.44 Tim
+ // Fix for non-appearing scrollbar. Yes, we must allow the recursive call, but try it here, not above. p4.0.44 Tim
sb->setVisible(range != 0);
-
- //_inSetGeometry = false;
}
//---------------------------------------------------------
@@ -168,8 +158,6 @@ void TLLayout::setGeometry(const QRect &rect)
QSize TLLayout::sizeHint() const
{
return QSize(150, 100);
- // p4.0.11 Tim. 100 was allowing vertically shrunk trackinfo widgets. Nope, no help.
- //return minimumSize();
}
//---------------------------------------------------------
@@ -182,8 +170,6 @@ QSize TLLayout::minimumSize() const
w += li[1]->sizeHint().width();
return QSize(w, 50);
- // p4.0.11 Tim. 50 was allowing vertically shrunk trackinfo widgets. Nope, no help.
- //return QSize(w, stack->minimumSizeHint().height());
}
//---------------------------------------------------------
diff --git a/muse2/muse/arranger/alayout.h b/muse2/muse/arranger/alayout.h
index 2ffef621..8af26288 100644
--- a/muse2/muse/arranger/alayout.h
+++ b/muse2/muse/arranger/alayout.h
@@ -49,7 +49,6 @@ class TLLayout : public QLayout
WidgetStack* stack;
public:
- //TLLayout(QWidget *parent) : QLayout(parent, 0, -1) {}
TLLayout(QWidget *parent) : QLayout(parent) { _inSetGeometry = false; setContentsMargins(0, 0, 0, 0); setSpacing(-1); }
~TLLayout() { clear(); }
@@ -63,16 +62,10 @@ class TLLayout : public QLayout
virtual QSize sizeHint() const;
virtual QSize minimumSize() const;
virtual QSize maximumSize() const;
- //QSize sizeHint() const;
- //QSize minimumSize() const;
- //QSize maximumSize() const;
- ///QLayoutIterator iterator();
virtual void setGeometry(const QRect &rect);
- //virtual QLayoutItem* itemAt(int) const { return 0;} // ddskrjo, is pure virtual, overridden
virtual QLayoutItem* itemAt(int i) const { return ilist.value(i);}
- virtual QLayoutItem* takeAt(int); // { return 0;} // ddskrjo, is pure virtual, overridden
- ///virtual int count() const { return ilist.count(); } // ddskrjo, is pure virtual, overridden
+ virtual QLayoutItem* takeAt(int);
};
} // namespace MusEGui
diff --git a/muse2/muse/arranger/arranger.cpp b/muse2/muse/arranger/arranger.cpp
index 41cbf06f..9048bb3c 100644
--- a/muse2/muse/arranger/arranger.cpp
+++ b/muse2/muse/arranger/arranger.cpp
@@ -37,9 +37,8 @@
#include <QVBoxLayout>
#include <QWheelEvent>
#include <QPainter>
-//#include <QStackedWidget>
-#include "arrangerview.h"
+#include "arrangerview.h"
#include "arranger.h"
#include "song.h"
#include "app.h"
@@ -152,6 +151,13 @@ Arranger::custom_col_t Arranger::readOneCustomColumn(MusECore::Xml& xml)
+void ScrollBar::redirectedWheelEvent(QWheelEvent* e)
+{
+ if(isVisible())
+ wheelEvent(e);
+}
+
+
//---------------------------------------------------------
// Arranger::setHeaderToolTips
//---------------------------------------------------------
@@ -200,18 +206,13 @@ Arranger::Arranger(ArrangerView* parent, const char* name)
setObjectName(name);
_raster = 0; // measure
selected = 0;
- // Since program covers 3 controls at once, it is in 'midi controller' units rather than 'gui control' units.
- //program = -1;
- ///program = CTRL_VAL_UNKNOWN;
- ///pan = -65;
- ///volume = -1;
showTrackinfoFlag = true;
cursVal = MAXINT;
parentWin=parent;
- //setFocusPolicy(Qt::StrongFocus);
+ setFocusPolicy(Qt::NoFocus);
//---------------------------------------------------
// ToolBar
@@ -246,7 +247,6 @@ Arranger::Arranger(ArrangerView* parent, const char* name)
MusEGlobal::song->setArrangerRaster(0);
toolbar->addWidget(raster);
connect(raster, SIGNAL(activated(int)), SLOT(_setRaster(int)));
- ///raster->setFocusPolicy(Qt::NoFocus);
raster->setFocusPolicy(Qt::TabFocus);
// Song len
@@ -257,8 +257,8 @@ Arranger::Arranger(ArrangerView* parent, const char* name)
// song length is limited to 10000 bars; the real song len is limited
// by overflows in tick computations
- //
lenEntry = new SpinBox(1, 10000, 1);
+ lenEntry->setFocusPolicy(Qt::StrongFocus);
lenEntry->setValue(MusEGlobal::song->len());
lenEntry->setToolTip(tr("song length - bars"));
lenEntry->setWhatsThis(tr("song length - bars"));
@@ -273,7 +273,6 @@ Arranger::Arranger(ArrangerView* parent, const char* name)
typeBox->setCurrentIndex(0);
typeBox->setToolTip(tr("midi song type"));
typeBox->setWhatsThis(tr("midi song type"));
- ///typeBox->setFocusPolicy(Qt::NoFocus);
typeBox->setFocusPolicy(Qt::TabFocus);
toolbar->addWidget(typeBox);
connect(typeBox, SIGNAL(activated(int)), SLOT(modeChange(int)));
@@ -284,6 +283,7 @@ Arranger::Arranger(ArrangerView* parent, const char* name)
toolbar->addWidget(label);
globalPitchSpinBox = new SpinBox(-127, 127, 1);
+ globalPitchSpinBox->setFocusPolicy(Qt::StrongFocus);
globalPitchSpinBox->setValue(MusEGlobal::song->globalPitchShift());
globalPitchSpinBox->setToolTip(tr("midi pitch"));
globalPitchSpinBox->setWhatsThis(tr("global midi pitch shift"));
@@ -296,6 +296,7 @@ Arranger::Arranger(ArrangerView* parent, const char* name)
toolbar->addWidget(label);
globalTempoSpinBox = new SpinBox(50, 200, 1, toolbar);
+ globalTempoSpinBox->setFocusPolicy(Qt::StrongFocus);
globalTempoSpinBox->setSuffix(QString("%"));
globalTempoSpinBox->setValue(MusEGlobal::tempomap.globalTempo());
globalTempoSpinBox->setToolTip(tr("midi tempo"));
@@ -305,16 +306,19 @@ Arranger::Arranger(ArrangerView* parent, const char* name)
QToolButton* tempo50 = new QToolButton();
tempo50->setText(QString("50%"));
+ tempo50->setFocusPolicy(Qt::NoFocus);
toolbar->addWidget(tempo50);
connect(tempo50, SIGNAL(clicked()), SLOT(setTempo50()));
QToolButton* tempo100 = new QToolButton();
tempo100->setText(tr("N"));
+ tempo100->setFocusPolicy(Qt::NoFocus);
toolbar->addWidget(tempo100);
connect(tempo100, SIGNAL(clicked()), SLOT(setTempo100()));
QToolButton* tempo200 = new QToolButton();
tempo200->setText(QString("200%"));
+ tempo200->setFocusPolicy(Qt::NoFocus);
toolbar->addWidget(tempo200);
connect(tempo200, SIGNAL(clicked()), SLOT(setTempo200()));
@@ -322,9 +326,6 @@ Arranger::Arranger(ArrangerView* parent, const char* name)
box->setContentsMargins(0, 0, 0, 0);
box->setSpacing(0);
box->addWidget(MusECore::hLine(this), Qt::AlignTop);
- //QFrame* hline = MusECore::hLine(this);
- //hline->setLineWidth(0);
- //box->addWidget(hline, Qt::AlignTop);
//---------------------------------------------------
// Tracklist
@@ -336,12 +337,10 @@ Arranger::Arranger(ArrangerView* parent, const char* name)
split = new Splitter(Qt::Horizontal, this, "split");
split->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
box->addWidget(split, 1000);
- //split->setHandleWidth(10);
tracklist = new QWidget(split);
split->setStretchFactor(split->indexOf(tracklist), 0);
- //tracklist->setSizePolicy(QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding, 0, 100));
QSizePolicy tpolicy = QSizePolicy(QSizePolicy::Fixed, QSizePolicy::Expanding);
tpolicy.setHorizontalStretch(0);
tpolicy.setVerticalStretch(100);
@@ -349,11 +348,6 @@ Arranger::Arranger(ArrangerView* parent, const char* name)
QWidget* editor = new QWidget(split);
split->setStretchFactor(split->indexOf(editor), 1);
- //editor->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding,
- // Changed by T356. Was causing "large int implicitly truncated" warning. These are UCHAR values...
- //1000, 100));
- //232, 100)); // 232 is what it was being truncated to, but what is the right value?...
- //255, 100));
QSizePolicy epolicy = QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
epolicy.setHorizontalStretch(255);
epolicy.setVerticalStretch(100);
@@ -363,7 +357,7 @@ Arranger::Arranger(ArrangerView* parent, const char* name)
// Track Info
//---------------------------------------------------
- infoScroll = new QScrollBar(Qt::Vertical, tracklist);
+ infoScroll = new ScrollBar(Qt::Vertical, tracklist);
infoScroll->setObjectName("infoScrollBar");
//genTrackInfo(tracklist); // Moved below
@@ -380,16 +374,14 @@ Arranger::Arranger(ArrangerView* parent, const char* name)
tgrid=NULL;
updateTListHeader();
list = new TList(header, tracklist, "tracklist");
-
+
// Do this now that the list is available.
genTrackInfo(tracklist);
- ///connect(list, SIGNAL(selectionChanged()), SLOT(trackSelectionChanged()));
connect(list, SIGNAL(selectionChanged(MusECore::Track*)), SLOT(trackSelectionChanged()));
connect(list, SIGNAL(selectionChanged(MusECore::Track*)), midiTrackInfo, SLOT(setTrack(MusECore::Track*)));
connect(header, SIGNAL(sectionResized(int,int,int)), list, SLOT(redraw()));
connect(header, SIGNAL(sectionMoved(int,int,int)), list, SLOT(redraw()));
- connect(header, SIGNAL(sectionMoved(int,int,int)), this, SLOT(headerMoved()));
// tracklist:
//
@@ -422,15 +414,11 @@ Arranger::Arranger(ArrangerView* parent, const char* name)
hscroll->setFocusPolicy(Qt::NoFocus);
ib->setFixedHeight(hscroll->sizeHint().height());
- // Changed p3.3.43 Too small steps for me...
- //vscroll = new QScrollBar(1, 20*20, 1, 5, 0, Vertical, editor);
- //vscroll = new QScrollBar(1, 20*20, 5, 25, 0, Qt::Vertical, editor);
vscroll = new QScrollBar(editor);
- ///vscroll->setMinimum(1);
- vscroll->setMinimum(0); // Tim.
+ vscroll->setMinimum(0);
vscroll->setMaximum(20*20);
vscroll->setSingleStep(5);
- vscroll->setPageStep(25);
+ vscroll->setPageStep(25); // FIXME: too small steps here for me (flo), better control via window height?
vscroll->setValue(0);
vscroll->setOrientation(Qt::Vertical);
@@ -453,7 +441,8 @@ Arranger::Arranger(ArrangerView* parent, const char* name)
canvas->setCanvasTools(arrangerTools);
canvas->setOrigin(-offset, 0);
canvas->setFocus();
- setFocusProxy(canvas); // once removed by Tim (r735), added by flo again
+
+ list->setFocusProxy(canvas); // Make it easy for track list popup line editor to give focus back to canvas.
connect(canvas, SIGNAL(setUsedTool(int)), this, SIGNAL(setUsedTool(int)));
connect(canvas, SIGNAL(trackChanged(MusECore::Track*)), list, SLOT(selectTrack(MusECore::Track*)));
@@ -462,12 +451,22 @@ Arranger::Arranger(ArrangerView* parent, const char* name)
connect(canvas, SIGNAL(selectTrackBelow()), list, SLOT(selectTrackBelow()));
connect(canvas, SIGNAL(horizontalZoomIn()), SLOT(horizontalZoomIn()));
connect(canvas, SIGNAL(horizontalZoomOut()), SLOT(horizontalZoomOut()));
-
- connect(this, SIGNAL(redirectWheelEvent(QWheelEvent*)), canvas, SLOT(redirectedWheelEvent(QWheelEvent*)));
- connect(list, SIGNAL(redirectWheelEvent(QWheelEvent*)), canvas, SLOT(redirectedWheelEvent(QWheelEvent*)));
+ if(MusEGlobal::config.smartFocus)
+ {
+ connect(lenEntry, SIGNAL(returnPressed()), SLOT(focusCanvas()));
+ connect(lenEntry, SIGNAL(escapePressed()), SLOT(focusCanvas()));
+ connect(globalPitchSpinBox, SIGNAL(returnPressed()), SLOT(focusCanvas()));
+ connect(globalPitchSpinBox, SIGNAL(escapePressed()), SLOT(focusCanvas()));
+ connect(globalTempoSpinBox, SIGNAL(returnPressed()), SLOT(focusCanvas()));
+ connect(globalTempoSpinBox, SIGNAL(escapePressed()), SLOT(focusCanvas()));
+ connect(midiTrackInfo, SIGNAL(returnPressed()), SLOT(focusCanvas()));
+ connect(midiTrackInfo, SIGNAL(escapePressed()), SLOT(focusCanvas()));
+ }
+
+ //connect(this, SIGNAL(redirectWheelEvent(QWheelEvent*)), canvas, SLOT(redirectedWheelEvent(QWheelEvent*)));
+ connect(list, SIGNAL(redirectWheelEvent(QWheelEvent*)), canvas, SLOT(redirectedWheelEvent(QWheelEvent*)));
+ connect(trackInfo, SIGNAL(redirectWheelEvent(QWheelEvent*)), infoScroll, SLOT(redirectedWheelEvent(QWheelEvent*)));
- //egrid->addMultiCellWidget(time, 0, 0, 0, 1);
- //egrid->addMultiCellWidget(MusECore::hLine(editor), 1, 1, 0, 1);
egrid->addWidget(time, 0, 0, 1, 2);
egrid->addWidget(MusECore::hLine(editor), 1, 0, 1, 2);
@@ -479,7 +478,7 @@ Arranger::Arranger(ArrangerView* parent, const char* name)
connect(hscroll, SIGNAL(scrollChanged(int)), canvas, SLOT(setXPos(int)));
connect(hscroll, SIGNAL(scaleChanged(int)), canvas, SLOT(setXMag(int)));
connect(vscroll, SIGNAL(valueChanged(int)), list, SLOT(setYPos(int)));
- connect(hscroll, SIGNAL(scrollChanged(int)), time, SLOT(setXPos(int))); //
+ connect(hscroll, SIGNAL(scrollChanged(int)), time, SLOT(setXPos(int)));
connect(hscroll, SIGNAL(scaleChanged(int)), time, SLOT(setXMag(int)));
connect(canvas, SIGNAL(timeChanged(unsigned)), SLOT(setTime(unsigned)));
connect(canvas, SIGNAL(verticalScroll(unsigned)),SLOT(verticalScrollSetYpos(unsigned)));
@@ -492,7 +491,6 @@ Arranger::Arranger(ArrangerView* parent, const char* name)
connect(canvas, SIGNAL(startEditor(MusECore::PartList*,int)), SIGNAL(startEditor(MusECore::PartList*, int)));
connect(MusEGlobal::song, SIGNAL(songChanged(int)), SLOT(songChanged(int)));
- //connect(MusEGlobal::song, SIGNAL(mTypeChanged(MType)), SLOT(setMode((int)MType))); // p4.0.7 Tim.
connect(canvas, SIGNAL(followEvent(int)), hscroll, SLOT(setOffset(int)));
connect(canvas, SIGNAL(selectionChanged()), SIGNAL(selectionChanged()));
connect(canvas, SIGNAL(dropSongFile(const QString&)), SIGNAL(dropSongFile(const QString&)));
@@ -500,15 +498,10 @@ Arranger::Arranger(ArrangerView* parent, const char* name)
connect(canvas, SIGNAL(toolChanged(int)), SIGNAL(toolChanged(int)));
connect(MusEGlobal::song, SIGNAL(controllerChanged(MusECore::Track*)), SLOT(controllerChanged(MusECore::Track*)));
-// connect(MusEGlobal::song, SIGNAL(posChanged(int, unsigned, bool)), SLOT(seek()));
- // Removed p3.3.43
- // Song::addMarker() already emits a 'markerChanged'.
- //connect(time, SIGNAL(addMarker(int)), SIGNAL(addMarker(int)));
-
configChanged(); // set configuration values
if(canvas->part())
- midiTrackInfo->setTrack(canvas->part()->track()); // Tim.
+ midiTrackInfo->setTrack(canvas->part()->track());
showTrackInfo(showTrackinfoFlag);
// Take care of some tabbies!
@@ -521,7 +514,7 @@ Arranger::Arranger(ArrangerView* parent, const char* name)
}
-void Arranger::updateTListHeader()
+void Arranger::updateTListHeader() // TODO FIXME FINDMICHJETZT this doesn't work properly :/
{
if (header)
{
@@ -580,6 +573,7 @@ void Arranger::updateTListHeader()
}
}
+// DELETETHIS 20
//---------------------------------------------------------
// updateHScrollRange
//---------------------------------------------------------
@@ -600,15 +594,6 @@ void Arranger::updateTListHeader()
//}
//---------------------------------------------------------
-// headerMoved
-//---------------------------------------------------------
-
-void Arranger::headerMoved()
- {
- //header->setResizeMode(COL_NAME, QHeaderView::Stretch);
- }
-
-//---------------------------------------------------------
// setTime
//---------------------------------------------------------
@@ -648,23 +633,26 @@ void Arranger::dclickPart(MusECore::Track* t)
void Arranger::configChanged()
{
- //printf("Arranger::configChanged\n");
-
if (MusEGlobal::config.canvasBgPixmap.isEmpty()) {
canvas->setBg(MusEGlobal::config.partCanvasBg);
canvas->setBg(QPixmap());
- //printf("Arranger::configChanged - no bitmap!\n");
}
else {
-
- //printf("Arranger::configChanged - bitmap %s!\n", MusEGlobal::config.canvasBgPixmap.ascii());
canvas->setBg(QPixmap(MusEGlobal::config.canvasBgPixmap));
}
- ///midiTrackInfo->setFont(MusEGlobal::config.fonts[2]);
- //updateTrackInfo(type);
}
//---------------------------------------------------------
+// focusCanvas
+//---------------------------------------------------------
+
+void Arranger::focusCanvas()
+{
+ canvas->setFocus();
+ canvas->activateWindow();
+}
+
+//---------------------------------------------------------
// songlenChanged
//---------------------------------------------------------
@@ -714,8 +702,6 @@ void Arranger::songChanged(int type)
SC_SIG | SC_TEMPO)) // Maybe sig. Requires tempo.
canvas->partsChanged();
- //typeBox->setCurrentIndex(int(MusEGlobal::song->mtype())); // REMOVE Tim. Redundant.
-
if (type & SC_SIG)
time->redraw();
if (type & SC_TEMPO)
@@ -724,7 +710,6 @@ void Arranger::songChanged(int type)
if(type & SC_TRACK_REMOVED)
{
AudioStrip* w = (AudioStrip*)(trackInfo->getWidget(2));
- //AudioStrip* w = (AudioStrip*)(trackInfo->widget(2));
if(w)
{
MusECore::Track* t = w->getTrack();
@@ -743,7 +728,7 @@ void Arranger::songChanged(int type)
}
}
- // TEST p4.0.36 Try this
+ // TEST p4.0.36 Try this DELETETHIS and below and even more below
if(type & ( //SC_TRACK_INSERTED | SC_TRACK_REMOVED | SC_TRACK_MODIFIED |
SC_PART_INSERTED | SC_PART_REMOVED | SC_PART_MODIFIED |
SC_EVENT_INSERTED | SC_EVENT_REMOVED | SC_EVENT_MODIFIED)) //|
@@ -783,6 +768,8 @@ void Arranger::modeChange(int mode)
{
MusEGlobal::song->setMType(MType(mode));
updateTrackInfo(-1);
+ if(MusEGlobal::config.smartFocus)
+ focusCanvas();
}
//---------------------------------------------------------
@@ -791,10 +778,10 @@ void Arranger::modeChange(int mode)
void Arranger::setMode(int mode)
{
- typeBox->blockSignals(true); //
+ typeBox->blockSignals(true);
// This will only set if different.
typeBox->setCurrentIndex(mode);
- typeBox->blockSignals(false); //
+ typeBox->blockSignals(false);
}
//---------------------------------------------------------
@@ -904,6 +891,8 @@ void Arranger::_setRaster(int index)
// Set the audio record part snapping.
MusEGlobal::song->setArrangerRaster(_raster);
canvas->redraw();
+ if(MusEGlobal::config.smartFocus)
+ focusCanvas();
}
//---------------------------------------------------------
@@ -1102,10 +1091,8 @@ QWidget* WidgetStack::visibleWidget() const
QSize WidgetStack::minimumSizeHint() const
{
if (top == -1)
- {
- //printf("WidgetStack::minimumSizeHint top is -1\n");
return (QSize(0, 0));
- }
+
QSize s(0,0);
for (unsigned int i = 0; i < stack.size(); ++i) {
if (stack[i]) {
@@ -1115,11 +1102,20 @@ QSize WidgetStack::minimumSizeHint() const
s = s.expandedTo(ss);
}
}
- //printf("WidgetStack::minimumSizeHint width:%d height:%d\n", s.width(), s.height());
+
return s;
}
//---------------------------------------------------------
+// wheelEvent
+//---------------------------------------------------------
+
+void WidgetStack::wheelEvent(QWheelEvent* ev)
+ {
+ emit redirectWheelEvent(ev);
+ }
+
+//---------------------------------------------------------
// clear
//---------------------------------------------------------
@@ -1133,10 +1129,10 @@ void Arranger::clear()
midiTrackInfo->setTrack(0);
}
-void Arranger::wheelEvent(QWheelEvent* ev)
- {
- emit redirectWheelEvent(ev);
- }
+//void Arranger::wheelEvent(QWheelEvent* ev)
+// {
+// emit redirectWheelEvent(ev);
+// }
void Arranger::controllerChanged(MusECore::Track *t)
{
@@ -1162,12 +1158,10 @@ void Arranger::showTrackInfo(bool flag)
void Arranger::genTrackInfo(QWidget* parent)
{
trackInfo = new WidgetStack(parent, "trackInfoStack");
- //trackInfo->setFocusPolicy(Qt::TabFocus); // p4.0.9
- //trackInfo->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
noTrackInfo = new QWidget(trackInfo);
noTrackInfo->setAutoFillBackground(true);
- QPixmap *noInfoPix = new QPixmap(160, 1000); //muse_leftside_logo_xpm);
+ QPixmap *noInfoPix = new QPixmap(160, 1000);
const QPixmap *logo = new QPixmap(*museLeftSideLogo);
noInfoPix->fill(noTrackInfo->palette().color(QPalette::Window) );
QPainter p(noInfoPix);
@@ -1181,13 +1175,9 @@ void Arranger::genTrackInfo(QWidget* parent)
midiTrackInfo = new MidiTrackInfo(trackInfo);
- //midiTrackInfo->setFocusPolicy(Qt::TabFocus); // p4.0.9
- //midiTrackInfo->setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum));
trackInfo->addWidget(noTrackInfo, 0);
trackInfo->addWidget(midiTrackInfo, 1);
trackInfo->addWidget(0, 2);
-
-/// genMidiTrackInfo();
}
//---------------------------------------------------------
@@ -1249,7 +1239,7 @@ void Arranger::switchInfo(int n)
tgrid->update(); // muse-2 Qt4
}
-/*
+/* DELETETHIS 12
QSize WidgetStack::minimumSize() const
{
printf("WidgetStack::minimumSize\n");
diff --git a/muse2/muse/arranger/arranger.h b/muse2/muse/arranger/arranger.h
index c2746ba7..6069c8b3 100644
--- a/muse2/muse/arranger/arranger.h
+++ b/muse2/muse/arranger/arranger.h
@@ -26,6 +26,9 @@
#include <vector>
#include <QString>
+#include <QScrollBar>
+#include <QResizeEvent>
+
#include "midieditor.h"
#include "pcanvas.h"
#include "trackautomationview.h"
@@ -34,11 +37,9 @@ class QAction;
class QCheckBox;
class QMainWindow;
class QMenu;
-class QScrollBar;
class QToolButton;
class QWheelEvent;
class QKeyEvent;
-//class QStackedWidget;
namespace MusECore {
class Track;
@@ -60,6 +61,7 @@ class TLLayout;
class TList;
class WidgetStack;
+
//---------------------------------------------------------
// WidgetStack
//---------------------------------------------------------
@@ -69,6 +71,12 @@ class WidgetStack : public QWidget {
std::vector<QWidget*> stack;
int top;
+ protected:
+ virtual void wheelEvent(QWheelEvent* e);
+
+ signals:
+ void redirectWheelEvent(QWheelEvent*);
+
public:
WidgetStack(QWidget* parent, const char* name = 0);
void raiseWidget(int idx);
@@ -77,11 +85,27 @@ class WidgetStack : public QWidget {
QWidget* visibleWidget() const;
int curIdx() const { return top; }
virtual QSize minimumSizeHint() const;
- //QSize minimumSize() const;
- //int minimumHeight() const;
};
//---------------------------------------------------------
+// ScrollBar
+//---------------------------------------------------------
+
+class ScrollBar : public QScrollBar {
+ Q_OBJECT
+
+ public slots:
+ void redirectedWheelEvent(QWheelEvent*);
+
+ protected:
+ virtual void resizeEvent(QResizeEvent* e) { setPageStep(e->size().height()); }
+
+ public:
+ ScrollBar(Qt::Orientation orientation, QWidget * parent = 0 ) : QScrollBar(orientation, parent) {};
+};
+
+
+//---------------------------------------------------------
// Arranger
//---------------------------------------------------------
@@ -100,9 +124,7 @@ class Arranger : public QWidget {
SpinBox* lenEntry;
bool showTrackinfoFlag;
WidgetStack* trackInfo;
- //QStackedWidget* trackInfo;
- QScrollBar* infoScroll;
- //MidiTrackInfoBase* midiTrackInfo;
+ ScrollBar* infoScroll;
MidiTrackInfo* midiTrackInfo;
AudioStrip* waveTrackInfo;
QWidget* noTrackInfo;
@@ -115,7 +137,6 @@ class Arranger : public QWidget {
QToolButton* ib;
int trackInfoType;
Splitter* split;
- ///QMenu* pop;
int songType;
PosLabel* cursorPos;
SpinBox* globalTempoSpinBox;
@@ -138,31 +159,27 @@ class Arranger : public QWidget {
void songChanged(int);
void modeChange(int);
void setTime(unsigned);
- void headerMoved();
void globalPitchChanged(int);
void globalTempoChanged(int);
void setTempo50();
void setTempo100();
void setTempo200();
- //void seek();
void verticalScrollSetYpos(unsigned);
void horizontalZoomIn();
void horizontalZoomOut();
+ void focusCanvas();
signals:
- void redirectWheelEvent(QWheelEvent*);
void editPart(MusECore::Track*);
void selectionChanged();
void dropSongFile(const QString&);
void dropMidiFile(const QString&);
void startEditor(MusECore::PartList*, int);
void toolChanged(int);
- //void addMarker(int);
void setUsedTool(int);
protected:
- virtual void wheelEvent(QWheelEvent* e);
virtual void keyPressEvent(QKeyEvent* event);
public slots:
diff --git a/muse2/muse/arranger/arrangerview.cpp b/muse2/muse/arranger/arrangerview.cpp
index d38b5284..da510c0e 100644
--- a/muse2/muse/arranger/arrangerview.cpp
+++ b/muse2/muse/arranger/arrangerview.cpp
@@ -37,7 +37,6 @@
#include <QMessageBox>
#include <QMimeData>
#include <QPushButton>
-//#include <QResizeEvent>
#include <QScrollArea>
#include <QScrollBar>
#include <QSettings>
@@ -59,7 +58,6 @@
#include "mtscale.h"
#include "scoreedit.h"
#include "shortcuts.h"
-#include "sig.h"
#include "song.h"
#include "structure.h"
#include "tb1.h"
@@ -78,15 +76,12 @@ namespace MusEGui {
ArrangerView::ArrangerView(QWidget* parent)
: TopWin(TopWin::ARRANGER, parent, "arrangerview", Qt::Window)
{
- //using MusEGlobal::muse;
-
- //setAttribute(Qt::WA_DeleteOnClose);
setWindowTitle(tr("MusE: Arranger"));
- setFocusPolicy(Qt::StrongFocus);
+ setFocusPolicy(Qt::NoFocus);
arranger = new Arranger(this, "arranger");
setCentralWidget(arranger);
- setFocusProxy(arranger);
+ //setFocusProxy(arranger);
scoreOneStaffPerTrackMapper = new QSignalMapper(this);
scoreAllInOneMapper = new QSignalMapper(this);
@@ -658,7 +653,6 @@ void ArrangerView::populateAddTrack()
void ArrangerView::addNewTrack(QAction* action)
{
MusEGlobal::song->addNewTrack(action, MusEGlobal::muse->arranger()->curTrack()); // Insert at current selected track.
- //MusEGlobal::song->addNewTrack(action); // Add at end.
}
void ArrangerView::updateShortcuts()
diff --git a/muse2/muse/arranger/pcanvas.cpp b/muse2/muse/arranger/pcanvas.cpp
index 897ae1c8..f3e71916 100644
--- a/muse2/muse/arranger/pcanvas.cpp
+++ b/muse2/muse/arranger/pcanvas.cpp
@@ -34,7 +34,6 @@
#include <QLineEdit>
#include <QMenu>
#include <QMessageBox>
-//#include <QPainter>
#include <QUrl>
#include <QPoint>
@@ -48,7 +47,6 @@
#include "globals.h"
#include "icons.h"
#include "event.h"
-//#include "xml.h"
#include "wave.h"
#include "audio.h"
#include "shortcuts.h"
@@ -65,8 +63,6 @@
#include "dialogs.h"
#include "widgets/pastedialog.h"
-//#define ABS(x) ((x) < 0) ? -(x) : (x))
-//#define ABS(x) (x>=0?x:-x)
#define ABS(x) (abs(x))
#define EDITING_FINISHED_TIMEOUT 50 /* in milliseconds */
@@ -108,7 +104,6 @@ PartCanvas::PartCanvas(int* r, QWidget* parent, int sx, int sy)
setMouseTracking(true);
drag = DRAG_OFF;
curColorIndex = 0;
- //automation.currentCtrl = 0;
automation.currentCtrlValid = false;
automation.controllerState = doNothing;
automation.moveController = false;
@@ -117,7 +112,6 @@ PartCanvas::PartCanvas(int* r, QWidget* parent, int sx, int sy)
PartCanvas::~PartCanvas()
{
- //items.clearDelete();
}
//---------------------------------------------------------
@@ -131,7 +125,6 @@ int PartCanvas::y2pitch(int y) const
int idx = 0;
for (MusECore::iTrack it = tl->begin(); it != tl->end(); ++it, ++idx) {
int h = (*it)->height();
- // if ((y >= yy) && (y < yy+h))
if (y < yy+h)
break;
yy += h;
@@ -177,7 +170,6 @@ void PartCanvas::returnPressed()
//twice. the second call would cause a crash, however!
MusECore::Part* oldPart = editPart->part();
MusECore::Part* newPart = oldPart->clone();
- //printf("PartCanvas::returnPressed before msgChangePart oldPart refs:%d Arefs:%d newPart refs:%d Arefs:%d\n", oldPart->events()->refCount(), oldPart->events()->arefCount(), newPart->events()->refCount(), newPart->events()->arefCount());
newPart->setName(lineEditor->text());
// Indicate do undo, and do port controller values but not clone parts.
@@ -290,6 +282,7 @@ void PartCanvas::moveCanvasItems(CItemList& items, int dp, int dx, DragType dtyp
{
CItem* ci = ici->second;
+ // DELETETHIS 5
// If this item's part is in the parts2change list, change the item's part to the new part.
//MusECore::Part* pt = ci->part();
//iP2C ip2c = parts2change.find(pt);
@@ -323,7 +316,6 @@ void PartCanvas::moveCanvasItems(CItemList& items, int dp, int dx, DragType dtyp
// return false, if copy/move not allowed
//---------------------------------------------------------
-// Changed by T356.
bool PartCanvas::moveItem(MusECore::Undo& operations, CItem* item, const QPoint& newpos, DragType t)
{
NPart* npart = (NPart*) item;
@@ -380,12 +372,7 @@ bool PartCanvas::moveItem(MusECore::Undo& operations, CItem* item, const QPoint&
if(t == MOVE_MOVE)
item->setPart(dpart);
if (t == MOVE_COPY && !clone) {
- //dpart->events()->incARef(-1); // the later MusEGlobal::song->applyOperationGroup() will increment it
- // so we must decrement it first :/
-
- //
// Copy Events
- //
MusECore::EventList* se = spart->events();
MusECore::EventList* de = dpart->events();
for (MusECore::iEvent i = se->begin(); i != se->end(); ++i) {
@@ -400,7 +387,7 @@ bool PartCanvas::moveItem(MusECore::Undo& operations, CItem* item, const QPoint&
dpart->events()->incARef(-1); // the later MusEGlobal::song->applyOperationGroup() will increment it
// so we must decrement it first :/
// These will not increment ref count, and will not chain clones...
- // TODO: is this comment still correct (by flo93)? i doubt it!
+ // TODO DELETETHIS: is the above comment still correct (by flo93)? i doubt it!
operations.push_back(MusECore::UndoOp(MusECore::UndoOp::AddPart,dpart));
}
else if (t == MOVE_MOVE) {
@@ -412,7 +399,7 @@ bool PartCanvas::moveItem(MusECore::Undo& operations, CItem* item, const QPoint&
// so we must increment it first :/
dpart->setSelected(spart->selected());
// These will increment ref count if not a clone, and will chain clones...
- // TODO: is this comment still correct (by flo93)? i doubt it!
+ // TODO DELETETHIS: is the above comment still correct (by flo93)? i doubt it!
operations.push_back(MusECore::UndoOp(MusECore::UndoOp::ModifyPart,spart, dpart, true, false));
spart->setSelected(false);
@@ -456,7 +443,6 @@ void PartCanvas::songIsClearing()
void PartCanvas::partsChanged()
{
- //items.clear();
int sn = -1;
if (curItem) sn=curItem->part()->sn();
curItem=NULL;
@@ -975,7 +961,7 @@ MusECore::Track* PartCanvas::y2Track(int y) const
void PartCanvas::keyPress(QKeyEvent* event)
{
int key = event->key();
-
+// DELETETHIS 10
// if (_tool == AutomationTool) { // can't get the cursor pos to work right, skipping for now
// // clear all the automation parameters
// automation.moveController=false;
@@ -992,7 +978,6 @@ void PartCanvas::keyPress(QKeyEvent* event)
// to "false" some usec ago by returnPressed, called by editingFinished.
if ( key == Qt::Key_Return || key == Qt::Key_Enter )
{
- //returnPressed(); commented out by flo
return;
}
// the below CAN indeed happen.
@@ -1090,9 +1075,8 @@ void PartCanvas::keyPress(QKeyEvent* event)
emit selectTrackBelow();
return;
}
- //
+
// Shortcuts that require selected parts from here
- //
if (!curItem) {
if (items.size()==0) {
event->ignore(); // give global accelerators a chance
@@ -1202,11 +1186,10 @@ void PartCanvas::keyPress(QKeyEvent* event)
MusECore::Track* track = curItem->part()->track();//top->part()->track();
track = y2Track(track->y() - 1);
- //If we're at topmost, leave
- if (!track) {
- //printf("no track above!\n");
+ //If we're at topmost (no track above), leave
+ if (!track)
return;
- }
+
int middle = curItem->x() + curItem->part()->lenTick()/2;
CItem *aboveL = 0, *aboveR = 0;
//Upper limit: song end, lower limit: song start
@@ -1367,7 +1350,7 @@ void PartCanvas::keyPress(QKeyEvent* event)
// draws a part
//---------------------------------------------------------
-#if 0
+#if 0 // DELETETHIS 430 WHOA!
void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect)
{
int from = rect.x();
@@ -1794,7 +1777,6 @@ void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect)
int from = rect.x();
int to = from + rect.width();
- //printf("from %d to %d\n", from,to);
MusECore::Part* part = ((NPart*)item)->part();
int pTick = part->tick();
from -= pTick;
@@ -1817,17 +1799,13 @@ void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect)
// Item bounding box x is in tick coordinates, same as rectangle.
if((rr & mr).isNull())
- {
- //printf("PartCanvas::drawItem rectangle is null\n");
return;
- }
- //p.save();
p.setWorldMatrixEnabled(false);
// NOTE: Optimization: For each item, hasHiddenEvents() is called once in Canvas::draw(), and we use cachedHasHiddenEvents().
// Not used for now.
- //int het = part->cachedHasHiddenEvents();
+ //int het = part->cachedHasHiddenEvents(); DELETETHIS or FIXME or whatever?
int het = part->hasHiddenEvents();
int xs_0 = rr.x();
@@ -1923,18 +1901,13 @@ void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect)
int h = rr.height();
double s = double(h) / 4.0;
int y0 = ys_0;
- //int y1 = y0 + lrint(s);
int y2 = y0 + lrint(s * 2.0);
- //int y3 = y0 + lrint(s * 3.0);
int y4 = y0 + h;
- //QPoint points[12];
QPoint points[8];
int pts;
- //
// Fill the part rectangles, accounting for hidden events by using 'jagged' edges...
- //
p.setBrush(brush);
p.setPen(Qt::NoPen);
@@ -1946,7 +1919,7 @@ void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect)
pts = 0;
if(het == (MusECore::Part::LeftEventsHidden | MusECore::Part::RightEventsHidden))
{
- //points[pts++] = QPoint(xs_0, y0);
+ //points[pts++] = QPoint(xs_0, y0); DELETETHIS 11
//points[pts++] = QPoint(xe_0, y0);
//points[pts++] = QPoint(xe_j, y1);
//points[pts++] = QPoint(xe_0, y2);
@@ -1969,7 +1942,7 @@ void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect)
else
if(het == MusECore::Part::LeftEventsHidden)
{
- //points[pts++] = QPoint(xs_0, y0);
+ //points[pts++] = QPoint(xs_0, y0); DELETETHIS 7
//points[pts++] = QPoint(xe_0, y0);
//points[pts++] = QPoint(xe_0, y4);
//points[pts++] = QPoint(xs_0, y4);
@@ -1988,7 +1961,7 @@ void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect)
else
if(het == MusECore::Part::RightEventsHidden)
{
- //points[pts++] = QPoint(xs_0, y0);
+ //points[pts++] = QPoint(xs_0, y0); DELETETHIS 7
//points[pts++] = QPoint(xe_0, y0);
//points[pts++] = QPoint(xe_j, y1);
//points[pts++] = QPoint(xe_0, y2);
@@ -2005,13 +1978,12 @@ void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect)
p.drawConvexPolygon(points, pts);
}
- //
// Draw remaining 'hidden events' decorations with 'jagged' edges...
- //
int part_r, part_g, part_b, brightness, color_brightness;
MusEGlobal::config.partColors[cidx].getRgb(&part_r, &part_g, &part_b);
brightness = part_r*29 + part_g*59 + part_b*12;
+ // DELETETHIS 4 ??
//if ((brightness < 12000 || part->selected()) && !part->mute() && !item->isMoving())
// color_brightness=223; // too dark: use lighter color
//else
@@ -2022,11 +1994,10 @@ void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect)
color_brightness=180; //255; // too dark: use lighter color
QColor c(color_brightness,color_brightness,color_brightness, MusEGlobal::config.globalAlphaBlend);
p.setBrush(QBrush(MusECore::gGradientFromQColor(c, rr.topLeft(), rr.bottomLeft())));
- //p.setBrush(QBrush(c));
if(het & MusECore::Part::RightEventsHidden)
{
pts = 0;
- //points[pts++] = QPoint(xe_0, y0);
+ //points[pts++] = QPoint(xe_0, y0); DELETETHIS 5
//points[pts++] = QPoint(xe_0, y4);
//points[pts++] = QPoint(xe_j, y3);
//points[pts++] = QPoint(xe_0, y2);
@@ -2041,7 +2012,7 @@ void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect)
if(het & MusECore::Part::LeftEventsHidden)
{
pts = 0;
- //points[pts++] = QPoint(xs_0, y0);
+ //points[pts++] = QPoint(xs_0, y0); DELETETHIS 5
//points[pts++] = QPoint(xs_j, y1);
//points[pts++] = QPoint(xs_0, y2);
//points[pts++] = QPoint(xs_j, y3);
@@ -2056,7 +2027,6 @@ void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect)
}
else
{
- //p.fillRect(rr, brush);
p.fillRect(rr & mr, brush); // Respect the requested drawing rectangle. Gives speed boost!
}
@@ -2064,11 +2034,8 @@ void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect)
if(part->mute())
{
p.setPen(Qt::NoPen);
- //brush.setStyle(Qt::DiagCrossPattern);
brush.setStyle(Qt::Dense7Pattern);
- //p.fillRect(rr, brush); // FIXME: Some shifting going on
- //p.fillRect(QRect(rr.x(), rr.y(), rr.width() + 1, rr.height() + 1), brush); // Same here
p.fillRect(rr & mr, brush); // Respect the requested drawing rectangle. Gives speed boost!
}
@@ -2093,7 +2060,7 @@ void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect)
p.setWorldMatrixEnabled(false);
- #if 0
+ #if 0 // DELETETHIS 13
//
// Now draw the borders...
// Works great but requires clones be drawn with the highest priority on top of all other parts, in Canvas::draw.
@@ -2108,7 +2075,7 @@ void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect)
//#else
#endif
- #if 1
+ #if 1 // DELETETHIS remove wrapping #if
//
// Now draw the borders, using custom segments...
//
@@ -2258,12 +2225,11 @@ void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect)
int part_r, part_g, part_b, brightness;
// Since we'll draw the text on the bottom (to accommodate drum 'slivers'),
// get the lowest colour in the gradient used to draw the part.
- //QRect rr = map(r);
QRect tr = rr;
tr.setX(tr.x() + 3);
MusECore::gGradientFromQColor(MusEGlobal::config.partColors[cidx], tr.topLeft(), tr.bottomLeft()).stops().last().second.getRgb(&part_r, &part_g, &part_b);
brightness = part_r*29 + part_g*59 + part_b*12;
- //bool rev = (brightness < 12000 || part->selected()) && !part->mute() && !item->isMoving();
+ //bool rev = (brightness < 12000 || part->selected()) && !part->mute() && !item->isMoving(); DELETETHIS
bool rev = brightness >= 12000 && !part->selected();
p.setFont(MusEGlobal::config.fonts[4]);
if (rev)
@@ -2278,7 +2244,6 @@ void PartCanvas::drawItem(QPainter& p, const CItem* item, const QRect& rect)
p.drawText(tr, Qt::AlignBottom|Qt::AlignLeft, part->name());
}
- //p.restore();
p.setWorldMatrixEnabled(true);
}
@@ -2292,7 +2257,7 @@ void PartCanvas::drawMoving(QPainter& p, const CItem* item, const QRect&)
p.setPen( Qt::black);
MusECore::Part* part = ((NPart*)item)->part();
QColor c(part->mute() ? Qt::white : MusEGlobal::config.partColors[part->colorIndex()]);
- //c.setAlpha(MusEGlobal::config.globalAlphaBlend);
+ //c.setAlpha(MusEGlobal::config.globalAlphaBlend); DELETETHIS
c.setAlpha(128); // Fix this regardless of global setting. Should be OK.
p.setBrush(c);
p.drawRect(item->mp().x(), item->mp().y(), item->width(), item->height());
@@ -2314,7 +2279,7 @@ void PartCanvas::drawMidiPart(QPainter& p, const QRect&, MusECore::EventList* ev
int part_r, part_g, part_b, brightness;
MusEGlobal::config.partColors[pt->colorIndex()].getRgb(&part_r, &part_g, &part_b);
brightness = part_r*29 + part_g*59 + part_b*12;
- //if ((brightness < 12000 || pt->selected()) && !pt->mute())
+ //if ((brightness < 12000 || pt->selected()) && !pt->mute()) DELETETHIS 4
// color_brightness=192; // too dark: use lighter color
//else
// color_brightness=64; // otherwise use dark color
@@ -2506,8 +2471,6 @@ void PartCanvas::drawMidiPart(QPainter& p, const QRect&, MusECore::EventList* ev
if (te < (from + pTick))
continue;
- //if (te > (to + pTick))
- // te = to + pTick;
if (te >= (to + pTick))
te = lrint(rmapxDev_f(rmapx_f(to + pTick) - 1.0));
@@ -2537,9 +2500,7 @@ void PartCanvas::drawMidiPart(QPainter& p, const QRect&, MusECore::EventList* ev
void PartCanvas::drawWavePart(QPainter& p,
const QRect& bb, MusECore::WavePart* wp, const QRect& _pr)
{
- //QRect rr = p.worldMatrix().mapRect(bb); // Gives inconsistent positions. Source shows wrong operation for our needs.
QRect rr = map(bb); // Use our own map instead.
- //QRect pr = p.worldMatrix().mapRect(_pr);
QRect pr = map(_pr);
p.save();
@@ -2592,10 +2553,7 @@ void PartCanvas::drawWavePart(QPainter& p,
if(ex > x2)
ex = x2;
if (h < 20) {
- //
// combine multi channels into one waveform
- //
- //printf("PartCanvas::drawWavePart i:%d ex:%d\n", i, ex);
for (; i < ex; i++) {
MusECore::SampleV sa[channels];
@@ -2620,14 +2578,12 @@ void PartCanvas::drawWavePart(QPainter& p,
}
}
else {
- //
// multi channel display
- //
int hm = hh / (channels * 2);
int cc = hh % (channels * 2) ? 0 : 1;
for (; i < ex; i++) {
y = pr.y() + hm;
- MusECore::SampleV sa[channels];
+ MusECore::SampleV sa[channels];
xScale = MusEGlobal::tempomap.deltaTick2frame(postick, postick + tickstep);
f.read(sa, xScale, pos);
postick += tickstep;
@@ -3147,10 +3103,6 @@ void PartCanvas::dragEnterEvent(QDragEnterEvent* event)
}
//---------------------------------------------------------
-// dragvent
-//---------------------------------------------------------
-
-//---------------------------------------------------------
// dropEvent
//---------------------------------------------------------
@@ -3394,7 +3346,7 @@ void PartCanvas::drawCanvas(QPainter& p, const QRect& rect)
// does NOT depend on the update rectangle (except to check intersection). That's why this issue
// does not show up there. Should probably try to make that routine more efficient, just like here. Tim. p4.0.30
QRect r(mx, yy, mw, th);
- //if(r.intersects(mr))
+ //if(r.intersects(mr)) DELETETHIS
{
if (!track->isMidiTrack() && (track->type() != MusECore::Track::WAVE)) {
//QRect r = rect & QRect(x, yy, w, track->height());
@@ -3402,6 +3354,7 @@ void PartCanvas::drawCanvas(QPainter& p, const QRect& rect)
//p.setPen(baseColor);
}
+ // DELETETHIS 13
// This was redundant drawing. Not required, done via drawTopItem in Canvas::draw
/*
//p.setWorldMatrixEnabled(true);
@@ -3418,7 +3371,6 @@ void PartCanvas::drawCanvas(QPainter& p, const QRect& rect)
}
p.restore();
- //p.setWorldMatrixEnabled(true);
}
//---------------------------------------------------------
@@ -3426,36 +3378,25 @@ void PartCanvas::drawCanvas(QPainter& p, const QRect& rect)
//---------------------------------------------------------
void PartCanvas::drawTopItem(QPainter& p, const QRect& rect)
{
- //int x = rect.x();
- //int y = rect.y();
- //int w = rect.width();
- //int h = rect.height();
-
- // Changed to draw in device coordinate space instead of virtual, transformed space. Tim. p4.0.30
-
//QRect mr = p.transform().mapRect(rect); // Gives inconsistent positions. Source shows wrong operation for our needs.
QRect mr = map(rect); // Use our own map instead.
- //printf("PartCanvas::drawTopItem x:%d y:%d w:%d h:%d\n", rect.x(), rect.y(), rect.width(), rect.height());
-
int mx = mr.x();
int my = mr.y();
int mw = mr.width();
int mh = mr.height();
QColor baseColor(MusEGlobal::config.partCanvasBg.light(104));
- //p.setPen(baseColor);
p.save();
p.setWorldMatrixEnabled(false);
MusECore::TrackList* tl = MusEGlobal::song->tracks();
int yoff = -rmapy(yorg) - ypos;
- //int yy = 0;
int yy = yoff;
int th;
for (MusECore::iTrack it = tl->begin(); it != tl->end(); ++it) {
- //if (yy > y + h)
+ //if (yy > y + h) DELETETHIS
if (yy > my + mh)
break;
MusECore::Track* track = *it;
@@ -3463,15 +3404,15 @@ void PartCanvas::drawTopItem(QPainter& p, const QRect& rect)
if (!th)
continue;
if (!track->isMidiTrack()) { // draw automation
- //QRect r = rect & QRect(x, yy, w, track->height());
+ //QRect r = rect & QRect(x, yy, w, track->height()); DELETETHIS
QRect r(mx, yy, mw, th);
if(r.intersects(mr))
{
drawAutomation(p, r, (MusECore::AudioTrack*)track);
- //p.setPen(baseColor);
+ //p.setPen(baseColor); DELETETHIS
}
}
- //yy += track->height();
+ //yy += track->height(); DELETETHIS
yy += th;
}
@@ -3482,22 +3423,16 @@ void PartCanvas::drawTopItem(QPainter& p, const QRect& rect)
int width = mapx(MusEGlobal::song->cpos()) - mapx(startPos);
if (MusEGlobal::song->cpos() < startPos) {
- //p.setWorldMatrixEnabled(true);
p.restore();
return; // no drawing if we are before punch out
}
if (MusEGlobal::song->punchout() && MusEGlobal::song->cpos() > MusEGlobal::song->rpos()) {
- //p.setWorldMatrixEnabled(true);
p.restore();
return; // no drawing if we are beyond punch out.
}
- ///p.save();
- ///p.resetTransform();
-
// write recording while it happens to get feedback
// should be enhanced with solution that draws waveform also
- //int yPos=0;
int yPos = yoff;
if (MusEGlobal::song->record() && MusEGlobal::audio->isPlaying()) {
for (MusECore::iTrack it = tl->begin(); it != tl->end(); ++it) {
@@ -3522,7 +3457,6 @@ void PartCanvas::drawTopItem(QPainter& p, const QRect& rect)
}
}
p.restore();
- //p.setWorldMatrixEnabled(true);
// draw midi events on
yPos=0;
@@ -3588,13 +3522,13 @@ void PartCanvas::drawAudioTrack(QPainter& p, const QRect& r, const QRect& bbox,
p.setPen(Qt::black);
QColor c(Qt::gray);
c.setAlpha(MusEGlobal::config.globalAlphaBlend);
- //QLinearGradient gradient(r.topLeft(), r.bottomLeft());
QLinearGradient gradient(mex + 1, mey + 1, mex + 1, mey + meh - 1); // Inside the border
gradient.setColorAt(0, c);
gradient.setColorAt(1, c.darker());
QBrush brush(gradient);
p.fillRect(mr, brush); // p4.0.30 ...
+ // DELETETHIS 6
//int xx = -rmapx(xorg) - xpos;
//printf("PartCanvas::drawAudioTrack x:%d y:%d w:%d h:%d th:%d xx:%d\n", r.x(), r.y(), r.width(), r.height(), t->height(), xx);
//if(r.x() <= xx)
@@ -3604,7 +3538,7 @@ void PartCanvas::drawAudioTrack(QPainter& p, const QRect& r, const QRect& bbox,
if(mex >= mx && mex <= mx + mw)
p.drawLine(mex, my, mex, my + mh - 1); // The left edge
- //if(mex + mew >= mx && mex + mew <= mx + mw)
+ //if(mex + mew >= mx && mex + mew <= mx + mw) DELETETHIS 2
// p.drawLine(mex + mew, my, mex + mew, my + mh - 1); // The right edge. Not used - infinite to the right
if(mey >= my && mey <= my + mh)
p.drawLine(mx, mey, mx + mw - 1, mey); // The top edge
@@ -3647,7 +3581,6 @@ void PartCanvas::drawAutomation(QPainter& p, const QRect& rr, MusECore::AudioTra
int ypixel = oldY;
double min, max;
cl->range(&min,&max);
- //bool discrete = cl->valueType() == VAL_BOOL || cl->mode() == MusECore::CtrlList::DISCRETE;
bool discrete = cl->mode() == MusECore::CtrlList::DISCRETE;
QPen pen1(cl->color(), 0);
QPen pen2(cl->color(), 2);
@@ -3658,7 +3591,6 @@ void PartCanvas::drawAutomation(QPainter& p, const QRect& rr, MusECore::AudioTra
{
double y;
if (cl->valueType() == MusECore::VAL_LOG ) { // use db scale for volume
- //printf("log conversion val=%f min=%f max=%f\n", cl->curVal(), min, max);
y = logToVal(cl->curVal(), min, max); // represent volume between 0 and 1
if (y < 0) y = 0.0;
}
@@ -3672,7 +3604,6 @@ void PartCanvas::drawAutomation(QPainter& p, const QRect& rr, MusECore::AudioTra
{
double y = ic->second.val;
if (cl->valueType() == MusECore::VAL_LOG ) { // use db scale for volume
- //printf("log conversion val=%f min=%f max=%f\n", cl->curVal(), min, max);
y = logToVal(y, min, max); // represent volume between 0 and 1
if (y < 0) y = 0.0;
}
@@ -3684,7 +3615,6 @@ void PartCanvas::drawAutomation(QPainter& p, const QRect& rr, MusECore::AudioTra
if (oldY==-1) oldY = ypixel;
- //printf(" line x1:%d x2:%d prevVal:%f nextVal:%f\n", leftX, currentPixel, prevVal, nextVal);
p.setPen(pen1);
if(discrete)
{
@@ -3712,12 +3642,10 @@ void PartCanvas::drawAutomation(QPainter& p, const QRect& rr, MusECore::AudioTra
}
if (xpixel <= rr.right())
{
- //printf(" endline prevVal:%f\n", prevVal);
p.setPen(pen1);
p.drawLine(xpixel, ypixel, rr.right(), ypixel);
}
}
- //p.restore();
}
@@ -3764,7 +3692,6 @@ void PartCanvas::checkAutomation(MusECore::Track * t, const QPoint &pointer, boo
int ypixel = oldY;
double min, max;
cl->range(&min,&max);
- //bool discrete = cl->valueType() == VAL_BOOL || cl->mode() == MusECore::CtrlList::DISCRETE; // Tim
bool discrete = cl->mode() == MusECore::CtrlList::DISCRETE;
// First check that there IS automation, ic == cl->end means no automation
@@ -3795,12 +3722,9 @@ void PartCanvas::checkAutomation(MusECore::Track * t, const QPoint &pointer, boo
xpixel = mapx(MusEGlobal::tempomap.frame2tick(ic->second.frame));
if (oldY==-1) oldY = ypixel;
- //printf(" oldX:%d oldY:%d xpixel:%d ypixel:%d\n", oldX, oldY, xpixel, ypixel);
bool foundIt=false;
if (addNewCtrl) {
- // check if we are reasonably close to a line
- //printf("xpixel=%d oldX=%d\n", xpixel, oldX);
double firstX=oldX;
double lastX=xpixel;
double firstY=oldY;
@@ -3808,8 +3732,6 @@ void PartCanvas::checkAutomation(MusECore::Track * t, const QPoint &pointer, boo
double proportion = (currX-firstX)/(lastX-firstX);
- //if ( (currX > lastX && firstY!=lastY) // omit special cases.
- // || firstX==lastX ) {
if((currX < oldX) || (currX > lastX) || (firstX==lastX) )
{
oldX = xpixel;
@@ -3825,7 +3747,6 @@ void PartCanvas::checkAutomation(MusECore::Track * t, const QPoint &pointer, boo
// /
// 1
double calcY = (lastY-firstY)*proportion+firstY;
- //printf("calcY=%f currY=%d\n", calcY, currY);
if(ABS(calcY-currY) < circumference || (xpixel == oldX && ABS(currX-xpixel) < circumference))
foundIt=true;
@@ -3847,9 +3768,7 @@ void PartCanvas::checkAutomation(MusECore::Track * t, const QPoint &pointer, boo
automation.currentCtrlValid = false;
automation.controllerState = addNewController;
}else {
- //automation.currentCtrl=&ic->second;
automation.currentCtrlFrame = ic->second.frame;
- //automation.currentCtrlVal = ic->second.val;
automation.currentCtrlValid = true;
automation.controllerState = movingController;
}
@@ -3869,7 +3788,6 @@ void PartCanvas::checkAutomation(MusECore::Track * t, const QPoint &pointer, boo
automation.controllerState = addNewController;
automation.currentCtrlList = cl;
automation.currentTrack = t;
- //automation.currentCtrl = 0;
automation.currentCtrlValid = false;
return;
}
@@ -3877,7 +3795,6 @@ void PartCanvas::checkAutomation(MusECore::Track * t, const QPoint &pointer, boo
}
// if there are no hits we default to clearing all the data
automation.controllerState = doNothing;
- //automation.currentCtrl = 0;
automation.currentCtrlValid = false;
automation.currentCtrlList = 0;
automation.currentTrack = 0;
@@ -3886,7 +3803,6 @@ void PartCanvas::checkAutomation(MusECore::Track * t, const QPoint &pointer, boo
void PartCanvas::controllerChanged(MusECore::Track* t)
{
- //redraw();
redraw((QRect(0, mapy(t->y()), width(), rmapy(t->height())))); // TODO Check this - correct?
}
@@ -3911,19 +3827,15 @@ void PartCanvas::processAutomationMovements(QPoint pos, bool addPoint)
if (automation.controllerState == addNewController)
{
- //printf("adding a new ctrler!\n");
int frame = MusEGlobal::tempomap.tick2frame(pos.x());
// FIXME Inefficient to add with wait here, then remove and add with wait again below. Tim.
MusEGlobal::audio->msgAddACEvent((MusECore::AudioTrack*)automation.currentTrack, automation.currentCtrlList->id(), frame, 1.0 /*dummy value */);
- //MusEGlobal::song->addACEvent((MusECore::AudioTrack*)automation.currentTrack, automation.currentCtrlList->id(), frame, 1.0 /*dummy value */);
MusECore::iCtrl ic=automation.currentCtrlList->begin();
for (; ic !=automation.currentCtrlList->end(); ++ic) {
MusECore::CtrlVal &cv = ic->second;
if (cv.frame == frame) {
- //automation.currentCtrl = &cv;
automation.currentCtrlFrame = cv.frame;
- //automation.currentCtrlVal = cv.val;
automation.currentCtrlValid = true;
automation.controllerState = movingController;
break;
@@ -3937,7 +3849,6 @@ void PartCanvas::processAutomationMovements(QPoint pos, bool addPoint)
for (; ic !=automation.currentCtrlList->end(); ++ic)
{
MusECore::CtrlVal &cv = ic->second;
- //if (&cv == automation.currentCtrl)
if (cv.frame == automation.currentCtrlFrame)
{
currFrame = cv.frame;
@@ -3958,9 +3869,7 @@ void PartCanvas::processAutomationMovements(QPoint pos, bool addPoint)
// there is only one value at t, and the next value at t+1, and so on.
// Also these are maps, not multimaps. p4.0.32 Tim.
int newFrame = MusEGlobal::tempomap.tick2frame(pos.x());
- //if(currFrame == 0)
- // newFrame = 0; // Force first item to stay at x = 0.
- //else
+
if (newFrame <= prevFrame)
newFrame=prevFrame + (icc == automation.currentCtrlList->begin() ? 0: 1); // Only first item is allowed to go to zero x.
if (nextFrame!=-1 && newFrame >= nextFrame) newFrame=nextFrame-1;
@@ -3968,7 +3877,6 @@ void PartCanvas::processAutomationMovements(QPoint pos, bool addPoint)
int posy=mapy(pos.y());
int tracky = mapy(automation.currentTrack->y());
int trackHeight = automation.currentTrack->height();
- //printf("posy=%d tracky=%d trackHeight=%d\n", posy,tracky,trackHeight);
int mouseY = trackHeight - (posy - tracky)-2;
double yfraction = ((double)mouseY)/automation.currentTrack->height();
@@ -3979,7 +3887,6 @@ void PartCanvas::processAutomationMovements(QPoint pos, bool addPoint)
if (automation.currentCtrlList->valueType() == MusECore::VAL_LOG ) { // use db scale for volume
printf("log conversion val=%f min=%f max=%f\n", yfraction, min, max);
cvval = valToLog(yfraction, min, max);
- //printf("calc yfraction = %f v=%f ",yfraction,cvval);
if (cvval< min) cvval=min;
if (cvval>max) cvval=max;
}
@@ -3987,7 +3894,6 @@ void PartCanvas::processAutomationMovements(QPoint pos, bool addPoint)
// we need to set val between 0 and 1 (unless integer)
cvval = yfraction * (max-min) + min;
// 'Snap' to integer or boolean
- //if (automation.currentCtrlList->valueType() == VAL_INT || automation.currentCtrlList->valueType() == VAL_BOOL)
if (automation.currentCtrlList->mode() == MusECore::CtrlList::DISCRETE)
cvval = rint(cvval + 0.1); // LADSPA docs say add a slight bias to avoid rounding errors. Try this.
if (cvval< min) cvval=min;
@@ -3995,18 +3901,12 @@ void PartCanvas::processAutomationMovements(QPoint pos, bool addPoint)
}
automation.currentCtrlFrame = newFrame;
- //automation.currentCtrlVal = cvval;
automation.currentCtrlValid = true;
if(icc != automation.currentCtrlList->end())
MusEGlobal::audio->msgChangeACEvent((MusECore::AudioTrack*)automation.currentTrack, automation.currentCtrlList->id(), icc->second.frame, newFrame, cvval);
- //MusEGlobal::song->changeACEvent((MusECore::AudioTrack*)automation.currentTrack, automation.currentCtrlList->id(), icc->second.frame, newFrame, cvval);
else
MusEGlobal::audio->msgAddACEvent((MusECore::AudioTrack*)automation.currentTrack, automation.currentCtrlList->id(), newFrame, cvval);
- //MusEGlobal::song->addACEvent((MusECore::AudioTrack*)automation.currentTrack, automation.currentCtrlList->id(), newFrame, cvval);
-
- // Not needed. Redraw is now handled by msgXXX().
- //controllerChanged(automation.currentTrack);
}
}
@@ -4019,7 +3919,6 @@ void PartCanvas::processAutomationMovements(QPoint pos, bool addPoint)
//---------------------------------------------------------
double PartCanvas::logToVal(double inLog, double min, double max)
{
- //printf("logToVal inLog %f :", inLog);
if (inLog < min) inLog = min;
if (inLog > max) inLog = max;
double linMin = 20.0*MusECore::fast_log10(min);
@@ -4027,7 +3926,6 @@ double PartCanvas::logToVal(double inLog, double min, double max)
double linVal = 20.0*MusECore::fast_log10(inLog);
double outVal = (linVal-linMin) / (linMax - linMin);
- // printf("inLog %f outVal %f linVal %f min %f max %f dbMin %f dbMax %f\n", inLog, outVal, linVal, min, max, linMin, linMax);
return outVal;
}
diff --git a/muse2/muse/arranger/pcanvas.h b/muse2/muse/arranger/pcanvas.h
index 34395688..7882ee5c 100644
--- a/muse2/muse/arranger/pcanvas.h
+++ b/muse2/muse/arranger/pcanvas.h
@@ -71,7 +71,6 @@ class NPart : public CItem {
enum ControllerVals { doNothing, movingController, addNewController };
struct AutomationObject {
- //MusECore::CtrlVal *currentCtrl;
int currentCtrlFrame;
bool currentCtrlValid;
MusECore::CtrlList *currentCtrlList;
@@ -99,8 +98,6 @@ class PartCanvas : public Canvas {
AutomationObject automation;
- //std::vector<TrackAutomationView*> automationViews;
-
virtual void keyPress(QKeyEvent*);
virtual void mousePress(QMouseEvent*);
virtual void mouseMove(QMouseEvent* event);
@@ -137,9 +134,7 @@ class PartCanvas : public Canvas {
enum paste_mode_t { PASTEMODE_MIX, PASTEMODE_MOVEALL, PASTEMODE_MOVESOME };
void paste(bool clone = false, paste_mode_t paste_mode = PASTEMODE_MIX, bool to_single_track=false, int amount=1, int raster=1536);
MusECore::Undo pasteAt(const QString&, MusECore::Track*, unsigned int, bool clone = false, bool toTrack = true, int* finalPosPtr = NULL, std::set<MusECore::Track*>* affected_tracks = NULL);
- //MusECore::Part* readClone(MusECore::Xml&, MusECore::Track*, bool toTrack = true);
void drawWavePart(QPainter&, const QRect&, MusECore::WavePart*, const QRect&);
- //void drawMidiPart(QPainter&, const QRect& rect, MusECore::EventList* events, MusECore::MidiTrack*mt, const QRect& r, int pTick, int from, int to);
void drawMidiPart(QPainter&, const QRect& rect, MusECore::EventList* events, MusECore::MidiTrack*mt, MusECore::MidiPart*pt, const QRect& r, int pTick, int from, int to);
MusECore::Track* y2Track(int) const;
void drawAudioTrack(QPainter& p, const QRect& r, const QRect& bbox, MusECore::AudioTrack* track);
diff --git a/muse2/muse/arranger/tlist.cpp b/muse2/muse/arranger/tlist.cpp
index 0ed201bf..b5fa2a1a 100644
--- a/muse2/muse/arranger/tlist.cpp
+++ b/muse2/muse/arranger/tlist.cpp
@@ -20,13 +20,10 @@
//
//=========================================================
-//#include "config.h"
-
#include <cmath>
#include <QKeyEvent>
#include <QLineEdit>
-//#include <QMenu>
#include <QMessageBox>
#include <QMouseEvent>
#include <QPainter>
@@ -95,7 +92,7 @@ TList::TList(Header* hdr, QWidget* parent, const char* name)
ypos = 0;
editMode = false;
editJustFinished=false;
- setFocusPolicy(Qt::StrongFocus);
+ setFocusPolicy(Qt::NoFocus);
setMouseTracking(true);
header = hdr;
@@ -106,7 +103,7 @@ TList::TList(Header* hdr, QWidget* parent, const char* name)
ctrl_edit = NULL;
mode = NORMAL;
- //setBackgroundMode(Qt::NoBackground); // ORCAN - FIXME
+ //setBackgroundMode(Qt::NoBackground); // ORCAN - FIXME. DELETETHIS?
//setAttribute(Qt::WA_OpaquePaintEvent);
resizeFlag = false;
@@ -312,7 +309,6 @@ void TList::paint(const QRect& r)
pm = addtrack_auxsendIcon;
break;
case MusECore::Track::AUDIO_SOFTSYNTH:
- //pm = waveIcon;
pm = synthIcon;
break;
}
@@ -401,7 +397,6 @@ void TList::paint(const QRect& r)
if (cl->isVisible())
countVisible++;
}
- //int count = ((MusECore::AudioTrack*)track)->controller()->size(); //commented out by flo: gives a "unused variable" warning
s.sprintf(" %d(%d) %s",countVisible, countAll, tr("visible").toAscii().data());
}
@@ -512,18 +507,14 @@ void TList::returnPressed()
}
}
- //MusECore::Track* track = editTrack->clone(false);
- //editTrack->setName(editor->text());
- //MusEGlobal::audio->msgChangeTrack(track, editTrack);
- // p4.0.46 Tim...
MusEGlobal::song->startUndo();
MusEGlobal::song->addUndo(MusECore::UndoOp(MusECore::UndoOp::ModifyTrackName,
editTrack,
editTrack->name().toLatin1().constData(),
editor->text().toLatin1().constData()));
editTrack->setName(editor->text());
- //MusEGlobal::song->update(SC_TRACK_MODIFIED);
- MusEGlobal::song->endUndo(-1);
+ //MusEGlobal::song->update(SC_TRACK_MODIFIED); //DELETETHIS
+ MusEGlobal::song->endUndo(-1); //uagh, why "-1", why no proper flags?
}
}
@@ -532,7 +523,7 @@ void TList::returnPressed()
editMode = false;
editJustFinished = true;
- if(editor->isVisible())
+ if(editor && editor->isVisible())
{
editor->blockSignals(true);
editor->hide();
@@ -541,13 +532,6 @@ void TList::returnPressed()
setFocus();
}
-void TList::chanValueChanged(int /*val*/)
-{
- //MusECore::Track* track = editTrack->clone(false);
- //((MusECore::MidiTrack*)editTrack)->setOutChannel(val-1);
- //MusEGlobal::audio->msgChangeTrack(track, editTrack);
-}
-
void TList::chanValueFinished()
{
if(editTrack)
@@ -569,7 +553,7 @@ void TList::chanValueFinished()
editTrack,
mt->outChannel(),
channel));
- //mt->setOutChannel(channel);
+ //mt->setOutChannel(channel); DELETETHIS 10 (only the comments of course)
MusEGlobal::audio->msgIdle(true);
//MusEGlobal::audio->msgSetTrackOutChannel(mt, channel);
mt->setOutChanAndUpdate(channel);
@@ -750,15 +734,11 @@ void TList::mouseDoubleClickEvent(QMouseEvent* ev)
editTrack = t;
if (editor == 0) {
editor = new QLineEdit(this);
- /*connect(editor, SIGNAL(returnPressed()),
- SLOT(returnPressed()));*/
- editor->setFrame(true);
+ editor->setFrame(false);
connect(editor, SIGNAL(editingFinished()), SLOT(returnPressed()));
}
- //editor->blockSignals(true);
editor->setText(editTrack->name());
- //editor->blockSignals(false);
- editor->end(false);
+ editor->selectAll();
editor->setGeometry(colx, coly, colw, colh);
editMode = true;
editor->show();
@@ -772,16 +752,21 @@ void TList::mouseDoubleClickEvent(QMouseEvent* ev)
return;
}
- //if(t->type() != MusECore::Track::DRUM && t->type() != MusECore::Track::AUDIO_SOFTSYNTH)
+ // A disabled spinbox up or down button will pass the event to the parent! Causes pseudo 'wrapping'. Eat it up.
+ if(chan_edit && chan_edit->hasFocus())
+ {
+ ev->accept();
+ return;
+ }
+ else
{
editTrack=t;
if (chan_edit==0) {
chan_edit=new QSpinBox(this);
+ chan_edit->setFrame(false);
chan_edit->setMinimum(1);
- //connect(chan_edit, SIGNAL(valueChanged(int)), SLOT(chanValueChanged(int)));
connect(chan_edit, SIGNAL(editingFinished()), SLOT(chanValueFinished()));
}
- //chan_edit->blockSignals(true);
if (t->isMidiTrack())
{
chan_edit->setMaximum(MIDI_CHANNELS);
@@ -792,10 +777,10 @@ void TList::mouseDoubleClickEvent(QMouseEvent* ev)
chan_edit->setMaximum(MAX_CHANNELS);
chan_edit->setValue(((MusECore::AudioTrack*)editTrack)->channels());
}
- //chan_edit->blockSignals(false);
int w=colw;
if (w < chan_edit->sizeHint().width()) w=chan_edit->sizeHint().width();
chan_edit->setGeometry(colx, coly, w, colh);
+ chan_edit->selectAll();
editMode = true;
chan_edit->show();
chan_edit->setFocus();
@@ -855,13 +840,11 @@ void TList::portsPopupMenu(MusECore::Track* t, int x, int y)
{
MusECore::MidiTrack* track = (MusECore::MidiTrack*)t;
- //QPopupMenu* p = MusECore::midiPortsPopup(0);
MusECore::MidiDevice* md = 0;
int potential_new_port_no=-1;
int port = -1;
if(t->type() == MusECore::Track::AUDIO_SOFTSYNTH)
{
- //MusECore::MidiDevice* md = dynamic_cast<MusECore::MidiDevice*>((MusECore::SynthI*)t);
md = dynamic_cast<MusECore::MidiDevice*>(t);
if(md)
port = md->midiPort();
@@ -869,7 +852,7 @@ void TList::portsPopupMenu(MusECore::Track* t, int x, int y)
else
port = track->outPort();
- QMenu* p = MusECore::midiPortsPopup(this, port); // 0, port);
+ QMenu* p = MusECore::midiPortsPopup(this, port);
if (t->isMidiTrack())
{
@@ -1021,8 +1004,10 @@ void TList::portsPopupMenu(MusECore::Track* t, int x, int y)
MusEGlobal::midiSeq->msgSetMidiDevice(&MusEGlobal::midiPorts[potential_new_port_no], sdev);
n=potential_new_port_no;
+
+ MusEGlobal::song->update();
}
- // Changed by T356.
+ // Changed by T356. DELETETHIS 5
//track->setOutPort(n);
//MusEGlobal::audio->msgSetTrackOutPort(track, n);
@@ -1035,27 +1020,23 @@ void TList::portsPopupMenu(MusECore::Track* t, int x, int y)
if (!change)
{
// Delete all port controller events.
- //MusEGlobal::audio->msgChangeAllPortDrumCtrlEvents(false);
MusEGlobal::song->changeAllPortDrumCtrlEvents(false);
track->setOutPort(n);
for (int i=0; i<DRUM_MAPSIZE; i++) //Remap all drum instruments to this port
MusEGlobal::drumMap[i].port = track->outPort();
// Add all port controller events.
- //MusEGlobal::audio->msgChangeAllPortDrumCtrlEvents(true);
MusEGlobal::song->changeAllPortDrumCtrlEvents(true);
}
else
{
- //MusEGlobal::audio->msgSetTrackOutPort(track, n);
track->setOutPortAndUpdate(n);
}
MusEGlobal::audio->msgIdle(false);
MusEGlobal::audio->msgUpdateSoloStates(); // (p4.0.14) p4.0.17
MusEGlobal::song->update();
}
- else
- if (t->type() == MusECore::Track::AUDIO_SOFTSYNTH)
+ else if (t->type() == MusECore::Track::AUDIO_SOFTSYNTH)
{
if(md != 0)
{
@@ -1066,17 +1047,14 @@ void TList::portsPopupMenu(MusECore::Track* t, int x, int y)
MusEGlobal::midiSeq->msgSetMidiDevice(&MusEGlobal::midiPorts[n], (MusEGlobal::midiPorts[n].device() == md) ? 0 : md);
MusEGlobal::muse->changeConfig(true); // save configuration file
- //MusEGlobal::audio->msgIdle(false);
MusEGlobal::song->update();
}
}
else
{
MusEGlobal::audio->msgIdle(true);
- //MusEGlobal::audio->msgSetTrackOutPort(track, n);
track->setOutPortAndUpdate(n);
MusEGlobal::audio->msgIdle(false);
- //MusEGlobal::song->update();
MusEGlobal::audio->msgUpdateSoloStates(); // (p4.0.14) p4.0.17
MusEGlobal::song->update(SC_MIDI_TRACK_PROP); //
}
@@ -1103,22 +1081,13 @@ void TList::oportPropertyPopupMenu(MusECore::Track* t, int x, int y)
MusECore::SynthI* synth = (MusECore::SynthI*)t;
QMenu* p = new QMenu;
- //QAction* act = p->addAction(tr("Show Gui"));
QAction* gact = p->addAction(tr("show gui"));
- //act->setCheckable(true);
gact->setCheckable(true);
- //printf("synth hasgui %d, gui visible %d\n",synth->hasGui(), synth->guiVisible());
- //act->setEnabled(synth->hasGui());
- //act->setChecked(synth->guiVisible());
gact->setEnabled(synth->hasGui());
gact->setChecked(synth->guiVisible());
QAction* nact = p->addAction(tr("show native gui"));
- //act->setCheckable(true);
nact->setCheckable(true);
- //printf("synth hasgui %d, gui visible %d\n",synth->hasGui(), synth->guiVisible());
- //act->setEnabled(synth->hasGui());
- //act->setChecked(synth->guiVisible());
nact->setEnabled(synth->hasNativeGui());
nact->setChecked(synth->nativeGuiVisible());
@@ -1127,8 +1096,6 @@ void TList::oportPropertyPopupMenu(MusECore::Track* t, int x, int y)
#ifdef DSSI_SUPPORT
if(dynamic_cast<MusECore::DssiSynthIF*>(synth->sif()))
{
- //act->setChecked(false);
- //act->setEnabled(false);
nact->setChecked(false);
nact->setEnabled(false);
}
@@ -1136,15 +1103,12 @@ void TList::oportPropertyPopupMenu(MusECore::Track* t, int x, int y)
#endif
QAction* ract = p->exec(mapToGlobal(QPoint(x, y)), 0);
- //if (ract == act) {
if (ract == gact) {
bool show = !synth->guiVisible();
- //MusEGlobal::audio->msgShowInstrumentGui(synth, show);
synth->showGui(show);
}
else if (ract == nact) {
bool show = !synth->nativeGuiVisible();
- //MusEGlobal::audio->msgShowInstrumentNativeGui(synth, show);
synth->showNativeGui(show);
}
delete p;
@@ -1158,19 +1122,13 @@ void TList::oportPropertyPopupMenu(MusECore::Track* t, int x, int y)
MusECore::MidiPort* port = &MusEGlobal::midiPorts[oPort];
QMenu* p = new QMenu;
- //QAction* act = p->addAction(tr("Show Gui"));
QAction* gact = p->addAction(tr("show gui"));
- //act->setCheckable(true);
gact->setCheckable(true);
- //printf("synth hasgui %d, gui visible %d\n",port->hasGui(), port->guiVisible());
- //act->setEnabled(port->hasGui());
- //act->setChecked(port->guiVisible());
gact->setEnabled(port->hasGui());
gact->setChecked(port->guiVisible());
QAction* nact = p->addAction(tr("show native gui"));
nact->setCheckable(true);
- //printf("synth hasgui %d, gui visible %d\n",synth->hasGui(), synth->guiVisible());
nact->setEnabled(port->hasNativeGui());
nact->setChecked(port->nativeGuiVisible());
@@ -1180,8 +1138,6 @@ void TList::oportPropertyPopupMenu(MusECore::Track* t, int x, int y)
MusECore::MidiDevice* dev = port->device();
if(dev && dev->isSynti() && (dynamic_cast<MusECore::DssiSynthIF*>(((MusECore::SynthI*)dev)->sif())))
{
- //act->setChecked(false);
- //act->setEnabled(false);
nact->setChecked(false);
nact->setEnabled(false);
}
@@ -1189,15 +1145,12 @@ void TList::oportPropertyPopupMenu(MusECore::Track* t, int x, int y)
#endif
QAction* ract = p->exec(mapToGlobal(QPoint(x, y)), 0);
- //if (ract == act) {
if (ract == gact) {
bool show = !port->guiVisible();
- //MusEGlobal::audio->msgShowInstrumentGui(port->instrument(), show);
port->instrument()->showGui(show);
}
else if (ract == nact) {
bool show = !port->nativeGuiVisible();
- //MusEGlobal::audio->msgShowInstrumentNativeGui(port->instrument(), show);
port->instrument()->showNativeGui(show);
}
delete p;
@@ -1219,16 +1172,14 @@ void TList::tracklistChanged()
void TList::keyPressEvent(QKeyEvent* e)
{
+ if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter)
+ {
+ e->accept();
+ return;
+ }
+
if (editMode)
{
- // First time we get a keypress event when lineedit is open is on the return key:
- // -- Not true for Qt4. Modifier keys also send key events - Orcan
- //if ( e->key() == Qt::Key_Return || e->key() == Qt::Key_Enter) // Removed p4.0.46 Tim.
- // {
- // returnPressed();
- // return;
- // }
- //else
if ( e->key() == Qt::Key_Escape )
{
if(editor && editor->isVisible())
@@ -1254,6 +1205,7 @@ void TList::keyPressEvent(QKeyEvent* e)
setFocus();
return;
}
+ return;
}
else if (!editJustFinished)
{
@@ -1263,24 +1215,24 @@ void TList::keyPressEvent(QKeyEvent* e)
editJustFinished=false;
- // p4.0.10 Removed by Tim. keyPressExt are sent to part canvas, where they are
- // ignored *only* if necessary.
- //e->ignore();
-
+ // Works OK (if focusing allowed). But instead we won't allow focus. Part canvas has Ctrl+up/down which moves selected track only.
/*
int key = e->key();
switch (key) {
- case Key_Up:
+ case Qt::Key_Up:
moveSelection(-1);
- break;
- case Key_Down:
+ return;
+ case Qt::Key_Down:
moveSelection(1);
- break;
+ return;
default:
-
break;
- }
- */
+ } */
+
+ // keyPressExt are sent to part canvas, where they are ignored *only* if necessary.
+ //e->ignore();
+
+ emit keyPressExt(e); //redirect keypress events to main app
}
//---------------------------------------------------------
@@ -1302,7 +1254,6 @@ void TList::moveSelection(int n)
for (MusECore::iTrack t = tracks->begin(); t != tracks->end(); ++t) {
MusECore::iTrack s = t;
if ((*t)->selected()) {
- selTrack = *t;
if (n > 0) {
while (n--) {
++t;
@@ -1313,7 +1264,10 @@ void TList::moveSelection(int n)
// skip over hidden tracks
if (!(*t)->isVisible()) {
n++;
+ continue;
}
+ selTrack = *t;
+ break;
}
}
else {
@@ -1324,40 +1278,42 @@ void TList::moveSelection(int n)
// skip over hidden tracks
if (!(*t)->isVisible()) {
n--;
+ continue;
}
+ selTrack = *t;
+ break;
}
}
- (*s)->setSelected(false);
- (*t)->setSelected(true);
-
- // rec enable track if expected
- MusECore::TrackList recd = getRecEnabledTracks();
- if (recd.size() == 1 && MusEGlobal::config.moveArmedCheckBox) { // one rec enabled track, move rec enabled with selection
- MusEGlobal::song->setRecordFlag((MusECore::Track*)recd.front(),false);
- MusEGlobal::song->setRecordFlag((*t),true);
- }
+ if(selTrack)
+ {
+ (*s)->setSelected(false);
+ selTrack->setSelected(true);
+
+ // rec enable track if expected
+ MusECore::TrackList recd = getRecEnabledTracks();
+ if (recd.size() == 1 && MusEGlobal::config.moveArmedCheckBox) { // one rec enabled track, move rec enabled with selection
+ MusEGlobal::song->setRecordFlag((MusECore::Track*)recd.front(),false);
+ MusEGlobal::song->setRecordFlag((selTrack),true);
+ }
- if (editTrack && editTrack != *t)
- returnPressed();
-
- redraw();
- break;
+ if (editTrack && editTrack != selTrack)
+ returnPressed();
+ redraw();
}
+ break;
+ }
}
- ///emit selectionChanged();
- emit selectionChanged(selTrack);
+ if(selTrack)
+ emit selectionChanged(selTrack);
}
MusECore::TrackList TList::getRecEnabledTracks()
{
- //printf("getRecEnabledTracks\n");
MusECore::TrackList recEnabled;
MusECore::TrackList* tracks = MusEGlobal::song->tracks();
for (MusECore::iTrack t = tracks->begin(); t != tracks->end(); ++t) {
- if ((*t)->recordFlag()) {
- //printf("rec enabled track\n");
+ if ((*t)->recordFlag())
recEnabled.push_back(*t);
- }
}
return recEnabled;
}
@@ -1368,7 +1324,6 @@ MusECore::TrackList TList::getRecEnabledTracks()
void TList::changeAutomation(QAction* act)
{
- //printf("changeAutomation %d\n", act->data().toInt());
if ( (editAutomation->type() == MusECore::Track::MIDI) || (editAutomation->type() == MusECore::Track::DRUM) || (editAutomation->type() == MusECore::Track::NEW_DRUM) ) {
printf("this is wrong, we can't edit automation for midi tracks from arranger yet!\n");
return;
@@ -1407,8 +1362,6 @@ void TList::changeAutomationColor(QAction* act)
// one of these days I'll rewrite this so it's understandable
// this is just to get it up and running...
- //printf("change automation color %d %d\n", id, colindex);
-
MusECore::CtrlListList* cll = ((MusECore::AudioTrack*)editAutomation)->controller();
for(MusECore::CtrlListList::iterator icll =cll->begin();icll!=cll->end();++icll) {
MusECore::CtrlList *cl = icll->second;
@@ -1421,12 +1374,9 @@ void TList::changeAutomationColor(QAction* act)
//---------------------------------------------------------
// colorMenu
//---------------------------------------------------------
-//QMenu* TList::colorMenu(QColor c, int id)
PopupMenu* TList::colorMenu(QColor c, int id, QWidget* parent)
{
- //QMenu * m = new QMenu(this);
- //PopupMenu * m = new PopupMenu(this); //, true); TODO
- PopupMenu * m = new PopupMenu(parent); //, true); //
+ PopupMenu * m = new PopupMenu(parent); //, true); //TODO
for (int i = 0; i< 6; i++) {
QPixmap pix(10,10);
QPainter p(&pix);
@@ -1490,7 +1440,7 @@ void TList::mousePressEvent(QMouseEvent* ev)
//delete synp;
delete p;
}
- /*else if (button == Qt::LeftButton) {
+ /*else if (button == Qt::LeftButton) { DELETETHIS
if (!ctrl)
{
MusEGlobal::song->deselectTracks();
@@ -1514,7 +1464,7 @@ void TList::mousePressEvent(QMouseEvent* ev)
ty += h;
if (y >= (ty-2)) {
- if ( (*it) == tracks->back() && y > ty ) {
+ if ( (*it) == tracks->back() && y > ty ) { // DELETETHIS, only retain if(foo) break;?
//printf("tracks->back() && y > ty\n");
}
else if ( y > (ty+2) ) {
@@ -1527,7 +1477,7 @@ void TList::mousePressEvent(QMouseEvent* ev)
}
- //&& y < (ty))
+ //&& y < (ty)) DELETETHIS
// break;
}
}
@@ -1578,7 +1528,6 @@ void TList::mousePressEvent(QMouseEvent* ev)
QAction* act = 0;
for(MusECore::CtrlListList::iterator icll =cll->begin();icll!=cll->end();++icll) {
MusECore::CtrlList *cl = icll->second;
- //printf("id = %d", cl->id());
if (cl->dontShow())
continue;
act = p->addAction(cl->name());
@@ -1587,8 +1536,6 @@ void TList::mousePressEvent(QMouseEvent* ev)
int data = cl->id() * 256; // shift 8 bits
data += 150; // illegal color > 100
act->setData(data);
- //QMenu *m = colorMenu(cl->color(), cl->id());
- //PopupMenu *m = colorMenu(cl->color(), cl->id());
PopupMenu *m = colorMenu(cl->color(), cl->id(), p);
act->setMenu(m);
}
@@ -1649,7 +1596,7 @@ void TList::mousePressEvent(QMouseEvent* ev)
classesPopupMenu(t, x, t->y() - ypos);
break;
case COL_OPORT:
- // Changed by Tim. p3.3.9
+ // Changed by Tim. p3.3.9 DELETETHIS 15
// Reverted.
if (button == Qt::LeftButton)
portsPopupMenu(t, x, t->y() - ypos);
@@ -1703,13 +1650,11 @@ void TList::mousePressEvent(QMouseEvent* ev)
t->setSelected(!t->selected());
if (editTrack && editTrack != t)
returnPressed();
- ///emit selectionChanged();
emit selectionChanged(t->selected() ? t : 0);
}
else if (button == Qt::RightButton) {
mode = NORMAL;
QMenu* p = new QMenu;
- //p->clear();
// Leave room for normal track IDs - base these at AUDIO_SOFTSYNTH.
p->addAction(QIcon(*automation_clear_dataIcon), tr("Delete Track"))->setData(1001);
p->addAction(QIcon(*track_commentIcon), tr("Track Comment"))->setData(1002);
@@ -1753,7 +1698,6 @@ void TList::mousePressEvent(QMouseEvent* ev)
{
TrackComment* tc = new TrackComment(t, 0);
tc->show();
- //QToolTip::add( this, "FOOOOOOOOOOOOO" );
}
break;
@@ -1845,16 +1789,14 @@ void TList::mousePressEvent(QMouseEvent* ev)
channel = MIDI_CHANNELS - 1;
if(channel < 0)
channel = 0;
- //if (channel != ((MusECore::MidiTrack*)t)->outChannel())
if (channel != mt->outChannel())
{
// Changed by T356.
- //mt->setOutChannel(channel);
MusEGlobal::audio->msgIdle(true);
- //MusEGlobal::audio->msgSetTrackOutChannel(mt, channel);
mt->setOutChanAndUpdate(channel);
MusEGlobal::audio->msgIdle(false);
+ // DELETETHIS 15?
/* --- I really don't like this, you can mess up the whole map "as easy as dell"
if (mt->type() == MusECore::MidiTrack::DRUM) {//Change channel on all drum instruments
for (int i=0; i<DRUM_MAPSIZE; i++)
@@ -2179,7 +2121,7 @@ void TList::mouseMoveEvent(QMouseEvent* ev)
int h = (*it)->height();
ty += h;
if (y >= (ty-2)) {
- if ( (*it) == tracks->back() && y >= ty ) {
+ if ( (*it) == tracks->back() && y >= ty ) { // DELETETHIS and cleanup
// outside last track don't change to splitVCursor
}
else if ( y > (ty+2) ) {
@@ -2267,7 +2209,7 @@ void TList::mouseReleaseEvent(QMouseEvent* ev)
if (editTrack && editor && editor->isVisible())
editor->setFocus();
//else // DELETETHIS or add the same for ctrl_edit!
- //if (editTrack && chan_edit && chan_edit->isVisible()) // p4.0.46
+ //if (editTrack && chan_edit && chan_edit->isVisible()) // p4.0.46 DELETETHIS?
// chan_edit->setFocus();
adjustScrollbar();
}
@@ -2329,15 +2271,11 @@ void TList::wheelEvent(QWheelEvent* ev)
else if (port < 0)
port = 0;
if (port != ((MusECore::MidiTrack*)t)->outPort()) {
- // Changed by T356.
- //mt->setOutPort(port);
MusEGlobal::audio->msgIdle(true);
- //MusEGlobal::audio->msgSetTrackOutPort(mt, port);
mt->setOutPortAndUpdate(port);
MusEGlobal::audio->msgIdle(false);
MusEGlobal::audio->msgUpdateSoloStates(); // p4.0.14
- //MusEGlobal::song->update(SC_ROUTE);
MusEGlobal::song->update(SC_MIDI_TRACK_PROP); // p4.0.17
}
}
@@ -2356,10 +2294,7 @@ void TList::wheelEvent(QWheelEvent* ev)
else if (channel < 0)
channel = 0;
if (channel != ((MusECore::MidiTrack*)t)->outChannel()) {
- // Changed by T356.
- //mt->setOutChannel(channel);
MusEGlobal::audio->msgIdle(true);
- //MusEGlobal::audio->msgSetTrackOutChannel(mt, channel);
mt->setOutChanAndUpdate(channel);
MusEGlobal::audio->msgIdle(false);
@@ -2473,15 +2408,6 @@ void TList::setYPos(int y)
}
//---------------------------------------------------------
-// resizeEvent
-//---------------------------------------------------------
-
-//void TList::resizeEvent(QResizeEvent* /*ev*/)
-// {
-//
-// }
-
-//---------------------------------------------------------
// classesPopupMenu
//---------------------------------------------------------
@@ -2514,7 +2440,7 @@ void TList::classesPopupMenu(MusECore::Track* t, int x, int y)
int pitch = ev.pitch();
// Changed by T356.
// Tested: Notes were being mixed up switching back and forth between midi and drum.
- //pitch = MusEGlobal::drumMap[pitch].anote;
+ //pitch = MusEGlobal::drumMap[pitch].anote; DELETETHIS
pitch = MusEGlobal::drumMap[pitch].enote;
ev.setPitch(pitch);
@@ -2546,7 +2472,6 @@ void TList::classesPopupMenu(MusECore::Track* t, int x, int y)
MusEGlobal::audio->msgIdle(true);
// Delete all port controller events.
- //MusEGlobal::audio->msgChangeAllPortDrumCtrlEvents(false);
MusEGlobal::song->changeAllPortDrumCtrlEvents(false);
if (!change) {
@@ -2557,7 +2482,6 @@ void TList::classesPopupMenu(MusECore::Track* t, int x, int y)
}
}
- //MusEGlobal::audio->msgIdle(true);
MusECore::PartList* pl = t->parts();
MusECore::MidiTrack* m = (MusECore::MidiTrack*) t;
for (MusECore::iPart ip = pl->begin(); ip != pl->end(); ++ip) {
@@ -2589,7 +2513,6 @@ void TList::classesPopupMenu(MusECore::Track* t, int x, int y)
t->setType(MusECore::Track::DRUM);
// Add all port controller events.
- //MusEGlobal::audio->msgChangeAllPortDrumCtrlEvents(true);
MusEGlobal::song->changeAllPortDrumCtrlEvents(true);
MusEGlobal::audio->msgIdle(false);
MusEGlobal::song->update(SC_EVENT_MODIFIED);
diff --git a/muse2/muse/arranger/tlist.h b/muse2/muse/arranger/tlist.h
index a113d221..ae50058a 100644
--- a/muse2/muse/arranger/tlist.h
+++ b/muse2/muse/arranger/tlist.h
@@ -33,10 +33,8 @@ class QLineEdit;
class QSpinBox;
class QMouseEvent;
class QPaintEvent;
-class QResizeEvent;
class QScrollBar;
class QWheelEvent;
-//class QMenu;
namespace MusECore {
class Track;
@@ -107,18 +105,15 @@ class TList : public QWidget {
void moveSelection(int n);
void adjustScrollbar();
void paint(const QRect& r);
- //virtual void resizeEvent(QResizeEvent*);
void redraw(const QRect& r);
MusECore::Track* y2Track(int) const;
void classesPopupMenu(MusECore::Track*, int x, int y);
MusECore::TrackList getRecEnabledTracks();
void setHeaderToolTips();
- //QMenu* colorMenu(QColor c, int id);
PopupMenu* colorMenu(QColor c, int id, QWidget* parent);
private slots:
void returnPressed();
- void chanValueChanged(int);
void chanValueFinished();
void ctrlValueFinished();
void instrPopupActivated(QAction*);
@@ -130,7 +125,6 @@ class TList : public QWidget {
void copyTrackDrummap(MusECore::MidiTrack*, bool full);
signals:
- ///void selectionChanged();
void selectionChanged(MusECore::Track*);
void keyPressExt(QKeyEvent*);
void redirectWheelEvent(QWheelEvent*);
diff --git a/muse2/muse/audio.cpp b/muse2/muse/audio.cpp
index 3f1d4dc8..80bffafe 100644
--- a/muse2/muse/audio.cpp
+++ b/muse2/muse/audio.cpp
@@ -63,11 +63,11 @@ void initAudio()
extern double curTime();
-//static const unsigned char mmcDeferredPlayMsg[] = { 0x7f, 0x7f, 0x06, 0x03 };
+//static const unsigned char mmcDeferredPlayMsg[] = { 0x7f, 0x7f, 0x06, 0x03 }; DELETETHIS 2
//static const unsigned char mmcStopMsg[] = { 0x7f, 0x7f, 0x06, 0x01 };
const char* seqMsgList[] = {
- "SEQM_ADD_TRACK", "SEQM_REMOVE_TRACK", //"SEQM_CHANGE_TRACK",
+ "SEQM_ADD_TRACK", "SEQM_REMOVE_TRACK", //"SEQM_CHANGE_TRACK", DELETETHIS
"SEQM_MOVE_TRACK",
"SEQM_ADD_PART", "SEQM_REMOVE_PART", "SEQM_CHANGE_PART",
"SEQM_ADD_EVENT", "SEQM_REMOVE_EVENT", "SEQM_CHANGE_EVENT",
@@ -87,15 +87,15 @@ const char* seqMsgList[] = {
"SEQM_SCAN_ALSA_MIDI_PORTS",
"SEQM_SET_AUX",
"SEQM_UPDATE_SOLO_STATES",
- //"MIDI_SHOW_INSTR_GUI",
- //"MIDI_SHOW_INSTR_NATIVE_GUI",
+ //"MIDI_SHOW_INSTR_GUI", DELETETHIS
+ //"MIDI_SHOW_INSTR_NATIVE_GUI", DELETETHIS
"AUDIO_RECORD",
"AUDIO_ROUTEADD", "AUDIO_ROUTEREMOVE", "AUDIO_REMOVEROUTES",
- //"AUDIO_VOL", "AUDIO_PAN",
+ //"AUDIO_VOL", "AUDIO_PAN", DELETETHIS
"AUDIO_ADDPLUGIN",
"AUDIO_SET_SEG_SIZE",
"AUDIO_SET_PREFADER", "AUDIO_SET_CHANNELS",
- //"AUDIO_SET_PLUGIN_CTRL_VAL",
+ //"AUDIO_SET_PLUGIN_CTRL_VAL", DELETETHIS
"AUDIO_SWAP_CONTROLLER_IDX",
"AUDIO_CLEAR_CONTROLLER_EVENTS",
"AUDIO_SEEK_PREV_AC_EVENT",
@@ -125,7 +125,6 @@ Audio::Audio()
idle = false;
_freewheel = false;
_bounce = false;
- //loopPassed = false;
_loopFrame = 0;
_loopCount = 0;
@@ -145,8 +144,6 @@ Audio::Audio()
state = STOP;
msg = 0;
- //startRecordPos.setType(Pos::TICKS);
- //endRecordPos.setType(Pos::TICKS);
startRecordPos.setType(Pos::FRAMES); // Tim
endRecordPos.setType(Pos::FRAMES);
@@ -189,22 +186,16 @@ extern bool initJackAudio();
bool Audio::start()
{
- //process(MusEGlobal::segmentSize); // warm up caches
state = STOP;
_loopCount = 0;
MusEGlobal::muse->setHeartBeat();
- if (MusEGlobal::audioDevice) {
- //_running = true;
- //MusEGlobal::audioDevice->start();
- }
- else {
- if(false == initJackAudio()) {
- //_running = true;
+ if (!MusEGlobal::audioDevice) {
+ if(initJackAudio() == false) {
InputList* itl = MusEGlobal::song->inputs();
for (iAudioInput i = itl->begin(); i != itl->end(); ++i) {
- //printf("reconnecting input %s\n", (*i)->name().ascii());
+ if (MusEGlobal::debugMsg) printf("reconnecting input %s\n", (*i)->name().toAscii().data());
for (int x=0; x < (*i)->channels();x++)
(*i)->setJackPort(x,0);
(*i)->setName((*i)->name()); // restore jack connection
@@ -212,13 +203,12 @@ bool Audio::start()
OutputList* otl = MusEGlobal::song->outputs();
for (iAudioOutput i = otl->begin(); i != otl->end(); ++i) {
- //printf("reconnecting output %s\n", (*i)->name().ascii());
+ if (MusEGlobal::debugMsg) printf("reconnecting output %s\n", (*i)->name().toAscii().data());
for (int x=0; x < (*i)->channels();x++)
(*i)->setJackPort(x,0);
- //printf("name=%s\n",(*i)->name().toLatin1());
+ if (MusEGlobal::debugMsg) printf("name=%s\n",(*i)->name().toAscii().data());
(*i)->setName((*i)->name()); // restore jack connection
}
- //MusEGlobal::audioDevice->start();
}
else {
printf("Failed to init audio!\n");
@@ -235,7 +225,6 @@ bool Audio::start()
MusEGlobal::audioDevice->stopTransport();
- //MusEGlobal::audioDevice->seekTransport(MusEGlobal::song->cPos().frame());
MusEGlobal::audioDevice->seekTransport(MusEGlobal::song->cPos());
return true;
@@ -260,12 +249,14 @@ void Audio::stop(bool)
bool Audio::sync(int jackState, unsigned frame)
{
+ //printf("Audio::sync: state:%d jackState:%d\n", state, jackState);
+
bool done = true;
if (state == LOOP1)
state = LOOP2;
else {
State s = State(jackState);
- //
+
// STOP -> START_PLAY start rolling
// STOP -> STOP seek in stop state
// PLAY -> START_PLAY seek in play state
@@ -273,10 +264,10 @@ bool Audio::sync(int jackState, unsigned frame)
if (state != START_PLAY) {
Pos p(frame, false);
seek(p);
- if (!_freewheel)
+ if (!_freewheel)
done = MusEGlobal::audioPrefetch->seekDone();
if (s == START_PLAY)
- state = START_PLAY;
+ state = START_PLAY;
}
else {
if (frame != _pos.frame()) {
@@ -286,6 +277,7 @@ bool Audio::sync(int jackState, unsigned frame)
done = MusEGlobal::audioPrefetch->seekDone();
}
}
+ //printf("Audio::sync: done:%d\n", done);
return done;
}
@@ -296,7 +288,6 @@ bool Audio::sync(int jackState, unsigned frame)
void Audio::setFreewheel(bool val)
{
-// printf("JACK: freewheel callback %d\n", val);
_freewheel = val;
}
@@ -319,9 +310,6 @@ void Audio::shutdown()
void Audio::process(unsigned frames)
{
-// extern int watchAudio;
-// ++watchAudio; // make a simple watchdog happy. Disabled.
-
if (!MusEGlobal::checkAudioDevice()) return;
if (msg) {
processMsg(msg);
@@ -360,16 +348,6 @@ void Audio::process(unsigned frames)
startRolling();
}
else if (isPlaying() && jackState == STOP) {
- // Make sure to stop bounce and freewheel mode, for example if user presses stop
- // in QJackCtl before right-hand marker is reached (which is handled below). p3.3.43
- //printf("Audio::process isPlaying() && jackState == STOP\n");
- //if (_bounce)
- //{
- //printf(" stopping bounce...\n");
- // _bounce = false;
- // write(sigFd, "F", 1);
- //}
-
stopRolling();
}
else if (state == START_PLAY && jackState == STOP) {
@@ -393,7 +371,7 @@ void Audio::process(unsigned frames)
printf("JACK: state transition %s -> %s ?\n",
audioStates[state], audioStates[jackState]);
-// printf("p %s %s %d\n", audioStates[jackState], audioStates[state], _pos.frame());
+ // printf("p %s %s %d\n", audioStates[jackState], audioStates[state], _pos.frame());
//
// clear aux send buffers
@@ -428,8 +406,9 @@ void Audio::process(unsigned frames)
&& !(MusEGlobal::song->record()
|| _bounce
|| MusEGlobal::song->loop())) {
- //if(MusEGlobal::debugMsg)
- // printf("Audio::process curTickPos >= MusEGlobal::song->len\n");
+
+ if(MusEGlobal::debugMsg)
+ printf("Audio::process curTickPos >= MusEGlobal::song->len\n");
MusEGlobal::audioDevice->stopTransport();
return;
@@ -456,7 +435,6 @@ void Audio::process(unsigned frames)
for (int ch = 0; ch < MIDI_CHANNELS; ++ch) {
if (mp->hwCtrlState(ch, CTRL_SUSTAIN) == 127) {
if (mp->device()!=NULL) {
- //printf("send clear sustain!!!!!!!! port %d ch %d\n", i,ch);
MidiPlayEvent ev(0, i, ch, ME_CONTROLLER, CTRL_SUSTAIN, 0);
// may cause problems, called from audio thread
mp->device()->putEvent(ev);
@@ -465,10 +443,8 @@ void Audio::process(unsigned frames)
}
}
- //MusEGlobal::audioDevice->seekTransport(_loopFrame);
Pos lp(_loopFrame, false);
MusEGlobal::audioDevice->seekTransport(lp);
-// printf(" process: seek to %d, end %d\n", _loopFrame, loop.frame());
}
}
@@ -493,8 +469,6 @@ void Audio::process(unsigned frames)
syncTime = curTime();
frameOffset = syncFrame - samplePos;
- //printf("Audio::process calling process1:\n");
-
process1(samplePos, offset, frames);
for (iAudioOutput i = ol->begin(); i != ol->end(); ++i)
(*i)->processWrite();
@@ -513,8 +487,6 @@ void Audio::process1(unsigned samplePos, unsigned offset, unsigned frames)
if (MusEGlobal::midiSeqRunning) {
processMidi();
}
- //MusEGlobal::midiSeq->msgProcess();
-
//
// process not connected tracks
// to animate meter display
@@ -553,14 +525,14 @@ void Audio::process1(unsigned samplePos, unsigned offset, unsigned frames)
track = (AudioTrack*)(*it);
if(!track->processed() && track->type() == Track::AUDIO_AUX)
{
- //printf("Audio::process1 Do aux: track:%s\n", track->name().toLatin1().constData());
+ //printf("Audio::process1 Do aux: track:%s\n", track->name().toLatin1().constData()); DELETETHIS
channels = track->channels();
// Just a dummy buffer.
float* buffer[channels];
float data[frames * channels];
for (int i = 0; i < channels; ++i)
buffer[i] = data + i * frames;
- //printf("Audio::process1 calling track->copyData for track:%s\n", track->name().toLatin1());
+ //printf("Audio::process1 calling track->copyData for track:%s\n", track->name().toLatin1()); DELETETHIS
track->copyData(samplePos, channels, -1, -1, frames, buffer);
}
}
@@ -580,20 +552,16 @@ void Audio::process1(unsigned samplePos, unsigned offset, unsigned frames)
if((*it)->isMidiTrack())
continue;
track = (AudioTrack*)(*it);
- // Ignore unprocessed tracks which have an output route, because they will be processed by
- // whatever track(s) they are routed to.
- //if(!track->processed() && track->noOutRoute() && (track->type() != Track::AUDIO_OUTPUT))
- // No, do all.
if(!track->processed() && (track->type() != Track::AUDIO_OUTPUT))
{
- //printf("Audio::process1 track:%s\n", track->name().toLatin1().constData());
+ //printf("Audio::process1 track:%s\n", track->name().toLatin1().constData()); DELETETHIS
channels = track->channels();
// Just a dummy buffer.
float* buffer[channels];
float data[frames * channels];
for (int i = 0; i < channels; ++i)
buffer[i] = data + i * frames;
- //printf("Audio::process1 calling track->copyData for track:%s\n", track->name().toLatin1());
+ //printf("Audio::process1 calling track->copyData for track:%s\n", track->name().toLatin1()); DELETETHIS
track->copyData(samplePos, channels, -1, -1, frames, buffer);
}
}
@@ -618,12 +586,6 @@ void Audio::processMsg(AudioMsg* msg)
case AUDIO_REMOVEROUTES:
removeAllRoutes(msg->sroute, msg->droute);
break;
- //case AUDIO_VOL:
- // msg->snode->setVolume(msg->dval);
- // break;
- //case AUDIO_PAN:
- // msg->snode->setPan(msg->dval);
- // break;
case SEQM_SET_AUX:
msg->snode->setAuxSend(msg->ival, msg->dval);
break;
@@ -636,10 +598,6 @@ void Audio::processMsg(AudioMsg* msg)
case AUDIO_ADDPLUGIN:
msg->snode->addPlugin(msg->plugin, msg->ival);
break;
- //case AUDIO_SET_PLUGIN_CTRL_VAL:
- //msg->plugin->track()->setPluginCtrlVal(msg->ival, msg->dval);
- // msg->snode->setPluginCtrlVal(msg->ival, msg->dval);
- // break;
case AUDIO_SWAP_CONTROLLER_IDX:
msg->snode->swapControllerIDX(msg->a, msg->b);
break;
@@ -675,7 +633,7 @@ void Audio::processMsg(AudioMsg* msg)
case AUDIO_SET_SEG_SIZE:
MusEGlobal::segmentSize = msg->ival;
MusEGlobal::sampleRate = msg->iival;
-#if 0 //TODO
+#if 0 //TODO or DELETETHIS ?
audioOutput.MusEGlobal::segmentSizeChanged();
for (int i = 0; i < mixerGroups; ++i)
audioGroups[i].MusEGlobal::segmentSizeChanged();
@@ -685,7 +643,6 @@ void Audio::processMsg(AudioMsg* msg)
break;
case SEQM_RESET_DEVICES:
- //printf("Audio::processMsg SEQM_RESET_DEVICES\n");
for (int i = 0; i < MIDI_PORTS; ++i)
{
if(MusEGlobal::midiPorts[i].device())
@@ -723,6 +680,7 @@ void Audio::processMsg(AudioMsg* msg)
case SEQM_SCAN_ALSA_MIDI_PORTS:
alsaScanMidiPorts();
break;
+ //DELETETHIS 6
//case MIDI_SHOW_INSTR_GUI:
// MusEGlobal::midiSeq->msgUpdatePollFd();
// break;
@@ -743,6 +701,7 @@ void Audio::processMsg(AudioMsg* msg)
frameOffset = syncFrame - samplePos;
}
break;
+ // DELETETHIS 6
//case SEQM_ADD_TRACK:
//case SEQM_REMOVE_TRACK:
//case SEQM_CHANGE_TRACK:
@@ -780,23 +739,27 @@ void Audio::seek(const Pos& p)
printf("Audio::seek already there\n");
return;
}
- //printf("Audio::seek frame:%d\n", p.frame());
+ if (MusEGlobal::heavyDebugMsg)
+ printf("Audio::seek frame:%d\n", p.frame());
+
_pos = p;
if (!MusEGlobal::checkAudioDevice()) return;
syncFrame = MusEGlobal::audioDevice->framePos();
frameOffset = syncFrame - _pos.frame();
curTickPos = _pos.tick();
- if (curTickPos == 0 && !MusEGlobal::song->record())
+// ALSA support
+#if 1
+ MusEGlobal::midiSeq->msgSeek(); // handle stuck notes and set controller for new position
+#else
+ if (curTickPos == 0 && !MusEGlobal::song->record()) // Moved here from MidiSeq::processStop()
MusEGlobal::audio->initDevices();
-
for(iMidiDevice i = MusEGlobal::midiDevices.begin(); i != MusEGlobal::midiDevices.end(); ++i)
(*i)->handleSeek();
+#endif
- //loopPassed = true; // for record loop mode
if (state != LOOP2 && !freewheel())
{
- //MusEGlobal::audioPrefetch->msgSeek(_pos.frame());
// We need to force prefetch to update, to ensure the most recent data.
// Things can happen to a part before play is pressed - such as part muting,
// part moving etc. Without a force, the wrong data was being played. Tim 08/17/08
@@ -863,11 +826,6 @@ void Audio::startRolling()
if(!dev)
continue;
- // Shall we check open flags?
- //if(!(dev->rwFlags() & 0x1) || !(dev->openFlags() & 1))
- //if(!(dev->openFlags() & 1))
- // continue;
-
MidiSyncInfo& si = mp->syncInfo();
if(si.MMCOut())
@@ -887,7 +845,8 @@ void Audio::startRolling()
&& MusEGlobal::song->click()
&& !MusEGlobal::extSyncFlag.value()
&& MusEGlobal::song->record()) {
-#if 0
+// DELETETHIS 14 or keep?
+/*
state = PRECOUNT;
int z, n;
if (precountFromMastertrackFlag)
@@ -899,7 +858,7 @@ void Audio::startRolling()
clickno = z * preMeasures;
clicksMeasure = z;
ticksBeat = (division * 4)/n;
-#endif
+*/
}
else {
//
@@ -919,15 +878,12 @@ void Audio::startRolling()
for (int ch = 0; ch < MIDI_CHANNELS; ++ch) {
if (mp->hwCtrlState(ch, CTRL_SUSTAIN) == 127) {
if(mp->device() != NULL) {
- //printf("send enable sustain!!!!!!!! port %d ch %d\n", i,ch);
MidiPlayEvent ev(0, i, ch, ME_CONTROLLER, CTRL_SUSTAIN, 127);
- mp->device()->addScheduledEvent(ev); // TODO: Not working? Try putEvent
+ mp->device()->putEvent(ev);
}
}
}
}
-
- //tempomap.clearExtTempoList();
}
//---------------------------------------------------------
@@ -936,19 +892,23 @@ void Audio::startRolling()
void Audio::stopRolling()
{
- //if(MusEGlobal::debugMsg)
- // printf("Audio::stopRolling state %s\n", audioStates[state]);
+ if (MusEGlobal::debugMsg)
+ printf("Audio::stopRolling state %s\n", audioStates[state]);
state = STOP;
- MusEGlobal::midiSeq->setExternalPlayState(false); // not playing Moved here from MidiSeq::processStop() p4.0.34
-
+// ALSA support
+#if 1
+ MusEGlobal::midiSeq->msgStop();
+#else
+ MusEGlobal::midiSeq->setExternalPlayState(false); // not playing Moved here from MidiSeq::processStop()
for(iMidiDevice id = MusEGlobal::midiDevices.begin(); id != MusEGlobal::midiDevices.end(); ++id)
{
MidiDevice* md = *id;
md->handleStop();
}
-
+#endif
+
WaveTrackList* tracks = MusEGlobal::song->waves();
for (iWaveTrack i = tracks->begin(); i != tracks->end(); ++i) {
WaveTrack* track = *i;
@@ -985,9 +945,7 @@ void Audio::recordStop()
// MusEGlobal::song->setRecordFlag knows about it...
track->setRecFile(0); // flush out the old file
- MusEGlobal::song->setRecordFlag(track, false); //
- //track->setRecordFlag1(true); // and re-arm the track here
- //MusEGlobal::song->setRecordFlag(track, true); // here
+ MusEGlobal::song->setRecordFlag(track, false);
}
}
MidiTrackList* ml = MusEGlobal::song->midis();
@@ -1000,7 +958,6 @@ void Audio::recordStop()
// resolve NoteOff events, Controller etc.
//---------------------------------------------------
- //buildMidiEventList(el, mpel, mt, MusEGlobal::config.division, true);
// Do SysexMeta. Do loops.
buildMidiEventList(el, mpel, mt, MusEGlobal::config.division, true, true);
MusEGlobal::song->cmdAddRecordedEvents(mt, el, startRecordPos.tick());
diff --git a/muse2/muse/audio.h b/muse2/muse/audio.h
index a81498a6..723c378c 100644
--- a/muse2/muse/audio.h
+++ b/muse2/muse/audio.h
@@ -55,7 +55,7 @@ class Track;
//---------------------------------------------------------
enum {
- SEQM_ADD_TRACK, SEQM_REMOVE_TRACK, //SEQM_CHANGE_TRACK,
+ SEQM_ADD_TRACK, SEQM_REMOVE_TRACK, //SEQM_CHANGE_TRACK, DELETETHIS
SEQM_MOVE_TRACK,
SEQM_ADD_PART, SEQM_REMOVE_PART, SEQM_CHANGE_PART,
SEQM_ADD_EVENT, SEQM_REMOVE_EVENT, SEQM_CHANGE_EVENT,
@@ -76,15 +76,15 @@ enum {
SEQM_SCAN_ALSA_MIDI_PORTS,
SEQM_SET_AUX,
SEQM_UPDATE_SOLO_STATES,
- //MIDI_SHOW_INSTR_GUI,
- //MIDI_SHOW_INSTR_NATIVE_GUI,
+ //MIDI_SHOW_INSTR_GUI, DELETETHIS
+ //MIDI_SHOW_INSTR_NATIVE_GUI, DELETETHIS
AUDIO_RECORD,
AUDIO_ROUTEADD, AUDIO_ROUTEREMOVE, AUDIO_REMOVEROUTES,
- //AUDIO_VOL, AUDIO_PAN,
+ //AUDIO_VOL, AUDIO_PAN, DELETETHIS
AUDIO_ADDPLUGIN,
AUDIO_SET_SEG_SIZE,
AUDIO_SET_PREFADER, AUDIO_SET_CHANNELS,
- //AUDIO_SET_PLUGIN_CTRL_VAL,
+ //AUDIO_SET_PLUGIN_CTRL_VAL, DELETETHIS
AUDIO_SWAP_CONTROLLER_IDX,
AUDIO_CLEAR_CONTROLLER_EVENTS,
AUDIO_SEEK_PREV_AC_EVENT,
@@ -167,14 +167,13 @@ class Audio {
int fromThreadFdw, fromThreadFdr; // message pipe
int sigFd; // pipe fd for messages to gui
- //QSocketNotifier* _socketNotifier;
int sigFdr;
// record values:
Pos startRecordPos;
Pos endRecordPos;
- //
+
AudioOutput* _audioMaster;
AudioOutput* _audioMonitor;
@@ -208,6 +207,7 @@ class Audio {
void stop(bool);
void seek(const Pos& pos);
+ bool isStarting() const { return state == START_PLAY; }
bool isPlaying() const { return state == PLAY || state == LOOP1 || state == LOOP2; }
bool isRecording() const { return state == PLAY && recording; }
void setRunning(bool val) { _running = val; }
@@ -222,7 +222,7 @@ class Audio {
void msgRemoveTrack(Track*, bool u = true);
void msgRemoveTracks();
- //void msgChangeTrack(Track* oldTrack, Track* newTrack, bool u = true);
+ //void msgChangeTrack(Track* oldTrack, Track* newTrack, bool u = true); DELETETHIS
void msgMoveTrack(int idx1, int dx2, bool u = true);
void msgAddPart(Part*, bool u = true);
void msgRemovePart(Part*, bool u = true);
@@ -241,8 +241,8 @@ class Audio {
void msgRemoveSig(int tick, int z, int n, bool doUndoFlag = true);
void msgAddKey(int tick, int key, bool doUndoFlag = true);
void msgRemoveKey(int tick, int key, bool doUndoFlag = true);
- //void msgShowInstrumentGui(MidiInstrument*, bool);
- //void msgShowInstrumentNativeGui(MidiInstrument*, bool);
+ //void msgShowInstrumentGui(MidiInstrument*, bool); DELETETHIS
+ //void msgShowInstrumentNativeGui(MidiInstrument*, bool); DELETETHIS
void msgPanic();
void sendMsg(AudioMsg*);
bool sendMessage(AudioMsg* m, bool doUndo);
@@ -254,8 +254,8 @@ class Audio {
void msgAddRoute1(Route, Route);
void msgAddPlugin(AudioTrack*, int idx, PluginI* plugin);
void msgSetMute(AudioTrack*, bool val);
- //void msgSetVolume(AudioTrack*, double val);
- //void msgSetPan(AudioTrack*, double val);
+ //void msgSetVolume(AudioTrack*, double val); DELETETHIS
+ //void msgSetPan(AudioTrack*, double val); DELETETHIS
void msgAddSynthI(SynthI* synth);
void msgRemoveSynthI(SynthI* synth);
void msgSetSegSize(int, int);
@@ -270,7 +270,7 @@ class Audio {
void msgResetMidiDevices();
void msgIdle(bool);
void msgBounce();
- //void msgSetPluginCtrlVal(AudioTrack*, int /*param*/, double /*val*/);
+ //void msgSetPluginCtrlVal(AudioTrack*, int /*param*/, double /*val*/); DELETETHIS
void msgSwapControllerIDX(AudioTrack*, int, int);
void msgClearControllerEvents(AudioTrack*, int);
void msgSeekPrevACEvent(AudioTrack*, int);
diff --git a/muse2/muse/audioconvert.cpp b/muse2/muse/audioconvert.cpp
index eeb11676..9ab2f066 100644
--- a/muse2/muse/audioconvert.cpp
+++ b/muse2/muse/audioconvert.cpp
@@ -114,7 +114,6 @@ AudioConverter* AudioConverter::release(AudioConverter* cv)
{
if(!cv)
return 0;
- //if(cv->incRefCount(-1) <= 0)
cv->_refCount -= 1;
#ifdef AUDIOCONVERT_DEBUG
printf("AudioConverter::release converter:%p current refcount:%d\n", cv, cv->_refCount);
@@ -130,13 +129,12 @@ AudioConverter* AudioConverter::release(AudioConverter* cv)
return cv;
}
-//off_t AudioConverter::readAudio(SndFileR& f, off_t sfCurFrame, unsigned offset, float** buffer, int channel, int n, bool doSeek, bool overwrite)
off_t AudioConverter::readAudio(MusECore::SndFileR& f, unsigned offset, float** buffer, int channel, int n, bool doSeek, bool overwrite)
{
if(f.isNull())
return _sfCurFrame;
- // Added by Tim. p3.3.17
+ // Added by Tim. p3.3.17 DELETETHIS or comment it in again. it's disabled anyway
//#ifdef AUDIOCONVERT_DEBUG_PRC
//printf("AudioConverter::process %s audConv:%p sfCurFrame:%ld offset:%u channel:%d fchan:%d n:%d\n",
// f.name().toLatin1(), this, sfCurFrame, offset, channel, f.channels(), n);
@@ -162,12 +160,12 @@ off_t AudioConverter::readAudio(MusECore::SndFileR& f, unsigned offset, float**
// Sample rates are different. Seek to a calculated 'sample rate ratio factored' position.
double srcratio = (double)fsrate / (double)MusEGlobal::sampleRate;
- //long inSize = long((double)frames * _src_ratio) + 1 // From MusE-2 file converter.
+ //long inSize = long((double)frames * _src_ratio) + 1 // From MusE-2 file converter. DELETETHIS ???
off_t newfr = (off_t)floor(((double)frame * srcratio)); // From simplesynth.
_sfCurFrame = f.seek(newfr, 0);
- // Added by Tim. p3.3.17
+ // Added by Tim. p3.3.17 DELETETHIS 3 or comment it in
//#ifdef AUDIOCONVERT_DEBUG_PRC
//printf("AudioConverter::process Seek frame:%ld converted to frame:%ld sfCurFrame:%ld\n", frame, newfr, sfCurFrame);
//#endif
@@ -178,7 +176,7 @@ off_t AudioConverter::readAudio(MusECore::SndFileR& f, unsigned offset, float**
else
{
// No seek requested.
- // Added by Tim. p3.3.17
+ // Added by Tim. p3.3.17 DELETETHIS 3 or comment it in
//#ifdef AUDIOCONVERT_DEBUG_PRC
//printf("AudioConverter::process No 'transport' seek, rates different. Seeking to sfCurFrame:%ld\n", sfCurFrame);
//#endif
@@ -189,19 +187,20 @@ off_t AudioConverter::readAudio(MusECore::SndFileR& f, unsigned offset, float**
_sfCurFrame = f.seek(_sfCurFrame, 0);
}
- /*
+ /* DELETETHIS 5
int fchan = f.channels();
long outFrames = n;
long outSize = outFrames * fchan;
float outbuffer[outSize];
*/
+ // DELETETHIS 4
//sfCurFrame = process(f, sfCurFrame, offset, &outbuffer[0], channel, n);
// sfCurFrame = process(f, sfCurFrame, outbuffer, channel, n);
//sfCurFrame = process(f, sfCurFrame, buffer, channel, n, overwrite);
_sfCurFrame = process(f, buffer, channel, n, overwrite);
- /*
+ /* DELETETHIS 58 (whoa!)
float* poutbuf = &outbuffer[0];
if(fchan == channel)
{
@@ -328,24 +327,22 @@ void SRCAudioConverter::reset()
return;
}
-//off_t SRCAudioConverter::process(SndFileR& f, off_t sfCurFrame, float** buffer, int channel, int n, bool overwrite)
off_t SRCAudioConverter::process(MusECore::SndFileR& f, float** buffer, int channel, int n, bool overwrite)
{
- //return src_process(_src_state, sd);
+ //return src_process(_src_state, sd); DELETETHIS
if(f.isNull())
- //return;
return _sfCurFrame;
- // Added by Tim. p3.3.17
+ // Added by Tim. p3.3.17 DELETETHIS 4
//#ifdef AUDIOCONVERT_DEBUG_PRC
//printf("AudioConverter::process %s audConv:%p sfCurFrame:%ld offset:%u channel:%d fchan:%d n:%d\n",
// f.name().toLatin1(), this, sfCurFrame, offset, channel, f.channels(), n);
//#endif
-// off_t frame = offset; // _spos is added before the call.
+// off_t frame = offset; // _spos is added before the call. DELETETHIS
unsigned fsrate = f.samplerate();
- //bool resample = src_state && ((unsigned)MusEGlobal::sampleRate != fsrate);
+ //bool resample = src_state && ((unsigned)MusEGlobal::sampleRate != fsrate); DELETETHIS 2
// bool resample = isValid() && ((unsigned)MusEGlobal::sampleRate != fsrate);
if((MusEGlobal::sampleRate == 0) || (fsrate == 0))
@@ -364,29 +361,30 @@ off_t SRCAudioConverter::process(MusECore::SndFileR& f, float** buffer, int chan
long inComp = 1;
long outFrames = n;
- //long outSize = outFrames * channel;
+ //long outSize = outFrames * channel; DELETETHIS
long outSize = outFrames * fchan;
- //long inSize = long(outSize * srcratio) + 1 // From MusE-2 file converter.
+ //long inSize = long(outSize * srcratio) + 1 // From MusE-2 file converter. DELETETHIS3
//long inSize = (long)floor(((double)outSize / srcratio)); // From simplesynth.
//long inFrames = (long)floor(((double)outFrames / srcratio)); // From simplesynth.
long inFrames = (long)ceil(((double)outFrames / srcratio)) + inComp; // From simplesynth.
+ // DELETETHIS
//long inFrames = (long)floor(double(outFrames * sfinfo.samplerate) / double(MusEGlobal::sampleRate)); // From simplesynth.
long inSize = inFrames * fchan;
- //long inSize = inFrames * channel;
+ //long inSize = inFrames * channel; DELETETHIS
// Start with buffers at expected sizes. We won't need anything larger than this, but add 4 for good luck.
float inbuffer[inSize + 4];
float outbuffer[outSize];
- //size_t sfTotalRead = 0;
+ //size_t sfTotalRead = 0; DELETETHIS
size_t rn = 0;
long totalOutFrames = 0;
srcdata.data_in = inbuffer;
srcdata.data_out = outbuffer;
-// srcdata.data_out = buffer;
+// srcdata.data_out = buffer; DELETETHIS
// Set some kind of limit on the number of attempts to completely fill the output buffer,
// in case something is really screwed up - we don't want to get stuck in a loop here.
@@ -394,10 +392,10 @@ off_t SRCAudioConverter::process(MusECore::SndFileR& f, float** buffer, int chan
for(int attempt = 0; attempt < attempts; ++attempt)
{
rn = f.readDirect(inbuffer, inFrames);
- //sfTotalRead += rn;
+ //sfTotalRead += rn; DELETETHIS
// convert
- //srcdata.data_in = inbuffer;
+ //srcdata.data_in = inbuffer; DELETETHIS 4
//srcdata.data_out = outbuffer;
//srcdata.data_out = poutbuf;
//srcdata.input_frames = inSize;
@@ -406,7 +404,7 @@ off_t SRCAudioConverter::process(MusECore::SndFileR& f, float** buffer, int chan
srcdata.end_of_input = ((long)rn != inFrames);
srcdata.src_ratio = srcratio;
- //#ifdef AUDIOCONVERT_DEBUG_PRC
+ //#ifdef AUDIOCONVERT_DEBUG_PRC DELETETHIS or comment it in, or maybe add an additional if (heavyDebugMsg)?
//printf("AudioConverter::process attempt:%d inFrames:%ld outFrames:%ld rn:%d data in:%p out:%p",
// attempt, inFrames, outFrames, rn, srcdata.data_in, srcdata.data_out);
//#endif
@@ -420,7 +418,7 @@ off_t SRCAudioConverter::process(MusECore::SndFileR& f, float** buffer, int chan
totalOutFrames += srcdata.output_frames_gen;
- //#ifdef AUDIOCONVERT_DEBUG_PRC
+ //#ifdef AUDIOCONVERT_DEBUG_PRC DELETETHIS or comment in or heavyDebugMsg
//printf(" frames used in:%ld out:%ld totalOutFrames:%ld data in:%p out:%p\n", srcdata.input_frames_used, srcdata.output_frames_gen, totalOutFrames, srcdata.data_in, srcdata.data_out);
//#endif
@@ -484,7 +482,7 @@ off_t SRCAudioConverter::process(MusECore::SndFileR& f, float** buffer, int chan
#endif
// We've reached the end of the file. Convert the number of frames read.
- //rn = (double)rn * srcratio + 1;
+ //rn = (double)rn * srcratio + 1; DELETETHIS 5
//rn = (long)floor((double)rn * srcratio);
//if(rn > (size_t)outFrames)
// rn = outFrames;
@@ -505,22 +503,18 @@ off_t SRCAudioConverter::process(MusECore::SndFileR& f, float** buffer, int chan
long e = n * channel;
for(long i = b; i < e; ++i)
outbuffer[i] = 0.0f;
- //buffer[i] = 0.0f;
}
- //float* poutbuf = &outbuffer[0];
float* poutbuf = outbuffer;
if(fchan == channel)
{
if(overwrite)
- //for (size_t i = 0; i < rn; ++i)
for (int i = 0; i < n; ++i)
{
for(int ch = 0; ch < channel; ++ch)
*(buffer[ch] + i) = *poutbuf++;
}
else
- //for(size_t i = 0; i < rn; ++i)
for(int i = 0; i < n; ++i)
{
for(int ch = 0; ch < channel; ++ch)
@@ -531,11 +525,9 @@ off_t SRCAudioConverter::process(MusECore::SndFileR& f, float** buffer, int chan
{
// stereo to mono
if(overwrite)
- //for(size_t i = 0; i < rn; ++i)
for(int i = 0; i < n; ++i)
*(buffer[0] + i) = poutbuf[i + i] + poutbuf[i + i + 1];
else
- //for(size_t i = 0; i < rn; ++i)
for(int i = 0; i < n; ++i)
*(buffer[0] + i) += poutbuf[i + i] + poutbuf[i + i + 1];
}
@@ -543,7 +535,6 @@ off_t SRCAudioConverter::process(MusECore::SndFileR& f, float** buffer, int chan
{
// mono to stereo
if(overwrite)
- //for(size_t i = 0; i < rn; ++i)
for(int i = 0; i < n; ++i)
{
float data = *poutbuf++;
@@ -551,7 +542,6 @@ off_t SRCAudioConverter::process(MusECore::SndFileR& f, float** buffer, int chan
*(buffer[1]+i) = data;
}
else
- //for(size_t i = 0; i < rn; ++i)
for(int i = 0; i < n; ++i)
{
float data = *poutbuf++;
@@ -585,7 +575,7 @@ RubberBandAudioConverter::RubberBandAudioConverter(int channels, int options) :
_rbs = 0;
_channels = channels;
- _rbs = new RubberBandStretcher(MusEGlobal::sampleRate, _channels, _options); // , initialTimeRatio = 1.0, initialPitchScale = 1.0
+ _rbs = new RubberBandStretcher(MusEGlobal::sampleRate, _channels, _options); // , initialTimeRatio = 1.0, initialPitchScale = 1.0 DELETETHIS
}
RubberBandAudioConverter::~RubberBandAudioConverter()
@@ -624,24 +614,23 @@ void RubberBandAudioConverter::reset()
/////////////////////////////////
// TODO: Not finished yet..
////////////////////////////////
-//off_t RubberBandAudioConverter::process(SndFileR& f, off_t sfCurFrame, float** buffer, int channel, int n, bool overwrite)
+// DELETETHIS well then... but maybe we can clean it up anyway? remove the below for example ;)?
off_t RubberBandAudioConverter::process(MusECore::SndFileR& f, float** buffer, int channel, int n, bool overwrite)
{
- //return src_process(_src_state, sd);
+ //return src_process(_src_state, sd); DELETETHIS
if(f.isNull())
- //return;
return _sfCurFrame;
- // Added by Tim. p3.3.17
+ // Added by Tim. p3.3.17 DELETETHIS 4
//#ifdef AUDIOCONVERT_DEBUG_PRC
//printf("AudioConverter::process %s audConv:%p sfCurFrame:%ld offset:%u channel:%d fchan:%d n:%d\n",
// f.name().toLatin1(), this, sfCurFrame, offset, channel, f.channels(), n);
//#endif
-// off_t frame = offset; // _spos is added before the call.
+// off_t frame = offset; // _spos is added before the call. DELETETHIS
unsigned fsrate = f.samplerate();
- //bool resample = src_state && ((unsigned)MusEGlobal::sampleRate != fsrate);
+ //bool resample = src_state && ((unsigned)MusEGlobal::sampleRate != fsrate); DELETETHIS 2
// bool resample = isValid() && ((unsigned)MusEGlobal::sampleRate != fsrate);
if((MusEGlobal::sampleRate == 0) || (fsrate == 0))
@@ -660,23 +649,24 @@ off_t RubberBandAudioConverter::process(MusECore::SndFileR& f, float** buffer, i
long inComp = 1;
long outFrames = n;
- //long outSize = outFrames * channel;
+ //long outSize = outFrames * channel; DELETETHIS
long outSize = outFrames * fchan;
- //long inSize = long(outSize * srcratio) + 1 // From MusE-2 file converter.
+ //long inSize = long(outSize * srcratio) + 1 // From MusE-2 file converter. DELETETHIS 3
//long inSize = (long)floor(((double)outSize / srcratio)); // From simplesynth.
//long inFrames = (long)floor(((double)outFrames / srcratio)); // From simplesynth.
long inFrames = (long)ceil(((double)outFrames / srcratio)) + inComp; // From simplesynth.
+ // DELETETHIS
//long inFrames = (long)floor(double(outFrames * sfinfo.samplerate) / double(MusEGlobal::sampleRate)); // From simplesynth.
long inSize = inFrames * fchan;
- //long inSize = inFrames * channel;
+ //long inSize = inFrames * channel; DELETETHIS
// Start with buffers at expected sizes. We won't need anything larger than this, but add 4 for good luck.
float inbuffer[inSize]; // +4
-// float outbuffer[outSize];
+// float outbuffer[outSize]; DELETETHIS
- //float* rbinbuffer[fchan];
+ //float* rbinbuffer[fchan]; DELETETHIS 4
//float rbindata[inSize];
//for (int i = 0; i < fchan; ++i)
// rbinbuffer[i] = rbindata + i * inFrames;
@@ -686,11 +676,11 @@ off_t RubberBandAudioConverter::process(MusECore::SndFileR& f, float** buffer, i
for (int i = 0; i < fchan; ++i)
rboutbuffer[i] = rboutdata + i * outFrames;
- //size_t sfTotalRead = 0;
+ //size_t sfTotalRead = 0; DELETETHIS
size_t rn = 0;
long totalOutFrames = 0;
-// srcdata.data_in = inbuffer;
+// srcdata.data_in = inbuffer; DELETETHIS 3
//srcdata.data_out = outbuffer;
// srcdata.data_out = buffer;
float** data_out = rboutbuffer;
@@ -712,9 +702,9 @@ off_t RubberBandAudioConverter::process(MusECore::SndFileR& f, float** buffer, i
for(int i = 0; i < fchan; ++i)
rbinbuffer[i] = rbindata + i * sreq;
-// rn = f.readDirect(inbuffer, inFrames);
+// rn = f.readDirect(inbuffer, inFrames); DELETETHIS
rn = f.readDirect(inbuffer, sreq);
- //sfTotalRead += rn;
+ //sfTotalRead += rn; DELETETHIS
// Must de-interleave soundfile data to feed to rubberband.
for(size_t i = 0; i < rn; ++i)
@@ -730,7 +720,7 @@ off_t RubberBandAudioConverter::process(MusECore::SndFileR& f, float** buffer, i
// convert
- //srcdata.data_in = inbuffer;
+ //srcdata.data_in = inbuffer; DELETETHIS 4
//srcdata.data_out = outbuffer;
//srcdata.data_out = poutbuf;
//srcdata.input_frames = inSize;
@@ -739,7 +729,7 @@ off_t RubberBandAudioConverter::process(MusECore::SndFileR& f, float** buffer, i
srcdata.end_of_input = ((long)rn != inFrames);
srcdata.src_ratio = srcratio;
- //#ifdef AUDIOCONVERT_DEBUG_PRC
+ //#ifdef AUDIOCONVERT_DEBUG_PRC DELETETHIS or comment in
//printf("AudioConverter::process attempt:%d inFrames:%ld outFrames:%ld rn:%d data in:%p out:%p",
// attempt, inFrames, outFrames, rn, srcdata.data_in, srcdata.data_out);
//#endif
@@ -753,7 +743,7 @@ off_t RubberBandAudioConverter::process(MusECore::SndFileR& f, float** buffer, i
totalOutFrames += srcdata.output_frames_gen;
- //#ifdef AUDIOCONVERT_DEBUG_PRC
+ //#ifdef AUDIOCONVERT_DEBUG_PRC DELETETHIS or comment in
//printf(" frames used in:%ld out:%ld totalOutFrames:%ld data in:%p out:%p\n", srcdata.input_frames_used, srcdata.output_frames_gen, totalOutFrames, srcdata.data_in, srcdata.data_out);
//#endif
@@ -817,7 +807,7 @@ off_t RubberBandAudioConverter::process(MusECore::SndFileR& f, float** buffer, i
#endif
// We've reached the end of the file. Convert the number of frames read.
- //rn = (double)rn * srcratio + 1;
+ //rn = (double)rn * srcratio + 1; DELETETHIS 5
//rn = (long)floor((double)rn * srcratio);
//if(rn > (size_t)outFrames)
// rn = outFrames;
@@ -837,23 +827,19 @@ off_t RubberBandAudioConverter::process(MusECore::SndFileR& f, float** buffer, i
long b = totalOutFrames * channel;
long e = n * channel;
for(long i = b; i < e; ++i)
- //outbuffer[i] = 0.0f;
buffer[i] = 0.0f;
}
- //float* poutbuf = &outbuffer[0];
float* poutbuf = outbuffer;
if(fchan == channel)
{
if(overwrite)
- //for (size_t i = 0; i < rn; ++i)
for (int i = 0; i < n; ++i)
{
for(int ch = 0; ch < channel; ++ch)
*(buffer[ch] + i) = *poutbuf++;
}
else
- //for(size_t i = 0; i < rn; ++i)
for(int i = 0; i < n; ++i)
{
for(int ch = 0; ch < channel; ++ch)
@@ -864,11 +850,9 @@ off_t RubberBandAudioConverter::process(MusECore::SndFileR& f, float** buffer, i
{
// stereo to mono
if(overwrite)
- //for(size_t i = 0; i < rn; ++i)
for(int i = 0; i < n; ++i)
*(buffer[0] + i) = poutbuf[i + i] + poutbuf[i + i + 1];
else
- //for(size_t i = 0; i < rn; ++i)
for(int i = 0; i < n; ++i)
*(buffer[0] + i) += poutbuf[i + i] + poutbuf[i + i + 1];
}
@@ -876,7 +860,6 @@ off_t RubberBandAudioConverter::process(MusECore::SndFileR& f, float** buffer, i
{
// mono to stereo
if(overwrite)
- //for(size_t i = 0; i < rn; ++i)
for(int i = 0; i < n; ++i)
{
float data = *poutbuf++;
@@ -884,7 +867,6 @@ off_t RubberBandAudioConverter::process(MusECore::SndFileR& f, float** buffer, i
*(buffer[1]+i) = data;
}
else
- //for(size_t i = 0; i < rn; ++i)
for(int i = 0; i < n; ++i)
{
float data = *poutbuf++;
diff --git a/muse2/muse/audioconvert.h b/muse2/muse/audioconvert.h
index d9d312ed..23f06ecf 100644
--- a/muse2/muse/audioconvert.h
+++ b/muse2/muse/audioconvert.h
@@ -36,7 +36,6 @@
#include <samplerate.h>
#include <sys/types.h>
-//#include "eventbase.h"
namespace MusECore {
class EventBase;
@@ -61,18 +60,14 @@ class AudioConverter
AudioConverter* reference();
static AudioConverter* release(AudioConverter* cv);
- //off_t readAudio(SndFileR& /*sf*/, off_t /*sfCurFrame*/, unsigned /*offset*/, float** /*buffer*/,
- // int /*channels*/, int /*frames*/, bool /*doSeek*/, bool /*overwrite*/);
- off_t readAudio(MusECore::SndFileR& /*sf*/, unsigned /*offset*/, float** /*buffer*/,
- int /*channels*/, int /*frames*/, bool /*doSeek*/, bool /*overwrite*/);
+ off_t readAudio(MusECore::SndFileR& sf, unsigned offset, float** buffer,
+ int channels, int frames, bool doSeek, bool overwrite);
virtual bool isValid() = 0;
virtual void reset() = 0;
virtual void setChannels(int ch) = 0;
- //virtual off_t process(SndFileR& /*sf*/, off_t /*sfCurFrame*/, float** /*buffer*/,
- // int /*channels*/, int /*frames*/, bool /*overwrite*/) = 0; // Interleaved buffer if stereo.
- virtual off_t process(MusECore::SndFileR& /*sf*/, float** /*buffer*/,
- int /*channels*/, int /*frames*/, bool /*overwrite*/) = 0; // Interleaved buffer if stereo.
+ virtual off_t process(MusECore::SndFileR& sf, float** buffer,
+ int channels, int frames, bool overwrite) = 0; // Interleaved buffer if stereo.
};
//---------------------------------------------------------
@@ -92,10 +87,8 @@ class SRCAudioConverter : public AudioConverter
virtual bool isValid() { return _src_state != 0; }
virtual void reset();
virtual void setChannels(int ch);
- //virtual off_t process(SndFileR& /*sf*/, off_t /*sfCurFrame*/, float** /*buffer*/,
- // int /*channels*/, int /*frames*/, bool /*overwrite*/); // Interleaved buffer if stereo.
- virtual off_t process(MusECore::SndFileR& /*sf*/, float** /*buffer*/,
- int /*channels*/, int /*frames*/, bool /*overwrite*/); // Interleaved buffer if stereo.
+ virtual off_t process(MusECore::SndFileR& sf, float** buffer,
+ int channels, int frames, bool overwrite); // Interleaved buffer if stereo.
};
#ifdef RUBBERBAND_SUPPORT
@@ -117,10 +110,8 @@ class RubberBandAudioConverter : public AudioConverter
virtual bool isValid() { return _rbs != 0; }
virtual void reset();
virtual void setChannels(int ch);
- //virtual off_t process(SndFileR& /*sf*/, off_t /*sfCurFrame*/, float** /*buffer*/,
- // int /*channels*/, int /*frames*/, bool /*overwrite*/); // Interleaved buffer if stereo.
- virtual off_t process(MusECore::SndFileR& /*sf*/, float** /*buffer*/,
- int /*channels*/, int /*frames*/, bool /*overwrite*/); // Interleaved buffer if stereo.
+ virtual off_t process(MusECore::SndFileR& sf, float** buffer,
+ int channels, int frames, bool overwrite); // Interleaved buffer if stereo.
};
#endif // RUBBERBAND_SUPPORT
@@ -132,14 +123,12 @@ class RubberBandAudioConverter : public AudioConverter
typedef std::map<EventBase*, AudioConverter*, std::less<EventBase*> >::iterator iAudioConvertMap;
typedef std::map<EventBase*, AudioConverter*, std::less<EventBase*> >::const_iterator ciAudioConvertMap;
-//typedef std::map<EventBase*, AudioConverter*, std::less<EventBase*> > AudioConvertMap;
class AudioConvertMap : public std::map<EventBase*, AudioConverter*, std::less<EventBase*> >
{
public:
void remapEvents(const EventList*);
iAudioConvertMap addEvent(EventBase*);
void removeEvent(EventBase*);
- //AudioConverter* getConverter(const EventBase*);
iAudioConvertMap getConverter(EventBase*);
};
diff --git a/muse2/muse/audioprefetch.cpp b/muse2/muse/audioprefetch.cpp
index 1fcb7cef..92689ddb 100644
--- a/muse2/muse/audioprefetch.cpp
+++ b/muse2/muse/audioprefetch.cpp
@@ -61,14 +61,11 @@ struct PrefetchMsg : public ThreadMsg {
// AudioPrefetch
//---------------------------------------------------------
-//AudioPrefetch::AudioPrefetch(int prio, const char* name)
-// : Thread(prio,name)
AudioPrefetch::AudioPrefetch(const char* name)
: Thread(name)
{
seekPos = ~0;
writePos = ~0;
- //seekDone = true;
seekCount = 0;
}
@@ -86,12 +83,10 @@ static void readMsgP(void* p, void*)
// start
//---------------------------------------------------------
-//void AudioPrefetch::start()
void AudioPrefetch::start(int priority)
{
clearPollFd();
addPollFd(toThreadFdr, POLLIN, MusECore::readMsgP, this, 0);
- //Thread::start();
Thread::start(priority);
}
@@ -112,13 +107,10 @@ void AudioPrefetch::processMsg1(const void* m)
const PrefetchMsg* msg = (PrefetchMsg*)m;
switch(msg->id) {
case PREFETCH_TICK:
- if (MusEGlobal::audio->isRecording()) {
- //puts("writeTick");
+ if (MusEGlobal::audio->isRecording())
MusEGlobal::audio->writeTick();
- }
+
// Indicate do not seek file before each read.
- // Changed by Tim. p3.3.17
- //prefetch();
prefetch(false);
seekPos = ~0; // invalidate cached last seek position
@@ -157,13 +149,10 @@ void AudioPrefetch::msgTick()
void AudioPrefetch::msgSeek(unsigned samplePos, bool force)
{
- if (samplePos == seekPos && !force) {
- //seekDone = true;
+ if (samplePos == seekPos && !force)
return;
- }
++seekCount;
- //seekDone = false;
#ifdef AUDIOPREFETCH_DEBUG
printf("AudioPrefetch::msgSeek samplePos:%u force:%d seekCount:%d\n", samplePos, force, seekCount);
@@ -182,7 +171,6 @@ void AudioPrefetch::msgSeek(unsigned samplePos, bool force)
// prefetch
//---------------------------------------------------------
-//void AudioPrefetch::prefetch()
void AudioPrefetch::prefetch(bool doSeek)
{
if (writePos == ~0U) {
@@ -197,31 +185,23 @@ void AudioPrefetch::prefetch(bool doSeek)
// adjust loop start so we get exact loop len
if (n > lpos)
n = 0;
-// printf("prefetch seek %d\n", writePos);
writePos = lpos - n;
}
}
WaveTrackList* tl = MusEGlobal::song->waves();
for (iWaveTrack it = tl->begin(); it != tl->end(); ++it) {
WaveTrack* track = *it;
- // p3.3.29
- // Save time. Don't bother if track is off. Track On/Off not designed for rapid repeated response (but mute is).
+ // Save time. Don't bother if track is off. Track On/Off not designed for rapid repeated response (but mute is). (p3.3.29)
if(track->off())
continue;
int ch = track->channels();
float* bp[ch];
-// printf("prefetch %d\n", writePos);
- if (track->prefetchFifo()->getWriteBuffer(ch, MusEGlobal::segmentSize, bp, writePos)) {
- // printf("AudioPrefetch::prefetch No write buffer!\n"); // p3.3.46 Was getting this...
+ if (track->prefetchFifo()->getWriteBuffer(ch, MusEGlobal::segmentSize, bp, writePos))
continue;
- }
- //track->fetchData(writePos, MusEGlobal::segmentSize, bp);
+
track->fetchData(writePos, MusEGlobal::segmentSize, bp, doSeek);
- // p3.3.41
- //fprintf(stderr, "AudioPrefetch::prefetch data: MusEGlobal::segmentSize:%ld %e %e %e %e\n", MusEGlobal::segmentSize, bp[0][0], bp[0][1], bp[0][2], bp[0][3]);
-
}
writePos += MusEGlobal::segmentSize;
}
@@ -232,7 +212,6 @@ void AudioPrefetch::prefetch(bool doSeek)
void AudioPrefetch::seek(unsigned seekTo)
{
-// printf("seek %d\n", seekTo);
#ifdef AUDIOPREFETCH_DEBUG
printf("AudioPrefetch::seek to:%u seekCount:%d\n", seekTo, seekCount);
#endif
@@ -264,14 +243,11 @@ void AudioPrefetch::seek(unsigned seekTo)
for (unsigned int i = 0; i < (MusEGlobal::fifoLength)-1; ++i)//prevent compiler warning: comparison of signed/unsigned
{
// Indicate do a seek command before read, but only on the first pass.
- // Changed by Tim. p3.3.17
- //prefetch();
prefetch(isFirstPrefetch);
isFirstPrefetch = false;
- // To help speed things up even more, check the count again. Return if more seek messages are pending.
- // Added by Tim. p3.3.20
+ // To help speed things up even more, check the count again. Return if more seek messages are pending. (p3.3.20)
if(seekCount > 1)
{
--seekCount;
@@ -280,7 +256,6 @@ void AudioPrefetch::seek(unsigned seekTo)
}
seekPos = seekTo;
- //seekDone = true;
--seekCount;
}
diff --git a/muse2/muse/audioprefetch.h b/muse2/muse/audioprefetch.h
index 5b34b2cc..7e8a5799 100644
--- a/muse2/muse/audioprefetch.h
+++ b/muse2/muse/audioprefetch.h
@@ -37,24 +37,20 @@ class AudioPrefetch : public Thread {
unsigned seekPos; // remember last seek to optimize seeks
virtual void processMsg1(const void*);
- //void prefetch();
void prefetch(bool doSeek);
void seek(unsigned pos);
volatile int seekCount;
public:
- //AudioPrefetch(int prio, const char* name);
AudioPrefetch(const char* name);
~AudioPrefetch();
- //virtual void start();
virtual void start(int);
void msgTick();
void msgSeek(unsigned samplePos, bool force=false);
- //volatile bool seekDone;
bool seekDone() const { return seekCount == 0; }
};
diff --git a/muse2/muse/audiotrack.cpp b/muse2/muse/audiotrack.cpp
index e542deec..981cdada 100644
--- a/muse2/muse/audiotrack.cpp
+++ b/muse2/muse/audiotrack.cpp
@@ -48,6 +48,7 @@ bool AudioOutput::_isVisible=false;
bool AudioGroup::_isVisible =false;
bool WaveTrack::_isVisible=true;
+// DELETETHIS 40. this caching stuff seems to be not used any more
// By T356. For caching jack in/out routing names BEFORE file save.
// Jack often shuts down during file save, causing the routes to be lost in the file.
// cacheJackRouteNames() is ONLY called from MusE::save() in app.cpp
@@ -95,7 +96,6 @@ void cacheJackRouteNames()
AudioTrack::AudioTrack(TrackType t)
: Track(t)
{
- //_totalOutChannels = num_out_bufs; // Is either parameter-default MAX_CHANNELS, or custom value passed (used by syntis).
_processed = false;
_haveData = false;
_sendMetronome = false;
@@ -104,28 +104,12 @@ AudioTrack::AudioTrack(TrackType t)
_recFile = 0;
_channels = 0;
_automationType = AUTO_OFF;
- //setChannels(1);
setChannels(2);
addController(new CtrlList(AC_VOLUME,"Volume",0.001,3.163 /* roughly 10 db */, VAL_LOG));
addController(new CtrlList(AC_PAN, "Pan", -1.0, 1.0, VAL_LINEAR));
addController(new CtrlList(AC_MUTE,"Mute",0.0,1.0, VAL_LINEAR, true /*dont show in arranger */));
- //outBuffers = new float*[MAX_CHANNELS];
- //for (int i = 0; i < MAX_CHANNELS; ++i)
- // outBuffers[i] = new float[MusEGlobal::segmentSize];
- //for (int i = 0; i < MAX_CHANNELS; ++i)
- // posix_memalign((void**)(outBuffers + i), 16, sizeof(float) * MusEGlobal::segmentSize);
-
- // Let's allocate it all in one block, and just point the remaining buffer pointers into the block
- // which allows faster one-shot buffer copying.
- // Nope. Nice but interferes with possibility we don't know if other buffers are contiguous (jack buffers, local stack buffers etc.).
- //posix_memalign((void**)(outBuffers), 16, sizeof(float) * MusEGlobal::segmentSize * MAX_CHANNELS);
- //for (int i = 0; i < MAX_CHANNELS; ++i)
- // *(outBuffers + i) = sizeof(float) * MusEGlobal::segmentSize * i;
-
- // Easy way, less desirable... Start out with enough for MAX_CHANNELS. Then multi-channel syntis can re-allocate,
- // via a call to (a modified!) setChannels().
- // Hard way, more desirable... Creating a synti instance passes the total channels to this constructor, overriding MAX_CHANNELS.
+ // for a lot of considerations and failures, see revision 1402 or earlier (flo)
_totalOutChannels = MAX_CHANNELS;
outBuffers = new float*[_totalOutChannels];
for (int i = 0; i < _totalOutChannels; ++i)
@@ -154,7 +138,6 @@ AudioTrack::AudioTrack(const AudioTrack& t, int flags)
bufferPos = MAXINT;
- //_recFile = t._recFile;
_recFile = NULL;
internal_assign(t, flags | ASSIGN_PROPERTIES);
@@ -193,16 +176,9 @@ void AudioTrack::internal_assign(const Track& t, int flags)
setTotalOutChannels(at._totalOutChannels);
// This is only set by multi-channel syntis...
- //_totalInChannels = 0;
- //_totalInChannels = t._totalInChannels;
setTotalInChannels(at._totalInChannels);
setChannels(at.channels()); // Set track channels (max 2).
-
- //bufferPos = MAXINT;
-
- //_recFile = at._recFile;
- //_recFile = NULL;
}
if(flags & ASSIGN_PLUGINS)
@@ -263,23 +239,13 @@ void AudioTrack::internal_assign(const Track& t, int flags)
if (!ol->empty()) {
AudioOutput* ao = ol->front();
switch(type()) {
- //case Track::MIDI:
- //case Track::DRUM:
- //case Track::AUDIO_OUTPUT:
- // break;
-
case Track::WAVE:
- //case Track::AUDIO_GROUP:
case Track::AUDIO_AUX:
- //case Track::AUDIO_INPUT:
- //case Track::AUDIO_SOFTSYNTH:
MusEGlobal::audio->msgAddRoute(Route(this, -1), Route(ao, -1));
- //updateFlags |= SC_ROUTE;
break;
// It should actually never get here now, but just in case.
case Track::AUDIO_SOFTSYNTH:
MusEGlobal::audio->msgAddRoute(Route(this, 0, channels()), Route(ao, 0, channels()));
- //updateFlags |= SC_ROUTE;
break;
default:
break;
@@ -495,7 +461,7 @@ void AudioTrack::swapControllerIDX(int idx1, int idx2)
_controller.insert(std::pair<const int, CtrlList*>(newcl->id(), newcl));
}
-
+ // DELETETHIS 67
/*
unsigned int idmask = ~AC_PLUGIN_CTL_ID_MASK;
@@ -616,7 +582,6 @@ void AudioTrack::processAutomationEvents()
{
// Don't bother looking for start, it's OK, just take the first one.
// Needed for mousewheel and paging etc.
- //if (icr->id == id && icr->type == ARVT_START)
if (icr->id == id)
{
int start = icr->frame;
@@ -679,17 +644,6 @@ void AudioTrack::processAutomationEvents()
// Done with the recorded automation event list. Clear it.
_recEvents.clear();
-
- // Try muse without this, so that the user can remain in automation write mode
- // after a stop.
- /*
- if (automationType() == AUTO_WRITE)
- {
- setAutomationType(AUTO_READ);
- MusEGlobal::song->update(SC_AUTOMATION);
- }
- */
-
}
//---------------------------------------------------------
@@ -734,12 +688,10 @@ void AudioTrack::seekPrevACEvent(int id)
if(cl->empty())
return;
- //iCtrl s = cl->lower_bound(MusEGlobal::song->cPos().frame());
iCtrl s = cl->lower_bound(MusEGlobal::audio->pos().frame()); // p4.0.33
if(s != cl->begin())
--s;
- //MusEGlobal::song->setPos(Song::CPOS, Pos(s->second.frame, false), true, false, true);
MusEGlobal::song->setPos(Song::CPOS, Pos(s->second.frame, false), false, true, false); // p4.0.33
return;
}
@@ -758,7 +710,6 @@ void AudioTrack::seekNextACEvent(int id)
if(cl->empty())
return;
- //iCtrl s = cl->upper_bound(MusEGlobal::song->cPos().frame());
iCtrl s = cl->upper_bound(MusEGlobal::audio->pos().frame()); // p4.0.33
if(s == cl->end())
@@ -766,7 +717,6 @@ void AudioTrack::seekNextACEvent(int id)
--s;
}
- //MusEGlobal::song->setPos(Song::CPOS, Pos(s->second.frame, false), true, false, true);
MusEGlobal::song->setPos(Song::CPOS, Pos(s->second.frame, false), false, true, false); // p4.0.33
return;
}
@@ -1015,7 +965,6 @@ void AudioTrack::writeProperties(int level, Xml& xml) const
if (hasAuxSend()) {
int naux = MusEGlobal::song->auxs()->size();
for (int idx = 0; idx < naux; ++idx) {
- //QString s("<auxSend idx=%1>%2</auxSend>\n");
QString s("<auxSend idx=\"%1\">%2</auxSend>\n"); // Aux fix from Remon, thanks.
xml.nput(level, s.arg(idx).arg(_auxSend[idx]).toAscii().constData());
}
@@ -1117,10 +1066,6 @@ bool AudioTrack::readProperties(Xml& xml, const QString& tag)
_sendMetronome = xml.parseInt();
else if (tag == "automation")
setAutomationType(AutomationType(xml.parseInt()));
- // Removed by T356
- // "recfile" tag not saved anymore
- //else if (tag == "recfile")
- // readRecfile(xml);
else if (tag == "controller") {
CtrlList* l = new CtrlList();
l->read(xml);
@@ -1132,7 +1077,6 @@ bool AudioTrack::readProperties(Xml& xml, const QString& tag)
// controls would all be set to zero.
// But we will allow for the (unintended, useless) possibility of a controller
// with no matching plugin control.
- //PluginI* p = 0;
PluginIBase* p = 0;
bool ctlfound = false;
unsigned m = l->id() & AC_PLUGIN_CTL_ID_MASK;
@@ -1152,6 +1096,7 @@ bool AudioTrack::readProperties(Xml& xml, const QString& tag)
SynthIF* sif = synti->sif();
if(sif)
{
+#ifdef DSSI_SUPPORT
DssiSynthIF* dsif = dynamic_cast < DssiSynthIF* > (sif);
if(dsif)
{
@@ -1159,6 +1104,7 @@ bool AudioTrack::readProperties(Xml& xml, const QString& tag)
if(p && m < p->parameters())
ctlfound = true;
}
+#endif
}
}
}
@@ -1285,7 +1231,6 @@ void AudioTrack::mapRackPluginsToControllers()
l->setValueType(p->ctrlValueType(i));
l->setMode(p->ctrlMode(i));
l->setCurVal(p->param(i));
- //l->setDefault(p->defaultValue(i));
}
}
@@ -1301,11 +1246,10 @@ void AudioTrack::mapRackPluginsToControllers()
// Ignore volume, pan, mute etc.
if(id < AC_PLUGIN_CTL_BASE)
continue;
+
unsigned param = id & AC_PLUGIN_CTL_ID_MASK;
int idx = (id >> AC_PLUGIN_CTL_BASE_POW) - 1;
- //PluginI* p = (*_efxPipe)[idx];
- // p4.0.20
PluginIBase* p = 0;
if(idx >= 0 && idx < PipelineDepth)
p = (*_efxPipe)[idx];
@@ -1318,9 +1262,11 @@ void AudioTrack::mapRackPluginsToControllers()
SynthIF* sif = synti->sif();
if(sif)
{
+#ifdef DSSI_SUPPORT
DssiSynthIF* dsif = dynamic_cast < DssiSynthIF* > (sif);
if(dsif)
p = dsif;
+#endif
}
}
}
@@ -1341,6 +1287,17 @@ void AudioTrack::mapRackPluginsToControllers()
while (loop);
+ // DELETETHIS 40 i DO trust the below. some container's erase functions
+ // return an iterator to the next, so sometimes you need it=erase(it)
+ // instead of erase(it++).
+ // i'm happy with both AS LONG the above does not slow down things.
+ // when in doubt, i'd prefer the below however.
+ // so either remove the below completely (if the above works fast),
+ // or remove the above and use the below.
+ // CAUTION: the below isn't quite up-to-date! first recheck.
+ // this "not-being-up-to-date" is another reason for NOT keeping such
+ // comments!
+
// FIXME: Although this tested OK, and is the 'official' way to erase while iterating,
// I don't trust it. I'm weary of this method. The technique didn't work
// in Audio::msgRemoveTracks(), see comments there.
@@ -1357,6 +1314,7 @@ void AudioTrack::mapRackPluginsToControllers()
++icl;
continue;
}
+
int param = id & AC_PLUGIN_CTL_ID_MASK;
int idx = (id >> AC_PLUGIN_CTL_BASE_POW) - 1;
PluginI* p = (*_efxPipe)[idx];
@@ -1372,6 +1330,7 @@ void AudioTrack::mapRackPluginsToControllers()
*/
}
+// DELETETHIS 60
/*
//---------------------------------------------------------
// writeRouting
@@ -1444,18 +1403,14 @@ AudioInput::AudioInput()
{
// set Default for Input Ports:
_mute = true;
- //setVolume(1.0);
for (int i = 0; i < MAX_CHANNELS; ++i)
jackPorts[i] = 0;
- //_channels = 0;
- //setChannels(2);
}
AudioInput::AudioInput(const AudioInput& t, int flags)
: AudioTrack(t, flags)
{
for (int i = 0; i < MAX_CHANNELS; ++i)
- //jackPorts[i] = t.jackPorts[i];
jackPorts[i] = 0;
// Register ports.
@@ -1559,17 +1514,13 @@ AudioOutput::AudioOutput()
{
for (int i = 0; i < MAX_CHANNELS; ++i)
jackPorts[i] = 0;
- //_channels = 0;
- //setChannels(2);
}
AudioOutput::AudioOutput(const AudioOutput& t, int flags)
: AudioTrack(t, flags)
{
for (int i = 0; i < MAX_CHANNELS; ++i)
- //jackPorts[i] = t.jackPorts[i];
jackPorts[i] = 0;
- //_nframes = t._nframes;
_nframes = 0;
// Register ports.
@@ -1724,10 +1675,6 @@ void AudioAux::write(int level, Xml& xml) const
AudioAux::AudioAux()
: AudioTrack(AUDIO_AUX)
{
- //_channels = 0;
- //setChannels(2);
- //for (int i = 0; i < MAX_CHANNELS; ++i)
- // buffer[i] = (i < channels()) ? new float[MusEGlobal::segmentSize] : 0;
for(int i = 0; i < MAX_CHANNELS; ++i)
{
if(i < channels())
@@ -1740,10 +1687,6 @@ AudioAux::AudioAux()
AudioAux::AudioAux(const AudioAux& t, int flags)
: AudioTrack(t, flags)
{
- //_channels = 0;
- //setChannels(2);
- //for (int i = 0; i < MAX_CHANNELS; ++i)
- // buffer[i] = (i < channels()) ? new float[MusEGlobal::segmentSize] : 0;
for(int i = 0; i < MAX_CHANNELS; ++i)
{
if(i < channels())
@@ -1757,14 +1700,12 @@ AudioAux::AudioAux(const AudioAux& t, int flags)
//---------------------------------------------------------
AudioAux::~AudioAux()
- {
- //for (int i = 0; i < channels(); ++i)
- // delete[] buffer[i];
+{
for (int i = 0; i < MAX_CHANNELS; ++i) {
if (buffer[i])
free(buffer[i]);
- }
}
+}
//---------------------------------------------------------
// read
@@ -1821,17 +1762,7 @@ bool AudioAux::getData(unsigned pos, int ch, unsigned samples, float** data)
for (int i = 0; i < chans; ++i)
buff[i] = buff_data + i * samples;
- //printf("AudioAux::getData name:%s\n calling copyData on:%s auxRefCount:%d\n",
- // name().toLatin1().constData(), track->name().toLatin1().constData(), track->auxRefCount());
-
track->copyData(pos, chans, -1, -1, samples, buff);
-
- /* float* buff[ch];
- float buff_data[samples * ch];
- for (int i = 0; i < ch; ++i)
- buff[i] = buff_data + i * samples;
- //printf("Audio::process1 calling track->copyData for track:%s\n", track->name().toLatin1());
- track->copyData(pos, ch, -1, -1, samples, buff); */
}
}
@@ -1848,15 +1779,11 @@ void AudioAux::setChannels(int n)
{
if(n > channels())
{
- //for (int i = channels(); i < n; ++i)
- // buffer[i] = new float[MusEGlobal::segmentSize];
for(int i = channels(); i < n; ++i)
posix_memalign((void**)(buffer + i), 16, sizeof(float) * MusEGlobal::segmentSize);
}
else if(n < channels())
{
- //for (int i = n; i < channels(); ++i)
- // delete[] buffer[i];
for(int i = n; i < channels(); ++i)
{
if(buffer[i])
@@ -1876,7 +1803,6 @@ bool AudioTrack::setRecordFlag1(bool f)
if (f == _recordFlag)
return true;
if (f) {
- // do nothing
if (_recFile == 0 && MusEGlobal::song->record()) {
// this rec-enables a track if the global arm already was done
// the standard case would be that rec-enable be done there
@@ -1899,7 +1825,6 @@ bool AudioTrack::setRecordFlag1(bool f)
remove(s.toLatin1().constData());
if(MusEGlobal::debugMsg)
printf("AudioNode::setRecordFlag1: remove file %s if it exists\n", s.toLatin1().constData());
- //_recFile = 0;
}
}
return true;
diff --git a/muse2/muse/cliplist/cliplist.cpp b/muse2/muse/cliplist/cliplist.cpp
index 02a30dec..f610805e 100644
--- a/muse2/muse/cliplist/cliplist.cpp
+++ b/muse2/muse/cliplist/cliplist.cpp
@@ -67,7 +67,7 @@ ClipItem::ClipItem(QTreeWidget* parent, const MusECore::SndFileR& w)
// samples2smpte
//---------------------------------------------------------
-#if 0
+#if 0 // DELETETHIS ?
static QString samples2smpte(int samples)
{
double time = double(samples) / double(sampleRate);
@@ -96,7 +96,7 @@ static QString samples2smpte(int samples)
}
#endif
-/*
+/* DELETETHIS
//---------------------------------------------------------
// text
//---------------------------------------------------------
@@ -126,14 +126,11 @@ QString ClipItem::text(int col) const
ClipListEdit::ClipListEdit(QWidget* parent)
: TopWin(TopWin::CLIPLIST, parent, "cliplist", Qt::Window)
{
- //setAttribute(Qt::WA_DeleteOnClose);
setWindowTitle(tr("MusE: Clip List Editor"));
editor = new ClipListEditorBaseWidget;
setCentralWidget(editor);
- //editor->view->setColumnAlignment(COL_REFS, Qt::AlignRight);
-
QMenu* settingsMenu = menuBar()->addMenu(tr("Window &Config"));
settingsMenu->addAction(subwinAction);
@@ -283,7 +280,7 @@ void ClipListEdit::writeConfiguration(int level, MusECore::Xml& xml)
void ClipListEdit::startChanged(const MusECore::Pos& /*pos*/)//prevent compiler warning: unsused parameter
{
-// editor->view->triggerUpdate();
+// editor->view->triggerUpdate(); DELETETHIS whole function?
}
//---------------------------------------------------------
@@ -292,7 +289,7 @@ void ClipListEdit::startChanged(const MusECore::Pos& /*pos*/)//prevent compiler
void ClipListEdit::lenChanged(const MusECore::Pos& /*pos*/) //prevent compiler warning: unsused parameter
{
-// curClip.setLenFrame(pos.frame());
+// curClip.setLenFrame(pos.frame()); DELETETHIS whole function?
// editor->view->triggerUpdate();
}
@@ -308,7 +305,7 @@ void ClipListEdit::clipSelectionChanged()
editor->start->setEnabled(false);
editor->len->setEnabled(false);
return;
-/*
+/* DELETETHIS and the above two comments
}
editor->start->setEnabled(true);
editor->len->setEnabled(true);
@@ -328,7 +325,7 @@ void ClipListEdit::clipSelectionChanged()
void ClipListEdit::clicked(QTreeWidgetItem*, int)
{
-// printf("clicked\n");
+// printf("clicked\n"); DELETETHIS whole function
}
} // namespace MusEGui
diff --git a/muse2/muse/cobject.cpp b/muse2/muse/cobject.cpp
index f13cd257..cb1600a4 100644
--- a/muse2/muse/cobject.cpp
+++ b/muse2/muse/cobject.cpp
@@ -59,8 +59,7 @@ TopWin::TopWin(ToplevelType t, QWidget* parent, const char* name, Qt::WindowFlag
_type=t;
setObjectName(QString(name));
- // Allow multiple rows. Tim.
- //setDockNestingEnabled(true);
+ //setDockNestingEnabled(true); // Allow multiple rows. Tim.
setIconSize(ICON_SIZE);
subwinAction=new QAction(tr("As subwindow"), this);
@@ -78,8 +77,12 @@ TopWin::TopWin(ToplevelType t, QWidget* parent, const char* name, Qt::WindowFlag
connect(fullscreenAction, SIGNAL(toggled(bool)), SLOT(setFullscreen(bool)));
mdisubwin=NULL;
- _sharesToolsAndMenu=_defaultSubwin[_type] ? _sharesWhenSubwin[_type] : _sharesWhenFree[_type];
- if (_defaultSubwin[_type])
+ if (!MusEGlobal::unityWorkaround)
+ _sharesToolsAndMenu=_defaultSubwin[_type] ? _sharesWhenSubwin[_type] : _sharesWhenFree[_type];
+ else
+ _sharesToolsAndMenu=false;
+
+ if (_defaultSubwin[_type] && !MusEGlobal::unityWorkaround)
{
setIsMdiWin(true);
_savedToolbarState=_toolbarNonsharedInit[_type];
@@ -90,6 +93,11 @@ TopWin::TopWin(ToplevelType t, QWidget* parent, const char* name, Qt::WindowFlag
subwinAction->setChecked(isMdiWin());
shareAction->setChecked(_sharesToolsAndMenu);
+ if (MusEGlobal::unityWorkaround)
+ {
+ shareAction->setEnabled(false);
+ subwinAction->setEnabled(false);
+ }
fullscreenAction->setEnabled(!isMdiWin());
if (mdisubwin)
@@ -288,6 +296,9 @@ QMdiSubWindow* TopWin::createMdiWrapper()
void TopWin::setIsMdiWin(bool val)
{
+ if (MusEGlobal::unityWorkaround)
+ return;
+
if (val)
{
if (!isMdiWin())
@@ -363,7 +374,7 @@ void TopWin::addToolBar(QToolBar* toolbar)
{
_toolbars.push_back(toolbar);
- if (!_sharesToolsAndMenu)
+ if (!_sharesToolsAndMenu || MusEGlobal::unityWorkaround)
QMainWindow::addToolBar(toolbar);
else
toolbar->hide();
@@ -381,6 +392,9 @@ QToolBar* TopWin::addToolBar(const QString& title)
void TopWin::shareToolsAndMenu(bool val)
{
+ if (MusEGlobal::unityWorkaround)
+ return;
+
if (_sharesToolsAndMenu == val)
{
if (MusEGlobal::debugMsg) printf("TopWin::shareToolsAndMenu() called but has no effect\n");
diff --git a/muse2/muse/cobject.h b/muse2/muse/cobject.h
index f13ff591..d58bb823 100644
--- a/muse2/muse/cobject.h
+++ b/muse2/muse/cobject.h
@@ -146,10 +146,6 @@ class TopWin : public QMainWindow
// ToplevelList
//---------------------------------------------------------
-//typedef std::list <TopWin*> ToplevelList;
-//typedef ToplevelList::iterator iToplevel;
-//typedef ToplevelList::const_iterator ciToplevel;
-
typedef std::list<TopWin*>::iterator iToplevel;
typedef std::list<TopWin*>::const_iterator ciToplevel;
diff --git a/muse2/muse/conf.cpp b/muse2/muse/conf.cpp
index 638f591b..f35fd6b2 100644
--- a/muse2/muse/conf.cpp
+++ b/muse2/muse/conf.cpp
@@ -39,7 +39,6 @@
#include "arrangerview.h"
#include "marker/markerview.h"
#include "master/lmaster.h"
-///#include "transport.h"
#include "bigtime.h"
#include "arranger.h"
#include "conf.h"
@@ -171,7 +170,6 @@ static void readController(Xml& xml, int midiPort, int channel)
case Xml::TagEnd:
if (tag == "controller") {
MidiPort* port = &MusEGlobal::midiPorts[midiPort];
- //port->addManagedController(channel, id);
val = port->limitValToInstrCtlRange(id, val);
// The value here will actually be sent to the device LATER, in MidiPort::setMidiDevice()
port->setHwCtrlState(channel, id, val);
@@ -225,9 +223,6 @@ static void readConfigMidiPort(Xml& xml, bool onlyReadChannelState)
int idx = 0;
QString device;
- //QString instrument;
- // Changed by Tim.
- //QString instrument("generic midi");
// Let's be bold. New users have been confused by generic midi not enabling any patches and controllers.
// I had said this may cause HW problems by sending out GM sysEx when really the HW might not be GM.
// But this really needs to be done, one way or another.
@@ -306,7 +301,6 @@ static void readConfigMidiPort(Xml& xml, bool onlyReadChannelState)
if(onlyReadChannelState) // p4.0.41
return;
- //if (idx > MIDI_PORTS) {
if (idx < 0 || idx >= MIDI_PORTS) {
fprintf(stderr, "bad midi port %d (>%d)\n",
idx, MIDI_PORTS);
@@ -315,9 +309,6 @@ static void readConfigMidiPort(Xml& xml, bool onlyReadChannelState)
MidiDevice* dev = MusEGlobal::midiDevices.find(device);
- //if(MusEGlobal::debugMsg && !dev)
- // fprintf(stderr, "readConfigMidiPort: device not found %s\n", device.toLatin1().constData());
-
if(!dev && type == MidiDevice::JACK_MIDI)
{
if(MusEGlobal::debugMsg)
@@ -357,83 +348,6 @@ static void readConfigMidiPort(Xml& xml, bool onlyReadChannelState)
}
}
-/*
-//---------------------------------------------------------
-// readConfigMidiSyncInfo
-//---------------------------------------------------------
-
-static void readConfigMidiSyncInfo(Xml& xml)
-{
- QString device;
- int idOut = 127;
- int idIn = 127;
- bool sendMC = false;
- bool sendMMC = false;
- bool sendMTC = false;
- bool recMC = false;
- bool recMMC = false;
- bool recMTC = false;
-
- for (;;) {
- Xml::Token token = xml.parse();
- if (token == Xml::Error || token == Xml::End)
- break;
- QString tag = xml.s1();
- switch (token) {
- case Xml::TagStart:
- if (tag == "device")
- device = xml.parse1();
- else if (tag == "idOut")
- idOut = (xml.parseInt());
- else if (tag == "idIn")
- idIn = xml.parseInt();
- else if (tag == "sendMC")
- sendMC = xml.parseInt();
- else if (tag == "sendMMC")
- sendMMC = xml.parseInt();
- else if (tag == "sendMTC")
- sendMTC = xml.parseInt();
- else if (tag == "recMC")
- recMC = xml.parseInt();
- else if (tag == "recMMC")
- recMMC = xml.parseInt();
- else if (tag == "recMTC")
- recMTC = xml.parseInt();
- else
- xml.unknown("midiSyncInfo");
- break;
- case Xml::Attribut:
- break;
- case Xml::TagEnd:
- if(tag == "midiSyncInfo")
- {
- MidiDevice* dev = MusEGlobal::midiDevices.find(device);
- if(dev)
- {
- MidiSyncInfo& si = dev->syncInfo();
- si.setIdIn(idIn);
- si.setIdOut(idOut);
-
- si.setMCIn(recMC);
- si.setMMCIn(recMMC);
- si.setMTCIn(recMTC);
-
- si.setMCOut(sendMC);
- si.setMMCOut(sendMMC);
- si.setMTCOut(sendMTC);
- }
- else
- fprintf(stderr, "Read configuration: Sync device: %s not found\n", device.toLatin1().constData());
-
- return;
- }
- default:
- break;
- }
- }
-}
-*/
-
//---------------------------------------------------------
// loadConfigMetronom
//---------------------------------------------------------
@@ -982,52 +896,37 @@ void readConfiguration(Xml& xml, bool doReadMidiPortConfig, bool doReadGlobalCon
MusEGlobal::config.drumTrackPreference = (MusEGlobal::drumTrackPreference_t) xml.parseInt();
else if (tag == "unhideTracks")
MusEGlobal::config.unhideTracks = xml.parseInt();
+ else if (tag == "smartFocus")
+ MusEGlobal::config.smartFocus = xml.parseInt();
// ---- the following only skips obsolete entries ----
else if ((tag == "arranger") || (tag == "geometryPianoroll") || (tag == "geometryDrumedit"))
xml.skip(tag);
else if (tag == "mixerVisible")
- // MusEGlobal::config.mixerVisible = xml.parseInt(); // Obsolete
xml.skip(tag);
else if (tag == "geometryMixer")
- // MusEGlobal::config.geometryMixer = readGeometry(xml, tag); // Obsolete
xml.skip(tag);
else if (tag == "txDeviceId")
- //txDeviceId = xml.parseInt();
xml.parseInt();
else if (tag == "rxDeviceId")
- //rxDeviceId = xml.parseInt();
xml.parseInt();
else if (tag == "txSyncPort")
- //txSyncPort= xml.parseInt();
xml.parseInt();
else if (tag == "rxSyncPort")
- //rxSyncPort= xml.parseInt();
xml.parseInt();
- else if (tag == "syncgentype") {
- // for compatibility
- //int syncGenType= xml.parseInt();
- //genMTCSync = syncGenType == 1;
- //genMCSync = syncGenType == 2;
+ else if (tag == "syncgentype")
xml.parseInt();
- }
else if (tag == "genMTCSync")
- //genMTCSync = xml.parseInt();
xml.parseInt();
else if (tag == "genMCSync")
- //genMCSync = xml.parseInt();
xml.parseInt();
else if (tag == "genMMC")
- //genMMC = xml.parseInt();
xml.parseInt();
else if (tag == "acceptMTC")
- //acceptMTC = xml.parseInt();
xml.parseInt();
else if (tag == "acceptMMC")
- //acceptMMC = xml.parseInt();
xml.parseInt();
else if (tag == "acceptMC")
- //acceptMC = xml.parseInt();
xml.parseInt();
else if ((tag == "samplerate") || (tag == "segmentsize") || (tag == "segmentcount"))
xml.parseInt();
@@ -1164,8 +1063,6 @@ static void writeSeqConfiguration(int level, Xml& xml, bool writePortInfo)
// This prevents bogus routes from being saved and propagated in the med file.
// Hmm tough decision, should we save if no device? That would preserve routes in case user upgrades HW,
// or ALSA reorders or renames devices etc etc, then we have at least kept the track <-> port routes.
- //if(((!mport->noInRoute() || !mport->noOutRoute()) && dev) ||
- //mport->defaultInChannels() || mport->defaultOutChannels() ||
mport->defaultInChannels() != (1<<MIDI_CHANNELS)-1 || // p4.0.17 Default is now to connect to all channels.
mport->defaultOutChannels() ||
(!mport->instrument()->iname().isEmpty() && mport->instrument()->iname() != "GM") ||
@@ -1189,7 +1086,6 @@ static void writeSeqConfiguration(int level, Xml& xml, bool writePortInfo)
continue;
xml.tag(level++, "midiport idx=\"%d\"", i);
- //if(mport->defaultInChannels())
if(mport->defaultInChannels() != (1<<MIDI_CHANNELS)-1) // p4.0.17 Default is now to connect to all channels.
xml.intTag(level, "defaultInChans", mport->defaultInChannels());
if(mport->defaultOutChannels())
@@ -1202,14 +1098,9 @@ static void writeSeqConfiguration(int level, Xml& xml, bool writePortInfo)
if (dev) {
xml.strTag(level, "name", dev->name());
- //if(dynamic_cast<MidiJackDevice*>(dev))
if(dev->deviceType() != MidiDevice::ALSA_MIDI)
- //xml.intTag(level, "type", MidiDevice::JACK_MIDI);
xml.intTag(level, "type", dev->deviceType());
- // Changed by T356. "record" is old and by mistake written as rwFlags here.
- // openFlags was read before, but never written here.
- //xml.intTag(level, "record", dev->rwFlags() & 0x2 ? 1 : 0);
xml.intTag(level, "openFlags", dev->openFlags());
if(dev->deviceType() == MidiDevice::JACK_MIDI)
@@ -1282,8 +1173,6 @@ void MusE::writeGlobalConfiguration(int level, MusECore::Xml& xml) const
xml.uintTag(level, "minControlProcessPeriod", MusEGlobal::config.minControlProcessPeriod);
xml.intTag(level, "guiRefresh", MusEGlobal::config.guiRefresh);
- // Removed by Orcan. 20101220
- //xml.strTag(level, "helpBrowser", config.helpBrowser);
xml.intTag(level, "extendedMidi", MusEGlobal::config.extendedMidi);
xml.intTag(level, "midiExportDivision", MusEGlobal::config.midiDivision);
xml.intTag(level, "guiDivision", MusEGlobal::config.guiDivision);
@@ -1307,8 +1196,6 @@ void MusE::writeGlobalConfiguration(int level, MusECore::Xml& xml) const
xml.intTag(level, "midiFilterCtrl3", MusEGlobal::midiFilterCtrl3);
xml.intTag(level, "midiFilterCtrl4", MusEGlobal::midiFilterCtrl4);
- //xml.intTag(level, "txDeviceId", txDeviceId);
- //xml.intTag(level, "rxDeviceId", rxDeviceId);
xml.strTag(level, "theme", MusEGlobal::config.style);
xml.strTag(level, "styleSheetFile", MusEGlobal::config.styleSheetFile);
xml.strTag(level, "externalWavEditor", MusEGlobal::config.externalWavEditor);
@@ -1317,6 +1204,7 @@ void MusE::writeGlobalConfiguration(int level, MusECore::Xml& xml) const
xml.intTag(level, "popupsDefaultStayOpen", MusEGlobal::config.popupsDefaultStayOpen);
xml.intTag(level, "leftMouseButtonCanDecrease", MusEGlobal::config.leftMouseButtonCanDecrease);
xml.intTag(level, "rangeMarkerWithoutMMB", MusEGlobal::config.rangeMarkerWithoutMMB);
+ xml.intTag(level, "smartFocus", MusEGlobal::config.smartFocus);
xml.intTag(level, "unhideTracks", MusEGlobal::config.unhideTracks);
xml.intTag(level, "addHiddenTracks", MusEGlobal::config.addHiddenTracks);
@@ -1330,7 +1218,6 @@ void MusE::writeGlobalConfiguration(int level, MusECore::Xml& xml) const
xml.intTag(level, "outputTracksVisible", MusECore::AudioOutput::visible());
xml.intTag(level, "synthTracksVisible", MusECore::SynthI::visible());
- //for (int i = 0; i < 6; ++i) {
for (int i = 0; i < NUM_FONTS; ++i) {
char buffer[32];
sprintf(buffer, "font%d", i);
@@ -1384,28 +1271,15 @@ void MusE::writeGlobalConfiguration(int level, MusECore::Xml& xml) const
xml.colorTag(level, "auxTrackBg", MusEGlobal::config.auxTrackBg);
xml.colorTag(level, "synthTrackBg", MusEGlobal::config.synthTrackBg);
- //xml.intTag(level, "txSyncPort", txSyncPort);
- //xml.intTag(level, "rxSyncPort", rxSyncPort);
xml.intTag(level, "mtctype", MusEGlobal::mtcType);
xml.nput(level, "<mtcoffset>%02d:%02d:%02d:%02d:%02d</mtcoffset>\n",
MusEGlobal::mtcOffset.h(), MusEGlobal::mtcOffset.m(), MusEGlobal::mtcOffset.s(),
MusEGlobal::mtcOffset.f(), MusEGlobal::mtcOffset.sf());
- //xml.uintTag(level, "sendClockDelay", MusEGlobal::syncSendFirstClockDelay);
- //xml.intTag(level, "useJackTransport", MusEGlobal::useJackTransport);
- //xml.intTag(level, "jackTransportMaster", MusEGlobal::jackTransportMaster);
MusEGlobal::extSyncFlag.save(level, xml);
-// xml.intTag(level, "genMTCSync", genMTCSync);
-// xml.intTag(level, "genMCSync", genMCSync);
-// xml.intTag(level, "genMMC", genMMC);
-// xml.intTag(level, "acceptMTC", acceptMTC);
-// xml.intTag(level, "acceptMMC", acceptMMC);
-// xml.intTag(level, "acceptMC", acceptMC);
-
xml.qrectTag(level, "geometryMain", MusEGlobal::config.geometryMain);
xml.qrectTag(level, "geometryTransport", MusEGlobal::config.geometryTransport);
xml.qrectTag(level, "geometryBigTime", MusEGlobal::config.geometryBigTime);
- //xml.qrectTag(level, "geometryMixer", MusEGlobal::config.geometryMixer); // Obsolete
xml.intTag(level, "bigtimeVisible", MusEGlobal::config.bigTimeVisible);
xml.intTag(level, "transportVisible", MusEGlobal::config.transportVisible);
@@ -1464,39 +1338,6 @@ void MusE::writeConfiguration(int level, MusECore::Xml& xml) const
xml.intTag(level, "midiFilterCtrl3", MusEGlobal::midiFilterCtrl3);
xml.intTag(level, "midiFilterCtrl4", MusEGlobal::midiFilterCtrl4);
- //xml.intTag(level, "txDeviceId", txDeviceId);
- //xml.intTag(level, "rxDeviceId", rxDeviceId);
-
- //xml.intTag(level, "txSyncPort", txSyncPort);
- /*
- // To keep old muse versions happy...
- bool mcsync = mmc = mtc = false;
- for(int sp = 0; sp < MIDI_PORTS; ++sp)
- {
- MidiSyncTxPort* txPort = &midiSyncTxPorts[sp];
- if(txPort->doMCSync() || txPort->doMMC() || txPort->doMTC())
- {
- if(txPort->doMCSync())
- mcsync = true;
- if(txPort->doMMC())
- mmc = true;
- if(txPort->doMTC())
- mtc = true;
- xml.intTag(level, "txSyncPort", sp);
- break;
- }
- }
- */
-
- //xml.tag(level++, "midiSyncInfo");
- //for(iMusECore::MidiDevice id = MusECore::MusEGlobal::midiDevices.begin(); id != MusECore::MusEGlobal::midiDevices.end(); ++id)
- //{
- // MusECore::MidiDevice* md = *id;
- // md->syncInfo().write(level, xml, md);
- //}
- //xml.etag(level, "midiSyncInfo");
-
- //xml.intTag(level, "rxSyncPort", rxSyncPort);
xml.intTag(level, "mtctype", MusEGlobal::mtcType);
xml.nput(level, "<mtcoffset>%02d:%02d:%02d:%02d:%02d</mtcoffset>\n",
MusEGlobal::mtcOffset.h(), MusEGlobal::mtcOffset.m(), MusEGlobal::mtcOffset.s(),
@@ -1506,16 +1347,9 @@ void MusE::writeConfiguration(int level, MusECore::Xml& xml) const
xml.intTag(level, "jackTransportMaster", MusEGlobal::jackTransportMaster);
MusEGlobal::extSyncFlag.save(level, xml);
-// xml.intTag(level, "genMTCSync", genMTCSync);
-// xml.intTag(level, "genMCSync", genMCSync);
-// xml.intTag(level, "genMMC", genMMC);
-// xml.intTag(level, "acceptMTC", acceptMTC);
-// xml.intTag(level, "acceptMMC", acceptMMC);
-// xml.intTag(level, "acceptMC", acceptMC);
-
xml.intTag(level, "bigtimeVisible", viewBigtimeAction->isChecked());
xml.intTag(level, "transportVisible", viewTransportAction->isChecked());
-
+
xml.geometryTag(level, "geometryMain", this); // FINDME: maybe remove this? do we want
// the main win to jump around when loading?
if (transport)
@@ -1552,7 +1386,6 @@ void MusE::writeConfiguration(int level, MusECore::Xml& xml) const
void MusE::configMidiSync()
{
if (!midiSyncConfig)
- //midiSyncConfig = new MusEGui::MidiSyncConfig(this);
midiSyncConfig = new MusEGui::MidiSyncConfig;
if (midiSyncConfig->isVisible()) {
@@ -1734,11 +1567,9 @@ void MixerConfig::read(MusECore::Xml& xml)
else if (tag == "showSyntiTracks")
showSyntiTracks = xml.parseInt();
else
- //xml.unknown(name.toLatin1().constData());
xml.unknown("Mixer");
break;
case MusECore::Xml::TagEnd:
- //if (tag == name)
if (tag == "Mixer")
return;
default:
diff --git a/muse2/muse/confmport.cpp b/muse2/muse/confmport.cpp
index 0acb8f64..d3aef647 100644
--- a/muse2/muse/confmport.cpp
+++ b/muse2/muse/confmport.cpp
@@ -112,7 +112,6 @@ void MPConfig::changeDefInputRoutes(QAction* act)
if(defch)
MusEGlobal::audio->msgAddRoute(MusECore::Route(no, defch), MusECore::Route(*it, defch));
}
- //MusEGlobal::audio->msgUpdateSoloStates();
MusEGlobal::song->update(SC_ROUTE);
}
}
@@ -153,9 +152,9 @@ void MPConfig::changeDefOutputRoutes(QAction* act)
return;
int actid = act->data().toInt();
int defch = MusEGlobal::midiPorts[no].defaultOutChannels();
- // Turn on if and when multiple output routes are supported.
+ // Turn on if and when multiple output routes are supported. DELETETHIS??
#if 0
- int allch = (1 << MIDI_CHANNELS) - 1;
+ int allch = (1 << MIDI_CHANNELS) - 1;
#endif
if(actid == MIDI_CHANNELS + 1) // Apply to all tracks now.
@@ -164,6 +163,12 @@ void MPConfig::changeDefOutputRoutes(QAction* act)
// Tested: Hmm, allow ports with no device since that is a valid situation.
if(!MusEGlobal::song->midis()->empty()) // && MusEGlobal::midiPorts[no].device())
{
+ // Turn off if and when multiple output routes are supported.
+ #if 1
+ if(!defch) // No channels selected? Just return.
+ return;
+ #endif
+
int ret = QMessageBox::question(this, tr("Default output connections"),
tr("Are you sure you want to apply to all existing midi tracks now?"),
QMessageBox::Ok | QMessageBox::Cancel,
@@ -171,7 +176,7 @@ void MPConfig::changeDefOutputRoutes(QAction* act)
if(ret == QMessageBox::Ok)
{
MusECore::MidiTrackList* mtl = MusEGlobal::song->midis();
- // Turn on if and when multiple output routes are supported.
+ // Turn on if and when multiple output routes are supported. DELETETHIS??
#if 0
for(MusECore::iMidiTrack it = mtl->begin(); it != mtl->end(); ++it)
{
@@ -208,7 +213,7 @@ void MPConfig::changeDefOutputRoutes(QAction* act)
}
else
{
- #if 0 // Turn on if and when multiple output routes are supported.
+ #if 0 // Turn on if and when multiple output routes are supported. DELETETHIS??
int chbits;
if(actid == MIDI_CHANNELS) // Toggle all.
{
@@ -229,21 +234,31 @@ void MPConfig::changeDefOutputRoutes(QAction* act)
if(actid < MIDI_CHANNELS)
{
int chbits = 1 << actid;
- // Multiple out routes not supported. Make the setting exclusive to this port - exclude all other ports.
- MusECore::setPortExclusiveDefOutChan(no, chbits);
- int j = mdevView->rowCount();
- for(int i = 0; i < j; ++i)
- mdevView->item(i, DEVCOL_DEF_OUT_CHANS)->setText(MusECore::bitmap2String(i == no ? chbits : 0));
- if(defpup)
+ // Are we toggling off?
+ if(chbits & defch)
{
- QAction* a;
- for(int i = 0; i < MIDI_CHANNELS; ++i)
+ // Just clear this port's default channels.
+ MusEGlobal::midiPorts[no].setDefaultOutChannels(0);
+ mdevView->item(item->row(), DEVCOL_DEF_OUT_CHANS)->setText(MusECore::bitmap2String(0));
+ }
+ else
+ {
+ // Multiple out routes not supported. Make the setting exclusive to this port - exclude all other ports.
+ MusECore::setPortExclusiveDefOutChan(no, chbits);
+ int j = mdevView->rowCount();
+ for(int i = 0; i < j; ++i)
+ mdevView->item(i, DEVCOL_DEF_OUT_CHANS)->setText(MusECore::bitmap2String(i == no ? chbits : 0));
+ if(defpup)
{
- a = defpup->findActionFromData(i);
- if(a)
- a->setChecked(i == actid);
+ QAction* a;
+ for(int i = 0; i < MIDI_CHANNELS; ++i)
+ {
+ a = defpup->findActionFromData(i);
+ if(a)
+ a->setChecked(i == actid);
+ }
}
- }
+ }
}
#endif
}
@@ -257,13 +272,12 @@ void MPConfig::mdevViewItemRenamed(QTableWidgetItem* item)
{
int col = item->column();
QString s = item->text();
- //printf("MPConfig::mdevViewItemRenamed col:%d txt:%s\n", col, s.toLatin1().constData());
if(item == 0)
return;
switch(col)
{
// Enabled: Use editor (Not good - only responds if text changed. We need to respond always).
- // Disabled: Use pop-up menu.
+ // Disabled: Use pop-up menu. DELETETHIS?
#if 0
case DEVCOL_DEF_IN_CHANS:
{
@@ -284,7 +298,7 @@ void MPConfig::mdevViewItemRenamed(QTableWidgetItem* item)
QMessageBox::No);
if(ret == QMessageBox::Yes)
{
- MusECore::MidiTrackList* mtl = MusEGlobal::song->midis();
+ MusECore::MidiTrackList* mtl = MusEGlobal::song->midis();
for(MusECore::iMidiTrack it = mtl->begin(); it != mtl->end(); ++it)
{
// Remove all routes from this port to the tracks first.
@@ -301,7 +315,7 @@ void MPConfig::mdevViewItemRenamed(QTableWidgetItem* item)
// Enabled: Use editor (Not good - only responds if text changed. We need to respond always).
// Disabled: Use pop-up menu.
- // Only turn on if and when multiple output routes are supported.
+ // Only turn on if and when multiple output routes are supported. DELETETHIS?
#if 0
case DEVCOL_DEF_OUT_CHANS:
{
@@ -368,7 +382,6 @@ void MPConfig::mdevViewItemRenamed(QTableWidgetItem* item)
}
break;
default:
- //printf("MPConfig::mdevViewItemRenamed unknown column clicked col:%d txt:%s\n", col, s.toLatin1().constData());
break;
}
}
@@ -402,16 +415,10 @@ void MPConfig::rbClicked(QTableWidgetItem* item)
case DEVCOL_GUI:
if (dev == 0)
return;
- //if (port->hasGui())
if (port->hasNativeGui())
{
- //bool v = port->nativeGuiVisible()
- //port->instrument()->showGui(!port->guiVisible());
port->instrument()->showNativeGui(!port->nativeGuiVisible());
- //port->instrument()->showNativeGui(!v);
- //item->setIcon(port->guiVisible() ? QIcon(*dotIcon) : QIcon(*dothIcon));
item->setIcon(port->nativeGuiVisible() ? QIcon(*dotIcon) : QIcon(*dothIcon));
- //item->setIcon(!v ? QIcon(*dotIcon) : QIcon(*dothIcon));
}
return;
@@ -428,12 +435,12 @@ void MPConfig::rbClicked(QTableWidgetItem* item)
if(dev->openFlags() & 2)
{
item->tableWidget()->item(item->row(), DEVCOL_INROUTES)->setIcon(QIcon(*buttondownIcon));
- item->tableWidget()->item(item->row(), DEVCOL_INROUTES)->setText(tr("in"));
- }
+ item->tableWidget()->item(item->row(), DEVCOL_INROUTES)->setText(tr("in"));
+ }
else
{
item->tableWidget()->item(item->row(), DEVCOL_INROUTES)->setIcon(QIcon());
- item->tableWidget()->item(item->row(), DEVCOL_INROUTES)->setText("");
+ item->tableWidget()->item(item->row(), DEVCOL_INROUTES)->setText("");
}
}
return;
@@ -451,12 +458,12 @@ void MPConfig::rbClicked(QTableWidgetItem* item)
if(dev->openFlags() & 1)
{
item->tableWidget()->item(item->row(), DEVCOL_OUTROUTES)->setIcon(QIcon(*buttondownIcon));
- item->tableWidget()->item(item->row(), DEVCOL_OUTROUTES)->setText(tr("out"));
+ item->tableWidget()->item(item->row(), DEVCOL_OUTROUTES)->setText(tr("out"));
}
else
{
item->tableWidget()->item(item->row(), DEVCOL_OUTROUTES)->setIcon(QIcon());
- item->tableWidget()->item(item->row(), DEVCOL_OUTROUTES)->setText("");
+ item->tableWidget()->item(item->row(), DEVCOL_OUTROUTES)->setText("");
}
}
return;
@@ -474,16 +481,12 @@ void MPConfig::rbClicked(QTableWidgetItem* item)
return;
// Only Jack midi devices.
- //MusECore::MidiJackDevice* mjd = dynamic_cast<MusECore::MidiJackDevice*>(dev);
- //if(!mjd)
if(dev->deviceType() != MusECore::MidiDevice::JACK_MIDI)
return;
- //if(!(dev->rwFlags() & ((col == DEVCOL_OUTROUTES) ? 1 : 2)))
if(!(dev->openFlags() & ((col == DEVCOL_OUTROUTES) ? 1 : 2)))
return;
- //MusECore::RouteList* rl = (dev->rwFlags() & 1) ? dev->outRoutes() : dev->inRoutes();
MusECore::RouteList* rl = (col == DEVCOL_OUTROUTES) ? dev->outRoutes() : dev->inRoutes();
QMenu* pup = 0;
int gid = 0;
@@ -495,53 +498,40 @@ void MPConfig::rbClicked(QTableWidgetItem* item)
gid = 0;
// Jack input ports if device is writable, and jack output ports if device is readable.
- //sl = (dev->rwFlags() & 1) ? MusEGlobal::audioDevice->inputPorts(true, _showAliases) : MusEGlobal::audioDevice->outputPorts(true, _showAliases);
sl = (col == DEVCOL_OUTROUTES) ? MusEGlobal::audioDevice->inputPorts(true, _showAliases) : MusEGlobal::audioDevice->outputPorts(true, _showAliases);
- //for (int i = 0; i < channel; ++i)
- //{
- //char buffer[128];
- //snprintf(buffer, 128, "%s %d", tr("Channel").toLatin1().constData(), i+1);
- //MenuTitleItem* titel = new MenuTitleItem(QString(buffer));
- //pup->insertItem(titel);
-
- QAction* act;
-
- act = pup->addAction(tr("Show first aliases"));
- act->setData(gid);
- act->setCheckable(true);
- act->setChecked(_showAliases == 0);
- ++gid;
-
- act = pup->addAction(tr("Show second aliases"));
+ QAction* act;
+
+ act = pup->addAction(tr("Show first aliases"));
+ act->setData(gid);
+ act->setCheckable(true);
+ act->setChecked(_showAliases == 0);
+ ++gid;
+
+ act = pup->addAction(tr("Show second aliases"));
+ act->setData(gid);
+ act->setCheckable(true);
+ act->setChecked(_showAliases == 1);
+ ++gid;
+
+ pup->addSeparator();
+ for(std::list<QString>::iterator ip = sl.begin(); ip != sl.end(); ++ip)
+ {
+ act = pup->addAction(*ip);
act->setData(gid);
act->setCheckable(true);
- act->setChecked(_showAliases == 1);
- ++gid;
- pup->addSeparator();
- for(std::list<QString>::iterator ip = sl.begin(); ip != sl.end(); ++ip)
+ MusECore::Route rt(*ip, (col == DEVCOL_OUTROUTES), -1, MusECore::Route::JACK_ROUTE);
+ for(MusECore::ciRoute ir = rl->begin(); ir != rl->end(); ++ir)
{
- act = pup->addAction(*ip);
- act->setData(gid);
- act->setCheckable(true);
-
- //MusECore::Route dst(*ip, true, i);
- //MusECore::Route rt(*ip, (dev->rwFlags() & 1), -1, MusECore::Route::JACK_ROUTE);
- MusECore::Route rt(*ip, (col == DEVCOL_OUTROUTES), -1, MusECore::Route::JACK_ROUTE);
- for(MusECore::ciRoute ir = rl->begin(); ir != rl->end(); ++ir)
+ if (*ir == rt)
{
- if (*ir == rt)
- {
- act->setChecked(true);
- break;
- }
+ act->setChecked(true);
+ break;
}
- ++gid;
}
- //if (i+1 != channel)
- // pup->insertSeparator();
- //}
+ ++gid;
+ }
act = pup->exec(ppt);
if(act)
@@ -549,7 +539,6 @@ void MPConfig::rbClicked(QTableWidgetItem* item)
n = act->data().toInt();
if(n == 0) // Show first aliases
{
- //delete pup;
if(_showAliases == 0)
_showAliases = -1;
else
@@ -559,7 +548,6 @@ void MPConfig::rbClicked(QTableWidgetItem* item)
else
if(n == 1) // Show second aliases
{
- //delete pup;
if(_showAliases == 1)
_showAliases = -1;
else
@@ -569,7 +557,6 @@ void MPConfig::rbClicked(QTableWidgetItem* item)
QString s(act->text());
- //if(dev->rwFlags() & 1) // Writeable
if(col == DEVCOL_OUTROUTES) // Writeable
{
MusECore::Route srcRoute(dev, -1);
@@ -589,8 +576,6 @@ void MPConfig::rbClicked(QTableWidgetItem* item)
MusEGlobal::audio->msgAddRoute(srcRoute, dstRoute);
}
else
- //if(dev->rwFlags() & 2) // Readable
- //if(col == DEVCOL_INROUTES) // Readable
{
MusECore::Route srcRoute(s, false, -1, MusECore::Route::JACK_ROUTE);
MusECore::Route dstRoute(dev, -1);
@@ -612,24 +597,16 @@ void MPConfig::rbClicked(QTableWidgetItem* item)
MusEGlobal::audio->msgUpdateSoloStates();
MusEGlobal::song->update(SC_ROUTE);
- //delete pup;
// FIXME:
// Routes can't be re-read until the message sent from msgAddRoute1()
// has had time to be sent and actually affected the routes.
- ///goto _redisplay; // Go back
+ //goto _redisplay; // Go back
}
delete pup;
- //iR->setDown(false); // pup->exec() catches mouse release event
}
- //break;
return;
case DEVCOL_DEF_IN_CHANS:
- // Enabled: Use editor (Not good - only responds if text changed. We need to respond always).
- // Disabled: Use pop-up menu.
- #if 0
- return;
- #else
{
defpup = new MusEGui::PopupMenu(this, true);
defpup->addAction(new MusEGui::MenuTitleItem("Channel", defpup));
@@ -651,9 +628,10 @@ void MPConfig::rbClicked(QTableWidgetItem* item)
act->setData(MIDI_CHANNELS + 1);
// Enable only if there are tracks, and port has a device.
// Tested: Hmm, allow ports with no device since that is a valid situation.
- act->setEnabled(!MusEGlobal::song->midis()->empty()); // && MusEGlobal::midiPorts[no].device());
+ act->setEnabled(!MusEGlobal::song->midis()->empty()); // && MusEGlobal::midiPorts[no].device()); DELETETHIS
connect(defpup, SIGNAL(triggered(QAction*)), SLOT(changeDefInputRoutes(QAction*)));
+ // DELETETHIS 2
//connect(defpup, SIGNAL(aboutToHide()), MusEGlobal::muse, SLOT(routingPopupMenuAboutToHide()));
//defpup->popup(QCursor::pos());
defpup->exec(QCursor::pos());
@@ -661,15 +639,8 @@ void MPConfig::rbClicked(QTableWidgetItem* item)
defpup = 0;
}
return;
- #endif
case DEVCOL_DEF_OUT_CHANS:
- // Enabled: Use editor (Not good - only responds if text changed. We need to respond always).
- // Disabled: Use pop-up menu.
- // Only turn on if and when multiple output routes are supported.
- #if 0
- return;
- #else
{
defpup = new MusEGui::PopupMenu(this, true);
defpup->addAction(new MusEGui::MenuTitleItem("Channel", defpup));
@@ -683,7 +654,7 @@ void MPConfig::rbClicked(QTableWidgetItem* item)
act->setChecked((1 << i) & chbits);
}
- // Turn on if and when multiple output routes are supported.
+ // Turn on if and when multiple output routes are supported. DELETETHIS?
#if 0
act = defpup->addAction(tr("Toggle all"));
act->setData(MIDI_CHANNELS);
@@ -697,27 +668,21 @@ void MPConfig::rbClicked(QTableWidgetItem* item)
act->setEnabled(!MusEGlobal::song->midis()->empty()); // && MusEGlobal::midiPorts[no].device());
connect(defpup, SIGNAL(triggered(QAction*)), SLOT(changeDefOutputRoutes(QAction*)));
- //connect(defpup, SIGNAL(aboutToHide()), MusEGlobal::muse, SLOT(routingPopupMenuAboutToHide()));
- //defpup->popup(QCursor::pos());
defpup->exec(QCursor::pos());
delete defpup;
defpup = 0;
}
return;
- #endif
case DEVCOL_NAME:
{
- //printf("MPConfig::rbClicked DEVCOL_NAME\n");
-
// Did we click in the text area?
if((mousepos.x() - ppt.x()) > buttondownIcon->width())
{
- //printf("MPConfig::rbClicked starting item rename... enabled?:%d\n", item->renameEnabled(DEVCOL_NAME));
// Start the renaming of the cell...
- QModelIndex current = item->tableWidget()->currentIndex();
- if (item->flags() & Qt::ItemIsEditable)
- item->tableWidget()->edit(current.sibling(current.row(), DEVCOL_NAME));
+ QModelIndex current = item->tableWidget()->currentIndex();
+ if (item->flags() & Qt::ItemIsEditable)
+ item->tableWidget()->edit(current.sibling(current.row(), DEVCOL_NAME));
return;
}
@@ -748,20 +713,14 @@ void MPConfig::rbClicked(QTableWidgetItem* item)
int six = 0x30000000;
for(MusECore::iMidiDevice i = MusEGlobal::midiDevices.begin(); i != MusEGlobal::midiDevices.end(); ++i)
{
- //devALSA = dynamic_cast<MidiAlsaDevice*>(*i);
- //if(devALSA)
if((*i)->deviceType() == MusECore::MidiDevice::ALSA_MIDI)
{
- //mapALSA.insert( std::pair<std::string, int> (std::string(devALSA->name().lower().toLatin1().constData()), ii) );
mapALSA.insert( std::pair<std::string, int> (std::string((*i)->name().toLatin1().constData()), aix) );
++aix;
}
else
if((*i)->deviceType() == MusECore::MidiDevice::JACK_MIDI)
{
- //devJACK = dynamic_cast<MusECore::MidiJackDevice*>(*i);
- //if(devJACK)
- //mapJACK.insert( std::pair<std::string, int> (std::string(devJACK->name().lower().toLatin1().constData()), ii) );
mapJACK.insert( std::pair<std::string, int> (std::string((*i)->name().toLatin1().constData()), jix) );
++jix;
}
@@ -775,31 +734,27 @@ void MPConfig::rbClicked(QTableWidgetItem* item)
printf("MPConfig::rbClicked unknown midi device: %s\n", (*i)->name().toLatin1().constData());
}
- //int sz = MusEGlobal::midiDevices.size();
- //if(!mapALSA.empty())
+ pup->addSeparator();
+ pup->addAction(new MusEGui::MenuTitleItem("ALSA:", pup));
+
+ for(imap i = mapALSA.begin(); i != mapALSA.end(); ++i)
{
- pup->addSeparator();
- pup->addAction(new MusEGui::MenuTitleItem("ALSA:", pup));
-
- for(imap i = mapALSA.begin(); i != mapALSA.end(); ++i)
+ int idx = i->second;
+ //if(idx > sz) // Sanity check DELETETHIS 2
+ // continue;
+ QString s(i->first.c_str());
+ MusECore::MidiDevice* md = MusEGlobal::midiDevices.find(s, MusECore::MidiDevice::ALSA_MIDI);
+ if(md)
{
- int idx = i->second;
- //if(idx > sz) // Sanity check
- // continue;
- QString s(i->first.c_str());
- MusECore::MidiDevice* md = MusEGlobal::midiDevices.find(s, MusECore::MidiDevice::ALSA_MIDI);
- if(md)
- {
- //if(!dynamic_cast<MidiAlsaDevice*>(md))
- if(md->deviceType() != MusECore::MidiDevice::ALSA_MIDI)
- continue;
-
- act = pup->addAction(md->name());
- act->setData(idx);
- act->setCheckable(true);
- act->setChecked(md == dev);
- }
- }
+ //if(!dynamic_cast<MidiAlsaDevice*>(md)) DELETETHIS
+ if(md->deviceType() != MusECore::MidiDevice::ALSA_MIDI)
+ continue;
+
+ act = pup->addAction(md->name());
+ act->setData(idx);
+ act->setCheckable(true);
+ act->setChecked(md == dev);
+ }
}
if(!mapSYNTH.empty())
@@ -810,13 +765,10 @@ void MPConfig::rbClicked(QTableWidgetItem* item)
for(imap i = mapSYNTH.begin(); i != mapSYNTH.end(); ++i)
{
int idx = i->second;
- //if(idx > sz)
- // continue;
QString s(i->first.c_str());
MusECore::MidiDevice* md = MusEGlobal::midiDevices.find(s, MusECore::MidiDevice::SYNTH_MIDI);
if(md)
{
- //if(!dynamic_cast<MusECore::MidiJackDevice*>(md))
if(md->deviceType() != MusECore::MidiDevice::SYNTH_MIDI)
continue;
@@ -828,42 +780,34 @@ void MPConfig::rbClicked(QTableWidgetItem* item)
}
}
- //if(!mapJACK.empty())
+ pup->addSeparator();
+ pup->addAction(new MusEGui::MenuTitleItem("JACK:", pup));
+
+ for(imap i = mapJACK.begin(); i != mapJACK.end(); ++i)
{
- pup->addSeparator();
- pup->addAction(new MusEGui::MenuTitleItem("JACK:", pup));
-
- for(imap i = mapJACK.begin(); i != mapJACK.end(); ++i)
+ int idx = i->second;
+ QString s(i->first.c_str());
+ MusECore::MidiDevice* md = MusEGlobal::midiDevices.find(s, MusECore::MidiDevice::JACK_MIDI);
+ if(md)
{
- int idx = i->second;
- //if(idx > sz)
- // continue;
- QString s(i->first.c_str());
- MusECore::MidiDevice* md = MusEGlobal::midiDevices.find(s, MusECore::MidiDevice::JACK_MIDI);
- if(md)
- {
- //if(!dynamic_cast<MusECore::MidiJackDevice*>(md))
- if(md->deviceType() != MusECore::MidiDevice::JACK_MIDI)
- continue;
-
- act = pup->addAction(md->name());
- act->setData(idx);
- act->setCheckable(true);
- act->setChecked(md == dev);
- }
- }
- }
+ if(md->deviceType() != MusECore::MidiDevice::JACK_MIDI)
+ continue;
+
+ act = pup->addAction(md->name());
+ act->setData(idx);
+ act->setCheckable(true);
+ act->setChecked(md == dev);
+ }
+ }
act = pup->exec(ppt);
if(!act)
{
delete pup;
- //break;
return;
}
n = act->data().toInt();
- //printf("MPConfig::rbClicked n:%d\n", n);
MusECore::MidiDevice* sdev = 0;
if(n < 0x10000000)
@@ -891,11 +835,9 @@ void MPConfig::rbClicked(QTableWidgetItem* item)
int typ;
if(n < 0x20000000)
typ = MusECore::MidiDevice::ALSA_MIDI;
- else
- if(n < 0x30000000)
+ else if(n < 0x30000000)
typ = MusECore::MidiDevice::JACK_MIDI;
- else
- //if(n < 0x40000000)
+ else //if(n < 0x40000000)
typ = MusECore::MidiDevice::SYNTH_MIDI;
sdev = MusEGlobal::midiDevices.find(act->text(), typ);
@@ -918,13 +860,10 @@ void MPConfig::rbClicked(QTableWidgetItem* item)
for(MusECore::iMidiTrack it = mtl->begin(); it != mtl->end(); ++it)
MusEGlobal::audio->msgRemoveRoute(MusECore::Route(i, allch), MusECore::Route(*it, allch));
- // Turn on if and when multiple output routes are supported.
+ // Turn on if and when multiple output routes are supported. DELETETHIS?
#if 0
for(MusECore::iMidiTrack it = mtl->begin(); it != mtl->end(); ++it)
MusEGlobal::audio->msgRemoveRoute(MusECore::Route(no, allch), MusECore::Route(*it, allch));
-
- //MusEGlobal::audio->msgUpdateSoloStates();
- //MusEGlobal::song->update(SC_ROUTE);
#endif
break;
@@ -936,13 +875,10 @@ void MPConfig::rbClicked(QTableWidgetItem* item)
for(MusECore::iMidiTrack it = mtl->begin(); it != mtl->end(); ++it)
// Remove all routes from this port to the tracks.
MusEGlobal::audio->msgRemoveRoute(MusECore::Route(no, allch), MusECore::Route(*it, allch));
- // Turn on if and when multiple output routes are supported.
+ // Turn on if and when multiple output routes are supported. DELETETHIS?
#if 0
for(MusECore::iMidiTrack it = mtl->begin(); it != mtl->end(); ++it)
MusEGlobal::audio->msgRemoveRoute(MusECore::Route(no, allch), MusECore::Route(*it, allch));
-
- //MusEGlobal::audio->msgUpdateSoloStates();
- //MusEGlobal::song->update(SC_ROUTE);
#endif
MusEGlobal::midiSeq->msgSetMidiDevice(port, sdev);
@@ -957,26 +893,20 @@ void MPConfig::rbClicked(QTableWidgetItem* item)
{
for(MusECore::iMidiTrack it = mtl->begin(); it != mtl->end(); ++it)
{
- // Remove all routes from this port to the tracks first.
- //MusEGlobal::audio->msgRemoveRoute(MusECore::Route(no, allch), MusECore::Route(*it, allch));
- // Now connect all the specified routes.
+ // Connect all the specified routes.
if(chbits)
MusEGlobal::audio->msgAddRoute(MusECore::Route(no, chbits), MusECore::Route(*it, chbits));
}
}
chbits = MusEGlobal::midiPorts[no].defaultOutChannels();
- // Turn on if and when multiple output routes are supported.
+ // Turn on if and when multiple output routes are supported. DELETETHIS?
#if 0
for(MusECore::iMidiTrack it = mtl->begin(); it != mtl->end(); ++it)
{
- // Remove all routes from this port to the tracks first.
- //MusEGlobal::audio->msgRemoveRoute(MusECore::Route(no, allch), MusECore::Route(*it, allch));
- // Now connect all the specified routes.
+ // Connect all the specified routes.
if(chbits)
MusEGlobal::audio->msgAddRoute(MusECore::Route(no, chbits), MusECore::Route(*it, chbits));
}
- //MusEGlobal::audio->msgUpdateSoloStates();
- //MusEGlobal::song->update(SC_ROUTE);
#else
for(int ch = 0; ch < MIDI_CHANNELS; ++ch)
if(chbits & (1 << ch))
@@ -991,29 +921,21 @@ void MPConfig::rbClicked(QTableWidgetItem* item)
(*it)->setOutPortAndChannelAndUpdate(no, ch);
}
MusEGlobal::audio->msgIdle(false);
- //MusEGlobal::audio->msgUpdateSoloStates();
- //MusEGlobal::song->update(SC_MIDI_TRACK_PROP);
-
// Stop at the first output channel found.
break;
}
#endif
}
- //MusEGlobal::audio->msgUpdateSoloStates();
- ////MusEGlobal::song->update(SC_ROUTE);
-
MusEGlobal::audio->msgUpdateSoloStates();
MusEGlobal::song->update();
}
}
- //break;
return;
case DEVCOL_INSTR:
{
if (dev && dev->isSynti())
- //break;
return;
if (instrPopup == 0)
instrPopup = new QMenu(this);
@@ -1033,10 +955,9 @@ void MPConfig::rbClicked(QTableWidgetItem* item)
QAction* act = instrPopup->exec(ppt);
if(!act)
- //break;
return;
QString s = act->text();
- item->tableWidget()->item(item->row(), DEVCOL_INSTR)->setText(s);
+ item->tableWidget()->item(item->row(), DEVCOL_INSTR)->setText(s);
for (MusECore::iMidiInstrument i = MusECore::midiInstruments.begin(); i
!= MusECore::midiInstruments.end(); ++i) {
if ((*i)->iname() == s) {
@@ -1046,10 +967,8 @@ void MPConfig::rbClicked(QTableWidgetItem* item)
}
MusEGlobal::song->update();
}
- //break;
return;
}
- //songChanged(-1);
}
//---------------------------------------------------------
@@ -1065,11 +984,10 @@ void MPConfig::setToolTip(QTableWidgetItem *item, int col)
case DEVCOL_PLAY: item->setToolTip(tr("Enable writing")); break;
case DEVCOL_INSTR: item->setToolTip(tr("Port instrument")); break;
case DEVCOL_NAME: item->setToolTip(tr("Midi device name. Click to edit (Jack)")); break;
- //case DEVCOL_ROUTES: item->setToolTip(tr("Jack midi ports")); break;
case DEVCOL_INROUTES: item->setToolTip(tr("Connections from Jack Midi outputs")); break;
case DEVCOL_OUTROUTES: item->setToolTip(tr("Connections to Jack Midi inputs")); break;
case DEVCOL_DEF_IN_CHANS: item->setToolTip(tr("Auto-connect these channels to new midi tracks")); break;
- // Turn on if and when multiple output routes are supported.
+ // Turn on if and when multiple output routes are supported. DELETETHIS?
#if 0
case DEVCOL_DEF_OUT_CHANS: item->setToolTip(tr("Auto-connect new midi tracks to these channels")); break;
#else
@@ -1100,23 +1018,14 @@ void MPConfig::setWhatsThis(QTableWidgetItem *item, int col)
" this port number. Click to edit Jack midi name.")); break;
case DEVCOL_INSTR:
item->setWhatsThis(tr("Instrument connected to port")); break;
- //case DEVCOL_ROUTES:
- // item->setWhatsThis(tr("Jack midi ports")); break;
case DEVCOL_INROUTES:
item->setWhatsThis(tr("Connections from Jack Midi output ports")); break;
case DEVCOL_OUTROUTES:
item->setWhatsThis(tr("Connections to Jack Midi input ports")); break;
case DEVCOL_DEF_IN_CHANS:
- //item->setWhatsThis(tr("Auto-connect these channels, on this port, to new midi tracks.\n"
- // "Example:\n"
- // " 1 2 3 channel 1 2 and 3\n"
- // " 1-3 same\n"
- // " 1-3 5 channel 1 2 3 and 5\n"
- // " all all channels\n"
- // " none no channels")); break;
item->setWhatsThis(tr("Auto-connect these channels, on this port, to new midi tracks.")); break;
case DEVCOL_DEF_OUT_CHANS:
- // Turn on if and when multiple output routes are supported.
+ // Turn on if and when multiple output routes are supported. DELETETHIS?
#if 0
item->setWhatsThis(tr("Connect new midi tracks to these channels, on this port.")); break;
#else
@@ -1158,11 +1067,8 @@ MPConfig::MPConfig(QWidget* parent)
mdevView->setSelectionMode(QAbstractItemView::SingleSelection);
mdevView->setShowGrid(false);
- //popup = 0;
instrPopup = 0;
defpup = 0;
- //_showAliases = -1; // 0: Show first aliases, if available. Nah, stick with -1: none at first.
- //_showAliases = 0; // 0: Show first aliases, if available.
_showAliases = 1; // 0: Show second aliases, if available.
QStringList columnnames;
@@ -1199,7 +1105,6 @@ MPConfig::MPConfig(QWidget* parent)
connect(synthList, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), SLOT(addInstanceClicked()));
connect(removeInstance, SIGNAL(clicked()), SLOT(removeInstanceClicked()));
connect(instanceList, SIGNAL(itemDoubleClicked(QTreeWidgetItem*,int)), SLOT(removeInstanceClicked()));
- //songChanged(0);
songChanged(SC_CONFIG);
}
@@ -1224,9 +1129,6 @@ void MPConfig::selectionChanged()
void MPConfig::songChanged(int flags)
{
- // Is it simply a midi controller value adjustment? Forget it.
- //if(flags == SC_MIDI_CONTROLLER)
- // return;
if(!(flags & (SC_CONFIG | SC_TRACK_INSERTED | SC_TRACK_REMOVED | SC_TRACK_MODIFIED)))
return;
@@ -1235,7 +1137,7 @@ void MPConfig::songChanged(int flags)
QTableWidgetItem* sitem = mdevView->currentItem();
if(sitem)
{
- QString id = sitem->tableWidget()->item(sitem->row(), DEVCOL_NO)->text();
+ QString id = sitem->tableWidget()->item(sitem->row(), DEVCOL_NO)->text();
no = atoi(id.toLatin1().constData()) - 1;
if(no < 0 || no >= MIDI_PORTS)
no = -1;
@@ -1251,45 +1153,44 @@ void MPConfig::songChanged(int flags)
MusECore::MidiDevice* dev = port->device();
QString s;
s.setNum(i+1);
- QTableWidgetItem* itemno = new QTableWidgetItem(s);
- addItem(i, DEVCOL_NO, itemno, mdevView);
- itemno->setTextAlignment(Qt::AlignHCenter);
- itemno->setFlags(Qt::ItemIsEnabled);
- QTableWidgetItem* itemstate = new QTableWidgetItem(port->state());
- addItem(i, DEVCOL_STATE, itemstate, mdevView);
- itemstate->setFlags(Qt::ItemIsEnabled);
- QTableWidgetItem* iteminstr = new QTableWidgetItem(port->instrument() ?
- port->instrument()->iname() :
- tr("<unknown>"));
- addItem(i, DEVCOL_INSTR, iteminstr, mdevView);
- iteminstr->setFlags(Qt::ItemIsEnabled);
- QTableWidgetItem* itemname = new QTableWidgetItem;
- addItem(i, DEVCOL_NAME, itemname, mdevView);
- itemname->setFlags(Qt::ItemIsEnabled);
- QTableWidgetItem* itemgui = new QTableWidgetItem;
- addItem(i, DEVCOL_GUI, itemgui, mdevView);
- itemgui->setTextAlignment(Qt::AlignHCenter);
- itemgui->setFlags(Qt::ItemIsEnabled);
- QTableWidgetItem* itemrec = new QTableWidgetItem;
- addItem(i, DEVCOL_REC, itemrec, mdevView);
- itemrec->setTextAlignment(Qt::AlignHCenter);
- itemrec->setFlags(Qt::ItemIsEnabled);
- QTableWidgetItem* itemplay = new QTableWidgetItem;
- addItem(i, DEVCOL_PLAY, itemplay, mdevView);
- itemplay->setTextAlignment(Qt::AlignHCenter);
- itemplay->setFlags(Qt::ItemIsEnabled);
- QTableWidgetItem* itemout = new QTableWidgetItem;
- addItem(i, DEVCOL_OUTROUTES, itemout, mdevView);
- itemout->setFlags(Qt::ItemIsEnabled);
- QTableWidgetItem* itemin = new QTableWidgetItem;
- addItem(i, DEVCOL_INROUTES, itemin, mdevView);
- itemin->setFlags(Qt::ItemIsEnabled);
- //QTableWidgetItem* itemdefin = new QTableWidgetItem(MusECore::bitmap2String(port->defaultInChannels()));
+ QTableWidgetItem* itemno = new QTableWidgetItem(s);
+ addItem(i, DEVCOL_NO, itemno, mdevView);
+ itemno->setTextAlignment(Qt::AlignHCenter);
+ itemno->setFlags(Qt::ItemIsEnabled);
+ QTableWidgetItem* itemstate = new QTableWidgetItem(port->state());
+ addItem(i, DEVCOL_STATE, itemstate, mdevView);
+ itemstate->setFlags(Qt::ItemIsEnabled);
+ QTableWidgetItem* iteminstr = new QTableWidgetItem(port->instrument() ?
+ port->instrument()->iname() :
+ tr("<unknown>"));
+ addItem(i, DEVCOL_INSTR, iteminstr, mdevView);
+ iteminstr->setFlags(Qt::ItemIsEnabled);
+ QTableWidgetItem* itemname = new QTableWidgetItem;
+ addItem(i, DEVCOL_NAME, itemname, mdevView);
+ itemname->setFlags(Qt::ItemIsEnabled);
+ QTableWidgetItem* itemgui = new QTableWidgetItem;
+ addItem(i, DEVCOL_GUI, itemgui, mdevView);
+ itemgui->setTextAlignment(Qt::AlignHCenter);
+ itemgui->setFlags(Qt::ItemIsEnabled);
+ QTableWidgetItem* itemrec = new QTableWidgetItem;
+ addItem(i, DEVCOL_REC, itemrec, mdevView);
+ itemrec->setTextAlignment(Qt::AlignHCenter);
+ itemrec->setFlags(Qt::ItemIsEnabled);
+ QTableWidgetItem* itemplay = new QTableWidgetItem;
+ addItem(i, DEVCOL_PLAY, itemplay, mdevView);
+ itemplay->setTextAlignment(Qt::AlignHCenter);
+ itemplay->setFlags(Qt::ItemIsEnabled);
+ QTableWidgetItem* itemout = new QTableWidgetItem;
+ addItem(i, DEVCOL_OUTROUTES, itemout, mdevView);
+ itemout->setFlags(Qt::ItemIsEnabled);
+ QTableWidgetItem* itemin = new QTableWidgetItem;
+ addItem(i, DEVCOL_INROUTES, itemin, mdevView);
+ itemin->setFlags(Qt::ItemIsEnabled);
// Ignore synth devices. Default input routes make no sense for them (right now).
QTableWidgetItem* itemdefin = new QTableWidgetItem((dev && dev->isSynti()) ?
QString() : MusECore::bitmap2String(port->defaultInChannels()));
addItem(i, DEVCOL_DEF_IN_CHANS, itemdefin, mdevView);
- // Enabled: Use editor (not good). Disabled: Use pop-up menu.
+ // Enabled: Use editor (not good). Disabled: Use pop-up menu. DELETETHIS
#if 0
itemdefin->setFlags((dev && dev->isSynti()) ? Qt::NoItemFlags : Qt::ItemIsEditable | Qt::ItemIsEnabled);
# else
@@ -1302,13 +1203,12 @@ void MPConfig::songChanged(int flags)
}
#endif
- // Turn on if and when multiple output routes are supported.
+ // Turn on if and when multiple output routes are supported. DELETETHIS?
#if 0
QTableWidgetItem* itemdefout = new QTableWidgetItem(MusECore::bitmap2String(port->defaultOutChannels()));
addItem(i, DEVCOL_DEF_OUT_CHANS, itemdefout, mdevView);
itemdefout->setFlags(Qt::ItemIsEditable | Qt::ItemIsEnabled);
#else
- //QTableWidgetItem* itemdefout = new QTableWidgetItem(QString("--"));
QTableWidgetItem* itemdefout = new QTableWidgetItem(MusECore::bitmap2String(0));
defochs = port->defaultOutChannels();
if(defochs)
@@ -1333,7 +1233,6 @@ void MPConfig::songChanged(int flags)
itemname->setText(dev->name());
// Is it a Jack midi device? Allow renaming.
- //if(dynamic_cast<MusECore::MidiJackDevice*>(dev))
if (dev->deviceType() == MusECore::MidiDevice::JACK_MIDI)
itemname->setFlags(Qt::ItemIsEditable | Qt::ItemIsEnabled);
@@ -1347,46 +1246,38 @@ void MPConfig::songChanged(int flags)
itemplay->setIcon(QIcon(QPixmap()));
}
else {
- itemname->setText(tr("<none>"));
+ itemname->setText(tr("<none>"));
itemgui->setIcon(QIcon(*dothIcon));
- itemrec->setIcon(QIcon(QPixmap()));
- itemplay->setIcon(QIcon(QPixmap()));
+ itemrec->setIcon(QIcon(QPixmap()));
+ itemplay->setIcon(QIcon(QPixmap()));
}
- //if (port->hasGui()) {
- if (port->hasNativeGui()) {
- //itemgui->setIcon(port->guiVisible() ? QIcon(*dotIcon) : QIcon(*dothIcon));
+ if (port->hasNativeGui())
itemgui->setIcon(port->nativeGuiVisible() ? QIcon(*dotIcon) : QIcon(*dothIcon));
- }
- else {
- itemgui->setIcon(QIcon(QPixmap()));
- }
+ else
+ itemgui->setIcon(QIcon(QPixmap()));
+
if (!(dev && dev->isSynti()))
- iteminstr->setIcon(QIcon(*buttondownIcon));
- itemname->setIcon(QIcon(*buttondownIcon));
+ iteminstr->setIcon(QIcon(*buttondownIcon));
+
+ itemname->setIcon(QIcon(*buttondownIcon));
- //if(dev && dynamic_cast<MusECore::MidiJackDevice*>(dev))
if(dev && dev->deviceType() == MusECore::MidiDevice::JACK_MIDI)
{
- //item->setPixmap(DEVCOL_ROUTES, *buttondownIcon);
- //item->setText(DEVCOL_ROUTES, tr("routes"));
-
if(dev->rwFlags() & 1)
- //if(dev->openFlags() & 1)
{
if(dev->openFlags() & 1)
{
itemout->setIcon(QIcon(*buttondownIcon));
- itemout->setText(tr("out"));
+ itemout->setText(tr("out"));
}
}
if(dev->rwFlags() & 2)
- //if(dev->openFlags() & 2)
{
if(dev->openFlags() & 2)
{
itemin->setIcon(QIcon(*buttondownIcon));
- itemin->setText(tr("in"));
+ itemin->setText(tr("in"));
}
}
}
@@ -1405,7 +1296,6 @@ void MPConfig::songChanged(int flags)
item->setText(1, MusECore::synthType2String((*i)->synthType()));
s.setNum((*i)->instances());
item->setText(2, s);
- //item->setTextAlignment(2, Qt::AlignHCenter);
item->setText(3, QString((*i)->name()));
item->setText(4, QString((*i)->version()));
@@ -1422,7 +1312,6 @@ void MPConfig::songChanged(int flags)
else
s.setNum((*si)->midiPort() + 1);
iitem->setText(2, s);
- //iitem->setTextAlignment(2, Qt::AlignHCenter);
}
synthList->resizeColumnToContents(1);
mdevView->resizeColumnsToContents();
@@ -1456,7 +1345,7 @@ void MPConfig::addInstanceClicked()
MusECore::MidiDevice* dev = port->device();
if (dev==0) {
MusEGlobal::midiSeq->msgSetMidiDevice(port, si);
- MusEGlobal::muse->changeConfig(true); // save configuration file
+ MusEGlobal::muse->changeConfig(true); // save configuration file
MusEGlobal::song->update();
break;
}
diff --git a/muse2/muse/confmport.h b/muse2/muse/confmport.h
index 5d360319..ce23fd24 100644
--- a/muse2/muse/confmport.h
+++ b/muse2/muse/confmport.h
@@ -50,7 +50,6 @@ class PopupMenu;
class MPConfig : public QDialog, Ui::SynthConfigBase {
Q_OBJECT
QMenu* instrPopup;
- //QMenu* popup;
MusEGui::PopupMenu* defpup;
int _showAliases; // -1: None. 0: First aliases. 1: Second aliases etc.
void setWhatsThis(QTableWidgetItem *item, int col);
diff --git a/muse2/muse/controlfifo.cpp b/muse2/muse/controlfifo.cpp
index c9ff9ed6..b3b293bb 100644
--- a/muse2/muse/controlfifo.cpp
+++ b/muse2/muse/controlfifo.cpp
@@ -34,7 +34,6 @@ bool ControlFifo::put(const ControlEvent& event)
if (size < CONTROL_FIFO_SIZE) {
fifo[wIndex] = event;
wIndex = (wIndex + 1) % CONTROL_FIFO_SIZE;
- // q_atomic_increment(&size);
++size;
return false;
}
@@ -49,7 +48,6 @@ ControlEvent ControlFifo::get()
{
ControlEvent event(fifo[rIndex]);
rIndex = (rIndex + 1) % CONTROL_FIFO_SIZE;
- // q_atomic_decrement(&size);
--size;
return event;
}
@@ -71,7 +69,6 @@ const ControlEvent& ControlFifo::peek(int n)
void ControlFifo::remove()
{
rIndex = (rIndex + 1) % CONTROL_FIFO_SIZE;
- // q_atomic_decrement(&size);
--size;
}
diff --git a/muse2/muse/ctrl.cpp b/muse2/muse/ctrl.cpp
index f9353860..9f94e9df 100644
--- a/muse2/muse/ctrl.cpp
+++ b/muse2/muse/ctrl.cpp
@@ -27,7 +27,6 @@
#include <QLocale>
#include <QColor>
-//#include <stdlib.h>
#include "gconfig.h"
#include "fastlog.h"
@@ -126,10 +125,6 @@ void CtrlList::assign(const CtrlList& l, int flags)
double CtrlList::value(int frame) const
{
- // Changed by Tim. p4.0.32...
-
- ///if (!automation || empty())
- /// return _curVal;
if(empty())
return _curVal;
@@ -137,50 +132,32 @@ double CtrlList::value(int frame) const
ciCtrl i = upper_bound(frame); // get the index after current frame
if (i == end()) { // if we are past all items just return the last value
- ///ciCtrl i = end();
--i;
- ///const CtrlVal& val = i->second;
- ///_curVal = val.val;
rv = i->second.val;
}
else if(_mode == DISCRETE)
{
if(i == begin())
{
- ///_curVal = _default;
- //if(i->second.frame == frame)
rv = i->second.val;
- //else
- // rv = _default;
}
else
{
--i;
- ///const CtrlVal& val = i->second;
- ///_curVal = val.val;
rv = i->second.val;
}
}
else {
- ///int frame2 = i->second.frame;
- ///double val2 = i->second.val;
- ///int frame1;
- ///double val1;
if (i == begin()) {
- ///frame1 = 0;
- ///val1 = _default;
rv = i->second.val;
}
else {
int frame2 = i->second.frame;
double val2 = i->second.val;
--i;
- ///frame1 = i->second.frame;
- ///val1 = i->second.val;
int frame1 = i->second.frame;
double val1 = i->second.val;
- ///}
- //printf("before val1=%f val2=%f\n", val1,val2);
+
if (_valueType == VAL_LOG) {
val1 = 20.0*fast_log10(val1);
if (val1 < MusEGlobal::config.minSlider)
@@ -189,7 +166,7 @@ double CtrlList::value(int frame) const
if (val2 < MusEGlobal::config.minSlider)
val2=MusEGlobal::config.minSlider;
}
- //printf("after val1=%f val2=%f\n", val1,val2);
+
frame -= frame1;
val2 -= val1;
frame2 -= frame1;
@@ -198,13 +175,10 @@ double CtrlList::value(int frame) const
if (_valueType == VAL_LOG) {
val1 = exp10(val1/20.0);
}
- //printf("after val1=%f\n", val1);
- ///_curVal = val1;
+
rv = val1;
}
}
-// printf("autoVal %d %f\n", frame, _curVal);
- ///return _curVal;
return rv;
}
@@ -214,9 +188,6 @@ double CtrlList::value(int frame) const
//---------------------------------------------------------
double CtrlList::curVal() const
{
- //double v = value(Pos(audio->tickPos()).frame()); // p4.0.33
- //double v = value(audio->pos().frame()); // Try this.
- //return v;
return _curVal;
}
@@ -226,8 +197,6 @@ double CtrlList::curVal() const
void CtrlList::setCurVal(double val)
{
_curVal = val;
- //if (size() < 2) // Removed p4.0.32
- // add(0,val);
}
//---------------------------------------------------------
@@ -236,7 +205,6 @@ void CtrlList::setCurVal(double val)
void CtrlList::add(int frame, double val)
{
-// printf("add %d %f\n", frame, val);
iCtrl e = find(frame);
if (e != end())
e->second.val = val;
@@ -251,10 +219,9 @@ void CtrlList::add(int frame, double val)
void CtrlList::del(int frame)
{
iCtrl e = find(frame);
- if (e == end()) {
- //printf("CtrlList::del(%d): not found\n", frame);
+ if (e == end())
return;
- }
+
erase(e);
}
@@ -276,14 +243,12 @@ void CtrlList::read(Xml& xml)
case Xml::Attribut:
if (tag == "id")
{
- //_id = xml.s2().toInt();
_id = loc.toInt(xml.s2(), &ok);
if(!ok)
printf("CtrlList::read failed reading _id string: %s\n", xml.s2().toLatin1().constData());
}
else if (tag == "cur")
{
- //_curVal = xml.s2().toDouble();
_curVal = loc.toDouble(xml.s2(), &ok);
if(!ok)
printf("CtrlList::read failed reading _curVal string: %s\n", xml.s2().toLatin1().constData());
@@ -310,33 +275,6 @@ void CtrlList::read(Xml& xml)
break;
case Xml::Text:
{
- // Changed by Tim. Users in some locales reported corrupt reading,
- // because of the way floating point is represented (2,3456 not 2.3456).
- /*
- QByteArray ba = tag.toLatin1();
- const char* s = ba;.constData();
- int frame;
- double val;
-
- for (;;) {
- char* endp;
- while (*s == ' ' || *s == '\n')
- ++s;
- if (*s == 0)
- break;
- frame = strtol(s, &endp, 10);
- s = endp;
- while (*s == ' ' || *s == '\n')
- ++s;
- val = strtod(s, &endp);
- add(frame, val);
- s = endp;
- ++s;
- }
- */
-
- //printf("CtrlList::read tag:%s\n", tag.toLatin1().constData());
-
int len = tag.length();
int frame;
double val;
@@ -358,9 +296,6 @@ void CtrlList::read(Xml& xml)
if(i == len)
break;
- // Works OK, but only because if current locale fails it falls back on 'C' locale.
- // So, let's skip the fallback and force use of 'C' locale.
- //frame = fs.toInt(&ok);
frame = loc.toInt(fs, &ok);
if(!ok)
{
@@ -380,9 +315,6 @@ void CtrlList::read(Xml& xml)
++i;
}
- // Works OK, but only because if current locale fails it falls back on 'C' locale.
- // So, let's skip the fallback and force use of 'C' locale.
- //val = vs.toDouble(&ok);
val = loc.toDouble(vs, &ok);
if(!ok)
{
@@ -390,8 +322,6 @@ void CtrlList::read(Xml& xml)
break;
}
- //printf("CtrlList::read i:%d len:%d fs:%s frame %d: vs:%s val %f \n", i, len, fs.toLatin1().constData(), frame, vs.toLatin1().constData(), val);
-
add(frame, val);
if(i == len)
@@ -401,11 +331,7 @@ void CtrlList::read(Xml& xml)
break;
case Xml::TagEnd:
if (xml.s1() == "controller")
- {
- //printf("CtrlList::read _id:%d _curVal:%f\n", _id, _curVal);
-
return;
- }
default:
break;
}
@@ -418,7 +344,6 @@ void CtrlList::read(Xml& xml)
void CtrlListList::add(CtrlList* vl)
{
-// printf("CtrlListList(%p)::add(id=%d) size %d\n", this, vl->id(), size());
insert(std::pair<const int, CtrlList*>(vl->id(), vl));
}
diff --git a/muse2/muse/ctrl.h b/muse2/muse/ctrl.h
index 83db1063..53cdcf49 100644
--- a/muse2/muse/ctrl.h
+++ b/muse2/muse/ctrl.h
@@ -43,7 +43,6 @@ const int AC_VOLUME = 0;
const int AC_PAN = 1;
const int AC_MUTE = 2;
-//inline int genACnum(int plugin, int ctrl) { return (plugin + 1) * AC_PLUGIN_CTL_BASE + ctrl; }
inline unsigned long genACnum(unsigned long plugin, unsigned long ctrl) { return (plugin + 1) * AC_PLUGIN_CTL_BASE + ctrl; }
enum CtrlValueType { VAL_LOG, VAL_LINEAR, VAL_INT, VAL_BOOL };
@@ -122,8 +121,8 @@ class CtrlList : public std::map<int, CtrlVal, std::less<int> > {
void setMode(Mode m) { _mode = m; }
double getDefault() const { return _default; }
void setDefault(double val) { _default = val; }
- double curVal() const; /* { return _curVal; } */
- void setCurVal(double val); // { _curVal = val; }
+ double curVal() const;
+ void setCurVal(double val);
int id() const { return _id; }
QString name() const { return _name; }
void setName(const QString& s) { _name = s; }
diff --git a/muse2/muse/ctrl/ctrlcanvas.cpp b/muse2/muse/ctrl/ctrlcanvas.cpp
index ddecdbf6..36990595 100644
--- a/muse2/muse/ctrl/ctrlcanvas.cpp
+++ b/muse2/muse/ctrl/ctrlcanvas.cpp
@@ -114,7 +114,6 @@ static int computeY(const MusECore::MidiController* mc, int val, int height)
CEvent::CEvent(MusECore::Event e, MusECore::MidiPart* pt, int v)
{
_event = e;
- //_state = Normal;
_part = pt;
_val = v;
ex = !e.empty() ? e.tick() : 0;
@@ -128,16 +127,11 @@ bool CEvent::intersects(const MusECore::MidiController* mc, const QRect& r, cons
{
if(_event.empty())
return false;
- //int y1 = wh - (_val * wh / 128);
int y1 = computeY(mc, _val, wh);
int tick1 = _event.tick() + _part->tick();
if(ex == -1)
- {
- //printf("ex:-1 tick1:%d y1:%d r.x:%d r.y:%d r.w:%d r.h:%d\n", tick1, y1, r.x(), r.y(), r.width(), r.height());
- //return tick1 < (r.x() + r.width()) && y1 >= r.y() && y1 < (r.y() + r.height());
return tick1 < (r.x() + r.width()) && y1 < (r.y() + r.height());
- }
int tick2 = ex + _part->tick();
@@ -147,18 +141,10 @@ bool CEvent::intersects(const MusECore::MidiController* mc, const QRect& r, cons
// So that's 3 x tickstep for each velocity line.
// Hmm, actually, for better pin-point accuracy just use one tickstep for now.
if(MusECore::midiControllerType(mc->num()) == MusECore::MidiController::Velo)
- {
- //tick1 -= tickstep;
- //if(tick1 <= 0)
- // tick1 = 0;
- //tick2 += 2 * tickstep;
-
tick2 += tickstep;
- }
QRect er(tick1, y1, tick2 - tick1, wh - y1);
- //printf("t1:%d t2:%d ex:%d r.x:%d r.y:%d r.w:%d r.h:%d er.x:%d er.y:%d er.w:%d er.h:%d\n",
- // tick1, tick2, ex, r.x(), r.y(), r.width(), r.height(), er.x(), er.y(), er.width(), er.height());
+
return r.intersects(er);
}
@@ -174,7 +160,7 @@ bool CEvent::contains(int x1, int x2) const
int tick2 = ex + _part->tick();
return ((tick1 >= x1 && tick1 < x2)
- //|| (tick2 >= x1 && tick2 < x2)
+ //|| (tick2 >= x1 && tick2 < x2) DELETETHIS?
|| (tick2 > x1 && tick2 < x2)
|| (tick1 < x1 && tick2 >= x2));
}
@@ -210,8 +196,6 @@ CtrlCanvas::CtrlCanvas(MidiEditor* e, QWidget* parent, int xmag,
pos[1] = 0;
pos[2] = 0;
noEvents=false;
- //_isFirstMove = true;
- //_lastDelta = QPoint(0, 0);
if (dynamic_cast<DrumEdit*>(editor) && dynamic_cast<DrumEdit*>(editor)->old_style_drummap_mode()==false)
filterTrack=true;
@@ -326,8 +310,7 @@ void CtrlCanvas::setPos(int idx, unsigned val, bool adjustScrollbar)
void CtrlCanvas::setMidiController(int num)
{
_cnum = num;
- //if(curPart)
- partControllers(curPart, _cnum, &_dnum, &_didx, &_controller, &ctrl);
+ partControllers(curPart, _cnum, &_dnum, &_didx, &_controller, &ctrl);
if(_panel)
{
@@ -364,14 +347,9 @@ QPoint CtrlCanvas::raster(const QPoint& p) const
void CtrlCanvas::deselectAll()
{
for(iCEvent i = selection.begin(); i != selection.end(); ++i)
- {
- //(*i)->setState(CEvent::Normal);
- //if(!(*i)->event().empty())
- // (*i)->event().setSelected(false);
(*i)->setSelected(false);
- }
+
selection.clear();
- ///update();
}
//---------------------------------------------------------
@@ -380,12 +358,8 @@ void CtrlCanvas::deselectAll()
void CtrlCanvas::selectItem(CEvent* e)
{
- //e->setState(CEvent::Selected);
- //if(!e->event().empty())
- // e->event().setSelected(true);
e->setSelected(true);
selection.push_back(e);
- ///update();
}
//---------------------------------------------------------
@@ -394,9 +368,6 @@ void CtrlCanvas::selectItem(CEvent* e)
void CtrlCanvas::deselectItem(CEvent* e)
{
- //e->setState(CEvent::Normal);
- //if(!e->event().empty())
- // e->event().setSelected(false);
e->setSelected(false);
for (iCEvent i = selection.begin(); i != selection.end(); ++i) {
if (*i == e) {
@@ -404,7 +375,6 @@ void CtrlCanvas::deselectItem(CEvent* e)
break;
}
}
- ///update();
}
//---------------------------------------------------------
@@ -492,18 +462,14 @@ void CtrlCanvas::songChanged(int type)
// some other useless calls using SC_CONFIG, which was not used
// anywhere else in muse before now, except song header.
if((type & (SC_CONFIG | SC_DRUMMAP)) || ((type & (SC_PART_MODIFIED | SC_SELECTION)) && changed))
- {
setMidiController(_cnum);
- //return;
- }
if(!curPart) // p4.0.27
return;
if(type & (SC_CONFIG | SC_DRUMMAP | SC_PART_MODIFIED | SC_EVENT_INSERTED | SC_EVENT_REMOVED | SC_EVENT_MODIFIED)) // p4.0.18
updateItems();
- else
- if(type & SC_SELECTION)
+ else if(type & SC_SELECTION)
updateSelections(); // p4.0.18
}
@@ -551,7 +517,6 @@ void CtrlCanvas::partControllers(const MusECore::MidiPart* part, int num, int* d
{
di = (num & ~0xff) | curDrumPitch;
n = (num & ~0xff) | MusEGlobal::drumMap[curDrumPitch].anote; // construct real controller number
- //num = (num & ~0xff) | curDrumPitch); // construct real controller number
mp = &MusEGlobal::midiPorts[MusEGlobal::drumMap[curDrumPitch].port];
}
else if ((mt->type() == MusECore::Track::NEW_DRUM) && (curDrumPitch > 0) && ((num & 0xff) == 0xff)) //FINDMICHJETZT does this work?
@@ -619,9 +584,7 @@ void CtrlCanvas::updateItems()
continue;
MusECore::EventList* el = part->events();
- //MusECore::MidiController* mc;
MusECore::MidiCtrlValList* mcvl;
- //partControllers(part, _cnum, 0, 0, &mc, &mcvl);
partControllers(part, _cnum, 0, 0, 0, &mcvl);
unsigned len = part->lenTick();
@@ -634,7 +597,6 @@ void CtrlCanvas::updateItems()
if(_cnum == MusECore::CTRL_VELOCITY && e.type() == MusECore::Note)
{
- //printf("CtrlCanvas::updateItems MusECore::CTRL_VELOCITY curDrumPitch:%d\n", curDrumPitch);
newev = 0;
if (curDrumPitch == -1) // and NOT >0
{
@@ -823,7 +785,6 @@ void CtrlCanvas::viewMouseMoveEvent(QMouseEvent* event)
break;
case DRAG_NEW:
- ///newVal(start.x(), pos.x(), pos.y());
newVal(start.x(), start.y(), pos.x(), pos.y());
start = pos;
break;
@@ -857,11 +818,6 @@ void CtrlCanvas::viewMouseReleaseEvent(QMouseEvent* event)
bool ctrlKey = event->modifiers() & Qt::ControlModifier;
switch (drag) {
- ///case DRAG_RESIZE:
- ///case DRAG_NEW:
- ///case DRAG_DELETE:
- ///MusEGlobal::song->endUndo(SC_EVENT_MODIFIED | SC_EVENT_INSERTED);
- ///break;
case DRAG_RESIZE:
MusEGlobal::song->endUndo(SC_EVENT_MODIFIED);
break;
@@ -878,36 +834,22 @@ void CtrlCanvas::viewMouseReleaseEvent(QMouseEvent* event)
case DRAG_LASSO:
if(_controller) // p4.0.27
{
- ///if (!ctrlKey)
- /// deselectAll();
lasso = lasso.normalized();
int h = height();
- //bool do_redraw = false;
int tickstep = rmapxDev(1);
for (iCEvent i = items.begin(); i != items.end(); ++i) {
if((*i)->part() != curPart)
continue;
if ((*i)->intersects(_controller, lasso, tickstep, h)) {
if (ctrlKey && (*i)->selected())
- {
- //if (!ctrlKey) // ctrlKey p4.0.18
- {
- ///deselectItem(*i);
- //do_redraw = true;
- (*i)->setSelected(false);
- }
- }
+ (*i)->setSelected(false);
else
- {
- ///selectItem(*i);
- //do_redraw = true;
- (*i)->setSelected(true);
- }
+ (*i)->setSelected(true);
}
}
drag = DRAG_OFF;
// Let songChanged handle the redraw upon SC_SELECTION.
- MusEGlobal::song->update(SC_SELECTION); //
+ MusEGlobal::song->update(SC_SELECTION);
}
break;
@@ -1105,7 +1047,6 @@ void CtrlCanvas::changeVal(int x1, int x2, int y)
for (ciCEvent i = items.begin(); i != items.end(); ++i) {
if (!(*i)->contains(x1, x2))
- //if (!(*i)->contains(xx1, x2))
continue;
CEvent* ev = *i;
if(ev->part() != curPart)
@@ -1119,8 +1060,7 @@ void CtrlCanvas::changeVal(int x1, int x2, int y)
newEvent.setVelo(newval);
ev->setEvent(newEvent);
// Indicate no undo, and do not do port controller values and clone parts.
- MusEGlobal::audio->msgChangeEvent(event, newEvent, curPart, false, false, false);
- ///ev->setEvent(newEvent);
+ MusEGlobal::audio->msgChangeEvent(event, newEvent, curPart, false, false, false);
changed = true;
}
}
@@ -1145,8 +1085,7 @@ void CtrlCanvas::changeVal(int x1, int x2, int y)
newEvent.setB(nval);
ev->setEvent(newEvent);
// Indicate no undo, and do port controller values and clone parts.
- MusEGlobal::audio->msgChangeEvent(event, newEvent, curPart, false, true, true);
- ///ev->setEvent(newEvent);
+ MusEGlobal::audio->msgChangeEvent(event, newEvent, curPart, false, true, true);
changed = true;
}
}
@@ -1177,7 +1116,6 @@ void CtrlCanvas::newVal(int x1, int y)
bool found = false;
bool do_redraw = false;
- //bool do_selchanged = false;
iCEvent ice_tmp;
iCEvent prev_ev = items.end(); // End is OK with multi-part, this is just an end 'invalid' marker at first.
iCEvent insertPoint = items.end(); // Similar case here.
@@ -1188,7 +1126,6 @@ void CtrlCanvas::newVal(int x1, int y)
lastpv = ctrl->hwVal();
int partTick = curPart->tick();
- //for (ciCEvent i = items.begin(); i != items.end(); ++i) {
for (iCEvent i = items.begin(); i != items.end() ; )
{
CEvent* ev = *i;
@@ -1207,7 +1144,6 @@ void CtrlCanvas::newVal(int x1, int y)
}
curPartFound = true;
- //int partTick = ev->part()->tick();
MusECore::Event event = ev->event();
if (event.empty())
{
@@ -1216,7 +1152,6 @@ void CtrlCanvas::newVal(int x1, int y)
continue;
}
int ax = event.tick() + partTick;
- //printf("CtrlCanvas::newVal2 ax:%d xx1:%d xx2:%d len:%d\n", ax, xx1, xx2, curPart->lenTick());
if (ax < xx1)
{
@@ -1224,31 +1159,17 @@ void CtrlCanvas::newVal(int x1, int y)
++i;
continue;
}
- //if(ax <= xx1)
- //{
- // if(type == MusECore::CTRL_PROGRAM && event.dataB() != MusECore::CTRL_VAL_UNKNOWN && ((event.dataB() & 0xffffff) != 0xffffff))
- // lastpv = event.dataB();
- // if(ax < xx1)
- // continue;
- //}
if (ax >= xx2)
{
insertPoint = i;
break;
}
- // Do not add events which are past the end of the part.
- //if(event.tick() >= curPart->lenTick())
- // break;
-
int nval = newval;
if(type == MusECore::CTRL_PROGRAM)
{
if(event.dataB() == MusECore::CTRL_VAL_UNKNOWN)
{
- //if(lastpv == MusECore::CTRL_VAL_UNKNOWN)
- // lastpv = ctrl->hwVal();
-
if(lastpv == MusECore::CTRL_VAL_UNKNOWN)
{
--nval;
@@ -1271,14 +1192,11 @@ void CtrlCanvas::newVal(int x1, int y)
{
MusECore::Event newEvent = event.clone();
newEvent.setB(nval);
- //printf("CtrlCanvas::newVal2 change xx1:%d xx2:%d len:%d\n", xx1, xx2, curPart->lenTick());
ev->setEvent(newEvent);
// Indicate no undo, and do port controller values and clone parts.
- MusEGlobal::audio->msgChangeEvent(event, newEvent, curPart, false, true, true);
-
- ///ev->setEvent(newEvent);
+ MusEGlobal::audio->msgChangeEvent(event, newEvent, curPart, false, true, true);
do_redraw = true;
}
@@ -1289,11 +1207,9 @@ void CtrlCanvas::newVal(int x1, int y)
{
// delete event
- //printf("CtrlCanvas::newVal2 delete xx1:%d xx2:%d len:%d\n", xx1, xx2, curPart->lenTick());
-
deselectItem(ev);
// Indicate no undo, and do port controller values and clone parts.
- MusEGlobal::audio->msgDeleteEvent(event, curPart, false, true, true);
+ MusEGlobal::audio->msgDeleteEvent(event, curPart, false, true, true);
delete (ev);
i = items.erase(i);
@@ -1308,7 +1224,6 @@ void CtrlCanvas::newVal(int x1, int y)
}
do_redraw = true; // Let songChanged handle the redraw upon SC_SELECTION.
- //do_selchanged = true; //
prev_ev = i;
}
@@ -1339,10 +1254,8 @@ void CtrlCanvas::newVal(int x1, int y)
else
event.setB(newval);
- //printf("CtrlCanvas::newVal2 add tick:%d A:%d B:%d\n", tick, event.dataA(), event.dataB());
-
// Indicate no undo, and do port controller values and clone parts.
- MusEGlobal::audio->msgAddEvent(event, curPart, false, true, true);
+ MusEGlobal::audio->msgAddEvent(event, curPart, false, true, true);
CEvent* newev = new CEvent(event, curPart, event.dataB());
insertPoint = items.insert(insertPoint, newev);
@@ -1448,7 +1361,6 @@ void CtrlCanvas::newVal(int x1, int y1, int x2, int y2)
continue;
}
int x = event.tick() + partTick;
- //printf("CtrlCanvas::newVal x:%d xx1:%d xx2:%d len:%d\n", x, xx1, xx2, curPart->lenTick());
if (x < xx1)
{
@@ -1456,13 +1368,6 @@ void CtrlCanvas::newVal(int x1, int y1, int x2, int y2)
++i;
continue;
}
- //if (x <= xx1)
- //{
- // if(type == MusECore::CTRL_PROGRAM && event.dataB() != MusECore::CTRL_VAL_UNKNOWN && ((event.dataB() & 0xffffff) != 0xffffff))
- // lastpv = event.dataB();
- // if (x < xx1)
- // continue;
- //}
if (x >= xx2)
{
insertPoint = i;
@@ -1471,7 +1376,7 @@ void CtrlCanvas::newVal(int x1, int y1, int x2, int y2)
deselectItem(ev);
// Indicate no undo, and do port controller values and clone parts.
- MusEGlobal::audio->msgDeleteEvent(event, curPart, false, true, true);
+ MusEGlobal::audio->msgDeleteEvent(event, curPart, false, true, true);
delete (ev);
i = items.erase(i);
@@ -1524,7 +1429,7 @@ void CtrlCanvas::newVal(int x1, int y1, int x2, int y2)
event.setB(nval);
// Indicate no undo, and do port controller values and clone parts.
- MusEGlobal::audio->msgAddEvent(event, curPart, false, true, true);
+ MusEGlobal::audio->msgAddEvent(event, curPart, false, true, true);
CEvent* newev = new CEvent(event, curPart, event.dataB());
insertPoint = items.insert(insertPoint, newev);
@@ -1612,7 +1517,7 @@ void CtrlCanvas::deleteVal(int x1, int x2, int)
deselectItem(ev);
// Indicate no undo, and do port controller values and clone parts.
- MusEGlobal::audio->msgDeleteEvent(event, curPart, false, true, true);
+ MusEGlobal::audio->msgDeleteEvent(event, curPart, false, true, true);
delete (ev);
i = items.erase(i);
@@ -1675,7 +1580,6 @@ void CtrlCanvas::pdrawItems(QPainter& p, const QRect& rect, const MusECore::Midi
{
CEvent* e = *i;
// Draw selected part velocity events on top of unselected part events.
- //if((fg && e->part() != part) || (!fg && e->part() == part))
if(e->part() != part)
continue;
MusECore::Event event = e->event();
@@ -1689,7 +1593,6 @@ void CtrlCanvas::pdrawItems(QPainter& p, const QRect& rect, const MusECore::Midi
if(fg)
{
if(e->selected())
- //if(!event.empty() && event.selected())
p.setPen(QPen(Qt::blue, 3));
else
p.setPen(QPen(MusEGlobal::config.ctrlGraphFg, 3));
@@ -1731,14 +1634,12 @@ void CtrlCanvas::pdrawItems(QPainter& p, const QRect& rect, const MusECore::Midi
}
int x1 = rect.x();
int lval = MusECore::CTRL_VAL_UNKNOWN;
- ///noEvents=false;
bool selected = false;
for (iCEvent i = items.begin(); i != items.end(); ++i)
{
noEvents=false;
CEvent* e = *i;
// Draw unselected part controller events (lines) on top of selected part events (bars).
- //if((fg && (e->part() == part)) || (!fg && (e->part() != part)))
if(e->part() != part)
{
continue;
@@ -1799,13 +1700,11 @@ void CtrlCanvas::pdrawItems(QPainter& p, const QRect& rect, const MusECore::Midi
lval = wh - ((val - min - bias) * wh / (max - min));
}
selected = e->selected();
- //selected = !ev.empty() && ev.selected();
}
if (lval == MusECore::CTRL_VAL_UNKNOWN)
{
if(!fg) {
p.fillRect(x1, 0, (x+w) - x1, wh, Qt::darkGray);
- ///noEvents=true;
}
}
else
@@ -1816,7 +1715,6 @@ void CtrlCanvas::pdrawItems(QPainter& p, const QRect& rect, const MusECore::Midi
p.drawLine(x1, lval, x + w, lval);
}
else
- //p.fillRect(x1, lval, (x+w) - x1, wh - lval, MusEGlobal::config.ctrlGraphFg);
p.fillRect(x1, lval, (x+w) - x1, wh - lval, selected ? Qt::blue : MusEGlobal::config.ctrlGraphFg);
}
}
@@ -1873,7 +1771,6 @@ void CtrlCanvas::pdraw(QPainter& p, const QRect& rect)
for(MusECore::iPart ip = editor->parts()->begin(); ip != editor->parts()->end(); ++ip)
{
MusECore::MidiPart* part = (MusECore::MidiPart*)(ip->second);
- //if((velo && part == curPart) || (!velo && part != curPart))
if(part == curPart || (filterTrack && part->track() != curTrack))
continue;
// Draw items for all parts - other than current part
@@ -1944,12 +1841,8 @@ void CtrlCanvas::drawOverlay(QPainter& p)
{
p.drawText(2 , y * 2, tr("Make the current part's track match the selected drumlist entry"));
}
- else if (noEvents) {
- //p.setFont(MusEGlobal::config.fonts[3]);
- //p.setPen(Qt::black);
- //p.drawText(width()/2-100,height()/2-10, "Use shift + pencil or line tool to draw new events");
+ else if (noEvents)
p.drawText(2 , y * 2, tr("Drawing hint: Hold Ctrl to affect only existing events"));
- }
}
//---------------------------------------------------------
@@ -1963,7 +1856,6 @@ QRect CtrlCanvas::overlayRect() const
QFontMetrics fm(fontMetrics());
QRect r(fm.boundingRect(_controller ? _controller->name() : QString("")));
- //r.translate(2, 2); // top/left margin
int y = fm.lineSpacing() + 2;
r.translate(2, y);
if (curDrumPitch==-2)
@@ -1980,8 +1872,6 @@ QRect CtrlCanvas::overlayRect() const
r2.translate(2, y * 2);
r |= r2;
}
-
- //printf("CtrlCanvas::overlayRect x:%d y:%d w:%d h:%d\n", r.x(), r.y(), r.width(), r.height());
return r;
}
@@ -1992,7 +1882,6 @@ QRect CtrlCanvas::overlayRect() const
void CtrlCanvas::draw(QPainter& p, const QRect& rect)
{
drawTickRaster(p, rect.x(), rect.y(),
- //rect.width(), rect.height(), editor->quant());
rect.width(), rect.height(), editor->raster());
//---------------------------------------------------
@@ -2021,8 +1910,8 @@ void CtrlCanvas::setCurDrumPitch(int instrument)
else
curDrumPitch = -2; // this means "invalid", but not "unused"
}
-
-
+
+ // DELETETHIS
//printf("CtrlCanvas::setCurDrumPitch curDrumPitch:%d\n", curDrumPitch);
//
diff --git a/muse2/muse/ctrl/ctrlcanvas.h b/muse2/muse/ctrl/ctrlcanvas.h
index 50b71bbe..8e107789 100644
--- a/muse2/muse/ctrl/ctrlcanvas.h
+++ b/muse2/muse/ctrl/ctrlcanvas.h
@@ -53,12 +53,8 @@ class MidiEditor;
//---------------------------------------------------------
class CEvent {
- public:
- //enum State { Normal, Selected };
-
private:
MusECore::Event _event;
- //State _state;
int _val;
MusECore::MidiPart* _part;
int ex;
@@ -67,17 +63,14 @@ class CEvent {
CEvent(MusECore::Event e, MusECore::MidiPart* part, int v);
MusECore::Event event() const { return _event; }
void setEvent(MusECore::Event& ev) { _event = ev; }
- //State state() { return _state; }
- //void setState(State s) { _state = s; }
- //bool isSelected() { return _state == Selected; }
bool selected() const { return !_event.empty() && _event.selected(); }
void setSelected(bool v) { if(!_event.empty()) _event.setSelected(v); }
int val() const { return _val; }
void setVal(int v) { _val = v; }
void setEX(int v) { ex = v; }
MusECore::MidiPart* part() const { return _part; }
- bool contains(int /*x1*/, int /*x2*/) const;
- bool intersects(const MusECore::MidiController*, const QRect&, const int /*tickstep*/, const int /*windowHeight*/) const;
+ bool contains(int x1, int x2) const;
+ bool intersects(const MusECore::MidiController*, const QRect&, const int tickstep, const int windowHeight) const;
int x() { return ex; }
};
@@ -111,10 +104,8 @@ class CtrlCanvas : public MusEGui::View {
MusECore::MidiController* _controller;
CtrlPanel* _panel;
int _cnum;
- // Current real drum controller number (anote).
- int _dnum;
- // Current real drum controller index.
- int _didx;
+ int _dnum; // Current real drum controller number (anote).
+ int _didx; // Current real drum controller index.
int line1x;
int line1y;
int line2x;
@@ -135,7 +126,6 @@ class CtrlCanvas : public MusEGui::View {
void changeValRamp(int x1, int x2, int y1, int y2);
void newValRamp(int x1, int y1, int x2, int y2);
void changeVal(int x1, int x2, int y);
- //void newVal(int x1, int x2, int y);
void newVal(int x1, int y);
void newVal(int x1, int y1, int x2, int y2);
void deleteVal(int x1, int x2, int y);
@@ -176,8 +166,6 @@ class CtrlCanvas : public MusEGui::View {
void setMidiController(int);
void updateItems();
void updateSelections();
-
- //virtual void closeEvent(QCloseEvent*);
private slots:
void songChanged(int type);
diff --git a/muse2/muse/ctrl/ctrledit.cpp b/muse2/muse/ctrl/ctrledit.cpp
index 5fbdecaf..ec814f3e 100644
--- a/muse2/muse/ctrl/ctrledit.cpp
+++ b/muse2/muse/ctrl/ctrledit.cpp
@@ -88,7 +88,6 @@ void CtrlEdit::writeStatus(int level, MusECore::Xml& xml)
{
if (canvas->controller()) {
xml.tag(level++, "ctrledit");
- //xml.strTag(level, "ctrl", canvas->controller()->name());
xml.intTag(level, "ctrlnum", canvas->controller()->num());
xml.tag(level, "/ctrledit");
}
@@ -108,23 +107,8 @@ void CtrlEdit::readStatus(MusECore::Xml& xml)
case MusECore::Xml::End:
return;
case MusECore::Xml::TagStart:
- if (tag == "ctrl") {
- xml.parse1(); // Obsolete.
- /*
- QString name = xml.parse1();
- int portno = canvas->track()->outPort();
- MusECore::MidiPort* port = &midiPorts[portno];
- MusECore::MidiInstrument* instr = port->instrument();
- MusECore::MidiControllerList* mcl = instr->controller();
-
- for (MusECore::iMidiController ci = mcl->begin(); ci != mcl->end(); ++ci) {
- if (ci->second->name() == name) {
- canvas->setController(ci->second->num());
- break;
- }
- }
- */
- }
+ if (tag == "ctrl")
+ xml.parse1(); // Obsolete.
else if (tag == "ctrlnum") {
int num = xml.parseInt();
canvas->setController(num);
diff --git a/muse2/muse/ctrl/ctrledit.h b/muse2/muse/ctrl/ctrledit.h
index a0a941cc..0e3a280b 100644
--- a/muse2/muse/ctrl/ctrledit.h
+++ b/muse2/muse/ctrl/ctrledit.h
@@ -59,7 +59,7 @@ class CtrlEdit : public QWidget {
void setXPos(int val) { canvas->setXPos(val); }
void setXMag(int val) { canvas->setXMag(val); }
void setCanvasWidth(int w);
- void setController(int /*n*/);
+ void setController(int n);
void curPartHasChanged(MusECore::Part*);
signals:
diff --git a/muse2/muse/ctrl/ctrlpanel.cpp b/muse2/muse/ctrl/ctrlpanel.cpp
index 2de234b8..938ebd5a 100644
--- a/muse2/muse/ctrl/ctrlpanel.cpp
+++ b/muse2/muse/ctrl/ctrlpanel.cpp
@@ -26,7 +26,6 @@
#include "ctrlpanel.h"
#include "ctrlcanvas.h"
-//#include <QMenu>
#include <QAction>
#include <QPushButton>
#include <QSizePolicy>
@@ -69,8 +68,6 @@ CtrlPanel::CtrlPanel(QWidget* parent, MidiEditor* e, CtrlCanvas* c, const char*
{
setObjectName(name);
inHeartBeat = true;
- //ctrlMainPop = 0;
- //ctrlSubPop = 0;
editor = e;
ctrlcanvas = c;
setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
@@ -90,16 +87,16 @@ CtrlPanel::CtrlPanel(QWidget* parent, MidiEditor* e, CtrlCanvas* c, const char*
dbox->setContentsMargins(0, 0, 0, 0);
selCtrl = new QPushButton(tr("S"));
+ selCtrl->setFocusPolicy(Qt::NoFocus);
selCtrl->setFont(MusEGlobal::config.fonts[3]);
selCtrl->setFixedHeight(20);
selCtrl->setSizePolicy(
QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed));
selCtrl->setToolTip(tr("select controller"));
- ///pop = new QMenu;
-
// destroy button
QPushButton* destroy = new QPushButton(tr("X"));
+ destroy->setFocusPolicy(Qt::NoFocus);
destroy->setFont(MusEGlobal::config.fonts[3]);
destroy->setFixedHeight(20);
destroy->setSizePolicy(
@@ -138,7 +135,6 @@ CtrlPanel::CtrlPanel(QWidget* parent, MidiEditor* e, CtrlCanvas* c, const char*
connect(_knob, SIGNAL(sliderMoved(double,int)), SLOT(ctrlChanged(double)));
connect(_knob, SIGNAL(sliderRightClicked(const QPoint&, int)), SLOT(ctrlRightClicked(const QPoint&, int)));
- //connect(_knob, SIGNAL(sliderReleased(int)), SLOT(ctrlReleased(int)));
connect(_dl, SIGNAL(valueChanged(double,int)), SLOT(ctrlChanged(double)));
connect(_dl, SIGNAL(doubleClicked(int)), SLOT(labelDoubleClicked()));
@@ -169,7 +165,6 @@ void CtrlPanel::heartBeat()
if(_track && _ctrl && _dnum != -1)
{
- //if(_dnum != MusECore::CTRL_VELOCITY && _dnum != MusECore::CTRL_PROGRAM)
if(_dnum != MusECore::CTRL_VELOCITY)
{
int outport;
@@ -201,7 +196,7 @@ void CtrlPanel::heartBeat()
else
// Auto bias...
v -= _ctrl->bias();
- if(double(v) != _knob->value())
+ if (double(v) != _knob->value())
{
// Added by Tim. p3.3.6
//printf("CtrlPanel::heartBeat setting knob\n");
@@ -210,14 +205,11 @@ void CtrlPanel::heartBeat()
}
}
}
- else
- if(v != _val)
+ else if(v != _val)
{
_val = v;
if(v == MusECore::CTRL_VAL_UNKNOWN || ((_dnum == MusECore::CTRL_PROGRAM) && ((v & 0xff) == 0xff) ))
{
- // MusEGui::DoubleLabel ignores the value if already set...
- //_dl->setValue(double(_ctrl->minVal() - 1));
_dl->setValue(_dl->off() - 1.0);
}
else
@@ -228,9 +220,6 @@ void CtrlPanel::heartBeat()
// Auto bias...
v -= _ctrl->bias();
- // Added by Tim. p3.3.6
- //printf("CtrlPanel::heartBeat setting knob and label\n");
-
_knob->setValue(double(v));
_dl->setValue(double(v));
}
@@ -276,25 +265,22 @@ void CtrlPanel::labelDoubleClicked()
// (or the controller's initial value?) to 'turn on' the controller.
if(lastv == MusECore::CTRL_VAL_UNKNOWN || ((lastv & 0xffffff) == 0xffffff))
{
- //int kiv = _ctrl->initVal());
int kiv = lrint(_knob->value());
--kiv;
kiv &= 0x7f;
kiv |= 0xffff00;
- //MusECore::MidiPlayEvent ev(MusEGlobal::song->cpos(), outport, chan, MusECore::ME_CONTROLLER, _dnum, kiv);
MusECore::MidiPlayEvent ev(0, outport, chan, MusECore::ME_CONTROLLER, _dnum, kiv);
MusEGlobal::audio->msgPlayMidiEvent(&ev);
}
else
{
- //MusECore::MidiPlayEvent ev(MusEGlobal::song->cpos(), outport, chan, MusECore::ME_CONTROLLER, _dnum, lastv);
MusECore::MidiPlayEvent ev(0, outport, chan, MusECore::ME_CONTROLLER, _dnum, lastv);
MusEGlobal::audio->msgPlayMidiEvent(&ev);
}
}
else
{
- //if((curv & 0xffff00) == 0xffff00)
+ //if((curv & 0xffff00) == 0xffff00) DELETETHIS?
//{
////if(mp->hwCtrlState(chan, _dnum) != MusECore::CTRL_VAL_UNKNOWN)
MusEGlobal::audio->msgSetHwCtrlState(mp, chan, _dnum, MusECore::CTRL_VAL_UNKNOWN);
@@ -314,28 +300,24 @@ void CtrlPanel::labelDoubleClicked()
// (or the controller's initial value?) to 'turn on' the controller.
if(lastv == MusECore::CTRL_VAL_UNKNOWN)
{
- //int kiv = _ctrl->initVal());
int kiv = lrint(_knob->value());
if(kiv < _ctrl->minVal())
kiv = _ctrl->minVal();
if(kiv > _ctrl->maxVal())
kiv = _ctrl->maxVal();
kiv += _ctrl->bias();
- //MusECore::MidiPlayEvent ev(MusEGlobal::song->cpos(), outport, chan, MusECore::ME_CONTROLLER, _dnum, kiv);
MusECore::MidiPlayEvent ev(0, outport, chan, MusECore::ME_CONTROLLER, _dnum, kiv);
MusEGlobal::audio->msgPlayMidiEvent(&ev);
}
else
{
- //MusECore::MidiPlayEvent ev(MusEGlobal::song->cpos(), outport, chan, MusECore::ME_CONTROLLER, _dnum, lastv);
MusECore::MidiPlayEvent ev(0, outport, chan, MusECore::ME_CONTROLLER, _dnum, lastv);
MusEGlobal::audio->msgPlayMidiEvent(&ev);
}
}
else
{
- //if(mp->hwCtrlState(chan, _dnum) != MusECore::CTRL_VAL_UNKNOWN)
- MusEGlobal::audio->msgSetHwCtrlState(mp, chan, _dnum, MusECore::CTRL_VAL_UNKNOWN);
+ MusEGlobal::audio->msgSetHwCtrlState(mp, chan, _dnum, MusECore::CTRL_VAL_UNKNOWN);
}
}
MusEGlobal::song->update(SC_MIDI_CONTROLLER);
@@ -379,7 +361,6 @@ void CtrlPanel::ctrlChanged(double val)
ival |= 0xffff00;
else
ival |= (curval & 0xffff00);
- //MusECore::MidiPlayEvent ev(MusEGlobal::song->cpos(), outport, chan, MusECore::ME_CONTROLLER, _dnum, ival);
MusECore::MidiPlayEvent ev(0, outport, chan, MusECore::ME_CONTROLLER, _dnum, ival);
MusEGlobal::audio->msgPlayMidiEvent(&ev);
}
@@ -387,7 +368,6 @@ void CtrlPanel::ctrlChanged(double val)
// Shouldn't happen, but...
if((ival < _ctrl->minVal()) || (ival > _ctrl->maxVal()))
{
- //if(mp->hwCtrlState(chan, _dnum) != MusECore::CTRL_VAL_UNKNOWN)
if(curval != MusECore::CTRL_VAL_UNKNOWN)
MusEGlobal::audio->msgSetHwCtrlState(mp, chan, _dnum, MusECore::CTRL_VAL_UNKNOWN);
}
@@ -396,7 +376,6 @@ void CtrlPanel::ctrlChanged(double val)
// Auto bias...
ival += _ctrl->bias();
- //MusECore::MidiPlayEvent ev(MusEGlobal::song->cpos(), outport, chan, MusECore::ME_CONTROLLER, _dnum, ival);
MusECore::MidiPlayEvent ev(0, outport, chan, MusECore::ME_CONTROLLER, _dnum, ival);
MusEGlobal::audio->msgPlayMidiEvent(&ev);
}
@@ -445,7 +424,6 @@ void CtrlPanel::setHWController(MusECore::MidiTrack* t, MusECore::MidiController
ch = _track->outChannel();
}
- //if(_dnum == MusECore::CTRL_VELOCITY || _dnum == MusECore::CTRL_PROGRAM)
if(_dnum == MusECore::CTRL_VELOCITY)
{
_knob->setEnabled(false);
@@ -467,7 +445,6 @@ void CtrlPanel::setHWController(MusECore::MidiTrack* t, MusECore::MidiController
_val = v;
_knob->setRange(double(mn), double(mx), 1.0);
_dl->setRange(double(mn), double(mx));
- //_dl->setOff(double(mn - 1));
if(v == MusECore::CTRL_VAL_UNKNOWN || ((v & 0xffffff) == 0xffffff))
{
int lastv = mp->lastValidHWCtrlState(ch, _dnum);
@@ -484,7 +461,6 @@ void CtrlPanel::setHWController(MusECore::MidiTrack* t, MusECore::MidiController
if(v > 128)
v = 128;
- //dlv = mn - 1;
dlv = _dl->off() - 1.0;
}
else
@@ -503,7 +479,6 @@ void CtrlPanel::setHWController(MusECore::MidiTrack* t, MusECore::MidiController
_val = v;
_knob->setRange(double(mn), double(mx), 1.0);
_dl->setRange(double(mn), double(mx));
- //_dl->setOff(double(mn - 1));
if(v == MusECore::CTRL_VAL_UNKNOWN)
{
int lastv = mp->lastValidHWCtrlState(ch, _dnum);
@@ -516,7 +491,6 @@ void CtrlPanel::setHWController(MusECore::MidiTrack* t, MusECore::MidiController
}
else
v = lastv - _ctrl->bias();
- //dlv = mn - 1;
dlv = _dl->off() - 1.0;
}
else
@@ -548,7 +522,12 @@ void CtrlPanel::setHeight(int h)
setFixedHeight(h);
}
-#if 0
+#if 0 // DELETETHIS. yeah, really!
+// when flo added the new style drumtracks in trunk, he changed a
+// lot of things. he didn't update that disabled area here, so
+// after releasing 2.0, when we continue developing on trunk,
+// then the below code is not only disabled but INVALID (as in WRONG)
+
/* WARNING: INVALID CODE! *\
* the code which has been disabled by the above #if 0 is partly *
* OBSOLETE! it lacks support for new-style drum tracks, especially *
@@ -1013,34 +992,18 @@ void CtrlPanel::ctrlPopup()
void CtrlPanel::ctrlRightClicked(const QPoint& p, int /*id*/)
{
- //if(!_knob->selectedFaceColor())
- // _knob->selectFaceColor(true);
- //if(_dnum == -1)
- // return;
if(!editor->curCanvasPart() || !_ctrl)
return;
int cdp = ctrlcanvas->getCurDrumPitch();
int ctlnum = _ctrl->num();
if(_track->type() == MusECore::Track::DRUM && ((ctlnum & 0xff) == 0xff) && cdp != -1)
- //ctlnum = (ctlnum & ~0xff) | MusEGlobal::drumMap[cdp].enote;
+ //ctlnum = (ctlnum & ~0xff) | MusEGlobal::drumMap[cdp].enote; DELETETHIS or which of them is correct?
ctlnum = (ctlnum & ~0xff) | cdp;
MusECore::MidiPart* part = dynamic_cast<MusECore::MidiPart*>(editor->curCanvasPart());
MusEGlobal::song->execMidiAutomationCtlPopup(0, part, p, ctlnum);
}
-/*
-//---------------------------------------------------------
-// ctrlReleased
-//---------------------------------------------------------
-
-void CtrlPanel::ctrlReleased(int id)
-{
- //if(_knob->selectedFaceColor())
- // _knob->selectFaceColor(false);
-}
-*/
-
} // namespace MusEGui
diff --git a/muse2/muse/ctrl/ctrlpanel.h b/muse2/muse/ctrl/ctrlpanel.h
index ab6c1777..1a5245dc 100644
--- a/muse2/muse/ctrl/ctrlpanel.h
+++ b/muse2/muse/ctrl/ctrlpanel.h
@@ -46,7 +46,6 @@ class CtrlCanvas;
class CtrlPanel: public QWidget {
Q_OBJECT
- //QMenu* pop;
QPushButton* selCtrl;
MidiEditor* editor;
CtrlCanvas* ctrlcanvas;
@@ -69,7 +68,6 @@ class CtrlPanel: public QWidget {
void ctrlChanged(double val);
void labelDoubleClicked();
void ctrlRightClicked(const QPoint& p, int id);
- //void ctrlReleased(int id);
protected slots:
virtual void heartBeat();
diff --git a/muse2/muse/driver/alsamidi.cpp b/muse2/muse/driver/alsamidi.cpp
index 740de1fb..08f5345f 100644
--- a/muse2/muse/driver/alsamidi.cpp
+++ b/muse2/muse/driver/alsamidi.cpp
@@ -38,6 +38,7 @@
#include "xml.h"
#include "part.h"
#include "gconfig.h"
+#include "track.h"
#include <QApplication>
@@ -58,8 +59,6 @@ MidiAlsaDevice::MidiAlsaDevice(const snd_seq_addr_t& a, const QString& n)
: MidiDevice(n)
{
adr = a;
- stopPending = false;
- seekPending = false;
init();
}
@@ -285,7 +284,7 @@ void MidiAlsaDevice::writeRouting(int level, Xml& xml) const
bool MidiAlsaDevice::putMidiEvent(const MidiPlayEvent& e)
{
if (MusEGlobal::midiOutputTrace) {
- printf("MidiOut: midiAlsa: ");
+ printf("MidiOut: Alsa: <%s>: ", name().toLatin1().constData());
e.dump();
}
int chn = e.channel();
@@ -309,6 +308,19 @@ bool MidiAlsaDevice::putMidiEvent(const MidiPlayEvent& e)
snd_seq_ev_set_pgmchange(&event, chn, a);
break;
case ME_CONTROLLER:
+ {
+ if(a == CTRL_PROGRAM)
+ {
+ snd_seq_ev_set_pgmchange(&event, chn, b);
+ break;
+ }
+ else if(a == CTRL_PITCH)
+ {
+ snd_seq_ev_set_pitchbend(&event, chn, b);
+ break;
+ }
+ }
+
#if 1
snd_seq_ev_set_controller(&event, chn, a, b);
#else
@@ -453,77 +465,160 @@ bool MidiAlsaDevice::putEvent(snd_seq_event_t* event)
// Called from ALSA midi sequencer thread only.
//---------------------------------------------------------
-#if 0
-void MidiAlsaDevice::processMidi()
-{
- processStuckNotes();
- if (_playEvents.empty())
- return;
- int port = midiPort();
- MidiPort* mp = port != -1 ? &MusEGlobal::midiPorts[port] : 0;
- unsigned curFrame = MusEGlobal::audio->curFrame();
- int tickpos = MusEGlobal::audio->tickPos();
- bool extsync = MusEGlobal::extSyncFlag.value();
- //int frameOffset = getFrameOffset();
- //int nextTick = MusEGlobal::audio->nextTick();
-
- // Play all events up to current frame.
- iMPEvent i = _playEvents.begin();
- for (; i != _playEvents.end(); ++i) {
- if (i->time() > (extsync ? tickpos : curFrame)) // p3.3.25 Check: Should be nextTickPos? p4.0.34
- break;
- if(mp){
- if (mp->sendEvent(*i))
- break;
- }
- else
- if(putMidiEvent(*i))
- break;
- }
- _playEvents.erase(_playEvents.begin(), i);
-}
-
-#else
void MidiAlsaDevice::processMidi()
{
- bool stop = stopPending; // Snapshots
- bool seek = seekPending; //
- seekPending = stopPending = false;
+ //bool stop = stopPending; // Snapshots
+ //bool seek = seekPending; //
+ //seekPending = stopPending = false;
// Transfer the stuck notes FIFO to the play events list.
// FIXME It would be faster to have MidiAlsaDevice automatically add the stuck note so that only
// one FIFO would be needed. But that requires passing an extra 'tick' and 'off velocity' in
// addScheduledEvent, which felt too weird.
- while(!stuckNotesFifo.isEmpty())
- _stuckNotes.add(stuckNotesFifo.get());
+ //while(!stuckNotesFifo.isEmpty())
+ // _stuckNotes.add(stuckNotesFifo.get());
- bool extsync = MusEGlobal::extSyncFlag.value();
//int frameOffset = getFrameOffset();
//int nextTick = MusEGlobal::audio->nextTick();
- // We're in the ALSA midi thread. MusEGlobal::audio->isPlaying() might not be true during seek right now.
- //if(stop || (seek && MusEGlobal::audio->isPlaying()))
- if(stop || seek)
+ //bool is_playing = MusEGlobal::audio->isPlaying();
+ // We're in the ALSA midi thread. audio->isPlaying() might not be true during seek right now. Include START_PLAY state...
+ //bool is_playing = MusEGlobal::audio->isPlaying() || MusEGlobal::audio->isStarting(); // TODO Check this. It includes LOOP1 and LOOP2 besides PLAY.
+ int pos = MusEGlobal::audio->tickPos();
+ int port = midiPort();
+ MidiPort* mp = port == -1 ? 0 : &MusEGlobal::midiPorts[port];
+ bool ext_sync = MusEGlobal::extSyncFlag.value();
+
+ /*
+ if(mp)
{
- //---------------------------------------------------
- // Clear all notes and handle stuck notes
- //---------------------------------------------------
- playEventFifo.clear();
+ MidiSyncInfo& si = mp->syncInfo();
+ if(stop)
+ {
+ // Don't send if external sync is on. The master, and our sync routing system will take care of that.
+ if(!ext_sync)
+ {
+ // Shall we check open flags?
+ //if(!(dev->rwFlags() & 0x1) || !(dev->openFlags() & 1))
+ //if(!(dev->openFlags() & 1))
+ // return;
+
+ // Send MMC stop...
+ if(si.MMCOut())
+ {
+ unsigned char msg[mmcStopMsgLen];
+ memcpy(msg, mmcStopMsg, mmcStopMsgLen);
+ msg[1] = si.idOut();
+ putMidiEvent(MidiPlayEvent(0, 0, ME_SYSEX, msg, mmcStopMsgLen));
+ }
+
+ // Send midi stop...
+ if(si.MRTOut())
+ {
+ putMidiEvent(MidiPlayEvent(0, 0, 0, ME_STOP, 0, 0));
+ // Added check of option send continue not start. p3.3.31
+ // Hmm, is this required? Seems to make other devices unhappy.
+ // (Could try now that this is in MidiDevice. p4.0.22 )
+ //if(!si.sendContNotStart())
+ // mp->sendSongpos(MusEGlobal::audio->tickPos() * 4 / config.division);
+ }
+ }
+ }
+
+ if(seek)
+ {
+ // Don't send if external sync is on. The master, and our sync routing system will take care of that.
+ if(!ext_sync)
+ {
+ // Send midi stop and song position pointer...
+ if(si.MRTOut())
+ {
+ // Shall we check for device write open flag to see if it's ok to send?...
+ //if(!(rwFlags() & 0x1) || !(openFlags() & 1))
+ //if(!(openFlags() & 1))
+ // continue;
+ putMidiEvent(MidiPlayEvent(0, 0, 0, ME_STOP, 0, 0));
+ // Hm, try sending these after stuck notes below...
+ //putMidiEvent(MidiPlayEvent(0, 0, 0, ME_SONGPOS, beat, 0));
+ //if(is_playing)
+ // putMidiEvent(MidiPlayEvent(0, 0, 0, ME_CONTINUE, 0, 0));
+ }
+ }
+ }
+ }
+ */
+
+ /*
+ if(stop || (seek && is_playing))
+ {
+ // Clear all notes and handle stuck notes...
+ //playEventFifo.clear();
_playEvents.clear();
- //printf("transferring stuck notes\n");
for(iMPEvent i = _stuckNotes.begin(); i != _stuckNotes.end(); ++i)
{
- //printf(" stuck note\n");
MidiPlayEvent ev = *i;
ev.setTime(0);
- _playEvents.add(ev);
+ //_playEvents.add(ev);
+ putMidiEvent(ev); // Play immediately.
}
_stuckNotes.clear();
}
- else
+ */
+
+ /*
+ if(mp)
+ {
+ MidiSyncInfo& si = mp->syncInfo();
+ // Try sending these now after stuck notes above...
+ if(stop || seek)
+ {
+ // Reset sustain.
+ for(int ch = 0; ch < MIDI_CHANNELS; ++ch)
+ if(mp->hwCtrlState(ch, CTRL_SUSTAIN) == 127)
+ putMidiEvent(MidiPlayEvent(0, _port, ch, ME_CONTROLLER, CTRL_SUSTAIN, 0));
+ }
+ if(seek)
+ {
+ // Send new song position.
+ if(!ext_sync && si.MRTOut())
+ {
+ int beat = (pos * 4) / MusEGlobal::config.division;
+ putMidiEvent(MidiPlayEvent(0, 0, 0, ME_SONGPOS, beat, 0));
+ }
+ // Send new controller values.
+ MidiCtrlValListList* cll = mp->controller();
+ for(iMidiCtrlValList ivl = cll->begin(); ivl != cll->end(); ++ivl)
+ {
+ MidiCtrlValList* vl = ivl->second;
+ iMidiCtrlVal imcv = vl->iValue(pos);
+ if(imcv != vl->end()) {
+ Part* p = imcv->second.part;
+ // Don't send if part or track is muted or off.
+ if(!p || p->mute())
+ continue;
+ Track* track = p->track();
+ if(track && (track->isMute() || track->off()))
+ continue;
+ unsigned t = (unsigned)imcv->first;
+ // Do not add values that are outside of the part.
+ if(t >= p->tick() && t < (p->tick() + p->lenTick()))
+ // Use sendEvent to get the optimizations and limiting. But force if there's a value at this exact position.
+ mp->sendEvent(MidiPlayEvent(0, _port, ivl->first >> 24, ME_CONTROLLER, vl->num(), imcv->second.val), imcv->first == pos);
+ }
+ }
+
+ // Send continue.
+ // REMOVE Tim. This is redundant and too early - Audio::startRolling already properly sends it when sync ready.
+ //if(is_playing && !ext_sync && si.MRTOut())
+ // putMidiEvent(MidiPlayEvent(0, 0, 0, ME_CONTINUE, 0, 0));
+ }
+ }
+ */
+
+ //if(!(stop || (seek && is_playing)))
{
// Transfer the play events FIFO to the play events list.
- while(!playEventFifo.isEmpty())
- _playEvents.add(playEventFifo.get());
+ //while(!playEventFifo.isEmpty())
+ // _playEvents.add(playEventFifo.get());
/* TODO Handle these more directly than putting them into play events list.
//if(MusEGlobal::audio->isPlaying())
@@ -545,53 +640,18 @@ void MidiAlsaDevice::processMidi()
processStuckNotes();
}
- /* Instead, done immediately in handleStop and handleSeek using putEvent.
- if(stop)
- {
- // reset sustain...
- MidiPort* mp = &MusEGlobal::midiPorts[_port];
- for(int ch = 0; ch < MIDI_CHANNELS; ++ch)
- {
- if(mp->hwCtrlState(ch, CTRL_SUSTAIN) == 127)
- {
- //printf("send clear sustain!!!!!!!! port %d ch %d\n", i,ch);
- MidiPlayEvent ev(0, _port, ch, ME_CONTROLLER, CTRL_SUSTAIN, 0);
- _playEvents.add(ev);
- }
- }
- }
- if(seek)
- {
- // Send new contoller values...
- for(iMidiCtrlValList ivl = cll->begin(); ivl != cll->end(); ++ivl)
- {
- MidiCtrlValList* vl = ivl->second;
- iMidiCtrlVal imcv = vl->iValue(pos);
- if(imcv != vl->end()) {
- Part* p = imcv->second.part;
- unsigned t = (unsigned)imcv->first;
- // Do not add values that are outside of the part.
- if(p && t >= p->tick() && t < (p->tick() + p->lenTick()) )
- _playEvents.add(MidiPlayEvent(0, _port, ivl->first >> 24, ME_CONTROLLER, vl->num(), imcv->second.val));
- }
- }
- } */
-
- if (_playEvents.empty())
- return;
+ if(_playEvents.empty())
+ return;
- int port = midiPort();
- MidiPort* mp = port != -1 ? &MusEGlobal::midiPorts[port] : 0;
unsigned curFrame = MusEGlobal::audio->curFrame();
- int tickpos = MusEGlobal::audio->tickPos();
// Play all events up to current frame.
iMPEvent i = _playEvents.begin();
for (; i != _playEvents.end(); ++i) {
- if (i->time() > (extsync ? tickpos : curFrame)) // p3.3.25 Check: Should be nextTickPos? p4.0.34
+ if (i->time() > (ext_sync ? pos : curFrame)) // p3.3.25 Check: Should be nextTickPos? p4.0.34
break;
if(mp){
- if (mp->sendEvent(*i))
+ if (mp->sendEvent(*i, true)) // Force the event to be sent.
break;
}
else
@@ -601,6 +661,7 @@ void MidiAlsaDevice::processMidi()
_playEvents.erase(_playEvents.begin(), i);
}
+/*
//---------------------------------------------------------
// handleStop
//---------------------------------------------------------
@@ -614,21 +675,6 @@ void MidiAlsaDevice::handleStop()
stopPending = true; // Trigger stop handling in processMidi.
//---------------------------------------------------
- // reset sustain
- //---------------------------------------------------
-
- MidiPort* mp = &MusEGlobal::midiPorts[_port];
- for(int ch = 0; ch < MIDI_CHANNELS; ++ch)
- {
- if(mp->hwCtrlState(ch, CTRL_SUSTAIN) == 127)
- {
- //printf("send clear sustain!!!!!!!! port %d ch %d\n", i,ch);
- MidiPlayEvent ev(0, _port, ch, ME_CONTROLLER, CTRL_SUSTAIN, 0);
- putMidiEvent(ev);
- }
- }
-
- //---------------------------------------------------
// send midi stop
//---------------------------------------------------
@@ -646,18 +692,61 @@ void MidiAlsaDevice::handleStop()
if(si.MRTOut())
{
- // Send STOP
mp->sendStop();
-
- // Added check of option send continue not start. p3.3.31
- // Hmm, is this required? Seems to make other devices unhappy.
- // (Could try now that this is in MidiDevice. p4.0.22 )
+ // Added check of option send continue not start. Hmm, is this required? Seems to make other devices unhappy.
+ // (Could try now that this is in MidiDevice.)
//if(!si.sendContNotStart())
// mp->sendSongpos(MusEGlobal::audio->tickPos() * 4 / config.division);
}
}
+
+ //---------------------------------------------------
+ // reset sustain
+ //---------------------------------------------------
+
+ MidiPort* mp = &MusEGlobal::midiPorts[_port];
+ for(int ch = 0; ch < MIDI_CHANNELS; ++ch)
+ {
+ if(mp->hwCtrlState(ch, CTRL_SUSTAIN) == 127)
+ {
+ MidiPlayEvent ev(0, _port, ch, ME_CONTROLLER, CTRL_SUSTAIN, 0);
+ //putMidiEvent(ev);
+ putEvent(ev);
+ // Do sendEvent to get the optimizations - send only on a change of value.
+ //mp->sendEvent(ev);
+ }
+ }
+
+ //---------------------------------------------------
+ // send midi stop
+ //---------------------------------------------------
+
+// // Don't send if external sync is on. The master, and our sync routing system will take care of that.
+// if(!MusEGlobal::extSyncFlag.value())
+// {
+// // Shall we check open flags?
+// //if(!(dev->rwFlags() & 0x1) || !(dev->openFlags() & 1))
+// //if(!(dev->openFlags() & 1))
+// // return;
+//
+// MidiSyncInfo& si = mp->syncInfo();
+// if(si.MMCOut())
+// mp->sendMMCStop();
+//
+// if(si.MRTOut())
+// {
+// // Send STOP
+// mp->sendStop();
+// // Added check of option send continue not start. Hmm, is this required? Seems to make other devices unhappy.
+// // (Could try now that this is in MidiDevice.)
+// //if(!si.sendContNotStart())
+// // mp->sendSongpos(MusEGlobal::audio->tickPos() * 4 / config.division);
+// }
+// }
}
+*/
+/*
//---------------------------------------------------------
// handleSeek
//---------------------------------------------------------
@@ -675,7 +764,41 @@ void MidiAlsaDevice::handleSeek()
int pos = MusEGlobal::audio->tickPos();
//---------------------------------------------------
- // Send new contoller values
+ // Send STOP
+ //---------------------------------------------------
+
+ // Don't send if external sync is on. The master, and our sync routing system will take care of that.
+ if(!MusEGlobal::extSyncFlag.value())
+ {
+ if(mp->syncInfo().MRTOut())
+ {
+ // Shall we check for device write open flag to see if it's ok to send?...
+ //if(!(rwFlags() & 0x1) || !(openFlags() & 1))
+ //if(!(openFlags() & 1))
+ // continue;
+ mp->sendStop();
+ }
+ }
+
+ //---------------------------------------------------
+ // reset sustain
+ //---------------------------------------------------
+
+ MidiPort* mp = &MusEGlobal::midiPorts[_port];
+ for(int ch = 0; ch < MIDI_CHANNELS; ++ch)
+ {
+ if(mp->hwCtrlState(ch, CTRL_SUSTAIN) == 127)
+ {
+ MidiPlayEvent ev(0, _port, ch, ME_CONTROLLER, CTRL_SUSTAIN, 0);
+ putEvent(ev);
+ //putMidiEvent(ev);
+ // Do sendEvent to get the optimizations - send only on a change of value.
+ //mp->sendEvent(ev);
+ }
+ }
+
+ //---------------------------------------------------
+ // Send new controller values
//---------------------------------------------------
for(iMidiCtrlValList ivl = cll->begin(); ivl != cll->end(); ++ivl)
@@ -685,12 +808,18 @@ void MidiAlsaDevice::handleSeek()
if(imcv != vl->end())
{
Part* p = imcv->second.part;
+ // Don't send if part or track is muted or off.
+ if(!p || p->mute())
+ continue;
+ Track* track = p->track();
+ if(track && (track->isMute() || track->off()))
+ continue;
unsigned t = (unsigned)imcv->first;
// Do not add values that are outside of the part.
if(p && t >= p->tick() && t < (p->tick() + p->lenTick()) )
//_playEvents.add(MidiPlayEvent(0, _port, ivl->first >> 24, ME_CONTROLLER, vl->num(), imcv->second.val));
- // Hmm, play event list for immediate playback? Try putEvent instead. p4.0.34
- putMidiEvent(MidiPlayEvent(0, _port, ivl->first >> 24, ME_CONTROLLER, vl->num(), imcv->second.val));
+ // Use sendEvent to get the optimizations and limiting. But force if there's a value at this exact position.
+ mp->sendEvent(MidiPlayEvent(0, _port, ivl->first >> 24, ME_CONTROLLER, vl->num(), imcv->second.val), imcv->first == pos);
}
}
@@ -698,31 +827,23 @@ void MidiAlsaDevice::handleSeek()
// Send STOP and "set song position pointer"
//---------------------------------------------------
- // Don't send if external sync is on. The master, and our sync routing system will take care of that. p3.3.31
+ // Don't send if external sync is on. The master, and our sync routing system will take care of that.
if(!MusEGlobal::extSyncFlag.value())
{
if(mp->syncInfo().MRTOut())
{
// Shall we check for device write open flag to see if it's ok to send?...
- // This means obey what the user has chosen for read/write in the midi port config dialog,
- // which already takes into account whether the device is writable or not.
//if(!(rwFlags() & 0x1) || !(openFlags() & 1))
//if(!(openFlags() & 1))
// continue;
+ //mp->sendStop(); // Moved above.
int beat = (pos * 4) / MusEGlobal::config.division;
-
- //bool isPlaying = (state == PLAY);
- bool isPlaying = MusEGlobal::audio->isPlaying(); // TODO Check this it includes LOOP1 and LOOP2 besides PLAY. p4.0.22
-
- mp->sendStop();
mp->sendSongpos(beat);
- if(isPlaying)
- mp->sendContinue();
}
}
}
-#endif
+*/
//---------------------------------------------------------
// initMidiAlsa
diff --git a/muse2/muse/driver/alsamidi.h b/muse2/muse/driver/alsamidi.h
index 2054a7d3..7a1ac1c2 100644
--- a/muse2/muse/driver/alsamidi.h
+++ b/muse2/muse/driver/alsamidi.h
@@ -45,10 +45,8 @@ class MidiAlsaDevice : public MidiDevice {
private:
// Special for ALSA midi device: Play event list is processed in the ALSA midi sequencer thread.
// Need this FIFO, to decouple from audio thread which adds events to the list.
- MidiFifo playEventFifo;
- MidiFifo stuckNotesFifo;
- volatile bool stopPending;
- volatile bool seekPending;
+ //MidiFifo playEventFifo;
+ //MidiFifo stuckNotesFifo;
virtual QString open();
virtual void close();
@@ -69,13 +67,13 @@ class MidiAlsaDevice : public MidiDevice {
virtual void writeRouting(int, Xml&) const;
virtual inline int deviceType() const { return ALSA_MIDI; }
// Schedule an event for playback. Returns false if event cannot be delivered.
- virtual bool addScheduledEvent(const MidiPlayEvent& ev) { return !playEventFifo.put(ev); }
+ //virtual bool addScheduledEvent(const MidiPlayEvent& ev) { return !playEventFifo.put(ev); }
// Add a stuck note. Returns false if event cannot be delivered.
- virtual bool addStuckNote(const MidiPlayEvent& ev) { return !stuckNotesFifo.put(ev); }
+ //virtual bool addStuckNote(const MidiPlayEvent& ev) { return !stuckNotesFifo.put(ev); }
// Play all events up to current frame.
virtual void processMidi();
- virtual void handleStop();
- virtual void handleSeek();
+ //virtual void handleStop();
+ //virtual void handleSeek();
};
extern bool initMidiAlsa();
diff --git a/muse2/muse/driver/alsatimer.cpp b/muse2/muse/driver/alsatimer.cpp
index ee72d679..20f7ab88 100644
--- a/muse2/muse/driver/alsatimer.cpp
+++ b/muse2/muse/driver/alsatimer.cpp
@@ -173,7 +173,7 @@ namespace MusECore {
(long int)((1000000000.0 / snd_timer_info_get_resolution(info)) / snd_timer_params_get_ticks(params)));
}
- return 0;
+ return (long int)((1000000000.0 / snd_timer_info_get_resolution(info)) / snd_timer_params_get_ticks(params));
}
actFreq = (1000000000 / snd_timer_info_get_resolution(info)) / setTick;
if (actFreq != freq) {
diff --git a/muse2/muse/driver/jack.cpp b/muse2/muse/driver/jack.cpp
index 421152a7..a52410e9 100644
--- a/muse2/muse/driver/jack.cpp
+++ b/muse2/muse/driver/jack.cpp
@@ -3,6 +3,7 @@
// Linux Music Editor
// $Id: jack.cpp,v 1.30.2.17 2009/12/20 05:00:35 terminator356 Exp $
// (C) Copyright 2002 Werner Schweer (ws@seh.de)
+// (C) Copyright 2012 Tim E. Real (terminator356 on sourceforge.net)
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -82,15 +83,6 @@ bool checkAudioDevice()
namespace MusECore {
-//extern int jackmidi_pi[2];
-//extern int jackmidi_po[2];
-
-//jack_port_t *midi_port_in[JACK_MIDI_CHANNELS];
-//jack_port_t *midi_port_out[JACK_MIDI_CHANNELS];
-
-//muse_jack_midi_buffer jack_midi_out_data[JACK_MIDI_CHANNELS];
-//muse_jack_midi_buffer jack_midi_in_data[JACK_MIDI_CHANNELS];
-
JackAudioDevice* jackAudio;
//---------------------------------------------------------
@@ -109,38 +101,9 @@ inline bool checkJackClient(jack_client_t* _client)
// jack_thread_init
//---------------------------------------------------------
-static void jack_thread_init (void* ) // data
+static void jack_thread_init (void* )
{
MusEGlobal::doSetuid();
- /*
- if (jackAudio->isRealtime()) {
- struct sched_param rt_param;
- int rv;
- memset(&rt_param, 0, sizeof(sched_param));
- int type;
- rv = pthread_getschedparam(pthread_self(), &type, &rt_param);
- if (rv != 0)
- perror("get scheduler parameter");
- if (type != SCHED_FIFO) {
- fprintf(stderr, "JACK thread not running SCHED_FIFO, try to set...\n");
-
- memset(&rt_param, 0, sizeof(sched_param));
- rt_param.sched_priority = 1;
- rv = pthread_setschedparam(pthread_self(), SCHED_FIFO, &rt_param);
- if (rv != 0)
- perror("set realtime scheduler");
- memset(&rt_param, 0, sizeof(sched_param));
- rv = pthread_getschedparam(pthread_self(), &type, &rt_param);
- if (rv != 0)
- perror("get scheduler parameter");
- if (type != SCHED_FIFO)
- fprintf(stderr, "JACK still not running FIFO !?!\n"
- "======reliable RT operation not possible!!======\n");
- else
- fprintf(stderr, "JACK thread succesfully set to SCHED_FIFO\n");
- }
- }
- */
#ifdef VST_SUPPORT
if (loadVST)
fst_adopt_thread();
@@ -148,161 +111,78 @@ static void jack_thread_init (void* ) // data
MusEGlobal::undoSetuid();
}
-/*
-//---------------------------------------------------------
-// processAudio + Midi
-// JACK callback
-//---------------------------------------------------------
-void
-print_triplet(unsigned char *data)
-{
- int a,b,c;
- a = b = c = 0;
- memcpy(&a, data, 1);
- memcpy(&b, data+1, 1);
- memcpy(&c, data+2, 1);
- fprintf(stderr, "%x,%x,%x", a, b, c);
-}
-*/
-
-/*
-void handle_jack_midi_in_events(jack_nframes_t frames)
-{
- char buf = 0;
- int i,j;
- jack_midi_event_t midi_event;
- unsigned char t,n,v;
-
- for(j = 0; j < JACK_MIDI_CHANNELS; j++){
- void *midi_buffer_in = jack_port_get_buffer(midi_port_in[j], frames);
- int event_count = jack_midi_get_event_count(midi_buffer_in);
-
- for(i = 0; i < event_count; i++){
- jack_midi_event_get(&midi_event, midi_buffer_in, i);
- t = midi_event.buffer[0];
- n = midi_event.buffer[1];
- v = midi_event.buffer[2];
- if(((*(midi_event.buffer) & 0xf0)) == 0x90){
- fprintf(stderr, "jack-midi-in-event: ON_ time=%d %u ", midi_event.time,
- midi_event.size);
- print_triplet(midi_event.buffer);
- fprintf(stderr, "\n");
- }else if(((*(midi_event.buffer)) & 0xf0) == 0x80){
- fprintf(stderr, "jack-midi-in-event: OFF time=%d %u ", midi_event.time,
- midi_event.size);
- print_triplet(midi_event.buffer);
- fprintf(stderr, "\n");
- }else{
- fprintf(stderr, "jack-midi-in-event: ??? time=%d %u ", midi_event.time,
- midi_event.size);
- print_triplet(midi_event.buffer);
- fprintf(stderr, "\n");
- }
- jack_midi_in_data[j].buffer[0] = t;
- jack_midi_in_data[j].buffer[1] = n;
- jack_midi_in_data[j].buffer[2] = v;
- jack_midi_in_data[j].buffer[3] = 1;
- fprintf(stderr, "handle_jack_midi_in_events() w\n");
- write(jackmidi_pi[1], &buf, 1);
- fprintf(stderr, "handle_jack_midi_in_events() wd\n");
- }
- }
-}
-
-void handle_jack_midi_out_events(jack_nframes_t frames)
-{
- unsigned char *data;
- void *port_buf;
- int i,j,n,x;
-
- //for(i = 0; i < JACK_MIDI_CHANNELS; i++){
- for(i = 0; i < JACK_MIDI_CHANNELS; ++i){
- // jack-midi-clear any old events
- while(jack_midi_out_data[i].buffer[jack_midi_out_data[i].take*4+3] == 2){
- port_buf = jack_port_get_buffer(midi_port_out[i], frames);
- jack_midi_clear_buffer(port_buf);
- jack_midi_out_data[i].buffer[jack_midi_out_data[i].take*4+3] = 0;
- // point the take to the next slot
- jack_midi_out_data[i].take++;
- if(jack_midi_out_data[i].take >= JACK_MIDI_BUFFER_SIZE){
- jack_midi_out_data[i].take = 0;
- }
- }
- // check if any incoming midi-events from muse
- if(jack_midi_out_data[i].give != jack_midi_out_data[i].take){
-
- if(jack_midi_out_data[i].give > jack_midi_out_data[i].take){
- n = jack_midi_out_data[i].give - jack_midi_out_data[i].take;
- }else{
- n = jack_midi_out_data[i].give +
- (JACK_MIDI_BUFFER_SIZE - jack_midi_out_data[i].take);
- }
- port_buf = jack_port_get_buffer(midi_port_out[i], frames);
- jack_midi_clear_buffer(port_buf);
- // FIX: midi events has different sizes, compare note-on to
- // program-change. We should first walk over the events
- // counting the size.
- //data = jack_midi_event_reserve(port_buf, 0, n*3);
- //x = jack_midi_out_data[i].take;
- //for(j = 0; j < n; j++){
- // data[j*3+0] = jack_midi_out_data[i].buffer[x*4+0];
- // data[j*3+1] = jack_midi_out_data[i].buffer[x*4+1];
- // data[j*3+2] = jack_midi_out_data[i].buffer[x*4+2];
- // after having copied the buffer over to the jack-buffer,
- // mark the muses midi-out buffer as 'need-cleaning'
- // jack_midi_out_data[i].buffer[x*4+3] = 2;
- // x++;
- // if(x >= JACK_MIDI_BUFFER_SIZE){
- // x = 0;
- // }
- //}
-
- x = jack_midi_out_data[i].take;
- for(j = 0; j < n; ++j)
- {
- data = jack_midi_event_reserve(port_buf, 0, 3);
- if(data == 0)
- {
- fprintf(stderr, "handle_jack_midi_out_events: buffer overflow, event lost\n");
- // Can do no more processing. Just return.
- return;
- }
- data[0] = jack_midi_out_data[i].buffer[x*4+0];
- data[1] = jack_midi_out_data[i].buffer[x*4+1];
- data[2] = jack_midi_out_data[i].buffer[x*4+2];
- // after having copied the buffer over to the jack-buffer,
- // mark the muses midi-out buffer as 'need-cleaning'
- jack_midi_out_data[i].buffer[x*4+3] = 2;
- x++;
- if(x >= JACK_MIDI_BUFFER_SIZE){
- x = 0;
- }
- }
-
- }
- }
-}
-*/
-
-//static int processAudio(jack_nframes_t frames, void*)
int JackAudioDevice::processAudio(jack_nframes_t frames, void*)
{
- jackAudio->_frameCounter += frames;
-
-/// handle_jack_midi_in_events(frames);
-/// handle_jack_midi_out_events(frames);
-
-// if (JACK_DEBUG)
-// printf("processAudio - >>>>\n");
+ int state_pending = jackAudio->_dummyStatePending; // Snapshots.
+ int pos_pending = jackAudio->_dummyPosPending; //
+ jackAudio->_dummyStatePending = -1; // Reset.
+ jackAudio->_dummyPosPending = -1; //
+
+ jackAudio->_frameCounter += frames;
MusEGlobal::segmentSize = frames;
+
if (MusEGlobal::audio->isRunning())
- MusEGlobal::audio->process((unsigned long)frames);
+ {
+ // Are we not using Jack transport?
+ if(!MusEGlobal::useJackTransport.value())
+ {
+ // STOP -> STOP, STOP -> START_PLAY, PLAY -> START_PLAY all count as 'syncing'.
+ if(((jackAudio->dummyState == Audio::STOP || jackAudio->dummyState == Audio::PLAY) && state_pending == Audio::START_PLAY)
+ || (jackAudio->dummyState == Audio::STOP && state_pending == Audio::STOP) )
+ {
+ jackAudio->_syncTimeout = (float)frames / (float)MusEGlobal::sampleRate; // (Re)start the timeout counter...
+ if(pos_pending != -1)
+ jackAudio->dummyPos = pos_pending; // Set the new dummy position.
+ if((jackAudio->dummyState == Audio::STOP || jackAudio->dummyState == Audio::PLAY) && state_pending == Audio::START_PLAY)
+ jackAudio->dummyState = Audio::START_PLAY;
+ }
+ else // All other states such as START_PLAY -> STOP, PLAY -> STOP.
+ if(state_pending != -1 && state_pending != jackAudio->dummyState)
+ {
+ jackAudio->_syncTimeout = 0.0; // Reset.
+ jackAudio->dummyState = state_pending;
+ }
+
+ // Is the sync timeout counter running?
+ if(jackAudio->_syncTimeout > 0.0)
+ {
+ //printf("Jack processAudio dummy sync: state:%d pending:%d\n", jackAudio->dummyState, state_pending);
+ // Is MusE audio ready to roll?
+ if(MusEGlobal::audio->sync(jackAudio->dummyState, jackAudio->dummyPos))
+ {
+ jackAudio->_syncTimeout = 0.0; // Reset.
+ // We're ready. Switch to PLAY state.
+ if(jackAudio->dummyState == Audio::START_PLAY)
+ jackAudio->dummyState = Audio::PLAY;
+ }
+ else
+ {
+ jackAudio->_syncTimeout += (float)frames / (float)MusEGlobal::sampleRate;
+ if(jackAudio->_syncTimeout > 5.0) // TODO: Make this timeout a 'settings' option so it can be applied both to Jack and here.
+ {
+ if (MusEGlobal::debugMsg)
+ puts("Jack dummy sync timeout! Starting anyway...\n");
+ jackAudio->_syncTimeout = 0.0; // Reset.
+ // We're not ready, but no time left - gotta roll anyway. Switch to PLAY state, similar to how Jack is supposed to work.
+ if(jackAudio->dummyState == Audio::START_PLAY)
+ {
+ jackAudio->dummyState = Audio::PLAY;
+ // Docs say sync will be called with Rolling state when timeout expires.
+ MusEGlobal::audio->sync(jackAudio->dummyState, jackAudio->dummyPos);
+ }
+ }
+ }
+ }
+ }
+
+ //if(jackAudio->getState() != Audio::START_PLAY) // Don't process while we're syncing. TODO: May need to deliver silence in process!
+ MusEGlobal::audio->process((unsigned long)frames);
+ }
else {
if (MusEGlobal::debugMsg)
puts("jack calling when audio is disconnected!\n");
}
-// if (JACK_DEBUG)
-// printf("processAudio - <<<<\n");
+
return 0;
}
@@ -344,13 +224,9 @@ static int processSync(jack_transport_state_t state, jack_position_t* pos, void*
}
unsigned frame = pos->frame;
- //printf("processSync valid:%d frame:%d\n", pos->valid, frame);
-
- // p3.3.23
- //printf("Jack processSync() before MusEGlobal::audio->sync frame:%d\n", frame);
//return MusEGlobal::audio->sync(audioState, frame);
int rv = MusEGlobal::audio->sync(audioState, frame);
- //printf("Jack processSync() after MusEGlobal::audio->sync frame:%d\n", frame);
+ //printf("Jack processSync() after MusEGlobal::audio->sync frame:%d\n", frame);
return rv;
}
@@ -366,7 +242,6 @@ static void timebase_callback(jack_transport_state_t /* state */,
{
//printf("Jack timebase_callback pos->frame:%u MusEGlobal::audio->tickPos:%d MusEGlobal::song->cpos:%d\n", pos->frame, MusEGlobal::audio->tickPos(), MusEGlobal::song->cpos());
- // p3.3.27
//Pos p(pos->frame, false);
Pos p(MusEGlobal::extSyncFlag.value() ? MusEGlobal::audio->tickPos() : pos->frame, MusEGlobal::extSyncFlag.value() ? true : false);
// Can't use song pos - it is only updated every (slow) GUI heartbeat !
@@ -382,7 +257,6 @@ static void timebase_callback(jack_transport_state_t /* state */,
// dummy:
//
- // p3.3.26
//pos->beats_per_bar = 4;
//pos->beat_type = 4;
//pos->ticks_per_beat = 384;
@@ -472,20 +346,7 @@ JackAudioDevice::~JackAudioDevice()
if (JACK_DEBUG)
printf("~JackAudioDevice()\n");
if (_client) {
-
- /*
- // p3.3.35
- for(int i = 0; i < JACK_MIDI_CHANNELS; i++)
- {
- if(midi_port_in[i])
- jack_port_unregister(_client, midi_port_in[i]);
- if(midi_port_out[i])
- jack_port_unregister(_client, midi_port_out[i]);
- }
- */
-
if (jack_client_close(_client)) {
- //error->logError("jack_client_close() failed: %s\n", strerror(errno));
fprintf(stderr,"jack_client_close() failed: %s\n", strerror(errno));
}
}
@@ -518,32 +379,6 @@ int JackAudioDevice::realtimePriority() const
return param.sched_priority;
}
-/*
-//---------------------------------------------------------
-// getJackName()
-//---------------------------------------------------------
-
-char* JackAudioDevice::getJackName()
- {
- return jackRegisteredName;
- }
-*/
-
-/*
-//---------------------------------------------------------
-// clientName()
-//---------------------------------------------------------
-
-const char* JackAudioDevice::clientName()
-{
- //if(_client)
- // return jack_get_client_name(_client);
- //else
- // return "MusE";
- return jackRegisteredName;
-}
-*/
-
//---------------------------------------------------------
// initJackAudio
// return true if JACK not found
@@ -551,15 +386,6 @@ const char* JackAudioDevice::clientName()
bool initJackAudio()
{
- /*
- // p3.3.35
- for(int i = 0; i < JACK_MIDI_CHANNELS; i++)
- {
- midi_port_in[i] = 0;
- midi_port_out[i] = 0;
- }
- */
-
if (JACK_DEBUG)
printf("initJackAudio()\n");
if (MusEGlobal::debugMsg) {
@@ -596,7 +422,7 @@ bool initJackAudio()
if (status & JackVersionError)
printf("jack server has wrong version\n");
printf("cannot create jack client\n");
- MusEGlobal::undoSetuid(); // p3.3.51
+ MusEGlobal::undoSetuid();
return true;
}
@@ -616,39 +442,6 @@ bool initJackAudio()
}
MusEGlobal::undoSetuid();
- /*
- // setup midi input/output
- //memset(jack_midi_out_data, 0, JACK_MIDI_CHANNELS * sizeof(muse_jack_midi_buffer));
- //memset(jack_midi_in_data, 0, JACK_MIDI_CHANNELS * sizeof(muse_jack_midi_buffer));
- if(client){
- for(i = 0; i < JACK_MIDI_CHANNELS; i++)
- {
- char buf[80];
- snprintf(buf, 80, "muse-jack-midi-in-%d", i+1);
- midi_port_in[i] = jack_port_register(client, buf,
- JACK_DEFAULT_MIDI_TYPE,
- JackPortIsInput, 0);
- if(midi_port_in[i] == NULL){
- fprintf(stderr, "failed to register jack-midi-in\n");
- exit(-1);
- }
- snprintf(buf, 80, "muse-jack-midi-out-%d", i+1);
- midi_port_out[i] = jack_port_register(client, buf,
- JACK_DEFAULT_MIDI_TYPE,
- JackPortIsOutput, 0);
- if(midi_port_out == NULL)
- {
- fprintf(stderr, "failed to register jack-midi-out\n");
- exit(-1);
- }
- }
- }
- else
- {
- fprintf(stderr, "WARNING NO muse-jack midi connection\n");
- }
- */
-
if (client) {
MusEGlobal::audioDevice = jackAudio;
jackAudio->scanMidiPorts();
@@ -730,8 +523,8 @@ void JackAudioDevice::connectJackMidiPorts()
//void* port = md->clientPort();
if(md->rwFlags() & 1)
{
- void* port = md->outClientPort(); // p3.3.55
- if(port) //
+ void* port = md->outClientPort();
+ if(port)
{
RouteList* rl = md->outRoutes();
for (ciRoute r = rl->begin(); r != rl->end(); ++r)
@@ -743,12 +536,10 @@ void JackAudioDevice::connectJackMidiPorts()
}
}
- // else // p3.3.55 Removed
-
if(md->rwFlags() & 2)
{
- void* port = md->inClientPort(); // p3.3.55
- if(port) //
+ void* port = md->inClientPort();
+ if(port)
{
RouteList* rl = md->inRoutes();
for (ciRoute r = rl->begin(); r != rl->end(); ++r)
@@ -760,117 +551,8 @@ void JackAudioDevice::connectJackMidiPorts()
}
}
}
-
-
- /*
- const char* type = JACK_DEFAULT_MIDI_TYPE;
- const char** ports = jack_get_ports(_client, 0, type, 0);
- for (const char** p = ports; p && *p; ++p)
- {
- jack_port_t* port = jack_port_by_name(_client, *p);
- if(!port)
- continue;
- // Ignore our own client ports.
- if(jack_port_is_mine(_client, port))
- {
- if(MusEGlobal::debugMsg)
- printf(" ignoring own port: %s\n", *p);
- continue;
- }
- int nsz = jack_port_name_size();
- char buffer[nsz];
- strncpy(buffer, *p, nsz);
- // Ignore the MusE Jack port.
- //if(strncmp(buffer, "MusE", 4) == 0)
- // continue;
-
- if(MusEGlobal::debugMsg)
- printf(" found port: %s ", buffer);
-
- // If there are aliases for this port, use the first one - much better for identifying.
- //char a1[nsz];
- char a2[nsz];
- char* aliases[2];
- //aliases[0] = a1;
- aliases[0] = buffer;
- aliases[1] = a2;
- // To disable aliases, just rem this line.
- jack_port_get_aliases(port, aliases);
- //int na = jack_port_get_aliases(port, aliases);
- //char* namep = (na >= 1) ? aliases[0] : buffer;
- char* namep = aliases[0];
-
- if(MusEGlobal::debugMsg)
- printf("alias: %s\n", aliases[0]);
-
- //int flags = 0;
- int pf = jack_port_flags(port);
- // If Jack port can send data to us...
- //if(pf & JackPortIsOutput)
- // Mark as input capable.
- // flags |= 2;
- // If Jack port can receive data from us...
- //if(pf & JackPortIsInput)
- // Mark as output capable.
- // flags |= 1;
-
- //JackPort jp(0, QString(buffer), flags);
- //portList.append(jp);
-
- QString name(namep);
-
- if(JACK_DEBUG)
- printf("JackAudioDevice::graphChanged %s\n", name.toLatin1());
-
- for(iMidiDevice imd = MusEGlobal::midiDevices.begin(); imd != MusEGlobal::midiDevices.end(); ++imd)
- {
- // Is it a Jack midi device?
- MidiJackDevice* mjd = dynamic_cast<MidiJackDevice*>(*imd);
- if(!mjd)
- continue;
-
- //if(dev->name() != name)
- // continue;
-
- // Is this port the one created for the Jack midi device?
- if(!mjd->clientJackPort() || (mjd->clientJackPort() != port))
- continue;
-
- jack_port_t* devport = jack_port_by_name(_client, mjd->name().toLatin1());
- if(!devport)
- continue;
-
- int ofl = mjd->openFlags();
-
- if(JACK_DEBUG)
- printf("JackAudioDevice::graphChanged found MidiJackDevice:%s\n", mjd->name().toLatin1());
-
- // Note docs say it can't be both input and output. src, dest
- // If Jack port can receive data from us and we actually want to...
- if((pf & JackPortIsOutput) && (ofl & 1))
- {
- if(JACK_DEBUG)
- printf("JackAudioDevice::graphChanged connecting MusE output\n");
- MusEGlobal::audioDevice->connect(port, devport);
- }
- else
- // If Jack port can send data to us and we actually want it...
- if((pf & JackPortIsInput) && (ofl & 2))
- {
- if(JACK_DEBUG)
- printf("JackAudioDevice::graphChanged connecting MusE input\n");
- MusEGlobal::audioDevice->connect(devport, port);
- }
-
- break;
- }
- }
-
- if(ports)
- free(ports);
-
- */
}
+
//---------------------------------------------------------
// client_registration_callback
//---------------------------------------------------------
@@ -1009,9 +691,6 @@ void JackAudioDevice::graphChanged()
++pn;
}
- // p3.3.37
- //delete ports;
- //free(ports);
jack_free(ports); // p4.0.29
ports = NULL;
@@ -1100,9 +779,6 @@ void JackAudioDevice::graphChanged()
++pn;
}
- // p3.3.37
- //delete ports;
- //free(ports);
jack_free(ports); // p4.0.29
ports = NULL;
@@ -1134,12 +810,9 @@ void JackAudioDevice::graphChanged()
if(md->rwFlags() & 1) // Writable
{
- // p3.3.55
jack_port_t* port = (jack_port_t*)md->outClientPort();
if(port != 0)
{
- //printf("graphChanged() valid out client port\n"); // p3.3.55
-
const char** ports = jack_port_get_all_connections(_client, port);
RouteList* rl = md->outRoutes();
@@ -1160,7 +833,7 @@ void JackAudioDevice::graphChanged()
//if (irl->channel != channel)
// continue;
QString name = irl->name();
- //name += QString(JACK_MIDI_OUT_PORT_SUFFIX); // p3.3.55
+ //name += QString(JACK_MIDI_OUT_PORT_SUFFIX);
QByteArray ba = name.toLatin1();
const char* portName = ba.constData();
bool found = false;
@@ -1224,9 +897,6 @@ void JackAudioDevice::graphChanged()
++pn;
}
- // p3.3.55
- // Done with ports. Free them.
- //free(ports);
jack_free(ports); // p4.0.29
}
}
@@ -1239,11 +909,9 @@ void JackAudioDevice::graphChanged()
if(md->rwFlags() & 2) // Readable
{
- // p3.3.55
jack_port_t* port = (jack_port_t*)md->inClientPort();
if(port != 0)
{
- //printf("graphChanged() valid in client port\n"); // p3.3.55
const char** ports = jack_port_get_all_connections(_client, port);
RouteList* rl = md->inRoutes();
@@ -1326,20 +994,11 @@ void JackAudioDevice::graphChanged()
}
++pn;
}
- // p3.3.55
- // Done with ports. Free them.
- //free(ports);
+
jack_free(ports); // p4.0.29
}
}
}
-
- // p3.3.55 Removed.
- //if(ports)
- // Done with ports. Free them.
- //delete ports;
- // free(ports);
- //ports = NULL;
}
}
@@ -1360,18 +1019,12 @@ void JackAudioDevice::registerClient()
if(!checkJackClient(_client)) return;
jack_set_process_callback(_client, processAudio, 0);
jack_set_sync_callback(_client, processSync, 0);
- // FIXME: FIXME:
- // Added by Tim. p3.3.20
- // Did not help. Seek during play: Jack keeps switching to STOP state after about 1-2 seconds timeout if sync is holding it up.
- // Nothing in MusE seems to be telling it to stop.
- // NOTE: Update: It was a bug in QJackCtl. Fixed now.
//jack_set_sync_timeout(_client, 5000000); // Change default 2 to 5 second sync timeout because prefetch may be very slow esp. with resampling !
jack_on_shutdown(_client, processShutdown, 0);
jack_set_buffer_size_callback(_client, bufsize_callback, 0);
jack_set_sample_rate_callback(_client, srate_callback, 0);
jack_set_port_registration_callback(_client, registration_callback, 0);
- // p3.3.37
jack_set_client_registration_callback(_client, client_registration_callback, 0);
jack_set_port_connect_callback(_client, port_connect_callback, 0);
@@ -1384,7 +1037,6 @@ void JackAudioDevice::registerClient()
// registerInPort
//---------------------------------------------------------
-//void* JackAudioDevice::registerInPort(const char* name)
void* JackAudioDevice::registerInPort(const char* name, bool midi)
{
if (JACK_DEBUG)
@@ -1401,7 +1053,6 @@ void* JackAudioDevice::registerInPort(const char* name, bool midi)
// registerOutPort
//---------------------------------------------------------
-//void* JackAudioDevice::registerOutPort(const char* name)
void* JackAudioDevice::registerOutPort(const char* name, bool midi)
{
if (JACK_DEBUG)
@@ -1452,7 +1103,7 @@ void JackAudioDevice::disconnect(void* src, void* dst)
if (JACK_DEBUG)
printf("JackAudioDevice::disconnect()\n");
if(!checkJackClient(_client)) return;
- if(!src || !dst) // p3.3.55
+ if(!src || !dst)
return;
const char* sn = jack_port_name((jack_port_t*) src);
const char* dn = jack_port_name((jack_port_t*) dst);
@@ -1478,7 +1129,6 @@ void JackAudioDevice::disconnect(void* src, void* dst)
// start
//---------------------------------------------------------
-//void JackAudioDevice::start()
void JackAudioDevice::start(int /*priority*/)
{
if (JACK_DEBUG)
@@ -1488,7 +1138,7 @@ void JackAudioDevice::start(int /*priority*/)
MusEGlobal::doSetuid();
if (jack_activate(_client)) {
- MusEGlobal::undoSetuid(); // p3.3.51
+ MusEGlobal::undoSetuid();
fprintf (stderr, "JACK: cannot activate client\n");
exit(-1);
}
@@ -1530,7 +1180,6 @@ void JackAudioDevice::start(int /*priority*/)
}
}
- // p3.3.37
// Connect the Jack midi client ports to device ports.
connectJackMidiPorts();
@@ -1723,9 +1372,6 @@ void JackAudioDevice::getJackPorts(const char** ports, std::list<QString>& name_
name_list.push_back(qname);
}
- // p3.3.37
- //if(ports)
- //free(ports);
// jack_free(ports); // p4.0.29
//return clientList;
@@ -1744,61 +1390,6 @@ std::list<QString> JackAudioDevice::outputPorts(bool midi, int aliases)
const char* type = midi ? JACK_DEFAULT_MIDI_TYPE : JACK_DEFAULT_AUDIO_TYPE;
const char** ports = jack_get_ports(_client, 0, type, JackPortIsOutput);
- /*
- QString qname;
- for (const char** p = ports; p && *p; ++p) {
- jack_port_t* port = jack_port_by_name(_client, *p);
- //int flags = jack_port_flags(port);
- //if (!(flags & JackPortIsOutput))
- // continue;
- //char buffer[128];
-
- int nsz = jack_port_name_size();
- char buffer[nsz];
-
- strncpy(buffer, *p, nsz);
- //if (strncmp(buffer, "MusE", 4) == 0)
- //{
- // if(MusEGlobal::debugMsg)
- // printf("JackAudioDevice::outputPorts ignoring own MusE port: %s\n", *p);
- // continue;
- //}
-
- // Ignore our own client ports.
- if(jack_port_is_mine(_client, port))
- {
- if(MusEGlobal::debugMsg)
- printf("JackAudioDevice::outputPorts ignoring own port: %s\n", *p);
- continue;
- }
-
- // p3.3.38
- if((aliases == 0) || (aliases == 1))
- {
- //char a1[nsz];
- char a2[nsz];
- char* al[2];
- //aliases[0] = a1;
- al[0] = buffer;
- al[1] = a2;
- int na = jack_port_get_aliases(port, al);
- int a = aliases;
- if(a >= na)
- {
- a = na;
- if(a > 0)
- a--;
- }
- qname = QString(al[a]);
- }
- else
- qname = QString(buffer);
-
- //clientList.push_back(QString(buffer));
- clientList.push_back(qname);
- }
- */
-
if(ports)
{
getJackPorts(ports, clientList, midi, true, aliases); // Get physical ports first.
@@ -1823,61 +1414,6 @@ std::list<QString> JackAudioDevice::inputPorts(bool midi, int aliases)
const char* type = midi ? JACK_DEFAULT_MIDI_TYPE : JACK_DEFAULT_AUDIO_TYPE;
const char** ports = jack_get_ports(_client, 0, type, JackPortIsInput);
- /*
- QString qname;
- for (const char** p = ports; p && *p; ++p) {
- jack_port_t* port = jack_port_by_name(_client, *p);
- //int flags = jack_port_flags(port);
- //if (!(flags & JackPortIsInput))
- // continue;
- //char buffer[128];
-
- int nsz = jack_port_name_size();
- char buffer[nsz];
-
- strncpy(buffer, *p, nsz);
- //if (strncmp(buffer, "MusE", 4) == 0)
- //{
- // if(MusEGlobal::debugMsg)
- // printf("JackAudioDevice::inputPorts ignoring own MusE port: %s\n", *p);
- // continue;
- //}
-
- // Ignore our own client ports.
- if(jack_port_is_mine(_client, port))
- {
- if(MusEGlobal::debugMsg)
- printf("JackAudioDevice::inputPorts ignoring own port: %s\n", *p);
- continue;
- }
-
- // p3.3.38
- if((aliases == 0) || (aliases == 1))
- {
- //char a1[nsz];
- char a2[nsz];
- char* al[2];
- //aliases[0] = a1;
- al[0] = buffer;
- al[1] = a2;
- int na = jack_port_get_aliases(port, al);
- int a = aliases;
- if(a >= na)
- {
- a = na;
- if(a > 0)
- a--;
- }
- qname = QString(al[a]);
- }
- else
- qname = QString(buffer);
-
- //clientList.push_back(QString(buffer));
- clientList.push_back(qname);
- }
- */
-
if(ports)
{
getJackPorts(ports, clientList, midi, true, aliases); // Get physical ports first.
@@ -1979,37 +1515,6 @@ void JackAudioDevice::setFreewheel(bool f)
}
//---------------------------------------------------------
-// dummySync
-//---------------------------------------------------------
-
-bool JackAudioDevice::dummySync(int state)
-{
- // Roughly segment time length.
- //timespec ts = { 0, (1000000000 * MusEGlobal::segmentSize) / MusEGlobal::sampleRate }; // In nanoseconds.
- unsigned int sl = (1000000 * MusEGlobal::segmentSize) / MusEGlobal::sampleRate; // In microseconds.
-
- double ct = curTime();
- // Wait for a default maximum of 5 seconds.
- // Similar to how Jack is supposed to wait a default of 2 seconds for slow clients.
- // TODO: Make this timeout a 'settings' option so it can be applied both to Jack and here.
- while((curTime() - ct) < 5.0)
- {
- // Is MusE audio ready to roll?
- if(MusEGlobal::audio->sync(state, dummyPos))
- return true;
-
- // Not ready. Wait a 'segment', try again...
- //nanosleep(&ts, NULL);
- usleep(sl); // usleep is supposed to be obsolete!
- }
-
- //if(JACK_DEBUG)
- printf("JackAudioDevice::dummySync Sync timeout - audio not ready!\n");
-
- return false;
-}
-
-//---------------------------------------------------------
// startTransport
//---------------------------------------------------------
@@ -2022,19 +1527,7 @@ void JackAudioDevice::startTransport()
// as if processSync was called.
if(!MusEGlobal::useJackTransport.value())
{
- //dummyState = Audio::START_PLAY;
-
- // Is MusE audio ready to roll?
- //if(dummySync(dummyState))
- if(dummySync(Audio::START_PLAY))
- {
- // MusE audio is ready to roll. Let's play.
- dummyState = Audio::PLAY;
- return;
- }
-
- // Ready or not, we gotta roll. Similar to how Jack is supposed to roll anyway.
- dummyState = Audio::PLAY;
+ _dummyStatePending = Audio::START_PLAY;
return;
}
@@ -2052,11 +1545,9 @@ void JackAudioDevice::stopTransport()
if (JACK_DEBUG)
printf("JackAudioDevice::stopTransport()\n");
- dummyState = Audio::STOP;
-
if(!MusEGlobal::useJackTransport.value())
{
- //dummyState = Audio::STOP;
+ _dummyStatePending = Audio::STOP;
return;
}
@@ -2077,32 +1568,11 @@ void JackAudioDevice::seekTransport(unsigned frame)
if (JACK_DEBUG)
printf("JackAudioDevice::seekTransport() frame:%d\n", frame);
- dummyPos = frame;
if(!MusEGlobal::useJackTransport.value())
{
- // If we're not using Jack's transport, just pass the current state and new frame along
- // as if processSync was called.
- //dummyPos = frame;
- int tempState = dummyState;
- //dummyState = Audio::START_PLAY;
-
- // Is MusE audio ready yet?
- //MusEGlobal::audio->sync(dummyState, dummyPos);
- //if(dummySync(dummyState))
- if(dummySync(Audio::START_PLAY))
- {
- dummyState = tempState;
- return;
- }
-
- // Not ready, resume previous state anyway.
- // FIXME: Observed: Seek during play: Jack transport STOPs on timeout.
- // Docs say when starting play, transport will roll anyway, ready or not (observed),
- // but don't mention what should happen on seek during play.
- // And setting the slow-sync timeout doesn't seem to do anything!
- // NOTE: Update: It was a bug with QJackCtl. Fixed now.
- //dummyState = tempState;
- dummyState = Audio::STOP;
+ _dummyPosPending = frame;
+ // STOP -> STOP means seek in stop mode. PLAY -> START_PLAY means seek in play mode.
+ _dummyStatePending = (dummyState == Audio::STOP ? Audio::STOP : Audio::START_PLAY);
return;
}
@@ -2120,28 +1590,11 @@ void JackAudioDevice::seekTransport(const Pos &p)
if (JACK_DEBUG)
printf("JackAudioDevice::seekTransport() frame:%d\n", p.frame());
- dummyPos = p.frame();
if(!MusEGlobal::useJackTransport.value())
{
- // If we're not using Jack's transport, just pass the current state and new frame along
- // as if processSync was called.
- //dummyPos = p.frame();
- int tempState = dummyState;
- //dummyState = Audio::START_PLAY;
-
- // Is MusE audio ready yet?
- //MusEGlobal::audio->sync(dummyState, dummyPos);
- //if(dummySync(dummyState))
- if(dummySync(Audio::START_PLAY))
- {
- dummyState = tempState;
- return;
- }
-
- // Not ready, resume previous state anyway.
- // FIXME: See fixme in other seekTransport...
- //dummyState = tempState;
- dummyState = Audio::STOP;
+ _dummyPosPending = p.frame();
+ // STOP -> STOP means seek in stop mode. PLAY -> START_PLAY means seek in play mode.
+ _dummyStatePending = (dummyState == Audio::STOP ? Audio::STOP : Audio::START_PLAY);
return;
}
@@ -2380,8 +1833,7 @@ void exitJackAudio()
if (JACK_DEBUG)
printf("exitJackAudio() after delete jackAudio\n");
- // Added by Tim. p3.3.14
- MusEGlobal::audioDevice = NULL;
+ MusEGlobal::audioDevice = NULL; // By Tim
}
} // namespace MusECore
diff --git a/muse2/muse/driver/jackaudio.h b/muse2/muse/driver/jackaudio.h
index c4d37db9..838a20df 100644
--- a/muse2/muse/driver/jackaudio.h
+++ b/muse2/muse/driver/jackaudio.h
@@ -40,13 +40,16 @@ class MidiPlayEvent;
class JackAudioDevice : public AudioDevice {
jack_client_t* _client;
- double sampleTime;
- int samplePos;
+ //double sampleTime;
+ //int samplePos;
+ float _syncTimeout;
jack_transport_state_t transportState;
jack_position_t pos;
char jackRegisteredName[16];
int dummyState;
int dummyPos;
+ volatile int _dummyStatePending;
+ volatile int _dummyPosPending;
// Free-running frame counter incremented always in process.
jack_nframes_t _frameCounter;
@@ -58,14 +61,13 @@ class JackAudioDevice : public AudioDevice {
virtual ~JackAudioDevice();
virtual void nullify_client() { _client = 0; }
- virtual inline int deviceType() const { return JACK_AUDIO; } // p3.3.52
+ virtual inline int deviceType() const { return JACK_AUDIO; }
void scanMidiPorts();
//virtual void start();
virtual void start(int);
virtual void stop ();
- virtual bool dummySync(int state); // Artificial sync when not using Jack transport.
virtual int framePos() const;
virtual unsigned frameTime() const { return _frameCounter; }
@@ -80,8 +82,6 @@ class JackAudioDevice : public AudioDevice {
virtual void registerClient();
virtual const char* clientName() { return jackRegisteredName; }
- //virtual void* registerOutPort(const char* name);
- //virtual void* registerInPort(const char* name);
virtual void* registerOutPort(const char* /*name*/, bool /*midi*/);
virtual void* registerInPort(const char* /*name*/, bool /*midi*/);
diff --git a/muse2/muse/driver/jackmidi.cpp b/muse2/muse/driver/jackmidi.cpp
index 7a12b92d..706fa269 100644
--- a/muse2/muse/driver/jackmidi.cpp
+++ b/muse2/muse/driver/jackmidi.cpp
@@ -24,6 +24,7 @@
#include <QString>
#include <stdio.h>
+#include <string.h>
#include <jack/jack.h>
//#include <jack/midiport.h>
@@ -43,6 +44,8 @@
#include "../mplugins/midiitransform.h"
#include "../mplugins/mitplugin.h"
#include "xml.h"
+#include "gconfig.h"
+#include "track.h"
// Turn on debug messages.
//#define JACK_MIDI_DEBUG
@@ -336,10 +339,10 @@ void MidiJackDevice::recordEvent(MidiRecordEvent& event)
event.setLoopNum(MusEGlobal::audio->loopCount());
if (MusEGlobal::midiInputTrace) {
- printf("Jack MidiInput: ");
+ printf("MidiIn Jack: <%s>: ", name().toLatin1().constData());
event.dump();
}
-
+
int typ = event.type();
if(_port != -1)
@@ -431,7 +434,8 @@ void MidiJackDevice::eventReceived(jack_midi_event_t* ev)
{
MidiRecordEvent event;
event.setB(0);
-
+ event.setPort(_port);
+
// NOTE: From muse_qt4_evolution. Not done here in Muse-2 (yet).
// move all events 2*MusEGlobal::segmentSize into the future to get
// jitterfree playback
@@ -452,6 +456,7 @@ void MidiJackDevice::eventReceived(jack_midi_event_t* ev)
int a = *(ev->buffer + 1) & 0x7f;
int b = *(ev->buffer + 2) & 0x7f;
event.setType(type);
+
switch(type) {
case ME_NOTEON:
case ME_NOTEOFF:
@@ -494,7 +499,7 @@ void MidiJackDevice::eventReceived(jack_midi_event_t* ev)
return;
case ME_SONGPOS:
if(_port != -1)
- MusEGlobal::midiSeq->setSongPosition(_port, *(ev->buffer + 1) | (*(ev->buffer + 2) >> 2 )); // LSB then MSB
+ MusEGlobal::midiSeq->setSongPosition(_port, *(ev->buffer + 1) | (*(ev->buffer + 2) << 7 )); // LSB then MSB
return;
//case ME_SONGSEL:
//case ME_TUNE_REQ:
@@ -525,11 +530,6 @@ void MidiJackDevice::eventReceived(jack_midi_event_t* ev)
return;
}
- if (MusEGlobal::midiInputTrace) {
- printf("MidiInput<%s>: ", name().toLatin1().constData());
- event.dump();
- }
-
#ifdef JACK_MIDI_DEBUG
printf("MidiJackDevice::eventReceived time:%d type:%d ch:%d A:%d B:%d\n", event.time(), event.type(), event.channel(), event.dataA(), event.dataB());
#endif
@@ -600,14 +600,6 @@ bool MidiJackDevice::queueEvent(const MidiPlayEvent& e)
//if(port >= JACK_MIDI_CHANNELS)
// return false;
- //if (midiOutputTrace) {
- // printf("MidiOut<%s>: jackMidi: ", portName(port).toLatin1().constData());
- // e.dump();
- // }
-
- //if(MusEGlobal::debugMsg)
- // printf("MidiJackDevice::queueEvent\n");
-
if(!_out_client_jackport)
return false;
void* pb = jack_port_get_buffer(_out_client_jackport, MusEGlobal::segmentSize);
@@ -626,9 +618,14 @@ bool MidiJackDevice::queueEvent(const MidiPlayEvent& e)
}
#ifdef JACK_MIDI_DEBUG
- printf("MidiJackDevice::queueEvent time:%d type:%d ch:%d A:%d B:%d\n", e.time(), e.type(), e.channel(), e.dataA(), e.dataB());
+ printf("MidiJackDevice::queueEvent pos:%d fo:%d ft:%d time:%d type:%d ch:%d A:%d B:%d\n", pos, frameOffset, ft, e.time(), e.type(), e.channel(), e.dataA(), e.dataB());
#endif
+ if (MusEGlobal::midiOutputTrace) {
+ printf("MidiOut: Jack: <%s>: ", name().toLatin1().constData());
+ e.dump();
+ }
+
switch(e.type()) {
case ME_NOTEON:
case ME_NOTEOFF:
@@ -698,14 +695,47 @@ bool MidiJackDevice::queueEvent(const MidiPlayEvent& e)
}
break;
case ME_SONGPOS:
+ {
+ #ifdef JACK_MIDI_DEBUG
+ printf("MidiJackDevice::queueEvent songpos %d\n", e.dataA());
+ #endif
+
+ unsigned char* p = jack_midi_event_reserve(pb, ft, 3);
+ if (p == 0) {
+ #ifdef JACK_MIDI_DEBUG
+ fprintf(stderr, "MidiJackDevice::queueEvent songpos: buffer overflow, stopping until next cycle\n");
+ #endif
+ return false;
+ }
+ int pos = e.dataA();
+ p[0] = e.type();
+ p[1] = pos & 0x7f; // LSB
+ p[2] = (pos >> 7) & 0x7f; // MSB
+ }
+ break;
case ME_CLOCK:
case ME_START:
case ME_CONTINUE:
case ME_STOP:
+ {
+ #ifdef JACK_MIDI_DEBUG
+ printf("MidiJackDevice::queueEvent realtime %x\n", e.type());
+ #endif
+
+ unsigned char* p = jack_midi_event_reserve(pb, ft, 1);
+ if (p == 0) {
+ #ifdef JACK_MIDI_DEBUG
+ fprintf(stderr, "MidiJackDevice::queueEvent realtime: buffer overflow, stopping until next cycle\n");
+ #endif
+ return false;
+ }
+ p[0] = e.type();
+ }
+ break;
+ default:
if(MusEGlobal::debugMsg)
printf("MidiJackDevice::queueEvent: event type %x not supported\n", e.type());
- //return false;
- return true; // Absorb the event. Don't want it hanging around in the list. FIXME: Support these? p4.0.15 Tim.
+ return true; // Absorb the event. Don't want it hanging around in the list.
break;
}
@@ -757,12 +787,18 @@ bool MidiJackDevice::processEvent(const MidiPlayEvent& event)
// event.time(), event.type(), event.channel(), event.dataA(), event.dataB(), hb, lb, pr);
if (hb != 0xff)
+ {
if(!queueEvent(MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_HBANK, hb)))
return false; // p4.0.15 Inform that processing the event in general failed. Ditto all below...
+/// t += 1;
+ }
if (lb != 0xff)
- if(!queueEvent(MidiPlayEvent(t+1, port, chn, ME_CONTROLLER, CTRL_LBANK, lb)))
+ {
+ if(!queueEvent(MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_LBANK, lb)))
return false;
- if(!queueEvent(MidiPlayEvent(t+2, port, chn, ME_PROGRAM, pr, 0)))
+/// t += 1;
+ }
+ if(!queueEvent(MidiPlayEvent(t, port, chn, ME_PROGRAM, pr, 0)))
return false;
// }
@@ -815,13 +851,15 @@ bool MidiJackDevice::processEvent(const MidiPlayEvent& event)
{
if(!queueEvent(MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_HBANK, hb)))
return false;
+/// t += 1;
}
if (lb != 0xff)
{
- if(!queueEvent(MidiPlayEvent(t+1, port, chn, ME_CONTROLLER, CTRL_LBANK, lb)))
+ if(!queueEvent(MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_LBANK, lb)))
return false;
+/// t += 1;
}
- if(!queueEvent(MidiPlayEvent(t+2, port, chn, ME_PROGRAM, pr, 0)))
+ if(!queueEvent(MidiPlayEvent(t, port, chn, ME_PROGRAM, pr, 0)))
return false;
// }
@@ -851,7 +889,8 @@ bool MidiJackDevice::processEvent(const MidiPlayEvent& event)
int dataL = b & 0x7f;
if(!queueEvent(MidiPlayEvent(t, port, chn, ME_CONTROLLER, ctrlH, dataH)))
return false;
- if(!queueEvent(MidiPlayEvent(t+1, port, chn, ME_CONTROLLER, ctrlL, dataL)))
+/// t += 1;
+ if(!queueEvent(MidiPlayEvent(t, port, chn, ME_CONTROLLER, ctrlL, dataL)))
return false;
}
else if (a < CTRL_NRPN_OFFSET)
@@ -860,19 +899,22 @@ bool MidiJackDevice::processEvent(const MidiPlayEvent& event)
int ctrlL = a & 0x7f;
if(!queueEvent(MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_HRPN, ctrlH)))
return false;
- if(!queueEvent(MidiPlayEvent(t+1, port, chn, ME_CONTROLLER, CTRL_LRPN, ctrlL)))
+/// t += 1;
+ if(!queueEvent(MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_LRPN, ctrlL)))
return false;
- if(!queueEvent(MidiPlayEvent(t+2, port, chn, ME_CONTROLLER, CTRL_HDATA, b)))
+/// t += 1;
+ if(!queueEvent(MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_HDATA, b)))
return false;
+/// t += 1;
- t += 3;
+ //t += 3;
// Select null parameters so that subsequent data controller events do not upset the last *RPN controller.
//sendNullRPNParams(chn, false);
if(nvh != 0xff)
{
if(!queueEvent(MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_HRPN, nvh & 0x7f)))
return false;
- t += 1;
+/// t += 1;
}
if(nvl != 0xff)
{
@@ -887,18 +929,21 @@ bool MidiJackDevice::processEvent(const MidiPlayEvent& event)
int ctrlL = a & 0x7f;
if(!queueEvent(MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_HNRPN, ctrlH)))
return false;
- if(!queueEvent(MidiPlayEvent(t+1, port, chn, ME_CONTROLLER, CTRL_LNRPN, ctrlL)))
+/// t += 1;
+ if(!queueEvent(MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_LNRPN, ctrlL)))
return false;
- if(!queueEvent(MidiPlayEvent(t+2, port, chn, ME_CONTROLLER, CTRL_HDATA, b)))
+/// t += 1;
+ if(!queueEvent(MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_HDATA, b)))
return false;
+/// t += 1;
- t += 3;
+ //t += 3;
//sendNullRPNParams(chn, true);
if(nvh != 0xff)
{
if(!queueEvent(MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_HNRPN, nvh & 0x7f)))
return false;
- t += 1;
+/// t += 1;
}
if(nvl != 0xff)
{
@@ -914,20 +959,24 @@ bool MidiJackDevice::processEvent(const MidiPlayEvent& event)
int dataL = b & 0x7f;
if(!queueEvent(MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_HRPN, ctrlH)))
return false;
- if(!queueEvent(MidiPlayEvent(t+1, port, chn, ME_CONTROLLER, CTRL_LRPN, ctrlL)))
+/// t += 1;
+ if(!queueEvent(MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_LRPN, ctrlL)))
return false;
- if(!queueEvent(MidiPlayEvent(t+2, port, chn, ME_CONTROLLER, CTRL_HDATA, dataH)))
+/// t += 1;
+ if(!queueEvent(MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_HDATA, dataH)))
return false;
- if(!queueEvent(MidiPlayEvent(t+3, port, chn, ME_CONTROLLER, CTRL_LDATA, dataL)))
+/// t += 1;
+ if(!queueEvent(MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_LDATA, dataL)))
return false;
+/// t += 1;
- t += 4;
+ //t += 4;
//sendNullRPNParams(chn, false);
if(nvh != 0xff)
{
if(!queueEvent(MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_HRPN, nvh & 0x7f)))
return false;
- t += 1;
+/// t += 1;
}
if(nvl != 0xff)
{
@@ -943,20 +992,24 @@ bool MidiJackDevice::processEvent(const MidiPlayEvent& event)
int dataL = b & 0x7f;
if(!queueEvent(MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_HNRPN, ctrlH)))
return false;
- if(!queueEvent(MidiPlayEvent(t+1, port, chn, ME_CONTROLLER, CTRL_LNRPN, ctrlL)))
+/// t += 1;
+ if(!queueEvent(MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_LNRPN, ctrlL)))
return false;
- if(!queueEvent(MidiPlayEvent(t+2, port, chn, ME_CONTROLLER, CTRL_HDATA, dataH)))
+/// t += 1;
+ if(!queueEvent(MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_HDATA, dataH)))
return false;
- if(!queueEvent(MidiPlayEvent(t+3, port, chn, ME_CONTROLLER, CTRL_LDATA, dataL)))
+/// t += 1;
+ if(!queueEvent(MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_LDATA, dataL)))
return false;
+/// t += 1;
- t += 4;
+ //t += 4;
//sendNullRPNParams(chn, true);
if(nvh != 0xff)
{
if(!queueEvent(MidiPlayEvent(t, port, chn, ME_CONTROLLER, CTRL_HNRPN, nvh & 0x7f)))
return false;
- t += 1;
+/// t += 1;
}
if(nvl != 0xff)
{
@@ -988,8 +1041,16 @@ bool MidiJackDevice::processEvent(const MidiPlayEvent& event)
void MidiJackDevice::processMidi()
{
+ //bool stop = stopPending; // Snapshots
+ //bool seek = seekPending; //
+ //seekPending = stopPending = false;
+
processStuckNotes();
+ // Don't process if the device is not assigned to a port.
+ //if(_port == -1)
+ // return;
+
void* port_buf = 0;
if(_out_client_jackport && _writeEnable)
{
@@ -997,65 +1058,294 @@ void MidiJackDevice::processMidi()
jack_midi_clear_buffer(port_buf);
}
+ int port = midiPort();
+ MidiPort* mp = port == -1 ? 0 : &MusEGlobal::midiPorts[port];
+
+ /*
+ bool is_playing = MusEGlobal::audio->isPlaying(); // TODO Check this. It includes LOOP1 and LOOP2 besides PLAY.
+ //bool is_playing = MusEGlobal::audio->isPlaying() || MusEGlobal::audio->isStarting();
+ int pos = MusEGlobal::audio->tickPos();
+ bool ext_sync = MusEGlobal::extSyncFlag.value();
+
+ if(mp)
+ {
+ MidiSyncInfo& si = mp->syncInfo();
+ if(stop)
+ {
+ // Don't send if external sync is on. The master, and our sync routing system will take care of that.
+ if(!ext_sync)
+ {
+ // Shall we check open flags?
+ //if(!(dev->rwFlags() & 0x1) || !(dev->openFlags() & 1))
+ //if(!(dev->openFlags() & 1))
+ // return;
+
+ // Send MMC stop...
+ if(si.MMCOut())
+ {
+ unsigned char msg[mmcStopMsgLen];
+ memcpy(msg, mmcStopMsg, mmcStopMsgLen);
+ msg[1] = si.idOut();
+ putEvent(MidiPlayEvent(0, 0, ME_SYSEX, msg, mmcStopMsgLen));
+ }
+
+ // Send midi stop...
+ if(si.MRTOut())
+ {
+ putEvent(MidiPlayEvent(0, 0, 0, ME_STOP, 0, 0));
+ // Added check of option send continue not start. p3.3.31
+ // Hmm, is this required? Seems to make other devices unhappy.
+ // (Could try now that this is in MidiDevice. p4.0.22 )
+ //if(!si.sendContNotStart())
+ // mp->sendSongpos(MusEGlobal::audio->tickPos() * 4 / config.division);
+ }
+ }
+ }
+
+ if(seek)
+ {
+ // Don't send if external sync is on. The master, and our sync routing system will take care of that.
+ if(!ext_sync)
+ {
+ // Send midi stop and song position pointer...
+ if(si.MRTOut())
+ {
+ // Shall we check for device write open flag to see if it's ok to send?...
+ //if(!(rwFlags() & 0x1) || !(openFlags() & 1))
+ //if(!(openFlags() & 1))
+ // continue;
+ putEvent(MidiPlayEvent(0, 0, 0, ME_STOP, 0, 0));
+ // Hm, try scheduling these for after stuck notes scheduled below...
+ //putEvent(MidiPlayEvent(0, 0, 0, ME_SONGPOS, beat, 0));
+ //if(is_playing)
+ // putEvent(MidiPlayEvent(0, 0, 0, ME_CONTINUE, 0, 0));
+ }
+ }
+ }
+ }
+
+ if(stop || (seek && is_playing))
+ {
+ // Clear all notes and handle stuck notes...
+ _playEvents.clear();
+ for(iMPEvent i = _stuckNotes.begin(); i != _stuckNotes.end(); ++i)
+ {
+ MidiPlayEvent ev = *i;
+ ev.setTime(0); // Schedule immediately.
+ putEvent(ev);
+ }
+ _stuckNotes.clear();
+ }
+
+ if(mp)
+ {
+ MidiSyncInfo& si = mp->syncInfo();
+ // Try scheduling these now for after stuck notes scheduled above...
+ if(stop || seek)
+ {
+ // Reset sustain.
+ for(int ch = 0; ch < MIDI_CHANNELS; ++ch)
+ if(mp->hwCtrlState(ch, CTRL_SUSTAIN) == 127)
+ putEvent(MidiPlayEvent(0, _port, ch, ME_CONTROLLER, CTRL_SUSTAIN, 0));
+ }
+ if(seek)
+ {
+ // Send new song position.
+ if(!ext_sync && si.MRTOut())
+ {
+ int beat = (pos * 4) / MusEGlobal::config.division;
+ putEvent(MidiPlayEvent(0, 0, 0, ME_SONGPOS, beat, 0));
+ }
+ // Send new controller values.
+ MidiCtrlValListList* cll = mp->controller();
+ for(iMidiCtrlValList ivl = cll->begin(); ivl != cll->end(); ++ivl)
+ {
+ MidiCtrlValList* vl = ivl->second;
+ iMidiCtrlVal imcv = vl->iValue(pos);
+ if(imcv != vl->end()) {
+ Part* p = imcv->second.part;
+ // Don't send if part or track is muted or off.
+ if(!p || p->mute())
+ continue;
+ Track* track = p->track();
+ if(track && (track->isMute() || track->off()))
+ continue;
+ unsigned t = (unsigned)imcv->first;
+ // Do not add values that are outside of the part.
+ if(t >= p->tick() && t < (p->tick() + p->lenTick()))
+ // Use sendEvent to get the optimizations and limiting. But force if there's a value at this exact position.
+ mp->sendEvent(MidiPlayEvent(0, _port, ivl->first >> 24, ME_CONTROLLER, vl->num(), imcv->second.val), imcv->first == pos);
+ }
+ }
+ // Send continue.
+ // REMOVE Tim. This is redundant and too early - Audio::startRolling already properly sends it when sync ready.
+ //if(is_playing && !ext_sync && si.MRTOut())
+ // putEvent(MidiPlayEvent(0, 0, 0, ME_CONTINUE, 0, 0));
+ }
+ }
+ */
+
while(!eventFifo.isEmpty())
{
MidiPlayEvent e(eventFifo.peek());
+ //printf("MidiJackDevice::processMidi FIFO event time:%d type:%d ch:%d A:%d B:%d\n", e.time(), e.type(), e.channel(), e.dataA(), e.dataB());
// Try to process only until full, keep rest for next cycle. If no out client port or no write enable, eat up events. p4.0.15
if(port_buf && !processEvent(e))
return; // Give up. The Jack buffer is full. Nothing left to do.
eventFifo.remove(); // Successfully processed event. Remove it from FIFO.
}
+ //if(!(stop || (seek && is_playing)))
+ // processStuckNotes();
+
if(_playEvents.empty())
- {
- //printf("MidiJackDevice::processMidi play events empty\n");
return;
- }
iMPEvent i = _playEvents.begin();
for(; i != _playEvents.end(); ++i)
{
//printf("MidiJackDevice::processMidi playEvent time:%d type:%d ch:%d A:%d B:%d\n", i->time(), i->type(), i->channel(), i->dataA(), i->dataB());
// Update hardware state so knobs and boxes are updated. Optimize to avoid re-setting existing values.
- // Same code as in MidiPort::sendEvent()
- if(_port != -1)
- {
- MidiPort* mp = &MusEGlobal::midiPorts[_port];
- if(i->type() == ME_CONTROLLER)
- {
- int da = i->dataA();
- int db = i->dataB();
- db = mp->limitValToInstrCtlRange(da, db);
- if(!mp->setHwCtrlState(i->channel(), da, db))
- continue;
- //mp->setHwCtrlState(i->channel(), da, db);
- }
- else
- if(i->type() == ME_PITCHBEND)
- {
- //printf("MidiJackDevice::processMidi playEvents ME_PITCHBEND time:%d type:%d ch:%d A:%d B:%d\n", (*i).time(), (*i).type(), (*i).channel(), (*i).dataA(), (*i).dataB());
- int da = mp->limitValToInstrCtlRange(CTRL_PITCH, i->dataA());
- if(!mp->setHwCtrlState(i->channel(), CTRL_PITCH, da))
- continue;
- //mp->setHwCtrlState(i->channel(), CTRL_PITCH, da);
- //(MidiPlayEvent(t, port, chn, ME_PITCHBEND, v & 0x7f, (v >> 7) & 0x7f));
- }
- else
- if(i->type() == ME_PROGRAM)
- {
- if(!mp->setHwCtrlState(i->channel(), CTRL_PROGRAM, i->dataA()))
- continue;
- //mp->setHwCtrlState(i->channel(), CTRL_PROGRAM, i->dataA());
- }
- }
+ if(mp && !mp->sendHwCtrlState(*i, true)) // Force the event to be sent.
+ continue;
// Try to process only until full, keep rest for next cycle. If no out client port or no write enable, eat up events. p4.0.15
if(port_buf && !processEvent(*i))
break;
}
_playEvents.erase(_playEvents.begin(), i);
+}
+
+/*
+//---------------------------------------------------------
+// handleStop
+//---------------------------------------------------------
+
+void MidiJackDevice::handleStop()
+{
+ // If the device is not in use by a port, don't bother it.
+ if(_port == -1)
+ return;
+
+ stopPending = true; // Trigger stop handling in processMidi.
+// //---------------------------------------------------
+// // reset sustain
+// //---------------------------------------------------
+//
+// MidiPort* mp = &MusEGlobal::midiPorts[_port];
+// for(int ch = 0; ch < MIDI_CHANNELS; ++ch)
+// {
+// if(mp->hwCtrlState(ch, CTRL_SUSTAIN) == 127)
+// {
+// //printf("send clear sustain!!!!!!!! port %d ch %d\n", i,ch);
+// MidiPlayEvent ev(0, _port, ch, ME_CONTROLLER, CTRL_SUSTAIN, 0);
+// putEvent(ev);
+// // Do sendEvent to get the optimizations - send only on a change of value.
+// //mp->sendEvent(ev);
+// }
+// }
+
+// //---------------------------------------------------
+// // send midi stop
+// //---------------------------------------------------
+//
+// // Don't send if external sync is on. The master, and our sync routing system will take care of that.
+// if(!MusEGlobal::extSyncFlag.value())
+// {
+// // Shall we check open flags?
+// //if(!(dev->rwFlags() & 0x1) || !(dev->openFlags() & 1))
+// //if(!(dev->openFlags() & 1))
+// // return;
+//
+// MidiSyncInfo& si = mp->syncInfo();
+// if(si.MMCOut())
+// mp->sendMMCStop();
+//
+// if(si.MRTOut())
+// {
+// // Send STOP
+// mp->sendStop();
+//
+// // Added check of option send continue not start. p3.3.31
+// // Hmm, is this required? Seems to make other devices unhappy.
+// // (Could try now that this is in MidiDevice. p4.0.22 )
+// //if(!si.sendContNotStart())
+// // mp->sendSongpos(MusEGlobal::audio->tickPos() * 4 / config.division);
+// }
+// }
+}
+*/
+
+/*
+//---------------------------------------------------------
+// handleSeek
+//---------------------------------------------------------
+
+void MidiJackDevice::handleSeek()
+{
+ // If the device is not in use by a port, don't bother it.
+ if(_port == -1)
+ return;
+
+ seekPending = true; // Trigger seek handling in processMidi.
+
+ //MidiPort* mp = &MusEGlobal::midiPorts[_port];
+ //MidiCtrlValListList* cll = mp->controller();
+ //int pos = MusEGlobal::audio->tickPos();
+
+ //---------------------------------------------------
+ // Send new contoller values
+ //---------------------------------------------------
+
+// for(iMidiCtrlValList ivl = cll->begin(); ivl != cll->end(); ++ivl)
+// {
+// MidiCtrlValList* vl = ivl->second;
+// iMidiCtrlVal imcv = vl->iValue(pos);
+// if(imcv != vl->end())
+// {
+// Part* p = imcv->second.part;
+// //printf("MidiAlsaDevice::handleSeek _port:%d ctl:%d num:%d val:%d\n", _port, ivl->first >> 24, vl->num(), imcv->second.val);
+// unsigned t = (unsigned)imcv->first;
+// // Do not add values that are outside of the part.
+// if(p && t >= p->tick() && t < (p->tick() + p->lenTick()) )
+// // Keep this and the section in processMidi() just in case we need to revert...
+// //_playEvents.add(MidiPlayEvent(0, _port, ivl->first >> 24, ME_CONTROLLER, vl->num(), imcv->second.val));
+// // Hmm, play event list for immediate playback? Try putEvent, putMidiEvent, or sendEvent (for the optimizations) instead.
+// mp->sendEvent(MidiPlayEvent(0, _port, ivl->first >> 24, ME_CONTROLLER, vl->num(), imcv->second.val));
+// }
+// }
+
+ //---------------------------------------------------
+ // Send STOP and "set song position pointer"
+ //---------------------------------------------------
+
+// // Don't send if external sync is on. The master, and our sync routing system will take care of that. p3.3.31
+// if(!MusEGlobal::extSyncFlag.value())
+// {
+// if(mp->syncInfo().MRTOut())
+// {
+// // Shall we check for device write open flag to see if it's ok to send?...
+// // This means obey what the user has chosen for read/write in the midi port config dialog,
+// // which already takes into account whether the device is writable or not.
+// //if(!(rwFlags() & 0x1) || !(openFlags() & 1))
+// //if(!(openFlags() & 1))
+// // continue;
+//
+// int beat = (pos * 4) / MusEGlobal::config.division;
+//
+// //bool isPlaying = (state == PLAY);
+// bool isPlaying = MusEGlobal::audio->isPlaying(); // TODO Check this it includes LOOP1 and LOOP2 besides PLAY. p4.0.22
+//
+// mp->sendStop();
+// mp->sendSongpos(beat);
+// // REMOVE Tim. This is redundant and too early - Audio::startRolling already properly sends it when sync ready.
+// //if(isPlaying)
+// // mp->sendContinue();
+// }
+// }
}
+*/
//---------------------------------------------------------
// initMidiJack
diff --git a/muse2/muse/driver/jackmidi.h b/muse2/muse/driver/jackmidi.h
index d2c14190..c8f7f901 100644
--- a/muse2/muse/driver/jackmidi.h
+++ b/muse2/muse/driver/jackmidi.h
@@ -74,13 +74,15 @@ class MidiJackDevice : public MidiDevice {
public:
MidiJackDevice(const QString& name);
+ virtual ~MidiJackDevice();
static MidiDevice* createJackMidiDevice(QString name = "", int rwflags = 3); // 1:Writable 2: Readable 3: Writable + Readable
virtual inline int deviceType() const { return JACK_MIDI; }
virtual void setName(const QString&);
+ //virtual void handleStop();
+ //virtual void handleSeek();
virtual void processMidi();
- virtual ~MidiJackDevice();
virtual void recordEvent(MidiRecordEvent&);
diff --git a/muse2/muse/driver/rtctimer.cpp b/muse2/muse/driver/rtctimer.cpp
index 365b8501..c50fadf6 100644
--- a/muse2/muse/driver/rtctimer.cpp
+++ b/muse2/muse/driver/rtctimer.cpp
@@ -99,9 +99,9 @@ unsigned int RtcTimer::setTimerFreq(unsigned int freq)
{
int rc = ioctl(timerFd, RTC_IRQP_SET, freq);
if (rc == -1) {
- fprintf(stderr, "RtcTimer::setTimerFreq(): cannot set tick on /dev/rtc: %s\n",
+ fprintf(stderr, "RtcTimer::setTimerFreq(): cannot set freq %d on /dev/rtc: %s\n", freq,
strerror(errno));
- fprintf(stderr, " precise timer not available\n");
+ fprintf(stderr, " precise timer not available, check file permissions and allowed RTC freq (/sys/class/rtc/rtc0/max_user_freq)\n");
return 0;
}
return freq;
diff --git a/muse2/muse/driver/rtctimer.h b/muse2/muse/driver/rtctimer.h
index 425ea643..2b1921a2 100644
--- a/muse2/muse/driver/rtctimer.h
+++ b/muse2/muse/driver/rtctimer.h
@@ -1,12 +1,12 @@
- //=========================================================
- // MusE
- // Linux Music Editor
- // $Id: rtctimer.h,v 1.1.2.3 2005/08/21 18:11:28 spamatica Exp $
- //
- // Most code moved from midiseq.cpp
- //
- // (C) Copyright -2004 Werner Schweer (werner@seh.de)
- // (C) Copyright 2004 Robert Jonsson (rj@spamatica.se)
+//=========================================================
+// MusE
+// Linux Music Editor
+// $Id: rtctimer.h,v 1.1.2.3 2005/08/21 18:11:28 spamatica Exp $
+//
+// Most code moved from midiseq.cpp
+//
+// (C) Copyright -2004 Werner Schweer (werner@seh.de)
+// (C) Copyright 2004 Robert Jonsson (rj@spamatica.se)
//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
@@ -22,7 +22,7 @@
// along with this program; if not, write to the Free Software
// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
//
- //=========================================================
+//=========================================================
#ifndef __RTCTIMER_H__
#define __RTCTIMER_H__
@@ -59,4 +59,4 @@ class RtcTimer : public Timer{
} // namespace MusECore
-#endif //__ALSATIMER_H__
+#endif //__RTCTIMER_H__
diff --git a/muse2/muse/dssihost.cpp b/muse2/muse/dssihost.cpp
index 2e4e6d35..69c6259d 100644
--- a/muse2/muse/dssihost.cpp
+++ b/muse2/muse/dssihost.cpp
@@ -112,19 +112,12 @@ static void scanDSSILib(QFileInfo& fi) // ddskrjo removed const for argument
for(is = MusEGlobal::synthis.begin(); is != MusEGlobal::synthis.end(); ++is)
{
Synth* s = *is;
- //#ifdef DSSI_DEBUG
- // fprintf(stderr, "scanDSSILib: name:%s listname:%s lib:%s listlib:%s\n",
- // label.toLatin1().constData(), s->name().toLatin1().constData(), fi.baseName(true).toLatin1().constData(), s->baseName().toLatin1().constData());
- //#endif
-
if(s->name() == label && s->baseName() == fi.completeBaseName())
break;
}
if(is != MusEGlobal::synthis.end())
- {
- //delete descr;
continue;
- }
+
DssiSynth* s = new DssiSynth(fi, descr);
if(MusEGlobal::debugMsg)
@@ -152,9 +145,6 @@ static void scanDSSILib(QFileInfo& fi) // ddskrjo removed const for argument
MusEGlobal::synthis.push_back(s);
}
- //else
- // delete descr;
-
}
}
dlclose(handle);
@@ -331,12 +321,8 @@ SynthIF* DssiSynth::createSIF(SynthI* synti)
iUsedIdx.clear();
midiCtl2PortMap.clear();
port2MidiCtlMap.clear();
- //synti->_guiUpdateControls.clear();
const LADSPA_Descriptor* descr = dssi->LADSPA_Plugin;
- //#ifdef DSSI_DEBUG
- // printf("DssiSynth::createSIF ladspa plugin PortCount:%lu\n", d->PortCount);
- //#endif
_portCount = descr->PortCount;
@@ -370,8 +356,6 @@ SynthIF* DssiSynth::createSIF(SynthI* synti)
{
rpIdx.push_back(_controlInPorts);
++_controlInPorts;
- // Set to false at first.
- //synti->_guiUpdateControls.push_back(false);
}
else if (LADSPA_IS_PORT_OUTPUT(pd))
{
@@ -403,14 +387,10 @@ SynthIF* DssiSynth::createSIF(SynthI* synti)
++_instances;
sif->init(this);
- //_plugin->incInstances(1);
-
QString guiPath(info.path() + "/" + info.baseName());
QDir guiDir(guiPath, "*", QDir::Unsorted, QDir::Files);
_hasGui = guiDir.exists();
- //sif->initGui();
-
return sif;
}
@@ -418,7 +398,6 @@ SynthIF* DssiSynth::createSIF(SynthI* synti)
// guiVisible
//---------------------------------------------------------
-//bool DssiSynthIF::guiVisible() const
bool DssiSynthIF::nativeGuiVisible() const
{
#ifdef OSC_SUPPORT
@@ -571,7 +550,7 @@ bool DssiSynthIF::init(DssiSynth* s)
#endif
// This code is duplicated in ::getControllerInfo()
- //
+
int ctlnum = DSSI_NONE;
if(dssi->get_midi_controller_for_port)
@@ -890,11 +869,8 @@ void DssiSynthIF::setParameter(unsigned long n, float v)
// write
//---------------------------------------------------------
-//void DssiSynthIF::write(Xml&) const
void DssiSynthIF::write(int level, Xml& xml) const
{
- //bool vstsaved = false;
-
#ifdef DSSI_VST_CHUNK_SUPPORT
if(synth->dssi->getCustomData)
{
@@ -913,16 +889,13 @@ void DssiSynthIF::write(int level, Xml& xml) const
void* p = 0;
synth->dssi->getCustomData(handle,&p, &len);
if (len) {
- //xml.tag(level++, "midistate");
xml.tag(level++, "midistate version=\"%d\"", SYNTH_MIDI_STATE_SAVE_VERSION);
xml.nput(level++, "<event type=\"%d\"", Sysex);
- //xml.nput(" datalen=\"%d\">\n", len+7 /*VSTSAVE*/);
- xml.nput(" datalen=\"%d\">\n", len+9 /* 2 bytes header + "VSTSAVE" */);
+ xml.nput(" datalen=\"%d\">\n", len+9 /* 9 = 2 bytes header + "VSTSAVE"*/);
xml.nput(level, "");
xml.nput("%02x %02x ", (char)MUSE_SYNTH_SYSEX_MFG_ID, (char)DSSI_SYNTH_UNIQUE_ID); // Wrap in a proper header
xml.nput("56 53 54 53 41 56 45 "); // embed a save marker "string 'VSTSAVE'
for (long unsigned int i = 0; i < len; ++i) {
- //if (i && (((i+7) % 16) == 0)) {
if (i && (((i+9) % 16) == 0)) {
xml.nput("\n");
xml.nput(level, "");
@@ -932,14 +905,14 @@ void DssiSynthIF::write(int level, Xml& xml) const
xml.nput("\n");
xml.tag(level--, "/event");
xml.etag(level--, "midistate");
- //vstsaved = true;
}
}
}
#else
printf("support for vst chunks not compiled in!\n");
#endif
-
+
+ // DELETETHIS 97 ???
/*
// p3.3.39 Store the state of current program and bank and all input control values, but only if VSTSAVE above didn't do it already!
// TODO: Not quite good enough, we would want to store all controls for EACH program, not just the current one.
@@ -1040,7 +1013,6 @@ void DssiSynthIF::write(int level, Xml& xml) const
{
float f = controls[c].val;
xml.floatTag(level, "param", f);
- //xml.tag(level, "param name=\"%s\" val=\"%s\"/", name, r->first.c_str(), r->second.c_str());
}
}
@@ -1065,17 +1037,6 @@ bool DssiSynthIF::processEvent(const MusECore::MidiPlayEvent& e, snd_seq_event_t
int chn = e.channel();
int a = e.dataA();
int b = e.dataB();
- //for sysex
- //QByteArray ba = QByteArray((const char*)e.data(), e.len());
- //we must had 0xF0 at the beginning and 0xF7 at the end of e.data()
- //ba.push_front(0xF0);
- //ba.push_back(0xF7);
-
- //QByteArray ba();
- ////ba.assign((const char*)e.data(), e.len());
- ////ba.duplicate((const char*)e.data(), e.len());
- ////ba.setRawData((const char*)e.data(), e.len());
- //int len = e.len() + 2;
int len = e.len();
char ca[len + 2];
@@ -1117,8 +1078,6 @@ bool DssiSynthIF::processEvent(const MusECore::MidiPlayEvent& e, snd_seq_event_t
int bank = (a >> 8) & 0xff;
int prog = a & 0xff;
- //_curBank = bank;
- //_curProgram = prog;
synti->_curBankH = 0;
synti->_curBankL = bank;
synti->_curProgram = prog;
@@ -1187,29 +1146,12 @@ bool DssiSynthIF::processEvent(const MusECore::MidiPlayEvent& e, snd_seq_event_t
// For example sustain footpedal or pitch bend may be supported, but not mapped to any LADSPA port.
if(ip == synth->midiCtl2PortMap.end())
{
- // p3.3.39 Changed to return false because of crashes with unknown controllers when switching a midi track
- // among different dssi synths and regular synths etc. For example high RPN offset numbers (set by another
- // device selected into the midi port before selecting this synth) were passing through here when in fact
- // the particular synth had no such midi controllers.
- // No, that leaves out regular controllers like footpedal
- //#ifdef DSSI_DEBUG
- //fprintf(stderr, "DssiSynthIF::processEvent dataA:%d not found in map (not a ladspa controller). Ignoring.\n", a);
- //#endif
- //return false;
-
- //#ifdef DSSI_DEBUG
- //fprintf(stderr, "DssiSynthIF::processEvent dataA:%d not found in map (not a ladspa controller). Filling event as regular controller.\n", a);
- //#endif
- //snd_seq_ev_set_controller(event, chn, a, b);
- //return true;
-
int ctlnum = a;
if(MusECore::midiControllerType(a) != MusECore::MidiController::Controller7)
return false; // Event pointer not filled. Return false.
else
{
#ifdef DSSI_DEBUG
- //fprintf(stderr, "DssiSynthIF::processEvent midi event is Controller7. Changing to DSSI_CC type. Current dataA:%d\n", a);
fprintf(stderr, "DssiSynthIF::processEvent non-ladspa midi event is Controller7. Current dataA:%d\n", a);
#endif
a &= 0x7f;
@@ -1239,12 +1181,6 @@ bool DssiSynthIF::processEvent(const MusECore::MidiPlayEvent& e, snd_seq_event_t
if(k > synth->_controlInPorts)
return false;
- // TODO: If necessary... choose non-existing numbers...
- //for(int k = 0; k < controlPorts; ++k)
- //{
- // int i = synth->pIdx[k];
- //}
-
// Simple but flawed solution: Start them at 0x60000 + 0x2000 = 0x62000. Max NRPN number is 0x3fff.
ctlnum = k + (MusECore::CTRL_NRPN14_OFFSET + 0x2000);
}
@@ -1284,14 +1220,13 @@ bool DssiSynthIF::processEvent(const MusECore::MidiPlayEvent& e, snd_seq_event_t
float val = midi2LadspaValue(ld, i, ctlnum, b);
#ifdef DSSI_DEBUG
- //fprintf(stderr, "DssiSynthIF::processEvent No midi controller for control port:%d port:%d dataA:%d Converting val from:%d to ladspa:%f\n", i, k, a, b, val);
fprintf(stderr, "DssiSynthIF::processEvent control port:%lu port:%lu dataA:%d Converting val from:%d to ladspa:%f\n", i, k, a, b, val);
#endif
// Set the ladspa port value.
controls[k].val = val;
// FIXME: Testing - Works but is this safe in a RT process callback? Try hooking into gui heartbeat timer instead...
- //lo_send(uiTarget, uiOscControlPath, "if", i, val);
+ // lo_send(uiTarget, uiOscControlPath, "if", i, val);
// Notify that changes are to be sent upon heartbeat.
synti->_guiUpdateControls[k] = true;
@@ -1324,14 +1259,11 @@ bool DssiSynthIF::processEvent(const MusECore::MidiPlayEvent& e, snd_seq_event_t
{
if(e.len() >= 9)
{
- //if (QString((const char*)e.data()).startsWith("VSTSAVE")) {
if (QString((const char*)(data + 2)).startsWith("VSTSAVE")) {
#ifdef DSSI_VST_CHUNK_SUPPORT
if(dssi->setCustomData)
{
- //printf("loading chunk from sysex %s!\n", e.data()+7);
printf("loading chunk from sysex %s!\n", data+9);
- //dssi->setCustomData(handle, e.data()+7 /* len of str*/,e.len()-7);
dssi->setCustomData(handle, (unsigned char*)(data+9) /* len of str*/,e.len()-9);
}
#else
@@ -1344,6 +1276,8 @@ bool DssiSynthIF::processEvent(const MusECore::MidiPlayEvent& e, snd_seq_event_t
}
}
}
+
+ // DELETETHIS, 50 clean it up or fix it?
/*
// p3.3.39 Read the state of current bank and program and all input control values.
// TODO: Needs to be better. See write().
@@ -1408,7 +1342,6 @@ bool DssiSynthIF::processEvent(const MusECore::MidiPlayEvent& e, snd_seq_event_t
snd_seq_ev_clear(event);
event->queue = SND_SEQ_QUEUE_DIRECT;
snd_seq_ev_set_sysex(event, len,
- //(unsigned char*)ba.data());
(unsigned char*)ca);
}
}
@@ -1430,18 +1363,9 @@ bool DssiSynthIF::processEvent(const MusECore::MidiPlayEvent& e, snd_seq_event_t
MusECore::iMPEvent DssiSynthIF::getData(MusECore::MidiPort* /*mp*/, MusECore::MPEventList* el, MusECore::iMPEvent start_event, unsigned pos, int ports, unsigned nframes, float** buffer)
{
- //#ifdef DSSI_DEBUG
- // fprintf(stderr, "DssiSynthIF::getData elsize:%d pos:%d ports:%d samples:%d processed already?:%d\n", el->size(), pos, ports, n, synti->processed());
- //#endif
-
- // Grab the control ring buffer size now.
- //const int cbsz = _controlFifo.getSize();
-
// We may not be using nevents all at once - this will be just the maximum.
unsigned long nevents = el->size() + synti->eventFifo.getSize();
snd_seq_event_t events[nevents];
- // No, do this in processEvent.
- //memset(events, 0, sizeof(events));
int frameOffset = MusEGlobal::audio->getFrameOffset();
unsigned long syncFrame = MusEGlobal::audio->curSyncFrame();
@@ -1449,15 +1373,11 @@ MusECore::iMPEvent DssiSynthIF::getData(MusECore::MidiPort* /*mp*/, MusECore::MP
// All ports must be connected to something!
unsigned long nop, k;
- // Watch our limits.
- //willyfoobar-2011-02-13
- //old code//np = ports > synth->_outports ? synth->_outports : ports;
nop = ((unsigned long) ports) > synth->_outports ? synth->_outports : ((unsigned long) ports);
const DSSI_Descriptor* dssi = synth->dssi;
const LADSPA_Descriptor* descr = dssi->LADSPA_Plugin;
unsigned long sample = 0;
- int loopcount = 0; // REMOVE Tim.
// To remember the last retrieved value of each AudioTrack controller.
//float prev_ctrl_values[synth->_controlInPorts];
@@ -1503,12 +1423,7 @@ MusECore::iMPEvent DssiSynthIF::getData(MusECore::MidiPort* /*mp*/, MusECore::MP
{
RouteList* irl = ((MusECore::AudioTrack*)synti)->inRoutes();
iRoute i = irl->begin();
- if(i->track->isMidiTrack())
- {
- //if(MusEGlobal::debugMsg)
- //printf("DssiSynthIF::getData: Error: First route is a midi track route!\n");
- }
- else
+ if(!i->track->isMidiTrack())
{
int ch = i->channel == -1 ? 0 : i->channel;
int remch = i->remoteChannel == -1 ? 0 : i->remoteChannel;
@@ -1516,14 +1431,9 @@ MusECore::iMPEvent DssiSynthIF::getData(MusECore::MidiPort* /*mp*/, MusECore::MP
if((unsigned)ch < synth->_inports && (unsigned)(ch + chs) <= synth->_inports)
{
- //printf("DssiSynthIF::getData calling copyData on %s ch:%d remch:%d chs:%d\n", i->track->name().toLatin1().constData(), ch, remch, chs);
-
int h = remch + chs;
for(int j = remch; j < h; ++j)
- {
- //printf(" setting used idx:%d\n", j);
synth->iUsedIdx[j] = true;
- }
((MusECore::AudioTrack*)i->track)->copyData(pos, chs, ch, -1, nframes, &audioInBuffers[remch]);
}
@@ -1533,11 +1443,7 @@ MusECore::iMPEvent DssiSynthIF::getData(MusECore::MidiPort* /*mp*/, MusECore::MP
for(; i != irl->end(); ++i)
{
if(i->track->isMidiTrack())
- {
- //if(MusEGlobal::debugMsg)
- // printf("DssiSynthIF::getData: Error: Route is a midi track route!\n");
continue;
- }
int ch = i->channel == -1 ? 0 : i->channel;
int remch = i->remoteChannel == -1 ? 0 : i->remoteChannel;
@@ -1545,8 +1451,6 @@ MusECore::iMPEvent DssiSynthIF::getData(MusECore::MidiPort* /*mp*/, MusECore::MP
if((unsigned)ch < synth->_inports && (unsigned)(ch + chs) <= synth->_inports)
{
- //printf("DssiSynthIF::getData calling addData on %s ch:%d remch:%d chs:%d\n", i->track->name().toLatin1().constData(), ch, remch, chs);
-
bool u1 = synth->iUsedIdx[remch];
if(chs >= 2)
{
@@ -1579,10 +1483,7 @@ MusECore::iMPEvent DssiSynthIF::getData(MusECore::MidiPort* /*mp*/, MusECore::MP
int h = remch + chs;
for(int j = remch; j < h; ++j)
- {
- //printf(" setting used idx:%d\n", j);
synth->iUsedIdx[j] = true;
- }
}
}
}
@@ -1600,22 +1501,17 @@ MusECore::iMPEvent DssiSynthIF::getData(MusECore::MidiPort* /*mp*/, MusECore::MP
while(sample < nframes)
{
- //unsigned long nsamp = n;
- //unsigned long nsamp = n - sample;
unsigned long nsamp = usefixedrate ? fixedsize : nframes - sample;
bool found = false;
unsigned long frame = 0;
unsigned long index = 0;
unsigned long evframe;
// Get all control ring buffer items valid for this time period...
- //for(int m = 0; m < cbsz; ++m) // Doesn't like this. Why?
while(!_controlFifo.isEmpty())
{
- //ControlValue v = _controlFifo.get();
ControlEvent v = _controlFifo.peek();
// The events happened in the last period or even before that. Shift into this period with + n. This will sync with MusEGlobal::audio.
// If the events happened even before current frame - n, make sure they are counted immediately as zero-frame.
- //evframe = (pos + frameOffset > v.frame + n) ? 0 : v.frame - pos - frameOffset + n;
evframe = (syncFrame > v.frame + nframes) ? 0 : v.frame - syncFrame + nframes;
// Protection. Observed this condition. Why? Supposed to be linear timestamps.
if(found && evframe < frame)
@@ -1626,34 +1522,14 @@ MusECore::iMPEvent DssiSynthIF::getData(MusECore::MidiPort* /*mp*/, MusECore::MP
evframe = frame;
}
- //printf("DssiSynthIF::getData ctrl dssi:%d idx:%lu frame:%lu val:%f unique:%d evframe:%lu\n",
- // synth->_isDssiVst, v.idx, v.frame, v.value, v.unique, evframe); // REMOVE Tim.
- // Process only items in this time period. Make sure to process all
- // subsequent items which have the same frame.
- //if(v.frame >= (endPos + frameOffset) || (found && v.frame != frame))
- //if(v.frame < sample || v.frame >= (sample + nsamp) || (found && v.frame != frame))
- //if(v.frame < sample || v.frame >= (endPos + frameOffset) || (found && v.frame != frame))
- //if(v.frame < startPos || v.frame >= (endPos + frameOffset)
- //if(evframe < sample || evframe >= n
- //if(evframe < sample || evframe >= (n + frameOffset)
if(evframe >= nframes
- //|| (found && v.frame != frame)
- //|| (!usefixedrate && found && !v.unique && v.frame != frame)
- //|| (found && !v.unique && evframe != frame)
- // Not enough requested samples to satisfy minimum setting? Keep going.
|| (found && !v.unique && (evframe - sample >= min_per))
- // dssi-vst needs them serialized and accounted for, no matter what. This works with fixed rate
- // because nsamp is constant. But with packets, we need to guarantee at least one-frame spacing.
- // Although we likely won't be using packets with dssi-vst, so it's OK for now.
- //|| (found && v.idx == index))
- //|| (usefixedrate && found && v.idx == index)) // Try this.
- || (usefixedrate && found && v.unique && v.idx == index)) //
+ || (usefixedrate && found && v.unique && v.idx == index))
break;
_controlFifo.remove(); // Done with the ring buffer's item. Remove it.
if(v.idx >= synth->_controlInPorts) // Sanity check.
break;
found = true;
- //frame = v.frame;
frame = evframe;
index = v.idx;
// Set the ladspa control port value.
@@ -1664,9 +1540,9 @@ MusECore::iMPEvent DssiSynthIF::getData(MusECore::MidiPort* /*mp*/, MusECore::MP
{
// Since we are now in the audio thread context, there's no need to send a message,
// just modify directly.
- //MusEGlobal::audio->msgSetPluginCtrlVal(_track, genACnum(_id, k), controls[k].val);
synti->setPluginCtrlVal(genACnum(id(), v.idx), v.value);
+ // DELETETHIS 15, cleanup, fix, maybe just keep it? dunno.
// Record automation.
// NO! Take care of this immediately in the OSC control handler, because we don't want
// any delay.
@@ -1685,6 +1561,7 @@ MusECore::iMPEvent DssiSynthIF::getData(MusECore::MidiPort* /*mp*/, MusECore::MP
}
+ // DELETETHIS 10 ?
// Process automation control values now.
//if(MusEGlobal::automation && synti && synti->automationType() != AUTO_OFF && id() != -1)
//{
@@ -1695,16 +1572,11 @@ MusECore::iMPEvent DssiSynthIF::getData(MusECore::MidiPort* /*mp*/, MusECore::MP
// }
//}
- //if(found)
if(found && !usefixedrate)
- //nsamp = frame - sample + 1;
nsamp = frame - sample;
if(sample + nsamp >= nframes) // Safety check.
nsamp = nframes - sample;
- //printf("DssiSynthIF::getData n:%d frame:%lu sample:%lu nsamp:%lu pos:%d fOffset:%d syncFrame:%lu loopcount:%d\n",
- // n, frame, sample, nsamp, pos, frameOffset, syncFrame, loopcount); // REMOVE Tim.
-
// TODO: TESTING: Don't allow zero-length runs. This could/should be checked in the control loop instead.
// Note this means it is still possible to get stuck in the top loop (at least for a while).
if(nsamp == 0)
@@ -1714,7 +1586,6 @@ MusECore::iMPEvent DssiSynthIF::getData(MusECore::MidiPort* /*mp*/, MusECore::MP
// Process event list events...
for(; start_event != el->end(); ++start_event)
{
- //if(i->time() >= (endPos + frameOffset)) // NOTE: frameOffset? Tested, examined printouts of times: Seems OK for playback.
if(start_event->time() >= (pos + sample + nsamp + frameOffset)) // frameOffset? Test again...
break;
@@ -1757,12 +1628,10 @@ MusECore::iMPEvent DssiSynthIF::getData(MusECore::MidiPort* /*mp*/, MusECore::MP
int ft = start_event->time() - frameOffset - pos;
if(ft < 0)
ft = 0;
- //if (ft >= (int)MusEGlobal::segmentSize)
+
if (ft >= int(sample + nsamp))
{
- printf("DssiSynthIF::getData: eventlist event time:%d out of range. pos:%d offset:%d ft:%d sample:%lu nsamp:%lu\n", start_event->time(), pos, frameOffset, ft, sample, nsamp);
- ///if (ft > (int)MusEGlobal::segmentSize)
- //ft = MusEGlobal::segmentSize - 1;
+ printf("DssiSynthIF::getData: eventlist event time:%d out of range. pos:%d offset:%d ft:%d sample:%lu nsamp:%lu\n", start_event->time(), pos, frameOffset, ft, sample, nsamp);
ft = sample + nsamp - 1;
}
// "Each event is timestamped relative to the start of the block, (mis)using the ALSA "tick time" field as a frame count.
@@ -1776,14 +1645,12 @@ MusECore::iMPEvent DssiSynthIF::getData(MusECore::MidiPort* /*mp*/, MusECore::MP
// Now process putEvent events...
while(!synti->eventFifo.isEmpty())
{
- //MusECore::MidiPlayEvent e = synti->eventFifo.get();
MusECore::MidiPlayEvent e = synti->eventFifo.peek();
#ifdef DSSI_DEBUG
fprintf(stderr, "DssiSynthIF::getData eventFifo event time:%d\n", e.time());
#endif
- //if(e.time() >= (endPos + frameOffset))
if(e.time() >= (pos + sample + nsamp + frameOffset))
break;
@@ -1795,13 +1662,9 @@ MusECore::iMPEvent DssiSynthIF::getData(MusECore::MidiPort* /*mp*/, MusECore::MP
int ft = e.time() - frameOffset - pos;
if(ft < 0)
ft = 0;
- //if (ft >= (int)MusEGlobal::segmentSize)
if (ft >= int(sample + nsamp))
{
- //printf("DssiSynthIF::getData: eventFifo event time:%d out of range. pos:%d offset:%d ft:%d (seg=%d)\n", e.time(), pos, frameOffset, ft, MusEGlobal::segmentSize);
- printf("DssiSynthIF::getData: eventFifo event time:%d out of range. pos:%d offset:%d ft:%d sample:%lu nsamp:%lu\n", e.time(), pos, frameOffset, ft, sample, nsamp);
- ///if (ft > (int)MusEGlobal::segmentSize)
- //ft = MusEGlobal::segmentSize - 1;
+ printf("DssiSynthIF::getData: eventFifo event time:%d out of range. pos:%d offset:%d ft:%d sample:%lu nsamp:%lu\n", e.time(), pos, frameOffset, ft, sample, nsamp);
ft = sample + nsamp - 1;
}
// "Each event is timestamped relative to the start of the block, (mis)using the ALSA "tick time" field as a frame count.
@@ -1822,7 +1685,6 @@ MusECore::iMPEvent DssiSynthIF::getData(MusECore::MidiPort* /*mp*/, MusECore::MP
// Connect all inputs either to some local buffers, or a silence buffer.
for(k = 0; k < synth->_inports; ++k)
{
- //printf(" k:%d synth->iIdx[k]:%d\n", k, synth->iIdx[k]);
if(synth->iUsedIdx[k])
{
synth->iUsedIdx[k] = false; // Reset
@@ -1830,7 +1692,6 @@ MusECore::iMPEvent DssiSynthIF::getData(MusECore::MidiPort* /*mp*/, MusECore::MP
}
else
{
- //printf(" input used size:%ld idx:%ld = %d silencing...\n", synth->iUsedIdx.size(), k, synth->iUsedIdx[k]);
descr->connect_port(handle, synth->iIdx[k], audioInSilenceBuf + sample);
}
}
@@ -1853,7 +1714,6 @@ MusECore::iMPEvent DssiSynthIF::getData(MusECore::MidiPort* /*mp*/, MusECore::MP
//}
sample += nsamp;
- loopcount++; // REMOVE Tim.
}
return start_event;
@@ -1871,7 +1731,6 @@ bool DssiSynthIF::putEvent(const MusECore::MidiPlayEvent& ev)
if (MusEGlobal::midiOutputTrace)
ev.dump();
return synti->eventFifo.put(ev);
- //return false;
}
//---------------------------------------------------------
@@ -1900,7 +1759,6 @@ void DssiSynth::incInstances(int val)
iUsedIdx.clear();
midiCtl2PortMap.clear();
port2MidiCtlMap.clear();
- //synti->_guiUpdateControls.clear();
}
}
@@ -1991,8 +1849,6 @@ int DssiSynthIF::oscProgram(unsigned long program, unsigned long bank)
int ch = 0; // TODO: ??
int port = synti->midiPort();
- //_curBank = bank;
- //_curProgram = program;
synti->_curBankH = 0;
synti->_curBankL = bank;
synti->_curProgram = program;
@@ -2000,11 +1856,8 @@ int DssiSynthIF::oscProgram(unsigned long program, unsigned long bank)
bank &= 0xff;
program &= 0xff;
- //MidiEvent event(0, ch, MusECore::ME_CONTROLLER, MusECore::CTRL_PROGRAM, (bank << 8) + program);
-
if(port != -1)
{
- //MusECore::MidiPlayEvent event(0, port, ch, MusECore::ME_CONTROLLER, MusECore::CTRL_PROGRAM, (bank << 8) + program);
MusECore::MidiPlayEvent event(0, port, ch, MusECore::ME_PROGRAM, (bank << 8) + program, 0);
#ifdef DSSI_DEBUG
@@ -2014,7 +1867,7 @@ int DssiSynthIF::oscProgram(unsigned long program, unsigned long bank)
MusEGlobal::midiPorts[port].sendEvent(event);
}
- //synti->playMidiEvent(&event); // TODO
+ //synti->playMidiEvent(&event); // TODO DELETETHIS 7 hasn't changed since r462
//
//MidiDevice* md = dynamic_cast<MidiDevice*>(synti);
//if(md)
@@ -2050,11 +1903,12 @@ int DssiSynthIF::oscControl(unsigned long port, float value)
return 0;
}
+ // DELETETHIS????: is the below still correct? of so, then keep it of course!
// p3.3.39 Set the DSSI control input port's value.
// Observations: With a native DSSI synth like LessTrivialSynth, the native GUI's controls do not change the sound at all
// ie. they don't update the DSSI control port values themselves.
// Hence in response to the call to this oscControl, sent by the native GUI, it is required to that here.
-/// controls[cport].val = value;
+/// controls[cport].val = value; DELETETHIS
// DSSI-VST synths however, unlike DSSI synths, DO change their OWN sound in response to their gui controls.
// AND this function is called.
// Despite the descrepency we are STILL required to update the DSSI control port values here
@@ -2071,6 +1925,7 @@ int DssiSynthIF::oscControl(unsigned long port, float value)
// (Because the server simply ignores the 'expected' messages.)
//
// Well, at least here are the fifos. Try this ...
+ // DELETETHIS 20 pretty old as well
/*
OscControlFifo* cfifo = _oscif.oscFifo(cport);
if(cfifo)
@@ -2093,13 +1948,12 @@ int DssiSynthIF::oscControl(unsigned long port, float value)
ce.unique = synth->_isDssiVst; // Special for messages from vst gui to host - requires processing every message.
ce.idx = cport;
ce.value = value;
- // Time-stamp the event. This does a possibly slightly slow call to gettimeofday via timestamp().
- // timestamp() is more or less an estimate of the current frame. (This is exactly how ALSA events
- // are treated when they arrive in our ALSA driver.)
- //ce.frame = MusEGlobal::audio->timestamp();
- // p4.0.23 timestamp() is circular, which is making it impossible to deal with 'modulo' events which
- // slip in 'under the wire' before processing the ring buffers. So try this linear timestamp instead:
- ce.frame = MusEGlobal::audio->curFrame();
+
+ ce.frame = MusEGlobal::audio->curFrame();
+ // don't use timestamp(), because it's circular, which is making it impossible to deal
+ // with 'modulo' events which slip in 'under the wire' before processing the ring buffers.
+
+
if(_controlFifo.put(ce))
{
fprintf(stderr, "DssiSynthIF::oscControl: fifo overflow: in control number:%lu\n", cport);
@@ -2113,7 +1967,6 @@ int DssiSynthIF::oscControl(unsigned long port, float value)
// That makes this pretty useless... But what the heck...
if(id() != -1)
{
- //int id = genACnum(_id, cport);
unsigned long pid = genACnum(id(), cport);
AutomationType at = synti->automationType();
@@ -2126,17 +1979,6 @@ int DssiSynthIF::oscControl(unsigned long port, float value)
synti->recordAutomation(pid, value);
}
- //MusECore::ciMidiCtl2LadspaPort ip = synth->port2MidiCtlMap.find(cport);
- //if(ip != synth->port2MidiCtlMap.end())
- //{
- // TODO: TODO: Update midi MusE's midi controller knobs, sliders, boxes etc with a call to the midi port's setHwCtrlState() etc.
- // But first we need a ladspa2MidiValue() function! ...
- //
- //
- //float val = ladspa2MidiValue(ld, i, ?, ?);
-
- //}
-
return 0;
}
@@ -2164,15 +2006,6 @@ int DssiSynthIF::oscMidi(int a, int b, int c)
MusEGlobal::midiPorts[port].sendEvent(event);
}
- //synti->playMidiEvent(&event); // TODO
- //
- //MidiDevice* md = dynamic_cast<MidiDevice*>(synti);
- //if(md)
- // md->putEvent(event);
- //
- //synti->putEvent(event);
- //
-
return 0;
}
@@ -2217,6 +2050,7 @@ int DssiSynthIF::oscConfigure(const char *key, const char *value)
free(message);
}
+ // DELETETHIS 6 ???
// "also call back on UIs for plugins other than the one
// that requested this:"
// if (n != instance->number && instances[n].uiTarget) {
@@ -2262,7 +2096,6 @@ void DssiSynthIF::queryPrograms()
// getPatchName
//---------------------------------------------------------
-//QString DssiSynthIF::getPatchName(int, int prog)
const char* DssiSynthIF::getPatchName(int /*chan*/, int prog, MType /*type*/, bool /*drum*/)
{
unsigned program = prog & 0x7f;
@@ -2315,12 +2148,6 @@ int DssiSynthIF::getControllerInfo(int id, const char** name, int* ctrl, int* mi
const DSSI_Descriptor* dssi = synth->dssi;
const LADSPA_Descriptor* ld = dssi->LADSPA_Plugin;
- // Hmm, <map> has a weird [] operator. Would it work?
- // For now just use duplicate code found in ::init()
- //iMidiCtl2LadspaPort ip = midiCtl2PortMap[id];
- //int ctlnum = ip->first;
- //int k = ip->second;
-
unsigned long i = controls[id].idx;
#ifdef DSSI_DEBUG
@@ -2335,12 +2162,6 @@ int DssiSynthIF::getControllerInfo(int id, const char** name, int* ctrl, int* mi
// No controller number? Give it one.
if(ctlnum == DSSI_NONE)
{
- // TODO: If neccesary... choose non-existing numbers...
- //for(int k = 0; k < controlPorts; ++k)
- //{
- // int i = synth->pIdx[k];
- //}
-
// Simple but flawed solution: Start them at 0x60000 + 0x2000 = 0x62000. Max NRPN number is 0x3fff.
ctlnum = MusECore::CTRL_NRPN14_OFFSET + 0x2000 + id;
}
@@ -2393,9 +2214,6 @@ int DssiSynthIF::getControllerInfo(int id, const char** name, int* ctrl, int* mi
int DssiSynthIF::channels() const
{
- //willyfoobar-2011-02-13
- //!! either change return type to unsigend long or do this change
- //old code //return synth->_outports > MAX_CHANNELS ? MAX_CHANNELS : synth->_outports;
return ((int)synth->_outports) > MAX_CHANNELS ? MAX_CHANNELS : ((int)synth->_outports) ;
}
diff --git a/muse2/muse/dssihost.h b/muse2/muse/dssihost.h
index 2836d72e..1166886a 100644
--- a/muse2/muse/dssihost.h
+++ b/muse2/muse/dssihost.h
@@ -26,15 +26,21 @@
#include "config.h"
-#include <vector>
-#include <map>
-#include <string>
-
// Make sure this number is unique among all the MESS synths and DSSI host synth.
#define DSSI_SYNTH_UNIQUE_ID 8
// Midistate sysex initialization command.
#define DSSI_INIT_DATA_CMD 1
+#define DSSI_PARAMSAVE_VERSION_MAJOR 0
+#define DSSI_PARAMSAVE_VERSION_MINOR 1
+
+
+#ifdef DSSI_SUPPORT
+
+#include <vector>
+#include <map>
+#include <string>
+
#ifdef OSC_SUPPORT
#include <lo/lo.h>
#include "osc.h"
@@ -42,6 +48,7 @@
#include "ladspa.h"
#include <dssi.h>
+
#include <alsa/asoundlib.h>
#include "midictrl.h"
@@ -53,15 +60,15 @@
//#include <QMenu>
#include "popupmenu.h"
-#define DSSI_PARAMSAVE_VERSION_MAJOR 0
-#define DSSI_PARAMSAVE_VERSION_MINOR 1
+#endif // DSSI_SUPPORT
namespace MusECore {
+#ifdef DSSI_SUPPORT
+
struct _DSSI;
class DssiPluginIF;
-//class LadspaPort;
class Port;
//---------------------------------------------------------
@@ -76,7 +83,6 @@ class DssiSynth : public Synth {
unsigned long _portCount, _inports, _outports, _controlInPorts, _controlOutPorts;
std::vector<unsigned long> iIdx; // Audio input index to port number.
std::vector<unsigned long> oIdx; // Audio output index to port number.
- //std::vector<bool> iUsedIdx; // During process, tells whether an audio input port was used by any input routes.
std::vector<int> iUsedIdx; // During process, tells whether an audio input port was used by any input routes.
std::vector<unsigned long> rpIdx; // Port number to control input index. Item is -1 if it's not a control input.
MusECore::MidiCtl2LadspaPortMap midiCtl2PortMap; // Maps midi controller numbers to DSSI port numbers.
@@ -95,7 +101,6 @@ class DssiSynth : public Synth {
virtual SynthIF* createSIF(SynthI*);
friend class DssiSynthIF;
- //float defaultValue(int); // Not required
unsigned long inPorts() const { return _inports; }
unsigned long outPorts() const { return _outports; }
unsigned long inControls() const { return _controlInPorts; }
@@ -179,19 +184,18 @@ class DssiSynthIF : public SynthIF, public PluginIBase
#ifdef OSC_SUPPORT
OscDssiIF& oscIF() { return _oscif; }
- int oscProgram(unsigned long /*prog*/, unsigned long /*bank*/);
- int oscControl(unsigned long /*dssiPort*/, float /*val*/);
- int oscMidi(int /*a*/, int /*b*/, int /*c*/);
- int oscConfigure(const char */*key*/, const char */*val*/);
+ int oscProgram(unsigned long prog, unsigned long bank);
+ int oscControl(unsigned long dssiPort, float val);
+ int oscMidi(int a, int b, int c);
+ int oscConfigure(const char *key, const char *val);
int oscUpdate();
- //int oscExiting();
#endif
//-------------------------
// Methods for PluginIBase:
//-------------------------
bool on() const;
- void setOn(bool /*val*/);
+ void setOn(bool val);
unsigned long pluginID();
int id();
QString pluginLabel() const;
@@ -201,28 +205,30 @@ class DssiSynthIF : public SynthIF, public PluginIBase
QString fileName() const;
QString titlePrefix() const;
MusECore::AudioTrack* track();
- void enableController(unsigned long /*i*/, bool v = true);
- bool controllerEnabled(unsigned long /*i*/) const;
- bool controllerEnabled2(unsigned long /*i*/) const;
+ void enableController(unsigned long i, bool v = true);
+ bool controllerEnabled(unsigned long i) const;
+ bool controllerEnabled2(unsigned long i) const;
void updateControllers();
- void writeConfiguration(int /*level*/, Xml& /*xml*/);
- bool readConfiguration(Xml& /*xml*/, bool readPreset=false);
+ void writeConfiguration(int level, Xml& xml);
+ bool readConfiguration(Xml& xml, bool readPreset=false);
unsigned long parameters() const;
unsigned long parametersOut() const;
- void setParam(unsigned long /*i*/, float /*val*/);
- float param(unsigned long /*i*/) const;
- float paramOut(unsigned long /*i*/) const;
- const char* paramName(unsigned long /*i*/);
- const char* paramOutName(unsigned long /*i*/);
- LADSPA_PortRangeHint range(unsigned long /*i*/);
- LADSPA_PortRangeHint rangeOut(unsigned long /*i*/);
- CtrlValueType ctrlValueType(unsigned long /*i*/) const;
- CtrlList::Mode ctrlMode(unsigned long /*i*/) const;
+ void setParam(unsigned long i, float val);
+ float param(unsigned long i) const;
+ float paramOut(unsigned long i) const;
+ const char* paramName(unsigned long i);
+ const char* paramOutName(unsigned long i);
+ LADSPA_PortRangeHint range(unsigned long i);
+ LADSPA_PortRangeHint rangeOut(unsigned long i);
+ CtrlValueType ctrlValueType(unsigned long i) const;
+ CtrlList::Mode ctrlMode(unsigned long i) const;
friend class DssiSynth;
};
+#endif // DSSI_SUPPORT
+
extern void initDSSI();
} // namespace MusECore
diff --git a/muse2/muse/evdata.h b/muse2/muse/evdata.h
index 333a5e2d..f180cf28 100644
--- a/muse2/muse/evdata.h
+++ b/muse2/muse/evdata.h
@@ -25,7 +25,6 @@
#define __EVDATA_H__
#include <string.h>
-// #include <memory.h>
namespace MusECore {
diff --git a/muse2/muse/event.cpp b/muse2/muse/event.cpp
index 2993b286..6ea1b852 100644
--- a/muse2/muse/event.cpp
+++ b/muse2/muse/event.cpp
@@ -239,11 +239,6 @@ void Event::setSndFile(MusECore::SndFileR& sf)
#ifdef USE_SAMPLERATE
if(_audConv)
{
- // Do we release? Or keep the converter around, while gaining speed since no rapid creation/destruction.
- //if(sf.isNull())
- // _audConv = AudioConverter::release(_audConv);
- //else
- // _audConv->setChannels(sf.channels());
if(!sf.isNull())
_audConv->setChannels(sf.channels());
}
diff --git a/muse2/muse/event.h b/muse2/muse/event.h
index 01e8e9c2..7e3e498c 100644
--- a/muse2/muse/event.h
+++ b/muse2/muse/event.h
@@ -27,7 +27,7 @@
#include <map>
#include <sys/types.h>
-#include "wave.h" // wg. SndFile
+#include "wave.h" // for SndFile
#include "pos.h"
#include "evdata.h"
@@ -103,7 +103,7 @@ class Event {
MusECore::SndFileR sndFile() const;
virtual void setSndFile(MusECore::SndFileR& sf);
- virtual void readAudio(MusECore::WavePart* /*part*/, unsigned /*offset*/, float** /*bpp*/, int /*channels*/, int /*nn*/, bool /*doSeek*/, bool /*overwrite*/);
+ virtual void readAudio(MusECore::WavePart* part, unsigned offset, float** bpp, int channels, int nn, bool doSeek, bool overwrite);
void setTick(unsigned val);
unsigned tick() const;
diff --git a/muse2/muse/eventbase.h b/muse2/muse/eventbase.h
index 89d38ec3..0cb960d9 100644
--- a/muse2/muse/eventbase.h
+++ b/muse2/muse/eventbase.h
@@ -24,13 +24,11 @@
#ifndef __EVENTBASE_H__
#define __EVENTBASE_H__
-//#include <samplerate.h>
#include <sys/types.h>
#include "pos.h"
#include "event.h"
-//class AudioConverter;
namespace MusECore {
class WavePart;
@@ -60,7 +58,6 @@ class EventBase : public PosLen {
void move(int offset);
virtual void read(Xml&) = 0;
- //virtual void write(int, Xml&, const Pos& offset) const = 0;
virtual void write(int, Xml&, const Pos& offset, bool forcePath = false) const = 0;
virtual void dump(int n = 0) const;
virtual EventBase* mid(unsigned, unsigned) = 0;
@@ -100,12 +97,6 @@ class EventBase : public PosLen {
virtual void setSndFile(SndFileR&) { }
virtual EventBase* clone() = 0;
- //virtual void read(unsigned /*offset*/, float** /*bpp*/, int /*channels*/, int /*nn*/, bool /*doSeek*/, bool overwrite = true) {}
- //virtual void readAudio(unsigned /*offset*/, float** /*bpp*/, int /*channels*/, int /*nn*/, bool /*doSeek*/, bool /*overwrite*/) {}
- //virtual off_t readAudio(SRC_STATE* /*src_state*/, off_t /*sfCurFrame*/, unsigned /*offset*/,
- // float** /*bpp*/, int /*channels*/, int /*nn*/, bool /*doSeek*/, bool /*overwrite*/) { return 0; }
- //virtual off_t readAudio(AudioConverter* /*audConv*/, off_t /*sfCurFrame*/, unsigned /*offset*/,
- // float** /*bpp*/, int /*channels*/, int /*nn*/, bool /*doSeek*/, bool /*overwrite*/) { return 0; }
virtual void readAudio(WavePart* /*part*/, unsigned /*offset*/,
float** /*bpp*/, int /*channels*/, int /*nn*/, bool /*doSeek*/, bool /*overwrite*/) { }
};
diff --git a/muse2/muse/eventlist.cpp b/muse2/muse/eventlist.cpp
index a411fc61..66780adb 100644
--- a/muse2/muse/eventlist.cpp
+++ b/muse2/muse/eventlist.cpp
@@ -104,9 +104,6 @@ void EventList::move(Event& event, unsigned tick)
iEvent EventList::find(const Event& event)
{
- // Changed by T356.
- // Changed by Tim. p3.3.8
- //EventRange range = equal_range(event.tick());
EventRange range = equal_range(event.type() == Wave ? event.frame() : event.tick());
diff --git a/muse2/muse/exportmidi.cpp b/muse2/muse/exportmidi.cpp
index 4a9c1f6d..c5cb44c4 100644
--- a/muse2/muse/exportmidi.cpp
+++ b/muse2/muse/exportmidi.cpp
@@ -48,12 +48,9 @@ namespace MusECore {
static void addController(MPEventList* l, int tick, int port, int channel, int a, int b)
{
- // p3.3.37
- //if (a < 0x1000) { // 7 Bit Controller
if (a < CTRL_14_OFFSET) { // 7 Bit Controller
l->add(MidiPlayEvent(tick, port, channel, ME_CONTROLLER, a, b));
}
- //else if (a < 0x20000) { // 14 Bit Controller
else if (a < CTRL_RPN_OFFSET) { // 14 Bit Controller
int ctrlH = (a >> 8) & 0x7f;
int ctrlL = a & 0x7f;
@@ -62,7 +59,6 @@ static void addController(MPEventList* l, int tick, int port, int channel, int a
l->add(MidiPlayEvent(tick, port, channel, ME_CONTROLLER, ctrlH, dataH));
l->add(MidiPlayEvent(tick+1, port, channel, ME_CONTROLLER, ctrlL, dataL));
}
- //else if (a < 0x30000) { // RPN 7-Bit Controller
else if (a < CTRL_NRPN_OFFSET) { // RPN 7-Bit Controller
int ctrlH = (a >> 8) & 0x7f;
int ctrlL = a & 0x7f;
@@ -70,7 +66,6 @@ static void addController(MPEventList* l, int tick, int port, int channel, int a
l->add(MidiPlayEvent(tick+1, port, channel, ME_CONTROLLER, CTRL_LRPN, ctrlL));
l->add(MidiPlayEvent(tick+2, port, channel, ME_CONTROLLER, CTRL_HDATA, b));
}
- //else if (a < 0x40000) { // NRPN 7-Bit Controller
else if (a < CTRL_INTERNAL_OFFSET) { // NRPN 7-Bit Controller
int ctrlH = (a >> 8) & 0x7f;
int ctrlL = a & 0x7f;
@@ -106,7 +101,6 @@ static void addController(MPEventList* l, int tick, int port, int channel, int a
}
l->add(MidiPlayEvent(tick+tickoffset, port, channel, ME_PROGRAM, pr, 0));
}
- //else if (a < 0x60000) { // RPN14 Controller
else if (a < CTRL_NRPN14_OFFSET) { // RPN14 Controller
int ctrlH = (a >> 8) & 0x7f;
int ctrlL = a & 0x7f;
@@ -117,7 +111,6 @@ static void addController(MPEventList* l, int tick, int port, int channel, int a
l->add(MidiPlayEvent(tick+2, port, channel, ME_CONTROLLER, CTRL_HDATA, dataH));
l->add(MidiPlayEvent(tick+3, port, channel, ME_CONTROLLER, CTRL_LDATA, dataL));
}
- //else if (a < 0x70000) { // NRPN14 Controller
else if (a < CTRL_NONE_OFFSET) { // NRPN14 Controller
int ctrlH = (a >> 8) & 0x7f;
int ctrlL = a & 0x7f;
@@ -142,21 +135,17 @@ void MusE::exportMidi()
{
MusEGui::MFile file(QString("midis"), QString(".mid"));
- //FILE* fp = file.open("w", midi_file_pattern, this, false, true,
FILE* fp = file.open("w", MusEGlobal::midi_file_save_pattern, this, false, true,
tr("MusE: Export Midi"));
if (fp == 0)
return;
MusECore::MidiFile mf(fp);
- //MusECore::MidiTrackList* tl = MusEGlobal::song->midis();
MusECore::TrackList* tl = MusEGlobal::song->tracks(); // Changed to full track list so user can rearrange tracks.
- //int ntracks = tl->size();
MusECore::MidiFileTrackList* mtl = new MusECore::MidiFileTrackList;
int i = 0;
MusECore::MidiFileTrack* mft = 0;
- //for (MusECore::iMidiTrack im = tl->begin(); im != tl->end(); ++im, ++i) {
for (MusECore::ciTrack im = tl->begin(); im != tl->end(); ++im) {
if(!(*im)->isMidiTrack())
@@ -164,7 +153,6 @@ void MusE::exportMidi()
MusECore::MidiTrack* track = (MusECore::MidiTrack*)(*im);
- //MusECore::MidiFileTrack* mft = new MusECore::MidiFileTrack;
if (i == 0 || (i != 0 && MusEGlobal::config.smfFormat != 0)) // Changed to single track. Tim
{
mft = new MusECore::MidiFileTrack;
@@ -211,7 +199,7 @@ void MusE::exportMidi()
}
//---------------------------------------------------
- // Write Coment
+ // Write Comment
//
//if (MusEGlobal::config.smfFormat == 0) // Only for smf 0 added by Tim. FIXME: Is this correct? See below.
{
@@ -263,11 +251,8 @@ void MusE::exportMidi()
//---------------------------------------------------
// Write Signatures
//
- ///const SigList* sl = &sigmap;
const AL::SigList* sl = &AL::sigmap;
- ///for (ciSigEvent e = sl->begin(); e != sl->end(); ++e) {
for (AL::ciSigEvent e = sl->begin(); e != sl->end(); ++e) {
- ///SigEvent* event = e->second;
AL::SigEvent* event = e->second;
int sz = (MusEGlobal::config.exp2ByteTimeSigs ? 2 : 4); // export 2 byte timesigs instead of 4 ?
unsigned char data[sz];
@@ -281,7 +266,7 @@ void MusE::exportMidi()
case 32: data[1] = 5; break;
case 64: data[1] = 6; break;
default:
- fprintf(stderr, "falsche Signatur; nenner %d\n", event->sig.n);
+ fprintf(stderr, "wrong Signature; denominator is %d\n", event->sig.n);
break;
}
// By T356. In muse the metronome pulse is fixed at 24 (once per quarter-note).
@@ -319,10 +304,6 @@ void MusE::exportMidi()
// track comment
//-----------------------------------
- // FIXME: What are these 0x0F? All I found was that they are unspecified part of the sixteen text meta events.
- // So why not use 0x01? And do we include it for all tracks, or only above 1? Tim.
- //if (i == 0 || (i != 0 && MusEGlobal::config.smfFormat != 0))
- //if (i != 0 && MusEGlobal::config.smfFormat != 0)
if (MusEGlobal::config.smfFormat != 0)
{
if (!track->comment().isEmpty()) {
@@ -351,13 +332,9 @@ void MusE::exportMidi()
}
int pitch;
if (track->type() == MusECore::Track::DRUM) {
- //
// Map drum-notes to the drum-map values
- //
int instr = ev.pitch();
pitch = MusEGlobal::drumMap[instr].anote;
- // port = MusEGlobal::drumMap[instr].port;
- // channel = MusEGlobal::drumMap[instr].channel;
}
else
pitch = ev.pitch();
@@ -431,10 +408,10 @@ void MusE::exportMidi()
}
mf.setDivision(MusEGlobal::config.midiDivision);
mf.setMType(MusEGlobal::song->mtype());
- //mf.setTrackList(mtl, ntracks);
mf.setTrackList(mtl, i);
mf.write();
+ // DELETETHIS 4 ??? or is this still an issue?
// TESTING: Cleanup. I did not valgrind this feature in last memleak fixes, but I suspect it leaked.
//for(MusECore::iMidiFileTrack imft = mtl->begin(); imft != mtl->end(); ++imft)
// delete *imft;
diff --git a/muse2/muse/functions.cpp b/muse2/muse/functions.cpp
index 71621b0d..ddbd3ce5 100644
--- a/muse2/muse/functions.cpp
+++ b/muse2/muse/functions.cpp
@@ -1181,7 +1181,7 @@ void paste_at(const QString& pt, int pos, int max_distance, bool always_new_part
schedule_resize_all_same_len_clone_parts(it->first, it->second, operations);
MusEGlobal::song->informAboutNewParts(new_part_map); // must be called before apply. otherwise
- // pointer changes (by resize) screw it up
+ // pointer changes (by resize) screw it up
MusEGlobal::song->applyOperationGroup(operations);
MusEGlobal::song->update(SC_SELECTION);
}
diff --git a/muse2/muse/gconfig.cpp b/muse2/muse/gconfig.cpp
index 68ac6315..cb9184a3 100644
--- a/muse2/muse/gconfig.cpp
+++ b/muse2/muse/gconfig.cpp
@@ -147,7 +147,6 @@ GlobalConfigValues config = {
QRect(0, 0, 400, 300), // GeometryMain;
QRect(0, 0, 200, 100), // GeometryTransport;
QRect(0, 0, 600, 200), // GeometryBigTime;
- //QRect(0, 0, 300, 500), // GeometryMixer; // Obsolete
{
QString("Mixer A"),
QRect(0, 0, 300, 500), // Mixer1
@@ -193,9 +192,8 @@ GlobalConfigValues config = {
MusECore::DONT_REC_MUTED_OR_HIDDEN,
true, // addHiddenTracks
true, // unhideTracks
- MusEGlobal::PREFER_NEW // drumTrackPreference
+ MusEGlobal::PREFER_NEW, // drumTrackPreference
+ false // smartFocus
};
-//GlobalConfigValues globalConfig = config;
-
} // namespace MusEGlobal
diff --git a/muse2/muse/gconfig.h b/muse2/muse/gconfig.h
index 4ba9efea..a76b7e13 100644
--- a/muse2/muse/gconfig.h
+++ b/muse2/muse/gconfig.h
@@ -71,11 +71,7 @@ struct MixerConfig {
bool showAuxTracks;
bool showSyntiTracks;
- //void write(MusECore::Xml&, const char* name);
- //void write(int level, MusECore::Xml& xml, const char* name);
void write(int level, MusECore::Xml& xml);
- //void read(QDomNode);
- //void read(MusECore::Xml& xml, const QString& name);
void read(MusECore::Xml& xml);
};
@@ -92,7 +88,6 @@ struct GlobalConfigValues {
QColor bigTimeForegroundColor;
QColor bigTimeBackgroundColor;
QColor waveEditBackgroundColor;
- //QFont fonts[6];
QFont fonts[NUM_FONTS];
QColor trackBg;
QColor selectTrackBg;
@@ -148,12 +143,10 @@ struct GlobalConfigValues {
QRect geometryMain;
QRect geometryTransport;
QRect geometryBigTime;
-// QRect geometryMixer;
MixerConfig mixer1;
MixerConfig mixer2;
bool transportVisible;
bool bigTimeVisible;
-// bool mixerVisible;
bool mixer1Visible;
bool mixer2Visible;
bool markerVisible;
@@ -188,6 +181,7 @@ struct GlobalConfigValues {
bool addHiddenTracks;
bool unhideTracks;
drumTrackPreference_t drumTrackPreference;
+ bool smartFocus;
};
diff --git a/muse2/muse/globals.cpp b/muse2/muse/globals.cpp
index d50ea1eb..112b9890 100644
--- a/muse2/muse/globals.cpp
+++ b/muse2/muse/globals.cpp
@@ -103,6 +103,7 @@ QString lastWavePath(".");
QString lastMidiPath(".");
bool debugMode = false;
+bool unityWorkaround = false;
bool debugMsg = false;
bool heavyDebugMsg = false;
bool midiInputTrace = false;
@@ -129,18 +130,7 @@ const char* midi_file_pattern[] = {
// the file is a pipe, and pipes can't seek !
// This results in a corrupted midi file from MidiFile::writeTrack().
// So exporting compressed midi has simply been disabled here for now...
-/*
-const char* midi_file_save_pattern[] = {
- "Midi (*.mid)",
- "gzip compressed Midi (*.mid.gz)",
- "bzip2 compressed Midi (*.mid.bz2)",
- "Karaoke (*.kar)",
- "gzip compressed karaoke (*.kar.gz)",
- "bzip2 compressed karaoke (*.kar.bz2)",
- "All Files (*)",
- 0
- };
-*/
+// For re-enabling, add .mid.gz and .mid.bz2 and same for .kar again
const char* midi_file_save_pattern[] = {
QT_TRANSLATE_NOOP("file_patterns", "Midi (*.mid)"),
QT_TRANSLATE_NOOP("file_patterns", "Karaoke (*.kar)"),
@@ -181,15 +171,6 @@ const char* image_file_pattern[] = {
0
};
-// Not used.
-/*
-const char* ctrl_file_pattern[] = {
- "ctrl Files (*.ctrl *.ctrl.gz *.ctrl.bz2)",
- "All Files (*)",
- 0
- };
-*/
-
const char* part_file_pattern[] = {
QT_TRANSLATE_NOOP("file_patterns", "part Files (*.mpt *.mpt.gz *.mpt.bz2)"),
QT_TRANSLATE_NOOP("file_patterns", "All Files (*)"),
@@ -203,14 +184,6 @@ const char* part_file_save_pattern[] = {
0
};
-/*
-const char* plug_file_pattern[] = {
- QT_TRANSLATE_NOOP("file_patterns", "part Files (*.pre)"),
- QT_TRANSLATE_NOOP("file_patterns", "All Files (*)"),
- 0
- };
-*/
-
const char* preset_file_pattern[] = {
QT_TRANSLATE_NOOP("file_patterns", "Presets (*.pre *.pre.gz *.pre.bz2)"),
QT_TRANSLATE_NOOP("file_patterns", "All Files (*)"),
@@ -247,7 +220,6 @@ const char* audio_file_pattern[] = {
0
};
-///Qt::ButtonState globalKeyState;
Qt::KeyboardModifiers globalKeyState;
// Midi Filter Parameter
@@ -275,7 +247,6 @@ QAction* punchoutAction;
QAction* recordAction;
QAction* panicAction;
-//AudioMixerApp* audioMixer;
MusEGui::MusE* muse = 0;
int preMeasures = 2;
diff --git a/muse2/muse/globals.h b/muse2/muse/globals.h
index 7563c171..d691fad1 100644
--- a/muse2/muse/globals.h
+++ b/muse2/muse/globals.h
@@ -77,6 +77,7 @@ extern QString lastMidiPath;
extern bool debugMode;
extern bool midiInputTrace;
extern bool midiOutputTrace;
+extern bool unityWorkaround;
extern bool debugMsg;
extern bool heavyDebugMsg;
extern bool debugSync;
@@ -96,7 +97,6 @@ extern const char* med_file_pattern[];
extern const char* med_file_save_pattern[];
extern const char* project_create_file_save_pattern[];
extern const char* image_file_pattern[];
-//extern const char* ctrl_file_pattern[];
extern const char* part_file_pattern[];
extern const char* part_file_save_pattern[];
extern const char* preset_file_pattern[];
@@ -105,7 +105,6 @@ extern const char* drum_map_file_pattern[];
extern const char* drum_map_file_save_pattern[];
extern const char* audio_file_pattern[];
-///extern Qt::ButtonState globalKeyState;
extern Qt::KeyboardModifiers globalKeyState;
extern int midiInputPorts; //!< receive from all devices
@@ -146,8 +145,6 @@ extern QAction* punchoutAction;
extern QAction* recordAction;
extern QAction* panicAction;
-//class AudioMixerApp;
-//extern AudioMixerApp* audioMixer;
extern MusEGui::MusE* muse;
extern int preMeasures;
diff --git a/muse2/muse/gui.h b/muse2/muse/gui.h
index 43836dbb..1f3e773a 100644
--- a/muse2/muse/gui.h
+++ b/muse2/muse/gui.h
@@ -29,27 +29,6 @@
// central point of tweaking the gui
//
-/*
-// size of horizontal and vertical splitter
-//
-static const int splitWidth = 6;
-
-// arranger:
-static const int trackRowHeight = 24;
-static const int minTrackHeight = trackRowHeight + splitWidth + 1;
-static const int defaultTrackHeight = minTrackHeight;
-static const int infoHeight = 20;
-static const int infoWidth = 140;
-static const int trackSeparator = 1;
-static const int yTrackOffset = -2; // -4;
-
-// mixer:
-static const int STRIP_WIDTH = 60;
-static const int LABEL_HEIGHT = 20;
-static const int BUTTON_HEIGHT = STRIP_WIDTH / 3;
-static const int ENTRY_HEIGHT = 17;
-*/
-
static const int ICON_WIDTH = 18;
static const QSize ICON_SIZE(ICON_WIDTH, ICON_WIDTH);
diff --git a/muse2/muse/help.cpp b/muse2/muse/help.cpp
index c7ae1ff7..4bce3a16 100644
--- a/muse2/muse/help.cpp
+++ b/muse2/muse/help.cpp
@@ -73,7 +73,6 @@ void MusE::startHomepageBrowser()
void MusE::startBugBrowser()
{
- //QString museBugPage("http://www.muse-sequencer.org/wiki/index.php/Report_a_bug");
QString museBugPage("http://www.muse-sequencer.org/index.php/Report_a_bug");
launchBrowser(museBugPage);
}
diff --git a/muse2/muse/helper.cpp b/muse2/muse/helper.cpp
index ce96d6fe..89b0b641 100644
--- a/muse2/muse/helper.cpp
+++ b/muse2/muse/helper.cpp
@@ -40,12 +40,12 @@
#include "audiodev.h"
#include "midiseq.h"
+#include <QMenu>
#include <QApplication>
#include <QDir>
#include <QFileInfo>
#include <QFileDialog>
#include <QString>
-//#include <QTemporaryFile>
#ifdef DSSI_SUPPORT
#include "dssihost.h"
@@ -364,10 +364,7 @@ QMenu* populateAddSynth(QWidget* parent)
{
QMenu* synp = new QMenu(parent);
- //typedef std::multimap<std::string, int, addSynth_cmp_str > asmap;
typedef std::multimap<std::string, int > asmap;
-
- //typedef std::multimap<std::string, int, addSynth_cmp_str >::iterator imap;
typedef std::multimap<std::string, int >::iterator imap;
@@ -514,8 +511,6 @@ QActionGroup* populateAddTrack(QMenu* addTrack, bool populateAll, bool evenIgnor
addTrack->addMenu(synp);
}
- //QObject::connect(addTrack, SIGNAL(triggered(QAction *)), MusEGlobal::song, SLOT(addNewTrack(QAction *)));
-
return grp;
}
@@ -525,9 +520,7 @@ QActionGroup* populateAddTrack(QMenu* addTrack, bool populateAll, bool evenIgnor
QString getFilterExtension(const QString &filter)
{
- //
// Return the first extension found. Must contain at least one * character.
- //
int pos = filter.indexOf('*');
if(pos == -1)
@@ -564,11 +557,9 @@ QString browseProjectFolder(QWidget* parent)
path = d.absolutePath();
}
- QString dir = QFileDialog::getExistingDirectory(parent, qApp->tr("Select project directory"), path);
+ QString dir = QFileDialog::getExistingDirectory(parent, qApp->translate("@default", QT_TRANSLATE_NOOP("@default", "Select project directory")), path);
if(dir.isEmpty())
dir = MusEGlobal::config.projectBaseFolder;
- // projDirLineEdit->setText(dir);
- //return QFileDialog::getExistingDirectory(this, qApp.tr("Select project directory"), path);
return dir;
}
@@ -586,7 +577,6 @@ QString projectTitleFromFilename(QString filename)
QFileInfo fi(filename);
- //return fi.baseName();
return fi.fileName();
}
@@ -615,9 +605,6 @@ QString projectExtensionFromFilename(QString filename)
QString getUniqueUntitledName()
{
QString filename("untitled");
- //QTemporaryFile tf(MusEGlobal::config.projectBaseFolder +"/" + s + "XXXXXX.med");
- //if(tf.open())
- // s = MusEGui::projectTitleFromFilename(tf.fileName());
QString fbase(MusEGlobal::config.projectBaseFolder);
@@ -626,7 +613,6 @@ QString getUniqueUntitledName()
nfb += "/" + filename;
QFileInfo fi(nfb + "/" + filename + ".med"); // TODO p4.0.40 Check other extensions.
if(!fi.exists())
- //return filename;
return fi.filePath();
// Find a new filename
@@ -640,14 +626,10 @@ QString getUniqueUntitledName()
nfb += "/" + nfn;
QFileInfo fi(nfb + "/" + nfn + ".med");
if(!fi.exists())
- //break;
return fi.filePath();
}
- //if(idx >= 10000)
- printf("MusE error: Could not make untitled project name (10000 or more untitled projects in project dir - clean up!\n");
-
- //return nfn;
+ printf("MusE error: Could not make untitled project name (10000 or more untitled projects in project dir - clean up!\n");
nfb = fbase;
if(MusEGlobal::config.projectStoreInFolder)
@@ -686,8 +668,6 @@ void populateMidiPorts()
if(dev)
{
++jack_midis_found;
- //printf("populateMidiPorts Created jack writeable device: %s\n", dev->name().toLatin1().constData());
- //dev->setOpenFlags(1);
MusEGlobal::midiSeq->msgSetMidiDevice(&MusEGlobal::midiPorts[port_num], dev);
MusECore::Route srcRoute(dev, -1);
MusECore::Route dstRoute(*i, true, -1, MusECore::Route::JACK_ROUTE);
@@ -704,8 +684,6 @@ void populateMidiPorts()
if(dev)
{
++jack_midis_found;
- //printf("populateMidiPorts Created jack readable device: %s\n", dev->name().toLatin1().constData());
- //dev->setOpenFlags(2);
MusEGlobal::midiSeq->msgSetMidiDevice(&MusEGlobal::midiPorts[port_num], dev);
MusECore::Route srcRoute(*i, false, -1, MusECore::Route::JACK_ROUTE);
MusECore::Route dstRoute(dev, -1);
@@ -717,10 +695,10 @@ void populateMidiPorts()
}
//else
// If Jack is not running, use ALSA devices.
- //if(MusEGlobal::audioDevice->deviceType() == MusECore::AudioDevice::DUMMY_AUDIO)
// Try to do the user a favour: If we still have no Jack devices, even if Jack is running, fill with ALSA.
// It is possible user has Jack running on ALSA back-end but without midi support.
// IE. They use Jack for audio but use ALSA for midi!
+ // If unwanted, remove "|| jack_midis_found == 0".
if(MusEGlobal::audioDevice->deviceType() == MusECore::AudioDevice::DUMMY_AUDIO || jack_midis_found == 0)
{
for(MusECore::iMidiDevice i = MusEGlobal::midiDevices.begin(); i != MusEGlobal::midiDevices.end(); ++i)
@@ -728,40 +706,16 @@ void populateMidiPorts()
if((*i)->deviceType() != MusECore::MidiDevice::ALSA_MIDI)
continue;
dev = *i;
- // Select only sensible devices first - not thru etc.
- //if( ... )
- // continue;
-
- //dev->setOpenFlags(1);
MusEGlobal::midiSeq->msgSetMidiDevice(&MusEGlobal::midiPorts[port_num], dev);
if(++port_num == MIDI_PORTS)
return;
}
-
- //for(MusECore::iMidiDevice i = MusEGlobal::midiDevices.begin(); i != MusEGlobal::midiDevices.end(); ++i)
- //{
- // if((*i)->deviceType() != MusECore::MidiDevice::ALSA_MIDI)
- // continue;
- // // Select the ones ignored in the first pass.
- // if(! ... )
- // continue;
- //
- // dev->setOpenFlags(1);
- // MusEGlobal::midiSeq->msgSetMidiDevice(port_num, dev);
- //
- // if(++port_num == MIDI_PORTS)
- // return;
- //}
}
-
- //MusEGlobal::muse->changeConfig(true); // save configuration file
- //MusEGlobal::song->update();
-
}
#else // this code is disabled
-
+// DELETETHIS uhm, yeah... do we need this?
DISABLED AND MAYBE OUT-OF-DATE CODE!
the code below is disabled for a longer period of time,
there were certain changes and merges. dunno if that code
@@ -792,9 +746,7 @@ void populateMidiPorts()
{
std::list<QString> wsl;
std::list<QString> rsl;
- //wsl = MusEGlobal::audioDevice->inputPorts(true, 1); // Ask for second aliases.
wsl = MusEGlobal::audioDevice->inputPorts(true, 0); // Ask for first aliases.
- //rsl = MusEGlobal::audioDevice->outputPorts(true, 1); // Ask for second aliases.
rsl = MusEGlobal::audioDevice->outputPorts(true, 0); // Ask for first aliases.
for(std::list<QString>::iterator wi = wsl.begin(); wi != wsl.end(); ++wi)
@@ -824,16 +776,9 @@ void populateMidiPorts()
// Do we have a matching pair?
if(rs == ws)
{
- // Would like to remove the client name, but no, we need it as a distinguishing identifier.
- //int z = ws.indexOf(":");
- //if(z >= 0)
- // ws.remove(0, z + 1);
-
dev = MusECore::MidiJackDevice::createJackMidiDevice(ws, 3);
if(dev)
{
- //printf("populateMidiPorts Created jack writeable/readable device: %s\n", dev->name().toLatin1().constData());
- //dev->setOpenFlags(1);
MusEGlobal::midiSeq->msgSetMidiDevice(&MusEGlobal::midiPorts[port_num], dev);
MusECore::Route devRoute(dev, -1);
MusECore::Route wdstRoute(*wi, true, -1, MusECore::Route::JACK_ROUTE);
@@ -854,15 +799,9 @@ void populateMidiPorts()
{
// No match was found. Create a single writeable device.
QString s = *wi;
- // Would like to remove the client name, but no, we need it as a distinguishing identifier.
- //int z = s.indexOf(":");
- //if(z >= 0)
- // s.remove(0, z + 1);
dev = MusECore::MidiJackDevice::createJackMidiDevice(s, 1);
if(dev)
{
- //printf("populateMidiPorts Created jack writeable device: %s\n", dev->name().toLatin1().constData());
- //dev->setOpenFlags(1);
MusEGlobal::midiSeq->msgSetMidiDevice(&MusEGlobal::midiPorts[port_num], dev);
MusECore::Route srcRoute(dev, -1);
MusECore::Route dstRoute(*wi, true, -1, MusECore::Route::JACK_ROUTE);
@@ -877,15 +816,9 @@ void populateMidiPorts()
for(std::list<QString>::iterator ri = rsl.begin(); ri != rsl.end(); ++ri)
{
QString s = *ri;
- // Would like to remove the client name, but no, we need it as a distinguishing identifier.
- //int z = s.indexOf(":");
- //if(z >= 0)
- // s.remove(0, z + 1);
dev = MusECore::MidiJackDevice::createJackMidiDevice(s, 2);
if(dev)
{
- //printf("populateMidiPorts Created jack readable device: %s\n", dev->name().toLatin1().constData());
- //dev->setOpenFlags(2);
MusEGlobal::midiSeq->msgSetMidiDevice(&MusEGlobal::midiPorts[port_num], dev);
MusECore::Route srcRoute(*ri, false, -1, MusECore::Route::JACK_ROUTE);
MusECore::Route dstRoute(dev, -1);
@@ -904,36 +837,12 @@ void populateMidiPorts()
if((*i)->deviceType() != MusECore::MidiDevice::ALSA_MIDI)
continue;
dev = *i;
- // Select only sensible devices first - not thru etc.
- //if( ... )
- // continue;
-
- //dev->setOpenFlags(1);
MusEGlobal::midiSeq->msgSetMidiDevice(&MusEGlobal::midiPorts[port_num], dev);
if(++port_num == MIDI_PORTS)
return;
}
-
- //for(MusECore::iMidiDevice i = MusEGlobal::midiDevices.begin(); i != MusEGlobal::midiDevices.end(); ++i)
- //{
- // if((*i)->deviceType() != MusECore::MidiDevice::ALSA_MIDI)
- // continue;
- // // Select the ones ignored in the first pass.
- // if(! ... )
- // continue;
- //
- // dev->setOpenFlags(1);
- // MusEGlobal::midiSeq->msgSetMidiDevice(port_num, dev);
- //
- // if(++port_num == MIDI_PORTS)
- // return;
- //}
}
-
- //MusEGlobal::muse->changeConfig(true); // save configuration file
- //MusEGlobal::song->update();
-
}
#endif // populateMidiPorts
diff --git a/muse2/muse/importmidi.cpp b/muse2/muse/importmidi.cpp
index bd3c8a9f..44b68353 100644
--- a/muse2/muse/importmidi.cpp
+++ b/muse2/muse/importmidi.cpp
@@ -38,13 +38,11 @@
#include "midiport.h"
#include "transport.h"
#include "arranger.h"
-//#include "arranger/arranger.h" // p4.0.2
#include "mpevent.h"
#include "event.h"
#include "midictrl.h"
#include "instruments/minstrument.h"
#include "drummap.h"
-//#include "midiedit/drummap.h" // p4.0.2
#include "xml.h"
#include "audio.h"
#include "gconfig.h"
@@ -195,9 +193,7 @@ bool MusE::importMidi(const QString name, bool merge)
mport->setInstrument(instr);
MusECore::EventList* mel = track->events();
- //buildMidiEventList(mel, el, track, division, first);
- // Don't do loops.
- buildMidiEventList(mel, el, track, division, first, false);
+ buildMidiEventList(mel, el, track, division, first, false); // Don't do loops.
first = false;
// Comment Added by T356.
@@ -209,8 +205,7 @@ bool MusE::importMidi(const QString name, bool merge)
else
{
track->setType(MusECore::Track::DRUM);
-
- // remap drum pitch with drumOutmap
+ // remap drum pitch with drumOutmap (was: Inmap. flo93 thought this was wrong)
MusECore::EventList* tevents = track->events();
for (MusECore::iEvent i = tevents->begin(); i != tevents->end(); ++i) {
MusECore::Event ev = i->second;
@@ -246,9 +241,7 @@ bool MusE::importMidi(const QString name, bool merge)
track->setOutChannel(0);
track->setOutPort(0);
MusECore::EventList* mel = track->events();
- //buildMidiEventList(mel, el, track, division, true);
- // Do SysexMeta. Don't do loops.
- buildMidiEventList(mel, el, track, division, true, false);
+ buildMidiEventList(mel, el, track, division, true, false); // Do SysexMeta. Don't do loops.
processTrack(track);
MusEGlobal::song->insertTrack0(track, -1);
}
@@ -263,7 +256,6 @@ bool MusE::importMidi(const QString name, bool merge)
MusEGlobal::song->initLen();
int z, n;
- ///sigmap.timesig(0, z, n);
AL::sigmap.timesig(0, z, n);
int tempo = MusEGlobal::tempomap.tempo(0);
@@ -277,7 +269,6 @@ bool MusE::importMidi(const QString name, bool merge)
MusEGlobal::song->updatePos();
_arranger->reset();
- ///_arranger->setMode(int(MusEGlobal::song->mtype())); // p4.0.7 Tim
}
else {
MusEGlobal::song->initLen();
@@ -324,7 +315,6 @@ void MusE::processTrack(MusECore::MidiTrack* track)
int bar2, beat;
unsigned tick;
- ///sigmap.tickValues(len, &bar2, &beat, &tick);
AL::sigmap.tickValues(len, &bar2, &beat, &tick);
int lastOff = 0;
@@ -333,7 +323,6 @@ void MusE::processTrack(MusECore::MidiTrack* track)
int x2 = 0; // end tick current measure
for (int bar = 0; bar < bar2; ++bar, x1 = x2) {
- ///x2 = sigmap.bar2tick(bar+1, 0, 0);
x2 = AL::sigmap.bar2tick(bar+1, 0, 0);
if (lastOff > x2) {
// this measure is busy!
@@ -347,7 +336,6 @@ void MusE::processTrack(MusECore::MidiTrack* track)
MusECore::MidiPart* part = new MusECore::MidiPart(track);
part->setTick(st);
part->setLenTick(x1-st);
- // printf("new part %d len: %d\n", st, x1-st);
part->setName(partname);
pl->add(part);
st = -1;
@@ -371,7 +359,6 @@ void MusE::processTrack(MusECore::MidiTrack* track)
if (st != -1) {
MusECore::MidiPart* part = new MusECore::MidiPart(track);
part->setTick(st);
- // printf("new part %d len: %d\n", st, x2-st);
part->setLenTick(x2-st);
part->setName(partname);
pl->add(part);
@@ -381,7 +368,6 @@ void MusE::processTrack(MusECore::MidiTrack* track)
{
// Just one long part...
MusECore::MidiPart* part = new MusECore::MidiPart(track);
- //part->setTick(st);
part->setTick(0);
part->setLenTick(len);
part->setName(partname);
@@ -434,11 +420,9 @@ void MusE::importController(int channel, MusECore::MidiPort* mport, int n)
return; // controller does already exist
MusECore::MidiController* ctrl = 0;
MusECore::MidiControllerList* mcl = instr->controller();
-// printf("import Ctrl\n");
for (MusECore::iMidiController i = mcl->begin(); i != mcl->end(); ++i) {
MusECore::MidiController* mc = i->second;
int cn = mc->num();
-// printf(" %x %x\n", n, cn);
if (cn == n) {
ctrl = mc;
break;
@@ -452,8 +436,6 @@ void MusE::importController(int channel, MusECore::MidiPort* mport, int n)
if (ctrl == 0) {
printf("controller 0x%x not defined for instrument %s, channel %d\n",
n, instr->iname().toLatin1().constData(), channel);
-// TODO: register default Controller
-// MusECore::MidiController* MusECore::MidiPort::midiController(int num) const
}
MusECore::MidiCtrlValList* newValList = new MusECore::MidiCtrlValList(n);
vll->add(channel, newValList);
@@ -473,13 +455,11 @@ void MusE::importPart()
MusECore::Track* t = *i;
if (t->selected()) {
// Changed by T356. Support mixed .mpt files.
- //if (t->isMidiTrack()) {
if (t->isMidiTrack() || t->type() == MusECore::Track::WAVE) {
track = t;
break;
}
else {
- //QMessageBox::warning(this, QString("MusE"), tr("Import part is only valid for midi tracks!"));
QMessageBox::warning(this, QString("MusE"), tr("Import part is only valid for midi and wave tracks!"));
return;
}
@@ -515,6 +495,7 @@ void MusE::importPart()
//---------------------------------------------------------
void MusE::importPartToTrack(QString& filename, unsigned tick, MusECore::Track* track)
{
+ // DELETETHIS 41
// Changed by T356
/*
bool popenFlag = false;
@@ -581,9 +562,6 @@ void MusE::importPartToTrack(QString& filename, unsigned tick, MusECore::Track*
break;
case MusECore::Xml::TagStart:
if (tag == "part") {
- //MusECore::MidiPart* p = new MusECore::MidiPart((MusECore::MidiTrack*)track);
- //p->read(xml);
-
// Read the part.
MusECore::Part* p = 0;
p = readXmlPart(xml, track);
@@ -604,8 +582,6 @@ void MusE::importPartToTrack(QString& filename, unsigned tick, MusECore::Track*
posOffset = tick - p->tick();
}
p->setTick(p->tick() + posOffset);
- //finalPos=p->tick() + p->lenTick();
- ////pos += p->lenTick();
MusEGlobal::audio->msgAddPart(p,false);
}
else
diff --git a/muse2/muse/instruments/editinstrument.cpp b/muse2/muse/instruments/editinstrument.cpp
index ac3ec68f..e9ced6b2 100644
--- a/muse2/muse/instruments/editinstrument.cpp
+++ b/muse2/muse/instruments/editinstrument.cpp
@@ -73,9 +73,6 @@ EditInstrument::EditInstrument(QWidget* parent, Qt::WFlags fl)
toolBar->addAction(QWhatsThis::createAction(this));
Help->addAction(QWhatsThis::createAction(this));
- ///patchpopup = new QMenu(patchButton);
- //patchpopup->setCheckable(false);// Qt4 doc says this is unnecessary.
-
// populate instrument list
// Populate common controller list.
for(int i = 0; i < 128; ++i)
@@ -102,6 +99,7 @@ EditInstrument::EditInstrument(QWidget* parent, Qt::WFlags fl)
instrumentList->setSelectionMode(QAbstractItemView::SingleSelection);
if(instrumentList->item(0))
instrumentList->setCurrentItem(instrumentList->item(0));
+ //DELETETHIS
//oldMidiInstrument = (MusECore::MidiInstrument*)((ListBoxData*)instrumentList->item(0))->data();
//oldMidiInstrument = (ListBoxData*)instrumentList->item(0);
//oldMidiInstrument = (ListBoxData*)instrumentList->selectedItem();
@@ -173,13 +171,10 @@ EditInstrument::EditInstrument(QWidget* parent, Qt::WFlags fl)
- //instrumentChanged();
changeInstrument();
- //connect(listController, SIGNAL(selectionChanged()), SLOT(controllerChanged()));
connect(viewController, SIGNAL(itemSelectionChanged()), SLOT(controllerChanged()));
- //connect(instrumentName, SIGNAL(textChanged(const QString&)), SLOT(instrumentNameChanged(const QString&)));
connect(instrumentName, SIGNAL(returnPressed()), SLOT(instrumentNameReturn()));
connect(instrumentName, SIGNAL(lostFocus()), SLOT(instrumentNameReturn()));
@@ -188,7 +183,6 @@ EditInstrument::EditInstrument(QWidget* parent, Qt::WFlags fl)
connect(patchDelete, SIGNAL(clicked()), SLOT(deletePatchClicked()));
connect(patchNew, SIGNAL(clicked()), SLOT(newPatchClicked()));
connect(patchNewGroup, SIGNAL(clicked()), SLOT(newGroupClicked()));
- //connect(newCategory, SIGNAL(clicked()), SLOT(newCategoryClicked()));
connect(patchButton, SIGNAL(clicked()), SLOT(patchButtonClicked()));
connect(defPatchH, SIGNAL(valueChanged(int)), SLOT(defPatchChanged(int)));
@@ -201,7 +195,6 @@ EditInstrument::EditInstrument(QWidget* parent, Qt::WFlags fl)
connect(ctrlType,SIGNAL(activated(int)), SLOT(ctrlTypeChanged(int)));
connect(ctrlName, SIGNAL(returnPressed()), SLOT(ctrlNameReturn()));
connect(ctrlName, SIGNAL(lostFocus()), SLOT(ctrlNameReturn()));
- //connect(ctrlName, SIGNAL(textChanged(const QString&)), SLOT(ctrlNameChanged(const QString&)));
connect(spinBoxHCtrlNo, SIGNAL(valueChanged(int)), SLOT(ctrlHNumChanged(int)));
connect(spinBoxLCtrlNo, SIGNAL(valueChanged(int)), SLOT(ctrlLNumChanged(int)));
connect(spinBoxMin, SIGNAL(valueChanged(int)), SLOT(ctrlMinChanged(int)));
@@ -211,7 +204,7 @@ EditInstrument::EditInstrument(QWidget* parent, Qt::WFlags fl)
connect(nullParamSpinBoxL, SIGNAL(valueChanged(int)), SLOT(ctrlNullParamLChanged(int)));
connect(tabWidget3, SIGNAL(currentChanged(QWidget*)), SLOT(tabChanged(QWidget*)));
- //connect(sysexList, SIGNAL(selectionChanged()), SLOT(sysexChanged()));
+ //connect(sysexList, SIGNAL(selectionChanged()), SLOT(sysexChanged())); DELETETHIS or is it needed later?
//connect(deleteSysex, SIGNAL(clicked()), SLOT(deleteSysexClicked()));
//connect(newSysex, SIGNAL(clicked()), SLOT(newSysexClicked()));
}
@@ -546,21 +539,15 @@ void EditInstrument::fileNew()
}
}
if (!found) {
- //if(oldMidiInstrument)
- //{
MusECore::MidiInstrument* oi = 0;
if(oldMidiInstrument)
oi = (MusECore::MidiInstrument*)oldMidiInstrument->data(Qt::UserRole).value<void*>();
MusECore::MidiInstrument* wip = &workingInstrument;
- //checkDirty(oi);
- //if(checkDirty(oi))
- if(checkDirty(wip))
- // No save was chosen. Restore the actual instrument name.
+ if(checkDirty(wip)) // No save was chosen. Restore the actual instrument name.
{
if(oi)
{
oldMidiInstrument->setText(oi->iname());
- //workingInstrument.setIName(oi->iname());
// No file path? Only a new unsaved instrument can do that. So delete it.
if(oi->filePath().isEmpty())
@@ -569,29 +556,14 @@ void EditInstrument::fileNew()
}
}
- //else
- //{
- // if(oi)
- // Save was chosen. Assign the working instrument to the actual instrument.
- // oi->assign(workingInstrument);
- //}
-
- //oi->setDirty(false);
workingInstrument.setDirty(false);
- //}
MusECore::MidiInstrument* ni = new MusECore::MidiInstrument(s);
- //MusECore::midiInstruments.append(ni);
MusECore::midiInstruments.push_back(ni);
- //QListWidgetItem* item = new QListWidgetItem(ni->iname());
- //InstrumentListItem* item = new InstrumentListItem(ni->iname());
QListWidgetItem* item = new QListWidgetItem(ni->iname());
- //oldMidiInstrument = item;
workingInstrument.assign( *ni );
- //workingInstrument.setDirty(false);
-
- //item->setText(ni->iname());
+
QVariant v = qVariantFromValue((void*)(ni));
item->setData(Qt::UserRole, v);
instrumentList->addItem(item);
@@ -617,14 +589,8 @@ void EditInstrument::fileNew()
// fileOpen
//---------------------------------------------------------
-void EditInstrument::fileOpen()
+void EditInstrument::fileOpen() //DELETETHIS?
{
- // Allow these to update...
- //instrumentNameReturn();
- //patchNameReturn();
- //ctrlNameReturn();
-
-
}
//---------------------------------------------------------
@@ -633,10 +599,8 @@ void EditInstrument::fileOpen()
void EditInstrument::fileSave()
{
- //if (instrument->filePath().isEmpty())
if (workingInstrument.filePath().isEmpty())
{
- //fileSaveAs();
saveAs();
return;
}
@@ -645,18 +609,13 @@ void EditInstrument::fileSave()
QFileInfo qfi(workingInstrument.filePath());
if(qfi.absolutePath() == MusEGlobal::museInstruments)
{
- //fileSaveAs();
saveAs();
return;
}
- //QFile f(instrument->filePath());
- //if (!f.open(QIODevice::WriteOnly)) {
- //FILE* f = fopen(instrument->filePath().toLatin1().constData(), "w");
FILE* f = fopen(workingInstrument.filePath().toLatin1().constData(), "w");
if(f == 0)
{
- //fileSaveAs();
saveAs();
return;
}
@@ -666,20 +625,14 @@ void EditInstrument::fileSave()
patchNameReturn();
ctrlNameReturn();
- //f.close();
if(fclose(f) != 0)
{
- //QString s = QString("Creating file:\n") + instrument->filePath() + QString("\nfailed: ")
QString s = QString("Creating file:\n") + workingInstrument.filePath() + QString("\nfailed: ")
- //+ f.errorString();
+ QString(strerror(errno) );
- //fprintf(stderr, "poll failed: %s\n", strerror(errno));
QMessageBox::critical(this, tr("MusE: Create file failed"), s);
return;
}
- //if(fileSave(instrument, instrument->filePath()))
- // instrument->setDirty(false);
if(fileSave(&workingInstrument, workingInstrument.filePath()))
workingInstrument.setDirty(false);
}
@@ -690,7 +643,7 @@ void EditInstrument::fileSave()
bool EditInstrument::fileSave(MusECore::MidiInstrument* instrument, const QString& name)
{
- //QFile f(name);
+ //QFile f(name); DELETETHIS
//if (!f.open(QIODevice::WriteOnly)) {
// QString s("Creating file failed: ");
// s += strerror(errno);
@@ -703,8 +656,6 @@ bool EditInstrument::fileSave(MusECore::MidiInstrument* instrument, const QStrin
FILE* f = fopen(name.toAscii().constData(), "w");
if(f == 0)
{
- //if(debugMsg)
- // printf("READ IDF %s\n", fi->filePath().toLatin1().constData());
QString s("Creating file failed: ");
s += QString(strerror(errno));
QMessageBox::critical(this,
@@ -716,7 +667,6 @@ bool EditInstrument::fileSave(MusECore::MidiInstrument* instrument, const QStrin
updateInstrument(instrument);
- //instrument->write(xml);
instrument->write(0, xml);
// Assign the working instrument values to the actual current selected instrument...
@@ -729,18 +679,13 @@ bool EditInstrument::fileSave(MusECore::MidiInstrument* instrument, const QStrin
// Now signal the rest of the app so stuff can change...
MusEGlobal::song->update(SC_CONFIG | SC_MIDI_CONTROLLER);
- //MusEGlobal::song->update(SC_CONFIG | SC_MIDI_CONTROLLER | SC_MIDI_CONTROLLER_ADD);
}
}
- //f.close();
- //if (f.error()) {
if(fclose(f) != 0)
{
QString s = QString("Write File\n") + name + QString("\nfailed: ")
- //+ f.errorString();
+ QString(strerror(errno));
- //fprintf(stderr, "poll failed: %s\n", strerror(errno));
QMessageBox::critical(this, tr("MusE: Write File failed"), s);
return false;
}
@@ -758,7 +703,7 @@ void EditInstrument::saveAs()
patchNameReturn();
ctrlNameReturn();
- //QListWidgetItem* item = instrumentList->currentItem();
+ //QListWidgetItem* item = instrumentList->currentItem(); DELETETHIS
// ListBoxData* item = (ListBoxData*)instrumentList->selectedItem();
// if (item == 0)
// return;
@@ -774,15 +719,13 @@ void EditInstrument::saveAs()
{
printf("MusE Error! User instrument directory: %s does not exist. Should be created at startup!\n", MusEGlobal::museUserInstruments.toLatin1().constData());
- //path = MusEGlobal::museUser;
+ //path = MusEGlobal::museUser; DELETETHIS?
//path = MusEGlobal::configPath;
}
- //if (instrument->filePath().isEmpty())
if (workingInstrument.filePath().isEmpty())
path += QString("/%1.idf").arg(workingInstrument.iname());
else {
- //QFileInfo fi(instrument->filePath());
QFileInfo fi(workingInstrument.filePath());
// Prompt for a new instrument name if the name has not been changed, to avoid duplicates.
@@ -797,7 +740,7 @@ void EditInstrument::saveAs()
// This will still allow a user instrument to override a built-in instrument with the same name.
if(fi.absolutePath() != MusEGlobal::museInstruments)
{
- //QMessageBox::critical(this,
+ //QMessageBox::critical(this, DELETETHIS???
// tr("MusE: Bad instrument name"),
// tr("Please change the instrument name to a new unique name before saving, to avoid duplicates"),
// QMessageBox::Ok,
@@ -811,20 +754,13 @@ void EditInstrument::saveAs()
}
path += QString("/%1.idf").arg(fi.baseName());
}
- //QString s = QFileDialog::getSaveFileName(this,
- // tr("MusE: Save Instrument Definition"),
- // path,
- // tr("Instrument Definition (*.idf)"));
-
+
QString s = QFileDialog::getSaveFileName(this, tr("MusE: Save Instrument Definition").toLatin1().constData(),
path, tr("Instrument Definition (*.idf)"));
if (s.isEmpty())
return;
- //instrument->setFilePath(s);
workingInstrument.setFilePath(s);
- //if (fileSave(instrument, s))
- // instrument->setDirty(false);
if(fileSave(&workingInstrument, s))
workingInstrument.setDirty(false);
}
@@ -856,16 +792,10 @@ void EditInstrument::fileSaveAs()
{
// No save:
case 1:
- //item->setText(instrument->iname());
- //instrumentList->triggerUpdate(true);
- //instrument->setDirty(false);
workingInstrument.setDirty(false);
if(oi)
{
oldMidiInstrument->setText(oi->iname());
- //workingInstrument.setIName(oi->iname());
-
- //workingInstrument.assign(*oi);
// No file path? Only a new unsaved instrument can do that. So delete it.
if(oi->filePath().isEmpty())
@@ -888,13 +818,11 @@ void EditInstrument::fileSaveAs()
// Save:
case 0:
- //if(oi)
- // oi->assign(workingInstrument);
workingInstrument.setDirty(false);
break;
}
- //QListWidgetItem* item = instrumentList->currentItem();
+ //QListWidgetItem* item = instrumentList->currentItem(); DELETETHIS
// ListBoxData* item = (ListBoxData*)instrumentList->selectedItem();
// if (item == 0)
// return;
@@ -975,8 +903,7 @@ void EditInstrument::fileSaveAs()
break;
}
}
- // Assign the found instrument to the working instrument.
- //workingInstrument.assign(*(*imi));
+
// Assign the found instrument name to the working instrument name.
workingInstrument.setIName(s);
@@ -1007,22 +934,13 @@ void EditInstrument::fileSaveAs()
ni->assign(workingInstrument);
ni->setIName(so);
ni->setFilePath(QString());
- //MusECore::midiInstruments.append(ni);
MusECore::midiInstruments.push_back(ni);
- //QListWidgetItem* item = new QListWidgetItem(ni->iname());
- //InstrumentListItem* item = new InstrumentListItem(ni->iname());
- //ListBoxData* item = new ListBoxData(ni->iname());
QListWidgetItem* item = new QListWidgetItem(so);
- //oldMidiInstrument = item;
workingInstrument.assign( *ni );
- //workingInstrument.setDirty(false);
-
- //item->setText(ni->iname());
- //item->setData((void*)ni);
+
QVariant v = qVariantFromValue((void*)(ni));
item->setData(Qt::UserRole, v);
- //instrumentList->addItem(item);
instrumentList->addItem(item);
oldMidiInstrument = 0;
@@ -1040,25 +958,17 @@ void EditInstrument::fileSaveAs()
break;
}
- //QString path = QDir::homePath() + "/" + MusEGlobal::config.instrumentPath;
- //QString path = QDir::homeDirPath() + "/" + MusEGlobal::museGlobalShare;
- //QString path = MusEGlobal::museInstruments;
QString path = MusEGlobal::museUserInstruments;
if(!QDir(MusEGlobal::museUserInstruments).exists())
{
printf("MusE Error! User instrument directory: %s does not exist. Should be created at startup!\n", MusEGlobal::museUserInstruments.toLatin1().constData());
- //path = MusEGlobal::museUser;
+ //path = MusEGlobal::museUser; DELETETHIS
//path = MusEGlobal::configPath;
}
path += QString("/%1.idf").arg(so);
-
- //QString s = QFileDialog::getSaveFileName(this,
- // tr("MusE: Save Instrument Definition"),
- // path,
- // tr("Instrument Definition (*.idf)"));
-
+
QString sfn;
// If we are overwriting a user instrument just force the path.
if(isuser)
@@ -1069,12 +979,9 @@ void EditInstrument::fileSaveAs()
path, tr("Instrument Definition (*.idf)"));
if (sfn.isEmpty())
return;
- //instrument->setFilePath(s);
workingInstrument.setFilePath(sfn);
}
- //if (fileSave(instrument, s))
- // instrument->setDirty(false);
if(fileSave(&workingInstrument, sfn))
workingInstrument.setDirty(false);
}
@@ -1099,7 +1006,7 @@ void EditInstrument::closeEvent(QCloseEvent* ev)
patchNameReturn();
ctrlNameReturn();
- //QListWidgetItem* item = instrumentList->currentItem();
+ //QListWidgetItem* item = instrumentList->currentItem(); DELETETHIS
// ListBoxData* item = (ListBoxData*)instrumentList->selectedItem();
@@ -1117,16 +1024,10 @@ void EditInstrument::closeEvent(QCloseEvent* ev)
{
// No save:
case 1:
- //item->setText(instrument->iname());
- //instrumentList->triggerUpdate(true);
- //instrument->setDirty(false);
workingInstrument.setDirty(false);
if(oi)
{
oldMidiInstrument->setText(oi->iname());
- //workingInstrument.setIName(oi->iname());
-
- //workingInstrument.assign(*oi);
// No file path? Only a new unsaved instrument can do that. So delete it.
if(oi->filePath().isEmpty())
@@ -1149,14 +1050,10 @@ void EditInstrument::closeEvent(QCloseEvent* ev)
// Save:
case 0:
- //if(oi)
- // oi->assign(workingInstrument);
workingInstrument.setDirty(false);
break;
}
-
-// }
QMainWindow::closeEvent(ev);
}
@@ -1172,10 +1069,8 @@ void EditInstrument::changeInstrument()
if(!sel)
return;
- //oldMidiInstrument = (MusECore::MidiInstrument*)sel->data();
oldMidiInstrument = sel;
// Assignment
- //workingInstrument = *((MusECore::MidiInstrument*)sel->data());
// Assign will 'delete' any existing patches, groups, or controllers.
workingInstrument.assign( *((MusECore::MidiInstrument*)sel->data(Qt::UserRole).value<void*>()) );
@@ -1189,23 +1084,11 @@ void EditInstrument::changeInstrument()
patchView->clear();
patchView->blockSignals(false);
- //viewController->blockSignals(true);
for (int i = 0; i < viewController->topLevelItemCount(); ++i)
qDeleteAll(viewController->topLevelItem(i)->takeChildren());
viewController->clear();
- //viewController->blockSignals(false);
-
- //listController->clear();
- //category->clear();
- //sysexList->clear();
-
-
- //MusECore::MidiInstrument* instrument = (MusECore::MidiInstrument*)sel->data(Qt::UserRole).value<void*>();
- //MusECore::MidiInstrument* instrument = (MusECore::MidiInstrument*)sel->data();
- //instrument->setDirty(false);
instrumentName->blockSignals(true);
- //instrumentName->setText(instrument->iname());
instrumentName->setText(workingInstrument.iname());
instrumentName->blockSignals(false);
@@ -1233,55 +1116,30 @@ void EditInstrument::changeInstrument()
nullParamSpinBoxH->blockSignals(false);
nullParamSpinBoxL->blockSignals(false);
- //std::vector<MusECore::PatchGroup>* pg = instrument->groups();
- //MusECore::PatchGroupList* pg = instrument->groups();
MusECore::PatchGroupList* pg = workingInstrument.groups();
- //for (std::vector<MusECore::PatchGroup>::iterator g = pg->begin(); g != pg->end(); ++g) {
for (MusECore::ciPatchGroup g = pg->begin(); g != pg->end(); ++g) {
MusECore::PatchGroup* pgp = *g;
if(pgp)
{
- //QTreeWidgetItem* item = new QTreeWidgetItem;
QTreeWidgetItem* item = new QTreeWidgetItem(patchView);
- //item->setText(0, g->name);
item->setText(0, pgp->name);
- //QVariant v = QVariant::fromValue((void*)0);
- //item->setData(0, Qt::UserRole, v);
- //item->setData((void*)*g);
- //item->setData((void*)0);
- //item->setData((void*)&*g);
- //item->setData((void*)pgp);
QVariant v = qVariantFromValue((void*)(pgp));
item->setData(0, Qt::UserRole, v);
- //patchView->addTopLevelItem(item);
- //for (MusECore::ciPatch p = g->patches.begin(); p != g->patches.end(); ++p)
for (MusECore::ciPatch p = pgp->patches.begin(); p != pgp->patches.end(); ++p)
{
- //const Patch& patch = *p;
MusECore::Patch* patch = *p;
if(patch)
{
- //QTreeWidgetItem* sitem = new QTreeWidgetItem;
QTreeWidgetItem* sitem = new QTreeWidgetItem(item);
- //printf("%s \n", qPrintable(patch->name));
-
- //sitem->setText(0, patch.name);
- //sitem->setText(0, p->name);
sitem->setText(0, patch->name);
- //QVariant v = QVariant::fromValue((void*)patch);
- //sitem->setData(0, Qt::UserRole, v);
- //sitem->setData((void*)&*p);
- //sitem->setData((void*)patch);
QVariant v = QVariant::fromValue((void*)patch);
sitem->setData(0, Qt::UserRole, v);
- //item->addChild(sitem);
}
}
}
}
- //patchView->setSelected(patchView->item(0), true);
oldPatchItem = 0;
@@ -1289,20 +1147,20 @@ void EditInstrument::changeInstrument()
if(fc)
{
// This may cause a patchChanged call.
- //if(patchView->selectedItem() != fc)
+ //if(patchView->selectedItem() != fc) DELETETHIS
patchView->blockSignals(true);
fc->setSelected(true);
patchView->blockSignals(false);
//else
- // patchChanged();
+ // patchChanged(); DELETETHIS
- //patchView->firstChild()->setSelected(true);
+ //patchView->firstChild()->setSelected(true); DELETETHIS
//patchView->triggerUpdate(true);
}
patchChanged();
-// oldPatchItem = (ListViewData*)patchView->selectedItem();
+// oldPatchItem = (ListViewData*)patchView->selectedItem(); DELETETHIS
//patchChanged();
// if(oldPatchItem)
// {
@@ -1317,7 +1175,7 @@ void EditInstrument::changeInstrument()
MusECore::MidiControllerList* cl = workingInstrument.controller();
for (MusECore::ciMidiController ic = cl->begin(); ic != cl->end(); ++ic) {
MusECore::MidiController* c = ic->second;
- //QListWidgetItem* item = new QListWidgetItem(c->name());
+ //QListWidgetItem* item = new QListWidgetItem(c->name()); DELETETHIS
// ListBoxData* item = new ListBoxData(c->name());
//QVariant v = QVariant::fromValue((void*)c);
//item->setData(Qt::UserRole, v);
@@ -1328,7 +1186,7 @@ void EditInstrument::changeInstrument()
}
- //listController->setItemSelected(listController->item(0), true);
+ //listController->setItemSelected(listController->item(0), true); DELETETHIS
// oldController = 0;
@@ -1338,7 +1196,7 @@ void EditInstrument::changeInstrument()
if(ci)
{
- // This may cause a controllerChanged call.
+ // This may cause a controllerChanged call. DELETETHIS
//if(listController->selectedItem != ci)
// listController->blockSignals(true);
// listController->setSelected(ci, true);
@@ -1353,13 +1211,13 @@ void EditInstrument::changeInstrument()
controllerChanged();
- //oldController = (ListBoxData*)listController->selectedItem();
+ //oldController = (ListBoxData*)listController->selectedItem(); DELETETHIS
//controllerChanged(listController->item(0), 0);
//controllerChanged();
-/*
+/* DELETETHIS
category->addItems(instrument->categories());
foreach(const SysEx* s, instrument->sysex()) {
@@ -1411,25 +1269,17 @@ void EditInstrument::instrumentChanged()
if(!sel)
return;
- //printf("instrument changed: %s\n", sel->text().toLatin1().constData());
-
- //if (old) {
- //if(oldMidiInstrument)
- //{
MusECore::MidiInstrument* oi = 0;
if(oldMidiInstrument)
oi = (MusECore::MidiInstrument*)oldMidiInstrument->data(Qt::UserRole).value<void*>();
MusECore::MidiInstrument* wip = &workingInstrument;
// Returns true if aborted.
- //checkDirty(oi);
- //if(checkDirty(oi))
if(checkDirty(wip))
{
// No save was chosen. Abandon changes, or delete if it is new...
if(oi)
{
oldMidiInstrument->setText(oi->iname());
- //wip->setText(oi->iname());
// No file path? Only a new unsaved instrument can do that. So delete it.
if(oi->filePath().isEmpty())
@@ -1441,20 +1291,9 @@ void EditInstrument::instrumentChanged()
}
}
- //else
- //{
- // Save was chosen.
- // if(oi)
- // oi->assign(workingInstrument);
- //}
-
- //oi->setDirty(false);
- //wip->setDirty(false);
workingInstrument.setDirty(false);
- //}
changeInstrument();
-
}
//---------------------------------------------------------
@@ -1462,9 +1301,7 @@ void EditInstrument::instrumentChanged()
//---------------------------------------------------------
void EditInstrument::instrumentNameReturn()
-//void EditInstrument::instrumentNameChanged(const QString& s)
{
- //instrumentNameChanged(instrumentName->text());
QListWidgetItem* item = instrumentList->currentItem();
if (item == 0)
@@ -1482,7 +1319,6 @@ void EditInstrument::instrumentNameReturn()
{
instrumentName->blockSignals(true);
// Grab the last valid name from the item text, since the instrument has not been updated yet.
- //instrumentName->setText(curins->iname());
instrumentName->setText(item->text());
instrumentName->blockSignals(false);
@@ -1497,16 +1333,9 @@ void EditInstrument::instrumentNameReturn()
}
}
- //if (s != workingInstrument.iname()) {
- item->setText(s);
- //MusECore::MidiInstrument* instrument = (MusECore::MidiInstrument*)item->data(Qt::UserRole).value<void*>();
- //MusECore::MidiInstrument* instrument = (MusECore::MidiInstrument*)item->data();
- //instrument->setDirty(true);
- workingInstrument.setIName(s);
- workingInstrument.setDirty(true);
- //instrumentList->updateItem(item);
- //instrumentList->update();
- // }
+ item->setText(s);
+ workingInstrument.setIName(s);
+ workingInstrument.setDirty(true);
}
//---------------------------------------------------------
@@ -1518,20 +1347,15 @@ void EditInstrument::deleteInstrument(QListWidgetItem* item)
if(!item)
return;
- //ListBoxData* curritem = (ListBoxData*)instrumentList->selectedItem();
-
MusECore::MidiInstrument* ins = (MusECore::MidiInstrument*)item->data(Qt::UserRole).value<void*>();
- // Be kind to the list item, just in case we install a delete handler or something.
- //item->setData(0);
-
// Delete the list item.
// Test this: Is this going to change the current selection?
instrumentList->blockSignals(true);
delete item;
instrumentList->blockSignals(false);
- // Test this: Neccessary?
+ // Test this: Neccessary? DELETETHIS
// if(curritem)
// instrumentList->setCurrentItem(curritem);
@@ -1619,7 +1443,6 @@ void EditInstrument::patchNameReturn()
{
patchNameEdit->blockSignals(true);
// Grab the last valid name from the item text, since the patch has not been updated yet.
- //patchNameEdit->setText(curp->name);
patchNameEdit->setText(item->text(0));
patchNameEdit->blockSignals(false);
@@ -1642,7 +1465,6 @@ void EditInstrument::patchNameReturn()
{
patchNameEdit->blockSignals(true);
// Grab the last valid name from the item text, since the patch group has not been updated yet.
- //patchNameEdit->setText(curpg->name);
patchNameEdit->setText(item->text(0));
patchNameEdit->blockSignals(false);
@@ -1661,6 +1483,7 @@ void EditInstrument::patchNameReturn()
item->setText(0, s);
workingInstrument.setDirty(true);
+ // DELETETHIS
// Since the name of the patch/group in the working instrument will be updated later,
// there's no need to do manually set the name here now.
/*
@@ -1696,15 +1519,8 @@ void EditInstrument::patchNameReturn()
//---------------------------------------------------------
void EditInstrument::patchChanged()
{
- //if (old && old->data(0, Qt::UserRole).value<void*>()) {
if(oldPatchItem)
{
- //QListWidgetItem* item = instrumentList->currentItem();
- //if (item == 0)
- // return;
- //MusECore::MidiInstrument* instrument = (MusECore::MidiInstrument*)item->data(Qt::UserRole).value<void*>();
- //MusECore::Patch* p = (MusECore::Patch*)old->data(0, Qt::UserRole).value<void*>();
- //updatePatch(instrument, p);
if(oldPatchItem->parent())
updatePatch(&workingInstrument, (MusECore::Patch*)oldPatchItem->data(0, Qt::UserRole).value<void*>());
else
@@ -1746,12 +1562,10 @@ void EditInstrument::patchChanged()
spinBoxHBank->setValue(hb);
spinBoxLBank->setValue(lb);
spinBoxProgram->setValue(pr);
- //checkBoxDrum->setChecked(p->drumMap);
checkBoxDrum->setChecked(p->drum);
checkBoxGM->setChecked(p->typ & 1);
checkBoxGS->setChecked(p->typ & 2);
checkBoxXG->setChecked(p->typ & 4);
- //category->setCurrentIndex(p->categorie);
}
else
// The item is a patch group item.
@@ -1782,10 +1596,7 @@ void EditInstrument::defPatchChanged(int)
int val = getDefaultPatchNumber();
- //if(val == c->minVal() - 1)
- // c->setInitVal(MusECore::CTRL_VAL_UNKNOWN);
- //else
- c->setInitVal(val);
+ c->setInitVal(val);
setDefaultPatchName(val);
@@ -1799,13 +1610,6 @@ void EditInstrument::defPatchChanged(int)
void EditInstrument::patchButtonClicked()
{
- //MidiTrack* track = (MidiTrack*)selected;
- //int channel = track->outChannel();
- //int port = track->outPort();
- //MusECore::MidiInstrument* instr = midiPorts[port].instrument();
-
- //patchpopup->clear();
-
QMenu* patchpopup = new QMenu;
MusECore::PatchGroupList* pg = workingInstrument.groups();
@@ -1819,17 +1623,10 @@ void EditInstrument::patchButtonClicked()
const MusECore::PatchList& pl = pgp->patches;
for (MusECore::ciPatch ipl = pl.begin(); ipl != pl.end(); ++ipl) {
const MusECore::Patch* mp = *ipl;
- //if ((mp->typ & mask) &&
- // ((drum && songType != MT_GM) ||
- // (mp->drum == drumchan)) )
-
- // {
int id = ((mp->hbank & 0xff) << 16)
+ ((mp->lbank & 0xff) << 8) + (mp->prog & 0xff);
QAction *ac1 = pm->addAction(mp->name);
- ac1->setData(id);
- // }
-
+ ac1->setData(id);
}
}
}
@@ -1838,12 +1635,10 @@ void EditInstrument::patchButtonClicked()
const MusECore::PatchList& pl = pg->front()->patches;
for (MusECore::ciPatch ipl = pl.begin(); ipl != pl.end(); ++ipl) {
const MusECore::Patch* mp = *ipl;
- //if (mp->typ & mask) {
int id = ((mp->hbank & 0xff) << 16)
+ ((mp->lbank & 0xff) << 8) + (mp->prog & 0xff);
QAction *ac2 = patchpopup->addAction(mp->name);
ac2->setData(id);
- // }
}
}
@@ -1865,8 +1660,6 @@ void EditInstrument::patchButtonClicked()
if (rv != -1)
{
- //if(rv != workingInstrument.
-
setDefaultPatchControls(rv);
QTreeWidgetItem* item = viewController->currentItem();
@@ -1896,7 +1689,6 @@ QTreeWidgetItem* EditInstrument::addControllerToView(MusECore::MidiController* m
QString def;
int defval = mctrl->initVal();
int n = mctrl->num();
- //int h = (n >> 7) & 0x7f;
int h = (n >> 8) & 0x7f;
int l = n & 0x7f;
if((n & 0xff) == 0xff)
@@ -1906,8 +1698,6 @@ QTreeWidgetItem* EditInstrument::addControllerToView(MusECore::MidiController* m
switch(t)
{
case MusECore::MidiController::Controller7:
- //case MusECore::MidiController::RPN:
- //case MusECore::MidiController::NRPN:
hnum = "---";
if(l == -1)
lnum = "*";
@@ -1958,8 +1748,6 @@ QTreeWidgetItem* EditInstrument::addControllerToView(MusECore::MidiController* m
default:
hnum = "---";
lnum = "---";
- //min.setNum(0);
- //max.setNum(0);
min = "---";
max = "---";
def = "---";
@@ -1967,12 +1755,8 @@ QTreeWidgetItem* EditInstrument::addControllerToView(MusECore::MidiController* m
}
QTreeWidgetItem* ci = new QTreeWidgetItem(viewController, QStringList() << mctrl->name() << int2ctrlType(t) << hnum << lnum << min << max << def);
- //ListViewData* ci = new ListViewData(viewController, mctrl->name(), int2ctrlType(t),
- // hnum, lnum, min, max, def);
- //ci->setData((void*)mctrl);
QVariant v = qVariantFromValue((void*)(mctrl));
ci->setData(0, Qt::UserRole, v);
- //setModified(true);
return ci;
}
@@ -1983,29 +1767,13 @@ QTreeWidgetItem* EditInstrument::addControllerToView(MusECore::MidiController* m
void EditInstrument::controllerChanged()
{
- //if (old) {
-// if(oldController)
-// {
- //QListWidgetItem* item = instrumentList->currentItem();
- //if (item == 0)
- // return;
- //MusECore::MidiInstrument* instrument = (MusECore::MidiInstrument*)item->data(Qt::UserRole).value<void*>();
- //MusECore::MidiController* oc = (MusECore::MidiController*)old->data(Qt::UserRole).value<void*>();
- //updateController(instrument, oc);
-// updateController(&workingInstrument, (MusECore::MidiController*)oldController->data());
-// }
-
- // ListBoxData* sel = (ListBoxData*)listController->selectedItem();
-
QTreeWidgetItem* sel = viewController->selectedItems().size() ? viewController->selectedItems()[0] : 0;
-// oldController = sel;
if(!sel || !sel->data(0, Qt::UserRole).value<void*>())
{
ctrlName->blockSignals(true);
ctrlName->setText("");
ctrlName->blockSignals(false);
- //ctrlComment->setText("");
return;
}
@@ -2015,33 +1783,24 @@ void EditInstrument::controllerChanged()
ctrlName->setText(c->name());
ctrlName->blockSignals(false);
- //ctrlComment->setText(c->comment());
int ctrlH = (c->num() >> 8) & 0x7f;
int ctrlL = c->num() & 0x7f;
if((c->num() & 0xff) == 0xff)
ctrlL = -1;
- //int type = int(c->type());
MusECore::MidiController::ControllerType type = MusECore::midiControllerType(c->num());
- //ctrlType->setCurrentIndex(type);
ctrlType->blockSignals(true);
ctrlType->setCurrentIndex(type);
ctrlType->blockSignals(false);
- //ctrlTypeChanged(type);
-
spinBoxHCtrlNo->blockSignals(true);
spinBoxLCtrlNo->blockSignals(true);
spinBoxMin->blockSignals(true);
spinBoxMax->blockSignals(true);
spinBoxDefault->blockSignals(true);
- //ctrlTypeChanged(type);
-
switch (type) {
- //case MusECore::MidiController::RPN:
- //case MusECore::MidiController::NRPN:
case MusECore::MidiController::Controller7:
spinBoxHCtrlNo->setEnabled(false);
spinBoxLCtrlNo->setEnabled(true);
@@ -2129,14 +1888,11 @@ void EditInstrument::controllerChanged()
{
spinBoxDefault->setRange(c->minVal() - 1, c->maxVal());
if(c->initVal() == MusECore::CTRL_VAL_UNKNOWN)
- //spinBoxDefault->setValue(c->minVal() - 1);
spinBoxDefault->setValue(spinBoxDefault->minimum());
else
spinBoxDefault->setValue(c->initVal());
}
- //moveWithPart->setChecked(c->moveWithPart());
-
spinBoxHCtrlNo->blockSignals(false);
spinBoxLCtrlNo->blockSignals(false);
spinBoxMin->blockSignals(false);
@@ -2149,7 +1905,6 @@ void EditInstrument::controllerChanged()
//---------------------------------------------------------
void EditInstrument::ctrlNameReturn()
-//void EditInstrument::ctrlNameChanged(const QString& s)
{
QTreeWidgetItem* item = viewController->currentItem();
@@ -2161,8 +1916,7 @@ void EditInstrument::ctrlNameReturn()
if(c->name() == cName)
return;
-
- //MusECore::MidiControllerList* cl = instrument->controller();
+
MusECore::MidiControllerList* cl = workingInstrument.controller();
for(MusECore::ciMidiController ic = cl->begin(); ic != cl->end(); ++ic)
{
@@ -2186,8 +1940,6 @@ void EditInstrument::ctrlNameReturn()
c->setName(ctrlName->text());
item->setText(COL_CNAME, ctrlName->text());
- //c->setName(s);
- //item->setText(COL_CNAME, s);
workingInstrument.setDirty(true);
}
@@ -2207,20 +1959,15 @@ void EditInstrument::ctrlTypeChanged(int idx)
if(t == MusECore::midiControllerType(c->num()))
return;
- //if(item)
- item->setText(COL_TYPE, ctrlType->currentText());
+ item->setText(COL_TYPE, ctrlType->currentText());
int hnum = 0, lnum = 0;
- //int rng = 0;
- //int min = 0, max = 0;
spinBoxMin->blockSignals(true);
spinBoxMax->blockSignals(true);
spinBoxDefault->blockSignals(true);
switch (t) {
- //case MusECore::MidiController::RPN:
- //case MusECore::MidiController::NRPN:
case MusECore::MidiController::Controller7:
spinBoxHCtrlNo->setEnabled(false);
spinBoxLCtrlNo->setEnabled(true);
@@ -2236,22 +1983,17 @@ void EditInstrument::ctrlTypeChanged(int idx)
spinBoxDefault->setValue(spinBoxDefault->minimum());
lnum = spinBoxLCtrlNo->value();
- //rng = 127;
- //min = -128;
- //max = 127;
- //if(item)
- //{
- //item->setText(COL_LNUM, QString().setNum(spinBoxLCtrlNo->value()));
- if(lnum == -1)
- item->setText(COL_LNUM, QString("*"));
- else
- item->setText(COL_LNUM, QString().setNum(lnum));
- item->setText(COL_HNUM, QString("---"));
- item->setText(COL_MIN, QString().setNum(spinBoxMin->value()));
- item->setText(COL_MAX, QString().setNum(spinBoxMax->value()));
- item->setText(COL_DEF, QString("---"));
- //}
+
+ if(lnum == -1)
+ item->setText(COL_LNUM, QString("*"));
+ else
+ item->setText(COL_LNUM, QString().setNum(lnum));
+ item->setText(COL_HNUM, QString("---"));
+ item->setText(COL_MIN, QString().setNum(spinBoxMin->value()));
+ item->setText(COL_MAX, QString().setNum(spinBoxMax->value()));
+ item->setText(COL_DEF, QString("---"));
break;
+
case MusECore::MidiController::RPN:
case MusECore::MidiController::NRPN:
spinBoxHCtrlNo->setEnabled(true);
@@ -2269,23 +2011,17 @@ void EditInstrument::ctrlTypeChanged(int idx)
hnum = spinBoxHCtrlNo->value();
lnum = spinBoxLCtrlNo->value();
- //rng = 127;
- //min = -128;
- //max = 127;
- //if(item)
- //{
- //item->setText(COL_LNUM, QString().setNum(spinBoxLCtrlNo->value()));
- //item->setText(COL_HNUM, QString().setNum(spinBoxHCtrlNo->value()));
- if(lnum == -1)
- item->setText(COL_LNUM, QString("*"));
- else
- item->setText(COL_LNUM, QString().setNum(lnum));
- item->setText(COL_HNUM, QString().setNum(hnum));
- item->setText(COL_MIN, QString().setNum(spinBoxMin->value()));
- item->setText(COL_MAX, QString().setNum(spinBoxMax->value()));
- item->setText(COL_DEF, QString("---"));
- //}
+
+ if(lnum == -1)
+ item->setText(COL_LNUM, QString("*"));
+ else
+ item->setText(COL_LNUM, QString().setNum(lnum));
+ item->setText(COL_HNUM, QString().setNum(hnum));
+ item->setText(COL_MIN, QString().setNum(spinBoxMin->value()));
+ item->setText(COL_MAX, QString().setNum(spinBoxMax->value()));
+ item->setText(COL_DEF, QString("---"));
break;
+
case MusECore::MidiController::Controller14:
case MusECore::MidiController::RPN14:
case MusECore::MidiController::NRPN14:
@@ -2304,23 +2040,16 @@ void EditInstrument::ctrlTypeChanged(int idx)
hnum = spinBoxHCtrlNo->value();
lnum = spinBoxLCtrlNo->value();
- //rng = 16383;
- //min = -16384;
- //max = 16383;
- //if(item)
- //{
- //item->setText(COL_LNUM, QString().setNum(spinBoxLCtrlNo->value()));
- //item->setText(COL_HNUM, QString().setNum(spinBoxHCtrlNo->value()));
- if(lnum == -1)
- item->setText(COL_LNUM, QString("*"));
- else
- item->setText(COL_LNUM, QString().setNum(lnum));
- item->setText(COL_HNUM, QString().setNum(hnum));
- item->setText(COL_MIN, QString().setNum(spinBoxMin->value()));
- item->setText(COL_MAX, QString().setNum(spinBoxMax->value()));
- item->setText(COL_DEF, QString("---"));
- //}
+ if(lnum == -1)
+ item->setText(COL_LNUM, QString("*"));
+ else
+ item->setText(COL_LNUM, QString().setNum(lnum));
+ item->setText(COL_HNUM, QString().setNum(hnum));
+ item->setText(COL_MIN, QString().setNum(spinBoxMin->value()));
+ item->setText(COL_MAX, QString().setNum(spinBoxMax->value()));
+ item->setText(COL_DEF, QString("---"));
break;
+
case MusECore::MidiController::Pitch:
spinBoxHCtrlNo->setEnabled(false);
spinBoxLCtrlNo->setEnabled(false);
@@ -2335,18 +2064,13 @@ void EditInstrument::ctrlTypeChanged(int idx)
spinBoxDefault->setRange(spinBoxMin->value() - 1, spinBoxMax->value());
spinBoxDefault->setValue(spinBoxDefault->minimum());
- //rng = 8191;
- //min = -8192;
- //max = 8191;
- //if(item)
- //{
item->setText(COL_LNUM, QString("---"));
item->setText(COL_HNUM, QString("---"));
item->setText(COL_MIN, QString().setNum(spinBoxMin->value()));
item->setText(COL_MAX, QString().setNum(spinBoxMax->value()));
item->setText(COL_DEF, QString("---"));
- //}
break;
+
case MusECore::MidiController::Program:
spinBoxHCtrlNo->setEnabled(false);
spinBoxLCtrlNo->setEnabled(false);
@@ -2361,17 +2085,13 @@ void EditInstrument::ctrlTypeChanged(int idx)
spinBoxDefault->setRange(0, 0);
spinBoxDefault->setValue(0);
- //if(item)
- //{
item->setText(COL_LNUM, QString("---"));
item->setText(COL_HNUM, QString("---"));
item->setText(COL_MIN, QString("---"));
item->setText(COL_MAX, QString("---"));
-
- //item->setText(COL_DEF, QString("0-0-0"));
item->setText(COL_DEF, QString("---"));
- //}
break;
+
// Shouldn't happen...
default:
spinBoxHCtrlNo->setEnabled(false);
@@ -2411,7 +2131,7 @@ void EditInstrument::ctrlTypeChanged(int idx)
}
- /*
+ /* DELETETHIS
if(rng != 0)
{
@@ -2500,7 +2220,6 @@ void EditInstrument::ctrlHNumChanged(int val)
QString s;
s.setNum(val);
MusECore::MidiController* c = (MusECore::MidiController*)item->data(0, Qt::UserRole).value<void*>();
- //int n = c->num() & 0xff;
int n = c->num() & 0x7fff00ff;
c->setNum(n | ((val & 0xff) << 8));
item->setText(COL_HNUM, s);
@@ -2518,7 +2237,6 @@ void EditInstrument::ctrlLNumChanged(int val)
if (item == 0)
return;
MusECore::MidiController* c = (MusECore::MidiController*)item->data(0, Qt::UserRole).value<void*>();
- //int n = c->num() & 0xff00;
int n = c->num() & ~0xff;
c->setNum(n | (val & 0xff));
if(val == -1)
@@ -2551,7 +2269,6 @@ void EditInstrument::ctrlMinChanged(int val)
c->setMinVal(val);
int rng = 0;
- //switch((MusECore::MidiController::ControllerType)ctrlType->currentItem())
switch(MusECore::midiControllerType(c->num()))
{
case MusECore::MidiController::Controller7:
@@ -2571,7 +2288,6 @@ void EditInstrument::ctrlMinChanged(int val)
int mx = c->maxVal();
- //if(val > item->text(COL_MAX).toInt())
if(val > mx)
{
c->setMaxVal(val);
@@ -2637,7 +2353,6 @@ void EditInstrument::ctrlMaxChanged(int val)
c->setMaxVal(val);
int rng = 0;
- //switch((MusECore::MidiController::ControllerType)ctrlType->currentItem())
switch(MusECore::midiControllerType(c->num()))
{
case MusECore::MidiController::Controller7:
@@ -2657,7 +2372,6 @@ void EditInstrument::ctrlMaxChanged(int val)
int mn = c->minVal();
- //if(val < item->text(COL_MIN).toInt())
if(val < mn)
{
c->setMinVal(val);
@@ -2798,49 +2512,23 @@ void EditInstrument::ctrlNullParamLChanged(int nvl)
void EditInstrument::deletePatchClicked()
{
- //QListWidgetItem* item = instrumentList->currentItem();
-// ListBoxData* item = (ListBoxData*)instrumentList->selectedItem();
-// if (item == 0)
-// return;
- //MusECore::MidiInstrument* instrument = (MusECore::MidiInstrument*)item->data(Qt::UserRole).value<void*>();
-// MusECore::MidiInstrument* instrument = (MusECore::MidiInstrument*)item->data();
- //QTreeWidgetItem* pi = patchView->currentItem();
QTreeWidgetItem* pi = patchView->currentItem();
if (pi == 0)
return;
- //void* p = pi->data(0, Qt::UserRole).value<void*>();
-// MusECore::Patch* patch = (MusECore::Patch*)pi->data();
- //if (p == 0)
- // If patch is zero it's a patch group.
-// if(patch == 0)
-
// If the item has a parent item, it's a patch item...
if(pi->parent())
{
- MusECore::PatchGroup* group = (MusECore::PatchGroup*)(pi->parent())->data(0, Qt::UserRole).value<void*>();
+ MusECore::PatchGroup* group = (MusECore::PatchGroup*)(pi->parent())->data(0, Qt::UserRole).value<void*>();
// If there is an allocated patch in the data, delete it.
- //MusECore::Patch* patch = (MusECore::Patch*)pi->auxData();
MusECore::Patch* patch = (MusECore::Patch*)pi->data(0, Qt::UserRole).value<void*>();
if(patch)
{
if(group)
- {
- //for(iPatch ip = group->patches.begin(); ip != group->patches.end(); ++ip)
- // if(&*ip == patch)
- // if(*ip == patch)
- // {
- //
- // printf("deletePatchClicked: erasing patch\n");
- //
- // group->patches.erase(ip);
- // break;
- // }
- //group->patches.remove( (const Patch&)(*patch) );
group->patches.remove(patch);
- }
+
delete patch;
}
}
@@ -2848,19 +2536,14 @@ void EditInstrument::deletePatchClicked()
// The item has no parent item, it's a patch group item...
{
// Is there an allocated patch group in the data?
- //MusECore::PatchGroup* group = (MusECore::PatchGroup*)pi->auxData();
MusECore::PatchGroup* group = (MusECore::PatchGroup*)pi->data(0, Qt::UserRole).value<void*>();
if(group)
{
MusECore::PatchGroupList* pg = workingInstrument.groups();
- //for(MusECore::ciPatchGroup ipg = pg->begin(); ipg != pg->end(); ++ipg)
for(MusECore::iPatchGroup ipg = pg->begin(); ipg != pg->end(); ++ipg)
{
- //printf("deletePatchClicked: working patch group name:%s ad:%X group name:%s ad:%X\n", (*ipg)->name.toLatin1().constData(), (unsigned int)(*ipg), group->name.toLatin1().constData(), (unsigned int) group);
-
- //if(&*ipg == group)
if(*ipg == group)
{
pg->erase(ipg);
@@ -2868,43 +2551,20 @@ void EditInstrument::deletePatchClicked()
}
}
- // Iterate all child list view (patch) items. Find and delete any allocated patches in the items' data.
-// for(ListViewData* i = (ListViewData*)pi->firstChild(); i; i = (ListViewData*)i->nextSibling())
-// {
- //MusECore::Patch* patch = (MusECore::Patch*)i->auxData();
-// MusECore::Patch* patch = (MusECore::Patch*)i->data();
-// if(patch)
-// {
- //delete patch;
- //group->patches.remove(*patch);
const MusECore::PatchList& pl = group->patches;
for(MusECore::ciPatch ip = pl.begin(); ip != pl.end(); ++ip)
{
-// if(&*ip == patch)
-// {
-// group->patches.erase(ip);
-// break;
-// }
-
// Delete the patch.
if(*ip)
delete *ip;
}
- //group->patches.clear();
-
-// }
-// }
-
// Now delete the group.
delete group;
}
}
- //oldPatchItem = (ListViewData*)patchView->selectedItem();
- //oldPatchItem = 0;
-
// Now delete the patch or group item (and any child patch items) from the list view tree.
// !!! This will trigger a patchChanged call.
patchView->blockSignals(true);
@@ -2916,24 +2576,6 @@ void EditInstrument::deletePatchClicked()
oldPatchItem = 0;
patchChanged();
- //MusECore::Patch* patch = (MusECore::Patch*)p;
-
- //std::vector<MusECore::PatchGroup>* pg = instrument->groups();
- //for (std::vector<MusECore::PatchGroup>::iterator g = pg->begin(); g != pg->end(); ++g) {
- // for (MusECore::iPatch p = g->patches.begin(); p != g->patches.end(); ++p) {
- // if (patch == *p) {
- // g->patches.erase(p);
- // delete pi;
- // instrument->setDirty(true);
- // return;
- // }
- // }
- // }
- //printf("fatal: patch not found\n");
- //delete patch;
- //delete pi;
-
-
workingInstrument.setDirty(true);
}
@@ -2943,11 +2585,6 @@ void EditInstrument::deletePatchClicked()
void EditInstrument::newPatchClicked()
{
- //QListWidgetItem* item = instrumentList->currentItem();
-// ListBoxData* item = (ListBoxData*)instrumentList->selectedItem();
-// if (item == 0)
-// return;
-
if(oldPatchItem)
{
if(oldPatchItem->parent())
@@ -2955,23 +2592,16 @@ void EditInstrument::newPatchClicked()
else
updatePatchGroup(&workingInstrument, (MusECore::PatchGroup*)oldPatchItem->data(0, Qt::UserRole).value<void*>());
}
-
- //MusECore::MidiInstrument* instrument = (MusECore::MidiInstrument*)item->data(Qt::UserRole).value<void*>();
-// MusECore::MidiInstrument* instrument = (MusECore::MidiInstrument*)item->data();
- //std::vector<MusECore::PatchGroup>* pg = instrument->groups();
-// MusECore::PatchGroupList* pg = instrument->groups();
+
MusECore::PatchGroupList* pg = workingInstrument.groups();
QString patchName;
for (int i = 1;; ++i) {
patchName = QString("Patch-%1").arg(i);
bool found = false;
- //for (std::vector<MusECore::PatchGroup>::iterator g = pg->begin(); g != pg->end(); ++g) {
for (MusECore::iPatchGroup g = pg->begin(); g != pg->end(); ++g) {
MusECore::PatchGroup* pgp = *g;
- //for (MusECore::iPatch p = g->patches.begin(); p != g->patches.end(); ++p) {
for (MusECore::iPatch p = pgp->patches.begin(); p != pgp->patches.end(); ++p) {
- //if (p->name == patchName) {
if ((*p)->name == patchName) {
found = true;
break;
@@ -2984,20 +2614,12 @@ void EditInstrument::newPatchClicked()
break;
}
- //
// search current patch group
- //
- //MusECore::PatchGroup* pGroup = 0;
- //QTreeWidgetItem* pi = patchView->currentItem();
QTreeWidgetItem* pi = patchView->currentItem();
if (pi == 0)
return;
- // If there is data then pi is a patch item, and there must be a parent patch group item (with null data).
- //if (pi->data(0, Qt::UserRole).value<void*>())
- //if (pi->data())
-
MusECore::Patch* selpatch = 0;
// If there is a parent item then pi is a patch item, and there must be a parent patch group item.
@@ -3013,17 +2635,6 @@ void EditInstrument::newPatchClicked()
if(!group)
return;
- //for (std::vector<MusECore::PatchGroup>::iterator g = pg->begin(); g != pg->end(); ++g) {
-// for (MusECore::ciPatchGroup g = pg->begin(); g != pg->end(); ++g) {
-// if (g->name == pi->text(0)) {
-// pGroup = &*g;
-// break;
-// }
-// }
-// if (pGroup == 0) {
-// printf("group not found\n");
-// return;
-// }
// Create a new Patch, then store its pointer in a new patch item,
// to be added later to the patch group only upon save...
@@ -3062,10 +2673,10 @@ void EditInstrument::newPatchClicked()
for(MusECore::iPatchGroup g = pg->begin(); g != pg->end(); ++g)
{
- MusECore::PatchGroup* pgp = *g;
+ MusECore::PatchGroup* pgp = *g;
for(MusECore::iPatch ip = pgp->patches.begin(); ip != pgp->patches.end(); ++ip)
{
- MusECore::Patch* p = *ip;
+ MusECore::Patch* p = *ip;
if((p->prog == ((prg + i) & 0x7f)) &&
((p->lbank == -1 && lb == -1) || (p->lbank == ((lb + j) & 0x7f))) &&
((p->hbank == -1 && hb == -1) || (p->hbank == ((hb + k) & 0x7f))))
@@ -3091,8 +2702,6 @@ void EditInstrument::newPatchClicked()
else
patch->hbank = (hb + k) & 0x7f;
- //patch->typ = selpatch->typ;
- //patch->drum = selpatch->drum;
break;
}
@@ -3107,34 +2716,14 @@ void EditInstrument::newPatchClicked()
patch->name = patchName;
group->patches.push_back(patch);
- //MusECore::Patch* pp = &(group->patches.back());
-
- //QTreeWidgetItem* sitem = new QTreeWidgetItem;
+
QTreeWidgetItem* sitem = new QTreeWidgetItem(pi);
- //sitem->setText(0, patch->name);
sitem->setText(0, patchName);
patchNameEdit->setText(patchName);
- //QVariant v = QVariant::fromValue((void*)(patch));
- //sitem->setData(0, Qt::UserRole, v);
-
- // Set the list view item's data.
- //sitem->setData((void*)patch);
QVariant v = qVariantFromValue((void*)(patch));
sitem->setData(0, Qt::UserRole, v);
- //sitem->setAuxData((void*)patch);
- //sitem->setData((void*)pp);
-
- //pi->addChild(sitem);
-
- //printf("newPatchClicked: before patchView->setCurrentItem\n");
-
- //patchView->setCurrentItem(sitem);
-
- //printf("newPatchClicked: after patchView->setCurrentItem\n");
-
- //oldPatchItem = 0;
// May cause patchChanged call.
patchView->blockSignals(true);
@@ -3142,10 +2731,6 @@ void EditInstrument::newPatchClicked()
patchView->scrollToItem((QTreeWidgetItem*)sitem, QAbstractItemView::EnsureVisible);
patchView->blockSignals(false);
- //oldPatchItem = (ListViewData*)patchView->selectedItem();
- //oldPatchItem = sitem;
- //oldPatchItem = 0;
-
spinBoxHBank->setEnabled(true);
spinBoxLBank->setEnabled(true);
spinBoxProgram->setEnabled(true);
@@ -3157,7 +2742,6 @@ void EditInstrument::newPatchClicked()
oldPatchItem = 0;
patchChanged();
- //instrument->setDirty(true);
workingInstrument.setDirty(true);
}
@@ -3167,11 +2751,6 @@ void EditInstrument::newPatchClicked()
void EditInstrument::newGroupClicked()
{
- //QListWidgetItem* item = instrumentList->currentItem();
-// ListBoxData* item = (ListBoxData*)instrumentList->selectedItem();
-// if (item == 0)
-// return;
-
if(oldPatchItem)
{
if(oldPatchItem->parent())
@@ -3180,19 +2759,13 @@ void EditInstrument::newGroupClicked()
updatePatchGroup(&workingInstrument, (MusECore::PatchGroup*)oldPatchItem->data(0, Qt::UserRole).value<void*>());
}
- //MusECore::MidiInstrument* instrument = (MusECore::MidiInstrument*)item->data(Qt::UserRole).value<void*>();
-// MusECore::MidiInstrument* instrument = (MusECore::MidiInstrument*)item->data();
- //std::vector<MusECore::PatchGroup>* pg = instrument->groups();
-// MusECore::PatchGroupList* pg = instrument->groups();
MusECore::PatchGroupList* pg = workingInstrument.groups();
QString groupName;
for (int i = 1;; ++i) {
groupName = QString("Group-%1").arg(i);
bool found = false;
- //for (std::vector<MusECore::PatchGroup>::iterator g = pg->begin(); g != pg->end(); ++g) {
for (MusECore::ciPatchGroup g = pg->begin(); g != pg->end(); ++g) {
- //if (g->name == groupName) {
if ((*g)->name == groupName) {
found = true;
break;
@@ -3206,40 +2779,25 @@ void EditInstrument::newGroupClicked()
// to be added later to the instrument only upon save...
MusECore::PatchGroup* group = new MusECore::PatchGroup;
group->name = groupName;
- //MusECore::PatchGroup group;
- //group.name = groupName;
pg->push_back(group);
- //MusECore::PatchGroup* pgp = &(pg->back());
QTreeWidgetItem* sitem = new QTreeWidgetItem(patchView);
sitem->setText(0, groupName);
patchNameEdit->setText(groupName);
- //QVariant v = QVariant::fromValue((void*)0);
- //sitem->setData(0, Qt::UserRole, v);
- //sitem->setData((void*)0);
-
// Set the list view item's data.
QVariant v = qVariantFromValue((void*)(group));
sitem->setData(0, Qt::UserRole, v);
//sitem->setAuxData((void*)pgp);
- //patchView->addTopLevelItem(sitem);
- //patchView->setCurrentItem(sitem);
-
- //oldPatchItem = 0;
-
// May cause patchChanged call.
patchView->blockSignals(true);
sitem->setSelected(true);
patchView->blockSignals(false);
- //oldPatchItem = (ListViewData*)patchView->selectedItem();
oldPatchItem = sitem;
- //oldPatchItem = 0;
- //patchChanged();
spinBoxHBank->setEnabled(false);
spinBoxLBank->setEnabled(false);
@@ -3249,7 +2807,6 @@ void EditInstrument::newGroupClicked()
checkBoxGS->setEnabled(false);
checkBoxXG->setEnabled(false);
- //instrument->setDirty(true);
workingInstrument.setDirty(true);
}
@@ -3259,21 +2816,10 @@ void EditInstrument::newGroupClicked()
void EditInstrument::deleteControllerClicked()
{
- //QListWidgetItem* item = instrumentList->currentItem();
- //ListBoxData* item = (ListBoxData*)instrumentList->selectedItem();
- //QListWidgetItem* item2 = listController->currentItem();
-// ListBoxData* item = (ListBoxData*)listController->selectedItem();
QTreeWidgetItem* item = viewController->currentItem();
- //if (item == 0 || item2 == 0)
if(!item)
return;
- //MusECore::MidiInstrument* instrument = (MusECore::MidiInstrument*)item->data(Qt::UserRole).value<void*>();
-// MusECore::MidiInstrument* instrument = (MusECore::MidiInstrument*)item->data();
- //MusECore::MidiController* ctrl = (MusECore::MidiController*)item2->data(Qt::UserRole).value<void*>();
- //MusECore::MidiController* ctrl = (MusECore::MidiController*)item2->data();
- //MusECore::MidiControllerList* cl = instrument->controller();
- //cl->removeAll(ctrl);
MusECore::MidiController* ctrl = (MusECore::MidiController*)item->data(0, Qt::UserRole).value<void*>();
if(!ctrl)
@@ -3285,20 +2831,14 @@ void EditInstrument::deleteControllerClicked()
// Now remove the controller item from the list.
// This may cause a controllerChanged call.
-// listController->blockSignals(true);
viewController->blockSignals(true);
delete item;
if(viewController->currentItem())
viewController->currentItem()->setSelected(true);
-// listController->blockSignals(false);
viewController->blockSignals(false);
- //oldController = (ListBoxData*)listController->selectedItem();
-// oldController = 0;
-
controllerChanged();
- //instrument->setDirty(true);
workingInstrument.setDirty(true);
}
@@ -3307,20 +2847,10 @@ void EditInstrument::deleteControllerClicked()
//---------------------------------------------------------
void EditInstrument::newControllerClicked()
- {
- //QListWidgetItem* item = instrumentList->currentItem();
- //if (item == 0)
- // return;
- //MusECore::MidiInstrument* instrument = (MusECore::MidiInstrument*)item->data(Qt::UserRole).value<void*>();
-
-// if(oldController)
-// updateController(&workingInstrument, (MusECore::MidiController*)oldController->data());
-
+ {
QString cName;
- //MusECore::MidiControllerList* cl = instrument->controller();
MusECore::MidiControllerList* cl = workingInstrument.controller();
for (int i = 1;; ++i) {
- //ctrlName = QString("Controller-%d").arg(i);
cName = QString("Controller-%1").arg(i);
bool found = false;
for (MusECore::iMidiController ic = cl->begin(); ic != cl->end(); ++ic) {
@@ -3348,17 +2878,12 @@ void EditInstrument::newControllerClicked()
if(ci)
{
MusECore::MidiController* selctl = (MusECore::MidiController*)ci->data(0, Qt::UserRole).value<void*>();
- // Assign.
- // *ctrl = *selctl;
// Auto increment controller number.
- //int l = ctrl->num() & 0x7f;
- //int h = ctrl->num() & 0xffffff00;
int l = selctl->num() & 0x7f;
int h = selctl->num() & 0xffffff00;
// Ignore internal controllers and wild cards.
- //if(((h & 0xff0000) != 0x40000) && ((ctrl->num() & 0xff) != 0xff))
if(((h & 0xff0000) != 0x40000) && ((selctl->num() & 0xff) != 0xff))
{
// Assign.
@@ -3366,8 +2891,6 @@ void EditInstrument::newControllerClicked()
for (int i = 1; i < 128; ++i)
{
- //ctrlName = QString("Controller-%d").arg(i);
- //cName = QString("Controller-%1").arg(i);
int j = ((i + l) & 0x7f) | h;
found = false;
for (MusECore::iMidiController ic = cl->begin(); ic != cl->end(); ++ic)
@@ -3390,34 +2913,15 @@ void EditInstrument::newControllerClicked()
ctrl->setName(cName);
- //item = new QListWidgetItem(ctrlName);
-// ListBoxData* item = new ListBoxData(ctrlName);
-
- //QVariant v = qVariantFromValue((void*)(ctrl));
- //item->setData(Qt::UserRole, v);
-// item->setData((void*)ctrl);
- //listController->addItem(item);
-// listController->insertItem(item);
- //listController->setCurrentItem(item);
-
workingInstrument.controller()->add(ctrl);
QTreeWidgetItem* item = addControllerToView(ctrl);
-// listController->blockSignals(true);
-// listController->setSelected(item, true);
-// listController->blockSignals(false);
viewController->blockSignals(true);
item->setSelected(true);
viewController->blockSignals(false);
- //oldController = (ListBoxData*)listController->selectedItem();
-// oldController = item;
- //oldController = 0;
- // MidiController is a class, with itialized values. We have to call this to show the values.
- // To make multiple entries easier, don't bother calling this.
controllerChanged();
-
- //instrument->setDirty(true);
+
workingInstrument.setDirty(true);
}
@@ -3427,12 +2931,6 @@ void EditInstrument::newControllerClicked()
void EditInstrument::addControllerClicked()
{
- //int lnum = listController->currentItem();
- //if(lnum == -1)
- // return;
-
- //QString name = midiCtrlName(lnum);
-
QListWidgetItem* idx = listController->currentItem();
if(idx == 0)
return;
@@ -3504,7 +3002,7 @@ void EditInstrument::addControllerClicked()
workingInstrument.setDirty(true);
}
-/*
+/* DELETETHIS or later needed???
//---------------------------------------------------------
// deleteSysexClicked
//---------------------------------------------------------
@@ -3562,8 +3060,6 @@ void EditInstrument::updatePatch(MusECore::MidiInstrument* instrument, MusECore:
}
signed char hb = (spinBoxHBank->value() - 1) & 0xff;
- //if (p->hbank != (spinBoxHBank->value() & 0xff)) {
- // p->hbank = spinBoxHBank->value() & 0xff;
if (p->hbank != hb) {
p->hbank = hb;
@@ -3571,8 +3067,6 @@ void EditInstrument::updatePatch(MusECore::MidiInstrument* instrument, MusECore:
}
signed char lb = (spinBoxLBank->value() - 1) & 0xff;
- //if (p->lbank != (spinBoxLBank->value() & 0xff)) {
- // p->lbank = spinBoxLBank->value() & 0xff;
if (p->lbank != lb) {
p->lbank = lb;
@@ -3609,14 +3103,9 @@ void EditInstrument::updatePatch(MusECore::MidiInstrument* instrument, MusECore:
p->typ = value;
instrument->setDirty(true);
}
-
- //if (p->categorie != category->currentIndex()) {
- // p->categorie = category->currentIndex();
- // instrument->setDirty(true);
- // }
}
-/*
+/* DELETETHIS
//---------------------------------------------------------
// updateController
//---------------------------------------------------------
@@ -3704,38 +3193,10 @@ void EditInstrument::updateController(MusECore::MidiInstrument* instrument, MusE
void EditInstrument::updateInstrument(MusECore::MidiInstrument* instrument)
{
- //QListWidgetItem* sysexItem = sysexList->currentItem();
- //ListBoxData* sysexItem = sysexList->currentItem();
- //if (sysexItem) {
- // SysEx* so = (SysEx*)sysexItem->data(Qt::UserRole).value<void*>();
- // updateSysex(instrument, so);
- // }
-
- //QListWidgetItem* ctrlItem = listController->currentItem();
- //ListBoxData* ctrlItem = (ListBoxData*)listController->currentItem();
- //ListBoxData* ctrlItem = (ListBoxData*)listController->selectedItem();
-// ListViewData* ctrlItem = (ListViewData*)viewController->selectedItem();
-
-// if (ctrlItem) {
- //MusECore::MidiController* ctrl = (MusECore::MidiController*)ctrlItem->data(Qt::UserRole).value<void*>();
-
-// printf("updateInstrument: AB\n");
-
-// MusECore::MidiController* ctrl = (MusECore::MidiController*)ctrlItem->data();
-
-// printf("updateInstrument: AC\n");
-
-// updateController(instrument, ctrl);
-// }
-
-// printf("updateInstrument: B\n");
-
QTreeWidgetItem* patchItem = patchView->currentItem();
if (patchItem)
{
- //MusECore::Patch* p = (MusECore::Patch*)patchItem->data(0, Qt::UserRole).value<void*>();
-
// If the item has a parent, it's a patch item.
if(patchItem->parent())
updatePatch(instrument, (MusECore::Patch*)patchItem->data(0, Qt::UserRole).value<void*>());
@@ -3754,8 +3215,8 @@ int EditInstrument::checkDirty(MusECore::MidiInstrument* i, bool isClose)
{
updateInstrument(i);
if (!i->dirty())
- //return false;
return 0;
+
int n;
if(isClose)
n = QMessageBox::warning(this, tr("MusE"),
@@ -3770,18 +3231,13 @@ int EditInstrument::checkDirty(MusECore::MidiInstrument* i, bool isClose)
if (n == 0) {
if (i->filePath().isEmpty())
{
- //fileSaveAs();
saveAs();
}
else {
- //QFile f(i->filePath());
- //if (!f.open(QIODevice::WriteOnly))
FILE* f = fopen(i->filePath().toLatin1().constData(), "w");
if(f == 0)
- //fileSaveAs();
saveAs();
else {
- //f.close();
if(fclose(f) != 0)
printf("EditInstrument::checkDirty: Error closing file\n");
@@ -3789,10 +3245,8 @@ int EditInstrument::checkDirty(MusECore::MidiInstrument* i, bool isClose)
i->setDirty(false);
}
}
- //return false;
return 0;
}
- //return n == 2;
return n;
}
@@ -3899,7 +3353,7 @@ void EditInstrument::setDefaultPatchNumbers(int val)
defPatchH->blockSignals(true);
defPatchL->blockSignals(true);
defPatchProg->blockSignals(true);
- defPatchH->setValue(hb);
+ defPatchH->setValue(hb);
defPatchL->setValue(lb);
defPatchProg->setValue(pr);
defPatchH->blockSignals(false);
@@ -3927,8 +3381,6 @@ QString EditInstrument::getPatchName(int prog)
if(prog == MusECore::CTRL_VAL_UNKNOWN || pr == 0xff)
return "---";
- //int hbank = (prog >> 16) & 0x7f;
- //int lbank = (prog >> 8) & 0x7f;
int hbank = (prog >> 16) & 0xff;
int lbank = (prog >> 8) & 0xff;
@@ -3938,9 +3390,9 @@ QString EditInstrument::getPatchName(int prog)
const MusECore::PatchList& pl = (*i)->patches;
for (MusECore::ciPatch ipl = pl.begin(); ipl != pl.end(); ++ipl) {
const MusECore::Patch* mp = *ipl;
- if (//(mp->typ & tmask) &&
+ if (//(mp->typ & tmask) && DELETETHIS
(pr == mp->prog)
- //&& ((drum && mode != MT_GM) ||
+ //&& ((drum && mode != MT_GM) || DELETETHIS
// (mp->drum == drumchan))
//&& (hbank == mp->hbank || !hb || mp->hbank == -1)
diff --git a/muse2/muse/instruments/editinstrument.h b/muse2/muse/instruments/editinstrument.h
index ab5edf39..187f1989 100644
--- a/muse2/muse/instruments/editinstrument.h
+++ b/muse2/muse/instruments/editinstrument.h
@@ -87,7 +87,6 @@ class EditInstrument : public QMainWindow, public Ui::EditInstrumentBase {
void tabChanged(QWidget*);
void patchChanged();
void controllerChanged();
- //void instrumentNameChanged(const QString&);
void instrumentNameReturn();
void patchNameReturn();
void deletePatchClicked();
@@ -95,19 +94,17 @@ class EditInstrument : public QMainWindow, public Ui::EditInstrumentBase {
void newGroupClicked();
void patchButtonClicked();
void defPatchChanged(int);
- //void newCategoryClicked();
void deleteControllerClicked();
void newControllerClicked();
void addControllerClicked();
void ctrlTypeChanged(int);
- //void ctrlNameChanged(const QString&);
void ctrlNameReturn();
void ctrlHNumChanged(int);
void ctrlLNumChanged(int);
void ctrlMinChanged(int);
void ctrlMaxChanged(int);
void ctrlDefaultChanged(int);
- //void sysexChanged();
+ //void sysexChanged(); DELETETHIS?
//void deleteSysexClicked();
//void newSysexClicked();
void ctrlNullParamHChanged(int);
diff --git a/muse2/muse/instruments/midictrledit.cpp b/muse2/muse/instruments/midictrledit.cpp
index a9ca6383..44f1a150 100644
--- a/muse2/muse/instruments/midictrledit.cpp
+++ b/muse2/muse/instruments/midictrledit.cpp
@@ -146,19 +146,12 @@ void MidiControllerEditDialog::songChanged(int flags)
return;
if(flags & (SC_CONFIG | SC_MIDI_CONTROLLER))
- //if(flags & (SC_CONFIG | SC_MIDI_CONTROLLER_ADD))
{
- //listController->blockSignals(true);
midiPortsList->blockSignals(true);
- //viewController->blockSignals(true);
updatePredefinedList();
updateMidiPortsList();
updateViewController();
- //viewController->setCurrentItem(viewController->firstChild());
- //controllerChanged(viewController->currentItem());
- //listController->blockSignals(false);
midiPortsList->blockSignals(false);
- //viewController->blockSignals(false);
}
}
@@ -199,18 +192,11 @@ void MidiControllerEditDialog::updateMidiPortsList()
void MidiControllerEditDialog::updateViewController()
{
- //for (iMidiController i = midiControllerList.begin();
- // i != midiControllerList.end(); ++i) {
- // addControllerToView(&*i);
int mpidx = midiPortsList->currentItem();
viewController->clear();
- //MidiControllerList* mcl;
MidiInstrument* mi = midiPorts[mpidx].instrument();
- //if(mi)
MidiControllerList* mcl = mi->controller();
- //else
- // mcl = &defaultMidiController;
for (iMidiController i = mcl->begin(); i != mcl->end(); ++i)
addControllerToView(*i);
@@ -249,15 +235,6 @@ void MidiControllerEditDialog::setModified(bool v)
void MidiControllerEditDialog::reject()
{
- //MidiControllerList* mcl;
-// MidiInstrument* mi = midiPorts[mpidx].instrument();
- //if(mi)
-// MidiControllerList* mcl = mi->controller();
- //else
- // mcl = &defaultMidiController;
-// for (iMidiController i = mcl->begin(); i != mcl->end(); ++i)
-// addControllerToView(*i);
-
// Restore the list before closing this dialog.
updateViewController();
//setModified(false);
@@ -272,12 +249,8 @@ void MidiControllerEditDialog::reject()
void MidiControllerEditDialog::apply()
{
int mpidx = midiPortsList->currentItem();
- //MidiControllerList* mcl;
MidiInstrument* mi = midiPorts[mpidx].instrument();
- //if(mi)
MidiControllerList* mcl = mi->controller();
- //else
- // mcl = &defaultMidiController;
mcl->clear();
@@ -336,9 +309,6 @@ void MidiControllerEditDialog::apply()
item = item->nextSibling();
}
- // Update the list before closing this dialog.
- //updateViewController();
- //setModified(false);
MusEGlobal::song->update(SC_CONFIG | SC_MIDI_CONTROLLER);
}
@@ -442,14 +412,14 @@ void MidiControllerEditDialog::portChanged(int n)
return;
_lastPort = n;
- //listController->blockSignals(true);
+ //listController->blockSignals(true); DELETETHIS
//midiPortsList->blockSignals(true);
//viewController->blockSignals(true);
//updatePredefinedList();
//updateMidiPortsList();
//reject(); // populate list
updateViewController();
- //viewController->setCurrentItem(viewController->firstChild());
+ //viewController->setCurrentItem(viewController->firstChild()); DELETETHIS
//controllerChanged(viewController->currentItem());
//listController->blockSignals(false);
//midiPortsList->blockSignals(false);
diff --git a/muse2/muse/instruments/minstrument.cpp b/muse2/muse/instruments/minstrument.cpp
index bbb2a076..5d578803 100644
--- a/muse2/muse/instruments/minstrument.cpp
+++ b/muse2/muse/instruments/minstrument.cpp
@@ -26,14 +26,13 @@
#include <QAction>
#include <QDir>
#include <QFileInfo>
-//#include <QMenu>
#include <QMessageBox>
#include "minstrument.h"
#include "midiport.h"
-#include "mididev.h" // p4.0.15
-#include "audio.h" // p4.0.15
-#include "midi.h" // p4.0.15
+#include "mididev.h"
+#include "audio.h"
+#include "midi.h"
#include "globals.h"
#include "xml.h"
#include "event.h"
@@ -153,7 +152,7 @@ static void readEventList(Xml& xml, EventList* el, const char* name)
static void loadIDF(QFileInfo* fi)
{
-/*
+/* DELETETHIS
QFile qf(fi->filePath());
if (!qf.open(IO_ReadOnly)) {
printf("cannot open file %s\n", fi->fileName().toLatin1());
@@ -282,7 +281,7 @@ void initMidiInstruments()
++it;
}
}
- //else
+ //else DELETETHIS
//{
// if(usrInstrumentsDir.mkdir(MusEGlobal::museUserInstruments))
// printf("Created user instrument directory: %s\n", MusEGlobal::museUserInstruments.toLatin1());
@@ -416,8 +415,7 @@ MidiInstrument::~MidiInstrument()
}
-
-/*
+/* DELETETHIS
//---------------------------------------------------------
// uniqueCopy
//---------------------------------------------------------
@@ -465,7 +463,6 @@ MidiInstrument& MidiInstrument::assign(const MidiInstrument& ins)
_nullvalue = ins._nullvalue;
// Assignment
- // *_controller = *(ins._controller);
for(ciMidiController i = ins._controller->begin(); i != ins._controller->end(); ++i)
{
MidiController* mc = i->second;
@@ -473,7 +470,7 @@ MidiInstrument& MidiInstrument::assign(const MidiInstrument& ins)
}
// pg.clear();
-// for(iPatchGroup ipg = pg.begin(); ipg != pg.end(); ++ipg)
+// for(iPatchGroup ipg = pg.begin(); ipg != pg.end(); ++ipg) DELETETHIS
// {
//ipg->patches.clear();
@@ -498,7 +495,6 @@ MidiInstrument& MidiInstrument::assign(const MidiInstrument& ins)
pg.clear();
// Assignment
-// pg = ins.pg;
for(ciPatchGroup g = ins.pg.begin(); g != ins.pg.end(); ++g)
{
PatchGroup* pgp = *g;
@@ -527,7 +523,7 @@ MidiInstrument& MidiInstrument::assign(const MidiInstrument& ins)
- // Hmm, dirty, yes? But init sets it to false...
+ // Hmm, dirty, yes? But init sets it to false... DELETETHIS
//_dirty = ins._dirty;
//_dirty = false;
//_dirty = true;
@@ -543,18 +539,13 @@ MidiInstrument& MidiInstrument::assign(const MidiInstrument& ins)
void MidiInstrument::reset(int portNo, MType)
{
MusECore::MidiPort* port = &MusEGlobal::midiPorts[portNo];
- //if (port == 0)
- // return;
if(port->device() == 0) // p4.0.15
- {
- //printf("MidiInstrument::reset port device is 0\n");
return;
- }
+
MusECore::MidiPlayEvent ev;
ev.setType(0x90);
ev.setPort(portNo);
ev.setTime(0); // p4.0.15
- //ev.setTime(audio->getFrameOffset() + audio->pos().frame());
for (int chan = 0; chan < MIDI_CHANNELS; ++chan)
{
@@ -563,15 +554,8 @@ void MidiInstrument::reset(int portNo, MType)
{
ev.setA(pitch);
ev.setB(0);
- //printf("MidiInstrument::reset adding event channel:%d pitch:%d\n", chan, pitch);
- //ev.dump();
port->sendEvent(ev);
- // Changed to use play events list instead of putEvent FIFO.
- // These loops send 2048 events, which is more than our FIFO (or Jack buffer) can handle! p4.0.15 Tim.
- // Nope, instead, increased FIFO sizes to accommodate.
- //port->device()->playEvents()->add(ev);
- //port->device()->addScheduledEvent(ev);
}
}
}
@@ -661,13 +645,6 @@ void Patch::read(Xml& xml)
void Patch::write(int level, Xml& xml)
{
- //if (drumMap == 0)
- //{
- //QString s = QString("Patch name=\"%1\"").arg(Xml::xmlString(name));
- //if (typ != -1)
- // s += QString(" mode=\"%d\"").arg(typ);
- //s += QString(" hbank=\"%1\" lbank=\"%2\" prog=\"%3\"").arg(hbank).arg(lbank).arg(prog);
- //xml.tagE(s);
xml.nput(level, "<Patch name=\"%s\"", Xml::xmlString(name).toLatin1().constData());
if(typ != -1)
xml.nput(" mode=\"%d\"", typ);
@@ -680,24 +657,9 @@ void Patch::write(int level, Xml& xml)
xml.nput(" prog=\"%d\"", prog);
- //xml.nput(level, " hbank=\"%d\" lbank=\"%d\" prog=\"%d\"", hbank, lbank, prog);
if(drum)
- //xml.nput(level, " drum=\"%d\"", int(drum));
xml.nput(" drum=\"%d\"", int(drum));
- //xml.put(level, " />");
xml.put(" />");
-
- //return;
- //}
-
- //QString s = QString("drummap name=\"%1\"").arg(Xml::xmlString(name));
- //s += QString(" hbank=\"%1\" lbank=\"%2\" prog=\"%3\"").arg(hbank).arg(lbank).arg(prog);
- //xml.stag(s);
- //for (int i = 0; i < DRUM_MAPSIZE; ++i) {
- // DrumMapEntry* dm = drumMap->entry(i);
- // dm->write(xml);
- // }
- //xml.etag("drummap");
}
//---------------------------------------------------------
@@ -706,8 +668,6 @@ void Patch::write(int level, Xml& xml)
void MidiInstrument::readMidiState(Xml& xml)
{
- ///_midiState->read(xml, "midistate", true);
-
// p4.0.27 A kludge to support old midistates by wrapping them in the proper header.
_tmpMidiStateVersion = 1; // Assume old (unmarked) first version 1.
for (;;)
@@ -997,11 +957,8 @@ void MidiInstrument::read(Xml& xml)
void MidiInstrument::write(int level, Xml& xml)
{
xml.header();
- //xml.stag("muse version=\"2.1\"");
xml.tag(level, "muse version=\"1.0\"");
- //xml.stag(QString("MidiInstrument name=\"%1\"").arg(Xml::xmlString(iname())));
level++;
- //xml.tag(level, "MidiInstrument name=\"%s\"", Xml::xmlString(iname()).toLatin1().constData());
xml.nput(level, "<MidiInstrument name=\"%s\"", Xml::xmlString(iname()).toLatin1().constData());
if(_nullvalue != -1)
@@ -1016,10 +973,7 @@ void MidiInstrument::write(int level, Xml& xml)
// TODO: What about Init, Reset, State, and InitScript ?
// -------------
- //std::vector<PatchGroup>* pg = groups();
- //for (std::vector<PatchGroup>::iterator g = pg->begin(); g != pg->end(); ++g) {
level++;
- //for (std::vector<PatchGroup>::iterator g = pg.begin(); g != pg.end(); ++g) {
for (ciPatchGroup g = pg.begin(); g != pg.end(); ++g) {
PatchGroup* pgp = *g;
const PatchList& pl = pgp->patches;
@@ -1029,27 +983,86 @@ void MidiInstrument::write(int level, Xml& xml)
level++;
//for (iPatch p = g->patches.begin(); p != g->patches.end(); ++p)
for (ciPatch p = pl.begin(); p != pl.end(); ++p)
- //(*p)->write(xml);
- //p->write(level, xml);
(*p)->write(level, xml);
level--;
- //xml.etag("PatchGroup");
xml.etag(level, "PatchGroup");
}
for (iMidiController ic = _controller->begin(); ic != _controller->end(); ++ic)
- //(*ic)->write(xml);
ic->second->write(level, xml);
- //xml.etag("MidiInstrument");
writeDrummaps(level, xml);
level--;
xml.etag(level, "MidiInstrument");
- //xml.etag("muse");
level--;
xml.etag(level, "muse");
}
+
+//---------------------------------------------------------
+// populatePatchPopup
+//---------------------------------------------------------
+
+void MidiInstrument::populatePatchPopup(MusEGui::PopupMenu* menu, int chan, MType songType, bool drum)
+ {
+ menu->clear();
+ int mask = 0;
+ bool drumchan = chan == 9;
+ switch (songType) {
+ case MT_XG: mask = 4; break;
+ case MT_GS: mask = 2; break;
+ case MT_GM:
+ if(drumchan)
+ {
+ int id = (0xff << 16) + (0xff << 8) + 0x00; // First patch
+ QAction* act = menu->addAction(gmdrumname);
+ act->setData(id);
+ return;
+ }
+ mask = 1;
+ break;
+ case MT_UNKNOWN: mask = 7; break;
+ }
+ if (pg.size() > 1) {
+ for (ciPatchGroup i = pg.begin(); i != pg.end(); ++i) {
+ PatchGroup* pgp = *i;
+ MusEGui::PopupMenu* pm = new MusEGui::PopupMenu(pgp->name, menu, menu->stayOpen()); // Use the parent stayOpen here.
+ menu->addMenu(pm);
+ pm->setFont(MusEGlobal::config.fonts[0]);
+ const PatchList& pl = pgp->patches;
+ for (ciPatch ipl = pl.begin(); ipl != pl.end(); ++ipl) {
+ const Patch* mp = *ipl;
+ if ((mp->typ & mask) &&
+ ((drum && songType != MT_GM) ||
+ (mp->drum == drumchan)) )
+ {
+ int id = ((mp->hbank & 0xff) << 16)
+ + ((mp->lbank & 0xff) << 8) + (mp->prog & 0xff);
+ QAction* act = pm->addAction(mp->name);
+ act->setData(id);
+ }
+
+ }
+ }
+ }
+ else if (pg.size() == 1 ){
+ // no groups
+ const PatchList& pl = pg.front()->patches;
+ for (ciPatch ipl = pl.begin(); ipl != pl.end(); ++ipl) {
+ const Patch* mp = *ipl;
+ if (mp->typ & mask) {
+ int id = ((mp->hbank & 0xff) << 16)
+ + ((mp->lbank & 0xff) << 8) + (mp->prog & 0xff);
+ QAction* act = menu->addAction(mp->name);
+ act->setData(id);
+ }
+ }
+ }
+
+ }
+
+
+
//---------------------------------------------------------
// getPatchName
//---------------------------------------------------------
@@ -1222,72 +1235,6 @@ QList<dumb_patchlist_entry_t> MidiInstrument::getPatches(int channel, MType mode
}
-//---------------------------------------------------------
-// populatePatchPopup
-//---------------------------------------------------------
-
-void MidiInstrument::populatePatchPopup(MusEGui::PopupMenu* menu, int chan, MType songType, bool drum)
- {
- menu->clear();
- int mask = 0;
- bool drumchan = chan == 9;
- switch (songType) {
- case MT_XG: mask = 4; break;
- case MT_GS: mask = 2; break;
- case MT_GM:
- if(drumchan)
- {
- int id = (0xff << 16) + (0xff << 8) + 0x00; // First patch
- QAction* act = menu->addAction(gmdrumname);
- //act->setCheckable(true);
- act->setData(id);
- return;
- }
- mask = 1;
- break;
- case MT_UNKNOWN: mask = 7; break;
- }
- if (pg.size() > 1) {
- for (ciPatchGroup i = pg.begin(); i != pg.end(); ++i) {
- PatchGroup* pgp = *i;
- //QMenu* pm = menu->addMenu(pgp->name);
- MusEGui::PopupMenu* pm = new MusEGui::PopupMenu(pgp->name, menu, menu->stayOpen()); // Use the parent stayOpen here.
- menu->addMenu(pm);
- pm->setFont(MusEGlobal::config.fonts[0]);
- const PatchList& pl = pgp->patches;
- for (ciPatch ipl = pl.begin(); ipl != pl.end(); ++ipl) {
- const Patch* mp = *ipl;
- if ((mp->typ & mask) &&
- ((drum && songType != MT_GM) ||
- (mp->drum == drumchan)) )
- {
- int id = ((mp->hbank & 0xff) << 16)
- + ((mp->lbank & 0xff) << 8) + (mp->prog & 0xff);
- QAction* act = pm->addAction(mp->name);
- //act->setCheckable(true);
- act->setData(id);
- }
-
- }
- }
- }
- else if (pg.size() == 1 ){
- // no groups
- const PatchList& pl = pg.front()->patches;
- for (ciPatch ipl = pl.begin(); ipl != pl.end(); ++ipl) {
- const Patch* mp = *ipl;
- if (mp->typ & mask) {
- int id = ((mp->hbank & 0xff) << 16)
- + ((mp->lbank & 0xff) << 8) + (mp->prog & 0xff);
- QAction* act = menu->addAction(mp->name);
- //act->setCheckable(true);
- act->setData(id);
- }
- }
- }
-
- }
-
const DrumMap* MidiInstrument::drummap_for_patch(int patch) const
{
using std::list;
diff --git a/muse2/muse/instruments/minstrument.h b/muse2/muse/instruments/minstrument.h
index 823b9895..4d5ad8c2 100644
--- a/muse2/muse/instruments/minstrument.h
+++ b/muse2/muse/instruments/minstrument.h
@@ -233,7 +233,6 @@ class MidiInstrument {
virtual void reset(int, MType);
virtual QString getPatchName(int,int,MType,bool);
- //virtual void populatePatchPopup(QMenu*, int, MType, bool);
virtual void populatePatchPopup(MusEGui::PopupMenu*, int, MType, bool);
void read(Xml&);
void write(int level, Xml&);
@@ -264,7 +263,7 @@ extern void removeMidiInstrument(const MidiInstrument* instr);
} // namespace MusECore
//namespace MusEGui {
-//extern void populatePatchPopup(MusECore::MidiInstrument*, PopupMenu*, int, MType, bool);
+//extern void populatePatchPopup(MusECore::MidiInstrument*, PopupMenu*, int, MType, bool); DELETETHIS
//}
#endif
diff --git a/muse2/muse/liste/editevent.cpp b/muse2/muse/liste/editevent.cpp
index c31ecb3a..6781c365 100644
--- a/muse2/muse/liste/editevent.cpp
+++ b/muse2/muse/liste/editevent.cpp
@@ -27,7 +27,6 @@
#include <QGridLayout>
#include <QLabel>
#include <QListWidget>
-//#include <QMenu>
#include <QMessageBox>
#include <QPushButton>
#include <QRadioButton>
@@ -45,7 +44,6 @@
#include "pitchedit.h"
#include "intlabel.h"
#include "globals.h"
-///#include "posedit.h"
#include "gconfig.h"
#include "midiport.h"
#include "midiedit/drummap.h"
@@ -445,7 +443,6 @@ EditCAfterDialog::EditCAfterDialog(int tick, const MusECore::Event& event,
setWindowTitle(tr("MusE: Enter Channel Aftertouch"));
QLabel* l1 = new QLabel(tr("Time Position"));
- ///epos = new PosEdit;
epos = new Awl::PosEdit;
QLabel* l2 = new QLabel(tr("Pressure"));
@@ -504,7 +501,6 @@ EditPAfterDialog::EditPAfterDialog(int tick, const MusECore::Event& event,
setWindowTitle(tr("MusE: Enter Poly Aftertouch"));
QLabel* l1 = new QLabel(tr("Time Position"));
- ///epos = new PosEdit;
epos = new Awl::PosEdit;
QLabel* l2 = new QLabel(tr("Pitch"));
@@ -632,8 +628,8 @@ EditCtrlDialog::EditCtrlDialog(int tick, const MusECore::Event& event,
std::list<QString> sList;
typedef std::list<QString>::iterator isList;
- for (MusECore::iMidiCtrlValList i = cll->begin(); i != cll->end(); ++i) {
- MusECore::MidiCtrlValList* cl = i->second;
+ for (MusECore::iMidiCtrlValList it = cll->begin(); it != cll->end(); ++it) {
+ MusECore::MidiCtrlValList* cl = it->second;
int num = cl->num();
// dont show drum specific controller if not a drum track
@@ -697,13 +693,11 @@ EditCtrlDialog::EditCtrlDialog(int tick, const MusECore::Event& event,
void EditCtrlDialog::newController()
{
- //QMenu* pup = new QMenu(this);
MusEGui::PopupMenu* pup = new MusEGui::PopupMenu(this);
- //pup->setCheckable(this);//not necessary in Qt4
- //
+
// populate popup with all controllers available for
// current instrument
- //
+
MusECore::MidiTrack* track = part->track();
int portn = track->outPort();
MusECore::MidiPort* port = &MusEGlobal::midiPorts[portn];
@@ -732,24 +726,16 @@ void EditCtrlDialog::newController()
{
MusECore::MidiCtrlValList* vl = new MusECore::MidiCtrlValList(mc->num());
cll->add(channel, vl);
- //MusEGlobal::song->update(SC_MIDI_CONTROLLER_ADD);
}
- //for (int idx = 0; ;++idx) {
int idx = 0;
for (; idx < ctrlList->count() ;++idx) { // p4.0.25 Fix segfault
- QString str = ctrlList->item(idx)->text();
+ QString str = ctrlList->item(idx)->text();
if (s == str)
{
- ctrlList->item(idx)->setSelected(true);
+ ctrlList->item(idx)->setSelected(true);
ctrlListClicked(ctrlList->item(idx));
break;
}
- //if (str.isNull()) {
- // ctrlList->addItem(s);
- // ctrlList->item(idx)->setSelected(true);
- // ctrlListClicked(ctrlList->item(idx));
- // break;
- // }
}
if (idx >= ctrlList->count()) { // p4.0.25 Fix segfault
ctrlList->addItem(s);
@@ -871,9 +857,7 @@ void EditCtrlDialog::instrPopup()
int port = track->outPort();
MusECore::MidiInstrument* instr = MusEGlobal::midiPorts[port].instrument();
- //QMenu* pup = new QMenu(this);
MusEGui::PopupMenu* pup = new MusEGui::PopupMenu(this);
- //populatePatchPopup(instr, pup, channel, MusEGlobal::song->mtype(), track->isDrumTrack());
instr->populatePatchPopup(pup, channel, MusEGlobal::song->mtype(), track->isDrumTrack());
if(pup->actions().count() == 0)
@@ -897,9 +881,6 @@ void EditCtrlDialog::instrPopup()
void EditCtrlDialog::programChanged()
{
-// MusECore::MidiTrack* track = part->track();
-// int channel = track->outChannel();
-// int port = track->outPort();
int hb = hbank->value();
int lb = lbank->value();
int prog = program->value();
diff --git a/muse2/muse/liste/editevent.h b/muse2/muse/liste/editevent.h
index 51ba80d0..cd02c82e 100644
--- a/muse2/muse/liste/editevent.h
+++ b/muse2/muse/liste/editevent.h
@@ -48,7 +48,6 @@ namespace MusEGui {
class IntLabel;
class PitchEdit;
-///class PosEdit;
//---------------------------------------------------------
@@ -117,7 +116,6 @@ class EditCtrlDialog : public QDialog, public Ui::EditCtrlBase {
int val; // controller value (for prog. changes)
const MusECore::MidiPart* part;
- ///QMenu* pop;
void updatePatch();
@@ -148,7 +146,6 @@ class EditMetaDialog : public EditEventDialog {
unsigned char* meta;
int len;
- ///PosEdit* epos;
Awl::PosEdit* epos;
QTextEdit* edit;
MusEGui::IntLabel* il2;
@@ -179,7 +176,6 @@ class EditMetaDialog : public EditEventDialog {
class EditCAfterDialog : public EditEventDialog {
Q_OBJECT
- ///PosEdit* epos;
Awl::PosEdit* epos;
MusEGui::IntLabel* il2;
@@ -201,7 +197,6 @@ class EditCAfterDialog : public EditEventDialog {
class EditPAfterDialog : public EditEventDialog {
Q_OBJECT
- ///PosEdit* epos;
Awl::PosEdit* epos;
MusEGui::PitchEdit* pl;
MusEGui::IntLabel* il2;
diff --git a/muse2/muse/liste/listedit.cpp b/muse2/muse/liste/listedit.cpp
index 5e72a0c7..a0d82969 100644
--- a/muse2/muse/liste/listedit.cpp
+++ b/muse2/muse/liste/listedit.cpp
@@ -197,13 +197,13 @@ void ListEdit::songChanged(int type)
{
if(_isDeleting) // Ignore while while deleting to prevent crash.
return;
-
+
if (type == 0)
return;
if (type & (SC_PART_REMOVED | SC_PART_MODIFIED
| SC_PART_INSERTED | SC_EVENT_REMOVED | SC_EVENT_MODIFIED
| SC_EVENT_INSERTED | SC_SELECTION)) {
- if (type & (SC_PART_REMOVED | SC_PART_INSERTED))
+ if (type & (SC_PART_REMOVED | SC_PART_INSERTED | SC_PART_MODIFIED))
genPartlist();
// close window if editor has no parts anymore
if (parts()->empty()) {
@@ -213,6 +213,8 @@ void ListEdit::songChanged(int type)
liste->setSortingEnabled(false);
if (type == SC_SELECTION) {
+
+ // DELETETHIS or clean up or whatever?
// BUGFIX: I found the keyboard modifier states affect how QTreeWidget::setCurrentItem() operates.
// So for example (not) holding shift while lassoo-ing notes in piano roll affected
// whether multiple items were selected in this event list editor!
@@ -244,12 +246,10 @@ void ListEdit::songChanged(int type)
// Go backwards to avoid QTreeWidget::setCurrentItem() dependency on KB modifiers!
for (int row = liste->topLevelItemCount() -1; row >= 0 ; --row)
{
- //printf("ListEdit::songChanged row:%d\n", row);
QTreeWidgetItem* i = liste->topLevelItem(row);
bool sel = ((EventListItem*)i)->event.selected();
if (i->isSelected() ^ sel)
{
- //printf("ListEdit::songChanged changing row:%d sel:%d\n", row, sel);
// Do setCurrentItem() before setSelected().
if(sel && !ci_done)
{
@@ -496,7 +496,7 @@ ListEdit::ListEdit(MusECore::PartList* pl)
menuEdit->addActions(MusEGlobal::undoRedo->actions());
menuEdit->addSeparator();
-#if 0
+#if 0 // DELETETHIS or implement?
QAction *cutAction = menuEdit->addAction(QIcon(*editcutIconSet), tr("Cut"));
connect(cutAction, SIGNAL(triggered()), editSignalMapper, SLOT(map()));
editSignalMapper->setMapping(cutAction, EList::CMD_CUT);
@@ -615,7 +615,6 @@ ListEdit::ListEdit(MusECore::PartList* pl)
ListEdit::~ListEdit()
{
- // MusEGlobal::undoRedo->removeFrom(listTools); // p4.0.6 Removed
}
//---------------------------------------------------------
@@ -1003,8 +1002,8 @@ void ListEdit::initShortcuts()
void ListEdit::keyPressEvent(QKeyEvent* event)
{
-int key = event->key();
-if (key == Qt::Key_Escape) {
+ int key = event->key();
+ if (key == Qt::Key_Escape) {
close();
return;
}
diff --git a/muse2/muse/main.cpp b/muse2/muse/main.cpp
index d946bf00..f7aee078 100644
--- a/muse2/muse/main.cpp
+++ b/muse2/muse/main.cpp
@@ -35,6 +35,8 @@
#include <QIcon>
#include <QString>
#include <QStringList>
+#include <QStyle>
+
#include <sys/mman.h>
#include <alsa/asoundlib.h>
@@ -43,12 +45,14 @@
#include "app.h"
#include "audio.h"
#include "audiodev.h"
+#include "config.h"
#include "gconfig.h"
#include "globals.h"
#include "helper.h"
#include "icons.h"
#include "sync.h"
#include "functions.h"
+#include "appearance.h"
#ifdef HAVE_LASH
#include <lash/lash.h>
@@ -138,27 +142,17 @@ class MuseApplication : public QApplication {
}
bool notify(QObject* receiver, QEvent* event) {
- //if (event->type() == QEvent::KeyPress)
- // printf("notify key press before app::notify accepted:%d\n", event->isAccepted());
bool flag = QApplication::notify(receiver, event);
if (event->type() == QEvent::KeyPress) {
- //printf("notify key press after app::notify accepted:%d\n", event->isAccepted());
QKeyEvent* ke = (QKeyEvent*)event;
- ///MusEGlobal::globalKeyState = ke->stateAfter();
- MusEGlobal::globalKeyState = ke->modifiers();
+ MusEGlobal::globalKeyState = ke->modifiers();
bool accepted = ke->isAccepted();
if (!accepted) {
int key = ke->key();
- ///if (ke->state() & Qt::ShiftModifier)
- //if (MusEGlobal::globalKeyState & Qt::ShiftModifier)
if (((QInputEvent*)ke)->modifiers() & Qt::ShiftModifier)
key += Qt::SHIFT;
- ///if (ke->state() & Qt::AltModifier)
- //if (MusEGlobal::globalKeyState & Qt::AltModifier)
if (((QInputEvent*)ke)->modifiers() & Qt::AltModifier)
key += Qt::ALT;
- ///if (ke->state() & Qt::ControlModifier)
- //if (MusEGlobal::globalKeyState & Qt::ControlModifier)
if (((QInputEvent*)ke)->modifiers() & Qt::ControlModifier)
key+= Qt::CTRL;
muse->kbAccel(key);
@@ -175,7 +169,7 @@ class MuseApplication : public QApplication {
}
#ifdef HAVE_LASH
- virtual void timerEvent (QTimerEvent * /* e */) {
+ virtual void timerEvent (QTimerEvent*) {
if(MusEGlobal::useLASH)
muse->lash_idle_cb ();
}
@@ -226,6 +220,8 @@ static void usage(const char* prog, const char* txt)
fprintf(stderr, " -m debug mode: trace midi Input\n");
fprintf(stderr, " -M debug mode: trace midi Output\n");
fprintf(stderr, " -s debug mode: trace sync\n");
+ fprintf(stderr, " -u ubuntu/unity workaround: don't allow sharing menus\n");
+ fprintf(stderr, " and mdi-subwins.\n");
fprintf(stderr, " -a no audio\n");
fprintf(stderr, " -P n set audio driver real time priority to n\n");
fprintf(stderr, " (Dummy only, default 40. Else fixed by Jack.)\n");
@@ -254,7 +250,6 @@ static void usage(const char* prog, const char* txt)
int main(int argc, char* argv[])
{
-// error = ErrorHandler::create(argv[0]);
MusEGlobal::ruid = getuid();
MusEGlobal::euid = geteuid();
MusEGlobal::undoSetuid();
@@ -279,13 +274,12 @@ int main(int argc, char* argv[])
utemplDir.mkpath(".");
// Support old versions: Copy existing templates over.
QDir old_utemplDir = QDir(QString(getenv("HOME")) + QString("/templates"));
- // printf(" old templates dir:%s\n", (QString(getenv("HOME")) + QString("/templates")).toLatin1().constData());
if(old_utemplDir.exists())
{
- //printf(" found old templates dir\n");
// We really just want these, even though it's possible other filenames were saved.
// Another application might have used that directory.
- QStringList flt; flt << "*.med" << "*.med.gz" << "*.med.bz2" << "*.mid" << "*.midi" << "*.kar";
+ QStringList flt;
+ flt << "*.med" << "*.med.gz" << "*.med.bz2" << "*.mid" << "*.midi" << "*.kar";
old_utemplDir.setNameFilters(flt);
QFileInfoList fil = old_utemplDir.entryInfoList();
@@ -295,7 +289,6 @@ int main(int argc, char* argv[])
QString fn = fi.fileName();
QFile f(fi.absoluteFilePath());
f.copy(utemplDir.absolutePath() + "/" + fn);
- //printf(" copy old template to:%s result:%d\n", QString(utemplPath.absolutePath() + "/" + fn).toLatin1().constData(), rv);
}
}
}
@@ -330,10 +323,11 @@ int main(int argc, char* argv[])
#endif
srand(time(0)); // initialize random number generator
-// signal(SIGCHLD, catchSignal); // interferes with initVST()
+// signal(SIGCHLD, catchSignal); // interferes with initVST(). see also app.cpp, function catchSignal()
MusECore::initMidiController();
QApplication::setColorSpec(QApplication::ManyColor);
MuseApplication app(argc, argv);
+ MusEGui::Appearance::defaultStyle = MuseApplication::style()->objectName();
MusEGui::init_function_dialogs(MusEGlobal::muse);
MusEGui::initShortCuts();
@@ -344,8 +338,6 @@ int main(int argc, char* argv[])
if(!cConfExists)
MusEGlobal::config.projectBaseFolder = MusEGlobal::museUser + QString("/MusE");
- //MusEGlobal::museUserInstruments = MusEGlobal::config.userInstrumentsDir;
-
// Create user instruments dir if it doesn't exist
{
QString uinstrPath = MusEGlobal::configPath + QString("/instruments");
@@ -357,10 +349,8 @@ int main(int argc, char* argv[])
{
// Support old versions: Copy existing instruments over.
QDir old_uinstrDir(MusEGlobal::config.userInstrumentsDir);
- //printf(" old instruments dir:%s\n", MusEGlobal::config.userInstrumentsDir.toLatin1().constData());
if(old_uinstrDir.exists())
{
- //printf(" found old instruments dir\n");
QStringList flt; flt << "*.idf";
old_uinstrDir.setNameFilters(flt);
@@ -374,7 +364,6 @@ int main(int argc, char* argv[])
if(!newf.exists())
{
f.copy(newf.fileName());
- //printf(" copy old instrument to:%s result:%d\n", newf.fileName().toLatin1().constData(), rv);
}
}
}
@@ -395,14 +384,14 @@ int main(int argc, char* argv[])
muse_splash->show();
QTimer* stimer = new QTimer(0);
muse_splash->connect(stimer, SIGNAL(timeout()), muse_splash, SLOT(close()));
- stimer->setSingleShot(true);
+ stimer->setSingleShot(true);
stimer->start(6000);
}
}
int i;
- QString optstr("ahvdDmMsP:Y:l:py");
+ QString optstr("ahvdDumMsP:Y:l:py");
#ifdef VST_SUPPORT
optstr += QString("V");
#endif
@@ -413,12 +402,6 @@ int main(int argc, char* argv[])
optstr += QString("L");
#endif
-//#ifdef VST_SUPPORT
-// while ((i = getopt(argc, argv, "ahvdDmMsVP:py")) != EOF) {
-//#else
-// while ((i = getopt(argc, argv, "ahvdDmMsP:py")) != EOF) {
-//#endif
-
while ((i = getopt(argc, argv, optstr.toLatin1().constData())) != EOF) {
char c = (char)i;
switch (c) {
@@ -438,6 +421,7 @@ int main(int argc, char* argv[])
case 'm': MusEGlobal::midiInputTrace = true; break;
case 'M': MusEGlobal::midiOutputTrace = true; break;
case 's': MusEGlobal::debugSync = true; break;
+ case 'u': MusEGlobal::unityWorkaround = true; break;
case 'P': MusEGlobal::realTimePriority = atoi(optarg); break;
case 'Y': MusEGlobal::midiRTPrioOverride = atoi(optarg); break;
case 'p': MusEGlobal::loadPlugins = false; break;
@@ -451,23 +435,6 @@ int main(int argc, char* argv[])
}
}
- /*
- if(!MusEGlobal::config.styleSheetFile.isEmpty())
- {
- if(MusEGlobal::debugMsg)
- printf("loading style sheet <%s> \n", qPrintable(MusEGlobal::config.styleSheetFile));
- QFile cf(MusEGlobal::config.styleSheetFile);
- if (cf.open(QIODevice::ReadOnly)) {
- QByteArray ss = cf.readAll();
- QString sheet(QString::fromUtf8(ss.data()));
- app.setStyleSheet(sheet);
- cf.close();
- }
- else
- printf("loading style sheet <%s> failed\n", qPrintable(MusEGlobal::config.styleSheetFile));
- }
- */
-
AL::initDsp();
@@ -481,9 +448,6 @@ int main(int argc, char* argv[])
else if (noAudio) {
MusECore::initDummyAudio();
MusEGlobal::realTimeScheduling = true;
- //if (MusEGlobal::debugMode) { // ??
- // MusEGlobal::realTimeScheduling = false;
- // }
}
else if (MusECore::initJackAudio()) {
if (!MusEGlobal::debugMode)
@@ -507,7 +471,6 @@ int main(int argc, char* argv[])
fprintf(stderr, "no audio functions available\n");
fprintf(stderr, "*** experimental mode -- no play possible ***\n");
MusECore::initDummyAudio();
- //MusEGlobal::realTimeScheduling = MusEGlobal::audioDevice->isRealtime();
}
MusEGlobal::realTimeScheduling = true;
}
@@ -517,8 +480,6 @@ int main(int argc, char* argv[])
// ??? With Jack2 this reports true even if it is not running realtime.
// Jack says: "Cannot use real-time scheduling (RR/10)(1: Operation not permitted)". The kernel is non-RT.
// I cannot seem to find a reliable answer to the question, even with dummy audio and system calls.
- //if (MusEGlobal::debugMsg)
- // printf("MusEGlobal::realTimeScheduling:%d\n", MusEGlobal::realTimeScheduling);
MusEGlobal::useJackTransport.setValue(true);
@@ -575,8 +536,6 @@ int main(int argc, char* argv[])
MusECore::initMetronome();
- //QApplication::clipboard()->setSelectionMode(false); ddskrjo obsolete even in Qt3
-
QApplication::addLibraryPath(MusEGlobal::museGlobalLib + "/qtplugins");
if (MusEGlobal::debugMsg) {
QStringList list = app.libraryPaths();
diff --git a/muse2/muse/marker/marker.cpp b/muse2/muse/marker/marker.cpp
index fe643ccf..c825b3bf 100644
--- a/muse2/muse/marker/marker.cpp
+++ b/muse2/muse/marker/marker.cpp
@@ -84,7 +84,6 @@ void MarkerList::write(int level, Xml& xml) const
for (ciMarker i = begin(); i != end(); ++i) {
const Marker& m = i->second;
xml.put(level, "<marker tick=\"%d\" lock=\"%d\" name=\"%s\" />",
- //m.tick(), m.type()==Pos::FRAMES, m.name().toLatin1().constData());
m.tick(), m.type()==Pos::FRAMES, Xml::xmlString(m.name()).toLatin1().constData());
}
}
diff --git a/muse2/muse/marker/markerview.cpp b/muse2/muse/marker/markerview.cpp
index a957e3bf..5e84295e 100644
--- a/muse2/muse/marker/markerview.cpp
+++ b/muse2/muse/marker/markerview.cpp
@@ -30,7 +30,6 @@
#include "sync.h"
#include "icons.h"
#include "song.h"
-///#include "posedit.h"
#include "awl/posedit.h"
#include <QCloseEvent>
@@ -121,7 +120,6 @@ void MarkerItem::setTick(unsigned v)
QString s;
int bar, beat;
unsigned tick;
- ///sigmap.tickValues(v, &bar, &beat, &tick);
AL::sigmap.tickValues(v, &bar, &beat, &tick);
s.sprintf("%04d.%02d.%03d", bar+1, beat+1, tick);
setText(COL_TICK, s);
@@ -168,10 +166,8 @@ void MarkerView::closeEvent(QCloseEvent* e)
//---------------------------------------------------------
MarkerView::MarkerView(QWidget* parent)
- : TopWin(TopWin::MARKER, parent, "markerview", Qt::Window /*| WDestructiveClose*/)
+ : TopWin(TopWin::MARKER, parent, "markerview", Qt::Window)
{
- //setAttribute(Qt::WA_DeleteOnClose);
-
setWindowTitle(tr("MusE: Marker"));
QAction* markerAdd = new QAction(QIcon(*flagIcon), tr("add marker"), this);
@@ -181,10 +177,6 @@ MarkerView::MarkerView(QWidget* parent)
connect(markerDelete, SIGNAL(activated()), SLOT(deleteMarker()));
//---------Pulldown Menu----------------------------
- /* We probably don't need an empty menu - Orcan
- QMenu* fileMenu = new QMenu(tr("&File"));
- menuBar()->addMenu(fileMenu);
- */
QMenu* editMenu = menuBar()->addMenu(tr("&Edit"));
editMenu->addAction(markerAdd);
@@ -238,7 +230,6 @@ MarkerView::MarkerView(QWidget* parent)
editTick->setSizePolicy(QSizePolicy(QSizePolicy::Fixed,
QSizePolicy::Fixed));
- ///editSMPTE = new PosEdit;
editSMPTE = new Awl::PosEdit;
editSMPTE->setSmpte(true);
editSMPTE->setSizePolicy(QSizePolicy(QSizePolicy::Fixed,
@@ -280,7 +271,6 @@ MarkerView::MarkerView(QWidget* parent)
// Rest
//---------------------------------------------------
- //connect(song, SIGNAL(songChanged(int)), SLOT(updateList()));
connect(MusEGlobal::song, SIGNAL(songChanged(int)), SLOT(songChanged(int)));
updateList();
@@ -296,14 +286,11 @@ MarkerView::MarkerView(QWidget* parent)
}
//---------------------------------------------------------
-// MArkerView
+// MarkerView
//---------------------------------------------------------
MarkerView::~MarkerView()
{
- //printf("MarkerView::~MarkerView() before undoRedo->removeFrom(tools)\n");
-
- // undoRedo->removeFrom(tools); // p4.0.6 Removed
}
//---------------------------------------------------------
@@ -507,9 +494,6 @@ void MarkerView::updateList()
MusECore::Marker* m = &i->second;
// Changed p3.3.43
- //QString tick;
- //tick.setNum(i->first);
- //new MarkerItem(table, m);
MarkerItem* item = new MarkerItem(table, m);
if(m == selm)
{
@@ -548,8 +532,6 @@ void MarkerView::markerSelectionChanged()
lock->setChecked(item->lock());
lock->setEnabled(true);
- //printf("MarkerView::markerSelectionChanged item->lock:%d\n", item->lock());
-
editSMPTE->setEnabled(item->lock());
editTick->setEnabled(!item->lock());
}
@@ -613,9 +595,6 @@ void MarkerView::lockChanged(bool lck)
void MarkerView::markerChanged(int val)
{
- //if (val != MusECore::Song::MARKER_CUR)
- // return;
- // p3.3.43
switch(val)
{
// MARKER_CUR, MARKER_ADD, MARKER_REMOVE, MARKER_NAME,
@@ -673,8 +652,7 @@ void MarkerView::prevMarker()
if (i->second.tick() < curPos && i->second.tick() > nextPos)
nextPos = i->second.tick();
}
-/* if (nextPos == 0)
- return;*/
+
MusECore::Pos p(nextPos, true);
MusEGlobal::song->setPos(0, p, true, true, false);
}
diff --git a/muse2/muse/marker/markerview.h b/muse2/muse/marker/markerview.h
index 06e22daf..3da98b31 100644
--- a/muse2/muse/marker/markerview.h
+++ b/muse2/muse/marker/markerview.h
@@ -72,8 +72,6 @@ class MarkerView : public TopWin {
QTreeWidget* table;
QLineEdit* editName;
- ///PosEdit* editSMPTE;
- ///PosEdit* editTick;
Awl::PosEdit* editSMPTE;
Awl::PosEdit* editTick;
QToolButton* lock;
diff --git a/muse2/muse/master/lmaster.cpp b/muse2/muse/master/lmaster.cpp
index 91ffdf7e..1553e17f 100644
--- a/muse2/muse/master/lmaster.cpp
+++ b/muse2/muse/master/lmaster.cpp
@@ -29,8 +29,6 @@
#include "globals.h"
#include "app.h"
#include "audio.h"
-//#include "posedit.h"
-//#include "sigedit.h"
#include "shortcuts.h"
#include "debug.h"
@@ -157,8 +155,8 @@ LMaster::LMaster()
editingNewItem = false;
setWindowTitle(tr("MusE: Mastertrack"));
setMinimumHeight(100);
- setFixedWidth(400);
- setFocusPolicy(Qt::StrongFocus);
+ //setFixedWidth(400); // FIXME: Arbitrary. But without this, sig editor is too wide. Must fix sig editor width...
+ setFocusPolicy(Qt::NoFocus);
comboboxTimer=new QTimer(this);
@@ -208,6 +206,9 @@ LMaster::LMaster()
QToolButton* tempoButton = new QToolButton();
QToolButton* timeSigButton = new QToolButton();
QToolButton* keyButton = new QToolButton();
+ tempoButton->setFocusPolicy(Qt::NoFocus);
+ timeSigButton->setFocusPolicy(Qt::NoFocus);
+ keyButton->setFocusPolicy(Qt::NoFocus);
tempoButton->setText(tr("Tempo"));
timeSigButton->setText(tr("Timesig"));
keyButton->setText(tr("Key"));
@@ -218,10 +219,6 @@ LMaster::LMaster()
edit->addWidget(timeSigButton);
edit->addWidget(keyButton);
- ///Q3Accel* qa = new Q3Accel(this);
- ///qa->connectItem(qa->insertItem(Qt::CTRL+Qt::Key_Z), song, SLOT(undo()));
- ///qa->connectItem(qa->insertItem(Qt::CTRL+Qt::Key_Y), song, SLOT(redo()));
-
//---------------------------------------------------
// master
//---------------------------------------------------
@@ -242,25 +239,26 @@ LMaster::LMaster()
// Rest
//---------------------------------------------------
-// QSizeGrip* corner = new QSizeGrip(mainw);
-
mainGrid->setRowStretch(0, 100);
mainGrid->setColumnStretch(0, 100);
mainGrid->addWidget(view, 0, 0);
-// mainGrid->addWidget(corner, 1, 1, AlignBottom | AlignRight);
updateList();
tempo_editor = new QLineEdit(view->viewport());
+ tempo_editor->setFrame(false);
tempo_editor->hide();
connect(tempo_editor, SIGNAL(returnPressed()), SLOT(returnPressed()));
sig_editor = new SigEdit(view->viewport());
+ sig_editor->setFrame(false);
sig_editor->hide();
connect(sig_editor, SIGNAL(returnPressed()), SLOT(returnPressed()));
pos_editor = new Awl::PosEdit(view->viewport());
+ pos_editor->setFrame(false);
pos_editor->hide();
connect(pos_editor, SIGNAL(returnPressed()), SLOT(returnPressed()));
key_editor = new QComboBox(view->viewport());
+ key_editor->setFrame(false);
key_editor->addItems(MusECore::keyStrs);
key_editor->hide();
connect(key_editor, SIGNAL(activated(int)), SLOT(returnPressed()));
@@ -284,7 +282,6 @@ LMaster::LMaster()
LMaster::~LMaster()
{
- //undoRedo->removeFrom(tools); // p4.0.6 Removed
}
//---------------------------------------------------------
@@ -479,9 +476,9 @@ void LMaster::writeConfiguration(int level, MusECore::Xml& xml)
// select
//---------------------------------------------------------
+//DELETETHIS (whole function)? or is this todo?
void LMaster::select(QTreeWidgetItem* /*item*/, QTreeWidgetItem* /*previous_item*/)
{
-// printf("select %x\n", unsigned(item));
}
//---------------------------------------------------------
@@ -518,7 +515,6 @@ void LMaster::cmd(int cmd)
case LMASTER_KEYEVENT:
{
LMasterKeyEventItem* k = (LMasterKeyEventItem*) l;
- //keymap.delKey(l->tick());
MusEGlobal::audio->msgRemoveKey(k->tick(), k->key());
break;
}
@@ -553,7 +549,6 @@ void LMaster::cmd(int cmd)
*/
void LMaster::itemPressed(QTreeWidgetItem* i, int column)
{
- //printf("itemPressed, column: %d\n", column);
if (editedItem) {
if (editorColumn != column || editedItem != i)
returnPressed();
@@ -572,9 +567,10 @@ void LMaster::itemPressed(QTreeWidgetItem* i, int column)
//---------------------------------------------------------
void LMaster::itemDoubleClicked(QTreeWidgetItem* i)
{
- //printf("itemDoubleClicked\n");
emit seekTo(((LMasterLViewItem*) i)->tick());
+ QFontMetrics fm(font());
+ int fnt_w = fm.width('0');
if (!editedItem && editorColumn == LMASTER_VAL_COL) {
editedItem = (LMasterLViewItem*) i;
QRect itemRect = view->visualItemRect(editedItem);
@@ -583,7 +579,6 @@ void LMaster::itemDoubleClicked(QTreeWidgetItem* i)
itemRect.setX(x1);
//Qt makes crazy things with itemRect if this is called directly..
if (editingNewItem) {
- QFontMetrics fm(font());
int fw = style()->pixelMetric(QStyle::PM_DefaultFrameWidth,0 , this); // ddskrjo 0
int h = fm.height() + fw * 2;
itemRect.setWidth(view->columnWidth(LMASTER_VAL_COL));
@@ -601,9 +596,11 @@ void LMaster::itemDoubleClicked(QTreeWidgetItem* i)
tempo_editor->selectAll();
}
else if (editedItem->getType() == LMASTER_SIGEVENT) { // Edit signatur value:
- //sig_editor->setValue(editedItem->text(LMASTER_VAL_COL));
sig_editor->setValue(((LMasterSigEventItem*)editedItem)->getEvent()->sig);
- sig_editor->setGeometry(itemRect);
+ int w = fnt_w * 14;
+ if(w > itemRect.width())
+ w = itemRect.width();
+ sig_editor->setGeometry(itemRect.x(), itemRect.y(), w, itemRect.height());
sig_editor->show();
sig_editor->setFocus();
}
@@ -631,8 +628,11 @@ void LMaster::itemDoubleClicked(QTreeWidgetItem* i)
else {
pos_editor->setValue(editedItem->tick());
QRect itemRect = view->visualItemRect(editedItem);
- itemRect.setX(0);
- itemRect.setWidth(view->columnWidth(LMASTER_BEAT_COL));
+ itemRect.setX(view->indentation());
+ int w = view->columnWidth(LMASTER_BEAT_COL) - view->indentation();
+ if(w < (fnt_w * 13))
+ w = fnt_w * 13;
+ itemRect.setWidth(w);
pos_editor->setGeometry(itemRect);
pos_editor->show();
pos_editor->setFocus();
@@ -724,7 +724,6 @@ void LMaster::returnPressed()
}
else
MusEGlobal::audio->msgAddSig(newtick, z, n, false);
- //MusEGlobal::audio->msgAddSig(newtick, z, n, true);
// Select the item:
QTreeWidgetItem* newSelected = (QTreeWidgetItem*) getItemAtPos(newtick, LMASTER_SIGEVENT);
@@ -761,7 +760,6 @@ void LMaster::returnPressed()
//
else if (editedItem->getType() == LMASTER_SIGEVENT && editorColumn == LMASTER_VAL_COL)
{
- ///Sig newSig = sig_editor->sig();
AL::TimeSignature newSig = sig_editor->sig();
sig_editor->hide();
@@ -770,7 +768,6 @@ void LMaster::returnPressed()
if(newSig.isValid())
{
LMasterSigEventItem* e = (LMasterSigEventItem*) editedItem;
- //printf("adding sig %d %d\n", e->z(),e->n());
int tick = e->tick();
if (!editingNewItem) {
MusEGlobal::song->startUndo();
@@ -865,7 +862,6 @@ LMasterKeyEventItem::LMasterKeyEventItem(QTreeWidget* parent, const MusECore::Ke
int msec = int((time - (min*60 + sec)) * 1000.0);
c2.sprintf("%03d:%02d:%03d", min, sec, msec);
c3 = "Key";
- //int dt = ev.key;
c4 = keyToString(ev.key);
setText(0, c1);
setText(1, c2);
@@ -884,13 +880,12 @@ LMasterTempoItem::LMasterTempoItem(QTreeWidget* parent, const MusECore::TEvent*
{
tempoEvent = ev;
unsigned t = ev->tick;
- //QString c1, c2, c3, c4;
int bar, beat;
unsigned tick;
AL::sigmap.tickValues(t, &bar, &beat, &tick);
c1.sprintf("%04d.%02d.%03d", bar+1, beat+1, tick);
- double time = double(MusEGlobal::tempomap.tick2frame(t) /*ev->frame*/) / double(MusEGlobal::sampleRate);
+ double time = double(MusEGlobal::tempomap.tick2frame(t)) / double(MusEGlobal::sampleRate);
int min = int(time) / 60;
int sec = int(time) % 60;
int msec = int((time - (min*60 + sec)) * 1000.0);
@@ -938,7 +933,7 @@ LMasterSigEventItem::LMasterSigEventItem(QTreeWidget* parent, const AL::SigEvent
void LMaster::tempoButtonClicked()
{
LMasterTempoItem* lastTempo = (LMasterTempoItem*) getLastOfType(LMASTER_TEMPO);
-// QString beatString = ((LMasterLViewItem*)lastTempo)->text(LMASTER_BEAT_COL);
+// QString beatString = ((LMasterLViewItem*)lastTempo)->text(LMASTER_BEAT_COL); DELETETHIS?
// int m, b, t;
// Pos p = Pos(beatString);
// p.mbt(&m, &b, &t);
@@ -948,7 +943,6 @@ void LMaster::tempoButtonClicked()
MusECore::TEvent* ev = new MusECore::TEvent(lastTempo->tempo(), newTick);
new LMasterTempoItem(view, ev);
QTreeWidgetItem* newTempoItem = view->topLevelItem(0);
- //LMasterTempoItem* newTempoItem = new LMasterTempoItem(view, ev);
editingNewItem = true; // State
editorColumn = LMASTER_VAL_COL; // Set that we edit editorColumn
@@ -965,7 +959,7 @@ void LMaster::tempoButtonClicked()
void LMaster::timeSigButtonClicked()
{
LMasterSigEventItem* lastSig = (LMasterSigEventItem*) getLastOfType(LMASTER_SIGEVENT);
-// QString beatString = ((LMasterLViewItem*)lastSig)->text(LMASTER_BEAT_COL);
+// QString beatString = ((LMasterLViewItem*)lastSig)->text(LMASTER_BEAT_COL); DELETETHIS
// int m, b, t;
// Pos p = Pos(beatString);
// p.mbt(&m, &b, &t);
@@ -975,7 +969,6 @@ void LMaster::timeSigButtonClicked()
AL::SigEvent* ev = new AL::SigEvent(AL::TimeSignature(lastSig->z(), lastSig->n()), newTick);
new LMasterSigEventItem(view, ev);
QTreeWidgetItem* newSigItem = view->topLevelItem(0);
- //LMasterSigEventItem* newSigItem = new LMasterSigEventItem(view, ev);
editingNewItem = true; // State
editorColumn = LMASTER_VAL_COL; // Set that we edit editorColumn
@@ -992,13 +985,12 @@ void LMaster::insertKey()
{
LMasterKeyEventItem* lastKey = (LMasterKeyEventItem*) getLastOfType(LMASTER_KEYEVENT);
- //QString beatString = ((LMasterLViewItem*)lastKey)->text(LMASTER_BEAT_COL);
+ //QString beatString = ((LMasterLViewItem*)lastKey)->text(LMASTER_BEAT_COL); DELETETHIS
//int m, b, t;
//Pos p = Pos(beatString);
//p.mbt(&m, &b, &t);
//m++; //Next bar
- //int newTick = AL::sigmap.bar2tick(m, b, t);
int newTick = MusEGlobal::song->cpos();
new LMasterKeyEventItem(view, MusECore::KeyEvent(lastKey->key(), newTick));
QTreeWidgetItem* newKeyItem = view->topLevelItem(0);
@@ -1066,17 +1058,4 @@ void LMaster::comboboxTimerSlot()
key_editor->showPopup();
}
-//void LMaster::keyPressEvent(QKeyEvent*ev)
-//{
-// switch (ev->key()) {
-// case Qt::Key_Return:
-// // add return as a valid action for editing values too
-// cmd (CMD_EDIT_VALUE);
-// break;
-// default:
-// break;
-// }
-// MidiEditor::keyPressEvent(ev);
-//}
-
} // namespace MusEGui
diff --git a/muse2/muse/master/lmaster.h b/muse2/muse/master/lmaster.h
index 33b40f30..367eff77 100644
--- a/muse2/muse/master/lmaster.h
+++ b/muse2/muse/master/lmaster.h
@@ -28,7 +28,6 @@
#include "cobject.h"
#include "tempo.h"
#include "keyevent.h"
-///#include "sig.h"
#include "al/sig.h"
#include <QTreeWidgetItem>
@@ -154,9 +153,6 @@ class LMaster : public MidiEditor {
QAction *tempoAction, *signAction, *posAction, *valAction, *delAction, *keyAction;
-// protected:
-// virtual void keyPressEvent(QKeyEvent*);
-
private slots:
void select(QTreeWidgetItem*, QTreeWidgetItem*);
void itemDoubleClicked(QTreeWidgetItem* item);
diff --git a/muse2/muse/master/master.cpp b/muse2/muse/master/master.cpp
index 02bef8a1..239467ee 100644
--- a/muse2/muse/master/master.cpp
+++ b/muse2/muse/master/master.cpp
@@ -245,7 +245,7 @@ void Master::viewMouseMoveEvent(QMouseEvent* event)
{
QPoint pos = event->pos();
// QPoint dist = pos - start;
-// bool moving = dist.y() >= 3 || dist.y() <= 3 || dist.x() >= 3 || dist.x() <= 3;
+// bool moving = dist.y() >= 3 || dist.y() <= 3 || dist.x() >= 3 || dist.x() <= 3; DELETETHIS
switch (drag) {
case DRAG_NEW:
diff --git a/muse2/muse/master/masteredit.cpp b/muse2/muse/master/masteredit.cpp
index 571d3c83..82ac697b 100644
--- a/muse2/muse/master/masteredit.cpp
+++ b/muse2/muse/master/masteredit.cpp
@@ -35,9 +35,10 @@
#include "xml.h"
#include "lcombo.h"
#include "doublelabel.h"
-///#include "sigedit.h"
#include "globals.h"
#include "app.h"
+#include "gconfig.h"
+#include "audio.h"
#include <values.h>
@@ -76,7 +77,7 @@ void MasterEdit::songChanged(int type)
return;
if (type & SC_TEMPO) {
- int tempo = MusEGlobal::tempomap.tempo(MusEGlobal::song->cpos());
+ int tempo = MusEGlobal::tempomap.tempoAt(MusEGlobal::song->cpos()); // Bypass the useList flag and read from the list.
curTempo->blockSignals(true);
curTempo->setValue(double(60000000.0/tempo));
@@ -105,12 +106,10 @@ MasterEdit::MasterEdit()
: MidiEditor(TopWin::MASTER, _rasterInit, 0)
{
setWindowTitle(tr("MusE: Mastertrack"));
+ setFocusPolicy(Qt::NoFocus);
_raster = 0; // measure
//---------Pulldown Menu----------------------------
-// QPopupMenu* file = new QPopupMenu(this);
-// menuBar()->insertItem("&File", file);
-
QMenu* settingsMenu = menuBar()->addMenu(tr("Window &Config"));
settingsMenu->addAction(subwinAction);
settingsMenu->addAction(shareAction);
@@ -123,6 +122,7 @@ MasterEdit::MasterEdit()
QToolBar* enableMaster = addToolBar(tr("Enable master"));
enableMaster->setObjectName("Enable master");
enableButton = new QToolButton();
+ enableButton->setFocusPolicy(Qt::NoFocus);
enableButton->setCheckable(true);
enableButton->setText(tr("Enable"));
enableButton->setToolTip(tr("Enable usage of master track"));
@@ -150,7 +150,7 @@ MasterEdit::MasterEdit()
QT_TRANSLATE_NOOP("MusEGui::MasterEdit", "Off"), QT_TRANSLATE_NOOP("MusEGui::MasterEdit", "Bar"), "1/2", "1/4", "1/8", "1/16"
};
rasterLabel = new MusEGui::LabelCombo(tr("Snap"), 0);
- rasterLabel->setFocusPolicy(Qt::NoFocus);
+ rasterLabel->setFocusPolicy(Qt::TabFocus);
for (int i = 0; i < 6; i++)
rasterLabel->insertItem(i, tr(rastval[i]));
rasterLabel->setCurrentIndex(1);
@@ -160,17 +160,16 @@ MasterEdit::MasterEdit()
//---------values for current position---------------
info->addWidget(new QLabel(tr("CurPos ")));
curTempo = new MusEGui::TempoEdit(0);
- curSig = new SigEdit(0);
+ curSig = new SigEdit(0); // SigEdit is already StrongFocus.
+ curTempo->setFocusPolicy(Qt::StrongFocus);
curSig->setValue(AL::TimeSignature(4, 4));
curTempo->setToolTip(tr("tempo at current position"));
curSig->setToolTip(tr("time signature at current position"));
info->addWidget(curTempo);
info->addWidget(curSig);
- ///connect(curSig, SIGNAL(valueChanged(int,int)), song, SLOT(setSig(int,int)));
- connect(curSig, SIGNAL(valueChanged(const AL::TimeSignature&)), MusEGlobal::song, SLOT(setSig(const AL::TimeSignature&)));
-
- ///connect(curTempo, SIGNAL(valueChanged(double)), song, SLOT(setTempo(double)));
- connect(curTempo, SIGNAL(tempoChanged(double)), MusEGlobal::song, SLOT(setTempo(double)));
+
+ connect(curSig, SIGNAL(valueChanged(const AL::TimeSignature&)), SLOT(sigChange(const AL::TimeSignature&)));
+ connect(curTempo, SIGNAL(tempoChanged(double)), SLOT(tempoChange(double)));
//---------------------------------------------------
// master
@@ -183,7 +182,7 @@ MasterEdit::MasterEdit()
vscroll->setRange(30000, 250000);
time1 = new MusEGui::MTScale(&_raster, mainw, xscale);
sign = new MusEGui::SigScale(&_raster, mainw, xscale);
-// thits = new MusEGui::HitScale(&_raster, mainw, xscale);
+// thits = new MusEGui::HitScale(&_raster, mainw, xscale); DELETETHIS what IS this? delete zhits as well
canvas = new Master(this, mainw, xscale, yscale);
@@ -196,8 +195,6 @@ MasterEdit::MasterEdit()
// Rest
//---------------------------------------------------
-// QSizeGrip* corner = new QSizeGrip(mainw);
-
mainGrid->setRowStretch(5, 100);
mainGrid->setColumnStretch(1, 100);
@@ -206,19 +203,18 @@ MasterEdit::MasterEdit()
mainGrid->addWidget(MusECore::hLine(mainw), 2, 1);
mainGrid->addWidget(sign, 3, 1);
mainGrid->addWidget(MusECore::hLine(mainw), 4, 1);
-// mainGrid->addWidget(thits, 5, 1);
+// mainGrid->addWidget(thits, 5, 1); DELETETHIS
// mainGrid->addWidget(MusECore::hLine(mainw), 6, 1);
mainGrid->addWidget(canvas, 5, 1);
mainGrid->addWidget(tscale, 5, 0);
mainGrid->addWidget(MusECore::hLine(mainw), 6, 1);
-// mainGrid->addWidget(zhits, 9, 1);
+// mainGrid->addWidget(zhits, 9, 1); DELETETHIS
// mainGrid->addWidget(MusECore::hLine(mainw), 7, 1);
mainGrid->addWidget(time2, 7, 1);
mainGrid->addWidget(hscroll, 8, 1);
mainGrid->addWidget(vscroll, 0, 2, 10, 1);
-// mainGrid->addWidget(corner, 9, 2, AlignBottom | AlignRight);
- canvas->setFocus(); // Tim.
+ canvas->setFocus();
connect(tools2, SIGNAL(toolChanged(int)), canvas, SLOT(setTool(int)));
connect(vscroll, SIGNAL(scrollChanged(int)), canvas, SLOT(setYPos(int)));
@@ -229,20 +225,20 @@ MasterEdit::MasterEdit()
connect(hscroll, SIGNAL(scrollChanged(int)), time1, SLOT(setXPos(int)));
connect(hscroll, SIGNAL(scrollChanged(int)), sign, SLOT(setXPos(int)));
-// connect(hscroll, SIGNAL(scrollChanged(int)), thits, SLOT(setXPos(int)));
+// connect(hscroll, SIGNAL(scrollChanged(int)), thits, SLOT(setXPos(int))); DELETETHIS
connect(hscroll, SIGNAL(scrollChanged(int)), canvas, SLOT(setXPos(int)));
-// connect(hscroll, SIGNAL(scrollChanged(int)), zhits, SLOT(setXPos(int)));
+// connect(hscroll, SIGNAL(scrollChanged(int)), zhits, SLOT(setXPos(int)));DELETETHIS
connect(hscroll, SIGNAL(scrollChanged(int)), time2, SLOT(setXPos(int)));
connect(hscroll, SIGNAL(scaleChanged(int)), time1, SLOT(setXMag(int)));
connect(hscroll, SIGNAL(scaleChanged(int)), sign, SLOT(setXMag(int)));
-// connect(hscroll, SIGNAL(scaleChanged(int)), thits, SLOT(setXMag(int)));
+// connect(hscroll, SIGNAL(scaleChanged(int)), thits, SLOT(setXMag(int)));DELETETHIS
connect(hscroll, SIGNAL(scaleChanged(int)), canvas, SLOT(setXMag(int)));
-// connect(hscroll, SIGNAL(scaleChanged(int)), zhits, SLOT(setXMag(int)));
+// connect(hscroll, SIGNAL(scaleChanged(int)), zhits, SLOT(setXMag(int))); DELETETHIS
connect(hscroll, SIGNAL(scaleChanged(int)), time2, SLOT(setXMag(int)));
connect(time1, SIGNAL(timeChanged(unsigned)), SLOT(setTime(unsigned)));
-// connect(sign, SIGNAL(timeChanged(unsigned)), pos, SLOT(setValue(unsigned)));
+// connect(sign, SIGNAL(timeChanged(unsigned)), pos, SLOT(setValue(unsigned))); DELETETHIS
// connect(thits, SIGNAL(timeChanged(unsigned)), pos, SLOT(setValue(unsigned)));
// connect(canvas, SIGNAL(timeChanged(unsigned)), pos, SLOT(setValue(unsigned)));
// connect(zhits, SIGNAL(timeChanged(unsigned)), pos, SLOT(setValue(unsigned)));
@@ -256,6 +252,14 @@ MasterEdit::MasterEdit()
connect(canvas, SIGNAL(followEvent(int)), hscroll, SLOT(setOffset(int)));
connect(canvas, SIGNAL(timeChanged(unsigned)), SLOT(setTime(unsigned)));
+ if(MusEGlobal::config.smartFocus)
+ {
+ connect(curSig, SIGNAL(returnPressed()), SLOT(focusCanvas()));
+ connect(curSig, SIGNAL(escapePressed()), SLOT(focusCanvas()));
+ connect(curTempo, SIGNAL(returnPressed()), SLOT(focusCanvas()));
+ connect(curTempo, SIGNAL(escapePressed()), SLOT(focusCanvas()));
+ }
+
initTopwinState();
MusEGlobal::muse->topwinMenuInited(this);
}
@@ -266,7 +270,6 @@ MasterEdit::MasterEdit()
MasterEdit::~MasterEdit()
{
- //undoRedo->removeFrom(tools); // p4.0.6 Removed
}
//---------------------------------------------------------
@@ -297,7 +300,7 @@ void MasterEdit::readStatus(MusECore::Xml& xml)
break;
case MusECore::Xml::TagEnd:
if (tag == "master") {
- // raster setzen
+ // set raster
int item = 0;
switch(_raster) {
case 1: item = 0; break;
@@ -373,6 +376,16 @@ void MasterEdit::writeConfiguration(int level, MusECore::Xml& xml)
}
//---------------------------------------------------------
+// focusCanvas
+//---------------------------------------------------------
+
+void MasterEdit::focusCanvas()
+{
+ canvas->setFocus();
+ canvas->activateWindow();
+}
+
+//---------------------------------------------------------
// _setRaster
//---------------------------------------------------------
@@ -383,6 +396,8 @@ void MasterEdit::_setRaster(int index)
};
_raster = rasterTable[index];
_rasterInit = _raster;
+ if(MusEGlobal::config.smartFocus)
+ focusCanvas();
}
//---------------------------------------------------------
@@ -393,7 +408,7 @@ void MasterEdit::posChanged(int idx, unsigned val, bool)
{
if (idx == 0) {
int z, n;
- int tempo = MusEGlobal::tempomap.tempo(val);
+ int tempo = MusEGlobal::tempomap.tempoAt(val); // Bypass the useList flag and read from the list.
AL::sigmap.timesig(val, z, n);
curTempo->blockSignals(true);
curSig->blockSignals(true);
@@ -435,5 +450,24 @@ void MasterEdit::setTempo(int val)
tempo->setValue(val);
}
}
+
+void MasterEdit::sigChange(const AL::TimeSignature& sig)
+{
+ // TODO: FIXME: Tempo/sig undo + redo broken here. Either fix tempo and sig, or finish something here...
+ MusEGlobal::audio->msgAddSig(MusEGlobal::song->cPos().tick(), sig.z, sig.n); // Add will replace if found.
+}
+
+void MasterEdit::tempoChange(double t)
+{
+ if(int(t) == 0)
+ return;
+
+ // TODO: FIXME: Tempo/sig undo + redo broken here. Either fix tempo and sig, or finish something here... Also in transport.
+ //MusEGlobal::song->startUndo();
+ //iTEvent e = find(tick);
+ //MusEGlobal::audio->msgDeleteTempo(it->first, it->second, false);
+ MusEGlobal::audio->msgAddTempo(MusEGlobal::song->cPos().tick(), int(60000000.0/t), true); // Add will replace if found.
+ //MusEGlobal::song->endUndo(SC_TEMPO);
+}
} // namespace MusEGui
diff --git a/muse2/muse/master/masteredit.h b/muse2/muse/master/masteredit.h
index 835ca879..faff69e2 100644
--- a/muse2/muse/master/masteredit.h
+++ b/muse2/muse/master/masteredit.h
@@ -85,10 +85,12 @@ class MasterEdit : public MidiEditor {
void posChanged(int,unsigned,bool);
void setTime(unsigned);
void setTempo(int);
+ void sigChange(const AL::TimeSignature&);
+ void tempoChange(double);
+ void focusCanvas();
public slots:
void songChanged(int);
-// void tempoChanged(double);
signals:
void isDeleting(MusEGui::TopWin*);
diff --git a/muse2/muse/master/tscale.cpp b/muse2/muse/master/tscale.cpp
index 57bb898d..2dbc9eac 100644
--- a/muse2/muse/master/tscale.cpp
+++ b/muse2/muse/master/tscale.cpp
@@ -38,7 +38,6 @@ TScale::TScale(QWidget* parent, int ymag)
: View(parent, 1, ymag)
{
setFont(MusEGlobal::config.fonts[5]);
- //int w = 4 * QFontMetrics(MusEGlobal::config.fonts[4]).width('0');
int w = 4 * fontMetrics().width('0');
setFixedWidth(w);
setMouseTracking(true);
@@ -52,7 +51,6 @@ void TScale::pdraw(QPainter& p, const QRect& r)
{
int y = r.y();
int h = r.height();
- //p.setFont(MusEGlobal::config.fonts[4]);
QString s;
for (int i = 30000; i <= 250000; i += 10000) {
int yy = mapy(280000 - i);
@@ -62,8 +60,6 @@ void TScale::pdraw(QPainter& p, const QRect& r)
continue;
p.drawLine(0, yy, width(), yy);
s.setNum(i/1000);
- //QFontMetrics fm(MusEGlobal::config.fonts[4]);
- //p.drawText(width() - fm.width(s) - 1, yy-2, s);
p.drawText(width() - fontMetrics().width(s) - 1, yy-2, s); // Use the window font. Tim p4.0.31
}
}
diff --git a/muse2/muse/memory.cpp b/muse2/muse/memory.cpp
index a1ece0a7..8fd70da6 100644
--- a/muse2/muse/memory.cpp
+++ b/muse2/muse/memory.cpp
@@ -61,8 +61,6 @@ Pool::~Pool()
void Pool::grow(int idx)
{
-// printf("grow memory idx %d\n", idx);
-
int esize = (idx+1) * sizeof(unsigned long);
Chunk* n = new Chunk;
@@ -93,14 +91,13 @@ struct mops {
};
typedef std::list<struct mops, RTalloc<struct mops> > List;
-// typedef std::vector<struct mops> List;
typedef List::iterator iList;
//---------------------------------------------------------
// main
// 2.8 s normal 0.7 vector
// 2.5 s RTalloc
-// 1.18 alle optimierungen (0.97)
+// 1.18 all optimisations (0.97)
//---------------------------------------------------------
int main()
diff --git a/muse2/muse/midi.cpp b/muse2/muse/midi.cpp
index 85a47ead..2c3c3d8c 100644
--- a/muse2/muse/midi.cpp
+++ b/muse2/muse/midi.cpp
@@ -168,7 +168,6 @@ QString nameSysex(unsigned int len, const unsigned char* buf)
case 0x43: s = "Yamaha: "; break;
case 0x44: s = "Casio"; break;
case 0x45: s = "Akai"; break;
- //case 0x7c: s = "MusE Soft Synth"; break;
case MUSE_SYNTH_SYSEX_MFG_ID: s = "MusE Soft Synth"; break; // p4.0.27
case 0x7d: s = "Educational Use"; break;
case 0x7e: s = "Universal: Non Real Time"; break;
@@ -423,7 +422,7 @@ void buildMidiEventList(EventList* del, const MPEventList* el, MidiTrack* track,
break;
case 0x6: // Marker
{
- unsigned ltick = CALC_TICK(tick);//(tick * MusEGlobal::config.division + div/2) / div;
+ unsigned ltick = CALC_TICK(tick);
MusEGlobal::song->addMarker(QString((const char*)(data)), ltick, false);
}
break;
@@ -439,8 +438,8 @@ void buildMidiEventList(EventList* del, const MPEventList* el, MidiTrack* track,
case 0x51: // Tempo
{
unsigned tempo = data[2] + (data[1] << 8) + (data[0] <<16);
- unsigned ltick = CALC_TICK(tick);// (unsigned(tick) * unsigned(MusEGlobal::config.division) + unsigned(div/2)) / unsigned(div);
- // After ca 10 mins 32 bits will not be enough... This expression has to be changed/factorized or so in some "sane" way...
+ unsigned ltick = CALC_TICK(tick);
+ // FIXME: After ca 10 mins 32 bits will not be enough... This expression has to be changed/factorized or so in some "sane" way...
MusEGlobal::tempomap.addTempo(ltick, tempo);
}
break;
@@ -451,8 +450,7 @@ void buildMidiEventList(EventList* del, const MPEventList* el, MidiTrack* track,
int timesig_n = 1;
for (int i = 0; i < n; i++)
timesig_n *= 2;
- int ltick = CALC_TICK(tick);//(tick * MusEGlobal::config.division + div/2) / div;
- ///sigmap.add(ltick, timesig_z, timesig_n);
+ int ltick = CALC_TICK(tick);
AL::sigmap.add(ltick, AL::TimeSignature(timesig_z, timesig_n));
}
break;
@@ -535,9 +533,9 @@ void buildMidiEventList(EventList* del, const MPEventList* el, MidiTrack* track,
i->first, ev.pitch(), ev.velo());
continue;
}
- int tick = CALC_TICK(ev.tick()); //(ev.tick() * MusEGlobal::config.division + div/2) / div;
+ int tick = CALC_TICK(ev.tick());
if (ev.isNote()) {
- int lenTick = CALC_TICK(ev.lenTick()); //(ev.lenTick() * MusEGlobal::config.division + div/2) / div;
+ int lenTick = CALC_TICK(ev.lenTick());
ev.setLenTick(lenTick);
}
ev.setTick(tick);
@@ -566,7 +564,7 @@ void Audio::sendLocalOff()
{
for (int k = 0; k < MIDI_PORTS; ++k) {
for (int i = 0; i < MIDI_CHANNELS; ++i)
- MusEGlobal::midiPorts[k].sendEvent(MusECore::MidiPlayEvent(0, k, i, MusECore::ME_CONTROLLER, MusECore::CTRL_LOCAL_OFF, 0));
+ MusEGlobal::midiPorts[k].sendEvent(MusECore::MidiPlayEvent(0, k, i, MusECore::ME_CONTROLLER, MusECore::CTRL_LOCAL_OFF, 0), true);
}
}
@@ -636,12 +634,10 @@ void Audio::initDevices()
}
}
//
- // damit Midi-Devices, die mehrere Ports besitzen, wie z.B.
- // das Korg NS5R, nicht mehrmals zwischen GM und XG/GS hin und
- // hergeschaltet werden, wird zun�hst auf allen Ports GM
- // initialisiert, und dann erst XG/GS
+ // First all ports are initialized to GM and then are changed
+ // to XG/GS in order to prevent that devices with more than one
+ // port, e.g. Korg NS5R, toggle between GM and XG/GS several times.
//
-
// Standard initialization...
for (int i = 0; i < MIDI_PORTS; ++i) {
if (!activePorts[i])
@@ -1082,14 +1078,12 @@ void Audio::processMidi()
if (devport == defaultPort) {
event.setPort(port);
if(md && track->recEcho())
- //playEvents->add(event);
md->addScheduledEvent(event);
}
else {
// Hmm, this appears to work, but... Will this induce trouble with md->setNextPlayEvent??
MidiDevice* mdAlt = MusEGlobal::midiPorts[devport].device();
if(mdAlt && track->recEcho())
- //mdAlt->playEvents()->add(event);
mdAlt->addScheduledEvent(event);
}
// Shall we activate meters even while rec echo is off? Sure, why not...
@@ -1128,7 +1122,6 @@ void Audio::processMidi()
drumRecEvent.setB(preVelo);
// Tested: Events were not being recorded for a drum map entry pointing to a
// different port. This must have been wrong - buildMidiEventList would ignore this. Tim.
- //drumRecEvent.setPort(devport);
drumRecEvent.setPort(port); //rec-event to current port
drumRecEvent.setChannel(track->outChannel()); //rec-event to current channel
@@ -1174,11 +1167,9 @@ void Audio::processMidi()
else if (state == PRECOUNT) {
isMeasure = (clickno % clicksMeasure) == 0;
}
- //int frame = MusEGlobal::tempomap.tick2frame(midiClick) + frameOffset;
int evtime = extsync ? midiClick : MusEGlobal::tempomap.tick2frame(midiClick) + frameOffset; // p3.3.25
if (md) {
- //MusECore::MidiPlayEvent ev(frame, MusEGlobal::clickPort, MusEGlobal::clickChan, MusECore::ME_NOTEON,
MusECore::MidiPlayEvent ev(evtime, MusEGlobal::clickPort, MusEGlobal::clickChan, MusECore::ME_NOTEON,
MusEGlobal::beatClickNote, MusEGlobal::beatClickVelo);
@@ -1193,7 +1184,6 @@ void Audio::processMidi()
md->addStuckNote(ev);
}
if (MusEGlobal::audioClickFlag) {
- //MusECore::MidiPlayEvent ev1(frame, 0, 0, MusECore::ME_NOTEON, 0, 0);
MusECore::MidiPlayEvent ev(evtime, 0, 0, MusECore::ME_NOTEON, 0, 0);
ev.setA(isMeasure ? 0 : 1);
metronome->addScheduledEvent(ev);
@@ -1221,7 +1211,6 @@ void Audio::processMidi()
// ALSA devices handled by another thread.
if((*id)->deviceType() != MidiDevice::ALSA_MIDI)
- //if((*id)->deviceType() == MidiDevice::JACK_MIDI)
(*id)->processMidi();
}
MusEGlobal::midiBusy=false;
diff --git a/muse2/muse/midi.h b/muse2/muse/midi.h
index 0d83b7ae..711b36d5 100644
--- a/muse2/muse/midi.h
+++ b/muse2/muse/midi.h
@@ -90,8 +90,7 @@ QString midiMetaName(int);
class MPEventList;
class MidiTrack;
-extern void buildMidiEventList(EventList* mel, const MPEventList* el, MidiTrack* track, int division, bool /*addSysexMeta*/, bool /*doLoops*/);
-// extern bool checkSysex(MidiTrack* track, unsigned int len, unsigned char* buf);
+extern void buildMidiEventList(EventList* mel, const MPEventList* el, MidiTrack* track, int division, bool addSysexMeta, bool doLoops);
} // namespace MusECore
diff --git a/muse2/muse/midictrl.cpp b/muse2/muse/midictrl.cpp
index c477297e..b95ccf77 100644
--- a/muse2/muse/midictrl.cpp
+++ b/muse2/muse/midictrl.cpp
@@ -148,7 +148,6 @@ void initMidiController()
defaultMidiController.add(&veloCtrl);
defaultMidiController.add(&pitchCtrl);
defaultMidiController.add(&programCtrl);
- // Removed p3.3.37 Re-added p4.0.15
defaultMidiController.add(&mastervolCtrl);
defaultMidiController.add(&volumeCtrl);
defaultMidiController.add(&panCtrl);
@@ -198,11 +197,6 @@ QString midiCtrlNumString(int ctrl, bool fullyQualified)
QString midiCtrlName(int ctrl, bool fullyQualified)
{
- //if (ctrl < 0x10000)
- // return QString(ctrlName[ctrl]);
- //return QString("?N?");
-
- // p4.0.25 Tim
int h = (ctrl >> 8) & 0xff;
int l = ctrl & 0xff;
QString s1 = QString("%1").arg(h);
@@ -271,7 +265,6 @@ void MidiController::copy(const MidiController &mc)
_minVal = mc._minVal;
_maxVal = mc._maxVal;
_initVal = mc._initVal;
- //updateBias();
_bias = mc._bias;
}
@@ -291,17 +284,12 @@ MidiController& MidiController::operator=(const MidiController &mc)
MidiController::ControllerType midiControllerType(int num)
{
- // p3.3.37
- //if (num < 0x10000)
if (num < CTRL_14_OFFSET)
return MidiController::Controller7;
- //if (num < 0x20000)
if (num < CTRL_RPN_OFFSET)
return MidiController::Controller14;
- //if (num < 0x30000)
if (num < CTRL_NRPN_OFFSET)
return MidiController::RPN;
- //if (num < 0x40000)
if (num < CTRL_INTERNAL_OFFSET)
return MidiController::NRPN;
if (num == CTRL_PITCH)
@@ -310,10 +298,8 @@ MidiController::ControllerType midiControllerType(int num)
return MidiController::Program;
if (num == CTRL_VELOCITY)
return MidiController::Velo;
- //if (num < 0x60000)
if (num < CTRL_NRPN14_OFFSET)
return MidiController::RPN14;
- //if (num < 0x70000)
if (num < CTRL_NONE_OFFSET)
return MidiController::NRPN14;
return MidiController::Controller7;
@@ -366,14 +352,6 @@ void MidiController::updateBias()
break;
}
- // Special handling of pan: Only thing to do is force the range!
- //if(_num == CTRL_PANPOT)
- //{
- // _minVal = -64;
- // _maxVal = 63;
- // _initVal = 0;
- //}
-
// TODO: Limit _minVal and _maxVal to range.
if(_minVal >= 0)
@@ -386,11 +364,9 @@ void MidiController::updateBias()
{
// Adjust bias to fit desired range.
if(_minVal + _bias < mn)
- //_minVal = mn - _bias;
_bias += mn - _minVal + _bias;
else
if(_maxVal + _bias > mx)
- //_maxVal = mx - _bias;
_bias -= _maxVal + _bias - mx;
}
}
@@ -467,7 +443,6 @@ void MidiController::write(int level, Xml& xml) const
if(_initVal != CTRL_VAL_UNKNOWN)
xml.nput(" init=\"%d\"", _initVal);
}
- //xml.put(level, " />");
xml.put(" />");
}
@@ -532,14 +507,11 @@ void MidiController::read(Xml& xml)
case RPN:
if (_maxVal == NOT_SET)
_maxVal = 127;
- // p3.3.37
- //_num |= 0x20000;
_num |= CTRL_RPN_OFFSET;
break;
case NRPN:
if (_maxVal == NOT_SET)
_maxVal = 127;
- //_num |= 0x30000;
_num |= CTRL_NRPN_OFFSET;
break;
case Controller7:
@@ -547,7 +519,6 @@ void MidiController::read(Xml& xml)
_maxVal = 127;
break;
case Controller14:
- //_num |= 0x10000;
_num |= CTRL_14_OFFSET;
if (_maxVal == NOT_SET)
_maxVal = 16383;
@@ -555,13 +526,11 @@ void MidiController::read(Xml& xml)
case RPN14:
if (_maxVal == NOT_SET)
_maxVal = 16383;
- //_num |= 0x50000;
_num |= CTRL_RPN14_OFFSET;
break;
case NRPN14:
if (_maxVal == NOT_SET)
_maxVal = 16383;
- //_num |= 0x60000;
_num |= CTRL_NRPN14_OFFSET;
break;
case Pitch:
@@ -604,10 +573,8 @@ int MidiController::genNum(MidiController::ControllerType t, int h, int l)
case Controller14:
return val + CTRL_14_OFFSET;
case RPN:
- //return l + CTRL_RPN_OFFSET;
return val + CTRL_RPN_OFFSET;
case NRPN:
- //return l + CTRL_NRPN_OFFSET;
return val + CTRL_NRPN_OFFSET;
case RPN14:
return val + CTRL_RPN14_OFFSET;
@@ -772,8 +739,6 @@ int MidiCtrlValList::value(int tick, Part* part) const
// return true if new controller value added or replaced
//---------------------------------------------------------
-// Changed by T356.
-//bool MidiCtrlValList::add(int tick, int val)
bool MidiCtrlValList::addMCtlVal(int tick, int val, Part* part)
{
iMidiCtrlVal e = findMCtlVal(tick, part);
@@ -798,8 +763,6 @@ bool MidiCtrlValList::addMCtlVal(int tick, int val, Part* part)
// del
//---------------------------------------------------------
-// Changed by T356.
-//void MidiCtrlValList::del(int tick)
void MidiCtrlValList::delMCtlVal(int tick, Part* part)
{
iMidiCtrlVal e = findMCtlVal(tick, part);
@@ -815,8 +778,6 @@ void MidiCtrlValList::delMCtlVal(int tick, Part* part)
// find
//---------------------------------------------------------
-// Changed by T356.
-//iMidiCtrlVal MidiCtrlValList::find(int tick, Part* part)
iMidiCtrlVal MidiCtrlValList::findMCtlVal(int tick, Part* part)
{
MidiCtrlValRange range = equal_range(tick);
@@ -834,8 +795,6 @@ iMidiCtrlVal MidiCtrlValList::findMCtlVal(int tick, Part* part)
MidiControllerList::MidiControllerList(const MidiControllerList& mcl) : std::map<int, MidiController*>()
{
- //copy(mcl);
-
for(ciMidiController i = mcl.begin(); i != mcl.end(); ++i)
{
MidiController* mc = i->second;
@@ -843,26 +802,4 @@ MidiControllerList::MidiControllerList(const MidiControllerList& mcl) : std::map
}
}
-//---------------------------------------------------------
-// copy
-//---------------------------------------------------------
-//void MidiControllerList::copy(const MidiControllerList &mcl)
-//{
-// clear();
-// for(ciMidiController i = mcl.begin(); i != mcl.end(); ++i)
-// {
-// MidiController* mc = *i;
-// push_back(new MidiController(*mc));
-// }
-//}
-
-//---------------------------------------------------------
-// operator =
-//---------------------------------------------------------
-//MidiControllerList& MidiControllerList::operator= (const MidiControllerList &mcl)
-//{
-// copy(mcl);
-// return *this;
-//}
-
} // namespace MusECore
diff --git a/muse2/muse/midictrl.h b/muse2/muse/midictrl.h
index 8a0a3c6d..74902bc2 100644
--- a/muse2/muse/midictrl.h
+++ b/muse2/muse/midictrl.h
@@ -80,11 +80,6 @@ const int CTRL_LOCAL_OFF = 0x7a; // 122
// internal controller types:
const int CTRL_INTERNAL_OFFSET = 0x40000;
-// p3.3.37
-//const int CTRL_PITCH = 0x40000;
-//const int CTRL_PROGRAM = 0x40001;
-//const int CTRL_VELOCITY = 0x40002;
-//const int CTRL_MASTER_VOLUME = 0x40003;
const int CTRL_PITCH = CTRL_INTERNAL_OFFSET;
const int CTRL_PROGRAM = CTRL_INTERNAL_OFFSET + 1;
const int CTRL_VELOCITY = CTRL_INTERNAL_OFFSET + 2;
@@ -167,15 +162,10 @@ struct MidiCtrlVal
// list for easy retrieval
//---------------------------------------------------------
-// Changed by T356.
-//typedef std::map<int, int, std::less<int> >::iterator iMidiCtrlVal;
-//typedef std::map<int, int, std::less<int> >::const_iterator ciMidiCtrlVal;
typedef std::multimap<int, MidiCtrlVal, std::less<int> >::iterator iMidiCtrlVal;
typedef std::multimap<int, MidiCtrlVal, std::less<int> >::const_iterator ciMidiCtrlVal;
typedef std::pair <iMidiCtrlVal, iMidiCtrlVal> MidiCtrlValRange;
-// Changed by T356.
-//class MidiCtrlValList : public std::map<int, int, std::less<int> > {
class MidiCtrlValList : public std::multimap<int, MidiCtrlVal, std::less<int> > {
int ctrlNum;
@@ -194,11 +184,7 @@ class MidiCtrlValList : public std::multimap<int, MidiCtrlVal, std::less<int> >
iMidiCtrlVal iValue(int tick);
int value(int tick) const;
- //int value(int tick, Part** part = 0) const;
int value(int tick, Part* part) const;
- // Changed by T356.
- //bool add(int tick, int value);
- //void del(int tick);
bool addMCtlVal(int tick, int value, Part* part);
void delMCtlVal(int tick, Part* part);
diff --git a/muse2/muse/mididev.cpp b/muse2/muse/mididev.cpp
index f7686e18..31a8f6fe 100644
--- a/muse2/muse/mididev.cpp
+++ b/muse2/muse/mididev.cpp
@@ -42,7 +42,6 @@
#include "sync.h"
#include "midiitransform.h"
#include "part.h"
-//#include "mpevent.h"
namespace MusEGlobal {
MusECore::MidiDeviceList midiDevices;
@@ -92,6 +91,9 @@ void initMidiDevices()
void MidiDevice::init()
{
+ stopPending = false;
+ seekPending = false;
+
_readEnable = false;
_writeEnable = false;
_rwFlags = 3;
@@ -109,7 +111,6 @@ MidiDevice::MidiDevice()
_tmpRecordCount[i] = 0;
_sysexFIFOProcessed = false;
- //_sysexWritingChunks = false;
_sysexReadingChunks = false;
init();
@@ -122,7 +123,6 @@ MidiDevice::MidiDevice(const QString& n)
_tmpRecordCount[i] = 0;
_sysexFIFOProcessed = false;
- //_sysexWritingChunks = false;
_sysexReadingChunks = false;
init();
@@ -205,43 +205,17 @@ void MidiDevice::beforeProcess()
_sysexFIFOProcessed = false;
}
-/*
-//---------------------------------------------------------
-// getEvents
-//---------------------------------------------------------
-
-void MidiDevice::getEvents(unsigned , unsigned , int ch, MPEventList* dst) //from //to
-{
- for (int i = 0; i < _tmpRecordCount; ++i) {
- const MidiPlayEvent& ev = _recordFifo.peek(i);
- if (ch == -1 || (ev.channel() == ch))
- dst->insert(ev);
- }
-
- //while(!recordFifo.isEmpty())
- //{
- // MidiPlayEvent e(recordFifo.get());
- // if (ch == -1 || (e.channel() == ch))
- // dst->insert(e);
- //}
-}
-*/
-
//---------------------------------------------------------
// recordEvent
//---------------------------------------------------------
void MidiDevice::recordEvent(MidiRecordEvent& event)
{
- // p3.3.35
// TODO: Tested, but record resolution not so good. Switch to wall clock based separate list in MidiDevice. And revert this line.
//event.setTime(MusEGlobal::audio->timestamp());
event.setTime(MusEGlobal::extSyncFlag.value() ? MusEGlobal::lastExtMidiSyncTick : MusEGlobal::audio->timestamp());
- //printf("MidiDevice::recordEvent event time:%d\n", event.time());
- // By T356. Set the loop number which the event came in at.
- //if(MusEGlobal::audio->isRecording())
if(MusEGlobal::audio->isPlaying())
event.setLoopNum(MusEGlobal::audio->loopCount());
@@ -255,10 +229,7 @@ void MidiDevice::recordEvent(MidiRecordEvent& event)
if(_port != -1)
{
int idin = MusEGlobal::midiPorts[_port].syncInfo().idIn();
-
-// p3.3.26 1/23/10 Section was disabled, enabled by Tim.
-//#if 0
-
+
//---------------------------------------------------
// filter some SYSEX events
//---------------------------------------------------
@@ -268,21 +239,17 @@ void MidiDevice::recordEvent(MidiRecordEvent& event)
int n = event.len();
if (n >= 4) {
if ((p[0] == 0x7f)
- //&& ((p[1] == 0x7f) || (p[1] == rxDeviceId))) {
&& ((p[1] == 0x7f) || (idin == 0x7f) || (p[1] == idin))) {
if (p[2] == 0x06) {
- //mmcInput(p, n);
MusEGlobal::midiSeq->mmcInput(_port, p, n);
return;
}
if (p[2] == 0x01) {
- //mtcInputFull(p, n);
MusEGlobal::midiSeq->mtcInputFull(_port, p, n);
return;
}
}
else if (p[0] == 0x7e) {
- //nonRealtimeSystemSysex(p, n);
MusEGlobal::midiSeq->nonRealtimeSystemSysex(_port, p, n);
return;
}
@@ -291,9 +258,6 @@ void MidiDevice::recordEvent(MidiRecordEvent& event)
else
// Trigger general activity indicator detector. Sysex has no channel, don't trigger.
MusEGlobal::midiPorts[_port].syncInfo().trigActDetect(event.channel());
-
-//#endif
-
}
//
@@ -485,8 +449,9 @@ bool MidiDevice::putEvent(const MidiPlayEvent& ev)
putMidiEvent(MidiPlayEvent(0, 0, chn, ME_CONTROLLER, CTRL_LBANK, lb));
return putMidiEvent(MidiPlayEvent(0, 0, chn, ME_PROGRAM, pr, 0));
}
+ return false; // Should absorb anyway and return, right? p4.0.48 Tim.
}
-#if 1 // if ALSA cannot handle RPN NRPN etc.
+#if 1 // if ALSA cannot handle RPN NRPN etc. DELETETHIS? remove the wrapping #if #endif
if (a < CTRL_14_OFFSET) { // 7 Bit Controller
putMidiEvent(ev);
@@ -590,6 +555,35 @@ void MidiDevice::handleStop()
if(_port == -1)
return;
+ MidiPort* mp = &MusEGlobal::midiPorts[_port];
+
+ //---------------------------------------------------
+ // send midi stop
+ //---------------------------------------------------
+
+ // Don't send if external sync is on. The master, and our sync routing system will take care of that.
+ if(!MusEGlobal::extSyncFlag.value())
+ {
+ // Shall we check open flags? DELETETHIS 4?
+ //if(!(dev->rwFlags() & 0x1) || !(dev->openFlags() & 1))
+ //if(!(dev->openFlags() & 1))
+ // return;
+
+ MidiSyncInfo& si = mp->syncInfo();
+ if(si.MMCOut())
+ mp->sendMMCStop();
+
+ if(si.MRTOut())
+ {
+ mp->sendStop();
+ //DELETETHIS 5?
+ // Added check of option send continue not start. Hmm, is this required? Seems to make other devices unhappy.
+ // (Could try now that this is in MidiDevice.)
+ //if(!si.sendContNotStart())
+ // mp->sendSongpos(MusEGlobal::audio->tickPos() * 4 / MusEGlobal::config.division);
+ }
+ }
+
//---------------------------------------------------
// Clear all notes and handle stuck notes
//---------------------------------------------------
@@ -599,26 +593,24 @@ void MidiDevice::handleStop()
{
MidiPlayEvent ev = *i;
ev.setTime(0);
- _playEvents.add(ev);
+ putEvent(ev);
}
_stuckNotes.clear();
-
//---------------------------------------------------
// reset sustain
//---------------------------------------------------
- MidiPort* mp = &MusEGlobal::midiPorts[_port];
for(int ch = 0; ch < MIDI_CHANNELS; ++ch)
{
if(mp->hwCtrlState(ch, CTRL_SUSTAIN) == 127)
{
- //printf("send clear sustain!!!!!!!! port %d ch %d\n", i,ch);
MidiPlayEvent ev(0, _port, ch, ME_CONTROLLER, CTRL_SUSTAIN, 0);
putEvent(ev);
}
}
+ /* DELETETHIS 23
//---------------------------------------------------
// send midi stop
//---------------------------------------------------
@@ -626,11 +618,6 @@ void MidiDevice::handleStop()
// Don't send if external sync is on. The master, and our sync routing system will take care of that.
if(!MusEGlobal::extSyncFlag.value())
{
- // Shall we check open flags?
- //if(!(dev->rwFlags() & 0x1) || !(dev->openFlags() & 1))
- //if(!(dev->openFlags() & 1))
- // return;
-
MidiSyncInfo& si = mp->syncInfo();
if(si.MMCOut())
mp->sendMMCStop();
@@ -639,17 +626,13 @@ void MidiDevice::handleStop()
{
// Send STOP
mp->sendStop();
-
- // p3.3.31
- // Added check of option send continue not start.
- // Hmm, is this required? Seems to make other devices unhappy.
- // (Could try now that this is in MidiDevice. p4.0.22 )
- /*
- if(!si.sendContNotStart())
- mp->sendSongpos(MusEGlobal::audio->tickPos() * 4 / MusEGlobal::config.division);
- */
+ // Added check of option send continue not start. Hmm, is this required? Seems to make other devices unhappy.
+ // (Could try now that this is in MidiDevice.)
+ //if(!si.sendContNotStart())
+ // mp->sendSongpos(MusEGlobal::audio->tickPos() * 4 / MusEGlobal::config.division);
}
}
+ */
}
//---------------------------------------------------------
@@ -662,6 +645,27 @@ void MidiDevice::handleSeek()
if(_port == -1)
return;
+ MidiPort* mp = &MusEGlobal::midiPorts[_port];
+ MidiCtrlValListList* cll = mp->controller();
+ int pos = MusEGlobal::audio->tickPos();
+
+ //---------------------------------------------------
+ // Send STOP
+ //---------------------------------------------------
+
+ // Don't send if external sync is on. The master, and our sync routing system will take care of that.
+ if(!MusEGlobal::extSyncFlag.value())
+ {
+ if(mp->syncInfo().MRTOut())
+ {
+ // Shall we check for device write open flag to see if it's ok to send?...
+ //if(!(rwFlags() & 0x1) || !(openFlags() & 1))
+ //if(!(openFlags() & 1))
+ // continue;
+ mp->sendStop();
+ }
+ }
+
//---------------------------------------------------
// If playing, clear all notes and handle stuck notes
//---------------------------------------------------
@@ -673,17 +677,15 @@ void MidiDevice::handleSeek()
{
MidiPlayEvent ev = *i;
ev.setTime(0);
- _playEvents.add(ev);
+ //_playEvents.add(ev);
+ putEvent(ev); // For immediate playback try putEvent, putMidiEvent, or sendEvent (for the optimizations) instead.
+ //mp->sendEvent(ev);
}
_stuckNotes.clear();
}
- MidiPort* mp = &MusEGlobal::midiPorts[_port];
- MidiCtrlValListList* cll = mp->controller();
- int pos = MusEGlobal::audio->tickPos();
-
//---------------------------------------------------
- // Send new contoller values
+ // Send new controller values
//---------------------------------------------------
for(iMidiCtrlValList ivl = cll->begin(); ivl != cll->end(); ++ivl)
@@ -693,10 +695,32 @@ void MidiDevice::handleSeek()
if(imcv != vl->end())
{
Part* p = imcv->second.part;
+ // Don't send if part or track is muted or off.
+ if(!p || p->mute())
+ continue;
+ Track* track = p->track();
+ if(track && (track->isMute() || track->off()))
+ continue;
unsigned t = (unsigned)imcv->first;
// Do not add values that are outside of the part.
if(p && t >= p->tick() && t < (p->tick() + p->lenTick()) )
- _playEvents.add(MidiPlayEvent(0, _port, ivl->first >> 24, ME_CONTROLLER, vl->num(), imcv->second.val));
+ //_playEvents.add(MidiPlayEvent(0, _port, ivl->first >> 24, ME_CONTROLLER, vl->num(), imcv->second.val));
+ // Use sendEvent to get the optimizations and limiting. But force if there's a value at this exact position.
+ mp->sendEvent(MidiPlayEvent(0, _port, ivl->first >> 24, ME_CONTROLLER, vl->num(), imcv->second.val), imcv->first == pos);
+ //mp->sendEvent(MidiPlayEvent(0, _port, ivl->first >> 24, ME_CONTROLLER, vl->num(), imcv->second.val), pos == 0 || imcv->first == pos);
+ }
+ }
+
+ //---------------------------------------------------
+ // reset sustain
+ //---------------------------------------------------
+
+ for(int ch = 0; ch < MIDI_CHANNELS; ++ch)
+ {
+ if(mp->hwCtrlState(ch, CTRL_SUSTAIN) == 127)
+ {
+ MidiPlayEvent ev(0, _port, ch, ME_CONTROLLER, CTRL_SUSTAIN, 0);
+ putEvent(ev);
}
}
@@ -709,24 +733,9 @@ void MidiDevice::handleSeek()
{
if(mp->syncInfo().MRTOut())
{
- // Shall we check for device write open flag to see if it's ok to send?...
- // This means obey what the user has chosen for read/write in the midi port config dialog,
- // which already takes into account whether the device is writable or not.
- //if(!(rwFlags() & 0x1) || !(openFlags() & 1))
- //if(!(openFlags() & 1))
- // continue;
-
+ //mp->sendStop(); // Moved above
int beat = (pos * 4) / MusEGlobal::config.division;
-
- //bool isPlaying = false;
- //if(state == PLAY)
- // isPlaying = true;
- bool isPlaying = MusEGlobal::audio->isPlaying(); // Check this it includes LOOP1 and LOOP2 besides PLAY. p4.0.22
-
- mp->sendStop();
mp->sendSongpos(beat);
- if(isPlaying)
- mp->sendContinue();
}
}
}
diff --git a/muse2/muse/mididev.h b/muse2/muse/mididev.h
index 57c96090..18a58623 100644
--- a/muse2/muse/mididev.h
+++ b/muse2/muse/mididev.h
@@ -28,7 +28,6 @@
#include <list>
#include "mpevent.h"
-//#include "sync.h"
#include "route.h"
#include "globaldefs.h"
@@ -37,7 +36,6 @@
namespace MusECore {
-//class RouteList;
class Xml;
//---------------------------------------------------------
@@ -57,9 +55,6 @@ class MidiDevice {
bool _readEnable; // set when opened/closed.
bool _writeEnable; //
- //int _sysexWriteChunk;
- //int _sysexReadChunk;
- //bool _sysexWritingChunks;
bool _sysexReadingChunks;
MPEventList _stuckNotes;
@@ -69,6 +64,9 @@ class MidiDevice {
MidiFifo eventFifo;
// Recording fifos. To speed up processing, one per channel plus one special system 'channel' for channel-less events like sysex.
MidiRecFifo _recordFifo[MIDI_CHANNELS + 1];
+
+ volatile bool stopPending;
+ volatile bool seekPending;
RouteList _inRoutes, _outRoutes;
@@ -126,7 +124,7 @@ class MidiDevice {
virtual bool putEvent(const MidiPlayEvent&);
// This method will try to putEvent 'tries' times, waiting 'delayUs' microseconds between tries.
// Since it waits, it should not be used in RT or other time-sensitive threads. p4.0.15
- bool putEventWithRetry(const MidiPlayEvent&, int /*tries*/ = 2, long /*delayUs*/ = 50000); // 2 tries, 50 mS by default.
+ bool putEventWithRetry(const MidiPlayEvent&, int tries = 2, long delayUs = 50000); // 2 tries, 50 mS by default.
virtual void handleStop();
virtual void handleSeek();
@@ -140,11 +138,8 @@ class MidiDevice {
MidiRecFifo& recordEvents(const unsigned int ch) { return _recordFifo[ch]; }
bool sysexFIFOProcessed() { return _sysexFIFOProcessed; }
void setSysexFIFOProcessed(bool v) { _sysexFIFOProcessed = v; }
- //bool sysexWritingChunks() { return _sysexWritingChunks; }
- //void setSysexWritingChunks(bool v) { _sysexWritingChunks = v; }
bool sysexReadingChunks() { return _sysexReadingChunks; }
void setSysexReadingChunks(bool v) { _sysexReadingChunks = v; }
- //virtual void getEvents(unsigned /*from*/, unsigned /*to*/, int /*channel*/, MPEventList* /*dst*/);
bool sendNullRPNParams(int, bool);
};
diff --git a/muse2/muse/midiedit/dcanvas.cpp b/muse2/muse/midiedit/dcanvas.cpp
index ad0226da..ab967fa9 100644
--- a/muse2/muse/midiedit/dcanvas.cpp
+++ b/muse2/muse/midiedit/dcanvas.cpp
@@ -35,8 +35,6 @@
#include <stdio.h>
#include <values.h>
#include <errno.h>
-//#include <sys/stat.h>
-//#include <sys/mman.h>
#include "dcanvas.h"
#include "midieditor.h"
@@ -97,7 +95,7 @@ CItem* DrumCanvas::addItem(MusECore::Part* part, MusECore::Event& event)
int diff = event.endTick()-part->lenTick();
if (diff > 0) {// too short part? extend it
- //printf("addItem - this code should not be run!\n");
+ //printf("addItem - this code should not be run!\n"); DELETETHIS
//MusECore::Part* newPart = part->clone();
//newPart->setLenTick(newPart->lenTick()+diff);
//MusEGlobal::audio->msgChangePart(part, newPart,false);
@@ -159,7 +157,6 @@ DrumCanvas::DrumCanvas(MidiEditor* pr, QWidget* parent, int sx,
DrumCanvas::~DrumCanvas()
{
- //items.clearDelete();
if (must_delete_our_drum_map && ourDrumMap!=NULL)
delete [] ourDrumMap;
@@ -338,10 +335,9 @@ bool DrumCanvas::moveItem(MusECore::Undo& operations, CItem* item, const QPoint&
newEvent.setPitch(ev_pitch);
newEvent.setTick(ntick);
- // Added by T356, removed by flo93: with operation groups, it happens that the
- // part is too short right now, even if it's queued for being extended
- //if(((int)newEvent.endTick() - (int)part->lenTick()) > 0)
- // printf("DrumCanvas::moveItem Error! New event end:%d exceeds length:%d of part:%s\n", newEvent.endTick(), part->lenTick(), part->name().toLatin1().constData());
+ // don't check, whether the new event is within the part
+ // at this place. with operation groups, the part isn't
+ // resized yet. (flo93)
if (dtype == MOVE_COPY || dtype == MOVE_CLONE)
operations.push_back(MusECore::UndoOp(MusECore::UndoOp::AddEvent, newEvent, dest_part, false, false));
@@ -364,7 +360,7 @@ bool DrumCanvas::moveItem(MusECore::Undo& operations, CItem* item, const QPoint&
CItem* DrumCanvas::newItem(const QPoint& p, int state)
{
- int instr = y2pitch(p.y()); //MusEGlobal::drumInmap[y2pitch(p.y())];
+ int instr = y2pitch(p.y());
if ((instr<0) || (instr>=getOurDrumMapSize()))
return NULL;
@@ -449,10 +445,8 @@ void DrumCanvas::newItem(CItem* item, bool noSnap, bool replace)
int npitch = event.pitch();
//event.setPitch(npitch); // commented out by flo: has no effect
- //
// check for existing event
// if found change command semantic from insert to delete
- //
MusECore::EventList* el = nevent->part()->events();
MusECore::iEvent lower = el->lower_bound(event.tick());
MusECore::iEvent upper = el->upper_bound(event.tick());
@@ -858,7 +852,7 @@ void DrumCanvas::dragLeaveEvent(QDragLeaveEvent*)
//---------------------------------------------------------
void DrumCanvas::keyPressed(int index, int velocity)
- {
+{
using MusECore::MidiTrack;
if ((index<0) || (index>=getOurDrumMapSize()))
diff --git a/muse2/muse/midiedit/dlist.cpp b/muse2/muse/midiedit/dlist.cpp
index ad0d05dd..e099ecc9 100644
--- a/muse2/muse/midiedit/dlist.cpp
+++ b/muse2/muse/midiedit/dlist.cpp
@@ -71,7 +71,7 @@ void DList::draw(QPainter& p, const QRect& rect)
if (dm == currentlySelected)
p.fillRect(x, yy, w, TH, Qt::yellow);
// else
-// p.eraseRect(x, yy, w, TH);
+// p.eraseRect(x, yy, w, TH); DELETETHIS?
QHeaderView *h = header;
p.save();
p.setWorldMatrixEnabled(false);
@@ -87,8 +87,6 @@ void DList::draw(QPainter& p, const QRect& rect)
QString s;
int align = Qt::AlignVCenter | Qt::AlignHCenter;
- //p.save();
- //p.setWorldMatrixEnabled(false);
switch (k) {
case COL_VOLUME:
s.setNum(dm->vol);
@@ -181,7 +179,6 @@ void DList::draw(QPainter& p, const QRect& rect)
}
if (!s.isEmpty())
p.drawText(r, align, s);
- //p.restore();
}
p.restore();
}
@@ -282,7 +279,6 @@ void DList::devicesPopupMenu(MusECore::DrumMap* t, int x, int y, bool changeAll)
{
int instr = getSelectedInstrument();
if(instr != -1)
- //emit curDrumInstrumentChanged(instr);
MusEGlobal::song->update(SC_DRUMMAP);
}
}
@@ -991,7 +987,7 @@ void DList::init(QHeaderView* h, QWidget* parent)
h = new QHeaderView(Qt::Horizontal, parent);
header = h;
- //ORCAN- CHECK if really needed: header->setTracking(true);
+ //ORCAN- CHECK if really needed: header->setTracking(true); DELETETHIS seems like it's unneeded ;)
connect(header, SIGNAL(sectionResized(int,int,int)),
SLOT(sizeChange(int,int,int)));
connect(header, SIGNAL(sectionMoved(int, int,int)), SLOT(moved(int,int,int)));
@@ -1104,7 +1100,7 @@ void DList::viewMouseReleaseEvent(QMouseEvent* ev)
emit mapChanged(sInstrument, (unsigned)dInstrument); //Track instrument change done in canvas
}
drag = NORMAL;
-//?? redraw(); //commented out NOT by flo93; was already commented out
+//?? redraw(); //commented out NOT by flo93; was already commented out. DELETETHIS? not the below, only this single line!
// if (editEntry) //removed by flo93; seems to work without it
// editor->setFocus(); //and causes segfaults after adding the pitchedits
int x = ev->x();
diff --git a/muse2/muse/midiedit/dlist.h b/muse2/muse/midiedit/dlist.h
index d864f23e..517ac722 100644
--- a/muse2/muse/midiedit/dlist.h
+++ b/muse2/muse/midiedit/dlist.h
@@ -141,8 +141,6 @@ class DList : public View {
void devicesPopupMenu(MusECore::DrumMap* t, int x, int y, bool changeAll);
void init(QHeaderView*, QWidget*);
-
- //void setCurDrumInstrument(int n);
private slots:
void sizeChange(int, int, int);
diff --git a/muse2/muse/midiedit/drumedit.cpp b/muse2/muse/midiedit/drumedit.cpp
index b4518fa9..e5b965f1 100644
--- a/muse2/muse/midiedit/drumedit.cpp
+++ b/muse2/muse/midiedit/drumedit.cpp
@@ -65,21 +65,6 @@
namespace MusEGui {
-/*
-static const char* map_file_pattern[] = {
- "Presets (*.map *.map.gz *.map.bz2)",
- "All Files (*)",
- 0
- };
-static const char* map_file_save_pattern[] = {
- "Presets (*.map)",
- "gzip compressed presets (*.map.gz)",
- "bzip2 compressed presets (*.map.bz2)",
- "All Files (*)",
- 0
- };
-*/
-
int DrumEdit::_rasterInit = 96;
int DrumEdit::_dlistWidthInit = 50;
int DrumEdit::_dcanvasWidthInit = 300;
@@ -143,7 +128,6 @@ void DrumEdit::closeEvent(QCloseEvent* e)
_isDeleting = true; // Set flag so certain signals like songChanged, which may cause crash during delete, can be ignored.
QSettings settings("MusE", "MusE-qt");
- //settings.setValue("Drumedit/geometry", saveGeometry());
settings.setValue("Drumedit/windowState", saveState());
//Store values of the horizontal splitter
@@ -163,7 +147,7 @@ void DrumEdit::closeEvent(QCloseEvent* e)
DrumEdit::DrumEdit(MusECore::PartList* pl, QWidget* parent, const char* name, unsigned initPos)
: MidiEditor(TopWin::DRUM, _rasterInit, pl, parent, name)
{
- setFocusPolicy(Qt::StrongFocus);
+ setFocusPolicy(Qt::NoFocus);
split1w1 = 0;
selPart = 0;
@@ -388,12 +372,14 @@ DrumEdit::DrumEdit(MusECore::PartList* pl, QWidget* parent, const char* name, un
QToolButton *ldm = new QToolButton();
ldm->setToolTip(tr("Load Drummap"));
ldm->setIcon(*openIcon);
+ ldm->setFocusPolicy(Qt::NoFocus);
connect(ldm, SIGNAL(clicked()), SLOT(load()));
maptools->addWidget(ldm);
QToolButton *sdm = new QToolButton();
sdm->setToolTip(tr("Store Drummap"));
sdm->setIcon(*saveIcon);
+ sdm->setFocusPolicy(Qt::NoFocus);
connect(sdm, SIGNAL(clicked()), SLOT(save()));
maptools->addWidget(sdm);
@@ -408,12 +394,14 @@ DrumEdit::DrumEdit(MusECore::PartList* pl, QWidget* parent, const char* name, un
srec->setToolTip(tr("Step Record"));
srec->setIcon(*steprecIcon);
srec->setCheckable(true);
+ srec->setFocusPolicy(Qt::NoFocus);
tools->addWidget(srec);
midiin = new QToolButton();
midiin->setToolTip(tr("Midi Input"));
midiin->setIcon(*midiinIcon);
midiin->setCheckable(true);
+ midiin->setFocusPolicy(Qt::NoFocus);
tools->addWidget(midiin);
@@ -436,7 +424,8 @@ DrumEdit::DrumEdit(MusECore::PartList* pl, QWidget* parent, const char* name, un
stepLenWidget->addItem("8");
stepLenWidget->addItem("16");
stepLenWidget->setCurrentIndex(0);
- connect(stepLenWidget, SIGNAL(currentIndexChanged(QString)), SLOT(setStep(QString)));
+ stepLenWidget->setFocusPolicy(Qt::TabFocus);
+ connect(stepLenWidget, SIGNAL(activated(QString)), SLOT(setStep(QString)));
cursorToolbar->addWidget(stepLenWidget);
addToolBarBreak();
@@ -456,9 +445,9 @@ DrumEdit::DrumEdit(MusECore::PartList* pl, QWidget* parent, const char* name, un
QPushButton* ctrl = new QPushButton(tr("ctrl"), mainw);
ctrl->setObjectName("Ctrl");
ctrl->setFont(MusEGlobal::config.fonts[3]);
- //hscroll = new MusEGui::ScrollScale(-25, -2, xscale, 20000, Qt::Horizontal, mainw);
- // Increased scale to -1. To resolve/select/edit 1-tick-wide (controller graph) events. p4.0.18 Tim.
- hscroll = new MusEGui::ScrollScale(-25, -1, xscale, 20000, Qt::Horizontal, mainw);
+ ctrl->setFocusPolicy(Qt::NoFocus);
+ // Increased scale to -1. To resolve/select/edit 1-tick-wide (controller graph) events.
+ hscroll = new MusEGui::ScrollScale(-25, -1 /* formerly -2 */, xscale, 20000, Qt::Horizontal, mainw);
ctrl->setFixedSize(40, hscroll->sizeHint().height());
ctrl->setToolTip(tr("Add Controller View"));
@@ -472,8 +461,6 @@ DrumEdit::DrumEdit(MusECore::PartList* pl, QWidget* parent, const char* name, un
mainGrid->addWidget(ctrl, 1, 0);
mainGrid->addWidget(hscroll, 1, 1);
mainGrid->addWidget(corner, 1, 2, Qt::AlignBottom|Qt::AlignRight);
-// mainGrid->addRowSpacing(1, hscroll->sizeHint().height());
-// mainGrid->addItem(new QSpacerItem(0, hscroll->sizeHint().height()), 1, 0);
split2 = new MusEGui::Splitter(Qt::Horizontal, split1, "split2");
split1w1 = new QWidget(split2);
@@ -503,7 +490,7 @@ DrumEdit::DrumEdit(MusECore::PartList* pl, QWidget* parent, const char* name, un
split2->setSizes(mops);
// By T356. Not much choice but to disable this for now, to stop runaway resize bug.
// Can't seem to get the splitter to readjust when manually setting sizes.
- //split2->setResizeMode(split1w1, QSplitter::KeepSize);
+ //split2->setResizeMode(split1w1, QSplitter::KeepSize); DELETETHIS or FIXME?
gridS2->setRowStretch(1, 100);
gridS2->setColumnStretch(0, 100);
@@ -513,9 +500,8 @@ DrumEdit::DrumEdit(MusECore::PartList* pl, QWidget* parent, const char* name, un
gridS2->addWidget(canvas, 2, 0);
gridS2->addWidget(vscroll, 2, 1);
- //
- // Reihenfolge in dlist.c festgeschrieben ("Dcols")
- //
+
+ // Ordering is hardcoded in dlist.c ("Dcols")
header = new MusEGui::Header(split1w1, "header");
header->setFixedHeight(31);
header->setColumnLabel(tr("H"), COL_HIDE, 20);
@@ -596,7 +582,12 @@ DrumEdit::DrumEdit(MusECore::PartList* pl, QWidget* parent, const char* name, un
connect(toolbar, SIGNAL(rasterChanged(int)), SLOT(setRaster(int)));
connect(toolbar, SIGNAL(soloChanged(bool)), SLOT(soloChanged(bool)));
connect(info, SIGNAL(valueChanged(MusEGui::NoteInfo::ValType, int)), SLOT(noteinfoChanged(MusEGui::NoteInfo::ValType, int)));
-
+ if(MusEGlobal::config.smartFocus)
+ {
+ connect(info, SIGNAL(returnPressed()), SLOT(focusCanvas()));
+ connect(info, SIGNAL(escapePressed()), SLOT(focusCanvas()));
+ }
+
connect(ctrl, SIGNAL(clicked()), SLOT(addCtrl()));
QClipboard* cb = QApplication::clipboard();
@@ -700,7 +691,6 @@ void DrumEdit::setTime(unsigned tick)
DrumEdit::~DrumEdit()
{
- //MusEGlobal::undoRedo->removeFrom(tools); // p4.0.6 Removed
}
//---------------------------------------------------------
@@ -725,6 +715,16 @@ void DrumEdit::setSelection(int tick, MusECore::Event& e, MusECore::Part* p)
}
//---------------------------------------------------------
+// focusCanvas
+//---------------------------------------------------------
+
+void DrumEdit::focusCanvas()
+{
+ canvas->setFocus();
+ canvas->activateWindow();
+}
+
+//---------------------------------------------------------
// soloChanged
//---------------------------------------------------------
@@ -743,6 +743,8 @@ void DrumEdit::setRaster(int val)
_rasterInit = val;
MidiEditor::setRaster(val);
canvas->redrawGrid();
+ if(MusEGlobal::config.smartFocus)
+ focusCanvas(); // give back focus after kb input
}
//---------------------------------------------------------
@@ -774,7 +776,6 @@ void DrumEdit::noteinfoChanged(MusEGui::NoteInfo::ValType type, int val)
break;
}
// Indicate do undo, and do not do port controller values and clone parts.
- //MusEGlobal::audio->msgChangeEvent(selEvent, event, selPart);
MusEGlobal::audio->msgChangeEvent(selEvent, event, selPart, true, false, false);
}
@@ -980,7 +981,6 @@ ende:
void DrumEdit::save()
{
- //QString fn = MusEGui::getSaveFileName(QString("drummaps"), map_file_pattern,
QString fn = MusEGui::getSaveFileName(QString("drummaps"), MusEGlobal::drum_map_file_save_pattern,
this, tr("MusE: Store Drum Map"));
if (fn.isEmpty())
@@ -1050,7 +1050,7 @@ void DrumEdit::cmd(int cmd)
if (quantize_dialog->exec())
quantize_notes(partlist_to_set(parts()), quantize_dialog->range,
(MusEGlobal::config.division*4)/raster,
- /* quant_len= */false, quantize_dialog->strength,
+ /* quant_len= */false, quantize_dialog->strength, // DELETETHIS
quantize_dialog->swing, quantize_dialog->threshold);
break;
}
@@ -1109,8 +1109,6 @@ CtrlEdit* DrumEdit::addCtrl()
connect(dlist, SIGNAL(curDrumInstrumentChanged(int)), canvas, SLOT(setCurDrumInstrument(int)));
connect(canvas, SIGNAL(curPartHasChanged(MusECore::Part*)), ctrlEdit, SLOT(curPartHasChanged(MusECore::Part*)));
- //printf("DrumEdit::addCtrl curDrumInstrument:%d\n", dlist->getSelectedInstrument());
-
setCurDrumInstrument(dlist->getSelectedInstrument());
// p3.3.44
@@ -1121,7 +1119,6 @@ CtrlEdit* DrumEdit::addCtrl()
if(split1w1)
{
- ///split2->setCollapsible(split1w1, false);
split2->setCollapsible(split2->indexOf(split1w1), false);
split1w1->setMinimumWidth(CTRL_PANEL_FIXED_WIDTH);
}
@@ -1155,7 +1152,6 @@ void DrumEdit::removeCtrl(CtrlEdit* ctrl)
if(ctrlEditList.empty())
{
split1w1->setMinimumWidth(0);
- ///split2->setCollapsible(split1w1, true);
split2->setCollapsible(split2->indexOf(split1w1), true);
}
}
@@ -1171,11 +1167,8 @@ void DrumEdit::newCanvasWidth(int w)
nw = 1;
for (std::list<CtrlEdit*>::iterator i = ctrlEditList.begin();
- i != ctrlEditList.end(); ++i) {
- // Changed by Tim. p3.3.7
- //(*i)->setCanvasWidth(w);
+ i != ctrlEditList.end(); ++i)
(*i)->setCanvasWidth(nw);
- }
updateHScrollRange();
}
@@ -1328,7 +1321,7 @@ void DrumEdit::keyPressEvent(QKeyEvent* event)
}
/*
- else if (key == shortcuts[SHRT_INSERT_AT_LOCATION].key) {
+ else if (key == shortcuts[SHRT_INSERT_AT_LOCATION].key) { DELETETHIS
pc->pianoCmd(CMD_INSERT);
return;
}
@@ -1350,7 +1343,7 @@ void DrumEdit::keyPressEvent(QKeyEvent* event)
else if (key == shortcuts[SHRT_TOGGLE_TRIOL].key)
val = rasterTable[index + ((off == 0) ? 9 : 0)];
/*
- else if (key == shortcuts[SHRT_EVENT_COLOR].key) {
+ else if (key == shortcuts[SHRT_EVENT_COLOR].key) { DELETETHIS
if (colorMode == 0)
colorMode = 1;
else if (colorMode == 1)
@@ -1417,7 +1410,6 @@ void DrumEdit::initShortcuts()
//---------------------------------------------------------
void DrumEdit::execDeliveredScript(int id)
{
- //QString scriptfile = QString(INSTPREFIX) + SCRIPTSSUFFIX + deliveredScriptNames[id];
QString scriptfile = MusEGlobal::song->getScriptPath(id, true);
MusEGlobal::song->executeScript(scriptfile.toLatin1().constData(), parts(), raster(), true);
}
@@ -1434,8 +1426,8 @@ void DrumEdit::execUserScript(int id)
void DrumEdit::setStep(QString v)
{
((DrumCanvas*)canvas)->setStep(v.toInt());
- stepLenWidget->setFocusPolicy(Qt::NoFocus);
- canvas->setFocus();
+ if(MusEGlobal::config.smartFocus)
+ focusCanvas();
}
void DrumEdit::ourDrumMapChanged(bool instrMapChanged)
diff --git a/muse2/muse/midiedit/drumedit.h b/muse2/muse/midiedit/drumedit.h
index 33491581..907b8b84 100644
--- a/muse2/muse/midiedit/drumedit.h
+++ b/muse2/muse/midiedit/drumedit.h
@@ -122,7 +122,6 @@ class DrumEdit : public MidiEditor {
private slots:
void setRaster(int);
void noteinfoChanged(MusEGui::NoteInfo::ValType type, int val);
- //CtrlEdit* addCtrl();
void removeCtrl(CtrlEdit* ctrl);
void cmd(int);
void clipboardChanged(); // enable/disable "Paste"
@@ -144,6 +143,7 @@ class DrumEdit : public MidiEditor {
void hideEmptyInstruments();
void display_old_new_conflict_message();
+ void focusCanvas();
public slots:
void setSelection(int, MusECore::Event&, MusECore::Part*);
diff --git a/muse2/muse/midiedit/drummap.cpp b/muse2/muse/midiedit/drummap.cpp
index d86bcd65..477b2f9d 100644
--- a/muse2/muse/midiedit/drummap.cpp
+++ b/muse2/muse/midiedit/drummap.cpp
@@ -119,77 +119,6 @@ const DrumMap idrumMap[DRUM_MAPSIZE] = {
{ QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 97, 97, false },
{ QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 98, 98, false },
- /*
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 83, 83, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 84, 84, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 85, 85, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 86, 86, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 87, 87, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 88, 88, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 89, 89, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 90, 90, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 91, 91, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 92, 92, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 93, 93, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 94, 94, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 95, 95, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 96, 96, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 97, 97, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 98, 98, false },
-
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 83, 83, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 84, 84, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 85, 85, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 86, 86, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 87, 87, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 88, 88, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 89, 89, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 90, 90, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 91, 91, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 92, 92, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 93, 93, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 94, 94, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 95, 95, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 96, 96, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 97, 97, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 98, 98, false },
-
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 83, 83, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 84, 84, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 85, 85, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 86, 86, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 87, 87, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 88, 88, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 89, 89, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 90, 90, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 91, 91, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 92, 92, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 93, 93, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 94, 94, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 95, 95, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 96, 96, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 97, 97, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 98, 98, false },
-
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 83, 83, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 84, 84, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 85, 85, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 86, 86, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 87, 87, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 88, 88, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 89, 89, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 90, 90, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 91, 91, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 92, 92, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 93, 93, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 94, 94, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 95, 95, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 96, 96, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 97, 97, false },
- { QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 98, 98, false }
- };
- */
-
{ QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 99, 99, false },
{ QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 100, 100, false },
{ QString(""), 100, 16, 32, 9, 0, 70, 90, 127, 110, 101, 101, false },
@@ -339,9 +268,7 @@ void initDrumMap()
void resetGMDrumMap()
{
MusEGlobal::audio->msgIdle(true);
- // Delete all port controller events.
- //MusEGlobal::audio->msgChangeAllPortDrumCtrlEvents(false);
- MusEGlobal::song->changeAllPortDrumCtrlEvents(false);
+ MusEGlobal::song->changeAllPortDrumCtrlEvents(false); // Delete all port controller events.
for(int i = 0; i < DRUM_MAPSIZE; ++i)
MusEGlobal::drumMap[i] = idrumMap[i];
@@ -351,9 +278,8 @@ void resetGMDrumMap()
MusEGlobal::drumInmap[(unsigned int)(MusEGlobal::drumMap[i].enote)] = i;
MusEGlobal::drumOutmap[(unsigned int)(MusEGlobal::drumMap[i].anote)] = i;
}
- // Add all port controller events.
- //MusEGlobal::audio->msgChangeAllPortDrumCtrlEvents(true);
- MusEGlobal::song->changeAllPortDrumCtrlEvents(true);
+
+ MusEGlobal::song->changeAllPortDrumCtrlEvents(true); // Add all port controller events.
MusEGlobal::audio->msgIdle(false);
}
@@ -522,9 +448,7 @@ static void readDrummapEntry(Xml& xml, DrumMap* dm)
void readDrumMap(Xml& xml, bool external)
{
MusEGlobal::audio->msgIdle(true);
- // Delete all port controller events.
- //MusEGlobal::audio->msgChangeAllPortDrumCtrlEvents(false);
- MusEGlobal::song->changeAllPortDrumCtrlEvents(false);
+ MusEGlobal::song->changeAllPortDrumCtrlEvents(false); // Delete all port controller events.
if (external) {
for (int i = 0; i < DRUM_MAPSIZE; ++i)
@@ -568,9 +492,8 @@ void readDrumMap(Xml& xml, bool external)
MusEGlobal::drumInmap[(unsigned int)(MusEGlobal::drumMap[i].enote)] = i;
MusEGlobal::drumOutmap[(unsigned int)(MusEGlobal::drumMap[i].anote)] = i;
}
- // Add all port controller events.
- //MusEGlobal::audio->msgChangeAllPortDrumCtrlEvents(true);
- MusEGlobal::song->changeAllPortDrumCtrlEvents(true);
+
+ MusEGlobal::song->changeAllPortDrumCtrlEvents(true); // Add all port controller events.
MusEGlobal::audio->msgIdle(false);
return;
@@ -579,9 +502,8 @@ void readDrumMap(Xml& xml, bool external)
break;
}
}
- // Add all port controller events.
- //MusEGlobal::audio->msgChangeAllPortDrumCtrlEvents(true);
- MusEGlobal::song->changeAllPortDrumCtrlEvents(true);
+
+ MusEGlobal::song->changeAllPortDrumCtrlEvents(true); // Add all port controller events.
MusEGlobal::audio->msgIdle(false);
}
diff --git a/muse2/muse/midiedit/drummap.h b/muse2/muse/midiedit/drummap.h
index 7f28b068..2dca10d6 100644
--- a/muse2/muse/midiedit/drummap.h
+++ b/muse2/muse/midiedit/drummap.h
@@ -45,7 +45,6 @@ struct DrumMap {
char lv1, lv2, lv3, lv4; // velocities
char enote, anote; // input note - output note
bool mute;
-// bool selected;
bool operator==(const DrumMap& map) const;
bool operator!=(const DrumMap& map) const { return !operator==(map); }
diff --git a/muse2/muse/midiedit/ecanvas.cpp b/muse2/muse/midiedit/ecanvas.cpp
index 3eeb4f84..984ec41c 100644
--- a/muse2/muse/midiedit/ecanvas.cpp
+++ b/muse2/muse/midiedit/ecanvas.cpp
@@ -21,6 +21,7 @@
//
//=========================================================
+#include <stdio.h>
#include <errno.h>
#include <values.h>
#include <sys/stat.h>
@@ -77,9 +78,7 @@ QString EventCanvas::getCaption() const
{
int bar1, bar2, xx;
unsigned x;
- ///sigmap.tickValues(curPart->tick(), &bar1, &xx, &x);
AL::sigmap.tickValues(curPart->tick(), &bar1, &xx, &x);
- ///sigmap.tickValues(curPart->tick() + curPart->lenTick(), &bar2, &xx, &x);
AL::sigmap.tickValues(curPart->tick() + curPart->lenTick(), &bar2, &xx, &x);
return QString("MusE: Part <") + curPart->name()
@@ -151,7 +150,7 @@ void EventCanvas::songChanged(int flags)
return;
if (flags & ~SC_SELECTION) {
- //items.clear();
+ //items.clear(); DELETETHIS
bool curItemNeedsRestore=false;
MusECore::Event storedEvent;
int partSn;
@@ -182,10 +181,8 @@ void EventCanvas::songChanged(int flags)
MusECore::EventList* el = part->events();
for (MusECore::iEvent i = el->begin(); i != el->end(); ++i) {
MusECore::Event e = i->second;
- // Added by T356. Do not add events which are either past, or extend past the end of the part.
- // Reverted to just events which are past. p4.0.24
+ // Do not add events which are past the end of the part.
if(e.tick() > len)
- //if(e.endTick() > len)
break;
if (e.isNote()) {
@@ -288,13 +285,10 @@ MusECore::MidiTrack* EventCanvas::track() const
void EventCanvas::keyPress(QKeyEvent* event)
{
int key = event->key();
- ///if (event->state() & Qt::ShiftButton)
if (((QInputEvent*)event)->modifiers() & Qt::ShiftModifier)
key += Qt::SHIFT;
- ///if (event->state() & Qt::AltButton)
if (((QInputEvent*)event)->modifiers() & Qt::AltModifier)
key += Qt::ALT;
- ///if (event->state() & Qt::ControlButton)
if (((QInputEvent*)event)->modifiers() & Qt::ControlModifier)
key+= Qt::CTRL;
diff --git a/muse2/muse/midiedit/ecanvas.h b/muse2/muse/midiedit/ecanvas.h
index ad19480e..349bb92b 100644
--- a/muse2/muse/midiedit/ecanvas.h
+++ b/muse2/muse/midiedit/ecanvas.h
@@ -73,7 +73,6 @@ class EventCanvas : public Canvas {
void updateSelection();
virtual CItem* addItem(MusECore::Part*, MusECore::Event&) = 0;
- // Added by T356.
virtual QPoint raster(const QPoint&) const;
virtual MusECore::Undo moveCanvasItems(CItemList&, int, int, DragType) = 0;
virtual bool moveItem(MusECore::Undo&, CItem*, const QPoint&, DragType) = 0;
diff --git a/muse2/muse/midiedit/piano.cpp b/muse2/muse/midiedit/piano.cpp
index abd360df..1000ffe9 100644
--- a/muse2/muse/midiedit/piano.cpp
+++ b/muse2/muse/midiedit/piano.cpp
@@ -404,13 +404,10 @@ void Piano::draw(QPainter& p, const QRect& r)
int drawY = octaveSize * drawKey + 81 - KH*2;
if (drawY > r.y() && drawY < r.y() + r.height()) {
- //printf("drawing c %d at %d r.y %d r.x %d\n",drawKey, drawY, r.y(), r.x());
p.drawPixmap(0,drawY,*c_keys[drawKey]);
}
}
- //p.drawTiledPixmap(r, *c1, r.topLeft()+offset + coffset);
- //printf("drawText KH %d %d, x %d y %d\n",KH, curPitch, r.x(), r.y());
- //p.drawText(r,Qt::AlignAuto,"A");
+
if (curPitch == -1)
return;
int y = pitch2y(curPitch);
@@ -457,7 +454,7 @@ int Piano::pitch2y(int pitch) const
int Piano::y2pitch(int y) const
{
- const int total = (10 * 7 + 5) * KH; // 75 Ganztonschritte
+ const int total = (10 * 7 + 5) * KH; // 75 full tone steps
y = total - y;
int oct = (y / (7 * KH)) * 12;
char kt[] = {
@@ -524,7 +521,6 @@ void Piano::viewMouseMoveEvent(QMouseEvent* event)
keyDown = nk;
if (keyDown != -1) {
int velocity = event->x()*127/40;
- //emit keyPressed(keyDown, shift);
emit keyPressed(keyDown, velocity>127 ? 127 : velocity, shift);
}
}
diff --git a/muse2/muse/midiedit/pianoroll.cpp b/muse2/muse/midiedit/pianoroll.cpp
index 33245c4c..71b2abf8 100644
--- a/muse2/muse/midiedit/pianoroll.cpp
+++ b/muse2/muse/midiedit/pianoroll.cpp
@@ -157,12 +157,10 @@ PianoRoll::PianoRoll(MusECore::PartList* pl, QWidget* parent, const char* name,
menuSelect->addSeparator();
- //selectPrevPartAction = select->addAction(tr("&Previous Part"));
selectPrevPartAction = menuSelect->addAction(QIcon(*select_all_parts_on_trackIcon), tr("&Previous Part"));
mapper->setMapping(selectPrevPartAction, PianoCanvas::CMD_SELECT_PREV_PART);
connect(selectPrevPartAction, SIGNAL(triggered()), mapper, SLOT(map()));
- //selNextPartAction = select->addAction(tr("&Next Part"));
selectNextPartAction = menuSelect->addAction(QIcon(*select_all_parts_on_trackIcon), tr("&Next Part"));
mapper->setMapping(selectNextPartAction, PianoCanvas::CMD_SELECT_NEXT_PART);
connect(selectNextPartAction, SIGNAL(triggered()), mapper, SLOT(map()));
@@ -232,17 +230,14 @@ PianoRoll::PianoRoll(MusECore::PartList* pl, QWidget* parent, const char* name,
QActionGroup* actgrp = new QActionGroup(this);
actgrp->setExclusive(true);
- //evColorBlueAction = eventColor->addAction(tr("&Blue"));
evColorBlueAction = actgrp->addAction(tr("&Blue"));
evColorBlueAction->setCheckable(true);
colorMapper->setMapping(evColorBlueAction, 0);
- //evColorPitchAction = eventColor->addAction(tr("&Pitch colors"));
evColorPitchAction = actgrp->addAction(tr("&Pitch colors"));
evColorPitchAction->setCheckable(true);
colorMapper->setMapping(evColorPitchAction, 1);
- //evColorVelAction = eventColor->addAction(tr("&Velocity colors"));
evColorVelAction = actgrp->addAction(tr("&Velocity colors"));
evColorVelAction->setCheckable(true);
colorMapper->setMapping(evColorVelAction, 2);
@@ -269,18 +264,21 @@ PianoRoll::PianoRoll(MusECore::PartList* pl, QWidget* parent, const char* name,
srec->setToolTip(tr("Step Record"));
srec->setIcon(*steprecIcon);
srec->setCheckable(true);
+ srec->setFocusPolicy(Qt::NoFocus);
tools->addWidget(srec);
midiin = new QToolButton();
midiin->setToolTip(tr("Midi Input"));
midiin->setIcon(*midiinIcon);
midiin->setCheckable(true);
+ midiin->setFocusPolicy(Qt::NoFocus);
tools->addWidget(midiin);
speaker = new QToolButton();
speaker->setToolTip(tr("Play Events"));
speaker->setIcon(*speakerIcon);
speaker->setCheckable(true);
+ speaker->setFocusPolicy(Qt::NoFocus);
tools->addWidget(speaker);
tools2 = new MusEGui::EditToolBar(this, pianorollTools);
@@ -306,31 +304,21 @@ PianoRoll::PianoRoll(MusECore::PartList* pl, QWidget* parent, const char* name,
hsplitter->setHandleWidth(2);
QPushButton* ctrl = new QPushButton(tr("ctrl"), mainw);
- //QPushButton* ctrl = new QPushButton(tr("C"), mainw); // Tim.
ctrl->setObjectName("Ctrl");
ctrl->setFont(MusEGlobal::config.fonts[3]);
ctrl->setToolTip(tr("Add Controller View"));
- //hscroll = new MusEGui::ScrollScale(-25, -2, xscale, 20000, Qt::Horizontal, mainw);
- // Increased scale to -1. To resolve/select/edit 1-tick-wide (controller graph) events. p4.0.18 Tim.
- hscroll = new MusEGui::ScrollScale(-25, -1, xscale, 20000, Qt::Horizontal, mainw);
+ ctrl->setFocusPolicy(Qt::NoFocus);
+ // Increased scale to -1. To resolve/select/edit 1-tick-wide (controller graph) events.
+ hscroll = new MusEGui::ScrollScale(-25, -1 /* formerly -2 */, xscale, 20000, Qt::Horizontal, mainw);
ctrl->setFixedSize(pianoWidth, hscroll->sizeHint().height());
- //ctrl->setFixedSize(pianoWidth / 2, hscroll->sizeHint().height()); // Tim.
-
- // Tim.
- /*
- QPushButton* trackInfoButton = new QPushButton(tr("T"), mainw);
- trackInfoButton->setObjectName("TrackInfo");
- trackInfoButton->setFont(MusEGlobal::config.fonts[3]);
- trackInfoButton->setToolTip(tr("Show track info"));
- trackInfoButton->setFixedSize(pianoWidth / 2, hscroll->sizeHint().height());
- */
+ //ctrl->setFixedSize(pianoWidth / 2, hscroll->sizeHint().height()); // DELETETHIS?
QSizeGrip* corner = new QSizeGrip(mainw);
midiTrackInfo = new MusEGui::MidiTrackInfo(mainw);
int mtiw = midiTrackInfo->width(); // Save this.
midiTrackInfo->setMinimumWidth(100);
- //midiTrackInfo->setMaximumWidth(150);
+ //midiTrackInfo->setMaximumWidth(150); DELETETHIS ?
midiTrackInfo->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Expanding));
infoScroll = new QScrollArea;
@@ -339,7 +327,8 @@ PianoRoll::PianoRoll(MusECore::PartList* pl, QWidget* parent, const char* name,
infoScroll->setSizePolicy(QSizePolicy(QSizePolicy::Maximum, QSizePolicy::Expanding));
infoScroll->setWidget(midiTrackInfo);
infoScroll->setWidgetResizable(true);
- //infoScroll->setVisible(false);
+ infoScroll->setFocusPolicy(Qt::NoFocus);
+ //infoScroll->setVisible(false); DELETETHIS 4?
//infoScroll->setEnabled(false);
//hsplitter->addWidget(midiTrackInfo);
@@ -350,7 +339,7 @@ PianoRoll::PianoRoll(MusECore::PartList* pl, QWidget* parent, const char* name,
mainGrid->setColumnStretch(1, 100);
mainGrid->addWidget(hsplitter, 0, 1, 1, 3);
- // Original.
+ // Original. DELETETHIS 21
/*
mainGrid->setColumnStretch(1, 100);
mainGrid->addWidget(splitter, 0, 0, 1, 3);
@@ -385,8 +374,6 @@ PianoRoll::PianoRoll(MusECore::PartList* pl, QWidget* parent, const char* name,
canvas = new PianoCanvas(this, split1, xscale, yscale);
vscroll = new MusEGui::ScrollScale(-3, 7, yscale, KH * 75, Qt::Vertical, split1);
- //setFocusProxy(canvas); // Tim.
-
int offset = -(MusEGlobal::config.division/4);
canvas->setOrigin(offset, 0);
canvas->setCanvasTools(pianorollTools);
@@ -398,7 +385,7 @@ PianoRoll::PianoRoll(MusECore::PartList* pl, QWidget* parent, const char* name,
gridS1->setRowStretch(2, 100);
gridS1->setColumnStretch(1, 100);
- //gridS1->setColumnStretch(2, 100); // Tim.
+ //gridS1->setColumnStretch(2, 100); // Tim. DELETETHIS
gridS1->addWidget(time, 0, 1, 1, 2);
gridS1->addWidget(MusECore::hLine(split1), 1, 0, 1, 3);
@@ -406,7 +393,7 @@ PianoRoll::PianoRoll(MusECore::PartList* pl, QWidget* parent, const char* name,
gridS1->addWidget(canvas, 2, 1);
gridS1->addWidget(vscroll, 2, 2);
- // Tim.
+ // Tim. DELETETHIS
/*
gridS1->addWidget(time, 0, 2, 1, 3);
gridS1->addWidget(MusECore::hLine(split1), 1, 1, 1, 4);
@@ -429,11 +416,10 @@ PianoRoll::PianoRoll(MusECore::PartList* pl, QWidget* parent, const char* name,
gridS2->addWidget(ctrl, 0, 0);
gridS2->addWidget(hscroll, 0, 1);
gridS2->addWidget(corner, 0, 2, Qt::AlignBottom|Qt::AlignRight);
- //splitter->setCollapsible(0, true);
+ //splitter->setCollapsible(0, true); DELETETHIS
piano->setFixedWidth(pianoWidth);
- // Tim.
QList<int> mops;
mops.append(mtiw + 30); // 30 for possible scrollbar
mops.append(width() - mtiw - 30);
@@ -442,8 +428,9 @@ PianoRoll::PianoRoll(MusECore::PartList* pl, QWidget* parent, const char* name,
connect(tools2, SIGNAL(toolChanged(int)), canvas, SLOT(setTool(int)));
connect(ctrl, SIGNAL(clicked()), SLOT(addCtrl()));
- //connect(trackInfoButton, SIGNAL(clicked()), SLOT(toggleTrackInfo())); Tim.
+ //connect(trackInfoButton, SIGNAL(clicked()), SLOT(toggleTrackInfo())); Tim. DELETETHIS
connect(info, SIGNAL(valueChanged(MusEGui::NoteInfo::ValType, int)), SLOT(noteinfoChanged(MusEGui::NoteInfo::ValType, int)));
+
connect(vscroll, SIGNAL(scrollChanged(int)), piano, SLOT(setYPos(int)));
connect(vscroll, SIGNAL(scrollChanged(int)), canvas, SLOT(setYPos(int)));
connect(vscroll, SIGNAL(scaleChanged(int)), canvas, SLOT(setYMag(int)));
@@ -470,11 +457,18 @@ PianoRoll::PianoRoll(MusECore::PartList* pl, QWidget* parent, const char* name,
connect(speaker, SIGNAL(toggled(bool)), SLOT(setSpeaker(bool)));
connect(canvas, SIGNAL(followEvent(int)), SLOT(follow(int)));
+ if(MusEGlobal::config.smartFocus)
+ {
+ connect(info, SIGNAL(returnPressed()), SLOT(focusCanvas()));
+ connect(info, SIGNAL(escapePressed()), SLOT(focusCanvas()));
+ connect(midiTrackInfo, SIGNAL(returnPressed()), SLOT(focusCanvas()));
+ connect(midiTrackInfo, SIGNAL(escapePressed()), SLOT(focusCanvas()));
+ }
+
connect(hscroll, SIGNAL(scaleChanged(int)), SLOT(updateHScrollRange()));
piano->setYPos(KH * 30);
canvas->setYPos(KH * 30);
vscroll->setPos(KH * 30);
- //setSelection(0, 0, 0); //Really necessary? Causes segfault when only 1 item selected, replaced by the following:
info->setEnabled(false);
connect(MusEGlobal::song, SIGNAL(songChanged(int)), SLOT(songChanged1(int)));
@@ -490,10 +484,10 @@ PianoRoll::PianoRoll(MusECore::PartList* pl, QWidget* parent, const char* name,
connect(toolbar, SIGNAL(rasterChanged(int)),SLOT(setRaster(int)));
connect(toolbar, SIGNAL(soloChanged(bool)), SLOT(soloChanged(bool)));
- setFocusPolicy(Qt::StrongFocus);
+ setFocusPolicy(Qt::NoFocus);
+
setEventColorMode(colorMode);
-
QClipboard* cb = QApplication::clipboard();
connect(cb, SIGNAL(dataChanged()), SLOT(clipboardChanged()));
@@ -504,7 +498,6 @@ PianoRoll::PianoRoll(MusECore::PartList* pl, QWidget* parent, const char* name,
const MusECore::Pos cpos=MusEGlobal::song->cPos();
canvas->setPos(0, cpos.tick(), true);
canvas->selectAtTick(cpos.tick());
- //canvas->selectFirst();//
unsigned pos=0;
if(initPos >= MAXINT)
@@ -534,12 +527,10 @@ void PianoRoll::songChanged1(int bits)
return;
if (bits & SC_SOLO)
- {
toolbar->setSolo(canvas->track()->solo());
- return;
- }
+
songChanged(bits);
- //trackInfo->songChanged(bits);
+
// We'll receive SC_SELECTION if a different part is selected.
if (bits & SC_SELECTION)
updateTrackInfo();
@@ -552,7 +543,6 @@ void PianoRoll::songChanged1(int bits)
void PianoRoll::configChanged()
{
initShortcuts();
- //trackInfo->updateTrackInfo();
}
//---------------------------------------------------------
@@ -615,7 +605,6 @@ void PianoRoll::setTime(unsigned tick)
PianoRoll::~PianoRoll()
{
- // MusEGlobal::undoRedo->removeFrom(tools); // p4.0.6 Removed
}
//---------------------------------------------------------
@@ -701,11 +690,21 @@ void PianoRoll::setSelection(int tick, MusECore::Event& e, MusECore::Part* p)
}
//---------------------------------------------------------
+// focusCanvas
+//---------------------------------------------------------
+
+void PianoRoll::focusCanvas()
+{
+ canvas->setFocus();
+ canvas->activateWindow();
+}
+
+//---------------------------------------------------------
// edit currently selected Event
//---------------------------------------------------------
void PianoRoll::noteinfoChanged(MusEGui::NoteInfo::ValType type, int val)
- {
+ {
int selections = canvas->selectionSize();
if (selections == 0) {
@@ -731,7 +730,6 @@ void PianoRoll::noteinfoChanged(MusEGui::NoteInfo::ValType type, int val)
break;
}
// Indicate do undo, and do not do port controller values and clone parts.
- //MusEGlobal::audio->msgChangeEvent(selEvent, event, selPart);
MusEGlobal::audio->msgChangeEvent(selEvent, event, selPart, true, false, false);
}
else {
@@ -772,8 +770,7 @@ void PianoRoll::noteinfoChanged(MusEGui::NoteInfo::ValType type, int val)
CtrlEdit* PianoRoll::addCtrl()
{
- ///CtrlEdit* ctrlEdit = new CtrlEdit(splitter, this, xscale, false, "pianoCtrlEdit");
- CtrlEdit* ctrlEdit = new CtrlEdit(ctrlLane/*splitter*/, this, xscale, false, "pianoCtrlEdit"); // ccharrett
+ CtrlEdit* ctrlEdit = new CtrlEdit(ctrlLane/* formerly splitter*/, this, xscale, false, "pianoCtrlEdit"); // ccharrett
connect(tools2, SIGNAL(toolChanged(int)), ctrlEdit, SLOT(setTool(int)));
connect(hscroll, SIGNAL(scrollChanged(int)), ctrlEdit, SLOT(setXPos(int)));
connect(hscroll, SIGNAL(scaleChanged(int)), ctrlEdit, SLOT(setXMag(int)));
@@ -816,7 +813,6 @@ void PianoRoll::closeEvent(QCloseEvent* e)
_isDeleting = true; // Set flag so certain signals like songChanged, which may cause crash during delete, can be ignored.
QSettings settings("MusE", "MusE-qt");
- //settings.setValue("Pianoroll/geometry", saveGeometry());
settings.setValue("Pianoroll/windowState", saveState());
emit isDeleting(static_cast<TopWin*>(this));
@@ -887,7 +883,8 @@ void PianoRoll::setRaster(int val)
_rasterInit = val;
MidiEditor::setRaster(val);
canvas->redrawGrid();
- canvas->setFocus(); // give back focus after kb input
+ if(MusEGlobal::config.smartFocus)
+ focusCanvas(); // give back focus after kb input
}
//---------------------------------------------------------
@@ -1190,9 +1187,6 @@ void PianoRoll::setEventColorMode(int mode)
colorMode = mode;
colorModeInit = colorMode;
- ///eventColor->setItemChecked(0, mode == 0);
- ///eventColor->setItemChecked(1, mode == 1);
- ///eventColor->setItemChecked(2, mode == 2);
evColorBlueAction->setChecked(mode == 0);
evColorPitchAction->setChecked(mode == 1);
evColorVelAction->setChecked(mode == 2);
@@ -1234,7 +1228,7 @@ void PianoRoll::setSpeaker(bool val)
-/*
+/* DELETETHIS
//---------------------------------------------------------
// trackInfoScroll
//---------------------------------------------------------
@@ -1289,7 +1283,6 @@ void PianoRoll::initShortcuts()
//---------------------------------------------------------
void PianoRoll::execDeliveredScript(int id)
{
- //QString scriptfile = QString(INSTPREFIX) + SCRIPTSSUFFIX + deliveredScriptNames[id];
QString scriptfile = MusEGlobal::song->getScriptPath(id, true);
MusEGlobal::song->executeScript(scriptfile.toAscii().data(), parts(), raster(), true);
}
@@ -1309,7 +1302,7 @@ void PianoRoll::execUserScript(int id)
void PianoRoll::newCanvasWidth(int /*w*/)
{
-/*
+/* DELETETHIS whole function?
int nw = w + (vscroll->width() - 18); // 18 is the fixed width of the CtlEdit VScale widget.
if(nw < 1)
nw = 1;
diff --git a/muse2/muse/midiedit/pianoroll.h b/muse2/muse/midiedit/pianoroll.h
index 9b73fc1b..20ae093e 100644
--- a/muse2/muse/midiedit/pianoroll.h
+++ b/muse2/muse/midiedit/pianoroll.h
@@ -76,11 +76,6 @@ class PianoRoll : public MidiEditor {
MusECore::MidiPart* selPart;
int selTick;
- //enum { CMD_EVENT_COLOR, CMD_CONFIG_QUANT, CMD_LAST };
- //int menu_ids[CMD_LAST];
- //Q3PopupMenu *menuEdit, *menuFunctions, *menuSelect, *menuConfig, *menuPlugins;
-
-
QMenu *menuEdit, *menuFunctions, *menuSelect, *menuConfig, *eventColor, *menuPlugins;
MusEGui::MidiTrackInfo *midiTrackInfo;
MusECore::Track* selected;
@@ -143,7 +138,6 @@ class PianoRoll : public MidiEditor {
bool _playEvents;
- //QScrollBar* infoScroll;
QScrollArea* infoScroll;
@@ -156,10 +150,8 @@ class PianoRoll : public MidiEditor {
private slots:
void setSelection(int, MusECore::Event&, MusECore::Part*);
void noteinfoChanged(MusEGui::NoteInfo::ValType, int);
- //CtrlEdit* addCtrl();
void removeCtrl(CtrlEdit* ctrl);
void soloChanged(bool flag);
- //void trackInfoScroll(int);
void setRaster(int);
void cmd(int);
void setSteprec(bool);
@@ -174,6 +166,7 @@ class PianoRoll : public MidiEditor {
void newCanvasWidth(int);
void toggleTrackInfo();
void updateTrackInfo();
+ void focusCanvas();
signals:
void isDeleting(MusEGui::TopWin*);
diff --git a/muse2/muse/midiedit/prcanvas.cpp b/muse2/muse/midiedit/prcanvas.cpp
index fe7f6979..794e04ad 100644
--- a/muse2/muse/midiedit/prcanvas.cpp
+++ b/muse2/muse/midiedit/prcanvas.cpp
@@ -38,11 +38,6 @@
#include <stdio.h>
#include <math.h>
#include <errno.h>
-//#include <sys/stat.h>
-//#include <sys/types.h>
-//#include <sys/mman.h>
-//#include <fcntl.h>
-//#include <dirent.h>
#include "xml.h"
#include "prcanvas.h"
@@ -88,7 +83,7 @@ CItem* PianoCanvas::addItem(MusECore::Part* part, MusECore::Event& event)
int diff = event.tick()-part->lenTick();
if (diff > 0) {// too short part? extend it
- //printf("addItem - this code should not be run!\n");
+ //printf("addItem - this code should not be run!\n"); DELETETHIS
//MusECore::Part* newPart = part->clone();
//newPart->setLenTick(newPart->lenTick()+diff);
//MusEGlobal::audio->msgChangePart(part, newPart,false);
@@ -177,24 +172,16 @@ void PianoCanvas::drawItem(QPainter& p, const MusEGui::CItem* item,
QRect rr = map(rect); // Use our own map instead.
QRect mer = map(r);
- ///r = r.intersected(rect);
- //QRect rr = r & rect;
- ///if(!r.isValid())
- //if(!rr.isValid())
- // return;
QRect mr = rr & mer;
- //if(!mr.isValid())
if(mr.isNull())
return;
- //p.save();
-
p.setPen(Qt::black);
struct Triple {
int r, g, b;
};
- static Triple myColors /*Qt::color1*/[12] = { // ddskrjp
+ static Triple myColors [12] = { // ddskrjp
{ 0xff, 0x3d, 0x39 },
{ 0x39, 0xff, 0x39 },
{ 0x39, 0x3d, 0xff },
@@ -234,7 +221,7 @@ void PianoCanvas::drawItem(QPainter& p, const MusEGui::CItem* item,
break;
case 1: // pitch
{
- Triple* c = &myColors/*Qt::color1*/[event.pitch() % 12];
+ Triple* c = &myColors[event.pitch() % 12];
color.setRgb(c->r, c->g, c->b);
}
break;
@@ -261,7 +248,7 @@ void PianoCanvas::drawItem(QPainter& p, const MusEGui::CItem* item,
int mey = mer.y();
int mew = mer.width();
int meh = mer.height();
- //int mfx = mx;
+ //int mfx = mx; DELETETHIS
//if(mfx == mex) mfx += 1;
//int mfy = my;
//if(mfy == mey) mfy += 1;
@@ -272,13 +259,13 @@ void PianoCanvas::drawItem(QPainter& p, const MusEGui::CItem* item,
//if(mfh == meh) mfh -= 1;
//if(mfy == mey) mfh -= 1;
color.setAlpha(MusEGlobal::config.globalAlphaBlend);
- //QLinearGradient gradient(mex + 1, mey + 1, mex + 1, mey + meh - 2); // Inside the border
+ //QLinearGradient gradient(mex + 1, mey + 1, mex + 1, mey + meh - 2); // Inside the border DELETETHIS
//gradient.setColorAt(0, color);
//gradient.setColorAt(1, color.darker());
//QBrush brush(gradient);
QBrush brush(color);
p.fillRect(mr, brush);
- //p.fillRect(mfx, mfy, mfw, mfh, brush);
+ //p.fillRect(mfx, mfy, mfw, mfh, brush); DELETETHIS
if(mex >= mx && mex <= mx + mw)
p.drawLine(mex, my, mex, my + mh - 1); // The left edge
@@ -289,9 +276,7 @@ void PianoCanvas::drawItem(QPainter& p, const MusEGui::CItem* item,
if(mey + meh >= my && mey + meh <= my + mh)
p.drawLine(mx, mey + meh - 1, mx + mw - 1, mey + meh - 1); // The bottom edge
- //p.setWorldMatrixEnabled(true);
p.setWorldMatrixEnabled(wmtxen);
- //p.restore();
}
//---------------------------------------------------------
@@ -307,10 +292,6 @@ void PianoCanvas::drawTopItem(QPainter& , const QRect&)
void PianoCanvas::drawMoving(QPainter& p, const MusEGui::CItem* item, const QRect& rect)
{
- //if(((NEvent*)item)->part() != curPart)
- // return;
- //if(!item->isMoving())
- // return;
QRect mr = QRect(item->mp().x(), item->mp().y() - item->height()/2, item->width(), item->height());
mr = mr.intersected(rect);
if(!mr.isValid())
@@ -479,9 +460,7 @@ bool PianoCanvas::moveItem(MusECore::Undo& operations, MusEGui::CItem* item, con
MusEGlobal::audio->msgPlayMidiEvent(&ev2);
}
- // Changed by T356.
- MusECore::Part* part = nevent->part(); //
- //MusECore::Part* part = Canvas::part(); // part can be dynamically recreated, ask the authority
+ MusECore::Part* part = nevent->part();
newEvent.setPitch(npitch);
int ntick = editor->rasterVal(x) - part->tick();
@@ -490,10 +469,9 @@ bool PianoCanvas::moveItem(MusECore::Undo& operations, MusEGui::CItem* item, con
newEvent.setTick(ntick);
newEvent.setLenTick(event.lenTick());
- // Added by T356, removed by flo93: with operation groups, it happens that the
- // part is too short right now, even if it's queued for being extended
- //if(((int)newEvent.endTick() - (int)part->lenTick()) > 0)
- // printf("PianoCanvas::moveItem Error! New event end:%d exceeds length:%d of part:%s\n", newEvent.endTick(), part->lenTick(), part->name().toLatin1().constData());
+ // don't check, whether the new event is within the part
+ // at this place. with operation groups, the part isn't
+ // resized yet. (flo93)
if (dtype == MOVE_COPY || dtype == MOVE_CLONE)
operations.push_back(MusECore::UndoOp(MusECore::UndoOp::AddEvent, newEvent, part, false, false));
@@ -509,7 +487,6 @@ bool PianoCanvas::moveItem(MusECore::Undo& operations, MusEGui::CItem* item, con
MusEGui::CItem* PianoCanvas::newItem(const QPoint& p, int)
{
- //printf("newItem point\n");
int pitch = y2pitch(p.y());
int tick = editor->rasterVal1(p.x());
int len = p.x() - tick;
@@ -526,7 +503,6 @@ MusEGui::CItem* PianoCanvas::newItem(const QPoint& p, int)
void PianoCanvas::newItem(MusEGui::CItem* item, bool noSnap)
{
- //printf("newItem citem\n");
NEvent* nevent = (NEvent*) item;
MusECore::Event event = nevent->event();
int x = item->x();
@@ -560,8 +536,7 @@ void PianoCanvas::newItem(MusEGui::CItem* item, bool noSnap)
MusEGlobal::song->applyOperationGroup(operations);
}
- //else forbid action by not applying it
- else
+ else // forbid action by not applying it
songChanged(SC_EVENT_INSERTED); //this forces an update of the itemlist, which is neccessary
//to remove "forbidden" events from the list again
}
@@ -572,7 +547,6 @@ void PianoCanvas::newItem(MusEGui::CItem* item, bool noSnap)
void PianoCanvas::resizeItem(MusEGui::CItem* item, bool noSnap, bool) // experimental changes to try dynamically extending parts
{
- //printf("resizeItem!\n");
NEvent* nevent = (NEvent*) item;
MusECore::Event event = nevent->event();
MusECore::Event newEvent = event.clone();
@@ -583,7 +557,6 @@ void PianoCanvas::resizeItem(MusEGui::CItem* item, bool noSnap, bool) //
if (noSnap)
len = nevent->width();
else {
- //MusECore::Part* part = nevent->part();
unsigned tick = event.tick() + part->tick();
len = editor->rasterVal(tick + nevent->width()) - tick;
if (len <= 0)
@@ -687,7 +660,7 @@ void PianoCanvas::pianoCmd(int cmd)
for (std::list<MusECore::Event>::iterator i = elist.begin(); i != elist.end(); ++i) {
MusECore::Event event = *i;
MusECore::Event newEvent = event.clone();
- newEvent.setTick(event.tick() + editor->raster());// - part->tick());
+ newEvent.setTick(event.tick() + editor->raster());// - part->tick()); DELETETHIS
// Do not do port controller values and clone parts.
operations.push_back(MusECore::UndoOp(MusECore::UndoOp::ModifyEvent, newEvent, event, part, false, false));
}
@@ -740,7 +713,7 @@ void PianoCanvas::pianoPressed(int pitch, int velocity, bool shift)
MusECore::MidiPlayEvent e(0, port, channel, 0x90, pitch, velocity);
MusEGlobal::audio->msgPlayMidiEvent(&e);
- if (_steprec && curPart /* && pos[0] >= start_tick && pos[0] < end_tick [removed by flo93: this is handled in steprec->record] */)
+ if (_steprec && curPart) // && pos[0] >= start_tick && pos[0] < end_tick [removed by flo93: this is handled in steprec->record]
steprec->record(curPart,pitch,editor->raster(),editor->raster(),velocity,MusEGlobal::globalKeyState&Qt::ControlModifier,shift, -1 /* anything which is != rcSteprecNote */);
}
@@ -770,6 +743,8 @@ void PianoCanvas::drawCanvas(QPainter& p, const QRect& rect)
int w = rect.width();
int h = rect.height();
+ //DELETETHIS whoa, clean up the whole function. remove every commented out code line
+
// Changed to draw in device coordinate space instead of virtual, transformed space. Tim. p4.0.30
//int mx = mapx(x);
@@ -990,7 +965,7 @@ void PianoCanvas::startDrag(MusEGui::CItem* /* item*/, bool copymode)
void PianoCanvas::dragEnterEvent(QDragEnterEvent* event)
{
- ///event->accept(Q3TextDrag::canDecode(event));
+ //event->accept(Q3TextDrag::canDecode(event));
event->acceptProposedAction(); // TODO CHECK Tim.
}
@@ -1000,7 +975,7 @@ void PianoCanvas::dragEnterEvent(QDragEnterEvent* event)
void PianoCanvas::dragMoveEvent(QDragMoveEvent*)
{
- //printf("drag move %x\n", this);
+ //printf("drag move %x\n", this); DELETETHIS (whole function?)
//event->acceptProposedAction();
}
@@ -1010,7 +985,7 @@ void PianoCanvas::dragMoveEvent(QDragMoveEvent*)
void PianoCanvas::dragLeaveEvent(QDragLeaveEvent*)
{
- //printf("drag leave\n");
+ //printf("drag leave\n"); DELETETHIS (whole function?)
//event->acceptProposedAction();
}
@@ -1159,7 +1134,6 @@ void PianoCanvas::modifySelected(MusEGui::NoteInfo::ValType type, int delta)
}
MusEGlobal::song->changeEvent(event, newEvent, part);
// Indicate do not do port controller values and clone parts.
- //MusEGlobal::song->addUndo(MusECore::UndoOp(MusECore::UndoOp::ModifyEvent, newEvent, event, part));
MusEGlobal::song->addUndo(MusECore::UndoOp(MusECore::UndoOp::ModifyEvent, newEvent, event, part, false, false));
already_done.append(QPair<MusECore::EventList*,MusECore::Event>(part->events(), event));
diff --git a/muse2/muse/midiedit/scoreedit.cpp b/muse2/muse/midiedit/scoreedit.cpp
index 955a73d0..5722a275 100644
--- a/muse2/muse/midiedit/scoreedit.cpp
+++ b/muse2/muse/midiedit/scoreedit.cpp
@@ -45,7 +45,6 @@
#include <QImage>
#include <QInputDialog>
#include <QMessageBox>
-#include <QSpinBox>
#include <stdio.h>
#include <math.h>
@@ -69,12 +68,9 @@ using namespace std;
#include "functions.h"
#include "helper.h"
#include "cmd.h"
-#include "sig.h"
#include "song.h"
#include "shortcuts.h"
-//#include "../ctrl/ctrledit.h"
-
using MusEGlobal::debugMsg;
using MusEGlobal::heavyDebugMsg;
@@ -108,7 +104,8 @@ QString IntToQStr(int i);
-//do NOT put parentheses around this!
+//do NOT put parentheses around this! and always right-multiply it,
+//that is: foo * PAGESTEP, never PAGESTEP * foo!
#define PAGESTEP 3/4
@@ -184,7 +181,7 @@ ScoreEdit::ScoreEdit(QWidget* parent, const char* name, unsigned initPos)
: TopWin(TopWin::SCORE, parent, name)
{
setAttribute(Qt::WA_DeleteOnClose);
- setFocusPolicy(Qt::StrongFocus);
+ setFocusPolicy(Qt::NoFocus);
mainw = new QWidget(this);
@@ -243,6 +240,7 @@ ScoreEdit::ScoreEdit(QWidget* parent, const char* name, unsigned initPos)
srec->setToolTip(tr("Step Record"));
srec->setIcon(*steprecIcon);
srec->setCheckable(true);
+ srec->setFocusPolicy(Qt::NoFocus);
steprec_tools->addWidget(srec);
connect(srec, SIGNAL(toggled(bool)), score_canvas, SLOT(set_steprec(bool)));
@@ -318,24 +316,34 @@ ScoreEdit::ScoreEdit(QWidget* parent, const char* name, unsigned initPos)
note_settings_toolbar->addWidget(apply_velo_to_label);
note_settings_toolbar->addWidget(new QLabel(tr("Velocity:"), note_settings_toolbar));
- velo_spinbox = new QSpinBox(this);
+ velo_spinbox = new SpinBox(this);
velo_spinbox->setRange(0, 127);
velo_spinbox->setSingleStep(1);
//we do not use the valueChanged signal, because that would generate
//many many undos when using the spin buttons.
connect(velo_spinbox, SIGNAL(editingFinished()), SLOT(velo_box_changed()));
connect(this,SIGNAL(velo_changed(int)), score_canvas, SLOT(set_velo(int)));
+ if(MusEGlobal::config.smartFocus)
+ {
+ connect(velo_spinbox, SIGNAL(returnPressed()), SLOT(focusCanvas()));
+ connect(velo_spinbox, SIGNAL(escapePressed()), SLOT(focusCanvas()));
+ }
note_settings_toolbar->addWidget(velo_spinbox);
velo_spinbox->setValue(ScoreCanvas::note_velo_init);
note_settings_toolbar->addWidget(new QLabel(tr("Off-Velocity:"), note_settings_toolbar));
- velo_off_spinbox = new QSpinBox(this);
+ velo_off_spinbox = new SpinBox(this);
velo_off_spinbox->setRange(0, 127);
velo_off_spinbox->setSingleStep(1);
//we do not use the valueChanged signal, because that would generate
//many many undos when using the spin buttons.
connect(velo_off_spinbox, SIGNAL(editingFinished()), SLOT(velo_off_box_changed()));
connect(this,SIGNAL(velo_off_changed(int)), score_canvas, SLOT(set_velo_off(int)));
+ if(MusEGlobal::config.smartFocus)
+ {
+ connect(velo_off_spinbox, SIGNAL(returnPressed()), SLOT(focusCanvas()));
+ connect(velo_off_spinbox, SIGNAL(escapePressed()), SLOT(focusCanvas()));
+ }
note_settings_toolbar->addWidget(velo_off_spinbox);
velo_off_spinbox->setValue(ScoreCanvas::note_velo_off_init);
@@ -350,25 +358,33 @@ ScoreEdit::ScoreEdit(QWidget* parent, const char* name, unsigned initPos)
quant_combobox->addItem("8"); // _quant_power2 and _quant_power2_init
quant_combobox->addItem("16"); // and MAX_QUANT_POWER (must be log2(largest_value))
quant_combobox->addItem("32");
+ quant_combobox->setFocusPolicy(Qt::TabFocus);
quant_combobox->setCurrentIndex(score_canvas->quant_power2()-1);
// the above is intendedly executed BEFORE connecting. otherwise this would
// destroy pixels_per_whole_init!
- connect(quant_combobox, SIGNAL(currentIndexChanged(int)), score_canvas, SLOT(set_quant(int)));
+ //connect(quant_combobox, SIGNAL(currentIndexChanged(int)), score_canvas, SLOT(set_quant(int)));
+ connect(quant_combobox, SIGNAL(activated(int)), SLOT(quant_combobox_changed(int))); // Tim
quant_toolbar->addWidget(quant_combobox);
quant_toolbar->addSeparator();
quant_toolbar->addWidget(new QLabel(tr("Pixels per whole:"), quant_toolbar));
- px_per_whole_spinbox = new QSpinBox(this);
+ px_per_whole_spinbox = new SpinBox(this);
+ px_per_whole_spinbox->setFocusPolicy(Qt::StrongFocus);
px_per_whole_spinbox->setRange(10, 1200);
px_per_whole_spinbox->setSingleStep(50);
connect(px_per_whole_spinbox, SIGNAL(valueChanged(int)), score_canvas, SLOT(set_pixels_per_whole(int)));
connect(score_canvas, SIGNAL(pixels_per_whole_changed(int)), px_per_whole_spinbox, SLOT(setValue(int)));
+ if(MusEGlobal::config.smartFocus)
+ {
+ connect(px_per_whole_spinbox, SIGNAL(returnPressed()), SLOT(focusCanvas()));
+ connect(px_per_whole_spinbox, SIGNAL(escapePressed()), SLOT(focusCanvas()));
+ }
quant_toolbar->addWidget(px_per_whole_spinbox);
px_per_whole_spinbox->setValue(ScoreCanvas::_pixels_per_whole_init);
- QMenu* edit_menu = menuBar()->addMenu(tr("&Edit"));
+ QMenu* edit_menu = menuBar()->addMenu(tr("&Edit"));
edit_menu->addActions(MusEGlobal::undoRedo->actions());
edit_menu->addSeparator();
@@ -426,7 +442,7 @@ ScoreEdit::ScoreEdit(QWidget* parent, const char* name, unsigned initPos)
connect(select_oloop_action, SIGNAL(triggered()), menu_mapper, SLOT(map()));
- QMenu* functions_menu = menuBar()->addMenu(tr("Fu&nctions"));
+ QMenu* functions_menu = menuBar()->addMenu(tr("Fu&nctions"));
func_quantize_action = functions_menu->addAction(tr("&Quantize"), menu_mapper, SLOT(map()));
func_notelen_action = functions_menu->addAction(tr("Change note &length"), menu_mapper, SLOT(map()));
@@ -450,7 +466,7 @@ ScoreEdit::ScoreEdit(QWidget* parent, const char* name, unsigned initPos)
menu_mapper->setMapping(func_legato_action, CMD_LEGATO);
- QMenu* settings_menu = menuBar()->addMenu(tr("Window &Config"));
+ QMenu* settings_menu = menuBar()->addMenu(tr("Window &Config"));
color_menu = settings_menu->addMenu(tr("Note head &colors"));
color_actions = new QActionGroup(this);
@@ -491,7 +507,7 @@ ScoreEdit::ScoreEdit(QWidget* parent, const char* name, unsigned initPos)
preamble_keysig_action->setChecked(ScoreCanvas::preamble_contains_keysig_init);
preamble_timesig_action->setChecked(ScoreCanvas::preamble_contains_timesig_init);
-
+
QAction* set_name_action = settings_menu->addAction(tr("Set Score &name"), menu_mapper, SLOT(map()));
menu_mapper->setMapping(set_name_action, CMD_SET_NAME);
@@ -499,7 +515,7 @@ ScoreEdit::ScoreEdit(QWidget* parent, const char* name, unsigned initPos)
settings_menu->addAction(subwinAction);
settings_menu->addAction(shareAction);
settings_menu->addAction(fullscreenAction);
-
+
init_shortcuts();
@@ -614,6 +630,12 @@ ScoreEdit::~ScoreEdit()
names.erase(name);
}
+void ScoreEdit::focusCanvas()
+{
+ score_canvas->setFocus();
+ score_canvas->activateWindow();
+}
+
void ScoreEdit::velo_box_changed()
{
emit velo_changed(velo_spinbox->value());
@@ -624,11 +646,18 @@ void ScoreEdit::velo_off_box_changed()
emit velo_off_changed(velo_off_spinbox->value());
}
+void ScoreEdit::quant_combobox_changed(int idx)
+{
+ score_canvas->set_quant(idx);
+ if(MusEGlobal::config.smartFocus)
+ focusCanvas();
+}
+
void ScoreEdit::song_changed(int flags)
{
if(_isDeleting) // Ignore while while deleting to prevent crash.
return;
-
+
if (flags & (SC_SELECTION | SC_EVENT_MODIFIED | SC_EVENT_REMOVED))
{
map<MusECore::Event*, MusECore::Part*> selection=get_events(score_canvas->get_all_parts(),1);
@@ -699,7 +728,7 @@ void ScoreEdit::closeEvent(QCloseEvent* e)
{
_isDeleting = true; // Set flag so certain signals like songChanged, which may cause crash during delete, can be ignored.
names.erase(name);
-
+
QSettings settings("MusE", "MusE-qt");
//settings.setValue("ScoreEdit/geometry", saveGeometry());
settings.setValue("ScoreEdit/windowState", saveState());
@@ -976,6 +1005,10 @@ void ScoreCanvas::write_staves(int level, MusECore::Xml& xml) const
void ScoreEdit::readStatus(MusECore::Xml& xml)
{
+ // never "return;" inside that function.
+ // instead, goto end_of_scoreedit_read_status;
+ // (there is a command which must be executed!)
+
bool apply_velo_temp=apply_velo;
apply_velo=false;
@@ -1063,12 +1096,15 @@ void ScoreEdit::readStatus(MusECore::Xml& xml)
case MusECore::Xml::TagEnd:
if (tag == "scoreedit")
- return;
+ goto end_of_scoreedit_read_status;
default:
break;
}
}
+
+end_of_scoreedit_read_status:
+
apply_velo=apply_velo_temp;
}
@@ -1510,7 +1546,7 @@ void ScoreCanvas::song_changed(int flags)
{
if(parent && parent->deleting()) // Ignore while while deleting to prevent crash.
return;
-
+
if (flags & (SC_PART_MODIFIED | SC_PART_REMOVED | SC_PART_INSERTED | SC_TRACK_REMOVED))
{
update_parts();
@@ -2132,12 +2168,19 @@ list<note_len_t> parse_note_len(int len_ticks, int begin_tick, vector<int>& foo,
#define NUMBER_HEIGHT (pix_num[0].height())
-//kann 0 oder 1 sein:
-//bei notenkollisionen mit ungerader anzahl von kollidierenden
-//wird immer so ausgewichen, dass möglichst wenige ausweichen müssen
-//wenn die anzahl aber gerade ist, gibt es keine "bessere" lösung
-//in dem fall werden immer die geraden (0) bzw. ungeraden (1)
-//ausweichen.
+// kann 0 oder 1 sein:
+// bei notenkollisionen mit ungerader anzahl von kollidierenden
+// wird immer so ausgewichen, dass möglichst wenige ausweichen müssen
+// wenn die anzahl aber gerade ist, gibt es keine "bessere" lösung
+// in dem fall werden immer die geraden (0) bzw. ungeraden (1)
+// ausweichen.
+// ROUGH TRANSLATION:
+// can be 0 or 1:
+// when there are note head collisions with an odd number of colliding
+// heads there's an unique solution for "stepping aside", so that
+// fewer notes must "step aside". but when the number of colliding
+// heads is even, there is no "better" solution. this constant
+// specifies whether the "odd" (1) or the "even" (0) heads will move.
#define AUSWEICHEN_BEVORZUGT 0
#define STEM_LEN 30
@@ -2861,9 +2904,11 @@ void ScoreCanvas::draw_note_lines(QPainter& p, int y, bool reserve_akkolade_spac
void staff_t::calc_item_pos()
{
- MusECore::key_enum curr_key=MusECore::KEY_C; //this has to be KEY_C or KEY_C_B and nothing else,
- //because only with these two keys the next (initial)
- //key signature is properly drawn.
+ //this has to be KEY_C or KEY_C_B and nothing else,
+ //because only with these two keys the next (initial)
+ //key signature is properly drawn.
+ MusECore::key_enum curr_key=MusECore::KEY_C;
+
int pos_add=0;
max_y_coord=0;
@@ -2974,9 +3019,13 @@ void ScoreCanvas::calc_pos_add_list()
//process key changes
- MusECore::key_enum curr_key=MusECore::KEY_C; //this has to be KEY_C or KEY_C_B and nothing else,
- //because only with these two keys the next (initial)
- //key signature is properly calculated.
+
+ //this has to be KEY_C or KEY_C_B and nothing else,
+ //because only with these two keys the next (initial)
+ //key signature is properly calculated.
+ MusECore::key_enum curr_key=MusECore::KEY_C;
+
+
for (MusECore::iKeyEvent it=MusEGlobal::keymap.begin(); it!=MusEGlobal::keymap.end(); it++)
{
MusECore::key_enum new_key=it->second.key;
@@ -3252,10 +3301,10 @@ void ScoreCanvas::draw_items(QPainter& p, int y_offset, staff_t& staff, ScoreIte
list<int> aufloes_list=calc_accidentials(curr_key, staff.clef, new_key);
list<int> new_acc_list=calc_accidentials(new_key, staff.clef);
- // vorzeichen aus curr_key auflösen
+ // cancel accidentials from curr_key
draw_accidentials(p, it->x + KEYCHANGE_ACC_LEFTDIST - x_pos+x_left, y_offset, aufloes_list, pix_noacc[BLACK_PIXMAP]);
- // alle vorzeichen aus new_key zeichnen
+ // draw all accidentials from new_key
QPixmap* pix = is_sharp_key(new_key) ? &pix_sharp[BLACK_PIXMAP] : &pix_b[BLACK_PIXMAP];
vorzeichen_t new_accidential = is_sharp_key(new_key) ? SHARP : B;
@@ -3650,9 +3699,9 @@ void ScoreCanvas::mousePressEvent (QMouseEvent* event)
keystate=event->modifiers();
bool ctrl=keystate & Qt::ControlModifier;
- // den errechneten tick immer ABrunden!
- // denn der "bereich" eines schlags geht von schlag_begin bis nächsterschlag_begin-1
- // noten werden aber genau in die mitte dieses bereiches gezeichnet
+ // always round DOWN.
+ // because the "area" of a beat goes from "beat_begin" to "nextbeat_begin-1",
+ // but notes are drawn in the middle of that area!
list<staff_t>::iterator staff_it=staff_at_y(event->y() + y_pos);
@@ -4644,7 +4693,8 @@ void ScoreCanvas::add_new_parts(const std::map< MusECore::Part*, std::set<MusECo
/* BUGS and potential bugs
* o tied notes don't work properly when there's a key-change in
- * between, for example, when a cis is tied to a des
+ * between, for example, when a cis is tied to a des [ will not fix ]
+ * (reason: this actually never happens if dealing with a sane piece)
* > o when changing toolbarstate when sharing and immediately after that
* changing "share" status, the changed state isn't stored
* (could be solved by storing the current window when quitting/saving whatever)
@@ -4689,6 +4739,15 @@ void ScoreCanvas::add_new_parts(const std::map< MusECore::Part*, std::set<MusECo
* o all places where i added doubleclick-edits: only react on left-click double clicks!
* o support "new style" reordering with old style drum tracks as well
* (not swapping but inserting!)
+ *
+ * o canvas editor: create clone via "alt+drag" moves window instead
+ * o controller view in score editor
+ * o solo button
+ * o do partial recalculating; recalculating can take pretty long
+ * (0,5 sec) when displaying a whole song in scores
+ * o transpose etc. must also transpose key-pressure events
+ * o transpose: support in-key-transpose
+ * o thin out: remove unneeded ctrl messages
* o support edge-scrolling when opening a lasso
* o add "dotted quarter" quantize option (for 6/8 beat)
* o ticks-to-quarter spinboxes
@@ -4702,15 +4761,6 @@ void ScoreCanvas::add_new_parts(const std::map< MusECore::Part*, std::set<MusECo
*
* o shrink a part from its beginning as well! watch out for clones!
*
- * o canvas editor: create clone via "alt+drag" moves window instead
- * o controller view in score editor
- * o solo button
- * > o do partial recalculating; recalculating can take pretty long
- * (0,5 sec) when displaying a whole song in scores
- * o transpose etc. must also transpose key-pressure events
- * o transpose: support in-key-transpose
- * o thin out: remove unneeded ctrl messages
- *
* less important stuff
* o allow "fixating" toolbars?
* o quantize-templates (everything is forced into a specified
diff --git a/muse2/muse/midiedit/scoreedit.h b/muse2/muse/midiedit/scoreedit.h
index 7a16d19f..584c5f78 100644
--- a/muse2/muse/midiedit/scoreedit.h
+++ b/muse2/muse/midiedit/scoreedit.h
@@ -51,6 +51,7 @@
#include "steprec.h"
#include "cleftypes.h"
#include "helper.h"
+#include "spinbox.h"
#include <set>
#include <map>
@@ -106,11 +107,11 @@ class ScoreEdit : public TopWin
QWidget* mainw;
MusEGui::EditToolBar* edit_tools;
- QSpinBox* velo_spinbox;
- QSpinBox* velo_off_spinbox;
+ SpinBox* velo_spinbox;
+ SpinBox* velo_off_spinbox;
QComboBox* quant_combobox;
- QSpinBox* px_per_whole_spinbox;
+ SpinBox* px_per_whole_spinbox;
QAction* preamble_keysig_action;
QAction* preamble_timesig_action;
@@ -179,9 +180,11 @@ class ScoreEdit : public TopWin
void menu_command(int);
void velo_box_changed();
void velo_off_box_changed();
+ void quant_combobox_changed(int);
void init_shortcuts();
void selection_changed();
void clipboard_changed();
+ void focusCanvas();
signals:
void isDeleting(MusEGui::TopWin*);
diff --git a/muse2/muse/midieditor.h b/muse2/muse/midieditor.h
index fa59c9cc..9a215a03 100644
--- a/muse2/muse/midieditor.h
+++ b/muse2/muse/midieditor.h
@@ -23,7 +23,6 @@
#ifndef __MIDIEDITOR_H__
#define __MIDIEDITOR_H__
-///#include "sig.h"
#include "al/sig.h"
#include "cobject.h"
@@ -93,10 +92,6 @@ class MidiEditor : public TopWin {
QWidget* parent = 0, const char* name = 0);
~MidiEditor();
- ///int rasterStep(unsigned tick) const { return sigmap.rasterStep(tick, _raster); }
- ///unsigned rasterVal(unsigned v) const { return sigmap.raster(v, _raster); }
- ///unsigned rasterVal1(unsigned v) const { return sigmap.raster1(v, _raster); }
- ///unsigned rasterVal2(unsigned v) const { return sigmap.raster2(v, _raster); }
int rasterStep(unsigned tick) const { return AL::sigmap.rasterStep(tick, _raster); }
unsigned rasterVal(unsigned v) const { return AL::sigmap.raster(v, _raster); }
unsigned rasterVal1(unsigned v) const { return AL::sigmap.raster1(v, _raster); }
diff --git a/muse2/muse/midievent.cpp b/muse2/muse/midievent.cpp
index 97f2359a..9e0e8974 100644
--- a/muse2/muse/midievent.cpp
+++ b/muse2/muse/midievent.cpp
@@ -90,7 +90,6 @@ void MidiEventBase::dump(int n) const
// MidiEventBase::write
//---------------------------------------------------------
-//void MidiEventBase::write(int level, Xml& xml, const Pos& offset) const
void MidiEventBase::write(int level, Xml& xml, const Pos& offset, bool /*forcePath*/) const
{
xml.nput(level++, "<event tick=\"%d\"", tick() + offset.tick());
@@ -120,12 +119,6 @@ void MidiEventBase::write(int level, Xml& xml, const Pos& offset, bool /*forcePa
xml.tag(level, "/event");
}
else {
- //if (a)
- // xml.nput(" a=\"%d\"", a);
- //if (b)
- // xml.nput(" b=\"%d\"", b);
- //if (c)
- // xml.nput(" c=\"%d\"", c);
xml.nput(" />\n");
}
}
diff --git a/muse2/muse/midievent.h b/muse2/muse/midievent.h
index 2c832cdf..a63fede2 100644
--- a/muse2/muse/midievent.h
+++ b/muse2/muse/midievent.h
@@ -70,7 +70,6 @@ class MidiEventBase : public EventBase {
virtual void dump(int n = 0) const;
virtual void read(Xml&);
- //virtual void write(int, Xml&, const Pos& offset) const;
virtual void write(int, Xml&, const Pos& offset, bool forcePath = false) const;
virtual EventBase* mid(unsigned, unsigned);
};
diff --git a/muse2/muse/midifile.cpp b/muse2/muse/midifile.cpp
index 1fc7e114..5e45f261 100644
--- a/muse2/muse/midifile.cpp
+++ b/muse2/muse/midifile.cpp
@@ -340,8 +340,8 @@ int MidiFile::readEvent(MidiPlayEvent* event, MidiFileTrack* t)
return -2;
}
if (buffer[len-1] != 0xf7) {
- printf("SYSEX endet nicht mit 0xf7!\n");
- // Fortsetzung folgt?
+ printf("SYSEX doesn't end with 0xf7!\n");
+ // to be continued?
}
else
--len; // don't count 0xf7
@@ -566,7 +566,7 @@ void MidiFile::writeEvent(const MidiPlayEvent* event)
int c = event->channel();
int nstat = event->type();
- // we dont save meta data into smf type 0 files:
+ // we dont save meta data into smf type 0 files: DELETETHIS 4 ???
// Oct 16, 2011: Apparently it is legal to do that. Part of fix for bug tracker 3293339.
//if (MusEGlobal::config.smfFormat == 0 && nstat == ME_META)
// return;
@@ -620,6 +620,7 @@ bool MidiFile::write()
writeLong(6); // header len
writeShort(MusEGlobal::config.smfFormat);
if (MusEGlobal::config.smfFormat == 0) {
+ // DELETETHIS 30
/*
//writeShort(1); // Removed. Bug tracker 3293339
MidiFileTrack dst;
@@ -645,7 +646,7 @@ bool MidiFile::write()
*/
writeShort(1);
- //writeShort(_division);
+ //writeShort(_division); DELETETHIS 3
//if(!_tracks->empty())
// writeTrack(*(_tracks->begin()));
@@ -658,7 +659,7 @@ bool MidiFile::write()
writeShort(_division);
for (ciMidiFileTrack i = _tracks->begin(); i != _tracks->end(); ++i)
writeTrack(*i);
-/// }
+
return (ferror(fp) != 0);
}
diff --git a/muse2/muse/midiport.cpp b/muse2/muse/midiport.cpp
index b7d1d7b7..ef94c659 100644
--- a/muse2/muse/midiport.cpp
+++ b/muse2/muse/midiport.cpp
@@ -21,8 +21,6 @@
//
//=========================================================
-//#include "config.h"
-
#include <QMenu>
#include <QApplication>
@@ -31,7 +29,6 @@
#include "midictrl.h"
#include "midi.h"
#include "minstrument.h"
-//#include "instruments/minstrument.h" // p4.0.2
#include "xml.h"
#include "globals.h"
#include "mpevent.h"
@@ -41,10 +38,6 @@
#include "menutitleitem.h"
#include "icons.h"
-//#ifdef DSSI_SUPPORT
-//#include "dssihost.h"
-//#endif
-
namespace MusEGlobal {
MusECore::MidiPort midiPorts[MIDI_PORTS];
}
@@ -75,7 +68,6 @@ void initMidiPorts()
MidiPort::MidiPort()
: _state("not configured")
{
- //_defaultInChannels = 0;
_defaultInChannels = (1 << MIDI_CHANNELS) -1; // p4.0.17 Default is now to connect to all channels.
_defaultOutChannels = 0;
_device = 0;
@@ -181,15 +173,14 @@ void MidiPort::setMidiDevice(MidiDevice* dev)
// The 'reverb level' controller would still be at '100', and could adversely affect the song,
// but if the instrument has an available initial value of say '0', it will be used instead.
//
- //if(_instrument)
- // p3.3.39 NOT for syntis! Use midiState an/or initParams for that.
+
+ // NOT for syntis. Use midiState and/or initParams for that.
if(_instrument && !_device->isSynti())
{
MidiControllerList* cl = _instrument->controller();
MidiController* mc;
for(ciMidiController imc = cl->begin(); imc != cl->end(); ++imc)
{
- //mc = *imc;
mc = imc->second;
for(int chan = 0; chan < MIDI_CHANNELS; ++chan)
{
@@ -210,38 +201,12 @@ void MidiPort::setMidiDevice(MidiDevice* dev)
if(mc->initVal() != CTRL_VAL_UNKNOWN)
{
int ctl = mc->num();
-
-///#ifdef DSSI_SUPPORT
- // Exclude dssi synths from this, as some of them have hundreds of controls.
- // Another difference is dssi synth devices (usually) have readable default port values,
- // unlike a midi output port, which cannot be queried for a current or default value,
- // so we blindly send values here. Also some dssi have a different default mechanism or
- // storage systems for parameters, with complex GUIs with their own manipulation schemes.
- // Another difference is dssi controls are best manipulated as ladspa controls -
- // (they ARE ladspa controls). This is stuff I mainly put for midi ports and MESS...
- // I DO allow midi control of those ladspa controls, so our midi controls shall be updated here...
- // p3.3.39 Only non-syntis! Use midiState an/or initParams for that.
- ///if(!_device->isSynti() || (dynamic_cast<DssiSynthIF*>(((SynthI*)_device)->sif()) == 0))
- ///{
-///#endif
- // Note the addition of bias!
- //_device->putEvent(MidiPlayEvent(0, portno(), chan,
- // ME_CONTROLLER, ctl, mc->initVal() + mc->bias()));
- // Retry added. Use default attempts and delay. p4.0.15
- _device->putEventWithRetry(MidiPlayEvent(0, portno(), chan,
- ME_CONTROLLER, ctl, mc->initVal() + mc->bias()));
- //if(_device->putEventWithRetry(MidiPlayEvent(0, portno(), chan,
- // ME_CONTROLLER, ctl, mc->initVal() + mc->bias())))
- // return;
-
-///#ifdef DSSI_SUPPORT
- ///}
-///#endif
-
+ // Note the addition of bias!
+ // Retry added. Use default attempts and delay.
+ _device->putEventWithRetry(MidiPlayEvent(0, portno(), chan,
+ ME_CONTROLLER, ctl, mc->initVal() + mc->bias()));
// Set it once so the 'last HW value' is set, and control knobs are positioned at the value...
- //setHwCtrlState(chan, ctl, mc->initVal() + mc->bias());
// Set it again so that control labels show 'off'...
- //setHwCtrlState(chan, ctl, CTRL_VAL_UNKNOWN);
setHwCtrlStates(chan, ctl, CTRL_VAL_UNKNOWN, mc->initVal() + mc->bias());
}
}
@@ -250,42 +215,18 @@ void MidiPort::setMidiDevice(MidiDevice* dev)
}
// init HW controller state
- // p3.3.39 NOT for syntis! Use midiState an/or initParams for that.
- if(!_device->isSynti())
- {
- for (iMidiCtrlValList i = _controller->begin(); i != _controller->end(); ++i) {
- int channel = i->first >> 24;
- int cntrl = i->first & 0xffffff;
- int val = i->second->hwVal();
- if (val != CTRL_VAL_UNKNOWN) {
-
-
-///#ifdef DSSI_SUPPORT
- // Not for dssi synths...
- ///if(!_device->isSynti() || (dynamic_cast<DssiSynthIF*>(((SynthI*)_device)->sif()) == 0))
- ///{
-///#endif
- //_device->putEvent(MidiPlayEvent(0, portno(), channel,
- // ME_CONTROLLER, cntrl, val));
- // Retry added. Use default attempts and delay. p4.0.15
- _device->putEventWithRetry(MidiPlayEvent(0, portno(), channel,
- ME_CONTROLLER, cntrl, val));
- //if(_device->putEventWithRetry(MidiPlayEvent(0, portno(), channel,
- // ME_CONTROLLER, cntrl, val)))
- // return;
-
-///#ifdef DSSI_SUPPORT
- ///}
-///#endif
-
- // Set it once so the 'last HW value' is set, and control knobs are positioned at the value...
- setHwCtrlState(channel, cntrl, val);
- // Set it again so that control labels show 'off'...
- //setHwCtrlState(channel, cntrl, CTRL_VAL_UNKNOWN);
- //setHwCtrlStates(channel, cntrl, CTRL_VAL_UNKNOWN, val);
- }
+ for (iMidiCtrlValList i = _controller->begin(); i != _controller->end(); ++i) {
+ int channel = i->first >> 24;
+ int cntrl = i->first & 0xffffff;
+ int val = i->second->hwVal();
+ if (val != CTRL_VAL_UNKNOWN) {
+ // Retry added. Use default attempts and delay.
+ _device->putEventWithRetry(MidiPlayEvent(0, portno(), channel,
+ ME_CONTROLLER, cntrl, val));
+ // Set it once so the 'last HW value' is set, and control knobs are positioned at the value...
+ setHwCtrlState(channel, cntrl, val);
}
- }
+ }
}
else
@@ -331,9 +272,7 @@ QMenu* midiPortsPopup(QWidget* parent, int checkPort)
for( ; pi < MIDI_PORTS; ++pi)
{
MusECore::MidiDevice* md = MusEGlobal::midiPorts[pi].device();
- //if(md && !md->isSynti() && (md->rwFlags() & 1))
if(md && (md->rwFlags() & 1))
- //if(md && (md->rwFlags() & 1 || md->isSynti()) ) // Revert. Hm, why synths? Only writeable ports. p4.0.41
break;
}
if(pi == MIDI_PORTS)
@@ -353,7 +292,6 @@ QMenu* midiPortsPopup(QWidget* parent, int checkPort)
for (int i = 0; i < MIDI_PORTS; ++i) {
MidiPort* port = &MusEGlobal::midiPorts[i];
MusECore::MidiDevice* md = port->device();
- //if(md && !(md->rwFlags() & 1 || md->isSynti()) && (i != checkPort))
if(md && !(md->rwFlags() & 1) && (i != checkPort)) // Only writeable ports, or current one.
continue;
name.sprintf("%d:%s", port->portno()+1, port->portname().toLatin1().constData());
@@ -371,9 +309,7 @@ QMenu* midiPortsPopup(QWidget* parent, int checkPort)
{
subp = new QMenu(p);
subp->setTitle(qApp->translate("@default", QT_TRANSLATE_NOOP("@default", "Empty ports")));
- //subp->addAction(new MusEGui::MenuTitleItem("Empty Ports", subp));
}
- //act = subp->addAction(name); // No need for all those "<None>" names.
act = subp->addAction(QString().setNum(i+1));
act->setData(i);
act->setCheckable(true);
@@ -391,7 +327,6 @@ QMenu* midiPortsPopup(QWidget* parent, int checkPort)
const QString& MidiPort::portname() const
{
- //static const QString none("<none>");
static const QString none(QT_TRANSLATE_NOOP("@default", "<none>"));
if (_device)
return _device->name();
@@ -405,50 +340,18 @@ const QString& MidiPort::portname() const
void MidiPort::tryCtrlInitVal(int chan, int ctl, int val)
{
- // p4.0.27
- // Look for an initial value in the song for this midi controller, on this midi channel...
- //for(iMidiCtrlValList i = _controller->begin(); i != _controller->end(); ++i)
+ // Look for an initial value in the song for this midi controller, on this midi channel... (p4.0.27)
iMidiCtrlValList i = _controller->find(chan, ctl);
if(i != _controller->end())
{
- //int channel = i->first >> 24;
- //int cntrl = i->first & 0xffffff;
- //if(channel == chan && cntrl == ctl)
int v = i->second->value(0); // Value at tick 0.
if(v != CTRL_VAL_UNKNOWN)
{
if(_device)
- {
- ///#ifdef DSSI_SUPPORT
-
- // Not for dssi synths...
- ///if(!_device->isSynti() || (dynamic_cast<DssiSynthIF*>(((SynthI*)_device)->sif()) == 0))
- ///{
-
- ///#endif
-
- //_device->putEvent(MidiPlayEvent(0, portno(), channel,
- // ME_CONTROLLER, cntrl, v));
- // Retry added. Use default attempts and delay. p4.0.15
- _device->putEventWithRetry(MidiPlayEvent(0, portno(), chan,
- ME_CONTROLLER, ctl, v));
- //if(_device->putEventWithRetry(MidiPlayEvent(0, portno(), chan,
- // ME_CONTROLLER, ctl, v)))
- // return;
-
- ///#ifdef DSSI_SUPPORT
-
- ///}
-
- ///#endif
-
- }
+ _device->putEventWithRetry(MidiPlayEvent(0, portno(), chan, ME_CONTROLLER, ctl, v));
// Set it once so the 'last HW value' is set, and control knobs are positioned at the value...
setHwCtrlState(chan, ctl, v);
- // Set it again so that control labels show 'off'...
- //setHwCtrlState(chan, ctl, CTRL_VAL_UNKNOWN);
- //setHwCtrlStates(chan, ctl, CTRL_VAL_UNKNOWN, v);
return;
}
@@ -458,52 +361,35 @@ void MidiPort::tryCtrlInitVal(int chan, int ctl, int val)
if(_instrument)
{
MidiControllerList* cl = _instrument->controller();
- //for(ciMidiController imc = cl->begin(); imc != cl->end(); ++imc)
ciMidiController imc = cl->find(ctl);
if(imc != cl->end())
{
- //MidiController* mc = *imc;
MidiController* mc = imc->second;
- //int cnum = mc->num();
- //if(cnum == ctl)
- //{
- int initval = mc->initVal();
-
- // Initialize from either the instrument controller's initial value, or the supplied value.
- if(initval != CTRL_VAL_UNKNOWN)
+ int initval = mc->initVal();
+
+ // Initialize from either the instrument controller's initial value, or the supplied value.
+ if(initval != CTRL_VAL_UNKNOWN)
+ {
+ if(_device)
{
- if(_device)
- {
- //MidiPlayEvent ev(song->cpos(), portno(), chan, ME_CONTROLLER, ctl, initval + mc->bias());
- MidiPlayEvent ev(0, portno(), chan, ME_CONTROLLER, ctl, initval + mc->bias());
- _device->putEvent(ev);
- // Retry added. Use default attempts and delay. p4.0.15
- //_device->putEventWithRetry(ev);
- }
- // Set it once so the 'last HW value' is set, and control knobs are positioned at the value...
- //setHwCtrlState(chan, ctl, initval + mc->bias());
- // Set it again so that control labels show 'off'...
- //setHwCtrlState(chan, ctl, CTRL_VAL_UNKNOWN);
- setHwCtrlStates(chan, ctl, CTRL_VAL_UNKNOWN, initval + mc->bias());
-
- return;
- }
+ MidiPlayEvent ev(0, portno(), chan, ME_CONTROLLER, ctl, initval + mc->bias());
+ _device->putEvent(ev);
+ // Retry added. Use default attempts and delay. p4.0.15
+ //_device->putEventWithRetry(ev);
+ }
+ setHwCtrlStates(chan, ctl, CTRL_VAL_UNKNOWN, initval + mc->bias());
+
+ return;
+ }
}
}
// No initial value was found in the song or instrument for this midi controller. Just send the given value.
if(_device)
{
- //MidiPlayEvent ev(song->cpos(), portno(), chan, ME_CONTROLLER, ctl, val);
MidiPlayEvent ev(0, portno(), chan, ME_CONTROLLER, ctl, val);
_device->putEvent(ev);
- // Retry added. Use default attempts and delay. p4.0.15
- //_device->putEventWithRetry(ev);
}
- // Set it once so the 'last HW value' is set, and control knobs are positioned at the value...
- //setHwCtrlState(chan, ctl, val);
- // Set it again so that control labels show 'off'...
- //setHwCtrlState(chan, ctl, CTRL_VAL_UNKNOWN);
setHwCtrlStates(chan, ctl, CTRL_VAL_UNKNOWN, val);
}
@@ -514,14 +400,6 @@ void MidiPort::tryCtrlInitVal(int chan, int ctl, int val)
void MidiPort::sendGmInitValues()
{
for (int i = 0; i < MIDI_CHANNELS; ++i) {
- // Changed by T356.
- //setHwCtrlState(i, CTRL_PROGRAM, 0);
- //setHwCtrlState(i, CTRL_PITCH, 0);
- //setHwCtrlState(i, CTRL_VOLUME, 100);
- //setHwCtrlState(i, CTRL_PANPOT, 64);
- //setHwCtrlState(i, CTRL_REVERB_SEND, 40);
- //setHwCtrlState(i, CTRL_CHORUS_SEND, 0);
-
// By T356. Initialize from instrument controller if it has an initial value, otherwise use the specified value.
// Tested: Ultimately, a track's controller stored values take priority by sending any 'zero time' value
// AFTER these GM/GS/XG init routines are called via initDevices().
@@ -550,25 +428,6 @@ void MidiPort::sendGsInitValues()
void MidiPort::sendXgInitValues()
{
for (int i = 0; i < MIDI_CHANNELS; ++i) {
- // Changed by T356.
- //setHwCtrlState(i, CTRL_PROGRAM, 0);
- //setHwCtrlState(i, CTRL_MODULATION, 0);
- //setHwCtrlState(i, CTRL_PORTAMENTO_TIME, 0);
- //setHwCtrlState(i, CTRL_VOLUME, 0x64);
- //setHwCtrlState(i, CTRL_PANPOT, 0x40);
- //setHwCtrlState(i, CTRL_EXPRESSION, 0x7f);
- //setHwCtrlState(i, CTRL_SUSTAIN, 0x0);
- //setHwCtrlState(i, CTRL_PORTAMENTO, 0x0);
- //setHwCtrlState(i, CTRL_SOSTENUTO, 0x0);
- //setHwCtrlState(i, CTRL_SOFT_PEDAL, 0x0);
- //setHwCtrlState(i, CTRL_HARMONIC_CONTENT, 0x40);
- //setHwCtrlState(i, CTRL_RELEASE_TIME, 0x40);
- //setHwCtrlState(i, CTRL_ATTACK_TIME, 0x40);
- //setHwCtrlState(i, CTRL_BRIGHTNESS, 0x40);
- //setHwCtrlState(i, CTRL_REVERB_SEND, 0x28);
- //setHwCtrlState(i, CTRL_CHORUS_SEND, 0x0);
- //setHwCtrlState(i, CTRL_VARIATION_SEND, 0x0);
-
// By T356. Initialize from instrument controller if it has an initial value, otherwise use the specified value.
tryCtrlInitVal(i, CTRL_PROGRAM, 0);
tryCtrlInitVal(i, CTRL_MODULATION, 0);
@@ -609,10 +468,6 @@ void MidiPort::sendGmOn()
void MidiPort::sendGsOn()
{
- //static unsigned char data2[] = { 0x41, 0x10, 0x42, 0x12, 0x40, 0x01, 0x33, 0x50, 0x3c };
- //static unsigned char data3[] = { 0x41, 0x10, 0x42, 0x12, 0x40, 0x01, 0x34, 0x50, 0x3b };
- //sendSysex(data2, sizeof(data2));
- //sendSysex(data3, sizeof(data3));
sendSysex(gsOnMsg2, gsOnMsg2Len);
sendSysex(gsOnMsg3, gsOnMsg3Len);
}
@@ -822,57 +677,21 @@ int MidiPort::limitValToInstrCtlRange(int ctl, int val)
}
//---------------------------------------------------------
-// sendEvent
-// return true, if event cannot be delivered
+// sendHwCtrlState
+// Return true if it is OK to go ahead and deliver the event.
//---------------------------------------------------------
-bool MidiPort::sendEvent(const MidiPlayEvent& ev, bool forceSend)
+bool MidiPort::sendHwCtrlState(const MidiPlayEvent& ev, bool forceSend)
{
if (ev.type() == ME_CONTROLLER) {
-// printf("current sustain %d %d %d\n", hwCtrlState(ev.channel(),CTRL_SUSTAIN), CTRL_SUSTAIN, ev.dataA());
-
- // Added by T356.
int da = ev.dataA();
int db = ev.dataB();
- /*
- // Is it a drum controller?
- MidiController* mc = drumController(da);
- if(mc)
- {
- DrumMap* dm = &drumMap[da & 0x7f];
- int port = dm->port;
- MidiPort* mp = &MusEGlobal::midiPorts[port];
- // Is it NOT for this MidiPort?
- if(mp && (mp != this))
- {
- // Redirect the event to the mapped port and channel...
- da = (da & ~0xff) | (dm->anote & 0x7f);
- db = mp->limitValToInstrCtlRange(da, db);
- MidiPlayEvent nev(ev.time(), port, dm->channel, ME_CONTROLLER, da, db);
- if(!mp->setHwCtrlState(ev.channel(), da, db))
- return false;
- if(!mp->device())
- return true;
- return mp->device()->putEvent(nev);
- }
- }
- */
db = limitValToInstrCtlRange(da, db);
-
- // Removed by T356.
- //
- // optimize controller settings
- //
- //if (hwCtrlState(ev.channel(), ev.dataA()) == ev.dataB()) {
-// printf("optimize ctrl %d %x val %d\n", ev.dataA(), ev.dataA(), ev.dataB());
- // return false;
- // }
-// printf("set HW Ctrl State ch:%d 0x%x 0x%x\n", ev.channel(), ev.dataA(), ev.dataB());
if(!setHwCtrlState(ev.channel(), da, db)) {
if (MusEGlobal::debugMsg && forceSend)
- printf("sendEvent: State already set. Forcing anyway...\n");
+ printf("sendHwCtrlState: State already set. Forcing anyway...\n");
if (!forceSend)
return false;
}
@@ -881,10 +700,6 @@ bool MidiPort::sendEvent(const MidiPlayEvent& ev, bool forceSend)
if (ev.type() == ME_PITCHBEND)
{
int da = limitValToInstrCtlRange(CTRL_PITCH, ev.dataA());
- // Removed by T356.
- //if (hwCtrlState(ev.channel(), CTRL_PITCH) == ev.dataA())
- // return false;
-
if(!setHwCtrlState(ev.channel(), CTRL_PITCH, da)) {
if (!forceSend)
return false;
@@ -899,7 +714,19 @@ bool MidiPort::sendEvent(const MidiPlayEvent& ev, bool forceSend)
}
}
-
+ return true;
+ }
+
+//---------------------------------------------------------
+// sendEvent
+// return true, if event cannot be delivered
+//---------------------------------------------------------
+
+bool MidiPort::sendEvent(const MidiPlayEvent& ev, bool forceSend)
+ {
+ if(!sendHwCtrlState(ev, forceSend))
+ return false;
+
if (!_device) {
if (MusEGlobal::debugMsg)
printf("no device for this midi port\n");
@@ -931,11 +758,8 @@ int MidiPort::hwCtrlState(int ch, int ctrl) const
{
ch &= 0xff;
iMidiCtrlValList cl = _controller->find(ch, ctrl);
- if (cl == _controller->end()) {
- //if (MusEGlobal::debugMsg)
- // printf("hwCtrlState: chan %d ctrl 0x%x not found\n", ch, ctrl);
+ if (cl == _controller->end())
return CTRL_VAL_UNKNOWN;
- }
MidiCtrlValList* vl = cl->second;
return vl->hwVal();
}
@@ -947,22 +771,6 @@ int MidiPort::hwCtrlState(int ch, int ctrl) const
bool MidiPort::setHwCtrlState(int ch, int ctrl, int val)
{
- // Changed by T356.
- //iMidiCtrlValList cl = _controller->find(ch, ctrl);
- //if (cl == _controller->end()) {
- // try to add new controller
- // addManagedController(ch, ctrl);
-// muse->importController(ch, this, ctrl);
- // cl = _controller->find(ch, ctrl);
- // if (cl == _controller->end()) {
- // if (MusEGlobal::debugMsg)
- // printf("setHwCtrlState(%d,0x%x,0x%x): not found\n", ch, ctrl, val);
- // return;
- // }
- // }
- //MidiCtrlValList* vl = cl->second;
-// printf("setHwCtrlState ch %d ctrl %x val %x\n", ch, ctrl, val);
-
// By T356. This will create a new value list if necessary, otherwise it returns the existing list.
MidiCtrlValList* vl = addManagedController(ch, ctrl);
@@ -985,24 +793,6 @@ bool MidiPort::setHwCtrlStates(int ch, int ctrl, int val, int lastval)
return vl->setHwVals(val, lastval);
}
-// Removed by T356.
-//---------------------------------------------------------
-// setCtrl
-// return true if new controller value added
-//---------------------------------------------------------
-
-//bool MidiPort::setCtrl(int ch, int tick, int ctrl, int val)
-// {
-// if (MusEGlobal::debugMsg)
-// printf("setCtrl(tick=%d val=%d)\n",tick,val);
-// iMidiCtrlValList cl = _controller->find(ch, ctrl);
-// if (cl == _controller->end()) {
-// if (MusEGlobal::debugMsg)
-// printf("setCtrl: controller 0x%x for channel %d not found\n", ctrl, ch);
-// return false;
-// }
-// return cl->second->add(tick, val);
-// }
//---------------------------------------------------------
// setControllerVal
@@ -1033,24 +823,18 @@ bool MidiPort::setControllerVal(int ch, int tick, int ctrl, int val, Part* part)
int MidiPort::getCtrl(int ch, int tick, int ctrl) const
{
iMidiCtrlValList cl = _controller->find(ch, ctrl);
- if (cl == _controller->end()) {
- //if (MusEGlobal::debugMsg)
- // printf("getCtrl: controller %d(0x%x) for channel %d not found size %zd\n",
- // ctrl, ctrl, ch, _controller->size());
+ if (cl == _controller->end())
return CTRL_VAL_UNKNOWN;
- }
+
return cl->second->value(tick);
}
int MidiPort::getCtrl(int ch, int tick, int ctrl, Part* part) const
{
iMidiCtrlValList cl = _controller->find(ch, ctrl);
- if (cl == _controller->end()) {
- //if (MusEGlobal::debugMsg)
- // printf("getCtrl: controller %d(0x%x) for channel %d not found size %zd\n",
- // ctrl, ctrl, ch, _controller->size());
+ if (cl == _controller->end())
return CTRL_VAL_UNKNOWN;
- }
+
return cl->second->value(tick, part);
}
//---------------------------------------------------------
diff --git a/muse2/muse/midiport.h b/muse2/muse/midiport.h
index 8c12e2c6..0faccce2 100644
--- a/muse2/muse/midiport.h
+++ b/muse2/muse/midiport.h
@@ -75,7 +75,6 @@ class MidiPort {
int getCtrl(int ch, int tick, int ctrl) const;
int getCtrl(int ch, int tick, int ctrl, Part* part) const;
// Removed by T356.
- //bool setCtrl(int ch, int tick, int ctrl, int val);
bool setControllerVal(int ch, int tick, int ctrl, int val, Part* part);
// Can be CTRL_VAL_UNKNOWN until a valid state is set
int lastValidHWCtrlState(int ch, int ctrl) const;
@@ -138,6 +137,7 @@ class MidiPort {
void sendMMCStop(int devid = -1);
void sendMMCDeferredPlay(int devid = -1);
+ bool sendHwCtrlState(const MidiPlayEvent&, bool forceSend = false );
bool sendEvent(const MidiPlayEvent&, bool forceSend = false );
AutomationType automationType(int channel) { return _automationType[channel]; }
void setAutomationType(int channel, AutomationType t) {
@@ -153,7 +153,6 @@ extern void initMidiPorts();
extern void setPortExclusiveDefOutChan(int /*port*/, int /*chan*/);
#endif
-//extern QPopupMenu* midiPortsPopup(QWidget*);
extern QMenu* midiPortsPopup(QWidget* parent = 0, int checkPort = -1);
} // namespace MusECore
diff --git a/muse2/muse/midiseq.cpp b/muse2/muse/midiseq.cpp
index 1e46db11..94335d99 100644
--- a/muse2/muse/midiseq.cpp
+++ b/muse2/muse/midiseq.cpp
@@ -31,6 +31,7 @@
#include <poll.h>
#include <math.h>
+#include "app.h"
#include "globals.h"
#include "midi.h"
#include "midiseq.h"
@@ -44,7 +45,6 @@
#include "synth.h"
#include "song.h"
#include "gconfig.h"
-#include <lo/lo_osc_types.h>
namespace MusEGlobal {
MusECore::MidiSeq* midiSeq;
@@ -57,7 +57,6 @@ int MidiSeq::ticker = 0;
void initMidiSequencer()
{
- //MusEGlobal::midiSeq = new MidiSeq(MusEGlobal::realTimeScheduling ? MusEGlobal::realTimePriority : 0, "Midi");
MusEGlobal::midiSeq = new MidiSeq("Midi");
}
@@ -80,19 +79,18 @@ void MidiSeq::processMsg(const ThreadMsg* m)
{
MusECore::AudioMsg* msg = (MusECore::AudioMsg*)m;
switch(msg->id) {
- // This does not appear to be used anymore. Was sent in Audio::process1,
+ // This does not appear to be used anymore. Was sent in Audio::process1, DELETETHIS 5 ??
// now Audio::processMidi is called directly. p4.0.15 Tim.
//case MusECore::MS_PROCESS:
// audio->processMidi();
// break;
- // Removed p4.0.34
- //case MusECore::SEQM_SEEK:
- // processSeek();
- // break;
- //case MusECore::MS_STOP:
- // processStop();
- // break;
+ case MusECore::SEQM_SEEK:
+ processSeek();
+ break;
+ case MusECore::MS_STOP:
+ processStop();
+ break;
case MusECore::MS_SET_RTC:
MusEGlobal::doSetuid();
@@ -102,8 +100,9 @@ void MidiSeq::processMsg(const ThreadMsg* m)
case MusECore::MS_UPDATE_POLL_FD:
updatePollFd();
break;
- // Moved into Song::processMsg p4.0.34
- /*
+
+
+ // Moved into Song::processMsg p4.0.34 ...
case MusECore::SEQM_ADD_TRACK:
MusEGlobal::song->insertTrack2(msg->track, msg->ival);
updatePollFd();
@@ -112,10 +111,10 @@ void MidiSeq::processMsg(const ThreadMsg* m)
MusEGlobal::song->cmdRemoveTrack(msg->track);
updatePollFd();
break;
- case MusECore::SEQM_CHANGE_TRACK:
- MusEGlobal::song->changeTrack((Track*)(msg->p1), (Track*)(msg->p2));
- updatePollFd();
- break;
+ //case MusECore::SEQM_CHANGE_TRACK: DELETETHIS 4
+ // MusEGlobal::song->changeTrack((Track*)(msg->p1), (Track*)(msg->p2));
+ // updatePollFd();
+ // break;
case MusECore::SEQM_ADD_PART:
MusEGlobal::song->cmdAddPart((Part*)msg->p1);
break;
@@ -123,10 +122,10 @@ void MidiSeq::processMsg(const ThreadMsg* m)
MusEGlobal::song->cmdRemovePart((Part*)msg->p1);
break;
case MusECore::SEQM_CHANGE_PART:
- //MusEGlobal::song->cmdChangePart((Part*)msg->p1, (Part*)msg->p2);
MusEGlobal::song->cmdChangePart((Part*)msg->p1, (Part*)msg->p2, msg->a, msg->b);
break;
- */
+
+
case MusECore::SEQM_SET_TRACK_OUT_CHAN:
{
MidiTrack* track = (MidiTrack*)(msg->p1);
@@ -158,29 +157,26 @@ void MidiSeq::processMsg(const ThreadMsg* m)
}
}
-#if 0
-// Removed p4.0.34
+#if 1 // DELETETHIS the #if and #endif?
//---------------------------------------------------------
// processStop
//---------------------------------------------------------
void MidiSeq::processStop()
{
- // p3.3.28
- // TODO Try to move this into Audio::stopRolling(). p4.0.22 // Done p4.0.34
- //playStateExt = false; // not playing
+ // TODO Try to move this into Audio::stopRolling().
+ playStateExt = false; // not playing
//
// clear Alsa midi device notes and stop stuck notes
- // Jack midi devices are handled in Audio::stopRolling()
//
for(iMidiDevice id = MusEGlobal::midiDevices.begin(); id != MusEGlobal::midiDevices.end(); ++id)
{
- //MidiDevice* md = *id;
+ //MidiDevice* md = *id; DELETETHIS 3
// Only ALSA devices are handled by this thread.
- if((*id)->deviceType() == MidiDevice::ALSA_MIDI) // p4.0.22
- (*id)->handleStop(); // p4.0.22
- /*
+ //if((*id)->deviceType() == MidiDevice::ALSA_MIDI)
+ (*id)->handleStop();
+ /* DELETETHIS 14
if (md->midiPort() == -1)
continue;
MPEventList* pel = md->playEvents();
@@ -199,18 +195,17 @@ void MidiSeq::processStop()
}
#endif
-#if 0
-// Removed p4.0.34
+#if 1 //DELETETHIS #if and #endif
//---------------------------------------------------------
// processSeek
//---------------------------------------------------------
void MidiSeq::processSeek()
{
- //int pos = MusEGlobal::audio->tickPos();
- // TODO Try to move this into MusEGlobal::audio::seek(). p4.0.22 Done p4.0.34
- //if (pos == 0 && !MusEGlobal::song->record())
- // MusEGlobal::audio->initDevices();
+ int pos = MusEGlobal::audio->tickPos();
+ // TODO Try to move this into MusEGlobal::audio::seek().
+ if (pos == 0 && !MusEGlobal::song->record())
+ MusEGlobal::audio->initDevices();
//---------------------------------------------------
// set all controller
@@ -218,11 +213,11 @@ void MidiSeq::processSeek()
for (iMidiDevice i = MusEGlobal::midiDevices.begin(); i != MusEGlobal::midiDevices.end(); ++i)
{
- //MidiDevice* md = *i;
+ //MidiDevice* md = *i; DELETETHIS 3
// Only ALSA devices are handled by this thread.
- if((*i)->deviceType() == MidiDevice::ALSA_MIDI) // p4.0.22
- (*i)->handleSeek(); // p4.0.22
- /*
+ //if((*i)->deviceType() == MidiDevice::ALSA_MIDI)
+ (*i)->handleSeek();
+ /* DELETETHIS 47
int port = md->midiPort();
if (port == -1)
continue;
@@ -278,13 +273,9 @@ void MidiSeq::processSeek()
// MidiSeq
//---------------------------------------------------------
-//MidiSeq::MidiSeq(int priority, const char* name)
-// : Thread(priority, name)
MidiSeq::MidiSeq(const char* name)
: Thread(name)
{
- // Changed by Tim. p3.3.17
- //prio = priority;
prio = 0;
idle = false;
@@ -352,7 +343,7 @@ signed int MidiSeq::selectTimer()
void MidiSeq::threadStart(void*)
{
- // Removed by Tim. p3.3.17
+ // Removed by Tim. p3.3.17 DELETETHIS 13
/*
struct sched_param rt_param;
memset(&rt_param, 0, sizeof(rt_param));
@@ -397,6 +388,7 @@ static void midiRead(void*, void* d)
dev->processInput();
}
+// DELETETHIS 12
//---------------------------------------------------------
// synthIRead
//---------------------------------------------------------
@@ -446,24 +438,13 @@ void MidiSeq::updatePollFd()
for (iMidiDevice imd = MusEGlobal::midiDevices.begin(); imd != MusEGlobal::midiDevices.end(); ++imd) {
MidiDevice* dev = *imd;
int port = dev->midiPort();
- //const QString name = dev->name();
if (port == -1)
continue;
if ((dev->rwFlags() & 0x2) || (MusEGlobal::extSyncFlag.value()
- //&& (rxSyncPort == port || rxSyncPort == -1))) {
- //&& (dev->syncInfo().MCIn()))) {
- && (MusEGlobal::midiPorts[port].syncInfo().MCIn()))) {
- if(dev->selectRfd() < 0){
- //fprintf(stderr, "WARNING: read-file-descriptor for {%s} is negative\n", name.toLatin1());
- }
+ && (MusEGlobal::midiPorts[port].syncInfo().MCIn())))
addPollFd(dev->selectRfd(), POLLIN, MusECore::midiRead, this, dev);
- }
- if (dev->bytesToWrite()){
- if(dev->selectWfd() < 0){
- //fprintf(stderr, "WARNING: write-file-descriptor for {%s} is negative\n", name.toLatin1());
- }
+ if (dev->bytesToWrite())
addPollFd(dev->selectWfd(), POLLOUT, MusECore::midiWrite, this, dev);
- }
}
// special handling for alsa midi:
// (one fd for all devices)
@@ -480,23 +461,19 @@ void MidiSeq::updatePollFd()
void MidiSeq::threadStop()
{
timer->stopTimer();
- //timer.stopTimer();
}
//---------------------------------------------------------
// setRtcTicks
-// return true on success
+// returns actual tick frequency
//---------------------------------------------------------
-bool MidiSeq::setRtcTicks()
+int MidiSeq::setRtcTicks()
{
+ int gotTicks = timer->setTimerFreq(MusEGlobal::config.rtcTicks);
- //timer.setTimerFreq(MusEGlobal::config.rtcTicks);
- //timer.startTimer();
- timer->setTimerFreq(MusEGlobal::config.rtcTicks);
timer->startTimer();
- realRtcTicks = MusEGlobal::config.rtcTicks;
- return true;
+ return gotTicks;
}
//---------------------------------------------------------
@@ -504,24 +481,20 @@ bool MidiSeq::setRtcTicks()
// return true on error
//---------------------------------------------------------
-//bool MidiSeq::start()
void MidiSeq::start(int priority)
{
- // Changed by Tim. p3.3.17
-
prio = priority;
- //timerFd = -1;
-
MusEGlobal::doSetuid();
- //timerFd = selectTimer();
- //timerFd = timer.initTimer();
- //printf("timerFd=%d\n",timerFd);
- setRtcTicks();
+ int gotTicks = setRtcTicks();
MusEGlobal::undoSetuid();
- //Thread::start();
Thread::start(priority);
- //return false;
+
+ if (gotTicks < 500) {
+ QMessageBox::warning( MusEGlobal::muse, QString("Bad timing"), QString("Timing source has a frequency below 500hz!\n" \
+ "This could lead to audible timing problems.\n" \
+ "Please see console output for any further error messages\n "));
+ }
}
//---------------------------------------------------------
@@ -530,6 +503,7 @@ void MidiSeq::start(int priority)
void MidiSeq::processMidiClock()
{
+ // DELETETHIS 30, maybe remove entire function?
// if (genMCSync) {
// MusEGlobal::midiPorts[txSyncPort].sendClock();
// }
@@ -584,10 +558,6 @@ void MidiSeq::midiTick(void* p, void*)
void MidiSeq::processTimerTick()
{
- // Disabled by Tim. p3.3.22
-// extern int watchMidi;
-// ++watchMidi; // make a simple watchdog happy
-
//---------------------------------------------------
// read elapsed rtc timer ticks
//---------------------------------------------------
@@ -596,14 +566,12 @@ void MidiSeq::processTimerTick()
unsigned long nn;
if (timerFd != -1) {
nn = timer->getTimerTicks();
- //nn = timer.getTimerTicks();
nn >>= 8;
}
- if (idle) {
-// printf("IDLE\n");
+ if (idle)
return;
- }
+
if (MusEGlobal::midiBusy) {
// we hit MusEGlobal::audio: MusEGlobal::midiSeq->msgProcess (actually this has been MusEGlobal::audio->processMidi for some time now - Tim)
// miss this timer tick
@@ -612,70 +580,32 @@ void MidiSeq::processTimerTick()
unsigned curFrame = MusEGlobal::audio->curFrame();
- // Keep the sync detectors running...
- // No, done in Song::beat(), (at the much slower heartbeat rate).
- //
- //for(int port = 0; port < MIDI_PORTS; ++port)
- //{
- // Must keep them running even if there's no device...
- //if(MusEGlobal::midiPorts[port].device())
- // MusEGlobal::midiPorts[port].syncInfo().setCurFrame(curFrame);
- //}
- //for(iMidiDevice imd = MusEGlobal::midiDevices.begin(); imd != MusEGlobal::midiDevices.end(); ++imd)
- // (*imd)->syncInfo().setCurFrame(curFrame);
-
if (!MusEGlobal::extSyncFlag.value()) {
- //int curTick = MusEGlobal::tempomap.frame2tick(curFrame);
- // Copied from Tempomap.
- //int curTick = lrint((double(curFrame)/double(MusEGlobal::sampleRate)) * MusEGlobal::tempomap.globalTempo() * MusEGlobal::config.division * 10000.0 / double(MusEGlobal::tempomap.tempo(MusEGlobal::song->cpos())));
- //int curTick = lrint((double(curFrame)/double(MusEGlobal::sampleRate)) * MusEGlobal::tempomap.globalTempo() * 240000.0 / double(MusEGlobal::tempomap.tempo(MusEGlobal::song->cpos())));
int curTick = lrint((double(curFrame)/double(MusEGlobal::sampleRate)) * double(MusEGlobal::tempomap.globalTempo()) * double(MusEGlobal::config.division) * 10000.0 / double(MusEGlobal::tempomap.tempo(MusEGlobal::song->cpos())));
- //int curTick = int((double(curFrame)/double(MusEGlobal::sampleRate)) * double(MusEGlobal::tempomap.globalTempo()) * double(MusEGlobal::config.division * 10000.0) / double(MusEGlobal::tempomap.tempo(MusEGlobal::song->cpos())));
-
-/* if ( midiClock > curTick + 100) // reinitialize
- {
- midiClock = curTick;
- }
- else if( curTick > midiClock + 100) // reinitialize
- {
- midiClock = curTick;
- }*/
if(midiClock > curTick)
midiClock = curTick;
int div = MusEGlobal::config.division/24;
if(curTick >= midiClock + div) {
- //if(curTick >= midiClock) {
- //processMidiClock();
int perr = (curTick - midiClock) / div;
- //int perr = curTick - midiClock;
bool used = false;
- //if(genMCSync)
- //{
- //MusEGlobal::midiPorts[txSyncPort].sendClock();
for(int port = 0; port < MIDI_PORTS; ++port)
{
MidiPort* mp = &MusEGlobal::midiPorts[port];
- // No device? Clock out not turned on?
- //MidiDevice* dev = mp->device();
- //if(!dev || !mp->syncInfo().MCOut())
+ // No device? Clock out not turned on? DELETETHIS 3
if(!mp->device() || !mp->syncInfo().MCOut())
continue;
- // Shall we check open flags?
- //if(!(dev->rwFlags() & 0x1) || !(dev->openFlags() & 1))
- //if(!(dev->openFlags() & 1))
- // continue;
-
used = true;
mp->sendClock();
}
+ // DELETETHIS 35 ??
/*
for(iMidiDevice imd = MusEGlobal::midiDevices.begin(); imd != MusEGlobal::midiDevices.end(); ++imd)
{
@@ -710,7 +640,7 @@ void MidiSeq::processTimerTick()
if(MusEGlobal::debugMsg && used && perr > 1)
printf("Dropped %d midi out clock(s). curTick:%d midiClock:%d div:%d\n", perr, curTick, midiClock, div);
- //}
+ //} DELETETHIS and maybe the below ???
// Increment as if we had caught the timer exactly on the mark, even if the timer
// has passed beyond the mark, or even beyond 2 * div.
@@ -732,25 +662,16 @@ void MidiSeq::processTimerTick()
//
// Using equalization periods...
midiClock += (perr * div);
- //midiClock += perr;
+ //midiClock += perr; DELETETHIS
//
- // No equalization periods... TODO:
+ // No equalization periods... TODO: or DELETETHIS?
//midiClock += (perr * div);
}
}
-// if (genMTCSync) {
- // printf("Midi Time Code Sync generation not impl.\n");
-// }
-
- // p3.3.25
- //int tickpos = MusEGlobal::audio->tickPos();
- //bool extsync = MusEGlobal::extSyncFlag.value();
- //
// play all events upto curFrame
- //
for (iMidiDevice id = MusEGlobal::midiDevices.begin(); id != MusEGlobal::midiDevices.end(); ++id) {
- //MidiDevice* md = *id;
+ //MidiDevice* md = *id; DELETETHIS 10
// Is it a Jack midi device? They are iterated in Audio::processMidi. p3.3.36
//MidiJackDevice* mjd = dynamic_cast<MidiJackDevice*>(md);
//if(mjd)
@@ -762,7 +683,7 @@ void MidiSeq::processTimerTick()
if((*id)->deviceType() == MidiDevice::ALSA_MIDI)
(*id)->processMidi();
- // Moved into MidiAlsaDevice. p4.0.34
+ // Moved into MidiAlsaDevice. p4.0.34 DELETETHIS 40
/*
int port = md->midiPort();
MidiPort* mp = port != -1 ? &MusEGlobal::midiPorts[port] : 0;
@@ -838,10 +759,8 @@ void MidiSeq::msgSetMidiDevice(MidiPort* port, MidiDevice* device)
Thread::sendMsg(&msg);
}
-// This does not appear to be used anymore. Was called in Audio::process1, now Audio::processMidi is called directly. p4.0.15 Tim.
-//void MidiSeq::msgProcess() { msgMsg(MusECore::MS_PROCESS); }
-//void MidiSeq::msgSeek() { msgMsg(MusECore::SEQM_SEEK); } // Removed p4.0.34
-//void MidiSeq::msgStop() { msgMsg(MusECore::MS_STOP); } //
+void MidiSeq::msgSeek() { msgMsg(MusECore::SEQM_SEEK); }
+void MidiSeq::msgStop() { msgMsg(MusECore::MS_STOP); }
void MidiSeq::msgSetRtc() { msgMsg(MusECore::MS_SET_RTC); }
void MidiSeq::msgUpdatePollFd() { msgMsg(MusECore::MS_UPDATE_POLL_FD); }
diff --git a/muse2/muse/midiseq.h b/muse2/muse/midiseq.h
index 3c3813ef..bf7a3376 100644
--- a/muse2/muse/midiseq.h
+++ b/muse2/muse/midiseq.h
@@ -42,7 +42,6 @@ class SynthI;
//---------------------------------------------------------
class MidiSeq : public Thread {
- int realRtcTicks;
int timerFd;
int idle;
int prio; // realtime priority
@@ -52,9 +51,6 @@ class MidiSeq : public Thread {
/* Testing */
bool playStateExt; // used for keeping play state in sync functions
int recTick; // ext sync tick position
-// int lastTickPos; // position of last sync tick
- // run values:
-// unsigned _midiTick;
double mclock1, mclock2;
double songtick1, songtick2;
int recTick1, recTick2;
@@ -68,7 +64,7 @@ class MidiSeq : public Thread {
Timer *timer;
signed int selectTimer();
- bool setRtcTicks();
+ int setRtcTicks();
static void midiTick(void* p, void*);
void processTimerTick();
void processSeek();
@@ -78,16 +74,12 @@ class MidiSeq : public Thread {
void updatePollFd();
void mtcSyncMsg(const MTC&, int, bool);
- //void mtcInputFull(const unsigned char* p, int n);
- //void nonRealtimeSystemSysex(const unsigned char* p, int n);
public:
- //MidiSeq(int prio, const char* name);
MidiSeq(const char* name);
~MidiSeq();
- //bool start();
virtual void start(int);
virtual void threadStop();
@@ -98,16 +90,13 @@ class MidiSeq : public Thread {
void realtimeSystemInput(int, int);
void mtcInputQuarter(int, unsigned char);
void setSongPosition(int, int);
- // void eventReceived(MidiRecordEvent& event);
- //void mmcInput(const unsigned char* p, int n);
void mmcInput(int, const unsigned char*, int);
void mtcInputFull(int, const unsigned char*, int);
void nonRealtimeSystemSysex(int, const unsigned char*, int);
void msgMsg(int id);
- //void msgProcess();
- //void msgSeek();
- //void msgStop();
+ void msgSeek();
+ void msgStop();
void msgSetRtc();
void msgUpdatePollFd();
void msgAddSynthI(SynthI* synth);
diff --git a/muse2/muse/miditransform.cpp b/muse2/muse/miditransform.cpp
index ffc67f53..9f068882 100644
--- a/muse2/muse/miditransform.cpp
+++ b/muse2/muse/miditransform.cpp
@@ -37,7 +37,6 @@
#include "xml.h"
#include "globals.h"
#include "comboQuant.h"
-//#include "pitchedit.h"
#include "audio.h"
#include "gconfig.h"
#include "midictrl.h"
@@ -467,9 +466,6 @@ void MidiTransformerDialog::updatePresetList()
presetList->setCurrentItem(0);
}
- //data->cindex = 0;
- //presetList->setCurrentItem(0);
-
}
//---------------------------------------------------------
@@ -683,13 +679,11 @@ void MidiTransformerDialog::transformEvent(MusECore::Event& event, MusECore::Mid
// Indicate do clone parts.
addPortCtrlEvents(newEvent, part, true);
// Indicate do port controller values and clone parts.
- //MusEGlobal::song->addUndo(MusECore::UndoOp(MusECore::UndoOp::ModifyEvent, newEvent, event, part));
MusEGlobal::song->addUndo(MusECore::UndoOp(MusECore::UndoOp::ModifyEvent, newEvent, event, part, true, true));
MusEGlobal::song->addUpdateFlags(SC_EVENT_MODIFIED);
break;
case MusECore::Insert:
// Indicate do port controller values and clone parts.
- //MusEGlobal::song->addUndo(MusECore::UndoOp(MusECore::UndoOp::AddEvent, dummy, newEvent, part));
MusEGlobal::song->addUndo(MusECore::UndoOp(MusECore::UndoOp::AddEvent, dummy, newEvent, part, true, true));
MusEGlobal::song->addEvent(newEvent, part);
// Indicate do clone parts.
@@ -698,7 +692,6 @@ void MidiTransformerDialog::transformEvent(MusECore::Event& event, MusECore::Mid
break;
case MusECore::Extract:
// Indicate do port controller values and clone parts.
- //MusEGlobal::song->addUndo(MusECore::UndoOp(MusECore::UndoOp::DeleteEvent, dummy, event, part));
MusEGlobal::song->addUndo(MusECore::UndoOp(MusECore::UndoOp::DeleteEvent, dummy, event, part, true, true));
// Indicate do clone parts.
removePortCtrlEvents(event, part, true);
@@ -734,7 +727,6 @@ void MidiTransformerDialog::processEvent(MusECore::Event& event, MusECore::MidiP
// Indicate do clone parts.
addPortCtrlEvents(newEvent, part, true);
// Indicate do port controller values and clone parts.
- //MusEGlobal::song->addUndo(MusECore::UndoOp(MusECore::UndoOp::ModifyEvent, newEvent, event, part));
MusEGlobal::song->addUndo(MusECore::UndoOp(MusECore::UndoOp::ModifyEvent, newEvent, event, part, true, true));
MusEGlobal::song->addUpdateFlags(SC_EVENT_MODIFIED);
}
@@ -744,7 +736,6 @@ void MidiTransformerDialog::processEvent(MusECore::Event& event, MusECore::MidiP
{
MusECore::Event ev;
// Indicate do port controller values and clone parts.
- //MusEGlobal::song->addUndo(MusECore::UndoOp(MusECore::UndoOp::DeleteEvent, ev, event, part, true, true));
MusEGlobal::song->addUndo(MusECore::UndoOp(MusECore::UndoOp::DeleteEvent, ev, event, part, true, true));
// Indicate do clone parts.
removePortCtrlEvents(event, part, true);
diff --git a/muse2/muse/miditransform.h b/muse2/muse/miditransform.h
index 38b0211a..690bd868 100644
--- a/muse2/muse/miditransform.h
+++ b/muse2/muse/miditransform.h
@@ -68,7 +68,6 @@ class MidiTransformerDialog : public QDialog, public Ui::MidiTransformDialogBase
MusECore::MidiTransformPrivate* data;
virtual void accept();
-// virtual void reject();
void setValOp(QWidget* a, QWidget* b, MusECore::ValOp op);
void processEvent(MusECore::Event&, MusECore::MidiPart*, MusECore::MidiPart*);
bool isSelected(MusECore::Event&, MusECore::MidiPart*);
diff --git a/muse2/muse/mixer/astrip.cpp b/muse2/muse/mixer/astrip.cpp
index ccd47661..6b8043b9 100644
--- a/muse2/muse/mixer/astrip.cpp
+++ b/muse2/muse/mixer/astrip.cpp
@@ -781,6 +781,7 @@ AudioStrip::AudioStrip(QWidget* parent, MusECore::AudioTrack* at)
stereo = new QToolButton();
///stereo->setFont(MusEGlobal::config.fonts[1]);
+ stereo->setFocusPolicy(Qt::NoFocus);
stereo->setCheckable(true);
stereo->setToolTip(tr("1/2 channel"));
stereo->setChecked(channel == 2);
@@ -795,6 +796,7 @@ AudioStrip::AudioStrip(QWidget* parent, MusECore::AudioTrack* at)
pre = new QToolButton();
///pre->setFont(MusEGlobal::config.fonts[1]);
+ pre->setFocusPolicy(Qt::NoFocus);
pre->setCheckable(true);
pre->setText(tr("Pre"));
pre->setToolTip(tr("pre fader - post fader"));
@@ -895,6 +897,7 @@ AudioStrip::AudioStrip(QWidget* parent, MusECore::AudioTrack* at)
if (track->canRecord()) {
record = new MusEGui::TransparentToolButton(this);
+ record->setFocusPolicy(Qt::NoFocus);
record->setCheckable(true);
record->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
record->setBackgroundRole(QPalette::Mid);
@@ -908,6 +911,7 @@ AudioStrip::AudioStrip(QWidget* parent, MusECore::AudioTrack* at)
MusECore::Track::TrackType type = t->type();
mute = new QToolButton();
+ mute->setFocusPolicy(Qt::NoFocus);
mute->setCheckable(true);
mute->setToolTip(tr("mute"));
mute->setChecked(t->mute());
@@ -917,7 +921,7 @@ AudioStrip::AudioStrip(QWidget* parent, MusECore::AudioTrack* at)
connect(mute, SIGNAL(clicked(bool)), SLOT(muteToggled(bool)));
solo = new QToolButton();
-
+ solo->setFocusPolicy(Qt::NoFocus);
solo->setCheckable(true);
solo->setChecked(t->solo());
if(t->internalSolo())
@@ -938,6 +942,7 @@ AudioStrip::AudioStrip(QWidget* parent, MusECore::AudioTrack* at)
}
off = new MusEGui::TransparentToolButton(this);
+ off->setFocusPolicy(Qt::NoFocus);
off->setBackgroundRole(QPalette::Mid);
off->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
off->setCheckable(true);
@@ -960,6 +965,7 @@ AudioStrip::AudioStrip(QWidget* parent, MusECore::AudioTrack* at)
if (type != MusECore::Track::AUDIO_AUX) {
iR = new QToolButton();
+ iR->setFocusPolicy(Qt::NoFocus);
///iR->setFont(MusEGlobal::config.fonts[1]);
iR->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum));
///iR->setText(tr("iR"));
@@ -972,6 +978,7 @@ AudioStrip::AudioStrip(QWidget* parent, MusECore::AudioTrack* at)
}
oR = new QToolButton();
+ oR->setFocusPolicy(Qt::NoFocus);
///oR->setFont(MusEGlobal::config.fonts[1]);
oR->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum));
///oR->setText(tr("oR"));
@@ -987,6 +994,7 @@ AudioStrip::AudioStrip(QWidget* parent, MusECore::AudioTrack* at)
//---------------------------------------------------
autoType = new MusEGui::ComboBox();
+ autoType->setFocusPolicy(Qt::NoFocus);
///autoType->setFont(MusEGlobal::config.fonts[1]);
autoType->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
//autoType->setAutoFillBackground(true);
diff --git a/muse2/muse/mixer/mstrip.cpp b/muse2/muse/mixer/mstrip.cpp
index 80663c29..61bd9ba5 100644
--- a/muse2/muse/mixer/mstrip.cpp
+++ b/muse2/muse/mixer/mstrip.cpp
@@ -297,6 +297,7 @@ MidiStrip::MidiStrip(QWidget* parent, MusECore::MidiTrack* t)
//---------------------------------------------------
record = new MusEGui::TransparentToolButton(this);
+ record->setFocusPolicy(Qt::NoFocus);
record->setBackgroundRole(QPalette::Mid);
record->setCheckable(true);
record->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
@@ -307,6 +308,7 @@ MidiStrip::MidiStrip(QWidget* parent, MusECore::MidiTrack* t)
connect(record, SIGNAL(clicked(bool)), SLOT(recordToggled(bool)));
mute = new QToolButton();
+ mute->setFocusPolicy(Qt::NoFocus);
mute->setCheckable(true);
mute->setToolTip(tr("mute"));
mute->setChecked(track->mute());
@@ -316,7 +318,7 @@ MidiStrip::MidiStrip(QWidget* parent, MusECore::MidiTrack* t)
connect(mute, SIGNAL(clicked(bool)), SLOT(muteToggled(bool)));
solo = new QToolButton();
- //solo->setToolTip(tr("pre fader listening"));
+ solo->setFocusPolicy(Qt::NoFocus);
solo->setToolTip(tr("solo mode"));
solo->setCheckable(true);
solo->setChecked(track->solo());
@@ -328,43 +330,8 @@ MidiStrip::MidiStrip(QWidget* parent, MusECore::MidiTrack* t)
///solo->setIconSize(soloIconOn->size());
connect(solo, SIGNAL(clicked(bool)), SLOT(soloToggled(bool)));
- /*
- // Changed by Tim. p3.3.21
- //QToolTip::add(record, tr("record"));
- //smBox1->addStretch(100);
- //smBox1->addWidget(record);
- QLabel* dev_ch_label = new QLabel();
- ///dev_ch_label->setMinimumWidth(STRIP_WIDTH/2);
-
- // Special here: Must make label same size as the 'exit' button would be IF this were an audio strip...
- // (The 'exit1' icon is BIGGER than the 'record on' icon.)
- MusEGui::TransparentToolButton* off = new MusEGui::TransparentToolButton(this);
- QIcon iconOff;
- iconOff.addPixmap(*exit1Icon, QIcon::Normal, QIcon::On);
- iconOff.addPixmap(*exitIcon, QIcon::Normal, QIcon::Off);
- off->setIcon(iconOff);
- off->setIconSize(exit1Icon->size());
- dev_ch_label->setMinimumHeight(off->height());
- delete off;
-
- //dev_ch_label->setSizePolicy(QSizePolicy(QSizePolicy::Ignored, QSizePolicy::Minimum));
- ///dev_ch_label->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Minimum));
- dev_ch_label->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
- dev_ch_label->setAlignment(Qt::AlignCenter);
- int port = track->outPort();
- int channel = track->outChannel();
- QString dcs;
- dcs.sprintf("%d-%d", port + 1, channel + 1);
- dev_ch_label->setText(dcs);
- //dev_ch_label->setBackgroundColor(QColor(0, 160, 255)); // Med blue
- //dev_ch_label->setFont(MusEGlobal::config.fonts[6]);
- dev_ch_label->setFont(MusEGlobal::config.fonts[1]);
- // Dealing with a horizontally constrained label. Ignore vertical. Use a minimum readable point size.
- //autoAdjustFontSize(dev_ch_label, dev_ch_label->text(), false, true, MusEGlobal::config.fonts[6].pointSize(), 5);
- QToolTip::add(dev_ch_label, tr("output port and channel"));
- */
-
off = new MusEGui::TransparentToolButton(this);
+ off->setFocusPolicy(Qt::NoFocus);
off->setBackgroundRole(QPalette::Mid);
off->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
off->setCheckable(true);
@@ -384,6 +351,7 @@ MidiStrip::MidiStrip(QWidget* parent, MusECore::MidiTrack* t)
//---------------------------------------------------
iR = new QToolButton();
+ iR->setFocusPolicy(Qt::NoFocus);
///iR->setFont(MusEGlobal::config.fonts[1]);
iR->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum));
///iR->setText(tr("iR"));
@@ -393,7 +361,9 @@ MidiStrip::MidiStrip(QWidget* parent, MusECore::MidiTrack* t)
iR->setToolTip(tr("input routing"));
grid->addWidget(iR, _curGridRow, 0);
connect(iR, SIGNAL(pressed()), SLOT(iRoutePressed()));
+
oR = new QToolButton();
+ oR->setFocusPolicy(Qt::NoFocus);
///oR->setFont(MusEGlobal::config.fonts[1]);
oR->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Maximum));
///oR->setText(tr("oR"));
@@ -412,6 +382,7 @@ MidiStrip::MidiStrip(QWidget* parent, MusECore::MidiTrack* t)
//---------------------------------------------------
autoType = new MusEGui::ComboBox();
+ autoType->setFocusPolicy(Qt::NoFocus);
///autoType->setFont(MusEGlobal::config.fonts[1]);
autoType->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Minimum));
autoType->setEnabled(false);
diff --git a/muse2/muse/mixer/rack.cpp b/muse2/muse/mixer/rack.cpp
index 0ba03beb..3df46dd5 100644
--- a/muse2/muse/mixer/rack.cpp
+++ b/muse2/muse/mixer/rack.cpp
@@ -182,6 +182,7 @@ EffectRack::EffectRack(QWidget* parent, MusECore::AudioTrack* t)
setSpacing(0);
setAcceptDrops(true);
+ setFocusPolicy(Qt::NoFocus);
}
void EffectRack::updateContents()
@@ -683,6 +684,8 @@ void EffectRack::initPlugin(MusECore::Xml xml, int idx)
//printf("instantiated!\n");
MusEGlobal::audio->msgAddPlugin(track, idx, plugi);
MusEGlobal::song->update(SC_RACK);
+ if (plugi->guiVisible())
+ plugi->gui()->setWindowTitle(plugi->titlePrefix() + plugi->name());
return;
}
}
diff --git a/muse2/muse/mpevent.cpp b/muse2/muse/mpevent.cpp
index 8b65bce1..d3709b1f 100644
--- a/muse2/muse/mpevent.cpp
+++ b/muse2/muse/mpevent.cpp
@@ -116,7 +116,8 @@ bool MEvent::operator<(const MEvent& e) const
if (channel() == e.channel())
return type() == ME_NOTEOFF
- || (type() == ME_NOTEON && dataB() == 0);
+ || (type() == ME_NOTEON && dataB() == 0)
+ || type() != ME_NOTEON; // Make note-ons last so that controllers such as program come before notes played. 1/31/2012 Tim.
int map[16] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 0, 10, 11, 12, 13, 14, 15 };
return map[channel()] < map[e.channel()];
@@ -147,7 +148,6 @@ MidiPlayEvent MidiFifo::get()
{
MidiPlayEvent event(fifo[rIndex]);
rIndex = (rIndex + 1) % MIDI_FIFO_SIZE;
- // q_atomic_decrement(&size);
--size;
return event;
}
@@ -169,7 +169,6 @@ const MidiPlayEvent& MidiFifo::peek(int n)
void MidiFifo::remove()
{
rIndex = (rIndex + 1) % MIDI_FIFO_SIZE;
- // q_atomic_decrement(&size);
--size;
}
@@ -184,7 +183,6 @@ bool MidiRecFifo::put(const MidiPlayEvent& event)
if (size < MIDI_REC_FIFO_SIZE) {
fifo[wIndex] = event;
wIndex = (wIndex + 1) % MIDI_REC_FIFO_SIZE;
- // q_atomic_increment(&size);
++size;
return false;
}
@@ -199,7 +197,6 @@ MidiPlayEvent MidiRecFifo::get()
{
MidiPlayEvent event(fifo[rIndex]);
rIndex = (rIndex + 1) % MIDI_REC_FIFO_SIZE;
- // q_atomic_decrement(&size);
--size;
return event;
}
@@ -221,7 +218,6 @@ const MidiPlayEvent& MidiRecFifo::peek(int n)
void MidiRecFifo::remove()
{
rIndex = (rIndex + 1) % MIDI_REC_FIFO_SIZE;
- // q_atomic_decrement(&size);
--size;
}
diff --git a/muse2/muse/mpevent.h b/muse2/muse/mpevent.h
index fde7c588..9b64f9cd 100644
--- a/muse2/muse/mpevent.h
+++ b/muse2/muse/mpevent.h
@@ -30,13 +30,10 @@
#include "memory.h"
// Play events ring buffer size
-//#define MIDI_FIFO_SIZE 512
-// Increased. FE/6/11 p4.0.15 Tim.
-#define MIDI_FIFO_SIZE 2100
+#define MIDI_FIFO_SIZE 4096
// Record events ring buffer size
-//#define MIDI_REC_FIFO_SIZE 512
-#define MIDI_REC_FIFO_SIZE 160
+#define MIDI_REC_FIFO_SIZE 256
namespace MusECore {
@@ -155,13 +152,12 @@ typedef std::multiset<MidiPlayEvent, std::less<MidiPlayEvent>, audioRTalloc<Midi
struct MPEventList : public MPEL {
void add(const MidiPlayEvent& ev) { MPEL::insert(ev); }
- //iterator add(const MidiPlayEvent& ev) { return MPEL::insert(ev); } // p4.0.15 We need the iterator.
};
typedef MPEventList::iterator iMPEvent;
typedef MPEventList::const_iterator ciMPEvent;
-/*
+/* DELETETHIS 20 ??
//---------------------------------------------------------
// MREventList
// memory allocation in midi thread domain
@@ -193,7 +189,7 @@ class MidiFifo {
public:
MidiFifo() { clear(); }
- bool put(const MidiPlayEvent& /*event*/); // returns true on fifo overflow
+ bool put(const MidiPlayEvent& event); // returns true on fifo overflow
MidiPlayEvent get();
const MidiPlayEvent& peek(int = 0);
void remove();
@@ -215,7 +211,7 @@ class MidiRecFifo {
public:
MidiRecFifo() { clear(); }
- bool put(const MidiPlayEvent& /*event*/); // returns true on fifo overflow
+ bool put(const MidiPlayEvent& event); // returns true on fifo overflow
MidiPlayEvent get();
const MidiPlayEvent& peek(int = 0);
void remove();
diff --git a/muse2/muse/node.cpp b/muse2/muse/node.cpp
index 20440b45..be72367f 100644
--- a/muse2/muse/node.cpp
+++ b/muse2/muse/node.cpp
@@ -392,7 +392,6 @@ void AudioTrack::copyData(unsigned pos, int dstChannels, int srcStartChan, int s
// and it has no in or out routes, yet multiple output tracks may call addData on it !
// We can't tell how many output tracks call it, so we can only assume there might be more than one.
// Not strictly necessary here because only addData is ever called, but just to be consistent...
- //bool usedirectbuf = ((outRoutes()->size() <= 1) || (type() == AUDIO_OUTPUT)) && (this != metronome);
int i;
@@ -468,23 +467,8 @@ void AudioTrack::copyData(unsigned pos, int dstChannels, int srcStartChan, int s
_efxPipe->apply(0, nframes, 0); // Just process controls only, not audio (do not 'run').
for(i = 0; i < trackChans; ++i)
- {
_meter[i] = 0.0;
- /*if(!usedirectbuf)
- {
- if(MusEGlobal::config.useDenormalBias)
- {
- for(q = 0; q < nframes; ++q)
- outBuffers[i][q] = MusEGlobal::denormalBias;
- }
- else
- memset(outBuffers[i], 0, sizeof(float) * nframes);
- } */
- }
- //_haveData = false;
- //_processed = true;
- //_isProcessing = false; // Unblock.
return;
}
@@ -520,7 +504,6 @@ void AudioTrack::copyData(unsigned pos, int dstChannels, int srcStartChan, int s
// apply plugin chain
//---------------------------------------------------
- //fprintf(stderr, "AudioTrack::copyData %s efx apply srcChans:%d\n", name().toLatin1().constData(), srcChans);
_efxPipe->apply(trackChans, nframes, buffer);
//---------------------------------------------------
@@ -598,22 +581,6 @@ void AudioTrack::copyData(unsigned pos, int dstChannels, int srcStartChan, int s
memset(dstBuffer[i], 0, sizeof(float) * nframes);
}
- /*
- if(!usedirectbuf)
- {
- for(i = 0; i < srcChannels; ++i)
- {
- if(MusEGlobal::config.useDenormalBias)
- {
- for(q = 0; q < nframes; ++q)
- outBuffers[i][q] = MusEGlobal::denormalBias;
- }
- else
- memset(outBuffers[i], 0, sizeof(float) * nframes);
- }
- } */
-
-
if(!_prefader)
for(i = 0; i < trackChans; ++i) // Must process ALL channels, even if unconnected. Only max 2 channels.
_meter[i] = 0.0;
@@ -622,11 +589,8 @@ void AudioTrack::copyData(unsigned pos, int dstChannels, int srcStartChan, int s
}
// If we're using local cached 'pre-volume' buffers, copy the input buffers (as they are right now: post-effect pre-volume) back to them.
- //if(!usedirectbuf)
- {
- for(i = 0; i < srcTotalOutChans; ++i)
- AL::dsp->cpy(outBuffers[i], buffer[i], nframes);
- }
+ for(i = 0; i < srcTotalOutChans; ++i)
+ AL::dsp->cpy(outBuffers[i], buffer[i], nframes);
// We have some data! Set to true.
_haveData = true;
@@ -688,7 +652,6 @@ void AudioTrack::copyData(unsigned pos, int dstChannels, int srcStartChan, int s
{
double v;
if(srcStartChan > 2 || _prefader) // Don't apply pan or volume to extra channels above 2. Or if prefader on.
- //v = _volume;
v = 1.0;
else
if(srcChans >= 2) // If 2 channels apply pan normally.
@@ -702,7 +665,6 @@ void AudioTrack::copyData(unsigned pos, int dstChannels, int srcStartChan, int s
float* sp = buffer[c + srcStartChan];
float* dp = dstBuffer[c];
for(unsigned k = 0; k < nframes; ++k)
- //*dp++ = (*sp++ * vol[c]);
*dp++ = (*sp++ * v);
}
}
@@ -712,7 +674,6 @@ void AudioTrack::copyData(unsigned pos, int dstChannels, int srcStartChan, int s
{
double v;
if(srcStartChan > 2 || _prefader) // Don't apply pan or volume to extra channels above 2. Or if prefader on.
- //v = _volume;
v = 1.0;
else
if(trackChans <= 1) // If track is mono apply pan.
@@ -723,21 +684,17 @@ void AudioTrack::copyData(unsigned pos, int dstChannels, int srcStartChan, int s
float* sp = buffer[srcStartChan];
float* dp = dstBuffer[c];
for(unsigned k = 0; k < nframes; ++k)
- //*dp++ = (*sp++ * vol[c]);
*dp++ = (*sp++ * v);
}
}
else if(srcChans == 2 && dstChannels == 1)
{
- //double v1 = (srcStartChan > 2 ? _volume : vol[srcStartChan]); //
- //double v2 = (srcStartChan > 2 ? _volume : vol[srcStartChan + 1]); //
double v1 = ((srcStartChan > 2 || _prefader) ? 1.0 : vol[srcStartChan]); // Don't apply pan or volume to extra channels above 2. Or if prefader on.
double v2 = ((srcStartChan > 2 || _prefader) ? 1.0 : vol[srcStartChan + 1]); //
float* dp = dstBuffer[0];
float* sp1 = buffer[srcStartChan];
float* sp2 = buffer[srcStartChan + 1];
for(unsigned k = 0; k < nframes; ++k)
- //*dp++ = (*sp1++ * vol[0] + *sp2++ * vol[1]);
*dp++ = (*sp1++ * v1 + *sp2++ * v2);
}
}
@@ -758,12 +715,6 @@ void AudioTrack::addData(unsigned pos, int dstChannels, int srcStartChan, int sr
printf("MusE: AudioTrack::addData name:%s processed:%d\n", name().toLatin1().constData(), processed());
#endif
- //if (off())
- //{
- // _processed = true;
- // return;
- //}
-
if(srcStartChan == -1)
srcStartChan = 0;
@@ -773,10 +724,9 @@ void AudioTrack::addData(unsigned pos, int dstChannels, int srcStartChan, int sr
if(channels() == 1)
srcTotalOutChans = 1;
- // Special consideration for metronome: It is not part of the track list,
+ // Special consideration for metronome: It is not part of the track list, DELETETHIS??
// and it has no in or out routes, yet multiple output tracks may call addData on it !
// We can't tell how many output tracks call it, so we can only assume there might be more than one.
- //bool usedirectbuf = ((outRoutes()->size() <= 1) || (type() == AUDIO_OUTPUT)) && (this != metronome);
int i;
@@ -789,7 +739,6 @@ void AudioTrack::addData(unsigned pos, int dstChannels, int srcStartChan, int sr
double _pan = pan();
vol[0] = _volume * (1.0 - _pan);
vol[1] = _volume * (1.0 + _pan);
- //float meter[srcChans];
float meter[trackChans];
// Have we been here already during this process cycle?
@@ -832,19 +781,7 @@ void AudioTrack::addData(unsigned pos, int dstChannels, int srcStartChan, int sr
_efxPipe->apply(0, nframes, 0); // Track is off. Just process controls only, not audio (do not 'run').
for(i = 0; i < trackChans; ++i)
- {
_meter[i] = 0.0;
- /*if(!usedirectbuf)
- {
- if(MusEGlobal::config.useDenormalBias)
- {
- for(q = 0; q < nframes; ++q)
- outBuffers[i][q] = MusEGlobal::denormalBias;
- }
- else
- memset(outBuffers[i], 0, sizeof(float) * nframes);
- } */
- }
return;
}
@@ -873,15 +810,9 @@ void AudioTrack::addData(unsigned pos, int dstChannels, int srcStartChan, int sr
//---------------------------------------------------
// apply plugin chain
//---------------------------------------------------
-
- //fprintf(stderr, "AudioTrack::addData %s efx apply srcChans:%d nframes:%ld %e %e %e %e\n",
- // name().toLatin1().constData(), srcChans, nframes, buffer[0][0], buffer[0][1], buffer[0][2], buffer[0][3]);
_efxPipe->apply(trackChans, nframes, buffer);
- //fprintf(stderr, "AudioTrack::addData after efx: %e %e %e %e\n",
- // buffer[0][0], buffer[0][1], buffer[0][2], buffer[0][3]);
-
//---------------------------------------------------
// aux sends
//---------------------------------------------------
@@ -945,23 +876,7 @@ void AudioTrack::addData(unsigned pos, int dstChannels, int srcStartChan, int sr
if(isMute())
{
- // If we're using local buffers, we must zero them.
- /* if(!usedirectbuf)
- {
- for(i = 0; i < srcChannels; ++i)
- {
- if(MusEGlobal::config.useDenormalBias)
- {
- for(unsigned int q = 0; q < nframes; ++q)
- outBuffers[i][q] = MusEGlobal::denormalBias;
- }
- else
- memset(outBuffers[i], 0, sizeof(float) * nframes);
- }
- } */
-
if(!_prefader)
- //for(i = 0; i < srcChans; ++i)
for(i = 0; i < trackChans; ++i)
_meter[i] = 0.0;
@@ -969,11 +884,8 @@ void AudioTrack::addData(unsigned pos, int dstChannels, int srcStartChan, int sr
}
// If we're using local cached 'pre-volume' buffers, copy the input buffers (as they are right now: post-effect pre-volume) back to them.
- //if(!usedirectbuf)
- {
- for(i = 0; i < srcTotalOutChans; ++i)
- AL::dsp->cpy(outBuffers[i], buffer[i], nframes);
- }
+ for(i = 0; i < srcTotalOutChans; ++i)
+ AL::dsp->cpy(outBuffers[i], buffer[i], nframes);
// We have some data! Set to true.
_haveData = true;
@@ -1035,7 +947,6 @@ void AudioTrack::addData(unsigned pos, int dstChannels, int srcStartChan, int sr
{
double v;
if(srcStartChan > 2 || _prefader) // Don't apply pan or volume to extra channels above 2. Or if prefader on.
- //v = _volume;
v = 1.0;
else
if(srcChans >= 2) // If 2 channels apply pan normally.
@@ -1049,7 +960,6 @@ void AudioTrack::addData(unsigned pos, int dstChannels, int srcStartChan, int sr
float* sp = buffer[c + srcStartChan];
float* dp = dstBuffer[c];
for(unsigned k = 0; k < nframes; ++k)
- //*dp++ += (*sp++ * vol[c]);
*dp++ += (*sp++ * v);
}
}
@@ -1059,7 +969,6 @@ void AudioTrack::addData(unsigned pos, int dstChannels, int srcStartChan, int sr
{
double v;
if(srcStartChan > 2 || _prefader) // Don't apply pan or volume to extra channels above 2. Or if prefader on.
- //v = _volume;
v = 1.0;
else
if(trackChans <= 1) // If track is mono apply pan.
@@ -1070,21 +979,17 @@ void AudioTrack::addData(unsigned pos, int dstChannels, int srcStartChan, int sr
float* sp = buffer[srcStartChan];
float* dp = dstBuffer[c];
for(unsigned k = 0; k < nframes; ++k)
- //*dp++ += (*sp++ * vol[c]);
*dp++ += (*sp++ * v);
}
}
else if(srcChans == 2 && dstChannels == 1)
{
- //double v1 = (srcStartChan > 2 ? _volume : vol[srcStartChan]); // Don't apply pan to extra channels above 2.
- //double v2 = (srcStartChan > 2 ? _volume : vol[srcStartChan + 1]); //
double v1 = ((srcStartChan > 2 || _prefader) ? 1.0 : vol[srcStartChan]); // Don't apply pan or volume to extra channels above 2. Or if prefader on.
double v2 = ((srcStartChan > 2 || _prefader) ? 1.0 : vol[srcStartChan + 1]); //
float* sp1 = buffer[srcStartChan];
float* sp2 = buffer[srcStartChan + 1];
float* dp = dstBuffer[0];
for(unsigned k = 0; k < nframes; ++k)
- //*dp++ += (*sp1++ * vol[0] + *sp2++ * vol[1]);
*dp++ += (*sp1++ * v1 + *sp2++ * v2);
}
}
@@ -1095,7 +1000,6 @@ void AudioTrack::addData(unsigned pos, int dstChannels, int srcStartChan, int sr
void AudioTrack::readVolume(Xml& xml)
{
- //int ch = 0;
for (;;) {
Xml::Token token = xml.parse();
switch (token) {
@@ -1122,6 +1026,7 @@ void AudioTrack::readVolume(Xml& xml)
}
}
+// DELETETHIS 56
// Removed by T356
// "recfile" tag not saved anymore
/*
@@ -1189,9 +1094,7 @@ void Track::setChannels(int n)
else
_channels = n;
for (int i = 0; i < _channels; ++i) {
- //_meter[i] = 0;
_meter[i] = 0.0;
- //_peak[i] = 0;
_peak[i] = 0.0;
}
}
@@ -1201,7 +1104,6 @@ void AudioInput::setChannels(int n)
{
if (n == _channels)
return;
-//was ist mit: void* jackPorts[MAX_CHANNELS];
AudioTrack::setChannels(n);
}
@@ -1250,12 +1152,10 @@ bool AudioTrack::getData(unsigned pos, int channels, unsigned nframes, float** b
#endif
((AudioTrack*)ir->track)->copyData(pos, channels,
- //(ir->track->type() == Track::AUDIO_SOFTSYNTH && ir->channel != -1) ? ir->channel : 0,
ir->channel,
ir->channels,
nframes, buffer);
- //fprintf(stderr, "AudioTrack::getData %s data: nframes:%ld %e %e %e %e\n", name().toLatin1().constData(), nframes, buffer[0][0], buffer[0][1], buffer[0][2], buffer[0][3]);
++ir;
for (; ir != rl->end(); ++ir) {
@@ -1286,7 +1186,6 @@ bool AudioInput::getData(unsigned, int channels, unsigned nframes, float** buffe
for (int ch = 0; ch < channels; ++ch)
{
void* jackPort = jackPorts[ch];
- //float* jackbuf = 0;
// Do not get buffers of unconnected client ports. Causes repeating leftover data, can be loud, or DC !
if (jackPort && MusEGlobal::audioDevice->connections(jackPort))
@@ -1302,15 +1201,12 @@ bool AudioInput::getData(unsigned, int channels, unsigned nframes, float** buffe
// their channel port buffers (if that's even possible) in order to determine if the buffer is shared,
// let's just copy always, for now shall we ?
float* jackbuf = MusEGlobal::audioDevice->getBuffer(jackPort, nframes);
- //memcpy(buffer[ch], jackbuf, nframes* sizeof(float));
AL::dsp->cpy(buffer[ch], jackbuf, nframes);
if (MusEGlobal::config.useDenormalBias)
{
for (unsigned int i=0; i < nframes; i++)
buffer[ch][i] += MusEGlobal::denormalBias;
- //fprintf(stderr, "AudioInput::getData %s Jack port %p efx apply channels:%d nframes:%ld %e %e %e %e\n",
- // name().toLatin1().constData(), jackPort, channels, nframes, buffer[0][0], buffer[0][1], buffer[0][2], buffer[0][3]);
}
}
else
@@ -1324,8 +1220,6 @@ bool AudioInput::getData(unsigned, int channels, unsigned nframes, float** buffe
{
memset(buffer[ch], 0, nframes * sizeof(float));
}
-
- // name().toLatin1().constData(), channels, nframes, buffer[0][0], buffer[0][1], buffer[0][2], buffer[0][3]);
}
}
return true;
@@ -1345,7 +1239,6 @@ void AudioInput::setName(const QString& s)
if (jackPorts[i])
MusEGlobal::audioDevice->setPortName(jackPorts[i], buffer);
else {
- //jackPorts[i] = MusEGlobal::audioDevice->registerInPort(buffer);
jackPorts[i] = MusEGlobal::audioDevice->registerInPort(buffer, false);
}
}
@@ -1359,7 +1252,6 @@ void AudioInput::setName(const QString& s)
void Track::resetMeter()
{
for (int i = 0; i < _channels; ++i)
- //_meter[i] = 0;
_meter[i] = 0.0;
}
@@ -1370,7 +1262,6 @@ void Track::resetMeter()
void Track::resetPeaks()
{
for (int i = 0; i < _channels; ++i)
- //_peak[i] = 0;
_peak[i] = 0.0;
_lastActivity = 0;
}
@@ -1454,8 +1345,6 @@ void AudioTrack::record()
unsigned pos = 0;
float* buffer[_channels];
- //printf("AudioTrack: record() fifo %p, count=%d\n", &fifo, fifo.getCount());
-
while(fifo.getCount()) {
if (fifo.get(_channels, MusEGlobal::segmentSize, buffer, &pos)) {
@@ -1509,8 +1398,6 @@ void AudioTrack::record()
if( (pos >= fr) && (!MusEGlobal::song->punchout() || (!MusEGlobal::song->loop() && pos < MusEGlobal::song->rPos().frame())) )
{
pos -= fr;
- //int position = _recFile->seek(0, SEEK_CUR);
- //printf("AudioTrack::record loopcnt:%d lframe:%d newpos:%d curpos:%d start:%d end:%d\n", MusEGlobal::audio->loopCount(), MusEGlobal::audio->loopFrame(), pos, position, MusEGlobal::audio->getStartRecordPos().frame(), MusEGlobal::audio->getEndRecordPos().frame());
_recFile->seek(pos, 0);
_recFile->write(_channels, buffer, MusEGlobal::segmentSize);
@@ -1600,8 +1487,6 @@ void AudioOutput::processWrite()
putFifo(_channels, _nframes, buffer);
}
}
- // Changed by Tim.
- //if (MusEGlobal::audioClickFlag && MusEGlobal::song->click()) {
if (sendMetronome() && MusEGlobal::audioClickFlag && MusEGlobal::song->click()) {
#ifdef METRONOME_DEBUG
@@ -1621,13 +1506,10 @@ void AudioOutput::setName(const QString& s)
for (int i = 0; i < channels(); ++i) {
char buffer[128];
snprintf(buffer, 128, "%s-%d", _name.toLatin1().constData(), i);
- if (jackPorts[i]) {
+ if (jackPorts[i])
MusEGlobal::audioDevice->setPortName(jackPorts[i], buffer);
- }
- else {
- //jackPorts[i] = MusEGlobal::audioDevice->registerOutPort(buffer);
+ else
jackPorts[i] = MusEGlobal::audioDevice->registerOutPort(buffer, false);
- }
}
}
@@ -1639,7 +1521,6 @@ void AudioOutput::setName(const QString& s)
Fifo::Fifo()
{
muse_atomic_init(&count);
- //nbuffer = FIFO_BUFFER;
nbuffer = MusEGlobal::fifoLength;
buffer = new FifoBuffer*[nbuffer];
for (int i = 0; i < nbuffer; ++i)
@@ -1652,10 +1533,7 @@ Fifo::~Fifo()
for (int i = 0; i < nbuffer; ++i)
{
if(buffer[i]->buffer)
- {
- //printf("Fifo::~Fifo freeing buffer\n");
free(buffer[i]->buffer);
- }
delete buffer[i];
}
@@ -1684,14 +1562,9 @@ bool Fifo::put(int segs, unsigned long samples, float** src, unsigned pos)
if (b->maxSize < n) {
if (b->buffer)
{
- // Changed by Tim. p3.3.15
- //delete[] b->buffer;
free(b->buffer);
- // p3.3.45
b->buffer = 0;
}
- // Changed by Tim. p3.3.15
- //b->buffer = new float[n];
posix_memalign((void**)&(b->buffer), 16, sizeof(float) * n);
if(!b->buffer)
{
@@ -1711,7 +1584,6 @@ bool Fifo::put(int segs, unsigned long samples, float** src, unsigned pos)
b->segs = segs;
b->pos = pos;
for (int i = 0; i < segs; ++i)
- //memcpy(b->buffer + i * samples, src[i], samples * sizeof(float));
AL::dsp->cpy(b->buffer + i * samples, src[i], samples);
add();
return false;
@@ -1779,15 +1651,10 @@ bool Fifo::getWriteBuffer(int segs, unsigned long samples, float** buf, unsigned
if (b->maxSize < n) {
if (b->buffer)
{
- // Changed by Tim. p3.3.15
- //delete[] b->buffer;
free(b->buffer);
- // p3.3.45
b->buffer = 0;
}
- // Changed by Tim. p3.3.15
- //b->buffer = new float[n];
posix_memalign((void**)&(b->buffer), 16, sizeof(float) * n);
if(!b->buffer)
{
@@ -1840,14 +1707,9 @@ void AudioTrack::setChannels(int n)
void AudioTrack::setTotalOutChannels(int num)
{
- //if(num == _totalOutChannels)
- // return;
- // p4.0.27 Fixes crash if file loaded with track channels less than synth channels.
int chans = _totalOutChannels;
if(num != chans)
{
-
- //int chans = _totalOutChannels;
// Number of allocated buffers is always MAX_CHANNELS or more, even if _totalOutChannels is less.
if(chans < MAX_CHANNELS)
chans = MAX_CHANNELS;
@@ -1870,11 +1732,6 @@ void AudioTrack::setTotalOutChannels(int num)
outBuffers = new float*[chans];
for (int i = 0; i < chans; ++i)
posix_memalign((void**)&outBuffers[i], 16, sizeof(float) * MusEGlobal::segmentSize);
-
- //chans = num;
- // Limit the actual track (meters, copying etc, all 'normal' operation) to two-channel stereo.
- //if(chans > MAX_CHANNELS)
- // chans = MAX_CHANNELS;
}
chans = num;
// Limit the actual track (meters, copying etc, all 'normal' operation) to two-channel stereo.
diff --git a/muse2/muse/node.h b/muse2/muse/node.h
index 15b27d13..50f20546 100644
--- a/muse2/muse/node.h
+++ b/muse2/muse/node.h
@@ -101,9 +101,6 @@ class Pipeline;
class SndFile;
-// superceeded by dynamic allocation of fifoLength
-//const int FIFO_BUFFER = 4096;//64;
-
//---------------------------------------------------------
// Fifo
//---------------------------------------------------------
diff --git a/muse2/muse/osc.cpp b/muse2/muse/osc.cpp
index 7bdc0b00..f78e7a61 100644
--- a/muse2/muse/osc.cpp
+++ b/muse2/muse/osc.cpp
@@ -33,6 +33,7 @@
#include <string.h>
#include <stdlib.h>
+#include <errno.h>
#include <QFileInfo>
#include <QString>
@@ -43,7 +44,6 @@
#else
#include <unistd.h>
#include <signal.h>
- #include <errno.h>
#endif
#include <lo/lo.h>
@@ -154,55 +154,106 @@ int oscMessageHandler(const char* path, const char* types, lo_arg** argv,
fprintf(stderr, "oscMessageHandler: got message for ladspa effect...\n");
#endif
- // FIXME: Slowdowns: Shouldn't need these retries but they are needed, only upon creation of the synth.
- // Need to fix the real source of the problem! The instance is taking too long to appear after creation.
- //
- ///for(int retry = 0; retry < 5000; ++retry)
- {
- ///#ifdef OSC_DEBUG
- ///fprintf(stderr, "oscMessageHandler: search retry number:%d ...\n", retry);
- ///#endif
-
- //if(_uiOscPath)
- // break;
- #ifdef DSSI_SUPPORT
- if(isSynth)
+ #ifdef DSSI_SUPPORT
+ if(isSynth)
+ {
+ // Message is meant for a dssi synth. Check dssi synth instances...
+ SynthIList* sl = MusEGlobal::song->syntis();
+ for(iSynthI si = sl->begin(); si != sl->end(); ++si)
{
- // Message is meant for a dssi synth. Check dssi synth instances...
- SynthIList* sl = MusEGlobal::song->syntis();
- for(iSynthI si = sl->begin(); si != sl->end(); ++si)
+ SynthI* synti = *si;
+
+ #ifdef OSC_DEBUG
+ fprintf(stderr, "oscMessageHandler: searching for:%s checking synth instance:%s\n", p, synti->name().toLatin1().constData());
+ #endif
+
+ QByteArray ba = synti->name().toLatin1();
+ const char* sub = strstr(p, ba.constData());
+ if(sub == NULL)
+ continue;
+
+ // TODO: Fix this dynamic cast - it may be a slowdown.
+ DssiSynthIF* instance = dynamic_cast<DssiSynthIF*>(synti->sif());
+ if(!instance)
+ break;
+
+ QByteArray ba2 = synti->name().toLatin1();
+ p = sub + strlen(ba2.constData());
+
+ if (*p != '/' || *(p + 1) == 0)
{
- SynthI* synti = *si;
+ fprintf(stderr, "oscMessageHandler error: synth: end of path or no /\n");
+ return oscDebugHandler(path, types, argv, argc, data, user_data);
+ }
+
+ ++p;
+
+ #ifdef OSC_DEBUG
+ fprintf(stderr, "oscMessageHandler: synth track:%s method:%s\n", synti->name().toLatin1().constData(), p);
+ #endif
+
+ OscIF& oscif = instance->oscIF();
+
+ if (!strcmp(p, "configure") && argc == 2 && !strcmp(types, "ss"))
+ return oscif.oscConfigure(argv);
+ else if (!strcmp(p, "control") && argc == 2 && !strcmp(types, "if"))
+ return oscif.oscControl(argv);
+ else if (!strcmp(p, "midi") && argc == 1 && !strcmp(types, "m"))
+ return oscif.oscMidi(argv);
+ else if (!strcmp(p, "program") && argc == 2 && !strcmp(types, "ii"))
+ return oscif.oscProgram(argv);
+ else if (!strcmp(p, "update") && argc == 1 && !strcmp(types, "s"))
+ return oscif.oscUpdate(argv);
+ else if (!strcmp(p, "exiting") && argc == 0)
+ return oscif.oscExiting(argv);
+ return oscDebugHandler(path, types, argv, argc, data, user_data);
+ }
+ }
+ else
+ #endif //DSSI_SUPPORT
+ // Message is meant for a ladspa effect. Check all ladspa effect instances...
+ for(ciTrack it = tl->begin(); it != tl->end(); ++it)
+ {
+ if((*it)->isMidiTrack())
+ continue;
+
+ Pipeline* efxPipe = ((AudioTrack*)*it)->efxPipe();
+ if(efxPipe)
+ {
+ for(ciPluginI ip = efxPipe->begin(); ip != efxPipe->end(); ++ip)
+ {
+ PluginI* instance = *ip;
+ if(!instance)
+ continue;
#ifdef OSC_DEBUG
- fprintf(stderr, "oscMessageHandler: searching for:%s checking synth instance:%s\n", p, synti->name().toLatin1().constData());
+ fprintf(stderr, "oscMessageHandler: searching for:%s checking effect instance:%s label:%s lib:%s\n",
+ p, instance->name().toLatin1().constData(), instance->label().toLatin1().constData(), instance->lib().toLatin1().constData());
#endif
- QByteArray ba = synti->name().toLatin1();
+ QByteArray ba = instance->label().toLatin1();
const char* sub = strstr(p, ba.constData());
if(sub == NULL)
continue;
-
- //DssiSynthIF* instance = (DssiSynthIF*)synti->sif();
- // TODO: Fix this dynamic cast - it may be a slowdown.
- DssiSynthIF* instance = dynamic_cast<DssiSynthIF*>(synti->sif());
- if(!instance)
- break;
- QByteArray ba2 = synti->name().toLatin1();
- p = sub + strlen(ba2.constData());
+ Plugin* plugin = instance->plugin();
+ if(!plugin)
+ break;
+
+ QByteArray ba3 = instance->label().toLatin1();
+ p = sub + strlen(ba3.constData());
if (*p != '/' || *(p + 1) == 0)
{
- fprintf(stderr, "oscMessageHandler error: synth: end of path or no /\n");
+ fprintf(stderr, "oscMessageHandler: error: effect: end of path or no /\n");
return oscDebugHandler(path, types, argv, argc, data, user_data);
}
++p;
#ifdef OSC_DEBUG
- fprintf(stderr, "oscMessageHandler: synth track:%s method:%s\n", synti->name().toLatin1().constData(), p);
+ fprintf(stderr, "oscMessageHandler: effect:%s method:%s\n", instance->label().toLatin1().constData(), p);
#endif
OscIF& oscif = instance->oscIF();
@@ -222,76 +273,6 @@ int oscMessageHandler(const char* path, const char* types, lo_arg** argv,
return oscDebugHandler(path, types, argv, argc, data, user_data);
}
}
- else
- #endif //DSSI_SUPPORT
- // Message is meant for a ladspa effect. Check all ladspa effect instances...
- for(ciTrack it = tl->begin(); it != tl->end(); ++it)
- {
- if((*it)->isMidiTrack())
- continue;
-
- Pipeline* efxPipe = ((AudioTrack*)*it)->efxPipe();
- if(efxPipe)
- {
- for(ciPluginI ip = efxPipe->begin(); ip != efxPipe->end(); ++ip)
- {
- PluginI* instance = *ip;
- if(!instance)
- continue;
-
- #ifdef OSC_DEBUG
- fprintf(stderr, "oscMessageHandler: searching for:%s checking effect instance:%s label:%s lib:%s\n",
- p, instance->name().toLatin1().constData(), instance->label().toLatin1().constData(), instance->lib().toLatin1().constData());
- #endif
-
- //const char* sub = strstr(p, instance->name().toLatin1().constData());
- ///const char* sub = strstr(p, instance->label().toLatin1().constData());
- QByteArray ba = instance->label().toLatin1();
- const char* sub = strstr(p, ba.constData());
- if(sub == NULL)
- continue;
-
- Plugin* plugin = instance->plugin();
- if(!plugin)
- break;
-
- //p = sub + strlen(instance->name().toLatin1().constData());
- QByteArray ba3 = instance->label().toLatin1();
- p = sub + strlen(ba3.constData());
-
- if (*p != '/' || *(p + 1) == 0)
- {
- fprintf(stderr, "oscMessageHandler: error: effect: end of path or no /\n");
- return oscDebugHandler(path, types, argv, argc, data, user_data);
- }
-
- ++p;
-
- #ifdef OSC_DEBUG
- //fprintf(stderr, "oscMessageHandler: effect:%s method:%s\n", instance->name().toLatin1().constData(), p);
- fprintf(stderr, "oscMessageHandler: effect:%s method:%s\n", instance->label().toLatin1().constData(), p);
- #endif
-
- OscIF& oscif = instance->oscIF();
-
- if (!strcmp(p, "configure") && argc == 2 && !strcmp(types, "ss"))
- return oscif.oscConfigure(argv);
- else if (!strcmp(p, "control") && argc == 2 && !strcmp(types, "if"))
- return oscif.oscControl(argv);
- else if (!strcmp(p, "midi") && argc == 1 && !strcmp(types, "m"))
- return oscif.oscMidi(argv);
- else if (!strcmp(p, "program") && argc == 2 && !strcmp(types, "ii"))
- return oscif.oscProgram(argv);
- else if (!strcmp(p, "update") && argc == 1 && !strcmp(types, "s"))
- return oscif.oscUpdate(argv);
- else if (!strcmp(p, "exiting") && argc == 0)
- return oscif.oscExiting(argv);
- return oscDebugHandler(path, types, argv, argc, data, user_data);
- }
- }
- }
-
- ///usleep(1000);
}
fprintf(stderr, "oscMessageHandler: timeout error: no synth or effect instance found for given path\n");
@@ -321,12 +302,6 @@ void initOSC()
}
}
- ///snprintf(osc_path_tmp, 31, "/dssi");
- // Test: Clear the temp path:
- //snprintf(osc_path_tmp, 31, "");
-
- ///char* tmp = lo_server_thread_get_url(serverThread);
-
url = lo_server_thread_get_url(serverThread);
if(!url)
{
@@ -335,14 +310,6 @@ void initOSC()
return;
}
- ///url = (char *)malloc(strlen(tmp) + strlen(osc_path_tmp));
- //url = (char *)malloc(strlen(tmp));
-
- ///sprintf(url, "%s%s", tmp, osc_path_tmp + 1);
- //sprintf(url, "%s", tmp, osc_path_tmp + 1);
-
- ///free(tmp);
-
lo_method meth = 0;
meth = lo_server_thread_add_method(serverThread, 0, 0, oscMessageHandler, 0);
if(!meth)
@@ -433,19 +400,7 @@ OscIF::~OscIF()
printf("OscIF::~OscIF terminating _oscGuiQProc\n");
#endif
- //_oscGuiQProc->kill();
- // "This tries to terminate the process the nice way. If the process is still running after 5 seconds,
- // it terminates the process the hard way. The timeout should be chosen depending on the time the
- // process needs to do all its cleanup: use a higher value if the process is likely to do a lot of
- // computation or I/O on cleanup."
_oscGuiQProc->terminate();
- // FIXME: In Qt4 this can only be used with threads started with QThread.
- // Kill is bad anyway, app should check at close if all these guis closed or not
- // and ask user if they really want to close, possibly with kill.
- // Terminate might not terminate the thread. It is given a chance to prompt for saving etc.
- // so kill is not desirable.
- // We could wait until terminate finished but don't think that's good here.
- ///QTimer::singleShot( 5000, _oscGuiQProc, SLOT( kill() ) );
_oscGuiQProc->waitForFinished(3000);
}
delete _oscGuiQProc;
@@ -552,6 +507,7 @@ int OscIF::oscUpdate(lo_arg **argv)
// Send sample rate.
lo_send(_uiOscTarget, _uiOscSampleRatePath, "i", MusEGlobal::sampleRate);
+ // DELETETHIS 46
// Send project directory.
//lo_send(_uiOscTarget, _uiOscConfigurePath, "ss",
// DSSI_PROJECT_DIRECTORY_KEY, museProject.toLatin1().constData()); // MusEGlobal::song->projectPath()
@@ -598,7 +554,7 @@ int OscIF::oscUpdate(lo_arg **argv)
lo_send(_uiOscTarget, uiOscGuiPath, "");
*/
-
+ // DELETETHIS 22
#if 0
/* Send current bank/program (-FIX- another race...) */
if (instance->pendingProgramChange < 0) {
@@ -633,6 +589,7 @@ int OscIF::oscExiting(lo_arg**)
// The gui is gone now, right?
_oscGuiVisible = false;
+// DELETETHIS 52
// Just an attempt to really kill the process, an attempt to fix gui not re-showing after closing. Doesn't help.
/*
#ifdef _USE_QPROCESS_FOR_GUI_
@@ -707,6 +664,7 @@ int OscIF::oscExiting(lo_arg**)
free(_uiOscPath);
_uiOscPath = 0;
+ // DELETETHIS 20
//const DSSI_Descriptor* dssi = synth->dssi;
//const LADSPA_Descriptor* ld = dssi->LADSPA_Plugin;
//if(ld->deactivate)
@@ -726,7 +684,8 @@ int OscIF::oscExiting(lo_arg**)
lo_send(_uiOscTarget, uiOscGuiPath, "");
*/
-
+
+// DELETETHIS 37
#if 0
int i;
@@ -837,7 +796,6 @@ bool OscIF::oscInitGui(const QString& typ, const QString& baseName, const QStrin
// Using QProcess works OK.
// No QProcess created yet? Do it now. Only once per SynthIF instance. Exists until parent destroyed.
if(_oscGuiQProc == 0)
- //_oscGuiQProc = new QProcess(muse);
_oscGuiQProc = new QProcess();
QString program(guiPath);
@@ -845,7 +803,6 @@ bool OscIF::oscInitGui(const QString& typ, const QString& baseName, const QStrin
arguments << oscUrl
<< filePath
<< name
- //<< QString("channel-1");
<< (titlePrefix() + label);
#ifdef OSC_DEBUG
@@ -867,7 +824,6 @@ bool OscIF::oscInitGui(const QString& typ, const QString& baseName, const QStrin
filePath.toLatin1().constData(),
name.toLatin1().constData(),
strerror(errno));
- //exit(1);
}
#ifdef OSC_DEBUG
@@ -998,7 +954,7 @@ int OscDssiIF::oscUpdate(lo_arg **argv)
// Make sure to call base method.
OscIF::oscUpdate(argv);
- // Send sample rate. No, done in base class.
+ // Send sample rate. No, done in base class. DELETETHIS 7
//lo_send(_uiOscTarget, _uiOscSampleRatePath, "i", sampleRate);
// Send project directory. No, done in DssiSynthIF.
@@ -1007,7 +963,7 @@ int OscDssiIF::oscUpdate(lo_arg **argv)
if(_oscSynthIF)
_oscSynthIF->oscUpdate();
-
+// DELETETHIS 23
#if 0
/* Send current bank/program (-FIX- another race...) */
if (instance->pendingProgramChange < 0) {
@@ -1124,10 +1080,6 @@ int OscEffectIF::oscUpdate(lo_arg** argv)
// Make sure to call base method.
OscIF::oscUpdate(argv);
- // Send project directory. No, done in PluginI.
- //lo_send(_uiOscTarget, _uiOscConfigurePath, "ss",
- // DSSI_PROJECT_DIRECTORY_KEY, museProject.toLatin1().constData()); // MusEGlobal::song->projectPath()
-
if(_oscPluginI)
_oscPluginI->oscUpdate();
diff --git a/muse2/muse/osc.h b/muse2/muse/osc.h
index e3f1a26d..f75b5168 100644
--- a/muse2/muse/osc.h
+++ b/muse2/muse/osc.h
@@ -24,14 +24,19 @@
#ifndef __OSC_H__
#define __OSC_H__
-#include <lo/lo.h>
-
#include "config.h"
+#ifdef OSC_SUPPORT
+#include <lo/lo.h>
+
class QProcess;
class QString;
+#endif // OSC_SUPPORT
+
namespace MusECore {
+#ifdef OSC_SUPPORT
+
#ifdef DSSI_SUPPORT
class DssiSynthIF;
#endif
@@ -53,8 +58,8 @@ class OscIF
char* _uiOscShowPath;
bool _oscGuiVisible;
- virtual bool oscInitGui(const QString& /*typ*/, const QString& /*baseName*/, const QString& /*name*/,
- const QString& /*label*/, const QString& /*filePath*/, const QString& /*guiPath*/);
+ virtual bool oscInitGui(const QString& typ, const QString& baseName, const QString& name,
+ const QString& label, const QString& filePath, const QString& guiPath);
public:
OscIF();
@@ -67,9 +72,9 @@ class OscIF
virtual int oscMidi(lo_arg**) { return 0; }
virtual int oscConfigure(lo_arg**) { return 0; }
- virtual void oscSendProgram(unsigned long /*prog*/, unsigned long /*bank*/);
- virtual void oscSendControl(unsigned long /*dssiPort*/, float /*val*/);
- virtual void oscSendConfigure(const char */*key*/, const char */*val*/);
+ virtual void oscSendProgram(unsigned long prog, unsigned long bank);
+ virtual void oscSendControl(unsigned long dssiPort, float val);
+ virtual void oscSendConfigure(const char *key, const char *val);
virtual bool oscInitGui() { return false; }
virtual void oscShowGui(bool);
@@ -85,15 +90,11 @@ class OscEffectIF : public OscIF
public:
OscEffectIF() {}
- //~OscEffectIF();
void oscSetPluginI(PluginI*);
virtual int oscUpdate(lo_arg**);
- //virtual int oscProgram(lo_arg**);
virtual int oscControl(lo_arg**);
- //virtual int oscExiting(lo_arg**);
- //virtual int oscMidi(lo_arg**);
virtual int oscConfigure(lo_arg**);
virtual bool oscInitGui();
@@ -109,14 +110,12 @@ class OscDssiIF : public OscIF
public:
OscDssiIF() {}
- //~OscDssiIF();
void oscSetSynthIF(DssiSynthIF*);
virtual int oscUpdate(lo_arg**);
virtual int oscProgram(lo_arg**);
virtual int oscControl(lo_arg**);
- //virtual int oscExiting(lo_arg**);
virtual int oscMidi(lo_arg**);
virtual int oscConfigure(lo_arg**);
@@ -125,6 +124,8 @@ class OscDssiIF : public OscIF
virtual QString titlePrefix() const;
};
#endif // DSSI_SUPPORT
+
+#endif // OSC_SUPPORT
extern void initOSC();
diff --git a/muse2/muse/part.cpp b/muse2/muse/part.cpp
index 33519e11..8363ff68 100644
--- a/muse2/muse/part.cpp
+++ b/muse2/muse/part.cpp
@@ -34,7 +34,6 @@
#include "wave.h"
#include "midiport.h"
#include "drummap.h"
-//#include "midiedit/drummap.h" // p4.0.2
namespace MusECore {
@@ -182,7 +181,7 @@ void replaceClone(Part* p1, Part* p2)
if(p1->cevents() != p2->cevents())
{
bool ret = false;
- // If the part to be replaced is a single uncloned part,
+ // If the part to be replaced is a single uncloned part, DELETETHIS 4 this seems outdated=wrong to me
// and the replacement part is not, then this operation
// MUST be an undo of a de-cloning of a cloned part.
//if(p1->cevents()->refCount() <= 1 && p2->cevents()->refCount() > 1)
@@ -191,11 +190,11 @@ void replaceClone(Part* p1, Part* p2)
// Chain the replacement part. We don't know the chain it came from,
// so we use the slow method.
chainCloneInternal(p2);
- //return;
+ //return; DELETETHIS
ret = true;
}
- // If the replacement part is a single uncloned part,
+ // If the replacement part is a single uncloned part, DELETETHIS same as above
// and the part to be replaced is not, then this operation
// MUST be a de-cloning of a cloned part.
//if(p1->cevents()->refCount() > 1 && p2->cevents()->refCount() <= 1)
@@ -207,7 +206,6 @@ void replaceClone(Part* p1, Part* p2)
// Isolate the part.
p1->setPrevClone(p1);
p1->setNextClone(p1);
- //return;
ret = true;
}
@@ -376,57 +374,52 @@ void addPortCtrlEvents(Event& event, Part* part, bool doClones)
// Update: Due to the varying calls, and order of, incARefcount, (msg)ChangePart, replaceClone, and remove/addPortCtrlEvents,
// we can not rely on the reference count as a safety net in these routines. We will just have to trust the clone chain.
Part* p = part;
- //int j = doClones ? p->cevents()->arefCount() : 1;
- //if(j > 0)
+ while(1)
{
- //for(int i = 0; i < j; ++i)
- while(1)
+ Track* t = p->track();
+ if(t && t->isMidiTrack())
{
- Track* t = p->track();
- if(t && t->isMidiTrack())
- {
- MidiTrack* mt = (MidiTrack*)t;
- int port = mt->outPort();
- unsigned len = p->lenTick();
+ MidiTrack* mt = (MidiTrack*)t;
+ int port = mt->outPort();
+ unsigned len = p->lenTick();
+
+ // Do not add events which are past the end of the part.
+ if(event.tick() >= len)
+ break;
+
+ if(event.type() == Controller)
+ {
+ int ch = mt->outChannel();
+ int tck = event.tick() + p->tick();
+ int cntrl = event.dataA();
+ int val = event.dataB();
+ MidiPort* mp = &MusEGlobal::midiPorts[port];
- // Do not add events which are past the end of the part.
- if(event.tick() >= len)
- break;
-
- if(event.type() == Controller)
+ // Is it a drum controller event, according to the track port's instrument?
+ if(mt->type() == Track::DRUM)
{
- int ch = mt->outChannel();
- int tck = event.tick() + p->tick();
- int cntrl = event.dataA();
- int val = event.dataB();
- MidiPort* mp = &MusEGlobal::midiPorts[port];
-
- // Is it a drum controller event, according to the track port's instrument?
- if(mt->type() == Track::DRUM)
+ MidiController* mc = mp->drumController(cntrl);
+ if(mc)
{
- MidiController* mc = mp->drumController(cntrl);
- if(mc)
- {
- int note = cntrl & 0x7f;
- cntrl &= ~0xff;
- ch = MusEGlobal::drumMap[note].channel;
- mp = &MusEGlobal::midiPorts[MusEGlobal::drumMap[note].port];
- cntrl |= MusEGlobal::drumMap[note].anote;
- }
+ int note = cntrl & 0x7f;
+ cntrl &= ~0xff;
+ ch = MusEGlobal::drumMap[note].channel;
+ mp = &MusEGlobal::midiPorts[MusEGlobal::drumMap[note].port];
+ cntrl |= MusEGlobal::drumMap[note].anote;
}
-
- mp->setControllerVal(ch, tck, cntrl, val, p);
}
- }
-
- if(!doClones)
- break;
- // Get the next clone in the chain ring.
- p = p->nextClone();
- // Same as original part? Finished.
- if(p == part)
- break;
+
+ mp->setControllerVal(ch, tck, cntrl, val, p);
+ }
}
+
+ if(!doClones)
+ break;
+ // Get the next clone in the chain ring.
+ p = p->nextClone();
+ // Same as original part? Finished.
+ if(p == part)
+ break;
}
}
@@ -441,61 +434,56 @@ void addPortCtrlEvents(Part* part, bool doClones)
// Update: Due to the varying calls, and order of, incARefcount, (msg)ChangePart, replaceClone, and remove/addPortCtrlEvents,
// we can not rely on the reference count as a safety net in these routines. We will just have to trust the clone chain.
Part* p = part;
- //int j = doClones ? p->cevents()->arefCount() : 1;
- //if(j > 0)
+ while(1)
{
- //for(int i = 0; i < j; ++i)
- while(1)
+ Track* t = p->track();
+ if(t && t->isMidiTrack())
{
- Track* t = p->track();
- if(t && t->isMidiTrack())
+ MidiTrack* mt = (MidiTrack*)t;
+ int port = mt->outPort();
+ const EventList* el = p->cevents();
+ unsigned len = p->lenTick();
+ for(ciEvent ie = el->begin(); ie != el->end(); ++ie)
{
- MidiTrack* mt = (MidiTrack*)t;
- int port = mt->outPort();
- const EventList* el = p->cevents();
- unsigned len = p->lenTick();
- for(ciEvent ie = el->begin(); ie != el->end(); ++ie)
+ const Event& ev = ie->second;
+ // Added by T356. Do not add events which are past the end of the part.
+ if(ev.tick() >= len)
+ break;
+
+ if(ev.type() == Controller)
{
- const Event& ev = ie->second;
- // Added by T356. Do not add events which are past the end of the part.
- if(ev.tick() >= len)
- break;
-
- if(ev.type() == Controller)
+ int ch = mt->outChannel();
+ int tck = ev.tick() + p->tick();
+ int cntrl = ev.dataA();
+ int val = ev.dataB();
+ MidiPort* mp = &MusEGlobal::midiPorts[port];
+
+ // Is it a drum controller event, according to the track port's instrument?
+ if(mt->type() == Track::DRUM)
{
- int ch = mt->outChannel();
- int tck = ev.tick() + p->tick();
- int cntrl = ev.dataA();
- int val = ev.dataB();
- MidiPort* mp = &MusEGlobal::midiPorts[port];
-
- // Is it a drum controller event, according to the track port's instrument?
- if(mt->type() == Track::DRUM)
+ MidiController* mc = mp->drumController(cntrl);
+ if(mc)
{
- MidiController* mc = mp->drumController(cntrl);
- if(mc)
- {
- int note = cntrl & 0x7f;
- cntrl &= ~0xff;
- ch = MusEGlobal::drumMap[note].channel;
- mp = &MusEGlobal::midiPorts[MusEGlobal::drumMap[note].port];
- cntrl |= MusEGlobal::drumMap[note].anote;
- }
+ int note = cntrl & 0x7f;
+ cntrl &= ~0xff;
+ ch = MusEGlobal::drumMap[note].channel;
+ mp = &MusEGlobal::midiPorts[MusEGlobal::drumMap[note].port];
+ cntrl |= MusEGlobal::drumMap[note].anote;
}
-
- mp->setControllerVal(ch, tck, cntrl, val, p);
}
+
+ mp->setControllerVal(ch, tck, cntrl, val, p);
}
}
- if(!doClones)
- break;
- // Get the next clone in the chain ring.
- p = p->nextClone();
- // Same as original part? Finished.
- if(p == part)
- break;
}
- }
+ if(!doClones)
+ break;
+ // Get the next clone in the chain ring.
+ p = p->nextClone();
+ // Same as original part? Finished.
+ if(p == part)
+ break;
+ }
}
//---------------------------------------------------------
@@ -509,51 +497,46 @@ void removePortCtrlEvents(Event& event, Part* part, bool doClones)
// Update: Due to the varying calls, and order of, incARefcount, (msg)ChangePart, replaceClone, and remove/addPortCtrlEvents,
// we can not rely on the reference count as a safety net in these routines. We will just have to trust the clone chain.
Part* p = part;
- //int j = doClones ? p->cevents()->arefCount() : 1;
- //if(j > 0)
+ while(1)
{
- //for(int i = 0; i < j; ++i)
- while(1)
+ Track* t = p->track();
+ if(t && t->isMidiTrack())
{
- Track* t = p->track();
- if(t && t->isMidiTrack())
- {
- MidiTrack* mt = (MidiTrack*)t;
- int port = mt->outPort();
-
- if(event.type() == Controller)
+ MidiTrack* mt = (MidiTrack*)t;
+ int port = mt->outPort();
+
+ if(event.type() == Controller)
+ {
+ int ch = mt->outChannel();
+ int tck = event.tick() + p->tick();
+ int cntrl = event.dataA();
+ MidiPort* mp = &MusEGlobal::midiPorts[port];
+
+ // Is it a drum controller event, according to the track port's instrument?
+ if(mt->type() == Track::DRUM)
{
- int ch = mt->outChannel();
- int tck = event.tick() + p->tick();
- int cntrl = event.dataA();
- MidiPort* mp = &MusEGlobal::midiPorts[port];
-
- // Is it a drum controller event, according to the track port's instrument?
- if(mt->type() == Track::DRUM)
+ MidiController* mc = mp->drumController(cntrl);
+ if(mc)
{
- MidiController* mc = mp->drumController(cntrl);
- if(mc)
- {
- int note = cntrl & 0x7f;
- cntrl &= ~0xff;
- ch = MusEGlobal::drumMap[note].channel;
- mp = &MusEGlobal::midiPorts[MusEGlobal::drumMap[note].port];
- cntrl |= MusEGlobal::drumMap[note].anote;
- }
+ int note = cntrl & 0x7f;
+ cntrl &= ~0xff;
+ ch = MusEGlobal::drumMap[note].channel;
+ mp = &MusEGlobal::midiPorts[MusEGlobal::drumMap[note].port];
+ cntrl |= MusEGlobal::drumMap[note].anote;
}
-
- mp->deleteController(ch, tck, cntrl, p);
}
- }
-
- if(!doClones)
- break;
- // Get the next clone in the chain ring.
- p = p->nextClone();
- // Same as original part? Finished.
- if(p == part)
- break;
- }
+
+ mp->deleteController(ch, tck, cntrl, p);
+ }
+ }
+
+ if(!doClones)
+ break;
+ // Get the next clone in the chain ring.
+ p = p->nextClone();
+ // Same as original part? Finished.
+ if(p == part)
+ break;
}
}
@@ -568,62 +551,57 @@ void removePortCtrlEvents(Part* part, bool doClones)
// Update: Due to the varying calls, and order of, incARefcount, (msg)ChangePart, replaceClone, and remove/addPortCtrlEvents,
// we can not rely on the reference count as a safety net in these routines. We will just have to trust the clone chain.
Part* p = part;
- //int j = doClones ? p->cevents()->arefCount() : 1;
- //if(j > 0)
+ while(1)
{
- //for(int i = 0; i < j; ++i)
- while(1)
+ Track* t = p->track();
+ if(t && t->isMidiTrack())
{
- Track* t = p->track();
- if(t && t->isMidiTrack())
+ MidiTrack* mt = (MidiTrack*)t;
+ int port = mt->outPort();
+ const EventList* el = p->cevents();
+ //unsigned len = p->lenTick();
+ for(ciEvent ie = el->begin(); ie != el->end(); ++ie)
{
- MidiTrack* mt = (MidiTrack*)t;
- int port = mt->outPort();
- const EventList* el = p->cevents();
- //unsigned len = p->lenTick();
- for(ciEvent ie = el->begin(); ie != el->end(); ++ie)
+ const Event& ev = ie->second;
+ // Added by T356. Do not remove events which are past the end of the part. DELETETHIS 5
+ // No, actually, do remove ALL of them belonging to the part.
+ // Just in case there are stray values left after the part end.
+ //if(ev.tick() >= len)
+ // break;
+
+ if(ev.type() == Controller)
{
- const Event& ev = ie->second;
- // Added by T356. Do not remove events which are past the end of the part.
- // No, actually, do remove ALL of them belonging to the part.
- // Just in case there are stray values left after the part end.
- //if(ev.tick() >= len)
- // break;
-
- if(ev.type() == Controller)
+ int ch = mt->outChannel();
+ int tck = ev.tick() + p->tick();
+ int cntrl = ev.dataA();
+ MidiPort* mp = &MusEGlobal::midiPorts[port];
+
+ // Is it a drum controller event, according to the track port's instrument?
+ if(mt->type() == Track::DRUM)
{
- int ch = mt->outChannel();
- int tck = ev.tick() + p->tick();
- int cntrl = ev.dataA();
- MidiPort* mp = &MusEGlobal::midiPorts[port];
-
- // Is it a drum controller event, according to the track port's instrument?
- if(mt->type() == Track::DRUM)
+ MidiController* mc = mp->drumController(cntrl);
+ if(mc)
{
- MidiController* mc = mp->drumController(cntrl);
- if(mc)
- {
- int note = cntrl & 0x7f;
- cntrl &= ~0xff;
- ch = MusEGlobal::drumMap[note].channel;
- mp = &MusEGlobal::midiPorts[MusEGlobal::drumMap[note].port];
- cntrl |= MusEGlobal::drumMap[note].anote;
- }
+ int note = cntrl & 0x7f;
+ cntrl &= ~0xff;
+ ch = MusEGlobal::drumMap[note].channel;
+ mp = &MusEGlobal::midiPorts[MusEGlobal::drumMap[note].port];
+ cntrl |= MusEGlobal::drumMap[note].anote;
}
-
- mp->deleteController(ch, tck, cntrl, p);
}
+
+ mp->deleteController(ch, tck, cntrl, p);
}
- }
-
- if(!doClones)
- break;
- // Get the next clone in the chain ring.
- p = p->nextClone();
- // Same as original part? Finished.
- if(p == part)
- break;
- }
+ }
+ }
+
+ if(!doClones)
+ break;
+ // Get the next clone in the chain ring.
+ p = p->nextClone();
+ // Same as original part? Finished.
+ if(p == part)
+ break;
}
}
@@ -649,7 +627,6 @@ int PartList::index(Part* part)
}
if(MusEGlobal::debugMsg)
printf("PartList::index(): not found!\n");
- //return 0; // don't comment this in again
return -1; // don't change that value. at least MidiEditor::addNewParts relies on this
}
@@ -904,7 +881,7 @@ void Song::cmdResizePart(Track* track, Part* oPart, unsigned int len, bool doClo
i--;
Event last = i->second;
unsigned last_start = last.frame();
- MusECore::SndFileR file = last.sndFile();
+ MusECore::SndFileR file = last.sndFile();
if (file.isNull())
return;
@@ -1069,7 +1046,6 @@ void Song::cmdSplitPart(Track* track, Part* part, int tick)
startUndo();
// Indicate no undo, and do port controller values but not clone parts.
- //MusEGlobal::audio->msgChangePart(part, p1, false);
MusEGlobal::audio->msgChangePart(part, p1, false, true, false);
MusEGlobal::audio->msgAddPart(p2, false);
endUndo(SC_TRACK_MODIFIED | SC_PART_MODIFIED | SC_PART_INSERTED);
@@ -1211,19 +1187,6 @@ WavePart* WavePart::clone() const
}
-/*
-bool Part::hasHiddenNotes()
-{
- unsigned lastNote=0;
-
- for (iEvent ev=events()->begin(); ev!=events()->end(); ev++)
- if (ev->second.endTick() > lastNote)
- lastNote=ev->second.endTick();
-
- return lastNote > lenTick();
-}
-*/
-
//---------------------------------------------------------
// hasHiddenEvents
// Returns combination of HiddenEventsType enum.
@@ -1246,4 +1209,18 @@ int Part::hasHiddenEvents()
return _hiddenEvents;
}
+
+
+//---------------------------------------------------------
+// ClonePart
+//---------------------------------------------------------
+
+ClonePart::ClonePart(const Part* p, int i)
+{
+ cp = p;
+ id = i;
+ uuid_generate(uuid);
+}
+
+
} // namespace MusECore
diff --git a/muse2/muse/plugin.cpp b/muse2/muse/plugin.cpp
index ed3a8655..9b3879b9 100644
--- a/muse2/muse/plugin.cpp
+++ b/muse2/muse/plugin.cpp
@@ -82,22 +82,6 @@ namespace MusEGlobal {
MusECore::PluginList plugins;
}
-/*
-static const char* MusEGlobal::preset_file_pattern[] = {
- QT_TRANSLATE_NOOP("@default", "Presets (*.pre *.pre.gz *.pre.bz2)"),
- QT_TRANSLATE_NOOP("@default", "All Files (*)"),
- 0
- };
-
-static const char* MusEGlobal::preset_file_save_pattern[] = {
- QT_TRANSLATE_NOOP("@default", "Presets (*.pre)"),
- QT_TRANSLATE_NOOP("@default", "gzip compressed presets (*.pre.gz)"),
- QT_TRANSLATE_NOOP("@default", "bzip2 compressed presets (*.pre.bz2)"),
- QT_TRANSLATE_NOOP("@default", "All Files (*)"),
- 0
- };
-*/
-
namespace MusEGui {
int PluginDialog::selectedPlugType = 0;
QStringList PluginDialog::sortItems = QStringList();
@@ -113,7 +97,6 @@ namespace MusECore {
// ladspa2MidiControlValues
//---------------------------------------------------------
-//bool ladspa2MidiControlValues(const LADSPA_Descriptor* plugin, int port, int ctlnum, int* min, int* max, int* def)
bool ladspa2MidiControlValues(const LADSPA_Descriptor* plugin, unsigned long port, int ctlnum, int* min, int* max, int* def)
{
LADSPA_PortRangeHint range = plugin->PortRangeHints[port];
@@ -122,12 +105,8 @@ bool ladspa2MidiControlValues(const LADSPA_Descriptor* plugin, unsigned long por
float fmin, fmax, fdef;
int imin, imax;
float frng;
- //int idef;
-
- //ladspaControlRange(plugin, port, &fmin, &fmax);
bool hasdef = ladspaDefaultValue(plugin, port, &fdef);
- //bool isint = desc & LADSPA_HINT_INTEGER;
MidiController::ControllerType t = midiControllerType(ctlnum);
#ifdef PLUGIN_DEBUGIN
@@ -181,7 +160,6 @@ bool ladspa2MidiControlValues(const LADSPA_Descriptor* plugin, unsigned long por
frng = fmax - fmin;
imin = lrint(fmin);
imax = lrint(fmax);
- //irng = imax - imin;
int ctlmn = 0;
int ctlmx = 127;
@@ -190,7 +168,6 @@ bool ladspa2MidiControlValues(const LADSPA_Descriptor* plugin, unsigned long por
printf("ladspa2MidiControlValues: port min:%f max:%f \n", fmin, fmax);
#endif
- //bool isneg = (fmin < 0.0);
bool isneg = (imin < 0);
int bias = 0;
switch(t)
@@ -227,7 +204,6 @@ bool ladspa2MidiControlValues(const LADSPA_Descriptor* plugin, unsigned long por
break;
case MidiController::Program:
ctlmn = 0;
- //ctlmx = 0xffffff;
ctlmx = 0x3fff; // FIXME: Really should not happen or be allowed. What to do here...
break;
case MidiController::Pitch:
@@ -238,7 +214,6 @@ bool ladspa2MidiControlValues(const LADSPA_Descriptor* plugin, unsigned long por
default:
break;
}
- //int ctlrng = ctlmx - ctlmn;
float fctlrng = float(ctlmx - ctlmn);
// Is it an integer control?
@@ -248,17 +223,7 @@ bool ladspa2MidiControlValues(const LADSPA_Descriptor* plugin, unsigned long por
printf("ladspa2MidiControlValues: has LADSPA_HINT_INTEGER\n");
#endif
- // If the upper or lower limit is beyond the controller limits, just scale the whole range to fit.
- // We could get fancy by scaling only the negative or positive domain, or each one separately, but no...
- //if((imin < ctlmn) || (imax > ctlmx))
- //{
- // float scl = float(irng) / float(fctlrng);
- // if((ctlmn - imin) > (ctlmx - imax))
- // scl = float(ctlmn - imin);
- // else
- // scl = float(ctlmx - imax);
- //}
- // No, instead just clip the limits. ie fit the range into clipped space.
+ // just clip the limits instead of scaling the whole range. ie fit the range into clipped space.
if(imin < ctlmn)
imin = ctlmn;
if(imax > ctlmx)
@@ -267,13 +232,6 @@ bool ladspa2MidiControlValues(const LADSPA_Descriptor* plugin, unsigned long por
*min = imin;
*max = imax;
- //int idef = (int)lrint(fdef);
- //if(idef < ctlmn)
- // idef = ctlmn;
- //if(idef > ctlmx)
- // idef = ctlmx;
- //*def = idef;
-
*def = (int)lrint(fdef);
return hasdef;
@@ -283,9 +241,6 @@ bool ladspa2MidiControlValues(const LADSPA_Descriptor* plugin, unsigned long por
*min = ctlmn;
*max = ctlmx;
- // Orcan: commented out next 2 lines to suppress compiler warning:
- //float fbias = (fmin + fmax) / 2.0;
- //float normbias = fbias / frng;
float normdef = fdef / frng;
fdef = normdef * fctlrng;
@@ -304,7 +259,6 @@ bool ladspa2MidiControlValues(const LADSPA_Descriptor* plugin, unsigned long por
// midi2LadspaValue
//---------------------------------------------------------
-//float midi2LadspaValue(const LADSPA_Descriptor* plugin, int port, int ctlnum, int val)
float midi2LadspaValue(const LADSPA_Descriptor* plugin, unsigned long port, int ctlnum, int val)
{
LADSPA_PortRangeHint range = plugin->PortRangeHints[port];
@@ -312,14 +266,8 @@ float midi2LadspaValue(const LADSPA_Descriptor* plugin, unsigned long port, int
float fmin, fmax;
int imin;
- //int imax;
float frng;
- //int idef;
-
- //ladspaControlRange(plugin, port, &fmin, &fmax);
- //bool hasdef = ladspaDefaultValue(plugin, port, &fdef);
- //bool isint = desc & LADSPA_HINT_INTEGER;
MidiController::ControllerType t = midiControllerType(ctlnum);
#ifdef PLUGIN_DEBUGIN
@@ -360,8 +308,6 @@ float midi2LadspaValue(const LADSPA_Descriptor* plugin, unsigned long port, int
frng = fmax - fmin;
imin = lrint(fmin);
- //imax = lrint(fmax);
- //irng = imax - imin;
if(desc & LADSPA_HINT_TOGGLED)
{
@@ -382,7 +328,6 @@ float midi2LadspaValue(const LADSPA_Descriptor* plugin, unsigned long port, int
printf("midi2LadspaValue: port min:%f max:%f \n", fmin, fmax);
#endif
- //bool isneg = (fmin < 0.0);
bool isneg = (imin < 0);
int bval = val;
int cval = val;
@@ -458,11 +403,6 @@ float midi2LadspaValue(const LADSPA_Descriptor* plugin, unsigned long port, int
// It's a floating point control, just use wide open maximum range.
float normval = float(bval) / fctlrng;
- //float fbias = (fmin + fmax) / 2.0;
- //float normfbias = fbias / frng;
- //float ret = (normdef + normbias) * fctlrng;
- //float normdef = fdef / frng;
-
float ret = normval * frng + fmin;
#ifdef PLUGIN_DEBUGIN
@@ -510,13 +450,13 @@ CtrlList::Mode ladspaCtrlMode(const LADSPA_Descriptor* plugin, int port)
return CtrlList::INTERPOLATE;
}
+// DELETETHIS 20
// Works but not needed.
/*
//---------------------------------------------------------
// ladspa2MidiController
//---------------------------------------------------------
-//MidiController* ladspa2MidiController(const LADSPA_Descriptor* plugin, int port, int ctlnum)
MidiController* ladspa2MidiController(const LADSPA_Descriptor* plugin, unsigned long port, int ctlnum)
{
int min, max, def;
@@ -535,16 +475,12 @@ MidiController* ladspa2MidiController(const LADSPA_Descriptor* plugin, unsigned
// If no default ladspa value found, still sets *def to 1.0, but returns false.
//---------------------------------------------------------------------------------
-//float ladspaDefaultValue(const LADSPA_Descriptor* plugin, int k)
-//bool ladspaDefaultValue(const LADSPA_Descriptor* plugin, int port, float* val)
bool ladspaDefaultValue(const LADSPA_Descriptor* plugin, unsigned long port, float* val)
{
if(port < plugin->PortCount)
{
LADSPA_PortRangeHint range = plugin->PortRangeHints[port];
LADSPA_PortRangeHintDescriptor rh = range.HintDescriptor;
- // bool isLog = LADSPA_IS_HINT_LOGARITHMIC(rh);
- //double val = 1.0;
float m = (rh & LADSPA_HINT_SAMPLE_RATE) ? float(MusEGlobal::sampleRate) : 1.0f;
if (LADSPA_IS_HINT_DEFAULT_MINIMUM(rh))
{
@@ -555,9 +491,6 @@ bool ladspaDefaultValue(const LADSPA_Descriptor* plugin, unsigned long port, flo
{
if (LADSPA_IS_HINT_LOGARITHMIC(rh))
{
- //*val = exp(fast_log10(range.LowerBound * m) * .75 +
- // log(range.UpperBound * m) * .25);
- // p4.0.21 And below...
*val = expf(fast_log10(range.LowerBound * m) * .75 + // Why fast_log10?
logf(range.UpperBound * m) * .25);
return true;
@@ -572,8 +505,6 @@ bool ladspaDefaultValue(const LADSPA_Descriptor* plugin, unsigned long port, flo
{
if (LADSPA_IS_HINT_LOGARITHMIC(rh))
{
- //*val = exp(log(range.LowerBound * m) * .5 +
- // log10(range.UpperBound * m) * .5);
*val = expf(logf(range.LowerBound * m) * .5 +
log10f(range.UpperBound * m) * .5); // Why log10?
return true;
@@ -588,8 +519,6 @@ bool ladspaDefaultValue(const LADSPA_Descriptor* plugin, unsigned long port, flo
{
if (LADSPA_IS_HINT_LOGARITHMIC(rh))
{
- //*val = exp(log(range.LowerBound * m) * .25 +
- // log(range.UpperBound * m) * .75);
*val = expf(logf(range.LowerBound * m) * .25 +
logf(range.UpperBound * m) * .75);
return true;
@@ -636,7 +565,6 @@ bool ladspaDefaultValue(const LADSPA_Descriptor* plugin, unsigned long port, flo
// ladspaControlRange
//---------------------------------------------------------
-//void ladspaControlRange(const LADSPA_Descriptor* plugin, int i, float* min, float* max)
void ladspaControlRange(const LADSPA_Descriptor* plugin, unsigned long port, float* min, float* max)
{
LADSPA_PortRangeHint range = plugin->PortRangeHints[port];
@@ -660,6 +588,7 @@ void ladspaControlRange(const LADSPA_Descriptor* plugin, unsigned long port, flo
*max = 1.0;
}
+// DELETETHIS 35
/*
//---------------------------------------------------------
// PluginBase
@@ -717,10 +646,6 @@ Plugin::Plugin(QFileInfo* f, const LADSPA_Descriptor* d, bool isDssi)
_copyright = QString(d->Copyright);
_portCount = d->PortCount;
- //_portDescriptors = 0;
- //if(_portCount)
- // _portDescriptors = new LADSPA_PortDescriptor[_portCount];
-
_inports = 0;
_outports = 0;
@@ -729,7 +654,6 @@ Plugin::Plugin(QFileInfo* f, const LADSPA_Descriptor* d, bool isDssi)
for(unsigned long k = 0; k < _portCount; ++k)
{
LADSPA_PortDescriptor pd = d->PortDescriptors[k];
- //_portDescriptors[k] = pd;
if(pd & LADSPA_PORT_AUDIO)
{
if(pd & LADSPA_PORT_INPUT)
@@ -780,8 +704,6 @@ Plugin::Plugin(QFileInfo* f, const LADSPA_Descriptor* d, bool isDssi)
Plugin::~Plugin()
{
- //if(_portDescriptors)
- // delete[] _portDescriptors;
if(plugin)
delete plugin;
}
@@ -822,18 +744,14 @@ int Plugin::incReferences(int val)
return 0;
}
- //if(_references == 0)
if(_handle == 0)
{
- //_references = 0;
_handle = dlopen(fi.filePath().toLatin1().constData(), RTLD_NOW);
- //handle = dlopen(fi.absFilePath().toLatin1().constData(), RTLD_NOW);
if(_handle == 0)
{
fprintf(stderr, "Plugin::incReferences dlopen(%s) failed: %s\n",
fi.filePath().toLatin1().constData(), dlerror());
- //fi.absFilePath().toLatin1().constData(), dlerror());
return 0;
}
@@ -852,7 +770,6 @@ int Plugin::incReferences(int val)
QString label(descr->LADSPA_Plugin->Label);
// Listing effect plugins only while excluding synths:
// Do exactly what dssi-vst.cpp does for listing ladspa plugins.
- //if(label == _name &&
if(label == _label &&
!descr->run_synth &&
!descr->run_synth_adding &&
@@ -865,8 +782,6 @@ int Plugin::incReferences(int val)
plugin = descr->LADSPA_Plugin;
break;
}
- //else
- // delete descr;
}
}
else
@@ -876,7 +791,6 @@ int Plugin::incReferences(int val)
if(ladspadf)
{
const LADSPA_Descriptor* descr;
- //for(int i = 0;; ++i)
for(unsigned long i = 0;; ++i) // p4.0.21
{
descr = ladspadf(i);
@@ -884,7 +798,6 @@ int Plugin::incReferences(int val)
break;
QString label(descr->Label);
- //if(label == _name)
if(label == _label)
{
_isDssi = false;
@@ -897,26 +810,18 @@ int Plugin::incReferences(int val)
break;
}
- //else
- // delete descr;
}
}
}
if(plugin != NULL)
{
- //_instNo = 0;
_name = QString(plugin->Name);
_uniqueID = plugin->UniqueID;
_maker = QString(plugin->Maker);
_copyright = QString(plugin->Copyright);
- //if(_portDescriptors)
- // delete[] _portDescriptors;
- //_portDescriptors = 0;
_portCount = plugin->PortCount;
- //if(_portCount)
- // _portDescriptors = new LADSPA_PortDescriptor[_portCount];
_inports = 0;
_outports = 0;
@@ -925,7 +830,6 @@ int Plugin::incReferences(int val)
for(unsigned long k = 0; k < _portCount; ++k)
{
LADSPA_PortDescriptor pd = plugin->PortDescriptors[k];
- //_portDescriptors[k] = pd;
if(pd & LADSPA_PORT_AUDIO)
{
if(pd & LADSPA_PORT_INPUT)
@@ -974,10 +878,6 @@ int Plugin::incReferences(int val)
_references = newref;
- //QString guiPath(info.dirPath() + "/" + info.baseName());
- //QDir guiDir(guiPath, "*", QDir::Unsorted, QDir::Files);
- //_hasGui = guiDir.exists();
-
return _references;
}
@@ -987,27 +887,6 @@ int Plugin::incReferences(int val)
void Plugin::range(unsigned long i, float* min, float* max) const
{
- /*
- LADSPA_PortRangeHint range = plugin->PortRangeHints[i];
- LADSPA_PortRangeHintDescriptor desc = range.HintDescriptor;
- if (desc & LADSPA_HINT_TOGGLED) {
- *min = 0.0;
- *max = 1.0;
- return;
- }
- float m = 1.0;
- if (desc & LADSPA_HINT_SAMPLE_RATE)
- m = float(MusEGlobal::sampleRate);
-
- if (desc & LADSPA_HINT_BOUNDED_BELOW)
- *min = range.LowerBound * m;
- else
- *min = 0.0;
- if (desc & LADSPA_HINT_BOUNDED_ABOVE)
- *max = range.UpperBound * m;
- else
- *max = 1.0;
- */
ladspaControlRange(plugin, i, min, max); // p4.0.20
}
@@ -1015,7 +894,6 @@ void Plugin::range(unsigned long i, float* min, float* max) const
// defaultValue
//---------------------------------------------------------
-//double Plugin::defaultValue(unsigned long port) const
float Plugin::defaultValue(unsigned long port) const
{
// p4.0.21
@@ -1023,6 +901,7 @@ float Plugin::defaultValue(unsigned long port) const
ladspaDefaultValue(plugin, port, &val);
return val;
+ // DELETETHIS 50
/*
if(port >= plugin->PortCount)
return 0.0;
@@ -1108,7 +987,6 @@ static void loadPluginLib(QFileInfo* fi)
if(dssi)
{
const DSSI_Descriptor* descr;
- //for (int i = 0;; ++i)
for (unsigned long i = 0;; ++i) // p4.0.21
{
descr = dssi(i);
@@ -1124,24 +1002,17 @@ static void loadPluginLib(QFileInfo* fi)
{
// Make sure it doesn't already exist.
if(MusEGlobal::plugins.find(fi->completeBaseName(), QString(descr->LADSPA_Plugin->Label)) != 0)
- {
- //delete descr;
continue;
- }
+
#ifdef PLUGIN_DEBUGIN
fprintf(stderr, "loadPluginLib: dssi effect name:%s inPlaceBroken:%d\n", descr->LADSPA_Plugin->Name, LADSPA_IS_INPLACE_BROKEN(descr->LADSPA_Plugin->Properties));
#endif
- //LADSPA_Properties properties = descr->LADSPA_Plugin->Properties;
- //bool inPlaceBroken = LADSPA_IS_INPLACE_BROKEN(properties);
- //MusEGlobal::plugins.add(fi, descr, !inPlaceBroken);
if(MusEGlobal::debugMsg)
fprintf(stderr, "loadPluginLib: adding dssi effect plugin:%s name:%s label:%s\n", fi->filePath().toLatin1().constData(), descr->LADSPA_Plugin->Name, descr->LADSPA_Plugin->Label);
MusEGlobal::plugins.add(fi, descr->LADSPA_Plugin, true);
}
- //else
- // delete descr;
}
}
else
@@ -1165,7 +1036,6 @@ static void loadPluginLib(QFileInfo* fi)
}
const LADSPA_Descriptor* descr;
- //for (int i = 0;; ++i)
for (unsigned long i = 0;; ++i) // p4.0.21
{
descr = ladspa(i);
@@ -1174,17 +1044,12 @@ static void loadPluginLib(QFileInfo* fi)
// Make sure it doesn't already exist.
if(MusEGlobal::plugins.find(fi->completeBaseName(), QString(descr->Label)) != 0)
- {
- //delete descr;
continue;
- }
+
#ifdef PLUGIN_DEBUGIN
fprintf(stderr, "loadPluginLib: ladspa effect name:%s inPlaceBroken:%d\n", descr->Name, LADSPA_IS_INPLACE_BROKEN(descr->Properties));
#endif
- //LADSPA_Properties properties = descr->Properties;
- //bool inPlaceBroken = LADSPA_IS_INPLACE_BROKEN(properties);
- //MusEGlobal::plugins.add(fi, ladspa, descr, !inPlaceBroken);
if(MusEGlobal::debugMsg)
fprintf(stderr, "loadPluginLib: adding ladspa plugin:%s name:%s label:%s\n", fi->filePath().toLatin1().constData(), descr->Name, descr->Label);
MusEGlobal::plugins.add(fi, descr);
@@ -1289,7 +1154,7 @@ Plugin* PluginList::find(const QString& file, const QString& name)
if ((file == i->lib()) && (name == i->label()))
return &*i;
}
- //printf("Plugin <%s> not found\n", name.ascii());
+
return 0;
}
@@ -1492,21 +1357,6 @@ bool Pipeline::isDssiPlugin(int idx) const
return false;
}
-/*
-//---------------------------------------------------------
-// dssi_ui_filename
-//---------------------------------------------------------
-
-QString dssi_ui_filename(int idx) const
-{
- PluginI* p = (*this)[idx];
- if(p)
- return p->dssi_ui_filename();
-
- return QString();
-}
-*/
-
//---------------------------------------------------------
// has_dssi_ui
//---------------------------------------------------------
@@ -1597,15 +1447,6 @@ bool Pipeline::nativeGuiVisible(int idx)
void Pipeline::apply(unsigned long ports, unsigned long nframes, float** buffer1)
{
- // prepare a second set of buffers in case a plugin is not
- // capable of inPlace processing
- //float* buffer2[ports];
- //float data[nframes * ports];
- //for (int i = 0; i < ports; ++i)
- // buffer2[i] = data + i * nframes;
-
- //fprintf(stderr, "Pipeline::apply data: nframes:%lu %e %e %e %e\n", nframes, buffer1[0][0], buffer1[0][1], buffer1[0][2], buffer1[0][3]);
-
bool swap = false;
for (iPluginI ip = begin(); ip != end(); ++ip) {
@@ -1613,10 +1454,8 @@ void Pipeline::apply(unsigned long ports, unsigned long nframes, float** buffer1
if(p)
{
- //if (p && p->on()) {
if (p->on())
{
- //fprintf(stderr, "Pipeline::apply PluginI:%p on:%d\n", p, p->on());
if (p->inPlaceCapable())
{
if (swap)
@@ -1642,8 +1481,6 @@ void Pipeline::apply(unsigned long ports, unsigned long nframes, float** buffer1
if (ports != 0 && swap)
{
for (unsigned long i = 0; i < ports; ++i)
- //memcpy(buffer1[i], buffer2[i], sizeof(float) * nframes);
- //memcpy(buffer1[i], buffer[i], sizeof(float) * nframes);
AL::dsp->cpy(buffer1[i], buffer[i], nframes);
}
}
@@ -1671,8 +1508,6 @@ QString PluginIBase::dssi_ui_filename() const
QString guiPath(dirPath() + "/" + libr);
- //fprintf(stderr, "PluginIBase::dssi_ui_filename guiPath:%s\n", guiPath.toLatin1().constData());
-
QDir guiDir(guiPath, "*", QDir::Unsorted, QDir::Files);
if(!guiDir.exists())
return QString();
@@ -1713,10 +1548,6 @@ QString PluginIBase::dssi_ui_filename() const
}
}
- //fprintf(stderr, "PluginIBase::dssi_ui_filename plug_qt_ui:%s plug_any_ui:%s lib_qt_ui:%s lib_any_ui:%s\n",
- // plug_qt_ui.toLatin1().constData(), plug_any_ui.toLatin1().constData(),
- // lib_qt_ui.toLatin1().constData(), lib_any_ui.toLatin1().constData());
-
// Prefer qt plugin ui
if(!plug_qt_ui.isEmpty())
return plug_qt_ui;
@@ -1771,8 +1602,6 @@ PluginI::~PluginI()
deactivate();
_plugin->incReferences(-1);
}
- //if (_gui)
- // delete _gui;
if (controlsOut)
delete[] controlsOut;
if (controls)
@@ -1799,12 +1628,7 @@ void PluginI::updateControllers()
if(!_track)
return;
- //for(int i = 0; i < controlPorts; ++i)
for(unsigned long i = 0; i < controlPorts; ++i)
- //MusEGlobal::audio->msgSetPluginCtrlVal(this, genACnum(_id, i), controls[i].val);
- // p3.3.43
- //MusEGlobal::audio->msgSetPluginCtrlVal(_track, genACnum(_id, i), controls[i].val);
- // p4.0.21 MusEGlobal::audio->msgXXX waits. Do we really need to?
_track->setPluginCtrlVal(genACnum(_id, i), controls[i].val); // TODO A faster bulk message
MusEGlobal::song->controllerChange(_track);
@@ -1816,30 +1640,10 @@ void PluginI::updateControllers()
void PluginI::setChannels(int c)
{
- // p3.3.41 Removed
- //if (channel == c)
- // return;
-
- // p3.3.41
channel = c;
- //int ni = c / _plugin->outports();
- //if (ni == 0)
- // ni = 1;
- // p3.3.41 Some plugins have zero out ports, causing exception with the above line.
- // Also, pick the least number of ins or outs, and base the number of instances on that.
unsigned long ins = _plugin->inports();
unsigned long outs = _plugin->outports();
- /*
- unsigned long minports = ~0ul;
- if(outs && outs < minports)
- minports = outs;
- if(ins && ins < minports)
- minports = ins;
- if(minports == ~0ul)
- minports = 1;
- int ni = c / minports;
- */
int ni = 1;
if(outs)
ni = c / outs;
@@ -1853,9 +1657,6 @@ void PluginI::setChannels(int c)
if (ni == instances)
return;
- // p3.3.41 Moved above.
- //channel = c;
-
// remove old instances:
deactivate();
delete[] handle;
@@ -1869,8 +1670,6 @@ void PluginI::setChannels(int c)
}
}
- //int curPort = 0;
- //int curOutPort = 0;
unsigned long curPort = 0; // p4.0.21
unsigned long curOutPort = 0;
unsigned long ports = _plugin->ports();
@@ -1906,11 +1705,7 @@ void PluginI::setChannels(int c)
void PluginI::setParam(unsigned long i, float val)
{
- //controls[i].tmpVal = val;
-
- // p4.0.21
if(i >= _plugin->_controlInPorts)
- //if(i >= controlPorts)
{
printf("PluginI::setParameter param number %lu out of range of ports:%lu\n", i, _plugin->_controlInPorts);
return;
@@ -1932,7 +1727,7 @@ void PluginI::setParam(unsigned long i, float val)
fprintf(stderr, "PluginI::setParameter: fifo overflow: in control number:%lu\n", i);
}
- // Notify that changes are to be sent upon heartbeat.
+ // Notify that changes are to be sent upon heartbeat. DELETETHIS 4
// TODO: No, at least not for now. So far, setParameter is only called during loading of stored params,
// and we don't want this interfering with oscUpdate which also sends the values.
//synti->_guiUpdateControls[n] = true;
@@ -1942,7 +1737,6 @@ void PluginI::setParam(unsigned long i, float val)
// defaultValue
//---------------------------------------------------------
-//double PluginI::defaultValue(unsigned int param) const
float PluginI::defaultValue(unsigned long param) const
{
if(param >= controlPorts)
@@ -1960,10 +1754,6 @@ LADSPA_Handle Plugin::instantiate()
return NULL;
}
- //QString guiPath(info.dirPath() + "/" + info.baseName());
- //QDir guiDir(guiPath, "*", QDir::Unsorted, QDir::Files);
- //_hasGui = guiDir.exists();
-
return h;
}
@@ -1992,23 +1782,8 @@ bool PluginI::initPluginInstance(Plugin* plug, int c)
_name = _plugin->name() + inst;
_label = _plugin->label() + inst;
- //instances = channel/plug->outports();
- // p3.3.41 Some plugins have zero out ports, causing exception with the above line.
- // Also, pick the least number of ins or outs, and base the number of instances on that.
unsigned long ins = plug->inports();
unsigned long outs = plug->outports();
- /*
- unsigned long minports = ~0ul;
- if(outs && outs < minports)
- minports = outs;
- if(ins && ins < minports)
- minports = ins;
- if(minports == ~0ul)
- minports = 1;
- instances = channel / minports;
- if(instances < 1)
- instances = 1;
- */
if(outs)
{
instances = channel / outs;
@@ -2033,7 +1808,6 @@ bool PluginI::initPluginInstance(Plugin* plug, int c)
#endif
handle[i] = _plugin->instantiate();
- //if (handle[i] == 0)
if(handle[i] == NULL)
return true;
}
@@ -2059,8 +1833,6 @@ bool PluginI::initPluginInstance(Plugin* plug, int c)
controls = new Port[controlPorts];
controlsOut = new Port[controlOutPorts];
- //int i = 0;
- //int ii = 0;
unsigned long curPort = 0;
unsigned long curOutPort = 0;
for(unsigned long k = 0; k < ports; ++k)
@@ -2070,7 +1842,6 @@ bool PluginI::initPluginInstance(Plugin* plug, int c)
{
if(pd & LADSPA_PORT_INPUT)
{
- //double val = _plugin->defaultValue(k);
float val = _plugin->defaultValue(k); // p4.0.21
controls[curPort].val = val;
controls[curPort].tmpVal = val;
@@ -2081,8 +1852,6 @@ bool PluginI::initPluginInstance(Plugin* plug, int c)
else
if(pd & LADSPA_PORT_OUTPUT)
{
- //double val = _plugin->defaultValue(k);
- //float val = _plugin->defaultValue(k);
controlsOut[curOutPort].val = 0.0;
controlsOut[curOutPort].tmpVal = 0.0;
controlsOut[curOutPort].enCtrl = false;
@@ -2091,8 +1860,6 @@ bool PluginI::initPluginInstance(Plugin* plug, int c)
}
}
}
- //unsigned long curPort = 0;
- //unsigned long curOutPort = 0;
curPort = 0;
curOutPort = 0;
for(unsigned long k = 0; k < ports; ++k)
@@ -2125,15 +1892,12 @@ bool PluginI::initPluginInstance(Plugin* plug, int c)
// connect
//---------------------------------------------------------
-//void PluginI::connect(int ports, float** src, float** dst)
void PluginI::connect(unsigned long ports, unsigned long offset, float** src, float** dst)
{
- //int port = 0;
unsigned long port = 0; // p4.0.21
for (int i = 0; i < instances; ++i) {
for (unsigned long k = 0; k < _plugin->ports(); ++k) {
if (isAudioIn(k)) {
- //_plugin->connectPort(handle[i], k, src[port]);
_plugin->connectPort(handle[i], k, src[port] + offset); // p4.0.21
port = (port + 1) % ports;
}
@@ -2143,13 +1907,8 @@ void PluginI::connect(unsigned long ports, unsigned long offset, float** src, fl
for (int i = 0; i < instances; ++i) {
for (unsigned long k = 0; k < _plugin->ports(); ++k) {
if (isAudioOut(k)) {
- // _plugin->connectPort(handle[i], k, dst[port]);
_plugin->connectPort(handle[i], k, dst[port] + offset); // p4.0.21
port = (port + 1) % ports; // overwrite output?
-// ++port;
-// if (port >= ports) {
-// return;
-// }
}
}
}
@@ -2176,18 +1935,12 @@ void PluginI::activate()
for (int i = 0; i < instances; ++i)
_plugin->activate(handle[i]);
if (initControlValues) {
- //printf("PluginI::activate init:%d\n", initControlValues);
- //for (int i = 0; i < controlPorts; ++i) {
for (unsigned long i = 0; i < controlPorts; ++i) {
controls[i].val = controls[i].tmpVal;
}
}
else {
- //
// get initial control values from plugin
- //
- //printf("PluginI::activate init:%d\n", initControlValues);
- //for (int i = 0; i < controlPorts; ++i) {
for (unsigned long i = 0; i < controlPorts; ++i) {
controls[i].tmpVal = controls[i].val;
}
@@ -2199,13 +1952,10 @@ void PluginI::activate()
// set plugin instance controller value by name
//---------------------------------------------------------
-//bool PluginI::setControl(const QString& s, double val)
bool PluginI::setControl(const QString& s, float val)
{
- //for (int i = 0; i < controlPorts; ++i) {
for (unsigned long i = 0; i < controlPorts; ++i) {
if (_plugin->portName(controls[i].idx) == s) {
- //controls[i].val = controls[i].tmpVal = val;
setParam(i, val); // p4.0.21
return false;
}
@@ -2222,17 +1972,11 @@ bool PluginI::setControl(const QString& s, float val)
void PluginI::writeConfiguration(int level, Xml& xml)
{
xml.tag(level++, "plugin file=\"%s\" label=\"%s\" channel=\"%d\"",
- //_plugin->lib().toLatin1().constData(), _plugin->label().toLatin1().constData(), instances * _plugin->inports());
- // p3.3.41
- //_plugin->lib().toLatin1().constData(), _plugin->label().toLatin1().constData(), channel);
Xml::xmlString(_plugin->lib()).toLatin1().constData(), Xml::xmlString(_plugin->label()).toLatin1().constData(), channel);
- //for (int i = 0; i < controlPorts; ++i) {
- //int idx = controls[i].idx;
for (unsigned long i = 0; i < controlPorts; ++i) { // p4.0.21
- unsigned long idx = controls[i].idx; //
+ unsigned long idx = controls[i].idx;
QString s("control name=\"%1\" val=\"%2\" /");
- //xml.tag(level, s.arg(_plugin->portName(idx)).arg(controls[i].tmpVal).toLatin1().constData());
xml.tag(level, s.arg(Xml::xmlString(_plugin->portName(idx)).toLatin1().constData()).arg(controls[i].tmpVal).toLatin1().constData());
}
if (_on == false)
@@ -2241,11 +1985,9 @@ void PluginI::writeConfiguration(int level, Xml& xml)
xml.intTag(level, "gui", 1);
xml.geometryTag(level, "geometry", _gui);
}
- if (nativeGuiVisible()) {
+ if (nativeGuiVisible())
xml.intTag(level, "nativegui", 1);
- // TODO:
- //xml.geometryTag(level, "nativegeometry", ?);
- }
+
xml.tag(level--, "/plugin");
}
@@ -2258,8 +2000,7 @@ bool PluginI::loadControl(Xml& xml)
QString file;
QString label;
QString name("mops");
- //double val = 0.0;
- float val = 0.0; // p4.0.21
+ float val = 0.0;
for (;;) {
Xml::Token token = xml.parse();
@@ -2276,36 +2017,30 @@ bool PluginI::loadControl(Xml& xml)
if (tag == "name")
name = xml.s2();
else if (tag == "val")
- //val = xml.s2().toDouble();
val = xml.s2().toFloat(); // p4.0.21
break;
case Xml::TagEnd:
if (tag == "control") {
- //if (setControl(name, val))
- // return false;
- // p4.0.23 Special for loader - bypass the ring buffer and store directly,
- // so that upon the 'gui = 1' tag (show the gui), the gui has immediate
- // access to the values.
if(_plugin)
- {
- bool found = false;
- for(unsigned long i = 0; i < controlPorts; ++i)
- {
- if(_plugin->portName(controls[i].idx) == name)
- {
- controls[i].val = controls[i].tmpVal = val;
- found = true;
- }
- }
- if(!found)
- {
- printf("PluginI:loadControl(%s, %f) controller not found\n",
- name.toLatin1().constData(), val);
- return false;
- }
- initControlValues = true;
- }
+ {
+ bool found = false;
+ for(unsigned long i = 0; i < controlPorts; ++i)
+ {
+ if(_plugin->portName(controls[i].idx) == name)
+ {
+ controls[i].val = controls[i].tmpVal = val;
+ found = true;
+ }
+ }
+ if(!found)
+ {
+ printf("PluginI:loadControl(%s, %f) controller not found\n",
+ name.toLatin1().constData(), val);
+ return false;
+ }
+ initControlValues = true;
}
+ }
return true;
default:
break;
@@ -2324,8 +2059,6 @@ bool PluginI::readConfiguration(Xml& xml, bool readPreset)
QString file;
QString label;
if (!readPreset)
- //instances = 1;
- // p3.3.41
channel = 1;
for (;;) {
@@ -2339,24 +2072,16 @@ bool PluginI::readConfiguration(Xml& xml, bool readPreset)
if (!readPreset && _plugin == 0) {
_plugin = MusEGlobal::plugins.find(file, label);
- //if (_plugin && initPluginInstance(_plugin, instances)) {
- // p3.3.41
if (_plugin)
- {
- if(initPluginInstance(_plugin, channel)) {
+ {
+ if(initPluginInstance(_plugin, channel)) {
_plugin = 0;
xml.parse1();
printf("Error initializing plugin instance (%s, %s)\n",
file.toLatin1().constData(), label.toLatin1().constData());
- //break; // Don't break - let it read any control tags.
+ //break; // Don't break - let it read any control tags. DELETETHIS
}
- }
- else
- {
- //printf("Warning: Plugin not found (%s, %s)\n",
- // file.toLatin1().constData(), label.toLatin1().constData());
- //break; // Don't break - let it read any control tags.
- }
+ }
}
if (tag == "control")
loadControl(xml);
@@ -2407,8 +2132,6 @@ bool PluginI::readConfiguration(Xml& xml, bool readPreset)
}
else if (tag == "channel") {
if (!readPreset)
- //instances = xml.s2().toInt();
- // p3.3.41
channel = xml.s2().toInt();
}
break;
@@ -2417,20 +2140,18 @@ bool PluginI::readConfiguration(Xml& xml, bool readPreset)
if (!readPreset && _plugin == 0) {
_plugin = MusEGlobal::plugins.find(file, label);
if (_plugin == 0)
- {
+ {
printf("Warning: Plugin not found (%s, %s)\n",
file.toLatin1().constData(), label.toLatin1().constData());
return true;
- }
+ }
- //if (initPluginInstance(_plugin, instances))
- // p3.3.41
if (initPluginInstance(_plugin, channel))
- {
+ {
printf("Error initializing plugin instance (%s, %s)\n",
file.toLatin1().constData(), label.toLatin1().constData());
return true;
- }
+ }
}
if (_gui)
_gui->updateValues();
@@ -2531,7 +2252,6 @@ bool PluginI::nativeGuiVisible()
// makeGui
//---------------------------------------------------------
-//void PluginI::makeGui()
void PluginIBase::makeGui()
{
_gui = new MusEGui::PluginGui(this);
@@ -2540,7 +2260,6 @@ void PluginIBase::makeGui()
//---------------------------------------------------------
// deleteGui
//---------------------------------------------------------
-//void PluginI::deleteGui()
void PluginIBase::deleteGui()
{
if(_gui)
@@ -2556,7 +2275,6 @@ void PluginIBase::deleteGui()
void PluginI::enableAllControllers(bool v)
{
- //for(int i = 0; i < controlPorts; ++i)
for(unsigned long i = 0; i < controlPorts; ++i)
controls[i].enCtrl = v;
}
@@ -2567,7 +2285,6 @@ void PluginI::enableAllControllers(bool v)
void PluginI::enable2AllControllers(bool v)
{
- //for(int i = 0; i < controlPorts; ++i)
for(unsigned long i = 0; i < controlPorts; ++i)
controls[i].en2Ctrl = v;
}
@@ -2578,7 +2295,9 @@ void PluginI::enable2AllControllers(bool v)
QString PluginI::titlePrefix() const
{
- return _track->name() + QString(": ");
+ if (_track)
+ return _track->name() + QString(": ");
+ else return ":";
}
//---------------------------------------------------------
@@ -2586,6 +2305,8 @@ QString PluginI::titlePrefix() const
// If ports is 0, just process controllers only, not audio (do not 'run').
//---------------------------------------------------------
+//DELETETHIS 90
+
/*
//void PluginI::apply(int n)
void PluginI::apply(unsigned long n)
@@ -2676,11 +2397,10 @@ void PluginI::apply(unsigned long n)
}
}
*/
-
-#if 1
+
void PluginI::apply(unsigned long n, unsigned long ports, float** bufIn, float** bufOut)
{
- // Process control value changes.
+ // Process control value changes. DELETETHIS 10
//if(MusEGlobal::automation && _track && _track->automationType() != AUTO_OFF && _id != -1)
//{
// for(int i = 0; i < controlPorts; ++i)
@@ -2691,7 +2411,7 @@ void PluginI::apply(unsigned long n, unsigned long ports, float** bufIn, float**
//}
// Grab the control ring buffer size now.
- //const int cbsz = _controlFifo.getSize();
+ //const int cbsz = _controlFifo.getSize(); DELETETHIS 4
//unsigned endPos = pos + n;
//unsigned long frameOffset = MusEGlobal::audio->getFrameOffset();
@@ -2732,7 +2452,7 @@ void PluginI::apply(unsigned long n, unsigned long ports, float** bufIn, float**
while(sample < n)
{
- //unsigned long nsamp = n;
+ //unsigned long nsamp = n; DELETETHIS 2
//unsigned long nsamp = n - sample;
unsigned long nsamp = usefixedrate ? fixedsize : n - sample;
bool found = false;
@@ -2740,18 +2460,18 @@ void PluginI::apply(unsigned long n, unsigned long ports, float** bufIn, float**
unsigned long index = 0;
unsigned long evframe;
// Get all control ring buffer items valid for this time period...
- //for(int m = 0; m < cbsz; ++m) // Doesn't like this. Why?
+ //for(int m = 0; m < cbsz; ++m) // Doesn't like this. Why? DELETETHIS
while(!_controlFifo.isEmpty())
{
- //ControlValue v = _controlFifo.get();
+ //ControlValue v = _controlFifo.get(); DELETETHIS
ControlEvent v = _controlFifo.peek();
// The events happened in the last period or even before that. Shift into this period with + n. This will sync with audio.
// If the events happened even before current frame - n, make sure they are counted immediately as zero-frame.
- //evframe = (pos + frameOffset > v.frame + n) ? 0 : v.frame - pos - frameOffset + n;
+ //evframe = (pos + frameOffset > v.frame + n) ? 0 : v.frame - pos - frameOffset + n; DELETETHIS
evframe = (syncFrame > v.frame + n) ? 0 : v.frame - syncFrame + n;
// Process only items in this time period. Make sure to process all
// subsequent items which have the same frame.
- //printf("PluginI::apply control idx:%lu frame:%lu val:%f unique:%d evframe:%lu\n",
+ //printf("PluginI::apply control idx:%lu frame:%lu val:%f unique:%d evframe:%lu\n", DELETETHIS
// v.idx, v.frame, v.value, v.unique, evframe); // REMOVE Tim.
// Protection. Observed this condition. Why? Supposed to be linear timestamps.
if(found && evframe < frame)
@@ -2761,42 +2481,42 @@ void PluginI::apply(unsigned long n, unsigned long ports, float** bufIn, float**
// Just make it equal to the current frame so it gets processed right away.
evframe = frame;
}
- //if(v.frame >= (endPos + frameOffset) || (found && v.frame != frame))
+ //if(v.frame >= (endPos + frameOffset) || (found && v.frame != frame)) DELETETHIS 5
//if(v.frame < sample || v.frame >= (sample + nsamp) || (found && v.frame != frame))
//if(v.frame < sample || v.frame >= (endPos + frameOffset) || (found && v.frame != frame))
//if(v.frame < sample || v.frame >= (endPos + frameOffset)
//if(v.frame < sample || v.frame >= frameOffset
if(evframe >= n
- //|| (found && v.frame != frame)
+ //|| (found && v.frame != frame) DELETETHIS 3
//|| (!usefixedrate && found && !v.unique && v.frame != frame)
//|| (found && !v.unique && evframe != frame)
// Not enough requested samples to satisfy minimum setting? Keep going.
|| (found && !v.unique && (evframe - sample >= min_per))
// Protection. Observed this condition (dummy audio so far). Why? Supposed to be linear timestamps.
- //|| (found && evframe < frame)
+ //|| (found && evframe < frame) DELETETHIS
// dssi-vst needs them serialized and accounted for, no matter what. This works with fixed rate
// because nsamp is constant. But with packets, we need to guarantee at least one-frame spacing.
// Although we likely won't be using packets with dssi-vst, so it's OK for now.
- //|| (found && v.idx == index))
+ //|| (found && v.idx == index)) DELETETHIS
//|| (usefixedrate && found && v.idx == index)) // Try this.
|| (usefixedrate && found && v.unique && v.idx == index)) //
break;
_controlFifo.remove(); // Done with the ring buffer's item. Remove it.
- //if(v.idx >= controlPorts) // Sanity check.
+ //if(v.idx >= controlPorts) // Sanity check. DELETETHIS
if(v.idx >= _plugin->_controlInPorts)
break;
found = true;
- //frame = v.frame;
+ //frame = v.frame; DELETETHIS
frame = evframe;
index = v.idx;
// Set the ladspa control port value.
- //controls[v.idx].val = v.value;
+ //controls[v.idx].val = v.value; DELETETHIS
controls[v.idx].tmpVal = v.value;
// Need to update the automation value, otherwise it overwrites later with the last MusEGlobal::automation value.
if(_track && _id != -1)
{
- // Since we are now in the audio thread context, there's no need to send a message,
+ // Since we are now in the audio thread context, there's no need to send a message, DELETETHIS 5
// just modify directly.
//MusEGlobal::audio->msgSetPluginCtrlVal(this, genACnum(_id, k), controls[k].val);
// p3.3.43
@@ -2814,7 +2534,7 @@ void PluginI::apply(unsigned long n, unsigned long ports, float** bufIn, float**
// TODO: Taken from our native gui control handlers.
// This may need modification or may cause problems -
// we don't have the luxury of access to the dssi gui controls !
- //if(at == AUTO_WRITE || (MusEGlobal::audio->isPlaying() && at == AUTO_TOUCH))
+ //if(at == AUTO_WRITE || (MusEGlobal::audio->isPlaying() && at == AUTO_TOUCH)) DELETETHIS 3
// enableController(k, false);
//_track->recordAutomation(id, v.value);
}
@@ -2823,20 +2543,17 @@ void PluginI::apply(unsigned long n, unsigned long ports, float** bufIn, float**
// Now update the actual values from the temporary values...
for(unsigned long k = 0; k < controlPorts; ++k)
{
- // printf("PluginI::apply updating port:%lu val:%f\n", k, controls[k].tmpVal);
+ // printf("PluginI::apply updating port:%lu val:%f\n", k, controls[k].tmpVal); DELETETHIS
controls[k].val = controls[k].tmpVal;
}
//if(found)
if(found && !usefixedrate)
- //nsamp = frame - sample + 1;
+ //nsamp = frame - sample + 1; DELETETHIS
nsamp = frame - sample;
if(sample + nsamp >= n) // Safety check.
nsamp = n - sample;
- //printf("PluginI::apply ports:%lu n:%lu frame:%lu sample:%lu nsamp:%lu syncFrame:%lu loopcount:%d\n",
- // ports, n, frame, sample, nsamp, syncFrame, loopcount);
-
// Don't allow zero-length runs. This could/should be checked in the control loop instead.
// Note this means it is still possible to get stuck in the top loop (at least for a while).
if(nsamp == 0)
@@ -2847,17 +2564,13 @@ void PluginI::apply(unsigned long n, unsigned long ports, float** bufIn, float**
connect(ports, sample, bufIn, bufOut);
for(int i = 0; i < instances; ++i)
- {
- //fprintf(stderr, "PluginI::apply handle %d\n", i);
_plugin->apply(handle[i], nsamp);
- }
}
sample += nsamp;
- loopcount++; // REMOVE Tim.
+ loopcount++; // REMOVE Tim. DELETETHIS then
}
}
-#endif
//---------------------------------------------------------
// oscConfigure
@@ -2885,7 +2598,6 @@ int Plugin::oscConfigure(LADSPA_Handle handle, const char* key, const char* valu
char* message = dssi_descr->configure(handle, key, value);
if (message) {
printf("Plugin::oscConfigure on configure '%s' '%s', plugin '%s' returned error '%s'\n",
- //key, value, synti->name().toAscii().data(), message);
key, value, plugin->Label, message);
free(message);
@@ -2898,10 +2610,6 @@ int Plugin::oscConfigure(LADSPA_Handle handle, const char* key, const char* valu
// instances[n].ui_osc_configure_path, "ss", key, value);
// }
- // configure invalidates bank and program information, so
- // we should do this again now:
- //queryPrograms();
-
#endif // DSSI_SUPPORT
return 0;
@@ -2928,9 +2636,6 @@ int PluginI::oscConfigure(const char *key, const char *value)
// concept of restoring an instance from one run to the next, so
// we don't bother remembering these at all.
- //const char *key = (const char *)&argv[0]->s;
- //const char *value = (const char *)&argv[1]->s;
-
#ifdef PLUGIN_DEBUGIN
printf("PluginI::oscConfigure effect plugin name:%s label:%s key:%s value:%s\n", _name.toLatin1().constData(), _label.toLatin1().constData(), key, value);
#endif
@@ -2939,17 +2644,6 @@ int PluginI::oscConfigure(const char *key, const char *value)
// FIXME: Don't think this is right, should probably do as example shows below.
for(int i = 0; i < instances; ++i)
_plugin->oscConfigure(handle[i], key, value);
-
- // also call back on UIs for plugins other than the one
- // that requested this:
- // if (n != instance->number && instances[n].uiTarget) {
- // lo_send(instances[n].uiTarget,
- // instances[n].ui_osc_configure_path, "ss", key, value);
- // }
-
- // configure invalidates bank and program information, so
- // we should do this again now:
- //queryPrograms();
#endif // DSSI_SUPPORT
return 0;
@@ -2965,7 +2659,7 @@ int PluginI::oscUpdate()
// Send project directory.
_oscif.oscSendConfigure(DSSI_PROJECT_DIRECTORY_KEY, MusEGlobal::museProject.toLatin1().constData()); // MusEGlobal::song->projectPath()
- /*
+ /* DELETETHIS 20
// Send current string configuration parameters.
StringParamMap& map = synti->stringParameters();
int i = 0;
@@ -2989,11 +2683,11 @@ int PluginI::oscUpdate()
usleep(300000);
// Send current control values.
- //unsigned long ports = controlPorts;
+ //unsigned long ports = controlPorts; DELETETHIS 2
//for(int i = 0; i < controlPorts; ++i)
for(unsigned long i = 0; i < controlPorts; ++i)
{
- //unsigned long k = synth->pIdx(i);
+ //unsigned long k = synth->pIdx(i); DELETETHIS 2
//_oscIF.oscSendControl(k, controls[i]);
//printf("PluginI::oscUpdate() sending control:%lu val:%f\n", i, controls[i].val);
_oscif.oscSendControl(controls[i].idx, controls[i].val);
@@ -3012,17 +2706,10 @@ int PluginI::oscUpdate()
int PluginI::oscControl(unsigned long port, float value)
{
- //int port = argv[0]->i;
- //LADSPA_Data value = argv[1]->f;
-
#ifdef PLUGIN_DEBUGIN
printf("PluginI::oscControl received oscControl port:%lu val:%f\n", port, value);
#endif
- //int controlPorts = synth->_controller;
-
- //if(port >= controlPorts)
- //if(port < 0 || port >= _plugin->rpIdx.size())
if(port >= _plugin->rpIdx.size())
{
fprintf(stderr, "PluginI::oscControl: port number:%lu is out of range of index list size:%zd\n", port, _plugin->rpIdx.size());
@@ -3054,7 +2741,7 @@ int PluginI::oscControl(unsigned long port, float value)
// TODO: May need FIFOs on each control(!) so that the control changes get sent one per process cycle!
// Observed countdown not actually going to zero upon string of changes.
// Try this ...
- /*
+ /* DELETETHIS 20
OscControlFifo* cfifo = _oscif.oscFifo(cport);
if(cfifo)
{
@@ -3097,7 +2784,6 @@ int PluginI::oscControl(unsigned long port, float value)
// That makes this pretty useless... But what the heck...
if(_track && _id != -1)
{
- //int id = genACnum(_id, cport);
unsigned long id = genACnum(_id, cport);
AutomationType at = _track->automationType();
@@ -3110,7 +2796,7 @@ int PluginI::oscControl(unsigned long port, float value)
_track->recordAutomation(id, value);
}
- /*
+ /* DELETETHIS 12
const DSSI_Descriptor* dssi = synth->dssi;
const LADSPA_Descriptor* ld = dssi->LADSPA_Plugin;
@@ -3126,6 +2812,7 @@ int PluginI::oscControl(unsigned long port, float value)
}
*/
+// DELETETHIS 20
#if 0
int port = argv[0]->i;
LADSPA_Data value = argv[1]->f;
@@ -3175,7 +2862,7 @@ PluginDialog::PluginDialog(QWidget* parent)
// "Note: In order to avoid performance issues, it is recommended that sorting
// is enabled after inserting the items into the tree. Alternatively, you could
// also insert the items into a list before inserting the items into the tree. "
- //pList->setSortingEnabled(true);
+ //pList->setSortingEnabled(true); DELETETHIS
QStringList headerLabels;
headerLabels << tr("Lib");
headerLabels << tr("Label");
@@ -3196,7 +2883,7 @@ PluginDialog::PluginDialog(QWidget* parent)
pList->setAlternatingRowColors(true);
pList->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
- //fillPlugs(selectedPlugType);
+ //fillPlugs(selectedPlugType); DELETETHIS 3
//pList->setSortingEnabled(true);
//pList->sortByColumn(sortColumn, sortOrder);
@@ -3218,20 +2905,14 @@ PluginDialog::PluginDialog(QWidget* parent)
okB->setFixedWidth(80);
okB->setEnabled(false);
cancelB->setFixedWidth(80);
- //ok_lo->addStretch(4);
- //ok_lo->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Maximum));
ok_lo->addWidget(okB);
ok_lo->addSpacing(8);
ok_lo->addWidget(cancelB);
- //ok_lo->addStretch(4);
- //ok_lo->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Maximum));
QGroupBox* plugSelGroup = new QGroupBox(this);
plugSelGroup->setTitle("Show plugs:");
plugSelGroup->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Maximum);
- //QHBoxLayout* psl = new QHBoxLayout;
QGridLayout* psl = new QGridLayout;
- //psl->setRowStretch(0, 0);
plugSelGroup->setLayout(psl);
QButtonGroup* plugSel = new QButtonGroup(plugSelGroup);
@@ -3239,25 +2920,21 @@ PluginDialog::PluginDialog(QWidget* parent)
onlySM->setText(tr("Mono and Stereo"));
onlySM->setCheckable(true);
plugSel->addButton(onlySM);
- //psl->addWidget(onlySM);
psl->addWidget(onlySM, 1, 0);
onlyS = new QRadioButton(this);
onlyS->setText(tr("Stereo"));
onlyS->setCheckable(true);
plugSel->addButton(onlyS);
- //psl->addWidget(onlyS);
psl->addWidget(onlyS, 0, 1);
onlyM = new QRadioButton(this);
onlyM->setText(tr("Mono"));
onlyM->setCheckable(true);
plugSel->addButton(onlyM);
- //psl->addWidget(onlyM);
psl->addWidget(onlyM, 0, 0);
allPlug = new QRadioButton(this);
allPlug->setText(tr("Show All"));
allPlug->setCheckable(true);
plugSel->addButton(allPlug);
- //psl->addWidget(allPlug);
psl->addWidget(allPlug, 1, 1);
plugSel->setExclusive(true);
@@ -3292,7 +2969,7 @@ PluginDialog::PluginDialog(QWidget* parent)
sortBox->setMinimumSize(100, 10);
srch_lo->addWidget(sortBox);
- //srch_lo->addStretch();
+ //srch_lo->addStretch(); DELETETHIS 4
// FIXME: Adding this makes the whole bottom hlayout expand. Would like some space between lineedit and bottom.
// Same thing if spacers added to group box or Ok Cancel box.
//srch_lo->addSpacerItem(new QSpacerItem(0, 0, QSizePolicy::Minimum, QSizePolicy::Maximum));
@@ -3303,18 +2980,12 @@ PluginDialog::PluginDialog(QWidget* parent)
if(listSave.isEmpty())
{
- //int sizes[] = { 110, 110, 0, 30, 30, 30, 30, 30, 50, 110, 110 };
int sizes[] = { 110, 110, 110, 30, 30, 30, 30, 30, 50, 110, 110 };
for (int i = 0; i < 11; ++i) {
- //if (sizes[i] == 0) {
- // pList->header()->setResizeMode(i, QHeaderView::Stretch);
- // }
- //else {
- if (sizes[i] <= 50) // hack alert!
- pList->header()->setResizeMode(i, QHeaderView::Fixed);
- pList->header()->resizeSection(i, sizes[i]);
- // }
- }
+ if (sizes[i] <= 50) // hack alert!
+ pList->header()->setResizeMode(i, QHeaderView::Fixed);
+ pList->header()->resizeSection(i, sizes[i]);
+ }
pList->sortByColumn(0, Qt::AscendingOrder);
}
else
@@ -3368,13 +3039,10 @@ void PluginDialog::saveSettings()
sortItems.push_front(sortBox->currentText());
}
- ///sortColumn = pList->sortColumn();
QHeaderView* hdr = pList->header();
if(hdr)
- {
- ///sortOrder = hdr->sortIndicatorOrder();
listSave = hdr->saveState();
- }
+
geometrySave = geometry();
}
@@ -3405,16 +3073,12 @@ void PluginDialog::reject()
void PluginDialog::fillPlugs(QAbstractButton* ab)
{
if (ab == allPlug)
- //fillPlugs(SEL_ALL);
selectedPlugType = SEL_ALL;
else if (ab == onlyM)
- //fillPlugs(SEL_M);
selectedPlugType = SEL_M;
else if (ab == onlyS)
- //fillPlugs(SEL_S);
selectedPlugType = SEL_S;
else if (ab == onlySM)
- //fillPlugs(SEL_SM);
selectedPlugType = SEL_SM;
fillPlugs();
}
@@ -3423,10 +3087,6 @@ void PluginDialog::fillPlugs()
{
pList->clear();
for (MusECore::iPlugin i = MusEGlobal::plugins.begin(); i != MusEGlobal::plugins.end(); ++i) {
- //int ai = i->inports();
- //int ao = i->outports();
- //int ci = i->controlInPorts();
- //int co = i->controlOutPorts();
unsigned long ai = i->inports(); // p4.0.21
unsigned long ao = i->outports();
unsigned long ci = i->controlInPorts();
@@ -3503,8 +3163,6 @@ const char* presetBypassText = "Click this button to bypass effect unit";
// PluginGui
//---------------------------------------------------------
-//PluginGui::PluginGui(PluginI* p)
-// p3.3.43
PluginGui::PluginGui(MusECore::PluginIBase* p)
: QMainWindow(0)
{
@@ -3512,7 +3170,6 @@ PluginGui::PluginGui(MusECore::PluginIBase* p)
params = 0;
paramsOut = 0;
plugin = p;
- //setWindowTitle(plugin->name());
setWindowTitle(plugin->titlePrefix() + plugin->name());
QToolBar* tools = addToolBar(tr("File Buttons"));
@@ -3536,7 +3193,6 @@ PluginGui::PluginGui(MusECore::PluginIBase* p)
// TODO: We need to use .qrc files to use icons in WhatsThis bubbles. See Qt
// Resource System in Qt documentation - ORCAN
- //Q3MimeSourceFactory::defaultFactory()->setPixmap(QString("fileopen"), *openIcon );
fileOpen->setWhatsThis(tr(presetOpenText));
onOff->setWhatsThis(tr(presetBypassText));
fileSave->setWhatsThis(tr(presetSaveText));
@@ -3567,10 +3223,6 @@ PluginGui::PluginGui(MusECore::PluginIBase* p)
const char* name = ba.constData();
if (*name !='P')
continue;
- //int parameter = -1;
- //sscanf(name, "P%d", &parameter);
- //if (parameter == -1)
- // continue;
unsigned long parameter; // p4.0.21
int rv = sscanf(name, "P%lu", &parameter);
if(rv != 1)
@@ -3598,10 +3250,6 @@ PluginGui::PluginGui(MusECore::PluginIBase* p)
const char* name = ba.constData();
if (*name !='P')
continue;
- //int parameter = -1;
- //sscanf(name, "P%d", &parameter);
- //if (parameter == -1)
- // continue;
unsigned long parameter; // p4.0.21
int rv = sscanf(name, "P%lu", &parameter);
if(rv != 1)
@@ -3619,7 +3267,6 @@ PluginGui::PluginGui(MusECore::PluginIBase* p)
gw[nobj].type = GuiWidgets::SLIDER;
((Slider*)obj)->setId(nobj);
((Slider*)obj)->setCursorHoming(true);
- //for(int i = 0; i < nobj; i++)
for(unsigned long i = 0; i < nobj; i++) // p4.0.21
{
if(gw[i].type == GuiWidgets::DOUBLE_LABEL && gw[i].param == parameter)
@@ -3633,7 +3280,6 @@ PluginGui::PluginGui(MusECore::PluginIBase* p)
else if (strcmp(obj->metaObject()->className(), "MusEGui::DoubleLabel") == 0) {
gw[nobj].type = GuiWidgets::DOUBLE_LABEL;
((DoubleLabel*)obj)->setId(nobj);
- //for(int i = 0; i < nobj; i++)
for(unsigned long i = 0; i < nobj; i++)
{
if(gw[i].type == GuiWidgets::SLIDER && gw[i].param == parameter)
@@ -3674,15 +3320,12 @@ PluginGui::PluginGui(MusECore::PluginIBase* p)
mw->setSizePolicy(QSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding));
- //int n = plugin->parameters();
unsigned long n = plugin->parameters(); // p4.0.21
params = new GuiParam[n];
- //int style = Slider::BgTrough | Slider::BgSlot;
QFontMetrics fm = fontMetrics();
int h = fm.height() + 4;
- //for (int i = 0; i < n; ++i) {
for (unsigned long i = 0; i < n; ++i) { // p4.0.21
QLabel* label = 0;
LADSPA_PortRangeHint range = plugin->range(i);
@@ -3698,7 +3341,7 @@ PluginGui::PluginGui(MusECore::PluginIBase* p)
if (LADSPA_IS_HINT_TOGGLED(range.HintDescriptor)) {
params[i].type = GuiParam::GUI_SWITCH;
- CheckBox* cb = new CheckBox(mw, i, "param");
+ CheckBox* cb = new CheckBox(mw, i, "param");
cb->setId(i);
cb->setText(QString(plugin->paramName(i)));
cb->setChecked(plugin->param(i) != 0.0);
@@ -3734,20 +3377,15 @@ PluginGui::PluginGui(MusECore::PluginIBase* p)
params[i].actuator = s;
params[i].label->setSlider((Slider*)params[i].actuator);
}
- //params[i].actuator->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Maximum));
params[i].actuator->setSizePolicy(QSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed));
if (params[i].type == GuiParam::GUI_SLIDER) {
- //label->setFixedHeight(20);
- //label->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Maximum));
label->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed));
- //params[i].label->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Maximum));
params[i].label->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed));
grid->addWidget(label, i, 0);
grid->addWidget(params[i].label, i, 1);
grid->addWidget(params[i].actuator, i, 2);
}
else if (params[i].type == GuiParam::GUI_SWITCH) {
- //grid->addMultiCellWidget(params[i].actuator, i, i, 0, 2);
grid->addWidget(params[i].actuator, i, 0, 1, 3);
}
if (params[i].type == GuiParam::GUI_SLIDER) {
@@ -3793,20 +3431,16 @@ PluginGui::PluginGui(MusECore::PluginIBase* p)
if(LADSPA_IS_HINT_INTEGER(range.HintDescriptor))
mType=Meter::DBMeter;
VerticalMeter* m = new VerticalMeter(this, mType);
- //printf("lower =%f upper=%f dlower=%f dupper=%f\n", lower, upper,dlower,dupper);
m->setRange(dlower, dupper);
m->setVal(dval);
m->setFixedHeight(h);
paramsOut[i].actuator = m;
-// paramsOut[i].label->setSlider((Slider*)params[i].actuator);
- //paramsOut[i].actuator->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed));
label->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed));
paramsOut[i].label->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed));
grid->addWidget(label, n+i, 0);
grid->addWidget(paramsOut[i].label, n+i, 1);
grid->addWidget(paramsOut[i].actuator, n+i, 2);
-// connect(paramsOut[i].label, SIGNAL(valueChanged(double,int)), SLOT(labelChanged(double,int)));
}
}
@@ -3897,14 +3531,8 @@ void PluginGui::ctrlPressed(int param)
plugin->setParam(param, val);
((DoubleLabel*)params[param].label)->setValue(val);
- // p3.3.43
- //MusEGlobal::audio->msgSetPluginCtrlVal(((PluginI*)plugin), id, val);
-
if(track)
{
- // p3.3.43
- //MusEGlobal::audio->msgSetPluginCtrlVal(track, id, val);
- // p4.0.21 MusEGlobal::audio->msgXXX waits. Do we really need to?
track->setPluginCtrlVal(id, val);
MusEGlobal::song->controllerChange(track);
@@ -3913,18 +3541,11 @@ void PluginGui::ctrlPressed(int param)
}
else if(params[param].type == GuiParam::GUI_SWITCH)
{
- //double val = (double)((CheckBox*)params[param].actuator)->isChecked();
float val = (float)((CheckBox*)params[param].actuator)->isChecked(); // p4.0.21
plugin->setParam(param, val);
- // p3.3.43
- //MusEGlobal::audio->msgSetPluginCtrlVal(((PluginI*)plugin), id, val);
-
if(track)
{
- // p3.3.43
- //MusEGlobal::audio->msgSetPluginCtrlVal(track, id, val);
- // p4.0.21 MusEGlobal::audio->msgXXX waits. Do we really need to?
track->setPluginCtrlVal(id, val);
MusEGlobal::song->controllerChange(track);
@@ -3964,12 +3585,6 @@ void PluginGui::ctrlReleased(int param)
val = rint(val);
track->stopAutoRecord(id, val);
}
- //else if(params[param].type == GuiParam::GUI_SWITCH)
- //{
- //double val = (double)((CheckBox*)params[param].actuator)->isChecked();
- // No concept of 'untouching' a checkbox. Remain 'touched' until stop.
- //plugin->track()->stopAutoRecord(MusECore::genACnum(plugin->id(), param), val);
- //}
}
//---------------------------------------------------------
@@ -3980,7 +3595,6 @@ void PluginGui::ctrlRightClicked(const QPoint &p, int param)
{
int id = plugin->id();
if(id != -1)
- //MusEGlobal::song->execAutomationCtlPopup((MusECore::AudioTrack*)plugin->track(), p, MusECore::genACnum(id, param));
MusEGlobal::song->execAutomationCtlPopup(plugin->track(), p, MusECore::genACnum(id, param));
}
@@ -4012,14 +3626,8 @@ void PluginGui::sliderChanged(double val, int param)
return;
id = MusECore::genACnum(id, param);
- // p3.3.43
- //MusEGlobal::audio->msgSetPluginCtrlVal(((PluginI*)plugin), id, val);
-
if(track)
{
- // p3.3.43
- //MusEGlobal::audio->msgSetPluginCtrlVal(track, id, val);
- // p4.0.21 MusEGlobal::audio->msgXXX waits. Do we really need to?
track->setPluginCtrlVal(id, val);
MusEGlobal::song->controllerChange(track);
@@ -4057,14 +3665,8 @@ void PluginGui::labelChanged(double val, int param)
id = MusECore::genACnum(id, param);
- // p3.3.43
- //MusEGlobal::audio->msgSetPluginCtrlVal(((PluginI*)plugin), id, val);
-
if(track)
{
- // p3.3.43
- //MusEGlobal::audio->msgSetPluginCtrlVal(track, id, val);
- // p4.0.21 MusEGlobal::audio->msgXXX waits. Do we really need to?
track->setPluginCtrlVal(id, val);
MusEGlobal::song->controllerChange(track);
@@ -4079,7 +3681,6 @@ void PluginGui::labelChanged(double val, int param)
void PluginGui::load()
{
QString s("presets/plugins/");
- //s += plugin->plugin()->label();
s += plugin->pluginLabel();
s += "/";
@@ -4144,11 +3745,9 @@ ende:
void PluginGui::save()
{
QString s("presets/plugins/");
- //s += plugin->plugin()->label();
s += plugin->pluginLabel();
s += "/";
- //QString fn = getSaveFileName(s, MusEGlobal::preset_file_pattern, this,
QString fn = getSaveFileName(s, MusEGlobal::preset_file_save_pattern, this,
tr("MusE: save preset"));
if (fn.isEmpty())
@@ -4199,7 +3798,6 @@ void PluginGui::setOn(bool val)
void PluginGui::updateValues()
{
if (params) {
- //for (int i = 0; i < plugin->parameters(); ++i) {
for (unsigned long i = 0; i < plugin->parameters(); ++i) { // p4.0.21
GuiParam* gp = &params[i];
if (gp->type == GuiParam::GUI_SLIDER) {
@@ -4221,12 +3819,9 @@ void PluginGui::updateValues()
}
}
else if (gw) {
- //for (int i = 0; i < nobj; ++i) {
for (unsigned long i = 0; i < nobj; ++i) { // p4.0.21
QWidget* widget = gw[i].widget;
int type = gw[i].type;
- //int param = gw[i].param;
- //double val = plugin->param(param);
unsigned long param = gw[i].param; // p4.0.21
float val = plugin->param(param);
switch(type) {
@@ -4279,13 +3874,7 @@ void PluginGui::updateControls()
}
- //if(!MusEGlobal::automation)
- // return;
- //AutomationType at = plugin->track()->automationType();
- //if(at == AUTO_OFF)
- // return;
if (params) {
- //for (int i = 0; i < plugin->parameters(); ++i) {
for (unsigned long i = 0; i < plugin->parameters(); ++i) { // p4.0.21
GuiParam* gp = &params[i];
if (gp->type == GuiParam::GUI_SLIDER) {
@@ -4303,8 +3892,6 @@ void PluginGui::updateControls()
}
if(((Slider*)(gp->actuator))->value() != sv)
{
- //printf("PluginGui::updateControls slider\n");
-
gp->label->blockSignals(true);
((Slider*)(gp->actuator))->blockSignals(true);
((Slider*)(gp->actuator))->setValue(sv);
@@ -4321,8 +3908,6 @@ void PluginGui::updateControls()
bool v = (int)plugin->track()->pluginCtrlVal(MusECore::genACnum(plugin->id(), i));
if(((CheckBox*)(gp->actuator))->isChecked() != v)
{
- //printf("PluginGui::updateControls switch\n");
-
((CheckBox*)(gp->actuator))->blockSignals(true);
((CheckBox*)(gp->actuator))->setChecked(v);
((CheckBox*)(gp->actuator))->blockSignals(false);
@@ -4332,11 +3917,9 @@ void PluginGui::updateControls()
}
}
else if (gw) {
- //for (int i = 0; i < nobj; ++i) {
for (unsigned long i = 0; i < nobj; ++i) { // p4.0.21
QWidget* widget = gw[i].widget;
int type = gw[i].type;
- //int param = gw[i].param;
unsigned long param = gw[i].param; // p4.0.21
switch(type) {
case GuiWidgets::SLIDER:
@@ -4345,8 +3928,6 @@ void PluginGui::updateControls()
double v = plugin->track()->pluginCtrlVal(MusECore::genACnum(plugin->id(), param));
if(((Slider*)widget)->value() != v)
{
- //printf("PluginGui::updateControls slider\n");
-
((Slider*)widget)->blockSignals(true);
((Slider*)widget)->setValue(v);
((Slider*)widget)->blockSignals(false);
@@ -4359,8 +3940,6 @@ void PluginGui::updateControls()
double v = plugin->track()->pluginCtrlVal(MusECore::genACnum(plugin->id(), param));
if(((DoubleLabel*)widget)->value() != v)
{
- //printf("PluginGui::updateControls label\n");
-
((DoubleLabel*)widget)->blockSignals(true);
((DoubleLabel*)widget)->setValue(v);
((DoubleLabel*)widget)->blockSignals(false);
@@ -4373,8 +3952,6 @@ void PluginGui::updateControls()
bool b = (bool) plugin->track()->pluginCtrlVal(MusECore::genACnum(plugin->id(), param));
if(((QCheckBox*)widget)->isChecked() != b)
{
- //printf("PluginGui::updateControls checkbox\n");
-
((QCheckBox*)widget)->blockSignals(true);
((QCheckBox*)widget)->setChecked(b);
((QCheckBox*)widget)->blockSignals(false);
@@ -4387,8 +3964,6 @@ void PluginGui::updateControls()
int n = (int) plugin->track()->pluginCtrlVal(MusECore::genACnum(plugin->id(), param));
if(((QComboBox*)widget)->currentIndex() != n)
{
- //printf("PluginGui::updateControls combobox\n");
-
((QComboBox*)widget)->blockSignals(true);
((QComboBox*)widget)->setCurrentIndex(n);
((QComboBox*)widget)->blockSignals(false);
@@ -4407,7 +3982,6 @@ void PluginGui::updateControls()
void PluginGui::guiParamChanged(int idx)
{
QWidget* w = gw[idx].widget;
- //int param = gw[idx].param;
unsigned long param = gw[idx].param; // p4.0.21
int type = gw[idx].type;
@@ -4435,7 +4009,6 @@ void PluginGui::guiParamChanged(int idx)
break;
}
- //for (int i = 0; i < nobj; ++i) {
for (unsigned long i = 0; i < nobj; ++i) { // p4.0.21
QWidget* widget = gw[i].widget;
if (widget == w || param != gw[i].param)
@@ -4462,28 +4035,19 @@ void PluginGui::guiParamChanged(int idx)
{
id = MusECore::genACnum(id, param);
- // p3.3.43
- //MusEGlobal::audio->msgSetPluginCtrlVal(((PluginI*)plugin), id, val);
+ track->setPluginCtrlVal(id, val);
+ MusEGlobal::song->controllerChange(track);
- //if(track)
- //{
- // p3.3.43
- //MusEGlobal::audio->msgSetPluginCtrlVal(track, id, val);
- // p4.0.21 MusEGlobal::audio->msgXXX waits. Do we really need to?
- track->setPluginCtrlVal(id, val);
- MusEGlobal::song->controllerChange(track);
-
- switch(type)
- {
- case GuiWidgets::DOUBLE_LABEL:
- case GuiWidgets::QCHECKBOX:
- track->startAutoRecord(id, val);
- break;
- default:
- track->recordAutomation(id, val);
- break;
- }
- //}
+ switch(type)
+ {
+ case GuiWidgets::DOUBLE_LABEL:
+ case GuiWidgets::QCHECKBOX:
+ track->startAutoRecord(id, val);
+ break;
+ default:
+ track->recordAutomation(id, val);
+ break;
+ }
}
plugin->setParam(param, val);
}
@@ -4494,7 +4058,6 @@ void PluginGui::guiParamChanged(int idx)
void PluginGui::guiParamPressed(int idx)
{
- //int param = gw[idx].param;
unsigned long param = gw[idx].param; // p4.0.21
AutomationType at = AUTO_OFF;
@@ -4515,7 +4078,7 @@ void PluginGui::guiParamPressed(int idx)
// would have to be used, and changed to use CheckBox and ComboBox
// instead of QCheckBox and QComboBox, since both of those would
// need customization (Ex. QCheckBox doesn't check on click).
- /*
+ /* DELETETHIS 10 plus above
switch(type) {
case GuiWidgets::QCHECKBOX:
double val = (double)((CheckBox*)w)->isChecked();
@@ -4535,7 +4098,6 @@ void PluginGui::guiParamPressed(int idx)
void PluginGui::guiParamReleased(int idx)
{
- //int param = gw[idx].param;
unsigned long param = gw[idx].param; // p4.0.21
int type = gw[idx].type;
@@ -4561,7 +4123,7 @@ void PluginGui::guiParamReleased(int idx)
// would have to be used, and changed to use CheckBox and ComboBox
// instead of QCheckBox and QComboBox, since both of those would
// need customization (Ex. QCheckBox doesn't check on click).
- /*
+ /* DELETETHIS 10 plus above
switch(type) {
case GuiWidgets::QCHECKBOX:
double val = (double)((CheckBox*)w)->isChecked();
@@ -4581,7 +4143,6 @@ void PluginGui::guiParamReleased(int idx)
void PluginGui::guiSliderPressed(int idx)
{
- //int param = gw[idx].param;
unsigned long param = gw[idx].param; // p4.0.21
QWidget *w = gw[idx].widget;
@@ -4603,17 +4164,12 @@ void PluginGui::guiSliderPressed(int idx)
double val = ((Slider*)w)->value();
plugin->setParam(param, val);
- //MusEGlobal::audio->msgSetPluginCtrlVal(((PluginI*)plugin), id, val);
- // p3.3.43
- //MusEGlobal::audio->msgSetPluginCtrlVal(track, id, val);
- // p4.0.21 MusEGlobal::audio->msgXXX waits. Do we really need to?
track->setPluginCtrlVal(id, val);
MusEGlobal::song->controllerChange(track);
track->startAutoRecord(id, val);
// Needed so that paging a slider updates a label or other buddy control.
- //for (int i = 0; i < nobj; ++i) {
for (unsigned long i = 0; i < nobj; ++i) { // p4.0.21
QWidget* widget = gw[i].widget;
if (widget == w || param != gw[i].param)
@@ -4673,7 +4229,6 @@ void PluginGui::guiSliderRightClicked(const QPoint &p, int idx)
int param = gw[idx].param;
int id = plugin->id();
if(id != -1)
- //MusEGlobal::song->execAutomationCtlPopup((MusECore::AudioTrack*)plugin->track(), p, MusECore::genACnum(id, param));
MusEGlobal::song->execAutomationCtlPopup(plugin->track(), p, MusECore::genACnum(id, param));
}
diff --git a/muse2/muse/plugin.h b/muse2/muse/plugin.h
index 719db108..81c41396 100644
--- a/muse2/muse/plugin.h
+++ b/muse2/muse/plugin.h
@@ -40,12 +40,9 @@
#include "ctrl.h"
#include "controlfifo.h"
-//#include "stringparam.h"
-
#include "config.h"
#ifdef OSC_SUPPORT
-//class OscIF;
#include "osc.h"
#endif
@@ -103,7 +100,6 @@ class Plugin {
const DSSI_Descriptor* dssi_descr;
#endif
- //LADSPA_PortDescriptor* _portDescriptors;
unsigned long _portCount;
unsigned long _inports;
unsigned long _outports;
@@ -122,7 +118,7 @@ class Plugin {
unsigned long id() const { return _uniqueID; }
QString maker() const { return _maker; }
QString copyright() const { return _copyright; }
- QString lib(bool complete = true) /*const*/ { return complete ? fi.completeBaseName() : fi.baseName(); } // ddskrjo const
+ QString lib(bool complete = true) { return complete ? fi.completeBaseName() : fi.baseName(); } // ddskrjo const
QString dirPath(bool complete = true) const { return complete ? fi.absolutePath() : fi.path(); }
QString filePath() const { return fi.filePath(); }
QString fileName() const { return fi.fileName(); }
@@ -155,7 +151,7 @@ class Plugin {
}
#ifdef OSC_SUPPORT
- int oscConfigure(LADSPA_Handle /*handle*/, const char* /*key*/, const char* /*value*/);
+ int oscConfigure(LADSPA_Handle handle, const char* key, const char* value);
#endif
unsigned long ports() { return _portCount; }
@@ -166,22 +162,19 @@ class Plugin {
LADSPA_PortRangeHint range(unsigned long i) {
// FIXME:
- //return plugin ? plugin->PortRangeHints[i] : 0;
+ //return plugin ? plugin->PortRangeHints[i] : 0; DELETETHIS
return plugin->PortRangeHints[i];
}
float defaultValue(unsigned long port) const;
void range(unsigned long i, float*, float*) const;
- CtrlValueType ctrlValueType(unsigned long /*i*/) const;
- CtrlList::Mode ctrlMode(unsigned long /*i*/) const;
+ CtrlValueType ctrlValueType(unsigned long i) const;
+ CtrlList::Mode ctrlMode(unsigned long i) const;
const char* portName(unsigned long i) {
return plugin ? plugin->PortNames[i] : 0;
}
- // Returns (int)-1 if not an input control.
- //unsigned long port2InCtrl(unsigned long p) { return p >= rpIdx.size() ? (unsigned long)-1 : rpIdx[p]; }
-
unsigned long inports() const { return _inports; }
unsigned long outports() const { return _outports; }
unsigned long controlInPorts() const { return _controlInPorts; }
@@ -211,7 +204,6 @@ class PluginList : public std::list<Plugin> {
//---------------------------------------------------------
struct Port {
- //int idx;
unsigned long idx;
float val;
float tmpVal;
@@ -236,7 +228,7 @@ class PluginIBase
PluginIBase();
~PluginIBase();
virtual bool on() const = 0;
- virtual void setOn(bool /*val*/) = 0;
+ virtual void setOn(bool val) = 0;
virtual unsigned long pluginID() = 0;
virtual int id() = 0;
virtual QString pluginLabel() const = 0;
@@ -248,33 +240,33 @@ class PluginIBase
virtual AudioTrack* track() = 0;
- virtual void enableController(unsigned long /*i*/, bool /*v*/ = true) = 0;
- virtual bool controllerEnabled(unsigned long /*i*/) const = 0;
- virtual bool controllerEnabled2(unsigned long /*i*/) const = 0;
+ virtual void enableController(unsigned long i, bool v = true) = 0;
+ virtual bool controllerEnabled(unsigned long i) const = 0;
+ virtual bool controllerEnabled2(unsigned long i) const = 0;
virtual void updateControllers() = 0;
- virtual void writeConfiguration(int /*level*/, Xml& /*xml*/) = 0;
- virtual bool readConfiguration(Xml& /*xml*/, bool /*readPreset*/=false) = 0;
+ virtual void writeConfiguration(int level, Xml& xml) = 0;
+ virtual bool readConfiguration(Xml& xml, bool readPreset=false) = 0;
virtual unsigned long parameters() const = 0;
virtual unsigned long parametersOut() const = 0;
- virtual void setParam(unsigned long /*i*/, float /*val*/) = 0;
- virtual float param(unsigned long /*i*/) const = 0;
- virtual float paramOut(unsigned long /*i*/) const = 0;
- virtual const char* paramName(unsigned long /*i*/) = 0;
- virtual const char* paramOutName(unsigned long /*i*/) = 0;
- virtual LADSPA_PortRangeHint range(unsigned long /*i*/) = 0;
- virtual LADSPA_PortRangeHint rangeOut(unsigned long /*i*/) = 0;
-
- virtual CtrlValueType ctrlValueType(unsigned long /*i*/) const = 0;
- virtual CtrlList::Mode ctrlMode(unsigned long /*i*/) const = 0;
+ virtual void setParam(unsigned long i, float val) = 0;
+ virtual float param(unsigned long i) const = 0;
+ virtual float paramOut(unsigned long i) const = 0;
+ virtual const char* paramName(unsigned long i) = 0;
+ virtual const char* paramOutName(unsigned long i) = 0;
+ virtual LADSPA_PortRangeHint range(unsigned long i) = 0;
+ virtual LADSPA_PortRangeHint rangeOut(unsigned long i) = 0;
+
+ virtual CtrlValueType ctrlValueType(unsigned long i) const = 0;
+ virtual CtrlList::Mode ctrlMode(unsigned long i) const = 0;
QString dssi_ui_filename() const;
MusEGui::PluginGui* gui() const { return _gui; }
void deleteGui();
};
-/*
+/* DELETETHIS 30
class PluginBase
{
public:
@@ -328,23 +320,17 @@ class PluginI : public PluginIBase {
unsigned long controlPorts;
unsigned long controlOutPorts;
- ///PluginGui* _gui;
bool _on;
bool initControlValues;
QString _name;
QString _label;
- //#ifdef DSSI_SUPPORT
- //StringParamMap _stringParamMap;
- //#endif
-
#ifdef OSC_SUPPORT
OscEffectIF _oscif;
#endif
bool _showNativeGuiPending;
void init();
- ///void makeGui();
public:
PluginI();
@@ -353,8 +339,6 @@ class PluginI : public PluginIBase {
Plugin* plugin() const { return _plugin; }
bool on() const { return _on; }
void setOn(bool val) { _on = val; }
- ///PluginGui* gui() const { return _gui; }
- ///void deleteGui();
void setTrack(AudioTrack* t) { _track = t; }
AudioTrack* track() { return _track; }
@@ -387,17 +371,10 @@ class PluginI : public PluginIBase {
#ifdef OSC_SUPPORT
OscEffectIF& oscIF() { return _oscif; }
- /*
- int oscConfigure(lo_arg**);
- int oscControl(lo_arg**);
- //int oscUpdate(lo_arg**);
- //int oscExiting(lo_arg**);
- */
-
- int oscControl(unsigned long /*dssiPort*/, float /*val*/);
- int oscConfigure(const char */*key*/, const char */*val*/);
+
+ int oscControl(unsigned long dssiPort, float val);
+ int oscConfigure(const char *key, const char *val);
int oscUpdate();
- //int oscExiting();
#endif
void writeConfiguration(int level, Xml& xml);
@@ -453,7 +430,6 @@ class Pipeline : public std::vector<PluginI*> {
QString name(int idx) const;
void showGui(int, bool);
bool isDssiPlugin(int) const;
- //QString dssi_ui_filename(int) const;
bool has_dssi_ui(int idx) const;
void showNativeGui(int, bool);
void deleteGui(int idx);
@@ -477,7 +453,6 @@ extern bool ladspa2MidiControlValues(const LADSPA_Descriptor* plugin, unsigned l
extern float midi2LadspaValue(const LADSPA_Descriptor* plugin, unsigned long port, int ctlnum, int val);
extern CtrlValueType ladspaCtrlValueType(const LADSPA_Descriptor* plugin, int port);
extern CtrlList::Mode ladspaCtrlMode(const LADSPA_Descriptor* plugin, int port);
-//extern MidiController* ladspa2MidiController(const LADSPA_Descriptor* plugin, unsigned long port, int ctlnum);
} // namespace MusECore
@@ -599,8 +574,6 @@ class PluginDialog : public QDialog {
void accept();
void reject();
void fillPlugs(QAbstractButton*);
- //void fillPlugs(int i);
- //void fillPlugs(const QString& sortValue);
void fillPlugs();
private slots:
@@ -610,8 +583,6 @@ class PluginDialog : public QDialog {
QComboBox *sortBox;
static int selectedPlugType;
static QStringList sortItems;
- //static int sortColumn;
- //static Qt::SortOrder sortOrder;
static QRect geometrySave;
static QByteArray listSave;
};
diff --git a/muse2/muse/pos.cpp b/muse2/muse/pos.cpp
index 70de99e1..efa847cc 100644
--- a/muse2/muse/pos.cpp
+++ b/muse2/muse/pos.cpp
@@ -458,8 +458,7 @@ void PosLen::setLenTick(unsigned len)
{
_lenTick = len;
sn = -1;
-// if (type() == FRAMES)
- _lenFrame = MusEGlobal::tempomap.deltaTick2frame(tick(), tick() + len, &sn);
+ _lenFrame = MusEGlobal::tempomap.deltaTick2frame(tick(), tick() + len, &sn);
}
//---------------------------------------------------------
@@ -470,8 +469,7 @@ void PosLen::setLenFrame(unsigned len)
{
_lenFrame = len;
sn = -1;
-// if (type() == TICKS)
- _lenTick = MusEGlobal::tempomap.deltaFrame2tick(frame(), frame() + len, &sn);
+ _lenTick = MusEGlobal::tempomap.deltaFrame2tick(frame(), frame() + len, &sn);
}
//---------------------------------------------------------
diff --git a/muse2/muse/remote/pyapi.cpp b/muse2/muse/remote/pyapi.cpp
index 90818a44..2a10afa4 100644
--- a/muse2/muse/remote/pyapi.cpp
+++ b/muse2/muse/remote/pyapi.cpp
@@ -1130,11 +1130,12 @@ bool Song::event(QEvent* _e)
pipeline->setOn(fxid, onoff);
break;
}
- case QPybridgeEvent::SONG_ADD_TRACK:
+ case QPybridgeEvent::SONG_ADD_TRACK: {
MusECore::Undo operations;
MusEGlobal::song->addTrack(operations, (Track::TrackType)e->getP1()); // Add at end of list.
MusEGlobal::song->applyOperationGroup(operations);
break;
+ }
case QPybridgeEvent::SONG_CHANGE_TRACKNAME: {
Track* t = this->findTrack(e->getS1());
if (t == NULL)
diff --git a/muse2/muse/route.cpp b/muse2/muse/route.cpp
index 1d494fb0..18672159 100644
--- a/muse2/muse/route.cpp
+++ b/muse2/muse/route.cpp
@@ -173,9 +173,7 @@ void addRoute(Route src, Route dst)
{
if (*i == src) // route already there
{
- //#ifdef ROUTE_DEBUG
fprintf(stderr, "addRoute: src track route already exists.\n");
- //#endif
return;
}
}
@@ -195,9 +193,7 @@ void addRoute(Route src, Route dst)
{
if (*i == src) // route already there
{
- //#ifdef ROUTE_DEBUG
fprintf(stderr, "addRoute: src Jack midi route already exists.\n");
- //#endif
return;
}
}
@@ -262,9 +258,7 @@ void addRoute(Route src, Route dst)
{
if (*i == dst) // route already there
{
- //#ifdef ROUTE_DEBUG
fprintf(stderr, "addRoute: dst Jack midi route already exists.\n");
- //#endif
return;
}
}
@@ -295,13 +289,7 @@ void addRoute(Route src, Route dst)
MidiPort *mp = &MusEGlobal::midiPorts[src.midiPort];
- // Do not allow ports with synth midi devices to connect to audio ins! p4.0.17
- //if(dst.track->type() == Track::AUDIO_INPUT && mp->device() && mp->device()->isSynti())
- //{
- // fprintf(stderr, "addRoute: destination is audio in, but source midi port:%d is synth device\n", src.midiPort);
- // return;
- //}
- // Actually, do not allow synth ports to connect to any track. It may be useful in some cases,
+ // Do not allow synth ports to connect to any track. It may be useful in some cases,
// may be desired later, but for now it's just a routing hassle. p4.0.35
if(mp->device() && mp->device()->isSynti())
return;
@@ -311,14 +299,7 @@ void addRoute(Route src, Route dst)
fprintf(stderr, "addRoute: source is midi port:%d, but destination channel mask:%d out of range\n", src.midiPort, dst.channel);
return;
}
-
- //MidiDevice *md = MusEGlobal::midiPorts[src.midiPort].device();
- //if(!md)
- //{
- // fprintf(stderr, "addRoute: source is midi port, but no destination port device\n");
- // return;
- //}
-
+
src.channel = dst.channel;
RouteList* outRoutes = mp->outRoutes();
iRoute ir = outRoutes->begin();
@@ -366,13 +347,6 @@ void addRoute(Route src, Route dst)
return;
}
- //MidiDevice *md = MusEGlobal::midiPorts[dst.midiPort].device();
- //if(!md)
- //{
- // fprintf(stderr, "addRoute: dst is midi port, but no destination port device\n");
- // return;
- //}
-
dst.channel = src.channel;
RouteList* outRoutes = src.track->outRoutes();
@@ -437,7 +411,7 @@ void addRoute(Route src, Route dst)
for (ciRoute i = outRoutes->begin(); i != outRoutes->end(); ++i)
{
if (*i == dst) // route already there
- // TODO:
+ // TODO: DELETETHIS all these comments wtf?
//if (i->type == dst.type && i->channel == dst.channel)
{
//if(i->type == Route::TRACK_ROUTE)
@@ -463,29 +437,23 @@ void addRoute(Route src, Route dst)
RouteList* inRoutes;
#ifdef ROUTE_DEBUG
- //fprintf(stderr, "addRoute: src track ch:%d chs:%d dst track ch:%d chs:%d name: %s pushing destination and source routes\n", src.channel, src.channels, dst.channel, dst.channels, dst.track->name().toLatin1().constData());
fprintf(stderr, "addRoute: src track ch:%d chs:%d remch:%d dst track ch:%d chs:%d remch:%d name: %s pushing dest and source routes\n",
src.channel, src.channels, src.remoteChannel, dst.channel, dst.channels, dst.remoteChannel, dst.track->name().toLatin1().constData());
- //fprintf(stderr, "addRoute: src track ch:%d dst track ch:%d name: %s pushing destination and source routes\n", src.channel, dst.channel, dst.track->name().toLatin1().constData());
#endif
inRoutes = dst.track->inRoutes();
- //
// make sure AUDIO_AUX is processed last
- //
if (src.track->type() == Track::AUDIO_AUX) // REMOVE Tim. This special aux code may not be useful or needed now.
- inRoutes->push_back(src); //
+ inRoutes->push_back(src); // so DELETETHIS?
else
inRoutes->insert(inRoutes->begin(), src);
// Is the source an Aux Track or else does it have Aux Tracks routed to it?
// Update the destination track's aux ref count, and all tracks it is routed to.
if(src.track->auxRefCount())
- //dst.track->updateAuxStates( src.track->auxRefCount() );
src.track->updateAuxRoute( src.track->auxRefCount(), dst.track );
else
if(src.track->type() == Track::AUDIO_AUX)
- //dst.track->updateAuxStates( 1 );
src.track->updateAuxRoute( 1, dst.track );
}
}
@@ -496,10 +464,6 @@ void addRoute(Route src, Route dst)
void removeRoute(Route src, Route dst)
{
- //printf("removeRoute %d.%d:<%s> %d.%d:<%s>\n",
- // src.type, src.channel, src.name().toLatin1().constData(),
- // dst.type, dst.channel, dst.name().toLatin1().constData());
-
if (src.type == Route::JACK_ROUTE)
{
if(!dst.isValid())
@@ -701,11 +665,9 @@ void removeRoute(Route src, Route dst)
if(src.isValid() && dst.isValid())
{
if(src.track->auxRefCount())
- //dst.track->updateAuxStates( -src.track->auxRefCount() );
src.track->updateAuxRoute( -src.track->auxRefCount(), dst.track );
else
if(src.track->type() == Track::AUDIO_AUX)
- //dst.track->updateAuxStates( -1 );
src.track->updateAuxRoute( -1, dst.track );
}
@@ -755,7 +717,7 @@ void removeAllRoutes(Route src, Route dst)
{
// TODO: Is the source an Aux Track or else does it have Aux Tracks routed to it?
// Update the destination track's aux ref count, and all tracks it is routed to.
- /* if(src.isValid() && dst.isValid())
+ /* if(src.isValid() && dst.isValid()) DELETETHIS 8
{
if(src.track->auxRefCount())
dst.track->updateAuxStates( -src.track->auxRefCount() );
@@ -804,6 +766,7 @@ QString Route::name() const
{
if(device)
{
+ // DELETETHIS 6
// For unified jack in/out devices, the actual port names are now different from device name.
// Like this: device: "MyJackDevice1" -> inport: "MyJackDevice1_in" outport: "MyJackDevice1_out"
/*
@@ -835,10 +798,8 @@ QString Route::name() const
// name2route
//---------------------------------------------------------
-//Route name2route(const QString& rn, bool dst)
Route name2route(const QString& rn, bool /*dst*/, int rtype)
{
-// printf("name2route %s\n", rn.toLatin1().constData());
int channel = -1;
QString s(rn);
// Support old route style in med files. Obsolete.
@@ -919,7 +880,7 @@ Route name2route(const QString& rn, bool /*dst*/, int rtype)
if((*i)->name() == s)
return Route(*i, channel);
- /*
+ /* DELETETHIS 16?
MidiJackDevice* jmd = dynamic_cast<MidiJackDevice*>(*i);
if(jmd)
{
@@ -1049,9 +1010,6 @@ bool checkRoute(const QString& s, const QString& d)
}
}
}
- //else if (dst.type == Route::MIDI_PORT_ROUTE)
- //{
- //}
else
{
RouteList* outRoutes = (src.type == Route::MIDI_DEVICE_ROUTE) ? src.device->outRoutes() : src.track->outRoutes();
@@ -1086,9 +1044,6 @@ void Route::read(Xml& xml)
case Xml::Error:
case Xml::End:
return;
- //case Xml::TagStart:
- // xml.unknown("Route");
- // break;
case Xml::Attribut:
#ifdef ROUTE_DEBUG
printf("Route::read(): attribute:%s\n", tag.toLatin1().constData());
@@ -1310,7 +1265,6 @@ void Song::readRoute(Xml& xml)
}
else
{
- //printf("adding new route...\n");
addRoute(sroute, droute);
}
}
@@ -1331,12 +1285,7 @@ void Song::readRoute(Xml& xml)
void RouteList::removeRoute(const Route& r)
{
- //printf("RouteList::removeRoute:\n");
- //r.dump();
- //printf("Searching routes:\n");
-
for (iRoute i = begin(); i != end(); ++i) {
- //i->dump();
if (r == *i) {
erase(i);
return;
@@ -1355,9 +1304,6 @@ void Route::dump() const
{
if(track)
printf("Route dump: track <%s> channel %d channels %d\n", track->name().toLatin1().constData(), channel, channels);
- //printf("Route dump: track <%s> channel %d\n", track->name().toLatin1().constData(), channel);
- //else
- // printf("Route dump: invalid track, channel %d\n", channel);
}
else
if (type == JACK_ROUTE)
@@ -1413,16 +1359,7 @@ void Route::dump() const
bool Route::operator==(const Route& a) const
{
- //if (type == MIDI_PORT_ROUTE) // p3.3.50
- //{
- // Use new channel mask. True if all the bits in a.channel are contained in this route's channel.
- // Hmm, not commutative... Two such routes are equal if _____ what? ... Code-specific for now.
- // return midiPort == a.midiPort && (channel & a.channel) == a.channel;
- //}
- //else
-
if ((type == a.type) && (channel == a.channel))
- //if (type == a.type)
{
if (type == TRACK_ROUTE)
{
@@ -1433,8 +1370,8 @@ bool Route::operator==(const Route& a) const
{
if (type == JACK_ROUTE)
{
- //if (!MusEGlobal::checkAudioDevice()) return false;
- //return MusEGlobal::audioDevice->portName(jackPort) == MusEGlobal::audioDevice->portName(a.jackPort);
+ //if (!MusEGlobal::checkAudioDevice()) return false; DELETETHIS? or keep?
+ //else return MusEGlobal::audioDevice->portName(jackPort) == MusEGlobal::audioDevice->portName(a.jackPort);
return jackPort == a.jackPort; // Simplified.
}
else
@@ -1452,7 +1389,7 @@ bool Route::operator==(const Route& a) const
return false;
}
-/*
+/* yaaaay, depth search. just wrote an exam about that. but DELETETHIS, looks unused
//---------------------------------------------------------
// isCircularRoute
// Recursive.
@@ -1462,10 +1399,6 @@ bool Route::operator==(const Route& a) const
bool isCircularRoutePath(Track* src, Track* dst)
{
- //if(isMidiTrack() || _type == AUDIO_AUX)
- //if(isMidiTrack())
- // return;
-
bool rv = false;
if(dst)
@@ -1473,8 +1406,6 @@ bool isCircularRoutePath(Track* src, Track* dst)
src->setNodeTraversed(true);
rv = isCircularRoutePath(dst, NULL);
src->setNodeTraversed(false);
- //if(rv)
- // fprintf(stderr, " Circular route %s -> %s\n", src->name().toLatin1().constData(), dst->name().toLatin1().constData());
return rv;
}
@@ -1483,8 +1414,6 @@ bool isCircularRoutePath(Track* src, Track* dst)
src->setNodeTraversed(true);
- //printf("isCircularRoute %s\n", src->name().toLatin1().constData());
-
RouteList* orl = src->outRoutes();
for (iRoute i = orl->begin(); i != orl->end(); ++i)
{
diff --git a/muse2/muse/route.h b/muse2/muse/route.h
index 587369bc..a0c433f1 100644
--- a/muse2/muse/route.h
+++ b/muse2/muse/route.h
@@ -105,17 +105,7 @@ extern void removeRoute(Route, Route);
extern void removeAllRoutes(Route, Route); // p3.3.55
extern Route name2route(const QString&, bool dst, int rtype = -1);
extern bool checkRoute(const QString&, const QString&);
-//extern bool isCircularRoutePath(Track* src, Track* dst); // Recursive.
-
-//---------------------------------------------------------
-// RouteMenuMap
-//---------------------------------------------------------
-
-//typedef std::map<int, Route, std::less<int> >::iterator iRouteMenuMap;
-//typedef std::map<int, Route, std::less<int> >::const_iterator ciRouteMenuMap;
-//typedef std::map<int, Route, std::less<int> > RouteMenuMap;
-//typedef std::pair<int, Route> pRouteMenuMap;
-//typedef std::pair<iRouteMenuMap, bool > rpRouteMenuMap;
+//extern bool isCircularRoutePath(Track* src, Track* dst); // Recursive. DELETETHIS
} // namespace MusECore
diff --git a/muse2/muse/seqmsg.cpp b/muse2/muse/seqmsg.cpp
index abdebda7..a3ea4ddc 100644
--- a/muse2/muse/seqmsg.cpp
+++ b/muse2/muse/seqmsg.cpp
@@ -83,7 +83,7 @@ bool Audio::sendMessage(AudioMsg* m, bool doUndo)
MusEGlobal::song->startUndo();
sendMsg(m);
if (doUndo)
- MusEGlobal::song->endUndo(0); // MusEGlobal::song->endMsgCmd();
+ MusEGlobal::song->endUndo(0);
return false;
}
@@ -94,22 +94,17 @@ bool Audio::sendMessage(AudioMsg* m, bool doUndo)
void Audio::msgRemoveRoute(Route src, Route dst)
{
msgRemoveRoute1(src, dst);
- //if (!MusEGlobal::checkAudioDevice()) return;
if (src.type == Route::JACK_ROUTE)
{
if (!MusEGlobal::checkAudioDevice()) return;
- //if(dst.type == Route::JACK_MIDI_ROUTE)
if(dst.type == Route::MIDI_DEVICE_ROUTE)
{
- //MidiJackDevice* jmd = dynamic_cast<MidiJackDevice*>(dst.device);
- //if(jmd)
if(dst.device)
{
if(dst.device->deviceType() == MidiDevice::JACK_MIDI)
- //MusEGlobal::audioDevice->disconnect(src.jackPort, dst.device->clientPort());
MusEGlobal::audioDevice->disconnect(src.jackPort, dst.device->inClientPort()); // p3.3.55
- //else
+ //else DELETETHIS
//{
// TODO...
//MidiAlsaDevice* amd = dynamic_cast<MidiAlsaDevice*>(dst.device);
@@ -124,17 +119,16 @@ void Audio::msgRemoveRoute(Route src, Route dst)
{
if (!MusEGlobal::checkAudioDevice()) return;
- //if(src.type == Route::JACK_MIDI_ROUTE)
+ //if(src.type == Route::JACK_MIDI_ROUTE) DELETETHIS
if(src.type == Route::MIDI_DEVICE_ROUTE)
{
- //MidiJackDevice* jmd = dynamic_cast<MidiJackDevice*>(src.device);
+ //MidiJackDevice* jmd = dynamic_cast<MidiJackDevice*>(src.device); DELETETHIS
//if(jmd)
if(src.device)
{
if(src.device->deviceType() == MidiDevice::JACK_MIDI)
- //MusEGlobal::audioDevice->disconnect(src.device->clientPort(), dst.jackPort);
MusEGlobal::audioDevice->disconnect(src.device->outClientPort(), dst.jackPort); // p3.3.55
- //else
+ //else DELETETHIS
//{
// TODO...
//MidiAlsaDevice* amd = dynamic_cast<MidiAlsaDevice*>(src.device);
@@ -169,7 +163,7 @@ void Audio::msgRemoveRoutes(Route src, Route dst)
{
msgRemoveRoutes1(src, dst);
- // TODO
+ // TODO or DELETETHIS? looks old.
/*
//if (!MusEGlobal::checkAudioDevice()) return;
if (src.type == Route::JACK_ROUTE)
@@ -230,7 +224,6 @@ void Audio::msgRemoveRoutes(Route src, Route dst)
// msgRemoveRoutes1
//---------------------------------------------------------
-// p3.3.55
void Audio::msgRemoveRoutes1(Route src, Route dst)
{
AudioMsg msg;
@@ -251,19 +244,18 @@ void Audio::msgAddRoute(Route src, Route dst)
if (!MusEGlobal::checkAudioDevice()) return;
if (isRunning())
{
- //if(dst.type == Route::JACK_MIDI_ROUTE)
+ //if(dst.type == Route::JACK_MIDI_ROUTE) DELETETHIS
if(dst.type == Route::MIDI_DEVICE_ROUTE)
{
- //MidiJackDevice* jmd = dynamic_cast<MidiJackDevice*>(dst.device);
+ //MidiJackDevice* jmd = dynamic_cast<MidiJackDevice*>(dst.device); DELETETHIS
//if(jmd)
if(dst.device)
{
if(dst.device->deviceType() == MidiDevice::JACK_MIDI)
- //MusEGlobal::audioDevice->connect(src.jackPort, dst.device->clientPort());
MusEGlobal::audioDevice->connect(src.jackPort, dst.device->inClientPort()); // p3.3.55
//else
//{
- // TODO...
+ // TODO... or DELETETHIS
//MidiAlsaDevice* amd = dynamic_cast<MidiAlsaDevice*>(dst.device);
//if(amd)
//}
@@ -278,19 +270,19 @@ void Audio::msgAddRoute(Route src, Route dst)
if (!MusEGlobal::checkAudioDevice()) return;
if (MusEGlobal::audio->isRunning())
{
- //if(src.type == Route::JACK_MIDI_ROUTE)
+ //if(src.type == Route::JACK_MIDI_ROUTE) DELETETHIS
if(src.type == Route::MIDI_DEVICE_ROUTE)
{
- //MidiJackDevice* jmd = dynamic_cast<MidiJackDevice*>(src.device);
+ //MidiJackDevice* jmd = dynamic_cast<MidiJackDevice*>(src.device); DELETETHIS
//if(jmd)
if(src.device)
{
if(src.device->deviceType() == MidiDevice::JACK_MIDI)
- //MusEGlobal::audioDevice->connect(src.device->clientPort(), dst.jackPort);
+ //MusEGlobal::audioDevice->connect(src.device->clientPort(), dst.jackPort); DELETETHIS
MusEGlobal::audioDevice->connect(src.device->outClientPort(), dst.jackPort); // p3.3.55
//else
//{
- // TODO...
+ // TODO... or DELETETHIS
//MidiAlsaDevice* amd = dynamic_cast<MidiAlsaDevice*>(src.device);
//if(amd)
//}
@@ -343,7 +335,7 @@ void Audio::msgSetRecord(AudioTrack* node, bool val)
sendMsg(&msg);
}
-/*
+/* DELETETHIS 34
//---------------------------------------------------------
// msgSetVolume
//---------------------------------------------------------
@@ -411,7 +403,6 @@ void Audio::msgSetChannels(AudioTrack* node, int n)
{
char buffer[128];
snprintf(buffer, 128, "%s-%d", name.toLatin1().constData(), i);
- //ai->setJackPort(i, MusEGlobal::audioDevice->registerInPort(buffer));
ai->setJackPort(i, MusEGlobal::audioDevice->registerInPort(buffer, false));
}
else if ((i >= n) && ai->jackPort(i))
@@ -442,7 +433,6 @@ void Audio::msgSetChannels(AudioTrack* node, int n)
{
char buffer[128];
snprintf(buffer, 128, "%s-%d", name.toLatin1().constData(), i);
- //ao->setJackPort(i, MusEGlobal::audioDevice->registerOutPort(buffer));
ao->setJackPort(i, MusEGlobal::audioDevice->registerOutPort(buffer, false));
}
else if (i >= n && jp)
@@ -464,6 +454,7 @@ void Audio::msgSetChannels(AudioTrack* node, int n)
}
}
+ // DELETETHIS 47
/* TODO TODO: Change all stereo routes to mono.
// If we are going from stereo to mono we need to disconnect any stray synti 'mono last channel'...
if(n == 1 && node->channels() > 1)
@@ -517,13 +508,11 @@ void Audio::msgSetChannels(AudioTrack* node, int n)
sendMsg(&msg);
}
-/*
+/* DELETETHIS 20
//---------------------------------------------------------
// msgSetPluginCtrlVal
//---------------------------------------------------------
-//void Audio::msgSetPluginCtrlVal(PluginI* plugin, int param, double val)
-// p3.3.43
void Audio::msgSetPluginCtrlVal(AudioTrack* track, int param, double val)
{
AudioMsg msg;
@@ -552,7 +541,6 @@ void Audio::msgSwapControllerIDX(AudioTrack* node, int idx1, int idx2)
msg.a = idx1;
msg.b = idx2;
sendMsg(&msg);
- //muse->arranger->controllerChanged(node);
MusEGlobal::song->controllerChange(node);
}
@@ -568,7 +556,6 @@ void Audio::msgClearControllerEvents(AudioTrack* node, int acid)
msg.snode = node;
msg.ival = acid;
sendMsg(&msg);
- //muse->arranger->controllerChanged(node);
MusEGlobal::song->controllerChange(node);
}
@@ -613,7 +600,6 @@ void Audio::msgEraseACEvent(AudioTrack* node, int acid, int frame)
msg.ival = acid;
msg.a = frame;
sendMsg(&msg);
- //muse->arranger->controllerChanged(node);
MusEGlobal::song->controllerChange(node);
}
@@ -631,7 +617,6 @@ void Audio::msgEraseRangeACEvents(AudioTrack* node, int acid, int frame1, int fr
msg.a = frame1;
msg.b = frame2;
sendMsg(&msg);
- //muse->arranger->controllerChanged(node);
MusEGlobal::song->controllerChange(node);
}
@@ -649,7 +634,6 @@ void Audio::msgAddACEvent(AudioTrack* node, int acid, int frame, double val)
msg.a = frame;
msg.dval = val;
sendMsg(&msg);
- //muse->arranger->controllerChanged(node);
MusEGlobal::song->controllerChange(node);
}
@@ -668,7 +652,6 @@ void Audio::msgChangeACEvent(AudioTrack* node, int acid, int frame, int newFrame
msg.b = newFrame;
msg.dval = val;
sendMsg(&msg);
- //muse->arranger->controllerChanged(node);
MusEGlobal::song->controllerChange(node);
}
@@ -705,12 +688,7 @@ void Audio::msgSetSegSize(int bs, int sr)
void Audio::msgSeek(const Pos& pos)
{
if (!MusEGlobal::checkAudioDevice()) return;
- //MusEGlobal::audioDevice->seekTransport(pos.frame());
- // p3.3.23
- //printf("Audio::msgSeek before MusEGlobal::audioDevice->seekTransport frame:%d\n", pos.frame());
MusEGlobal::audioDevice->seekTransport(pos);
- // p3.3.23
- //printf("Audio::msgSeek after MusEGlobal::audioDevice->seekTransport frame:%d\n", pos.frame());
}
//---------------------------------------------------------
@@ -747,7 +725,6 @@ void Audio::msgPlay(bool val)
unsigned sfr = MusEGlobal::song->cPos().frame();
unsigned dcfr = MusEGlobal::audioDevice->getCurFrame();
if(dcfr != sfr)
- //MusEGlobal::audioDevice->seekTransport(sfr);
MusEGlobal::audioDevice->seekTransport(MusEGlobal::song->cPos());
MusEGlobal::audioDevice->startTransport();
}
@@ -759,7 +736,7 @@ void Audio::msgPlay(bool val)
}
}
-/*
+/* DELETETHIS 31
//---------------------------------------------------------
// msgShowInstrumentGui
//---------------------------------------------------------
@@ -849,7 +826,7 @@ void Audio::msgRemoveTracks()
}
while (loop);
- /*
+ /* DELETETHIS 28
// TESTED: DIDN'T WORK: It still skipped some selected tracks !
// Quote from SGI STL: "Erasing an element from a map also does not invalidate any iterators,
// except, of course, for iterators that actually point to the element
@@ -879,7 +856,7 @@ void Audio::msgRemoveTracks()
}
-/*
+/* DELETETHIS 18
//---------------------------------------------------------
// msgChangeTrack
// oldTrack - copy of the original track befor modification
@@ -971,7 +948,6 @@ bool Song::msgRemoveParts()
// msgChangePart
//---------------------------------------------------------
-//void Audio::msgChangePart(Part* oldPart, Part* newPart, bool doUndoFlag)
void Audio::msgChangePart(Part* oldPart, Part* newPart, bool doUndoFlag, bool doCtrls, bool doClones)
{
AudioMsg msg;
@@ -987,7 +963,6 @@ void Audio::msgChangePart(Part* oldPart, Part* newPart, bool doUndoFlag, bool do
// msgAddEvent
//---------------------------------------------------------
-//void Audio::msgAddEvent(Event& event, Part* part, bool doUndoFlag)
void Audio::msgAddEvent(Event& event, Part* part, bool doUndoFlag, bool doCtrls, bool doClones)
{
AudioMsg msg;
@@ -1003,7 +978,6 @@ void Audio::msgAddEvent(Event& event, Part* part, bool doUndoFlag, bool doCtrls,
// msgDeleteEvent
//---------------------------------------------------------
-//void Audio::msgDeleteEvent(Event& event, Part* part, bool doUndoFlag)
void Audio::msgDeleteEvent(Event& event, Part* part, bool doUndoFlag, bool doCtrls, bool doClones)
{
AudioMsg msg;
@@ -1019,7 +993,6 @@ void Audio::msgDeleteEvent(Event& event, Part* part, bool doUndoFlag, bool doCtr
// msgChangeEvent
//---------------------------------------------------------
-//void Audio::msgChangeEvent(Event& oe, Event& ne, Part* part, bool doUndoFlag)
void Audio::msgChangeEvent(Event& oe, Event& ne, Part* part, bool doUndoFlag, bool doCtrls, bool doClones)
{
AudioMsg msg;
@@ -1338,7 +1311,6 @@ void Audio::msgBounce()
{
_bounce = true;
if (!MusEGlobal::checkAudioDevice()) return;
- //MusEGlobal::audioDevice->seekTransport(MusEGlobal::song->lPos().frame());
MusEGlobal::audioDevice->seekTransport(MusEGlobal::song->lPos());
}
diff --git a/muse2/muse/shortcuts.h b/muse2/muse/shortcuts.h
index dc2e6f22..3e01788b 100644
--- a/muse2/muse/shortcuts.h
+++ b/muse2/muse/shortcuts.h
@@ -4,12 +4,12 @@
// $Id: ./muse/shortcuts.h $
//
// Copyright (C) 1999-2011 by Werner Schweer and others
+//
// Author: Mathias Lundgren <lunar_shuttle@users.sourceforge.net>, (C) 2003
//
// Copyright: Mathias Lundgren (lunar_shuttle@users.sourceforge.net) (C) 2003
//
//
-//
// This program is free software; you can redistribute it and/or
// modify it under the terms of the GNU General Public License
// as published by the Free Software Foundation; version 2 of
diff --git a/muse2/muse/sig.cpp b/muse2/muse/sig.cpp
index b11aa622..5e3db71e 100644
--- a/muse2/muse/sig.cpp
+++ b/muse2/muse/sig.cpp
@@ -1,3 +1,5 @@
+// THIS FILE IS ORPHANED: nothing uses its functions
+
//=========================================================
// MusE
// Linux Music Editor
@@ -84,7 +86,6 @@ void SigList::add(unsigned tick, int z, int n)
void SigList::del(unsigned tick)
{
-// printf("SigList::del(%d)\n", tick);
iSigEvent e = find(tick);
if (e == end()) {
printf("SigList::del(%d): not found\n", tick);
@@ -98,7 +99,7 @@ void SigList::del(unsigned tick)
}
ne->second->z = e->second->z;
ne->second->n = e->second->n;
- ne->second->tick = e->second->tick;
+ ne->second->tick = e->second->tick;
erase(e);
normalize();
}
@@ -133,7 +134,7 @@ void SigList::normalize()
int ticksB = ticks_beat(e->second->n);
int ticksM = ticksB * e->second->z;
bar += delta / ticksM;
- if (delta % ticksM) // Teil eines Taktes
+ if (delta % ticksM) // Part of a measure
++bar;
++e;
}
@@ -175,7 +176,6 @@ int SigList::ticksMeasure(unsigned tick) const
ciSigEvent i = upper_bound(tick);
if (i == end()) {
printf("ticksMeasure: not found %d\n", tick);
- // abort();
return 0;
}
return ticksMeasure(i->second->z, i->second->n);
@@ -223,7 +223,6 @@ void SigList::timesig(unsigned tick, int& z, int& n) const
ciSigEvent i = upper_bound(tick);
if (i == end()) {
printf("timesig(%d): not found\n", tick);
- // abort();
z = 4;
n = 4;
}
@@ -242,7 +241,6 @@ void SigList::tickValues(unsigned t, int* bar, int* beat, unsigned* tick) const
ciSigEvent e = upper_bound(t);
if (e == end()) {
fprintf(stderr, "tickValues(0x%x) not found(%zd)\n", t, size());
- // abort();
*bar = 0;
*beat = 0;
*tick = 0;
@@ -293,7 +291,6 @@ unsigned SigList::raster(unsigned t, int raster) const
ciSigEvent e = upper_bound(t);
if (e == end()) {
printf("SigList::raster(%x,)\n", t);
- // abort();
return t;
}
int delta = t - e->second->tick;
diff --git a/muse2/muse/sig.h b/muse2/muse/sig.h
index 727ce79e..9f38afd6 100644
--- a/muse2/muse/sig.h
+++ b/muse2/muse/sig.h
@@ -1,3 +1,5 @@
+// THIS FILE IS ORPHANED: nothing uses its functions
+
//=========================================================
// MusE
// Linux Music Editor
@@ -39,8 +41,8 @@ class Xml;
//---------------------------------------------------------
struct SigEvent {
- int z, n; // takt signatur
- unsigned tick; // ab dieser Position gilt signatur
+ int z, n; // beat signature
+ unsigned tick; // valid from this position
int bar; // precomputed
int read(Xml&);
diff --git a/muse2/muse/song.cpp b/muse2/muse/song.cpp
index 6d7e419e..1b7354f2 100644
--- a/muse2/muse/song.cpp
+++ b/muse2/muse/song.cpp
@@ -59,11 +59,9 @@
#include "menutitleitem.h"
#include "tracks_duplicate.h"
#include "midi.h"
-///#include "sig.h"
#include "al/sig.h"
#include "keyevent.h"
#include <sys/wait.h>
-//#include "utils.h"
namespace MusEGlobal {
MusECore::Song* song = 0;
@@ -158,7 +156,6 @@ void Song::setSig(const AL::TimeSignature& sig)
Track* Song::addNewTrack(QAction* action, Track* insertAt)
{
-printf("Song::addNewTrack\n");
int n = action->data().toInt();
// Ignore negative numbers since this slot could be called by a menu or list etc. passing -1.
if(n < 0)
@@ -176,7 +173,9 @@ printf("Song::addNewTrack\n");
if(n >= (int)MusEGlobal::synthis.size())
return 0;
- //printf("Song::addNewTrack synth: type:%d idx:%d class:%s label:%s\n", ntype, n, MusEGlobal::synthis[n]->baseName().toLatin1().constData(), MusEGlobal::synthis[n]->name().toLatin1().constData());
+ if (MusEGlobal::debugMsg)
+ printf("Song::addNewTrack synth: type:%d idx:%d class:%s label:%s\n", ntype, n, MusEGlobal::synthis[n]->baseName().toLatin1().constData(), MusEGlobal::synthis[n]->name().toLatin1().constData());
+
SynthI* si = createSynthI(MusEGlobal::synthis[n]->baseName(), MusEGlobal::synthis[n]->name(), (Synth::Type)ntype, insertAt);
if(!si)
return 0;
@@ -234,9 +233,8 @@ printf("Song::addNewTrack\n");
// If insertAt is valid, inserts before insertAt. Else at the end after all tracks.
//---------------------------------------------------------
-Track* Song::addTrack(Undo& operations, Track::TrackType type, Track* insertAt)
+Track* Song::addTrack(Undo& /*operations*/, Track::TrackType type, Track* insertAt)
{
- printf("Song::addTrack\n");
Track* track = 0;
int lastAuxIdx = _auxs.size();
switch(type) {
@@ -292,10 +290,12 @@ Track* Song::addTrack(Undo& operations, Track::TrackType type, Track* insertAt)
int idx = insertAt ? _tracks.index(insertAt) : -1;
- // insertTrack1(track, idx); // this and the below are replaced
- // msgInsertTrack(track, idx, true); // by the UndoOp-operation
- // insertTrack3(track, idx); // does nothing
- operations.push_back(UndoOp(UndoOp::AddTrack, idx, track));
+ insertTrack1(track, idx); // this and the below are replaced
+ msgInsertTrack(track, idx, true); // by the UndoOp-operation
+ insertTrack3(track, idx); // does nothing
+ // No, can't do this. insertTrack2 needs to be called now, not later, otherwise it sees
+ // that the track may have routes, and reciprocates them, causing duplicate routes.
+ ///operations.push_back(UndoOp(UndoOp::AddTrack, idx, track));
// Add default track <-> midiport routes.
if(track->isMidiTrack())
@@ -354,18 +354,8 @@ Track* Song::addTrack(Undo& operations, Track::TrackType type, Track* insertAt)
if (!ol->empty()) {
AudioOutput* ao = ol->front();
switch(type) {
- //case Track::MIDI:
- //case Track::DRUM:
- //case Track::NEW_DRUM:
- //case Track::AUDIO_OUTPUT:
- // break;
-
case Track::WAVE:
- //case Track::AUDIO_GROUP: // Removed by Tim.
case Track::AUDIO_AUX:
- //case Track::AUDIO_INPUT: // Removed by Tim.
- // p3.3.38
- //case Track::AUDIO_SOFTSYNTH:
MusEGlobal::audio->msgAddRoute(Route((AudioTrack*)track, -1), Route(ao, -1));
updateFlags |= SC_ROUTE;
break;
@@ -465,7 +455,9 @@ void Song::duplicateTracks()
// required for fine-grained control over initializing various track types.
//
- // Set to 0 to use the copy constructor. Set to 1 to use new + assign().
+ // Set to 0 to use the copy constructor. Set to 1 to use new + assign().
+ // DELETETHIS is this still necessary to keep around?
+ // also consider removing and adding a hint to a revision number instead
#if 0
Track* new_track = 0;
@@ -473,7 +465,7 @@ void Song::duplicateTracks()
switch(track->type())
{
case Track::AUDIO_SOFTSYNTH: // TODO: Handle synths. p4.0.47
- // ((AudioTrack*)new_track)->addAuxSend(lastAuxIdx);
+ // ((AudioTrack*)new_track)->addAuxSend(lastAuxIdx); DELETETHIS?
break;
case Track::MIDI:
@@ -483,25 +475,25 @@ void Song::duplicateTracks()
case Track::DRUM:
new_track = new MidiTrack();
new_track->setType(Track::DRUM);
- //((MidiTrack*)new_track)->setOutChannel(9);
+ //((MidiTrack*)new_track)->setOutChannel(9); DELETETHIS?
break;
case Track::WAVE:
new_track = new MusECore::WaveTrack();
- //((AudioTrack*)new_track)->addAuxSend(lastAuxIdx);
+ //((AudioTrack*)new_track)->addAuxSend(lastAuxIdx); DELETETHIS?
break;
case Track::AUDIO_OUTPUT:
new_track = new AudioOutput();
break;
case Track::AUDIO_GROUP:
new_track = new AudioGroup();
- //((AudioTrack*)new_track)->addAuxSend(lastAuxIdx);
+ //((AudioTrack*)new_track)->addAuxSend(lastAuxIdx); DELETETHIS?
break;
case Track::AUDIO_AUX:
new_track = new AudioAux();
break;
case Track::AUDIO_INPUT:
new_track = new AudioInput();
- //((AudioTrack*)new_track)->addAuxSend(lastAuxIdx);
+ //((AudioTrack*)new_track)->addAuxSend(lastAuxIdx); DELETETHIS?
break;
default:
printf("Song::duplicateTracks: Illegal type %d\n", track->type());
@@ -535,13 +527,6 @@ void Song::duplicateTracks()
update_flags |= SC_ROUTE;
MusEGlobal::song->endUndo(update_flags);
MusEGlobal::audio->msgUpdateSoloStates();
-
- //if (t->isVisible())
- //{
- ////deselectTracks();
- //t->setSelected(true);
- ////update(SC_SELECTION);
- //}
}
//---------------------------------------------------------
@@ -585,7 +570,7 @@ void Song::deselectTracks()
(*t)->setSelected(false);
}
-/*
+/* DELETETHIS 17
//---------------------------------------------------------
// changeTrack
// oldTrack - copy of the original track befor modification
@@ -636,9 +621,7 @@ void Song::changeEvent(Event& oldEvent, Event& newEvent, Part* part)
// This can be normal for some (redundant) operations.
if(MusEGlobal::debugMsg)
printf("Song::changeEvent event not found in part:%s size:%zd\n", part->name().toLatin1().constData(), part->events()->size());
- // Removed by T356. Allow it to add the new event.
- // (And remove the old one from the midi port controller!)
- //return;
+ // no "return;" because: Allow it to add the new event. (And remove the old one from the midi port controller!) (tim)
}
else
part->events()->erase(i);
@@ -684,16 +667,9 @@ void Song::remapPortDrumCtrlEvents(int mapidx, int newnote, int newchan, int new
{
MidiPart* part = (MidiPart*)(ip->second);
const EventList* el = part->cevents();
- // unsigned len = part->lenTick(); // Commented out by flo, see below
for(ciEvent ie = el->begin(); ie != el->end(); ++ie)
{
const Event& ev = ie->second;
- // Added by T356. Do not handle events which are past the end of the part.
- // Commented out by flo: yes, DO handle them! these are "hidden events"
- // which may be revealed later again!
- // if(ev.tick() >= len)
- // break;
-
if(ev.type() != Controller)
continue;
@@ -834,9 +810,6 @@ void Song::cmdAddRecordedEvents(MidiTrack* mt, EventList* events, unsigned start
iEvent e;
unsigned endTick;
- // Changed by Tim. p3.3.8
-
- //if (punchin())
if((MusEGlobal::audio->loopCount() > 0 && startTick > lPos().tick()) || (punchin() && startTick < lPos().tick()))
{
startTick = lpos();
@@ -845,28 +818,17 @@ void Song::cmdAddRecordedEvents(MidiTrack* mt, EventList* events, unsigned start
else
{
s = events->begin();
-// startTick = s->first;
}
- // Changed by Tim. p3.3.8
-
- //if (punchout())
- //{
- // endTick = rpos();
- // e = events->lower_bound(endTick);
- //}
- //else
- //{
- // search for last noteOff:
- endTick = 0;
- for (iEvent i = events->begin(); i != events->end(); ++i) {
- Event ev = i->second;
- unsigned l = ev.endTick();
- if (l > endTick)
- endTick = l;
- }
- // e = events->end();
- //}
+ // search for last noteOff:
+ endTick = 0;
+ for (iEvent i = events->begin(); i != events->end(); ++i) {
+ Event ev = i->second;
+ unsigned l = ev.endTick();
+ if (l > endTick)
+ endTick = l;
+ }
+
if((MusEGlobal::audio->loopCount() > 0) || (punchout() && endTick > rPos().tick()) )
{
endTick = rpos();
@@ -904,11 +866,6 @@ void Song::cmdAddRecordedEvents(MidiTrack* mt, EventList* events, unsigned start
// create new part
part = new MidiPart(mt);
- // Changed by Tim. p3.3.8
-
- // Honour the Arranger snap settings. (Set to bar by default).
- //startTick = roundDownBar(startTick);
- //endTick = roundUpBar(endTick);
// Round the start down using the Arranger part snap raster value.
startTick = AL::sigmap.raster1(startTick, arrangerRaster());
// Round the end up using the Arranger part snap raster value.
@@ -949,23 +906,25 @@ void Song::cmdAddRecordedEvents(MidiTrack* mt, EventList* events, unsigned start
// Round the end up (again) using the Arranger part snap raster value.
endTick = AL::sigmap.raster2(endTick, arrangerRaster());
- // Remove all of the part's port controller values. Indicate do not do clone parts.
- removePortCtrlEvents(part, false);
+
+ removePortCtrlEvents(part, false); // Remove all of the part's port controller values. Don't do clone parts.
+
// Clone the part. This doesn't increment aref count, and doesn't chain clones.
// It also gives the new part a new serial number, but it is
// overwritten with the old one by Song::changePart(), below.
Part* newPart = part->clone();
- // Set the new part's length.
- newPart->setLenTick(endTick);
- // Change the part.
- changePart(part, newPart);
- // Manually adjust reference counts.
- part->events()->incARef(-1);
+
+ newPart->setLenTick(endTick); // Set the new part's length.
+ changePart(part, newPart); // Change the part.
+
+ part->events()->incARef(-1); // Manually adjust reference counts. HACK!
newPart->events()->incARef(1);
- // Replace the part in the clone chain with the new part.
- replaceClone(part, newPart);
+
+ replaceClone(part, newPart); // Replace the part in the clone chain with the new part.
+
// Now add all of the new part's port controller values. Indicate do not do clone parts.
addPortCtrlEvents(newPart, false);
+
// Create an undo op. Indicate do port controller values but not clone parts.
addUndo(UndoOp(UndoOp::ModifyPart, part, newPart, true, false));
updateFlags |= SC_PART_MODIFIED;
@@ -977,7 +936,7 @@ void Song::cmdAddRecordedEvents(MidiTrack* mt, EventList* events, unsigned start
for (iEvent i = si; i != ei; ++i)
{
Event event = i->second;
- // Create an undo op. Indicate do port controller values and clone parts.
+ // Indicate do port controller values and clone parts.
addUndo(UndoOp(UndoOp::DeleteEvent, event, newPart, true, true));
// Remove the event from the new part's port controller values, and do all clone parts.
removePortCtrlEvents(event, newPart, true);
@@ -1006,8 +965,7 @@ void Song::cmdAddRecordedEvents(MidiTrack* mt, EventList* events, unsigned start
for (iEvent i = si; i != ei; ++i) {
Event event = i->second;
- // Create an undo op. Indicate that controller values and clone parts were handled.
- //addUndo(UndoOp(UndoOp::DeleteEvent, event, part));
+ // Indicate that controller values and clone parts were handled.
addUndo(UndoOp(UndoOp::DeleteEvent, event, part, true, true));
// Remove the event from the part's port controller values, and do all clone parts.
removePortCtrlEvents(event, part, true);
@@ -1019,11 +977,9 @@ void Song::cmdAddRecordedEvents(MidiTrack* mt, EventList* events, unsigned start
int tick = event.tick() - partTick;
event.setTick(tick);
- // Create an undo op. Indicate that controller values and clone parts were handled.
- //addUndo(UndoOp(UndoOp::AddEvent, event, part));
+ // Indicate that controller values and clone parts were handled.
addUndo(UndoOp(UndoOp::AddEvent, event, part, true, true));
- //addEvent(event, part);
if(part->events()->find(event) == part->events()->end())
part->events()->add(event);
@@ -1108,7 +1064,7 @@ void Song::setRecord(bool f, bool autoRecEnable)
Track *selectedTrack = 0;
// loop through list and check if any track is rec enabled
// if not then rec enable the selected track
- MusECore::WaveTrackList* wtl = waves();
+ MusECore::WaveTrackList* wtl = waves();
for (MusECore::iWaveTrack i = wtl->begin(); i != wtl->end(); ++i) {
if((*i)->recordFlag())
{
@@ -1152,6 +1108,7 @@ void Song::setRecord(bool f, bool autoRecEnable)
}
}
+// DELETETHIS? 14
#if 0
// check for midi devices suitable for recording
bool portFound = false;
@@ -1239,11 +1196,8 @@ void Song::setMasterFlag(bool val)
_masterFlag = val;
if (MusEGlobal::tempomap.setMasterFlag(cpos(), val))
{
- //MusEGlobal::audioDevice->setMaster(val);
emit songChanged(SC_MASTER);
}
- // Removed. p3.3.26
- //MusEGlobal::audioDevice->setMaster(val);
}
//---------------------------------------------------------
@@ -1324,31 +1278,31 @@ void Song::seekTo(int tick)
void Song::setPos(int idx, const Pos& val, bool sig,
bool isSeek, bool adjustScrollbar)
{
-// printf("setPos %d sig=%d,seek=%d,scroll=%d ",
-// idx, sig, isSeek, adjustScrollbar);
-// val.dump(0);
-// printf("\n");
- //printf("Song::setPos before MusEGlobal::audio->msgSeek idx:%d isSeek:%d frame:%d\n", idx, isSeek, val.frame());
+ if (MusEGlobal::heavyDebugMsg)
+ {
+ printf("setPos %d sig=%d,seek=%d,scroll=%d ",
+ idx, sig, isSeek, adjustScrollbar);
+ val.dump(0);
+ printf("\n");
+ printf("Song::setPos before MusEGlobal::audio->msgSeek idx:%d isSeek:%d frame:%d\n", idx, isSeek, val.frame());
+ }
- // If seeking audio, ensure frame resolution CAN be kept throughout. This compares apples and oranges. Moved below. p4.0.33
- //if (pos[idx] == val)
- // return;
if (idx == CPOS) {
_vcpos = val;
if (isSeek && !MusEGlobal::extSyncFlag.value()) {
if (val == MusEGlobal::audio->pos())
{
- //printf("Song::setPos seek MusEGlobal::audio->pos already == val tick:%d frame:%d\n", val.tick(), val.frame());
+ if (MusEGlobal::heavyDebugMsg) printf("Song::setPos seek MusEGlobal::audio->pos already == val tick:%d frame:%d\n", val.tick(), val.frame());
return;
}
MusEGlobal::audio->msgSeek(val);
- //printf("Song::setPos after MusEGlobal::audio->msgSeek idx:%d isSeek:%d frame:%d\n", idx, isSeek, val.frame());
+ if (MusEGlobal::heavyDebugMsg) printf("Song::setPos after MusEGlobal::audio->msgSeek idx:%d isSeek:%d frame:%d\n", idx, isSeek, val.frame());
return;
}
}
if (val == pos[idx])
{
- //printf("Song::setPos MusEGlobal::song->pos already == val tick:%d frame:%d\n", val.tick(), val.frame());
+ if (MusEGlobal::heavyDebugMsg) printf("Song::setPos MusEGlobal::song->pos already == val tick:%d frame:%d\n", val.tick(), val.frame());
return;
}
pos[idx] = val;
@@ -1433,13 +1387,7 @@ void Song::rewind()
void Song::rewindStart()
{
- // Added by T356
- //MusEGlobal::audio->msgIdle(true);
-
MusEGlobal::audio->msgSeek(Pos(0, true));
-
- // Added by T356
- //MusEGlobal::audio->msgIdle(false);
}
//---------------------------------------------------------
@@ -1576,15 +1524,6 @@ PartList* Song::getSelectedMidiParts() const
{
PartList* parts = new PartList();
- //------------------------------------------------------
- // wenn ein Part selektiert ist, diesen editieren
- // wenn ein Track selektiert ist, den Ersten
- // Part des Tracks editieren, die restlichen sind
- // 'ghostparts'
- // wenn mehrere Parts selektiert sind, dann Ersten
- // editieren, die restlichen sind 'ghostparts'
- //
- // Rough translation:
/*
If a part is selected, edit that.
If a track is selected, edit the first
@@ -1628,16 +1567,16 @@ PartList* Song::getSelectedWaveParts() const
{
PartList* parts = new PartList();
- //------------------------------------------------------
- // wenn ein Part selektiert ist, diesen editieren
- // wenn ein Track selektiert ist, den Ersten
- // Part des Tracks editieren, die restlichen sind
- // 'ghostparts'
- // wenn mehrere Parts selektiert sind, dann Ersten
- // editieren, die restlichen sind 'ghostparts'
- //
+ /*
+ If a part is selected, edit that.
+ If a track is selected, edit the first
+ part of the track, the rest are
+ 'ghost parts'
+ When multiple parts are selected, then edit the first,
+ the rest are 'ghost parts'
+ */
- // markierte Parts sammeln
+ // collect selected parts
for (ciTrack t = _tracks.begin(); t != _tracks.end(); ++t) {
MusECore::WaveTrack* track = dynamic_cast<MusECore::WaveTrack*>(*t);
if (track == 0)
@@ -1649,8 +1588,8 @@ PartList* Song::getSelectedWaveParts() const
}
}
}
- // wenn keine Parts selektiert, dann markierten Track suchen
- // und alle Parts dieses Tracks zusammensuchen
+ // if no parts are selected, then search the selected track
+ // and collect all parts in this track
if (parts->empty()) {
for (ciTrack t = _tracks.begin(); t != _tracks.end(); ++t) {
@@ -1670,9 +1609,8 @@ PartList* Song::getSelectedWaveParts() const
void Song::setMType(MType t)
{
-// printf("set MType %d\n", t);
_mtype = t;
- MusEGlobal::song->update(SC_SONG_TYPE); // p4.0.7 Tim.
+ MusEGlobal::song->update(SC_SONG_TYPE);
}
//---------------------------------------------------------
@@ -1681,6 +1619,7 @@ void Song::setMType(MType t)
void Song::beat()
{
+ // DELETETHIS 15
#if 0
// Just a rate test...
static double _heartbeatRateTimer = 0.0;
@@ -1699,21 +1638,13 @@ void Song::beat()
// Keep the sync detectors running...
for(int port = 0; port < MIDI_PORTS; ++port)
- {
- // Must keep them running even if there's no device...
- //if(MusEGlobal::midiPorts[port].device())
MusEGlobal::midiPorts[port].syncInfo().setTime();
- }
- //int tick = MusEGlobal::audio->tickPos();
if (MusEGlobal::audio->isPlaying())
- {
- //Pos tick(MusEGlobal::audio->tickPos());
- //setPos(0, tick, true, false, true);
setPos(0, MusEGlobal::audio->tickPos(), true, false, true);
- }
- // p3.3.40 Update synth native guis at the heartbeat rate.
+
+ // Update synth native guis at the heartbeat rate.
for(ciSynthI is = _synthIs.begin(); is != _synthIs.end(); ++is)
(*is)->guiHeartBeat();
@@ -1771,11 +1702,9 @@ Marker* Song::getMarkerAt(int t)
{
iMarker markerI;
for (markerI=_markerList->begin(); markerI != _markerList->end(); ++markerI) {
-// if (i1->second.current())
- if (unsigned(t) == markerI->second.tick())//prevent of copmiler warning: comparison signed/unsigned
+ if (unsigned(t) == markerI->second.tick()) //prevent of compiler warning: comparison signed/unsigned
return &markerI->second;
}
- //Marker* marker = _markerList->add(s, t, lck);
return NULL;
}
@@ -1813,23 +1742,6 @@ Marker* Song::setMarkerLock(Marker* m, bool f)
return m;
}
-// kommer inte att gå göra undo på, kanske skulle fixa det.
-
-//void Song::moveMarkers(int startOffset, int ticks)
-//{
-// iMarker markerI;
-// for (markerI=_markerList->rbegin(); markerI != _markerList->rend(); ++markerI) {
-// if (markerI->second.tick() > startOffset) {
-// if (markerI-> )
-// }
-//
-//
-//
-// if (unsigned(t) == markerI->second.tick())//prevent of copmiler warning: comparison signed/unsigned
-// return &markerI->second;
-// }
-//
-//}
//---------------------------------------------------------
// setRecordFlag
@@ -1847,7 +1759,6 @@ void Song::setRecordFlag(Track* track, bool val)
track->setRecordFlag1(val);
track->setRecordFlag2(val);
}
-// updateFlags |= SC_RECFLAG;
update(SC_RECFLAG);
}
@@ -1868,8 +1779,7 @@ void Song::rescanAlsaPorts()
void Song::endMsgCmd()
{
if (updateFlags) {
- //redoList->clear(); // TODO: delete elements in list
- redoList->clearDelete(); // p4.0.46 Tim. NOTE Hm, shouldn't this be above?
+ redoList->clearDelete();
MusEGlobal::undoAction->setEnabled(true);
MusEGlobal::redoAction->setEnabled(false);
emit songChanged(updateFlags);
@@ -1950,7 +1860,6 @@ void Song::processMsg(AudioMsg* msg)
updateFlags = SC_EVENT_INSERTED;
if (addEvent(msg->ev1, (MidiPart*)msg->p2)) {
Event ev;
- //addUndo(UndoOp(UndoOp::AddEvent, ev, msg->ev1, (Part*)msg->p2));
addUndo(UndoOp(UndoOp::AddEvent, ev, msg->ev1, (Part*)msg->p2, msg->a, msg->b));
}
else
@@ -1965,7 +1874,6 @@ void Song::processMsg(AudioMsg* msg)
if(msg->a)
removePortCtrlEvents(event, part, msg->b);
Event e;
- //addUndo(UndoOp(UndoOp::DeleteEvent, e, event, (Part*)part));
addUndo(UndoOp(UndoOp::DeleteEvent, e, event, (Part*)part, msg->a, msg->b));
deleteEvent(event, part);
updateFlags = SC_EVENT_REMOVED;
@@ -1977,7 +1885,6 @@ void Song::processMsg(AudioMsg* msg)
changeEvent(msg->ev1, msg->ev2, (MidiPart*)msg->p3);
if(msg->a)
addPortCtrlEvents(msg->ev2, (Part*)msg->p3, msg->b);
- //addUndo(UndoOp(UndoOp::ModifyEvent, msg->ev2, msg->ev1, (Part*)msg->p3));
addUndo(UndoOp(UndoOp::ModifyEvent, msg->ev2, msg->ev1, (Part*)msg->p3, msg->a, msg->b));
updateFlags = SC_EVENT_MODIFIED;
break;
@@ -1987,10 +1894,9 @@ void Song::processMsg(AudioMsg* msg)
insertTrack2(msg->track, msg->ival);
break;
case SEQM_REMOVE_TRACK:
- //removeTrack2(msg->track);
cmdRemoveTrack(msg->track);
break;
- //case SEQM_CHANGE_TRACK:
+ //case SEQM_CHANGE_TRACK: DELETETHIS 3
// changeTrack((Track*)(msg->p1), (Track*)(msg->p2));
// break;
case SEQM_ADD_PART:
@@ -2000,7 +1906,6 @@ void Song::processMsg(AudioMsg* msg)
cmdRemovePart((Part*)msg->p1);
break;
case SEQM_CHANGE_PART:
- //cmdChangePart((Part*)msg->p1, (Part*)msg->p2);
cmdChangePart((Part*)msg->p1, (Part*)msg->p2, msg->a, msg->b);
break;
@@ -2076,7 +1981,6 @@ void Song::cmdRemovePart(Part* part)
removePart(part);
addUndo(UndoOp(UndoOp::DeletePart, part));
part->events()->incARef(-1);
- //part->unchainClone();
unchainClone(part);
updateFlags = SC_PART_REMOVED;
}
@@ -2087,14 +1991,11 @@ void Song::cmdRemovePart(Part* part)
void Song::cmdChangePart(Part* oldPart, Part* newPart, bool doCtrls, bool doClones)
{
- //printf("Song::cmdChangePart before changePart oldPart:%p events:%p refs:%d Arefs:%d sn:%d newPart:%p events:%p refs:%d Arefs:%d sn:%d\n", oldPart, oldPart->events(), oldPart->events()->refCount(), oldPart->events()->arefCount(), oldPart->sn(), newPart, newPart->events(), newPart->events()->refCount(), newPart->events()->arefCount(), newPart->sn());
-
if(doCtrls)
removePortCtrlEvents(oldPart, doClones);
changePart(oldPart, newPart);
- //addUndo(UndoOp(UndoOp::ModifyPart, oldPart, newPart));
addUndo(UndoOp(UndoOp::ModifyPart, oldPart, newPart, doCtrls, doClones));
// Changed by T356. Do not decrement ref count if the new part is a clone of the old part, since the event list
@@ -2102,17 +2003,11 @@ void Song::cmdChangePart(Part* oldPart, Part* newPart, bool doCtrls, bool doClon
if(oldPart->cevents() != newPart->cevents())
oldPart->events()->incARef(-1);
- //oldPart->replaceClone(newPart);
-
- //printf("Song::cmdChangePart before repl/unchClone oldPart:%p events:%p refs:%d Arefs:%d sn:%d newPart:%p events:%p refs:%d Arefs:%d sn:%d\n", oldPart, oldPart->events(), oldPart->events()->refCount(), oldPart->events()->arefCount(), oldPart->sn(), newPart, newPart->events(), newPart->events()->refCount(), newPart->events()->arefCount(), newPart->sn());
-
replaceClone(oldPart, newPart);
if(doCtrls)
addPortCtrlEvents(newPart, doClones);
- //printf("Song::cmdChangePart after repl/unchClone oldPart:%p events:%p refs:%d Arefs:%d sn:%d newPart:%p events:%p refs:%d Arefs:%d sn:%d\n", oldPart, oldPart->events(), oldPart->events()->refCount(), oldPart->events()->arefCount(), oldPart->sn(), newPart, newPart->events(), newPart->events()->refCount(), newPart->events()->arefCount(), newPart->sn());
-
updateFlags = SC_PART_MODIFIED;
}
@@ -2174,7 +2069,6 @@ void Song::clear(bool signal, bool clear_all)
loop = false;
for(iMidiDevice imd = MusEGlobal::midiDevices.begin(); imd != MusEGlobal::midiDevices.end(); ++imd)
{
- //if((*imd)->deviceType() == MidiDevice::JACK_MIDI)
if(dynamic_cast< MidiJackDevice* >(*imd))
{
if(clear_all) // Allow not touching devices. p4.0.17 TESTING: Maybe some problems...
@@ -2190,9 +2084,7 @@ void Song::clear(bool signal, bool clear_all)
break;
}
}
- else
- //if((*imd)->deviceType() == MidiDevice::ALSA_MIDI)
- if(dynamic_cast< MidiAlsaDevice* >(*imd))
+ else if(dynamic_cast< MidiAlsaDevice* >(*imd))
{
// With alsa devices, we must not delete them (they're always in the list). But we must
// clear all routes. They point to non-existant midi tracks, which were all deleted above.
@@ -2208,6 +2100,7 @@ void Song::clear(bool signal, bool clear_all)
MusEGlobal::keymap.clear();
undoList->clearDelete();
+ // DELETETHIS
//redoList->clear(); // Check this - Should we do a clearDelete? IIRC it was OK this way - no clearDelete in case of same items in both lists.
redoList->clearDelete(); // p4.0.46 Tim
if(MusEGlobal::undoAction)
@@ -2245,7 +2138,6 @@ void Song::clear(bool signal, bool clear_all)
_quantize = false;
_len = 0; // song len in ticks
_follow = JUMP;
- // _tempo = 500000; // default tempo 120
dirty = false;
initDrumMap();
initNewDrumMap();
@@ -2305,6 +2197,7 @@ void Song::cleanupForQuit()
if(MusEGlobal::debugMsg)
printf("deleting undoList, clearing redoList\n");
undoList->clearDelete();
+ //DELETETHIS
//redoList->clear(); // Check this - Should we do a clearDelete? IIRC it was OK this way - no clearDelete in case of same items in both lists.
redoList->clearDelete(); // p4.0.46 Tim
@@ -2317,12 +2210,12 @@ void Song::cleanupForQuit()
if(MusEGlobal::debugMsg)
printf("deleting midiport controllers\n");
+
// Clear all midi port controllers and values.
for(int i = 0; i < MIDI_PORTS; ++i)
- // Remove the controllers and the values.
- MusEGlobal::midiPorts[i].controller()->clearDelete(true);
+ MusEGlobal::midiPorts[i].controller()->clearDelete(true); // Remove the controllers and the values.
- // Can't do this here. Jack isn't running. Fixed. Test OK so far.
+ // Can't do this here. Jack isn't running. Fixed. Test OK so far. DELETETHIS (the comment and #if/#endif)
#if 1
if(MusEGlobal::debugMsg)
printf("deleting midi devices except synths\n");
@@ -2340,6 +2233,7 @@ void Song::cleanupForQuit()
if(MusEGlobal::debugMsg)
printf("deleting global available synths\n");
+
// Delete all synths.
std::vector<Synth*>::iterator is;
for(is = MusEGlobal::synthis.begin(); is != MusEGlobal::synthis.end(); ++is)
@@ -2392,7 +2286,6 @@ void Song::seqSignal(int fd)
return;
}
for (int i = 0; i < n; ++i) {
-// printf("seqSignal to gui:<%c>\n", buffer[i]);
switch(buffer[i]) {
case '0': // STOP
stopRolling();
@@ -2436,7 +2329,7 @@ void Song::seqSignal(int fd)
"click on the Restart button."), "restart", "cancel");
if (btn == 0) {
printf("restarting!\n");
- MusEGlobal::muse->seqRestart();
+ MusEGlobal::muse->seqRestart();
}
}
@@ -2458,7 +2351,7 @@ void Song::seqSignal(int fd)
MusEGlobal::audioDevice->setFreewheel(false);
MusEGlobal::audio->msgPlay(false);
-#if 0
+#if 0 // DELETETHIS
if (record())
MusEGlobal::audio->recordStop();
setStopPlay(false);
@@ -2511,7 +2404,6 @@ void Song::recordEvent(MidiTrack* mt, Event& event)
// create new part
part = new MidiPart(mt);
int startTick = roundDownBar(tick);
- //int endTick = roundUpBar(tick);
int endTick = roundUpBar(tick + 1);
part->setTick(startTick);
part->setLenTick(endTick - startTick);
@@ -2532,15 +2424,9 @@ void Song::recordEvent(MidiTrack* mt, Event& event)
for(iEvent i = range.first; i != range.second; ++i)
{
ev = i->second;
- // At the moment, Song::recordEvent() is only called by the 'Rec' buttons in the
- // midi track info panel. So only controller types are fed to it. If other event types
- // are to be passed, we will have to expand on this to check if equal. Instead, maybe add an isEqual() to Event class.
- //if((ev.type() == Controller && event.type() == Controller || ev.type() == Controller && event.type() == Controller)
- // && ev.dataA() == event.dataA() && ev.dataB() == event.dataB())
if(ev.type() == Controller && ev.dataA() == event.dataA())
{
- // Don't bother if already set.
- if(ev.dataB() == event.dataB())
+ if(ev.dataB() == event.dataB()) // Don't bother if already set.
return;
// Indicate do undo, and do port controller values and clone parts.
MusEGlobal::audio->msgChangeEvent(ev, event, part, true, true, true);
@@ -2550,7 +2436,6 @@ void Song::recordEvent(MidiTrack* mt, Event& event)
}
// Indicate do undo, and do port controller values and clone parts.
- //MusEGlobal::audio->msgAddEvent(event, part);
MusEGlobal::audio->msgAddEvent(event, part, true, true, true);
}
@@ -2575,17 +2460,11 @@ int Song::execAutomationCtlPopup(AudioTrack* track, const QPoint& menupos, int a
CtrlList *cl = icl->second;
canAdd = true;
- //int frame = pos[0].frame();
- int frame = MusEGlobal::audio->pos().frame(); // Try this. p4.0.33
-
- //printf("pos[0]:%d f:%d tickPos:%d f:%d\n", pos[0].tick(), pos[0].frame(), MusEGlobal::audio->tickPos(), Pos(MusEGlobal::audio->tickPos(), true).frame());
+ //int frame = pos[0].frame(); DELETETHIS
+ int frame = MusEGlobal::audio->pos().frame(); // Try this. p4.0.33 DELETETHIS
- //ctlval = cl->curVal();
- //AutomationType at = track->MusEGlobal::automationType();
- //if(!MusEGlobal::automation || track->MusEGlobal::automationType() == AUTO_OFF)
- ctlval = cl->curVal();
- //else
- // ctlval = cl->value(frame);
+ ctlval = cl->curVal();
+
count = cl->size();
if(count)
{
@@ -2639,16 +2518,12 @@ int Song::execAutomationCtlPopup(AudioTrack* track, const QPoint& menupos, int a
clearAction->setEnabled((bool)count);
QAction* act = menu->exec(menupos);
- //delete menu;
if (!act || !track)
{
delete menu;
return -1;
}
- //if(!track)
- // return -1;
-
int sel = act->data().toInt();
delete menu;
@@ -2697,15 +2572,10 @@ int Song::execMidiAutomationCtlPopup(MidiTrack* track, MidiPart* part, const QPo
if(!track && !part)
return -1;
- //enum { PREV_EVENT, NEXT_EVENT, ADD_EVENT, CLEAR_EVENT, CLEAR_RANGE, CLEAR_ALL_EVENTS };
enum { ADD_EVENT, CLEAR_EVENT };
QMenu* menu = new QMenu;
- //int count = 0;
bool isEvent = false;
- //bool canSeekPrev = false, canSeekNext = false, canEraseRange = false;
- //bool canAdd = false;
- //double ctlval = 0.0;
MidiTrack* mt;
if(track)
@@ -2729,8 +2599,6 @@ int Song::execMidiAutomationCtlPopup(MidiTrack* track, MidiPart* part, const QPo
dctl |= MusEGlobal::drumMap[note].anote;
}
- //printf("Song::execMidiAutomationCtlPopup ctlnum:%d dctl:%d anote:%d\n", ctlnum, dctl, MusEGlobal::drumMap[ctlnum & 0x7f].anote);
-
unsigned tick = cpos();
if(!part)
@@ -2771,9 +2639,6 @@ int Song::execMidiAutomationCtlPopup(MidiTrack* track, MidiPart* part, const QPo
ev = i->second;
if(ev.type() == Controller)
{
- //printf("Song::execMidiAutomationCtlPopup ev.dataA:%d\n", ev.dataA());
-
- //if(ev.dataA() == dctl)
if(ev.dataA() == ctlnum)
{
isEvent = true;
@@ -2793,31 +2658,19 @@ int Song::execMidiAutomationCtlPopup(MidiTrack* track, MidiPart* part, const QPo
else
addEvent->setText(tr("add event"));
addEvent->setData(ADD_EVENT);
- //addEvent->setEnabled(canAdd);
addEvent->setEnabled(true);
QAction* eraseEventAction = menu->addAction(tr("erase event"));
eraseEventAction->setData(CLEAR_EVENT);
eraseEventAction->setEnabled(isEvent);
-// menu->insertItem(tr("erase range"), CLEAR_RANGE, CLEAR_RANGE);
-// menu->setItemEnabled(CLEAR_RANGE, canEraseRange);
-
-// menu->insertItem(tr("clear automation"), CLEAR_ALL_EVENTS, CLEAR_ALL_EVENTS);
-// menu->setItemEnabled(CLEAR_ALL_EVENTS, (bool)count);
-
-
QAction* act = menu->exec(menupos);
- //delete menu;
if (!act)
{
delete menu;
return -1;
}
- //if(!part)
- // return -1;
-
int sel = act->data().toInt();
delete menu;
@@ -2825,19 +2678,16 @@ int Song::execMidiAutomationCtlPopup(MidiTrack* track, MidiPart* part, const QPo
{
case ADD_EVENT:
{
- //int val = mp->hwCtrlState(channel, ctlnum);
int val = mp->hwCtrlState(channel, dctl);
if(val == CTRL_VAL_UNKNOWN)
return -1;
Event e(Controller);
- //e.setA(dctl);
e.setA(ctlnum);
e.setB(val);
// Do we replace an old event?
if(isEvent)
{
- // Don't bother if already set.
- if(ev.dataB() == val)
+ if(ev.dataB() == val) // Don't bother if already set.
return -1;
e.setTick(tick - part->tick());
@@ -2875,25 +2725,6 @@ int Song::execMidiAutomationCtlPopup(MidiTrack* track, MidiPart* part, const QPo
MusEGlobal::audio->msgDeleteEvent(ev, part, true, true, true);
break;
- //case CLEAR_RANGE:
- //MusEGlobal::audio->msgEraseRangeACEvents(track, acid, pos[1].frame(), pos[2].frame());
- //break;
-
- //case CLEAR_ALL_EVENTS:
- //if(QMessageBox::question(MusEGlobal::muse, QString("Muse"),
- // tr("Clear all controller events?"), tr("&Ok"), tr("&Cancel"),
- // QString::null, 0, 1 ) == 0)
- //MusEGlobal::audio->msgClearControllerEvents(track, acid);
- //break;
-
- //case PREV_EVENT:
- //MusEGlobal::audio->msgSeekPrevACEvent(track, acid);
- //break;
-
- //case NEXT_EVENT:
- //MusEGlobal::audio->msgSeekNextACEvent(track, acid);
- //break;
-
default:
return -1;
break;
@@ -3053,7 +2884,7 @@ void Song::connectJackRoutes(AudioTrack* track, bool disconnect)
void Song::insertTrack0(Track* track, int idx)
{
insertTrack1(track, idx);
- insertTrack2(track, idx); // MusEGlobal::audio->msgInsertTrack(track, idx, false);
+ insertTrack2(track, idx); // MusEGlobal::audio->msgInsertTrack(track, idx, false); DELETETHIS or is this somehow explanatory?
insertTrack3(track, idx);
}
@@ -3064,8 +2895,6 @@ void Song::insertTrack0(Track* track, int idx)
void Song::insertTrack1(Track* track, int /*idx*/)
{
- //printf("Song::insertTrack1 track:%lx\n", track);
-
switch(track->type()) {
case Track::AUDIO_SOFTSYNTH:
{
@@ -3079,9 +2908,6 @@ void Song::insertTrack1(Track* track, int /*idx*/)
default:
break;
}
-
- //printf("Song::insertTrack1 end of function\n");
-
}
//---------------------------------------------------------
@@ -3091,16 +2917,12 @@ void Song::insertTrack1(Track* track, int /*idx*/)
void Song::insertTrack2(Track* track, int idx)
{
- //printf("Song::insertTrack2 track:%lx\n", track);
-
int n;
switch(track->type()) {
case Track::MIDI:
case Track::DRUM:
case Track::NEW_DRUM:
_midis.push_back((MidiTrack*)track);
- // Added by T356.
- //((MidiTrack*)track)->addPortCtrlEvents();
addPortCtrlEvents(((MidiTrack*)track));
break;
@@ -3137,14 +2959,10 @@ void Song::insertTrack2(Track* track, int idx)
return;
}
- //
// initialize missing aux send
- //
iTrack i = _tracks.index2iterator(idx);
- //printf("Song::insertTrack2 inserting into _tracks...\n");
_tracks.insert(i, track);
- //printf("Song::insertTrack2 inserted\n");
n = _auxs.size();
for (iTrack i = _tracks.begin(); i != _tracks.end(); ++i) {
@@ -3156,18 +2974,13 @@ void Song::insertTrack2(Track* track, int idx)
}
}
- //
// add routes
- //
if (track->type() == Track::AUDIO_OUTPUT)
{
const RouteList* rl = track->inRoutes();
for (ciRoute r = rl->begin(); r != rl->end(); ++r)
{
- //if(r->track == track)
- // r->track->outRoutes()->push_back(*r);
- // p3.3.50
Route src(track, r->channel, r->channels);
src.remoteChannel = r->remoteChannel;
r->track->outRoutes()->push_back(src);
@@ -3175,8 +2988,7 @@ void Song::insertTrack2(Track* track, int idx)
// Update the Audio Output track's aux ref count. p4.0.37
if(r->track->auxRefCount())
track->updateAuxRoute( r->track->auxRefCount(), NULL );
- else
- if(r->track->type() == Track::AUDIO_AUX)
+ else if(r->track->type() == Track::AUDIO_AUX)
track->updateAuxRoute( 1, NULL );
}
}
@@ -3185,9 +2997,6 @@ void Song::insertTrack2(Track* track, int idx)
const RouteList* rl = track->outRoutes();
for (ciRoute r = rl->begin(); r != rl->end(); ++r)
{
- //if(r->track == track)
- // r->track->inRoutes()->push_back(*r);
- // p3.3.50
Route src(track, r->channel, r->channels);
src.remoteChannel = r->remoteChannel;
r->track->inRoutes()->push_back(src);
@@ -3195,8 +3004,7 @@ void Song::insertTrack2(Track* track, int idx)
// Update the other track's aux ref count and all tracks it is connected to. p4.0.37
if(track->auxRefCount())
r->track->updateAuxRoute( track->auxRefCount(), NULL );
- else
- if(track->type() == Track::AUDIO_AUX)
+ else if(track->type() == Track::AUDIO_AUX)
r->track->updateAuxRoute( 1, NULL );
}
}
@@ -3205,14 +3013,12 @@ void Song::insertTrack2(Track* track, int idx)
const RouteList* rl = track->inRoutes();
for (ciRoute r = rl->begin(); r != rl->end(); ++r)
{
- //printf("Song::insertTrack2 %s in route port:%d\n", track->name().toLatin1().constData(), r->midiPort);
Route src(track, r->channel);
MusEGlobal::midiPorts[r->midiPort].outRoutes()->push_back(src);
}
rl = track->outRoutes();
for (ciRoute r = rl->begin(); r != rl->end(); ++r)
{
- //printf("Song::insertTrack2 %s out route port:%d\n", track->name().toLatin1().constData(), r->midiPort);
Route src(track, r->channel);
MusEGlobal::midiPorts[r->midiPort].inRoutes()->push_back(src);
}
@@ -3222,9 +3028,6 @@ void Song::insertTrack2(Track* track, int idx)
const RouteList* rl = track->inRoutes();
for (ciRoute r = rl->begin(); r != rl->end(); ++r)
{
- //if(r->track == track)
- // r->track->outRoutes()->push_back(*r);
- // p3.3.50
Route src(track, r->channel, r->channels);
src.remoteChannel = r->remoteChannel;
r->track->outRoutes()->push_back(src);
@@ -3232,16 +3035,12 @@ void Song::insertTrack2(Track* track, int idx)
// Update this track's aux ref count. p4.0.37
if(r->track->auxRefCount())
track->updateAuxRoute( r->track->auxRefCount(), NULL );
- else
- if(r->track->type() == Track::AUDIO_AUX)
+ else if(r->track->type() == Track::AUDIO_AUX)
track->updateAuxRoute( 1, NULL );
}
rl = track->outRoutes();
for (ciRoute r = rl->begin(); r != rl->end(); ++r)
{
- //if(r->track == track)
- // r->track->inRoutes()->push_back(*r);
- // p3.3.50
Route src(track, r->channel, r->channels);
src.remoteChannel = r->remoteChannel;
r->track->inRoutes()->push_back(src);
@@ -3249,14 +3048,10 @@ void Song::insertTrack2(Track* track, int idx)
// Update the other track's aux ref count and all tracks it is connected to. p4.0.37
if(track->auxRefCount())
r->track->updateAuxRoute( track->auxRefCount(), NULL );
- else
- if(track->type() == Track::AUDIO_AUX)
+ else if(track->type() == Track::AUDIO_AUX)
r->track->updateAuxRoute( 1, NULL );
}
}
-
- //printf("Song::insertTrack2 end of function\n");
-
}
//---------------------------------------------------------
@@ -3278,7 +3073,6 @@ void Song::removeTrack0(Track* track)
removeTrack1(track);
MusEGlobal::audio->msgRemoveTrack(track);
removeTrack3(track);
- //delete track;
update(SC_TRACK_REMOVED);
}
@@ -3330,21 +3124,16 @@ void Song::removeTrack1(Track* track)
void Song::removeTrack2(Track* track)
{
- //printf("Song::removeTrack2 track:%s\n", track->name().toLatin1().constData());
-
switch(track->type()) {
case Track::MIDI:
case Track::DRUM:
case Track::NEW_DRUM:
- // Added by T356.
- //((MidiTrack*)track)->removePortCtrlEvents();
removePortCtrlEvents(((MidiTrack*)track));
unchainTrackParts(track, true);
_midis.erase(track);
break;
case Track::WAVE:
- // Added by T356.
unchainTrackParts(track, true);
_waves.erase(track);
@@ -3371,19 +3160,13 @@ void Song::removeTrack2(Track* track)
}
_tracks.erase(track);
- //
// remove routes
- //
if (track->type() == Track::AUDIO_OUTPUT)
{
const RouteList* rl = track->inRoutes();
for (ciRoute r = rl->begin(); r != rl->end(); ++r)
{
- //if(r->track == track)
- // r->track->outRoutes()->removeRoute(*r);
- //printf("Song::removeTrack2 %s audio out track:%s\n", track->name().toLatin1().constData(), r->track->name().toLatin1().constData());
- // p3.3.50
Route src(track, r->channel, r->channels);
src.remoteChannel = r->remoteChannel;
r->track->outRoutes()->removeRoute(src);
@@ -3391,8 +3174,7 @@ void Song::removeTrack2(Track* track)
// Update the Audio Output track's aux ref count. p4.0.37
if(r->track->auxRefCount())
track->updateAuxRoute( -r->track->auxRefCount(), NULL );
- else
- if(r->track->type() == Track::AUDIO_AUX)
+ else if(r->track->type() == Track::AUDIO_AUX)
track->updateAuxRoute( -1, NULL );
}
}
@@ -3401,10 +3183,6 @@ void Song::removeTrack2(Track* track)
const RouteList* rl = track->outRoutes();
for (ciRoute r = rl->begin(); r != rl->end(); ++r)
{
- //if(r->track == track)
- // r->track->inRoutes()->removeRoute(*r);
- //printf("Song::removeTrack2 %s audio in track:%s\n", track->name().toLatin1().constData(), r->track->name().toLatin1().constData());
- // p3.3.50
Route src(track, r->channel, r->channels);
src.remoteChannel = r->remoteChannel;
r->track->inRoutes()->removeRoute(src);
@@ -3412,8 +3190,7 @@ void Song::removeTrack2(Track* track)
// Update the other track's aux ref count and all tracks it is connected to. p4.0.37
if(track->auxRefCount())
r->track->updateAuxRoute( -track->auxRefCount(), NULL );
- else
- if(track->type() == Track::AUDIO_AUX)
+ else if(track->type() == Track::AUDIO_AUX)
r->track->updateAuxRoute( -1, NULL );
}
}
@@ -3422,14 +3199,12 @@ void Song::removeTrack2(Track* track)
const RouteList* rl = track->inRoutes();
for (ciRoute r = rl->begin(); r != rl->end(); ++r)
{
- //printf("Song::removeTrack2 %s in route port:%d\n", track->name().toLatin1().constData(), r->midiPort);
Route src(track, r->channel);
MusEGlobal::midiPorts[r->midiPort].outRoutes()->removeRoute(src);
}
rl = track->outRoutes();
for (ciRoute r = rl->begin(); r != rl->end(); ++r)
{
- //printf("Song::removeTrack2 %s out route port:%d\n", track->name().toLatin1().constData(), r->midiPort);
Route src(track, r->channel);
MusEGlobal::midiPorts[r->midiPort].inRoutes()->removeRoute(src);
}
@@ -3439,10 +3214,6 @@ void Song::removeTrack2(Track* track)
const RouteList* rl = track->inRoutes();
for (ciRoute r = rl->begin(); r != rl->end(); ++r)
{
- //if(r->track == track)
- // r->track->outRoutes()->removeRoute(*r);
- //printf("Song::removeTrack2 %s in route track:%s\n", track->name().toLatin1().constData(), r->track->name().toLatin1().constData());
- // p3.3.50
Route src(track, r->channel, r->channels);
src.remoteChannel = r->remoteChannel;
r->track->outRoutes()->removeRoute(src);
@@ -3450,17 +3221,12 @@ void Song::removeTrack2(Track* track)
// Update this track's aux ref count. p4.0.37
if(r->track->auxRefCount())
track->updateAuxRoute( -r->track->auxRefCount(), NULL );
- else
- if(r->track->type() == Track::AUDIO_AUX)
+ else if(r->track->type() == Track::AUDIO_AUX)
track->updateAuxRoute( -1, NULL );
}
rl = track->outRoutes();
for (ciRoute r = rl->begin(); r != rl->end(); ++r)
{
- //if(r->track == track)
- // r->track->inRoutes()->removeRoute(*r);
- //printf("Song::removeTrack2 %s out route track:%s\n", track->name().toLatin1().constData(), r->track->name().toLatin1().constData());
- // p3.3.50
Route src(track, r->channel, r->channels);
src.remoteChannel = r->remoteChannel;
r->track->inRoutes()->removeRoute(src);
@@ -3468,8 +3234,7 @@ void Song::removeTrack2(Track* track)
// Update the other track's aux ref count and all tracks it is connected to. p4.0.37
if(track->auxRefCount())
r->track->updateAuxRoute( -track->auxRefCount(), NULL );
- else
- if(track->type() == Track::AUDIO_AUX)
+ else if(track->type() == Track::AUDIO_AUX)
r->track->updateAuxRoute( -1, NULL );
}
}
@@ -3518,7 +3283,6 @@ void Song::executeScript(const char* scriptfile, PartList* parts, int quant, boo
fprintf(fp, "BEATLEN %d\n", AL::sigmap.ticksBeat(0));
fprintf(fp, "QUANTLEN %d\n", quant);
- //for (iCItem i = items.begin(); i != items.end(); ++i) {
for (iEvent e = part->events()->begin(); e != part->events()->end(); e++) {
Event ev = e->second;
@@ -3582,7 +3346,6 @@ void Song::executeScript(const char* scriptfile, PartList* parts, int quant, boo
QStringList sl = line.split(" ");
Event e(Controller);
- //int tick = sl[1].toInt();
int a = sl[2].toInt();
int b = sl[3].toInt();
int c = sl[4].toInt();
@@ -3606,11 +3369,8 @@ void Song::executeScript(const char* scriptfile, PartList* parts, int quant, boo
void Song::populateScriptMenu(QMenu* menuPlugins, QObject* receiver)
{
- //
// List scripts
- //
QString distScripts = MusEGlobal::museGlobalShare + "/scripts";
-
QString userScripts = MusEGlobal::configPath + "/scripts";
QFileInfo distScriptsFi(distScripts);
@@ -3630,13 +3390,9 @@ void Song::populateScriptMenu(QMenu* menuPlugins, QObject* receiver)
QSignalMapper* userSignalMapper = new QSignalMapper(this);
if (deliveredScriptNames.size() > 0 || userScriptNames.size() > 0) {
- //menuPlugins = new QPopupMenu(this);
- //menuBar()->insertItem(tr("&Plugins"), menuPlugins);
int id = 0;
if (deliveredScriptNames.size() > 0) {
for (QStringList::Iterator it = deliveredScriptNames.begin(); it != deliveredScriptNames.end(); it++, id++) {
- //menuPlugins->insertItem(*it, this, SLOT(execDeliveredScript(int)), 0, id);
- //menuPlugins->insertItem(*it, this, slot_deliveredscripts, 0, id);
QAction* act = menuPlugins->addAction(*it);
connect(act, SIGNAL(triggered()), distSignalMapper, SLOT(map()));
distSignalMapper->setMapping(act, id);
@@ -3645,7 +3401,6 @@ void Song::populateScriptMenu(QMenu* menuPlugins, QObject* receiver)
}
if (userScriptNames.size() > 0) {
for (QStringList::Iterator it = userScriptNames.begin(); it != userScriptNames.end(); it++, id++) {
- //menuPlugins->insertItem(*it, this, slot_userscripts, 0, id);
QAction* act = menuPlugins->addAction(*it);
connect(act, SIGNAL(triggered()), userSignalMapper, SLOT(map()));
userSignalMapper->setMapping(act, id);
diff --git a/muse2/muse/song.h b/muse2/muse/song.h
index 22a3a86c..7f0aae70 100644
--- a/muse2/muse/song.h
+++ b/muse2/muse/song.h
@@ -33,7 +33,6 @@
#include "pos.h"
#include "globaldefs.h"
#include "tempo.h"
-///#include "sig.h"
#include "al/sig.h"
#include "undo.h"
#include "track.h"
@@ -264,7 +263,6 @@ class Song : public QObject {
// event manipulations
//-----------------------------------------
- //void cmdAddRecordedWave(WaveTrack* track, const Pos&, const Pos&);
void cmdAddRecordedWave(WaveTrack* track, Pos, Pos);
void cmdAddRecordedEvents(MidiTrack*, EventList*, unsigned);
bool addEvent(Event&, Part*);
@@ -293,7 +291,6 @@ class Song : public QObject {
PartList* getSelectedWaveParts() const;
bool msgRemoveParts();
- //void cmdChangePart(Part* oldPart, Part* newPart);
void cmdChangePart(Part* oldPart, Part* newPart, bool doCtrls, bool doClones);
void cmdRemovePart(Part* part);
void cmdAddPart(Part* part);
@@ -319,7 +316,7 @@ class Song : public QObject {
void removeTrack2(Track* track);
void removeTrack3(Track* track);
void removeMarkedTracks();
- //void changeTrack(Track* oldTrack, Track* newTrack);
+ //void changeTrack(Track* oldTrack, Track* newTrack); DELETETHIS
MidiTrack* findTrack(const Part* part) const;
Track* findTrack(const QString& name) const;
void swapTracks(int i1, int i2);
@@ -339,7 +336,6 @@ class Song : public QObject {
int execMidiAutomationCtlPopup(MidiTrack*, MidiPart*, const QPoint&, int);
void connectJackRoutes(AudioTrack* track, bool disconnect);
void updateSoloStates();
- //void chooseMidiRoutes(QButton* /*parent*/, MidiTrack* /*track*/, bool /*dst*/);
//-----------------------------------------
// undo, redo
diff --git a/muse2/muse/songfile.cpp b/muse2/muse/songfile.cpp
index f76c16f9..07430c26 100644
--- a/muse2/muse/songfile.cpp
+++ b/muse2/muse/songfile.cpp
@@ -29,23 +29,18 @@
#include "song.h"
#include "arranger.h"
#include "arrangerview.h"
-//#include "arranger/arranger.h" // p4.0.2
#include "cobject.h"
#include "drumedit.h"
-//#include "midiedit/drumedit.h" // p4.0.2
#include "pianoroll.h"
#include "scoreedit.h"
-//#include "midiedit/pianoroll.h" // p4.0.2
#include "globals.h"
#include "xml.h"
#include "drummap.h"
-//#include "midiedit/drummap.h" // p4.0.2
#include "event.h"
#include "marker/marker.h"
#include "midiport.h"
#include "audio.h"
#include "mitplugin.h"
-//#include "mplugins/mitplugin.h" // p4.0.2
#include "wave.h"
#include "midictrl.h"
#include "amixer.h"
@@ -55,38 +50,13 @@
#include "keyevent.h"
namespace MusEGlobal {
-//static CloneList cloneList;
-//static CloneList copyCloneList;
MusECore::CloneList cloneList;
-//CloneList copyCloneList;
}
namespace MusECore {
-//struct ClonePart {
- //const EventList* el;
-// const Part* cp;
-// int id;
- //ClonePart(const EventList* e, int i) : el(e), id(i) {}
-// ClonePart(const Part* p, int i) : cp(p), id(i) {}
-// };
-//typedef std::list<ClonePart> CloneList;
-//typedef CloneList::iterator iClone;
-
-//---------------------------------------------------------
-// ClonePart
-//---------------------------------------------------------
-
-ClonePart::ClonePart(const Part* p, int i)
-{
- cp = p;
- id = i;
- uuid_generate(uuid);
-}
-
-
-/*
+/* DELETETHIS 42
//---------------------------------------------------------
// updateCloneList
//---------------------------------------------------------
@@ -219,41 +189,28 @@ Part* readXmlPart(Xml& xml, Track* track, bool doClone, bool toTrack)
case Xml::End:
return npart;
case Xml::TagStart:
- // If the part has not been created yet...
- if(!npart)
+ if(!npart) // If the part has not been created yet...
{
- // If an id was found...
- if(id != -1)
+ if(id != -1) // If an id was found...
{
for(iClone i = MusEGlobal::cloneList.begin(); i != MusEGlobal::cloneList.end(); ++i)
{
- // Is a matching part found in the clone list?
- if(i->id == id)
+ if(i->id == id) // Is a matching part found in the clone list?
{
- // If it's a regular paste (not paste clone), and the original part is
- // not a clone, defer so that a new copy is created in TagStart above.
- //if(!doClone && i->cp->cevents()->arefCount() <= 1)
- //if(!doClone && !isclone)
- // break;
-
// This makes a clone, chains the part, and increases ref counts.
npart = track->newPart((Part*)i->cp, true);
break;
}
}
}
- else
- // If a uuid was found...
- if(uuidvalid)
+ else if(uuidvalid) // If a uuid was found...
{
for(iClone i = MusEGlobal::cloneList.begin(); i != MusEGlobal::cloneList.end(); ++i)
{
- // Is a matching part found in the clone list?
- if(uuid_compare(uuid, i->uuid) == 0)
+ if(uuid_compare(uuid, i->uuid) == 0) // Is a matching part found in the clone list?
{
Track* cpt = i->cp->track();
- // If we want to paste to the given track...
- if(toTrack)
+ if(toTrack) // If we want to paste to the given track...
{
// If the given track type is not the same as the part's
// original track type, we can't continue. Just return.
@@ -263,15 +220,13 @@ Part* readXmlPart(Xml& xml, Track* track, bool doClone, bool toTrack)
return 0;
}
}
- else
- // ...else we want to paste to the part's original track.
+ else // ...else we want to paste to the part's original track.
{
// Make sure the track exists (has not been deleted).
if((cpt->isMidiTrack() && MusEGlobal::song->midis()->find(cpt) != MusEGlobal::song->midis()->end()) ||
(cpt->type() == Track::WAVE && MusEGlobal::song->waves()->find(cpt) != MusEGlobal::song->waves()->end()))
track = cpt;
- else
- // Track was not found. Try pasting to the given track, as above...
+ else // Track was not found. Try pasting to the given track, as above...
{
if(!track || cpt->type() != track->type())
{
@@ -284,7 +239,6 @@ Part* readXmlPart(Xml& xml, Track* track, bool doClone, bool toTrack)
// If it's a regular paste (not paste clone), and the original part is
// not a clone, defer so that a new copy is created in TagStart above.
- //if(!doClone && i->cp->cevents()->arefCount() <= 1)
if(!doClone && !isclone)
break;
@@ -295,12 +249,11 @@ Part* readXmlPart(Xml& xml, Track* track, bool doClone, bool toTrack)
}
}
- // If the part still has not been created yet...
- if(!npart)
+ if(!npart) // If the part still has not been created yet...
{
- // A clone was not created from any matching part. Create a non-clone part now.
- if(!track)
- {
+
+ if(!track) // A clone was not created from any matching
+ { // part. Create a non-clone part now.
xml.skip("part");
return 0;
}
@@ -387,6 +340,7 @@ Part* readXmlPart(Xml& xml, Track* track, bool doClone, bool toTrack)
e.move( -npart->tick() );
int tick = e.tick();
+ // DELETETHIS 7
// Do not discard events belonging to clone parts,
// at least not yet. A later clone might have a longer,
// fully accommodating part length!
@@ -396,7 +350,6 @@ Part* readXmlPart(Xml& xml, Track* track, bool doClone, bool toTrack)
// No choice but to accept all events past 0.
if(tick < 0)
{
- //printf("readClone: warning: event not in part: %d - %d -%d, discarded\n",
printf("readClone: warning: event at tick:%d not in part:%s, discarded\n",
tick, npart->name().toLatin1().constData());
}
@@ -405,8 +358,7 @@ Part* readXmlPart(Xml& xml, Track* track, bool doClone, bool toTrack)
npart->events()->add(e);
}
}
- else
- // ...Otherwise a clone was created, so we don't need the events.
+ else // ...Otherwise a clone was created, so we don't need the events.
xml.skip(tag);
}
else
@@ -421,7 +373,7 @@ Part* readXmlPart(Xml& xml, Track* track, bool doClone, bool toTrack)
else if (tag == "cloneId")
{
id = xml.s2().toInt();
- //if(id != -1)
+ //if(id != -1) DELETETHIS 19
//{
// for(iClone i = MusEGlobal::cloneList.begin(); i != MusEGlobal::cloneList.end(); ++i)
// {
@@ -447,7 +399,7 @@ Part* readXmlPart(Xml& xml, Track* track, bool doClone, bool toTrack)
if(!uuid_is_null(uuid))
{
uuidvalid = true;
- /*
+ /* DELETETHIS 50
for(iClone i = MusEGlobal::cloneList.begin(); i != MusEGlobal::cloneList.end(); ++i)
{
// Is a matching part found in the clone list?
@@ -517,7 +469,6 @@ Part* readXmlPart(Xml& xml, Track* track, bool doClone, bool toTrack)
// we can have 'Paste Clone' feature.
//---------------------------------------------------------
-//void Part::write(int level, Xml& xml) const
void Part::write(int level, Xml& xml, bool isCopy, bool forceWavePaths) const
{
const EventList* el = cevents();
@@ -529,28 +480,19 @@ void Part::write(int level, Xml& xml, bool isCopy, bool forceWavePaths) const
if(isCopy)
{
- //for(iClone i = copyCloneList.begin(); i != copyCloneList.end(); ++i)
for(iClone i = MusEGlobal::cloneList.begin(); i != MusEGlobal::cloneList.end(); ++i)
{
- //if(i->el == el) {
if(i->cp->cevents() == el)
{
- //id = i->id;
uuid_copy(uuid, i->uuid);
dumpEvents = false;
break;
}
}
- //if(id == -1)
if(uuid_is_null(uuid))
{
- //id = copyCloneList.size();
- //id = MusEGlobal::cloneList.size();
- //ClonePart cp(el, id);
- //ClonePart cp(this, id);
ClonePart cp(this);
uuid_copy(uuid, cp.uuid);
- //copyCloneList.push_back(cp);
MusEGlobal::cloneList.push_back(cp);
}
}
@@ -560,22 +502,17 @@ void Part::write(int level, Xml& xml, bool isCopy, bool forceWavePaths) const
{
for (iClone i = MusEGlobal::cloneList.begin(); i != MusEGlobal::cloneList.end(); ++i)
{
- //if (i->el == el) {
if (i->cp->cevents() == el)
{
id = i->id;
- //uuid_copy(id, i->uid);
dumpEvents = false;
break;
}
}
if (id == -1)
- //if(uuid_is_null(id))
{
id = MusEGlobal::cloneList.size();
- //ClonePart cp(el, id);
ClonePart cp(this, id);
- //ClonePart cp(this);
MusEGlobal::cloneList.push_back(cp);
}
}
@@ -588,9 +525,7 @@ void Part::write(int level, Xml& xml, bool isCopy, bool forceWavePaths) const
char sid[40]; // uuid string is 36 chars. Try 40 for good luck.
sid[0] = 0;
uuid_unparse_lower(uuid, sid);
- //if(midi)
- // xml.nput(level, "<midipart uuid=\"%s\"", sid);
- //else
+
if(wave)
xml.nput(level, "<part type=\"wave\" uuid=\"%s\"", sid);
else
@@ -603,22 +538,14 @@ void Part::write(int level, Xml& xml, bool isCopy, bool forceWavePaths) const
}
else
if (id != -1)
- //if(!uuid_is_null(id))
{
xml.tag(level++, "part cloneId=\"%d\"", id);
- //char sid[40]; // uuid string is 36 chars. Try 40 for good luck.
- //sid[0] = 0;
- //uuid_unparse_lower(id, sid);
- //xml.tag(level++, "part cloneId=\"%s\"", sid);
}
else
xml.tag(level++, "part");
xml.strTag(level, "name", _name);
-// PosLen poslen(*this);
-// int tickpos = tick();
-// poslen.setTick(tickpos);
PosLen::write(level, xml, "poslen");
xml.intTag(level, "selected", _selected);
xml.intTag(level, "color", _colorIndex);
@@ -626,12 +553,12 @@ void Part::write(int level, Xml& xml, bool isCopy, bool forceWavePaths) const
xml.intTag(level, "mute", _mute);
if (dumpEvents) {
for (ciEvent e = el->begin(); e != el->end(); ++e)
- //e->second.write(level, xml, *this);
e->second.write(level, xml, *this, forceWavePaths);
}
xml.etag(level, "part");
}
+// DELETETHIS 280! whoa!
/*
//---------------------------------------------------------
// Part::read
@@ -920,7 +847,6 @@ void Song::writeFont(int level, Xml& xml, const char* name,
const QFont& font) const
{
xml.nput(level, "<%s family=\"%s\" size=\"%d\"",
- //name, font.family().toLatin1().constData(), font.pointSize());
name, Xml::xmlString(font.family()).toLatin1().constData(), font.pointSize());
if (font.weight() != QFont::Normal)
xml.nput(" weight=\"%d\"", font.weight());
@@ -1183,33 +1109,18 @@ void Song::write(int level, Xml& xml) const
(*i)->write(level, xml);
// write routing
- for (ciTrack i = _tracks.begin(); i != _tracks.end(); ++i) {
-
- // p3.3.38 Changed
- //if ((*i)->isMidiTrack())
- // continue;
- //MusECore::WaveTrack* track = (MusECore::WaveTrack*)(*i);
- //track->writeRouting(level, xml);
-
+ for (ciTrack i = _tracks.begin(); i != _tracks.end(); ++i)
(*i)->writeRouting(level, xml);
- }
// Write midi device routing.
- for (iMidiDevice i = MusEGlobal::midiDevices.begin(); i != MusEGlobal::midiDevices.end(); ++i) {
- //MidiJackDevice* mjd = dynamic_cast<MidiJackDevice*>(*i);
- //if (!mjd)
- // continue;
- //mjd->writeRouting(level, xml);
+ for (iMidiDevice i = MusEGlobal::midiDevices.begin(); i != MusEGlobal::midiDevices.end(); ++i)
(*i)->writeRouting(level, xml);
- }
- // p3.3.49 Write midi port routing.
- for (int i = 0; i < MIDI_PORTS; ++i) {
+ // Write midi port routing.
+ for (int i = 0; i < MIDI_PORTS; ++i)
MusEGlobal::midiPorts[i].writeRouting(level, xml);
- }
MusEGlobal::tempomap.write(level, xml);
- ///sigmap.write(level, xml);
AL::sigmap.write(level, xml);
MusEGlobal::keymap.write(level, xml);
_markerList->write(level, xml);
@@ -1386,7 +1297,7 @@ void MusE::readToplevels(MusECore::Xml& xml)
void MusE::readCtrl(MusECore::Xml&, int /*prt*/, int /*channel*/)
{
-#if 0
+#if 0 // DELETETHIS 30. delete the whole function?
ChannelState* iState = MusEGlobal::midiPorts[prt].iState(channel);
int idx = 0;
@@ -1410,7 +1321,6 @@ void MusE::readCtrl(MusECore::Xml&, int /*prt*/, int /*channel*/)
case MusECore::Xml::TagEnd:
if (xml.s1() == "ctrl") {
iState->controller[idx] = val;
-// printf("%d %d ctrl %d val %d\n", prt, channel, idx, val);
return;
}
default:
@@ -1427,7 +1337,6 @@ void MusE::readCtrl(MusECore::Xml&, int /*prt*/, int /*channel*/)
void MusE::readMidichannel(MusECore::Xml& xml, int prt)
{
int channel = 0;
-// MidiPort* port = &MusEGlobal::midiPorts[prt];
for (;;) {
MusECore::Xml::Token token = xml.parse();
@@ -1438,7 +1347,7 @@ void MusE::readMidichannel(MusECore::Xml& xml, int prt)
return;
case MusECore::Xml::TagStart:
if (tag == "pitch") {
-//TODO port->setCtrl(channel, 0, CTRL_PITCH, xml.parseInt());
+//TODO port->setCtrl(channel, 0, CTRL_PITCH, xml.parseInt()); DELETETHIS? and below
}
else if (tag == "program") {
//TODO port->setCtrl(channel, 0, CTRL_PROGRAM, xml.parseInt());
@@ -1507,6 +1416,9 @@ void MusE::readMidiport(MusECore::Xml& xml)
void MusE::read(MusECore::Xml& xml, bool doReadMidiPorts, bool isTemplate)
{
bool skipmode = true;
+
+ writeTopwinState=true;
+
for (;;) {
if (progress)
progress->setValue(progress->value()+1);
@@ -1563,6 +1475,14 @@ void MusE::read(MusECore::Xml& xml, bool doReadMidiPorts, bool isTemplate)
readStatusMidiInputTransformPlugin(xml);
else if (tag == "toplevels")
readToplevels(xml);
+ else if (tag == "no_toplevels")
+ {
+ if (!isTemplate)
+ writeTopwinState=false;
+
+ xml.skip("no_toplevels");
+ }
+
else
xml.unknown("muse");
break;
@@ -1588,7 +1508,7 @@ void MusE::read(MusECore::Xml& xml, bool doReadMidiPorts, bool isTemplate)
// write song
//---------------------------------------------------------
-void MusE::write(MusECore::Xml& xml) const
+void MusE::write(MusECore::Xml& xml, bool writeTopwins) const
{
xml.header();
@@ -1600,7 +1520,7 @@ void MusE::write(MusECore::Xml& xml) const
MusEGlobal::song->write(level, xml);
- if (!toplevels.empty()) {
+ if (writeTopwins && !toplevels.empty()) {
xml.tag(level++, "toplevels");
for (MusEGui::ciToplevel i = toplevels.begin(); i != toplevels.end(); ++i) {
if ((*i)->isVisible())
@@ -1608,6 +1528,11 @@ void MusE::write(MusECore::Xml& xml) const
}
xml.tag(level--, "/toplevels");
}
+ else if (!writeTopwins)
+ {
+ xml.tag(level, "no_toplevels");
+ xml.etag(level, "no_toplevels");
+ }
xml.tag(level, "/muse");
}
diff --git a/muse2/muse/stringparam.h b/muse2/muse/stringparam.h
index 448c61b6..2ab2ba37 100644
--- a/muse2/muse/stringparam.h
+++ b/muse2/muse/stringparam.h
@@ -33,21 +33,19 @@ namespace MusECore {
class Xml;
-//typedef std::pair<std::string, std::string > StringParamMapItem;
typedef std::map<std::string, std::string >::iterator iStringParamMap;
typedef std::map<std::string, std::string >::const_iterator ciStringParamMap;
class StringParamMap : public std::map<std::string, std::string >
{
public:
- void set(const char* /*key*/, const char* /*value*/);
- void remove(const char* /*key*/);
+ void set(const char* key, const char* value);
+ void remove(const char* key);
- iStringParamMap findKey(const char* /*key*/);
- //int index(char* /*key*/);
+ iStringParamMap findKey(const char* key);
- void read(Xml& /*xml*/, const QString& /*name*/);
- void write(int /*level*/, Xml& /*xml*/, const char* /*name*/) const;
+ void read(Xml& xml, const QString& name);
+ void write(int level, Xml& xml, const char* name) const;
};
} // namespace MusECore
diff --git a/muse2/muse/structure.cpp b/muse2/muse/structure.cpp
index d1d8d3a1..65489cac 100644
--- a/muse2/muse/structure.cpp
+++ b/muse2/muse/structure.cpp
@@ -145,7 +145,6 @@ void globalCut(bool onlySelectedTracks)
TrackList* tracks = MusEGlobal::song->tracks();
for (iTrack it = tracks->begin(); it != tracks->end(); ++it) {
- //MidiTrack* track = dynamic_cast<MidiTrack*>(*it);
Track* track = *it;
if (track == 0 || (onlySelectedTracks && !track->selected()))
continue;
@@ -169,7 +168,6 @@ void globalCut(bool onlySelectedTracks)
nPart = new WavePart(*(WavePart*)part);
nPart->setLenTick(len);
- //
// cut Events in nPart
EventList* el = nPart->events();
for (iEvent ie = el->lower_bound(len); ie != el->end(); ++ie)
@@ -214,7 +212,6 @@ void globalCut(bool onlySelectedTracks)
nPart = new MidiPart(*(MidiPart*)part);
else
nPart = new WavePart(*(WavePart*)part);
- //MidiPart* nPart = new MidiPart(*(MidiPart*)part);
int nt = part->tick();
nPart->setTick(nt - (rpos -lpos));
// Indicate no undo, and do port controller values but not clone parts.
diff --git a/muse2/muse/style.qss b/muse2/muse/style.qss
index d3eb889d..f196ff19 100644
--- a/muse2/muse/style.qss
+++ b/muse2/muse/style.qss
@@ -5,7 +5,7 @@
/* TODO */
-/*
+/* DELETETHIS all?
QLabel#midiChannelLabel { font-size: 6pt }
MidiRack, EffectRack { font-size: 8pt }
@@ -70,4 +70,4 @@ QLabel#M-Synth {
background-color: gray;
}
-*/ \ No newline at end of file
+*/
diff --git a/muse2/muse/sync.cpp b/muse2/muse/sync.cpp
index 5cdc9729..56560a5e 100644
--- a/muse2/muse/sync.cpp
+++ b/muse2/muse/sync.cpp
@@ -31,18 +31,12 @@
#include "midiseq.h"
#include "audio.h"
#include "audiodev.h"
-//#include "driver/audiodev.h" // p4.0.2
#include "gconfig.h"
#include "xml.h"
#include "midi.h"
namespace MusEGlobal {
-//int rxSyncPort = -1; // receive from all ports
-//int txSyncPort = 1;
-//int rxDeviceId = 0x7f; // any device
-//int txDeviceId = 0x7f; // any device
-//MidiSyncPort midiSyncPorts[MIDI_PORTS];
int volatile curMidiSyncInPort = -1;
bool debugSync = false;
@@ -50,12 +44,6 @@ bool debugSync = false;
int mtcType = 1;
MusECore::MTC mtcOffset;
MusECore::BValue extSyncFlag(0, "extSync"); // false - MASTER, true - SLAVE
-//bool genMTCSync = false; // output MTC Sync
-//bool genMCSync = false; // output MidiClock Sync
-//bool genMMC = false; // output Midi Machine Control
-//bool acceptMTC = false;
-//bool acceptMC = true;
-//bool acceptMMC = true;
MusECore::BValue useJackTransport(0,"useJackTransport");
bool volatile jackTransportMaster = true;
@@ -65,16 +53,14 @@ static bool mtcValid;
static int mtcLost;
static bool mtcSync; // receive complete mtc frame?
-// p3.3.28
static bool playPendingFirstClock = false;
unsigned int syncSendFirstClockDelay = 1; // In milliseconds.
-//static int lastStoppedBeat = 0;
static unsigned int curExtMidiSyncTick = 0;
unsigned int volatile lastExtMidiSyncTick = 0;
double volatile curExtMidiSyncTime = 0.0;
double volatile lastExtMidiSyncTime = 0.0;
-// Not used yet.
+// Not used yet. DELETETHIS?
// static bool mcStart = false;
// static int mcStartTick;
@@ -124,7 +110,6 @@ MidiSyncInfo::MidiSyncInfo()
_MTCDetect = false;
_recMTCtype = 0;
_recRewOnStart = true;
- //_sendContNotStart = false;
_actDetectBits = 0;
for(int i = 0; i < MIDI_CHANNELS; ++i)
{
@@ -140,8 +125,6 @@ MidiSyncInfo::MidiSyncInfo()
MidiSyncInfo& MidiSyncInfo::operator=(const MidiSyncInfo &sp)
{
- //_port = sp._port;
-
copyParams(sp);
_lastClkTime = sp._lastClkTime;
@@ -175,8 +158,6 @@ MidiSyncInfo& MidiSyncInfo::operator=(const MidiSyncInfo &sp)
MidiSyncInfo& MidiSyncInfo::copyParams(const MidiSyncInfo &sp)
{
- //_port = sp._port;
-
_idOut = sp._idOut;
_idIn = sp._idIn;
_sendMC = sp._sendMC;
@@ -188,7 +169,6 @@ MidiSyncInfo& MidiSyncInfo::copyParams(const MidiSyncInfo &sp)
_recMMC = sp._recMMC;
_recMTC = sp._recMTC;
_recRewOnStart = sp._recRewOnStart;
- //_sendContNotStart = sp._sendContNotStart;
return *this;
}
@@ -235,7 +215,7 @@ void MidiSyncInfo::setTime()
if(_MRTDetect && (t - _lastMRTTime) >= 1.0) // Set detect indicator timeout to about 1 second.
{
_MRTDetect = false;
- // Give up the current midi sync in port number if we took it...
+ // Give up the current midi sync in port number if we took it... DELETETHIS 3
//if(MusEGlobal::curMidiSyncInPort == _port)
// MusEGlobal::curMidiSyncInPort = -1;
}
@@ -249,7 +229,7 @@ void MidiSyncInfo::setTime()
if(_MMCDetect && (t - _lastMMCTime) >= 1.0) // Set detect indicator timeout to about 1 second.
{
_MMCDetect = false;
- // Give up the current midi sync in port number if we took it...
+ // Give up the current midi sync in port number if we took it... DELETETHIS 3
//if(MusEGlobal::curMidiSyncInPort == _port)
// MusEGlobal::curMidiSyncInPort = -1;
}
@@ -279,7 +259,6 @@ void MidiSyncInfo::setTime()
if(_actDetect[i] && (t - _lastActTime[i]) >= 1.0) // Set detect indicator timeout to about 1 second.
{
_actDetect[i] = false;
- //_actDetectBits &= ~bitShiftLU[i];
_actDetectBits &= ~(1 << i);
}
}
@@ -304,6 +283,7 @@ void MidiSyncInfo::setMCIn(const bool v)
void MidiSyncInfo::setMRTIn(const bool v)
{
_recMRT = v;
+ // DELETETHIS 4
// If sync receive was turned off, clear the current midi sync in port number so another port can grab it.
//if(!_recMRT && _port != -1 && MusEGlobal::curMidiSyncInPort == _port)
// MusEGlobal::curMidiSyncInPort = -1;
@@ -316,6 +296,7 @@ void MidiSyncInfo::setMRTIn(const bool v)
void MidiSyncInfo::setMMCIn(const bool v)
{
_recMMC = v;
+ // DELETETHIS 4
// If sync receive was turned off, clear the current midi sync in port number so another port can grab it.
//if(!_recMMC && _port != -1 && MusEGlobal::curMidiSyncInPort == _port)
// MusEGlobal::curMidiSyncInPort = -1;
@@ -364,7 +345,7 @@ void MidiSyncInfo::trigMRTDetect()
{
_MRTDetect = true;
_MRTTrig = true;
- // Set the current midi sync in port number if it's not taken...
+ // Set the current midi sync in port number if it's not taken... //DELETETHIS 3
//if(_recMRT && MusEGlobal::curMidiSyncInPort == -1)
// MusEGlobal::curMidiSyncInPort = _port;
}
@@ -377,7 +358,7 @@ void MidiSyncInfo::trigMMCDetect()
{
_MMCDetect = true;
_MMCTrig = true;
- // Set the current midi sync in port number if it's not taken...
+ // Set the current midi sync in port number if it's not taken... DELETETHIS 3
//if(_recMMC && MusEGlobal::curMidiSyncInPort == -1)
// MusEGlobal::curMidiSyncInPort = _port;
}
@@ -416,7 +397,6 @@ void MidiSyncInfo::trigActDetect(const int ch)
if(ch < 0 || ch >= MIDI_CHANNELS)
return;
- //_actDetectBits |= bitShiftLU[ch];
_actDetectBits |= (1 << ch);
_actDetect[ch] = true;
_actTrig[ch] = true;
@@ -429,7 +409,7 @@ void MidiSyncInfo::trigActDetect(const int ch)
bool MidiSyncInfo::isDefault() const
{
return(_idOut == 127 && _idIn == 127 && !_sendMC && !_sendMRT && !_sendMMC && !_sendMTC &&
- /* !_sendContNotStart && */ !_recMC && !_recMRT && !_recMMC && !_recMTC && _recRewOnStart);
+ !_recMC && !_recMRT && !_recMMC && !_recMTC && _recRewOnStart);
}
//---------------------------------------------------------
@@ -458,8 +438,6 @@ void MidiSyncInfo::read(Xml& xml)
_sendMMC = xml.parseInt();
else if (tag == "sendMTC")
_sendMTC = xml.parseInt();
- //else if (tag == "sendContNotStart")
- // _sendContNotStart = xml.parseInt();
else if (tag == "recMC")
_recMC = xml.parseInt();
else if (tag == "recMRT")
@@ -486,26 +464,13 @@ void MidiSyncInfo::read(Xml& xml)
// write
//---------------------------------------------------------
-//void MidiSyncInfo::write(int level, Xml& xml, MidiDevice* md)
void MidiSyncInfo::write(int level, Xml& xml)
{
- //if(!md)
- // return;
-
- // All defaults? Nothing to write.
- //if(_idOut == 127 && _idIn == 127 && !_sendMC && !_sendMRT && !_sendMMC && !_sendMTC &&
- // /* !_sendContNotStart && */ !_recMC && !_recMRT && !_recMMC && !_recMTC && _recRewOnStart)
- // return;
if(isDefault())
return;
xml.tag(level++, "midiSyncInfo");
- //xml.intTag(level, "idx", idx);
- //xml.intTag(level++, "midiSyncPort", idx);
- //xml.tag(level++, "midiSyncInfo idx=\"%d\"", idx);
-
- //xml.strTag(level, "device", md->name());
-
+
if(_idOut != 127)
xml.intTag(level, "idOut", _idOut);
if(_idIn != 127)
@@ -515,12 +480,10 @@ void MidiSyncInfo::write(int level, Xml& xml)
xml.intTag(level, "sendMC", true);
if(_sendMRT)
xml.intTag(level, "sendMRT", true);
- if(_sendMRT)
+ if(_sendMMC)
xml.intTag(level, "sendMMC", true);
if(_sendMTC)
xml.intTag(level, "sendMTC", true);
- //if(_sendContNotStart)
- // xml.intTag(level, "sendContNotStart", true);
if(_recMC)
xml.intTag(level, "recMC", true);
@@ -541,7 +504,6 @@ void MidiSyncInfo::write(int level, Xml& xml)
// Midi Machine Control Input received
//---------------------------------------------------------
-//void MidiSeq::mmcInput(const unsigned char* p, int n)
void MidiSeq::mmcInput(int port, const unsigned char* p, int n)
{
if (MusEGlobal::debugSync)
@@ -560,10 +522,6 @@ void MidiSeq::mmcInput(int port, const unsigned char* p, int n)
if(!msync.MMCIn())
return;
- //if (!(MusEGlobal::extSyncFlag.value() && acceptMMC))
- //if(!MusEGlobal::extSyncFlag.value())
- // return;
-
switch(p[3]) {
case 1:
if (MusEGlobal::debugSync)
@@ -571,12 +529,10 @@ void MidiSeq::mmcInput(int port, const unsigned char* p, int n)
MusEGlobal::playPendingFirstClock = false;
- //if ((state == PLAY || state == PRECOUNT))
if (MusEGlobal::audio->isPlaying())
MusEGlobal::audio->msgPlay(false);
playStateExt = false;
alignAllTicks();
- //stopPlay();
break;
case 2:
if (MusEGlobal::debugSync)
@@ -588,7 +544,6 @@ void MidiSeq::mmcInput(int port, const unsigned char* p, int n)
MusEGlobal::mtcValid = false;
MusEGlobal::mtcLost = 0;
MusEGlobal::mtcSync = false;
- //startPlay();
alignAllTicks();
MusEGlobal::audio->msgPlay(true);
playStateExt = true;
@@ -623,23 +578,16 @@ void MidiSeq::mmcInput(int port, const unsigned char* p, int n)
if (!MusEGlobal::checkAudioDevice()) return;
MTC mtc(p[6] & 0x1f, p[7], p[8], p[9], p[10]);
int type = (p[6] >> 5) & 3;
- //int mmcPos = MusEGlobal::tempomap.frame2tick(lrint(mtc.time()*MusEGlobal::sampleRate));
- //int mmcPos = lrint(mtc.time()*MusEGlobal::sampleRate);
int mmcPos = lrint(mtc.time(type) * MusEGlobal::sampleRate);
- //Pos tp(mmcPos, true);
Pos tp(mmcPos, false);
- //MusEGlobal::audioDevice->seekTransport(tp.frame());
MusEGlobal::audioDevice->seekTransport(tp);
alignAllTicks();
- //seek(tp);
if (MusEGlobal::debugSync) {
- //printf("MMC: %f %d seek ", mtc.time(), mmcPos);
printf("MMC: LOCATE mtc type:%d time:%lf frame:%d mtc: ", type, mtc.time(), mmcPos);
mtc.print();
printf("\n");
}
- //write(sigFd, "G", 1);
break;
}
// fall through
@@ -653,12 +601,9 @@ void MidiSeq::mmcInput(int port, const unsigned char* p, int n)
// process Quarter Frame Message
//---------------------------------------------------------
-//void MidiSeq::mtcInputQuarter(int, unsigned char c)
void MidiSeq::mtcInputQuarter(int port, unsigned char c)
{
static int hour, min, sec, frame;
-
- //printf("MidiSeq::mtcInputQuarter c:%h\n", c);
int valL = c & 0xf;
int valH = valL << 4;
@@ -727,9 +672,7 @@ void MidiSeq::mtcInputQuarter(int port, unsigned char c)
}
else if (MusEGlobal::mtcValid && (MusEGlobal::mtcLost == 0))
{
- //MusEGlobal::mtcCurTime.incQuarter();
MusEGlobal::mtcCurTime.incQuarter(type);
- //MusEGlobal::mtcSyncMsg(MusEGlobal::mtcCurTime, type, false);
}
}
@@ -738,13 +681,10 @@ void MidiSeq::mtcInputQuarter(int port, unsigned char c)
// process Frame Message
//---------------------------------------------------------
-//void MidiSeq::mtcInputFull(const unsigned char* p, int n)
void MidiSeq::mtcInputFull(int port, const unsigned char* p, int n)
{
if (MusEGlobal::debugSync)
printf("mtcInputFull\n");
- //if (!MusEGlobal::extSyncFlag.value())
- // return;
if (p[3] != 1) {
if (p[3] != 2) { // silently ignore user bits
@@ -779,10 +719,8 @@ void MidiSeq::mtcInputFull(int port, const unsigned char* p, int n)
msync.setRecMTCtype(type);
msync.trigMTCDetect();
// MTC in not turned on? Forget it.
- //if(MusEGlobal::extSyncFlag.value() && msync.MTCIn())
if(msync.MTCIn())
{
- //Pos tp(lrint(MusEGlobal::mtcCurTime.time() * MusEGlobal::sampleRate), false);
Pos tp(lrint(MusEGlobal::mtcCurTime.time(type) * MusEGlobal::sampleRate), false);
MusEGlobal::audioDevice->seekTransport(tp);
alignAllTicks();
@@ -794,10 +732,8 @@ void MidiSeq::mtcInputFull(int port, const unsigned char* p, int n)
// nonRealtimeSystemSysex
//---------------------------------------------------------
-//void MidiSeq::nonRealtimeSystemSysex(const unsigned char* p, int n)
void MidiSeq::nonRealtimeSystemSysex(int /*port*/, const unsigned char* p, int n)
{
-// int chan = p[2];
switch(p[3]) {
case 4:
printf("NRT Setup\n");
@@ -822,30 +758,23 @@ void MidiSeq::setSongPosition(int port, int midiBeat)
if (MusEGlobal::midiInputTrace)
printf("set song position port:%d %d\n", port, midiBeat);
- //MusEGlobal::midiPorts[port].syncInfo().trigMCSyncDetect();
MusEGlobal::midiPorts[port].syncInfo().trigMRTDetect();
- //if (!MusEGlobal::extSyncFlag.value())
- // External sync not on? Clock in not turned on?
- //if(!MusEGlobal::extSyncFlag.value() || !MusEGlobal::midiPorts[port].syncInfo().MCIn())
if(!MusEGlobal::extSyncFlag.value() || !MusEGlobal::midiPorts[port].syncInfo().MRTIn())
return;
// Re-transmit song position to other devices if clock out turned on.
for(int p = 0; p < MIDI_PORTS; ++p)
- //if(p != port && MusEGlobal::midiPorts[p].syncInfo().MCOut())
if(p != port && MusEGlobal::midiPorts[p].syncInfo().MRTOut())
MusEGlobal::midiPorts[p].sendSongpos(midiBeat);
MusEGlobal::curExtMidiSyncTick = (MusEGlobal::config.division * midiBeat) / 4;
MusEGlobal::lastExtMidiSyncTick = MusEGlobal::curExtMidiSyncTick;
- //Pos pos((MusEGlobal::config.division * midiBeat) / 4, true);
Pos pos(MusEGlobal::curExtMidiSyncTick, true);
if (!MusEGlobal::checkAudioDevice()) return;
- //MusEGlobal::audioDevice->seekTransport(pos.frame());
MusEGlobal::audioDevice->seekTransport(pos);
alignAllTicks(pos.frame());
if (MusEGlobal::debugSync)
@@ -859,8 +788,6 @@ void MidiSeq::setSongPosition(int port, int midiBeat)
//---------------------------------------------------------
void MidiSeq::alignAllTicks(int frameOverride)
{
- //printf("alignAllTicks audioDriver->framePos=%d, audio->pos().frame()=%d\n",
- // MusEGlobal::audioDevice->framePos(), audio->pos().frame());
unsigned curFrame;
if (!frameOverride)
curFrame = MusEGlobal::audio->pos().frame();
@@ -906,13 +833,6 @@ void MidiSeq::realtimeSystemInput(int port, int c)
if (MusEGlobal::midiInputTrace)
printf("realtimeSystemInput port:%d 0x%x\n", port+1, c);
- //if (MusEGlobal::midiInputTrace && (rxSyncPort != port) && rxSyncPort != -1) {
- // if (MusEGlobal::debugSync)
- // printf("rxSyncPort configured as %d; received sync from port %d\n",
- // rxSyncPort, port);
- // return;
- // }
-
MidiPort* mp = &MusEGlobal::midiPorts[port];
// Trigger on any tick, clock, or realtime command.
@@ -944,8 +864,6 @@ void MidiSeq::realtimeSystemInput(int port, int c)
if(port != MusEGlobal::curMidiSyncInPort)
break;
- //printf("midi clock:%f\n", curTime());
-
// Re-transmit clock to other devices if clock out turned on.
// Must be careful not to allow more than one clock input at a time.
// Would re-transmit mixture of multiple clocks - confusing receivers.
@@ -955,7 +873,6 @@ void MidiSeq::realtimeSystemInput(int port, int c)
if(p != port && MusEGlobal::midiPorts[p].syncInfo().MCOut())
MusEGlobal::midiPorts[p].sendClock();
- // p3.3.28
if(MusEGlobal::playPendingFirstClock)
{
MusEGlobal::playPendingFirstClock = false;
@@ -965,10 +882,9 @@ void MidiSeq::realtimeSystemInput(int port, int c)
if(!MusEGlobal::audio->isPlaying())
MusEGlobal::audioDevice->startTransport();
}
- //else
+ //else DELETETHIS?
// This part will be run on the second and subsequent clocks, after start.
// Can't check audio state, might not be playing yet, we might miss some increments.
- //if(MusEGlobal::audio->isPlaying())
if(playStateExt)
{
MusEGlobal::lastExtMidiSyncTime = MusEGlobal::curExtMidiSyncTime;
@@ -979,7 +895,7 @@ void MidiSeq::realtimeSystemInput(int port, int c)
MusEGlobal::curExtMidiSyncTick += div;
}
-//BEGIN : Original code:
+//BEGIN : Original code: DELETETHIS 250
/*
double mclock0 = curTime();
// Difference in time last 2 rounds:
@@ -1230,6 +1146,7 @@ void MidiSeq::realtimeSystemInput(int port, int c)
}
break;
case ME_TICK: // midi tick (every 10 msec)
+ //DELETETHIS 6
// FIXME: Unfinished? mcStartTick is uninitialized and Song::setPos doesn't set it either. Dangerous to allow this.
//if (mcStart) {
// song->setPos(0, mcStartTick);
@@ -1240,10 +1157,8 @@ void MidiSeq::realtimeSystemInput(int port, int c)
case ME_START: // start
// Re-transmit start to other devices if clock out turned on.
for(int p = 0; p < MIDI_PORTS; ++p)
- //if(p != port && MusEGlobal::midiPorts[p].syncInfo().MCOut())
if(p != port && MusEGlobal::midiPorts[p].syncInfo().MRTOut())
{
- // p3.3.31
// If we aren't rewinding on start, there's no point in re-sending start.
// Re-send continue instead, for consistency.
if(MusEGlobal::midiPorts[port].syncInfo().recRewOnStart())
@@ -1254,34 +1169,26 @@ void MidiSeq::realtimeSystemInput(int port, int c)
if (MusEGlobal::debugSync)
printf(" start\n");
- //printf("midi start:%f\n", curTime());
+ // DELETETHIS, remove the wrapping if(true)
if (1 /* !MusEGlobal::audio->isPlaying()*/ /*state == IDLE*/) {
if (!MusEGlobal::checkAudioDevice()) return;
- // p3.3.31
// Rew on start option.
if(MusEGlobal::midiPorts[port].syncInfo().recRewOnStart())
{
MusEGlobal::curExtMidiSyncTick = 0;
MusEGlobal::lastExtMidiSyncTick = MusEGlobal::curExtMidiSyncTick;
- //MusEGlobal::audioDevice->seekTransport(0);
MusEGlobal::audioDevice->seekTransport(Pos(0, false));
}
- //unsigned curFrame = MusEGlobal::audio->curFrame();
- //if (MusEGlobal::debugSync)
- // printf(" curFrame=%d\n", curFrame);
-
alignAllTicks();
- //if (MusEGlobal::debugSync)
- // printf(" curFrame: %d curTick: %d tempo: %d\n", curFrame, recTick, MusEGlobal::tempomap.tempo(0));
storedtimediffs = 0;
for (int i=0; i<24; i++)
timediff[i] = 0.0;
- // p3.3.26 1/23/10
+ // p3.3.26 1/23/10 DELETETHIS 6
// Changed because msgPlay calls MusEGlobal::audioDevice->seekTransport(song->cPos())
// and song->cPos() may not be changed to 0 yet, causing tranport not to go to 0.
//MusEGlobal::audio->msgPlay(true);
@@ -1296,7 +1203,6 @@ void MidiSeq::realtimeSystemInput(int port, int c)
case ME_CONTINUE: // continue
// Re-transmit continue to other devices if clock out turned on.
for(int p = 0; p < MIDI_PORTS; ++p)
- //if(p != port && MusEGlobal::midiPorts[p].syncInfo().MCOut())
if(p != port && MusEGlobal::midiPorts[p].syncInfo().MRTOut())
MusEGlobal::midiPorts[p].sendContinue();
@@ -1321,7 +1227,6 @@ void MidiSeq::realtimeSystemInput(int port, int c)
break;
case ME_STOP: // stop
{
- // p3.3.35
// Stop the increment right away.
MusEGlobal::midiExtSyncTicks = 0;
playStateExt = false;
@@ -1329,25 +1234,17 @@ void MidiSeq::realtimeSystemInput(int port, int c)
// Re-transmit stop to other devices if clock out turned on.
for(int p = 0; p < MIDI_PORTS; ++p)
- //if(p != port && MusEGlobal::midiPorts[p].syncInfo().MCOut())
if(p != port && MusEGlobal::midiPorts[p].syncInfo().MRTOut())
MusEGlobal::midiPorts[p].sendStop();
- //MusEGlobal::playPendingFirstClock = false;
-
- //lastStoppedBeat = (MusEGlobal::audio->tickPos() * 4) / MusEGlobal::config.division;
- //MusEGlobal::curExtMidiSyncTick = (MusEGlobal::config.division * lastStoppedBeat) / 4;
-
- //printf("stop:%f\n", curTime());
- if (MusEGlobal::audio->isPlaying() /*state == PLAY*/) {
+ if (MusEGlobal::audio->isPlaying())
MusEGlobal::audio->msgPlay(false);
- //playStateExt = false;
- }
if (MusEGlobal::debugSync)
printf("realtimeSystemInput stop\n");
+ //DELETETHIS 7
// Just in case the process still runs a cycle or two and causes the
// audio tick position to increment, reset the incrementer and force
// the transport position to what the hardware thinks is the current position.
@@ -1358,7 +1255,7 @@ void MidiSeq::realtimeSystemInput(int port, int c)
}
break;
- //case 0xfd: // unknown
+ //case 0xfd: // unknown DELETETHIS 3
//case ME_SENSE: // active sensing
//case ME_META: // system reset (reset is 0xff same enumeration as file meta event)
default:
@@ -1381,10 +1278,7 @@ void MidiSeq::mtcSyncMsg(const MTC& mtc, int type, bool seekFlag)
if (MusEGlobal::debugSync)
printf("MidiSeq::MusEGlobal::mtcSyncMsg time:%lf stime:%lf seekFlag:%d\n", time, stime, seekFlag);
- if (seekFlag && MusEGlobal::audio->isRunning() /*state == START_PLAY*/) {
-// int tick = MusEGlobal::tempomap.time2tick(time);
- //state = PLAY;
- //write(sigFd, "1", 1); // say PLAY to gui
+ if (seekFlag && MusEGlobal::audio->isRunning()) {
if (!MusEGlobal::checkAudioDevice()) return;
if (MusEGlobal::debugSync)
printf("MidiSeq::MusEGlobal::mtcSyncMsg starting transport.\n");
@@ -1392,7 +1286,7 @@ void MidiSeq::mtcSyncMsg(const MTC& mtc, int type, bool seekFlag)
return;
}
- /*if (tempoSN != MusEGlobal::tempomap.tempoSN()) {
+ /*if (tempoSN != MusEGlobal::tempomap.tempoSN()) { DELETETHIS 13
double cpos = MusEGlobal::tempomap.tick2time(_midiTick, 0);
samplePosStart = samplePos - lrint(cpos * MusEGlobal::sampleRate);
rtcTickStart = rtcTick - lrint(cpos * realRtcTicks);
diff --git a/muse2/muse/sync.h b/muse2/muse/sync.h
index 8aa1084d..41ad34ad 100644
--- a/muse2/muse/sync.h
+++ b/muse2/muse/sync.h
@@ -31,9 +31,8 @@
namespace MusECore {
class Xml;
-//class MidiDevice;
-//class MidiSyncPort
+
class MidiSyncInfo
{
private:
@@ -54,7 +53,6 @@ class MidiSyncInfo
int _recMTCtype;
bool _recRewOnStart;
- //bool _sendContNotStart;
double _lastClkTime;
double _lastTickTime;
@@ -113,8 +111,6 @@ class MidiSyncInfo
bool recRewOnStart() const { return _recRewOnStart; }
void setRecRewOnStart(const bool v) { _recRewOnStart = v; }
- //bool sendContNotStart() const { return _sendContNotStart; }
- //void setSendContNotStart(const bool v) { _sendContNotStart = v; }
bool MCSyncDetect() const { return _clockDetect; }
void trigMCSyncDetect();
@@ -139,7 +135,6 @@ class MidiSyncInfo
bool isDefault() const;
void read(Xml& xml);
- //void write(int level, Xml& xml, MidiDevice* md);
void write(int level, Xml& xml);
};
@@ -147,24 +142,11 @@ class MidiSyncInfo
namespace MusEGlobal {
-//extern MidiSync midiSyncPorts[MIDI_PORTS];
-
extern bool debugSync;
-//extern int rxSyncPort;
-//extern int txSyncPort;
-//extern int rxDeviceId;
-//extern int txDeviceId;
-
extern int mtcType;
extern MusECore::MTC mtcOffset;
extern MusECore::BValue extSyncFlag;
-//extern bool genMTCSync; // output MTC Sync
-//extern bool genMCSync; // output MidiClock Sync
-//extern bool genMMC; // output Midi Machine Control
-//extern bool acceptMTC;
-//extern bool acceptMC;
-//extern bool acceptMMC;
extern int volatile curMidiSyncInPort;
extern MusECore::BValue useJackTransport;
extern bool volatile jackTransportMaster;
diff --git a/muse2/muse/synth.cpp b/muse2/muse/synth.cpp
index 7ab18bda..cf065bbb 100644
--- a/muse2/muse/synth.cpp
+++ b/muse2/muse/synth.cpp
@@ -33,7 +33,6 @@
#include <QDir>
#include <QString>
-//#include <QMenu>
#include "app.h"
#include "arranger.h"
@@ -50,7 +49,6 @@
#include "audio.h"
#include "midiseq.h"
#include "midictrl.h"
-//#include "stringparam.h"
#include "popupmenu.h"
#include "globaldefs.h"
@@ -76,26 +74,6 @@ Synth::Type string2SynthType(const QString& type)
return Synth::SYNTH_TYPE_END;
}
-/*
-//---------------------------------------------------------
-// description
-//---------------------------------------------------------
-
-const char* MessSynth::description() const
- {
- return _descr ? _descr->description : "";
- }
-
-//---------------------------------------------------------
-// version
-//---------------------------------------------------------
-
-const char* MessSynth::version() const
- {
- return _descr ? _descr->version : "";
- }
-*/
-
bool MessSynthIF::nativeGuiVisible() const
{
return _mess ? _mess->nativeGuiVisible() : false;
@@ -186,7 +164,6 @@ static SynthI* createSynthInstance(const QString& sclass, const QString& label,
si = new SynthI();
QString n;
n.setNum(s->instances());
- //QString instance_name = s->baseName() + "-" + n;
QString instance_name = s->name() + "-" + n;
if (si->initInstance(s, instance_name)) {
@@ -203,10 +180,6 @@ static SynthI* createSynthInstance(const QString& sclass, const QString& label,
// Synth
//---------------------------------------------------------
-//Synth::Synth(const QFileInfo& fi)
-// : info(fi)
-//Synth::Synth(const QFileInfo& fi, QString label)
-// : info(fi), _name(label)
Synth::Synth(const QFileInfo& fi, QString label, QString descr, QString maker, QString ver)
: info(fi), _name(label), _description(descr), _maker(maker), _version(ver)
{
@@ -217,15 +190,10 @@ Synth::Synth(const QFileInfo& fi, QString label, QString descr, QString maker, Q
// instantiate
//---------------------------------------------------------
-//void* MessSynth::instantiate()
void* MessSynth::instantiate(const QString& instanceName)
{
++_instances;
- //QString n;
- //n.setNum(_instances);
- //QString instanceName = baseName() + "-" + n;
-
MusEGlobal::doSetuid();
QByteArray ba = info.filePath().toLatin1();
const char* path = ba.constData();
@@ -326,13 +294,17 @@ void SynthI::close()
//---------------------------------------------------------
bool SynthI::putEvent(const MidiPlayEvent& ev)
-//bool SynthI::putMidiEvent(const MidiPlayEvent& ev)
{
if(_writeEnable)
+ {
+ if (MusEGlobal::midiOutputTrace)
+ {
+ printf("MidiOut: Synth: <%s>: ", name().toLatin1().constData());
+ ev.dump();
+ }
return _sif->putEvent(ev);
-
- // Hmm, act as if the event went through?
- //return true;
+ }
+
return false;
}
@@ -373,10 +345,8 @@ void SynthI::currentProg(unsigned long *prog, unsigned long *bankL, unsigned lon
// init
//---------------------------------------------------------
-//bool MessSynthIF::init(Synth* s)
bool MessSynthIF::init(Synth* s, SynthI* si)
{
- //_mess = (Mess*)s->instantiate();
_mess = (Mess*)((MessSynth*)s)->instantiate(si->name());
return (_mess == 0);
@@ -397,11 +367,8 @@ int MessSynthIF::totalInChannels() const
return 0;
}
-//SynthIF* MessSynth::createSIF() const
SynthIF* MessSynth::createSIF(SynthI* si)
{
- //return new MessSynthIF(si);
-
MessSynthIF* sif = new MessSynthIF(si);
sif->init(this, si);
return sif;
@@ -415,17 +382,11 @@ SynthIF* MessSynth::createSIF(SynthI* si)
bool SynthI::initInstance(Synth* s, const QString& instanceName)
{
synthesizer = s;
- //sif = s->createSIF();
- //_sif = s->createSIF(this);
-
- //sif->init(s);
setName(instanceName); // set midi device name
setIName(instanceName); // set instrument name
_sif = s->createSIF(this);
- // p3.3.38
- //AudioTrack::setChannels(_sif->channels());
AudioTrack::setTotalOutChannels(_sif->totalOutChannels());
AudioTrack::setTotalInChannels(_sif->totalInChannels());
@@ -442,10 +403,8 @@ bool SynthI::initInstance(Synth* s, const QString& instanceName)
int max;
int initval = CTRL_VAL_UNKNOWN;
id = _sif->getControllerInfo(id, &name, &ctrl, &min, &max, &initval);
-// printf("looking for params\n");
if (id == 0)
break;
-// printf("got parameter:: %s\n", name);
// Added by T356. Override existing program controller.
@@ -543,8 +502,8 @@ void SynthI::deactivate2()
void SynthI::deactivate3()
{
_sif->deactivate3();
- // Moved below by Tim. p3.3.14
- //synthesizer->incInstances(-1);
+
+ //synthesizer->incInstances(-1); // Moved below by Tim. p3.3.14
if(MusEGlobal::debugMsg)
printf("SynthI::deactivate3 deleting _sif...\n");
@@ -596,17 +555,13 @@ void initMidiSynth()
while(it!=list.end()) {
fi = &*it;
- //MusEGlobal::doSetuid();
QByteArray ba = fi->filePath().toLatin1();
const char* path = ba.constData();
// load Synti dll
- //printf("initMidiSynth: dlopen file:%s name:%s desc:%s\n", fi->filePath().toLatin1().constData(), QString(descr->name), QString(descr->description), QString(""), QString(descr->version)));
void* handle = dlopen(path, RTLD_NOW);
if (handle == 0) {
fprintf(stderr, "initMidiSynth: MESS dlopen(%s) failed: %s\n", path, dlerror());
- //MusEGlobal::undoSetuid();
- //return 0;
++it;
continue;
}
@@ -622,8 +577,6 @@ void initMidiSynth()
"library file \"%s\": %s.\n"
"Are you sure this is a MESS plugin file?\n",
path, txt);
- //MusEGlobal::undoSetuid();
- //return 0;
}
#endif
dlclose(handle);
@@ -633,19 +586,11 @@ void initMidiSynth()
const MESS* descr = msynth();
if (descr == 0) {
fprintf(stderr, "initMidiSynth: no MESS descr found in %s\n", path);
- //MusEGlobal::undoSetuid();
- //return 0;
dlclose(handle);
++it;
continue;
}
- //Mess* mess = descr->instantiate(MusEGlobal::sampleRate, muse, &museProject, instanceName.toLatin1().constData());
- //MusEGlobal::undoSetuid();
-
-
-
- //MusEGlobal::synthis.push_back(new MessSynth(*fi));
MusEGlobal::synthis.push_back(new MessSynth(*fi, QString(descr->name), QString(descr->description), QString(""), QString(descr->version)));
dlclose(handle);
@@ -665,38 +610,29 @@ void initMidiSynth()
SynthI* Song::createSynthI(const QString& sclass, const QString& label, Synth::Type type, Track* insertAt)
{
- //printf("Song::createSynthI calling ::createSynthI class:%s\n", sclass.toLatin1().constData());
-
SynthI* si = createSynthInstance(sclass, label, type);
if(!si)
return 0;
- //printf("Song::createSynthI created SynthI. Before insertTrack1...\n");
int idx = insertAt ? _tracks.index(insertAt) : -1;
insertTrack1(si, idx);
- //printf("Song::createSynthI after insertTrack1. Before msgInsertTrack...\n");
msgInsertTrack(si, idx, true); // add to instance list
- //printf("Song::createSynthI after msgInsertTrack. Before insertTrack3...\n");
insertTrack3(si, idx);
- //printf("Song::createSynthI after insertTrack3. Adding default routes...\n");
-
OutputList* ol = MusEGlobal::song->outputs();
// add default route to master (first audio output)
if (!ol->empty()) {
AudioOutput* ao = ol->front();
- // p3.3.38
- //MusEGlobal::audio->msgAddRoute(Route(si, -1), Route(ao, -1));
- //MusEGlobal::audio->msgAddRoute(Route((AudioTrack*)si, -1), Route(ao, -1));
// Make sure the route channel and channels are valid.
MusEGlobal::audio->msgAddRoute(Route((AudioTrack*)si, 0, ((AudioTrack*)si)->channels()), Route(ao, 0, ((AudioTrack*)si)->channels()));
MusEGlobal::audio->msgUpdateSoloStates();
}
+ // DELETETHIS 5
// Now that the track has been added to the lists in insertTrack2(),
// if it's a dssi synth, OSC can find the synth, and initialize (and show) its native gui.
// No, initializing OSC without actually showing the gui doesn't work, at least for
@@ -714,7 +650,6 @@ void SynthI::write(int level, Xml& xml) const
{
xml.tag(level++, "SynthI");
AudioTrack::writeProperties(level, xml);
- //xml.intTag(level, "synthType", synth()->synthType());
xml.strTag(level, "synthType", synthType2String(synth()->synthType()));
xml.strTag(level, "class", synth()->baseName());
@@ -739,7 +674,6 @@ void SynthI::write(int level, Xml& xml) const
getGeometry(&x, &y, &w, &h);
if (h || w)
xml.qrectTag(level, "geometry", QRect(x, y, w, h));
- //xml.geometryTag(level, "geometry", _gui);
}
if (hasNativeGui()) {
@@ -851,7 +785,6 @@ void SynthI::read(Xml& xml)
return;
case Xml::TagStart:
if (tag == "synthType")
- //type = xml.parseInt();
type = string2SynthType(xml.parse1());
else if (tag == "class")
sclass = xml.parse1();
@@ -900,6 +833,7 @@ void SynthI::read(Xml& xml)
if (port != -1 && port < MIDI_PORTS)
MusEGlobal::midiPorts[port].setMidiDevice(this);
+ // DELETETHIS 5
// Now that the track has been added to the lists in insertTrack2(),
// if it's a dssi synth, OSC can find the synth, and initialize (and show) its native gui.
// No, initializing OSC without actually showing the gui doesn't work, at least for
@@ -934,7 +868,6 @@ const char* MessSynthIF::getPatchName(int channel, int prog, MType type, bool dr
{
if (_mess)
{
- //return _mess->getPatchName(channel, prog, type, drum);
const char* s = _mess->getPatchName(channel, prog, type, drum);
if(s)
return s;
@@ -953,7 +886,7 @@ void MessSynthIF::populatePatchPopup(MusEGui::PopupMenu* menu, int ch, MType, bo
while (mp) {
int id = ((mp->hbank & 0xff) << 16)
+ ((mp->lbank & 0xff) << 8) + mp->prog;
- /*
+ /* DELETETHIS 9
int pgid = ((mp->hbank & 0xff) << 8) | (mp->lbank & 0xff) | 0x40000000;
int itemnum = menu->indexOf(pgid);
if(itemnum == -1)
@@ -997,10 +930,10 @@ void SynthI::preProcessAlways()
if(off())
{
// Clear any accumulated play events.
- //playEvents()->clear();
+ //playEvents()->clear(); DELETETHIS
_playEvents.clear();
// Eat up any fifo events.
- //while(!eventFifo.isEmpty())
+ //while(!eventFifo.isEmpty()) DELETETHIS
// eventFifo.get();
eventFifo.clear(); // Clear is the same but faster AND safer, right?
}
@@ -1023,26 +956,18 @@ bool SynthI::getData(unsigned pos, int ports, unsigned n, float** buffer)
int p = midiPort();
MidiPort* mp = (p != -1) ? &MusEGlobal::midiPorts[p] : 0;
- //MPEventList* el = playEvents();
- ///iMPEvent ie = nextPlayEvent();
- //iMPEvent ie = el->begin(); // p4.0.15 Tim.
iMPEvent ie = _playEvents.begin();
-
- //ie = _sif->getData(mp, el, ie, pos, ports, n, buffer);
ie = _sif->getData(mp, &_playEvents, ie, pos, ports, n, buffer);
- ///setNextPlayEvent(ie);
// p4.0.15 We are done with these events. Let us erase them here instead of Audio::processMidi.
// That way we can simply set the next play event to the beginning.
// This also allows other events to be inserted without the problems caused by the next play event
// being at the 'end' iterator and not being *easily* set to some new place beginning of the newer insertions.
// The way that MPEventList sorts made it difficult to predict where the iterator of the first newly inserted items was.
// The erasure in Audio::processMidi was missing some events because of that.
- //el->erase(el->begin(), ie);
_playEvents.erase(_playEvents.begin(), ie);
- // setNextPlayEvent(el->begin()); // Removed p4.0.15
return true;
}
@@ -1057,22 +982,17 @@ iMPEvent MessSynthIF::getData(MidiPort* mp, MPEventList* el, iMPEvent i, unsigne
for (; i != el->end(); ++i) {
int evTime = i->time();
- if (evTime == 0) {
- // printf("MessSynthIF::getData - time is 0!\n");
- // continue;
+ if (evTime == 0)
evTime=abs(frameOffset); // will cause frame to be zero, problem?
- }
+
int frame = evTime - abs(frameOffset);
- if (frame >= endPos) {
- printf("frame > endPos!! frame = %d >= endPos %d, i->time() %d, frameOffset %d curPos=%d\n", frame, endPos, i->time(), frameOffset,curPos);
- continue;
- }
+ if (frame >= endPos) {
+ printf("frame > endPos!! frame = %d >= endPos %d, i->time() %d, frameOffset %d curPos=%d\n", frame, endPos, i->time(), frameOffset,curPos);
+ continue;
+ }
if (frame > curPos) {
- //willyfoobar-2011-02-13
- //!!! comparison of signed with unsigened
- //old code//if (frame < pos)
if (frame < (int) pos)
printf("should not happen: missed event %d\n", pos -frame);
else
@@ -1085,14 +1005,16 @@ iMPEvent MessSynthIF::getData(MidiPort* mp, MPEventList* el, iMPEvent i, unsigne
}
}
curPos = frame;
- }
+ }
+
if (mp)
mp->sendEvent(*i);
else {
if (putEvent(*i))
break;
- }
}
+ }
+
if (endPos - curPos)
{
if (!_mess)
@@ -1112,14 +1034,17 @@ iMPEvent MessSynthIF::getData(MidiPort* mp, MPEventList* el, iMPEvent i, unsigne
bool MessSynthIF::putEvent(const MidiPlayEvent& ev)
{
- if (MusEGlobal::midiOutputTrace)
- ev.dump();
+ //if (MusEGlobal::midiOutputTrace) DELETETHIS or re-enable?
+ //{
+ // printf("MidiOut: MESS: <%s>: ", synti->name().toLatin1().constData());
+ // ev.dump();
+ //}
if (_mess)
return _mess->processEvent(ev);
return true;
}
-//unsigned long MessSynthIF::uniqueID() const
+//unsigned long MessSynthIF::uniqueID() const DELETETHIS
//{
// return _mess ? _mess->uniqueID() : 0;
//}
diff --git a/muse2/muse/synth.h b/muse2/muse/synth.h
index b9f1dcd2..8e19d5e8 100644
--- a/muse2/muse/synth.h
+++ b/muse2/muse/synth.h
@@ -40,8 +40,6 @@
// Current version of saved midistate data.
#define SYNTH_MIDI_STATE_SAVE_VERSION 2
-//class QMenu;
-
class Mess;
struct MESS;
@@ -51,9 +49,6 @@ class PopupMenu;
namespace MusECore {
-//class MidiEvent;
-//class MidiPlayEvent;
-
class SynthI;
class SynthIF;
@@ -74,19 +69,15 @@ class Synth {
public:
enum Type { METRO_SYNTH=0, MESS_SYNTH, DSSI_SYNTH, VST_SYNTH, SYNTH_TYPE_END };
- //Synth(const QFileInfo& fi);
- //Synth(const QFileInfo& fi, QString label);
Synth(const QFileInfo& fi, QString label, QString descr, QString maker, QString ver);
virtual ~Synth() {}
- //virtual const char* description() const { return ""; }
- //virtual const char* version() const { return ""; }
virtual Type synthType() const = 0;
int instances() const { return _instances; }
virtual void incInstances(int val) { _instances += val; }
- QString completeBaseName() /*const*/ { return info.completeBaseName(); } // ddskrjo
- QString baseName() /*const*/ { return info.baseName(); } // ddskrjo
+ QString completeBaseName() { return info.completeBaseName(); } // ddskrjo
+ QString baseName() { return info.baseName(); } // ddskrjo
QString name() const { return _name; }
QString absolutePath() const { return info.absolutePath(); }
QString path() const { return info.path(); }
@@ -94,12 +85,8 @@ class Synth {
QString fileName() const { return info.fileName(); }
QString description() const { return _description; }
QString version() const { return _version; }
- //QString maker() const { return _version; } ??
QString maker() const { return _maker; }
- //virtual void* instantiate() = 0;
-
- //virtual SynthIF* createSIF() const = 0;
virtual SynthIF* createSIF(SynthI*) = 0;
};
@@ -111,21 +98,14 @@ class MessSynth : public Synth {
const MESS* _descr;
public:
- //MessSynth(const QFileInfo& fi) : Synth(fi) { descr = 0; }
- //MessSynth(const QFileInfo& fi) : Synth(fi, fi.baseName()) { descr = 0; }
MessSynth(const QFileInfo& fi, QString label, QString descr, QString maker, QString ver) :
Synth(fi, label, descr, maker, ver) { _descr = 0; }
virtual ~MessSynth() {}
- //virtual const char* description() const;
- //virtual const char* version() const;
-
virtual Type synthType() const { return MESS_SYNTH; }
- //virtual void* instantiate();
virtual void* instantiate(const QString&);
- //virtual SynthIF* createSIF() const;
virtual SynthIF* createSIF(SynthI*);
};
@@ -145,7 +125,6 @@ class SynthIF {
SynthI* synti;
public:
- //SynthIF() {}
SynthIF(SynthI* s) { synti = s; }
virtual ~SynthIF() {}
@@ -157,13 +136,13 @@ class SynthIF {
virtual bool guiVisible() const = 0;
virtual void showGui(bool v) = 0;
virtual bool hasGui() const = 0;
- //virtual bool guiVisible() const { return false; }
+ //virtual bool guiVisible() const { return false; } DELETETHIS 3
//virtual void showGui(bool v) { };
//virtual bool hasGui() const { return false; }
virtual bool nativeGuiVisible() const = 0;
virtual void showNativeGui(bool v) = 0;
virtual bool hasNativeGui() const = 0;
- //virtual bool nativeGuiVisible() const { return false; }
+ //virtual bool nativeGuiVisible() const { return false; } DELETETHIS 3
//virtual void showNativeGui(bool v) { };
//virtual bool hasNativeGui() const { return false; }
virtual void getGeometry(int*, int*, int*, int*) const = 0;
@@ -176,15 +155,12 @@ class SynthIF {
virtual MidiPlayEvent receiveEvent() = 0;
virtual int eventsPending() const = 0;
- //virtual bool init(Synth* s) = 0;
-
virtual int channels() const = 0;
virtual int totalOutChannels() const = 0;
virtual int totalInChannels() const = 0;
virtual void deactivate3() = 0;
virtual const char* getPatchName(int, int, int, bool) const = 0;
virtual const char* getPatchName(int, int, MType, bool) = 0;
- //virtual void populatePatchPopup(QMenu*, int, MType, bool) = 0;
virtual void populatePatchPopup(MusEGui::PopupMenu*, int, MType, bool) = 0;
virtual void write(int level, Xml& xml) const = 0;
virtual float getParameter(unsigned long idx) const = 0;
@@ -213,12 +189,16 @@ class SynthI : public AudioTrack, public MidiDevice,
// List of initial floating point parameters, for synths which use them.
// Used once upon song reload, then discarded.
std::vector<float> initParams;
+
// List of gui controls to update upon heartbeat.
std::vector<bool> _guiUpdateControls;
+
// Update gui program upon heartbeat.
bool _guiUpdateProgram;
+
// Initial, and running, string parameters for synths which use them, like dssi.
StringParamMap _stringParamMap;
+
// Current bank and program for synths which use them, like dssi.
// In cases like dssi which have no 'hi' and 'lo' bank, just use _curBankL.
unsigned long _curBankH;
@@ -228,13 +208,10 @@ class SynthI : public AudioTrack, public MidiDevice,
void preProcessAlways();
bool getData(unsigned a, int b, unsigned c, float** data);
- //bool putEvent(const MidiPlayEvent& ev);
-
virtual QString open();
virtual void close();
virtual bool putMidiEvent(const MidiPlayEvent&) {return true;}
- //bool putMidiEvent(const MidiEvent&);
virtual Track* newTrack() const { return 0; }
@@ -246,7 +223,7 @@ class SynthI : public AudioTrack, public MidiDevice,
SynthI();
virtual ~SynthI();
- SynthI* clone(int /*flags*/) const { return new SynthI(*this/*, flags*/); }
+ SynthI* clone(int /*flags*/) const { return new SynthI(*this); }
virtual inline int deviceType() const { return SYNTH_MIDI; }
@@ -263,19 +240,15 @@ class SynthI : public AudioTrack, public MidiDevice,
Synth* synth() const { return synthesizer; }
virtual bool isSynti() const { return true; }
- //virtual const char* getPatchName(int ch, int prog, MType t, bool dr) {
virtual QString getPatchName(int ch, int prog, MType t, bool dr) {
return _sif->getPatchName(ch, prog, t, dr);
}
- //virtual void populatePatchPopup(QMenu* m, int i, MType t, bool d) {
virtual void populatePatchPopup(MusEGui::PopupMenu* m, int i, MType t, bool d) {
_sif->populatePatchPopup(m, i, t, d);
}
- // void setParameter(const char* name, const char* value) const; // Not required
- //StringParamMap& stringParameters() { return _stringParamMap; } // Not required
- void currentProg(unsigned long */*prog*/, unsigned long */*bankL*/, unsigned long */*bankH*/);
+ void currentProg(unsigned long *prog, unsigned long *bankL, unsigned long *bankH);
void guiHeartBeat() { return _sif->guiHeartBeat(); }
bool initGui() const { return _sif->initGui(); }
@@ -326,7 +299,6 @@ class MessSynthIF : public SynthIF {
Mess* _mess;
public:
- //MessSynthIF() { _mess = 0; }
MessSynthIF(SynthI* s) : SynthIF(s) { _mess = 0; }
virtual ~MessSynthIF() { }
@@ -350,7 +322,6 @@ class MessSynthIF : public SynthIF {
virtual bool putEvent(const MidiPlayEvent& ev);
virtual MidiPlayEvent receiveEvent();
virtual int eventsPending() const;
- //virtual bool init(Synth* s);
bool init(Synth* s, SynthI* si);
virtual int channels() const;
@@ -359,7 +330,6 @@ class MessSynthIF : public SynthIF {
virtual void deactivate3();
virtual const char* getPatchName(int, int, int, bool) const { return ""; }
virtual const char* getPatchName(int, int, MType, bool);
- //virtual void populatePatchPopup(QMenu*, int, MType, bool);
virtual void populatePatchPopup(MusEGui::PopupMenu*, int, MType, bool);
virtual void write(int level, Xml& xml) const;
virtual float getParameter(unsigned long) const { return 0.0; }
diff --git a/muse2/muse/tempo.cpp b/muse2/muse/tempo.cpp
index 051fc7c5..1147fd78 100644
--- a/muse2/muse/tempo.cpp
+++ b/muse2/muse/tempo.cpp
@@ -138,12 +138,26 @@ int TempoList::tempo(unsigned tick) const
}
//---------------------------------------------------------
+// tempo
+// Bypass the useList flag and read from the list
+//---------------------------------------------------------
+
+int TempoList::tempoAt(unsigned tick) const
+ {
+ ciTEvent i = upper_bound(tick);
+ if (i == end()) {
+ printf("tempoAt: no TEMPO at tick %d,0x%x\n", tick, tick);
+ return 1000;
+ }
+ return i->second->tempo;
+ }
+
+//---------------------------------------------------------
// del
//---------------------------------------------------------
void TempoList::del(unsigned tick)
{
-// printf("TempoList::del(%d)\n", tick);
iTEvent e = find(tick);
if (e == end()) {
printf("TempoList::del(%d): not found\n", tick);
@@ -270,7 +284,6 @@ unsigned TempoList::tick2frame(unsigned tick, int* sn) const
ciTEvent i = upper_bound(tick);
if (i == end()) {
printf("tick2frame(%d,0x%x): not found\n", tick, tick);
- // abort();
return 0;
}
unsigned dtick = tick - i->second->tick;
diff --git a/muse2/muse/tempo.h b/muse2/muse/tempo.h
index 5c408630..7a3f413b 100644
--- a/muse2/muse/tempo.h
+++ b/muse2/muse/tempo.h
@@ -86,6 +86,7 @@ class TempoList : public TEMPOLIST {
void dump() const;
int tempo(unsigned tick) const;
+ int tempoAt(unsigned tick) const;
unsigned tick2frame(unsigned tick, unsigned frame, int* sn) const;
unsigned tick2frame(unsigned tick, int* sn = 0) const;
unsigned frame2tick(unsigned frame, int* sn = 0) const;
diff --git a/muse2/muse/thread.cpp b/muse2/muse/thread.cpp
index 8fe0cdb8..69238922 100644
--- a/muse2/muse/thread.cpp
+++ b/muse2/muse/thread.cpp
@@ -57,16 +57,13 @@ static void* loop(void* mops)
// start
//---------------------------------------------------------
-//void Thread::start(void* ptr)
void Thread::start(int prio, void* ptr)
{
- // Changed by Tim. p3.3.17
-
userPtr = ptr;
pthread_attr_t* attributes = 0;
_realTimePriority = prio;
- /*
+ /* DELETETHIS 14
attributes = (pthread_attr_t*) malloc(sizeof(pthread_attr_t));
pthread_attr_init(attributes);
*/
@@ -105,7 +102,7 @@ void Thread::start(int prio, void* ptr)
}
- /*
+ /* DELETETHIS 8
if (pthread_create(&thread, attributes, MusECore::loop, this))
perror("creating thread failed:");
// else
@@ -136,7 +133,6 @@ void Thread::start(int prio, void* ptr)
free(attributes);
}
- //undoSetuid();
}
//---------------------------------------------------------
@@ -145,11 +141,8 @@ void Thread::start(int prio, void* ptr)
void Thread::stop(bool force)
{
- // Changed by Tim. p3.3.17
-
if (thread == 0)
return;
- //if (force && thread > 0) {
if (force) {
pthread_cancel(thread);
threadStop();
@@ -157,7 +150,7 @@ void Thread::stop(bool force)
_running = false;
if (thread) {
if (pthread_join(thread, 0)) {
- // perror("Failed to join sequencer thread");
+ // perror("Failed to join sequencer thread"); DELETETHIS and the if around?
}
}
}
@@ -166,14 +159,10 @@ void Thread::stop(bool force)
// prio = 0 no realtime scheduling
//---------------------------------------------------------
-//Thread::Thread(int prio, const char* s)
Thread::Thread(const char* s)
{
- // Changed by Tim. p3.3.17
-
userPtr = 0;
_name = s;
- //realTimePriority = prio;
_realTimePriority = 0;
pfd = 0;
@@ -183,9 +172,6 @@ Thread::Thread(const char* s)
_pollWait = -1;
thread = 0;
- //if (MusEGlobal::debugMsg)
- // printf("Start thread %s with priority %d\n", s, prio);
-
// create message channels
int filedes[2]; // 0 - reading 1 - writing
if (pipe(filedes) == -1) {
@@ -202,7 +188,7 @@ Thread::Thread(const char* s)
fromThreadFdr = filedes[0];
fromThreadFdw = filedes[1];
-// pthread_mutexattr_t mutexattr;
+// pthread_mutexattr_t mutexattr; DELETETHIS 5
// pthread_mutexattr_init(&mutexattr);
// pthread_mutexattr_settype(&mutexattr, PTHREAD_MUTEX_TIMED_NP);
// pthread_mutex_init(&lock, &mutexattr);
@@ -271,7 +257,7 @@ void Thread::loop()
perror("WARNING: Cannot lock memory:");
}
-/*
+/* DELETETHIS 46
pthread_attr_t* attributes = 0;
attributes = (pthread_attr_t*) malloc(sizeof(pthread_attr_t));
pthread_attr_init(attributes);
@@ -337,19 +323,13 @@ void Thread::loop()
printf("Thread: Cannot get current client scheduler: %s\n", strerror(errno));
}
- /*
- if (MusEGlobal::debugMsg)
- printf("Thread <%s> set to %s priority %d\n",
- _name, policy == SCHED_FIFO ? "SCHED_FIFO" : "SCHED_OTHER",
- realTimePriority);
- */
if (MusEGlobal::debugMsg)
printf("Thread <%s, id %p> has %s priority %d\n",
_name, (void *)pthread_self(), policy == SCHED_FIFO ? "SCHED_FIFO" : "SCHED_OTHER",
policy == SCHED_FIFO ? _realTimePriority : 0);
-// pthread_mutex_lock(&lock);
+// pthread_mutex_lock(&lock); DELETETHIS and below
_running = true;
// pthread_cond_signal(&ready);
// pthread_mutex_unlock(&lock);
@@ -394,8 +374,6 @@ void Thread::loop()
bool Thread::sendMsg(const ThreadMsg* m)
{
- // Changed by Tim. p3.3.17
-
if (_running)
{
int rv = write(toThreadFdw, &m, sizeof(ThreadMsg*));
@@ -412,7 +390,7 @@ bool Thread::sendMsg(const ThreadMsg* m)
perror("Thread::sendMessage(): read pipe failed");
return true;
}
- //int c;
+ //int c; DELETETHIS 6
//rv = read(fromThreadFdr, &c, sizeof(c));
//if (rv != sizeof(c)) {
// perror("Thread::sendMessage(): read pipe failed");
@@ -460,7 +438,7 @@ void Thread::readMsg()
int rv = write(fromThreadFdw, &c, 1);
if (rv != 1)
perror("Thread::readMessage(): write pipe failed");
- //int c = p->serialNo;
+ //int c = p->serialNo; DELETETHIS 4
//int rv = write(fromThreadFdw, &c, sizeof(c));
//if (rv != sizeof(c))
// perror("Thread::readMsg(): write pipe failed");
diff --git a/muse2/muse/thread.h b/muse2/muse/thread.h
index 755754f9..ab897834 100644
--- a/muse2/muse/thread.h
+++ b/muse2/muse/thread.h
@@ -70,7 +70,6 @@ struct ThreadMsg {
class Thread {
const char* _name;
volatile bool _running;
- //int realTimePriority;
int _pollWait; // poll timeout in msec (-1 = infinite)
pthread_t thread;
@@ -78,7 +77,7 @@ class Thread {
int toThreadFdw; // message to thread (app write)
PollList plist;
-// pthread_mutex_t lock;
+// pthread_mutex_t lock; DELETETHIS 2
// pthread_cond_t ready;
void* userPtr;
@@ -95,13 +94,11 @@ class Thread {
virtual void defaultTick() {}
public:
- //Thread(int prio, const char* name);
Thread(const char* name);
virtual ~Thread();
const char* name() const { return _name; }
- //virtual void start(void* ptr=0);
virtual void start(int priority, void* ptr=0);
void stop(bool);
diff --git a/muse2/muse/ticksynth.cpp b/muse2/muse/ticksynth.cpp
index 6d3721ea..48e1ba2b 100644
--- a/muse2/muse/ticksynth.cpp
+++ b/muse2/muse/ticksynth.cpp
@@ -24,7 +24,6 @@
#include "ticksynth.h"
#include "default_click.h"
-//#include <QMenu>
#include "popupmenu.h"
// If sysex support is ever added, make sure this number is unique among all the MESS synths.
@@ -45,15 +44,12 @@ static MetronomeSynth* metronomeSynth = 0;
class MetronomeSynth : public Synth {
public:
- //MetronomeSynth(const QFileInfo& fi) : Synth(fi) {}
- //MetronomeSynth(const QFileInfo& fi) : Synth(fi, QString("Metronome")) {}
MetronomeSynth(const QFileInfo& fi) : Synth(fi, QString("Metronome"), QString("Metronome"), QString(), QString()) {}
virtual ~MetronomeSynth() {}
virtual Type synthType() const { return METRO_SYNTH; }
virtual void incInstances(int) {}
virtual void* instantiate();
- //virtual SynthIF* createSIF() const;
virtual SynthIF* createSIF(SynthI*);
};
@@ -78,9 +74,6 @@ class MetronomeSynthIF : public SynthIF
void process(float** buffer, int offset, int n);
public:
- //MetronomeSynthIF() {
- // data = 0;
- // }
MetronomeSynthIF(SynthI* s) : SynthIF(s) {
data = 0;
}
@@ -103,15 +96,12 @@ class MetronomeSynthIF : public SynthIF
virtual MidiPlayEvent receiveEvent() { return MidiPlayEvent(); }
virtual int eventsPending() const { return 0; }
- //virtual bool init(Synth*) { return true; }
-
virtual int channels() const { return 1; }
virtual int totalOutChannels() const { return 1; }
virtual int totalInChannels() const { return 0; }
virtual void deactivate3() {}
virtual const char* getPatchName(int, int, int, bool) const { return ""; }
virtual const char* getPatchName(int, int, MType, bool) { return ""; }
- //virtual void populatePatchPopup(QMenu*, int, MType, bool) {};
virtual void populatePatchPopup(MusEGui::PopupMenu*, int, MType, bool) {};
virtual void write(int, Xml&) const {}
virtual float getParameter(unsigned long) const { return 0.0; }
@@ -130,7 +120,7 @@ iMPEvent MetronomeSynthIF::getData(MidiPort*, MPEventList* el, iMPEvent i, unsig
printf("MusE: MetronomeSynthIF::getData\n");
#endif
- //set type to unsigned , due to compiler warning: comparison signed/unsigned
+ //set type to unsigned , due to compiler warning: comparison signed/unsigned
unsigned int curPos = pos; //prevent compiler warning: comparison signed/unsigned
unsigned int endPos = pos + n; //prevent compiler warning: comparison signed/unsigned
unsigned int off = pos; //prevent compiler warning: comparison signed/unsigned
@@ -172,6 +162,7 @@ bool MetronomeSynthIF::putEvent(const MidiPlayEvent& ev)
return false;
}
+// DELETETHIS 9
//---------------------------------------------------------
// createSIF
//---------------------------------------------------------
diff --git a/muse2/muse/track.cpp b/muse2/muse/track.cpp
index cdb81a8f..e810f677 100644
--- a/muse2/muse/track.cpp
+++ b/muse2/muse/track.cpp
@@ -39,13 +39,10 @@
namespace MusECore {
-//bool Track::_isVisible=true;
unsigned int Track::_soloRefCnt = 0;
Track* Track::_tmpSoloChainTrack = 0;
bool Track::_tmpSoloChainDoIns = false;
bool Track::_tmpSoloChainNoDec = false;
-//bool Track::_tmpIsAuxProcessing = false;
-//int Track::_tmpIsAuxProcRefCount = 0;
const char* Track::_cname[] = {
"Midi", "Drum", "NewStyleDrum", "Wave",
@@ -113,15 +110,9 @@ void removePortCtrlEvents(MidiTrack* t)
{
Part* part = ip->second;
const EventList* el = part->cevents();
- //unsigned len = part->lenTick();
for(ciEvent ie = el->begin(); ie != el->end(); ++ie)
{
const Event& ev = ie->second;
- // Added by T356. Do not remove events which are past the end of the part.
- // No, actually, do remove ALL of them belonging to the part.
- // Just in case there are stray values left after the part end.
- //if(ev.tick() >= len)
- // break;
if(ev.type() == Controller)
{
@@ -159,7 +150,6 @@ bool Track::isVisible()
{
case Track::AUDIO_AUX:
return AudioAux::visible();
- break;
case Track::AUDIO_GROUP:
return AudioGroup::visible();
case Track::AUDIO_INPUT:
@@ -169,9 +159,10 @@ bool Track::isVisible()
case Track::WAVE:
return WaveTrack::visible();
case Track::MIDI:
+ case Track::DRUM:
return MidiTrack::visible();
case Track::AUDIO_SOFTSYNTH:
- return AudioAux::visible();
+ return SynthI::visible();
default:
break;
}
@@ -225,8 +216,6 @@ void Track::init()
_height = 20;
_locked = false;
for (int i = 0; i < MAX_CHANNELS; ++i) {
- //_meter[i] = 0;
- //_peak[i] = 0;
_meter[i] = 0.0;
_peak[i] = 0.0;
}
@@ -242,8 +231,6 @@ Track::Track(const Track& t, int flags)
{
internal_assign(t, flags | ASSIGN_PROPERTIES);
for (int i = 0; i < MAX_CHANNELS; ++i) {
- //_meter[i] = 0;
- //_peak[i] = 0;
_meter[i] = 0.0;
_peak[i] = 0.0;
}
@@ -290,7 +277,6 @@ void Track::internal_assign(const Track& t, int flags)
_type = t.type();
_locked = t.locked();
- //_name = t.name();
_name = t.name() + " #";
for(int i = 2; true; ++i)
{
@@ -421,12 +407,9 @@ void Track::dump() const
void Track::updateAuxRoute(int refInc, Track* dst)
{
- //if(isMidiTrack() || _type == AUDIO_AUX)
if(isMidiTrack())
return;
- //printf("Track::updateAuxRoute %s _auxRouteCount:%d refInc:%d\n", name().toLatin1().constData(), _auxRouteCount, refInc);
-
if(dst)
{
_nodeTraversed = true;
@@ -454,7 +437,6 @@ void Track::updateAuxRoute(int refInc, Track* dst)
if(_auxRouteCount < 0)
{
fprintf(stderr, "Track::updateAuxRoute Ref underflow! %s _auxRouteCount:%d refInc:%d\n", name().toLatin1().constData(), _auxRouteCount, refInc);
- //_auxRouteCount = 0;
}
for (iRoute i = _outRoutes.begin(); i != _outRoutes.end(); ++i)
@@ -462,8 +444,6 @@ void Track::updateAuxRoute(int refInc, Track* dst)
if( !(*i).isValid() || (*i).type != Route::TRACK_ROUTE )
continue;
Track* t = (*i).track;
- //if(t->isMidiTrack())
- // continue;
t->updateAuxRoute(refInc, NULL);
}
@@ -478,10 +458,6 @@ void Track::updateAuxRoute(int refInc, Track* dst)
bool Track::isCircularRoute(Track* dst)
{
- //if(isMidiTrack() || _type == AUDIO_AUX)
- //if(isMidiTrack())
- // return;
-
bool rv = false;
if(dst)
@@ -489,8 +465,6 @@ bool Track::isCircularRoute(Track* dst)
_nodeTraversed = true;
rv = dst->isCircularRoute(NULL);
_nodeTraversed = false;
- //if(rv)
- // fprintf(stderr, " Circular route %s -> %s\n", name().toLatin1().constData(), dst->name().toLatin1().constData());
return rv;
}
@@ -504,8 +478,6 @@ bool Track::isCircularRoute(Track* dst)
if( !(*i).isValid() || (*i).type != Route::TRACK_ROUTE )
continue;
Track* t = (*i).track;
- //if(t->isMidiTrack())
- // continue;
rv = t->isCircularRoute(NULL);
if(rv)
break;
@@ -601,13 +573,10 @@ void MidiTrack::internal_assign(const Track& t, int flags)
{
c = mp->defaultInChannels();
if(c)
- {
MusEGlobal::audio->msgAddRoute(Route(i, c), Route(this, c));
- //updateFlags |= SC_ROUTE;
- }
}
- if(!defOutFound) ///
+ if(!defOutFound)
{
c = mp->defaultOutChannels();
if(c)
@@ -616,7 +585,6 @@ void MidiTrack::internal_assign(const Track& t, int flags)
/// TODO: Switch if and when multiple output routes supported.
#if 0
MusEGlobal::audio->msgAddRoute(Route(this, c), Route(i, c));
- //updateFlags |= SC_ROUTE;
#else
for(ch = 0; ch < MIDI_CHANNELS; ++ch)
{
@@ -627,7 +595,6 @@ void MidiTrack::internal_assign(const Track& t, int flags)
_outPort = i;
if(type() != Track::DRUM) // Leave drum tracks at channel 10.
_outChannel = ch;
- //updateFlags |= SC_ROUTE;
break;
}
}
@@ -682,10 +649,7 @@ void MidiTrack::init()
{
_outPort = 0;
_outChannel = (type()==NEW_DRUM) ? 9 : 0;
- //_inPortMask = 0xffff;
- ///_inPortMask = 0xffffffff;
-
- ///_inChannelMask = 0xffff; // "ALL"
+
transposition = 0;
velocity = 0;
delay = 0;
@@ -751,10 +715,8 @@ void MidiTrack::setOutChanAndUpdate(int i)
if(_outChannel == i)
return;
- //removePortCtrlEvents();
removePortCtrlEvents(this);
_outChannel = i;
- //addPortCtrlEvents();
addPortCtrlEvents(this);
}
@@ -767,10 +729,8 @@ void MidiTrack::setOutPortAndUpdate(int i)
if(_outPort == i)
return;
- //removePortCtrlEvents();
removePortCtrlEvents(this);
_outPort = i;
- //addPortCtrlEvents();
addPortCtrlEvents(this);
}
@@ -783,11 +743,9 @@ void MidiTrack::setOutPortAndChannelAndUpdate(int port, int ch)
if(_outPort == port && _outChannel == ch)
return;
- //removePortCtrlEvents();
removePortCtrlEvents(this);
_outPort = port;
_outChannel = ch;
- //addPortCtrlEvents();
addPortCtrlEvents(this);
}
@@ -799,10 +757,6 @@ void MidiTrack::setOutPortAndChannelAndUpdate(int port, int ch)
void MidiTrack::setInPortAndChannelMask(unsigned int portmask, int chanmask)
{
- //if(!portmask || !chanmask)
- // return;
-
- //RouteList* rl = inRoutes();
bool changed = false;
for(int port = 0; port < 32; ++port) // 32 is the old maximum number of ports.
@@ -812,7 +766,7 @@ void MidiTrack::setInPortAndChannelMask(unsigned int portmask, int chanmask)
if(!MusEGlobal::midiPorts[port].foundInSongFile())
continue;
- //if(!(portmask & (1 << port)))
+ //if(!(portmask & (1 << port))) DELETETHIS 8
// continue;
// Removed. Allow to connect to port with no device so user can change device later.
@@ -825,24 +779,17 @@ void MidiTrack::setInPortAndChannelMask(unsigned int portmask, int chanmask)
Route bRoute(this, chanmask);
// Route wanted?
- //if((portmask & (1 << port)) && (chanmask & (1 << ch)))
if(portmask & (1 << port))
{
- // Route already exists?
- //if(iir != rl->end())
- // continue;
MusEGlobal::audio->msgAddRoute(aRoute, bRoute);
changed = true;
}
else
{
- // Route does not exist?
- //if(iir == rl->end())
- // continue;
MusEGlobal::audio->msgRemoveRoute(aRoute, bRoute);
changed = true;
}
- //}
+ //} DELETETHIS
}
if(changed)
@@ -852,7 +799,7 @@ void MidiTrack::setInPortAndChannelMask(unsigned int portmask, int chanmask)
}
}
-/*
+/* DELETETHIS 84
//---------------------------------------------------------
// addPortCtrlEvents
//---------------------------------------------------------
@@ -1001,9 +948,6 @@ void MidiTrack::write(int level, Xml& xml) const
xml.intTag(level, "device", outPort());
xml.intTag(level, "channel", outChannel());
- //xml.intTag(level, "inportMap", inPortMask());
- ///xml.uintTag(level, "inportMap", inPortMask()); // Obsolete
- ///xml.intTag(level, "inchannelMap", inChannelMask()); // Obsolete
xml.intTag(level, "locked", _locked);
xml.intTag(level, "echo", _recEcho);
@@ -1081,14 +1025,9 @@ void MidiTrack::read(Xml& xml)
else if (tag == "channel")
setOutChannel(xml.parseInt());
else if (tag == "inportMap")
- //setInPortMask(xml.parseInt());
- ///setInPortMask(xml.parseUInt());
- //xml.skip(tag); // Obsolete.
- portmask = xml.parseUInt(); // Support old files.
+ portmask = xml.parseUInt(); // Obsolete but support old files.
else if (tag == "inchannelMap")
- ///setInChannelMask(xml.parseInt());
- //xml.skip(tag); // Obsolete.
- chanmask = xml.parseInt(); // Support old files.
+ chanmask = xml.parseInt(); // Obsolete but support old files.
else if (tag == "locked")
_locked = xml.parseInt();
else if (tag == "echo")
@@ -1327,13 +1266,9 @@ void Track::writeRouting(int level, Xml& xml) const
s = "dest";
- //if(r->type == Route::MIDI_DEVICE_ROUTE) // Obsolete since 1.1-RC2
- // s += QString(QT_TRANSLATE_NOOP("@default", " devtype=\"%1\"")).arg(r->device->deviceType()); //
- //if(r->type != Route::TRACK_ROUTE) //
if(r->type != Route::TRACK_ROUTE && r->type != Route::MIDI_PORT_ROUTE)
s += QString(" type=\"%1\"").arg(r->type);
- //s += QString(QT_TRANSLATE_NOOP("@default", " name=\"%1\"/")).arg(r->name());
if(r->type == Route::MIDI_PORT_ROUTE)
s += QString(" mport=\"%1\"/").arg(r->midiPort);
else
diff --git a/muse2/muse/track.h b/muse2/muse/track.h
index 5cc217b6..b8133fae 100644
--- a/muse2/muse/track.h
+++ b/muse2/muse/track.h
@@ -110,7 +110,7 @@ class Track {
Track(TrackType);
Track(const Track&, int flags);
virtual ~Track();
- //virtual Track& operator=(const Track& t);
+ //virtual Track& operator=(const Track& t); DELETETHIS
virtual void assign(const Track&, int flags);
static const char* _cname[];
@@ -220,14 +220,9 @@ class Track {
//---------------------------------------------------------
class MidiTrack : public Track {
- //friend class AudioTrack;
- //static unsigned int _soloRefCnt;
int _outPort;
int _outChannel;
- //int _inPortMask;
- //unsigned int _inPortMask; // bitmask of accepted record ports
- //int _inChannelMask; // bitmask of accepted record channels
bool _recEcho; // For midi (and audio). Whether to echo incoming record events to output device.
EventList* _events; // tmp Events during midi import
@@ -288,23 +283,17 @@ class MidiTrack : public Track {
void setOutChannel(int i) { _outChannel = i; }
void setOutPort(int i) { _outPort = i; }
// These will transfer controller data to the new selected port and/or channel.
- void setOutChanAndUpdate(int /*chan*/);
- void setOutPortAndUpdate(int /*port*/);
+ void setOutChanAndUpdate(int chan);
+ void setOutPortAndUpdate(int port);
// Combines both port and channel operations.
- void setOutPortAndChannelAndUpdate(int /*port*/, int /*chan*/);
+ void setOutPortAndChannelAndUpdate(int port, int chan);
- //void setInPortMask(int i) { _inPortMask = i; }
- //void setInPortMask(unsigned int i) { _inPortMask = i; } // Obsolete
- //void setInChannelMask(int i) { _inChannelMask = i; } //
// Backward compatibility: For reading old songs.
- void setInPortAndChannelMask(unsigned int /*portmask*/, int /*chanmask*/);
+ void setInPortAndChannelMask(unsigned int portmask, int chanmask);
void setRecEcho(bool b) { _recEcho = b; }
int outPort() const { return _outPort; }
- //int inPortMask() const { return _inPortMask; }
- //unsigned int inPortMask() const { return _inPortMask; }
int outChannel() const { return _outChannel; }
- //int inChannelMask() const { return _inChannelMask; }
bool recEcho() const { return _recEcho; }
virtual bool isMute() const;
@@ -312,8 +301,6 @@ class MidiTrack : public Track {
virtual void updateSoloStates(bool noDec);
virtual void updateInternalSoloStates();
- //bool soloMode() const { return _soloRefCnt; }
-
virtual bool canRecord() const { return true; }
static void setVisible(bool t) { _isVisible = t; }
static bool visible() { return _isVisible; }
@@ -350,9 +337,6 @@ class MidiTrack : public Track {
//---------------------------------------------------------
class AudioTrack : public Track {
- //friend class MidiTrack;
- //static unsigned int _soloRefCnt;
-
bool _haveData; // Whether we have data from a previous process call during current cycle.
CtrlListList _controller;
@@ -360,7 +344,6 @@ class AudioTrack : public Track {
bool _prefader; // prefader metering
std::vector<double> _auxSend;
- //void readRecfile(Xml& xml);
void readAuxSend(Xml& xml);
bool _sendMetronome;
@@ -370,7 +353,6 @@ class AudioTrack : public Track {
protected:
float** outBuffers;
- //float* outBuffers[MAX_CHANNELS];
int _totalOutChannels;
int _totalInChannels;
@@ -382,7 +364,6 @@ class AudioTrack : public Track {
public:
AudioTrack(TrackType t);
- //AudioTrack(TrackType t, int num_out_bufs = MAX_CHANNELS);
AudioTrack(const AudioTrack&, int flags);
virtual ~AudioTrack();
@@ -397,7 +378,6 @@ class AudioTrack : public Track {
bool prepareRecording();
bool processed() { return _processed; }
- //void setProcessed(bool v) { _processed = v; }
void addController(CtrlList*);
void removeController(int id);
@@ -425,8 +405,6 @@ class AudioTrack : public Track {
virtual void updateSoloStates(bool noDec);
virtual void updateInternalSoloStates();
- //bool soloMode() const { return _soloRefCnt; }
-
void putFifo(int channels, unsigned long n, float** bp);
void record();
@@ -457,11 +435,10 @@ class AudioTrack : public Track {
void setPluginCtrlVal(int param, double val);
void readVolume(Xml& xml);
- //void writeRouting(int, Xml&) const;
virtual void preProcessAlways() { _processed = false; }
- virtual void addData(unsigned /*samplePos*/, int /*channels*/, int /*srcStartChan*/, int /*srcChannels*/, unsigned /*frames*/, float** /*buffer*/);
- virtual void copyData(unsigned /*samplePos*/, int /*channels*/, int /*srcStartChan*/, int /*srcChannels*/, unsigned /*frames*/, float** /*buffer*/);
+ virtual void addData(unsigned samplePos, int channels, int srcStartChan, int srcChannels, unsigned frames, float** buffer);
+ virtual void copyData(unsigned samplePos, int channels, int srcStartChan, int srcChannels, unsigned frames, float** buffer);
virtual bool hasAuxSend() const { return false; }
// automation
@@ -539,7 +516,6 @@ class AudioOutput : public AudioTrack {
void* jackPort(int channel) { return jackPorts[channel]; }
void setJackPort(int channel, void*p) { jackPorts[channel] = p; }
virtual void setChannels(int n);
-// virtual bool isMute() const;
void processInit(unsigned);
void process(unsigned pos, unsigned offset, unsigned);
void processWrite();
@@ -617,7 +593,6 @@ class WaveTrack : public AudioTrack {
virtual void read(Xml&);
virtual void write(int, Xml&) const;
- //virtual void fetchData(unsigned pos, unsigned frames, float** bp);
virtual void fetchData(unsigned pos, unsigned frames, float** bp, bool doSeek);
virtual bool getData(unsigned, int ch, unsigned, float** bp);
diff --git a/muse2/muse/transport.cpp b/muse2/muse/transport.cpp
index 96ca599d..aa0036e5 100644
--- a/muse2/muse/transport.cpp
+++ b/muse2/muse/transport.cpp
@@ -37,11 +37,11 @@
#include "siglabel.h"
#include "globals.h"
#include "icons.h"
-///#include "posedit.h"
#include "sync.h"
#include "shortcuts.h"
#include "gconfig.h"
#include "app.h"
+#include "audio.h"
namespace MusEGui {
@@ -76,8 +76,7 @@ static QToolButton* newButton(const QPixmap* pm, const QString& tt,
//---------------------------------------------------------
// Handle
-// erlaubt das Verschieben eines Root-Windows mit der
-// Maus
+// allows moving a root-window with the mouse
//---------------------------------------------------------
Handle::Handle(QWidget* r, QWidget* parent)
@@ -114,7 +113,7 @@ void Handle::mousePressEvent(QMouseEvent* ev)
//---------------------------------------------------------
// TempoSig
-// Widget f�r Tempo + Signature
+// Widget for Tempo + Signature
//---------------------------------------------------------
TempoSig::TempoSig(QWidget* parent)
@@ -228,10 +227,6 @@ void Transport::setRecord(bool flag)
//---------------------------------------------------------
Transport::Transport(QWidget* parent, const char* name)
- // : QWidget(0, name, WStyle_Customize | WType_TopLevel | WStyle_Tool
- //| WStyle_NoBorder | WStyle_StaysOnTop)
- //: QWidget(0, name, Qt::WStyle_Customize | Qt::Window | Qt::WStyle_NoBorder | Qt::WStyle_StaysOnTop)
- //: QWidget(0, name, Qt::Window | Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint ) // Possibly also Qt::X11BypassWindowManagerHint
: QWidget(parent, Qt::Window | Qt::WindowStaysOnTopHint | Qt::FramelessWindowHint ) // Possibly also Qt::X11BypassWindowManagerHint
{
setObjectName(name);
@@ -326,7 +321,6 @@ Transport::Transport(QWidget* parent, const char* name)
marken->setSpacing(0);
marken->setContentsMargins(0, 0, 0, 0);
- ///tl1 = new PosEdit(0);
tl1 = new Awl::PosEdit(0);
tl1->setMinimumSize(105,0);
tl1->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed));
@@ -339,7 +333,6 @@ Transport::Transport(QWidget* parent, const char* name)
l5->setAlignment(Qt::AlignCenter);
marken->addWidget(l5);
- ///tl2 = new PosEdit(0);
tl2 = new Awl::PosEdit(0);
tl2->setMinimumSize(105,0);
tl2->setSizePolicy(QSizePolicy(QSizePolicy::Minimum, QSizePolicy::Fixed));
@@ -364,9 +357,7 @@ Transport::Transport(QWidget* parent, const char* name)
QHBoxLayout *hbox1 = new QHBoxLayout;
hbox1->setContentsMargins(0, 0, 0, 0);
- ///time1 = new PosEdit(0);
time1 = new Awl::PosEdit(0);
- ///time2 = new PosEdit(0);
time2 = new Awl::PosEdit(0);
time2->setSmpte(true);
time1->setMinimumSize(105,0);
@@ -508,8 +499,7 @@ Transport::Transport(QWidget* parent, const char* name)
connect(slider,SIGNAL(valueChanged(int)), SLOT(cposChanged(int)));
connect(MusEGlobal::song, SIGNAL(posChanged(int, unsigned, bool)), SLOT(setPos(int, unsigned, bool)));
connect(tempo, SIGNAL(tempoChanged(int)), MusEGlobal::song, SLOT(setTempo(int)));
- ///connect(tempo, SIGNAL(sigChanged(int, int)), MusEGlobal::song, SLOT(setSig(int, int)));
- connect(tempo, SIGNAL(sigChanged(const AL::TimeSignature&)), MusEGlobal::song, SLOT(setSig(const AL::TimeSignature&)));
+ connect(tempo, SIGNAL(sigChanged(const AL::TimeSignature&)), SLOT(sigChange(const AL::TimeSignature&)));
connect(MusEGlobal::song, SIGNAL(playChanged(bool)), SLOT(setPlay(bool)));
connect(MusEGlobal::song, SIGNAL(songChanged(int)), this, SLOT(songChanged(int)));
connect(MusEGlobal::muse, SIGNAL(configChanged()), SLOT(configChanged()));
@@ -801,5 +791,11 @@ void Transport::playToggled(bool val)
buttons[4]->blockSignals(false);
}
}
+
+void Transport::sigChange(const AL::TimeSignature& sig)
+{
+ MusEGlobal::audio->msgAddSig(MusEGlobal::song->cPos().tick(), sig.z, sig.n); // Add will replace if found.
+}
+
} // namespace MusEGui
diff --git a/muse2/muse/transport.h b/muse2/muse/transport.h
index 27fd7624..50422b66 100644
--- a/muse2/muse/transport.h
+++ b/muse2/muse/transport.h
@@ -136,6 +136,7 @@ class Transport : public QWidget
void stopToggled(bool);
void playToggled(bool);
void configChanged();
+ void sigChange(const AL::TimeSignature&);
public slots:
void setTempo(int tempo);
diff --git a/muse2/muse/undo.cpp b/muse2/muse/undo.cpp
index 9cece41c..e12fcedc 100644
--- a/muse2/muse/undo.cpp
+++ b/muse2/muse/undo.cpp
@@ -151,7 +151,7 @@ void UndoList::clearDelete()
}
}
break;
- /* case UndoOp::ModifyTrack:
+ /* case UndoOp::ModifyTrack: DELETETHIS 50
if(i->oTrack)
{
// Prevent delete i->oTrack from crashing.
@@ -207,7 +207,6 @@ void UndoList::clearDelete()
delete i->copyMarker;
break;
case UndoOp::ModifyTrackName:
- //printf("UndoList::clearDelete ModifyTrackName old:%s new:%s\n", i->_oldName, i->_newName);
if (i->_oldName)
delete i->_oldName;
if (i->_newName)
@@ -230,9 +229,8 @@ void UndoList::clearDelete()
void Song::startUndo()
{
- //redoList->clear(); // added by flo93: redo must be invalidated when a new undo is started
- redoList->clearDelete(); // p4.0.46 Tim
- MusEGlobal::redoAction->setEnabled(false); //
+ redoList->clearDelete(); // redo must be invalidated when a new undo is started
+ MusEGlobal::redoAction->setEnabled(false);
undoList->push_back(Undo());
updateFlags = 0;
@@ -299,9 +297,8 @@ bool Song::applyOperationGroup(Undo& group, bool doUndo)
}
else
{
- //redoList->clear(); // added by flo93: redo must be invalidated when a new undo is started
- redoList->clearDelete(); // p4.0.46 Tim.
- MusEGlobal::redoAction->setEnabled(false); //
+ redoList->clearDelete(); // redo must be invalidated when a new undo is started
+ MusEGlobal::redoAction->setEnabled(false);
}
return doUndo;
@@ -328,12 +325,11 @@ void Song::doUndo2()
break;
case UndoOp::DeleteTrack:
insertTrack2(i->oTrack, i->trackno);
- // Added by T356.
chainTrackParts(i->oTrack, true);
updateFlags |= SC_TRACK_INSERTED;
break;
-/*
+/* DELETETHIS 130
case UndoOp::ModifyTrack:
{
//printf("Song::doUndo2 ModifyTrack #1 oTrack %p %s nTrack %p %s\n", i->oTrack, i->oTrack->name().toLatin1().constData(), i->nTrack, i->nTrack->name().toLatin1().constData());
@@ -483,7 +479,7 @@ void Song::doUndo2()
removePart(part);
updateFlags |= SC_PART_REMOVED;
i->oPart->events()->incARef(-1);
- //i->oPart->unchainClone();
+ //i->oPart->unchainClone(); DELETETHIS
unchainClone(i->oPart);
}
break;
@@ -491,7 +487,7 @@ void Song::doUndo2()
addPart(i->oPart);
updateFlags |= SC_PART_INSERTED;
i->oPart->events()->incARef(1);
- //i->oPart->chainClone();
+ //i->oPart->chainClone(); DELETETHIS
chainClone(i->oPart);
break;
case UndoOp::ModifyPart:
@@ -500,7 +496,7 @@ void Song::doUndo2()
changePart(i->oPart, i->nPart);
i->oPart->events()->incARef(-1);
i->nPart->events()->incARef(1);
- //i->oPart->replaceClone(i->nPart);
+ //i->oPart->replaceClone(i->nPart); DELETETHIS
replaceClone(i->oPart, i->nPart);
if(i->doCtrls)
addPortCtrlEvents(i->nPart, i->doClones);
@@ -527,22 +523,18 @@ void Song::doUndo2()
updateFlags |= SC_EVENT_MODIFIED;
break;
case UndoOp::AddTempo:
- //printf("doUndo2: UndoOp::AddTempo. deleting tempo at: %d\n", i->a);
MusEGlobal::tempomap.delTempo(i->a);
updateFlags |= SC_TEMPO;
break;
case UndoOp::DeleteTempo:
- //printf("doUndo2: UndoOp::DeleteTempo. adding tempo at: %d, tempo=%d\n", i->a, i->b);
MusEGlobal::tempomap.addTempo(i->a, i->b);
updateFlags |= SC_TEMPO;
break;
case UndoOp::AddSig:
- ///sigmap.del(i->a);
AL::sigmap.del(i->a);
updateFlags |= SC_SIG;
break;
case UndoOp::DeleteSig:
- ///sigmap.add(i->a, i->b, i->c);
AL::sigmap.add(i->a, AL::TimeSignature(i->b, i->c));
updateFlags |= SC_SIG;
break;
@@ -581,7 +573,6 @@ void Song::doRedo2()
switch(i->type) {
case UndoOp::AddTrack:
insertTrack2(i->oTrack, i->trackno);
- // Added by T356.
chainTrackParts(i->oTrack, true);
updateFlags |= SC_TRACK_INSERTED;
@@ -591,7 +582,7 @@ void Song::doRedo2()
updateFlags |= SC_TRACK_REMOVED;
break;
-/*
+/* DELETETHIS 130
case UndoOp::ModifyTrack:
{
// Unchain the track parts, but don't touch the ref counts.
@@ -732,14 +723,14 @@ void Song::doRedo2()
addPart(i->oPart);
updateFlags |= SC_PART_INSERTED;
i->oPart->events()->incARef(1);
- //i->oPart->chainClone();
+ //i->oPart->chainClone(); DELETETHIS
chainClone(i->oPart);
break;
case UndoOp::DeletePart:
removePart(i->oPart);
updateFlags |= SC_PART_REMOVED;
i->oPart->events()->incARef(-1);
- //i->oPart->unchainClone();
+ //i->oPart->unchainClone(); DELETETHIS
unchainClone(i->oPart);
break;
case UndoOp::ModifyPart:
@@ -748,7 +739,7 @@ void Song::doRedo2()
changePart(i->nPart, i->oPart);
i->oPart->events()->incARef(1);
i->nPart->events()->incARef(-1);
- //i->nPart->replaceClone(i->oPart);
+ //i->nPart->replaceClone(i->oPart); DELETETHIS
replaceClone(i->nPart, i->oPart);
if(i->doCtrls)
addPortCtrlEvents(i->oPart, i->doClones);
@@ -775,22 +766,18 @@ void Song::doRedo2()
updateFlags |= SC_EVENT_MODIFIED;
break;
case UndoOp::AddTempo:
- //printf("doRedo2: UndoOp::AddTempo. adding tempo at: %d with tempo=%d\n", i->a, i->b);
MusEGlobal::tempomap.addTempo(i->a, i->b);
updateFlags |= SC_TEMPO;
break;
case UndoOp::DeleteTempo:
- //printf("doRedo2: UndoOp::DeleteTempo. deleting tempo at: %d with tempo=%d\n", i->a, i->b);
MusEGlobal::tempomap.delTempo(i->a);
updateFlags |= SC_TEMPO;
break;
case UndoOp::AddSig:
- ///sigmap.add(i->a, i->b, i->c);
AL::sigmap.add(i->a, AL::TimeSignature(i->b, i->c));
updateFlags |= SC_SIG;
break;
case UndoOp::DeleteSig:
- ///sigmap.del(i->a);
AL::sigmap.del(i->a);
updateFlags |= SC_SIG;
break;
@@ -982,7 +969,7 @@ bool Song::doUndo1()
case Track::AUDIO_INPUT:
connectJackRoutes((AudioTrack*)i->oTrack, false);
break;
- //case Track::AUDIO_SOFTSYNTH:
+ //case Track::AUDIO_SOFTSYNTH: DELETETHIS 4
//SynthI* si = (SynthI*)i->oTrack;
//si->synth()->init(
// break;
@@ -1003,22 +990,19 @@ bool Song::doUndo1()
{
MusECore::MidiTrack* mt = dynamic_cast<MusECore::MidiTrack*>(i->_propertyTrack);
if (mt == 0 || mt->type() == MusECore::Track::DRUM)
- //if (mt == 0 || mt->isDrumTrack()) // For Flo later with new drum tracks. p4.0.46 Tim
break;
if (i->_oldPropValue != mt->outChannel())
{
- //mt->setOutChannel(i->_oldPropValue);
MusEGlobal::audio->msgIdle(true);
- //MusEGlobal::audio->msgSetTrackOutChannel(mt, i->_oldPropValue);
mt->setOutChanAndUpdate(i->_oldPropValue);
MusEGlobal::audio->msgIdle(false);
+ // DELETETHIS 6
//if (mt->type() == MusECore::MidiTrack::DRUM) {//Change channel on all drum instruments
// for (int i=0; i<DRUM_MAPSIZE; i++)
// MusEGlobal::drumMap[i].channel = i->_oldPropValue;
// }
//updateFlags |= SC_CHANNELS;
MusEGlobal::audio->msgUpdateSoloStates();
- //updateFlags |= SC_MIDI_TRACK_PROP | SC_ROUTE;
updateFlags |= SC_MIDI_TRACK_PROP;
}
}
@@ -1061,19 +1045,17 @@ void Song::doUndo3()
insertTrack3(i->oTrack, i->trackno);
break;
case UndoOp::ModifyTrack:
- // Not much choice but to do this - Tim.
+ // Not much choice but to do this - Tim. DELETETHIS 2
//clearClipboardAndCloneList();
break;
case UndoOp::ModifyMarker:
{
- //printf("performing undo for one marker at copy %d real %d\n", i->copyMarker, i->realMarker);
if (i->realMarker) {
Marker tmpMarker = *i->realMarker;
*i->realMarker = *i->copyMarker; // swap them
*i->copyMarker = tmpMarker;
}
else {
- //printf("flipping marker\n");
i->realMarker = _markerList->add(*i->copyMarker);
delete i->copyMarker;
i->copyMarker = 0;
@@ -1112,7 +1094,7 @@ bool Song::doRedo1()
case Track::AUDIO_INPUT:
connectJackRoutes((AudioTrack*)i->oTrack, false);
break;
- //case Track::AUDIO_SOFTSYNTH:
+ //case Track::AUDIO_SOFTSYNTH: DELETETHIS 4
//SynthI* si = (SynthI*)i->oTrack;
//si->synth()->init(
// break;
@@ -1136,22 +1118,19 @@ bool Song::doRedo1()
{
MusECore::MidiTrack* mt = dynamic_cast<MusECore::MidiTrack*>(i->_propertyTrack);
if (mt == 0 || mt->type() == MusECore::Track::DRUM)
- //if (mt == 0 || mt->isDrumTrack()) // For Flo later with new drum tracks. p4.0.46 Tim
break;
if (i->_newPropValue != mt->outChannel())
{
- //mt->setOutChannel(i->_newPropValue);
MusEGlobal::audio->msgIdle(true);
- //MusEGlobal::audio->msgSetTrackOutChannel(mt, i->_newPropValue);
mt->setOutChanAndUpdate(i->_newPropValue);
MusEGlobal::audio->msgIdle(false);
+ // DELETETHIS 5
//if (mt->type() == MusECore::MidiTrack::DRUM) {//Change channel on all drum instruments
// for (int i=0; i<DRUM_MAPSIZE; i++)
// MusEGlobal::drumMap[i].channel = i->_newPropValue;
// }
//updateFlags |= SC_CHANNELS;
MusEGlobal::audio->msgUpdateSoloStates();
- //updateFlags |= SC_MIDI_TRACK_PROP | SC_ROUTE;
updateFlags |= SC_MIDI_TRACK_PROP;
}
}
@@ -1194,12 +1173,11 @@ void Song::doRedo3()
removeTrack3(i->oTrack);
break;
case UndoOp::ModifyTrack:
- // Not much choice but to do this - Tim.
+ // Not much choice but to do this - Tim. DELETETHIS 2
//clearClipboardAndCloneList();
break;
case UndoOp::ModifyMarker:
{
- //printf("performing redo for one marker at copy %d real %d\n", i->copyMarker, i->realMarker);
if (i->copyMarker) {
Marker tmpMarker = *i->realMarker;
*i->realMarker = *i->copyMarker; // swap them
diff --git a/muse2/muse/vst.cpp b/muse2/muse/vst.cpp
index f72d426b..1f03e0ac 100644
--- a/muse2/muse/vst.cpp
+++ b/muse2/muse/vst.cpp
@@ -60,7 +60,6 @@ long vstHostCallback(AEffect* effect,
{
static VstTimeInfo _timeInfo;
-// JackVST* jackvst = effect ? ((JackVST*) effect->user) : NULL;
jack_position_t jack_pos;
jack_transport_state_t tstate;
@@ -300,7 +299,6 @@ static void scanVstDir(const QString& s)
FSTInfo* info = fst_get_info(path);
if (info) {
if (info->numInputs == 0 && info->numOutputs)
- //synthis.push_back(new VstSynth(*fi));
synthis.push_back(new VstSynth(*fi, fi->baseName(), QString(), QString(), QString()));
fst_free_info(info);
}
@@ -468,7 +466,7 @@ void* VstSynth::instantiate()
undoSetuid();
return 0;
}
-// int vst_version = plugin->dispatcher (plugin, effGetVstVersion, 0, 0, NULL, 0.0f);
+
undoSetuid();
return fst;
}
@@ -509,11 +507,8 @@ int VstSynthIF::totalInChannels() const
// createSIF
//---------------------------------------------------------
-//SynthIF* VstSynth::createSIF() const
SynthIF* VstSynth::createSIF(SynthI* s)
{
- //return new VstSynthIF();
-
VstSynthIF* sif = new VstSynthIF(s);
sif->init(this, s);
return sif;
diff --git a/muse2/muse/vst.h b/muse2/muse/vst.h
index b41e7137..3490cb39 100644
--- a/muse2/muse/vst.h
+++ b/muse2/muse/vst.h
@@ -44,7 +44,6 @@ class VstSynth : public Synth {
_FSTHandle* fstHandle;
public:
- //VstSynth(const QFileInfo& fi) : Synth(fi) { fstHandle = 0; }
VstSynth(const QFileInfo& fi) : Synth(fi, fi->baseName()) {
fstHandle = 0;
}
@@ -53,7 +52,6 @@ class VstSynth : public Synth {
virtual Type synthType() const { return VST_SYNTH; }
virtual void incInstances(int val);
virtual void* instantiate();
- //virtual SynthIF* createSIF() const;
virtual SynthIF* createSIF(SynthI*) const;
};
@@ -68,7 +66,6 @@ class VstSynthIF : public SynthIF
bool _guiVisible;
public:
- //VstSynthIF() { _fst = 0; _guiVisible = false; }
VstSynthIF(SynthI* s) : SynthIF(s) {
_fst = 0;
_guiVisible = false;
@@ -98,7 +95,6 @@ class VstSynthIF : public SynthIF
virtual void deactivate3();
virtual const char* getPatchName(int, int, int, bool) const { return ""; }
virtual const char* getPatchName(int, int, MType, bool) { return ""; }
- //virtual void populatePatchPopup(QMenu*, int, MType, bool) {};
virtual void populatePatchPopup(PopupMenu*, int, MType, bool) {};
virtual void write(int level, Xml& xml) const;
virtual float getParameter(unsigned long idx) const;
diff --git a/muse2/muse/wave.cpp b/muse2/muse/wave.cpp
index f22f6f97..536320d5 100644
--- a/muse2/muse/wave.cpp
+++ b/muse2/muse/wave.cpp
@@ -48,18 +48,8 @@
namespace MusECore {
-/*
-const char* audioFilePattern[] = {
- "Wave/Binary (*.wav *.ogg *.bin)",
- "Wave (*.wav *.ogg)",
- "Binary (*.bin)",
- "All Files (*)",
- 0
- };
-*/
const int cacheMag = 128;
-// ClipList* waveClips;
SndFileList SndFile::sndFiles;
@@ -147,18 +137,14 @@ void SndFile::update()
void SndFile::readCache(const QString& path, bool showProgress)
{
-// printf("readCache %s for %d samples channel %d\n",
-// path.toLatin1().constData(), samples(), channels());
-
if (cache) {
for (unsigned i = 0; i < channels(); ++i)
delete [] cache[i];
delete[] cache;
}
- if (samples() == 0) {
-// printf("SndFile::readCache: file empty\n");
+ if (samples() == 0)
return;
- }
+
csize = (samples() + cacheMag - 1)/cacheMag;
cache = new SampleV*[channels()];
for (unsigned ch = 0; ch < channels(); ++ch)
@@ -249,10 +235,9 @@ void SndFile::read(SampleV* s, int mag, unsigned pos, bool overwrite)
s[ch].rms = 0;
}
- if (pos > samples()) {
-// printf("%p pos %d > samples %d\n", this, pos, samples());
+ if (pos > samples())
return;
- }
+
if (mag < cacheMag) {
float data[channels()][mag];
@@ -556,7 +541,6 @@ size_t SndFile::write(int srcChannels, float** src, size_t n)
if (srcChannels == dstChannels) {
for (size_t i = 0; i < n; ++i) {
for (int ch = 0; ch < dstChannels; ++ch)
- //*dst++ = *(src[ch]+i); // < limitValue ? *(src[ch]+i) : limitValue;
if (*(src[ch]+i) > 0)
*dst++ = *(src[ch]+i) < limitValue ? *(src[ch]+i) : limitValue;
else
@@ -648,7 +632,6 @@ SndFile* getWave(const QString& inName, bool readOnlyFlag)
}
}
}
-// printf("=====%s %s\n", inName.toLatin1().constData(), name.toLatin1().constData());
// only open one instance of wave file
SndFile* f = SndFile::sndFiles.search(name);
@@ -669,7 +652,6 @@ SndFile* getWave(const QString& inName, bool readOnlyFlag)
QString cacheName = wavinfo.absolutePath() + QString("/") + wavinfo.completeBaseName() + QString(".wca");
QFileInfo wcainfo(cacheName);
if (!wcainfo.exists() || wcainfo.lastModified() < wavinfo.lastModified()) {
- //printf("wcafile is older or does not exist!\n");
QFile(cacheName).remove();
f->readCache(cacheName,true);
}
@@ -702,7 +684,6 @@ SndFile* getWave(const QString& inName, bool readOnlyFlag)
QString cacheName = wavinfo.absolutePath() + QString("/") + wavinfo.completeBaseName() + QString(".wca");
QFileInfo wcainfo(cacheName);
if (!wcainfo.exists() || wcainfo.lastModified() < wavinfo.lastModified()) {
- //printf("wcafile is older or does not exist!\n");
QFile(cacheName).remove();
f->readCache(cacheName,true);
}
@@ -727,7 +708,6 @@ void SndFile::applyUndoFile(const QString& original, const QString& tmpfile, uns
// put in the tmpfile, and when redo is eventually called the data is switched again (causing the muted data to be written to the "original"
// file. The data is merely switched.
- //printf("Applying undofile: orig=%s tmpfile=%s startframe=%d endframe=%d\n", original.toLatin1().constData(), tmpfile.toLatin1().constData(), startframe, endframe);
SndFile* orig = sndFiles.search(original);
SndFile tmp = SndFile(tmpfile);
if (!orig) {
@@ -809,6 +789,7 @@ void SndFile::applyUndoFile(const QString& original, const QString& tmpfile, uns
MusEGlobal::audio->msgIdle(false);
}
+// DELETETHIS 170
#if 0
//---------------------------------------------------------
// Clip
@@ -983,7 +964,6 @@ int ClipList::idx(const Clip& clip) const
// cmdAddRecordedWave
//---------------------------------------------------------
-//void Song::cmdAddRecordedWave(WaveTrack* track, const MusECore::Pos& s, const MusECore::Pos& e)
void Song::cmdAddRecordedWave(MusECore::WaveTrack* track, MusECore::Pos s, MusECore::Pos e)
{
if (MusEGlobal::debugMsg)
@@ -996,18 +976,11 @@ void Song::cmdAddRecordedWave(MusECore::WaveTrack* track, MusECore::Pos s, MusEC
return;
}
- // Removed by Tim. p3.3.8
- //unsigned startTick = roundDownBar(s.tick());
- //unsigned endTick = roundUpBar(e.tick());
-
- // Added by Tim. p3.3.8
-
if((MusEGlobal::audio->loopCount() > 0 && s.tick() > lPos().tick()) || (punchin() && s.tick() < lPos().tick()))
s.setTick(lPos().tick());
// If we are looping, just set the end to the right marker, since we don't know how many loops have occurred.
// (Fixed: Added Audio::loopCount)
// Otherwise if punchout is on, limit the end to the right marker.
- //if(loop() || (punchout() && e.tick() > rPos().tick()) )
if((MusEGlobal::audio->loopCount() > 0) || (punchout() && e.tick() > rPos().tick()) )
e.setTick(rPos().tick());
// No part to be created? Delete the rec sound file.
@@ -1126,13 +1099,6 @@ void SndFileList::clearDelete()
// sure) and deletes the entry on its own.
while (!empty())
delete *begin();
-
- /* this is wrong, because ~SndFile deletes itself from the
- * list, causing the iterator to be invalidated -> fail.
- for (SndFileList::iterator i = begin(); i != end(); ++i)
- delete *i;
- clear();
- */
}
@@ -1153,7 +1119,6 @@ void MusE::importWave()
"a wave track"));
return;
}
- //QString fn = MusEGui::getOpenFileName(MusEGlobal::lastWavePath, audioFilePattern, this,
QString fn = MusEGui::getOpenFileName(MusEGlobal::lastWavePath, MusEGlobal::audio_file_pattern, this,
tr("Import Wave File"), 0);
if (!fn.isEmpty()) {
@@ -1186,7 +1151,6 @@ bool MusE::importWaveToTrack(QString& name, unsigned tick, MusECore::Track* trac
tr("&Yes"), tr("&No"),
QString::null, 0, 1 ))
{
- //printf("why won't muse let me delete the file object? %d\n", f->getRefCount());
if (f->getRefCount() == 0)
delete f;
return true;
diff --git a/muse2/muse/wave.h b/muse2/muse/wave.h
index 535df939..133c0dfd 100644
--- a/muse2/muse/wave.h
+++ b/muse2/muse/wave.h
@@ -52,7 +52,6 @@ class SndFileList;
//---------------------------------------------------------
class SndFile {
- //static SndFileList _sndFiles;
QFileInfo* finfo;
SNDFILE* sf;
SNDFILE* sfUI;
@@ -242,7 +241,6 @@ class Clip {
bool operator==(ClipBase* c) const { return clip == c; }
~Clip();
- // ClipBase* clipBase() const { return clip; }
bool isNull() const { return clip == 0; }
int getRefCount() const { return clip->getRefCount(); }
diff --git a/muse2/muse/waveedit/waveedit.cpp b/muse2/muse/waveedit/waveedit.cpp
index 06b5ab1d..6cad9871 100644
--- a/muse2/muse/waveedit/waveedit.cpp
+++ b/muse2/muse/waveedit/waveedit.cpp
@@ -80,7 +80,7 @@ void WaveEdit::closeEvent(QCloseEvent* e)
WaveEdit::WaveEdit(MusECore::PartList* pl)
: MidiEditor(TopWin::WAVE, 1, pl)
{
- setFocusPolicy(Qt::StrongFocus);
+ setFocusPolicy(Qt::NoFocus);
QSignalMapper* mapper = new QSignalMapper(this);
QAction* act;
@@ -190,6 +190,7 @@ WaveEdit::WaveEdit(MusECore::PartList* pl)
solo = new QToolButton();
solo->setText(tr("Solo"));
solo->setCheckable(true);
+ solo->setFocusPolicy(Qt::NoFocus);
tb1->addWidget(solo);
connect(solo, SIGNAL(toggled(bool)), SLOT(soloChanged(bool)));
@@ -230,7 +231,8 @@ WaveEdit::WaveEdit(MusECore::PartList* pl)
ymag->setMaximum(256);
ymag->setPageStep(256);
ymag->setValue(yscale);
-
+ ymag->setFocusPolicy(Qt::NoFocus);
+
time = new MTScale(&_raster, mainw, xscale, true);
ymag->setFixedWidth(16);
connect(view, SIGNAL(mouseWheelMoved(int)), this, SLOT(moveVerticalSlider(int)));
@@ -250,7 +252,7 @@ WaveEdit::WaveEdit(MusECore::PartList* pl)
mainGrid->addWidget(hscroll, 3, 0);
mainGrid->addWidget(corner, 3, 1, Qt::AlignBottom | Qt::AlignRight);
- view->setFocus(); // Tim.
+ view->setFocus();
connect(hscroll, SIGNAL(scrollChanged(int)), view, SLOT(setXPos(int)));
connect(hscroll, SIGNAL(scaleChanged(int)), view, SLOT(setXMag(int)));
diff --git a/muse2/muse/waveevent.cpp b/muse2/muse/waveevent.cpp
index 22041bd8..2cbf7cad 100644
--- a/muse2/muse/waveevent.cpp
+++ b/muse2/muse/waveevent.cpp
@@ -32,7 +32,7 @@
// Added by Tim. p3.3.18
//#define USE_SAMPLERATE
-//
+
//#define WAVEEVENT_DEBUG
//#define WAVEEVENT_DEBUG_PRC
@@ -141,8 +141,6 @@ void WaveEventBase::write(int level, Xml& xml, const Pos& offset, bool forcePath
xml.tag(level++, "event");
PosLen wpos(*this);
wpos += offset;
-// if (offset)
-// wpos.setTick(wpos.tick() + offset);
wpos.write(level, xml, "poslen");
xml.intTag(level, "frame", _spos); // offset in wave file
@@ -152,7 +150,6 @@ void WaveEventBase::write(int level, Xml& xml, const Pos& offset, bool forcePath
//
QString path = f.dirPath();
- //if (path.contains(MusEGlobal::museProject)) {
if (!forcePath && path.contains(MusEGlobal::museProject)) {
// extract MusEGlobal::museProject.
QString newName = f.path().remove(MusEGlobal::museProject+"/");
@@ -163,11 +160,6 @@ void WaveEventBase::write(int level, Xml& xml, const Pos& offset, bool forcePath
xml.etag(level, "event");
}
-//void WaveEventBase::read(unsigned offset, float** buffer, int channel, int n, bool overwrite)
-//void WaveEventBase::readAudio(unsigned offset, float** buffer, int channel, int n, bool doSeek, bool overwrite)
-//off_t WaveEventBase::readAudio(SRC_STATE* src_state, off_t sfCurFrame, unsigned offset, float** buffer, int channel, int n, bool doSeek, bool overwrite)
-//off_t WaveEventBase::readAudio(AudioConverter* audConv, off_t sfCurFrame, unsigned offset, float** buffer, int channel, int n, bool doSeek, bool overwrite)
-// p3.3.33
void WaveEventBase::readAudio(WavePart* /*part*/, unsigned offset, float** buffer, int channel, int n, bool /*doSeek*/, bool overwrite)
{
// Added by Tim. p3.3.17
@@ -175,6 +167,11 @@ void WaveEventBase::readAudio(WavePart* /*part*/, unsigned offset, float** buffe
printf("WaveEventBase::readAudio audConv:%p sfCurFrame:%ld offset:%u channel:%d n:%d\n", audConv, sfCurFrame, offset, channel, n);
#endif
+ // DELETETHIS 270. all the below stuff hasn't changed since revision 462, and
+ // will not compile, and has a TODO in it.
+ // will this ever be done, or is it completely obsolete?
+ // even if we keep the #ifdef branch, there's a huge
+ // comment in it. delete that?
// Changed by Tim. p3.3.18
#ifdef USE_SAMPLERATE
@@ -182,7 +179,7 @@ void WaveEventBase::readAudio(WavePart* /*part*/, unsigned offset, float** buffe
>>>>>>>>>>>+++++++++++++++++++++++++++++
// If we have a valid audio converter then use it to do the processing. Otherwise just a normal seek + read.
if(audConv)
- //sfCurFrame = audConv->process(f, sfCurFrame, offset + _spos, buffer, channel, n, doSeek, overwrite);
+ //sfCurFrame = audConv->process(f, sfCurFrame, offset + _spos, buffer, channel, n, doSeek, overwrite); DELETETHIS
sfCurFrame = audConv->readAudio(f, sfCurFrame, offset, buffer, channel, n, doSeek, overwrite);
else
{
@@ -192,10 +189,9 @@ void WaveEventBase::readAudio(WavePart* /*part*/, unsigned offset, float** buffe
sfCurFrame += f.read(channel, buffer, n, overwrite);
}
}
- //return sfCurFrame;
return;
- /*
+ /* DELETETHIS 250
unsigned fsrate = f.samplerate();
int fchan = f.channels();
off_t frame = offset + _spos;
@@ -451,18 +447,12 @@ void WaveEventBase::readAudio(WavePart* /*part*/, unsigned offset, float** buffe
#else
if(f.isNull())
return;
- //return sfCurFrame;
- //sfCurFrame = f.seek(offset + _spos, 0);
+ //sfCurFrame = f.seek(offset + _spos, 0); DELETETHIS 2
//sfCurFrame += f.read(channel, buffer, n, overwrite);
f.seek(offset + _spos, 0);
f.read(channel, buffer, n, overwrite);
- // p3.3.41
- //fprintf(stderr, "WaveEventBase::readAudio data: n:%ld %e %e %e %e\n", n, buffer[0][0], buffer[0][1], buffer[0][2], buffer[0][3]);
-
-
- //return sfCurFrame;
return;
#endif
diff --git a/muse2/muse/waveevent.h b/muse2/muse/waveevent.h
index 278b0ad3..2c1bf76d 100644
--- a/muse2/muse/waveevent.h
+++ b/muse2/muse/waveevent.h
@@ -24,7 +24,6 @@
#ifndef __WAVE_EVENT_H__
#define __WAVE_EVENT_H__
-//#include <samplerate.h>
#include <sys/types.h>
#include "eventbase.h"
@@ -45,8 +44,6 @@ class WaveEventBase : public EventBase {
int _spos; // start sample position in WaveFile
bool deleted;
- // p3.3.31
- //virtual EventBase* clone() { return new WaveEventBase(*this); }
virtual EventBase* clone();
public:
@@ -54,7 +51,6 @@ class WaveEventBase : public EventBase {
virtual ~WaveEventBase() {}
virtual void read(Xml&);
- //virtual void write(int, Xml&, const Pos& offset) const;
virtual void write(int, Xml&, const Pos& offset, bool forcePath = false) const;
virtual EventBase* mid(unsigned, unsigned);
@@ -67,15 +63,8 @@ class WaveEventBase : public EventBase {
virtual SndFileR sndFile() const { return f; }
virtual void setSndFile(SndFileR& sf) { f = sf; }
- // Changed by Tim. p3.3.17
- //virtual void read(unsigned offset, float** bpp, int channels, int nn, bool overwrite = true);
- //virtual void readAudio(unsigned /*offset*/, float** /*bpp*/, int /*channels*/, int /*nn*/, bool /*doSeek*/, bool /*overwrite*/);
- //virtual off_t readAudio(SRC_STATE* /*src_state*/, off_t /*sfCurFrame*/, unsigned /*offset*/,
- // float** /*bpp*/, int /*channels*/, int /*nn*/, bool /*doSeek*/, bool /*overwrite*/);
- //virtual off_t readAudio(AudioConverter* /*audConv*/, off_t /*sfCurFrame*/, unsigned /*offset*/,
- // float** /*bpp*/, int /*channels*/, int /*nn*/, bool /*doSeek*/, bool /*overwrite*/);
- virtual void readAudio(WavePart* /*part*/, unsigned /*offset*/,
- float** /*bpp*/, int /*channels*/, int /*nn*/, bool /*doSeek*/, bool /*overwrite*/);
+ virtual void readAudio(WavePart* part, unsigned offset,
+ float** bpp, int channels, int nn, bool doSeek, bool overwrite);
};
} // namespace MusECore
diff --git a/muse2/muse/wavetrack.cpp b/muse2/muse/wavetrack.cpp
index 0d699cbe..cc788d2d 100644
--- a/muse2/muse/wavetrack.cpp
+++ b/muse2/muse/wavetrack.cpp
@@ -41,7 +41,6 @@ namespace MusECore {
// called from prefetch thread
//---------------------------------------------------------
-//void WaveTrack::fetchData(unsigned pos, unsigned samples, float** bp)
void WaveTrack::fetchData(unsigned pos, unsigned samples, float** bp, bool doSeek)
{
// Added by Tim. p3.3.17
@@ -53,7 +52,6 @@ void WaveTrack::fetchData(unsigned pos, unsigned samples, float** bp, bool doSee
for (int i = 0; i < channels(); ++i)
memset(bp[i], 0, samples * sizeof(float));
- // p3.3.29
// Process only if track is not off.
if(!off())
{
@@ -62,8 +60,6 @@ void WaveTrack::fetchData(unsigned pos, unsigned samples, float** bp, bool doSee
unsigned n = samples;
for (iPart ip = pl->begin(); ip != pl->end(); ++ip) {
WavePart* part = (WavePart*)(ip->second);
- // Changed by Tim. p3.3.17
- //if (part->mute() || isMute())
if (part->mute())
continue;
@@ -106,12 +102,6 @@ void WaveTrack::fetchData(unsigned pos, unsigned samples, float** bp, bool doSee
for (int i = 0; i < channels(); ++i)
bpp[i] = bp[i] + dstOffset;
- // By T356. Allow overlapping parts or events to mix together !
- // Since the buffers are cleared above, just read and add (don't overwrite) the samples.
- //event.read(srcOffset, bpp, channels(), nn);
- //event.read(srcOffset, bpp, channels(), nn, false);
- //event.readAudio(srcOffset, bpp, channels(), nn, doSeek, false);
- // p3.3.33
event.readAudio(part, srcOffset, bpp, channels(), nn, doSeek, false);
}
@@ -122,22 +112,9 @@ void WaveTrack::fetchData(unsigned pos, unsigned samples, float** bp, bool doSee
// add denormal bias to outdata
for (int i = 0; i < channels(); ++i)
for (unsigned int j = 0; j < samples; ++j)
- {
bp[i][j] +=MusEGlobal::denormalBias;
-
- /*
- // p3.3.41
- if(j & 1)
- bp[i][j] -=MusEGlobal::denormalBias;
- else
- bp[i][j] +=MusEGlobal::denormalBias;
- */
- }
}
- // p3.3.41
- //fprintf(stderr, "WaveTrack::fetchData data: samples:%ld %e %e %e %e\n", samples, bp[0][0], bp[0][1], bp[0][2], bp[0][3]);
-
_prefetchFifo.add();
}
@@ -170,8 +147,6 @@ void WaveTrack::read(Xml& xml)
return;
case Xml::TagStart:
if (tag == "part") {
- //Part* p = newPart();
- //p->read(xml);
Part* p = 0;
p = readXmlPart(xml, this);
if(p)
@@ -209,7 +184,6 @@ Part* WaveTrack::newPart(Part*p, bool clone)
}
if(clone)
- //p->chainClone(part);
chainClone(p, part);
return part;
@@ -221,22 +195,13 @@ Part* WaveTrack::newPart(Part*p, bool clone)
bool WaveTrack::getData(unsigned framePos, int channels, unsigned nframe, float** bp)
{
- //if(MusEGlobal::debugMsg)
- // printf("WaveTrack::getData framePos:%u channels:%d nframe:%u processed?:%d\n", framePos, channels, nframe, processed());
-
if ((MusEGlobal::song->bounceTrack != this) && !noInRoute()) {
RouteList* irl = inRoutes();
ciRoute i = irl->begin();
if(i->track->isMidiTrack())
- {
- //if(MusEGlobal::debugMsg)
- // printf("WaveTrack::getData: Error: First route is a midi track route!\n");
return false;
- }
- // p3.3.38
- //((AudioTrack*)i->track)->copyData(framePos, channels, nframe, bp);
+
((AudioTrack*)i->track)->copyData(framePos, channels,
- //(i->track->type() == Track::AUDIO_SOFTSYNTH && i->channel != -1) ? i->channel : 0,
i->channel,
i->channels,
nframe, bp);
@@ -245,16 +210,9 @@ bool WaveTrack::getData(unsigned framePos, int channels, unsigned nframe, float*
for (; i != irl->end(); ++i)
{
if(i->track->isMidiTrack())
- {
- //if(MusEGlobal::debugMsg)
- // printf("WaveTrack::getData: Error: Route is a midi track route!\n");
- //return false;
continue;
- }
- // p3.3.38
- //((AudioTrack*)i->track)->addData(framePos, channels, nframe, bp);
+
((AudioTrack*)i->track)->addData(framePos, channels,
- //(i->track->type() == Track::AUDIO_SOFTSYNTH && i->channel != -1) ? i->channel : 0,
i->channel,
i->channels,
nframe, bp);
@@ -276,6 +234,7 @@ bool WaveTrack::getData(unsigned framePos, int channels, unsigned nframe, float*
if (!MusEGlobal::audio->isPlaying())
return false;
+ // DELETETHIS 43
// Removed by T356. Multiple out route cacheing now handled by AudioTrack::copyData and ::addData.
/*
if (outRoutes()->size() > 1) {
@@ -318,14 +277,11 @@ bool WaveTrack::getData(unsigned framePos, int channels, unsigned nframe, float*
else {
*/
- //printf("WaveTrack::getData no out routes\n");
if (MusEGlobal::audio->freewheel()) {
// when freewheeling, read data direct from file:
// Indicate do not seek file before each read.
- // Changed by Tim. p3.3.17
- //fetchData(framePos, nframe, bp);
fetchData(framePos, nframe, bp, false);
}
@@ -348,12 +304,7 @@ bool WaveTrack::getData(unsigned framePos, int channels, unsigned nframe, float*
}
}
}
-
- // p3.3.41
- //fprintf(stderr, "WaveTrack::getData %s data: nframe:%ld %e %e %e %e\n", name().toLatin1().constData(), nframe, bp[0][0], bp[0][1], bp[0][2], bp[0][3]);
-
}
- //}
return true;
}
diff --git a/muse2/muse/widgets/CMakeLists.txt b/muse2/muse/widgets/CMakeLists.txt
index d037f06e..fae0d614 100644
--- a/muse2/muse/widgets/CMakeLists.txt
+++ b/muse2/muse/widgets/CMakeLists.txt
@@ -45,6 +45,7 @@ QT4_WRAP_CPP (widget_mocs
dentry.h
didyouknow.h
doublelabel.h
+ doublespinbox.h
filedialog.h
genset.h
mdisettings.h
@@ -155,6 +156,7 @@ file (GLOB widgets_source_files
dentry.cpp
dimap.cpp
doublelabel.cpp
+ doublespinbox.cpp
drange.cpp
filedialog.cpp
genset.cpp
diff --git a/muse2/muse/widgets/doublespinbox.cpp b/muse2/muse/widgets/doublespinbox.cpp
new file mode 100644
index 00000000..71ca4149
--- /dev/null
+++ b/muse2/muse/widgets/doublespinbox.cpp
@@ -0,0 +1,102 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// doublespinbox.cpp (C) Copyright 2012 Tim E. Real (terminator356 at users dot sourceforge dot net)
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; version 2 of
+// the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+//=========================================================
+
+#include <QKeyEvent>
+#include <QLineEdit>
+#include <QMouseEvent>
+#include "doublespinbox.h"
+
+namespace MusEGui {
+
+//void DoubleSpinBoxLineEdit::mouseDoubleClickEvent(QMouseEvent* e)
+//{
+// QLineEdit::mouseDoubleClickEvent(e);
+// emit doubleClicked();
+// if((e->buttons() & Qt::LeftButton) && (e->modifiers() & Qt::ControlModifier))
+// emit ctrlDoubleClicked();
+//}
+
+void DoubleSpinBoxLineEdit::mousePressEvent(QMouseEvent* e)
+{
+ QLineEdit::mousePressEvent(e);
+ //selectAll();
+ if((e->buttons() & Qt::LeftButton) && (e->modifiers() & Qt::ControlModifier))
+ emit ctrlClicked();
+}
+
+//---------------------------------------------------------
+// DoubleSpinBox
+//---------------------------------------------------------
+
+DoubleSpinBox::DoubleSpinBox(QWidget* parent)
+ : QDoubleSpinBox(parent)
+{
+ DoubleSpinBoxLineEdit* le = new DoubleSpinBoxLineEdit(this);
+ setLineEdit(le);
+ setKeyboardTracking(false);
+
+ //connect(le, SIGNAL(doubleClicked()), this, SIGNAL(doubleClicked()));
+ //connect(le, SIGNAL(ctrlDoubleClicked()), this, SIGNAL(ctrlDoubleClicked()));
+ connect(le, SIGNAL(ctrlClicked()), this, SIGNAL(ctrlClicked()));
+}
+
+DoubleSpinBox::DoubleSpinBox(double minValue, double maxValue, double step, QWidget* parent)
+ : QDoubleSpinBox(parent)
+{
+ DoubleSpinBoxLineEdit* le = new DoubleSpinBoxLineEdit(this);
+ setLineEdit(le);
+ setRange(minValue, maxValue);
+ setSingleStep(step);
+ setKeyboardTracking(false);
+
+ //connect(le, SIGNAL(doubleClicked()), this, SIGNAL(doubleClicked()));
+ //connect(le, SIGNAL(ctrlDoubleClicked()), this, SIGNAL(ctrlDoubleClicked()));
+ connect(le, SIGNAL(ctrlClicked()), this, SIGNAL(ctrlClicked()));
+}
+
+void DoubleSpinBox::keyPressEvent(QKeyEvent* ev)
+{
+ switch (ev->key()) {
+ case Qt::Key_Return:
+ QDoubleSpinBox::keyPressEvent(ev);
+ emit returnPressed();
+ return;
+ break;
+ case Qt::Key_Escape:
+ emit escapePressed();
+ return;
+ break;
+ default:
+ break;
+ }
+ QDoubleSpinBox::keyPressEvent(ev);
+}
+
+void DoubleSpinBox::wheelEvent(QWheelEvent* e)
+{
+ QDoubleSpinBox::wheelEvent(e);
+ // Need this because Qt doesn't deselect the text if not focused.
+ if(!hasFocus() && lineEdit())
+ lineEdit()->deselect();
+}
+
+} // namespace MusEGui
+
diff --git a/muse2/muse/widgets/doublespinbox.h b/muse2/muse/widgets/doublespinbox.h
new file mode 100644
index 00000000..f3dfcdb0
--- /dev/null
+++ b/muse2/muse/widgets/doublespinbox.h
@@ -0,0 +1,73 @@
+//=========================================================
+// MusE
+// Linux Music Editor
+// doublespinbox.h (C) Copyright 2012 Tim E. Real (terminator356 at users dot sourceforge dot net)
+//
+// This program is free software; you can redistribute it and/or
+// modify it under the terms of the GNU General Public License
+// as published by the Free Software Foundation; version 2 of
+// the License, or (at your option) any later version.
+//
+// This program is distributed in the hope that it will be useful,
+// but WITHOUT ANY WARRANTY; without even the implied warranty of
+// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+// GNU General Public License for more details.
+//
+// You should have received a copy of the GNU General Public License
+// along with this program; if not, write to the Free Software
+// Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+//
+//=========================================================
+
+#ifndef __DOUBLESPINBOX_H__
+#define __DOUBLESPINBOX_H__
+
+#include <QDoubleSpinBox>
+#include <QLineEdit>
+
+namespace MusEGui {
+
+class DoubleSpinBoxLineEdit : public QLineEdit
+{
+ Q_OBJECT
+
+ protected:
+ //virtual void mouseDoubleClickEvent(QMouseEvent* e);
+ virtual void mousePressEvent(QMouseEvent* e);
+
+ signals:
+ //void doubleClicked();
+ //void ctrlDoubleClicked();
+ void ctrlClicked();
+
+ public:
+ DoubleSpinBoxLineEdit(QWidget* parent = 0) : QLineEdit(parent) {};
+};
+
+//---------------------------------------------------------
+// DoubleSpinBox
+//---------------------------------------------------------
+
+class DoubleSpinBox : public QDoubleSpinBox {
+ Q_OBJECT
+
+ protected:
+ virtual void keyPressEvent(QKeyEvent*);
+ virtual void wheelEvent(QWheelEvent*);
+
+ signals:
+ //void doubleClicked();
+ //void ctrlDoubleClicked();
+ void ctrlClicked();
+ void returnPressed();
+ void escapePressed();
+
+ public:
+ DoubleSpinBox(QWidget* parent=0);
+ DoubleSpinBox(double minValue, double maxValue, double step = 1.0, QWidget* parent=0);
+};
+
+} // namespace MusEGui
+
+#endif
+
diff --git a/muse2/muse/widgets/fdialogbuttons.ui b/muse2/muse/widgets/fdialogbuttons.ui
index a2196b66..fdd2a22c 100644
--- a/muse2/muse/widgets/fdialogbuttons.ui
+++ b/muse2/muse/widgets/fdialogbuttons.ui
@@ -6,7 +6,7 @@
<rect>
<x>0</x>
<y>0</y>
- <width>150</width>
+ <width>154</width>
<height>438</height>
</rect>
</property>
@@ -146,6 +146,29 @@ Configuration</string>
</layout>
</widget>
</item>
+ <item>
+ <widget class="QFrame" name="writeWinStateGroup">
+ <property name="frameShape">
+ <enum>QFrame::StyledPanel</enum>
+ </property>
+ <property name="frameShadow">
+ <enum>QFrame::Raised</enum>
+ </property>
+ <layout class="QVBoxLayout" name="verticalLayout_4">
+ <item>
+ <widget class="QCheckBox" name="writeWinStateButton">
+ <property name="text">
+ <string>write window
+states</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </widget>
+ </item>
</layout>
</widget>
<layoutdefault spacing="6" margin="11"/>
diff --git a/muse2/muse/widgets/filedialog.cpp b/muse2/muse/widgets/filedialog.cpp
index 5fbae28b..b41f807e 100644
--- a/muse2/muse/widgets/filedialog.cpp
+++ b/muse2/muse/widgets/filedialog.cpp
@@ -240,6 +240,7 @@ MFileDialog::MFileDialog(const QString& dir,
}
buttons.readMidiPortsGroup->setVisible(false);
+ buttons.writeWinStateGroup->setVisible(false);
}
}
@@ -314,7 +315,7 @@ QString getOpenFileName(const QString &startWith, const char** filters_chararray
//---------------------------------------------------------
QString getSaveFileName(const QString &startWith,
- const char** filters_chararray, QWidget* parent, const QString& name)
+ const char** filters_chararray, QWidget* parent, const QString& name, bool* writeWinState)
{
QStringList filters = localizedStringListFromCharArray(filters_chararray, "file_patterns");
@@ -322,12 +323,20 @@ QString getSaveFileName(const QString &startWith,
dlg->setNameFilters(filters);
dlg->setWindowTitle(name);
dlg->setFileMode(QFileDialog::AnyFile);
+ if (writeWinState)
+ {
+ dlg->buttons.writeWinStateGroup->setVisible(true);
+ dlg->buttons.writeWinStateButton->setChecked(*writeWinState);
+ }
+
QStringList files;
QString result;
if (dlg->exec() == QDialog::Accepted) {
files = dlg->selectedFiles();
if (!files.isEmpty())
result = files[0];
+ if (writeWinState)
+ *writeWinState = dlg->buttons.writeWinStateButton->isChecked();
}
// Added by T356.
diff --git a/muse2/muse/widgets/filedialog.h b/muse2/muse/widgets/filedialog.h
index c9ab8e09..1e2616da 100644
--- a/muse2/muse/widgets/filedialog.h
+++ b/muse2/muse/widgets/filedialog.h
@@ -91,7 +91,7 @@ class ContentsPreview : public QWidget, public Q3FilePreview {
*/
QString getSaveFileName(const QString& startWidth, const char** filters,
- QWidget* parent, const QString& name);
+ QWidget* parent, const QString& name, bool* writeWinState=NULL);
QString getOpenFileName(const QString& startWidth, const char** filters,
QWidget* parent, const QString& name, bool* doReadMidiPorts, MFileDialog::ViewType viewType = MFileDialog::PROJECT_VIEW);
QString getImageFileName(const QString& startWith, const char** filters,
diff --git a/muse2/muse/widgets/genset.cpp b/muse2/muse/widgets/genset.cpp
index 422f5110..60127a0a 100644
--- a/muse2/muse/widgets/genset.cpp
+++ b/muse2/muse/widgets/genset.cpp
@@ -72,129 +72,9 @@ GlobalSettingsConfig::GlobalSettingsConfig(QWidget* parent)
recDrumGroup->addButton(dontRecMutedButton, MusECore::DONT_REC_MUTED);
recDrumGroup->addButton(dontRecBothButton, MusECore::DONT_REC_MUTED_OR_HIDDEN);
- for (unsigned i = 0; i < sizeof(rtcResolutions)/sizeof(*rtcResolutions); ++i) {
- if (rtcResolutions[i] == MusEGlobal::config.rtcTicks) {
- rtcResolutionSelect->setCurrentIndex(i);
- break;
- }
- }
- for (unsigned i = 0; i < sizeof(divisions)/sizeof(*divisions); ++i) {
- if (divisions[i] == MusEGlobal::config.division) {
- midiDivisionSelect->setCurrentIndex(i);
- break;
- }
- }
- for (unsigned i = 0; i < sizeof(divisions)/sizeof(*divisions); ++i) {
- if (divisions[i] == MusEGlobal::config.guiDivision) {
- guiDivisionSelect->setCurrentIndex(i);
- break;
- }
- }
- for (unsigned i = 0; i < sizeof(dummyAudioBufSizes)/sizeof(*dummyAudioBufSizes); ++i) {
- if (dummyAudioBufSizes[i] == MusEGlobal::config.dummyAudioBufSize) {
- dummyAudioSize->setCurrentIndex(i);
- break;
- }
- }
-
- for (unsigned i = 0; i < sizeof(minControlProcessPeriods)/sizeof(*minControlProcessPeriods); ++i) {
- if (minControlProcessPeriods[i] == MusEGlobal::config.minControlProcessPeriod) {
- minControlProcessPeriodComboBox->setCurrentIndex(i);
- break;
- }
- }
-
- guiRefreshSelect->setValue(MusEGlobal::config.guiRefresh);
- minSliderSelect->setValue(int(MusEGlobal::config.minSlider));
- minMeterSelect->setValue(MusEGlobal::config.minMeter);
- freewheelCheckBox->setChecked(MusEGlobal::config.freewheelMode);
- denormalCheckBox->setChecked(MusEGlobal::config.useDenormalBias);
- outputLimiterCheckBox->setChecked(MusEGlobal::config.useOutputLimiter);
- vstInPlaceCheckBox->setChecked(MusEGlobal::config.vstInPlace);
- dummyAudioRate->setValue(MusEGlobal::config.dummyAudioSampleRate);
+ updateSettings();
- //DummyAudioDevice* dad = dynamic_cast<DummyAudioDevice*>(audioDevice);
- //dummyAudioRealRate->setText(dad ? QString().setNum(sampleRate) : "---");
- //dummyAudioRealRate->setText(QString().setNum(sampleRate)); // Not used any more. p4.0.20
- // Just a record of what the gensetbase.ui file contained for dummyAudioRate whats this:
- /* <property name="whatsThis">
- <string>Actual rate used depends on limitations of
- timer used. If a high rate timer is available,
- short periods can be used with high sample rates.
-Period affects midi playback resolution.
-Shorter periods are desirable.</string>
- </property> */
-
- projDirEntry->setText(MusEGlobal::config.projectBaseFolder);
projDirOpenToolButton->setIcon(*openIcon);
-
- startSongEntry->setText(MusEGlobal::config.startSong);
- startSongGroup->button(MusEGlobal::config.startMode)->setChecked(true);
-
- recDrumGroup->button(MusEGlobal::config.newDrumRecordCondition)->setChecked(true);
-
- showTransport->setChecked(MusEGlobal::config.transportVisible);
- showBigtime->setChecked(MusEGlobal::config.bigTimeVisible);
- //showMixer->setChecked(MusEGlobal::config.mixerVisible);
- showMixer->setChecked(MusEGlobal::config.mixer1Visible);
- showMixer2->setChecked(MusEGlobal::config.mixer2Visible);
-
- mainX->setValue(MusEGlobal::config.geometryMain.x());
- mainY->setValue(MusEGlobal::config.geometryMain.y());
- mainW->setValue(MusEGlobal::config.geometryMain.width());
- mainH->setValue(MusEGlobal::config.geometryMain.height());
-
- transportX->setValue(MusEGlobal::config.geometryTransport.x());
- transportY->setValue(MusEGlobal::config.geometryTransport.y());
-
- bigtimeX->setValue(MusEGlobal::config.geometryBigTime.x());
- bigtimeY->setValue(MusEGlobal::config.geometryBigTime.y());
- bigtimeW->setValue(MusEGlobal::config.geometryBigTime.width());
- bigtimeH->setValue(MusEGlobal::config.geometryBigTime.height());
-
- //mixerX->setValue(MusEGlobal::config.geometryMixer.x());
- //mixerY->setValue(MusEGlobal::config.geometryMixer.y());
- //mixerW->setValue(MusEGlobal::config.geometryMixer.width());
- //mixerH->setValue(MusEGlobal::config.geometryMixer.height());
- mixerX->setValue(MusEGlobal::config.mixer1.geometry.x());
- mixerY->setValue(MusEGlobal::config.mixer1.geometry.y());
- mixerW->setValue(MusEGlobal::config.mixer1.geometry.width());
- mixerH->setValue(MusEGlobal::config.mixer1.geometry.height());
- mixer2X->setValue(MusEGlobal::config.mixer2.geometry.x());
- mixer2Y->setValue(MusEGlobal::config.mixer2.geometry.y());
- mixer2W->setValue(MusEGlobal::config.mixer2.geometry.width());
- mixer2H->setValue(MusEGlobal::config.mixer2.geometry.height());
-
- //setMixerCurrent->setEnabled(MusEGlobal::muse->mixerWindow());
- setMixerCurrent->setEnabled(MusEGlobal::muse->mixer1Window());
- setMixer2Current->setEnabled(MusEGlobal::muse->mixer2Window());
-
- setBigtimeCurrent->setEnabled(MusEGlobal::muse->bigtimeWindow());
- setTransportCurrent->setEnabled(MusEGlobal::muse->transportWindow());
-
- showSplash->setChecked(MusEGlobal::config.showSplashScreen);
- showDidYouKnow->setChecked(MusEGlobal::config.showDidYouKnow);
- externalWavEditorSelect->setText(MusEGlobal::config.externalWavEditor);
- oldStyleStopCheckBox->setChecked(MusEGlobal::config.useOldStyleStopShortCut);
- moveArmedCheckBox->setChecked(MusEGlobal::config.moveArmedCheckBox);
- projectSaveCheckBox->setChecked(MusEGlobal::config.useProjectSaveDialog);
- popsDefStayOpenCheckBox->setChecked(MusEGlobal::config.popupsDefaultStayOpen);
- lmbDecreasesCheckBox->setChecked(MusEGlobal::config.leftMouseButtonCanDecrease);
- rangeMarkerWithoutMMBCheckBox->setChecked(MusEGlobal::config.rangeMarkerWithoutMMB);
-
- addHiddenCheckBox->setChecked(MusEGlobal::config.addHiddenTracks);
- unhideTracksCheckBox->setChecked(MusEGlobal::config.unhideTracks);
-
- switch (MusEGlobal::config.drumTrackPreference)
- {
- case MusEGlobal::ONLY_NEW: onlyNewDrumBtn->setChecked(true); break;
- case MusEGlobal::ONLY_OLD: onlyOldDrumBtn->setChecked(true); break;
- case MusEGlobal::PREFER_NEW: preferNewDrumBtn->setChecked(true); break;
- case MusEGlobal::PREFER_OLD: preferOldDrumBtn->setChecked(true); break;
- }
-
- //updateSettings(); // TESTING
-
connect(projDirOpenToolButton, SIGNAL(clicked()), SLOT(browseProjDir()));
connect(applyButton, SIGNAL(clicked()), SLOT(apply()));
@@ -279,7 +159,7 @@ void GlobalSettingsConfig::updateSettings()
//DummyAudioDevice* dad = dynamic_cast<DummyAudioDevice*>(audioDevice);
//dummyAudioRealRate->setText(dad ? QString().setNum(sampleRate) : "---");
- //dummyAudioRealRate->setText(QString().setNum(sampleRate)); // Not used any more. p4.0.20
+ //dummyAudioRealRate->setText(QString().setNum(sampleRate)); // Not used any more. p4.0.20 DELETETHIS?
projDirEntry->setText(MusEGlobal::config.projectBaseFolder);
@@ -290,7 +170,6 @@ void GlobalSettingsConfig::updateSettings()
showTransport->setChecked(MusEGlobal::config.transportVisible);
showBigtime->setChecked(MusEGlobal::config.bigTimeVisible);
- //showMixer->setChecked(MusEGlobal::config.mixerVisible);
showMixer->setChecked(MusEGlobal::config.mixer1Visible);
showMixer2->setChecked(MusEGlobal::config.mixer2Visible);
@@ -307,10 +186,6 @@ void GlobalSettingsConfig::updateSettings()
bigtimeW->setValue(MusEGlobal::config.geometryBigTime.width());
bigtimeH->setValue(MusEGlobal::config.geometryBigTime.height());
- //mixerX->setValue(MusEGlobal::config.geometryMixer.x());
- //mixerY->setValue(MusEGlobal::config.geometryMixer.y());
- //mixerW->setValue(MusEGlobal::config.geometryMixer.width());
- //mixerH->setValue(MusEGlobal::config.geometryMixer.height());
mixerX->setValue(MusEGlobal::config.mixer1.geometry.x());
mixerY->setValue(MusEGlobal::config.mixer1.geometry.y());
mixerW->setValue(MusEGlobal::config.mixer1.geometry.width());
@@ -320,7 +195,6 @@ void GlobalSettingsConfig::updateSettings()
mixer2W->setValue(MusEGlobal::config.mixer2.geometry.width());
mixer2H->setValue(MusEGlobal::config.mixer2.geometry.height());
- //setMixerCurrent->setEnabled(MusEGlobal::muse->mixerWindow());
setMixerCurrent->setEnabled(MusEGlobal::muse->mixer1Window());
setMixer2Current->setEnabled(MusEGlobal::muse->mixer2Window());
@@ -336,6 +210,7 @@ void GlobalSettingsConfig::updateSettings()
popsDefStayOpenCheckBox->setChecked(MusEGlobal::config.popupsDefaultStayOpen);
lmbDecreasesCheckBox->setChecked(MusEGlobal::config.leftMouseButtonCanDecrease);
rangeMarkerWithoutMMBCheckBox->setChecked(MusEGlobal::config.rangeMarkerWithoutMMB);
+ smartFocusCheckBox->setChecked(MusEGlobal::config.smartFocus);
addHiddenCheckBox->setChecked(MusEGlobal::config.addHiddenTracks);
unhideTracksCheckBox->setChecked(MusEGlobal::config.unhideTracks);
@@ -370,7 +245,7 @@ void GlobalSettingsConfig::applyMdiSettings()
void GlobalSettingsConfig::showEvent(QShowEvent* e)
{
QDialog::showEvent(e);
- //updateSettings(); // TESTING
+ updateSettings();
}
//---------------------------------------------------------
@@ -408,7 +283,6 @@ void GlobalSettingsConfig::apply()
MusEGlobal::config.transportVisible = showTransport->isChecked();
MusEGlobal::config.bigTimeVisible = showBigtime->isChecked();
- //MusEGlobal::config.mixerVisible = showMixer->isChecked();
MusEGlobal::config.mixer1Visible = showMixer->isChecked();
MusEGlobal::config.mixer2Visible = showMixer2->isChecked();
@@ -427,10 +301,6 @@ void GlobalSettingsConfig::apply()
MusEGlobal::config.geometryBigTime.setWidth(bigtimeW->value());
MusEGlobal::config.geometryBigTime.setHeight(bigtimeH->value());
- //MusEGlobal::config.geometryMixer.setX(mixerX->value());
- //MusEGlobal::config.geometryMixer.setY(mixerY->value());
- //MusEGlobal::config.geometryMixer.setWidth(mixerW->value());
- //MusEGlobal::config.geometryMixer.setHeight(mixerH->value());
MusEGlobal::config.mixer1.geometry.setX(mixerX->value());
MusEGlobal::config.mixer1.geometry.setY(mixerY->value());
MusEGlobal::config.mixer1.geometry.setWidth(mixerW->value());
@@ -449,11 +319,11 @@ void GlobalSettingsConfig::apply()
MusEGlobal::config.popupsDefaultStayOpen = popsDefStayOpenCheckBox->isChecked();
MusEGlobal::config.leftMouseButtonCanDecrease = lmbDecreasesCheckBox->isChecked();
MusEGlobal::config.rangeMarkerWithoutMMB = rangeMarkerWithoutMMBCheckBox->isChecked();
+ MusEGlobal::config.smartFocus = smartFocusCheckBox->isChecked();
MusEGlobal::config.addHiddenTracks = addHiddenCheckBox->isChecked();
MusEGlobal::config.unhideTracks = unhideTracksCheckBox->isChecked();
- //MusEGlobal::muse->showMixer(MusEGlobal::config.mixerVisible);
MusEGlobal::muse->showMixer1(MusEGlobal::config.mixer1Visible);
MusEGlobal::muse->showMixer2(MusEGlobal::config.mixer2Visible);
@@ -464,11 +334,6 @@ void GlobalSettingsConfig::apply()
w->resize(MusEGlobal::config.geometryTransport.size());
w->move(MusEGlobal::config.geometryTransport.topLeft());
}
- //w = MusEGlobal::muse->mixerWindow();
- //if (w) {
- // w->resize(MusEGlobal::config.geometryMixer.size());
- // w->move(MusEGlobal::config.geometryMixer.topLeft());
- // }
w = MusEGlobal::muse->mixer1Window();
if (w) {
w->resize(MusEGlobal::config.mixer1.geometry.size());
diff --git a/muse2/muse/widgets/gensetbase.ui b/muse2/muse/widgets/gensetbase.ui
index aec753f1..2803c198 100644
--- a/muse2/muse/widgets/gensetbase.ui
+++ b/muse2/muse/widgets/gensetbase.ui
@@ -1470,6 +1470,49 @@ left button behave like the middle button in such areas.</string>
</property>
</widget>
</item>
+ <item row="9" column="0">
+ <widget class="QLabel" name="label5">
+ <property name="text">
+ <string>Smart focus (restart required)</string>
+ </property>
+ <property name="wordWrap">
+ <bool>false</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="9" column="1">
+ <widget class="QCheckBox" name="smartFocusCheckBox">
+ <property name="sizePolicy">
+ <sizepolicy hsizetype="Fixed" vsizetype="Fixed">
+ <horstretch>0</horstretch>
+ <verstretch>0</verstretch>
+ </sizepolicy>
+ </property>
+ <property name="text">
+ <string/>
+ </property>
+ <property name="toolTip">
+ <string>Smart focus</string>
+ </property>
+ <property name="whatsThis">
+ <string>After editing, controls will return
+ focus to their respective canvas</string>
+ </property>
+ </widget>
+ </item>
+ <item row="10" column="0">
+ <spacer name="verticalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Vertical</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>20</width>
+ <height>40</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
</layout>
</widget>
</item>
diff --git a/muse2/muse/widgets/knob.cpp b/muse2/muse/widgets/knob.cpp
index e53e1a05..1c35a3c2 100644
--- a/muse2/muse/widgets/knob.cpp
+++ b/muse2/muse/widgets/knob.cpp
@@ -340,6 +340,7 @@ void Knob::mousePressEvent(QMouseEvent *e)
}
setValue(v * halfRange + midValue);
SliderBase::valueChange();
+ emit sliderMoved(value(),id()); // sliderMoved is used by auxChanged
// fake a left-click to make the knob still "stick" to
// the mouse.
diff --git a/muse2/muse/widgets/midisync.ui b/muse2/muse/widgets/midisync.ui
index 81d7451e..a7464aaf 100644
--- a/muse2/muse/widgets/midisync.ui
+++ b/muse2/muse/widgets/midisync.ui
@@ -391,7 +391,7 @@ Enabled inputs in the list will
<item row="5" column="0">
<widget class="QLabel" name="toBeDoneLabel">
<property name="text">
- <string>Note: Sync delay and MTC sync currently not fully implemeted</string>
+ <string>Note: Sync delay and MTC sync currently not fully implemented</string>
</property>
<property name="alignment">
<set>Qt::AlignLeading|Qt::AlignLeft|Qt::AlignVCenter</set>
diff --git a/muse2/muse/widgets/mtrackinfo.cpp b/muse2/muse/widgets/mtrackinfo.cpp
index c02bd7f1..06bf10d2 100644
--- a/muse2/muse/widgets/mtrackinfo.cpp
+++ b/muse2/muse/widgets/mtrackinfo.cpp
@@ -104,18 +104,43 @@ MidiTrackInfo::MidiTrackInfo(QWidget* parent, MusECore::Track* sel_track) : QWid
//iChanDetectLabel->setPixmap(*darkgreendotIcon);
iChanDetectLabel->setPixmap(*darkRedLedIcon);
+ recEchoButton->setFocusPolicy(Qt::NoFocus);
recEchoButton->setIcon((selected && ((MusECore::MidiTrack*)selected)->recEcho()) ? QIcon(*midiThruOnIcon) : QIcon(*midiThruOffIcon));
recEchoButton->setIconSize(midiThruOnIcon->size());
//recEchoButton->setOffPixmap(midiThruOffIcon);
//recEchoButton->setOnPixmap(midiThruOnIcon);
+ iRButton->setFocusPolicy(Qt::NoFocus);
iRButton->setIcon(QIcon(*routesMidiInIcon));
iRButton->setIconSize(routesMidiInIcon->size());
//iRButton->setOffPixmap(routesMidiInIcon);
+ oRButton->setFocusPolicy(Qt::NoFocus);
oRButton->setIcon(QIcon(*routesMidiOutIcon));
oRButton->setIconSize(routesMidiOutIcon->size());
//oRButton->setOffPixmap(routesMidiOutIcon);
+
+ recordButton->setFocusPolicy(Qt::NoFocus);
+ progRecButton->setFocusPolicy(Qt::NoFocus);
+ volRecButton->setFocusPolicy(Qt::NoFocus);
+ panRecButton->setFocusPolicy(Qt::NoFocus);
+
+ iOutput->setFocusPolicy(Qt::StrongFocus);
+ iOutputChannel->setFocusPolicy(Qt::StrongFocus);
+ iHBank->setFocusPolicy(Qt::StrongFocus);
+ iLBank->setFocusPolicy(Qt::StrongFocus);
+ iProgram->setFocusPolicy(Qt::StrongFocus);
+ iHBank->setFocusPolicy(Qt::StrongFocus);
+ iLBank->setFocusPolicy(Qt::StrongFocus);
+ iProgram->setFocusPolicy(Qt::StrongFocus);
+ iLautst->setFocusPolicy(Qt::StrongFocus);
+ iLautst->setFocusPolicy(Qt::StrongFocus);
+ iTransp->setFocusPolicy(Qt::StrongFocus);
+ iAnschl->setFocusPolicy(Qt::StrongFocus);
+ iVerz->setFocusPolicy(Qt::StrongFocus);
+ iLen->setFocusPolicy(Qt::StrongFocus);
+ iKompr->setFocusPolicy(Qt::StrongFocus);
+ iPan->setFocusPolicy(Qt::StrongFocus);
// MusE-2: AlignCenter and WordBreak are set in the ui(3) file, but not supported by QLabel. Turn them on here.
trackNameLabel->setAlignment(Qt::AlignCenter);
@@ -180,18 +205,18 @@ MidiTrackInfo::MidiTrackInfo(QWidget* parent, MusECore::Track* sel_track) : QWid
connect(iHBank, SIGNAL(valueChanged(int)), SLOT(iProgHBankChanged()));
connect(iLBank, SIGNAL(valueChanged(int)), SLOT(iProgLBankChanged()));
connect(iProgram, SIGNAL(valueChanged(int)), SLOT(iProgramChanged()));
- connect(iHBank, SIGNAL(doubleClicked()), SLOT(iProgramDoubleClicked()));
- connect(iLBank, SIGNAL(doubleClicked()), SLOT(iProgramDoubleClicked()));
- connect(iProgram, SIGNAL(doubleClicked()), SLOT(iProgramDoubleClicked()));
+ connect(iHBank, SIGNAL(ctrlClicked()), SLOT(iProgramDoubleClicked()));
+ connect(iLBank, SIGNAL(ctrlClicked()), SLOT(iProgramDoubleClicked()));
+ connect(iProgram, SIGNAL(ctrlClicked()), SLOT(iProgramDoubleClicked()));
connect(iLautst, SIGNAL(valueChanged(int)), SLOT(iLautstChanged(int)));
- connect(iLautst, SIGNAL(doubleClicked()), SLOT(iLautstDoubleClicked()));
+ connect(iLautst, SIGNAL(ctrlClicked()), SLOT(iLautstDoubleClicked()));
connect(iTransp, SIGNAL(valueChanged(int)), SLOT(iTranspChanged(int)));
connect(iAnschl, SIGNAL(valueChanged(int)), SLOT(iAnschlChanged(int)));
connect(iVerz, SIGNAL(valueChanged(int)), SLOT(iVerzChanged(int)));
connect(iLen, SIGNAL(valueChanged(int)), SLOT(iLenChanged(int)));
connect(iKompr, SIGNAL(valueChanged(int)), SLOT(iKomprChanged(int)));
connect(iPan, SIGNAL(valueChanged(int)), SLOT(iPanChanged(int)));
- connect(iPan, SIGNAL(doubleClicked()), SLOT(iPanDoubleClicked()));
+ connect(iPan, SIGNAL(ctrlClicked()), SLOT(iPanDoubleClicked()));
connect(iOutput, SIGNAL(activated(int)), SLOT(iOutputPortChanged(int)));
///connect(iInput, SIGNAL(textChanged(const QString&)), SLOT(iInputPortChanged(const QString&)));
connect(recordButton, SIGNAL(clicked()), SLOT(recordClicked()));
@@ -200,6 +225,38 @@ MidiTrackInfo::MidiTrackInfo(QWidget* parent, MusECore::Track* sel_track) : QWid
connect(panRecButton, SIGNAL(clicked()), SLOT(panRecClicked()));
connect(recEchoButton, SIGNAL(toggled(bool)), SLOT(recEchoToggled(bool)));
connect(iRButton, SIGNAL(pressed()), SLOT(inRoutesPressed()));
+
+ connect(iOutputChannel, SIGNAL(returnPressed()), SIGNAL(returnPressed()));
+ connect(iHBank, SIGNAL(returnPressed()), SIGNAL(returnPressed()));
+ connect(iLBank, SIGNAL(returnPressed()), SIGNAL(returnPressed()));
+ connect(iProgram, SIGNAL(returnPressed()), SIGNAL(returnPressed()));
+ connect(iHBank, SIGNAL(returnPressed()), SIGNAL(returnPressed()));
+ connect(iLBank, SIGNAL(returnPressed()), SIGNAL(returnPressed()));
+ connect(iProgram, SIGNAL(returnPressed()), SIGNAL(returnPressed()));
+ connect(iLautst, SIGNAL(returnPressed()), SIGNAL(returnPressed()));
+ connect(iLautst, SIGNAL(returnPressed()), SIGNAL(returnPressed()));
+ connect(iTransp, SIGNAL(returnPressed()), SIGNAL(returnPressed()));
+ connect(iAnschl, SIGNAL(returnPressed()), SIGNAL(returnPressed()));
+ connect(iVerz, SIGNAL(returnPressed()), SIGNAL(returnPressed()));
+ connect(iLen, SIGNAL(returnPressed()), SIGNAL(returnPressed()));
+ connect(iKompr, SIGNAL(returnPressed()), SIGNAL(returnPressed()));
+ connect(iPan, SIGNAL(returnPressed()), SIGNAL(returnPressed()));
+
+ connect(iOutputChannel, SIGNAL(escapePressed()), SIGNAL(escapePressed()));
+ connect(iHBank, SIGNAL(escapePressed()), SIGNAL(escapePressed()));
+ connect(iLBank, SIGNAL(escapePressed()), SIGNAL(escapePressed()));
+ connect(iProgram, SIGNAL(escapePressed()), SIGNAL(escapePressed()));
+ connect(iHBank, SIGNAL(escapePressed()), SIGNAL(escapePressed()));
+ connect(iLBank, SIGNAL(escapePressed()), SIGNAL(escapePressed()));
+ connect(iProgram, SIGNAL(escapePressed()), SIGNAL(escapePressed()));
+ connect(iLautst, SIGNAL(escapePressed()), SIGNAL(escapePressed()));
+ connect(iLautst, SIGNAL(escapePressed()), SIGNAL(escapePressed()));
+ connect(iTransp, SIGNAL(escapePressed()), SIGNAL(escapePressed()));
+ connect(iAnschl, SIGNAL(escapePressed()), SIGNAL(escapePressed()));
+ connect(iVerz, SIGNAL(escapePressed()), SIGNAL(escapePressed()));
+ connect(iLen, SIGNAL(escapePressed()), SIGNAL(escapePressed()));
+ connect(iKompr, SIGNAL(escapePressed()), SIGNAL(escapePressed()));
+ connect(iPan, SIGNAL(escapePressed()), SIGNAL(escapePressed()));
// TODO: Works OK, but disabled for now, until we figure out what to do about multiple out routes and display values...
// Enabled (for Midi Port to Audio Input routing). p4.0.14 Tim.
diff --git a/muse2/muse/widgets/mtrackinfo.h b/muse2/muse/widgets/mtrackinfo.h
index b816f289..a38dcf20 100644
--- a/muse2/muse/widgets/mtrackinfo.h
+++ b/muse2/muse/widgets/mtrackinfo.h
@@ -80,6 +80,10 @@ class MidiTrackInfo : public QWidget, public Ui::MidiTrackInfoBase
void configChanged();
void songChanged(int);
+ signals:
+ void returnPressed();
+ void escapePressed();
+
public:
MidiTrackInfo(QWidget*, MusECore::Track* = 0);
MusECore::Track* track() const { return selected; }
diff --git a/muse2/muse/widgets/mtrackinfobase.ui b/muse2/muse/widgets/mtrackinfobase.ui
index 0bf58d76..c9298a5f 100644
--- a/muse2/muse/widgets/mtrackinfobase.ui
+++ b/muse2/muse/widgets/mtrackinfobase.ui
@@ -588,7 +588,7 @@
</sizepolicy>
</property>
<property name="toolTip">
- <string>Bank Select MSB. Double-click on/off.</string>
+ <string>Bank Select MSB. Ctrl-click on/off.</string>
</property>
<property name="autoFillBackground">
<bool>false</bool>
@@ -641,7 +641,7 @@
</sizepolicy>
</property>
<property name="toolTip">
- <string>Bank Select LSB. Double-click on/off.</string>
+ <string>Bank Select LSB. Ctrl-click on/off.</string>
</property>
<property name="autoFillBackground">
<bool>false</bool>
@@ -694,7 +694,7 @@
</sizepolicy>
</property>
<property name="toolTip">
- <string>Program. Double-click on/off.</string>
+ <string>Program. Ctrl-click on/off.</string>
</property>
<property name="autoFillBackground">
<bool>false</bool>
@@ -761,7 +761,7 @@
</sizepolicy>
</property>
<property name="toolTip">
- <string>Volume. Double-click on/off.</string>
+ <string>Volume. Ctrl-click on/off.</string>
</property>
<property name="autoFillBackground">
<bool>false</bool>
@@ -828,10 +828,10 @@
</sizepolicy>
</property>
<property name="toolTip">
- <string>Change stereo position. Double-click on/off.</string>
+ <string>Change stereo position. Ctrl-click on/off.</string>
</property>
<property name="whatsThis">
- <string>Change stereo position. Double-click on/off.</string>
+ <string>Change stereo position. Ctrl-click on/off.</string>
</property>
<property name="autoFillBackground">
<bool>false</bool>
diff --git a/muse2/muse/widgets/musewidgetsplug.cpp b/muse2/muse/widgets/musewidgetsplug.cpp
index 6cdc3812..398b6f5c 100644
--- a/muse2/muse/widgets/musewidgetsplug.cpp
+++ b/muse2/muse/widgets/musewidgetsplug.cpp
@@ -221,7 +221,8 @@ MusEGlobal::GlobalConfigValues config = {
MusECore::DONT_REC_MUTED_OR_HIDDEN,
true, // addHiddenTracks
true, // unhideTracks
- MusEGlobal::PREFER_NEW // drumTrackPreference
+ MusEGlobal::PREFER_NEW, // drumTrackPreference
+ false // smartFocus
};
//---------------------------------------------------------
diff --git a/muse2/muse/widgets/noteinfo.cpp b/muse2/muse/widgets/noteinfo.cpp
index 1411b7b5..a5002540 100644
--- a/muse2/muse/widgets/noteinfo.cpp
+++ b/muse2/muse/widgets/noteinfo.cpp
@@ -45,7 +45,7 @@ NoteInfo::NoteInfo(QWidget* parent)
{
setObjectName("Note Info");
deltaMode = false;
-
+
//QLabel* label = new QLabel(tr("Start"), this, "Start");
QLabel* label = new QLabel(tr("Start"));
label->setAlignment(Qt::AlignRight|Qt::AlignVCenter);
@@ -55,6 +55,7 @@ NoteInfo::NoteInfo(QWidget* parent)
//selTime = new PosEdit(this, "Start");
///selTime = new PosEdit(0, "Start");
selTime = new Awl::PosEdit;
+ selTime->setFocusPolicy(Qt::StrongFocus);
selTime->setObjectName("Start");
addWidget(selTime);
@@ -65,7 +66,8 @@ NoteInfo::NoteInfo(QWidget* parent)
label->setIndent(3);
addWidget(label);
//selLen = new QSpinBox(0, 100000, 1, this);
- selLen = new QSpinBox();
+ selLen = new SpinBox();
+ selLen->setFocusPolicy(Qt::StrongFocus);
selLen->setRange(0, 100000);
selLen->setSingleStep(1);
addWidget(selLen);
@@ -77,6 +79,8 @@ NoteInfo::NoteInfo(QWidget* parent)
addWidget(label);
//selPitch = new PitchEdit(this, "selPitch");
selPitch = new PitchEdit;
+ selPitch->setFocusPolicy(Qt::StrongFocus);
+ selPitch->setDeltaMode(deltaMode);
addWidget(selPitch);
//label = new QLabel(tr("Velo On"), this, "Velocity On");
@@ -85,7 +89,8 @@ NoteInfo::NoteInfo(QWidget* parent)
label->setIndent(3);
addWidget(label);
//selVelOn = new QSpinBox(0, 127, 1, this);
- selVelOn = new QSpinBox();
+ selVelOn = new SpinBox();
+ selVelOn->setFocusPolicy(Qt::StrongFocus);
selVelOn->setRange(0, 127);
selVelOn->setSingleStep(1);
addWidget(selVelOn);
@@ -96,7 +101,8 @@ NoteInfo::NoteInfo(QWidget* parent)
label->setIndent(3);
addWidget(label);
//selVelOff = new QSpinBox(0, 127, 1, this);
- selVelOff = new QSpinBox();
+ selVelOff = new SpinBox();
+ selVelOff->setFocusPolicy(Qt::StrongFocus);
selVelOff->setRange(0, 127);
selVelOff->setSingleStep(1);
addWidget(selVelOff);
@@ -106,6 +112,18 @@ NoteInfo::NoteInfo(QWidget* parent)
connect(selVelOn, SIGNAL(valueChanged(int)), SLOT(velOnChanged(int)));
connect(selVelOff, SIGNAL(valueChanged(int)), SLOT(velOffChanged(int)));
connect(selTime, SIGNAL(valueChanged(const MusECore::Pos&)), SLOT(timeChanged(const MusECore::Pos&)));
+
+ connect(selLen, SIGNAL(returnPressed()), SIGNAL(returnPressed()));
+ connect(selPitch, SIGNAL(returnPressed()), SIGNAL(returnPressed()));
+ connect(selVelOn, SIGNAL(returnPressed()), SIGNAL(returnPressed()));
+ connect(selVelOff, SIGNAL(returnPressed()), SIGNAL(returnPressed()));
+ connect(selTime, SIGNAL(returnPressed()), SIGNAL(returnPressed()));
+
+ connect(selLen, SIGNAL(escapePressed()), SIGNAL(escapePressed()));
+ connect(selPitch, SIGNAL(escapePressed()), SIGNAL(escapePressed()));
+ connect(selVelOn, SIGNAL(escapePressed()), SIGNAL(escapePressed()));
+ connect(selVelOff, SIGNAL(escapePressed()), SIGNAL(escapePressed()));
+ connect(selTime, SIGNAL(escapePressed()), SIGNAL(escapePressed()));
}
//---------------------------------------------------------
@@ -114,6 +132,8 @@ NoteInfo::NoteInfo(QWidget* parent)
void NoteInfo::setDeltaMode(bool val)
{
+ if(val == deltaMode)
+ return;
deltaMode = val;
selPitch->setDeltaMode(val);
if (val) {
diff --git a/muse2/muse/widgets/noteinfo.h b/muse2/muse/widgets/noteinfo.h
index 078ba85c..56079f34 100644
--- a/muse2/muse/widgets/noteinfo.h
+++ b/muse2/muse/widgets/noteinfo.h
@@ -29,8 +29,6 @@ namespace Awl {
//class PitchEdit;
};
-class QSpinBox;
-
///class PosEdit;
namespace MusECore {
class Pos;
@@ -39,6 +37,7 @@ class Pos;
namespace MusEGui {
class PitchEdit;
+class SpinBox;
//---------------------------------------------------------
// NoteInfo
@@ -46,17 +45,15 @@ class PitchEdit;
class NoteInfo : public QToolBar {
Q_OBJECT
-
+
///PosEdit* selTime;
Awl::PosEdit* selTime;
- QSpinBox* selLen;
+ SpinBox* selLen;
PitchEdit* selPitch;
- QSpinBox* selVelOn;
- QSpinBox* selVelOff;
+ SpinBox* selVelOn;
+ SpinBox* selVelOff;
bool deltaMode;
-
-
public:
enum ValType {VAL_TIME, VAL_LEN, VAL_VELON, VAL_VELOFF, VAL_PITCH };
//NoteInfo(QMainWindow* parent);
@@ -76,6 +73,8 @@ class NoteInfo : public QToolBar {
signals:
void valueChanged(MusEGui::NoteInfo::ValType, int);
+ void returnPressed();
+ void escapePressed();
};
} // namespace MusEGui
diff --git a/muse2/muse/widgets/pitchedit.cpp b/muse2/muse/widgets/pitchedit.cpp
index 3cbe882e..dd7524a2 100644
--- a/muse2/muse/widgets/pitchedit.cpp
+++ b/muse2/muse/widgets/pitchedit.cpp
@@ -31,7 +31,7 @@ namespace MusEGui {
//---------------------------------------------------------
PitchEdit::PitchEdit(QWidget* parent)
- : QSpinBox(parent)
+ : SpinBox(parent)
{
setMinimum(0);
setMaximum(127);
diff --git a/muse2/muse/widgets/pitchedit.h b/muse2/muse/widgets/pitchedit.h
index bcd77100..83e117fd 100644
--- a/muse2/muse/widgets/pitchedit.h
+++ b/muse2/muse/widgets/pitchedit.h
@@ -23,7 +23,7 @@
#ifndef __PITCHEDIT_H__
#define __PITCHEDIT_H__
-#include <QSpinBox>
+#include "spinbox.h"
namespace MusEGui {
@@ -31,7 +31,7 @@ namespace MusEGui {
// PitchEdit
//---------------------------------------------------------
-class PitchEdit : public QSpinBox {
+class PitchEdit : public SpinBox {
Q_OBJECT
bool deltaMode;
diff --git a/muse2/muse/widgets/projectcreate.ui b/muse2/muse/widgets/projectcreate.ui
index d03f093c..7d42628e 100644
--- a/muse2/muse/widgets/projectcreate.ui
+++ b/muse2/muse/widgets/projectcreate.ui
@@ -7,197 +7,208 @@
<x>0</x>
<y>0</y>
<width>569</width>
- <height>340</height>
+ <height>378</height>
</rect>
</property>
<property name="windowTitle">
<string>Create Project</string>
</property>
- <layout class="QVBoxLayout" name="verticalLayout_2">
+ <layout class="QVBoxLayout" name="verticalLayout">
<item>
- <layout class="QVBoxLayout" name="verticalLayout">
+ <layout class="QHBoxLayout" name="horizontalLayout_8">
<item>
- <layout class="QHBoxLayout" name="horizontalLayout_8">
- <item>
- <widget class="QLabel" name="label_5">
- <property name="text">
- <string>Projects folder:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLineEdit" name="projDirLineEdit">
- <property name="readOnly">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QToolButton" name="projDirToolButton">
- <property name="text">
- <string>...</string>
- </property>
- </widget>
- </item>
- </layout>
+ <widget class="QLabel" name="label_5">
+ <property name="text">
+ <string>Projects folder:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QLineEdit" name="projDirLineEdit">
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ </widget>
</item>
<item>
- <widget class="Line" name="line">
+ <widget class="QToolButton" name="projDirToolButton">
+ <property name="text">
+ <string>...</string>
+ </property>
+ </widget>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QGridLayout" name="gridLayout">
+ <property name="horizontalSpacing">
+ <number>6</number>
+ </property>
+ <property name="verticalSpacing">
+ <number>0</number>
+ </property>
+ <item row="0" column="0">
+ <widget class="QLabel" name="label_2">
+ <property name="text">
+ <string>Project Name:</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="3">
+ <widget class="QCheckBox" name="templateCheckBox">
+ <property name="text">
+ <string>Project is a Template</string>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="4" rowspan="2">
+ <spacer name="horizontalSpacer">
<property name="orientation">
<enum>Qt::Horizontal</enum>
</property>
+ <property name="sizeType">
+ <enum>QSizePolicy::Minimum</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>60</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ <item row="1" column="3">
+ <widget class="QCheckBox" name="winStateCheckbox">
+ <property name="text">
+ <string>Write window state</string>
+ </property>
+ <property name="checked">
+ <bool>true</bool>
+ </property>
+ </widget>
+ </item>
+ <item row="0" column="1">
+ <widget class="QLineEdit" name="projectNameEdit"/>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <widget class="Line" name="line">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_5">
+ <item>
+ <widget class="QLabel" name="label_4">
+ <property name="text">
+ <string>Project song file type:</string>
+ </property>
</widget>
</item>
<item>
- <layout class="QHBoxLayout" name="horizontalLayout_3">
- <item>
- <widget class="QLabel" name="label_2">
- <property name="text">
- <string>Project Name:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QLineEdit" name="projectNameEdit"/>
- </item>
- <item>
- <widget class="QCheckBox" name="templateCheckBox">
- <property name="text">
- <string>Project is a Template</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="horizontalSpacer">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeType">
- <enum>QSizePolicy::Minimum</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>60</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
+ <widget class="QComboBox" name="projectFileTypeCB"/>
+ </item>
+ <item>
+ <spacer name="horizontalSpacer_3">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
+ </item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_4">
+ <item>
+ <widget class="QLabel" name="label">
+ <property name="text">
+ <string>Project Path to song file:</string>
+ </property>
+ </widget>
</item>
<item>
- <layout class="QHBoxLayout" name="horizontalLayout_5">
- <item>
- <widget class="QLabel" name="label_4">
- <property name="text">
- <string>Project song file type:</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QComboBox" name="projectFileTypeCB"/>
- </item>
- <item>
- <spacer name="horizontalSpacer_3">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- </layout>
+ <spacer name="horizontalSpacer_2">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="sizeHint" stdset="0">
+ <size>
+ <width>40</width>
+ <height>20</height>
+ </size>
+ </property>
+ </spacer>
</item>
<item>
- <layout class="QHBoxLayout" name="horizontalLayout_4">
- <item>
- <widget class="QLabel" name="label">
- <property name="text">
- <string>Project Path to song file:</string>
- </property>
- </widget>
- </item>
- <item>
- <spacer name="horizontalSpacer_2">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="sizeHint" stdset="0">
- <size>
- <width>40</width>
- <height>20</height>
- </size>
- </property>
- </spacer>
- </item>
- <item>
- <widget class="QCheckBox" name="createFolderCheckbox">
- <property name="text">
- <string>Create project folder (recommended for audio projects)</string>
- </property>
- </widget>
- </item>
- </layout>
+ <widget class="QCheckBox" name="createFolderCheckbox">
+ <property name="text">
+ <string>Create project folder (recommended for audio projects)</string>
+ </property>
+ </widget>
</item>
+ </layout>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout">
<item>
- <layout class="QHBoxLayout" name="horizontalLayout">
- <item>
- <widget class="QLineEdit" name="storageDirEdit">
- <property name="readOnly">
- <bool>true</bool>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QToolButton" name="browseDirButton">
- <property name="text">
- <string>...</string>
- </property>
- </widget>
- </item>
- <item>
- <widget class="QToolButton" name="restorePathButton">
- <property name="text">
- <string>...</string>
- </property>
- </widget>
- </item>
- </layout>
+ <widget class="QLineEdit" name="storageDirEdit">
+ <property name="readOnly">
+ <bool>true</bool>
+ </property>
+ </widget>
</item>
<item>
- <widget class="QLabel" name="label_3">
+ <widget class="QToolButton" name="browseDirButton">
<property name="text">
- <string>Song information:</string>
+ <string>...</string>
</property>
</widget>
</item>
<item>
- <widget class="QPlainTextEdit" name="commentEdit"/>
+ <widget class="QToolButton" name="restorePathButton">
+ <property name="text">
+ <string>...</string>
+ </property>
+ </widget>
</item>
+ </layout>
+ </item>
+ <item>
+ <widget class="QLabel" name="label_3">
+ <property name="text">
+ <string>Song information:</string>
+ </property>
+ </widget>
+ </item>
+ <item>
+ <widget class="QPlainTextEdit" name="commentEdit"/>
+ </item>
+ <item>
+ <layout class="QHBoxLayout" name="horizontalLayout_2">
<item>
- <layout class="QHBoxLayout" name="horizontalLayout_2">
- <item>
- <widget class="QDialogButtonBox" name="buttonBox">
- <property name="orientation">
- <enum>Qt::Horizontal</enum>
- </property>
- <property name="standardButtons">
- <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
- </property>
- </widget>
- </item>
- </layout>
+ <widget class="QDialogButtonBox" name="buttonBox">
+ <property name="orientation">
+ <enum>Qt::Horizontal</enum>
+ </property>
+ <property name="standardButtons">
+ <set>QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
+ </property>
+ </widget>
</item>
</layout>
</item>
</layout>
</widget>
<tabstops>
- <tabstop>projectNameEdit</tabstop>
<tabstop>templateCheckBox</tabstop>
<tabstop>projectFileTypeCB</tabstop>
<tabstop>createFolderCheckbox</tabstop>
diff --git a/muse2/muse/widgets/projectcreateimpl.cpp b/muse2/muse/widgets/projectcreateimpl.cpp
index 665d725e..d34ccd2d 100644
--- a/muse2/muse/widgets/projectcreateimpl.cpp
+++ b/muse2/muse/widgets/projectcreateimpl.cpp
@@ -76,7 +76,7 @@ ProjectCreateImpl::ProjectCreateImpl(QWidget *parent) :
//createFolderCheckbox->setChecked(MusEGlobal::config.projectStoreInFolder && is_new); // Suggest no folder if not new.
- connect(templateCheckBox,SIGNAL(clicked()), this, SLOT(templateButtonChanged()));
+ connect(templateCheckBox,SIGNAL(toggled(bool)), this, SLOT(templateButtonChanged(bool)));
//connect(templateCheckBox,SIGNAL(clicked()), this, SLOT(updateDirectoryPath()));
connect(projDirToolButton,SIGNAL(clicked()), this, SLOT(browseProjDir()));
connect(restorePathButton,SIGNAL(clicked()), this, SLOT(restorePath()));
@@ -215,9 +215,10 @@ void ProjectCreateImpl::browseProjDir()
}
}
-void ProjectCreateImpl::templateButtonChanged()
+void ProjectCreateImpl::templateButtonChanged(bool v)
{
- restorePathButton->setEnabled(templateCheckBox->isChecked() ? !overrideTemplDirPath.isEmpty() : !overrideDirPath.isEmpty());
+ restorePathButton->setEnabled(v ? !overrideTemplDirPath.isEmpty() : !overrideDirPath.isEmpty());
+ winStateCheckbox->setChecked(!v);
updateDirectoryPath();
}
@@ -231,12 +232,18 @@ void ProjectCreateImpl::restorePath()
updateDirectoryPath();
}
-/*
-bool ProjectCreateImpl::getProjectIsTemplate() const
+
+bool ProjectCreateImpl::getWriteTopwins() const
{
- return templateCheckBox->isChecked();
+ return winStateCheckbox->isChecked();
}
+void ProjectCreateImpl::setWriteTopwins(bool v)
+{
+ winStateCheckbox->setChecked(v);
+}
+
+/*
QString ProjectCreateImpl::getTemplatePath() const
{
return templDirPath;
diff --git a/muse2/muse/widgets/projectcreateimpl.h b/muse2/muse/widgets/projectcreateimpl.h
index f08cb1bc..3cee0c52 100644
--- a/muse2/muse/widgets/projectcreateimpl.h
+++ b/muse2/muse/widgets/projectcreateimpl.h
@@ -42,7 +42,8 @@ public:
explicit ProjectCreateImpl(QWidget *parent = 0);
QString getProjectPath() const;
QString getSongInfo() const;
- //bool getProjectIsTemplate() const;
+ bool getWriteTopwins() const;
+ void setWriteTopwins(bool);
//QString getTemplatePath() const;
signals:
@@ -54,7 +55,7 @@ protected slots:
void ok();
void createProjFolderChanged();
void browseProjDir();
- void templateButtonChanged();
+ void templateButtonChanged(bool);
void restorePath();
};
diff --git a/muse2/muse/widgets/routepopup.cpp b/muse2/muse/widgets/routepopup.cpp
index 3e2ad008..72bcb05d 100644
--- a/muse2/muse/widgets/routepopup.cpp
+++ b/muse2/muse/widgets/routepopup.cpp
@@ -671,7 +671,7 @@ int RoutePopupMenu::addMidiPorts(MusECore::AudioTrack* t, PopupMenu* pup, int id
#ifdef _USE_CUSTOM_WIDGET_ACTIONS_
- PixmapButtonsWidgetAction* wa = new PixmapButtonsWidgetAction(QString::number(i + 1) + ":" + md->name(),
+ PixmapButtonsWidgetAction* wa = new PixmapButtonsWidgetAction(QString::number(i + 1) + ":" + (md ? md->name() : tr("<none>")),
redLedIcon, darkRedLedIcon,MIDI_CHANNELS, chanmask, pup);
MusECore::Route srcRoute(i, 0); // Ignore the routing channels - our action holds the channels.
//wa->setData(id++);
@@ -1331,7 +1331,7 @@ void RoutePopupMenu::prepare()
#ifdef _USE_CUSTOM_WIDGET_ACTIONS_
- PixmapButtonsWidgetAction* wa = new PixmapButtonsWidgetAction(QString::number(i + 1) + ":" + md->name(),
+ PixmapButtonsWidgetAction* wa = new PixmapButtonsWidgetAction(QString::number(i + 1) + ":" + (md ? md->name() : tr("<none>")),
redLedIcon, darkRedLedIcon, MIDI_CHANNELS, chanmask, this);
MusECore::Route srcRoute(i, 0); // Ignore the routing channels - our action holds the channels.
//wa->setData(id++);
diff --git a/muse2/muse/widgets/spinbox.cpp b/muse2/muse/widgets/spinbox.cpp
index 730e4828..b0b5d4ce 100644
--- a/muse2/muse/widgets/spinbox.cpp
+++ b/muse2/muse/widgets/spinbox.cpp
@@ -22,10 +22,28 @@
#include <QKeyEvent>
#include <QEvent>
+#include <QLineEdit>
+#include <QMouseEvent>
#include "spinbox.h"
namespace MusEGui {
+//void SpinBoxLineEdit::mouseDoubleClickEvent(QMouseEvent* e)
+//{
+// QLineEdit::mouseDoubleClickEvent(e);
+// emit doubleClicked();
+// if((e->buttons() & Qt::LeftButton) && (e->modifiers() & Qt::ControlModifier))
+// emit ctrlDoubleClicked();
+//}
+
+void SpinBoxLineEdit::mousePressEvent(QMouseEvent* e)
+{
+ QLineEdit::mousePressEvent(e);
+ //selectAll();
+ if((e->buttons() & Qt::LeftButton) && (e->modifiers() & Qt::ControlModifier))
+ emit ctrlClicked();
+}
+
//---------------------------------------------------------
// SpinBox
//---------------------------------------------------------
@@ -33,85 +51,54 @@ namespace MusEGui {
SpinBox::SpinBox(QWidget* parent)
: QSpinBox(parent)
{
- _clearFocus = true;
+ SpinBoxLineEdit* le = new SpinBoxLineEdit(this);
+ setLineEdit(le);
+ setKeyboardTracking(false);
+
+ //connect(le, SIGNAL(doubleClicked()), this, SIGNAL(doubleClicked()));
+ //connect(le, SIGNAL(ctrlDoubleClicked()), this, SIGNAL(ctrlDoubleClicked()));
+ connect(le, SIGNAL(ctrlClicked()), this, SIGNAL(ctrlClicked()));
}
SpinBox::SpinBox(int minValue, int maxValue, int step, QWidget* parent)
: QSpinBox(parent)
{
+ SpinBoxLineEdit* le = new SpinBoxLineEdit(this);
+ setLineEdit(le);
setRange(minValue, maxValue);
setSingleStep(step);
- _clearFocus = true;
-}
+ setKeyboardTracking(false);
-bool SpinBox::eventFilter(QObject* o, QEvent* ev)
-{
- // if (o != (QObject*)editor()) ddskrjo can't find editor()
- // return QSpinBox::eventFilter(o,ev);
-
- bool retval = false;
- if(ev->type() == QEvent::KeyPress)
- {
- QKeyEvent* k = (QKeyEvent*)ev;
- if(k->key() == Qt::Key_Up || k->key() == Qt::Key_Down)
- {
- // stepUp/stepDown will be called. Set this now.
- _clearFocus = false;
- }
- else if (k->key() == Qt::Key_Enter || k->key() == Qt::Key_Return)
- {
- // With this line, two enter presses after an edit will clear focus.
- // Without, just one enter press clears the focus.
- //if(!editor()->isModified())
- {
- clearFocus();
- return true;
- }
- }
- }
- else
- if(ev->type() == QEvent::MouseButtonDblClick)
- {
- emit doubleClicked();
- return true;
- }
-
- retval = QSpinBox::eventFilter(o, ev);
-
- return retval;
-}
-
-void SpinBox::stepUp()
-{
- QSpinBox::stepUp();
- if(_clearFocus)
- clearFocus();
- else
- _clearFocus = true;
-}
-
-void SpinBox::stepDown()
-{
- QSpinBox::stepDown();
- if(_clearFocus)
- clearFocus();
- else
- _clearFocus = true;
+ //connect(le, SIGNAL(doubleClicked()), this, SIGNAL(doubleClicked()));
+ //connect(le, SIGNAL(ctrlDoubleClicked()), this, SIGNAL(ctrlDoubleClicked()));
+ connect(le, SIGNAL(ctrlClicked()), this, SIGNAL(ctrlClicked()));
}
void SpinBox::keyPressEvent(QKeyEvent* ev)
{
switch (ev->key()) {
case Qt::Key_Return:
- clearFocus();
- //emit returnPressed();
- // return;
- break;
+ QSpinBox::keyPressEvent(ev);
+ emit returnPressed();
+ return;
+ break;
+ case Qt::Key_Escape:
+ emit escapePressed();
+ return;
+ break;
default:
- break;
+ break;
}
QSpinBox::keyPressEvent(ev);
}
+void SpinBox::wheelEvent(QWheelEvent* e)
+{
+ QSpinBox::wheelEvent(e);
+ // Need this because Qt doesn't deselect the text if not focused.
+ if(!hasFocus() && lineEdit())
+ lineEdit()->deselect();
+}
+
} // namespace MusEGui
diff --git a/muse2/muse/widgets/spinbox.h b/muse2/muse/widgets/spinbox.h
index cd37fb32..261ba05e 100644
--- a/muse2/muse/widgets/spinbox.h
+++ b/muse2/muse/widgets/spinbox.h
@@ -24,14 +24,43 @@
// Click up/down, or mousewheel, or hit enter with un-modified text (which means enter TWICE for modified text),
// and the control will give up focus, thereby allowing you to use global shortcut keys afterwards.
// Up/down keys still keep the focus.
+//
+// < Old. That was the SpinBox behaviour in MusE1 (Qt3). They are still desirable goals for MusE2 (Qt4).
+// < Flaw: Calling clearFocus() means nothing has focus, not canvases, not even the active top level window. We want canvases to have it.
+// < That requires (here in MusE2) setting top win focus proxies and using Application::focusChanged() to redirect focus to the
+// < active window's proxy.
+// < Very ugly. And with MDI, even more complicated to give focus back to current sub-window. Tried, was crash-prone.
+// < Also, toolbars can be floated, so calling clearFocus() from a SpinBox on a floating toolbar means nothing has focus but the
+// < toolbar itself is the active window, which requires setting a focus proxy on the toolbar so that Application::focusChanged()
+// < can figure out who to give the focus to!
+// < It seems we will have to use signals/slots instead of clearFocus()...
+// < Flaw: Clearing focus when up/down clicked (when stepBy() is called), auto-repeat might not work because the control has lost focus.
+
#ifndef __SPINBOX_H__
#define __SPINBOX_H__
#include <QSpinBox>
-#include <QEvent>
+#include <QLineEdit>
namespace MusEGui {
+class SpinBoxLineEdit : public QLineEdit
+{
+ Q_OBJECT
+
+ protected:
+ //virtual void mouseDoubleClickEvent(QMouseEvent* e);
+ virtual void mousePressEvent(QMouseEvent* e);
+
+ signals:
+ //void doubleClicked();
+ //void ctrlDoubleClicked();
+ void ctrlClicked();
+
+ public:
+ SpinBoxLineEdit(QWidget* parent = 0) : QLineEdit(parent) {};
+};
+
//---------------------------------------------------------
// SpinBox
//---------------------------------------------------------
@@ -39,18 +68,16 @@ namespace MusEGui {
class SpinBox : public QSpinBox {
Q_OBJECT
- bool _clearFocus;
-
protected:
- bool eventFilter(QObject* obj, QEvent* ev);
virtual void keyPressEvent(QKeyEvent*);
+ virtual void wheelEvent(QWheelEvent*);
- public slots:
- virtual void stepUp();
- virtual void stepDown();
-
signals:
- void doubleClicked();
+ //void doubleClicked();
+ //void ctrlDoubleClicked();
+ void ctrlClicked();
+ void returnPressed();
+ void escapePressed();
public:
SpinBox(QWidget* parent=0);
diff --git a/muse2/muse/widgets/tb1.cpp b/muse2/muse/widgets/tb1.cpp
index 589726a9..60140ee2 100644
--- a/muse2/muse/widgets/tb1.cpp
+++ b/muse2/muse/widgets/tb1.cpp
@@ -69,6 +69,7 @@ Toolbar1::Toolbar1(QWidget* parent, int r, bool sp)
solo = new QToolButton();
solo->setText(tr("Solo"));
solo->setCheckable(true);
+ solo->setFocusPolicy(Qt::NoFocus);
addWidget(solo);
//---------------------------------------------------
@@ -94,6 +95,7 @@ Toolbar1::Toolbar1(QWidget* parent, int r, bool sp)
//---------------------------------------------------
raster = new LabelCombo(tr("Snap"), 0);
+ raster->setFocusPolicy(Qt::TabFocus);
rlist = new QTableWidget(10, 3);
rlist->verticalHeader()->setDefaultSectionSize(22);
@@ -130,6 +132,7 @@ void Toolbar1::_rasterChanged(int /*i*/)
//void Toolbar1::_rasterChanged(int r, int c)
{
emit rasterChanged(rasterTable[rlist->currentRow() + rlist->currentColumn() * 10]);
+ //parentWidget()->setFocus();
//emit rasterChanged(rasterTable[r + c * 10]);
}
diff --git a/muse2/muse/widgets/tempolabel.cpp b/muse2/muse/widgets/tempolabel.cpp
index cc628f50..565a61c1 100644
--- a/muse2/muse/widgets/tempolabel.cpp
+++ b/muse2/muse/widgets/tempolabel.cpp
@@ -80,7 +80,7 @@ QSize TempoLabel::sizeHint() const
//---------------------------------------------------------
TempoEdit::TempoEdit(QWidget* parent)
- : QDoubleSpinBox(parent)
+ : DoubleSpinBox(parent)
{
curVal = -1.0;
setSingleStep(1.0);
diff --git a/muse2/muse/widgets/tempolabel.h b/muse2/muse/widgets/tempolabel.h
index 50d70180..555b985d 100644
--- a/muse2/muse/widgets/tempolabel.h
+++ b/muse2/muse/widgets/tempolabel.h
@@ -24,7 +24,7 @@
#define __TEMPOLABEL_H__
#include <QLabel>
-#include <QDoubleSpinBox>
+#include "doublespinbox.h"
namespace MusEGui {
@@ -54,7 +54,7 @@ class TempoLabel : public QLabel {
// TempoEdit
//---------------------------------------------------------
-class TempoEdit : public QDoubleSpinBox {
+class TempoEdit : public DoubleSpinBox {
Q_OBJECT
double curVal;
diff --git a/muse2/muse/xml.cpp b/muse2/muse/xml.cpp
index 1a989366..6f79c3e6 100644
--- a/muse2/muse/xml.cpp
+++ b/muse2/muse/xml.cpp
@@ -114,11 +114,9 @@ void Xml::nextc()
void Xml::token(int cc)
{
- //char buffer[512];
QByteArray buffer;
int i = 0;
- //for (; i < 511;) {
for (; i < 9999999;) { // Stop at a reasonably large amount 10 million.
if (c == ' ' || c == '\t' || c == cc || c == '\n' || c == EOF)
break;
@@ -136,7 +134,6 @@ void Xml::token(int cc)
void Xml::stoken()
{
- //char buffer[1024*4];
QByteArray buffer;
int i = 0;
@@ -144,7 +141,6 @@ void Xml::stoken()
++i;
next();
- //for (;i < 1024*4-1;) {
for (;i < 10000000*4-1;) { // Stop at a reasonably large amount 10 million.
if (c == '"') {
buffer[i++] = c;
@@ -216,8 +212,6 @@ QString Xml::strip(const QString& s)
Xml::Token Xml::parse()
{
- //char buffer[1024*1024]; // increase buffer -rj
- //char* p;
QByteArray buffer;
int idx = 0;
@@ -273,21 +267,17 @@ Xml::Token Xml::parse()
}
if (c == '?') {
next();
- //p = buffer;
- //p = buffer.data();
idx = 0;
for (;;) {
if (c == '?' || c == EOF || c == '>')
break;
- //*p++ = c;
buffer[idx++] = c;
// TODO: check overflow
next();
}
- //*p = 0;
buffer[idx] = 0;
_s1 = QString(buffer);
@@ -317,21 +307,17 @@ Xml::Token Xml::parse()
}
goto again;
}
- //p = buffer;
- //p = buffer.data();
idx = 0;
for (;;) {
if (c == '/' || c == ' ' || c == '\t' || c == '>' || c == '\n' || c == EOF)
break;
// TODO: check overflow
- //*p++ = c;
buffer[idx++] = c;
next();
}
- //*p = 0;
buffer[idx] = 0;
_s1 = QString(buffer);
@@ -382,8 +368,6 @@ Xml::Token Xml::parse()
fprintf(stderr, "XML: level = 0\n");
goto error;
}
- //p = buffer;
- //p = buffer.data();
idx = 0;
for (;;) {
if (c == EOF || c == '<')
@@ -391,32 +375,24 @@ Xml::Token Xml::parse()
if (c == '&') {
next();
if (c == '<') { // be tolerant with old muse files
-
- //*p++ = '&';
buffer[idx++] = '&';
continue;
}
- //char name[32];
- //char* dp = name;
QByteArray name;
int name_idx = 0;
- //*dp++ = c;
name[name_idx++] = c;
- //for (; dp-name < 31;) {
for (; name_idx < 9999999;) { // Stop at a reasonably large amount 10 million.
next();
if (c == ';')
break;
- //*dp++ = c;
name[name_idx++] = c;
}
- //*dp = 0;
name[name_idx] = 0;
if (strcmp(name, "lt") == 0)
@@ -432,14 +408,12 @@ Xml::Token Xml::parse()
else
c = '?';
}
-
- //*p++ = c;
+
buffer[idx++] = c;
next();
}
- //*p = 0;
buffer[idx] = 0;
_s1 = QString(buffer);