コード例 #1
0
ファイル: pos.cpp プロジェクト: faesong/oom
void PosLen::read(Xml& xml, const char* name)
{
    sn = -1;
    for (;;)
    {
        Xml::Token token = xml.parse();
        const QString& tag = xml.s1();
        switch (token)
        {
        case Xml::Error:
        case Xml::End:
            return;

        case Xml::TagStart:
            xml.unknown(name);
            break;

        case Xml::Attribut:
            if (tag == "tick")
            {
                setType(TICKS);
                setTick(xml.s2().toInt());
            }
            else if (tag == "sample")
            {
                setType(FRAMES);
                setFrame(xml.s2().toInt());
            }
            else if (tag == "len")
            {
                int n = xml.s2().toInt();
                switch (type())
                {
                case TICKS:
                    setLenTick(n);
                    break;
                case FRAMES:
                    setLenFrame(n);
                    break;
                }
            }
            else
                xml.unknown(name);
            break;

        case Xml::TagEnd:
            if (tag == name)
                return;
        default:
            break;
        }
    }
}
コード例 #2
0
ファイル: minstrument.cpp プロジェクト: UIKit0/muse
void MidiInstrument::readDrummaps(Xml& xml)
{
  patch_drummap_mapping.clear();

  for (;;)
  {
    Xml::Token token = xml.parse();
    const QString& tag = xml.s1();
    switch (token)
    {
      case Xml::Error:
      case Xml::End:
        return;

      case Xml::TagStart:
        if (tag == "entry")
          patch_drummap_mapping.push_back(readDrummapsEntry(xml));
        else
          xml.unknown("MidiInstrument::readDrummaps");
        break;

      case Xml::TagEnd:
        if (tag == "Drummaps")
          return;

      default:
        break;
    }
  }
  printf("ERROR: THIS CANNOT HAPPEN: exited infinite loop in MidiInstrument::readDrummaps()!\n"
         "                           not returning anything. expect undefined behaviour or even crashes.\n");
}
コード例 #3
0
ファイル: minstrument.cpp プロジェクト: UIKit0/muse
static void readEventList(Xml& xml, EventList* el, const char* name)
      {
      for (;;) {
            Xml::Token token = xml.parse();
            const QString& tag = xml.s1();
            switch (token) {
                  case Xml::Error:
                  case Xml::End:
                        return;
                  case Xml::TagStart:
                        if (tag == "event") {
                              Event e(Note);
                              e.read(xml);
                              el->add(e);
                              }
                        else
                              xml.unknown("readEventList");
                        break;
                  case Xml::TagEnd:
                        if (tag == name)
                              return;
                  default:
                        break;
                  }
            }
      }
コード例 #4
0
ファイル: AbstractMidiEditor.cpp プロジェクト: peter1000/los
void AbstractMidiEditor::readStatus(Xml& xml)/*{{{*/
{
    if (_pl == 0)
        _pl = new PartList;

    for (;;)
    {
        Xml::Token token = xml.parse();
        QString tag = xml.s1();
        switch (token)
        {
            case Xml::Error:
            case Xml::End:
                return;
            case Xml::TagStart:
                if (tag == "quant")
                    _quant = xml.parseInt();
                else if (tag == "raster")
                    _raster = xml.parseInt();
                else if (tag == "topwin")
                    TopWin::readStatus(xml);
                else
                    xml.unknown("AbstractMidiEditor");
                break;
            case Xml::TagEnd:
                if (tag == "midieditor")
                    return;
            default:
                break;
        }
    }
}/*}}}*/
コード例 #5
0
ファイル: tempo.cpp プロジェクト: Adamiko/los
int TEvent::read(Xml& xml)
{
	int at = 0;
	for (;;)
	{
		Xml::Token token = xml.parse();
		const QString& tag = xml.s1();
		switch (token)
		{
			case Xml::Error:
			case Xml::End:
				return 0;
			case Xml::TagStart:
				if (tag == "tick")
					tick = xml.parseInt();
				else if (tag == "val")
					tempo = xml.parseInt();
				else
					xml.unknown("TEvent");
				break;
			case Xml::Attribut:
				if (tag == "at")
					at = xml.s2().toInt();
				break;
			case Xml::TagEnd:
				if (tag == "tempo")
				{
					return at;
				}
			default:
				break;
		}
	}
	return 0;
}
コード例 #6
0
ファイル: conf.cpp プロジェクト: Adamiko/los
static QPair<int, QString> readMidiPortPreset(Xml& xml)/*{{{*/
{
    int id = 0;
    QString sysex;

    for (;;)
    {
        Xml::Token token = xml.parse();
        QString tag = xml.s1();
        switch (token)
        {
            case Xml::TagStart:
                xml.unknown("midiPreset");
                break;
            case Xml::Attribut:
                if (tag == "id")
                    id = xml.s2().toInt();
                else if (tag == "sysex")
                {
                    sysex = xml.s2();
                }
                break;
            case Xml::TagEnd:
                return qMakePair(id, sysex);
            default:
                break;
        }
    }
}/*}}}*/
コード例 #7
0
ファイル: minstrument.cpp プロジェクト: UIKit0/muse
void PatchGroup::read(Xml& xml)
      {
      for (;;) {
            Xml::Token token = xml.parse();
            const QString& tag = xml.s1();
            switch (token) {
                  case Xml::Error:
                  case Xml::End:
                        return;
                  case Xml::TagStart:
                        if (tag == "Patch") {
                              Patch* patch = new Patch;
                              patch->read(xml);
                              patches.push_back(patch);
                              }
                        else
                              xml.unknown("PatchGroup");
                        break;
                  case Xml::Attribut:
                        if (tag == "name")
                              name = xml.s2();
                        break;
                  case Xml::TagEnd:
                        if (tag == "PatchGroup")
                              return;
                  default:
                        break;
                  }
            }
      }
