From 11b2c2358ee52cd5cec2b57c2ae2c55a5eea1801 Mon Sep 17 00:00:00 2001 From: Werner Schweer Date: Wed, 25 Jun 2008 18:28:35 +0000 Subject: move mixer subdir --- muse/muse/CMakeLists.txt | 17 +- muse/muse/arranger/arranger.cpp | 4 +- muse/muse/astrip.cpp | 791 ++++++++++++++++++++++++ muse/muse/astrip.h | 101 ++++ muse/muse/conf.cpp | 2 +- muse/muse/importmidi.cpp | 2 +- muse/muse/midirack.cpp | 208 +++++++ muse/muse/midirack.h | 48 ++ muse/muse/mixer.cpp | 397 ++++++++++++ muse/muse/mixer.h | 95 +++ muse/muse/mixer/astrip.cpp | 791 ------------------------ muse/muse/mixer/astrip.h | 101 ---- muse/muse/mixer/midirack.cpp | 208 ------- muse/muse/mixer/midirack.h | 48 -- muse/muse/mixer/mixer.cpp | 397 ------------ muse/muse/mixer/mixer.h | 95 --- muse/muse/mixer/mstrip.cpp | 1279 --------------------------------------- muse/muse/mixer/mstrip.h | 192 ------ muse/muse/mixer/rack.cpp | 445 -------------- muse/muse/mixer/rack.h | 66 -- muse/muse/mixer/routedialog.cpp | 196 ------ muse/muse/mixer/routedialog.h | 53 -- muse/muse/mixer/routedialog.ui | 170 ------ muse/muse/mixer/strip.cpp | 123 ---- muse/muse/mixer/strip.h | 74 --- muse/muse/mstrip.cpp | 1279 +++++++++++++++++++++++++++++++++++++++ muse/muse/mstrip.h | 192 ++++++ muse/muse/muse.cpp | 4 +- muse/muse/preferences.cpp | 2 +- muse/muse/rack.cpp | 445 ++++++++++++++ muse/muse/rack.h | 66 ++ muse/muse/routedialog.cpp | 196 ++++++ muse/muse/routedialog.h | 53 ++ muse/muse/routedialog.ui | 170 ++++++ muse/muse/seqmsg.cpp | 2 +- muse/muse/song.cpp | 2 +- muse/muse/strip.cpp | 123 ++++ muse/muse/strip.h | 74 +++ 38 files changed, 4262 insertions(+), 4249 deletions(-) create mode 100644 muse/muse/astrip.cpp create mode 100644 muse/muse/astrip.h create mode 100644 muse/muse/midirack.cpp create mode 100644 muse/muse/midirack.h create mode 100644 muse/muse/mixer.cpp create mode 100644 muse/muse/mixer.h delete mode 100644 muse/muse/mixer/astrip.cpp delete mode 100644 muse/muse/mixer/astrip.h delete mode 100644 muse/muse/mixer/midirack.cpp delete mode 100644 muse/muse/mixer/midirack.h delete mode 100644 muse/muse/mixer/mixer.cpp delete mode 100644 muse/muse/mixer/mixer.h delete mode 100644 muse/muse/mixer/mstrip.cpp delete mode 100644 muse/muse/mixer/mstrip.h delete mode 100644 muse/muse/mixer/rack.cpp delete mode 100644 muse/muse/mixer/rack.h delete mode 100644 muse/muse/mixer/routedialog.cpp delete mode 100644 muse/muse/mixer/routedialog.h delete mode 100644 muse/muse/mixer/routedialog.ui delete mode 100644 muse/muse/mixer/strip.cpp delete mode 100644 muse/muse/mixer/strip.h create mode 100644 muse/muse/mstrip.cpp create mode 100644 muse/muse/mstrip.h create mode 100644 muse/muse/rack.cpp create mode 100644 muse/muse/rack.h create mode 100644 muse/muse/routedialog.cpp create mode 100644 muse/muse/routedialog.h create mode 100644 muse/muse/routedialog.ui create mode 100644 muse/muse/strip.cpp create mode 100644 muse/muse/strip.h diff --git a/muse/muse/CMakeLists.txt b/muse/muse/CMakeLists.txt index 1bda0e5c..000a8787 100644 --- a/muse/muse/CMakeLists.txt +++ b/muse/muse/CMakeLists.txt @@ -32,7 +32,6 @@ subdirs ( instruments marker liste - mixer arranger waveedit ) @@ -48,6 +47,7 @@ QT4_WRAP_UI (muse_ui_headers projectdialog.ui templatedialog.ui importmidi.ui + routedialog.ui ) QT4_WRAP_CPP ( muse_moc_headers @@ -78,6 +78,13 @@ QT4_WRAP_CPP ( muse_moc_headers importmidi.h midiinport.h midioutport.h + astrip.h + midirack.h + mixer.h + mstrip.h + rack.h + routedialog.h + strip.h ) QT4_ADD_RESOURCES (muse_qrc_files muse.qrc) @@ -159,6 +166,13 @@ add_executable ( muse exportmidi.cpp revision.cpp jack.cpp dummyaudio.cpp + astrip.cpp + midirack.cpp + mixer.cpp + mstrip.cpp + rack.cpp + routedialog.cpp + strip.cpp ) set_target_properties( muse @@ -173,7 +187,6 @@ target_link_libraries(muse liste synti arranger - mixer waveedit widgets al diff --git a/muse/muse/arranger/arranger.cpp b/muse/muse/arranger/arranger.cpp index 51e0324c..7b4be381 100644 --- a/muse/muse/arranger/arranger.cpp +++ b/muse/muse/arranger/arranger.cpp @@ -29,8 +29,8 @@ #include "canvas.h" #include "widgets/utils.h" #include "widgets/splitter.h" -#include "mixer/astrip.h" -#include "mixer/mstrip.h" +#include "astrip.h" +#include "mstrip.h" #include "audio.h" #include "shortcuts.h" #include "trackinfo.h" diff --git a/muse/muse/astrip.cpp b/muse/muse/astrip.cpp new file mode 100644 index 00000000..8d6cdd09 --- /dev/null +++ b/muse/muse/astrip.cpp @@ -0,0 +1,791 @@ +//============================================================================= +// MusE +// Linux Music Editor +// $Id:$ +// +// Copyright (C) 2000-2006 by Werner Schweer and others +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2. +// +// 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., 675 Mass Ave, Cambridge, MA 02139, USA. +//============================================================================= + +#include "audio.h" +#include "audiodev.h" +#include "song.h" +#include "astrip.h" +#include "synth.h" +#include "rack.h" +#include "gconfig.h" +#include "muse.h" +#include "widgets/simplebutton.h" +#include "widgets/utils.h" +#include "auxplugin.h" +#include "midiinport.h" +#include "midioutport.h" + +#include "awl/volknob.h" +#include "awl/panknob.h" +#include "awl/mslider.h" +#include "awl/volentry.h" +#include "awl/panentry.h" + +//--------------------------------------------------------- +// AudioStrip +// create mixer strip +//--------------------------------------------------------- + +AudioStrip::AudioStrip(Mixer* m, AudioTrack* t, bool align) + : Strip(m, t, align) + { + iR = 0; + oR = 0; + off = 0; + volume = -1.0; + channel = t->channels(); + + //--------------------------------------------------- + // prefader plugin rack + //--------------------------------------------------- + + rack1 = new EffectRack(this, t, true); + rack1->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + rack1->setFixedHeight(rack1->sizeHint().height() + 2); + grid->addWidget(rack1, 1, 0, 1, 2); + + //--------------------------------------------------- + // mono/stereo pre/post + //--------------------------------------------------- + + stereo = newStereoButton(); + stereo->setChecked(channel == 2); + stereo->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + stereo->setFixedHeight(LABEL_HEIGHT); + connect(stereo, SIGNAL(clicked(bool)), SLOT(stereoToggled(bool))); + + pre = new QToolButton; + pre->setObjectName("preButton"); + pre->setCheckable(true); + pre->setText(tr("Pre")); + pre->setToolTip(tr("pre fader - post fader")); + pre->setChecked(t->prefader()); + pre->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + pre->setFixedHeight(LABEL_HEIGHT); + connect(pre, SIGNAL(clicked(bool)), SLOT(preToggled(bool))); + + grid->addWidget(stereo, 2, 0); + grid->addWidget(pre, 2, 1); + + //--------------------------------------------------- + // slider, label + //--------------------------------------------------- + + slider = new Awl::MeterSlider(this); + slider->setRange(config.minSlider, config.maxSlider); + slider->setFixedWidth(60); + slider->setChannel(channel); + Ctrl* ctrl = t->getController(AC_VOLUME); + double vol = 0.0f; + if (ctrl) + vol = ctrl->curVal().f; + slider->setValue(vol); + grid->addWidget(slider, 3, 0, 1, 2); // 100, Qt::AlignRight); + + sl = new Awl::VolEntry(this); + sl->setSuffix(tr("dB")); + sl->setFrame(true); + sl->setValue(vol); + sl->setFixedHeight(entrySize.height()); + + connect(slider, SIGNAL(valueChanged(double,int)), SLOT(volumeChanged(double))); + connect(sl, SIGNAL(valueChanged(double,int)), SLOT(volumeChanged(double))); + + connect(slider, SIGNAL(sliderPressed(int)), SLOT(volumePressed())); + connect(slider, SIGNAL(sliderReleased(int)), SLOT(volumeReleased())); + connect(slider, SIGNAL(meterClicked()), SLOT(resetPeaks())); + grid->addWidget(sl, 4, 0, 1, 2); + + //--------------------------------------------------- + // pan, balance + //--------------------------------------------------- + + pan = addPanKnob(&panl, 5); + double panv = t->getController(AC_PAN)->curVal().f; + pan->setValue(panv); + panl->setValue(panv); + + //--------------------------------------------------- + // postfader plugin rack + //--------------------------------------------------- + + rack2 = new EffectRack(this, t, false); + rack2->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + rack2->setFixedHeight(rack1->sizeHint().height() + 2); + grid->addWidget(rack2, 7, 0, 1, 2); + + //--------------------------------------------------- + // mute, solo, record + //--------------------------------------------------- + + Track::TrackType type = t->type(); + + mute = newMuteButton(); + mute->setChecked(t->mute()); + mute->setFixedHeight(BUTTON_HEIGHT); + connect(mute, SIGNAL(clicked(bool)), SLOT(muteToggled(bool))); + connect(t, SIGNAL(muteChanged(bool)), mute, SLOT(setChecked(bool))); + + solo = newSoloButton(); + solo->setDisabled(true); + solo->setFixedHeight(BUTTON_HEIGHT); + connect(solo, SIGNAL(clicked(bool)), SLOT(soloToggled(bool))); + connect(t, SIGNAL(soloChanged(bool)), solo, SLOT(setChecked(bool))); + + off = newOffButton(); + off->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + off->setFixedHeight(BUTTON_HEIGHT); + off->setChecked(t->off()); + connect(off, SIGNAL(clicked(bool)), SLOT(offToggled(bool))); + connect(t, SIGNAL(offChanged(bool)), this, SLOT(updateOffState())); + + if (track->canRecord()) { + record = newRecordButton(); + record->setFixedHeight(BUTTON_HEIGHT); + if (type == Track::AUDIO_OUTPUT) + record->setToolTip(tr("record downmix")); + record->setChecked(t->recordFlag()); + connect(record, SIGNAL(clicked(bool)), SLOT(recordToggled(bool))); + connect(t, SIGNAL(recordChanged(bool)), record, SLOT(setChecked(bool))); + } + else + record = 0; + + grid->addWidget(off, 8, 0); + if (record) + grid->addWidget(record, 8, 1); + grid->addWidget(mute, 9, 0); + grid->addWidget(solo, 9, 1); + + //--------------------------------------------------- + // automation read write + //--------------------------------------------------- + + addAutomationButtons(10); + + //--------------------------------------------------- + // routing + //--------------------------------------------------- + + iR = newInRouteButton(); + grid->addWidget(iR, 12, 0); + connect(iR->menu(), SIGNAL(aboutToShow()), SLOT(iRouteShow())); + connect(iR->menu(), SIGNAL(aboutToHide()), SLOT(iRouteHide())); + connect(iR->menu(), SIGNAL(triggered(QAction*)), song, SLOT(routeChanged(QAction*))); + + oR = newOutRouteButton(); + grid->addWidget(oR, 12, 1); + connect(oR->menu(), SIGNAL(aboutToShow()), SLOT(oRouteShow())); + connect(oR->menu(), SIGNAL(aboutToHide()), SLOT(oRouteHide())); + connect(oR->menu(), SIGNAL(triggered(QAction*)), song, SLOT(routeChanged(QAction*))); + + if (off) { + updateOffState(); // init state + } + connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int))); + connect(track, SIGNAL(controllerChanged(int)), SLOT(controllerChanged(int))); + connect(track, SIGNAL(autoReadChanged(bool)), SLOT(autoChanged())); + connect(track, SIGNAL(autoWriteChanged(bool)), SLOT(autoChanged())); + autoChanged(); + } + +//--------------------------------------------------------- +// heartBeat +//--------------------------------------------------------- + +void AudioStrip::heartBeat() + { + int peakHold = (config.peakHoldTime * config.guiRefresh) / 1000; + for (int ch = 0; ch < channel; ++ch) { + int n = track->peakTimer(ch); + ++n; + double f = track->peak(ch); + if (n >= peakHold) { + // track->resetPeak(ch); + track->setPeak(ch, f * 0.7); + } + track->setPeakTimer(ch, n); + slider->setMeterVal(ch, track->meter(ch), f); + } + } + +//--------------------------------------------------------- +// songChanged +//--------------------------------------------------------- + +void AudioStrip::songChanged(int val) + { + AudioTrack* src = (AudioTrack*)track; + if (val & SC_TRACK_MODIFIED) + updateLabel(); + if ((val & SC_ROUTE) && pre) + pre->setChecked(src->prefader()); + if (val & SC_CHANNELS) + updateChannels(); + } + +//--------------------------------------------------------- +// offToggled +//--------------------------------------------------------- + +void AudioStrip::offToggled(bool val) + { + song->setOff(track, !val); + } + +//--------------------------------------------------------- +// updateOffState +//--------------------------------------------------------- + +void AudioStrip::updateOffState() + { + bool val = !track->off(); + slider->setEnabled(val); + sl->setEnabled(val); + pan->setEnabled(val); + panl->setEnabled(val); + pre->setEnabled(val); + rack1->setEnabled(val); + rack2->setEnabled(val); + + if (track->type() != Track::AUDIO_SOFTSYNTH) + stereo->setEnabled(val); + label->setEnabled(val); + if (solo) + solo->setEnabled(val); + if (mute) + mute->setEnabled(val); + if (iR) + iR->setEnabled(val); + if (oR) + oR->setEnabled(val); + if (off) + off->setChecked(track->off()); + if (ar) + ar->setEnabled(val); + if (aw) + aw->setEnabled(val); + } + +//--------------------------------------------------------- +// preToggled +//--------------------------------------------------------- + +void AudioStrip::preToggled(bool val) + { + ((AudioTrack*)track)->setPrefader(val); + resetPeaks(); + song->update(SC_ROUTE); + } + +//--------------------------------------------------------- +// stereoToggled +//--------------------------------------------------------- + +void AudioStrip::stereoToggled(bool val) + { + int nc = val ? 1 : 2; + if (channel == nc) + return; + audio->msgSetChannels((AudioTrack*)track, nc); + song->update(SC_CHANNELS); + } + +//--------------------------------------------------------- +// volumeChanged +//--------------------------------------------------------- + +void AudioStrip::volumeChanged(double v) + { + CVal val; + val.f = v; + song->setControllerVal(track, AC_VOLUME, val); + } + +//--------------------------------------------------------- +// volumePressed +//--------------------------------------------------------- + +void AudioStrip::volumePressed() + { + ((AudioTrack*)track)->startAutoRecord(AC_VOLUME); + } + +//--------------------------------------------------------- +// volumeReleased +//--------------------------------------------------------- + +void AudioStrip::volumeReleased() + { + ((AudioTrack*)track)->stopAutoRecord(AC_VOLUME); + } + +//--------------------------------------------------------- +// panChanged +//--------------------------------------------------------- + +void AudioStrip::panChanged(double v) + { + if (v != panVal) { + CVal val; + val.f = v; + song->setControllerVal(track, AC_PAN, val); + panVal = v; + } + } + +//--------------------------------------------------------- +// setPan +//--------------------------------------------------------- + +void AudioStrip::setPan(double val) + { + if (val != panVal) { + panVal = val; + pan->setValue(val); + panl->setValue(val); + } + } + +//--------------------------------------------------------- +// panPressed +//--------------------------------------------------------- + +void AudioStrip::panPressed() + { + track->startAutoRecord(AC_PAN); + } + +//--------------------------------------------------------- +// panReleased +//--------------------------------------------------------- + +void AudioStrip::panReleased() + { + track->stopAutoRecord(AC_PAN); + } + +//--------------------------------------------------------- +// updateChannels +//--------------------------------------------------------- + +void AudioStrip::updateChannels() + { + AudioTrack* t = (AudioTrack*)track; + int c = t->channels(); + if (c == channel) + return; + channel = c; + slider->setChannel(c); + stereo->setChecked(channel == 2); + } + +//--------------------------------------------------------- +// addPanKnob +//--------------------------------------------------------- + +Awl::PanKnob* AudioStrip::addPanKnob(Awl::PanEntry** dlabel, int row) + { + Awl::PanKnob* knob = new Awl::PanKnob(this); + knob->setToolTip(tr("panorama")); + knob->setFixedHeight(entrySize.height() * 2); + + Awl::PanEntry* pl = new Awl::PanEntry(this); + pl->setPrecision(2); + + if (dlabel) + *dlabel = pl; +// pl->setFont(config.fonts[1]); + pl->setFrame(true); + + pl->setFixedSize(entrySize); + + QLabel* plb = new QLabel; + plb->setObjectName("knobLabel"); + plb->setText(tr("Pan")); + plb->setFixedSize(entrySize); + plb->setAlignment(Qt::AlignCenter); + + grid->addWidget(plb, row, 0); + grid->addWidget(pl, row+1, 0); + grid->addWidget(knob, row, 1, 2, 1); + + connect(knob, SIGNAL(valueChanged(double,int)), SLOT(panChanged(double))); + connect(pl, SIGNAL(valueChanged(double,int)), SLOT(panChanged(double))); + connect(knob, SIGNAL(sliderPressed(int)), SLOT(panPressed())); + connect(knob, SIGNAL(sliderReleased(int)), SLOT(panReleased())); + return knob; + } + +//--------------------------------------------------------- +// addAuxPorts +//--------------------------------------------------------- + +static void addAuxPorts(AudioTrack* track, QMenu* lb, const RouteList& rl) + { + QList pre = track->preAux(); + QList post = track->postAux(); + foreach (AuxPluginIF* p, pre) { + QString s = p->pluginInstance()->name(); + QAction* a = lb->addAction(p->pluginInstance()->name()); + a->setCheckable(true); +// Route route(RouteNode(p), RouteNode(track)); + Route route = Route(RouteNode(p), RouteNode(track)); + a->setData(QVariant::fromValue(route)); + a->setChecked(rl.indexOf(route) != -1); + } + foreach(AuxPluginIF* p, post) { + QAction* a = lb->addAction(p->pluginInstance()->name()); + a->setCheckable(true); +// Route route(RouteNode(p), RouteNode(track)); // does not compile?! + Route route = Route(RouteNode(p), RouteNode(track)); + a->setData(QVariant::fromValue(route)); + a->setChecked(rl.indexOf(route) != -1); + } + } + +//--------------------------------------------------------- +// addInPorts +//--------------------------------------------------------- + +static void addInPorts(AudioTrack* t, QMenu* lb, const RouteList& rl, bool input) + { + RouteNode a(t); + + InputList* al = song->inputs(); + for (iAudioInput i = al->begin(); i != al->end(); ++i) { + AudioTrack* track = (AudioTrack*)*i; + if (t == track) + continue; + QAction* it = lb->addAction(track->name()); + it->setCheckable(true); + RouteNode b(track); + Route route = input ? Route(b, a) : Route(a, b); + it->setData(QVariant::fromValue(route)); + it->setChecked(rl.indexOf(route) != -1); + if (input) + addAuxPorts(track, lb, rl); + } + } + +//--------------------------------------------------------- +// addOutPorts +//--------------------------------------------------------- + +static void addOutPorts(AudioTrack* t, QMenu* lb, const RouteList& rl) + { + OutputList* al = song->outputs(); + for (iAudioOutput i = al->begin(); i != al->end(); ++i) { + Track* track = *i; + if (t == track) + continue; + QAction* it = lb->addAction(track->name()); + it->setCheckable(true); + Route route = Route(RouteNode(t), RouteNode(track)); + it->setData(QVariant::fromValue(route)); + it->setChecked(rl.indexOf(route) != -1); + } + } + +//--------------------------------------------------------- +// addGroupPorts +//--------------------------------------------------------- + +static void addGroupPorts(AudioTrack* t, QMenu* lb, const RouteList& rl) + { + GroupList* al = song->groups(); + for (iAudioGroup i = al->begin(); i != al->end(); ++i) { + AudioTrack* track = (AudioTrack*)*i; + if (t == track) + continue; + QAction* it = lb->addAction(track->name()); + it->setCheckable(true); + Route route = Route(RouteNode(t), RouteNode(track)); + it->setData(QVariant::fromValue(route)); + it->setChecked(rl.indexOf(route) != -1); + } + } + +//--------------------------------------------------------- +// addWavePorts +//--------------------------------------------------------- + +static void addWavePorts(AudioTrack* t, QMenu* lb, const RouteList& rl, bool input) + { + RouteNode a(t); + WaveTrackList* al = song->waves(); + for (iWaveTrack i = al->begin(); i != al->end(); ++i) { + AudioTrack* track = (AudioTrack*)*i; + if (t == track) // cannot connect to itself + continue; + QAction* it = lb->addAction(track->name()); + it->setCheckable(true); + RouteNode b(track); + Route route = input ? Route(b, a) : Route(a, b); + it->setData(QVariant::fromValue(route)); + it->setChecked(rl.indexOf(route) != -1); + if (input) + addAuxPorts(track, lb, rl); + } + } + +//--------------------------------------------------------- +// addSyntiPorts +//--------------------------------------------------------- + +static void addSyntiPorts(AudioTrack* t, QMenu* lb, const RouteList& rl) + { + SynthIList* al = song->syntis(); + for (iSynthI i = al->begin(); i != al->end(); ++i) { + AudioTrack* track = (AudioTrack*)*i; + if (t == track) + continue; + QAction* it = lb->addAction(track->name()); + it->setCheckable(true); + RouteNode a(t); + RouteNode b(track); + Route route = Route(b, a); + it->setData(QVariant::fromValue(route)); + it->setChecked(rl.indexOf(route) != -1); + } + } + +//--------------------------------------------------------- +// iRouteShow +//--------------------------------------------------------- + +extern void addMidiTracks(QMenu* menu, Track* track, int channel, bool input); +extern void addMidiInPorts(QMenu* menu, Track* dtrack, int channel); + +void AudioStrip::iRouteShow() + { + QMenu* pup = iR->menu(); + pup->clear(); + AudioTrack* t = (AudioTrack*)track; + RouteList* irl = t->inRoutes(); + + switch(track->type()) { + default: + return; + case Track::AUDIO_INPUT: + { + for (int i = 0; i < channel; ++i) { + pup->addSeparator()->setText(QString(tr("Channel %1")).arg(i+1)); + QList ol = audioDriver->outputPorts(false); + foreach (PortName ip, ol) { + QAction* id = pup->addAction(ip.name); + id->setCheckable(true); + RouteNode src(ip.port, -1, RouteNode::AUDIOPORT); + RouteNode dst(t, i, RouteNode::TRACK); + Route route = Route(src, dst); + id->setData(QVariant::fromValue(route)); + id->setChecked(irl->indexOf(route) != -1); + } + } + } + break; + case Track::AUDIO_OUTPUT: + addWavePorts(t, pup, *irl, true); + addInPorts(t, pup, *irl, true); + addGroupPorts(t, pup, *irl); + addSyntiPorts(t, pup, *irl); + break; + case Track::WAVE: + addInPorts(t, pup, *irl, true); + break; + case Track::AUDIO_GROUP: + addWavePorts(t, pup, *irl, true); + addInPorts(t, pup, *irl, true); + addGroupPorts(t, pup, *irl); + addSyntiPorts(t, pup, *irl); + break; + case Track::AUDIO_SOFTSYNTH: + pup->addSeparator()->setText(tr("MidiChannel")); + for (int ch = 0; ch < MIDI_CHANNELS; ++ch) { + QMenu* m = pup->addMenu(QString("Channel %1").arg(ch+1)); + addMidiTracks(m, track, ch, true); + addMidiInPorts(m, track, ch); + } + break; + } + } + +//--------------------------------------------------------- +// iRouteHide +//--------------------------------------------------------- + +void AudioStrip::iRouteHide() + { + // dont leave the menu if SHIFT is pressed; this allows + // for fast selecting of more than one input source + // + if (qApp->keyboardModifiers() & Qt::ShiftModifier) { + iR->menu()->show(); + } + } + +//--------------------------------------------------------- +// oRouteHide +//--------------------------------------------------------- + +void AudioStrip::oRouteHide() + { + // dont leave the menu if SHIFT is pressed; this allows + // for fast selecting of more than one input source + // + if (qApp->keyboardModifiers() & Qt::ShiftModifier) { + oR->menu()->show(); + } + } + +//--------------------------------------------------------- +// oRouteShow +//--------------------------------------------------------- + +void AudioStrip::oRouteShow() + { + QMenu* pup = oR->menu(); + pup->clear(); + AudioTrack* t = (AudioTrack*)track; + RouteList* orl = t->outRoutes(); + + switch(track->type()) { + default: + return; + case Track::AUDIO_OUTPUT: + { + for (int i = 0; i < channel; ++i) { + char buffer[128]; + snprintf(buffer, 128, "%s %d", tr("Channel").toLatin1().data(), i+1); + pup->addSeparator()->setText(QString(buffer)); + + QList ol = audioDriver->inputPorts(false); + foreach (PortName ip, ol) { + QAction* action = pup->addAction(ip.name); + action->setCheckable(true); + RouteNode src(t, i, RouteNode::TRACK); + RouteNode dst(ip.port, -1, RouteNode::AUDIOPORT); + Route r = Route(src, dst); + action->setData(QVariant::fromValue(r)); + action->setChecked(orl->indexOf(r) != -1); + } + } + } + break; + case Track::AUDIO_INPUT: + addWavePorts(t, pup, *orl, false); + case Track::WAVE: + case Track::AUDIO_GROUP: + case Track::AUDIO_SOFTSYNTH: + addOutPorts(t, pup, *orl); + addGroupPorts(t, pup, *orl); + break; + } + } + +//--------------------------------------------------------- +// muteToggled +//--------------------------------------------------------- + +void AudioStrip::muteToggled(bool val) + { + song->setMute(track, val); + } + +//--------------------------------------------------------- +// soloToggled +//--------------------------------------------------------- + +void AudioStrip::soloToggled(bool val) + { + song->setSolo(track, val); + } + +//--------------------------------------------------------- +// recordToggled +//--------------------------------------------------------- + +void AudioStrip::recordToggled(bool val) + { + song->setRecordFlag(track, !val); + } + +//--------------------------------------------------------- +// controllerChanged +//--------------------------------------------------------- + +void AudioStrip::controllerChanged(int id) + { + double val = track->getController(id)->curVal().f; + switch (id) { + case AC_VOLUME: + slider->setValue(val); + sl->setValue(val); + break; + case AC_PAN: + pan->setValue(val); + panl->setValue(val); + panVal = val; + break; + case AC_MUTE: + break; + default: + break; + } + } + +//--------------------------------------------------------- +// autoChanged +//--------------------------------------------------------- + +void AudioStrip::autoChanged() + { + bool ar = track->autoRead(); + bool aw = track->autoWrite(); + + // controller are enabled if + // autoRead is off + // autoRead and autoWrite are on (touch mode) + + bool ec = !ar || (ar && aw); + slider->setEnabled(ec); + sl->setEnabled(ec); + pan->setEnabled(ec); + panl->setEnabled(ec); + } + +//--------------------------------------------------------- +// autoReadToggled +//--------------------------------------------------------- + +void AudioStrip::autoReadToggled(bool val) + { + song->setAutoRead(track, val); + } + +//--------------------------------------------------------- +// autoWriteToggled +//--------------------------------------------------------- + +void AudioStrip::autoWriteToggled(bool val) + { + song->setAutoWrite(track, val); + } + diff --git a/muse/muse/astrip.h b/muse/muse/astrip.h new file mode 100644 index 00000000..f0806fda --- /dev/null +++ b/muse/muse/astrip.h @@ -0,0 +1,101 @@ +//============================================================================= +// MusE +// Linux Music Editor +// $Id:$ +// +// Copyright (C) 2002-2006 by Werner Schweer and others +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2. +// +// 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., 675 Mass Ave, Cambridge, MA 02139, USA. +//============================================================================= + +#ifndef __ASTRIP_H__ +#define __ASTRIP_H__ + +#include "strip.h" + +namespace Awl { + class MeterSlider; + class VolEntry; + class VolKnob; + class PanKnob; + class PanEntry; + }; + +class AudioTrack; +class SimpleButton; +class EffectRack; +class Mixer; + +//--------------------------------------------------------- +// AudioStrip +//--------------------------------------------------------- + +class AudioStrip : public Strip { + Q_OBJECT + + int channel; + EffectRack* rack1; + EffectRack* rack2; + + Awl::MeterSlider* slider; + Awl::VolEntry* sl; + double volume; + + Awl::PanKnob* pan; + Awl::PanEntry* panl; + double panVal; + + QToolButton* stereo; + QToolButton* pre; + + Awl::PanKnob* addPanKnob(Awl::PanEntry**, int); + + QToolButton* iR; + QToolButton* oR; + SimpleButton* off; + SimpleButton* record; + + void updateChannels(); + + private slots: + void stereoToggled(bool); + void preToggled(bool); + void offToggled(bool); + void iRouteShow(); + void iRouteHide(); + void oRouteShow(); + void oRouteHide(); + void volumeChanged(double); + void volumePressed(); + void volumeReleased(); + void panChanged(double); + void setPan(double); + void panPressed(); + void panReleased(); + void muteToggled(bool); + void soloToggled(bool); + void recordToggled(bool); + void autoChanged(); + virtual void controllerChanged(int id); + virtual void songChanged(int); + void autoReadToggled(bool); + void autoWriteToggled(bool); + void updateOffState(); + + public: + AudioStrip(Mixer*, AudioTrack*, bool align); + virtual void heartBeat(); + }; + +#endif + diff --git a/muse/muse/conf.cpp b/muse/muse/conf.cpp index 5dfbc8b2..162f6f9b 100644 --- a/muse/muse/conf.cpp +++ b/muse/muse/conf.cpp @@ -28,7 +28,7 @@ #include "al/xml.h" #include "widgets/midisync.h" #include "sync.h" -#include "mixer/mixer.h" +#include "mixer.h" #include "globals.h" #include "midirc.h" #include "awl/tcanvas.h" diff --git a/muse/muse/importmidi.cpp b/muse/muse/importmidi.cpp index 8f27e2d7..c995ed67 100644 --- a/muse/muse/importmidi.cpp +++ b/muse/muse/importmidi.cpp @@ -35,7 +35,7 @@ #include "projectdialog.h" #include "templatedialog.h" #include "audio.h" -#include "mixer/mixer.h" +#include "mixer.h" #include "arranger/arranger.h" #include "midictrl.h" #include "midiinport.h" diff --git a/muse/muse/midirack.cpp b/muse/muse/midirack.cpp new file mode 100644 index 00000000..0b054729 --- /dev/null +++ b/muse/muse/midirack.cpp @@ -0,0 +1,208 @@ +//============================================================================= +// MusE +// Linux Music Editor +// $Id:$ +// +// Copyright (C) 2002-2006 by Werner Schweer and others +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2. +// +// 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., 675 Mass Ave, Cambridge, MA 02139, USA. +//============================================================================= + +#include "icons.h" +#include "gconfig.h" +#include "midirack.h" +#include "track.h" +#include "song.h" +#include "midiplugin.h" +#include "audio.h" +#include "muse.h" +#include "gui.h" + +//--------------------------------------------------------- +// MidiRack +//--------------------------------------------------------- + +MidiRack::MidiRack(QWidget* parent, MidiTrackBase* t) + : QListWidget(parent) + { + setUniformItemSizes(true); + setAlternatingRowColors(true); + setAttribute(Qt::WA_DeleteOnClose, true); + verticalScrollBar()->setStyle(smallStyle); + track = t; +// setFont(config.fonts[1]); + + setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + + setSelectionMode(QAbstractItemView::SingleSelection); + songChanged(SC_RACK); // force update + connect(this, SIGNAL(itemDoubleClicked(QListWidgetItem*)), + this, SLOT(doubleClicked(QListWidgetItem*))); + connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int))); + setToolTip(tr("midi effect rack")); + } + +//--------------------------------------------------------- +// sizeHint +//--------------------------------------------------------- + +QSize MidiRack::sizeHint() const + { + QFontMetrics fm(font()); + int h = fm.lineSpacing() * MidiPipelineDepth + 1; + return QSize(STRIP_WIDTH, h); + } + +//--------------------------------------------------------- +// songChanged +//--------------------------------------------------------- + +void MidiRack::songChanged(int typ) + { + if (typ & (SC_ROUTE | SC_RACK)) { + clear(); + foreach(MidiPluginI* plugin, *(track->pipeline())) { + QListWidgetItem* item = new QListWidgetItem; + item->setText(plugin->name()); + // tooltip should only be set if name does not fit + // (is elided) + item->setToolTip(plugin->name()); + item->setBackgroundColor(plugin->on() ? Qt::white : Qt::gray); + addItem(item); + } + } + } + +//--------------------------------------------------------- +// contextMenuEvent +//--------------------------------------------------------- + +void MidiRack::contextMenuEvent(QContextMenuEvent* ev) + { + QPoint pt(ev->pos()); + QListWidgetItem* item = itemAt(pt); + MidiPipeline* pipe = track->pipeline(); + + QMenu* menu = new QMenu; + QAction* upAction = menu->addAction(QIcon(*upIcon), tr("move up")); + QAction* downAction = menu->addAction(QIcon(*downIcon), tr("move down")); + QAction* removeAction = menu->addAction(tr("remove")); + QAction* bypassAction = menu->addAction(tr("bypass")); + QAction* showAction = menu->addAction(tr("show gui")); + QAction* newAction = menu->addAction(tr("new")); + bypassAction->setCheckable(true); + showAction->setCheckable(true); + + int idx = -1; + if (item == 0) { + upAction->setEnabled(false); + downAction->setEnabled(false); + removeAction->setEnabled(false); + bypassAction->setEnabled(false); + showAction->setEnabled(false); + } + else { + idx = row(item); + upAction->setEnabled(idx != 0); + downAction->setEnabled(idx < (pipe->size() - 1)); + showAction->setEnabled(pipe->hasGui(idx)); + bypassAction->setEnabled(true); + bypassAction->setChecked(!pipe->isOn(idx)); + showAction->setChecked(pipe->guiVisible(idx)); + } + + QAction* sel = menu->exec(mapToGlobal(pt), newAction); + delete menu; + if (sel == 0) + return; + + if (sel == newAction) { + selectNew(); + return; + } + if (sel == removeAction) { + audio->msgAddMidiPlugin(track, idx, 0); + } + else if (sel == bypassAction) { + bool flag = !pipe->isOn(idx); + pipe->setOn(idx, flag); + } + else if (sel == showAction) { + bool flag = !pipe->guiVisible(idx); + pipe->showGui(idx, flag); + } + else if (sel == upAction) { + if (idx > 0) { + setCurrentRow(idx-1); + pipe->move(idx, true); + } + } + else if (sel == downAction) { + if (idx < (pipe->size() - 1)) { + setCurrentRow(idx+1); + pipe->move(idx, false); + } + } + song->update(SC_RACK); + } + +//--------------------------------------------------------- +// doubleClicked +// toggle gui +//--------------------------------------------------------- + +void MidiRack::doubleClicked(QListWidgetItem* it) + { + if (track == 0) + return; + int idx = row(it); + MidiPipeline* pipe = track->pipeline(); + bool flag = !pipe->guiVisible(idx); + pipe->showGui(idx, flag); + song->update(SC_RACK); + } + +//--------------------------------------------------------- +// mouseDoubleClickEvent +//--------------------------------------------------------- + +void MidiRack::mouseDoubleClickEvent(QMouseEvent* event) + { + QListWidgetItem* it = itemAt(event->pos()); + if (it || (track == 0)) { + QListWidget::mouseDoubleClickEvent(event); + return; + } + selectNew(); + } + +//--------------------------------------------------------- +// selectNew +//--------------------------------------------------------- + +void MidiRack::selectNew() + { + MidiPlugin* plugin = MidiPluginDialog::getPlugin(this); + if (plugin) { + MidiPluginI* plugi = plugin->instantiate(track); + if (plugi == 0) { + printf("cannot instantiate plugin <%s>\n", + plugin->name().toLatin1().data()); + delete plugi; + } + else + audio->msgAddMidiPlugin(track, track->pipeline()->size(), plugi); + song->update(SC_RACK); + } + } + diff --git a/muse/muse/midirack.h b/muse/muse/midirack.h new file mode 100644 index 00000000..7f83ca42 --- /dev/null +++ b/muse/muse/midirack.h @@ -0,0 +1,48 @@ +//============================================================================= +// MusE +// Linux Music Editor +// $Id:$ +// +// Copyright (C) 2002-2006 by Werner Schweer and others +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2. +// +// 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., 675 Mass Ave, Cambridge, MA 02139, USA. +//============================================================================= + +#ifndef __MIDIRACK_H__ +#define __MIDIRACK_H__ + +class MidiTrackBase; + +//--------------------------------------------------------- +// MidiRack +//--------------------------------------------------------- + +class MidiRack : public QListWidget { + MidiTrackBase* track; + Q_OBJECT + + virtual void contextMenuEvent(QContextMenuEvent*); + virtual void mouseDoubleClickEvent(QMouseEvent*); + void selectNew(); + + private slots: + void doubleClicked(QListWidgetItem*); + void songChanged(int); + + public: + MidiRack(QWidget*, MidiTrackBase* t); + QSize sizeHint() const; + }; + +#endif + diff --git a/muse/muse/mixer.cpp b/muse/muse/mixer.cpp new file mode 100644 index 00000000..b3e5ce06 --- /dev/null +++ b/muse/muse/mixer.cpp @@ -0,0 +1,397 @@ +//============================================================================= +// MusE +// Linux Music Editor +// $Id:$ +// +// Copyright (C) 2002-2006 by Werner Schweer and others +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2. +// +// 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., 675 Mass Ave, Cambridge, MA 02139, USA. +//============================================================================= + +#include "muse.h" +#include "mixer.h" +#include "song.h" +#include "icons.h" +#include "astrip.h" +#include "mstrip.h" +#include "routedialog.h" +#include "synth.h" +#include "midiinport.h" +#include "midioutport.h" + +extern void populateAddTrack(QMenu* addTrack); + +//--------------------------------------------------------- +// Mixer +// +// inputs | synthis | tracks | groups | master +//--------------------------------------------------------- + +Mixer::Mixer(QWidget* parent, MixerConfig* c) + : QMainWindow(parent) + { + mustUpdateMixer = false; + cfg = c; + routingDialog = 0; + setWindowTitle(tr("MusE: Mixer")); + setWindowIcon(*museIcon); + + QMenu* menuCreate = menuBar()->addMenu(tr("&Create")); + populateAddTrack(menuCreate); + + menuView = menuBar()->addMenu(tr("&View")); + routingAction = menuView->addAction(tr("Routing"), this, SLOT(toggleRouteDialog())); + routingAction->setCheckable(true); + + showMidiTracksId = menuView->addAction(tr("Show Midi Tracks")); + showMidiOutPortId = menuView->addAction(tr("Show Midi Out Ports")); + showMidiInPortId = menuView->addAction(tr("Show Midi In Ports")); + + menuView->addSeparator(); + + showWaveTracksId = menuView->addAction(tr("Show Wave Tracks")); + showOutputTracksId = menuView->addAction(tr("Show Output Tracks")); + showGroupTracksId = menuView->addAction(tr("Show Group Tracks")); + showInputTracksId = menuView->addAction(tr("Show Input Tracks")); + showSyntiTracksId = menuView->addAction(tr("Show Synthesizer")); + connect(menuView, SIGNAL(triggered(QAction*)), SLOT(showTracksChanged(QAction*))); + + showMidiTracksId->setCheckable(true); + showMidiInPortId->setCheckable(true); + showMidiOutPortId->setCheckable(true); + showWaveTracksId->setCheckable(true); + showOutputTracksId->setCheckable(true); + showGroupTracksId->setCheckable(true); + showInputTracksId->setCheckable(true); + showSyntiTracksId->setCheckable(true); + + QScrollArea* view = new QScrollArea; + view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + setCentralWidget(view); + + central = new QWidget; + layout = new QHBoxLayout; + central->setLayout(layout); + layout->setSpacing(0); + layout->setMargin(0); + view->setWidget(central); + view->setWidgetResizable(true); + + connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int))); + connect(muse, SIGNAL(configChanged()), SLOT(configChanged())); + song->update(); // calls update mixer + } + +//--------------------------------------------------------- +// addStrip +//--------------------------------------------------------- + +void Mixer::addStrip(Track* t, int idx) + { + StripList::iterator si = stripList.begin(); + for (int i = 0; i < idx; ++i) { + if (si != stripList.end()) + ++si; + } + if (si != stripList.end() && (*si)->getTrack() == t) + return; + + StripList::iterator nsi = si; + ++nsi; + if (si != stripList.end() + && nsi != stripList.end() + && (*nsi)->getTrack() == t) { + layout->removeWidget(*si); + delete *si; + stripList.erase(si); + } + else { + Strip* strip; + switch(t->type()) { + case Track::MIDI_IN: + strip = new MidiInPortStrip(this, (MidiInPort*)t, true); + break; + case Track::MIDI_OUT: + strip = new MidiOutPortStrip(this, (MidiOutPort*)t, true); + break; + case Track::MIDI: + strip = new MidiStrip(this, (MidiTrack*)t, true); + break; + case Track::MIDI_SYNTI: + strip = new MidiSyntiStrip(this, (MidiSynti*)t, true); + break; + default: + strip = new AudioStrip(this, (AudioTrack*)t, true); + break; + } + layout->insertWidget(idx, strip); + stripList.insert(si, strip); + strip->show(); + } + } + +//--------------------------------------------------------- +// clear +//--------------------------------------------------------- + +void Mixer::clear() + { + QLayoutItem* i; + while ((i = layout->takeAt(0))) { + if (i->widget()) + delete i->widget(); + delete i; + } + stripList.clear(); + } + +//--------------------------------------------------------- +// updateMixer +//--------------------------------------------------------- + +void Mixer::updateMixer(int action) + { + showMidiTracksId->setChecked(cfg->showMidiTracks); + showMidiInPortId->setChecked(cfg->showMidiInPorts); + showMidiOutPortId->setChecked(cfg->showMidiOutPorts); + showWaveTracksId->setChecked(cfg->showWaveTracks); + showOutputTracksId->setChecked(cfg->showOutputTracks); + showGroupTracksId->setChecked(cfg->showGroupTracks); + showInputTracksId->setChecked(cfg->showInputTracks); + showSyntiTracksId->setChecked(cfg->showSyntiTracks); + + if (action == STRIP_REMOVED) { + foreach(Strip* strip, stripList) { + Track* track = strip->getTrack(); + if (song->trackExists(track)) + continue; + layout->removeWidget(strip); + delete strip; + stripList.removeAt(stripList.indexOf(strip)); + } + int idx = stripList.size(); + setMaximumWidth(STRIP_WIDTH * idx + 4); + central->setFixedWidth(STRIP_WIDTH * idx); + if (idx < 4) + setMinimumWidth(idx * STRIP_WIDTH + 4); + return; + } + + clear(); + + int idx = 0; + //--------------------------------------------------- + // generate Input Strips + //--------------------------------------------------- + + if (cfg->showInputTracks) { + InputList* itl = song->inputs(); + for (iAudioInput i = itl->begin(); i != itl->end(); ++i) + addStrip(*i, idx++); + } + + //--------------------------------------------------- + // Synthesizer Strips + //--------------------------------------------------- + + if (cfg->showSyntiTracks) { + SynthIList* sl = song->syntis(); + for (iSynthI i = sl->begin(); i != sl->end(); ++i) + addStrip(*i, idx++); + } + + //--------------------------------------------------- + // generate Wave Track Strips + //--------------------------------------------------- + + if (cfg->showWaveTracks) { + WaveTrackList* wtl = song->waves(); + for (iWaveTrack i = wtl->begin(); i != wtl->end(); ++i) + addStrip(*i, idx++); + } + + //--------------------------------------------------- + // generate Midi strips + //--------------------------------------------------- + + if (cfg->showMidiInPorts) { + MidiInPortList* mpl = song->midiInPorts(); + for (iMidiInPort i = mpl->begin(); i != mpl->end(); ++i) + addStrip(*i, idx++); + } + + if (cfg->showMidiSyntiPorts) { + MidiSyntiList* mpl = song->midiSyntis(); + for (iMidiSynti i = mpl->begin(); i != mpl->end(); ++i) + addStrip(*i, idx++); + } + + if (cfg->showMidiTracks) { + MidiTrackList* mtl = song->midis(); + for (iMidiTrack i = mtl->begin(); i != mtl->end(); ++i) + addStrip(*i, idx++); + } + + if (cfg->showMidiOutPorts) { + MidiOutPortList* mpl = song->midiOutPorts(); + for (iMidiOutPort i = mpl->begin(); i != mpl->end(); ++i) + addStrip(*i, idx++); + } + + //--------------------------------------------------- + // Groups + //--------------------------------------------------- + + if (cfg->showGroupTracks) { + GroupList* gtl = song->groups(); + for (iAudioGroup i = gtl->begin(); i != gtl->end(); ++i) + addStrip(*i, idx++); + } + + //--------------------------------------------------- + // Master + //--------------------------------------------------- + + if (cfg->showOutputTracks) { + OutputList* otl = song->outputs(); + for (iAudioOutput i = otl->begin(); i != otl->end(); ++i) + addStrip(*i, idx++); + } + setMaximumWidth(STRIP_WIDTH * idx + 4); + central->setFixedWidth(STRIP_WIDTH * idx); + if (idx < 4) + setMinimumWidth(idx * STRIP_WIDTH + 4); + layout->update(); + } + +//--------------------------------------------------------- +// songChanged +//--------------------------------------------------------- + +void Mixer::songChanged(int flags) + { + int action = NO_UPDATE; + if (flags == -1) + action = UPDATE_ALL; + else { + if (flags & SC_TRACK_REMOVED) + action |= STRIP_REMOVED; + if (flags & SC_TRACK_INSERTED) + action |= STRIP_INSERTED; + } + if (action != NO_UPDATE) + updateMixer(action); + } + +//--------------------------------------------------------- +// closeEvent +//--------------------------------------------------------- + +void Mixer::closeEvent(QCloseEvent* e) + { + emit closed(); + e->accept(); + } + +//--------------------------------------------------------- +// toggleRouteDialog +//--------------------------------------------------------- + +void Mixer::toggleRouteDialog() + { + showRouteDialog(routingAction->isChecked()); + } + +//--------------------------------------------------------- +// showRouteDialog +//--------------------------------------------------------- + +void Mixer::showRouteDialog(bool on) + { + if (on && routingDialog == 0) { + routingDialog = new RouteDialog(this); + connect(routingDialog, SIGNAL(closed()), SLOT(routingDialogClosed())); + } + if (routingDialog) + routingDialog->setShown(on); + routingAction->setChecked(on); + } + +//--------------------------------------------------------- +// routingDialogClosed +//--------------------------------------------------------- + +void Mixer::routingDialogClosed() + { + routingAction->setChecked(false); + } + +//--------------------------------------------------------- +// showTracksChanged +//--------------------------------------------------------- + +void Mixer::showTracksChanged(QAction* id) + { + bool val = id->isChecked(); + if (id == showMidiTracksId) + cfg->showMidiTracks = val; + else if (id == showOutputTracksId) + cfg->showOutputTracks = val; + else if (id == showWaveTracksId) + cfg->showWaveTracks = val; + else if (id == showGroupTracksId) + cfg->showGroupTracks = val; + else if (id == showInputTracksId) + cfg->showInputTracks = val; + else if (id == showSyntiTracksId) + cfg->showSyntiTracks = val; + else if (id == showMidiInPortId) + cfg->showMidiInPorts = val; + else if (id == showMidiOutPortId) + cfg->showMidiOutPorts = val; + updateMixer(UPDATE_ALL); + } + +//--------------------------------------------------------- +// write +//--------------------------------------------------------- + +void Mixer::write(Xml& xml, const char* name) + { + xml.stag(QString(name)); + xml.tag("geometry", geometry()); + xml.tag("showMidiTracks", cfg->showMidiTracks); + xml.tag("showOutputTracks", cfg->showOutputTracks); + xml.tag("showWaveTracks", cfg->showWaveTracks); + xml.tag("showGroupTracks", cfg->showGroupTracks); + xml.tag("showInputTracks", cfg->showInputTracks); + xml.tag("showSyntiTracks", cfg->showSyntiTracks); + xml.tag("showMidiInPorts", cfg->showMidiInPorts); + xml.tag("showMidiOutPorts", cfg->showMidiOutPorts); + xml.etag(name); + } + +//--------------------------------------------------------- +// heartBeat +//--------------------------------------------------------- + +void Mixer::heartBeat() + { + if (mustUpdateMixer) { + updateMixer(STRIP_INSERTED | STRIP_REMOVED); + mustUpdateMixer = false; + } + foreach(Strip* s, stripList) + s->heartBeat(); + } + diff --git a/muse/muse/mixer.h b/muse/muse/mixer.h new file mode 100644 index 00000000..62c526a6 --- /dev/null +++ b/muse/muse/mixer.h @@ -0,0 +1,95 @@ +//============================================================================= +// MusE +// Linux Music Editor +// $Id:$ +// +// Copyright (C) 2002-2006 by Werner Schweer and others +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2. +// +// 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., 675 Mass Ave, Cambridge, MA 02139, USA. +//============================================================================= + +#ifndef __AMIXER_H__ +#define __AMIXER_H__ + +#include "gconfig.h" + +class Meter; +class Track; +class Slider; +class Knob; +class RouteDialog; +class Strip; + +typedef QList StripList; + +//--------------------------------------------------------- +// Mixer +//--------------------------------------------------------- + +class Mixer : public QMainWindow { + Q_OBJECT + + MixerConfig* cfg; + StripList stripList; + QWidget* central; + QHBoxLayout* lbox; + Strip* master; + QHBoxLayout* layout; + QMenu* menuView; + RouteDialog* routingDialog; + QAction* routingAction; + + QAction* routingId; + QAction* showMidiTracksId; + QAction* showMidiInPortId; + QAction* showMidiOutPortId; + QAction* showOutputTracksId; + QAction* showWaveTracksId; + QAction* showGroupTracksId; + QAction* showInputTracksId; + QAction* showSyntiTracksId; + + bool mustUpdateMixer; + + virtual void closeEvent(QCloseEvent*); + void addStrip(Track*, int); + void showRouteDialog(bool); + + enum { + NO_UPDATE = 0, + STRIP_INSERTED = 1, + STRIP_REMOVED = 2, + UPDATE_ALL = 4 + }; + void updateMixer(int); + + signals: + void closed(); + + private slots: + void songChanged(int); + void configChanged() { songChanged(-1); } + void toggleRouteDialog(); + void routingDialogClosed(); + void showTracksChanged(QAction*); + + public: + Mixer(QWidget* parent, MixerConfig*); + void clear(); + void write(Xml&, const char* name); + void setUpdateMixer() { mustUpdateMixer = true; } + void heartBeat(); + }; + +#endif + diff --git a/muse/muse/mixer/astrip.cpp b/muse/muse/mixer/astrip.cpp deleted file mode 100644 index 8d6cdd09..00000000 --- a/muse/muse/mixer/astrip.cpp +++ /dev/null @@ -1,791 +0,0 @@ -//============================================================================= -// MusE -// Linux Music Editor -// $Id:$ -// -// Copyright (C) 2000-2006 by Werner Schweer and others -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2. -// -// 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., 675 Mass Ave, Cambridge, MA 02139, USA. -//============================================================================= - -#include "audio.h" -#include "audiodev.h" -#include "song.h" -#include "astrip.h" -#include "synth.h" -#include "rack.h" -#include "gconfig.h" -#include "muse.h" -#include "widgets/simplebutton.h" -#include "widgets/utils.h" -#include "auxplugin.h" -#include "midiinport.h" -#include "midioutport.h" - -#include "awl/volknob.h" -#include "awl/panknob.h" -#include "awl/mslider.h" -#include "awl/volentry.h" -#include "awl/panentry.h" - -//--------------------------------------------------------- -// AudioStrip -// create mixer strip -//--------------------------------------------------------- - -AudioStrip::AudioStrip(Mixer* m, AudioTrack* t, bool align) - : Strip(m, t, align) - { - iR = 0; - oR = 0; - off = 0; - volume = -1.0; - channel = t->channels(); - - //--------------------------------------------------- - // prefader plugin rack - //--------------------------------------------------- - - rack1 = new EffectRack(this, t, true); - rack1->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - rack1->setFixedHeight(rack1->sizeHint().height() + 2); - grid->addWidget(rack1, 1, 0, 1, 2); - - //--------------------------------------------------- - // mono/stereo pre/post - //--------------------------------------------------- - - stereo = newStereoButton(); - stereo->setChecked(channel == 2); - stereo->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - stereo->setFixedHeight(LABEL_HEIGHT); - connect(stereo, SIGNAL(clicked(bool)), SLOT(stereoToggled(bool))); - - pre = new QToolButton; - pre->setObjectName("preButton"); - pre->setCheckable(true); - pre->setText(tr("Pre")); - pre->setToolTip(tr("pre fader - post fader")); - pre->setChecked(t->prefader()); - pre->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - pre->setFixedHeight(LABEL_HEIGHT); - connect(pre, SIGNAL(clicked(bool)), SLOT(preToggled(bool))); - - grid->addWidget(stereo, 2, 0); - grid->addWidget(pre, 2, 1); - - //--------------------------------------------------- - // slider, label - //--------------------------------------------------- - - slider = new Awl::MeterSlider(this); - slider->setRange(config.minSlider, config.maxSlider); - slider->setFixedWidth(60); - slider->setChannel(channel); - Ctrl* ctrl = t->getController(AC_VOLUME); - double vol = 0.0f; - if (ctrl) - vol = ctrl->curVal().f; - slider->setValue(vol); - grid->addWidget(slider, 3, 0, 1, 2); // 100, Qt::AlignRight); - - sl = new Awl::VolEntry(this); - sl->setSuffix(tr("dB")); - sl->setFrame(true); - sl->setValue(vol); - sl->setFixedHeight(entrySize.height()); - - connect(slider, SIGNAL(valueChanged(double,int)), SLOT(volumeChanged(double))); - connect(sl, SIGNAL(valueChanged(double,int)), SLOT(volumeChanged(double))); - - connect(slider, SIGNAL(sliderPressed(int)), SLOT(volumePressed())); - connect(slider, SIGNAL(sliderReleased(int)), SLOT(volumeReleased())); - connect(slider, SIGNAL(meterClicked()), SLOT(resetPeaks())); - grid->addWidget(sl, 4, 0, 1, 2); - - //--------------------------------------------------- - // pan, balance - //--------------------------------------------------- - - pan = addPanKnob(&panl, 5); - double panv = t->getController(AC_PAN)->curVal().f; - pan->setValue(panv); - panl->setValue(panv); - - //--------------------------------------------------- - // postfader plugin rack - //--------------------------------------------------- - - rack2 = new EffectRack(this, t, false); - rack2->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - rack2->setFixedHeight(rack1->sizeHint().height() + 2); - grid->addWidget(rack2, 7, 0, 1, 2); - - //--------------------------------------------------- - // mute, solo, record - //--------------------------------------------------- - - Track::TrackType type = t->type(); - - mute = newMuteButton(); - mute->setChecked(t->mute()); - mute->setFixedHeight(BUTTON_HEIGHT); - connect(mute, SIGNAL(clicked(bool)), SLOT(muteToggled(bool))); - connect(t, SIGNAL(muteChanged(bool)), mute, SLOT(setChecked(bool))); - - solo = newSoloButton(); - solo->setDisabled(true); - solo->setFixedHeight(BUTTON_HEIGHT); - connect(solo, SIGNAL(clicked(bool)), SLOT(soloToggled(bool))); - connect(t, SIGNAL(soloChanged(bool)), solo, SLOT(setChecked(bool))); - - off = newOffButton(); - off->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - off->setFixedHeight(BUTTON_HEIGHT); - off->setChecked(t->off()); - connect(off, SIGNAL(clicked(bool)), SLOT(offToggled(bool))); - connect(t, SIGNAL(offChanged(bool)), this, SLOT(updateOffState())); - - if (track->canRecord()) { - record = newRecordButton(); - record->setFixedHeight(BUTTON_HEIGHT); - if (type == Track::AUDIO_OUTPUT) - record->setToolTip(tr("record downmix")); - record->setChecked(t->recordFlag()); - connect(record, SIGNAL(clicked(bool)), SLOT(recordToggled(bool))); - connect(t, SIGNAL(recordChanged(bool)), record, SLOT(setChecked(bool))); - } - else - record = 0; - - grid->addWidget(off, 8, 0); - if (record) - grid->addWidget(record, 8, 1); - grid->addWidget(mute, 9, 0); - grid->addWidget(solo, 9, 1); - - //--------------------------------------------------- - // automation read write - //--------------------------------------------------- - - addAutomationButtons(10); - - //--------------------------------------------------- - // routing - //--------------------------------------------------- - - iR = newInRouteButton(); - grid->addWidget(iR, 12, 0); - connect(iR->menu(), SIGNAL(aboutToShow()), SLOT(iRouteShow())); - connect(iR->menu(), SIGNAL(aboutToHide()), SLOT(iRouteHide())); - connect(iR->menu(), SIGNAL(triggered(QAction*)), song, SLOT(routeChanged(QAction*))); - - oR = newOutRouteButton(); - grid->addWidget(oR, 12, 1); - connect(oR->menu(), SIGNAL(aboutToShow()), SLOT(oRouteShow())); - connect(oR->menu(), SIGNAL(aboutToHide()), SLOT(oRouteHide())); - connect(oR->menu(), SIGNAL(triggered(QAction*)), song, SLOT(routeChanged(QAction*))); - - if (off) { - updateOffState(); // init state - } - connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int))); - connect(track, SIGNAL(controllerChanged(int)), SLOT(controllerChanged(int))); - connect(track, SIGNAL(autoReadChanged(bool)), SLOT(autoChanged())); - connect(track, SIGNAL(autoWriteChanged(bool)), SLOT(autoChanged())); - autoChanged(); - } - -//--------------------------------------------------------- -// heartBeat -//--------------------------------------------------------- - -void AudioStrip::heartBeat() - { - int peakHold = (config.peakHoldTime * config.guiRefresh) / 1000; - for (int ch = 0; ch < channel; ++ch) { - int n = track->peakTimer(ch); - ++n; - double f = track->peak(ch); - if (n >= peakHold) { - // track->resetPeak(ch); - track->setPeak(ch, f * 0.7); - } - track->setPeakTimer(ch, n); - slider->setMeterVal(ch, track->meter(ch), f); - } - } - -//--------------------------------------------------------- -// songChanged -//--------------------------------------------------------- - -void AudioStrip::songChanged(int val) - { - AudioTrack* src = (AudioTrack*)track; - if (val & SC_TRACK_MODIFIED) - updateLabel(); - if ((val & SC_ROUTE) && pre) - pre->setChecked(src->prefader()); - if (val & SC_CHANNELS) - updateChannels(); - } - -//--------------------------------------------------------- -// offToggled -//--------------------------------------------------------- - -void AudioStrip::offToggled(bool val) - { - song->setOff(track, !val); - } - -//--------------------------------------------------------- -// updateOffState -//--------------------------------------------------------- - -void AudioStrip::updateOffState() - { - bool val = !track->off(); - slider->setEnabled(val); - sl->setEnabled(val); - pan->setEnabled(val); - panl->setEnabled(val); - pre->setEnabled(val); - rack1->setEnabled(val); - rack2->setEnabled(val); - - if (track->type() != Track::AUDIO_SOFTSYNTH) - stereo->setEnabled(val); - label->setEnabled(val); - if (solo) - solo->setEnabled(val); - if (mute) - mute->setEnabled(val); - if (iR) - iR->setEnabled(val); - if (oR) - oR->setEnabled(val); - if (off) - off->setChecked(track->off()); - if (ar) - ar->setEnabled(val); - if (aw) - aw->setEnabled(val); - } - -//--------------------------------------------------------- -// preToggled -//--------------------------------------------------------- - -void AudioStrip::preToggled(bool val) - { - ((AudioTrack*)track)->setPrefader(val); - resetPeaks(); - song->update(SC_ROUTE); - } - -//--------------------------------------------------------- -// stereoToggled -//--------------------------------------------------------- - -void AudioStrip::stereoToggled(bool val) - { - int nc = val ? 1 : 2; - if (channel == nc) - return; - audio->msgSetChannels((AudioTrack*)track, nc); - song->update(SC_CHANNELS); - } - -//--------------------------------------------------------- -// volumeChanged -//--------------------------------------------------------- - -void AudioStrip::volumeChanged(double v) - { - CVal val; - val.f = v; - song->setControllerVal(track, AC_VOLUME, val); - } - -//--------------------------------------------------------- -// volumePressed -//--------------------------------------------------------- - -void AudioStrip::volumePressed() - { - ((AudioTrack*)track)->startAutoRecord(AC_VOLUME); - } - -//--------------------------------------------------------- -// volumeReleased -//--------------------------------------------------------- - -void AudioStrip::volumeReleased() - { - ((AudioTrack*)track)->stopAutoRecord(AC_VOLUME); - } - -//--------------------------------------------------------- -// panChanged -//--------------------------------------------------------- - -void AudioStrip::panChanged(double v) - { - if (v != panVal) { - CVal val; - val.f = v; - song->setControllerVal(track, AC_PAN, val); - panVal = v; - } - } - -//--------------------------------------------------------- -// setPan -//--------------------------------------------------------- - -void AudioStrip::setPan(double val) - { - if (val != panVal) { - panVal = val; - pan->setValue(val); - panl->setValue(val); - } - } - -//--------------------------------------------------------- -// panPressed -//--------------------------------------------------------- - -void AudioStrip::panPressed() - { - track->startAutoRecord(AC_PAN); - } - -//--------------------------------------------------------- -// panReleased -//--------------------------------------------------------- - -void AudioStrip::panReleased() - { - track->stopAutoRecord(AC_PAN); - } - -//--------------------------------------------------------- -// updateChannels -//--------------------------------------------------------- - -void AudioStrip::updateChannels() - { - AudioTrack* t = (AudioTrack*)track; - int c = t->channels(); - if (c == channel) - return; - channel = c; - slider->setChannel(c); - stereo->setChecked(channel == 2); - } - -//--------------------------------------------------------- -// addPanKnob -//--------------------------------------------------------- - -Awl::PanKnob* AudioStrip::addPanKnob(Awl::PanEntry** dlabel, int row) - { - Awl::PanKnob* knob = new Awl::PanKnob(this); - knob->setToolTip(tr("panorama")); - knob->setFixedHeight(entrySize.height() * 2); - - Awl::PanEntry* pl = new Awl::PanEntry(this); - pl->setPrecision(2); - - if (dlabel) - *dlabel = pl; -// pl->setFont(config.fonts[1]); - pl->setFrame(true); - - pl->setFixedSize(entrySize); - - QLabel* plb = new QLabel; - plb->setObjectName("knobLabel"); - plb->setText(tr("Pan")); - plb->setFixedSize(entrySize); - plb->setAlignment(Qt::AlignCenter); - - grid->addWidget(plb, row, 0); - grid->addWidget(pl, row+1, 0); - grid->addWidget(knob, row, 1, 2, 1); - - connect(knob, SIGNAL(valueChanged(double,int)), SLOT(panChanged(double))); - connect(pl, SIGNAL(valueChanged(double,int)), SLOT(panChanged(double))); - connect(knob, SIGNAL(sliderPressed(int)), SLOT(panPressed())); - connect(knob, SIGNAL(sliderReleased(int)), SLOT(panReleased())); - return knob; - } - -//--------------------------------------------------------- -// addAuxPorts -//--------------------------------------------------------- - -static void addAuxPorts(AudioTrack* track, QMenu* lb, const RouteList& rl) - { - QList pre = track->preAux(); - QList post = track->postAux(); - foreach (AuxPluginIF* p, pre) { - QString s = p->pluginInstance()->name(); - QAction* a = lb->addAction(p->pluginInstance()->name()); - a->setCheckable(true); -// Route route(RouteNode(p), RouteNode(track)); - Route route = Route(RouteNode(p), RouteNode(track)); - a->setData(QVariant::fromValue(route)); - a->setChecked(rl.indexOf(route) != -1); - } - foreach(AuxPluginIF* p, post) { - QAction* a = lb->addAction(p->pluginInstance()->name()); - a->setCheckable(true); -// Route route(RouteNode(p), RouteNode(track)); // does not compile?! - Route route = Route(RouteNode(p), RouteNode(track)); - a->setData(QVariant::fromValue(route)); - a->setChecked(rl.indexOf(route) != -1); - } - } - -//--------------------------------------------------------- -// addInPorts -//--------------------------------------------------------- - -static void addInPorts(AudioTrack* t, QMenu* lb, const RouteList& rl, bool input) - { - RouteNode a(t); - - InputList* al = song->inputs(); - for (iAudioInput i = al->begin(); i != al->end(); ++i) { - AudioTrack* track = (AudioTrack*)*i; - if (t == track) - continue; - QAction* it = lb->addAction(track->name()); - it->setCheckable(true); - RouteNode b(track); - Route route = input ? Route(b, a) : Route(a, b); - it->setData(QVariant::fromValue(route)); - it->setChecked(rl.indexOf(route) != -1); - if (input) - addAuxPorts(track, lb, rl); - } - } - -//--------------------------------------------------------- -// addOutPorts -//--------------------------------------------------------- - -static void addOutPorts(AudioTrack* t, QMenu* lb, const RouteList& rl) - { - OutputList* al = song->outputs(); - for (iAudioOutput i = al->begin(); i != al->end(); ++i) { - Track* track = *i; - if (t == track) - continue; - QAction* it = lb->addAction(track->name()); - it->setCheckable(true); - Route route = Route(RouteNode(t), RouteNode(track)); - it->setData(QVariant::fromValue(route)); - it->setChecked(rl.indexOf(route) != -1); - } - } - -//--------------------------------------------------------- -// addGroupPorts -//--------------------------------------------------------- - -static void addGroupPorts(AudioTrack* t, QMenu* lb, const RouteList& rl) - { - GroupList* al = song->groups(); - for (iAudioGroup i = al->begin(); i != al->end(); ++i) { - AudioTrack* track = (AudioTrack*)*i; - if (t == track) - continue; - QAction* it = lb->addAction(track->name()); - it->setCheckable(true); - Route route = Route(RouteNode(t), RouteNode(track)); - it->setData(QVariant::fromValue(route)); - it->setChecked(rl.indexOf(route) != -1); - } - } - -//--------------------------------------------------------- -// addWavePorts -//--------------------------------------------------------- - -static void addWavePorts(AudioTrack* t, QMenu* lb, const RouteList& rl, bool input) - { - RouteNode a(t); - WaveTrackList* al = song->waves(); - for (iWaveTrack i = al->begin(); i != al->end(); ++i) { - AudioTrack* track = (AudioTrack*)*i; - if (t == track) // cannot connect to itself - continue; - QAction* it = lb->addAction(track->name()); - it->setCheckable(true); - RouteNode b(track); - Route route = input ? Route(b, a) : Route(a, b); - it->setData(QVariant::fromValue(route)); - it->setChecked(rl.indexOf(route) != -1); - if (input) - addAuxPorts(track, lb, rl); - } - } - -//--------------------------------------------------------- -// addSyntiPorts -//--------------------------------------------------------- - -static void addSyntiPorts(AudioTrack* t, QMenu* lb, const RouteList& rl) - { - SynthIList* al = song->syntis(); - for (iSynthI i = al->begin(); i != al->end(); ++i) { - AudioTrack* track = (AudioTrack*)*i; - if (t == track) - continue; - QAction* it = lb->addAction(track->name()); - it->setCheckable(true); - RouteNode a(t); - RouteNode b(track); - Route route = Route(b, a); - it->setData(QVariant::fromValue(route)); - it->setChecked(rl.indexOf(route) != -1); - } - } - -//--------------------------------------------------------- -// iRouteShow -//--------------------------------------------------------- - -extern void addMidiTracks(QMenu* menu, Track* track, int channel, bool input); -extern void addMidiInPorts(QMenu* menu, Track* dtrack, int channel); - -void AudioStrip::iRouteShow() - { - QMenu* pup = iR->menu(); - pup->clear(); - AudioTrack* t = (AudioTrack*)track; - RouteList* irl = t->inRoutes(); - - switch(track->type()) { - default: - return; - case Track::AUDIO_INPUT: - { - for (int i = 0; i < channel; ++i) { - pup->addSeparator()->setText(QString(tr("Channel %1")).arg(i+1)); - QList ol = audioDriver->outputPorts(false); - foreach (PortName ip, ol) { - QAction* id = pup->addAction(ip.name); - id->setCheckable(true); - RouteNode src(ip.port, -1, RouteNode::AUDIOPORT); - RouteNode dst(t, i, RouteNode::TRACK); - Route route = Route(src, dst); - id->setData(QVariant::fromValue(route)); - id->setChecked(irl->indexOf(route) != -1); - } - } - } - break; - case Track::AUDIO_OUTPUT: - addWavePorts(t, pup, *irl, true); - addInPorts(t, pup, *irl, true); - addGroupPorts(t, pup, *irl); - addSyntiPorts(t, pup, *irl); - break; - case Track::WAVE: - addInPorts(t, pup, *irl, true); - break; - case Track::AUDIO_GROUP: - addWavePorts(t, pup, *irl, true); - addInPorts(t, pup, *irl, true); - addGroupPorts(t, pup, *irl); - addSyntiPorts(t, pup, *irl); - break; - case Track::AUDIO_SOFTSYNTH: - pup->addSeparator()->setText(tr("MidiChannel")); - for (int ch = 0; ch < MIDI_CHANNELS; ++ch) { - QMenu* m = pup->addMenu(QString("Channel %1").arg(ch+1)); - addMidiTracks(m, track, ch, true); - addMidiInPorts(m, track, ch); - } - break; - } - } - -//--------------------------------------------------------- -// iRouteHide -//--------------------------------------------------------- - -void AudioStrip::iRouteHide() - { - // dont leave the menu if SHIFT is pressed; this allows - // for fast selecting of more than one input source - // - if (qApp->keyboardModifiers() & Qt::ShiftModifier) { - iR->menu()->show(); - } - } - -//--------------------------------------------------------- -// oRouteHide -//--------------------------------------------------------- - -void AudioStrip::oRouteHide() - { - // dont leave the menu if SHIFT is pressed; this allows - // for fast selecting of more than one input source - // - if (qApp->keyboardModifiers() & Qt::ShiftModifier) { - oR->menu()->show(); - } - } - -//--------------------------------------------------------- -// oRouteShow -//--------------------------------------------------------- - -void AudioStrip::oRouteShow() - { - QMenu* pup = oR->menu(); - pup->clear(); - AudioTrack* t = (AudioTrack*)track; - RouteList* orl = t->outRoutes(); - - switch(track->type()) { - default: - return; - case Track::AUDIO_OUTPUT: - { - for (int i = 0; i < channel; ++i) { - char buffer[128]; - snprintf(buffer, 128, "%s %d", tr("Channel").toLatin1().data(), i+1); - pup->addSeparator()->setText(QString(buffer)); - - QList ol = audioDriver->inputPorts(false); - foreach (PortName ip, ol) { - QAction* action = pup->addAction(ip.name); - action->setCheckable(true); - RouteNode src(t, i, RouteNode::TRACK); - RouteNode dst(ip.port, -1, RouteNode::AUDIOPORT); - Route r = Route(src, dst); - action->setData(QVariant::fromValue(r)); - action->setChecked(orl->indexOf(r) != -1); - } - } - } - break; - case Track::AUDIO_INPUT: - addWavePorts(t, pup, *orl, false); - case Track::WAVE: - case Track::AUDIO_GROUP: - case Track::AUDIO_SOFTSYNTH: - addOutPorts(t, pup, *orl); - addGroupPorts(t, pup, *orl); - break; - } - } - -//--------------------------------------------------------- -// muteToggled -//--------------------------------------------------------- - -void AudioStrip::muteToggled(bool val) - { - song->setMute(track, val); - } - -//--------------------------------------------------------- -// soloToggled -//--------------------------------------------------------- - -void AudioStrip::soloToggled(bool val) - { - song->setSolo(track, val); - } - -//--------------------------------------------------------- -// recordToggled -//--------------------------------------------------------- - -void AudioStrip::recordToggled(bool val) - { - song->setRecordFlag(track, !val); - } - -//--------------------------------------------------------- -// controllerChanged -//--------------------------------------------------------- - -void AudioStrip::controllerChanged(int id) - { - double val = track->getController(id)->curVal().f; - switch (id) { - case AC_VOLUME: - slider->setValue(val); - sl->setValue(val); - break; - case AC_PAN: - pan->setValue(val); - panl->setValue(val); - panVal = val; - break; - case AC_MUTE: - break; - default: - break; - } - } - -//--------------------------------------------------------- -// autoChanged -//--------------------------------------------------------- - -void AudioStrip::autoChanged() - { - bool ar = track->autoRead(); - bool aw = track->autoWrite(); - - // controller are enabled if - // autoRead is off - // autoRead and autoWrite are on (touch mode) - - bool ec = !ar || (ar && aw); - slider->setEnabled(ec); - sl->setEnabled(ec); - pan->setEnabled(ec); - panl->setEnabled(ec); - } - -//--------------------------------------------------------- -// autoReadToggled -//--------------------------------------------------------- - -void AudioStrip::autoReadToggled(bool val) - { - song->setAutoRead(track, val); - } - -//--------------------------------------------------------- -// autoWriteToggled -//--------------------------------------------------------- - -void AudioStrip::autoWriteToggled(bool val) - { - song->setAutoWrite(track, val); - } - diff --git a/muse/muse/mixer/astrip.h b/muse/muse/mixer/astrip.h deleted file mode 100644 index f0806fda..00000000 --- a/muse/muse/mixer/astrip.h +++ /dev/null @@ -1,101 +0,0 @@ -//============================================================================= -// MusE -// Linux Music Editor -// $Id:$ -// -// Copyright (C) 2002-2006 by Werner Schweer and others -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2. -// -// 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., 675 Mass Ave, Cambridge, MA 02139, USA. -//============================================================================= - -#ifndef __ASTRIP_H__ -#define __ASTRIP_H__ - -#include "strip.h" - -namespace Awl { - class MeterSlider; - class VolEntry; - class VolKnob; - class PanKnob; - class PanEntry; - }; - -class AudioTrack; -class SimpleButton; -class EffectRack; -class Mixer; - -//--------------------------------------------------------- -// AudioStrip -//--------------------------------------------------------- - -class AudioStrip : public Strip { - Q_OBJECT - - int channel; - EffectRack* rack1; - EffectRack* rack2; - - Awl::MeterSlider* slider; - Awl::VolEntry* sl; - double volume; - - Awl::PanKnob* pan; - Awl::PanEntry* panl; - double panVal; - - QToolButton* stereo; - QToolButton* pre; - - Awl::PanKnob* addPanKnob(Awl::PanEntry**, int); - - QToolButton* iR; - QToolButton* oR; - SimpleButton* off; - SimpleButton* record; - - void updateChannels(); - - private slots: - void stereoToggled(bool); - void preToggled(bool); - void offToggled(bool); - void iRouteShow(); - void iRouteHide(); - void oRouteShow(); - void oRouteHide(); - void volumeChanged(double); - void volumePressed(); - void volumeReleased(); - void panChanged(double); - void setPan(double); - void panPressed(); - void panReleased(); - void muteToggled(bool); - void soloToggled(bool); - void recordToggled(bool); - void autoChanged(); - virtual void controllerChanged(int id); - virtual void songChanged(int); - void autoReadToggled(bool); - void autoWriteToggled(bool); - void updateOffState(); - - public: - AudioStrip(Mixer*, AudioTrack*, bool align); - virtual void heartBeat(); - }; - -#endif - diff --git a/muse/muse/mixer/midirack.cpp b/muse/muse/mixer/midirack.cpp deleted file mode 100644 index 0b054729..00000000 --- a/muse/muse/mixer/midirack.cpp +++ /dev/null @@ -1,208 +0,0 @@ -//============================================================================= -// MusE -// Linux Music Editor -// $Id:$ -// -// Copyright (C) 2002-2006 by Werner Schweer and others -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2. -// -// 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., 675 Mass Ave, Cambridge, MA 02139, USA. -//============================================================================= - -#include "icons.h" -#include "gconfig.h" -#include "midirack.h" -#include "track.h" -#include "song.h" -#include "midiplugin.h" -#include "audio.h" -#include "muse.h" -#include "gui.h" - -//--------------------------------------------------------- -// MidiRack -//--------------------------------------------------------- - -MidiRack::MidiRack(QWidget* parent, MidiTrackBase* t) - : QListWidget(parent) - { - setUniformItemSizes(true); - setAlternatingRowColors(true); - setAttribute(Qt::WA_DeleteOnClose, true); - verticalScrollBar()->setStyle(smallStyle); - track = t; -// setFont(config.fonts[1]); - - setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - - setSelectionMode(QAbstractItemView::SingleSelection); - songChanged(SC_RACK); // force update - connect(this, SIGNAL(itemDoubleClicked(QListWidgetItem*)), - this, SLOT(doubleClicked(QListWidgetItem*))); - connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int))); - setToolTip(tr("midi effect rack")); - } - -//--------------------------------------------------------- -// sizeHint -//--------------------------------------------------------- - -QSize MidiRack::sizeHint() const - { - QFontMetrics fm(font()); - int h = fm.lineSpacing() * MidiPipelineDepth + 1; - return QSize(STRIP_WIDTH, h); - } - -//--------------------------------------------------------- -// songChanged -//--------------------------------------------------------- - -void MidiRack::songChanged(int typ) - { - if (typ & (SC_ROUTE | SC_RACK)) { - clear(); - foreach(MidiPluginI* plugin, *(track->pipeline())) { - QListWidgetItem* item = new QListWidgetItem; - item->setText(plugin->name()); - // tooltip should only be set if name does not fit - // (is elided) - item->setToolTip(plugin->name()); - item->setBackgroundColor(plugin->on() ? Qt::white : Qt::gray); - addItem(item); - } - } - } - -//--------------------------------------------------------- -// contextMenuEvent -//--------------------------------------------------------- - -void MidiRack::contextMenuEvent(QContextMenuEvent* ev) - { - QPoint pt(ev->pos()); - QListWidgetItem* item = itemAt(pt); - MidiPipeline* pipe = track->pipeline(); - - QMenu* menu = new QMenu; - QAction* upAction = menu->addAction(QIcon(*upIcon), tr("move up")); - QAction* downAction = menu->addAction(QIcon(*downIcon), tr("move down")); - QAction* removeAction = menu->addAction(tr("remove")); - QAction* bypassAction = menu->addAction(tr("bypass")); - QAction* showAction = menu->addAction(tr("show gui")); - QAction* newAction = menu->addAction(tr("new")); - bypassAction->setCheckable(true); - showAction->setCheckable(true); - - int idx = -1; - if (item == 0) { - upAction->setEnabled(false); - downAction->setEnabled(false); - removeAction->setEnabled(false); - bypassAction->setEnabled(false); - showAction->setEnabled(false); - } - else { - idx = row(item); - upAction->setEnabled(idx != 0); - downAction->setEnabled(idx < (pipe->size() - 1)); - showAction->setEnabled(pipe->hasGui(idx)); - bypassAction->setEnabled(true); - bypassAction->setChecked(!pipe->isOn(idx)); - showAction->setChecked(pipe->guiVisible(idx)); - } - - QAction* sel = menu->exec(mapToGlobal(pt), newAction); - delete menu; - if (sel == 0) - return; - - if (sel == newAction) { - selectNew(); - return; - } - if (sel == removeAction) { - audio->msgAddMidiPlugin(track, idx, 0); - } - else if (sel == bypassAction) { - bool flag = !pipe->isOn(idx); - pipe->setOn(idx, flag); - } - else if (sel == showAction) { - bool flag = !pipe->guiVisible(idx); - pipe->showGui(idx, flag); - } - else if (sel == upAction) { - if (idx > 0) { - setCurrentRow(idx-1); - pipe->move(idx, true); - } - } - else if (sel == downAction) { - if (idx < (pipe->size() - 1)) { - setCurrentRow(idx+1); - pipe->move(idx, false); - } - } - song->update(SC_RACK); - } - -//--------------------------------------------------------- -// doubleClicked -// toggle gui -//--------------------------------------------------------- - -void MidiRack::doubleClicked(QListWidgetItem* it) - { - if (track == 0) - return; - int idx = row(it); - MidiPipeline* pipe = track->pipeline(); - bool flag = !pipe->guiVisible(idx); - pipe->showGui(idx, flag); - song->update(SC_RACK); - } - -//--------------------------------------------------------- -// mouseDoubleClickEvent -//--------------------------------------------------------- - -void MidiRack::mouseDoubleClickEvent(QMouseEvent* event) - { - QListWidgetItem* it = itemAt(event->pos()); - if (it || (track == 0)) { - QListWidget::mouseDoubleClickEvent(event); - return; - } - selectNew(); - } - -//--------------------------------------------------------- -// selectNew -//--------------------------------------------------------- - -void MidiRack::selectNew() - { - MidiPlugin* plugin = MidiPluginDialog::getPlugin(this); - if (plugin) { - MidiPluginI* plugi = plugin->instantiate(track); - if (plugi == 0) { - printf("cannot instantiate plugin <%s>\n", - plugin->name().toLatin1().data()); - delete plugi; - } - else - audio->msgAddMidiPlugin(track, track->pipeline()->size(), plugi); - song->update(SC_RACK); - } - } - diff --git a/muse/muse/mixer/midirack.h b/muse/muse/mixer/midirack.h deleted file mode 100644 index 7f83ca42..00000000 --- a/muse/muse/mixer/midirack.h +++ /dev/null @@ -1,48 +0,0 @@ -//============================================================================= -// MusE -// Linux Music Editor -// $Id:$ -// -// Copyright (C) 2002-2006 by Werner Schweer and others -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2. -// -// 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., 675 Mass Ave, Cambridge, MA 02139, USA. -//============================================================================= - -#ifndef __MIDIRACK_H__ -#define __MIDIRACK_H__ - -class MidiTrackBase; - -//--------------------------------------------------------- -// MidiRack -//--------------------------------------------------------- - -class MidiRack : public QListWidget { - MidiTrackBase* track; - Q_OBJECT - - virtual void contextMenuEvent(QContextMenuEvent*); - virtual void mouseDoubleClickEvent(QMouseEvent*); - void selectNew(); - - private slots: - void doubleClicked(QListWidgetItem*); - void songChanged(int); - - public: - MidiRack(QWidget*, MidiTrackBase* t); - QSize sizeHint() const; - }; - -#endif - diff --git a/muse/muse/mixer/mixer.cpp b/muse/muse/mixer/mixer.cpp deleted file mode 100644 index b3e5ce06..00000000 --- a/muse/muse/mixer/mixer.cpp +++ /dev/null @@ -1,397 +0,0 @@ -//============================================================================= -// MusE -// Linux Music Editor -// $Id:$ -// -// Copyright (C) 2002-2006 by Werner Schweer and others -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2. -// -// 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., 675 Mass Ave, Cambridge, MA 02139, USA. -//============================================================================= - -#include "muse.h" -#include "mixer.h" -#include "song.h" -#include "icons.h" -#include "astrip.h" -#include "mstrip.h" -#include "routedialog.h" -#include "synth.h" -#include "midiinport.h" -#include "midioutport.h" - -extern void populateAddTrack(QMenu* addTrack); - -//--------------------------------------------------------- -// Mixer -// -// inputs | synthis | tracks | groups | master -//--------------------------------------------------------- - -Mixer::Mixer(QWidget* parent, MixerConfig* c) - : QMainWindow(parent) - { - mustUpdateMixer = false; - cfg = c; - routingDialog = 0; - setWindowTitle(tr("MusE: Mixer")); - setWindowIcon(*museIcon); - - QMenu* menuCreate = menuBar()->addMenu(tr("&Create")); - populateAddTrack(menuCreate); - - menuView = menuBar()->addMenu(tr("&View")); - routingAction = menuView->addAction(tr("Routing"), this, SLOT(toggleRouteDialog())); - routingAction->setCheckable(true); - - showMidiTracksId = menuView->addAction(tr("Show Midi Tracks")); - showMidiOutPortId = menuView->addAction(tr("Show Midi Out Ports")); - showMidiInPortId = menuView->addAction(tr("Show Midi In Ports")); - - menuView->addSeparator(); - - showWaveTracksId = menuView->addAction(tr("Show Wave Tracks")); - showOutputTracksId = menuView->addAction(tr("Show Output Tracks")); - showGroupTracksId = menuView->addAction(tr("Show Group Tracks")); - showInputTracksId = menuView->addAction(tr("Show Input Tracks")); - showSyntiTracksId = menuView->addAction(tr("Show Synthesizer")); - connect(menuView, SIGNAL(triggered(QAction*)), SLOT(showTracksChanged(QAction*))); - - showMidiTracksId->setCheckable(true); - showMidiInPortId->setCheckable(true); - showMidiOutPortId->setCheckable(true); - showWaveTracksId->setCheckable(true); - showOutputTracksId->setCheckable(true); - showGroupTracksId->setCheckable(true); - showInputTracksId->setCheckable(true); - showSyntiTracksId->setCheckable(true); - - QScrollArea* view = new QScrollArea; - view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - setCentralWidget(view); - - central = new QWidget; - layout = new QHBoxLayout; - central->setLayout(layout); - layout->setSpacing(0); - layout->setMargin(0); - view->setWidget(central); - view->setWidgetResizable(true); - - connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int))); - connect(muse, SIGNAL(configChanged()), SLOT(configChanged())); - song->update(); // calls update mixer - } - -//--------------------------------------------------------- -// addStrip -//--------------------------------------------------------- - -void Mixer::addStrip(Track* t, int idx) - { - StripList::iterator si = stripList.begin(); - for (int i = 0; i < idx; ++i) { - if (si != stripList.end()) - ++si; - } - if (si != stripList.end() && (*si)->getTrack() == t) - return; - - StripList::iterator nsi = si; - ++nsi; - if (si != stripList.end() - && nsi != stripList.end() - && (*nsi)->getTrack() == t) { - layout->removeWidget(*si); - delete *si; - stripList.erase(si); - } - else { - Strip* strip; - switch(t->type()) { - case Track::MIDI_IN: - strip = new MidiInPortStrip(this, (MidiInPort*)t, true); - break; - case Track::MIDI_OUT: - strip = new MidiOutPortStrip(this, (MidiOutPort*)t, true); - break; - case Track::MIDI: - strip = new MidiStrip(this, (MidiTrack*)t, true); - break; - case Track::MIDI_SYNTI: - strip = new MidiSyntiStrip(this, (MidiSynti*)t, true); - break; - default: - strip = new AudioStrip(this, (AudioTrack*)t, true); - break; - } - layout->insertWidget(idx, strip); - stripList.insert(si, strip); - strip->show(); - } - } - -//--------------------------------------------------------- -// clear -//--------------------------------------------------------- - -void Mixer::clear() - { - QLayoutItem* i; - while ((i = layout->takeAt(0))) { - if (i->widget()) - delete i->widget(); - delete i; - } - stripList.clear(); - } - -//--------------------------------------------------------- -// updateMixer -//--------------------------------------------------------- - -void Mixer::updateMixer(int action) - { - showMidiTracksId->setChecked(cfg->showMidiTracks); - showMidiInPortId->setChecked(cfg->showMidiInPorts); - showMidiOutPortId->setChecked(cfg->showMidiOutPorts); - showWaveTracksId->setChecked(cfg->showWaveTracks); - showOutputTracksId->setChecked(cfg->showOutputTracks); - showGroupTracksId->setChecked(cfg->showGroupTracks); - showInputTracksId->setChecked(cfg->showInputTracks); - showSyntiTracksId->setChecked(cfg->showSyntiTracks); - - if (action == STRIP_REMOVED) { - foreach(Strip* strip, stripList) { - Track* track = strip->getTrack(); - if (song->trackExists(track)) - continue; - layout->removeWidget(strip); - delete strip; - stripList.removeAt(stripList.indexOf(strip)); - } - int idx = stripList.size(); - setMaximumWidth(STRIP_WIDTH * idx + 4); - central->setFixedWidth(STRIP_WIDTH * idx); - if (idx < 4) - setMinimumWidth(idx * STRIP_WIDTH + 4); - return; - } - - clear(); - - int idx = 0; - //--------------------------------------------------- - // generate Input Strips - //--------------------------------------------------- - - if (cfg->showInputTracks) { - InputList* itl = song->inputs(); - for (iAudioInput i = itl->begin(); i != itl->end(); ++i) - addStrip(*i, idx++); - } - - //--------------------------------------------------- - // Synthesizer Strips - //--------------------------------------------------- - - if (cfg->showSyntiTracks) { - SynthIList* sl = song->syntis(); - for (iSynthI i = sl->begin(); i != sl->end(); ++i) - addStrip(*i, idx++); - } - - //--------------------------------------------------- - // generate Wave Track Strips - //--------------------------------------------------- - - if (cfg->showWaveTracks) { - WaveTrackList* wtl = song->waves(); - for (iWaveTrack i = wtl->begin(); i != wtl->end(); ++i) - addStrip(*i, idx++); - } - - //--------------------------------------------------- - // generate Midi strips - //--------------------------------------------------- - - if (cfg->showMidiInPorts) { - MidiInPortList* mpl = song->midiInPorts(); - for (iMidiInPort i = mpl->begin(); i != mpl->end(); ++i) - addStrip(*i, idx++); - } - - if (cfg->showMidiSyntiPorts) { - MidiSyntiList* mpl = song->midiSyntis(); - for (iMidiSynti i = mpl->begin(); i != mpl->end(); ++i) - addStrip(*i, idx++); - } - - if (cfg->showMidiTracks) { - MidiTrackList* mtl = song->midis(); - for (iMidiTrack i = mtl->begin(); i != mtl->end(); ++i) - addStrip(*i, idx++); - } - - if (cfg->showMidiOutPorts) { - MidiOutPortList* mpl = song->midiOutPorts(); - for (iMidiOutPort i = mpl->begin(); i != mpl->end(); ++i) - addStrip(*i, idx++); - } - - //--------------------------------------------------- - // Groups - //--------------------------------------------------- - - if (cfg->showGroupTracks) { - GroupList* gtl = song->groups(); - for (iAudioGroup i = gtl->begin(); i != gtl->end(); ++i) - addStrip(*i, idx++); - } - - //--------------------------------------------------- - // Master - //--------------------------------------------------- - - if (cfg->showOutputTracks) { - OutputList* otl = song->outputs(); - for (iAudioOutput i = otl->begin(); i != otl->end(); ++i) - addStrip(*i, idx++); - } - setMaximumWidth(STRIP_WIDTH * idx + 4); - central->setFixedWidth(STRIP_WIDTH * idx); - if (idx < 4) - setMinimumWidth(idx * STRIP_WIDTH + 4); - layout->update(); - } - -//--------------------------------------------------------- -// songChanged -//--------------------------------------------------------- - -void Mixer::songChanged(int flags) - { - int action = NO_UPDATE; - if (flags == -1) - action = UPDATE_ALL; - else { - if (flags & SC_TRACK_REMOVED) - action |= STRIP_REMOVED; - if (flags & SC_TRACK_INSERTED) - action |= STRIP_INSERTED; - } - if (action != NO_UPDATE) - updateMixer(action); - } - -//--------------------------------------------------------- -// closeEvent -//--------------------------------------------------------- - -void Mixer::closeEvent(QCloseEvent* e) - { - emit closed(); - e->accept(); - } - -//--------------------------------------------------------- -// toggleRouteDialog -//--------------------------------------------------------- - -void Mixer::toggleRouteDialog() - { - showRouteDialog(routingAction->isChecked()); - } - -//--------------------------------------------------------- -// showRouteDialog -//--------------------------------------------------------- - -void Mixer::showRouteDialog(bool on) - { - if (on && routingDialog == 0) { - routingDialog = new RouteDialog(this); - connect(routingDialog, SIGNAL(closed()), SLOT(routingDialogClosed())); - } - if (routingDialog) - routingDialog->setShown(on); - routingAction->setChecked(on); - } - -//--------------------------------------------------------- -// routingDialogClosed -//--------------------------------------------------------- - -void Mixer::routingDialogClosed() - { - routingAction->setChecked(false); - } - -//--------------------------------------------------------- -// showTracksChanged -//--------------------------------------------------------- - -void Mixer::showTracksChanged(QAction* id) - { - bool val = id->isChecked(); - if (id == showMidiTracksId) - cfg->showMidiTracks = val; - else if (id == showOutputTracksId) - cfg->showOutputTracks = val; - else if (id == showWaveTracksId) - cfg->showWaveTracks = val; - else if (id == showGroupTracksId) - cfg->showGroupTracks = val; - else if (id == showInputTracksId) - cfg->showInputTracks = val; - else if (id == showSyntiTracksId) - cfg->showSyntiTracks = val; - else if (id == showMidiInPortId) - cfg->showMidiInPorts = val; - else if (id == showMidiOutPortId) - cfg->showMidiOutPorts = val; - updateMixer(UPDATE_ALL); - } - -//--------------------------------------------------------- -// write -//--------------------------------------------------------- - -void Mixer::write(Xml& xml, const char* name) - { - xml.stag(QString(name)); - xml.tag("geometry", geometry()); - xml.tag("showMidiTracks", cfg->showMidiTracks); - xml.tag("showOutputTracks", cfg->showOutputTracks); - xml.tag("showWaveTracks", cfg->showWaveTracks); - xml.tag("showGroupTracks", cfg->showGroupTracks); - xml.tag("showInputTracks", cfg->showInputTracks); - xml.tag("showSyntiTracks", cfg->showSyntiTracks); - xml.tag("showMidiInPorts", cfg->showMidiInPorts); - xml.tag("showMidiOutPorts", cfg->showMidiOutPorts); - xml.etag(name); - } - -//--------------------------------------------------------- -// heartBeat -//--------------------------------------------------------- - -void Mixer::heartBeat() - { - if (mustUpdateMixer) { - updateMixer(STRIP_INSERTED | STRIP_REMOVED); - mustUpdateMixer = false; - } - foreach(Strip* s, stripList) - s->heartBeat(); - } - diff --git a/muse/muse/mixer/mixer.h b/muse/muse/mixer/mixer.h deleted file mode 100644 index 62c526a6..00000000 --- a/muse/muse/mixer/mixer.h +++ /dev/null @@ -1,95 +0,0 @@ -//============================================================================= -// MusE -// Linux Music Editor -// $Id:$ -// -// Copyright (C) 2002-2006 by Werner Schweer and others -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2. -// -// 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., 675 Mass Ave, Cambridge, MA 02139, USA. -//============================================================================= - -#ifndef __AMIXER_H__ -#define __AMIXER_H__ - -#include "gconfig.h" - -class Meter; -class Track; -class Slider; -class Knob; -class RouteDialog; -class Strip; - -typedef QList StripList; - -//--------------------------------------------------------- -// Mixer -//--------------------------------------------------------- - -class Mixer : public QMainWindow { - Q_OBJECT - - MixerConfig* cfg; - StripList stripList; - QWidget* central; - QHBoxLayout* lbox; - Strip* master; - QHBoxLayout* layout; - QMenu* menuView; - RouteDialog* routingDialog; - QAction* routingAction; - - QAction* routingId; - QAction* showMidiTracksId; - QAction* showMidiInPortId; - QAction* showMidiOutPortId; - QAction* showOutputTracksId; - QAction* showWaveTracksId; - QAction* showGroupTracksId; - QAction* showInputTracksId; - QAction* showSyntiTracksId; - - bool mustUpdateMixer; - - virtual void closeEvent(QCloseEvent*); - void addStrip(Track*, int); - void showRouteDialog(bool); - - enum { - NO_UPDATE = 0, - STRIP_INSERTED = 1, - STRIP_REMOVED = 2, - UPDATE_ALL = 4 - }; - void updateMixer(int); - - signals: - void closed(); - - private slots: - void songChanged(int); - void configChanged() { songChanged(-1); } - void toggleRouteDialog(); - void routingDialogClosed(); - void showTracksChanged(QAction*); - - public: - Mixer(QWidget* parent, MixerConfig*); - void clear(); - void write(Xml&, const char* name); - void setUpdateMixer() { mustUpdateMixer = true; } - void heartBeat(); - }; - -#endif - diff --git a/muse/muse/mixer/mstrip.cpp b/muse/muse/mixer/mstrip.cpp deleted file mode 100644 index d4c48f5e..00000000 --- a/muse/muse/mixer/mstrip.cpp +++ /dev/null @@ -1,1279 +0,0 @@ -//============================================================================= -// MusE -// Linux Music Editor -// $Id:$ -// -// Copyright (C) 2002-2006 by Werner Schweer and others -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2. -// -// 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., 675 Mass Ave, Cambridge, MA 02139, USA. -//============================================================================= - -#include "midictrl.h" -#include "mstrip.h" -#include "audio.h" -#include "song.h" -#include "mixer.h" -#include "widgets/simplebutton.h" -#include "widgets/utils.h" -#include "audiodev.h" -#include "synth.h" -#include "midirack.h" -#include "midiplugin.h" -#include "midiinport.h" -#include "midioutport.h" - -#include "awl/midimslider.h" -#include "awl/midimeter.h" -#include "awl/midivolentry.h" -#include "awl/midipanentry.h" -#include "awl/midipanknob.h" -#include "awl/knob.h" - -enum { KNOB_PAN, KNOB_CHOR_SEND, KNOB_VAR_SEND, KNOB_REV_SEND }; - -//--------------------------------------------------------- -// addMidiTracks -// input == true -// add routes from all possible midi tracks to input -// route list of track(channel) -// input == false -// add routes to all midi tracks to output route -// list of track(channel) -// -// Note: midi tracks do not have channels -//--------------------------------------------------------- - -void addMidiTracks(QMenu* menu, Track* track, int channel, bool input) - { - RouteList* rl = input ? track->inRoutes() : track->outRoutes(); - RouteNode a(track, channel, RouteNode::TRACK); - - MidiTrackList* tl = song->midis(); - for (iMidiTrack i = tl->begin();i != tl->end(); ++i) { - MidiTrack* track = *i; - QAction* action = menu->addAction(track->name()); - action->setCheckable(true); - RouteNode b(track); - Route r = input ? Route(b, a) : Route(a, b); - action->setData(QVariant::fromValue(r)); - action->setChecked(rl->indexOf(r) != -1); - } - } - -//--------------------------------------------------------- -// addMidiInPorts -// can only be added to input route lists -//--------------------------------------------------------- - -void addMidiInPorts(QMenu* menu, Track* dtrack, int channel) - { - RouteList* rl = dtrack->inRoutes(); - RouteNode dst(dtrack, channel, RouteNode::TRACK); - - MidiInPortList* tl = song->midiInPorts(); - for (iMidiInPort i = tl->begin();i != tl->end(); ++i) { - MidiInPort* track = *i; - QMenu* m = menu->addMenu(track->name()); - m->setSeparatorsCollapsible(false); - m->addSeparator()->setText(QT_TR_NOOP("Channels")); - for (int ch = 0; ch < MIDI_CHANNELS; ++ch) { - QAction* a = m->addAction(QString("Channel %1").arg(ch+1)); - a->setCheckable(true); - RouteNode src(track, ch, RouteNode::TRACK); - Route r = Route(src, dst); - a->setData(QVariant::fromValue(r)); - a->setChecked(rl->indexOf(r) != -1); - } - } - } - -//--------------------------------------------------------- -// addMidiOutPorts -// can only be added to output route lists -//--------------------------------------------------------- - -static void addMidiOutPorts(QMenu* menu, Track* strack, int channel) - { - RouteList* rl = strack->outRoutes(); - RouteNode src(strack, channel, RouteNode::TRACK); - - MidiOutPortList* tl = song->midiOutPorts(); - for (iMidiOutPort i = tl->begin();i != tl->end(); ++i) { - MidiOutPort* op = *i; - QMenu* m = menu->addMenu(op->name()); - m->setSeparatorsCollapsible(false); - m->addSeparator()->setText(QT_TR_NOOP("Channels")); - for (int ch = 0; ch < MIDI_CHANNELS; ++ch) { - QAction* a = m->addAction(QString("Channel %1").arg(ch+1)); - a->setCheckable(true); - RouteNode dst(op, ch, RouteNode::TRACK); - Route r = Route(src, dst); - a->setData(QVariant::fromValue(r)); - a->setChecked(rl->indexOf(r) != -1); - } - } - } - -//--------------------------------------------------------- -// addSyntiPorts -// can only be added to output route lists -//--------------------------------------------------------- - -static void addSyntiPorts(QMenu* menu, Track* strack, int channel) - { - RouteList* rl = strack->outRoutes(); - RouteNode src(strack, channel, RouteNode::TRACK); - - SynthIList* sl = song->syntis(); - for (iSynthI i = sl->begin(); i != sl->end(); ++i) { - SynthI* sy = *i; - QMenu* m = menu->addMenu(sy->name()); - m->setSeparatorsCollapsible(false); - m->addSeparator()->setText(QT_TR_NOOP("Channels")); - for (int ch = 0; ch < MIDI_CHANNELS; ++ch) { - QAction* a = m->addAction(QString("Channel %1").arg(ch+1)); - a->setCheckable(true); - RouteNode dst(sy, ch, RouteNode::TRACK); - Route r = Route(src, dst); - a->setData(QVariant::fromValue(r)); - a->setChecked(rl->indexOf(r) != -1); - } - } - } - -//--------------------------------------------------------- -// addKnob -//--------------------------------------------------------- - -void MidiStrip::addKnob(int ctrl, int idx, const QString& tt, const QString& label, - const char* slot, bool enabled, int row) - { - Awl::FloatEntry* dl; - Awl::Knob* knob; - - if (idx == KNOB_PAN) { - dl = new Awl::MidiPanEntry(this); - knob = new Awl::MidiPanKnob(this); - } - else { - dl = new Awl::MidiVolEntry(this); - knob = new Awl::Knob(this); - knob->setRange(0.0, 127.0); - } - knob->setId(ctrl); - dl->setId(ctrl); - dl->setFrame(true); - - controller[idx].knob = knob; - knob->setToolTip(tt); - knob->setEnabled(enabled); - - controller[idx].dl = dl; - dl->setFixedSize(entrySize); - dl->setEnabled(enabled); - - QLabel* lb = new QLabel(label, this); - lb->setObjectName("knobLabel"); - controller[idx].lb = lb; - lb->setFixedSize(entrySize); - lb->setAlignment(Qt::AlignCenter); - lb->setEnabled(enabled); - - grid->addWidget(lb, row, 0); - grid->addWidget(dl, row+1, 0); - grid->addWidget(knob, row, 1, 2, 1); - - connect(knob, SIGNAL(valueChanged(double,int)), slot); - connect(dl, SIGNAL(valueChanged(double,int)), slot); - connect(knob, SIGNAL(sliderPressed(int)), SLOT(sliderPressed(int))); - connect(knob, SIGNAL(sliderReleased(int)), SLOT(sliderReleased(int))); - } - -//--------------------------------------------------------- -// MidiStrip -//--------------------------------------------------------- - -MidiStrip::MidiStrip(Mixer* m, MidiTrack* t, bool align) - : Strip(m, t, align) - { - volumeTouched = false; - panTouched = false; - reverbSendTouched = false; - variSendTouched = false; - chorusSendTouched = false; - - addKnob(CTRL_VARIATION_SEND, KNOB_VAR_SEND, tr("VariationSend"), tr("Var"), SLOT(ctrlChanged(double,int)), true, 1); - addKnob(CTRL_REVERB_SEND, KNOB_REV_SEND, tr("ReverbSend"), tr("Rev"), SLOT(ctrlChanged(double,int)), true, 3); - addKnob(CTRL_CHORUS_SEND, KNOB_CHOR_SEND, tr("ChorusSend"), tr("Cho"), SLOT(ctrlChanged(double,int)), true, 5); - - //--------------------------------------------------- - // slider, label, meter - //--------------------------------------------------- - - slider = new Awl::MidiMeterSlider(this); - slider->setId(CTRL_VOLUME); - slider->setFixedWidth(40); - grid->addWidget(slider, 7, 0, 1, 2, Qt::AlignRight); - - sl = new Awl::MidiVolEntry(this); - sl->setId(CTRL_VOLUME); -// sl->setFont(config.fonts[1]); - sl->setFixedHeight(entrySize.height()); - - connect(slider, SIGNAL(valueChanged(double,int)), SLOT(ctrlChanged(double, int))); - connect(slider, SIGNAL(sliderPressed(int)), SLOT(sliderPressed(int))); - connect(slider, SIGNAL(sliderReleased(int)), SLOT(sliderReleased(int))); - connect(sl, SIGNAL(valueChanged(double,int)), SLOT(ctrlChanged(double, int))); - grid->addWidget(sl, 8, 0, 1, 2); - - //--------------------------------------------------- - // pan, balance - //--------------------------------------------------- - - addKnob(CTRL_PANPOT, KNOB_PAN, tr("Pan/Balance"), tr("Pan"), SLOT(ctrlChanged(double,int)), true, 9); - - //--------------------------------------------------- - // --- record - // mute, solo - //--------------------------------------------------- - - SimpleButton* monitor = newMonitorButton(); - monitor->setFixedHeight(BUTTON_HEIGHT); - monitor->setChecked(track->monitor()); - connect(monitor, SIGNAL(clicked(bool)), SLOT(monitorToggled(bool))); - connect(t, SIGNAL(monitorChanged(bool)), monitor, SLOT(setChecked(bool))); - - SimpleButton* record = newRecordButton(); - record->setFixedHeight(BUTTON_HEIGHT); - record->setChecked(track->recordFlag()); - connect(record, SIGNAL(clicked(bool)), SLOT(recordToggled(bool))); - connect(t, SIGNAL(recordChanged(bool)), record, SLOT(setChecked(bool))); - - mute = newMuteButton(); - mute->setChecked(track->isMute()); - mute->setFixedHeight(BUTTON_HEIGHT); - connect(mute, SIGNAL(clicked(bool)), SLOT(muteToggled(bool))); - - solo = newSoloButton(); - solo->setFixedHeight(BUTTON_HEIGHT); - solo->setChecked(track->solo()); - connect(solo, SIGNAL(clicked(bool)), SLOT(soloToggled(bool))); - - grid->addWidget(monitor, 11, 0); - grid->addWidget(record, 11, 1); - grid->addWidget(mute, 12, 0); - grid->addWidget(solo, 12, 1); - - //--------------------------------------------------- - // automation mode - //--------------------------------------------------- - - addAutomationButtons(13); - - //--------------------------------------------------- - // routing - //--------------------------------------------------- - - iR = newInRouteButton(); - grid->addWidget(iR, 14, 0); - connect(iR->menu(), SIGNAL(aboutToShow()), SLOT(iRouteShow())); - connect(iR->menu(), SIGNAL(aboutToHide()), SLOT(iRouteHide())); - connect(iR->menu(), SIGNAL(triggered(QAction*)), song, SLOT(routeChanged(QAction*))); - - oR = newOutRouteButton(); - grid->addWidget(oR, 14, 1); - connect(oR->menu(), SIGNAL(aboutToShow()), SLOT(oRouteShow())); - connect(oR->menu(), SIGNAL(aboutToHide()), SLOT(oRouteHide())); - connect(oR->menu(), SIGNAL(triggered(QAction*)), song, SLOT(routeChanged(QAction*))); - - connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int))); - connect(track, SIGNAL(muteChanged(bool)), mute, SLOT(setChecked(bool))); - connect(track, SIGNAL(soloChanged(bool)), solo, SLOT(setChecked(bool))); - connect(track, SIGNAL(autoReadChanged(bool)), SLOT(autoChanged())); - connect(track, SIGNAL(autoWriteChanged(bool)), SLOT(autoChanged())); - connect(track, SIGNAL(controllerChanged(int)), SLOT(controllerChanged(int))); - autoChanged(); - controllerChanged(CTRL_VOLUME); - controllerChanged(CTRL_PANPOT); - controllerChanged(CTRL_VARIATION_SEND); - controllerChanged(CTRL_REVERB_SEND); - controllerChanged(CTRL_CHORUS_SEND); - } - -//--------------------------------------------------------- -// iRouteHide -//--------------------------------------------------------- - -void MidiStrip::iRouteHide() - { - // dont leave the menu if SHIFT is pressed; this allows - // for fast selecting of more than one input source - // - if (qApp->keyboardModifiers() & Qt::ShiftModifier) { - iR->menu()->show(); - } - } - -//--------------------------------------------------------- -// oRouteHide -//--------------------------------------------------------- - -void MidiStrip::oRouteHide() - { - // dont leave the menu if SHIFT is pressed; this allows - // for fast selecting of more than one input source - // - if (qApp->keyboardModifiers() & Qt::ShiftModifier) { - oR->menu()->show(); - } - } - -//--------------------------------------------------------- -// songChanged -//--------------------------------------------------------- - -void MidiStrip::songChanged(int val) - { - if (val & SC_TRACK_MODIFIED) - updateLabel(); - } - -//--------------------------------------------------------- -// heartBeat -//--------------------------------------------------------- - -void MidiStrip::heartBeat() - { - double a = track->meter(0); // fast_log10(track->meter(0)) * .2f; - slider->setMeterVal(a * 0.008); - track->setMeter(0, a * 0.8); // hack - } - -//--------------------------------------------------------- -// controllerChanged -//--------------------------------------------------------- - -void MidiStrip::controllerChanged(int id) - { - CVal cv = track->ctrlVal(id); - double val = double(cv.i); - - switch (id) { - case CTRL_VOLUME: - if (!volumeTouched) - slider->setValue(val); - sl->setValue(val); - break; - case CTRL_PANPOT: - if (!panTouched) - controller[KNOB_PAN].knob->setValue(val); - controller[KNOB_PAN].dl->setValue(val); - break; - case CTRL_VARIATION_SEND: - if (!variSendTouched) - controller[KNOB_VAR_SEND].knob->setValue(val); - controller[KNOB_VAR_SEND].dl->setValue(val); - break; - case CTRL_REVERB_SEND: - if (!reverbSendTouched) - controller[KNOB_REV_SEND].knob->setValue(val); - controller[KNOB_REV_SEND].dl->setValue(val); - break; - case CTRL_CHORUS_SEND: - if (!chorusSendTouched) - controller[KNOB_CHOR_SEND].knob->setValue(val); - controller[KNOB_CHOR_SEND].dl->setValue(val); - break; - } - } - -//--------------------------------------------------------- -// ctrlChanged -// called when user changes controller -//--------------------------------------------------------- - -void MidiStrip::ctrlChanged(double val, int num) - { - int ival = int(val); - CVal cval; - cval.i = ival; - song->setControllerVal(track, num, cval); - } - -//--------------------------------------------------------- -// sliderPressed -//--------------------------------------------------------- - -void MidiStrip::sliderPressed(int id) - { - switch (id) { - case CTRL_VOLUME: volumeTouched = true; break; - case CTRL_PANPOT: panTouched = true; break; - case CTRL_VARIATION_SEND: variSendTouched = true; break; - case CTRL_REVERB_SEND: reverbSendTouched = true; break; - case CTRL_CHORUS_SEND: chorusSendTouched = true; break; - } - track->startAutoRecord(id); - } - -//--------------------------------------------------------- -// sliderReleased -//--------------------------------------------------------- - -void MidiStrip::sliderReleased(int id) - { - switch (id) { - case CTRL_VOLUME: volumeTouched = false; break; - case CTRL_PANPOT: panTouched = false; break; - case CTRL_VARIATION_SEND: variSendTouched = false; break; - case CTRL_REVERB_SEND: reverbSendTouched = false; break; - case CTRL_CHORUS_SEND: chorusSendTouched = false; break; - } - track->stopAutoRecord(id); - } - -//--------------------------------------------------------- -// muteToggled -//--------------------------------------------------------- - -void MidiStrip::muteToggled(bool val) - { - song->setMute(track, val); - } - -//--------------------------------------------------------- -// soloToggled -//--------------------------------------------------------- - -void MidiStrip::soloToggled(bool val) - { - song->setSolo(track, val); - } - -//--------------------------------------------------------- -// autoChanged -//--------------------------------------------------------- - -void MidiStrip::autoChanged() - { - bool ar = track->autoRead(); - bool aw = track->autoWrite(); - - // controller are enabled if - // autoRead is off - // autoRead and autoWrite are on (touch mode) - - bool ec = !ar || (ar && aw); - for (unsigned i = 0; i < sizeof(controller)/sizeof(*controller); ++i) { - controller[i].knob->setEnabled(ec); - controller[i].dl->setEnabled(ec); - } - slider->setEnabled(ec); - sl->setEnabled(ec); - } - -//--------------------------------------------------------- -// autoReadToggled -//--------------------------------------------------------- - -void MidiStrip::autoReadToggled(bool val) - { - song->setAutoRead(track, val); - } - -//--------------------------------------------------------- -// autoWriteToggled -//--------------------------------------------------------- - -void MidiStrip::autoWriteToggled(bool val) - { - song->setAutoWrite(track, val); - } - -//--------------------------------------------------------- -// iRouteShow -//--------------------------------------------------------- - -void MidiStrip::iRouteShow() - { - QMenu* pup = iR->menu(); - pup->clear(); - pup->addSeparator()->setText(tr("Tracks")); - addMidiInPorts(pup, track, -1); // add midi inputs to menu - } - -//--------------------------------------------------------- -// oRouteShow -//--------------------------------------------------------- - -void MidiStrip::oRouteShow() - { - QMenu* pup = oR->menu(); - pup->clear(); - pup->addSeparator()->setText(tr("OutputPorts")); - addMidiOutPorts(pup, track, -1); - addSyntiPorts(pup, track, -1); - } - -//--------------------------------------------------------- -// monitorToggled -//--------------------------------------------------------- - -void MidiStrip::monitorToggled(bool val) - { - song->setMonitor(track, val); - } - -//--------------------------------------------------------- -// recordToggled -//--------------------------------------------------------- - -void MidiStrip::recordToggled(bool val) - { - song->setRecordFlag(track, !val); - } - -//--------------------------------------------------------- -// MidiOutPortStrip -//--------------------------------------------------------- - -MidiOutPortStrip::MidiOutPortStrip(Mixer* m, MidiOutPort* t, bool align) - : Strip(m, t, align) - { - //--------------------------------------------------- - // plugin rack - //--------------------------------------------------- - - MidiRack* rack = new MidiRack(this, t); - rack->setFixedHeight(rack->sizeHint().height()+2); - grid->addWidget(rack, 1, 0, 1, 2); - - - if (_align) - grid->setRowMinimumHeight(2, STRIP_WIDTH/2); - - volumeTouched = false; - - //--------------------------------------------------- - // slider, label, meter - //--------------------------------------------------- - - slider = new Awl::MidiMeterSlider(this); - slider->setId(CTRL_MASTER_VOLUME); - slider->setRange(0.0, 1024*16.0); - slider->setFixedWidth(40); - grid->addWidget(slider, 3, 0, 1, 2, Qt::AlignRight); - - sl = new Awl::MidiVolEntry(this); - sl->setId(CTRL_MASTER_VOLUME); - sl->setMax(128 * 128 - 1); -// sl->setFont(config.fonts[1]); - sl->setFixedHeight(entrySize.height()); - - controllerChanged(CTRL_MASTER_VOLUME); - - connect(slider, SIGNAL(valueChanged(double,int)), SLOT(ctrlChanged(double, int))); - connect(slider, SIGNAL(sliderPressed(int)), SLOT(sliderPressed(int))); - connect(slider, SIGNAL(sliderReleased(int)), SLOT(sliderReleased(int))); - connect(sl, SIGNAL(valueChanged(double,int)), SLOT(ctrlChanged(double, int))); - grid->addWidget(sl, 4, 0, 1, 2); - - //--------------------------------------------------- - // pan, balance - //--------------------------------------------------- - - if (_align) - grid->setRowMinimumHeight(5, entrySize.height() * 2); - - //--------------------------------------------------- - // sync - // mute, solo - //--------------------------------------------------- - - sync = newSyncButton(); - sync->setFixedHeight(BUTTON_HEIGHT); - sync->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); - sync->setChecked(((MidiOutPort*)track)->sendSync()); - grid->addWidget(sync, 6, 0, 1, 2); - connect(sync, SIGNAL(clicked(bool)), SLOT(syncToggled(bool))); - connect(track, SIGNAL(sendSyncChanged(bool)), sync, SLOT(setChecked(bool))); - - mute = newMuteButton(); - mute->setChecked(track->isMute()); - mute->setFixedHeight(BUTTON_HEIGHT); - connect(mute, SIGNAL(clicked(bool)), SLOT(muteToggled(bool))); - - solo = newSoloButton(); - solo->setFixedHeight(BUTTON_HEIGHT); - solo->setChecked(track->solo()); - connect(solo, SIGNAL(clicked(bool)), SLOT(soloToggled(bool))); - - grid->addWidget(mute, 7, 0); - grid->addWidget(solo, 7, 1); - - //--------------------------------------------------- - // automation mode - //--------------------------------------------------- - - addAutomationButtons(8); - - //--------------------------------------------------- - // output routing - //--------------------------------------------------- - - iR = newInRouteButton(); - grid->addWidget(iR, 9, 0); - connect(iR->menu(), SIGNAL(aboutToShow()), SLOT(iRouteShow())); - connect(iR->menu(), SIGNAL(triggered(QAction*)), song, SLOT(routeChanged(QAction*))); - - oR = newOutRouteButton(); - grid->addWidget(oR, 9, 1); - connect(oR->menu(), SIGNAL(aboutToShow()), SLOT(oRouteShow())); - connect(oR->menu(), SIGNAL(triggered(QAction*)), song, SLOT(routeChanged(QAction*))); - - connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int))); - connect(track, SIGNAL(muteChanged(bool)), mute, SLOT(setChecked(bool))); - connect(track, SIGNAL(soloChanged(bool)), solo, SLOT(setChecked(bool))); - connect(track, SIGNAL(autoReadChanged(bool)), SLOT(autoChanged())); - connect(track, SIGNAL(autoWriteChanged(bool)), SLOT(autoChanged())); - autoChanged(); - controllerChanged(CTRL_MASTER_VOLUME); - } - -//--------------------------------------------------------- -// songChanged -//--------------------------------------------------------- - -void MidiOutPortStrip::songChanged(int val) - { - if (val & SC_TRACK_MODIFIED) - updateLabel(); - } - -//--------------------------------------------------------- -// heartBeat -//--------------------------------------------------------- - -void MidiOutPortStrip::heartBeat() - { - double a = track->meter(0); // fast_log10(track->meter(0)) * .2f; - slider->setMeterVal(a * 0.008); - track->setMeter(0, a * 0.8); // hack - } - -//--------------------------------------------------------- -// ctrlChanged -//--------------------------------------------------------- - -void MidiOutPortStrip::ctrlChanged(double val, int num) - { - int ival = int(val); - CVal cval; - cval.i = ival; - song->setControllerVal(track, num, cval); - } - -//--------------------------------------------------------- -// sliderPressed -//--------------------------------------------------------- - -void MidiOutPortStrip::sliderPressed(int id) - { - switch (id) { - case CTRL_MASTER_VOLUME: volumeTouched = true; break; - } - track->startAutoRecord(id); - } - -//--------------------------------------------------------- -// sliderReleased -//--------------------------------------------------------- - -void MidiOutPortStrip::sliderReleased(int id) - { - switch (id) { - case CTRL_MASTER_VOLUME: volumeTouched = false; break; - } - track->stopAutoRecord(id); - } - -//--------------------------------------------------------- -// muteToggled -//--------------------------------------------------------- - -void MidiOutPortStrip::muteToggled(bool val) - { - song->setMute(track, val); - } - -//--------------------------------------------------------- -// soloToggled -//--------------------------------------------------------- - -void MidiOutPortStrip::soloToggled(bool val) - { - song->setSolo(track, val); - } - -//--------------------------------------------------------- -// autoChanged -//--------------------------------------------------------- - -void MidiOutPortStrip::autoChanged() - { - bool ar = track->autoRead(); - bool aw = track->autoWrite(); - - // controller are enabled if - // autoRead is off - // autoRead and autoWrite are on (touch mode) - - bool ec = !ar || (ar && aw); - slider->setEnabled(ec); - sl->setEnabled(ec); - } - -//--------------------------------------------------------- -// autoReadToggled -//--------------------------------------------------------- - -void MidiOutPortStrip::autoReadToggled(bool val) - { - song->setAutoRead(track, val); - } - -//--------------------------------------------------------- -// autoWriteToggled -//--------------------------------------------------------- - -void MidiOutPortStrip::autoWriteToggled(bool val) - { - song->setAutoWrite(track, val); - } - -//--------------------------------------------------------- -// controllerChanged -//--------------------------------------------------------- - -void MidiOutPortStrip::controllerChanged(int id) - { - if (id == CTRL_MASTER_VOLUME) { - double val = double(track->ctrlVal(id).i); - if (!volumeTouched) - slider->setValue(val); - sl->setValue(val); - } - } - -//--------------------------------------------------------- -// iRouteShow -//--------------------------------------------------------- - -void MidiOutPortStrip::iRouteShow() - { - QMenu* pup = iR->menu(); - pup->clear(); - pup->addSeparator()->setText(tr("MidiChannel")); - - for (int ch = 0; ch < MIDI_CHANNELS; ++ch) { - QMenu* m = pup->addMenu(QString("Channel %1").arg(ch+1)); - addMidiTracks(m, track, ch, true); - addMidiInPorts(m, track, ch); - } - } - -//--------------------------------------------------------- -// oRouteShow -//--------------------------------------------------------- - -void MidiOutPortStrip::oRouteShow() - { - QMenu* pup = oR->menu(); - pup->clear(); - RouteList* orl = track->outRoutes(); - - QList ol; - // - // add JACK midi ports to list - // - ol = audioDriver->inputPorts(true); - foreach (PortName ip, ol) { - QAction* oa = pup->addAction(ip.name); - oa->setCheckable(true); - RouteNode dst(ip.port, RouteNode::JACKMIDIPORT); - Route r = Route(RouteNode(track), dst); - oa->setData(QVariant::fromValue(r)); - oa->setChecked(orl->indexOf(r) != -1); - } - } - -//--------------------------------------------------------- -// syncToggled -//--------------------------------------------------------- - -void MidiOutPortStrip::syncToggled(bool val) const - { - ((MidiOutPort*)track)->setSendSync(val); - } - -//--------------------------------------------------------- -// MidiInPortStrip -//--------------------------------------------------------- - -MidiInPortStrip::MidiInPortStrip(Mixer* m, MidiInPort* t, bool align) - : Strip(m, t, align) - { - //--------------------------------------------------- - // plugin rack - //--------------------------------------------------- - - MidiRack* rack = new MidiRack(this, t); - rack->setFixedHeight(rack->sizeHint().height()+2); - grid->addWidget(rack, 1, 0, 1, 2); - - //--------------------------------------------------- - // input activity - //--------------------------------------------------- - - grid->setRowStretch(2, 100); - - QGridLayout* ag = new QGridLayout; - ag->setMargin(4); - ag->setSpacing(1); - QSvgRenderer sr; - QPainter painter; - - sr.load(QString(":/xpm/activeon.svg")); - QSize aSize(sr.defaultSize()); - activityOn = new QPixmap(aSize); - activityOn->fill(Qt::transparent); - painter.begin(activityOn); - sr.render(&painter); - painter.end(); - - sr.load(QString(":/xpm/activeoff.svg")); - activityOff = new QPixmap(aSize); - activityOff->fill(Qt::transparent); - painter.begin(activityOff); - sr.render(&painter); - painter.end(); - - for (int ch = MIDI_CHANNELS-1; ch >= 0; --ch) { - QLabel* l = new QLabel(QString("%1").arg(ch+1)); - l->setObjectName("midiChannelLabel"); - ag->addWidget(l, ch, 0, Qt::AlignCenter); - channelActivity[ch] = new QLabel; - ag->addWidget(channelActivity[ch], ch, 1, Qt::AlignCenter); - channelActivity[ch]->setPixmap(*activityOff); - activity[ch] = 0; - } - grid->addLayout(ag, 3, 0, 2, Qt::AlignHCenter); - - if (_align) - grid->setRowMinimumHeight(4, BUTTON_HEIGHT); - - //--------------------------------------------------- - // mute, solo - // or - // record, mixdownfile - //--------------------------------------------------- - - mute = newMuteButton(); - mute->setChecked(track->isMute()); - mute->setFixedHeight(BUTTON_HEIGHT); - connect(mute, SIGNAL(clicked(bool)), SLOT(muteToggled(bool))); - - solo = newSoloButton(); - solo->setFixedHeight(BUTTON_HEIGHT); - solo->setChecked(track->solo()); - connect(solo, SIGNAL(clicked(bool)), SLOT(soloToggled(bool))); - - grid->addWidget(mute, 5, 0); - grid->addWidget(solo, 5, 1); - - //--------------------------------------------------- - // output routing - //--------------------------------------------------- - - if (_align) - grid->setRowMinimumHeight(6, BUTTON_HEIGHT); - - iR = newInRouteButton(); - connect(iR->menu(), SIGNAL(aboutToShow()), SLOT(iRouteShow())); - connect(iR->menu(), SIGNAL(triggered(QAction*)), song, SLOT(routeChanged(QAction*))); - - oR = newOutRouteButton(); - connect(oR->menu(), SIGNAL(aboutToShow()), SLOT(oRouteShow())); - connect(oR->menu(), SIGNAL(triggered(QAction*)), song, SLOT(routeChanged(QAction*))); - - grid->addWidget(iR, 7, 0); - grid->addWidget(oR, 7, 1); - - connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int))); - connect(track, SIGNAL(muteChanged(bool)), mute, SLOT(setChecked(bool))); - connect(track, SIGNAL(soloChanged(bool)), solo, SLOT(setChecked(bool))); - } - -//--------------------------------------------------------- -// songChanged -//--------------------------------------------------------- - -void MidiInPortStrip::songChanged(int val) - { - if (val & SC_TRACK_MODIFIED) - updateLabel(); - } - -//--------------------------------------------------------- -// heartBeat -//--------------------------------------------------------- - -void MidiInPortStrip::heartBeat() - { - for (int i = 0; i < MIDI_CHANNELS; ++i) { - bool isActive = inport()->checkActivity(i); - if (activity[i] != isActive) { - channelActivity[i]->setPixmap(isActive ? *activityOn : *activityOff); - activity[i] = isActive; - } - } - } - -//--------------------------------------------------------- -// muteToggled -//--------------------------------------------------------- - -void MidiInPortStrip::muteToggled(bool val) - { - song->setMute(track, val); - } - -//--------------------------------------------------------- -// soloToggled -//--------------------------------------------------------- - -void MidiInPortStrip::soloToggled(bool val) - { - song->setSolo(track, val); - } - -//--------------------------------------------------------- -// iRouteShow -//--------------------------------------------------------- - -void MidiInPortStrip::iRouteShow() - { - QMenu* pup = iR->menu(); - pup->clear(); - - RouteList* irl = track->inRoutes(); - - QList ol; - // - // add JACK midi ports to list - // - ol = audioDriver->outputPorts(true); - foreach (PortName ip, ol) { - QAction* action = pup->addAction(ip.name); - action->setCheckable(true); - RouteNode src(ip.port, RouteNode::JACKMIDIPORT); - Route r = Route(src, RouteNode(track)); - action->setData(QVariant::fromValue(r)); - action->setChecked(irl->indexOf(r) != -1); - } - } - -//--------------------------------------------------------- -// oRouteShow -//--------------------------------------------------------- - -void MidiInPortStrip::oRouteShow() - { - QMenu* pup = oR->menu(); - pup->clear(); - pup->addSeparator()->setText(tr("MidiChannel")); - - for (int ch = 0; ch < MIDI_CHANNELS; ++ch) { - QMenu* m = pup->addMenu(QString("Channel %1").arg(ch+1)); - addMidiTracks(m, track, ch, false); - addSyntiPorts(m, track, ch); - addMidiOutPorts(m, track, ch); - } - } - -//--------------------------------------------------------- -// MidiSyntiStrip -//--------------------------------------------------------- - -MidiSyntiStrip::MidiSyntiStrip(Mixer* m, MidiSynti* t, bool align) - : Strip(m, t, align) - { - if (_align) - grid->setRowMinimumHeight(1, STRIP_WIDTH/2 * 3); - - volumeTouched = false; - - //--------------------------------------------------- - // slider, label, meter - //--------------------------------------------------- - - slider = new Awl::MidiMeterSlider(this); - slider->setId(CTRL_MASTER_VOLUME); - slider->setRange(0.0, 1024*16.0); - slider->setFixedWidth(40); - grid->addWidget(slider, 2, 0, 1, 2, Qt::AlignRight); - - sl = new Awl::MidiVolEntry(this); - sl->setId(CTRL_MASTER_VOLUME); -// sl->setFont(config.fonts[1]); - sl->setFixedHeight(entrySize.height()); - - connect(slider, SIGNAL(valueChanged(double,int)), SLOT(ctrlChanged(double, int))); - connect(slider, SIGNAL(sliderPressed(int)), SLOT(sliderPressed(int))); - connect(slider, SIGNAL(sliderReleased(int)), SLOT(sliderReleased(int))); - connect(sl, SIGNAL(valueChanged(double,int)), SLOT(ctrlChanged(double, int))); - grid->addWidget(sl, 3, 0, 1, 2); - - //--------------------------------------------------- - // pan, balance - //--------------------------------------------------- - - if (_align) - grid->setRowMinimumHeight(4, STRIP_WIDTH); - - //--------------------------------------------------- - // sync - // mute, solo - //--------------------------------------------------- - - mute = newMuteButton(); - mute->setChecked(track->isMute()); - mute->setFixedHeight(BUTTON_HEIGHT); - connect(mute, SIGNAL(clicked(bool)), SLOT(muteToggled(bool))); - - solo = newSoloButton(); - solo->setFixedHeight(BUTTON_HEIGHT); - solo->setChecked(track->solo()); - connect(solo, SIGNAL(clicked(bool)), SLOT(soloToggled(bool))); - - grid->addWidget(mute, 5, 0); - grid->addWidget(solo, 5, 1); - - //--------------------------------------------------- - // automation mode - //--------------------------------------------------- - - addAutomationButtons(6); - - //--------------------------------------------------- - // output routing - //--------------------------------------------------- - - iR = newInRouteButton(); - grid->addWidget(iR, 7, 0); - connect(iR->menu(), SIGNAL(aboutToShow()), SLOT(iRouteShow())); - connect(iR->menu(), SIGNAL(triggered(QAction*)), song, SLOT(routeChanged(QAction*))); - - oR = newOutRouteButton(); - grid->addWidget(oR, 7, 1); - connect(oR->menu(), SIGNAL(aboutToShow()), SLOT(oRouteShow())); - connect(oR->menu(), SIGNAL(triggered(QAction*)), song, SLOT(routeChanged(QAction*))); - - connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int))); - connect(track, SIGNAL(muteChanged(bool)), mute, SLOT(setChecked(bool))); - connect(track, SIGNAL(soloChanged(bool)), solo, SLOT(setChecked(bool))); - connect(track, SIGNAL(autoReadChanged(bool)), SLOT(autoChanged())); - connect(track, SIGNAL(autoWriteChanged(bool)), SLOT(autoChanged())); - autoChanged(); - } - -//--------------------------------------------------------- -// songChanged -//--------------------------------------------------------- - -void MidiSyntiStrip::songChanged(int val) - { - if (val & SC_TRACK_MODIFIED) - updateLabel(); - } - -//--------------------------------------------------------- -// heartBeat -//--------------------------------------------------------- - -void MidiSyntiStrip::heartBeat() - { - double a = track->meter(0); // fast_log10(track->meter(0)) * .2f; - slider->setMeterVal(a * 0.008); - track->setMeter(0, a * 0.8); // hack - } - -//--------------------------------------------------------- -// ctrlChanged -//--------------------------------------------------------- - -void MidiSyntiStrip::ctrlChanged(double val, int num) - { - int ival = int(val); - CVal cval; - cval.i = ival; - song->setControllerVal(track, num, cval); - } - -//--------------------------------------------------------- -// sliderPressed -//--------------------------------------------------------- - -void MidiSyntiStrip::sliderPressed(int id) - { - switch (id) { - case CTRL_MASTER_VOLUME: volumeTouched = true; break; - } - track->startAutoRecord(id); - } - -//--------------------------------------------------------- -// sliderReleased -//--------------------------------------------------------- - -void MidiSyntiStrip::sliderReleased(int id) - { - switch (id) { - case CTRL_MASTER_VOLUME: volumeTouched = false; break; - } - track->stopAutoRecord(id); - } - -//--------------------------------------------------------- -// muteToggled -//--------------------------------------------------------- - -void MidiSyntiStrip::muteToggled(bool val) - { - song->setMute(track, val); - } - -//--------------------------------------------------------- -// soloToggled -//--------------------------------------------------------- - -void MidiSyntiStrip::soloToggled(bool val) - { - song->setSolo(track, val); - } - -//--------------------------------------------------------- -// autoChanged -//--------------------------------------------------------- - -void MidiSyntiStrip::autoChanged() - { - bool ar = track->autoRead(); - bool aw = track->autoWrite(); - - // controller are enabled if - // autoRead is off - // autoRead and autoWrite are on (touch mode) - - bool ec = !ar || (ar && aw); - slider->setEnabled(ec); - sl->setEnabled(ec); - } - -//--------------------------------------------------------- -// autoReadToggled -//--------------------------------------------------------- - -void MidiSyntiStrip::autoReadToggled(bool val) - { - song->setAutoRead(track, val); - } - -//--------------------------------------------------------- -// autoWriteToggled -//--------------------------------------------------------- - -void MidiSyntiStrip::autoWriteToggled(bool val) - { - song->setAutoWrite(track, val); - } - -//--------------------------------------------------------- -// controllerChanged -//--------------------------------------------------------- - -void MidiSyntiStrip::controllerChanged(int id) - { - if (id == CTRL_MASTER_VOLUME) { - double val = double(track->ctrlVal(id).i); - if (!volumeTouched) - slider->setValue(val); - sl->setValue(val); - } - } - -//--------------------------------------------------------- -// oRouteShow -//--------------------------------------------------------- - -void MidiSyntiStrip::oRouteShow() - { - QMenu* pup = oR->menu(); - pup->clear(); - pup->addSeparator()->setText(tr("OutputPorts")); - - MidiOutPortList* mpl = song->midiOutPorts(); - int pn = 0; - for (iMidiOutPort i = mpl->begin(); i != mpl->end(); ++i, ++pn) { - MidiOutPort* op = *i; - QMenu* m = pup->addMenu(op->name()); - m->addSeparator()->setText(tr("Channel")); -#if 0 //TODO - for (int channel = 0; channel < MIDI_CHANNELS; ++channel) { - QString s; - s.setNum(channel+1); - QAction* action = m->addAction(s); - MidiChannel* mc = op->channel(channel); - Route r(mc, -1, Route::TRACK); - action->setData(QVariant::fromValue(r)); - action->setCheckable(true); - - for (iRoute ir = orl->begin(); ir != orl->end(); ++ir) { - if (r == *ir) { - action->setChecked(true); - break; - } - } - } -#endif - } - } - -//--------------------------------------------------------- -// iRouteShow -//--------------------------------------------------------- - -void MidiSyntiStrip::iRouteShow() - { - QMenu* pup = oR->menu(); - pup->clear(); - - pup->addSeparator()->setText(tr("Input Ports")); - MidiOutPort* t = (MidiOutPort*)track; - - for (int ch = 0; ch < MIDI_CHANNELS; ++ch) { - QMenu* m = pup->addMenu(QString("Channel %1").arg(ch+1)); - addMidiTracks(m, t, ch, false); - addMidiInPorts(m, t, ch); - } - } diff --git a/muse/muse/mixer/mstrip.h b/muse/muse/mixer/mstrip.h deleted file mode 100644 index 4c3269de..00000000 --- a/muse/muse/mixer/mstrip.h +++ /dev/null @@ -1,192 +0,0 @@ -//============================================================================= -// MusE -// Linux Music Editor -// $Id:$ -// -// Copyright (C) 2002-2006 by Werner Schweer and others -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2. -// -// 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., 675 Mass Ave, Cambridge, MA 02139, USA. -//============================================================================= - -#ifndef __MSTRIP_H__ -#define __MSTRIP_H__ - -#include "strip.h" - -namespace Awl { - class MidiMeterSlider; - class MidiMeter; - class FloatEntry; - class MidiVolEntry; - class Knob; - }; - -class MidiTrack; -class MidiOutPort; -class MidiInPort; -class MidiChannel; -class MidiSynti; - -//--------------------------------------------------------- -// MidiStrip -//--------------------------------------------------------- - -class MidiStrip : public Strip { - Q_OBJECT - - Awl::MidiMeterSlider* slider; - Awl::MidiVolEntry* sl; - QToolButton* iR; - QToolButton* oR; - - struct KNOB { - Awl::Knob* knob; - Awl::FloatEntry* dl; - QLabel* lb; - } controller[4]; // pan variation reverb chorus - - bool volumeTouched; - bool panTouched; - bool reverbSendTouched; - bool variSendTouched; - bool chorusSendTouched; - - void addKnob(int ctrl, int idx, const QString&, const QString&, const char*, bool, int row); - - private slots: - virtual void controllerChanged(int id); - void ctrlChanged(double val, int num); - void muteToggled(bool); - void soloToggled(bool); - void autoChanged(); - void sliderPressed(int); - void sliderReleased(int); - void autoReadToggled(bool); - void autoWriteToggled(bool); - void iRouteShow(); - void iRouteHide(); - void oRouteShow(); - void oRouteHide(); - void recordToggled(bool); - void monitorToggled(bool); - - public slots: - virtual void songChanged(int); - - public: - MidiStrip(Mixer*, MidiTrack*, bool align = true); - virtual void heartBeat(); - }; - -//--------------------------------------------------------- -// MidiOutPortStrip -//--------------------------------------------------------- - -class MidiOutPortStrip : public Strip { - Q_OBJECT - - Awl::MidiMeterSlider* slider; - Awl::MidiVolEntry* sl; - QToolButton* oR; - QToolButton* iR; - SimpleButton* sync; - - bool volumeTouched; - - private slots: - virtual void controllerChanged(int id); - void ctrlChanged(double val, int num); - void muteToggled(bool); - void soloToggled(bool); - void autoChanged(); - void sliderPressed(int); - void sliderReleased(int); - void autoReadToggled(bool); - void autoWriteToggled(bool); - void iRouteShow(); - void oRouteShow(); - void syncToggled(bool) const; - - public slots: - virtual void songChanged(int); - - public: - MidiOutPortStrip(Mixer*, MidiOutPort*, bool align = true); - virtual void heartBeat(); - }; - -//--------------------------------------------------------- -// MidiSyntiStrip -//--------------------------------------------------------- - -class MidiSyntiStrip : public Strip { - Q_OBJECT - - Awl::MidiMeterSlider* slider; - Awl::MidiVolEntry* sl; - QToolButton* iR; - QToolButton* oR; - - bool volumeTouched; - - private slots: - virtual void controllerChanged(int id); - void ctrlChanged(double val, int num); - void muteToggled(bool); - void soloToggled(bool); - void autoChanged(); - void sliderPressed(int); - void sliderReleased(int); - void autoReadToggled(bool); - void autoWriteToggled(bool); - void iRouteShow(); - void oRouteShow(); - - public slots: - virtual void songChanged(int); - - public: - MidiSyntiStrip(Mixer*, MidiSynti*, bool align = true); - virtual void heartBeat(); - }; - -//--------------------------------------------------------- -// MidiInPortStrip -//--------------------------------------------------------- - -class MidiInPortStrip : public Strip { - Q_OBJECT - - bool activity[MIDI_CHANNELS]; - QPixmap* activityOn; - QPixmap* activityOff; - QLabel* channelActivity[MIDI_CHANNELS]; - QToolButton* iR; - QToolButton* oR; - MidiInPort* inport() const { return (MidiInPort*)track; } - - private slots: - void muteToggled(bool); - void soloToggled(bool); - void iRouteShow(); - void oRouteShow(); - - public slots: - virtual void songChanged(int); - - public: - MidiInPortStrip(Mixer*, MidiInPort*, bool align = true); - virtual void heartBeat(); - }; - -#endif diff --git a/muse/muse/mixer/rack.cpp b/muse/muse/mixer/rack.cpp deleted file mode 100644 index dbd76804..00000000 --- a/muse/muse/mixer/rack.cpp +++ /dev/null @@ -1,445 +0,0 @@ -//============================================================================= -// MusE -// Linux Music Editor -// $Id:$ -// -// Copyright (C) 2002-2006 by Werner Schweer and others -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2. -// -// 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., 675 Mass Ave, Cambridge, MA 02139, USA. -//============================================================================= - -#include "rack.h" -#include "song.h" -#include "audio.h" -#include "icons.h" -#include "gconfig.h" -#include "pipeline.h" -#include "auxplugin.h" -#include "plugingui.h" -#include "widgets/filedialog.h" -#include "muse.h" -#include "gui.h" - -static const int PipelineDepth = 4; - -//--------------------------------------------------------- -// EffectRack -//--------------------------------------------------------- - -EffectRack::EffectRack(QWidget* parent, AudioTrack* t, bool flag) - : QListWidget(parent) - { - setUniformItemSizes(true); - setAlternatingRowColors(true); - prefader = flag; - setAttribute(Qt::WA_DeleteOnClose, true); - verticalScrollBar()->setStyle(smallStyle); - - track = t; -// setFont(config.fonts[1]); - - setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); - - setSelectionMode(QAbstractItemView::SingleSelection); - songChanged(SC_RACK); // force update - connect(this, SIGNAL(itemDoubleClicked(QListWidgetItem*)), - this, SLOT(doubleClicked(QListWidgetItem*))); - connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int))); - setToolTip(tr("effect rack")); - setAcceptDrops(true); - } - -//--------------------------------------------------------- -// sizeHint -//--------------------------------------------------------- - -QSize EffectRack::sizeHint() const - { - QFontMetrics fm(font()); - int h = fm.lineSpacing() * PipelineDepth + 1; - return QSize(STRIP_WIDTH, h); - } - -//--------------------------------------------------------- -// songChanged -//--------------------------------------------------------- - -void EffectRack::songChanged(int typ) - { - if (!(typ & (SC_ROUTE | SC_RACK))) - return; - - clear(); - Pipeline* pipe = prefader ? track->prePipe() : track->postPipe(); - foreach (PluginI* plugin, *pipe) { - QListWidgetItem* item = new QListWidgetItem(this); - item->setText(plugin->name()); - // tooltip should only be set if name does not fit - // (is elided) - item->setToolTip(plugin->name()); - item->setBackgroundColor(plugin->on() ? Qt::white : Qt::gray); - } - } - -//--------------------------------------------------------- -// menuRequested -//--------------------------------------------------------- - -void EffectRack::contextMenuEvent(QContextMenuEvent* ev) - { - QPoint pt(ev->pos()); - QListWidgetItem* item = itemAt(pt); - - int idx = -1; - QString name; - Pipeline* pipe = prefader ? track->prePipe() : track->postPipe(); - - QMenu* menu = new QMenu; - QAction* upAction = menu->addAction(QIcon(*upIcon), tr("move up")); - QAction* downAction = menu->addAction(QIcon(*downIcon), tr("move down")); - QAction* removeAction = menu->addAction(tr("remove")); - menu->addSeparator(); - QAction* bypassAction = menu->addAction(tr("bypass")); - QAction* showAction = menu->addAction(tr("show gui")); - QAction* showCustomAction = menu->addAction(tr("show native gui")); - menu->addSeparator(); - QAction* newAction = menu->addAction(tr("New Plugin")); - QAction* auxAction = menu->addAction(tr("New Aux Send")); - - bypassAction->setCheckable(true); - showAction->setCheckable(true); - showCustomAction->setCheckable(true); - - if (!item) { - upAction->setEnabled(false); - downAction->setEnabled(false); - removeAction->setEnabled(false); - bypassAction->setEnabled(false); - showAction->setEnabled(false); - showCustomAction->setEnabled(false); - } - else { - idx = row(item); - upAction->setEnabled(idx != 0); - downAction->setEnabled(idx < pipe->size()-1); - idx = item->type(); - showCustomAction->setEnabled(pipe->hasNativeGui(idx)); - bypassAction->setEnabled(true); - showAction->setEnabled(true); - - bypassAction->setChecked(!pipe->isOn(idx)); - showAction->setChecked(pipe->guiVisible(idx)); - showCustomAction->setChecked(pipe->nativeGuiVisible(idx)); - } - if (track->type() != Track::WAVE && track->type() != Track::AUDIO_INPUT) - auxAction->setEnabled(false); - - QAction* sel = menu->exec(mapToGlobal(pt), newAction); - delete menu; - if (sel == 0) - return; - - if (sel == newAction) { - selectNew(); - return; - } - if (sel == removeAction) { - audio->msgAddPlugin(track, idx, 0, prefader); - } - else if (sel == bypassAction) { - bool flag = !pipe->isOn(idx); - pipe->setOn(idx, flag); - } - else if (sel == showAction) { - bool flag = !pipe->guiVisible(idx); - pipe->showGui(idx, flag); - } - else if (sel == showCustomAction) { - bool flag = !pipe->nativeGuiVisible(idx); - pipe->showNativeGui(idx, flag); - } - else if (sel == upAction) { - if (idx > 0) { - setCurrentRow(idx-1); - pipe->move(idx, true); - } - } - else if (sel == downAction) { - if (idx < (PipelineDepth-1)) { - setCurrentRow(idx+1); - pipe->move(idx, false); - } - } - else if (sel == auxAction) - addPlugin(auxPlugin); - song->update(SC_RACK); - } - -//--------------------------------------------------------- -// doubleClicked -// toggle gui and open requester if needed. -//--------------------------------------------------------- - -void EffectRack::doubleClicked(QListWidgetItem* it) - { - if (track == 0) - return; - int idx = row(it); - Pipeline* pipe = prefader ? track->prePipe() : track->postPipe(); - bool flag = !pipe->guiVisible(idx); - pipe->showGui(idx, flag); - } - -//--------------------------------------------------------- -// startDrag -//--------------------------------------------------------- - -void EffectRack::startDrag(int idx) - { - QString buffer; - AL::Xml xml(NULL); - xml.setString(&buffer); - Pipeline* pipe = prefader ? track->prePipe() : track->postPipe(); - if (pipe) { - if ((*pipe)[idx] != NULL) { - PluginI *plug = (*pipe)[idx]; - xml.header(); - xml.stag("muse version=\"1.0\""); - // header info - plug->writeConfiguration1(xml, prefader); // wC1 does not append endtag - // parameters - int noParams = plug->plugin()->parameter(); - for (int i=0;igetParameterName(i)); - fval.setNum(plug->param(i)); // wierd stuff to avoid localization - QString str=""; - xml.put(str.toLatin1().data()); - printf("%s\n",str.toLatin1().data()); - } - xml.etag("plugin"); - - xml.etag("muse"); - } - else { - //printf("no plugin!\n"); - return; - } - } - else { - //printf("no pipe!\n"); - return; - } - //printf("and i wish you were here: %s\n", xml.readAll().toLatin1().data()); - QByteArray xmldump = xml.readAll().toLatin1(); - //printf("xmldump=%s\n",xmldump.data()); - QDrag *drag = new QDrag(this); - QMimeData *mime = new QMimeData(); - mime->setData("text/x-muse-plugin", xmldump); - drag->setMimeData(mime); -/* Qt::DropAction dropAction =*/ drag->start(); - } - -//--------------------------------------------------------- -// startDrag -//--------------------------------------------------------- - -void EffectRack::dropEvent(QDropEvent *event) - { - // printf("drop!\n"); - QString text; - QListWidgetItem* i = itemAt( (event->pos()) ); - int idx = -1; - if (i) - idx = row(i); - - Pipeline* pipe = prefader ? track->prePipe() : track->postPipe(); - if (pipe) { - if (i) { - if(!QMessageBox::question(this, tr("Replace effect"),tr("Do you really want to replace the effect %1?").arg(pipe->name(idx)), - tr("&Yes"), tr("&No"), - QString::null, 0, 1 )) - { - audio->msgAddPlugin(track, idx, 0, prefader); - song->update(SC_RACK); - } - else { - printf("nothing here\n"); - return; - } - } - if(event->mimeData()->hasText()) - { - //printf("has text\n"); - text = event->mimeData()->text().trimmed(); - if (QString(text).endsWith(".pre")) - { - QUrl url(text); - QString newPath = url.path(); - - QFile xmlfile(newPath); - xmlfile.open(QIODevice::ReadOnly); - QDomDocument doc; - doc.setContent(&xmlfile); - QDomNode node = doc.documentElement().firstChild(); - initPlugin(node, idx); - } - } - else if (event->mimeData()->hasFormat("text/x-muse-plugin")) - { - QByteArray outxml = event->mimeData()->data("text/x-muse-plugin"); - //printf("DATA:%s\n",outxml.data()); - QDomDocument doc; - doc.setContent(outxml); - QDomNode node = doc.documentElement().firstChild(); - - initPlugin(node, idx); - } - } - } - -//--------------------------------------------------------- -// dragEnterEvent -//--------------------------------------------------------- -void EffectRack::dragEnterEvent(QDragEnterEvent *event) - { - //printf("dragEnterEvent\n"); - //if (event->mimeData()->hasFormat("text/x-muse-plugin")) - event->acceptProposedAction(); - } - -//--------------------------------------------------------- -// dragMoveEvent -//--------------------------------------------------------- -void EffectRack::dragMoveEvent(QDragMoveEvent *event) - { - //printf("dragMoveEvent\n"); - //if (event->mimeData()->hasFormat("text/x-muse-plugin")) - event->acceptProposedAction(); - } - -//--------------------------------------------------------- -// contentsMousePressEvent -//--------------------------------------------------------- -void EffectRack::mousePressEvent(QMouseEvent *event) - { - //printf("mousePressEvent\n"); - if(event->button() & Qt::LeftButton) { - dragPos = event->pos(); - } - QListWidget::mousePressEvent(event); - } - -//--------------------------------------------------------- -// contentsMouseMoveEvent -//--------------------------------------------------------- -void EffectRack::mouseMoveEvent(QMouseEvent *event) - { - if (event->buttons() & Qt::LeftButton) { - int distance = (dragPos-event->pos()).manhattanLength(); - if (distance > QApplication::startDragDistance()) { - QListWidgetItem *i = itemAt( event->pos() ); - int idx = row(i); - startDrag(idx); - } - } - QListWidget::mouseMoveEvent(event); - } - - -//--------------------------------------------------------- -// initPlugin -//--------------------------------------------------------- - -void EffectRack::initPlugin(QDomNode &node, int idx) - { - QDomElement e = node.toElement(); - //QString version = e.attribute("version"); - QString file = e.attribute("file"); - QString label = e.attribute("label"); - - //printf("version=%s file=%s label=%s channel=%d\n",version.toLatin1().data(),file.toLatin1().data(), label.toLatin1().data(), channel); - - //Plugin* plugin = PluginDialog::getPlugin(this); - Plugin* plugin = plugins.find(file, label); - if (plugin) { - PluginI* plugi = new PluginI(track); - if (plugi->initPluginInstance(plugin, track->channels())) { - printf("cannot instantiate plugin <%s>\n", - plugin->name().toLatin1().data()); - delete plugi; - } - else { - audio->msgAddPlugin(track, idx, plugi, prefader); - song->update(SC_RACK); - int i = 0; - for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { - QDomElement e = n.toElement(); - if (e.nodeName() == "control") { - //QString name = e.attribute("name"); // currently this value is just thrown. - QString value = e.attribute("val"); - QLocale::setDefault(QLocale::C); - double val = value.toFloat(); - CVal cval; - cval.f = val; - song->setControllerVal(plugi->track(), plugi->controller(i), cval); - i++; - } - } - } - } - } - -//--------------------------------------------------------- -// mouseDoubleClickEvent -//--------------------------------------------------------- - -void EffectRack::mouseDoubleClickEvent(QMouseEvent* event) - { - QListWidgetItem* it = itemAt(event->pos()); - if (it || (track == 0)) { - QListWidget::mouseDoubleClickEvent(event); - return; - } - selectNew(); - } - -//--------------------------------------------------------- -// selectNew -//--------------------------------------------------------- - -void EffectRack::selectNew() - { - Plugin* plugin = PluginDialog::getPlugin(this); - addPlugin(plugin); - song->update(SC_RACK); - } - -//--------------------------------------------------------- -// addPlugin -//--------------------------------------------------------- - -void EffectRack::addPlugin(Plugin* plugin) - { - if (plugin == 0) - return; - PluginI* plugi = new PluginI(track); - if (plugi->initPluginInstance(plugin, track->channels())) { - printf("cannot instantiate plugin <%s>\n", - plugin->name().toLatin1().data()); - delete plugi; - } - else - audio->msgAddPlugin(track, -1, plugi, prefader); - } - diff --git a/muse/muse/mixer/rack.h b/muse/muse/mixer/rack.h deleted file mode 100644 index c468d8b9..00000000 --- a/muse/muse/mixer/rack.h +++ /dev/null @@ -1,66 +0,0 @@ -//============================================================================= -// MusE -// Linux Music Editor -// $Id:$ -// -// Copyright (C) 2002-2006 by Werner Schweer and others -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2. -// -// 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., 675 Mass Ave, Cambridge, MA 02139, USA. -//============================================================================= - -#ifndef __RACK_H__ -#define __RACK_H__ - -#include - -class AudioTrack; -class Plugin; - -//--------------------------------------------------------- -// EffectRack -//--------------------------------------------------------- - -class EffectRack : public QListWidget { - Q_OBJECT - - bool prefader; - AudioTrack* track; - - QPoint dragPos; - - virtual void contextMenuEvent(QContextMenuEvent*); - virtual void mouseDoubleClickEvent(QMouseEvent*); - void selectNew(); - - void startDrag(int idx); - void initPlugin(QDomNode &node, int idx); - void addPlugin(Plugin* plugin); - - private slots: - void doubleClicked(QListWidgetItem*); - void songChanged(int); - - protected: - void dropEvent(QDropEvent *event); - void dragEnterEvent(QDragEnterEvent *event); - void mousePressEvent(QMouseEvent *event); - void mouseMoveEvent(QMouseEvent *event); - void dragMoveEvent(QDragMoveEvent *event); - - public: - EffectRack(QWidget*, AudioTrack*, bool); - QSize sizeHint() const; - }; - -#endif - diff --git a/muse/muse/mixer/routedialog.cpp b/muse/muse/mixer/routedialog.cpp deleted file mode 100644 index a2f3b584..00000000 --- a/muse/muse/mixer/routedialog.cpp +++ /dev/null @@ -1,196 +0,0 @@ -//============================================================================= -// MusE -// Linux Music Editor -// $Id:$ -// -// Copyright (C) 2002-2006 by Werner Schweer and others -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2. -// -// 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., 675 Mass Ave, Cambridge, MA 02139, USA. -//============================================================================= - -#include "routedialog.h" -#include "track.h" -#include "song.h" -#include "audio.h" -#include "jackaudio.h" - -//--------------------------------------------------------- -// RouteDialog -//--------------------------------------------------------- - -RouteDialog::RouteDialog(QWidget* parent) - : QDialog(parent) - { - setupUi(this); - connect(routeList, SIGNAL(selectionChanged()), SLOT(routeSelectionChanged())); - connect(newSrcList, SIGNAL(selectionChanged()), SLOT(srcSelectionChanged())); - connect(newDstList, SIGNAL(selectionChanged()), SLOT(dstSelectionChanged())); - connect(removeButton, SIGNAL(clicked()), SLOT(removeRoute())); - connect(connectButton, SIGNAL(clicked()), SLOT(addRoute())); - connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int))); - routingChanged(); - } - -//--------------------------------------------------------- -// routingChanged -//--------------------------------------------------------- - -void RouteDialog::routingChanged() - { - //--------------------------------------------------- - // populate lists - //--------------------------------------------------- - - routeList->clear(); - newSrcList->clear(); - newDstList->clear(); - -#if 0 //TODO3 - TrackList* tl = song->tracks(); - for (ciTrack i = tl->begin(); i != tl->end(); ++i) { - if ((*i)->isMidiTrack()) - continue; - Track* track = *i; - if (track->type() == Track::AUDIO_INPUT) { - for (int channel = 0; channel < track->channels(); ++channel) - newDstList->insertItem(Route(track, channel).name()); - const RouteList* rl = track->inRoutes(); - for (ciRoute r = rl->begin(); r != rl->end(); ++r) { - Route dst(track->name(), r->channel, Route::AUDIOPORT); - new QListWidgetItem(routeList, r->name(), dst.name()); - } - } - else - newDstList->insertItem(Route(track, -1).name()); - if (track->type() == Track::AUDIO_OUTPUT) { - for (int channel = 0; channel < track->channels(); ++channel) { - Route r(track, channel); - newSrcList->insertItem(r.name()); - } - } - else - newSrcList->insertItem(Route(track, -1).name()); - - const RouteList* rl = track->outRoutes(); - for (ciRoute r = rl->begin(); r != rl->end(); ++r) { - QString src(track->name()); - if (track->type() == Track::AUDIO_OUTPUT) { - Route s(src, r->channel, Route::AUDIOPORT); - src = s.name(); - } - new QListWidgetItem(routeList, src, r->name()); - } - } - - std::list sl = audioDriver->outputPorts(); - for (std::list::iterator i = sl.begin(); i != sl.end(); ++i) - newSrcList->insertItem(*i); - sl = audioDriver->inputPorts(); - for (std::list::iterator i = sl.begin(); i != sl.end(); ++i) - newDstList->insertItem(*i); -#endif - routeSelectionChanged(); // init remove button - srcSelectionChanged(); // init select button - } - -//--------------------------------------------------------- -// songChanged -//--------------------------------------------------------- - -void RouteDialog::songChanged(int v) - { - if (v & (SC_TRACK_INSERTED | SC_TRACK_REMOVED | SC_ROUTE)) { - routingChanged(); - } - } - -//--------------------------------------------------------- -// routeSelectionChanged -//--------------------------------------------------------- - -void RouteDialog::routeSelectionChanged() - { -//TD QListWidgetItem* item = routeList->selectedItem(); -// removeButton->setEnabled(item != 0); - } - -//--------------------------------------------------------- -// removeRoute -//--------------------------------------------------------- - -void RouteDialog::removeRoute() - { -#if 0 //TD - QListWidgetItem* item = routeList->selectedItem(); - if (item == 0) - return; - audio->msgRemoveRoute(Route(item->text(0), -1, Route::TRACK), Route(item->text(1), -1, Route::AUDIOPORT)); - delete item; -#endif - } - -//--------------------------------------------------------- -// addRoute -//--------------------------------------------------------- - -void RouteDialog::addRoute() - { -#if 0 //TD - QListWidgetItem* srcItem = newSrcList->selectedItem(); - QListWidgetItem* dstItem = newDstList->selectedItem(); - if (srcItem == 0 || dstItem == 0) - return; - audio->msgAddRoute(Route(srcItem->text(), -1, Route::TRACK), Route(dstItem->text(), -1, Route::AUDIOPORT)); - new QListWidgetItem(routeList, srcItem->text(), dstItem->text()); -#endif - } - -//--------------------------------------------------------- -// srcSelectionChanged -//--------------------------------------------------------- - -void RouteDialog::srcSelectionChanged() - { -#if 0 //TD - QListWidgetItem* srcItem = newSrcList->selectedItem(); - QListWidgetItem* dstItem = newDstList->selectedItem(); - connectButton->setEnabled((srcItem != 0) - && (dstItem != 0) - && checkRoute(srcItem->text(), dstItem->text())); -#endif - } - -//--------------------------------------------------------- -// dstSelectionChanged -//--------------------------------------------------------- - -void RouteDialog::dstSelectionChanged() - { -#if 0 //TD - QListWidgetItem* dstItem = newDstList->selectedItem(); - QListWidgetItem* srcItem = newSrcList->selectedItem(); - connectButton->setEnabled((srcItem != 0) - && (dstItem != 0) - && checkRoute(srcItem->text(), dstItem->text())); -#endif - } - -//--------------------------------------------------------- -// closeEvent -//--------------------------------------------------------- - -void RouteDialog::closeEvent(QCloseEvent* e) - { - emit closed(); - e->accept(); - } diff --git a/muse/muse/mixer/routedialog.h b/muse/muse/mixer/routedialog.h deleted file mode 100644 index 2bcbf471..00000000 --- a/muse/muse/mixer/routedialog.h +++ /dev/null @@ -1,53 +0,0 @@ -//============================================================================= -// MusE -// Linux Music Editor -// $Id:$ -// -// Copyright (C) 2002-2006 by Werner Schweer and others -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2. -// -// 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., 675 Mass Ave, Cambridge, MA 02139, USA. -//============================================================================= - -#ifndef __ROUTEDIALOG_H__ -#define __ROUTEDIALOG_H__ - -#include "ui_routedialog.h" - -//--------------------------------------------------------- -// RouteDialog -//--------------------------------------------------------- - -class RouteDialog : public QDialog, public Ui::RouteDialogBase { - Q_OBJECT - - virtual void closeEvent(QCloseEvent*); - void routingChanged(); - - private slots: - void routeSelectionChanged(); - void removeRoute(); - void addRoute(); - void srcSelectionChanged(); - void dstSelectionChanged(); - void songChanged(int); - - signals: - void closed(); - - public: - RouteDialog(QWidget* parent); - }; - - -#endif - diff --git a/muse/muse/mixer/routedialog.ui b/muse/muse/mixer/routedialog.ui deleted file mode 100644 index be34c451..00000000 --- a/muse/muse/mixer/routedialog.ui +++ /dev/null @@ -1,170 +0,0 @@ - - - - - RouteDialogBase - - - - 0 - 0 - 316 - 383 - - - - - 5 - 7 - 0 - 0 - - - - MusE: Routing - - - - 4 - - - 4 - - - - - Add Route - - - - 4 - - - 4 - - - - - 0 - - - 6 - - - - - - 7 - 7 - 0 - 0 - - - - Source: - - - - 2 - - - 0 - - - - - - - - - - - - 7 - 7 - 0 - 0 - - - - Destination: - - - - 2 - - - 0 - - - - - - - - - - - - - - 4 - 1 - 0 - 0 - - - - connect source to destination - - - Connect - - - - - - - - - - Current Routes - - - - 4 - - - 4 - - - - - - - - - 4 - 1 - 0 - 0 - - - - remove selected route - - - Remove - - - - - - - - - - qPixmapFromMimeSource - - - diff --git a/muse/muse/mixer/strip.cpp b/muse/muse/mixer/strip.cpp deleted file mode 100644 index 38519878..00000000 --- a/muse/muse/mixer/strip.cpp +++ /dev/null @@ -1,123 +0,0 @@ -//============================================================================= -// MusE -// Linux Music Editor -// $Id:$ -// -// Copyright (C) 2002-2006 by Werner Schweer and others -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2. -// -// 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., 675 Mass Ave, Cambridge, MA 02139, USA. -//============================================================================= - -#include "gconfig.h" -#include "song.h" -#include "strip.h" -#include "muse.h" -#include "widgets/simplebutton.h" -#include "widgets/utils.h" - -//--------------------------------------------------------- -// resetPeaks -//--------------------------------------------------------- - -void Strip::resetPeaks() - { - track->resetPeaks(); - } - -//--------------------------------------------------------- -// updateLabel -//--------------------------------------------------------- - -void Strip::updateLabel() - { - label->setText(track->name()); - label->setToolTip(track->name()); - } - -//--------------------------------------------------------- -// Strip -// create mixer strip -//--------------------------------------------------------- - -Strip::Strip(Mixer* m, Track* t, bool align) - : QFrame() - { - ar = 0; - aw = 0; - setAttribute(Qt::WA_DeleteOnClose, true); - mixer = m; - _align = align; - setFrameStyle(QFrame::Panel | QFrame::Raised); - setLineWidth(2); - - track = t; - grid = new QGridLayout; - grid->setMargin(0); - grid->setSpacing(0); - setLayout(grid); - - //--------------------------------------------- - // label - //--------------------------------------------- - - label = new QLabel; - label->setObjectName(track->cname()); - label->setFixedHeight(LABEL_HEIGHT); - label->setTextFormat(Qt::PlainText); - label->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); - label->setLineWidth(2); - label->setFrameStyle(QFrame::Sunken | QFrame::StyledPanel); - updateLabel(); - grid->addWidget(label, 0, 0, 1, 2); - connect(muse, SIGNAL(configChanged()), SLOT(configChanged())); - connect(track, SIGNAL(controllerChanged(int)), SLOT(controllerChanged(int))); - } - -//--------------------------------------------------------- -// Strip -//--------------------------------------------------------- - -Strip::~Strip() - { - } - -//--------------------------------------------------------- -// configChanged -//--------------------------------------------------------- - -void Strip::configChanged() - { - updateLabel(); - } - -//--------------------------------------------------------- -// addAutomationButtons -//--------------------------------------------------------- - -void Strip::addAutomationButtons(int row) - { - ar = newAutoReadButton(); - ar->setFixedHeight(BUTTON_HEIGHT); - ar->setChecked(track->autoRead()); - grid->addWidget(ar, row, 0); - aw = newAutoWriteButton(); - aw->setFixedHeight(BUTTON_HEIGHT); - aw->setChecked(track->autoWrite()); - grid->addWidget(aw, row, 1); - connect(ar, SIGNAL(clicked(bool)), SLOT(autoReadToggled(bool))); - connect(aw, SIGNAL(clicked(bool)), SLOT(autoWriteToggled(bool))); - connect(track, SIGNAL(autoReadChanged(bool)), ar, SLOT(setChecked(bool))); - connect(track, SIGNAL(autoWriteChanged(bool)), aw, SLOT(setChecked(bool))); - } - - diff --git a/muse/muse/mixer/strip.h b/muse/muse/mixer/strip.h deleted file mode 100644 index f9bc06ea..00000000 --- a/muse/muse/mixer/strip.h +++ /dev/null @@ -1,74 +0,0 @@ -//============================================================================= -// MusE -// Linux Music Editor -// $Id:$ -// -// Copyright (C) 2002-2006 by Werner Schweer and others -// -// This program is free software; you can redistribute it and/or modify -// it under the terms of the GNU General Public License version 2. -// -// 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., 675 Mass Ave, Cambridge, MA 02139, USA. -//============================================================================= - -#ifndef __STRIP_H__ -#define __STRIP_H__ - -#include "globaldefs.h" -#include "gui.h" - -class Track; -class Meter; -class SimpleButton; -class Mixer; - -// static const QSize buttonSize(STRIP_WIDTH/2-2, BUTTON_HEIGHT); -static const QSize entrySize(STRIP_WIDTH/2-2, ENTRY_HEIGHT); - -//--------------------------------------------------------- -// Strip -//--------------------------------------------------------- - -class Strip : public QFrame { - Q_OBJECT - - protected: - Mixer* mixer; - Track* track; - QLabel* label; - QGridLayout* grid; - - SimpleButton* solo; - SimpleButton* mute; - SimpleButton* ar; - SimpleButton* aw; - - void updateLabel(); - bool _align; // align elements for mixer app - - void recordToggled(bool); - void addAutomationButtons(int row); - - public slots: - void resetPeaks(); - virtual void songChanged(int) = 0; - virtual void controllerChanged(int) {} - void configChanged(); - - public: - Strip(Mixer* m, Track* t, bool align); - ~Strip(); - Track* getTrack() const { return track; } - virtual void heartBeat() = 0; - virtual QSize sizeHint() const { return QSize(STRIP_WIDTH, 80); } - }; - -#endif - diff --git a/muse/muse/mstrip.cpp b/muse/muse/mstrip.cpp new file mode 100644 index 00000000..d4c48f5e --- /dev/null +++ b/muse/muse/mstrip.cpp @@ -0,0 +1,1279 @@ +//============================================================================= +// MusE +// Linux Music Editor +// $Id:$ +// +// Copyright (C) 2002-2006 by Werner Schweer and others +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2. +// +// 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., 675 Mass Ave, Cambridge, MA 02139, USA. +//============================================================================= + +#include "midictrl.h" +#include "mstrip.h" +#include "audio.h" +#include "song.h" +#include "mixer.h" +#include "widgets/simplebutton.h" +#include "widgets/utils.h" +#include "audiodev.h" +#include "synth.h" +#include "midirack.h" +#include "midiplugin.h" +#include "midiinport.h" +#include "midioutport.h" + +#include "awl/midimslider.h" +#include "awl/midimeter.h" +#include "awl/midivolentry.h" +#include "awl/midipanentry.h" +#include "awl/midipanknob.h" +#include "awl/knob.h" + +enum { KNOB_PAN, KNOB_CHOR_SEND, KNOB_VAR_SEND, KNOB_REV_SEND }; + +//--------------------------------------------------------- +// addMidiTracks +// input == true +// add routes from all possible midi tracks to input +// route list of track(channel) +// input == false +// add routes to all midi tracks to output route +// list of track(channel) +// +// Note: midi tracks do not have channels +//--------------------------------------------------------- + +void addMidiTracks(QMenu* menu, Track* track, int channel, bool input) + { + RouteList* rl = input ? track->inRoutes() : track->outRoutes(); + RouteNode a(track, channel, RouteNode::TRACK); + + MidiTrackList* tl = song->midis(); + for (iMidiTrack i = tl->begin();i != tl->end(); ++i) { + MidiTrack* track = *i; + QAction* action = menu->addAction(track->name()); + action->setCheckable(true); + RouteNode b(track); + Route r = input ? Route(b, a) : Route(a, b); + action->setData(QVariant::fromValue(r)); + action->setChecked(rl->indexOf(r) != -1); + } + } + +//--------------------------------------------------------- +// addMidiInPorts +// can only be added to input route lists +//--------------------------------------------------------- + +void addMidiInPorts(QMenu* menu, Track* dtrack, int channel) + { + RouteList* rl = dtrack->inRoutes(); + RouteNode dst(dtrack, channel, RouteNode::TRACK); + + MidiInPortList* tl = song->midiInPorts(); + for (iMidiInPort i = tl->begin();i != tl->end(); ++i) { + MidiInPort* track = *i; + QMenu* m = menu->addMenu(track->name()); + m->setSeparatorsCollapsible(false); + m->addSeparator()->setText(QT_TR_NOOP("Channels")); + for (int ch = 0; ch < MIDI_CHANNELS; ++ch) { + QAction* a = m->addAction(QString("Channel %1").arg(ch+1)); + a->setCheckable(true); + RouteNode src(track, ch, RouteNode::TRACK); + Route r = Route(src, dst); + a->setData(QVariant::fromValue(r)); + a->setChecked(rl->indexOf(r) != -1); + } + } + } + +//--------------------------------------------------------- +// addMidiOutPorts +// can only be added to output route lists +//--------------------------------------------------------- + +static void addMidiOutPorts(QMenu* menu, Track* strack, int channel) + { + RouteList* rl = strack->outRoutes(); + RouteNode src(strack, channel, RouteNode::TRACK); + + MidiOutPortList* tl = song->midiOutPorts(); + for (iMidiOutPort i = tl->begin();i != tl->end(); ++i) { + MidiOutPort* op = *i; + QMenu* m = menu->addMenu(op->name()); + m->setSeparatorsCollapsible(false); + m->addSeparator()->setText(QT_TR_NOOP("Channels")); + for (int ch = 0; ch < MIDI_CHANNELS; ++ch) { + QAction* a = m->addAction(QString("Channel %1").arg(ch+1)); + a->setCheckable(true); + RouteNode dst(op, ch, RouteNode::TRACK); + Route r = Route(src, dst); + a->setData(QVariant::fromValue(r)); + a->setChecked(rl->indexOf(r) != -1); + } + } + } + +//--------------------------------------------------------- +// addSyntiPorts +// can only be added to output route lists +//--------------------------------------------------------- + +static void addSyntiPorts(QMenu* menu, Track* strack, int channel) + { + RouteList* rl = strack->outRoutes(); + RouteNode src(strack, channel, RouteNode::TRACK); + + SynthIList* sl = song->syntis(); + for (iSynthI i = sl->begin(); i != sl->end(); ++i) { + SynthI* sy = *i; + QMenu* m = menu->addMenu(sy->name()); + m->setSeparatorsCollapsible(false); + m->addSeparator()->setText(QT_TR_NOOP("Channels")); + for (int ch = 0; ch < MIDI_CHANNELS; ++ch) { + QAction* a = m->addAction(QString("Channel %1").arg(ch+1)); + a->setCheckable(true); + RouteNode dst(sy, ch, RouteNode::TRACK); + Route r = Route(src, dst); + a->setData(QVariant::fromValue(r)); + a->setChecked(rl->indexOf(r) != -1); + } + } + } + +//--------------------------------------------------------- +// addKnob +//--------------------------------------------------------- + +void MidiStrip::addKnob(int ctrl, int idx, const QString& tt, const QString& label, + const char* slot, bool enabled, int row) + { + Awl::FloatEntry* dl; + Awl::Knob* knob; + + if (idx == KNOB_PAN) { + dl = new Awl::MidiPanEntry(this); + knob = new Awl::MidiPanKnob(this); + } + else { + dl = new Awl::MidiVolEntry(this); + knob = new Awl::Knob(this); + knob->setRange(0.0, 127.0); + } + knob->setId(ctrl); + dl->setId(ctrl); + dl->setFrame(true); + + controller[idx].knob = knob; + knob->setToolTip(tt); + knob->setEnabled(enabled); + + controller[idx].dl = dl; + dl->setFixedSize(entrySize); + dl->setEnabled(enabled); + + QLabel* lb = new QLabel(label, this); + lb->setObjectName("knobLabel"); + controller[idx].lb = lb; + lb->setFixedSize(entrySize); + lb->setAlignment(Qt::AlignCenter); + lb->setEnabled(enabled); + + grid->addWidget(lb, row, 0); + grid->addWidget(dl, row+1, 0); + grid->addWidget(knob, row, 1, 2, 1); + + connect(knob, SIGNAL(valueChanged(double,int)), slot); + connect(dl, SIGNAL(valueChanged(double,int)), slot); + connect(knob, SIGNAL(sliderPressed(int)), SLOT(sliderPressed(int))); + connect(knob, SIGNAL(sliderReleased(int)), SLOT(sliderReleased(int))); + } + +//--------------------------------------------------------- +// MidiStrip +//--------------------------------------------------------- + +MidiStrip::MidiStrip(Mixer* m, MidiTrack* t, bool align) + : Strip(m, t, align) + { + volumeTouched = false; + panTouched = false; + reverbSendTouched = false; + variSendTouched = false; + chorusSendTouched = false; + + addKnob(CTRL_VARIATION_SEND, KNOB_VAR_SEND, tr("VariationSend"), tr("Var"), SLOT(ctrlChanged(double,int)), true, 1); + addKnob(CTRL_REVERB_SEND, KNOB_REV_SEND, tr("ReverbSend"), tr("Rev"), SLOT(ctrlChanged(double,int)), true, 3); + addKnob(CTRL_CHORUS_SEND, KNOB_CHOR_SEND, tr("ChorusSend"), tr("Cho"), SLOT(ctrlChanged(double,int)), true, 5); + + //--------------------------------------------------- + // slider, label, meter + //--------------------------------------------------- + + slider = new Awl::MidiMeterSlider(this); + slider->setId(CTRL_VOLUME); + slider->setFixedWidth(40); + grid->addWidget(slider, 7, 0, 1, 2, Qt::AlignRight); + + sl = new Awl::MidiVolEntry(this); + sl->setId(CTRL_VOLUME); +// sl->setFont(config.fonts[1]); + sl->setFixedHeight(entrySize.height()); + + connect(slider, SIGNAL(valueChanged(double,int)), SLOT(ctrlChanged(double, int))); + connect(slider, SIGNAL(sliderPressed(int)), SLOT(sliderPressed(int))); + connect(slider, SIGNAL(sliderReleased(int)), SLOT(sliderReleased(int))); + connect(sl, SIGNAL(valueChanged(double,int)), SLOT(ctrlChanged(double, int))); + grid->addWidget(sl, 8, 0, 1, 2); + + //--------------------------------------------------- + // pan, balance + //--------------------------------------------------- + + addKnob(CTRL_PANPOT, KNOB_PAN, tr("Pan/Balance"), tr("Pan"), SLOT(ctrlChanged(double,int)), true, 9); + + //--------------------------------------------------- + // --- record + // mute, solo + //--------------------------------------------------- + + SimpleButton* monitor = newMonitorButton(); + monitor->setFixedHeight(BUTTON_HEIGHT); + monitor->setChecked(track->monitor()); + connect(monitor, SIGNAL(clicked(bool)), SLOT(monitorToggled(bool))); + connect(t, SIGNAL(monitorChanged(bool)), monitor, SLOT(setChecked(bool))); + + SimpleButton* record = newRecordButton(); + record->setFixedHeight(BUTTON_HEIGHT); + record->setChecked(track->recordFlag()); + connect(record, SIGNAL(clicked(bool)), SLOT(recordToggled(bool))); + connect(t, SIGNAL(recordChanged(bool)), record, SLOT(setChecked(bool))); + + mute = newMuteButton(); + mute->setChecked(track->isMute()); + mute->setFixedHeight(BUTTON_HEIGHT); + connect(mute, SIGNAL(clicked(bool)), SLOT(muteToggled(bool))); + + solo = newSoloButton(); + solo->setFixedHeight(BUTTON_HEIGHT); + solo->setChecked(track->solo()); + connect(solo, SIGNAL(clicked(bool)), SLOT(soloToggled(bool))); + + grid->addWidget(monitor, 11, 0); + grid->addWidget(record, 11, 1); + grid->addWidget(mute, 12, 0); + grid->addWidget(solo, 12, 1); + + //--------------------------------------------------- + // automation mode + //--------------------------------------------------- + + addAutomationButtons(13); + + //--------------------------------------------------- + // routing + //--------------------------------------------------- + + iR = newInRouteButton(); + grid->addWidget(iR, 14, 0); + connect(iR->menu(), SIGNAL(aboutToShow()), SLOT(iRouteShow())); + connect(iR->menu(), SIGNAL(aboutToHide()), SLOT(iRouteHide())); + connect(iR->menu(), SIGNAL(triggered(QAction*)), song, SLOT(routeChanged(QAction*))); + + oR = newOutRouteButton(); + grid->addWidget(oR, 14, 1); + connect(oR->menu(), SIGNAL(aboutToShow()), SLOT(oRouteShow())); + connect(oR->menu(), SIGNAL(aboutToHide()), SLOT(oRouteHide())); + connect(oR->menu(), SIGNAL(triggered(QAction*)), song, SLOT(routeChanged(QAction*))); + + connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int))); + connect(track, SIGNAL(muteChanged(bool)), mute, SLOT(setChecked(bool))); + connect(track, SIGNAL(soloChanged(bool)), solo, SLOT(setChecked(bool))); + connect(track, SIGNAL(autoReadChanged(bool)), SLOT(autoChanged())); + connect(track, SIGNAL(autoWriteChanged(bool)), SLOT(autoChanged())); + connect(track, SIGNAL(controllerChanged(int)), SLOT(controllerChanged(int))); + autoChanged(); + controllerChanged(CTRL_VOLUME); + controllerChanged(CTRL_PANPOT); + controllerChanged(CTRL_VARIATION_SEND); + controllerChanged(CTRL_REVERB_SEND); + controllerChanged(CTRL_CHORUS_SEND); + } + +//--------------------------------------------------------- +// iRouteHide +//--------------------------------------------------------- + +void MidiStrip::iRouteHide() + { + // dont leave the menu if SHIFT is pressed; this allows + // for fast selecting of more than one input source + // + if (qApp->keyboardModifiers() & Qt::ShiftModifier) { + iR->menu()->show(); + } + } + +//--------------------------------------------------------- +// oRouteHide +//--------------------------------------------------------- + +void MidiStrip::oRouteHide() + { + // dont leave the menu if SHIFT is pressed; this allows + // for fast selecting of more than one input source + // + if (qApp->keyboardModifiers() & Qt::ShiftModifier) { + oR->menu()->show(); + } + } + +//--------------------------------------------------------- +// songChanged +//--------------------------------------------------------- + +void MidiStrip::songChanged(int val) + { + if (val & SC_TRACK_MODIFIED) + updateLabel(); + } + +//--------------------------------------------------------- +// heartBeat +//--------------------------------------------------------- + +void MidiStrip::heartBeat() + { + double a = track->meter(0); // fast_log10(track->meter(0)) * .2f; + slider->setMeterVal(a * 0.008); + track->setMeter(0, a * 0.8); // hack + } + +//--------------------------------------------------------- +// controllerChanged +//--------------------------------------------------------- + +void MidiStrip::controllerChanged(int id) + { + CVal cv = track->ctrlVal(id); + double val = double(cv.i); + + switch (id) { + case CTRL_VOLUME: + if (!volumeTouched) + slider->setValue(val); + sl->setValue(val); + break; + case CTRL_PANPOT: + if (!panTouched) + controller[KNOB_PAN].knob->setValue(val); + controller[KNOB_PAN].dl->setValue(val); + break; + case CTRL_VARIATION_SEND: + if (!variSendTouched) + controller[KNOB_VAR_SEND].knob->setValue(val); + controller[KNOB_VAR_SEND].dl->setValue(val); + break; + case CTRL_REVERB_SEND: + if (!reverbSendTouched) + controller[KNOB_REV_SEND].knob->setValue(val); + controller[KNOB_REV_SEND].dl->setValue(val); + break; + case CTRL_CHORUS_SEND: + if (!chorusSendTouched) + controller[KNOB_CHOR_SEND].knob->setValue(val); + controller[KNOB_CHOR_SEND].dl->setValue(val); + break; + } + } + +//--------------------------------------------------------- +// ctrlChanged +// called when user changes controller +//--------------------------------------------------------- + +void MidiStrip::ctrlChanged(double val, int num) + { + int ival = int(val); + CVal cval; + cval.i = ival; + song->setControllerVal(track, num, cval); + } + +//--------------------------------------------------------- +// sliderPressed +//--------------------------------------------------------- + +void MidiStrip::sliderPressed(int id) + { + switch (id) { + case CTRL_VOLUME: volumeTouched = true; break; + case CTRL_PANPOT: panTouched = true; break; + case CTRL_VARIATION_SEND: variSendTouched = true; break; + case CTRL_REVERB_SEND: reverbSendTouched = true; break; + case CTRL_CHORUS_SEND: chorusSendTouched = true; break; + } + track->startAutoRecord(id); + } + +//--------------------------------------------------------- +// sliderReleased +//--------------------------------------------------------- + +void MidiStrip::sliderReleased(int id) + { + switch (id) { + case CTRL_VOLUME: volumeTouched = false; break; + case CTRL_PANPOT: panTouched = false; break; + case CTRL_VARIATION_SEND: variSendTouched = false; break; + case CTRL_REVERB_SEND: reverbSendTouched = false; break; + case CTRL_CHORUS_SEND: chorusSendTouched = false; break; + } + track->stopAutoRecord(id); + } + +//--------------------------------------------------------- +// muteToggled +//--------------------------------------------------------- + +void MidiStrip::muteToggled(bool val) + { + song->setMute(track, val); + } + +//--------------------------------------------------------- +// soloToggled +//--------------------------------------------------------- + +void MidiStrip::soloToggled(bool val) + { + song->setSolo(track, val); + } + +//--------------------------------------------------------- +// autoChanged +//--------------------------------------------------------- + +void MidiStrip::autoChanged() + { + bool ar = track->autoRead(); + bool aw = track->autoWrite(); + + // controller are enabled if + // autoRead is off + // autoRead and autoWrite are on (touch mode) + + bool ec = !ar || (ar && aw); + for (unsigned i = 0; i < sizeof(controller)/sizeof(*controller); ++i) { + controller[i].knob->setEnabled(ec); + controller[i].dl->setEnabled(ec); + } + slider->setEnabled(ec); + sl->setEnabled(ec); + } + +//--------------------------------------------------------- +// autoReadToggled +//--------------------------------------------------------- + +void MidiStrip::autoReadToggled(bool val) + { + song->setAutoRead(track, val); + } + +//--------------------------------------------------------- +// autoWriteToggled +//--------------------------------------------------------- + +void MidiStrip::autoWriteToggled(bool val) + { + song->setAutoWrite(track, val); + } + +//--------------------------------------------------------- +// iRouteShow +//--------------------------------------------------------- + +void MidiStrip::iRouteShow() + { + QMenu* pup = iR->menu(); + pup->clear(); + pup->addSeparator()->setText(tr("Tracks")); + addMidiInPorts(pup, track, -1); // add midi inputs to menu + } + +//--------------------------------------------------------- +// oRouteShow +//--------------------------------------------------------- + +void MidiStrip::oRouteShow() + { + QMenu* pup = oR->menu(); + pup->clear(); + pup->addSeparator()->setText(tr("OutputPorts")); + addMidiOutPorts(pup, track, -1); + addSyntiPorts(pup, track, -1); + } + +//--------------------------------------------------------- +// monitorToggled +//--------------------------------------------------------- + +void MidiStrip::monitorToggled(bool val) + { + song->setMonitor(track, val); + } + +//--------------------------------------------------------- +// recordToggled +//--------------------------------------------------------- + +void MidiStrip::recordToggled(bool val) + { + song->setRecordFlag(track, !val); + } + +//--------------------------------------------------------- +// MidiOutPortStrip +//--------------------------------------------------------- + +MidiOutPortStrip::MidiOutPortStrip(Mixer* m, MidiOutPort* t, bool align) + : Strip(m, t, align) + { + //--------------------------------------------------- + // plugin rack + //--------------------------------------------------- + + MidiRack* rack = new MidiRack(this, t); + rack->setFixedHeight(rack->sizeHint().height()+2); + grid->addWidget(rack, 1, 0, 1, 2); + + + if (_align) + grid->setRowMinimumHeight(2, STRIP_WIDTH/2); + + volumeTouched = false; + + //--------------------------------------------------- + // slider, label, meter + //--------------------------------------------------- + + slider = new Awl::MidiMeterSlider(this); + slider->setId(CTRL_MASTER_VOLUME); + slider->setRange(0.0, 1024*16.0); + slider->setFixedWidth(40); + grid->addWidget(slider, 3, 0, 1, 2, Qt::AlignRight); + + sl = new Awl::MidiVolEntry(this); + sl->setId(CTRL_MASTER_VOLUME); + sl->setMax(128 * 128 - 1); +// sl->setFont(config.fonts[1]); + sl->setFixedHeight(entrySize.height()); + + controllerChanged(CTRL_MASTER_VOLUME); + + connect(slider, SIGNAL(valueChanged(double,int)), SLOT(ctrlChanged(double, int))); + connect(slider, SIGNAL(sliderPressed(int)), SLOT(sliderPressed(int))); + connect(slider, SIGNAL(sliderReleased(int)), SLOT(sliderReleased(int))); + connect(sl, SIGNAL(valueChanged(double,int)), SLOT(ctrlChanged(double, int))); + grid->addWidget(sl, 4, 0, 1, 2); + + //--------------------------------------------------- + // pan, balance + //--------------------------------------------------- + + if (_align) + grid->setRowMinimumHeight(5, entrySize.height() * 2); + + //--------------------------------------------------- + // sync + // mute, solo + //--------------------------------------------------- + + sync = newSyncButton(); + sync->setFixedHeight(BUTTON_HEIGHT); + sync->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); + sync->setChecked(((MidiOutPort*)track)->sendSync()); + grid->addWidget(sync, 6, 0, 1, 2); + connect(sync, SIGNAL(clicked(bool)), SLOT(syncToggled(bool))); + connect(track, SIGNAL(sendSyncChanged(bool)), sync, SLOT(setChecked(bool))); + + mute = newMuteButton(); + mute->setChecked(track->isMute()); + mute->setFixedHeight(BUTTON_HEIGHT); + connect(mute, SIGNAL(clicked(bool)), SLOT(muteToggled(bool))); + + solo = newSoloButton(); + solo->setFixedHeight(BUTTON_HEIGHT); + solo->setChecked(track->solo()); + connect(solo, SIGNAL(clicked(bool)), SLOT(soloToggled(bool))); + + grid->addWidget(mute, 7, 0); + grid->addWidget(solo, 7, 1); + + //--------------------------------------------------- + // automation mode + //--------------------------------------------------- + + addAutomationButtons(8); + + //--------------------------------------------------- + // output routing + //--------------------------------------------------- + + iR = newInRouteButton(); + grid->addWidget(iR, 9, 0); + connect(iR->menu(), SIGNAL(aboutToShow()), SLOT(iRouteShow())); + connect(iR->menu(), SIGNAL(triggered(QAction*)), song, SLOT(routeChanged(QAction*))); + + oR = newOutRouteButton(); + grid->addWidget(oR, 9, 1); + connect(oR->menu(), SIGNAL(aboutToShow()), SLOT(oRouteShow())); + connect(oR->menu(), SIGNAL(triggered(QAction*)), song, SLOT(routeChanged(QAction*))); + + connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int))); + connect(track, SIGNAL(muteChanged(bool)), mute, SLOT(setChecked(bool))); + connect(track, SIGNAL(soloChanged(bool)), solo, SLOT(setChecked(bool))); + connect(track, SIGNAL(autoReadChanged(bool)), SLOT(autoChanged())); + connect(track, SIGNAL(autoWriteChanged(bool)), SLOT(autoChanged())); + autoChanged(); + controllerChanged(CTRL_MASTER_VOLUME); + } + +//--------------------------------------------------------- +// songChanged +//--------------------------------------------------------- + +void MidiOutPortStrip::songChanged(int val) + { + if (val & SC_TRACK_MODIFIED) + updateLabel(); + } + +//--------------------------------------------------------- +// heartBeat +//--------------------------------------------------------- + +void MidiOutPortStrip::heartBeat() + { + double a = track->meter(0); // fast_log10(track->meter(0)) * .2f; + slider->setMeterVal(a * 0.008); + track->setMeter(0, a * 0.8); // hack + } + +//--------------------------------------------------------- +// ctrlChanged +//--------------------------------------------------------- + +void MidiOutPortStrip::ctrlChanged(double val, int num) + { + int ival = int(val); + CVal cval; + cval.i = ival; + song->setControllerVal(track, num, cval); + } + +//--------------------------------------------------------- +// sliderPressed +//--------------------------------------------------------- + +void MidiOutPortStrip::sliderPressed(int id) + { + switch (id) { + case CTRL_MASTER_VOLUME: volumeTouched = true; break; + } + track->startAutoRecord(id); + } + +//--------------------------------------------------------- +// sliderReleased +//--------------------------------------------------------- + +void MidiOutPortStrip::sliderReleased(int id) + { + switch (id) { + case CTRL_MASTER_VOLUME: volumeTouched = false; break; + } + track->stopAutoRecord(id); + } + +//--------------------------------------------------------- +// muteToggled +//--------------------------------------------------------- + +void MidiOutPortStrip::muteToggled(bool val) + { + song->setMute(track, val); + } + +//--------------------------------------------------------- +// soloToggled +//--------------------------------------------------------- + +void MidiOutPortStrip::soloToggled(bool val) + { + song->setSolo(track, val); + } + +//--------------------------------------------------------- +// autoChanged +//--------------------------------------------------------- + +void MidiOutPortStrip::autoChanged() + { + bool ar = track->autoRead(); + bool aw = track->autoWrite(); + + // controller are enabled if + // autoRead is off + // autoRead and autoWrite are on (touch mode) + + bool ec = !ar || (ar && aw); + slider->setEnabled(ec); + sl->setEnabled(ec); + } + +//--------------------------------------------------------- +// autoReadToggled +//--------------------------------------------------------- + +void MidiOutPortStrip::autoReadToggled(bool val) + { + song->setAutoRead(track, val); + } + +//--------------------------------------------------------- +// autoWriteToggled +//--------------------------------------------------------- + +void MidiOutPortStrip::autoWriteToggled(bool val) + { + song->setAutoWrite(track, val); + } + +//--------------------------------------------------------- +// controllerChanged +//--------------------------------------------------------- + +void MidiOutPortStrip::controllerChanged(int id) + { + if (id == CTRL_MASTER_VOLUME) { + double val = double(track->ctrlVal(id).i); + if (!volumeTouched) + slider->setValue(val); + sl->setValue(val); + } + } + +//--------------------------------------------------------- +// iRouteShow +//--------------------------------------------------------- + +void MidiOutPortStrip::iRouteShow() + { + QMenu* pup = iR->menu(); + pup->clear(); + pup->addSeparator()->setText(tr("MidiChannel")); + + for (int ch = 0; ch < MIDI_CHANNELS; ++ch) { + QMenu* m = pup->addMenu(QString("Channel %1").arg(ch+1)); + addMidiTracks(m, track, ch, true); + addMidiInPorts(m, track, ch); + } + } + +//--------------------------------------------------------- +// oRouteShow +//--------------------------------------------------------- + +void MidiOutPortStrip::oRouteShow() + { + QMenu* pup = oR->menu(); + pup->clear(); + RouteList* orl = track->outRoutes(); + + QList ol; + // + // add JACK midi ports to list + // + ol = audioDriver->inputPorts(true); + foreach (PortName ip, ol) { + QAction* oa = pup->addAction(ip.name); + oa->setCheckable(true); + RouteNode dst(ip.port, RouteNode::JACKMIDIPORT); + Route r = Route(RouteNode(track), dst); + oa->setData(QVariant::fromValue(r)); + oa->setChecked(orl->indexOf(r) != -1); + } + } + +//--------------------------------------------------------- +// syncToggled +//--------------------------------------------------------- + +void MidiOutPortStrip::syncToggled(bool val) const + { + ((MidiOutPort*)track)->setSendSync(val); + } + +//--------------------------------------------------------- +// MidiInPortStrip +//--------------------------------------------------------- + +MidiInPortStrip::MidiInPortStrip(Mixer* m, MidiInPort* t, bool align) + : Strip(m, t, align) + { + //--------------------------------------------------- + // plugin rack + //--------------------------------------------------- + + MidiRack* rack = new MidiRack(this, t); + rack->setFixedHeight(rack->sizeHint().height()+2); + grid->addWidget(rack, 1, 0, 1, 2); + + //--------------------------------------------------- + // input activity + //--------------------------------------------------- + + grid->setRowStretch(2, 100); + + QGridLayout* ag = new QGridLayout; + ag->setMargin(4); + ag->setSpacing(1); + QSvgRenderer sr; + QPainter painter; + + sr.load(QString(":/xpm/activeon.svg")); + QSize aSize(sr.defaultSize()); + activityOn = new QPixmap(aSize); + activityOn->fill(Qt::transparent); + painter.begin(activityOn); + sr.render(&painter); + painter.end(); + + sr.load(QString(":/xpm/activeoff.svg")); + activityOff = new QPixmap(aSize); + activityOff->fill(Qt::transparent); + painter.begin(activityOff); + sr.render(&painter); + painter.end(); + + for (int ch = MIDI_CHANNELS-1; ch >= 0; --ch) { + QLabel* l = new QLabel(QString("%1").arg(ch+1)); + l->setObjectName("midiChannelLabel"); + ag->addWidget(l, ch, 0, Qt::AlignCenter); + channelActivity[ch] = new QLabel; + ag->addWidget(channelActivity[ch], ch, 1, Qt::AlignCenter); + channelActivity[ch]->setPixmap(*activityOff); + activity[ch] = 0; + } + grid->addLayout(ag, 3, 0, 2, Qt::AlignHCenter); + + if (_align) + grid->setRowMinimumHeight(4, BUTTON_HEIGHT); + + //--------------------------------------------------- + // mute, solo + // or + // record, mixdownfile + //--------------------------------------------------- + + mute = newMuteButton(); + mute->setChecked(track->isMute()); + mute->setFixedHeight(BUTTON_HEIGHT); + connect(mute, SIGNAL(clicked(bool)), SLOT(muteToggled(bool))); + + solo = newSoloButton(); + solo->setFixedHeight(BUTTON_HEIGHT); + solo->setChecked(track->solo()); + connect(solo, SIGNAL(clicked(bool)), SLOT(soloToggled(bool))); + + grid->addWidget(mute, 5, 0); + grid->addWidget(solo, 5, 1); + + //--------------------------------------------------- + // output routing + //--------------------------------------------------- + + if (_align) + grid->setRowMinimumHeight(6, BUTTON_HEIGHT); + + iR = newInRouteButton(); + connect(iR->menu(), SIGNAL(aboutToShow()), SLOT(iRouteShow())); + connect(iR->menu(), SIGNAL(triggered(QAction*)), song, SLOT(routeChanged(QAction*))); + + oR = newOutRouteButton(); + connect(oR->menu(), SIGNAL(aboutToShow()), SLOT(oRouteShow())); + connect(oR->menu(), SIGNAL(triggered(QAction*)), song, SLOT(routeChanged(QAction*))); + + grid->addWidget(iR, 7, 0); + grid->addWidget(oR, 7, 1); + + connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int))); + connect(track, SIGNAL(muteChanged(bool)), mute, SLOT(setChecked(bool))); + connect(track, SIGNAL(soloChanged(bool)), solo, SLOT(setChecked(bool))); + } + +//--------------------------------------------------------- +// songChanged +//--------------------------------------------------------- + +void MidiInPortStrip::songChanged(int val) + { + if (val & SC_TRACK_MODIFIED) + updateLabel(); + } + +//--------------------------------------------------------- +// heartBeat +//--------------------------------------------------------- + +void MidiInPortStrip::heartBeat() + { + for (int i = 0; i < MIDI_CHANNELS; ++i) { + bool isActive = inport()->checkActivity(i); + if (activity[i] != isActive) { + channelActivity[i]->setPixmap(isActive ? *activityOn : *activityOff); + activity[i] = isActive; + } + } + } + +//--------------------------------------------------------- +// muteToggled +//--------------------------------------------------------- + +void MidiInPortStrip::muteToggled(bool val) + { + song->setMute(track, val); + } + +//--------------------------------------------------------- +// soloToggled +//--------------------------------------------------------- + +void MidiInPortStrip::soloToggled(bool val) + { + song->setSolo(track, val); + } + +//--------------------------------------------------------- +// iRouteShow +//--------------------------------------------------------- + +void MidiInPortStrip::iRouteShow() + { + QMenu* pup = iR->menu(); + pup->clear(); + + RouteList* irl = track->inRoutes(); + + QList ol; + // + // add JACK midi ports to list + // + ol = audioDriver->outputPorts(true); + foreach (PortName ip, ol) { + QAction* action = pup->addAction(ip.name); + action->setCheckable(true); + RouteNode src(ip.port, RouteNode::JACKMIDIPORT); + Route r = Route(src, RouteNode(track)); + action->setData(QVariant::fromValue(r)); + action->setChecked(irl->indexOf(r) != -1); + } + } + +//--------------------------------------------------------- +// oRouteShow +//--------------------------------------------------------- + +void MidiInPortStrip::oRouteShow() + { + QMenu* pup = oR->menu(); + pup->clear(); + pup->addSeparator()->setText(tr("MidiChannel")); + + for (int ch = 0; ch < MIDI_CHANNELS; ++ch) { + QMenu* m = pup->addMenu(QString("Channel %1").arg(ch+1)); + addMidiTracks(m, track, ch, false); + addSyntiPorts(m, track, ch); + addMidiOutPorts(m, track, ch); + } + } + +//--------------------------------------------------------- +// MidiSyntiStrip +//--------------------------------------------------------- + +MidiSyntiStrip::MidiSyntiStrip(Mixer* m, MidiSynti* t, bool align) + : Strip(m, t, align) + { + if (_align) + grid->setRowMinimumHeight(1, STRIP_WIDTH/2 * 3); + + volumeTouched = false; + + //--------------------------------------------------- + // slider, label, meter + //--------------------------------------------------- + + slider = new Awl::MidiMeterSlider(this); + slider->setId(CTRL_MASTER_VOLUME); + slider->setRange(0.0, 1024*16.0); + slider->setFixedWidth(40); + grid->addWidget(slider, 2, 0, 1, 2, Qt::AlignRight); + + sl = new Awl::MidiVolEntry(this); + sl->setId(CTRL_MASTER_VOLUME); +// sl->setFont(config.fonts[1]); + sl->setFixedHeight(entrySize.height()); + + connect(slider, SIGNAL(valueChanged(double,int)), SLOT(ctrlChanged(double, int))); + connect(slider, SIGNAL(sliderPressed(int)), SLOT(sliderPressed(int))); + connect(slider, SIGNAL(sliderReleased(int)), SLOT(sliderReleased(int))); + connect(sl, SIGNAL(valueChanged(double,int)), SLOT(ctrlChanged(double, int))); + grid->addWidget(sl, 3, 0, 1, 2); + + //--------------------------------------------------- + // pan, balance + //--------------------------------------------------- + + if (_align) + grid->setRowMinimumHeight(4, STRIP_WIDTH); + + //--------------------------------------------------- + // sync + // mute, solo + //--------------------------------------------------- + + mute = newMuteButton(); + mute->setChecked(track->isMute()); + mute->setFixedHeight(BUTTON_HEIGHT); + connect(mute, SIGNAL(clicked(bool)), SLOT(muteToggled(bool))); + + solo = newSoloButton(); + solo->setFixedHeight(BUTTON_HEIGHT); + solo->setChecked(track->solo()); + connect(solo, SIGNAL(clicked(bool)), SLOT(soloToggled(bool))); + + grid->addWidget(mute, 5, 0); + grid->addWidget(solo, 5, 1); + + //--------------------------------------------------- + // automation mode + //--------------------------------------------------- + + addAutomationButtons(6); + + //--------------------------------------------------- + // output routing + //--------------------------------------------------- + + iR = newInRouteButton(); + grid->addWidget(iR, 7, 0); + connect(iR->menu(), SIGNAL(aboutToShow()), SLOT(iRouteShow())); + connect(iR->menu(), SIGNAL(triggered(QAction*)), song, SLOT(routeChanged(QAction*))); + + oR = newOutRouteButton(); + grid->addWidget(oR, 7, 1); + connect(oR->menu(), SIGNAL(aboutToShow()), SLOT(oRouteShow())); + connect(oR->menu(), SIGNAL(triggered(QAction*)), song, SLOT(routeChanged(QAction*))); + + connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int))); + connect(track, SIGNAL(muteChanged(bool)), mute, SLOT(setChecked(bool))); + connect(track, SIGNAL(soloChanged(bool)), solo, SLOT(setChecked(bool))); + connect(track, SIGNAL(autoReadChanged(bool)), SLOT(autoChanged())); + connect(track, SIGNAL(autoWriteChanged(bool)), SLOT(autoChanged())); + autoChanged(); + } + +//--------------------------------------------------------- +// songChanged +//--------------------------------------------------------- + +void MidiSyntiStrip::songChanged(int val) + { + if (val & SC_TRACK_MODIFIED) + updateLabel(); + } + +//--------------------------------------------------------- +// heartBeat +//--------------------------------------------------------- + +void MidiSyntiStrip::heartBeat() + { + double a = track->meter(0); // fast_log10(track->meter(0)) * .2f; + slider->setMeterVal(a * 0.008); + track->setMeter(0, a * 0.8); // hack + } + +//--------------------------------------------------------- +// ctrlChanged +//--------------------------------------------------------- + +void MidiSyntiStrip::ctrlChanged(double val, int num) + { + int ival = int(val); + CVal cval; + cval.i = ival; + song->setControllerVal(track, num, cval); + } + +//--------------------------------------------------------- +// sliderPressed +//--------------------------------------------------------- + +void MidiSyntiStrip::sliderPressed(int id) + { + switch (id) { + case CTRL_MASTER_VOLUME: volumeTouched = true; break; + } + track->startAutoRecord(id); + } + +//--------------------------------------------------------- +// sliderReleased +//--------------------------------------------------------- + +void MidiSyntiStrip::sliderReleased(int id) + { + switch (id) { + case CTRL_MASTER_VOLUME: volumeTouched = false; break; + } + track->stopAutoRecord(id); + } + +//--------------------------------------------------------- +// muteToggled +//--------------------------------------------------------- + +void MidiSyntiStrip::muteToggled(bool val) + { + song->setMute(track, val); + } + +//--------------------------------------------------------- +// soloToggled +//--------------------------------------------------------- + +void MidiSyntiStrip::soloToggled(bool val) + { + song->setSolo(track, val); + } + +//--------------------------------------------------------- +// autoChanged +//--------------------------------------------------------- + +void MidiSyntiStrip::autoChanged() + { + bool ar = track->autoRead(); + bool aw = track->autoWrite(); + + // controller are enabled if + // autoRead is off + // autoRead and autoWrite are on (touch mode) + + bool ec = !ar || (ar && aw); + slider->setEnabled(ec); + sl->setEnabled(ec); + } + +//--------------------------------------------------------- +// autoReadToggled +//--------------------------------------------------------- + +void MidiSyntiStrip::autoReadToggled(bool val) + { + song->setAutoRead(track, val); + } + +//--------------------------------------------------------- +// autoWriteToggled +//--------------------------------------------------------- + +void MidiSyntiStrip::autoWriteToggled(bool val) + { + song->setAutoWrite(track, val); + } + +//--------------------------------------------------------- +// controllerChanged +//--------------------------------------------------------- + +void MidiSyntiStrip::controllerChanged(int id) + { + if (id == CTRL_MASTER_VOLUME) { + double val = double(track->ctrlVal(id).i); + if (!volumeTouched) + slider->setValue(val); + sl->setValue(val); + } + } + +//--------------------------------------------------------- +// oRouteShow +//--------------------------------------------------------- + +void MidiSyntiStrip::oRouteShow() + { + QMenu* pup = oR->menu(); + pup->clear(); + pup->addSeparator()->setText(tr("OutputPorts")); + + MidiOutPortList* mpl = song->midiOutPorts(); + int pn = 0; + for (iMidiOutPort i = mpl->begin(); i != mpl->end(); ++i, ++pn) { + MidiOutPort* op = *i; + QMenu* m = pup->addMenu(op->name()); + m->addSeparator()->setText(tr("Channel")); +#if 0 //TODO + for (int channel = 0; channel < MIDI_CHANNELS; ++channel) { + QString s; + s.setNum(channel+1); + QAction* action = m->addAction(s); + MidiChannel* mc = op->channel(channel); + Route r(mc, -1, Route::TRACK); + action->setData(QVariant::fromValue(r)); + action->setCheckable(true); + + for (iRoute ir = orl->begin(); ir != orl->end(); ++ir) { + if (r == *ir) { + action->setChecked(true); + break; + } + } + } +#endif + } + } + +//--------------------------------------------------------- +// iRouteShow +//--------------------------------------------------------- + +void MidiSyntiStrip::iRouteShow() + { + QMenu* pup = oR->menu(); + pup->clear(); + + pup->addSeparator()->setText(tr("Input Ports")); + MidiOutPort* t = (MidiOutPort*)track; + + for (int ch = 0; ch < MIDI_CHANNELS; ++ch) { + QMenu* m = pup->addMenu(QString("Channel %1").arg(ch+1)); + addMidiTracks(m, t, ch, false); + addMidiInPorts(m, t, ch); + } + } diff --git a/muse/muse/mstrip.h b/muse/muse/mstrip.h new file mode 100644 index 00000000..4c3269de --- /dev/null +++ b/muse/muse/mstrip.h @@ -0,0 +1,192 @@ +//============================================================================= +// MusE +// Linux Music Editor +// $Id:$ +// +// Copyright (C) 2002-2006 by Werner Schweer and others +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2. +// +// 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., 675 Mass Ave, Cambridge, MA 02139, USA. +//============================================================================= + +#ifndef __MSTRIP_H__ +#define __MSTRIP_H__ + +#include "strip.h" + +namespace Awl { + class MidiMeterSlider; + class MidiMeter; + class FloatEntry; + class MidiVolEntry; + class Knob; + }; + +class MidiTrack; +class MidiOutPort; +class MidiInPort; +class MidiChannel; +class MidiSynti; + +//--------------------------------------------------------- +// MidiStrip +//--------------------------------------------------------- + +class MidiStrip : public Strip { + Q_OBJECT + + Awl::MidiMeterSlider* slider; + Awl::MidiVolEntry* sl; + QToolButton* iR; + QToolButton* oR; + + struct KNOB { + Awl::Knob* knob; + Awl::FloatEntry* dl; + QLabel* lb; + } controller[4]; // pan variation reverb chorus + + bool volumeTouched; + bool panTouched; + bool reverbSendTouched; + bool variSendTouched; + bool chorusSendTouched; + + void addKnob(int ctrl, int idx, const QString&, const QString&, const char*, bool, int row); + + private slots: + virtual void controllerChanged(int id); + void ctrlChanged(double val, int num); + void muteToggled(bool); + void soloToggled(bool); + void autoChanged(); + void sliderPressed(int); + void sliderReleased(int); + void autoReadToggled(bool); + void autoWriteToggled(bool); + void iRouteShow(); + void iRouteHide(); + void oRouteShow(); + void oRouteHide(); + void recordToggled(bool); + void monitorToggled(bool); + + public slots: + virtual void songChanged(int); + + public: + MidiStrip(Mixer*, MidiTrack*, bool align = true); + virtual void heartBeat(); + }; + +//--------------------------------------------------------- +// MidiOutPortStrip +//--------------------------------------------------------- + +class MidiOutPortStrip : public Strip { + Q_OBJECT + + Awl::MidiMeterSlider* slider; + Awl::MidiVolEntry* sl; + QToolButton* oR; + QToolButton* iR; + SimpleButton* sync; + + bool volumeTouched; + + private slots: + virtual void controllerChanged(int id); + void ctrlChanged(double val, int num); + void muteToggled(bool); + void soloToggled(bool); + void autoChanged(); + void sliderPressed(int); + void sliderReleased(int); + void autoReadToggled(bool); + void autoWriteToggled(bool); + void iRouteShow(); + void oRouteShow(); + void syncToggled(bool) const; + + public slots: + virtual void songChanged(int); + + public: + MidiOutPortStrip(Mixer*, MidiOutPort*, bool align = true); + virtual void heartBeat(); + }; + +//--------------------------------------------------------- +// MidiSyntiStrip +//--------------------------------------------------------- + +class MidiSyntiStrip : public Strip { + Q_OBJECT + + Awl::MidiMeterSlider* slider; + Awl::MidiVolEntry* sl; + QToolButton* iR; + QToolButton* oR; + + bool volumeTouched; + + private slots: + virtual void controllerChanged(int id); + void ctrlChanged(double val, int num); + void muteToggled(bool); + void soloToggled(bool); + void autoChanged(); + void sliderPressed(int); + void sliderReleased(int); + void autoReadToggled(bool); + void autoWriteToggled(bool); + void iRouteShow(); + void oRouteShow(); + + public slots: + virtual void songChanged(int); + + public: + MidiSyntiStrip(Mixer*, MidiSynti*, bool align = true); + virtual void heartBeat(); + }; + +//--------------------------------------------------------- +// MidiInPortStrip +//--------------------------------------------------------- + +class MidiInPortStrip : public Strip { + Q_OBJECT + + bool activity[MIDI_CHANNELS]; + QPixmap* activityOn; + QPixmap* activityOff; + QLabel* channelActivity[MIDI_CHANNELS]; + QToolButton* iR; + QToolButton* oR; + MidiInPort* inport() const { return (MidiInPort*)track; } + + private slots: + void muteToggled(bool); + void soloToggled(bool); + void iRouteShow(); + void oRouteShow(); + + public slots: + virtual void songChanged(int); + + public: + MidiInPortStrip(Mixer*, MidiInPort*, bool align = true); + virtual void heartBeat(); + }; + +#endif diff --git a/muse/muse/muse.cpp b/muse/muse/muse.cpp index c6dbc103..c025491e 100644 --- a/muse/muse/muse.cpp +++ b/muse/muse/muse.cpp @@ -33,7 +33,7 @@ #include "liste/listedit.h" #include "master/masteredit.h" #include "midiedit/drumedit.h" -#include "mixer/mixer.h" +#include "mixer.h" #include "audiodev.h" #include "waveedit/waveedit.h" #include "icons.h" @@ -63,7 +63,7 @@ #include "midiedit/miditracker.h" #include "projectpropsdialog.h" #include "liste/listedit.h" -#include "mixer/strip.h" +#include "strip.h" extern void initMidiInstruments(); diff --git a/muse/muse/preferences.cpp b/muse/muse/preferences.cpp index ef3d23b1..6b7580d5 100644 --- a/muse/muse/preferences.cpp +++ b/muse/muse/preferences.cpp @@ -32,7 +32,7 @@ #include "gconfig.h" #include "audio.h" -#include "mixer/mixer.h" +#include "mixer.h" #include "midirc.h" #include "instruments/minstrument.h" #include "midiedit/pianoroll.h" diff --git a/muse/muse/rack.cpp b/muse/muse/rack.cpp new file mode 100644 index 00000000..dbd76804 --- /dev/null +++ b/muse/muse/rack.cpp @@ -0,0 +1,445 @@ +//============================================================================= +// MusE +// Linux Music Editor +// $Id:$ +// +// Copyright (C) 2002-2006 by Werner Schweer and others +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2. +// +// 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., 675 Mass Ave, Cambridge, MA 02139, USA. +//============================================================================= + +#include "rack.h" +#include "song.h" +#include "audio.h" +#include "icons.h" +#include "gconfig.h" +#include "pipeline.h" +#include "auxplugin.h" +#include "plugingui.h" +#include "widgets/filedialog.h" +#include "muse.h" +#include "gui.h" + +static const int PipelineDepth = 4; + +//--------------------------------------------------------- +// EffectRack +//--------------------------------------------------------- + +EffectRack::EffectRack(QWidget* parent, AudioTrack* t, bool flag) + : QListWidget(parent) + { + setUniformItemSizes(true); + setAlternatingRowColors(true); + prefader = flag; + setAttribute(Qt::WA_DeleteOnClose, true); + verticalScrollBar()->setStyle(smallStyle); + + track = t; +// setFont(config.fonts[1]); + + setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); + + setSelectionMode(QAbstractItemView::SingleSelection); + songChanged(SC_RACK); // force update + connect(this, SIGNAL(itemDoubleClicked(QListWidgetItem*)), + this, SLOT(doubleClicked(QListWidgetItem*))); + connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int))); + setToolTip(tr("effect rack")); + setAcceptDrops(true); + } + +//--------------------------------------------------------- +// sizeHint +//--------------------------------------------------------- + +QSize EffectRack::sizeHint() const + { + QFontMetrics fm(font()); + int h = fm.lineSpacing() * PipelineDepth + 1; + return QSize(STRIP_WIDTH, h); + } + +//--------------------------------------------------------- +// songChanged +//--------------------------------------------------------- + +void EffectRack::songChanged(int typ) + { + if (!(typ & (SC_ROUTE | SC_RACK))) + return; + + clear(); + Pipeline* pipe = prefader ? track->prePipe() : track->postPipe(); + foreach (PluginI* plugin, *pipe) { + QListWidgetItem* item = new QListWidgetItem(this); + item->setText(plugin->name()); + // tooltip should only be set if name does not fit + // (is elided) + item->setToolTip(plugin->name()); + item->setBackgroundColor(plugin->on() ? Qt::white : Qt::gray); + } + } + +//--------------------------------------------------------- +// menuRequested +//--------------------------------------------------------- + +void EffectRack::contextMenuEvent(QContextMenuEvent* ev) + { + QPoint pt(ev->pos()); + QListWidgetItem* item = itemAt(pt); + + int idx = -1; + QString name; + Pipeline* pipe = prefader ? track->prePipe() : track->postPipe(); + + QMenu* menu = new QMenu; + QAction* upAction = menu->addAction(QIcon(*upIcon), tr("move up")); + QAction* downAction = menu->addAction(QIcon(*downIcon), tr("move down")); + QAction* removeAction = menu->addAction(tr("remove")); + menu->addSeparator(); + QAction* bypassAction = menu->addAction(tr("bypass")); + QAction* showAction = menu->addAction(tr("show gui")); + QAction* showCustomAction = menu->addAction(tr("show native gui")); + menu->addSeparator(); + QAction* newAction = menu->addAction(tr("New Plugin")); + QAction* auxAction = menu->addAction(tr("New Aux Send")); + + bypassAction->setCheckable(true); + showAction->setCheckable(true); + showCustomAction->setCheckable(true); + + if (!item) { + upAction->setEnabled(false); + downAction->setEnabled(false); + removeAction->setEnabled(false); + bypassAction->setEnabled(false); + showAction->setEnabled(false); + showCustomAction->setEnabled(false); + } + else { + idx = row(item); + upAction->setEnabled(idx != 0); + downAction->setEnabled(idx < pipe->size()-1); + idx = item->type(); + showCustomAction->setEnabled(pipe->hasNativeGui(idx)); + bypassAction->setEnabled(true); + showAction->setEnabled(true); + + bypassAction->setChecked(!pipe->isOn(idx)); + showAction->setChecked(pipe->guiVisible(idx)); + showCustomAction->setChecked(pipe->nativeGuiVisible(idx)); + } + if (track->type() != Track::WAVE && track->type() != Track::AUDIO_INPUT) + auxAction->setEnabled(false); + + QAction* sel = menu->exec(mapToGlobal(pt), newAction); + delete menu; + if (sel == 0) + return; + + if (sel == newAction) { + selectNew(); + return; + } + if (sel == removeAction) { + audio->msgAddPlugin(track, idx, 0, prefader); + } + else if (sel == bypassAction) { + bool flag = !pipe->isOn(idx); + pipe->setOn(idx, flag); + } + else if (sel == showAction) { + bool flag = !pipe->guiVisible(idx); + pipe->showGui(idx, flag); + } + else if (sel == showCustomAction) { + bool flag = !pipe->nativeGuiVisible(idx); + pipe->showNativeGui(idx, flag); + } + else if (sel == upAction) { + if (idx > 0) { + setCurrentRow(idx-1); + pipe->move(idx, true); + } + } + else if (sel == downAction) { + if (idx < (PipelineDepth-1)) { + setCurrentRow(idx+1); + pipe->move(idx, false); + } + } + else if (sel == auxAction) + addPlugin(auxPlugin); + song->update(SC_RACK); + } + +//--------------------------------------------------------- +// doubleClicked +// toggle gui and open requester if needed. +//--------------------------------------------------------- + +void EffectRack::doubleClicked(QListWidgetItem* it) + { + if (track == 0) + return; + int idx = row(it); + Pipeline* pipe = prefader ? track->prePipe() : track->postPipe(); + bool flag = !pipe->guiVisible(idx); + pipe->showGui(idx, flag); + } + +//--------------------------------------------------------- +// startDrag +//--------------------------------------------------------- + +void EffectRack::startDrag(int idx) + { + QString buffer; + AL::Xml xml(NULL); + xml.setString(&buffer); + Pipeline* pipe = prefader ? track->prePipe() : track->postPipe(); + if (pipe) { + if ((*pipe)[idx] != NULL) { + PluginI *plug = (*pipe)[idx]; + xml.header(); + xml.stag("muse version=\"1.0\""); + // header info + plug->writeConfiguration1(xml, prefader); // wC1 does not append endtag + // parameters + int noParams = plug->plugin()->parameter(); + for (int i=0;igetParameterName(i)); + fval.setNum(plug->param(i)); // wierd stuff to avoid localization + QString str=""; + xml.put(str.toLatin1().data()); + printf("%s\n",str.toLatin1().data()); + } + xml.etag("plugin"); + + xml.etag("muse"); + } + else { + //printf("no plugin!\n"); + return; + } + } + else { + //printf("no pipe!\n"); + return; + } + //printf("and i wish you were here: %s\n", xml.readAll().toLatin1().data()); + QByteArray xmldump = xml.readAll().toLatin1(); + //printf("xmldump=%s\n",xmldump.data()); + QDrag *drag = new QDrag(this); + QMimeData *mime = new QMimeData(); + mime->setData("text/x-muse-plugin", xmldump); + drag->setMimeData(mime); +/* Qt::DropAction dropAction =*/ drag->start(); + } + +//--------------------------------------------------------- +// startDrag +//--------------------------------------------------------- + +void EffectRack::dropEvent(QDropEvent *event) + { + // printf("drop!\n"); + QString text; + QListWidgetItem* i = itemAt( (event->pos()) ); + int idx = -1; + if (i) + idx = row(i); + + Pipeline* pipe = prefader ? track->prePipe() : track->postPipe(); + if (pipe) { + if (i) { + if(!QMessageBox::question(this, tr("Replace effect"),tr("Do you really want to replace the effect %1?").arg(pipe->name(idx)), + tr("&Yes"), tr("&No"), + QString::null, 0, 1 )) + { + audio->msgAddPlugin(track, idx, 0, prefader); + song->update(SC_RACK); + } + else { + printf("nothing here\n"); + return; + } + } + if(event->mimeData()->hasText()) + { + //printf("has text\n"); + text = event->mimeData()->text().trimmed(); + if (QString(text).endsWith(".pre")) + { + QUrl url(text); + QString newPath = url.path(); + + QFile xmlfile(newPath); + xmlfile.open(QIODevice::ReadOnly); + QDomDocument doc; + doc.setContent(&xmlfile); + QDomNode node = doc.documentElement().firstChild(); + initPlugin(node, idx); + } + } + else if (event->mimeData()->hasFormat("text/x-muse-plugin")) + { + QByteArray outxml = event->mimeData()->data("text/x-muse-plugin"); + //printf("DATA:%s\n",outxml.data()); + QDomDocument doc; + doc.setContent(outxml); + QDomNode node = doc.documentElement().firstChild(); + + initPlugin(node, idx); + } + } + } + +//--------------------------------------------------------- +// dragEnterEvent +//--------------------------------------------------------- +void EffectRack::dragEnterEvent(QDragEnterEvent *event) + { + //printf("dragEnterEvent\n"); + //if (event->mimeData()->hasFormat("text/x-muse-plugin")) + event->acceptProposedAction(); + } + +//--------------------------------------------------------- +// dragMoveEvent +//--------------------------------------------------------- +void EffectRack::dragMoveEvent(QDragMoveEvent *event) + { + //printf("dragMoveEvent\n"); + //if (event->mimeData()->hasFormat("text/x-muse-plugin")) + event->acceptProposedAction(); + } + +//--------------------------------------------------------- +// contentsMousePressEvent +//--------------------------------------------------------- +void EffectRack::mousePressEvent(QMouseEvent *event) + { + //printf("mousePressEvent\n"); + if(event->button() & Qt::LeftButton) { + dragPos = event->pos(); + } + QListWidget::mousePressEvent(event); + } + +//--------------------------------------------------------- +// contentsMouseMoveEvent +//--------------------------------------------------------- +void EffectRack::mouseMoveEvent(QMouseEvent *event) + { + if (event->buttons() & Qt::LeftButton) { + int distance = (dragPos-event->pos()).manhattanLength(); + if (distance > QApplication::startDragDistance()) { + QListWidgetItem *i = itemAt( event->pos() ); + int idx = row(i); + startDrag(idx); + } + } + QListWidget::mouseMoveEvent(event); + } + + +//--------------------------------------------------------- +// initPlugin +//--------------------------------------------------------- + +void EffectRack::initPlugin(QDomNode &node, int idx) + { + QDomElement e = node.toElement(); + //QString version = e.attribute("version"); + QString file = e.attribute("file"); + QString label = e.attribute("label"); + + //printf("version=%s file=%s label=%s channel=%d\n",version.toLatin1().data(),file.toLatin1().data(), label.toLatin1().data(), channel); + + //Plugin* plugin = PluginDialog::getPlugin(this); + Plugin* plugin = plugins.find(file, label); + if (plugin) { + PluginI* plugi = new PluginI(track); + if (plugi->initPluginInstance(plugin, track->channels())) { + printf("cannot instantiate plugin <%s>\n", + plugin->name().toLatin1().data()); + delete plugi; + } + else { + audio->msgAddPlugin(track, idx, plugi, prefader); + song->update(SC_RACK); + int i = 0; + for (QDomNode n = node.firstChild(); !n.isNull(); n = n.nextSibling()) { + QDomElement e = n.toElement(); + if (e.nodeName() == "control") { + //QString name = e.attribute("name"); // currently this value is just thrown. + QString value = e.attribute("val"); + QLocale::setDefault(QLocale::C); + double val = value.toFloat(); + CVal cval; + cval.f = val; + song->setControllerVal(plugi->track(), plugi->controller(i), cval); + i++; + } + } + } + } + } + +//--------------------------------------------------------- +// mouseDoubleClickEvent +//--------------------------------------------------------- + +void EffectRack::mouseDoubleClickEvent(QMouseEvent* event) + { + QListWidgetItem* it = itemAt(event->pos()); + if (it || (track == 0)) { + QListWidget::mouseDoubleClickEvent(event); + return; + } + selectNew(); + } + +//--------------------------------------------------------- +// selectNew +//--------------------------------------------------------- + +void EffectRack::selectNew() + { + Plugin* plugin = PluginDialog::getPlugin(this); + addPlugin(plugin); + song->update(SC_RACK); + } + +//--------------------------------------------------------- +// addPlugin +//--------------------------------------------------------- + +void EffectRack::addPlugin(Plugin* plugin) + { + if (plugin == 0) + return; + PluginI* plugi = new PluginI(track); + if (plugi->initPluginInstance(plugin, track->channels())) { + printf("cannot instantiate plugin <%s>\n", + plugin->name().toLatin1().data()); + delete plugi; + } + else + audio->msgAddPlugin(track, -1, plugi, prefader); + } + diff --git a/muse/muse/rack.h b/muse/muse/rack.h new file mode 100644 index 00000000..c468d8b9 --- /dev/null +++ b/muse/muse/rack.h @@ -0,0 +1,66 @@ +//============================================================================= +// MusE +// Linux Music Editor +// $Id:$ +// +// Copyright (C) 2002-2006 by Werner Schweer and others +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2. +// +// 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., 675 Mass Ave, Cambridge, MA 02139, USA. +//============================================================================= + +#ifndef __RACK_H__ +#define __RACK_H__ + +#include + +class AudioTrack; +class Plugin; + +//--------------------------------------------------------- +// EffectRack +//--------------------------------------------------------- + +class EffectRack : public QListWidget { + Q_OBJECT + + bool prefader; + AudioTrack* track; + + QPoint dragPos; + + virtual void contextMenuEvent(QContextMenuEvent*); + virtual void mouseDoubleClickEvent(QMouseEvent*); + void selectNew(); + + void startDrag(int idx); + void initPlugin(QDomNode &node, int idx); + void addPlugin(Plugin* plugin); + + private slots: + void doubleClicked(QListWidgetItem*); + void songChanged(int); + + protected: + void dropEvent(QDropEvent *event); + void dragEnterEvent(QDragEnterEvent *event); + void mousePressEvent(QMouseEvent *event); + void mouseMoveEvent(QMouseEvent *event); + void dragMoveEvent(QDragMoveEvent *event); + + public: + EffectRack(QWidget*, AudioTrack*, bool); + QSize sizeHint() const; + }; + +#endif + diff --git a/muse/muse/routedialog.cpp b/muse/muse/routedialog.cpp new file mode 100644 index 00000000..a2f3b584 --- /dev/null +++ b/muse/muse/routedialog.cpp @@ -0,0 +1,196 @@ +//============================================================================= +// MusE +// Linux Music Editor +// $Id:$ +// +// Copyright (C) 2002-2006 by Werner Schweer and others +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2. +// +// 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., 675 Mass Ave, Cambridge, MA 02139, USA. +//============================================================================= + +#include "routedialog.h" +#include "track.h" +#include "song.h" +#include "audio.h" +#include "jackaudio.h" + +//--------------------------------------------------------- +// RouteDialog +//--------------------------------------------------------- + +RouteDialog::RouteDialog(QWidget* parent) + : QDialog(parent) + { + setupUi(this); + connect(routeList, SIGNAL(selectionChanged()), SLOT(routeSelectionChanged())); + connect(newSrcList, SIGNAL(selectionChanged()), SLOT(srcSelectionChanged())); + connect(newDstList, SIGNAL(selectionChanged()), SLOT(dstSelectionChanged())); + connect(removeButton, SIGNAL(clicked()), SLOT(removeRoute())); + connect(connectButton, SIGNAL(clicked()), SLOT(addRoute())); + connect(song, SIGNAL(songChanged(int)), SLOT(songChanged(int))); + routingChanged(); + } + +//--------------------------------------------------------- +// routingChanged +//--------------------------------------------------------- + +void RouteDialog::routingChanged() + { + //--------------------------------------------------- + // populate lists + //--------------------------------------------------- + + routeList->clear(); + newSrcList->clear(); + newDstList->clear(); + +#if 0 //TODO3 + TrackList* tl = song->tracks(); + for (ciTrack i = tl->begin(); i != tl->end(); ++i) { + if ((*i)->isMidiTrack()) + continue; + Track* track = *i; + if (track->type() == Track::AUDIO_INPUT) { + for (int channel = 0; channel < track->channels(); ++channel) + newDstList->insertItem(Route(track, channel).name()); + const RouteList* rl = track->inRoutes(); + for (ciRoute r = rl->begin(); r != rl->end(); ++r) { + Route dst(track->name(), r->channel, Route::AUDIOPORT); + new QListWidgetItem(routeList, r->name(), dst.name()); + } + } + else + newDstList->insertItem(Route(track, -1).name()); + if (track->type() == Track::AUDIO_OUTPUT) { + for (int channel = 0; channel < track->channels(); ++channel) { + Route r(track, channel); + newSrcList->insertItem(r.name()); + } + } + else + newSrcList->insertItem(Route(track, -1).name()); + + const RouteList* rl = track->outRoutes(); + for (ciRoute r = rl->begin(); r != rl->end(); ++r) { + QString src(track->name()); + if (track->type() == Track::AUDIO_OUTPUT) { + Route s(src, r->channel, Route::AUDIOPORT); + src = s.name(); + } + new QListWidgetItem(routeList, src, r->name()); + } + } + + std::list sl = audioDriver->outputPorts(); + for (std::list::iterator i = sl.begin(); i != sl.end(); ++i) + newSrcList->insertItem(*i); + sl = audioDriver->inputPorts(); + for (std::list::iterator i = sl.begin(); i != sl.end(); ++i) + newDstList->insertItem(*i); +#endif + routeSelectionChanged(); // init remove button + srcSelectionChanged(); // init select button + } + +//--------------------------------------------------------- +// songChanged +//--------------------------------------------------------- + +void RouteDialog::songChanged(int v) + { + if (v & (SC_TRACK_INSERTED | SC_TRACK_REMOVED | SC_ROUTE)) { + routingChanged(); + } + } + +//--------------------------------------------------------- +// routeSelectionChanged +//--------------------------------------------------------- + +void RouteDialog::routeSelectionChanged() + { +//TD QListWidgetItem* item = routeList->selectedItem(); +// removeButton->setEnabled(item != 0); + } + +//--------------------------------------------------------- +// removeRoute +//--------------------------------------------------------- + +void RouteDialog::removeRoute() + { +#if 0 //TD + QListWidgetItem* item = routeList->selectedItem(); + if (item == 0) + return; + audio->msgRemoveRoute(Route(item->text(0), -1, Route::TRACK), Route(item->text(1), -1, Route::AUDIOPORT)); + delete item; +#endif + } + +//--------------------------------------------------------- +// addRoute +//--------------------------------------------------------- + +void RouteDialog::addRoute() + { +#if 0 //TD + QListWidgetItem* srcItem = newSrcList->selectedItem(); + QListWidgetItem* dstItem = newDstList->selectedItem(); + if (srcItem == 0 || dstItem == 0) + return; + audio->msgAddRoute(Route(srcItem->text(), -1, Route::TRACK), Route(dstItem->text(), -1, Route::AUDIOPORT)); + new QListWidgetItem(routeList, srcItem->text(), dstItem->text()); +#endif + } + +//--------------------------------------------------------- +// srcSelectionChanged +//--------------------------------------------------------- + +void RouteDialog::srcSelectionChanged() + { +#if 0 //TD + QListWidgetItem* srcItem = newSrcList->selectedItem(); + QListWidgetItem* dstItem = newDstList->selectedItem(); + connectButton->setEnabled((srcItem != 0) + && (dstItem != 0) + && checkRoute(srcItem->text(), dstItem->text())); +#endif + } + +//--------------------------------------------------------- +// dstSelectionChanged +//--------------------------------------------------------- + +void RouteDialog::dstSelectionChanged() + { +#if 0 //TD + QListWidgetItem* dstItem = newDstList->selectedItem(); + QListWidgetItem* srcItem = newSrcList->selectedItem(); + connectButton->setEnabled((srcItem != 0) + && (dstItem != 0) + && checkRoute(srcItem->text(), dstItem->text())); +#endif + } + +//--------------------------------------------------------- +// closeEvent +//--------------------------------------------------------- + +void RouteDialog::closeEvent(QCloseEvent* e) + { + emit closed(); + e->accept(); + } diff --git a/muse/muse/routedialog.h b/muse/muse/routedialog.h new file mode 100644 index 00000000..2bcbf471 --- /dev/null +++ b/muse/muse/routedialog.h @@ -0,0 +1,53 @@ +//============================================================================= +// MusE +// Linux Music Editor +// $Id:$ +// +// Copyright (C) 2002-2006 by Werner Schweer and others +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2. +// +// 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., 675 Mass Ave, Cambridge, MA 02139, USA. +//============================================================================= + +#ifndef __ROUTEDIALOG_H__ +#define __ROUTEDIALOG_H__ + +#include "ui_routedialog.h" + +//--------------------------------------------------------- +// RouteDialog +//--------------------------------------------------------- + +class RouteDialog : public QDialog, public Ui::RouteDialogBase { + Q_OBJECT + + virtual void closeEvent(QCloseEvent*); + void routingChanged(); + + private slots: + void routeSelectionChanged(); + void removeRoute(); + void addRoute(); + void srcSelectionChanged(); + void dstSelectionChanged(); + void songChanged(int); + + signals: + void closed(); + + public: + RouteDialog(QWidget* parent); + }; + + +#endif + diff --git a/muse/muse/routedialog.ui b/muse/muse/routedialog.ui new file mode 100644 index 00000000..be34c451 --- /dev/null +++ b/muse/muse/routedialog.ui @@ -0,0 +1,170 @@ + + + + + RouteDialogBase + + + + 0 + 0 + 316 + 383 + + + + + 5 + 7 + 0 + 0 + + + + MusE: Routing + + + + 4 + + + 4 + + + + + Add Route + + + + 4 + + + 4 + + + + + 0 + + + 6 + + + + + + 7 + 7 + 0 + 0 + + + + Source: + + + + 2 + + + 0 + + + + + + + + + + + + 7 + 7 + 0 + 0 + + + + Destination: + + + + 2 + + + 0 + + + + + + + + + + + + + + 4 + 1 + 0 + 0 + + + + connect source to destination + + + Connect + + + + + + + + + + Current Routes + + + + 4 + + + 4 + + + + + + + + + 4 + 1 + 0 + 0 + + + + remove selected route + + + Remove + + + + + + + + + + qPixmapFromMimeSource + + + diff --git a/muse/muse/seqmsg.cpp b/muse/muse/seqmsg.cpp index 4df58e89..adf2a66e 100644 --- a/muse/muse/seqmsg.cpp +++ b/muse/muse/seqmsg.cpp @@ -21,7 +21,7 @@ #include "song.h" #include "instruments/minstrument.h" #include "muse.h" -#include "mixer/mixer.h" +#include "mixer.h" #include "al/tempo.h" #include "al/sig.h" #include "audio.h" diff --git a/muse/muse/song.cpp b/muse/muse/song.cpp index dd78cc5c..79e1f563 100644 --- a/muse/muse/song.cpp +++ b/muse/muse/song.cpp @@ -26,7 +26,7 @@ #include "event.h" #include "midiedit/drummap.h" #include "audio.h" -#include "mixer/mixer.h" +#include "mixer.h" #include "audiodev.h" #include "gconfig.h" #include "al/marker.h" diff --git a/muse/muse/strip.cpp b/muse/muse/strip.cpp new file mode 100644 index 00000000..38519878 --- /dev/null +++ b/muse/muse/strip.cpp @@ -0,0 +1,123 @@ +//============================================================================= +// MusE +// Linux Music Editor +// $Id:$ +// +// Copyright (C) 2002-2006 by Werner Schweer and others +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2. +// +// 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., 675 Mass Ave, Cambridge, MA 02139, USA. +//============================================================================= + +#include "gconfig.h" +#include "song.h" +#include "strip.h" +#include "muse.h" +#include "widgets/simplebutton.h" +#include "widgets/utils.h" + +//--------------------------------------------------------- +// resetPeaks +//--------------------------------------------------------- + +void Strip::resetPeaks() + { + track->resetPeaks(); + } + +//--------------------------------------------------------- +// updateLabel +//--------------------------------------------------------- + +void Strip::updateLabel() + { + label->setText(track->name()); + label->setToolTip(track->name()); + } + +//--------------------------------------------------------- +// Strip +// create mixer strip +//--------------------------------------------------------- + +Strip::Strip(Mixer* m, Track* t, bool align) + : QFrame() + { + ar = 0; + aw = 0; + setAttribute(Qt::WA_DeleteOnClose, true); + mixer = m; + _align = align; + setFrameStyle(QFrame::Panel | QFrame::Raised); + setLineWidth(2); + + track = t; + grid = new QGridLayout; + grid->setMargin(0); + grid->setSpacing(0); + setLayout(grid); + + //--------------------------------------------- + // label + //--------------------------------------------- + + label = new QLabel; + label->setObjectName(track->cname()); + label->setFixedHeight(LABEL_HEIGHT); + label->setTextFormat(Qt::PlainText); + label->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); + label->setLineWidth(2); + label->setFrameStyle(QFrame::Sunken | QFrame::StyledPanel); + updateLabel(); + grid->addWidget(label, 0, 0, 1, 2); + connect(muse, SIGNAL(configChanged()), SLOT(configChanged())); + connect(track, SIGNAL(controllerChanged(int)), SLOT(controllerChanged(int))); + } + +//--------------------------------------------------------- +// Strip +//--------------------------------------------------------- + +Strip::~Strip() + { + } + +//--------------------------------------------------------- +// configChanged +//--------------------------------------------------------- + +void Strip::configChanged() + { + updateLabel(); + } + +//--------------------------------------------------------- +// addAutomationButtons +//--------------------------------------------------------- + +void Strip::addAutomationButtons(int row) + { + ar = newAutoReadButton(); + ar->setFixedHeight(BUTTON_HEIGHT); + ar->setChecked(track->autoRead()); + grid->addWidget(ar, row, 0); + aw = newAutoWriteButton(); + aw->setFixedHeight(BUTTON_HEIGHT); + aw->setChecked(track->autoWrite()); + grid->addWidget(aw, row, 1); + connect(ar, SIGNAL(clicked(bool)), SLOT(autoReadToggled(bool))); + connect(aw, SIGNAL(clicked(bool)), SLOT(autoWriteToggled(bool))); + connect(track, SIGNAL(autoReadChanged(bool)), ar, SLOT(setChecked(bool))); + connect(track, SIGNAL(autoWriteChanged(bool)), aw, SLOT(setChecked(bool))); + } + + diff --git a/muse/muse/strip.h b/muse/muse/strip.h new file mode 100644 index 00000000..f9bc06ea --- /dev/null +++ b/muse/muse/strip.h @@ -0,0 +1,74 @@ +//============================================================================= +// MusE +// Linux Music Editor +// $Id:$ +// +// Copyright (C) 2002-2006 by Werner Schweer and others +// +// This program is free software; you can redistribute it and/or modify +// it under the terms of the GNU General Public License version 2. +// +// 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., 675 Mass Ave, Cambridge, MA 02139, USA. +//============================================================================= + +#ifndef __STRIP_H__ +#define __STRIP_H__ + +#include "globaldefs.h" +#include "gui.h" + +class Track; +class Meter; +class SimpleButton; +class Mixer; + +// static const QSize buttonSize(STRIP_WIDTH/2-2, BUTTON_HEIGHT); +static const QSize entrySize(STRIP_WIDTH/2-2, ENTRY_HEIGHT); + +//--------------------------------------------------------- +// Strip +//--------------------------------------------------------- + +class Strip : public QFrame { + Q_OBJECT + + protected: + Mixer* mixer; + Track* track; + QLabel* label; + QGridLayout* grid; + + SimpleButton* solo; + SimpleButton* mute; + SimpleButton* ar; + SimpleButton* aw; + + void updateLabel(); + bool _align; // align elements for mixer app + + void recordToggled(bool); + void addAutomationButtons(int row); + + public slots: + void resetPeaks(); + virtual void songChanged(int) = 0; + virtual void controllerChanged(int) {} + void configChanged(); + + public: + Strip(Mixer* m, Track* t, bool align); + ~Strip(); + Track* getTrack() const { return track; } + virtual void heartBeat() = 0; + virtual QSize sizeHint() const { return QSize(STRIP_WIDTH, 80); } + }; + +#endif + -- cgit v1.2.3