summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--muse/ChangeLog5
-rw-r--r--muse/muse/arranger/tlwidget.cpp4
-rw-r--r--muse/muse/arranger/trackinfo.cpp12
-rw-r--r--muse/muse/audio.cpp20
-rw-r--r--muse/muse/audioinput.cpp28
-rw-r--r--muse/muse/audioinput.h2
-rw-r--r--muse/muse/audiotrack.cpp230
-rw-r--r--muse/muse/audiotrack.h20
-rw-r--r--muse/muse/auxplugin.cpp14
-rw-r--r--muse/muse/auxplugin.h4
-rw-r--r--muse/muse/driver/alsamidi.cpp16
-rw-r--r--muse/muse/driver/alsamidi.h4
-rw-r--r--muse/muse/driver/coremidi.cpp12
-rw-r--r--muse/muse/driver/coremidi.h4
-rw-r--r--muse/muse/driver/driver.h4
-rw-r--r--muse/muse/driver/dummyaudio.cpp20
-rw-r--r--muse/muse/driver/jack.cpp60
-rw-r--r--muse/muse/driver/jackaudio.h4
-rw-r--r--muse/muse/importmidi.cpp6
-rw-r--r--muse/muse/miditrack.h2
-rw-r--r--muse/muse/mixer/astrip.cpp292
-rw-r--r--muse/muse/mixer/mstrip.cpp97
-rw-r--r--muse/muse/mixer/rack.cpp2
-rw-r--r--muse/muse/muse.cpp4
-rw-r--r--muse/muse/plugin.h3
-rw-r--r--muse/muse/preferences.cpp6
-rw-r--r--muse/muse/route.cpp236
-rw-r--r--muse/muse/route.h37
-rw-r--r--muse/muse/seqmsg.cpp2
-rw-r--r--muse/muse/song.cpp48
-rw-r--r--muse/muse/track.cpp41
-rw-r--r--muse/muse/wavetrack.cpp2
32 files changed, 612 insertions, 629 deletions
diff --git a/muse/ChangeLog b/muse/ChangeLog
index 52e69f50..282d5768 100644
--- a/muse/ChangeLog
+++ b/muse/ChangeLog
@@ -1,3 +1,8 @@
+12.10 (ws)
+ - added post fader plugins for mixer
+ - removed special aux send track type. Aux send is now implemented as
+ a special build in audio plugin.
+ - many routing changes
5.10 (ws)
- QT4.2 is now minimum required version
- changed font selector in "preferences" to QFontCombobox
diff --git a/muse/muse/arranger/tlwidget.cpp b/muse/muse/arranger/tlwidget.cpp
index 88a7fae1..13d77398 100644
--- a/muse/muse/arranger/tlwidget.cpp
+++ b/muse/muse/arranger/tlwidget.cpp
@@ -532,8 +532,8 @@ void TLWidget::outChannelChanged(int n)
int id = mc->channelNo();
if (id == n)
return;
- audio->msgRemoveRoute(Route(_track, -1, Route::TRACK), Route(mc,-1, Route::TRACK));
- audio->msgAddRoute(Route(_track, -1, Route::TRACK), Route(mp->channel(n),-1, Route::TRACK));
+ audio->msgRemoveRoute(Route(_track), Route(mc));
+ audio->msgAddRoute(Route(_track), Route(mp->channel(n)));
song->update(SC_ROUTE);
}
diff --git a/muse/muse/arranger/trackinfo.cpp b/muse/muse/arranger/trackinfo.cpp
index 9f44cadc..36a14692 100644
--- a/muse/muse/arranger/trackinfo.cpp
+++ b/muse/muse/arranger/trackinfo.cpp
@@ -246,10 +246,10 @@ void MidiTrackInfo::portSelected(int portno)
return;
--portno;
- Route srcRoute(track, -1, Route::TRACK);
+ Route srcRoute(track);
MidiChannel* midic = ((MidiTrack*)track)->channel();
if (midic) {
- Route odstRoute(midic, -1, Route::TRACK);
+ Route odstRoute(midic);
audio->msgRemoveRoute(srcRoute, odstRoute);
}
@@ -257,7 +257,7 @@ void MidiTrackInfo::portSelected(int portno)
MidiOutPort* midip = song->midiOutPort(portno);
midic = midip->channel(channel);
- Route dstRoute(midic, -1, Route::TRACK);
+ Route dstRoute(midic);
audio->msgAddRoute(srcRoute, dstRoute);
song->update(SC_ROUTE);
@@ -272,16 +272,16 @@ void MidiTrackInfo::channelSelected(int ch)
if (ch == 0)
return;
--ch;
- Route srcRoute(track, -1, Route::TRACK);
+ Route srcRoute(track);
MidiChannel* midic = ((MidiTrack*)track)->channel();
MidiOutPort* midip = midic->port();
if (midic) {
- Route odstRoute(midic, -1, Route::TRACK);
+ Route odstRoute(midic);
audio->msgRemoveRoute(srcRoute, odstRoute);
}
midic = midip->channel(ch);
- Route dstRoute(midic, -1, Route::TRACK);
+ Route dstRoute(midic);
audio->msgAddRoute(srcRoute, dstRoute);
song->update(SC_ROUTE);
diff --git a/muse/muse/audio.cpp b/muse/muse/audio.cpp
index 6f0209fe..ec8c6463 100644
--- a/muse/muse/audio.cpp
+++ b/muse/muse/audio.cpp
@@ -514,23 +514,9 @@ void Audio::process(unsigned frames)
}
for (iAudioGroup i = gl->begin(); i != gl->end(); ++i)
(*i)->process();
- for (iAudioOutput i = ol->begin(); i != ol->end(); ++i) {
- AudioOutput* ao = *i;
- ao->process();
- int och = ao->channels();
- float* buffer[och];
- for (int i = 0; i < och; ++i) {
- void* port = ao->jackPort(i);
- if (port)
- buffer[i] = audioDriver->getBuffer(port, frames);
- else
- printf("PANIC: process(): no buffer from audio driver\n");
- }
- if (!ao->multiplyCopy(och, buffer, 0)) {
- for (int i = 0; i < och; ++i)
- memset(buffer[i], 0, sizeof(float) * frames);
- }
- }
+ for (iAudioOutput i = ol->begin(); i != ol->end(); ++i)
+ (*i)->process();
+
if (_bounce == 1 && song->bounceTrack && song->bounceTrack->type() == Track::WAVE)
song->bounceTrack->process();
diff --git a/muse/muse/audioinput.cpp b/muse/muse/audioinput.cpp
index 4143196d..96e3fde6 100644
--- a/muse/muse/audioinput.cpp
+++ b/muse/muse/audioinput.cpp
@@ -37,14 +37,6 @@ AudioInput::AudioInput()
jackPorts[i] = 0;
_channels = 0;
setChannels(2);
- //
- // buffer pointer are filled in collectInputData()
- // (pointer to jack buffer)
-
- for (int i = 0; i < MAX_CHANNELS; ++i) {
- delete[] buffer[i];
- buffer[i] = 0;
- }
}
//---------------------------------------------------------
@@ -53,14 +45,10 @@ AudioInput::AudioInput()
AudioInput::~AudioInput()
{
- for (int i = 0; i < _channels; ++i)
- audioDriver->unregisterPort(jackPorts[i]);
- //
- // buffers belong to JACK: zero pointer so they are
- // not free'd by AudioTrack destructor
- //
- for (int i = 0; i < MAX_CHANNELS; ++i)
- buffer[i] = 0;
+ for (int i = 0; i < _channels; ++i) {
+ if (jackPorts[i])
+ audioDriver->unregisterPort(jackPorts[i]);
+ }
}
//---------------------------------------------------------
@@ -168,7 +156,7 @@ void AudioInput::setName(const QString& s)
//---------------------------------------------------------
// collectInputData
-// return true if data
+// if buffer contains silence, set bufferEmpty to true
//---------------------------------------------------------
void AudioInput::collectInputData()
@@ -177,12 +165,12 @@ void AudioInput::collectInputData()
for (int ch = 0; ch < channels(); ++ch) {
void* jackPort = jackPorts[ch];
if (jackPort)
- buffer[ch] = audioDriver->getBuffer(jackPort, segmentSize);
+ buffer[ch] = audioDriver->getBuffer(jackPort, segmentSize);
else {
- //TODO: this should crash
printf("NO JACK PORT\n");
- memset(buffer[ch], 0, segmentSize * sizeof(float));
+ abort();
}
}
}
+
diff --git a/muse/muse/audioinput.h b/muse/muse/audioinput.h
index 8d22f2a7..0fb3d409 100644
--- a/muse/muse/audioinput.h
+++ b/muse/muse/audioinput.h
@@ -31,7 +31,7 @@ class AudioInput : public AudioTrack {
Q_OBJECT
void* jackPorts[MAX_CHANNELS];
- virtual void collectInputData();
+ void collectInputData();
public:
AudioInput();
diff --git a/muse/muse/audiotrack.cpp b/muse/muse/audiotrack.cpp
index fa091263..711bdf78 100644
--- a/muse/muse/audiotrack.cpp
+++ b/muse/muse/audiotrack.cpp
@@ -91,7 +91,8 @@ Part* AudioTrack::newPart(Part*, bool /*clone*/)
//---------------------------------------------------------
// addPlugin
-// idx = -1 insert into first free slot
+// idx = -1 append
+// plugin = 0 remove plugin
//---------------------------------------------------------
void AudioTrack::addPlugin(PluginI* plugin, int idx, bool pre)
@@ -107,31 +108,42 @@ void AudioTrack::addPlugin(PluginI* plugin, int idx, bool pre)
}
pipe->removeAt(idx);
}
- return;
}
- if (idx == -1)
- idx = pipe->size();
- pipe->insert(idx, plugin);
- int ncontroller = plugin->plugin()->parameter();
- for (int i = 0; i < ncontroller; ++i) {
- int id = genACnum(idx, i, pre);
- QString name(plugin->getParameterName(i));
- double min, max;
- plugin->range(i, &min, &max);
- Ctrl* cl = getController(id);
- //printf("Plugin name: %s id:%d\n",name.toAscii().data(), id);
- if (cl == 0) {
- cl = new Ctrl(id, name);
+ else {
+ if (idx == -1)
+ idx = pipe->size();
+ pipe->insert(idx, plugin);
+ int ncontroller = plugin->plugin()->parameter();
+ for (int i = 0; i < ncontroller; ++i) {
+ int id = genACnum(idx, i, pre);
+ QString name(plugin->getParameterName(i));
+ double min, max;
+ plugin->range(i, &min, &max);
+ Ctrl* cl = getController(id);
+ //printf("Plugin name: %s id:%d\n",name.toAscii().data(), id);
+ if (cl == 0) {
+ cl = new Ctrl(id, name);
+ cl->setRange(min, max);
+ float defaultValue = plugin->defaultValue(i);
+ cl->setDefault(defaultValue);
+ cl->setCurVal(defaultValue);
+ addController(cl);
+ }
cl->setRange(min, max);
- float defaultValue = plugin->defaultValue(i);
- cl->setDefault(defaultValue);
- cl->setCurVal(defaultValue);
- addController(cl);
+ cl->setName(name);
+ plugin->setParam(i, cl->schedVal().f);
+ plugin->setControllerList(cl);
}
- cl->setRange(min, max);
- cl->setName(name);
- plugin->setParam(i, cl->schedVal().f);
- plugin->setControllerList(cl);
+ }
+ _preAux.clear();
+ _postAux.clear();
+ foreach(PluginI* pi, *_prePipe) {
+ if (pi->plugin() == auxPlugin)
+ _preAux.append((AuxPluginIF*)(pi->pluginIF(0)));
+ }
+ foreach(PluginI* pi, *_postPipe) {
+ if (pi->plugin() == auxPlugin)
+ _postAux.append((AuxPluginIF*)(pi->pluginIF(0)));
}
}
@@ -417,33 +429,40 @@ void AudioTrack::startRecording()
void AudioTrack::process()
{
+ bufferEmpty = false;
if (_off) {
bufferEmpty = true;
return;
}
collectInputData();
-
- //---------------------------------------------------
- // apply plugin chain
- //---------------------------------------------------
-
_prePipe->apply(channels(), segmentSize, buffer);
- //---------------------------------------------------
- // metering
- //---------------------------------------------------
-
+ if (_prefader) {
+ for (int i = 0; i < channels(); ++i) {
+ float* p = buffer[i];
+ float meter = 0.0;
+ for (unsigned k = 0; k < segmentSize; ++k) {
+ double f = fabs(*p++);
+ if (f > meter)
+ meter = f;
+ }
+ setMeter(i, meter);
+ }
+ }
double vol[channels()];
double _volume = _mute ? 0.0 : ctrlVal(AC_VOLUME).f;
- if (bufferEmpty || (!_prefader && _volume == 0.0)) {
- for (int i = 0; i < channels(); ++i)
- setMeter(i, 0.0);
+ double _pan = ctrlVal(AC_PAN).f;
+ vol[0] = _volume * (1.0 - _pan);
+ vol[1] = _volume * (1.0 + _pan);
+
+ for (int i = 0; i < channels(); ++i) {
+ float* p = buffer[i];
+ for (unsigned k = 0; k < segmentSize; ++k)
+ *p++ *= vol[i];
}
- else {
- double _pan = ctrlVal(AC_PAN).f;
- vol[0] = _volume * (1.0 - _pan);
- vol[1] = _volume * (1.0 + _pan);
+ _postPipe->apply(channels(), segmentSize, buffer);
+ if (!_prefader) {
for (int i = 0; i < channels(); ++i) {
float* p = buffer[i];
float meter = 0.0;
@@ -453,49 +472,27 @@ void AudioTrack::process()
meter = f;
++p;
}
- if (!_prefader)
- meter *= vol[i];
setMeter(i, meter);
}
}
}
//---------------------------------------------------------
-// multiplyAdd
-// apply _volume and _pan to track buffer and add to
-// destination buffer
+// add
+// add audio buffer to track buffer
//---------------------------------------------------------
-void AudioTrack::multiplyAdd(int dstChannels, float** dstBuffer, int bus)
+void AudioTrack::add(int srcChannels, float** srcBuffer)
{
- if (_mute || bufferEmpty)
- return;
- int volCtrl;
- int panCtrl;
- if (bus == 0) {
- volCtrl = AC_VOLUME;
- panCtrl = AC_PAN;
- }
- else {
- volCtrl = AC_AUX + bus - 1;
- panCtrl = AC_AUX_PAN + bus - 1;
- }
- double _volume = ctrlVal(volCtrl).f;
- if (_volume == 0.0)
- return;
- int srcChannels = channels();
- double vol[2];
- double _pan = ctrlVal(panCtrl).f;
- vol[0] = _volume * (1.0 - _pan);
- vol[1] = _volume * (1.0 + _pan);
+ int dstChannels = channels();
+ float** dstBuffer = buffer;
if (srcChannels == dstChannels) {
for (int c = 0; c < dstChannels; ++c) {
- float* sp = buffer[c];
+ float* sp = srcBuffer[c];
float* dp = dstBuffer[c];
- float v = vol[c];
for (unsigned k = 0; k < segmentSize; ++k)
- dp[k] += (sp[k] * v);
+ dp[k] += sp[k];
}
}
//
@@ -504,80 +501,56 @@ void AudioTrack::multiplyAdd(int dstChannels, float** dstBuffer, int bus)
else if (srcChannels == 1 && dstChannels == 2) {
float* dp1 = dstBuffer[0];
float* dp2 = dstBuffer[1];
- float* sp = buffer[0];
- double v1 = vol[0];
- double v2 = vol[1];
+ float* sp = srcBuffer[0];
for (unsigned k = 0; k < segmentSize; ++k) {
- dp1[k] += (sp[k] * v1);
- dp2[k] += (sp[k] * v2);
+ dp1[k] += sp[k];
+ dp2[k] += sp[k];
}
}
//
// downmix stereo to mono
//
else if (srcChannels == 2 && dstChannels == 1) {
- float* sp1 = buffer[0];
- float* sp2 = buffer[1];
- float* dp = dstBuffer[0];
+ float* sp1 = srcBuffer[0];
+ float* sp2 = srcBuffer[1];
+ float* dp = dstBuffer[0];
for (unsigned k = 0; k < segmentSize; ++k)
- dp[k] += (sp1[k] * vol[0] + sp2[k] * vol[1]);
+ dp[k] += sp1[k] + sp2[k];
}
}
//---------------------------------------------------------
-// multiplyCopy
-// return false if resulting buffer would be silence
+// copy
+// add audio buffer to track buffer
//---------------------------------------------------------
-bool AudioTrack::multiplyCopy(int dstChannels, float** dstBuffer, int bus)
+bool AudioTrack::copy(int srcChannels, float** srcBuffer)
{
- if (_mute || bufferEmpty)
- return false;
- int volCtrl;
- int panCtrl;
- if (bus == 0) {
- volCtrl = AC_VOLUME;
- panCtrl = AC_PAN;
- }
- else {
- volCtrl = AC_AUX + bus - 1;
- panCtrl = AC_AUX_PAN + bus - 1;
- }
- double _volume = ctrlVal(volCtrl).f;
- if (_volume == 0.0)
- return false;
- int srcChannels = channels();
- float vol[2];
- float _pan = ctrlVal(panCtrl).f;
- vol[0] = _volume * (1.0 - _pan);
- vol[1] = _volume * (1.0 + _pan);
+ int dstChannels = channels();
+ float** dstBuffer = buffer;
if (srcChannels == dstChannels) {
for (int c = 0; c < dstChannels; ++c) {
- float* sp = buffer[c];
+ float* sp = srcBuffer[c];
float* dp = dstBuffer[c];
- for (unsigned k = 0; k < segmentSize; ++k) {
- *dp++ = *sp++ * vol[c];
- }
+ for (unsigned k = 0; k < segmentSize; ++k)
+ *dp++ = *sp++;
}
}
else if (srcChannels == 1 && dstChannels == 2) {
- float* sp = buffer[0];
+ float* sp = srcBuffer[0];
for (unsigned k = 0; k < segmentSize; ++k) {
float val = *sp++;
- *(dstBuffer[0] + k) = val * vol[0];
- *(dstBuffer[1] + k) = val * vol[1];
+ *(dstBuffer[0] + k) = val;
+ *(dstBuffer[1] + k) = val;
}
}
else if (srcChannels == 2 && dstChannels == 1) {
- float* sp1 = buffer[0];
- float* sp2 = buffer[1];
+ float* sp1 = srcBuffer[0];
+ float* sp2 = srcBuffer[1];
float* dp = dstBuffer[0];
- for (unsigned k = 0; k < segmentSize; ++k) {
- float val1 = *sp1++ * vol[0];
- float val2 = *sp2++ * vol[1];
- *dp++ = (val1 + val2);
- }
+ for (unsigned k = 0; k < segmentSize; ++k)
+ dp[k] = sp1[k] + sp2[k];
}
return true;
}
@@ -591,17 +564,30 @@ void AudioTrack::collectInputData()
{
bufferEmpty = false;
RouteList* rl = inRoutes();
- bool copy = true;
+ bool copyFlag = true;
for (iRoute ir = rl->begin(); ir != rl->end(); ++ir) {
- AudioTrack* track = (AudioTrack*)ir->track;
- if (track->off() || song->bounceTrack == track)
- continue;
- if (copy)
- copy = !track->multiplyCopy(channels(), buffer, 0);
+ float** ptr;
+ float* b[channels()];
+ int ch;
+ if (ir->type == Route::TRACK) {
+ AudioTrack* track = (AudioTrack*)ir->track;
+ if (track->off() || song->bounceTrack == track)
+ continue;
+ ptr = track->buffer;
+ ch = track->channels();
+ }
+ else if (ir->type == Route::AUXPLUGIN) {
+ ch = ir->plugin->channel();
+ ptr = ir->plugin->buffer();
+ }
+ if (copyFlag) {
+ copy(ch, ptr);
+ copyFlag = false;
+ }
else
- track->multiplyAdd(channels(), buffer, 0);
+ add(ch, ptr);
}
- if (copy) {
+ if (copyFlag) {
//
// no input,
// fill with silence
diff --git a/muse/muse/audiotrack.h b/muse/muse/audiotrack.h
index 91c2ffcc..4f05b0ec 100644
--- a/muse/muse/audiotrack.h
+++ b/muse/muse/audiotrack.h
@@ -25,14 +25,7 @@
#include "track.h"
class PluginI;
-
-//---------------------------------------------------------
-// AuxSend
-//---------------------------------------------------------
-
-struct AuxSend {
- bool postfader;
- };
+class AuxPluginIF;
//---------------------------------------------------------
// AudioTrack
@@ -44,7 +37,8 @@ class AudioTrack : public Track {
bool _prefader; // prefader metering
Pipeline* _prePipe;
Pipeline* _postPipe;
- QList<AuxSend> sends;
+ QList<AuxPluginIF*> _preAux;
+ QList<AuxPluginIF*> _postAux;
void readRecfile(QDomNode);
@@ -94,13 +88,17 @@ class AudioTrack : public Track {
void setPrefader(bool val);
Pipeline* prePipe() { return _prePipe; }
Pipeline* postPipe() { return _postPipe; }
+
void addPlugin(PluginI* plugin, int idx, bool pre);
PluginI* plugin(int idx, bool prefader) const;
virtual bool hasAuxSend() const { return false; }
virtual void process();
- void multiplyAdd(int channel, float**, int bus);
- bool multiplyCopy(int channel, float**, int bus);
+ void add(int channel, float**);
+ bool copy(int channel, float**);
+ bool isBufferEmpty() const { return bufferEmpty; }
+ QList<AuxPluginIF*> preAux() const { return _preAux; }
+ QList<AuxPluginIF*> postAux() const { return _postAux; }
};
#endif
diff --git a/muse/muse/auxplugin.cpp b/muse/muse/auxplugin.cpp
index 0f25f814..e313e630 100644
--- a/muse/muse/auxplugin.cpp
+++ b/muse/muse/auxplugin.cpp
@@ -107,9 +107,9 @@ double AuxPlugin::defaultValue(int idx) const
AuxPluginIF::AuxPluginIF(PluginI* pi)
: PluginIF(pi)
{
- buffer = new float*[MAX_CHANNELS];
+ _buffer = new float*[MAX_CHANNELS];
for (int i = 0; i < MAX_CHANNELS; ++i)
- buffer[i] = new float[segmentSize];
+ _buffer[i] = new float[segmentSize];
}
//---------------------------------------------------------
@@ -119,10 +119,10 @@ AuxPluginIF::AuxPluginIF(PluginI* pi)
AuxPluginIF::~AuxPluginIF()
{
for (int i = 0; i < MAX_CHANNELS; ++i) {
- if (buffer[i])
- delete[] buffer[i];
+ if (_buffer[i])
+ delete[] _buffer[i];
}
- delete[] buffer;
+ delete[] _buffer;
}
//---------------------------------------------------------
@@ -137,10 +137,10 @@ void AuxPluginIF::apply(unsigned nframes, float** s, float** /*dst*/)
vol[1] = volume * (1.0 + pan);
for (int i = 0; i < pluginI->channel(); ++i) {
- float* dst = buffer[i];
+ float* dst = _buffer[i];
float* src = s[i];
double v = vol[i];
- for (int k = 0; k < nframes; ++k)
+ for (unsigned k = 0; k < nframes; ++k)
*dst++ = (*src++) * v;
}
}
diff --git a/muse/muse/auxplugin.h b/muse/muse/auxplugin.h
index 80624a27..3429e5e0 100644
--- a/muse/muse/auxplugin.h
+++ b/muse/muse/auxplugin.h
@@ -60,7 +60,7 @@ class AuxPlugin : public Plugin {
class AuxPluginIF : public PluginIF {
double volume;
double pan;
- float** buffer; // this buffer is filled by apply()
+ float** _buffer; // this buffer is filled by apply()
// _volume and _pan is applied
public:
@@ -75,6 +75,8 @@ class AuxPluginIF : public PluginIF {
virtual void setParam(int i, double val);
virtual float param(int i) const;
bool init(Plugin*);
+ float** buffer() { return _buffer; }
+ int channel() const { return pluginInstance()->channel(); }
};
extern AuxPlugin* auxPlugin;
diff --git a/muse/muse/driver/alsamidi.cpp b/muse/muse/driver/alsamidi.cpp
index f36ec681..c64d2451 100644
--- a/muse/muse/driver/alsamidi.cpp
+++ b/muse/muse/driver/alsamidi.cpp
@@ -97,9 +97,9 @@ bool AlsaMidi::init()
// outputPorts
//---------------------------------------------------------
-std::list<PortName>* AlsaMidi::outputPorts()
+QList<PortName> AlsaMidi::outputPorts()
{
- std::list<PortName>* clientList = new std::list<PortName>;
+ QList<PortName> clientList;
snd_seq_client_info_t* cinfo;
snd_seq_client_info_alloca(&cinfo);
snd_seq_client_info_set_client(cinfo, 0);
@@ -121,7 +121,7 @@ std::list<PortName>* AlsaMidi::outputPorts()
adr->port = snd_seq_port_info_get_port(pinfo);
adr->client = client;
pn.port = adr;
- clientList->push_back(pn);
+ clientList.append(pn);
}
}
}
@@ -133,9 +133,9 @@ std::list<PortName>* AlsaMidi::outputPorts()
// inputPorts
//---------------------------------------------------------
-std::list<PortName>* AlsaMidi::inputPorts()
+QList<PortName> AlsaMidi::inputPorts()
{
- std::list<PortName>* clientList = new std::list<PortName>;
+ QList<PortName> clientList;
snd_seq_client_info_t* cinfo;
snd_seq_client_info_alloca(&cinfo);
@@ -158,7 +158,7 @@ std::list<PortName>* AlsaMidi::inputPorts()
adr->port = snd_seq_port_info_get_port(pinfo);
adr->client = client;
pn.port = adr;
- clientList->push_back(pn);
+ clientList.append(pn);
}
}
}
@@ -372,7 +372,7 @@ void AlsaMidi::addConnection(snd_seq_connect_t* ev)
}
if (ir == orl->end()) {
snd_seq_addr_t* adr = new snd_seq_addr_t(ev->dest);
- orl->push_back(Route(Port(adr), Route::MIDIPORT));
+ orl->push_back(Route(Port(adr), -1, Route::MIDIPORT));
}
break;
}
@@ -393,7 +393,7 @@ void AlsaMidi::addConnection(snd_seq_connect_t* ev)
}
if (ir == irl->end()) {
snd_seq_addr_t* adr = new snd_seq_addr_t(ev->sender);
- irl->push_back(Route(Port(adr), Route::MIDIPORT));
+ irl->push_back(Route(Port(adr), -1, Route::MIDIPORT));
}
break;
}
diff --git a/muse/muse/driver/alsamidi.h b/muse/muse/driver/alsamidi.h
index 57c255d8..4d9910f7 100644
--- a/muse/muse/driver/alsamidi.h
+++ b/muse/muse/driver/alsamidi.h
@@ -45,8 +45,8 @@ class AlsaMidi : public Driver {
AlsaMidi();
virtual bool init();
- virtual std::list<PortName>* outputPorts();
- virtual std::list<PortName>* inputPorts();
+ virtual QList<PortName> outputPorts();
+ virtual QList<PortName> inputPorts();
virtual Port registerOutPort(const QString& name);
virtual Port registerInPort(const QString& name);
diff --git a/muse/muse/driver/coremidi.cpp b/muse/muse/driver/coremidi.cpp
index b785fb03..60d164be 100644
--- a/muse/muse/driver/coremidi.cpp
+++ b/muse/muse/driver/coremidi.cpp
@@ -97,9 +97,9 @@ bool CoreMidi::init()
// outputPorts
//---------------------------------------------------------
-std::list<PortName>* CoreMidi::outputPorts()
+QList<PortName> CoreMidi::outputPorts()
{
- std::list<PortName>* clientList = new std::list<PortName>;
+ QList<PortName> clientList;
/* snd_seq_client_info_t* cinfo;
snd_seq_client_info_alloca(&cinfo);
snd_seq_client_info_set_client(cinfo, 0);
@@ -121,7 +121,7 @@ std::list<PortName>* CoreMidi::outputPorts()
adr->port = snd_seq_port_info_get_port(pinfo);
adr->client = client;
pn.port = adr;
- clientList->push_back(pn);
+ clientList.append(pn);
}
}
}
@@ -133,9 +133,9 @@ std::list<PortName>* CoreMidi::outputPorts()
// inputPorts
//---------------------------------------------------------
-std::list<PortName>* CoreMidi::inputPorts()
+QList<PortName> CoreMidi::inputPorts()
{
- std::list<PortName>* clientList = new std::list<PortName>;
+ QList<PortName> clientList;
/* snd_seq_client_info_t* cinfo;
snd_seq_client_info_alloca(&cinfo);
@@ -158,7 +158,7 @@ std::list<PortName>* CoreMidi::inputPorts()
adr->port = snd_seq_port_info_get_port(pinfo);
adr->client = client;
pn.port = adr;
- clientList->push_back(pn);
+ clientList.append(pn);
}
}
}
diff --git a/muse/muse/driver/coremidi.h b/muse/muse/driver/coremidi.h
index 316bd9f1..28e79ca7 100644
--- a/muse/muse/driver/coremidi.h
+++ b/muse/muse/driver/coremidi.h
@@ -42,8 +42,8 @@ class CoreMidi : public Driver {
CoreMidi();
virtual bool init();
- virtual std::list<PortName>* outputPorts();
- virtual std::list<PortName>* inputPorts();
+ virtual QList<PortName> outputPorts();
+ virtual QList<PortName> inputPorts();
virtual Port registerOutPort(const QString& name);
virtual Port registerInPort(const QString& name);
diff --git a/muse/muse/driver/driver.h b/muse/muse/driver/driver.h
index 38ae8d4d..96ba26ec 100644
--- a/muse/muse/driver/driver.h
+++ b/muse/muse/driver/driver.h
@@ -41,8 +41,8 @@ class Driver {
virtual ~Driver() {}
virtual bool init() = 0;
- virtual std::list<PortName>* outputPorts() = 0;
- virtual std::list<PortName>* inputPorts() = 0;
+ virtual QList<PortName> outputPorts() = 0;
+ virtual QList<PortName> inputPorts() = 0;
virtual Port registerOutPort(const QString&) = 0;
virtual Port registerInPort(const QString&) = 0;
diff --git a/muse/muse/driver/dummyaudio.cpp b/muse/muse/driver/dummyaudio.cpp
index 7abe8196..7f669923 100644
--- a/muse/muse/driver/dummyaudio.cpp
+++ b/muse/muse/driver/dummyaudio.cpp
@@ -68,8 +68,8 @@ class DummyAudio : public AudioDriver {
return buffer;
}
- virtual std::list<PortName>* outputPorts();
- virtual std::list<PortName>* inputPorts();
+ virtual QList<PortName> outputPorts();
+ virtual QList<PortName> inputPorts();
virtual void registerClient() {}
@@ -162,17 +162,17 @@ bool initDummyAudio()
// outputPorts
//---------------------------------------------------------
-std::list<PortName>* DummyAudio::outputPorts()
+QList<PortName> DummyAudio::outputPorts()
{
- std::list<PortName>* clientList = new std::list<PortName>;
+ QList<PortName> clientList;
PortName p1;
p1.name = QString("output1");
p1.port = (void*)100;
PortName p2;
p2.name = QString("output2");
p2.port = (void*)101;
- clientList->push_back(p1);
- clientList->push_back(p2);
+ clientList.append(p1);
+ clientList.append(p2);
return clientList;
}
@@ -180,17 +180,17 @@ std::list<PortName>* DummyAudio::outputPorts()
// inputPorts
//---------------------------------------------------------
-std::list<PortName>* DummyAudio::inputPorts()
+QList<PortName> DummyAudio::inputPorts()
{
- std::list<PortName>* clientList = new std::list<PortName>;
+ QList<PortName> clientList;
PortName p1;
p1.name = QString("input1");
p1.port = (void*)0;
PortName p2;
p2.name = QString("input2");
p2.port = (void*)1;
- clientList->push_back(p1);
- clientList->push_back(p2);
+ clientList.append(p1);
+ clientList.append(p2);
return clientList;
}
diff --git a/muse/muse/driver/jack.cpp b/muse/muse/driver/jack.cpp
index 4d81a459..733cd70d 100644
--- a/muse/muse/driver/jack.cpp
+++ b/muse/muse/driver/jack.cpp
@@ -329,12 +329,11 @@ void JackAudio::graphChanged()
for (iRoute irl = rl->begin(); irl != rl->end(); ++irl) {
if (irl->channel != channel)
continue;
- QString name = irl->name();
- const char* portName = name.toLatin1().data();
+ const char* name = jack_port_name((jack_port_t*)irl->port);
bool found = false;
const char** pn = ports;
while (pn && *pn) {
- if (strcmp(*pn, portName) == 0) {
+ if (strcmp(*pn, name) == 0) {
found = true;
break;
}
@@ -342,8 +341,8 @@ void JackAudio::graphChanged()
}
if (!found) {
audio->msgRemoveRoute1(
- Route(portName, channel, Route::AUDIOPORT),
- Route(it, channel, Route::TRACK)
+ Route(irl->port, channel, Route::AUDIOPORT),
+ Route(it, channel)
);
erased = true;
break;
@@ -361,20 +360,21 @@ void JackAudio::graphChanged()
const char** pn = ports;
while (*pn) {
bool found = false;
+ Port port;
for (iRoute irl = rl->begin(); irl != rl->end(); ++irl) {
if (irl->channel != channel)
continue;
- QString name = irl->name();
- const char* portName = name.toLatin1().data();
- if (strcmp(*pn, portName) == 0) {
+ port = irl->port;
+ const char* name = jack_port_name((jack_port_t*)port);
+ if (strcmp(*pn, name) == 0) {
found = true;
break;
}
}
if (!found) {
audio->msgAddRoute1(
- Route(*pn, channel, Route::AUDIOPORT),
- Route(it, channel, Route::TRACK)
+ Route(port, channel, Route::AUDIOPORT),
+ Route(it, channel)
);
}
++pn;
@@ -405,12 +405,11 @@ void JackAudio::graphChanged()
for (iRoute irl = rl->begin(); irl != rl->end(); ++irl) {
if (irl->channel != channel)
continue;
- QString name = irl->name();
- const char* portName = name.toLatin1().data();
+ const char* name = jack_port_name((jack_port_t*)irl->port);
bool found = false;
const char** pn = ports;
while (pn && *pn) {
- if (strcmp(*pn, portName) == 0) {
+ if (strcmp(*pn, name) == 0) {
found = true;
break;
}
@@ -418,8 +417,8 @@ void JackAudio::graphChanged()
}
if (!found) {
audio->msgRemoveRoute1(
- Route(it, channel, Route::TRACK),
- Route(portName, channel, Route::AUDIOPORT)
+ Route(it, channel),
+ Route(irl->port, channel, Route::AUDIOPORT)
);
erased = true;
break;
@@ -437,20 +436,21 @@ void JackAudio::graphChanged()
const char** pn = ports;
while (*pn) {
bool found = false;
+ Port port;
for (iRoute irl = rl->begin(); irl != rl->end(); ++irl) {
if (irl->channel != channel)
continue;
- QString name = irl->name();
- const char* portName = name.toLatin1().data();
- if (strcmp(*pn, portName) == 0) {
+ port = irl->port;
+ const char* name = jack_port_name((jack_port_t*)port);
+ if (strcmp(*pn, name) == 0) {
found = true;
break;
}
}
if (!found) {
audio->msgAddRoute1(
- Route(it, channel, Route::TRACK),
- Route(*pn, channel, Route::AUDIOPORT)
+ Route(it, channel),
+ Route(port, channel, Route::AUDIOPORT)
);
}
++pn;
@@ -490,7 +490,7 @@ void JackAudio::registerClient()
//---------------------------------------------------------
// registerInPort
//---------------------------------------------------------
-
+
Port JackAudio::registerInPort(const QString& name)
{
void* p = jack_port_register(_client, name.toLatin1().data(), JACK_DEFAULT_AUDIO_TYPE, JackPortIsInput, 0);
@@ -537,8 +537,8 @@ bool JackAudio::connect(Port src, Port dst)
}
int rv = jack_connect(_client, sn, dn);
if (rv) {
- fprintf(stderr, "%d: jack connect <%s>%p - <%s>%p failed\n",
- rv, sn, src, dn, dst);
+ fprintf(stderr, "%d: jack connect <%s> - <%s> failed\n",
+ rv, sn, dn);
if (rv == EEXIST)
fprintf(stderr, " connection already made\n");
return false;
@@ -607,10 +607,10 @@ unsigned JackAudio::framePos() const
// outputPorts
//---------------------------------------------------------
-std::list<PortName>* JackAudio::outputPorts()
+QList<PortName> JackAudio::outputPorts()
{
const char** ports = jack_get_ports(_client, 0, 0, 0);
- std::list<PortName>* clientList = new std::list<PortName>;
+ QList<PortName> clientList;
for (const char** p = ports; p && *p; ++p) {
jack_port_t* port = jack_port_by_name(_client, *p);
int flags = jack_port_flags(port);
@@ -622,7 +622,8 @@ std::list<PortName>* JackAudio::outputPorts()
continue;
PortName pn;
pn.name = QString(buffer);
- clientList->push_back(pn);
+ pn.port = port;
+ clientList.append(pn);
}
return clientList;
}
@@ -631,10 +632,10 @@ std::list<PortName>* JackAudio::outputPorts()
// inputPorts
//---------------------------------------------------------
-std::list<PortName>* JackAudio::inputPorts()
+QList<PortName> JackAudio::inputPorts()
{
const char** ports = jack_get_ports(_client, 0, 0, 0);
- std::list<PortName>* clientList = new std::list<PortName>;
+ QList<PortName> clientList;
for (const char** p = ports; p && *p; ++p) {
jack_port_t* port = jack_port_by_name(_client, *p);
int flags = jack_port_flags(port);
@@ -646,7 +647,8 @@ std::list<PortName>* JackAudio::inputPorts()
continue;
PortName pn;
pn.name = QString(buffer);
- clientList->push_back(pn);
+ pn.port = port;
+ clientList.append(pn);
}
return clientList;
}
diff --git a/muse/muse/driver/jackaudio.h b/muse/muse/driver/jackaudio.h
index 35eba57d..9225d69e 100644
--- a/muse/muse/driver/jackaudio.h
+++ b/muse/muse/driver/jackaudio.h
@@ -47,8 +47,8 @@ class JackAudio : public AudioDriver {
return (float*)jack_port_get_buffer((jack_port_t*)port, nframes);
}
- virtual std::list<PortName>* outputPorts();
- virtual std::list<PortName>* inputPorts();
+ virtual QList<PortName> outputPorts();
+ virtual QList<PortName> inputPorts();
virtual void registerClient();
diff --git a/muse/muse/importmidi.cpp b/muse/muse/importmidi.cpp
index 5033b6f9..ed78c6c0 100644
--- a/muse/muse/importmidi.cpp
+++ b/muse/muse/importmidi.cpp
@@ -318,6 +318,7 @@ bool MusE::importMidi(const QString name, bool merge)
outPort->setDefaultName();
song->insertTrack0(outPort, -1);
+#if 0
//
// route output to preferred midi device
//
@@ -325,6 +326,7 @@ bool MusE::importMidi(const QString name, bool merge)
Route dst(config.defaultMidiOutputDevice, 0, Route::MIDIPORT);
outPort->outRoutes()->push_back(dst);
}
+#endif
//
// set preferred instrument
//
@@ -337,11 +339,12 @@ bool MusE::importMidi(const QString name, bool merge)
}
if (config.createDefaultMidiInput) {
+#if 0
inPort = new MidiInPort();
inPort->setDefaultName();
song->insertTrack0(inPort, -1);
if (config.connectToAllMidiDevices) {
- std::list<PortName>* ol = midiDriver->inputPorts();
+ QList<PortName> ol = midiDriver->inputPorts();
for (std::list<PortName>::iterator ip = ol->begin(); ip != ol->end(); ++ip) {
Route src(ip->name, 0, Route::MIDIPORT);
inPort->inRoutes()->push_back(src);
@@ -351,6 +354,7 @@ bool MusE::importMidi(const QString name, bool merge)
Route src(config.defaultMidiInputDevice, 0, Route::MIDIPORT);
inPort->inRoutes()->push_back(src);
}
+#endif
}
//
diff --git a/muse/muse/miditrack.h b/muse/muse/miditrack.h
index 1cb5862d..87f52886 100644
--- a/muse/muse/miditrack.h
+++ b/muse/muse/miditrack.h
@@ -91,5 +91,7 @@ typedef tracklist<MidiTrack*>::iterator iMidiTrack;
typedef tracklist<MidiTrack*>::const_iterator ciMidiTrack;
typedef tracklist<MidiTrack*> MidiTrackList;
+Q_DECLARE_METATYPE(class MidiTrack*);
+
#endif
diff --git a/muse/muse/mixer/astrip.cpp b/muse/muse/mixer/astrip.cpp
index 03b0f133..1f017e5b 100644
--- a/muse/muse/mixer/astrip.cpp
+++ b/muse/muse/mixer/astrip.cpp
@@ -1,10 +1,22 @@
-//=========================================================
+//=============================================================================
// MusE
// Linux Music Editor
-// $Id: astrip.cpp,v 1.81 2006/04/22 13:53:17 wschweer Exp $
+// $Id:$
//
-// (C) Copyright 2000-2005 Werner Schweer (ws@seh.de)
-//=========================================================
+// 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 "driver/audiodev.h"
@@ -16,7 +28,7 @@
#include "muse.h"
#include "widgets/simplebutton.h"
#include "widgets/utils.h"
-#include "plugin.h"
+#include "auxplugin.h"
#include "awl/volknob.h"
#include "awl/panknob.h"
@@ -443,25 +455,64 @@ Awl::PanKnob* AudioStrip::addPanKnob(Awl::PanEntry** dlabel)
}
//---------------------------------------------------------
+// addAuxPorts
+//---------------------------------------------------------
+
+static void addAuxPorts(AudioTrack* track, QMenu* lb, RouteList* r)
+ {
+ QList<AuxPluginIF*> pre = track->preAux();
+ QList<AuxPluginIF*> post = track->postAux();
+ foreach (AuxPluginIF* p, pre) {
+ QString s = p->pluginInstance()->name();
+ QAction* a = lb->addAction(p->pluginInstance()->name());
+ a->setCheckable(true);
+ Route route(p);
+ a->setData(QVariant::fromValue(route));
+ for (iRoute ir = r->begin(); ir != r->end(); ++ir) {
+ if (*ir == route) {
+ a->setChecked(true);
+ break;
+ }
+ }
+ }
+ foreach(AuxPluginIF* p, post) {
+ QAction* a = lb->addAction(p->pluginInstance()->name());
+ a->setCheckable(true);
+ Route route(p);
+ a->setData(QVariant::fromValue(route));
+ for (iRoute ir = r->begin(); ir != r->end(); ++ir) {
+ if (*ir == route) {
+ a->setChecked(true);
+ break;
+ }
+ }
+ }
+ }
+
+//---------------------------------------------------------
// addInPorts
//---------------------------------------------------------
-static void addInPorts(AudioTrack* t, QMenu* lb, RouteList* r)
+static void addInPorts(AudioTrack* t, QMenu* lb, RouteList* r, bool input)
{
InputList* al = song->inputs();
for (iAudioInput i = al->begin(); i != al->end(); ++i) {
- Track* track = *i;
+ AudioTrack* track = (AudioTrack*)*i;
if (t == track)
continue;
- QString s(track->name());
- QAction* it = lb->addAction(s); //int it = lb->insertItem(s);
+ QAction* it = lb->addAction(track->name());
+ it->setCheckable(true);
+ Route route(track);
+ it->setData(QVariant::fromValue(route));
+
for (iRoute ir = r->begin(); ir != r->end(); ++ir) {
- if (ir->type == 0 && ir->track == track) {
- it->setCheckable(true); //lb->setItemChecked(it, true);
+ if (*ir == route) {
it->setChecked(true);
break;
}
}
+ if (input)
+ addAuxPorts(track, lb, r);
}
}
@@ -476,11 +527,12 @@ static void addOutPorts(AudioTrack* t, QMenu* lb, RouteList* r)
Track* track = *i;
if (t == track)
continue;
- QString s(track->name());
- QAction* it = lb->addAction(s); //int it = lb->insertItem(s);
+ QAction* it = lb->addAction(track->name());
+ it->setCheckable(true);
+ Route route(track);
+ it->setData(QVariant::fromValue(route));
for (iRoute ir = r->begin(); ir != r->end(); ++ir) {
- if (ir->type == 0 && ir->track == track) {
- it->setCheckable(true); //lb->setItemChecked(it, true);
+ if (*ir == route) {
it->setChecked(true);
break;
}
@@ -496,14 +548,15 @@ static void addGroupPorts(AudioTrack* t, QMenu* lb, RouteList* r)
{
GroupList* al = song->groups();
for (iAudioGroup i = al->begin(); i != al->end(); ++i) {
- Track* track = *i;
+ AudioTrack* track = (AudioTrack*)*i;
if (t == track)
continue;
- QString s(track->name());
- QAction* it = lb->addAction(s); //int it = lb->insertItem(s);
+ QAction* it = lb->addAction(track->name());
+ it->setCheckable(true);
+ Route route(track);
+ it->setData(QVariant::fromValue(route));
for (iRoute ir = r->begin(); ir != r->end(); ++ir) {
- if (ir->type == 0 && ir->track == track) {
- it->setCheckable(true); //lb->setItemChecked(it, true);
+ if (*ir == route) {
it->setChecked(true);
break;
}
@@ -515,22 +568,25 @@ static void addGroupPorts(AudioTrack* t, QMenu* lb, RouteList* r)
// addWavePorts
//---------------------------------------------------------
-static void addWavePorts(AudioTrack* t, QMenu* lb, RouteList* r)
+static void addWavePorts(AudioTrack* t, QMenu* lb, RouteList* r, bool input)
{
WaveTrackList* al = song->waves();
for (iWaveTrack i = al->begin(); i != al->end(); ++i) {
- Track* track = *i;
- if (t == track)
+ AudioTrack* track = (AudioTrack*)*i;
+ if (t == track) // cannot connect to itself
continue;
- QString s(track->name());
- QAction* it = lb->addAction(s); //int it = lb->insertItem(s);
+ QAction* it = lb->addAction(track->name());
+ it->setCheckable(true);
+ Route route(track);
+ it->setData(QVariant::fromValue(route));
for (iRoute ir = r->begin(); ir != r->end(); ++ir) {
- if (ir->type == 0 && ir->track == track) {
- it->setCheckable(true); //lb->setItemChecked(it, true);
+ if (*ir == route) {
it->setChecked(true);
break;
}
}
+ if (input)
+ addAuxPorts(track, lb, r);
}
}
@@ -545,12 +601,12 @@ static void addMidiOutPorts(Track* t, QMenu* lb, RouteList* r)
Track* track = *i;
if (t == track)
continue;
- QString s(track->name());
- QAction* it = lb->addAction(s);//int it = lb->insertItem(s);
- Route route(track, -1, Route::TRACK);
+ QAction* it = lb->addAction(track->name());
+ it->setCheckable(true);
+ Route route(track);
+ it->setData(QVariant::fromValue(route));
for (iRoute ir = r->begin(); ir != r->end(); ++ir) {
if (*ir == route) {
- it->setCheckable(true);//lb->setItemChecked(it, true);
it->setChecked(true);
break;
}
@@ -569,12 +625,12 @@ static void addMidiInPorts(Track* t, QMenu* lb, RouteList* r)
Track* track = *i;
if (t == track)
continue;
- QString s(track->name());
- QAction* it = lb->addAction(s); //int it = lb->insertItem(s);
- Route route(track, -1, Route::TRACK);
+ QAction* it = lb->addAction(track->name());
+ it->setCheckable(true);
+ Route route(track);
+ it->setData(QVariant::fromValue(route));
for (iRoute ir = r->begin(); ir != r->end(); ++ir) {
if (*ir == route) {
- it->setCheckable(true); //lb->setItemChecked(it, true);
it->setChecked(true);
break;
}
@@ -590,16 +646,16 @@ static void addSyntiPorts(AudioTrack* t, QMenu* lb, RouteList* r)
{
SynthIList* al = song->syntis();
for (iSynthI i = al->begin(); i != al->end(); ++i) {
- Track* track = *i;
+ AudioTrack* track = (AudioTrack*)*i;
if (t == track)
continue;
- QString s(track->name());
- QAction* it = lb->addAction(s); //int it = lb->insertItem(s);
+ QAction* it = lb->addAction(track->name());
+ it->setCheckable(true);
Route route(track, -1, Route::SYNTIPORT);
+ it->setData(QVariant::fromValue(route));
for (iRoute ir = r->begin(); ir != r->end(); ++ir) {
if (*ir == route) {
- it->setCheckable(true);//lb->setItemChecked(it, true);
it->setChecked(true);
break;
}
@@ -613,97 +669,73 @@ static void addSyntiPorts(AudioTrack* t, QMenu* lb, RouteList* r)
void AudioStrip::iRoutePressed()
{
- QMenu* pup = new QMenu(iR);
+ QMenu pup(iR);
AudioTrack* t = (AudioTrack*)track;
RouteList* irl = t->inRoutes();
switch(track->type()) {
default:
- delete pup;
return;
case Track::AUDIO_INPUT:
{
- int gid = 0;
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));
-
- std::list<PortName>* ol = audioDriver->outputPorts();
- for (std::list<PortName>::iterator ip = ol->begin(); ip != ol->end(); ++ip) {
- QAction* id = pup->addAction(ip->name);
- id->setData(QVariant(gid * 16 + i));
- Route src(ip->name, i, Route::AUDIOPORT);
- ++gid;
+ pup.addSeparator()->setText(QString(buffer));
+ QList<PortName> ol = audioDriver->outputPorts();
+ foreach (PortName ip, ol) {
+ QAction* id = pup.addAction(ip.name);
+ id->setCheckable(true);
+ Route src(ip.port, i, Route::AUDIOPORT);
+ id->setData(QVariant::fromValue(src));
for (iRoute ir = irl->begin(); ir != irl->end(); ++ir) {
if (*ir == src) {
- id->setCheckable(true);
id->setChecked(true);
break;
}
}
}
- delete ol;
-// if (i+1 != channel)
-// pup->addSeparator();
}
}
break;
case Track::AUDIO_OUTPUT:
- addWavePorts(t, pup, irl);
- addInPorts(t, pup, irl);
- addGroupPorts(t, pup, irl);
- addSyntiPorts(t, pup, irl);
+ 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);
+ addInPorts(t, &pup, irl, true);
break;
case Track::AUDIO_GROUP:
- addWavePorts(t, pup, irl);
- addInPorts(t, pup, irl);
- addGroupPorts(t, pup, irl);
- addSyntiPorts(t, pup, irl);
+ addWavePorts(t, &pup, irl, true);
+ addInPorts(t, &pup, irl, true);
+ addGroupPorts(t, &pup, irl);
+ addSyntiPorts(t, &pup, irl);
break;
case Track::AUDIO_SOFTSYNTH:
- addMidiOutPorts(t, pup, irl);
- addMidiInPorts(t, pup, irl);
+ addMidiOutPorts(t, &pup, irl);
+ addMidiInPorts(t, &pup, irl);
break;
}
- QAction* n = pup->exec(QCursor::pos());
+ QAction* n = pup.exec(QCursor::pos());
if (n != 0) {
- int id = n->data().toInt();
- QString s(n->text());
- Route srcRoute, dstRoute;
+ Route srcRoute = n->data().value<Route>();
+ Route dstRoute(t);
+ dstRoute.channel = srcRoute.channel;
- if (track->type() == Track::AUDIO_INPUT) {
- srcRoute = Route(s, id & 0xf, Route::AUDIOPORT);
- dstRoute = Route(t, id & 0xf, Route::TRACK);
- }
- else if (track->type() == Track::AUDIO_SOFTSYNTH) {
- srcRoute = Route(s, -1, Route::TRACK);
- dstRoute = Route(t, -1, Route::SYNTIPORT);
- }
- else {
- srcRoute = Route(s, -1, Route::TRACK);
- dstRoute = Route(t, -1, Route::TRACK);
- }
- iRoute iir = irl->begin();
- for (; iir != irl->end(); ++iir) {
- if (*iir == srcRoute)
- break;
- }
- if (iir != irl->end()) {
- // disconnect
- audio->msgRemoveRoute(srcRoute, dstRoute);
- }
- else {
- // connect
+ if (track->type() == Track::AUDIO_INPUT)
+ dstRoute.channel = srcRoute.channel;
+ else if (track->type() == Track::AUDIO_SOFTSYNTH)
+ dstRoute.type = Route::SYNTIPORT;
+
+ if (n->isChecked())
audio->msgAddRoute(srcRoute, dstRoute);
- }
+ else
+ audio->msgRemoveRoute(srcRoute, dstRoute);
song->update(SC_ROUTE);
}
- delete pup;
- iR->setDown(false); // pup->exec() catches mouse release event
+ iR->setDown(false); // pup.exec() catches mouse release event
}
//---------------------------------------------------------
@@ -712,83 +744,62 @@ void AudioStrip::iRoutePressed()
void AudioStrip::oRoutePressed()
{
- QMenu* pup = new QMenu(oR);
+ QMenu pup(oR);
AudioTrack* t = (AudioTrack*)track;
RouteList* orl = t->outRoutes();
switch(track->type()) {
default:
- delete pup;
return;
case Track::AUDIO_OUTPUT:
{
- int gid = 0;
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));
-
- std::list<PortName>* ol = audioDriver->inputPorts();
- for (std::list<PortName>::iterator ip = ol->begin(); ip != ol->end(); ++ip) {
- QAction* action = pup->addAction(ip->name);
- action->setData(QVariant(gid * 16 + i));
- Route dst(ip->name, i, Route::AUDIOPORT);
- ++gid;
+ pup.addSeparator()->setText(QString(buffer));
+
+ QList<PortName> ol = audioDriver->inputPorts();
+ foreach (PortName ip, ol) {
+ QAction* action = pup.addAction(ip.name);
+ action->setCheckable(true);
+ Route dst(ip.port, i, Route::AUDIOPORT);
+ action->setData(QVariant::fromValue(dst));
for (iRoute ir = orl->begin(); ir != orl->end(); ++ir) {
if (*ir == dst) {
- action->setCheckable(true);
action->setChecked(true);
break;
}
}
}
- delete ol;
-// if (i+1 != channel)
-// pup->addSeparator();
}
}
break;
case Track::AUDIO_INPUT:
- addWavePorts(t, pup, orl);
+ addWavePorts(t, &pup, orl, false);
case Track::WAVE:
case Track::AUDIO_GROUP:
case Track::AUDIO_SOFTSYNTH:
- addOutPorts(t, pup, orl);
- addGroupPorts(t, pup, orl);
+ addOutPorts(t, &pup, orl);
+ addGroupPorts(t, &pup, orl);
break;
}
- QAction* n = pup->exec(QCursor::pos());
+ QAction* n = pup.exec(QCursor::pos());
if (n != 0) {
QString s(n->text());
- Route srcRoute(t, -1, track->type() == Track::AUDIO_SOFTSYNTH
- ? Route::SYNTIPORT : Route::TRACK);
- Route dstRoute(s, -1, track->type() == Track::AUDIO_OUTPUT
- ? Route::AUDIOPORT : Route::TRACK);
-
- if (track->type() == Track::AUDIO_OUTPUT) {
- QVariant data = n->data();
- srcRoute.channel = dstRoute.channel = data.toInt() & 0xf; //n & 0xf;
- }
-
-
- // check if route src->dst exists:
- iRoute iorl = orl->begin();
- for (; iorl != orl->end(); ++iorl) {
- if (*iorl == dstRoute)
- break;
- }
- if (iorl != orl->end()) {
- // disconnect if route exists
- audio->msgRemoveRoute(srcRoute, dstRoute);
- }
- else {
- // connect if route does not exist
+ Route srcRoute(t);
+ Route dstRoute = n->data().value<Route>();
+
+ if (track->type() == Track::AUDIO_SOFTSYNTH)
+ srcRoute.type = Route::SYNTIPORT;
+ else if (track->type() == Track::AUDIO_OUTPUT)
+ srcRoute.channel = dstRoute.channel;
+ if (n->isChecked())
audio->msgAddRoute(srcRoute, dstRoute);
- }
+ else
+ audio->msgRemoveRoute(srcRoute, dstRoute);
song->update(SC_ROUTE);
}
- delete pup;
- oR->setDown(false); // pup->exec() catches mouse release event
+ oR->setDown(false); // pup.exec() catches mouse release event
}
//---------------------------------------------------------
@@ -879,3 +890,4 @@ void AudioStrip::autoWriteToggled(bool val)
{
song->setAutoWrite(track, val);
}
+
diff --git a/muse/muse/mixer/mstrip.cpp b/muse/muse/mixer/mstrip.cpp
index 8e37816b..b93d747d 100644
--- a/muse/muse/mixer/mstrip.cpp
+++ b/muse/muse/mixer/mstrip.cpp
@@ -355,33 +355,31 @@ void MidiChannelStrip::iRoutePressed()
MidiTrackList* tl = song->midis();
int tn = 0;
for (iMidiTrack i = tl->begin();i != tl->end(); ++i, ++tn) {
- QAction* id = pup->addAction((*i)->name());
- id->setData(QVariant(0));
+ MidiTrack* track = *i;
+ QAction* id = pup->addAction(track->name());
+ id->setCheckable(true);
+ QVariant v(track);
+ id->setData(v);
Route dst(*i, -1, Route::TRACK);
for (iRoute ir = irl->begin(); ir != irl->end(); ++ir) {
if (*ir == dst) {
- id->setData(QVariant(1));
- id->setCheckable(true);
- id->setChecked(true);
- break;
+ id->setChecked(true);
+ break;
}
}
}
QAction* n = pup->exec(QCursor::pos());
- if (n) {//if (n != -1) {
- int was_checked = n->data().toInt(); // isChecked appears to always give false, storing in QVariant instead
+ if (n) {
QString s(n->text());
+ MidiTrack* track = n->data().value<MidiTrack*>();
Route dstRoute(t, -1, Route::TRACK);
- Route srcRoute(s, -1, Route::TRACK);
-
+ Route srcRoute(track, -1, Route::TRACK);
- if (was_checked == 1) {
+ if (n->isChecked())
audio->msgRemoveRoute(srcRoute, dstRoute);
- }
- else {
+ else
audio->msgAddRoute(srcRoute, dstRoute);
- }
song->update(SC_ROUTE);
}
delete pup;
@@ -920,24 +918,17 @@ void MidiOutPortStrip::oRoutePressed()
pup->addSeparator()->setText(tr("MidiDevices"));
RouteList* orl = track->outRoutes();
- std::list<PortName>* ol = midiDriver->outputPorts();
+ QList<PortName> ol = midiDriver->outputPorts();
int idx = 0;
- for (std::list<PortName>::iterator ip = ol->begin(); ip != ol->end(); ++ip, ++idx) {
- QAction* oa = pup->addAction(ip->name);
-
- QMap<QString, QVariant> data;
- data["was_checked"] = false;
- data["id"] = idx;
- oa->setData(data);
+ foreach (PortName ip, ol) {
+ QAction* oa = pup->addAction(ip.name);
+ oa->setCheckable(true);
+ oa->setData(qVariantFromValue(ip.port));
- Port port = ip->port;
- Route dst(port, Route::MIDIPORT);
+ Route dst(ip.port, Route::MIDIPORT);
for (iRoute ir = orl->begin(); ir != orl->end(); ++ir) {
if (*ir == dst) {
- oa->setCheckable(true);
oa->setChecked(true);
- data["was_checked"] = true;
- oa->setData(data);
break;
}
}
@@ -949,21 +940,15 @@ void MidiOutPortStrip::oRoutePressed()
idx = 1000;
SynthIList* sl = song->syntis();
for (iSynthI i = sl->begin(); i != sl->end(); ++i, ++idx) {
- //int id = pup->insertItem((*i)->name(), idx);
- QAction* oa = pup->addAction((*i)->name());
+ SynthI* track = *i;
+ QAction* oa = pup->addAction(track->name());
+ oa->setCheckable(true);
+ oa->setData(QVariant(idx));
- QMap<QString, QVariant> data;
- data["was_checked"] = false;
- data["id"] = idx;
- oa->setData(data);
-
- Route dst(*i, Route::SYNTIPORT);
+ Route dst(track, -1, Route::SYNTIPORT);
for (iRoute ir = orl->begin(); ir != orl->end(); ++ir) {
if (*ir == dst) {
- oa->setCheckable(true);
oa->setChecked(true);
- data["was_checked"] = true;
- oa->setData(data);
break;
}
}
@@ -971,21 +956,14 @@ void MidiOutPortStrip::oRoutePressed()
QAction* action = pup->exec(QCursor::pos());
if (action) {
- QString s(action->text()); //(pup->text(n));
- int n = action->data().toMap()["id"].toInt();
- int was_checked = action->data().toMap()["was_checked"].toInt();
+ QString s(action->text());
+ int n = action->data().toInt();
- Route srcRoute(track, -1, Route::TRACK);
+ Route srcRoute(track);
if (n < 1000) {
- int idx = 0;
- std::list<PortName>::iterator ip;
- for (ip = ol->begin(); ip != ol->end(); ++ip, ++idx) {
- if (idx == n)
- break;
- }
- Port port = ip->port;
- Route dstRoute(port, Route::MIDIPORT);
- if (was_checked)
+ PortName ip = ol[n];
+ Route dstRoute(ip.port, Route::MIDIPORT);
+ if (action->isChecked())
audio->msgRemoveRoute(srcRoute, dstRoute);
else
audio->msgAddRoute(srcRoute, dstRoute);
@@ -993,8 +971,8 @@ void MidiOutPortStrip::oRoutePressed()
else {
for (iSynthI i = sl->begin(); i != sl->end(); ++i) {
if ((*i)->name() == s) {
- Route dstRoute(*i, Route::SYNTIPORT);
- if (was_checked)
+ Route dstRoute(*i, -1, Route::SYNTIPORT);
+ if (action->isChecked())
audio->msgRemoveRoute(srcRoute, dstRoute);
else
audio->msgAddRoute(srcRoute, dstRoute);
@@ -1005,7 +983,6 @@ void MidiOutPortStrip::oRoutePressed()
song->update(SC_ROUTE);
}
delete pup;
- delete ol;
oR->setDown(false); // pup->exec() catches mouse release event
}
@@ -1286,20 +1263,18 @@ void MidiInPortStrip::iRoutePressed()
RouteList* irl = track->inRoutes();
- std::list<PortName>* ol = midiDriver->inputPorts();
- for (std::list<PortName>::iterator ip = ol->begin(); ip != ol->end(); ++ip) {
- QAction* action = pup->addAction(ip->name);
- Port port = ip->port;
- Route dst(port, Route::MIDIPORT);
+ QList<PortName> ol = midiDriver->inputPorts();
+ foreach (PortName ip, ol) {
+ QAction* action = pup->addAction(ip.name);
+ action->setCheckable(true);
+ Route dst(ip.port, Route::MIDIPORT);
for (iRoute ir = irl->begin(); ir != irl->end(); ++ir) {
if (*ir == dst) {
- action->setCheckable(true);
action->setChecked(true);
break;
}
}
}
- delete ol;
QAction* action = pup->exec(QCursor::pos());
if (action) {
QString s(action->text());
diff --git a/muse/muse/mixer/rack.cpp b/muse/muse/mixer/rack.cpp
index 44d49922..eb0822b2 100644
--- a/muse/muse/mixer/rack.cpp
+++ b/muse/muse/mixer/rack.cpp
@@ -126,6 +126,8 @@ void EffectRack::contextMenuEvent(QContextMenuEvent* ev)
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;
diff --git a/muse/muse/muse.cpp b/muse/muse/muse.cpp
index 782954bc..cc4e7221 100644
--- a/muse/muse/muse.cpp
+++ b/muse/muse/muse.cpp
@@ -350,6 +350,7 @@ void addProject(const QString& name)
void populateAddTrack(QMenu* m)
{
+ m->setSeparatorsCollapsible(false);
m->clear();
QAction* a;
@@ -357,6 +358,7 @@ void populateAddTrack(QMenu* m)
a->setText(QT_TR_NOOP("Midi"));
QFont f(a->font());
f.setBold(true);
+ f.setPointSize(8);
a->setFont(f);
a = m->addAction(QIcon(*addtrack_addmiditrackIcon), QT_TR_NOOP("Add Midi Track"));
@@ -380,7 +382,7 @@ void populateAddTrack(QMenu* m)
if (!midiOnly) {
a = m->addSeparator();
- a->setText(QT_TR_NOOP("Audio Strips"));
+ a->setText(QT_TR_NOOP("Audio"));
a->setFont(f);
a = m->addAction(QIcon(*addtrack_wavetrackIcon), QT_TR_NOOP("Add Wave Track"));
diff --git a/muse/muse/plugin.h b/muse/muse/plugin.h
index dbffa686..c01a1f18 100644
--- a/muse/muse/plugin.h
+++ b/muse/muse/plugin.h
@@ -110,6 +110,7 @@ class PluginIF {
virtual ~PluginIF() {}
PluginI* pluginInstance() { return pluginI; }
+ const PluginI* pluginInstance() const { return pluginI; }
virtual void apply(unsigned nframes, float** src, float** dst) = 0;
virtual void activate() = 0;
@@ -206,6 +207,8 @@ class PluginI {
bool isLog(int k) const { return _plugin->isLog(k); }
bool isBool(int k) const { return _plugin->isBool(k); }
bool isInt(int k) const { return _plugin->isInt(k); }
+
+ PluginIF* pluginIF(int idx) { return pif[idx]; }
};
extern void initPlugins();
diff --git a/muse/muse/preferences.cpp b/muse/muse/preferences.cpp
index 1807e88b..6587f48c 100644
--- a/muse/muse/preferences.cpp
+++ b/muse/muse/preferences.cpp
@@ -241,16 +241,16 @@ PreferencesDialog::PreferencesDialog(Arranger* a, QWidget* parent)
break;
}
}
- std::list<PortName>* ol = midiDriver->inputPorts();
+ QList<PortName> ol = midiDriver->inputPorts();
int i = 0;
- for (std::list<PortName>::iterator ip = ol->begin(); ip != ol->end(); ++ip, ++i) {
+ for (QList<PortName>::iterator ip = ol.begin(); ip != ol.end(); ++ip, ++i) {
preferredInput->addItem(ip->name);
if (ip->name == config->defaultMidiInputDevice)
preferredInput->setCurrentIndex(i);
}
ol = midiDriver->outputPorts();
i = 0;
- for (std::list<PortName>::iterator ip = ol->begin(); ip != ol->end(); ++ip, ++i) {
+ for (QList<PortName>::iterator ip = ol.begin(); ip != ol.end(); ++ip, ++i) {
preferredOutput->addItem(ip->name);
if (ip->name == config->defaultMidiOutputDevice)
preferredOutput->setCurrentIndex(i);
diff --git a/muse/muse/route.cpp b/muse/muse/route.cpp
index dc8ccb13..bc8a02e8 100644
--- a/muse/muse/route.cpp
+++ b/muse/muse/route.cpp
@@ -26,140 +26,51 @@
#include "driver/audiodev.h"
#include "driver/mididev.h"
#include "al/xml.h"
+#include "auxplugin.h"
//---------------------------------------------------------
-// name2route
+// Route
//---------------------------------------------------------
-static Route name2route(const QString& rn, Route::RouteType t)
+Route::Route(Port p, int ch, RouteType t)
{
- int channel = -1;
-
- // mainly for debugging purposes, it happens that name2route is called without an entry
- // possibly this should be removed if it's no longer the case.
- if (rn.isEmpty()) {
- static const char* names[] = {
- "TRACK", "AUDIOPORT", "MIDIPORT", "SYNTIPORT"
- };
- printf("!!!!!!!!!!!!!!!!!!!!!! empty route!!!!!!!!!!!!!!name2route: %s: <%s> not found\n", names[t], rn.toLatin1().data());
- return Route((Track*) 0, channel, Route::TRACK);
- }
- QString s(rn);
-
- if (rn[0].isNumber() && rn[1]==':') {
- int c = rn[0].toLatin1();
- channel = c - '1';
- s = rn.mid(2);
- }
- else if (rn[0].isNumber() && rn[1].isNumber() && rn[2]==':') {
- channel = (rn[0].toLatin1() - '0') * 10 + (rn[1].toLatin1() - '0') - 1;
- s = rn.mid(3);
- }
- switch (t) {
- case Route::TRACK:
- {
- TrackList* tl = song->tracks();
- for (iTrack i = tl->begin(); i != tl->end(); ++i) {
- Track* track = *i;
- if (track->name() == s)
- return Route(track, channel, Route::TRACK);
- }
- MidiChannelList* mc = song->midiChannel();
- for (iMidiChannel i = mc->begin(); i != mc->end(); ++i) {
- MidiChannel* t = *i;
- if (t->name() == s)
- return Route(t, channel, Route::TRACK);
- }
- }
- break;
- case Route::AUDIOPORT:
- {
- Port p = audioDriver->findPort(s);
- if (p)
- return Route(p, Route::AUDIOPORT);
- }
- break;
- case Route::MIDIPORT:
- {
- Port p = midiDriver->findPort(s);
- if (p)
- return Route(p, Route::MIDIPORT);
- }
- break;
- case Route::SYNTIPORT:
- {
- SynthIList* tl = song->syntis();
- for (iSynthI i = tl->begin(); i != tl->end(); ++i) {
- SynthI* track = *i;
- if (track->name() == s)
- return Route(track, channel, Route::SYNTIPORT);
- }
- }
-
- }
- static const char* names[] = {
- "TRACK", "AUDIOPORT", "MIDIPORT", "SYNTIPORT"
- };
- printf("name2route: %s: <%s> not found\n", names[t], rn.toLatin1().data());
- return Route((Track*) 0, channel, Route::TRACK);
+ port = p;
+ channel = ch;
+ type = t;
}
-//---------------------------------------------------------
-// Route
-//---------------------------------------------------------
-
Route::Route(Port p, RouteType t)
{
port = p;
channel = -1;
- stream = 0;
type = t;
}
-Route::Route(Track* tr, RouteType t)
+Route::Route(Track* tr)
{
track = tr;
channel = -1;
- stream = 0;
- type = t;
+ type = TRACK;
}
-Route::Route(Track* tr)
+Route::Route(AuxPluginIF* p)
{
- track = tr;
+ plugin = p;
channel = -1;
- stream = 0;
- type = TRACK;
+ type = AUXPLUGIN;
}
Route::Route(Track* tr, int ch, RouteType t)
{
track = tr;
channel = ch;
- stream = 0;
type = t;
}
-Route::Route(const QString& s, int ch, RouteType t)
- {
- Route node(name2route(s, t));
- if (node.isValid()) {
- channel = node.channel;
- if (channel == -1)
- channel = ch;
- if (node.type == TRACK)
- track = node.track;
- else
- port = node.port;
- type = t;
- }
- }
-
Route::Route()
{
track = 0;
channel = -1;
- stream = 0;
type = TRACK;
}
@@ -213,6 +124,10 @@ bool addRoute(Route src, Route dst)
}
outRoutes->push_back(dst);
}
+ else if (src.type == Route::AUXPLUGIN) {
+ RouteList* inRoutes = dst.track->inRoutes();
+ inRoutes->insert(inRoutes->begin(), src);
+ }
else {
RouteList* outRoutes = src.track->outRoutes();
for (iRoute i = outRoutes->begin(); i != outRoutes->end(); ++i) {
@@ -237,6 +152,7 @@ void removeRoute(Route src, Route dst)
// printf("removeRoute %s.%d:<%s> %s.%d:<%s>\n",
// src.tname(), src.channel, src.name().toLatin1().data(),
// dst.tname(), dst.channel, dst.name().toLatin1().data());
+
if (src.type == Route::AUDIOPORT || src.type == Route::MIDIPORT) {
if (dst.type != Route::TRACK && dst.type != Route::SYNTIPORT) {
fprintf(stderr, "removeRoute: bad route 1\n");
@@ -276,6 +192,19 @@ void removeRoute(Route src, Route dst)
}
}
}
+ else if (src.type == Route::AUXPLUGIN) {
+ if (dst.type != Route::TRACK) {
+ fprintf(stderr, "removeRoute: bad route 5\n");
+ goto error;
+ }
+ RouteList* inRoutes = dst.track->inRoutes();
+ for (iRoute i = inRoutes->begin(); i != inRoutes->end(); ++i) {
+ if (*i == src) {
+ inRoutes->erase(i);
+ break;
+ }
+ }
+ }
else {
RouteList* outRoutes = src.track->outRoutes();
for (iRoute i = outRoutes->begin(); i != outRoutes->end(); ++i) {
@@ -325,6 +254,8 @@ QString Route::name() const
return audioDriver->portName(port);
case MIDIPORT:
return midiDriver->portName(port);
+ case AUXPLUGIN:
+ return plugin->pluginInstance()->name();
}
return QString("?");
}
@@ -355,6 +286,10 @@ void Song::readRoute(QDomNode n)
else
printf("MusE:readRoute: unknown tag %s\n", e.tagName().toLatin1().data());
}
+ if (s.type == Route::AUDIOPORT)
+ s.channel = d.channel;
+ if (d.type == Route::AUDIOPORT)
+ d.channel = s.channel;
addRoute(s, d);
}
@@ -396,16 +331,18 @@ void Route::dump() const
bool Route::operator==(const Route& a) const
{
- if (type == a.type) {
- if (type == TRACK || type == SYNTIPORT) {
+ if (type != a.type)
+ return false;
+ switch(type) {
+ case TRACK:
+ case SYNTIPORT:
return channel == a.channel && track == a.track;
- }
- else if (type == MIDIPORT) {
+ case MIDIPORT:
return midiDriver->equal(port, a.port);
- }
- else if (type == AUDIOPORT) {
+ case AUDIOPORT:
return channel == a.channel && audioDriver->equal(port, a.port);
- }
+ case AUXPLUGIN:
+ return plugin == a.plugin;
}
return false;
}
@@ -417,9 +354,9 @@ bool Route::operator==(const Route& a) const
const char* Route::tname(RouteType t)
{
static const char* names[] = {
- "TRACK", "AUDIOPORT", "MIDIPORT", "SYNTIPORT"
+ "TRACK", "AUDIOPORT", "MIDIPORT", "SYNTIPORT", "AUX"
};
- if (t > 3)
+ if (t > (int)(sizeof(names)/sizeof(*names)))
return "???";
return names[t];
}
@@ -435,18 +372,24 @@ const char* Route::tname() const
void Route::write(Xml& xml, const char* label) const
{
- xml.put("<%s type=\"%s\" channel=\"%d\" stream=\"%d\" name=\"%s\"/>",
- label, tname(), channel + 1, stream, name().toUtf8().data());
- }
-
-//---------------------------------------------------------
-// write
-//---------------------------------------------------------
+ switch (type) {
+ case AUDIOPORT:
+ case MIDIPORT:
+ case AUXPLUGIN:
+ xml.put("<%s type=\"%s\" name=\"%s\"/>",
+ label, tname(), name().toUtf8().data());
+ break;
+ case TRACK:
+ case SYNTIPORT:
+ if (channel != -1)
+ xml.put("<%s type=\"%s\" channel=\"%d\" name=\"%s\"/>",
+ label, tname(), channel + 1, name().toUtf8().data());
+ else
+ xml.put("<%s type=\"%s\" name=\"%s\"/>",
+ label, tname(), name().toUtf8().data());
-void Route::write(Xml& xml, const char* label, const Track* track)
- {
- xml.put("<%s type=\"TRACK\" channel=\"0\" stream=\"0\" name=\"%s\"/>",
- label, track->name().toUtf8().data());
+ break;
+ }
}
//---------------------------------------------------------
@@ -457,7 +400,7 @@ void Route::read(QDomNode node)
{
QDomElement e = node.toElement();
channel = e.attribute("channel","0").toInt() - 1;
- stream = e.attribute("stream", "0").toInt();
+// int stream = e.attribute("stream", "0").toInt();
QString s = e.attribute("name");
QString st = e.attribute("type", "TRACK");
@@ -506,9 +449,60 @@ void Route::read(QDomNode node)
}
}
}
+ else if (st == "AUX") {
+ type = Route::AUXPLUGIN;
+ plugin = 0;
+ TrackList* tl = song->tracks();
+ for (iTrack i = tl->begin(); i != tl->end(); ++i) {
+ if ((*i)->type() == Track::WAVE || (*i)->type() == Track::AUDIO_INPUT) {
+ AudioTrack* t = (AudioTrack*)*i;
+ QList<AuxPluginIF*> pl = t->preAux();
+ foreach(AuxPluginIF* p, pl) {
+ if (p->pluginInstance()->name() == s) {
+ plugin = p;
+ break;
+ }
+ }
+ if (plugin)
+ break;
+ pl = t->postAux();
+ foreach(AuxPluginIF* p, pl) {
+ if (p->pluginInstance()->name() == s) {
+ plugin = p;
+ break;
+ }
+ }
+ if (plugin)
+ break;
+ }
+ }
+ }
else {
printf("Route::read(): unknown type <%s>\n", st.toLatin1().data());
type = Route::TRACK;
}
}
+//---------------------------------------------------------
+// findTrack
+//---------------------------------------------------------
+
+Track* Song::findTrack(const QString& s) const
+ {
+ TrackList* tl = song->tracks();
+ for (iTrack i = tl->begin(); i != tl->end(); ++i) {
+ Track* track = *i;
+ if (track->name() == s)
+ return track;
+ }
+ MidiChannelList* mc = song->midiChannel();
+ for (iMidiChannel i = mc->begin(); i != mc->end(); ++i) {
+ MidiChannel* t = *i;
+ if (t->name() == s)
+ return t;
+ }
+ printf("track <%s> not found\n", s.toLatin1().data());
+ return 0;
+ }
+
+
diff --git a/muse/muse/route.h b/muse/muse/route.h
index fe862041..35aeca95 100644
--- a/muse/muse/route.h
+++ b/muse/muse/route.h
@@ -22,6 +22,8 @@
#define __ROUTE_H__
class Track;
+class AuxPluginIF;
+
namespace AL {
class Xml;
};
@@ -30,31 +32,53 @@ using AL::Xml;
typedef void* Port;
+// Routing Types:
+//
+// Audio:
+// Port - Track::Channel Audio Input
+// Track::Channel - Port Audio Ouput
+// Track - Track
+// Aux - Track Audio Aux Send
+// Midi:
+// Port - Track Midi Input
+// Track - Port Midi Output
+// Track - Track
+//
+// A software synthesizer is somewhat special as it has
+// a midi input and an audio output
+
//---------------------------------------------------------
// Route
+// this describes one endpoint of a route
+// Track
+// Track/Channel
+// AuxPlugin
+// Port
+// SYNTI
//---------------------------------------------------------
struct Route {
- enum RouteType { TRACK, AUDIOPORT, MIDIPORT, SYNTIPORT};
+ enum RouteType { TRACK, AUDIOPORT, MIDIPORT, SYNTIPORT, AUXPLUGIN};
union {
Track* track;
Port port;
+ AuxPluginIF* plugin;
};
int channel; // route to/from JACK can specify a channel to connect to
- int stream; // 0 - main, 1-n - aux send
RouteType type;
Route();
- Route(const QString&, int ch, RouteType);
+ Route(Port, int, RouteType);
Route(Port, RouteType);
Route(Track*);
- Route(Track*, RouteType);
- Route(Track*, int, RouteType);
+ Route(Track*, int, RouteType t = TRACK);
+ Route(AuxPluginIF*);
+
QString name() const;
void read(QDomNode node);
void write(Xml&, const char* name) const;
- static void write(Xml&, const char* name, const Track*);
+// static void write(Xml&, const char* name, const Track*);
bool operator==(const Route& a) const;
bool isValid() const { return track != 0; }
@@ -63,6 +87,7 @@ struct Route {
static const char* tname(RouteType);
};
+Q_DECLARE_METATYPE(struct Route);
//---------------------------------------------------------
// RouteList
diff --git a/muse/muse/seqmsg.cpp b/muse/muse/seqmsg.cpp
index 356745d1..7c427d15 100644
--- a/muse/muse/seqmsg.cpp
+++ b/muse/muse/seqmsg.cpp
@@ -117,6 +117,7 @@ void Audio::msgAddRoute(Route src, Route dst)
msgAddRoute1(src, dst);
if (src.type == Route::AUDIOPORT) {
AudioInput* ai = (AudioInput*)dst.track;
+printf(" dst channel: %d\n", dst.channel);
audioDriver->connect(src.port, ai->jackPort(dst.channel));
}
if (src.type == Route::MIDIPORT) {
@@ -124,6 +125,7 @@ void Audio::msgAddRoute(Route src, Route dst)
}
else if (dst.type == Route::AUDIOPORT) {
AudioOutput* ao = (AudioOutput*)src.track;
+printf(" src channel: %d\n", src.channel);
audioDriver->connect(ao->jackPort(src.channel), dst.port);
}
else if (dst.type == Route::MIDIPORT) {
diff --git a/muse/muse/song.cpp b/muse/muse/song.cpp
index 88ee902e..86cfb410 100644
--- a/muse/muse/song.cpp
+++ b/muse/muse/song.cpp
@@ -260,20 +260,6 @@ MidiTrack* Song::findTrack(const Part* part) const
}
//---------------------------------------------------------
-// findTrack
-// find track by name
-//---------------------------------------------------------
-
-Track* Song::findTrack(const QString& name) const
- {
- for (ciTrack i = _tracks.begin(); i != _tracks.end(); ++i) {
- if ((*i)->name() == name)
- return *i;
- }
- return 0;
- }
-
-//---------------------------------------------------------
// setLoop
// set transport loop flag
//---------------------------------------------------------
@@ -1633,30 +1619,33 @@ void Song::insertTrack(Track* track, int idx)
case Track::WAVE:
case Track::AUDIO_GROUP:
+ if (ao)
+ track->outRoutes()->push_back(Route(ao));
+ break;
+
case Track::AUDIO_INPUT:
{
// connect first input channel to first available jack output
// etc.
- std::list<PortName>* op = audioDriver->outputPorts();
- std::list<PortName>::iterator is = op->begin();
+ QList<PortName> op = audioDriver->outputPorts();
+ QList<PortName>::iterator is = op.begin();
for (int ch = 0; ch < track->channels(); ++ch) {
- if (is != op->end()) {
- track->inRoutes()->push_back(Route(is->name, ch, Route::AUDIOPORT));
+ if (is != op.end()) {
+ track->inRoutes()->push_back(Route(is->port, ch, Route::AUDIOPORT));
++is;
}
}
- delete op;
if (ao)
- track->outRoutes()->push_back(Route(ao, -1, Route::TRACK));
+ track->outRoutes()->push_back(Route(ao));
}
break;
case Track::AUDIO_OUTPUT:
{
- std::list<PortName>* op = audioDriver->inputPorts();
- std::list<PortName>::iterator is = op->begin();
+ QList<PortName> op = audioDriver->inputPorts();
+ QList<PortName>::iterator is = op.begin();
for (int ch = 0; ch < track->channels(); ++ch) {
- if (is != op->end()) {
- track->outRoutes()->push_back(Route(is->name, ch, Route::AUDIOPORT));
+ if (is != op.end()) {
+ track->outRoutes()->push_back(Route(is->port, ch, Route::AUDIOPORT));
++is;
}
}
@@ -1774,7 +1763,7 @@ void Song::insertTrack2(Track* track)
// connect routes
//
- Route src(track, -1, Route::TRACK);
+ Route src(track);
if (track->type() == Track::AUDIO_SOFTSYNTH)
src.type = Route::SYNTIPORT;
if (track->type() == Track::AUDIO_OUTPUT || track->type() == Track::MIDI_OUT) {
@@ -1794,12 +1783,17 @@ void Song::insertTrack2(Track* track)
else {
const RouteList* rl = track->inRoutes();
for (ciRoute r = rl->begin(); r != rl->end(); ++r) {
- src.channel = r->channel;
- r->track->outRoutes()->push_back(src);
+ Route rt = *r;
+ src.channel = rt.channel;
+ if (rt.type == Route::AUXPLUGIN)
+ continue;
+ rt.track->outRoutes()->push_back(src);
}
rl = track->outRoutes();
for (ciRoute r = rl->begin(); r != rl->end(); ++r) {
src.channel = r->channel;
+ if (r->type == Route::AUXPLUGIN)
+ continue;
r->track->inRoutes()->push_back(src);
}
}
diff --git a/muse/muse/track.cpp b/muse/muse/track.cpp
index dbf90c84..67a5014f 100644
--- a/muse/muse/track.cpp
+++ b/muse/muse/track.cpp
@@ -663,22 +663,27 @@ void Track::updateController()
void Track::writeRouting(Xml& xml) const
{
- if (type() == AUDIO_INPUT || type() == MIDI_IN) {
- const RouteList* rl = &_inRoutes;
- Route::RouteType rt = type() == AUDIO_INPUT ? Route::AUDIOPORT : Route::MIDIPORT;
- for (ciRoute r = rl->begin(); r != rl->end(); ++r) {
- Route dst(name(), r->channel, Route::TRACK);
+ const RouteList* rl = &_inRoutes;
+ for (ciRoute r = rl->begin(); r != rl->end(); ++r) {
+ if (type() == AUDIO_INPUT || type() == MIDI_IN) {
xml.tag("Route");
- xml.put("<src type=\"%s\" name=\"%s\"/>",
- Route::tname(rt), r->name().toLatin1().data());
- xml.put("<dst type=\"TRACK\" name=\"%s\"/>",
- dst.name().toLatin1().data());
+ Route dst((Track*)this, r->channel);
+ r->write(xml, "src");
+ dst.write(xml, "dst");
+ xml.etag("Route");
+ }
+ if (r->type == Route::AUXPLUGIN) {
+ xml.tag("Route");
+ Route dst((Track*)this);
+ r->write(xml, "src");
+ dst.write(xml, "dst");
xml.etag("Route");
}
}
for (ciRoute r = _outRoutes.begin(); r != _outRoutes.end(); ++r) {
+ Route dst((Track*)this);
xml.tag("Route");
- Route::write(xml, "src", this);
+ dst.write(xml, "src");
r->write(xml, "dst");
xml.etag("Route");
}
@@ -726,19 +731,13 @@ bool MidiTrackBase::readProperties(QDomNode node)
QString tag(e.tagName());
if (tag == "midiPlugin") {
MidiPluginI* pi = new MidiPluginI(this);
- if (pi->readConfiguration(node)) {
+ if (pi->readConfiguration(node))
delete pi;
- }
- else {
- // insert plugin into first free slot
- // of plugin rack
+ else
addPlugin(pi, -1);
- }
- }
- else {
- bool rv = Track::readProperties(node);
- return rv;
}
+ else
+ return Track::readProperties(node);
return false;
}
@@ -753,7 +752,7 @@ MidiPluginI* MidiTrackBase::plugin(int idx) const
//---------------------------------------------------------
// addPlugin
-// idx = -1 append
+// idx = -1 append
// plugin = 0 remove slot
//---------------------------------------------------------
diff --git a/muse/muse/wavetrack.cpp b/muse/muse/wavetrack.cpp
index f177164d..61688014 100644
--- a/muse/muse/wavetrack.cpp
+++ b/muse/muse/wavetrack.cpp
@@ -315,12 +315,14 @@ void WaveTrack::collectInputData()
{
bufferEmpty = false;
if (recordFlag() && (audio->isRecording() || !audio->isPlaying())) {
+#if 0 // TODO bounce track
if (song->bounceTrack == this && audio->isPlaying()) {
OutputList* ol = song->outputs();
if (!ol->empty())
ol->front()->multiplyCopy(channels(), buffer, 0);
}
else
+#endif
AudioTrack::collectInputData();
return;
}