コード例 #8
0
ファイル: wavetrack.cpp プロジェクト: EQ4/muse
void WaveTrack::read(Xml& xml)
      {
      for (;;) {
            Xml::Token token = xml.parse();
            const QString& tag = xml.s1();
            switch (token) {
                  case Xml::Error:
                  case Xml::End:
                        goto out_of_WaveTrackRead_forloop;
                  case Xml::TagStart:
                        if (tag == "part") {
                              Part* p = 0;
                              p = Part::readFromXml(xml, this);
                              if(p)
                                parts()->add(p);
                              }
                        else if (AudioTrack::readProperties(xml, tag))
                              xml.unknown("WaveTrack");
                        break;
                  case Xml::Attribut:
                        break;
                  case Xml::TagEnd:
                        if (tag == "wavetrack") {
                              mapRackPluginsToControllers();
                              goto out_of_WaveTrackRead_forloop;
                              }
                  default:
                        break;
                  }
            }
out_of_WaveTrackRead_forloop:
      chainTrackParts(this);
      }
コード例 #9
0
ファイル: masteredit.cpp プロジェクト: Adamiko/los
void MasterEdit::readConfiguration(Xml& xml)
{
    for (;;)
    {
        Xml::Token token = xml.parse();
        const QString& tag = xml.s1();
        switch (token)
        {
            case Xml::Error:
            case Xml::End:
                return;
            case Xml::TagStart:
                if (tag == "raster")
                    _rasterInit = xml.parseInt();
                else
                    xml.unknown("MasterEdit");
                break;
            case Xml::TagEnd:
                if (tag == "masteredit")
                    return;
            default:
                break;
        }
    }
}
コード例 #10
0
ファイル: sig.cpp プロジェクト: faesong/oom
int SigEvent::read(Xml& xml)
{
	int at = 0;
	for (;;)
	{
		Xml::Token token = xml.parse();
		const QString& tag = xml.s1();
		switch (token)
		{
			case Xml::Error:
			case Xml::End:
				return 0;
			case Xml::TagStart:
				if (tag == "tick")
					tick = xml.parseInt();
				else if (tag == "nom")
					z = xml.parseInt();
				else if (tag == "denom")
					n = xml.parseInt();
				else
					xml.unknown("SigEvent");
				break;
			case Xml::Attribut:
				if (tag == "at")
					at = xml.s2().toInt();
				break;
			case Xml::TagEnd:
				if (tag == "sig")
					return at;
			default:
				break;
		}
	}
	return 0;
}
コード例 #11
0
ファイル: eventlist.cpp プロジェクト: 87maxi/oom
void EventList::read(Xml& xml, const char* name, bool midi)
{
	for (;;)
	{
		Xml::Token token = xml.parse();
		const QString& tag = xml.s1();
		switch (token)
		{
			case Xml::Error:
			case Xml::End:
				return;
			case Xml::TagStart:
				if (tag == "event")
				{
					Event e(midi ? Note : Wave);
					e.read(xml);
					add(e);
				}
				else
					xml.unknown("readEventList");
				break;
			case Xml::TagEnd:
				if (tag == name)
					return;
			default:
				break;
		}
	}
}
コード例 #12
0
ファイル: midievent.cpp プロジェクト: 87maxi/oom
void MidiEventBase::read(Xml& xml)
{
	setType(Note);
	a = 0;
	b = 0;
	c = 0;

	int dataLen = 0;
	for (;;)
	{
		Xml::Token token = xml.parse();
		const QString& tag = xml.s1();
		switch (token)
		{
			case Xml::Error:
			case Xml::End:
				return;
			case Xml::TagStart:
				xml.unknown("Event");
				break;
			case Xml::Text:
			{
				QByteArray ba = tag.toLatin1();
				const char*s = ba.constData();
				edata.data = new unsigned char[dataLen];
				edata.dataLen = dataLen;
				unsigned char* d = edata.data;
				for (int i = 0; i < dataLen; ++i)
				{
					char* endp;
					*d++ = strtol(s, &endp, 16);
					s = endp;
				}
			}
				break;
			case Xml::Attribut:
				if (tag == "tick")
					setTick(xml.s2().toInt());
				else if (tag == "type")
					setType(EventType(xml.s2().toInt()));
				else if (tag == "len")
					setLenTick(xml.s2().toInt());
				else if (tag == "a")
					a = xml.s2().toInt();
				else if (tag == "b")
					b = xml.s2().toInt();
				else if (tag == "c")
					c = xml.s2().toInt();
				else if (tag == "datalen")
					dataLen = xml.s2().toInt();
				break;
			case Xml::TagEnd:
				if (tag == "event")
					return;
			default:
				break;
		}
	}
}
コード例 #13
0
ファイル: pos.cpp プロジェクト: faesong/oom
void Pos::read(Xml& xml, const char* name)
{
    sn = -1;
    for (;;)
    {
        Xml::Token token = xml.parse();
        const QString& tag = xml.s1();
        switch (token)
        {
        case Xml::Error:
        case Xml::End:
            return;

        case Xml::TagStart:
            xml.unknown(name);
            break;

        case Xml::Attribut:
            if (tag == "tick")
            {
                _tick = xml.s2().toInt();
                _type = TICKS;
            }
            else if (tag == "frame")
            {
                _frame = xml.s2().toInt();
                _type = FRAMES;
            }
            else if (tag == "sample")
            {   // obsolete
                _frame = xml.s2().toInt();
                _type = FRAMES;
            }
            else
                xml.unknown(name);
            break;

        case Xml::TagEnd:
            if (tag == name)
                return;
        default:
            break;
        }
    }
}
コード例 #14
0
ファイル: masteredit.cpp プロジェクト: Adamiko/los
void MasterEdit::readStatus(Xml& xml)
{
    for (;;)
    {
        Xml::Token token = xml.parse();
        const QString& tag = xml.s1();
        switch (token)
        {
            case Xml::Error:
            case Xml::End:
                return;
            case Xml::TagStart:
                if (tag == "midieditor")
                    AbstractMidiEditor::readStatus(xml);
                else if (tag == "ypos")
                    vscroll->setPos(xml.parseInt());
                else if (tag == "ymag")
                {
                    // vscroll->setMag(xml.parseInt());
                    int mag = xml.parseInt();
                    vscroll->setMag(mag);
                }
                else
                    xml.unknown("MasterEdit");
                break;
            case Xml::TagEnd:
                if (tag == "master")
                {
                    // raster setzen
                    int item = 0;
                    switch (_raster)
                    {
                        case 1: item = 0;
                            break;
                        case 0: item = 1;
                            break;
                        case 768: item = 2;
                            break;
                        case 384: item = 3;
                            break;
                        case 192: item = 4;
                            break;
                        case 96: item = 5;
                            break;
                    }
                    _rasterInit = _raster;
                    rasterLabel->setCurrentIndex(item);
                    return;
                }
            default:
                break;
        }
    }
}
コード例 #15
0
ファイル: minstrument.cpp プロジェクト: UIKit0/muse
void MidiInstrument::readMidiState(Xml& xml)
{
  // A kludge to support old midistates by wrapping them in the proper header.
  _tmpMidiStateVersion = 1;    // Assume old (unmarked) first version 1.
  for (;;)
  {
    Xml::Token token = xml.parse();
    const QString tag = xml.s1();
    switch (token)
    {
          case Xml::Error:
          case Xml::End:
                return;
          case Xml::TagStart:
                if (tag == "event")
                {
                  Event e(Note);
                  e.read(xml);
                  _midiState->add(e);
                }
                else
                xml.unknown("midistate");
                break;
          case Xml::Attribut:
                if(tag == "version")
                  _tmpMidiStateVersion = xml.s2().toInt();
                else
                  xml.unknown("MidiInstrument");
                break;
          case Xml::TagEnd:
                if(tag == "midistate")
                  return;
          default:
                break;
    }
  }
}
コード例 #16
0
ファイル: minstrument.cpp プロジェクト: UIKit0/muse
bool SysEx::read(Xml& xml)
      {
      for (;;) {
            Xml::Token token = xml.parse();
            const QString& tag = xml.s1();
            switch (token) {
                  case Xml::Error:
                  case Xml::End:
                        return false;
                  case Xml::TagStart:
                        if (tag == "comment")
                              comment = xml.parse1();
                        else if (tag == "data")
                        {
                              unsigned char*d;
                              int len = string2sysex(xml.parse1(), &d);
                              // Was the conversion succesful, even if empty?
                              if(len != -1)
                              {
                                // Delete existing.
                                if(dataLen != 0 && data)
                                  delete[] data;
                                dataLen = len;
                                data = d;
                              }
                        }
                        else
                              xml.unknown("SysEx");
                        break;
                  case Xml::Attribut:
                        if (tag == "name")
                              name = xml.s2();
                        break;
                  case Xml::TagEnd:
                        if (tag == "SysEx")
                        {
                          return !name.isEmpty();
                        }
                  default:
                        break;
                  }
            }

      return false;
      }
