diff options
author | Werner Schweer <ws.seh.de> | 2006-11-03 15:53:35 +0000 |
---|---|---|
committer | Werner Schweer <ws.seh.de> | 2006-11-03 15:53:35 +0000 |
commit | b6c114cd8626e0cfd5256154d8d41bf5ae87098f (patch) | |
tree | 1d3387fc790e0f1811872b730a163be6c68bf3fc | |
parent | 48cb6e87fc888bdc1f4e80e7429e6f5f7c14d55f (diff) |
updates
55 files changed, 366 insertions, 495 deletions
@@ -4,15 +4,11 @@ - change default: show MidiChannel in mixer, dont show MidiTrack - Add "monitor" button to midi channel strip in mixer. - - add midi fifo for MESS synthesizer and repeat sending an event - in case the synthesizer is busy - change default: do not default to "automation read" when creating new strips - - change default: when creating midi input strips, route input - to all available midi sources BUGS - - updating the gui during midi recording is too slow; + ? updating the gui during midi recording is too slow; a new, faster implementation is needed - dont allow midi editing during recording. Treat recording diff --git a/muse/midiplugins/libmidiplugin/mempi.h b/muse/midiplugins/libmidiplugin/mempi.h index 122b5a17..a5f114b6 100644 --- a/muse/midiplugins/libmidiplugin/mempi.h +++ b/muse/midiplugins/libmidiplugin/mempi.h @@ -59,7 +59,7 @@ class Mempi { const char* name() const { return _name; } // process interface - virtual void process(unsigned, unsigned, MPEventList*, MPEventList*) = 0; + virtual void process(unsigned, unsigned, MidiEventList*, MidiEventList*) = 0; // session interface virtual void getInitData(int*, const unsigned char**) const {} diff --git a/muse/midiplugins/libmidiplugin/midievent.h b/muse/midiplugins/libmidiplugin/midievent.h index 86a7e734..a21bec88 100644 --- a/muse/midiplugins/libmidiplugin/midievent.h +++ b/muse/midiplugins/libmidiplugin/midievent.h @@ -70,35 +70,18 @@ class MidiEvent { }; //--------------------------------------------------------- -// MPEventList +// MidiEventList //--------------------------------------------------------- // typedef std::multiset<MidiEvent, std::less<MidiEvent>, // __gnu_cxx::__mt_alloc<MidiEvent> > MPEL; -typedef std::multiset<MidiEvent, std::less<MidiEvent> > MPEL; - -struct MPEventList : public MPEL { - void add(const MidiEvent& ev) { MPEL::insert(ev); } - }; - -typedef MPEventList::iterator iMPEvent; -typedef MPEventList::const_iterator ciMPEvent; - -//--------------------------------------------------------- -// MREventList -//--------------------------------------------------------- - -// typedef std::list<MidiEvent, __gnu_cxx::__mt_alloc<MidiEvent> > MREL; - -typedef std::list<MidiEvent> MREL; - -struct MREventList : public MREL { - void add(const MidiEvent& ev) { MREL::push_back(ev); } +struct MidiEventList : public std::multiset<MidiEvent, std::less<MidiEvent> > + { }; -typedef MREventList::iterator iMREvent; -typedef MREventList::const_iterator ciMREvent; +typedef MidiEventList::iterator iMidiEvent; +typedef MidiEventList::const_iterator ciMidiEvent; #endif diff --git a/muse/muse/arranger/tlwidget.cpp b/muse/muse/arranger/tlwidget.cpp index 267e3b7b..84f1044e 100644 --- a/muse/muse/arranger/tlwidget.cpp +++ b/muse/muse/arranger/tlwidget.cpp @@ -158,7 +158,7 @@ void TLWidget::mousePressEvent(QMouseEvent* ev) break; case 1: { - int idx = song->tracks()->index(_track); + int idx = song->tracks()->indexOf(_track); if (_track->type() == Track::MIDI) { MidiTrack* t = new MidiTrack(); t->clone((MidiTrack*)_track); diff --git a/muse/muse/arranger/trackinfo.cpp b/muse/muse/arranger/trackinfo.cpp index 2935b943..b930a491 100644 --- a/muse/muse/arranger/trackinfo.cpp +++ b/muse/muse/arranger/trackinfo.cpp @@ -257,7 +257,7 @@ void MidiTrackInfo::portSelected(int portno) } int channel = midic ? midic->channelNo() : 0; - MidiOutPort* midip = song->midiOutPort(portno); + MidiOutPort* midip = song->midiOutPorts()->at(portno); midic = midip->channel(channel); Route dstRoute(midic); @@ -431,7 +431,7 @@ void MidiTrackInfo::iKomprChanged(int val) // deviceIdChanged //--------------------------------------------------------- -void MidiTrackInfo::deviceIdChanged(int val) +void MidiTrackInfo::deviceIdChanged(int /*val*/) { MidiChannel* midic = ((MidiTrack*)track)->channel(); if (midic == 0) diff --git a/muse/muse/audio.cpp b/muse/muse/audio.cpp index 19eac9e9..8674d287 100644 --- a/muse/muse/audio.cpp +++ b/muse/muse/audio.cpp @@ -577,7 +577,6 @@ void Audio::processMsg() case SEQM_IDLE: idle = msg->a; - midiBusy = idle; break; case MS_SET_RTC: @@ -585,47 +584,31 @@ void Audio::processMsg() break; case SEQM_ADD_TRACK: - midiBusy = true; song->insertTrack2(msg->track); midiSeq->updatePollFd(); - midiBusy = false; break; case SEQM_REMOVE_TRACK: - midiBusy = true; song->removeTrack2(msg->track); midiSeq->updatePollFd(); - midiBusy = false; break; case SEQM_ADD_PART: - midiBusy = true; song->cmdAddPart((Part*)msg->p1); - midiBusy = false; break; case SEQM_REMOVE_PART: - midiBusy = true; song->cmdRemovePart((Part*)msg->p1); - midiBusy = false; break; case SEQM_CHANGE_PART: - midiBusy = true; song->cmdChangePart((Part*)msg->p1, (Part*)msg->p2); - midiBusy = false; break; case SEQM_MOVE_TRACK: - midiBusy = true; song->moveTrack((Track*)(msg->p1), (Track*)(msg->p2)); - midiBusy = false; break; case AUDIO_ADDMIDIPLUGIN: - midiBusy = true; ((MidiTrackBase*)msg->track)->addPlugin(msg->mplugin, msg->ival); - midiBusy = false; break; default: - midiBusy = true; song->processMsg(msg); - midiBusy = false; break; } } diff --git a/muse/muse/audiogroup.h b/muse/muse/audiogroup.h index 709166f5..d9837c74 100644 --- a/muse/muse/audiogroup.h +++ b/muse/muse/audiogroup.h @@ -38,9 +38,9 @@ class AudioGroup : public AudioTrack { virtual bool hasAuxSend() const { return true; } }; -typedef tracklist<AudioGroup*>::iterator iAudioGroup; -typedef tracklist<AudioGroup*>::const_iterator ciAudioGroup; -typedef tracklist<AudioGroup*> GroupList; +typedef QList<AudioGroup*> GroupList; +typedef GroupList::iterator iAudioGroup; +typedef GroupList::const_iterator ciAudioGroup; #endif diff --git a/muse/muse/audioinput.cpp b/muse/muse/audioinput.cpp index 4ff3449b..f9630cad 100644 --- a/muse/muse/audioinput.cpp +++ b/muse/muse/audioinput.cpp @@ -31,7 +31,7 @@ AudioInput::AudioInput() : AudioTrack() { // set Default for Input Ports: - _mute = true; + _mute = muteDefault(); _channels = 0; setChannels(2); // diff --git a/muse/muse/audioinput.h b/muse/muse/audioinput.h index ba8af1f6..9982daf1 100644 --- a/muse/muse/audioinput.h +++ b/muse/muse/audioinput.h @@ -41,12 +41,13 @@ class AudioInput : public AudioTrack { virtual void write(Xml&) const; virtual void setName(const QString& s); virtual void setChannels(int n); - virtual bool hasAuxSend() const { return true; } + virtual bool hasAuxSend() const { return true; } + virtual bool muteDefault() const { return true; } }; -typedef tracklist<AudioInput*>::iterator iAudioInput; -typedef tracklist<AudioInput*>::const_iterator ciAudioInput; -typedef tracklist<AudioInput*> InputList; +typedef QList<AudioInput*> InputList; +typedef InputList::iterator iAudioInput; +typedef InputList::const_iterator ciAudioInput; #endif diff --git a/muse/muse/audiooutput.h b/muse/muse/audiooutput.h index 384b5bde..8e0c5161 100644 --- a/muse/muse/audiooutput.h +++ b/muse/muse/audiooutput.h @@ -47,9 +47,9 @@ class AudioOutput : public AudioTrack { virtual void process(); }; -typedef tracklist<AudioOutput*>::iterator iAudioOutput; -typedef tracklist<AudioOutput*>::const_iterator ciAudioOutput; -typedef tracklist<AudioOutput*> OutputList; +typedef QList<AudioOutput*> OutputList; +typedef OutputList::iterator iAudioOutput; +typedef OutputList::const_iterator ciAudioOutput; #endif diff --git a/muse/muse/driver/port.h b/muse/muse/driver/port.h index 8b1dab47..d2f83de9 100644 --- a/muse/muse/driver/port.h +++ b/muse/muse/driver/port.h @@ -59,6 +59,14 @@ class Port { else return true; } + bool operator<(const Port& p) const { + if (type == ALSA_TYPE) { + if (_alsaPort != p._alsaPort) + return _alsaPort < p._alsaPort; + return _alsaClient < p._alsaClient; + } + return false; + } unsigned char alsaPort() const { return _alsaPort; } unsigned char alsaClient() const { return _alsaClient; } jack_port_t* jackPort() const { return _jackPort; } diff --git a/muse/muse/dssihost.cpp b/muse/muse/dssihost.cpp index 1c379ccb..85a7dba3 100644 --- a/muse/muse/dssihost.cpp +++ b/muse/muse/dssihost.cpp @@ -396,20 +396,20 @@ void DssiSynthIF::write(Xml&) const // getData //--------------------------------------------------------- -void DssiSynthIF::getData(MPEventList* el, unsigned pos, int ch, unsigned samples, float** data) +void DssiSynthIF::getData(MidiEventList* el, unsigned pos, int ch, unsigned samples, float** data) { const DSSI_Descriptor* dssi = synth->dssi; const LADSPA_Descriptor* descr = dssi->LADSPA_Plugin; unsigned long nevents = 0; - for (iMPEvent ii = i; ii != el->end(); ++ii, ++nevents) + for (iMidiEvent ii = i; ii != el->end(); ++ii, ++nevents) ; snd_seq_event_t events[nevents]; memset(events, 0, sizeof(events)); nevents = 0; int endPos = pos + samples; - iMPEvent i = el->begin(); + iMidiEvent i = el->begin(); for (; i != el->end(); ++i, ++nevents) { if (i->time() >= endPos) break; diff --git a/muse/muse/dssihost.h b/muse/muse/dssihost.h index 736621c3..47a15cd8 100644 --- a/muse/muse/dssihost.h +++ b/muse/muse/dssihost.h @@ -102,7 +102,7 @@ class DssiSynthIF : public SynthIF virtual bool hasGui() const { return synth->_hasGui; } virtual void getGeometry(int*, int*, int*, int*) const {} virtual void setGeometry(int, int, int, int) {} - virtual void getData(MPEventList*, unsigned pos, int ports, unsigned n, float** buffer) ; + virtual void getData(MidiEventList*, unsigned pos, int ports, unsigned n, float** buffer) ; virtual bool putEvent(const MidiEvent& ev); virtual MidiEvent receiveEvent(); virtual int eventsPending() const { return 0; } diff --git a/muse/muse/exportmidi.cpp b/muse/muse/exportmidi.cpp index fb17e485..b6bd2a62 100644 --- a/muse/muse/exportmidi.cpp +++ b/muse/muse/exportmidi.cpp @@ -40,37 +40,37 @@ // addController //--------------------------------------------------------- -static void addController(MPEventList* l, int tick, int /*port*/, int channel, int a, int b) +static void addController(MidiEventList* l, int tick, int /*port*/, int channel, int a, int b) { if (a < 0x1000) { // 7 Bit Controller - l->add(MidiEvent(tick, channel, ME_CONTROLLER, a, b)); + l->insert(MidiEvent(tick, channel, ME_CONTROLLER, a, b)); } else if (a < 0x20000) { // 14 Bit Controller int ctrlH = (a >> 8) & 0x7f; int ctrlL = a & 0x7f; int dataH = (b >> 7) & 0x7f; int dataL = b & 0x7f; - l->add(MidiEvent(tick, channel, ME_CONTROLLER, ctrlH, dataH)); - l->add(MidiEvent(tick+1, channel, ME_CONTROLLER, ctrlL, dataL)); + l->insert(MidiEvent(tick, channel, ME_CONTROLLER, ctrlH, dataH)); + l->insert(MidiEvent(tick+1, channel, ME_CONTROLLER, ctrlL, dataL)); } else if (a < 0x30000) { // RPN 7-Bit Controller int ctrlH = (a >> 8) & 0x7f; int ctrlL = a & 0x7f; - l->add(MidiEvent(tick, channel, ME_CONTROLLER, CTRL_HRPN, ctrlH)); - l->add(MidiEvent(tick+1, channel, ME_CONTROLLER, CTRL_LRPN, ctrlL)); - l->add(MidiEvent(tick+2, channel, ME_CONTROLLER, CTRL_HDATA, b)); + l->insert(MidiEvent(tick, channel, ME_CONTROLLER, CTRL_HRPN, ctrlH)); + l->insert(MidiEvent(tick+1, channel, ME_CONTROLLER, CTRL_LRPN, ctrlL)); + l->insert(MidiEvent(tick+2, channel, ME_CONTROLLER, CTRL_HDATA, b)); } else if (a < 0x40000) { // NRPN 7-Bit Controller int ctrlH = (a >> 8) & 0x7f; int ctrlL = a & 0x7f; - l->add(MidiEvent(tick, channel, ME_CONTROLLER, CTRL_HNRPN, ctrlH)); - l->add(MidiEvent(tick+1, channel, ME_CONTROLLER, CTRL_LNRPN, ctrlL)); - l->add(MidiEvent(tick+2, channel, ME_CONTROLLER, CTRL_HDATA, b)); + l->insert(MidiEvent(tick, channel, ME_CONTROLLER, CTRL_HNRPN, ctrlH)); + l->insert(MidiEvent(tick+1, channel, ME_CONTROLLER, CTRL_LNRPN, ctrlL)); + l->insert(MidiEvent(tick+2, channel, ME_CONTROLLER, CTRL_HDATA, b)); } else if (a == CTRL_PITCH) { int a = b + 8192; int b = a >> 7; - l->add(MidiEvent(tick, channel, ME_PITCHBEND, a & 0x7f, b & 0x7f)); + l->insert(MidiEvent(tick, channel, ME_PITCHBEND, a & 0x7f, b & 0x7f)); } else if (a == CTRL_PROGRAM) { int hb = (b >> 16) & 0xff; @@ -78,34 +78,34 @@ static void addController(MPEventList* l, int tick, int /*port*/, int channel, i int pr = b & 0x7f; int tickoffset = 0; if (hb != 0xff) { - l->add(MidiEvent(tick, channel, ME_CONTROLLER, CTRL_HBANK, hb)); + l->insert(MidiEvent(tick, channel, ME_CONTROLLER, CTRL_HBANK, hb)); ++tickoffset; } if (lb != 0xff) { - l->add(MidiEvent(tick+tickoffset, channel, ME_CONTROLLER, CTRL_LBANK, lb)); + l->insert(MidiEvent(tick+tickoffset, channel, ME_CONTROLLER, CTRL_LBANK, lb)); ++tickoffset; } - l->add(MidiEvent(tick+tickoffset, channel, ME_PROGRAM, pr, 0)); + l->insert(MidiEvent(tick+tickoffset, channel, ME_PROGRAM, pr, 0)); } else if (a < 0x60000) { // RPN14 Controller int ctrlH = (a >> 8) & 0x7f; int ctrlL = a & 0x7f; int dataH = (b >> 7) & 0x7f; int dataL = b & 0x7f; - l->add(MidiEvent(tick, channel, ME_CONTROLLER, CTRL_HRPN, ctrlH)); - l->add(MidiEvent(tick+1, channel, ME_CONTROLLER, CTRL_LRPN, ctrlL)); - l->add(MidiEvent(tick+2, channel, ME_CONTROLLER, CTRL_HDATA, dataH)); - l->add(MidiEvent(tick+3, channel, ME_CONTROLLER, CTRL_LDATA, dataL)); + l->insert(MidiEvent(tick, channel, ME_CONTROLLER, CTRL_HRPN, ctrlH)); + l->insert(MidiEvent(tick+1, channel, ME_CONTROLLER, CTRL_LRPN, ctrlL)); + l->insert(MidiEvent(tick+2, channel, ME_CONTROLLER, CTRL_HDATA, dataH)); + l->insert(MidiEvent(tick+3, channel, ME_CONTROLLER, CTRL_LDATA, dataL)); } else if (a < 0x70000) { // NRPN14 Controller int ctrlH = (a >> 8) & 0x7f; int ctrlL = a & 0x7f; int dataH = (b >> 7) & 0x7f; int dataL = b & 0x7f; - l->add(MidiEvent(tick, channel, ME_CONTROLLER, CTRL_HNRPN, ctrlH)); - l->add(MidiEvent(tick+1, channel, ME_CONTROLLER, CTRL_LNRPN, ctrlL)); - l->add(MidiEvent(tick+2, channel, ME_CONTROLLER, CTRL_HDATA, dataH)); - l->add(MidiEvent(tick+3, channel, ME_CONTROLLER, CTRL_LDATA, dataL)); + l->insert(MidiEvent(tick, channel, ME_CONTROLLER, CTRL_HNRPN, ctrlH)); + l->insert(MidiEvent(tick+1, channel, ME_CONTROLLER, CTRL_LNRPN, ctrlL)); + l->insert(MidiEvent(tick+2, channel, ME_CONTROLLER, CTRL_HDATA, dataH)); + l->insert(MidiEvent(tick+3, channel, ME_CONTROLLER, CTRL_LDATA, dataL)); } } @@ -146,7 +146,7 @@ void MusE::exportMidi() MidiFileTrack* mft = new MidiFileTrack; mtl->push_back(mft); - MPEventList* l = &(mft->events); + MidiEventList* l = &(mft->events); int port = 0; // track->channel()->port(); int channel = 0; if (track->channel()) @@ -176,7 +176,7 @@ void MusE::exportMidi() int len = strlen(name); MidiEvent ev(0, ME_META, (unsigned char*)name, len+1); ev.setA(0x3); // Meta Sequence/Track Name - l->add(ev); + l->insert(ev); } //----------------------------------- @@ -188,7 +188,7 @@ void MusE::exportMidi() int len = strlen(comment); MidiEvent ev(0, ME_META, (unsigned char*)comment, len+1); ev.setA(0xf); // Meta Text - l->add(ev); + l->insert(ev); } PartList* parts = track->parts(); for (iPart p = parts->begin(); p != parts->end(); ++p) { @@ -233,8 +233,8 @@ void MusE::exportMidi() } if (len <= 0) len = 1; - l->add(MidiEvent(tick, channel, ME_NOTEON, pitch, velo)); - l->add(MidiEvent(tick+len, channel, ME_NOTEON, pitch, 0)); + l->insert(MidiEvent(tick, channel, ME_NOTEON, pitch, velo)); + l->insert(MidiEvent(tick+len, channel, ME_NOTEON, pitch, 0)); } break; @@ -243,22 +243,22 @@ void MusE::exportMidi() break; case Sysex: - l->add(MidiEvent(tick, ME_SYSEX, ev.eventData())); + l->insert(MidiEvent(tick, ME_SYSEX, ev.eventData())); break; case PAfter: - l->add(MidiEvent(tick, channel, ME_AFTERTOUCH, ev.dataA(), ev.dataB())); + l->insert(MidiEvent(tick, channel, ME_AFTERTOUCH, ev.dataA(), ev.dataB())); break; case CAfter: - l->add(MidiEvent(tick, channel, ME_POLYAFTER, ev.dataA(), ev.dataB())); + l->insert(MidiEvent(tick, channel, ME_POLYAFTER, ev.dataA(), ev.dataB())); break; case Meta: { MidiEvent mpev(tick, ME_META, ev.eventData()); mpev.setA(ev.dataA()); - l->add(mpev); + l->insert(mpev); } break; case Wave: @@ -269,7 +269,7 @@ void MusE::exportMidi() } MidiFileTrack* mft = mtl->front(); - MPEventList* l = &(mft->events); + MidiEventList* l = &(mft->events); //--------------------------------------------------- // Write Track Marker @@ -280,7 +280,7 @@ void MusE::exportMidi() int len = strlen(name); MidiEvent ev(m->first, ME_META, (unsigned char*)name, len); ev.setA(0x6); - l->add(ev); + l->insert(ev); } //--------------------------------------------------- @@ -291,7 +291,7 @@ void MusE::exportMidi() int len = strlen(copyright); MidiEvent ev(0, ME_META, (unsigned char*)copyright, len); ev.setA(0x2); - l->add(ev); + l->insert(ev); } //--------------------------------------------------- @@ -307,7 +307,7 @@ void MusE::exportMidi() data[0] = (tempo >> 16) & 0xff; MidiEvent ev(event->tick, ME_META, data, 3); ev.setA(0x51); - l->add(ev); + l->insert(ev); } //--------------------------------------------------- @@ -332,7 +332,7 @@ void MusE::exportMidi() } MidiEvent ev(event->tick, ME_META, data, 2); ev.setA(0x58); - l->add(ev); + l->insert(ev); } mf.setDivision(config.midiDivision); diff --git a/muse/muse/gui.h b/muse/muse/gui.h index 155a8a58..05217e23 100644 --- a/muse/muse/gui.h +++ b/muse/muse/gui.h @@ -40,7 +40,7 @@ static const int trackSeparator = 1; static const int yTrackOffset = -4; // mixer: -static const int STRIP_WIDTH = 66; +static const int STRIP_WIDTH = 66+4; static const int LABEL_HEIGHT = 20; static const int ICON_WIDTH = 18; diff --git a/muse/muse/importmidi.cpp b/muse/muse/importmidi.cpp index 896cf5f3..38a27f25 100644 --- a/muse/muse/importmidi.cpp +++ b/muse/muse/importmidi.cpp @@ -403,7 +403,7 @@ void MusE::addMidiFile(const QString name) // - calculate tick value for internal resolution // for (iMidiFileTrack t = etl->begin(); t != etl->end(); ++t) { - MPEventList* el = &((*t)->events); + MidiEventList* el = &((*t)->events); if (el->empty()) continue; // @@ -415,7 +415,7 @@ void MusE::addMidiFile(const QString name) // // check if there are any events for channel in track: // - iMPEvent i; + iMidiEvent i; for (i = el->begin(); i != el->end(); ++i) { MidiEvent ev = *i; if (ev.type() != ME_SYSEX diff --git a/muse/muse/midi.cpp b/muse/muse/midi.cpp index fe9984d6..d1d391fc 100644 --- a/muse/muse/midi.cpp +++ b/muse/muse/midi.cpp @@ -197,7 +197,7 @@ QString nameSysex(unsigned int len, const unsigned char* buf) // generally: how to handle incomplete messages? //--------------------------------------------------------- -void buildMidiEventList(EventList* del, const MPEventList* el, MidiTrack* track, +void buildMidiEventList(EventList* del, const MidiEventList* el, MidiTrack* track, int div, bool addSysexMeta) { QString tname; @@ -216,7 +216,7 @@ void buildMidiEventList(EventList* del, const MPEventList* el, MidiTrack* track, EventList mel; int metaChannel = -1; - for (iMPEvent i = el->begin(); i != el->end(); ++i) { + for (iMidiEvent i = el->begin(); i != el->end(); ++i) { MidiEvent ev = *i; if (ev.type() == ME_META) { if (ev.dataA() == 0x20) { @@ -282,7 +282,7 @@ void buildMidiEventList(EventList* del, const MPEventList* el, MidiTrack* track, // check if a CTRL_LDATA follows // e.g. wie have a 14 bit controller: { - iMPEvent ii = i; + iMidiEvent ii = i; ++ii; bool found = false; for (; ii != el->end(); ++ii) { diff --git a/muse/muse/midi.h b/muse/muse/midi.h index 56a6ccfd..13d5ddcb 100644 --- a/muse/muse/midi.h +++ b/muse/muse/midi.h @@ -52,9 +52,10 @@ QString nameSysex(unsigned int len, const unsigned char* buf); QString midiMetaName(int); class EventList; -class MPEventList; class MidiTrack; -extern void buildMidiEventList(EventList* mel, const MPEventList* el, MidiTrack* track, int division, bool); +class MidiEventList; + +extern void buildMidiEventList(EventList* mel, const MidiEventList* el, MidiTrack* track, int division, bool); #endif diff --git a/muse/muse/midichannel.h b/muse/muse/midichannel.h index 8644c15e..1ec0872f 100644 --- a/muse/muse/midichannel.h +++ b/muse/muse/midichannel.h @@ -70,5 +70,9 @@ class MidiChannel : public MidiTrackBase { virtual void emitControllerChanged(int id); }; +typedef QList<MidiChannel*> MidiChannelList; +typedef MidiChannelList::iterator iMidiChannel; +typedef MidiChannelList::const_iterator ciMidiChannel; + #endif diff --git a/muse/muse/midiedit/midieditor.cpp b/muse/muse/midiedit/midieditor.cpp index 680fb25a..f212e2d6 100644 --- a/muse/muse/midiedit/midieditor.cpp +++ b/muse/muse/midiedit/midieditor.cpp @@ -42,7 +42,7 @@ MidiEditor::MidiEditor(PartList* pl) QMenuBar* mb = menuBar(); - //---------Menü---------------------------------- + //---------Menü------------------------------- menuEdit = new QMenu(tr("&Edit")); mb->addMenu(menuEdit); @@ -160,7 +160,7 @@ void MidiEditor::genPartlist() PartList* npl = new PartList; for (iPart ip = _pl->begin(); ip != _pl->end(); ++ip) { Part* part = ip->second; - for (iTrack it = tl->begin(); it != tl->end(); ++it) { + for (iMidiTrack it = tl->begin(); it != tl->end(); ++it) { PartList* pl2 = (*it)->parts(); iPart ip2 = pl2->begin(); for (; ip2 != pl2->end(); ++ip2) @@ -204,7 +204,7 @@ void MidiEditor::writePartList(Xml& xml) const for (ciPart p = _pl->begin(); p != _pl->end(); ++p) { Part* part = p->second; Track* track = part->track(); - int trkIdx = song->tracks()->index(track); + int trkIdx = song->tracks()->indexOf(track); int partIdx = track->parts()->index(part); xml.tag("part"); xml.put("%d:%d", trkIdx, partIdx); diff --git a/muse/muse/midievent.h b/muse/muse/midievent.h index 827ebf5a..d3dd4800 100644 --- a/muse/muse/midievent.h +++ b/muse/muse/midievent.h @@ -23,12 +23,11 @@ #include <set> #include "evdata.h" -#include <ext/mt_allocator.h> +// #include <ext/mt_allocator.h> #include "midi.h" class Event; -class EvData; //--------------------------------------------------------- // MidiEvent @@ -84,20 +83,19 @@ class MidiEvent { }; //--------------------------------------------------------- -// MPEventList +// MidiEventList //--------------------------------------------------------- // typedef std::multiset<MidiEvent, std::less<MidiEvent>, // __gnu_cxx::__mt_alloc<MidiEvent> > MPEL; -typedef std::multiset<MidiEvent, std::less<MidiEvent> > MPEL; - -struct MPEventList : public MPEL { - void add(const MidiEvent& ev) { MPEL::insert(ev); } +class MidiEventList : public std::multiset<MidiEvent, std::less<MidiEvent> > + { + public: }; -typedef MPEventList::iterator iMPEvent; -typedef MPEventList::const_iterator ciMPEvent; +typedef MidiEventList::iterator iMidiEvent; +typedef MidiEventList::const_iterator ciMidiEvent; #endif diff --git a/muse/muse/midififo.cpp b/muse/muse/midififo.cpp index 6264fdca..4bb43346 100644 --- a/muse/muse/midififo.cpp +++ b/muse/muse/midififo.cpp @@ -21,12 +21,31 @@ #include "midififo.h" //--------------------------------------------------------- -// MidiFifo +// put +// return true on fifo overflow //--------------------------------------------------------- -MidiFifo::MidiFifo() +bool MidiFifo::put(const MidiEvent& event) { - clear(); + if (size < MIDI_FIFO_SIZE) { + fifo[wIndex] = event; + wIndex = (wIndex + 1) % MIDI_FIFO_SIZE; + q_atomic_increment(&size); + return false; + } + return true; + } + +//--------------------------------------------------------- +// get +//--------------------------------------------------------- + +MidiEvent MidiFifo::get() + { + MidiEvent event(fifo[rIndex]); + rIndex = (rIndex + 1) % MIDI_FIFO_SIZE; + q_atomic_decrement(&size); + return event; } //--------------------------------------------------------- @@ -34,7 +53,7 @@ MidiFifo::MidiFifo() // return true on fifo overflow //--------------------------------------------------------- -bool MidiFifo::put(const MidiEvent& event) +bool MidiOutFifo::put(const MidiOutEvent& event) { if (size < MIDI_FIFO_SIZE) { fifo[wIndex] = event; @@ -49,9 +68,9 @@ bool MidiFifo::put(const MidiEvent& event) // get //--------------------------------------------------------- -MidiEvent MidiFifo::get() +MidiOutEvent MidiOutFifo::get() { - MidiEvent event(fifo[rIndex]); + MidiOutEvent event(fifo[rIndex]); rIndex = (rIndex + 1) % MIDI_FIFO_SIZE; q_atomic_decrement(&size); return event; diff --git a/muse/muse/midififo.h b/muse/muse/midififo.h index bd12ad39..e5964e99 100644 --- a/muse/muse/midififo.h +++ b/muse/muse/midififo.h @@ -22,6 +22,7 @@ #define __MIDIFIFO_H__ #include "midievent.h" +#include "driver/port.h" #define MIDI_FIFO_SIZE 512 @@ -36,12 +37,53 @@ class MidiFifo { int rIndex; public: - MidiFifo(); + MidiFifo() { clear(); } bool put(const MidiEvent& event); // returns true on fifo overflow MidiEvent get(); bool isEmpty() const { return size == 0; } void clear() { size = 0, wIndex = 0, rIndex = 0; } }; +//--------------------------------------------------------- +// MidiOutEvent +//--------------------------------------------------------- + +struct MidiOutEvent { + Port port; + MidiEvent event; + + MidiOutEvent() {} + MidiOutEvent(const Port& p, const MidiEvent& e) + : port(p), event(e) {} + bool operator<(const MidiOutEvent& e) const { + if (port == e.port) + return event < e.event; + return event < e.event; + } + }; + +typedef std::multiset<MidiOutEvent, std::less<MidiOutEvent> > MidiOutEventList; +typedef MidiOutEventList::iterator iMidiOutEvent; +typedef MidiOutEventList::const_iterator ciMidiOutEvent; + +//--------------------------------------------------------- +// MidiOutFifo +//--------------------------------------------------------- + +class MidiOutFifo { + MidiOutEvent fifo[MIDI_FIFO_SIZE]; + volatile int size; + int wIndex; + int rIndex; + + public: + MidiOutFifo() { clear(); } + bool put(const MidiOutEvent& event); // returns true on fifo overflow + MidiOutEvent get(); + bool isEmpty() const { return size == 0; } + void clear() { size = 0, wIndex = 0, rIndex = 0; } + }; + + #endif diff --git a/muse/muse/midifile.cpp b/muse/muse/midifile.cpp index bfe444c0..c45c57d2 100644 --- a/muse/muse/midifile.cpp +++ b/muse/muse/midifile.cpp @@ -218,7 +218,7 @@ void MidiFile::putvl(unsigned val) bool MidiFile::readTrack(MidiFileTrack* t) { - MPEventList* el = &(t->events); + MidiEventList* el = &(t->events); char tmp[4]; if (read(tmp, 4)) return true; @@ -262,7 +262,7 @@ bool MidiFile::readTrack(MidiFileTrack* t) event.setChannel(channel); else channel = event.channel(); - el->add(event); + el->insert(event); } int end = curPos; if (end != endPos) { @@ -501,14 +501,14 @@ int MidiFile::readEvent(MidiEvent* event, MidiFileTrack* t) bool MidiFile::writeTrack(const MidiFileTrack* t) { - const MPEventList* events = &(t->events); + const MidiEventList* events = &(t->events); write("MTrk", 4); int lenpos = fp->pos(); writeLong(0); // dummy len status = -1; int tick = 0; - for (iMPEvent i = events->begin(); i != events->end(); ++i) { + for (iMidiEvent i = events->begin(); i != events->end(); ++i) { int ntick = i->time(); if (ntick < tick) { printf("MidiFile::writeTrack: ntick %d < tick %d\n", ntick, tick); @@ -602,9 +602,9 @@ bool MidiFile::write(QFile* _fp) // ?? writeShort(1); MidiFileTrack dst; for (iMidiFileTrack i = _tracks->begin(); i != _tracks->end(); ++i) { - MPEventList* sl = &((*i)->events); - for (iMPEvent ie = sl->begin(); ie != sl->end(); ++ie) - dst.events.add(*ie); + MidiEventList* sl = &((*i)->events); + for (iMidiEvent ie = sl->begin(); ie != sl->end(); ++ie) + dst.events.insert(*ie); } writeShort(1); writeShort(_division); diff --git a/muse/muse/midifile.h b/muse/muse/midifile.h index c17fb9f7..dd51a7d3 100644 --- a/muse/muse/midifile.h +++ b/muse/muse/midifile.h @@ -24,7 +24,7 @@ #include "globaldefs.h" #include "midievent.h" -struct MPEventList; +struct MidiEventList; class MidiEvent; //--------------------------------------------------------- @@ -32,7 +32,7 @@ class MidiEvent; //--------------------------------------------------------- struct MidiFileTrack { - MPEventList events; + MidiEventList events; bool isDrumTrack; MidiFileTrack() { isDrumTrack = false; diff --git a/muse/muse/midiinport.cpp b/muse/muse/midiinport.cpp index ac55a813..a84e4741 100644 --- a/muse/muse/midiinport.cpp +++ b/muse/muse/midiinport.cpp @@ -166,7 +166,7 @@ void MidiInPort::eventReceived(snd_seq_event_t* ev) // _recordEvents // - MPEventList il, ol; + MidiEventList il, ol; il.insert(event); pipeline()->apply(audio->curTickPos(), audio->nextTickPos(), &il, &ol); @@ -174,7 +174,7 @@ void MidiInPort::eventReceived(snd_seq_event_t* ev) // update midi meter // notify gui of new events // - for (iMPEvent i = ol.begin(); i != ol.end(); ++i) { + for (iMidiEvent i = ol.begin(); i != ol.end(); ++i) { if (i->type() == ME_NOTEON) addMidiMeter(i->dataB()); song->putEvent(*i); @@ -186,7 +186,7 @@ void MidiInPort::eventReceived(snd_seq_event_t* ev) ++recordWrite; if (recordWrite == RECORD_FIFO_SIZE) recordWrite = 0; - ++recordCount; + q_atomic_increment(&recordCount); } } #endif @@ -202,7 +202,7 @@ void MidiInPort::afterProcess() ++recordRead; if (recordRead >= RECORD_FIFO_SIZE) recordRead = 0; - --recordCount; + q_atomic_decrement(&recordCount); } } @@ -220,7 +220,7 @@ void MidiInPort::beforeProcess() // called from jack process context //--------------------------------------------------------- -void MidiInPort::getEvents(unsigned, unsigned, int ch, MPEventList* dst) +void MidiInPort::getEvents(unsigned, unsigned, int ch, MidiEventList* dst) { int tmpRecordRead = recordRead; for (int i = 0; i < tmpRecordCount; ++i) { diff --git a/muse/muse/midiinport.h b/muse/muse/midiinport.h index 760ed7fe..a5d72804 100644 --- a/muse/muse/midiinport.h +++ b/muse/muse/midiinport.h @@ -22,6 +22,7 @@ #define __MIDIINPORT_H__ #include "track.h" +#include "midievent.h" static const int RECORD_FIFO_SIZE = 512; @@ -51,10 +52,14 @@ class MidiInPort : public MidiTrackBase { #ifndef __APPLE__ void eventReceived(snd_seq_event_t*); #endif - virtual void getEvents(unsigned from, unsigned to, int channel, MPEventList* dst); + virtual void getEvents(unsigned from, unsigned to, int channel, MidiEventList* dst); void beforeProcess(); void afterProcess(); }; +typedef QList<MidiInPort*> MidiInPortList; +typedef MidiInPortList::iterator iMidiInPort; +typedef MidiInPortList::const_iterator ciMidiInPort; + #endif diff --git a/muse/muse/midiout.cpp b/muse/muse/midiout.cpp index fc04b586..c07b2822 100644 --- a/muse/muse/midiout.cpp +++ b/muse/muse/midiout.cpp @@ -186,7 +186,7 @@ void MidiOut::seek(unsigned tickPos, unsigned framePos) // stop all notes //--------------------------------------------------- - for (iMPEvent i = _schedEvents.begin(); i != _schedEvents.end(); ++i) { + for (iMidiEvent i = _schedEvents.begin(); i != _schedEvents.end(); ++i) { MidiEvent ev = *i; if (ev.isNoteOff()) { ev.setTime(framePos); @@ -226,7 +226,7 @@ void MidiOut::stop() // stop all notes //--------------------------------------------------- - for (iMPEvent i = _schedEvents.begin(); i != _schedEvents.end(); ++i) { + for (iMidiEvent i = _schedEvents.begin(); i != _schedEvents.end(); ++i) { MidiEvent ev = *i; if (ev.isNoteOff()) { ev.setTime(frame); @@ -322,10 +322,10 @@ void MidiOut::reset() // _playEvents queue which is processed by the MidiSeq thread. //------------------------------------------------------------------- -void MidiOut::processMidi(MPEventList& el, unsigned fromTick, unsigned toTick, unsigned /*fromFrame*/, unsigned /*toFrame*/) +void MidiOut::processMidi(MidiEventList& el, unsigned fromTick, unsigned toTick, unsigned /*fromFrame*/, unsigned /*toFrame*/) { while (!eventFifo.isEmpty()) - el.add(eventFifo.get()); + el.insert(eventFifo.get()); // collect port controller if (fromTick != toTick) { // if rolling @@ -339,7 +339,7 @@ void MidiOut::processMidi(MPEventList& el, unsigned fromTick, unsigned toTick, u Event ev(Controller); ev.setA(c->id()); ev.setB(ic.value().i); - el.add(MidiEvent(frame, -1, ev)); + el.insert(MidiEvent(frame, -1, ev)); } } } @@ -360,7 +360,7 @@ void MidiOut::processMidi(MPEventList& el, unsigned fromTick, unsigned toTick, u Event ev(Controller); ev.setA(c->id()); ev.setB(is.value().i); - el.add(MidiEvent(frame, ch, ev)); + el.insert(MidiEvent(frame, ch, ev)); } } } @@ -371,10 +371,10 @@ void MidiOut::processMidi(MPEventList& el, unsigned fromTick, unsigned toTick, u MidiTrackBase* track = (MidiTrackBase*)i->track; if (track->isMute()) continue; - MPEventList ell; + MidiEventList ell; track->getEvents(fromTick, toTick, 0, &ell); int velo = 0; - for (iMPEvent i = ell.begin(); i != ell.end(); ++i) { + for (iMidiEvent i = ell.begin(); i != ell.end(); ++i) { MidiEvent ev(*i); ev.setChannel(ch); el.insert(ev); diff --git a/muse/muse/midiout.h b/muse/muse/midiout.h index 8fffb8fe..a76f3fe6 100644 --- a/muse/muse/midiout.h +++ b/muse/muse/midiout.h @@ -40,14 +40,14 @@ class MidiOut Track* track; MidiInstrument* _instrument; MidiChannel* _channel[MIDI_CHANNELS]; - MPEventList _schedEvents; // scheduled events by process() + MidiEventList _schedEvents; // scheduled events by process() // fifo for midi events send from gui // direct to midi port: MidiFifo eventFifo; - void processMidi(MPEventList& el, unsigned fromTick, unsigned toTick, + void processMidi(MidiEventList& el, unsigned fromTick, unsigned toTick, unsigned fromFrame, unsigned toFrame); MidiChannel* channel(int n) { return _channel[n]; } MidiInstrument* instrument() { return _instrument; } diff --git a/muse/muse/midioutport.cpp b/muse/muse/midioutport.cpp index b024a4ec..ff386c87 100644 --- a/muse/muse/midioutport.cpp +++ b/muse/muse/midioutport.cpp @@ -156,12 +156,6 @@ void MidiOutPort::routeEvent(const MidiEvent& event) case Route::MIDIPORT: queueAlsaEvent(event); break; -#if 0 - case Route::SYNTIPORT: - case Route::TRACK: - ((SynthI*)(r->track))->playEvents()->insert(event); - break; -#endif case Route::JACKMIDIPORT: queueJackEvent(event); break; @@ -177,9 +171,10 @@ void MidiOutPort::routeEvent(const MidiEvent& event) // called from MidiSeq //--------------------------------------------------------- +#define AO(e) midiSeq->putEvent(alsaPort(0), e); + void MidiOutPort::queueAlsaEvent(const MidiEvent& ev) { - midiBusy = true; if (ev.type() == ME_CONTROLLER) { int a = ev.dataA(); int b = ev.dataB(); @@ -193,11 +188,11 @@ void MidiOutPort::queueAlsaEvent(const MidiEvent& ev) int lb = (b >> 8) & 0xff; int pr = b & 0x7f; if (hb != 0xff) - _playEvents.insert(MidiEvent(t, chn, ME_CONTROLLER, CTRL_HBANK, hb)); + AO(MidiEvent(t, chn, ME_CONTROLLER, CTRL_HBANK, hb)); if (lb != 0xff) - _playEvents.insert(MidiEvent(t+1, chn, ME_CONTROLLER, CTRL_LBANK, lb)); - _playEvents.insert(MidiEvent(t+2, chn, ME_PROGRAM, pr, 0)); -// } + AO(MidiEvent(t+1, chn, ME_CONTROLLER, CTRL_LBANK, lb)); + AO(MidiEvent(t+2, chn, ME_PROGRAM, pr, 0)); +// } } else if (a == CTRL_MASTER_VOLUME) { unsigned char sysex[] = { @@ -206,60 +201,62 @@ void MidiOutPort::queueAlsaEvent(const MidiEvent& ev) sysex[1] = deviceId(); sysex[4] = b & 0x7f; sysex[5] = (b >> 7) & 0x7f; - _playEvents.insert(MidiEvent(t, ME_SYSEX, sysex, 6)); + AO(MidiEvent(t, ME_SYSEX, sysex, 6)); + } + else if (a < CTRL_14_OFFSET) { // 7 Bit Controller + AO(ev); } - else if (a < CTRL_14_OFFSET) // 7 Bit Controller - _playEvents.insert(ev); else if (a < CTRL_RPN_OFFSET) { // 14 bit high resolution controller int ctrlH = (a >> 8) & 0x7f; int ctrlL = a & 0x7f; int dataH = (b >> 7) & 0x7f; int dataL = b & 0x7f; - _playEvents.insert(MidiEvent(t, chn, ME_CONTROLLER, ctrlH, dataH)); - _playEvents.insert(MidiEvent(t+1, chn, ME_CONTROLLER, ctrlL, dataL)); + AO(MidiEvent(t, chn, ME_CONTROLLER, ctrlH, dataH)); + AO(MidiEvent(t+1, chn, ME_CONTROLLER, ctrlL, dataL)); } else if (a < CTRL_NRPN_OFFSET) { // RPN 7-Bit Controller int ctrlH = (a >> 8) & 0x7f; int ctrlL = a & 0x7f; - _playEvents.insert(MidiEvent(t, chn, ME_CONTROLLER, CTRL_HRPN, ctrlH)); - _playEvents.insert(MidiEvent(t+1, chn, ME_CONTROLLER, CTRL_LRPN, ctrlL)); - _playEvents.insert(MidiEvent(t+2, chn, ME_CONTROLLER, CTRL_HDATA, b)); + AO(MidiEvent(t, chn, ME_CONTROLLER, CTRL_HRPN, ctrlH)); + AO(MidiEvent(t+1, chn, ME_CONTROLLER, CTRL_LRPN, ctrlL)); + AO(MidiEvent(t+2, chn, ME_CONTROLLER, CTRL_HDATA, b)); } else if (a < CTRL_RPN14_OFFSET) { // NRPN 7-Bit Controller int ctrlH = (a >> 8) & 0x7f; int ctrlL = a & 0x7f; - _playEvents.insert(MidiEvent(t, chn, ME_CONTROLLER, CTRL_HNRPN, ctrlH)); - _playEvents.insert(MidiEvent(t+1, chn, ME_CONTROLLER, CTRL_LNRPN, ctrlL)); - _playEvents.insert(MidiEvent(t+2, chn, ME_CONTROLLER, CTRL_HDATA, b)); + AO(MidiEvent(t, chn, ME_CONTROLLER, CTRL_HNRPN, ctrlH)); + AO(MidiEvent(t+1, chn, ME_CONTROLLER, CTRL_LNRPN, ctrlL)); + AO(MidiEvent(t+2, chn, ME_CONTROLLER, CTRL_HDATA, b)); } else if (a < CTRL_NRPN14_OFFSET) { // RPN14 Controller int ctrlH = (a >> 8) & 0x7f; int ctrlL = a & 0x7f; int dataH = (b >> 7) & 0x7f; int dataL = b & 0x7f; - _playEvents.insert(MidiEvent(t, chn, ME_CONTROLLER, CTRL_HRPN, ctrlH)); - _playEvents.insert(MidiEvent(t+1, chn, ME_CONTROLLER, CTRL_LRPN, ctrlL)); - _playEvents.insert(MidiEvent(t+2, chn, ME_CONTROLLER, CTRL_HDATA, dataH)); - _playEvents.insert(MidiEvent(t+3, chn, ME_CONTROLLER, CTRL_LDATA, dataL)); + AO(MidiEvent(t, chn, ME_CONTROLLER, CTRL_HRPN, ctrlH)); + AO(MidiEvent(t+1, chn, ME_CONTROLLER, CTRL_LRPN, ctrlL)); + AO(MidiEvent(t+2, chn, ME_CONTROLLER, CTRL_HDATA, dataH)); + AO(MidiEvent(t+3, chn, ME_CONTROLLER, CTRL_LDATA, dataL)); } else if (a < CTRL_NONE_OFFSET) { // NRPN14 Controller int ctrlH = (a >> 8) & 0x7f; int ctrlL = a & 0x7f; int dataH = (b >> 7) & 0x7f; int dataL = b & 0x7f; - _playEvents.insert(MidiEvent(t, chn, ME_CONTROLLER, CTRL_HNRPN, ctrlH)); - _playEvents.insert(MidiEvent(t+1, chn, ME_CONTROLLER, CTRL_LNRPN, ctrlL)); - _playEvents.insert(MidiEvent(t+2, chn, ME_CONTROLLER, CTRL_HDATA, dataH)); - _playEvents.insert(MidiEvent(t+3, chn, ME_CONTROLLER, CTRL_LDATA, dataL)); + AO(MidiEvent(t, chn, ME_CONTROLLER, CTRL_HNRPN, ctrlH)); + AO(MidiEvent(t+1, chn, ME_CONTROLLER, CTRL_LNRPN, ctrlL)); + AO(MidiEvent(t+2, chn, ME_CONTROLLER, CTRL_HDATA, dataH)); + AO(MidiEvent(t+3, chn, ME_CONTROLLER, CTRL_LDATA, dataL)); } else { printf("putEvent: unknown controller type 0x%x\n", a); } } - else - _playEvents.insert(ev); - midiBusy = false; + else { + AO(ev); + } } +#undef AO //--------------------------------------------------------- // queueJackEvent @@ -354,16 +351,6 @@ void MidiOutPort::queueJackEvent(const MidiEvent& ev) #undef JO //--------------------------------------------------------- -// playAlsaEvent -// called from MidiSeq -//--------------------------------------------------------- - -void MidiOutPort::playAlsaEvent(const MidiEvent& event) const - { - midiDriver->putEvent(alsaPort(), event); - } - -//--------------------------------------------------------- // setInstrument //--------------------------------------------------------- @@ -423,7 +410,7 @@ void MidiOutPort::processMidi(unsigned fromTick, unsigned toTick, unsigned fromF if (track->mute()) return; - MPEventList el; + MidiEventList el; MidiOut::processMidi(el, fromTick, toTick, fromFrame, toFrame); pipeline()->apply(fromTick, toTick, &el, &_schedEvents); @@ -433,7 +420,7 @@ void MidiOutPort::processMidi(unsigned fromTick, unsigned toTick, unsigned fromF // int portVelo = 0; - iMPEvent i = _schedEvents.begin(); + iMidiEvent i = _schedEvents.begin(); for (; i != _schedEvents.end(); ++i) { if (i->time() >= toFrame) break; diff --git a/muse/muse/midioutport.h b/muse/muse/midioutport.h index 0d28c923..246db9f3 100644 --- a/muse/muse/midioutport.h +++ b/muse/muse/midioutport.h @@ -31,8 +31,6 @@ class MidiOutPort : public MidiTrackBase, public MidiOut { Q_OBJECT - MPEventList _playEvents; // event queue for MidiSeq - void routeEvent(const MidiEvent&); void queueAlsaEvent(const MidiEvent& event); void queueJackEvent(const MidiEvent& event); @@ -45,8 +43,6 @@ class MidiOutPort : public MidiTrackBase, public MidiOut { ~MidiOutPort(); virtual TrackType type() const { return MIDI_OUT; } - MidiChannel* channel(int n) { return _channel[n]; } - virtual void setName(const QString& s); virtual void write(Xml&) const; virtual void read(QDomNode); @@ -59,11 +55,12 @@ class MidiOutPort : public MidiTrackBase, public MidiOut { bool guiVisible() const; bool hasGui() const; - MPEventList* playEvents() { return &_playEvents; } - - void playAlsaEvent(const MidiEvent& event) const; void processMidi(unsigned fromTick, unsigned toTick, unsigned fromFrame, unsigned toFrame); }; +typedef QList<MidiOutPort*> MidiOutPortList; +typedef MidiOutPortList::iterator iMidiOutPort; +typedef MidiOutPortList::const_iterator ciMidiOutPort; + #endif diff --git a/muse/muse/midiplugin.cpp b/muse/muse/midiplugin.cpp index 498369df..b679fef9 100644 --- a/muse/muse/midiplugin.cpp +++ b/muse/muse/midiplugin.cpp @@ -375,10 +375,10 @@ bool MidiPipeline::hasGui(int idx) const // apply //--------------------------------------------------------- -void MidiPipeline::apply(unsigned from, unsigned to, MPEventList* il, MPEventList* ool) +void MidiPipeline::apply(unsigned from, unsigned to, MidiEventList* il, MidiEventList* ool) { - MPEventList oList; - MPEventList* ol = &oList; + MidiEventList oList; + MidiEventList* ol = &oList; bool swap = true; for (iMidiPluginI i = begin(); i != end(); ++i) { @@ -395,16 +395,16 @@ void MidiPipeline::apply(unsigned from, unsigned to, MPEventList* il, MPEventLis } swap = !swap; } - MPEventList* l = swap ? il : ol; - for (iMPEvent i = l->begin(); i != l->end(); ++i) - ool->add(*i); + MidiEventList* l = swap ? il : ol; + for (iMidiEvent i = l->begin(); i != l->end(); ++i) + ool->insert(*i); } //--------------------------------------------------------- // apply //--------------------------------------------------------- -void MidiPluginI::apply(unsigned from, unsigned to, MPEventList* il, MPEventList* ol) +void MidiPluginI::apply(unsigned from, unsigned to, MidiEventList* il, MidiEventList* ol) { mempi->process(from, to, il, ol); } diff --git a/muse/muse/midiplugin.h b/muse/muse/midiplugin.h index dbe8e631..87e91953 100644 --- a/muse/muse/midiplugin.h +++ b/muse/muse/midiplugin.h @@ -34,7 +34,7 @@ class MidiPluginGui; class MidiPluginI; class MidiTrackBase; class Ctrl; -class MPEventList; +class MidiEventList; class MidiTrackBase; typedef const MEMPI* (*MEMPI_Function)(); @@ -102,7 +102,7 @@ class MidiPluginI { MidiPlugin* plugin() const { return _plugin; } bool on() const { return _on; } void setOn(bool val) { _on = val; } - void apply(unsigned, unsigned, MPEventList*, MPEventList*); + void apply(unsigned, unsigned, MidiEventList*, MidiEventList*); QString name() const { return QString(mempi->name()); } QString lib() const { return _plugin->lib(); } @@ -134,7 +134,7 @@ class MidiPipeline : public QList<MidiPluginI*> { void showGui(int, bool); bool guiVisible(int) const; bool hasGui(int) const; - void apply(unsigned, unsigned, MPEventList*, MPEventList*); + void apply(unsigned, unsigned, MidiEventList*, MidiEventList*); void move(int idx, bool up); }; diff --git a/muse/muse/midiseq.cpp b/muse/muse/midiseq.cpp index db8e7bcf..205066ac 100644 --- a/muse/muse/midiseq.cpp +++ b/muse/muse/midiseq.cpp @@ -34,10 +34,8 @@ #include "sync.h" #include "song.h" #include "gconfig.h" -#include "midioutport.h" MidiSeq* midiSeq; -volatile bool midiBusy; //--------------------------------------------------------- // MidiSeq @@ -194,14 +192,7 @@ bool MidiSeq::start(int prio) //--------------------------------------------------------- // midiTick -// schedule events in MidiOutPort->playEvents() -// midiBusy locks access to MidiOutPortList and -// MidiOutPort. -// Locking is special and assumes that MidiSeq -// is a realtime thread and has higher priority than -// the audio thread (JACK callback) and can therefore not -// be interrupted. Instead of waiting for midiBusy to -// get false we simply miss this clock tick. +// schedule events in playEvents //--------------------------------------------------------- void MidiSeq::midiTick(void* p, void*) @@ -212,25 +203,20 @@ void MidiSeq::midiTick(void* p, void*) MidiSeq* at = (MidiSeq*)p; at->getTimerTicks(); // read elapsed rtc timer ticks - if (midiBusy) - return; + while (!at->fifo.isEmpty()) + at->playEvents.insert(at->fifo.get()); + // // schedule all events upto framePos-segmentSize // (previous segment) // unsigned curFrame = audioDriver->framePos() - segmentSize; - MidiOutPortList* ol = song->midiOutPorts(); - for (iMidiOutPort id = ol->begin(); id != ol->end(); ++id) { - MidiOutPort* mp = *id; - MPEventList* el = mp->playEvents(); - - iMPEvent i = el->begin(); - for (; i != el->end(); ++i) { - if (i->time() > curFrame) - break; - mp->playAlsaEvent(*i); - } - el->erase(el->begin(), i); + iMidiOutEvent i = at->playEvents.begin(); + for (; i != at->playEvents.end(); ++i) { + if (i->event.time() > curFrame) + break; + midiDriver->putEvent(i->port, i->event); } + at->playEvents.erase(at->playEvents.begin(), i); } diff --git a/muse/muse/midiseq.h b/muse/muse/midiseq.h index 7fee4bf1..a684886e 100644 --- a/muse/muse/midiseq.h +++ b/muse/muse/midiseq.h @@ -23,6 +23,7 @@ #include "thread.h" #include "driver/timerdev.h" +#include "midififo.h" //--------------------------------------------------------- // MidiSeq @@ -32,6 +33,9 @@ class MidiSeq : public Thread { int realRtcTicks; Timer* timer; + MidiOutFifo fifo; + MidiOutEventList playEvents; + static void midiTick(void* p, void*); int getTimerTicks() { return timer->getTimerTicks(); } @@ -42,9 +46,11 @@ class MidiSeq : public Thread { virtual void threadStart(void*); void updatePollFd(); bool initRealtimeTimer(); + void putEvent(const Port& p, const MidiEvent& e) { + fifo.put(MidiOutEvent(p,e)); + } }; extern MidiSeq* midiSeq; -extern volatile bool midiBusy; #endif diff --git a/muse/muse/midisynti.cpp b/muse/muse/midisynti.cpp index d8b8191b..c74a2694 100644 --- a/muse/muse/midisynti.cpp +++ b/muse/muse/midisynti.cpp @@ -200,9 +200,9 @@ void MidiSynti::read(QDomNode node) // getEvents //--------------------------------------------------------- -void MidiSynti::getEvents(unsigned from, unsigned to, int, MPEventList* dst) +void MidiSynti::getEvents(unsigned from, unsigned to, int, MidiEventList* dst) { - MPEventList il; + MidiEventList il; RouteList* rl = inRoutes(); for (iRoute i = rl->begin(); i != rl->end(); ++i) { MidiTrackBase* track = (MidiTrackBase*)i->track; @@ -210,9 +210,9 @@ void MidiSynti::getEvents(unsigned from, unsigned to, int, MPEventList* dst) continue; track->getEvents(from, to, i->channel, &il); } - MPEventList ol; + MidiEventList ol; _synti->apply(from, to, &il, &ol); - for (iMPEvent i = ol.begin(); i != ol.end(); ++i) { + for (iMidiEvent i = ol.begin(); i != ol.end(); ++i) { MidiEvent ev(*i); if (ev.type() == ME_NOTEON) { _meter[0] += ev.dataB()/2; diff --git a/muse/muse/midisynti.h b/muse/muse/midisynti.h index 4e3afe62..c74a0eb7 100644 --- a/muse/muse/midisynti.h +++ b/muse/muse/midisynti.h @@ -46,7 +46,7 @@ class MidiSynti : public MidiTrackBase { virtual Part* newPart(Part*, bool) { return 0; } bool initInstance(MidiPlugin*); - virtual void getEvents(unsigned from, unsigned to, int channel, MPEventList* dst); + virtual void getEvents(unsigned from, unsigned to, int channel, MidiEventList* dst); bool hasGui() const; bool guiVisible() const; @@ -54,9 +54,9 @@ class MidiSynti : public MidiTrackBase { }; -typedef tracklist<MidiSynti*>::iterator iMidiSynti; -typedef tracklist<MidiSynti*>::const_iterator ciMidiSynti; -typedef tracklist<MidiSynti*> MidiSyntiList; +typedef QList<MidiSynti*> MidiSyntiList; +typedef MidiSyntiList::iterator iMidiSynti; +typedef MidiSyntiList::const_iterator ciMidiSynti; #endif diff --git a/muse/muse/miditrack.cpp b/muse/muse/miditrack.cpp index f1c7c7c2..50605b5b 100644 --- a/muse/muse/miditrack.cpp +++ b/muse/muse/miditrack.cpp @@ -494,7 +494,7 @@ void MidiTrack::changeDrumMap() const // from/to - midi ticks //--------------------------------------------------------- -void MidiTrack::getEvents(unsigned from, unsigned to, int, MPEventList* dst) +void MidiTrack::getEvents(unsigned from, unsigned to, int, MidiEventList* dst) { if (from > to) { printf("getEvents(): FATAL: cur > next %d > %d\n", from, to); @@ -552,14 +552,14 @@ void MidiTrack::getEvents(unsigned from, unsigned to, int, MPEventList* dst) int veloOff = ev.veloOff(); unsigned eframe = AL::tempomap.tick2frame(tick+elen); - dst->add(MidiEvent(frame, 0, ME_NOTEON, pitch, velo)); - dst->add(MidiEvent(eframe, 0, veloOff ? ME_NOTEOFF : ME_NOTEON, pitch, veloOff)); + dst->insert(MidiEvent(frame, 0, ME_NOTEON, pitch, velo)); + dst->insert(MidiEvent(eframe, 0, veloOff ? ME_NOTEOFF : ME_NOTEON, pitch, veloOff)); _meter[0] += velo/2; if (_meter[0] > 127.0f) _meter[0] = 127.0f; } else { - dst->add(MidiEvent(frame, 0, ev)); + dst->insert(MidiEvent(frame, 0, ev)); } } } @@ -574,10 +574,10 @@ void MidiTrack::getEvents(unsigned from, unsigned to, int, MPEventList* dst) MidiTrackBase* track = (MidiTrackBase*)i->track; if (track->isMute()) continue; - MPEventList el; + MidiEventList el; track->getEvents(from, to, i->channel, &el); - for (iMPEvent ie = el.begin(); ie != el.end(); ++ie) { + for (iMidiEvent ie = el.begin(); ie != el.end(); ++ie) { MidiEvent event(*ie); int eventTime = event.time(); if (recordFlag() && audio->isRecording()) { @@ -607,7 +607,7 @@ void MidiTrack::getEvents(unsigned from, unsigned to, int, MPEventList* dst) } unsigned time = 0; // eventTime + segmentSize*(segmentCount-1); event.setTime(time); - dst->add(event); + dst->insert(event); } } } diff --git a/muse/muse/miditrack.h b/muse/muse/miditrack.h index e0ade62d..c7ecbc8b 100644 --- a/muse/muse/miditrack.h +++ b/muse/muse/miditrack.h @@ -84,14 +84,14 @@ class MidiTrack : public MidiTrackBase { virtual bool canRecord() const { return true; } void playMidiEvent(MidiEvent*); - virtual void getEvents(unsigned from, unsigned to, int channel, MPEventList* dst); + virtual void getEvents(unsigned from, unsigned to, int channel, MidiEventList* dst); bool useDrumMap() const; DrumMap* drumMap() const; }; -typedef tracklist<MidiTrack*>::iterator iMidiTrack; -typedef tracklist<MidiTrack*>::const_iterator ciMidiTrack; -typedef tracklist<MidiTrack*> MidiTrackList; +typedef QList<MidiTrack*> MidiTrackList; +typedef MidiTrackList::iterator iMidiTrack; +typedef MidiTrackList::const_iterator ciMidiTrack; Q_DECLARE_METATYPE(class MidiTrack*); diff --git a/muse/muse/mixer/mstrip.cpp b/muse/muse/mixer/mstrip.cpp index 7dae09aa..19021ea1 100644 --- a/muse/muse/mixer/mstrip.cpp +++ b/muse/muse/mixer/mstrip.cpp @@ -668,7 +668,7 @@ void MidiStrip::iRoutePressed() int port = trackid >> 5; int channel = trackid & 0x1f; - MidiInPort* mip = ipl->index(port); + MidiInPort* mip = ipl->at(port); if (channel == MIDI_CHANNELS) { for (channel = 0; channel < MIDI_CHANNELS; ++channel) { Route srcRoute(mip, channel, Route::TRACK); diff --git a/muse/muse/mixer/strip.cpp b/muse/muse/mixer/strip.cpp index 5e2fdc80..20441f3f 100644 --- a/muse/muse/mixer/strip.cpp +++ b/muse/muse/mixer/strip.cpp @@ -31,10 +31,7 @@ void Strip::updateLabel() QPalette p = label->palette(); p.setColor(label->backgroundRole(), track->ccolor()); label->setPalette(p); - - // qt4.1.0 specific label->setAutoFillBackground(true); - label->setFont(config.fonts[4]); label->setText(track->name()); label->setToolTip(track->name()); @@ -55,11 +52,11 @@ Strip::Strip(Mixer* m, Track* t, bool align) setLineWidth(2); track = t; - setFixedWidth(STRIP_WIDTH); layout = new QVBoxLayout; layout->setMargin(0); layout->setSpacing(0); setLayout(layout); +// setFixedWidth(STRIP_WIDTH); //--------------------------------------------- // label diff --git a/muse/muse/muse.cpp b/muse/muse/muse.cpp index fdf2c91c..7eaae2e5 100644 --- a/muse/muse/muse.cpp +++ b/muse/muse/muse.cpp @@ -3085,6 +3085,7 @@ int main(int argc, char* argv[]) // for (;;) { ProjectDialog projectDialog; + projectDialog.setProjectName(name); int rv = projectDialog.exec(); if (rv == 1) { path = projectDialog.projectPath(); @@ -3092,12 +3093,10 @@ int main(int argc, char* argv[]) break; } // the user did not select/create a project - QString s; - s = "before MusE starts, you must select a project\n" - "or create a new one"; rv = QMessageBox::question(0, - "MusE: create select project", - s, + "MusE: create/select project", + "before MusE starts, you must select a project\n" + "or create a new one", "Go Back", "Abort", QString(), diff --git a/muse/muse/seqmsg.cpp b/muse/muse/seqmsg.cpp index 0db3f0ab..45bd0014 100644 --- a/muse/muse/seqmsg.cpp +++ b/muse/muse/seqmsg.cpp @@ -344,7 +344,7 @@ void Audio::msgRemoveTracks() } for (iTrack t = tl.begin(); t != tl.end(); ++t) { Track* track = *t; - int idx = song->tracks()->index(track); + int idx = song->tracks()->indexOf(track); song->undoOp(UndoOp::DeleteTrack, idx, track); song->removeTrack1(track); msgRemoveTrack(track); diff --git a/muse/muse/song.cpp b/muse/muse/song.cpp index 6e06ef80..35e2078a 100644 --- a/muse/muse/song.cpp +++ b/muse/muse/song.cpp @@ -478,7 +478,7 @@ void Song::setPos(int idx, const Pos& val, bool sig, bool isSeek, bool follow) if (pos[idx] == val) return; if (idx == CPOS) { - _vcpos = val; +// _vcpos = val; if (isSeek) { seekInProgress = true; audio->msgSeek(val); @@ -1130,16 +1130,34 @@ void Song::clear(bool signal) _selectedTrack = 0; _tracks.clear(); - _midis.clearDelete(); - _waves.clearDelete(); - _inputs.clearDelete(); // audio input ports - _outputs.clearDelete(); // audio output ports - _groups.clearDelete(); // mixer groups - _synthIs.clearDelete(); - - _midiSyntis.clearDelete(); - _midiOutPorts.clearDelete(); - _midiInPorts.clearDelete(); + + qDeleteAll(_midis); + _midis.clear(); + + qDeleteAll(_waves); + _waves.clear(); + + qDeleteAll(_inputs); // audio input ports + _inputs.clear(); + + qDeleteAll(_outputs); // audio output ports + _outputs.clear(); + + qDeleteAll(_groups); // mixer groups + _groups.clear(); + + qDeleteAll(_synthIs); + _synthIs.clear(); + + qDeleteAll(_midiSyntis); + _midiSyntis.clear(); + + qDeleteAll(_midiOutPorts); + _midiOutPorts.clear(); + + qDeleteAll(_midiInPorts); + _midiInPorts.clear(); + _midiChannel.clear(); AL::tempomap.clear(); @@ -1150,7 +1168,7 @@ void Song::clear(bool signal) pos[0].setTick(0); pos[1].setTick(0); pos[2].setTick(0); - _vcpos.setTick(0); +// _vcpos.setTick(0); _masterFlag = true; loopFlag = false; @@ -1633,8 +1651,7 @@ void Song::insertTrack0(Track* track, int idx) void Song::insertTrack1(Track* track, int idx) { - iTrack i = _tracks.index2iterator(idx); - _tracks.insert(i, track); + _tracks.insert(idx, track); if (track->type() == Track::AUDIO_SOFTSYNTH) { SynthI* s = (SynthI*)track; Synth* sy = s->synth(); @@ -1752,7 +1769,7 @@ void Song::removeTrack(Track* track) for (int i = 0; i < MIDI_CHANNELS; ++i) { MidiChannel* mc = ((SynthI*)track)->channel(i); if (!mc->noInRoute()) { - int idx = _tracks.index(mc); + int idx = _tracks.indexOf(mc); undoOp(UndoOp::DeleteTrack, idx, mc); removeTrack1(mc); audio->msgRemoveTrack(mc); @@ -1764,7 +1781,7 @@ void Song::removeTrack(Track* track) for (int i = 0; i < MIDI_CHANNELS; ++i) { MidiChannel* mc = ((MidiOutPort*)track)->channel(i); if (!mc->noInRoute()) { - int idx = _tracks.index(mc); + int idx = _tracks.indexOf(mc); undoOp(UndoOp::DeleteTrack, idx, mc); removeTrack1(mc); audio->msgRemoveTrack(mc); @@ -1772,7 +1789,7 @@ void Song::removeTrack(Track* track) } } } - int idx = _tracks.index(track); + int idx = _tracks.indexOf(track); undoOp(UndoOp::DeleteTrack, idx, track); removeTrack1(track); audio->msgRemoveTrack(track); @@ -1788,24 +1805,8 @@ void Song::removeTrack(Track* track) void Song::removeTrack1(Track* track) { -#if 0 - if (track->type() == Track::AUDIO_SOFTSYNTH) { - for (int i = 0; i < MIDI_CHANNELS; ++i) { - MidiChannel* mc = ((SynthI*)track)->channel(i); - if (!mc->noInRoute()) - removeTrack1(mc); - } - } - else if (track->type() == Track::MIDI_OUT) { - for (int i = 0; i < MIDI_CHANNELS; ++i) { - MidiChannel* mc = ((MidiOutPort*)track)->channel(i); - if (!mc->noInRoute()) - removeTrack1(mc); - } - } -#endif track->deactivate(); - _tracks.erase(track); + _tracks.removeAt(_tracks.indexOf(track)); } //--------------------------------------------------------- @@ -1817,41 +1818,37 @@ void Song::removeTrack2(Track* track) { switch (track->type()) { case Track::MIDI_SYNTI: - _midiSyntis.erase(track); + _midiSyntis.removeAt(_midiSyntis.indexOf((MidiSynti*)track)); break; case Track::MIDI: - _midis.erase(track); + _midis.removeAt(_midis.indexOf((MidiTrack*)track)); break; case Track::MIDI_OUT: -// for (int i = 0; i < MIDI_CHANNELS; ++i) -// removeTrack2(((MidiOutPort*)track)->channel(i)); - _midiOutPorts.erase(track); + _midiOutPorts.removeAt(_midiOutPorts.indexOf((MidiOutPort*)track)); break; case Track::MIDI_IN: - _midiInPorts.erase(track); + _midiInPorts.removeAt(_midiInPorts.indexOf((MidiInPort*)track)); break; case Track::MIDI_CHANNEL: - _midiChannel.erase(track); + _midiChannel.removeAt(_midiChannel.indexOf((MidiChannel*)track)); break; case Track::WAVE: - _waves.erase(track); + _waves.removeAt(_waves.indexOf((WaveTrack*)track)); break; case Track::AUDIO_OUTPUT: - _outputs.erase(track); + _outputs.removeAt(_outputs.indexOf((AudioOutput*)track)); break; case Track::AUDIO_INPUT: - _inputs.erase(track); + _inputs.removeAt(_inputs.indexOf((AudioInput*)track)); break; case Track::AUDIO_GROUP: - _groups.erase(track); + _groups.removeAt(_groups.indexOf((AudioGroup*)track)); break; case Track::AUDIO_SOFTSYNTH: { SynthI* s = (SynthI*) track; -// for (int i = 0; i < MIDI_CHANNELS; ++i) -// removeTrack2(s->channel(i)); s->deactivate2(); - _synthIs.erase(track); + _synthIs.removeAt(_synthIs.indexOf(s)); } break; case Track::TRACK_TYPES: @@ -1898,23 +1895,7 @@ void Song::removeTrack3(Track* track) if (track->type() == Track::AUDIO_SOFTSYNTH) { SynthI* s = (SynthI*) track; s->deactivate3(); -#if 0 - for (int i = 0; i < MIDI_CHANNELS; ++i) { - MidiChannel* mc = ((SynthI*)track)->channel(i); - if (!mc->noInRoute()) - removeTrack3(mc); - } -#endif - } -#if 0 - else if (track->type() == Track::MIDI_OUT) { - for (int i = 0; i < MIDI_CHANNELS; ++i) { - MidiChannel* mc = ((MidiOutPort*)track)->channel(i); - if (!mc->noInRoute()) - removeTrack3(mc); - } } -#endif emit trackRemoved(track); } @@ -2306,8 +2287,8 @@ void Song::removeControllerVal(Track* t, int id, unsigned time) void Song::moveTrack(Track* src, Track* dst) { - iTrack si = _tracks.find(src); - iTrack di = _tracks.find(dst); + iTrack si = qFind(_tracks.begin(), _tracks.end(), src); + iTrack di = qFind(_tracks.begin(), _tracks.end(), dst); if (si == _tracks.end() || di == _tracks.end()) { printf("Song::moveTrack() track not found\n"); return; diff --git a/muse/muse/song.h b/muse/muse/song.h index 7e64de2c..a14b22e3 100644 --- a/muse/muse/song.h +++ b/muse/muse/song.h @@ -22,12 +22,15 @@ #define __SONG_H__ #include "undo.h" +#include "midiinport.h" +#include "midioutport.h" +#include "midichannel.h" #include "miditrack.h" +#include "midisynti.h" #include "wavetrack.h" #include "audioinput.h" #include "audiooutput.h" #include "audiogroup.h" -#include "midisynti.h" #include "synth.h" #include "ctrl.h" #include "midififo.h" @@ -113,7 +116,7 @@ class Song : public QObject { UndoList* undoList; UndoList* redoList; Pos pos[3]; - Pos _vcpos; // virtual CPOS (locate in progress) +// Pos _vcpos; // virtual CPOS (locate in progress) AL::MarkerList* _markerList; bool seekInProgress; // user initiated a seek @@ -159,8 +162,6 @@ class Song : public QObject { void setMeasureLen(int l); void changePart(Part*, unsigned, unsigned); void createLRPart(Track* track); - //void setTickPos(int, unsigned); - void setPos(int, const AL::Pos&); void setPos(int, const AL::Pos&, bool sig, bool isSeek = true, bool adjustScrollbar = false); @@ -236,8 +237,8 @@ class Song : public QObject { const Pos& lPos() const { return pos[1]; } const Pos& rPos() const { return pos[2]; } unsigned cpos() const { return pos[0].tick(); } - unsigned vcpos() const { return _vcpos.tick(); } - const Pos& vcPos() const { return _vcpos; } +// unsigned vcpos() const { return _vcpos.tick(); } +// const Pos& vcPos() const { return _vcpos; } unsigned lpos() const { return pos[1].tick(); } unsigned rpos() const { return pos[2].tick(); } @@ -294,8 +295,6 @@ class Song : public QObject { void copyPart(Part*, unsigned, Track*); void selectPart(Part*, bool add=false); -// SettingsList* settingsList() { return esettingsList; } - //----------------------------------------- // track manipulations //----------------------------------------- @@ -307,11 +306,10 @@ class Song : public QObject { OutputList* outputs() { return &_outputs; } GroupList* groups() { return &_groups; } SynthIList* syntis() { return &_synthIs; } - MidiOutPortList* midiOutPorts() { return &_midiOutPorts; } - MidiOutPort* midiOutPort(int idx) { return _midiOutPorts.index(idx); } - MidiSyntiList* midiSyntis() { return &_midiSyntis; } - MidiInPortList* midiInPorts() { return &_midiInPorts; } - MidiChannelList* midiChannel() { return &_midiChannel; } + MidiOutPortList* midiOutPorts() { return &_midiOutPorts; } + MidiSyntiList* midiSyntis() { return &_midiSyntis; } + MidiInPortList* midiInPorts() { return &_midiInPorts; } + MidiChannelList* midiChannel() { return &_midiChannel; } bool trackExists(Track*) const; @@ -319,7 +317,6 @@ class Song : public QObject { void removeTrack1(Track* track); void removeTrack2(Track* track); void removeTrack3(Track* track); -// void removeMarkedTracks(); void changeTrackName(Track* track, const QString&); void swapTracks(int i1, int i2); @@ -364,12 +361,6 @@ class Song : public QObject { void addUndo(UndoOp& i); //----------------------------------------- - // Configuration - //----------------------------------------- - -// void rescanAlsaPorts(); - - //----------------------------------------- // Controller //----------------------------------------- diff --git a/muse/muse/songfile.cpp b/muse/muse/songfile.cpp index 00977794..b6b7515f 100644 --- a/muse/muse/songfile.cpp +++ b/muse/muse/songfile.cpp @@ -51,13 +51,13 @@ Part* MusE::readPart(QDomNode node) QDomElement e = node.toElement(); Part* part = 0; QString s = e.text(); - unsigned trackIdx; + int trackIdx; int partIdx; sscanf(s.toLatin1().data(), "%d:%d", &trackIdx, &partIdx); TrackList* tl = song->tracks(); Track* track = 0; if (trackIdx < tl->size()) { - track = tl->index(trackIdx); + track = tl->at(trackIdx); part = track->parts()->find(partIdx); } return part; diff --git a/muse/muse/synth.cpp b/muse/muse/synth.cpp index ebdbc10f..23efe9c2 100644 --- a/muse/muse/synth.cpp +++ b/muse/muse/synth.cpp @@ -530,7 +530,7 @@ void MessSynthIF::populatePatchPopup(QMenu* menu, int ch) // getData //--------------------------------------------------------- -void MessSynthIF::getData(MPEventList* el, unsigned pos, int ports, unsigned n, float** buffer) +void MessSynthIF::getData(MidiEventList* el, unsigned pos, int ports, unsigned n, float** buffer) { // Reset buffers first for (int port = 0; port < ports; ++port) @@ -546,7 +546,7 @@ void MessSynthIF::getData(MPEventList* el, unsigned pos, int ports, unsigned n, putEvent(synti->putFifo.get()); if (ports >= channels()) { - iMPEvent i = el->begin(); + iMidiEvent i = el->begin(); for (; i != el->end(); ++i) { int frame = i->time(); if (frame >= endPos) diff --git a/muse/muse/synth.h b/muse/muse/synth.h index af45c04d..5ac241fd 100644 --- a/muse/muse/synth.h +++ b/muse/muse/synth.h @@ -95,7 +95,7 @@ class SynthIF { virtual bool hasGui() const = 0; virtual void getGeometry(int*, int*, int*, int*) const = 0; virtual void setGeometry(int, int, int, int) = 0; - virtual void getData(MPEventList*, unsigned pos, int ports, unsigned n, float** buffer) = 0; + virtual void getData(MidiEventList*, unsigned pos, int ports, unsigned n, float** buffer) = 0; virtual bool putEvent(const MidiEvent& ev) = 0; virtual MidiEvent receiveEvent() = 0; virtual int eventsPending() const = 0; @@ -198,7 +198,7 @@ class MessSynthIF : public SynthIF { virtual bool hasGui() const; virtual void getGeometry(int*, int*, int*, int*) const; virtual void setGeometry(int, int, int, int); - virtual void getData(MPEventList*, unsigned pos, int ports, unsigned n, float** buffer); + virtual void getData(MidiEventList*, unsigned pos, int ports, unsigned n, float** buffer); virtual bool putEvent(const MidiEvent& ev); virtual MidiEvent receiveEvent(); virtual int eventsPending() const; @@ -212,9 +212,9 @@ class MessSynthIF : public SynthIF { bool init(Synth* s, SynthI* si); }; -typedef tracklist<SynthI*>::iterator iSynthI; -typedef tracklist<SynthI*>::const_iterator ciSynthI; -typedef tracklist<SynthI*> SynthIList; +typedef QList<SynthI*> SynthIList; +typedef SynthIList::iterator iSynthI; +typedef SynthIList::const_iterator ciSynthI; extern std::vector<Synth*> synthis; // array of available synthis extern Synth* findSynth(const QString& sclass); diff --git a/muse/muse/ticksynth.cpp b/muse/muse/ticksynth.cpp index fd3dbb16..861861de 100644 --- a/muse/muse/ticksynth.cpp +++ b/muse/muse/ticksynth.cpp @@ -69,7 +69,7 @@ class MetronomeSynthIF : public SynthIF virtual bool hasGui() const { return false; } virtual void getGeometry(int*, int*, int*, int*) const {} virtual void setGeometry(int, int, int, int) {} - virtual void getData(MPEventList*, unsigned pos, int ports, unsigned n, float** buffer); + virtual void getData(MidiEventList*, unsigned pos, int ports, unsigned n, float** buffer); virtual bool putEvent(const MidiEvent& ev); virtual MidiEvent receiveEvent() { return MidiEvent(); } virtual int eventsPending() const { return 0; } @@ -89,13 +89,13 @@ class MetronomeSynthIF : public SynthIF // getData //--------------------------------------------------------- -void MetronomeSynthIF::getData(MPEventList* el, unsigned pos, int/*ports*/, unsigned n, float** buffer) +void MetronomeSynthIF::getData(MidiEventList* el, unsigned pos, int/*ports*/, unsigned n, float** buffer) { unsigned curPos = pos; unsigned endPos = pos + n; unsigned off = pos; - iMPEvent i = el->begin(); + iMidiEvent i = el->begin(); for (; i != el->end(); ++i) { unsigned frame = i->time(); if (frame >= endPos) diff --git a/muse/muse/track.cpp b/muse/muse/track.cpp index d744a237..18749960 100644 --- a/muse/muse/track.cpp +++ b/muse/muse/track.cpp @@ -106,7 +106,7 @@ Track::Track() _channels = 0; // 1 - mono, 2 - stereo _selected = false; _locked = false; - _autoRead = true; + _autoRead = false; _autoWrite = false; for (int i = 0; i < MAX_CHANNELS; ++i) { @@ -256,7 +256,7 @@ void Track::writeProperties(Xml& xml) const xml.strTag("comment", _comment); if (_recordFlag) xml.intTag("record", _recordFlag); -// if (mute()) // audioInput defaults to true + if (mute() != muteDefault()) xml.intTag("mute", mute()); if (solo()) xml.intTag("solo", solo()); diff --git a/muse/muse/track.h b/muse/muse/track.h index b5511486..354edf46 100644 --- a/muse/muse/track.h +++ b/muse/muse/track.h @@ -26,8 +26,6 @@ #include "route.h" #include "ctrl.h" #include "globaldefs.h" -#include "midievent.h" -#include "midififo.h" namespace AL { class Xml; @@ -39,7 +37,7 @@ using AL::TType; class DrumMap; class MidiPipeline; class MidiEvent; -class MPEventList; +class MidiEventList; class SynthI; class MidiPlugin; class MidiPluginI; @@ -55,8 +53,6 @@ class MidiChannel; typedef struct snd_seq_event snd_seq_event_t; #endif -static const int EVENT_FIFO_SIZE = 128; - //--------------------------------------------------------- // ArrangerTrack //--------------------------------------------------------- @@ -330,6 +326,8 @@ class Track : public QObject { void setSendSync(bool val); int deviceId() const { return _deviceId; } void setDeviceId(int val) { _deviceId = val; } + + virtual bool muteDefault() const { return false; } }; //--------------------------------------------------------- @@ -352,121 +350,13 @@ class MidiTrackBase : public Track { void addPlugin(MidiPluginI* plugin, int idx); MidiPluginI* plugin(int idx) const; - virtual void getEvents(unsigned /*from*/, unsigned /*to*/, int /*channel*/, MPEventList* /*dst*/) {} + virtual void getEvents(unsigned /*from*/, unsigned /*to*/, int /*channel*/, MidiEventList* /*dst*/) {} }; -//--------------------------------------------------------- -// TrackList -//--------------------------------------------------------- - -template<class T> class tracklist : public std::vector<Track*> { - typedef std::vector<Track*> vlist; - - public: - class iterator : public vlist::iterator { - public: - iterator() : vlist::iterator() {} - iterator(vlist::iterator i) : vlist::iterator(i) {} - - T operator*() { - return (T)(**((vlist::iterator*)this)); - } - iterator operator++(int) { - return iterator ((*(vlist::iterator*)this).operator++(0)); - } - iterator& operator++() { - return (iterator&) ((*(vlist::iterator*)this).operator++()); - } - }; - - class const_iterator : public vlist::const_iterator { - public: - const_iterator() : vlist::const_iterator() {} - const_iterator(vlist::const_iterator i) : vlist::const_iterator(i) {} - const_iterator(vlist::iterator i) : vlist::const_iterator(i) {} - - const T operator*() const { - return (T)(**((vlist::const_iterator*)this)); - } - }; - - class reverse_iterator : public vlist::reverse_iterator { - public: - reverse_iterator() : vlist::reverse_iterator() {} - reverse_iterator(vlist::reverse_iterator i) : vlist::reverse_iterator(i) {} - - T operator*() { - return (T)(**((vlist::reverse_iterator*)this)); - } - }; - - tracklist() : vlist() {} - virtual ~tracklist() {} - - void push_back(T v) { vlist::push_back(v); } - iterator begin() { return vlist::begin(); } - iterator end() { return vlist::end(); } - const_iterator begin() const { return vlist::begin(); } - const_iterator end() const { return vlist::end(); } - reverse_iterator rbegin() { return vlist::rbegin(); } - reverse_iterator rend() { return vlist::rend(); } - T& back() const { return (T&)(vlist::back()); } - T& front() const { return (T&)(vlist::front()); } - iterator find(const Track* t) { - return std::find(begin(), end(), t); - } - const_iterator find(const Track* t) const { - return std::find(begin(), end(), t); - } - unsigned index(const Track* t) const { - unsigned n = 0; - for (vlist::const_iterator i = begin(); i != end(); ++i, ++n) { - if (*i == t) - return n; - } - return -1; - } - T index(int k) const { return (T)((*this)[k]); } - - iterator index2iterator(int k) { - if ((unsigned)k >= size()) - return end(); - return begin() + k; - } - void erase(Track* t) { vlist::erase(find(t)); } - - void clearDelete() { - for (vlist::iterator i = begin(); i != end(); ++i) - delete *i; - vlist::clear(); - } - void erase(vlist::iterator i) { vlist::erase(i); } - void replace(Track* ot, Track* nt) { - for (vlist::iterator i = begin(); i != end(); ++i) { - if (*i == ot) { - *i = nt; - return; - } - } - } - }; - -typedef tracklist<Track*> TrackList; +typedef QList<Track*> TrackList; typedef TrackList::iterator iTrack; -typedef TrackList::reverse_iterator irTrack; typedef TrackList::const_iterator ciTrack; -typedef tracklist<MidiInPort*>::iterator iMidiInPort; -typedef tracklist<MidiInPort*>::const_iterator ciMidiInPort; -typedef tracklist<MidiInPort*> MidiInPortList; - -typedef tracklist<MidiOutPort*>::iterator iMidiOutPort; -typedef tracklist<MidiOutPort*>::const_iterator ciMidiOutPort; -typedef tracklist<MidiOutPort*> MidiOutPortList; - -typedef tracklist<MidiChannel*>::iterator iMidiChannel; -typedef tracklist<MidiChannel*>::const_iterator ciMidiChannel; -typedef tracklist<MidiChannel*> MidiChannelList; #endif diff --git a/muse/muse/vst.cpp b/muse/muse/vst.cpp index 89a66a06..91395444 100644 --- a/muse/muse/vst.cpp +++ b/muse/muse/vst.cpp @@ -809,10 +809,10 @@ void VstSynthIF::write(Xml& xml) const // getData //--------------------------------------------------------- -void VstSynthIF::getData(MPEventList* el, unsigned pos, int ports, unsigned n, float** buffer) +void VstSynthIF::getData(MidiEventList* el, unsigned pos, int ports, unsigned n, float** buffer) { int endPos = pos + n; - iMPEvent i = el->begin(); + iMidiEvent i = el->begin(); for (; i != el->end(); ++i) { if (i->time() >= endPos) break; diff --git a/muse/muse/vst.h b/muse/muse/vst.h index 6413d69f..b22b231c 100644 --- a/muse/muse/vst.h +++ b/muse/muse/vst.h @@ -101,7 +101,7 @@ class VstSynthIF : public SynthIF virtual bool hasGui() const; virtual void getGeometry(int*, int*, int*, int*) const {} virtual void setGeometry(int, int, int, int) {} - virtual void getData(MPEventList*, unsigned pos, int ports, unsigned n, float** buffer) ; + virtual void getData(MidiEventList*, unsigned pos, int ports, unsigned n, float** buffer) ; virtual bool putEvent(const MidiEvent& ev); virtual MidiEvent receiveEvent(); virtual int eventsPending() const { return 0; } diff --git a/muse/muse/wavetrack.cpp b/muse/muse/wavetrack.cpp index 65b91ceb..8504d35c 100644 --- a/muse/muse/wavetrack.cpp +++ b/muse/muse/wavetrack.cpp @@ -312,14 +312,13 @@ 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); + if (!ol->empty()) { +//TODO AudioOutput* out = ol->front(); + } } else -#endif AudioTrack::collectInputData(); return; } @@ -329,7 +328,6 @@ void WaveTrack::collectInputData() return; } -// unsigned framePos = audio->pos().frame(); if (audio->freewheel()) { // when freewheeling, read data direct from file: // TODO: fetchData(framePos, segmentSize, buffer); @@ -389,7 +387,6 @@ void WaveTrack::process() void WaveTrack::clone(WaveTrack* t) { -printf("clone WaveTrack\n"); QString name; for (int i = 1; ; ++i) { name.sprintf("%s-%d", t->name().toLatin1().data(), i); diff --git a/muse/muse/wavetrack.h b/muse/muse/wavetrack.h index c766e9b1..0e195ddb 100644 --- a/muse/muse/wavetrack.h +++ b/muse/muse/wavetrack.h @@ -74,9 +74,9 @@ class WaveTrack : public AudioTrack { }; -typedef tracklist<WaveTrack*>::iterator iWaveTrack; -typedef tracklist<WaveTrack*>::const_iterator ciWaveTrack; -typedef tracklist<WaveTrack*> WaveTrackList; +typedef QList<WaveTrack*> WaveTrackList; +typedef WaveTrackList::iterator iWaveTrack; +typedef WaveTrackList::const_iterator ciWaveTrack; #endif |