summaryrefslogtreecommitdiff
path: root/muse2
diff options
context:
space:
mode:
Diffstat (limited to 'muse2')
-rw-r--r--muse2/ChangeLog9
-rw-r--r--muse2/muse/app.cpp12
-rw-r--r--muse2/muse/app.h3
-rw-r--r--muse2/muse/appearance.cpp8
-rw-r--r--muse2/muse/arranger/arrangerview.cpp7
-rw-r--r--muse2/muse/arranger/arrangerview.h1
-rw-r--r--muse2/muse/arranger/pcanvas.cpp18
-rw-r--r--muse2/muse/arranger/tlist.cpp134
-rw-r--r--muse2/muse/conf.cpp2
-rw-r--r--muse2/muse/confmport.cpp3
-rw-r--r--muse2/muse/helper.cpp2
-rw-r--r--muse2/muse/importmidi.cpp4
-rw-r--r--muse2/muse/mixer/amixer.cpp7
-rw-r--r--muse2/muse/mixer/amixer.h1
-rw-r--r--muse2/muse/remote/pyapi.cpp2
-rw-r--r--muse2/muse/song.cpp76
-rw-r--r--muse2/muse/song.h7
-rw-r--r--muse2/muse/songfile.cpp2
-rw-r--r--muse2/muse/synth.cpp17
-rw-r--r--muse2/muse/wave.cpp4
20 files changed, 153 insertions, 166 deletions
diff --git a/muse2/ChangeLog b/muse2/ChangeLog
index c50fed97..1f032ab6 100644
--- a/muse2/ChangeLog
+++ b/muse2/ChangeLog
@@ -1,3 +1,12 @@
+13.09.2011:
+ *Added: You can now insert new tracks instead of always at the track list end. (Tim)
+ If main menu 'Add track': Inserts before currently selected track, else adds at end.
+ If Track List right-click existing Track Name: New 'Insert track' menu inserts before clicked track.
+ If Track List right-click on empty space, or Mixer 'Create': Adds at end, as usual.
+ - Fixed track selection bug: Track info panel not clearing when clicking empty area. (Tim)
+ Added an emit selectionChanged(0) in TList::mousePressEvent.
+ - Observed: Ancient bug: Track Info doesn't change if selecting multiple tracks in reverse order.
+ Will need to be fixed if/when adding 'multiple track global editing'.
09.09.2011:
- Removed sending of SEQM_ADD_TRACK, SEQM_REMOVE_TRACK, SEQM_CHANGE_TRACK, SEQM_REMOVE_PART, and
SEQM_CHANGE_PART to ALSA midi thread (which waits) from inside Audio::processMsg.
diff --git a/muse2/muse/app.cpp b/muse2/muse/app.cpp
index 454ae1d0..bbe5de22 100644
--- a/muse2/muse/app.cpp
+++ b/muse2/muse/app.cpp
@@ -930,7 +930,7 @@ MusE::MusE(int argc, char** argv) : QMainWindow()
connect(arrangerView, SIGNAL(closed()), SLOT(arrangerClosed()));
toplevels.push_back(arrangerView);
arrangerView->hide();
- arranger=arrangerView->getArranger();
+ _arranger=arrangerView->getArranger();
arrangerView->setIsMdiWin(true);
@@ -1151,7 +1151,7 @@ void MusE::loadProjectFile1(const QString& name, bool songTemplate, bool loadAll
mixer1->clear();
if (mixer2)
mixer2->clear();
- arranger->clear(); // clear track info
+ _arranger->clear(); // clear track info
//if (clearSong())
if (clearSong(loadAll)) // Allow not touching things like midi ports. p4.0.17 TESTING: Maybe some problems...
return;
@@ -1834,7 +1834,7 @@ void MusE::openInScoreEdit(ScoreEdit* destination, PartList* pl, bool allInOne)
{
if (destination==NULL) // if no destination given, create a new one
{
- destination = new ScoreEdit(this, 0, arranger->cursorValue());
+ destination = new ScoreEdit(this, 0, _arranger->cursorValue());
destination->show();
toplevels.push_back(destination);
connect(destination, SIGNAL(deleted(TopWin*)), SLOT(toplevelDeleted(TopWin*)));
@@ -1870,7 +1870,7 @@ void MusE::startPianoroll()
void MusE::startPianoroll(PartList* pl, bool showDefaultCtrls)
{
- PianoRoll* pianoroll = new PianoRoll(pl, this, 0, arranger->cursorValue());
+ PianoRoll* pianoroll = new PianoRoll(pl, this, 0, _arranger->cursorValue());
if(showDefaultCtrls) // p4.0.12
pianoroll->addCtrl();
pianoroll->show();
@@ -1944,7 +1944,7 @@ void MusE::startDrumEditor()
void MusE::startDrumEditor(PartList* pl, bool showDefaultCtrls)
{
- DrumEdit* drumEditor = new DrumEdit(pl, this, 0, arranger->cursorValue());
+ DrumEdit* drumEditor = new DrumEdit(pl, this, 0, _arranger->cursorValue());
if(showDefaultCtrls) // p4.0.12
drumEditor->addCtrl();
drumEditor->show();
@@ -2313,7 +2313,7 @@ void MusE::cmd(int cmd)
void MusE::configAppearance()
{
if (!appearance)
- appearance = new Appearance(arranger);
+ appearance = new Appearance(_arranger);
appearance->resetValues();
if(appearance->isVisible()) {
appearance->raise();
diff --git a/muse2/muse/app.h b/muse2/muse/app.h
index 721b9c05..cd18ba4a 100644
--- a/muse2/muse/app.h
+++ b/muse2/muse/app.h
@@ -205,6 +205,7 @@ class MusE : public QMainWindow
AudioMixerApp* mixer1;
AudioMixerApp* mixer2;
+ Arranger* _arranger;
ToplevelList toplevels;
ClipListEdit* clipListEdit;
MarkerView* markerView;
@@ -375,7 +376,7 @@ class MusE : public QMainWindow
public:
MusE(int argc, char** argv);
~MusE();
- Arranger* arranger;
+ Arranger* arranger() { return _arranger; }
QRect configGeometryMain;
QProgressDialog *progress;
bool importMidi(const QString name, bool merge);
diff --git a/muse2/muse/appearance.cpp b/muse2/muse/appearance.cpp
index c26f9542..835ced81 100644
--- a/muse2/muse/appearance.cpp
+++ b/muse2/muse/appearance.cpp
@@ -550,7 +550,7 @@ void Appearance::bgSelectionChanged(QTreeWidgetItem* item)
removeBgButton->setEnabled(true);
lastSelectedBgItem = item;
- MusEGlobal::muse->arranger->getCanvas()->setBg(QPixmap(item->data(0, Qt::UserRole).toString()));
+ MusEGlobal::muse->arranger()->getCanvas()->setBg(QPixmap(item->data(0, Qt::UserRole).toString()));
}
//---------------------------------------------------------
@@ -741,7 +741,7 @@ void Appearance::ok()
void Appearance::cancel()
{
- MusEGlobal::muse->arranger->getCanvas()->setBg(QPixmap(config->canvasBgPixmap));
+ MusEGlobal::muse->arranger()->getCanvas()->setBg(QPixmap(config->canvasBgPixmap));
close();
}
@@ -752,7 +752,7 @@ void Appearance::cancel()
void Appearance::removeBackground()
{
QTreeWidgetItem* item = backgroundTree->currentItem();
- MusEGlobal::muse->arranger->getCanvas()->setBg(QPixmap());
+ MusEGlobal::muse->arranger()->getCanvas()->setBg(QPixmap());
user_bg->takeChild(user_bg->indexOfChild(item));
backgroundTree->setCurrentItem (0);
removeBgButton->setEnabled(false);
@@ -791,7 +791,7 @@ void Appearance::addBackground()
void Appearance::clearBackground()
{
- MusEGlobal::muse->arranger->getCanvas()->setBg(QPixmap());
+ MusEGlobal::muse->arranger()->getCanvas()->setBg(QPixmap());
backgroundTree->setCurrentItem (0);
removeBgButton->setEnabled(false);
}
diff --git a/muse2/muse/arranger/arrangerview.cpp b/muse2/muse/arranger/arrangerview.cpp
index 10f43436..06d41802 100644
--- a/muse2/muse/arranger/arrangerview.cpp
+++ b/muse2/muse/arranger/arrangerview.cpp
@@ -628,6 +628,7 @@ void ArrangerView::clearScoreMenuMappers()
void ArrangerView::populateAddTrack()
{
QActionGroup *grp = MusEUtil::populateAddTrack(addTrack);
+ connect(addTrack, SIGNAL(triggered(QAction *)), SLOT(addNewTrack(QAction *)));
trackMidiAction = grp->actions()[0];
trackDrumAction = grp->actions()[1];
@@ -638,6 +639,12 @@ void ArrangerView::populateAddTrack()
trackAAuxAction = grp->actions()[6];
}
+void ArrangerView::addNewTrack(QAction* action)
+{
+ song->addNewTrack(action, MusEGlobal::muse->arranger()->curTrack()); // Insert at current selected track.
+ //song->addNewTrack(action); // Add at end.
+}
+
void ArrangerView::updateShortcuts()
{
editCutAction->setShortcut(shortcuts[SHRT_CUT].key);
diff --git a/muse2/muse/arranger/arrangerview.h b/muse2/muse/arranger/arrangerview.h
index d5e06c6c..bdb450ae 100644
--- a/muse2/muse/arranger/arrangerview.h
+++ b/muse2/muse/arranger/arrangerview.h
@@ -118,6 +118,7 @@ class ArrangerView : public TopWin
void globalInsert();
void globalSplit();
void cmd(int);
+ void addNewTrack(QAction* action);
signals:
void deleted(TopWin*);
diff --git a/muse2/muse/arranger/pcanvas.cpp b/muse2/muse/arranger/pcanvas.cpp
index 1dd4c44d..056dcce7 100644
--- a/muse2/muse/arranger/pcanvas.cpp
+++ b/muse2/muse/arranger/pcanvas.cpp
@@ -349,7 +349,7 @@ UndoOp PartCanvas::moveItem(MusEWidget::CItem* item, const QPoint& newpos, DragT
ntrack = tracks->size();
if (MusEGlobal::debugMsg)
printf("PartCanvas::moveItem - add new track\n");
- Track* newTrack = song->addTrack(int(type));
+ Track* newTrack = song->addTrack(type, false); // Add at end of list.
if (type == Track::WAVE) {
WaveTrack* st = (WaveTrack*) track;
WaveTrack* dt = (WaveTrack*) newTrack;
@@ -662,17 +662,17 @@ QMenu* PartCanvas::genItemPopup(MusEWidget::CItem* item)
partPopup->addSeparator();
switch(trackType) {
case Track::MIDI: {
- partPopup->addAction(MusEGlobal::muse->arranger->parentWin->startPianoEditAction);
- partPopup->addMenu(MusEGlobal::muse->arranger->parentWin->scoreSubmenu);
- partPopup->addAction(MusEGlobal::muse->arranger->parentWin->startScoreEditAction);
- partPopup->addAction(MusEGlobal::muse->arranger->parentWin->startListEditAction);
+ partPopup->addAction(MusEGlobal::muse->arranger()->parentWin->startPianoEditAction);
+ partPopup->addMenu(MusEGlobal::muse->arranger()->parentWin->scoreSubmenu);
+ partPopup->addAction(MusEGlobal::muse->arranger()->parentWin->startScoreEditAction);
+ partPopup->addAction(MusEGlobal::muse->arranger()->parentWin->startListEditAction);
QAction *act_mexport = partPopup->addAction(tr("save part to disk"));
act_mexport->setData(16);
}
break;
case Track::DRUM: {
- partPopup->addAction(MusEGlobal::muse->arranger->parentWin->startDrumEditAction);
- partPopup->addAction(MusEGlobal::muse->arranger->parentWin->startListEditAction);
+ partPopup->addAction(MusEGlobal::muse->arranger()->parentWin->startDrumEditAction);
+ partPopup->addAction(MusEGlobal::muse->arranger()->parentWin->startListEditAction);
QAction *act_dexport = partPopup->addAction(tr("save part to disk"));
act_dexport->setData(16);
}
@@ -3236,9 +3236,9 @@ void PartCanvas::viewDropEvent(QDropEvent* event)
if (!track) { // we need to create a track for this drop
if (text.endsWith(".mpt", Qt::CaseInsensitive)) {
- track = song->addTrack((Track::MIDI));
+ track = song->addTrack(Track::MIDI, false); // Add at end of list.
} else {
- track = song->addTrack((Track::WAVE));
+ track = song->addTrack(Track::WAVE, false); // Add at end of list.
}
}
if (track->type() == Track::WAVE &&
diff --git a/muse2/muse/arranger/tlist.cpp b/muse2/muse/arranger/tlist.cpp
index 786b4ad7..28b12fdc 100644
--- a/muse2/muse/arranger/tlist.cpp
+++ b/muse2/muse/arranger/tlist.cpp
@@ -990,105 +990,44 @@ void TList::mousePressEvent(QMouseEvent* ev)
Track* t = y2Track(y + ypos);
+ // FIXME Observed: Ancient bug: Track Info doesn't change if selecting multiple tracks in reverse order.
+ // Will need to be fixed if/when adding 'multiple track global editing'.
+
TrackColumn col = TrackColumn(header->logicalIndexAt(x));
if (t == 0) {
if (button == Qt::RightButton) {
QMenu* p = new QMenu;
- //p->clear();
- QAction* midi = p->addAction(*addtrack_addmiditrackIcon,
- tr("Add Midi Track"));
- midi->setData(Track::MIDI);
- QAction* drum = p->addAction(*addtrack_drumtrackIcon,
- tr("Add Drum Track"));
- drum->setData(Track::DRUM);
- QAction* wave = p->addAction(*addtrack_wavetrackIcon,
- tr("Add Wave Track"));
- wave->setData(Track::WAVE);
- QAction* aoutput = p->addAction(*addtrack_audiooutputIcon,
- tr("Add Output"));
- aoutput->setData(Track::AUDIO_OUTPUT);
- QAction* agroup = p->addAction(*addtrack_audiogroupIcon,
- tr("Add Group"));
- agroup->setData(Track::AUDIO_GROUP);
- QAction* ainput = p->addAction(*addtrack_audioinputIcon,
- tr("Add Input"));
- ainput->setData(Track::AUDIO_INPUT);
- QAction* aaux = p->addAction(*addtrack_auxsendIcon,
- tr("Add Aux Send"));
- aaux->setData(Track::AUDIO_AUX);
+ MusEUtil::populateAddTrack(p);
- // Create a sub-menu and fill it with found synth types. Make p the owner.
- QMenu* synp = MusEUtil::populateAddSynth(p);
- synp->setIcon(*synthIcon);
- synp->setTitle(QT_TRANSLATE_NOOP("@default", "Add Synth"));
-
- // Add the 'Add Synth' sub-menu to the menu.
- p->addMenu(synp);
-
// Show the menu
QAction* act = p->exec(ev->globalPos(), 0);
// Valid click?
if(act)
{
- int n = act->data().toInt();
- // Valid item?
- if((n >= 0) && ((Track::TrackType)n != Track::AUDIO_SOFTSYNTH))
+ t = song->addNewTrack(act); // Add at end of list.
+ if(t)
{
- // Synth sub-menu id?
- if(n >= MENU_ADD_SYNTH_ID_BASE)
- {
- n -= MENU_ADD_SYNTH_ID_BASE;
- //if(n < synthis.size())
- // t = song->createSynthI(synthis[n]->baseName());
- //if((n - MENU_ADD_SYNTH_ID_BASE) < (int)synthis.size())
- if(n < (int)synthis.size())
- {
- //t = song->createSynthI(synp->text(n));
- //t = song->createSynthI(synthis[n]->name());
- t = song->createSynthI(synthis[n]->baseName(), synthis[n]->name());
-
- if(t)
- {
- // Add instance last in midi device list.
- for (int i = 0; i < MIDI_PORTS; ++i)
- {
- MidiPort* port = &midiPorts[i];
- MidiDevice* dev = port->device();
- if (dev==0)
- {
- midiSeq->msgSetMidiDevice(port, (SynthI*)t);
- MusEGlobal::muse->changeConfig(true); // save configuration file
- song->update();
- break;
- }
- }
- }
- }
- }
- // Normal track.
- else
- t = song->addTrack((Track::TrackType)n);
-
- if(t)
- {
- song->deselectTracks();
- t->setSelected(true);
-
- ///emit selectionChanged();
- emit selectionChanged(t);
- adjustScrollbar();
- }
- }
+ song->deselectTracks();
+ t->setSelected(true);
+
+ ///emit selectionChanged();
+ emit selectionChanged(t);
+ adjustScrollbar();
+ }
}
// Just delete p, and all its children will go too, right?
//delete synp;
delete p;
- }
+ }
else if (button == Qt::LeftButton) {
- if (!ctrl) song->deselectTracks();
- }
+ if (!ctrl)
+ {
+ song->deselectTracks();
+ emit selectionChanged(0);
+ }
+ }
return;
}
@@ -1294,18 +1233,28 @@ void TList::mousePressEvent(QMouseEvent* ev)
mode = NORMAL;
QMenu* p = new QMenu;
//p->clear();
- p->addAction(QIcon(*automation_clear_dataIcon), tr("Delete Track"))->setData(0);
- p->addAction(QIcon(*track_commentIcon), tr("Track Comment"))->setData(1);
+ // Leave room for normal track IDs - base these at AUDIO_SOFTSYNTH.
+ p->addAction(QIcon(*automation_clear_dataIcon), tr("Delete Track"))->setData(Track::AUDIO_SOFTSYNTH + 1);
+ p->addAction(QIcon(*track_commentIcon), tr("Track Comment"))->setData(Track::AUDIO_SOFTSYNTH + 2);
+ p->addSeparator();
+ QMenu* pnew = new QMenu(p);
+ pnew->setTitle(tr("Insert Track"));
+ pnew->setIcon(QIcon(*edit_track_addIcon));
+ MusEUtil::populateAddTrack(pnew);
+ p->addMenu(pnew);
QAction* act = p->exec(ev->globalPos(), 0);
if (act) {
int n = act->data().toInt();
- switch (n) {
- case 0: // delete track
+ if(n >= Track::AUDIO_SOFTSYNTH && n < MENU_ADD_SYNTH_ID_BASE)
+ {
+ n -= Track::AUDIO_SOFTSYNTH;
+ switch (n) {
+ case 1: // delete track
song->removeTrack0(t);
audio->msgUpdateSoloStates();
break;
- case 1: // show track comment
+ case 2: // show track comment
{
MusEWidget::TrackComment* tc = new MusEWidget::TrackComment(t, 0);
tc->show();
@@ -1317,8 +1266,19 @@ void TList::mousePressEvent(QMouseEvent* ev)
printf("action %d\n", n);
break;
}
-
}
+ else
+ {
+ t = song->addNewTrack(act, t); // Let addNewTrack handle it. Insert before clicked-on track 't'.
+ if(t)
+ {
+ song->deselectTracks();
+ t->setSelected(true);
+ emit selectionChanged(t);
+ adjustScrollbar();
+ }
+ }
+ }
delete p;
}
break;
diff --git a/muse2/muse/conf.cpp b/muse2/muse/conf.cpp
index 669ba55e..3fb09c2a 100644
--- a/muse2/muse/conf.cpp
+++ b/muse2/muse/conf.cpp
@@ -1477,7 +1477,7 @@ void MusE::writeConfiguration(int level, Xml& xml) const
//mixer2->write(level, xml, "mixer2");
mixer2->write(level, xml);
- arranger->writeStatus(level, xml);
+ _arranger->writeStatus(level, xml);
writeSeqConfiguration(level, xml, true);
DrumEdit::writeConfiguration(level, xml);
diff --git a/muse2/muse/confmport.cpp b/muse2/muse/confmport.cpp
index ce59b673..6e371d0e 100644
--- a/muse2/muse/confmport.cpp
+++ b/muse2/muse/confmport.cpp
@@ -1341,8 +1341,7 @@ void MPConfig::addInstanceClicked()
QTreeWidgetItem* item = synthList->currentItem();
if (item == 0)
return;
- //SynthI *si = song->createSynthI(item->text(2));
- SynthI *si = song->createSynthI(item->text(0), item->text(2));
+ SynthI *si = song->createSynthI(item->text(0), item->text(2), false); // Add at end of list.
if(!si)
return;
diff --git a/muse2/muse/helper.cpp b/muse2/muse/helper.cpp
index 82c22c64..1a223bb3 100644
--- a/muse2/muse/helper.cpp
+++ b/muse2/muse/helper.cpp
@@ -318,7 +318,7 @@ QActionGroup* populateAddTrack(QMenu* addTrack)
// Add the sub-menu to the given menu.
addTrack->addMenu(synp);
- QObject::connect(addTrack, SIGNAL(triggered(QAction *)), song, SLOT(addNewTrack(QAction *)));
+ //QObject::connect(addTrack, SIGNAL(triggered(QAction *)), song, SLOT(addNewTrack(QAction *)));
return grp;
}
diff --git a/muse2/muse/importmidi.cpp b/muse2/muse/importmidi.cpp
index c7c02253..fd690671 100644
--- a/muse2/muse/importmidi.cpp
+++ b/muse2/muse/importmidi.cpp
@@ -268,8 +268,8 @@ bool MusE::importMidi(const QString name, bool merge)
song->updatePos();
- arranger->reset();
- ///arranger->setMode(int(song->mtype())); // p4.0.7 Tim
+ _arranger->reset();
+ ///_arranger->setMode(int(song->mtype())); // p4.0.7 Tim
}
else {
song->initLen();
diff --git a/muse2/muse/mixer/amixer.cpp b/muse2/muse/mixer/amixer.cpp
index 35173731..e30524ae 100644
--- a/muse2/muse/mixer/amixer.cpp
+++ b/muse2/muse/mixer/amixer.cpp
@@ -169,6 +169,7 @@ AudioMixerApp::AudioMixerApp(QWidget* parent, MusEConfig::MixerConfig* c)
QMenu* menuConfig = menuBar()->addMenu(tr("&Create"));
MusEUtil::populateAddTrack(menuConfig);
+ connect(menuConfig, SIGNAL(triggered(QAction *)), song, SLOT(addNewTrack(QAction *)));
QMenu* menuView = menuBar()->addMenu(tr("&View"));
routingId = menuView->addAction(tr("Routing"), this, SLOT(toggleRouteDialog()));
@@ -252,6 +253,12 @@ bool AudioMixerApp::event(QEvent* event)
}
*/
+//void AudioMixerApp::addNewTrack(QAction* action)
+//{
+ //song->addNewTrack(action, MusEGlobal::muse->arranger()->curTrack()); // Insert at current selected track.
+// song->addNewTrack(action); // Add at end.
+//}
+
void AudioMixerApp::setSizing()
{
int w = 0;
diff --git a/muse2/muse/mixer/amixer.h b/muse2/muse/mixer/amixer.h
index 1726ba7b..41f1e5e1 100644
--- a/muse2/muse/mixer/amixer.h
+++ b/muse2/muse/mixer/amixer.h
@@ -122,6 +122,7 @@ class AudioMixerApp : public QMainWindow {
void songChanged(int);
//void configChanged() { songChanged(-1); }
void configChanged();
+ //void addNewTrack(QAction*);
void setSizing();
void toggleRouteDialog();
void routingDialogClosed();
diff --git a/muse2/muse/remote/pyapi.cpp b/muse2/muse/remote/pyapi.cpp
index 2143faf0..c9f9470f 100644
--- a/muse2/muse/remote/pyapi.cpp
+++ b/muse2/muse/remote/pyapi.cpp
@@ -1127,7 +1127,7 @@ bool Song::event(QEvent* _e)
break;
}
case QPybridgeEvent::SONG_ADD_TRACK:
- song->addTrack(e->getP1());
+ song->addTrack((Track::TrackType)e->getP1(), false); // Add at end of list.
break;
case QPybridgeEvent::SONG_CHANGE_TRACKNAME: {
Track* t = this->findTrack(e->getS1());
diff --git a/muse2/muse/song.cpp b/muse2/muse/song.cpp
index af5b0489..7adc37f3 100644
--- a/muse2/muse/song.cpp
+++ b/muse2/muse/song.cpp
@@ -162,12 +162,13 @@ void Song::setSig(const AL::TimeSignature& sig)
//---------------------------------------------------------
// addNewTrack
// Called from GUI context
+// If insertAt is valid, inserts before insertAt. Else at the end after all tracks.
// Besides normal track types, n includes synth menu ids from populateAddTrack()
//---------------------------------------------------------
-Track* Song::addNewTrack(QAction* action)
+Track* Song::addNewTrack(QAction* action, Track* insertAt)
{
- int n = action->data().toInt();
+ 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)
return 0;
@@ -176,45 +177,42 @@ Track* Song::addNewTrack(QAction* action)
if(n >= MENU_ADD_SYNTH_ID_BASE)
{
n -= MENU_ADD_SYNTH_ID_BASE;
- if(n < (int)synthis.size())
- {
- //SynthI* si = createSynthI(synthis[n]->baseName());
- //SynthI* si = createSynthI(synthis[n]->name());
- SynthI* si = createSynthI(synthis[n]->baseName(), synthis[n]->name());
- if(!si)
- return 0;
+ if(n >= (int)synthis.size())
+ return 0;
- // Add instance last in midi device list.
- for (int i = 0; i < MIDI_PORTS; ++i)
+ SynthI* si = createSynthI(synthis[n]->baseName(), synthis[n]->name(), insertAt);
+ if(!si)
+ return 0;
+
+ // Add instance last in midi device list.
+ for (int i = 0; i < MIDI_PORTS; ++i)
+ {
+ MidiPort* port = &midiPorts[i];
+ MidiDevice* dev = port->device();
+ if (dev==0)
{
- MidiPort* port = &midiPorts[i];
- MidiDevice* dev = port->device();
- if (dev==0)
- {
- midiSeq->msgSetMidiDevice(port, si);
- MusEGlobal::muse->changeConfig(true); // save configuration file
- deselectTracks();
- si->setSelected(true);
- update();
- return si;
- }
+ midiSeq->msgSetMidiDevice(port, si);
+ MusEGlobal::muse->changeConfig(true); // save configuration file
+ deselectTracks();
+ si->setSelected(true);
+ update();
+ return si;
}
- deselectTracks();
- si->setSelected(true);
- update(SC_SELECTION);
- return si;
- }
- else
- return 0;
+ }
+ deselectTracks();
+ si->setSelected(true);
+ update(SC_SELECTION);
+ return si;
}
// Normal track.
else
{
- // Ignore AUDIO_SOFTSYNTH, now that we have it as the synth menu id, since addTrack doesn't like it.
- if((Track::TrackType)n == Track::AUDIO_SOFTSYNTH)
+ // Ignore AUDIO_SOFTSYNTH (or anything greater, to allow for other entries in some menu),
+ // now that we have it as the synth menu id, since addTrack doesn't like it.
+ if((Track::TrackType)n >= Track::AUDIO_SOFTSYNTH)
return 0;
- Track* t = addTrack((Track::TrackType)n);
+ Track* t = addTrack((Track::TrackType)n, insertAt);
deselectTracks();
t->setSelected(true);
update(SC_SELECTION);
@@ -226,11 +224,12 @@ Track* Song::addNewTrack(QAction* action)
//---------------------------------------------------------
// addTrack
// called from GUI context
+// type is track type
+// If insertAt is valid, inserts before insertAt. Else at the end after all tracks.
//---------------------------------------------------------
-Track* Song::addTrack(int t)
+Track* Song::addTrack(Track::TrackType type, Track* insertAt)
{
- Track::TrackType type = (Track::TrackType) t;
Track* track = 0;
int lastAuxIdx = _auxs.size();
switch(type) {
@@ -270,9 +269,12 @@ Track* Song::addTrack(int t)
abort();
}
track->setDefaultName();
- insertTrack1(track, -1);
- msgInsertTrack(track, -1, true);
- insertTrack3(track, -1);
+
+ int idx = insertAt ? _tracks.index(insertAt) : -1;
+
+ insertTrack1(track, idx);
+ msgInsertTrack(track, idx, true);
+ insertTrack3(track, idx);
// Add default track <-> midiport routes.
if(track->isMidiTrack())
diff --git a/muse2/muse/song.h b/muse2/muse/song.h
index 09174f71..79e5521f 100644
--- a/muse2/muse/song.h
+++ b/muse2/muse/song.h
@@ -358,8 +358,7 @@ class Song : public QObject {
// Configuration
//-----------------------------------------
- //SynthI* createSynthI(const QString& sclass);
- SynthI* createSynthI(const QString& sclass, const QString& label = QString());
+ SynthI* createSynthI(const QString& sclass, const QString& label = QString(), Track* insertAt = 0);
void rescanAlsaPorts();
@@ -407,8 +406,8 @@ class Song : public QObject {
void setQuantize(bool val);
void panic();
void seqSignal(int fd);
- Track* addTrack(int);
- Track* addNewTrack(QAction* action);
+ Track* addTrack(Track::TrackType type, Track* insertAt = 0);
+ Track* addNewTrack(QAction* action, Track* insertAt = 0);
QString getScriptPath(int id, bool delivered);
void populateScriptMenu(QMenu* menuPlugins, QObject* receiver);
diff --git a/muse2/muse/songfile.cpp b/muse2/muse/songfile.cpp
index 3958c933..2763f1b6 100644
--- a/muse2/muse/songfile.cpp
+++ b/muse2/muse/songfile.cpp
@@ -1033,7 +1033,7 @@ void MusE::readToplevels(Xml& xml)
}
}
else if (tag == "scoreedit") {
- ScoreEdit* score = new ScoreEdit(this, 0, arranger->cursorValue());
+ ScoreEdit* score = new ScoreEdit(this, 0, _arranger->cursorValue());
score->show();
toplevels.push_back(score);
connect(score, SIGNAL(deleted(TopWin*)), SLOT(toplevelDeleted(TopWin*)));
diff --git a/muse2/muse/synth.cpp b/muse2/muse/synth.cpp
index ae54cd15..62da5e1d 100644
--- a/muse2/muse/synth.cpp
+++ b/muse2/muse/synth.cpp
@@ -35,13 +35,13 @@
//#include <QMenu>
#include "app.h"
+#include "arranger.h"
#include "synth.h"
#include "xml.h"
#include "midi.h"
#include "midiport.h"
#include "mididev.h"
-//#include "libsynti/mess.h"
-#include "synti/libsynti/mess.h" // p4.0.2
+#include "synti/libsynti/mess.h"
#include "song.h"
#include "audio.h"
#include "event.h"
@@ -162,7 +162,6 @@ static Synth* findSynth(const QString& sclass, const QString& label)
// create a synthesizer instance of class "label"
//---------------------------------------------------------
-//static SynthI* createSynthI(const QString& sclass)
static SynthI* createSynthInstance(const QString& sclass, const QString& label)
{
//Synth* s = findSynth(sclass);
@@ -648,10 +647,10 @@ void initMidiSynth()
//---------------------------------------------------------
// createSynthI
// create a synthesizer instance of class "label"
+// If insertAt is valid, inserts before insertAt. Else at the end after all tracks.
//---------------------------------------------------------
-//SynthI* Song::createSynthI(const QString& sclass)
-SynthI* Song::createSynthI(const QString& sclass, const QString& label)
+SynthI* Song::createSynthI(const QString& sclass, const QString& label, Track* insertAt)
{
//printf("Song::createSynthI calling ::createSynthI class:%s\n", sclass.toLatin1().constData());
@@ -662,13 +661,15 @@ SynthI* Song::createSynthI(const QString& sclass, const QString& label)
return 0;
//printf("Song::createSynthI created SynthI. Before insertTrack1...\n");
- insertTrack1(si, -1);
+ int idx = insertAt ? _tracks.index(insertAt) : -1;
+
+ insertTrack1(si, idx);
//printf("Song::createSynthI after insertTrack1. Before msgInsertTrack...\n");
- msgInsertTrack(si, -1, true); // add to instance list
+ msgInsertTrack(si, idx, true); // add to instance list
//printf("Song::createSynthI after msgInsertTrack. Before insertTrack3...\n");
- insertTrack3(si, -1);
+ insertTrack3(si, idx);
//printf("Song::createSynthI after insertTrack3. Adding default routes...\n");
diff --git a/muse2/muse/wave.cpp b/muse2/muse/wave.cpp
index 6f97a3f0..731606d3 100644
--- a/muse2/muse/wave.cpp
+++ b/muse2/muse/wave.cpp
@@ -815,7 +815,7 @@ namespace MusEApp {
void MusE::importWave()
{
- Track* track = arranger->curTrack();
+ Track* track = _arranger->curTrack();
if (track == 0 || track->type() != Track::WAVE) {
QMessageBox::critical(this, QString("MusE"),
tr("to import an audio file you have first to select"
@@ -838,7 +838,7 @@ void MusE::importWave()
bool MusE::importWaveToTrack(QString& name, unsigned tick, Track* track)
{
if (track==NULL)
- track = (WaveTrack*)(arranger->curTrack());
+ track = (WaveTrack*)(_arranger->curTrack());
SndFile* f = getWave(name, true);