コード例 #17
0
ファイル: waveevent.cpp プロジェクト: Adamiko/los
void WaveEventBase::read(Xml& xml)
{
    for (;;)
    {
        Xml::Token token = xml.parse();
        const QString& tag = xml.s1();
        switch (token)
        {
            case Xml::Error:
            case Xml::End:
            case Xml::Attribut:
                return;
            case Xml::TagStart:
                if (tag == "poslen")
                    PosLen::read(xml, "poslen");
                else if (tag == "frame")
                    _spos = xml.parseInt();
                else if(tag == "leftclip")
                    m_leftclip = xml.parseInt();
                else if(tag == "rightclip")
                    m_rightclip = xml.parseInt();
                else if (tag == "file")
                {
                    SndFile* wf = getWave(xml.parse1(), true);
                    if (wf)
                    {
                        f = SndFileR(wf);
                    }
                }
                else
                    xml.unknown("Event");
                break;
            case Xml::TagEnd:
                if (tag == "event")
                {
                    Pos::setType(FRAMES); // DEBUG
                    return;
                }
            default:
                break;
        }
    }
}
コード例 #18
0
ファイル: tempo.cpp プロジェクト: Adamiko/los
void TempoList::read(Xml& xml)
{
	for (;;)
	{
		Xml::Token token = xml.parse();
		const QString& tag = xml.s1();
		switch (token)
		{
			case Xml::Error:
			case Xml::End:
				return;
			case Xml::TagStart:
				if (tag == "tempo")
				{
					TEvent* t = new TEvent();
					unsigned tick = t->read(xml);
					iTEvent pos = find(tick);
					if (pos != end())
						erase(pos);
					insert(std::pair<const int, TEvent*> (tick, t));
				}
				else if (tag == "globalTempo")
					_globalTempo = xml.parseInt();
				else
					xml.unknown("TempoList");
				break;
			case Xml::Attribut:
				if (tag == "fix")
					_tempo = xml.s2().toInt();
				break;
			case Xml::TagEnd:
				if (tag == "tempolist")
				{
					normalize();
					++_tempoSN;
					return;
				}
			default:
				break;
		}
	}
}
コード例 #19
0
ファイル: minstrument.cpp プロジェクト: UIKit0/muse
void Patch::read(Xml& xml)
      {
      //typ   = -1;
      hbank = -1;
      lbank = -1;
      prog  = 0;
      drum  = false;
      for (;;) {
            Xml::Token token = xml.parse();
            const QString& tag = xml.s1();
            switch (token) {
                  case Xml::Error:
                  case Xml::End:
                        return;
                  case Xml::TagStart:
                        xml.unknown("Patch");
                        break;
                  case Xml::Attribut:
                        if (tag == "name")
                              name = xml.s2();
                        else if (tag == "mode")  // Obsolete
                        {
                              //typ = xml.s2().toInt();
                              xml.s2().toInt();
                        }
                        else if (tag == "hbank")
                              hbank = xml.s2().toInt();
                        else if (tag == "lbank")
                              lbank = xml.s2().toInt();
                        else if (tag == "prog")
                              prog = xml.s2().toInt();
                        else if (tag == "drum")
                              drum = xml.s2().toInt();
                        break;
                  case Xml::TagEnd:
                        if (tag == "Patch")
                              return;
                  default:
                        break;
                  }
            }
      }
