From: werner s. <wsc...@us...> - 2004-09-24 16:26:04
|
Update of /cvsroot/lmuse/muse/muse In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12937/muse Modified Files: audiotrack.cpp conf.cpp ctrl.cpp ctrl.h midiport.cpp song.cpp track.cpp Log Message: misc fixes Index: track.cpp =================================================================== RCS file: /cvsroot/lmuse/muse/muse/track.cpp,v retrieving revision 1.41 retrieving revision 1.42 diff -C2 -d -r1.41 -r1.42 *** track.cpp 22 Sep 2004 17:05:37 -0000 1.41 --- track.cpp 24 Sep 2004 16:25:50 -0000 1.42 *************** *** 259,263 **** Ctrl* d = icl->second; for (iCtrlVal i = l->begin(); i != l->end(); ++i) ! d->insert(std::pair<const int, CtrlVal> (i->first, i->second)); d->setCurVal(l->curVal()); d->setDefault(l->getDefault()); --- 259,263 ---- Ctrl* d = icl->second; for (iCtrlVal i = l->begin(); i != l->end(); ++i) ! d->insert(std::pair<const unsigned, float> (i->first, i->second)); d->setCurVal(l->curVal()); d->setDefault(l->getDefault()); *************** *** 359,363 **** iCtrl i = controller()->find(list->id()); if (i != controller()->end()) { ! printf("Track::addController: already there 0x%x\n", list->id()); abort(); } --- 359,364 ---- iCtrl i = controller()->find(list->id()); if (i != controller()->end()) { ! printf("Track(%s)::addController(%s): already there 0x%x\n", ! name().latin1(), list->name().latin1(), list->id()); abort(); } Index: midiport.cpp =================================================================== RCS file: /cvsroot/lmuse/muse/muse/midiport.cpp,v retrieving revision 1.30 retrieving revision 1.31 diff -C2 -d -r1.30 -r1.31 *** midiport.cpp 22 Sep 2004 17:05:36 -0000 1.30 --- midiport.cpp 24 Sep 2004 16:25:50 -0000 1.31 *************** *** 65,99 **** void MidiPort::addManagedController(int channel, int ctrl) { MidiController* mc = midiController(ctrl); - QString name("unknown"); - Ctrl::Mode type = Ctrl::MIDI7; if (mc) { ! name = mc->name(); ! MidiController::ControllerType t = midiControllerType(ctrl); ! switch(t) { ! default: ! case MidiController::Program: //TODO ! case MidiController::Controller7: ! case MidiController::RPN: ! case MidiController::NRPN: ! if (mc->minVal() < 0) ! type = Ctrl::MIDIS7; ! break; ! case MidiController::Controller14: ! case MidiController::RPN14: ! case MidiController::NRPN14: ! type = Ctrl::MIDI14; ! break; ! case MidiController::Pitch: ! type = Ctrl::MIDIS14; ! break; ! } ! } ! iCtrl cl = _controller[channel].find(ctrl); ! if (cl == _controller[channel].end()) { ! Ctrl* pvl = new Ctrl(ctrl, name); ! pvl->setMode(type); ! _controller[channel].add(pvl); } } --- 65,81 ---- void MidiPort::addManagedController(int channel, int ctrl) { + iCtrl cl = _controller[channel].find(ctrl); + if (cl != _controller[channel].end()) + return; + + Ctrl* pvl = new Ctrl(ctrl, QString("unknown")); + MidiController* mc = midiController(ctrl); if (mc) { ! pvl->setName(mc->name()); ! pvl->setRange(float(mc->minVal()), float(mc->maxVal())); } + pvl->setType(Ctrl::DISCRETE); + _controller[channel].add(pvl); } *************** *** 110,114 **** Ctrl* d = icl->second; for (iCtrlVal i = c->begin(); i != c->end(); ++i) ! d->insert(std::pair<const int, CtrlVal> (i->first, i->second)); d->setCurVal(c->curVal()); d->setDefault(c->getDefault()); --- 92,96 ---- Ctrl* d = icl->second; for (iCtrlVal i = c->begin(); i != c->end(); ++i) ! d->insert(std::pair<const int, float> (i->first, i->second)); d->setCurVal(c->curVal()); d->setDefault(c->getDefault()); Index: song.cpp =================================================================== RCS file: /cvsroot/lmuse/muse/muse/song.cpp,v retrieving revision 1.78 retrieving revision 1.79 diff -C2 -d -r1.78 -r1.79 *** song.cpp 23 Sep 2004 18:28:06 -0000 1.78 --- song.cpp 24 Sep 2004 16:25:50 -0000 1.79 *************** *** 440,445 **** } if (ip == pl->end()) { - if (debugMsg) - printf("create new part for recorded events\n"); // create new part part = new MidiPart(mt); --- 440,443 ---- *************** *** 457,462 **** de->add(event); } ! audio->msgAddPart(part); ! updateFlags |= SC_PART_INSERTED; return; } --- 455,459 ---- de->add(event); } ! addPart(part); return; } *************** *** 488,491 **** --- 485,489 ---- undoOp(UndoOp::ModifyPart, part, newPart); part->events()->incARef(-1); + part->track()->partListChanged(); updateFlags |= SC_PART_MODIFIED; } Index: audiotrack.cpp =================================================================== RCS file: /cvsroot/lmuse/muse/muse/audiotrack.cpp,v retrieving revision 1.25 retrieving revision 1.26 diff -C2 -d -r1.25 -r1.26 *** audiotrack.cpp 23 Sep 2004 16:04:02 -0000 1.25 --- audiotrack.cpp 24 Sep 2004 16:25:49 -0000 1.26 *************** *** 15,18 **** --- 15,19 ---- #include "plugin.h" #include "audiodev.h" + #include "gconfig.h" //--------------------------------------------------------- *************** *** 29,34 **** _channels = 0; setChannels(1); ! addController(new Ctrl(AC_VOLUME, "Volume")); ! addController(new Ctrl(AC_PAN, "Pan")); outBuffers = new float*[MAX_CHANNELS]; for (int i = 0; i < MAX_CHANNELS; ++i) --- 30,48 ---- _channels = 0; setChannels(1); ! ! // ! // add two managed standard controller: ! // volume and pan ! // ! Ctrl* c; ! c = new Ctrl(AC_VOLUME, "Volume"); ! c->setType(Ctrl::INTERPOLATE | Ctrl::LOG); ! c->setRange(pow(10.0f, config.minSlider*0.05f), 2.0f); ! ! addController(c); ! c = new Ctrl(AC_PAN, "Pan"); ! c->setRange(-1.0f, +1.0f); ! addController(c); ! outBuffers = new float*[MAX_CHANNELS]; for (int i = 0; i < MAX_CHANNELS; ++i) *************** *** 193,197 **** } for (ciCtrl icl = controller()->begin(); icl != controller()->end(); ++icl) ! icl->second->write(xml); } --- 207,211 ---- } for (ciCtrl icl = controller()->begin(); icl != controller()->end(); ++icl) ! icl->second->write(xml, true); } Index: conf.cpp =================================================================== RCS file: /cvsroot/lmuse/muse/muse/conf.cpp,v retrieving revision 1.40 retrieving revision 1.41 diff -C2 -d -r1.40 -r1.41 *** conf.cpp 22 Sep 2004 23:35:03 -0000 1.40 --- conf.cpp 24 Sep 2004 16:25:49 -0000 1.41 *************** *** 460,465 **** else if (tag == "startSong") config.startSong = s; ! else ! printf("MusE:readConfiguration(): unknown tag %s\n", e.tagName().latin1()); node = node.nextSibling(); } --- 460,468 ---- else if (tag == "startSong") config.startSong = s; ! else { ! QDomDocument doc = node.ownerDocument(); ! printf("MusE:readConfiguration(): unknown tag %s in document %s\n", ! e.tagName().latin1(), doc.nodeName().latin1()); ! } node = node.nextSibling(); } *************** *** 584,588 **** xml.tag("channel idx=\"%d\"", k); for (iCtrl i = vll->begin(); i != vll->end(); ++i) ! i->second->write(xml); xml.etag("channel"); } --- 587,591 ---- xml.tag("channel idx=\"%d\"", k); for (iCtrl i = vll->begin(); i != vll->end(); ++i) ! i->second->write(xml, false); xml.etag("channel"); } Index: ctrl.h =================================================================== RCS file: /cvsroot/lmuse/muse/muse/ctrl.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** ctrl.h 22 Sep 2004 17:05:36 -0000 1.9 --- ctrl.h 24 Sep 2004 16:25:50 -0000 1.10 *************** *** 14,21 **** class Xml; const int AC_VOLUME = 0; const int AC_PAN = 1; const int AC_MUTE = 2; ! const int AC_AUX = 3; const int NUM_AUX = 32; // max number of aux channels --- 14,22 ---- class Xml; + // predefined controller: const int AC_VOLUME = 0; const int AC_PAN = 1; const int AC_MUTE = 2; ! const int AC_AUX = 3; // 3 -- 3+NUM_AUX const int NUM_AUX = 32; // max number of aux channels *************** *** 78,82 **** //--------------------------------------------------------- ! typedef std::map<unsigned, CtrlVal, std::less<unsigned> > CTRL; typedef CTRL::iterator iCtrlVal; typedef CTRL::const_iterator ciCtrlVal; --- 79,83 ---- //--------------------------------------------------------- ! typedef std::map<unsigned, float, std::less<unsigned> > CTRL; typedef CTRL::iterator iCtrlVal; typedef CTRL::const_iterator ciCtrlVal; *************** *** 84,96 **** class Ctrl : public CTRL { public: ! enum Mode { INTERPOLATE, DISCRETE, MIDI7, MIDI14, MIDIS7, MIDIS14 }; private: ! Mode _mode; ! int _id; float _default; float _curVal; ! QString _name; ! float _min, _max; bool _changed; --- 85,103 ---- class Ctrl : public CTRL { public: ! enum CtrlType { ! INTERPOLATE = 0, // values are linear interpolated ! DISCRETE = 1, // midi controller events ! LINEAR = 0, ! LOG = 2 ! }; private: ! int _id; ! QString _name; ! int _type; // bitmask of CtrlType float _default; float _curVal; ! float min, max; ! float minli; // 1.0f/log10(min) bool _changed; *************** *** 98,126 **** Ctrl(); Ctrl(int id, const QString& name); ! Mode mode() const { return _mode; } ! void setMode(Mode m) { _mode = m; } ! float getDefault() const { return _default; } ! void setDefault(float val) { _default = val; } ! float curVal() const { return _curVal; } ! void setCurVal(float val) { _curVal = val; } ! int id() const { return _id; } ! QString name() const { return _name; } ! void setName(const QString& s) { _name = s; } ! void setRange(float min, float max) { ! _min = min; ! _max = max; ! } ! void range(float* min, float* max) const { ! *min = _min; ! *max = _max; ! } ! ! float value(int frame); ! bool add(int tick, float value); ! void del(int tick); ! void setChanged(bool val) { _changed = val; } ! bool changed() const { return _changed; } void read(QDomNode); ! void write(Xml&); }; --- 105,127 ---- Ctrl(); Ctrl(int id, const QString& name); ! int type() const { return _type; } ! void setType(int t) { _type = t; } ! float getDefault() const { return _default; } ! void setDefault(float val) { _default = val; } ! float curVal() const { return _curVal; } ! void setCurVal(float val) { _curVal = val; } ! int id() const { return _id; } ! QString name() const { return _name; } ! void setName(const QString& s) { _name = s; } ! float value(unsigned); ! bool add(unsigned, float value); ! void del(unsigned); ! void setChanged(bool val) { _changed = val; } ! bool changed() const { return _changed; } ! void setRange(float min, float max); void read(QDomNode); ! void write(Xml&, bool writeValues); ! int val2pixel(float val, int maxpixel); ! float pixel2val(int pixel, int maxpixel); }; Index: ctrl.cpp =================================================================== RCS file: /cvsroot/lmuse/muse/muse/ctrl.cpp,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** ctrl.cpp 23 Sep 2004 16:04:02 -0000 1.7 --- ctrl.cpp 24 Sep 2004 16:25:50 -0000 1.8 *************** *** 9,13 **** //========================================================= ! #include "globals.h" #include "ctrl.h" --- 9,13 ---- //========================================================= ! #include "fastlog.h" #include "globals.h" #include "ctrl.h" *************** *** 21,29 **** : _id(id), _name(s) { ! _mode = INTERPOLATE; _default = 0.0; _curVal = 0.0; ! _min = 0.0; ! _max = 1.0; _changed = true; } --- 21,29 ---- : _id(id), _name(s) { ! _type = INTERPOLATE; _default = 0.0; _curVal = 0.0; ! min = 0.0; ! max = 1.0; _changed = true; } *************** *** 35,44 **** Ctrl::Ctrl() { ! _mode = INTERPOLATE; _id = 0; _default = 0.0; _curVal = 0.0; ! _min = 0.0; ! _max = 1.0; _changed = true; } --- 35,44 ---- Ctrl::Ctrl() { ! _type = INTERPOLATE; _id = 0; _default = 0.0; _curVal = 0.0; ! min = 0.0; ! max = 1.0; _changed = true; } *************** *** 48,68 **** //--------------------------------------------------------- ! float Ctrl::value(int frame) { ! if (empty()) { return _curVal; - } ! float v; ! ciCtrlVal i = upper_bound(frame); ! if (i == end()) { ! ciCtrlVal i = end(); ! --i; ! const CtrlVal& val = i->second; ! v = val.val; } else { ! int frame2 = i->second.frame; ! float val2 = i->second.val; int frame1; float val1; --- 48,82 ---- //--------------------------------------------------------- ! float Ctrl::value(unsigned frame) { ! if (empty()) return _curVal; ! float rv; ! if (_type & DISCRETE) { ! ciCtrlVal i = upper_bound(frame); ! if (i == end()) { ! --i; ! rv = i->second; ! } ! else if (i == begin()) { ! if (i->first == frame) ! rv = i->second; ! else ! return _curVal; ! } ! else { ! --i; ! rv = i->second; ! } } else { ! ciCtrlVal i = upper_bound(frame); ! if (i == end()) { ! --i; ! return i->second; ! } ! int frame2 = i->first; ! float val2 = i->second; int frame1; float val1; *************** *** 73,87 **** else { --i; ! frame1 = i->second.frame; ! val1 = i->second.val; } frame -= frame1; val2 -= val1; frame2 -= frame1; ! val1 += (frame * val2)/frame2; ! v = val1; } ! // printf("autoVal %d %f\n", frame, _curVal); ! return v; } --- 87,105 ---- else { --i; ! frame1 = i->first; ! val1 = i->second; } frame -= frame1; val2 -= val1; frame2 -= frame1; ! rv = val1 + (frame * val2)/frame2; } ! if (_type & LOG) { ! if (rv == 1.0f) ! rv = 0.0f; ! else ! rv = pow(10.0f, rv * min); ! } ! return rv; } *************** *** 91,108 **** //--------------------------------------------------------- ! bool Ctrl::add(int frame, float val) { ! // printf("add ctrl %x at %d val %f\n", _id, frame, val); ! // if (_id == 0 && frame == 0 && val == 0.0) ! // abort(); iCtrlVal e = find(frame); if (e != end()) { ! e->second.val = val; return false; } ! else { ! insert(std::pair<const int, CtrlVal> (frame, CtrlVal(frame, val))); ! return true; ! } } --- 109,127 ---- //--------------------------------------------------------- ! bool Ctrl::add(unsigned frame, float val) { ! if (_type & LOG) { ! if (val <= min) ! val = 1.0f; ! else ! val = fast_log10(val) * minli; ! } iCtrlVal e = find(frame); if (e != end()) { ! e->second = val; return false; } ! insert(std::pair<const int, float> (frame, val)); ! return true; } *************** *** 111,115 **** //--------------------------------------------------------- ! void Ctrl::del(int /* frame*/) { } --- 130,134 ---- //--------------------------------------------------------- ! void Ctrl::del(unsigned /* frame*/) { } *************** *** 163,185 **** //--------------------------------------------------------- ! void Ctrl::write(Xml& xml) { QString s("controller id=\"%1\" cur=\"%2\""); ! xml.tag(s.arg(id()).arg(curVal())); ! int i = 0; ! for (ciCtrlVal ic = begin(); ic != end(); ++ic) { ! if (i == 0) ! xml.putLevel(); ! QString s("%1 %2,"); ! xml.nput("%s", s.arg(ic->second.frame).arg(ic->second.val).latin1()); ! ++i; ! if (i >= 4) { ! xml.nput("\n"); ! i = 0; } } - if (i) - xml.nput("\n"); - xml.etag("controller"); } --- 182,248 ---- //--------------------------------------------------------- ! void Ctrl::write(Xml& xml, bool writeValues) { QString s("controller id=\"%1\" cur=\"%2\""); ! if (writeValues && !empty()) { ! xml.tag(s.arg(id()).arg(curVal())); ! int i = 0; ! for (ciCtrlVal ic = begin(); ic != end(); ++ic) { ! if (i == 0) ! xml.putLevel(); ! QString s("%1 %2,"); ! xml.nput("%s", s.arg(ic->first).arg(ic->second).latin1()); ! ++i; ! if (i >= 4) { ! xml.nput("\n"); ! i = 0; ! } } + if (i) + xml.nput("\n"); + xml.etag("controller"); + } + else + xml.tagE(s.arg(id()).arg(curVal())); + } + + //--------------------------------------------------------- + // val2pixel + //--------------------------------------------------------- + + int Ctrl::val2pixel(float val, int maxpixel) + { + return maxpixel - lrint((val * maxpixel) / (max - min) + min); + } + + //--------------------------------------------------------- + // pixel2val + //--------------------------------------------------------- + + float Ctrl::pixel2val(int pixel, int maxpixel) + { + float val = (float(maxpixel - pixel) + min) * (max - min) / float(maxpixel); + if (val < min) + val = min; + else if (val > max) + val = max; + return val; + } + + //--------------------------------------------------------- + // setRange + //--------------------------------------------------------- + + void Ctrl::setRange(float _min, float _max) + { + if (_type & LOG) { + min = fast_log10(_min); + max = fast_log10(_max); + minli = 1.0f/min; + } + else { + min = _min; + max = _max; } } |