コード例 #20
0
ファイル: minstrument.cpp プロジェクト: UIKit0/muse
patch_collection_t MidiInstrument::readDrummapsEntryPatchCollection(Xml& xml)
{
  int first_prog=0, last_prog=256;   // this means:
  int first_lbank=0, last_lbank=256; // "does not matter"
  int first_hbank=0, last_hbank=256;

  for (;;)
  {
    Xml::Token token = xml.parse();
    const QString& tag = xml.s1();
    switch (token)
    {
      case Xml::Error:
      case Xml::End:
        return patch_collection_t(-1,-1,-1,-1,-1,-1); // an invalid collection

      case Xml::TagStart:
        xml.unknown("MidiInstrument::readDrummapsEntryPatchCollection");
        break;

      case Xml::Attribut:
        if (tag == "prog")
          parse_range(xml.s2(), &first_prog, &last_prog);
        else if (tag == "lbank")
          parse_range(xml.s2(), &first_lbank, &last_lbank);
        else if (tag == "hbank")
          parse_range(xml.s2(), &first_hbank, &last_hbank);
        break;

      case Xml::TagEnd:
        if (tag == "patch_collection")
          return patch_collection_t(first_prog, last_prog, first_lbank, last_lbank, first_hbank, last_hbank);

      default:
        break;
    }
  }

  printf("ERROR: THIS CANNOT HAPPEN: exited infinite loop in MidiInstrument::readDrummapsEntryPatchCollection()!\n"
         "                           not returning anything. expect undefined behaviour or even crashes.\n");
}
コード例 #21
0
ファイル: markerview.cpp プロジェクト: faesong/oom
void MarkerView::readStatus(Xml& xml)
{
	for (;;)
	{
		Xml::Token token = xml.parse();
		const QString& tag = xml.s1();
		if (token == Xml::Error || token == Xml::End)
			break;
		switch (token)
		{
			case Xml::TagStart:
				xml.unknown("Marker");
				break;
			case Xml::TagEnd:
				if (tag == "marker")
					return;
			default:
				break;
		}
	}
}
コード例 #22
0
ファイル: minstrument.cpp プロジェクト: UIKit0/muse
patch_drummap_mapping_t MidiInstrument::readDrummapsEntry(Xml& xml)
{
  using std::list;

  patch_collection_t collection;
  DrumMap* drummap=new DrumMap[128];
  for (int i=0;i<128;i++)
    drummap[i]=iNewDrumMap[i];

  for (;;)
  {
    Xml::Token token = xml.parse();
    const QString& tag = xml.s1();
    switch (token)
    {
      case Xml::Error:
      case Xml::End:
        return patch_drummap_mapping_t(collection, drummap);

      case Xml::TagStart:
        if (tag == "patch_collection")
          collection=readDrummapsEntryPatchCollection(xml);
        else if (tag == "drummap")
          read_new_style_drummap(xml, "drummap", drummap);
        else
          xml.unknown("MidiInstrument::readDrummapsEntry");
        break;

      case Xml::TagEnd:
        if (tag == "entry")
          return patch_drummap_mapping_t(collection, drummap);

      default:
        break;
    }
  }
  printf("ERROR: THIS CANNOT HAPPEN: exited infinite loop in MidiInstrument::readDrummapsEntry()!\n"
         "                           not returning anything. expect undefined behaviour or even crashes.\n");
  return patch_drummap_mapping_t();
}
コード例 #23
0
ファイル: minstrument.cpp プロジェクト: ViktorNova/los
void KeyMap::read(Xml& xml)/*{{{*/
{
    program = -1;
    pname = "";
    comment = "";
    key = -1;
    hasProgram = false;
    for (;;)
    {
        Xml::Token token = xml.parse();
        const QString& tag = xml.s1();
        switch (token)
        {
            case Xml::Error:
            case Xml::End:
                return;
            case Xml::TagStart:
                xml.unknown("KeyMap");
                break;
            case Xml::Attribut:
                if (tag == "comment")
                    comment = xml.s2();
                else if (tag == "program")
                    program = xml.s2().toInt();
                else if (tag == "key")
                    key = xml.s2().toInt();
                else if (tag == "pname")
                    pname = xml.s2();
                else if(tag == "hasProgram")
                    hasProgram = (bool)xml.s2().toInt();
                break;
            case Xml::TagEnd:
                if (tag == "KeyMap")
                    return;
            default:
                break;
        }
    }
}/*}}}*/
コード例 #24
0
ファイル: plugin.cpp プロジェクト: 87maxi/oom
 virtual void read(Xml& xml)
 {
     for (;;)
     {
         Xml::Token token = xml.parse();
         const QString& tag = xml.s1();
         switch (token)
         {
             case Xml::Error:
             case Xml::End:
                 return;
             case Xml::TagStart:
                 if (tag == "SynthPluginTrack")
                 {
                     continue;
                 }
                 else if (tag == "LadspaPlugin" || tag == "Lv2Plugin" || tag == "VstPlugin")
                 {
                     // we already loaded this before
                     xml.parse1();
                     continue;
                 }
                 if (AudioTrack::readProperties(xml, tag))
                     xml.unknown("SynthPluginTrack");
                 break;
             case Xml::Attribut:
                 break;
             case Xml::TagEnd:
                 if (tag == "SynthPluginTrack")
                 {
                     mapRackPluginsToControllers();
                     return;
                 }
             default:
                 break;
         }
     }
 }
コード例 #25
0
ファイル: sig.cpp プロジェクト: faesong/oom
void SigList::read(Xml& xml)
{
	for (;;)
	{
		Xml::Token token = xml.parse();
		const QString& tag = xml.s1();
		switch (token)
		{
			case Xml::Error:
			case Xml::End:
				return;
			case Xml::TagStart:
				if (tag == "sig")
				{
					SigEvent* t = new SigEvent();
					unsigned tick = t->read(xml);
					iSigEvent pos = find(tick);
					if (pos != end())
						erase(pos);
					insert(std::pair<const unsigned, SigEvent*> (tick, t));
				}
				else
					xml.unknown("SigList");
				break;
			case Xml::Attribut:
				break;
			case Xml::TagEnd:
				if (tag == "siglist")
				{
					normalize();
					return;
				}
			default:
				break;
		}
	}
}
コード例 #26
0
ファイル: minstrument.cpp プロジェクト: UIKit0/muse
void MidiInstrument::read(Xml& xml)
      {
      for (;;) {
            Xml::Token token = xml.parse();
            const QString& tag = xml.s1();
            switch (token) {
                  case Xml::Error:
                  case Xml::End:
                        return;
                  case Xml::TagStart:
                        if (tag == "Patch") {
                              Patch* patch = new Patch;
                              patch->read(xml);
                              if (pg.empty()) {
                                    PatchGroup* p = new PatchGroup;
                                    p->patches.push_back(patch);
                                    pg.push_back(p);
                                    }
                              else
                                    pg[0]->patches.push_back(patch);
                              }
                        else if (tag == "PatchGroup") {
                              PatchGroup* p = new PatchGroup;
                              p->read(xml);
                              pg.push_back(p);
                              }
                        else if (tag == "Controller") {
                              MidiController* mc = new MidiController();
                              mc->read(xml);
                              //
                              // HACK: make predefined "Program" controller overloadable
                              //
                              if (mc->name() == "Program") {
                                    for (iMidiController i = _controller->begin(); i != _controller->end(); ++i) {
                                          if (i->second->name() == mc->name()) {
                                                delete i->second;
                                                _controller->del(i);
                                                break;
                                                }
                                          }
                                    }

                              _controller->add(mc);
                              }
                        else if (tag == "Drummaps") {
                              readDrummaps(xml);
                              }
                        else if (tag == "Init")
                              readEventList(xml, _midiInit, "Init");
                        else if (tag == "Reset")
                              readEventList(xml, _midiReset, "Reset");
                        else if (tag == "State")
                              readEventList(xml, _midiState, "State");
                        else if (tag == "InitScript") {
                              if (_initScript)
                                    delete _initScript;
                              QByteArray ba = xml.parse1().toLatin1();
                              const char* istr = ba.constData();
                              int len = ba.length() +1;
                              if (len > 1) {
                                    _initScript = new char[len];
                                    memcpy(_initScript, istr, len);
                                    }
                              }
                        else if (tag == "SysEx") {
                              SysEx* se = new SysEx;
                              if(!se->read(xml))
                              {
                                delete se;
                                printf("MidiInstrument::read():SysEx: reading sysex failed\n");
                              }
                              else
                                _sysex.append(se);
                              }
                        else
                              xml.unknown("MidiInstrument");
                        break;
                  case Xml::Attribut:
                        if (tag == "name")
                              setIName(xml.s2());
                        else if(tag == "nullparam") { } // Obsolete.
                        else if(tag == "NoteOffMode") 
                              _noteOffMode = (NoteOffMode)xml.s2().toInt(); // Default is NoteOffAll.
                        break;
                  case Xml::TagEnd:
                        if (tag == "MidiInstrument")
                              return;
                  default:
                        break;
                  }
            }
      }
コード例 #27
0
ファイル: minstrument.cpp プロジェクト: ViktorNova/los
void Patch::read(Xml& xml)/*{{{*/
{
    typ = -1;
    hbank = -1;
    lbank = -1;
    prog = 0;
    drum = false;
    keys.clear();
    keyswitches.clear();
    loadmode = -1;
    index = -1;
    volume = 1.0;
    for (;;)
    {
        Xml::Token token = xml.parse();
        const QString& tag = xml.s1();
        switch (token)
        {
            case Xml::Error:
            case Xml::End:
                return;
            case Xml::TagStart:
                xml.unknown("Patch");
                break;
            case Xml::Attribut:
                if (tag == "name")
                    name = xml.s2();
                else if (tag == "mode")
                    typ = xml.s2().toInt();
                else if (tag == "hbank")
                    hbank = xml.s2().toInt();
                else if (tag == "lbank")
                    lbank = xml.s2().toInt();
                else if (tag == "prog")
                    prog = xml.s2().toInt();
                else if (tag == "drum")
                    drum = xml.s2().toInt();
                else if(tag == "keys")
                {
                    QStringList klist = ((QString)xml.s2()).split(QString(" "), QString::SkipEmptyParts);
                    for (QStringList::Iterator it = klist.begin(); it != klist.end(); ++it)
                    {
                        int val = (*it).toInt();
                        keys.append(val);
                    }
                }
                else if(tag == "keyswitches")
                {
                    QStringList klist = ((QString)xml.s2()).split(QString(" "), QString::SkipEmptyParts);
                    for (QStringList::Iterator it = klist.begin(); it != klist.end(); ++it)
                    {
                        int val = (*it).toInt();
                        keyswitches.append(val);
                    }
                }
                else if(tag == "comments")
                {
                    QStringList clist = ((QString)xml.s2()).split(QString(" "), QString::SkipEmptyParts);
                    for (QStringList::Iterator it = clist.begin(); it != clist.end(); ++it)
                    {
                        QStringList hashlist = ((*it)).split(QString("@@:@@"), QString::SkipEmptyParts);
                        if(hashlist.size() == 2)
                        {
                            int k = hashlist.at(0).toInt();
                            comments[k] = hashlist.at(1);
                        }
                    }
                }
                else if(tag == "engine")
                {
                    engine = xml.s2();
                }
                else if(tag == "filename")
                {
                    filename = xml.s2();
                }
                else if(tag == "loadmode")
                {
                    loadmode = xml.s2().toInt();
                }
                else if(tag == "volume")
                {
                    volume = xml.s2().toFloat();
                }
                else if(tag == "index")
                {
                    index = xml.s2().toInt();
                }
                break;
            case Xml::TagEnd:
                if (tag == "Patch")
                    return;
            default:
                break;
        }
    }
}/*}}}*/
コード例 #28
0
ファイル: minstrument.cpp プロジェクト: ViktorNova/los
void MidiInstrument::read(Xml& xml)
{
    bool ok;
    int base = 10;
    _nullvalue = -1;
    m_keymaps.clear();
    for (;;)
    {
        Xml::Token token = xml.parse();
        const QString& tag = xml.s1();
        switch (token)
        {
            case Xml::Error:
            case Xml::End:
                return;
            case Xml::TagStart:
                if (tag == "Patch")
                {
                    Patch* patch = new Patch;
                    patch->read(xml);
                    if (pg.empty())
                    {
                        PatchGroup* p = new PatchGroup;
                        p->patches.push_back(patch);
                        pg.push_back(p);
                    }
                    else
                        pg[0]->patches.push_back(patch);
                }
                else if (tag == "PatchGroup")
                {
                    PatchGroup* p = new PatchGroup;
                    p->read(xml);
                    pg.push_back(p);
                }
                else if (tag == "Controller")
                {
                    MidiController* mc = new MidiController();
                    mc->read(xml);
                    // Added by Tim. Copied from los 2.
                    //
                    // HACK: make predefined "Program" controller overloadable
                    //
                    if (mc->name() == "Program")
                    {
                        for (iMidiController i = _controller->begin(); i != _controller->end(); ++i)
                        {
                            if (i->second->name() == mc->name())
                            {
                                delete i->second;
                                _controller->erase(i);
                                break;
                            }
                        }
                    }

                    _controller->add(mc);
                }
                else if (tag == "Init")
                    readEventList(xml, _midiInit, "Init");
                else if (tag == "Reset")
                    readEventList(xml, _midiReset, "Reset");
                else if (tag == "State")
                    readEventList(xml, _midiState, "State");
                else if (tag == "InitScript")
                {
                    if (_initScript)
                        delete _initScript;
                    QByteArray ba = xml.parse1().toLatin1();
                    const char* istr = ba.constData();
                    int len = strlen(istr) + 1;
                    if (len > 1)
                    {
                        _initScript = new char[len];
                        memcpy(_initScript, istr, len);
                    }
                }
                else if(tag == "KeyMap")
                {
                    KeyMap *km = new KeyMap;
                    km->read(xml);
                    m_keymaps.insert(km->key, km);
                }
                else
                    xml.unknown("MidiInstrument");
                break;
            case Xml::Attribut:
                if (tag == "name")
                    setIName(xml.s2());
                else if (tag == "nullparam")
                {
                    _nullvalue = xml.s2().toInt(&ok, base);
                }
                else if(tag == "panValue")
                    m_panValue = xml.s2().toDouble();
                break;
            case Xml::TagEnd:
                if (tag == "MidiInstrument")
                    return;
            default:
                break;
        }
    }
}
コード例 #29
0
ファイル: EffectRack.cpp プロジェクト: bartart3d/oom
void EffectRack::initPlugin(Xml xml, int idx)/*{{{*/
{
    for (;;)
    {
        Xml::Token token = xml.parse();
        QString tag = xml.s1();
        switch (token)
        {
        case Xml::Error:
        case Xml::End:
            return;
        case Xml::TagStart:
            if (tag == "LadspaPlugin" || tag == "plugin")
            {
                LadspaPlugin* ladplug = new LadspaPlugin();
                if (ladplug->readConfiguration(xml, false))
                {
                    printf("cannot instantiate plugin\n");
                    delete ladplug;
                }
                else
                {
                    audio->msgAddPlugin(track, idx, ladplug);
                    song->update(SC_RACK);
                    return;
                }
            }
            else if (tag == "Lv2Plugin")
            {
                Lv2Plugin* lv2plug = new Lv2Plugin();
                if (lv2plug->readConfiguration(xml, false))
                {
                    printf("cannot instantiate plugin\n");
                    delete lv2plug;
                }
                else
                {
                    audio->msgAddPlugin(track, idx, lv2plug);
                    song->update(SC_RACK);
                    return;
                }
            }
            else if (tag == "VstPlugin")
            {
                VstPlugin* vstplug = new VstPlugin();
                if (vstplug->readConfiguration(xml, false))
                {
                    printf("cannot instantiate plugin\n");
                    delete vstplug;
                }
                else
                {
                    audio->msgAddPlugin(track, idx, vstplug);
                    song->update(SC_RACK);
                    return;
                }
            }
            else if (tag == "oom")
                break;
            else
                xml.unknown("EffectRack");
            break;
        case Xml::Attribut:
            break;
        case Xml::TagEnd:
            if (tag == "oom")
                return;
        default:
            break;
        }
    }
}/*}}}*/
コード例 #30
0
ファイル: route.cpp プロジェクト: 87maxi/oom
void Song::readRoute(Xml& xml)/*{{{*/
{
	QString src;
	QString dst;
	int ch = -1;
	int chs = -1;
	int remch = -1;

	Route sroute, droute;

	for (;;)
	{
		const QString& tag = xml.s1();
		Xml::Token token = xml.parse();
		switch (token)
		{
			case Xml::Error:
			case Xml::End:
				return;
			case Xml::TagStart:
				if (tag == "source")
				{
					sroute.read(xml);
					sroute.channel = ch;
					sroute.channels = chs;
					sroute.remoteChannel = remch;
				}
				else if (tag == "dest")
				{
					droute.read(xml);
					droute.channel = ch;
					droute.channels = chs;
					droute.remoteChannel = remch;
				}
				else
					xml.unknown("readRoute");
				break;
			case Xml::Attribut:
#ifdef ROUTE_DEBUG
				printf("Song::readRoute(): attribute:%s\n", tag.toLatin1().constData());
#endif
				if (tag == "channel")
					ch = xml.s2().toInt();
				else
					if (tag == "channels")
					chs = xml.s2().toInt();
				else
					if (tag == "remch")
					remch = xml.s2().toInt();
				else
					if (tag == "channelMask") // p3.3.50 New channel mask for midi port-track routes.
					ch = xml.s2().toInt();
				else
					printf("Song::readRoute(): unknown attribute:%s\n", tag.toLatin1().constData());
				break;
			case Xml::TagEnd:
				if (xml.s1() == "Route")
				{
					if (sroute.isValid() && droute.isValid())// Support new routes.
					{
						// p3.3.49 Support pre- 1.1-RC2 midi-device-to-track routes. Obsolete. Replaced with midi port routes.
						if (sroute.type == Route::MIDI_DEVICE_ROUTE && droute.type == Route::TRACK_ROUTE)
						{
							if (sroute.device->midiPort() >= 0 && sroute.device->midiPort() < MIDI_PORTS
									&& ch >= 0 && ch < MIDI_CHANNELS)
							{
								sroute.midiPort = sroute.device->midiPort();
								sroute.device = 0;
								sroute.type = Route::MIDI_PORT_ROUTE;

								sroute.channel = 1 << ch; // p3.3.50  Convert to new bit-wise channel mask.
								droute.channel = sroute.channel;

								addRoute(sroute, droute);
							}
							else
								printf("  Warning - device:%s to track route, no device midi port or chan:%d out of range. Ignoring route!\n",
									sroute.device->name().toLatin1().constData(), ch);
						}
						else if (sroute.type == Route::TRACK_ROUTE && droute.type == Route::MIDI_DEVICE_ROUTE)
						{
							if (droute.device->midiPort() >= 0 && droute.device->midiPort() < MIDI_PORTS
									&& ch >= 0 && ch < MIDI_CHANNELS) // p3.3.50
							{
								droute.midiPort = droute.device->midiPort();
								droute.device = 0;
								droute.type = Route::MIDI_PORT_ROUTE;

								droute.channel = 1 << ch; // p3.3.50  Convert to new bit-wise channel mask.
								sroute.channel = droute.channel;

								addRoute(sroute, droute);
							}
							else
								printf("  Warning - track to device:%s route, no device midi port or chan:%d out of range. Ignoring route!\n",
									droute.device->name().toLatin1().constData(), ch);
						}
						else
						{
							//printf("adding new route...\n");
							addRoute(sroute, droute);
						}
					}
					else
						printf("  Warning - route invalid. Ignoring route! srcValid: %d, destValid: %d\n", 
								sroute.isValid(), droute.isValid());

					return;
				}
			default:
				break;
		}
	}
}/*}}}*/