예제 #1
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;
      }
예제 #2
0
파일: trackview.cpp 프로젝트: faesong/oom
void TrackView::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 == "name")
				{
					_name = xml.parse1();
				}
				else if(tag == "comment")
				{
					_comment = xml.parse1();
				}
				else if(tag == "selected")
				{
					_selected = (bool)xml.parseInt();
				}
				else if (tag == "vtrack")
				{
					Track* t = song->findTrack(xml.parse1());
					if (t)
					{
						//printf("TrackView::read() Adding track\n");
						addTrack(t);
					}
				}
				break;
			case Xml::Attribut:
				break;
			case Xml::TagEnd:
				if(tag == "trackview")
					return;
			default:
				break;
		}
	}
}/*}}}*/
예제 #3
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;
        }
    }
}
예제 #4
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;
         }
     }
 }
예제 #5
0
파일: conf.cpp 프로젝트: Adamiko/los
QRect readGeometry(Xml& xml, const QString& name)
{
    QRect r(0, 0, 50, 50);
    int val;

    for (;;)
    {
        Xml::Token token = xml.parse();
        if (token == Xml::Error || token == Xml::End)
            break;
        QString tag = xml.s1();
        switch (token)
        {
            case Xml::TagStart:
                xml.parse1();
                break;
            case Xml::Attribut:
                val = xml.s2().toInt();
                if (tag == "x")
                    r.setX(val);
                else if (tag == "y")
                    r.setY(val);
                else if (tag == "w")
                    r.setWidth(val);
                else if (tag == "h")
                    r.setHeight(val);
                break;
            case Xml::TagEnd:
                if (tag == name)
                    return r;
            default:
                break;
        }
    }
    return r;
}
예제 #6
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;
                  }
            }
      }
예제 #7
0
파일: conf.cpp 프로젝트: Adamiko/los
void readConfiguration(Xml& xml, bool readOnlySequencer)/*{{{*/
{
    for (;;)
    {
        Xml::Token token = xml.parse();
        if (token == Xml::Error || token == Xml::End)
            break;
        QString tag = xml.s1();
        switch (token)
        {
            case Xml::TagStart:
                /* the reading of configuration is split in two; read
                   "sequencer" and read ALL. The reason is that it is
                   possible to load a song without configuration. In
                   this case the <configuration> chapter in the song
                   file should be skipped. However the sub part
                   <sequencer> contains elements that are necessary
                   to preserve composition consistency. Mainly
                   midiport configuration and VOLUME.
                 */
                if (tag == "sequencer")
                {
                    readSeqConfiguration(xml);
                    break;
                }
                else if (readOnlySequencer)
                {
                    xml.skip(tag);
                    break;
                }

                if (tag == "theme")
                    config.style = xml.parse1();
                else if (tag == "styleSheetFile")
                    config.styleSheetFile = xml.parse1();
                else if (tag == "useOldStyleStopShortCut")
                    config.useOldStyleStopShortCut = xml.parseInt();
                else if (tag == "moveArmedCheckBox")
                    config.moveArmedCheckBox = xml.parseInt();
                else if (tag == "externalWavEditor")
                    config.externalWavEditor = xml.parse1();
                else if (tag == "font0")
                    config.fonts[0].fromString(xml.parse1());
                else if (tag == "font1")
                    config.fonts[1].fromString(xml.parse1());
                else if (tag == "font2")
                    config.fonts[2].fromString(xml.parse1());
                else if (tag == "font3")
                    config.fonts[3].fromString(xml.parse1());
                else if (tag == "font4")
                    config.fonts[4].fromString(xml.parse1());
                else if (tag == "font5")
                    config.fonts[5].fromString(xml.parse1());
                else if (tag == "font6")
                    config.fonts[6].fromString(xml.parse1());
                else if (tag == "globalAlphaBlend")
                    config.globalAlphaBlend = xml.parseInt();
                else if (tag == "palette0")
                    config.palette[0] = readColor(xml);
                else if (tag == "palette1")
                    config.palette[1] = readColor(xml);
                else if (tag == "palette2")
                    config.palette[2] = readColor(xml);
                else if (tag == "palette3")
                    config.palette[3] = readColor(xml);
                else if (tag == "palette4")
                    config.palette[4] = readColor(xml);
                else if (tag == "palette5")
                    config.palette[5] = readColor(xml);
                else if (tag == "palette6")
                    config.palette[6] = readColor(xml);
                else if (tag == "palette7")
                    config.palette[7] = readColor(xml);
                else if (tag == "palette8")
                    config.palette[8] = readColor(xml);
                else if (tag == "palette9")
                    config.palette[9] = readColor(xml);
                else if (tag == "palette10")
                    config.palette[10] = readColor(xml);
                else if (tag == "palette11")
                    config.palette[11] = readColor(xml);
                else if (tag == "palette12")
                    config.palette[12] = readColor(xml);
                else if (tag == "palette13")
                    config.palette[13] = readColor(xml);
                else if (tag == "palette14")
                    config.palette[14] = readColor(xml);
                else if (tag == "palette15")
                    config.palette[15] = readColor(xml);
                else if (tag == "palette16")
                    config.palette[16] = readColor(xml);
                else if (tag == "ctrlGraphFg")
                    config.ctrlGraphFg = readColor(xml);
                else if (tag == "extendedMidi")
                    config.extendedMidi = xml.parseInt();
                else if (tag == "midiExportDivision")
                    config.midiDivision = xml.parseInt();
                else if (tag == "smfFormat")
                    config.smfFormat = xml.parseInt();
                else if (tag == "exp2ByteTimeSigs")
                    config.exp2ByteTimeSigs = xml.parseInt();
                else if (tag == "expOptimNoteOffs")
                    config.expOptimNoteOffs = xml.parseInt();
                else if (tag == "importMidiSplitParts")
                    config.importMidiSplitParts = xml.parseInt();
                else if (tag == "midiInputDevice")
                    midiInputPorts = xml.parseInt();
                else if (tag == "midiInputChannel")
                    midiInputChannel = xml.parseInt();
                else if (tag == "midiRecordType")
                    midiRecordType = xml.parseInt();
                else if (tag == "midiThruType")
                    midiThruType = xml.parseInt();
                else if (tag == "midiFilterCtrl1")
                    midiFilterCtrl1 = xml.parseInt();
                else if (tag == "midiFilterCtrl2")
                    midiFilterCtrl2 = xml.parseInt();
                else if (tag == "midiFilterCtrl3")
                    midiFilterCtrl3 = xml.parseInt();
                else if (tag == "midiFilterCtrl4")
                    midiFilterCtrl4 = xml.parseInt();
                else if (tag == "canvasShowPartType")
                    config.canvasShowPartType = xml.parseInt();
                else if (tag == "canvasShowPartEvent")
                    config.canvasShowPartEvent = xml.parseInt();
                else if (tag == "canvasShowGrid")
                    config.canvasShowGrid = xml.parseInt();
                else if (tag == "canvasBgPixmap")
                    config.canvasBgPixmap = xml.parse1();
                else if (tag == "canvasCustomBgList")
                    config.canvasCustomBgList = xml.parse1().split(";", QString::SkipEmptyParts);
                else if(tag == "vuColorStrip")
                {
                    vuColorStrip = xml.parseInt();
                }
                else if(tag == "nextTrackPartColor")
                {
                    lastTrackPartColorIndex = xml.parseInt();
                }
                else if (tag == "mtctype")
                    AL::mtcType = xml.parseInt();
                else if (tag == "jackTransportMaster")
                {
                    // XXX FIXME
                    bool jackTransportMaster = xml.parseInt();
                    if (audioDevice)
                        audioDevice->setMaster(jackTransportMaster);
                }
                else if (tag == "shortcuts")
                    readShortCuts(xml);
                else if (tag == "division")
                    config.division = xml.parseInt();
                else if (tag == "guiDivision")
                    config.guiDivision = xml.parseInt();
                else if (tag == "rtcTicks")
                    config.rtcTicks = xml.parseInt();
                else if (tag == "minMeter")
                    config.minMeter = xml.parseInt();
                else if (tag == "minSlider")
                    config.minSlider = xml.parseDouble();
                else if (tag == "freewheelMode")
                    config.freewheelMode = xml.parseInt();
                else if (tag == "denormalProtection")
                    config.useDenormalBias = xml.parseInt();
                else if (tag == "outputLimiter")
                    config.useOutputLimiter = xml.parseInt();
                else if (tag == "dummyAudioSampleRate")
                    config.dummyAudioSampleRate = xml.parseInt();
                else if (tag == "dummyAudioBufSize")
                    config.dummyAudioBufSize = xml.parseInt();
                else if (tag == "guiRefresh")
                    config.guiRefresh = xml.parseInt();
                else if (tag == "userInstrumentsDir")
                    config.userInstrumentsDir = xml.parse1();
                else if (tag == "midiTransform")
                    readMidiTransform(xml);
                else if (tag == "midiInputTransform")
                    readMidiInputTransform(xml);
                else if (tag == "startMode")
                    config.startMode = xml.parseInt();
                else if (tag == "startSong")
                    config.startSong = xml.parse1();
                else if (tag == "projectBaseFolder")
                    config.projectBaseFolder = xml.parse1();
                else if (tag == "projectStoreInFolder")
                    config.projectStoreInFolder = xml.parseInt();
                else if (tag == "useProjectSaveDialog")
                    config.useProjectSaveDialog = xml.parseInt();
                else if (tag == "useAutoCrossFades")
                    config.useAutoCrossFades = xml.parseInt();
                else if(tag == "globalInputList")
                    readGlobalInputList(xml);
                else
                    xml.skip(tag);
                break;
            case Xml::Text:
                printf("text <%s>\n", xml.s1().toLatin1().constData());
                break;
            case Xml::Attribut:
                if (readOnlySequencer)
                    break;
                if (tag == "version")
                {
                    int major = xml.s2().section('.', 0, 0).toInt();
                    int minor = xml.s2().section('.', 1, 1).toInt();
                    xml.setVersion(major, minor);
                }
                break;
            case Xml::TagEnd:
                if (tag == "configuration")
                {
                    return;
                }
                break;
            case Xml::Proc:
            default:
                break;
        }
    }
}/*}}}*/
예제 #8
0
파일: conf.cpp 프로젝트: Adamiko/los
static void readConfigMidiPort(Xml& xml)/*{{{*/
{
    int idx = 0;
    qint64 id = -1;
    QString device;
    bool isGlobal = false;

    QString instrument("GM");

    QList<PatchSequence*> patchSequences;
    QList<QPair<int, QString> > presets;

    int openFlags = 1;
    int dic = 0;
    int doc = 0;
    int type = MidiDevice::ALSA_MIDI;
    bool cachenrpn = false;

    MidiDevice* dev = 0;

    for (;;)
    {
        Xml::Token token = xml.parse();
        if (token == Xml::Error || token == Xml::End)
            break;
        QString tag = xml.s1();
        switch (token)
        {
            case Xml::TagStart:
                if (tag == "name")
                {
                    device = xml.parse1();
                    if (!dev)//Look for it as an alsa or already created device
                        dev = midiDevices.find(device);
                }
                else if (tag == "type")
                {
                    type = xml.parseInt();
                }
                else if (tag == "record")
                {   // old
                    bool f = xml.parseInt();
                    if (f)
                        openFlags |= 2;
                }
                else if (tag == "openFlags")
                    openFlags = xml.parseInt();
                else if (tag == "defaultInChans")
                    dic = xml.parseInt();
                else if (tag == "defaultOutChans")
                    doc = xml.parseInt();
                else if (tag == "instrument")
                {
                    instrument = xml.parse1();
                }
                else if (tag == "channel")
                {
                    readPortChannel(xml, idx);
                }
                else if (tag == "preset" || tag == "patchSequence")
                {
                    PatchSequence* p = readMidiPortPatchSequences(xml);
                    if (p)
                        patchSequences.append(p);
                }
                else if(tag == "midiPreset")
                {
                    presets.append(readMidiPortPreset(xml));
                }
                else if(tag == "cacheNRPN")
                {
                    cachenrpn = xml.parseInt();
                }
                else
                    xml.skip(tag);
                break;
            case Xml::Attribut:
                if (tag == "idx")
                {//Check to see if this port is already used, and bump if so
                    idx = xml.s2().toInt();
                    int freePort = getFreeMidiPort();
                    if(freePort != idx)
                    {//Set a flag here so we know when loading tracks later that we are dealing with an old file or global inputs changed
                        idx = freePort;
                    }
                }
                else if(tag == "portId")
                {//New style
                    id = xml.s2().toLongLong();
                    idx = getFreeMidiPort();
                }
                else if(tag == "isGlobalInput")
                {//Find the matching input if posible and set our index to it
                    isGlobal = xml.s2().toInt();
                }
                break;
            case Xml::TagEnd:
                if (tag == "midiport")
                {
                    if(isGlobal)
                    {//Find the global input that matches
                        //
                        if(gInputListPorts.size())
                        {
                            int myport = -1;
                            for(int i = 0; i < gInputListPorts.size(); ++i)
                            {
                                myport =  gInputListPorts.at(i);

                                MidiPort* inport = &midiPorts[i];
                                if(inport && inport->device() && inport->device()->name() == device)
                                {
                                    idx = myport;
                                    break;
                                }
                            }
                        }
                    }

                    if (idx < 0 || idx >= MIDI_PORTS)
                    {
                        fprintf(stderr, "bad midi port %d (>%d)\n",
                                idx, MIDI_PORTS);
                        idx = 0;
                    }

                    if (!dev)
                    {
                        if (type == MidiDevice::JACK_MIDI)
                        {
                            dev = MidiJackDevice::createJackMidiDevice(device); // p3.3.55

                            if (debugMsg)
                                fprintf(stderr, "readConfigMidiPort: creating jack midi device %s\n", device.toLatin1().constData());
                        }
                        else
                            dev = midiDevices.find(device);
                    }

                    if (debugMsg && !dev)
                        fprintf(stderr, "readConfigMidiPort: device not found %s\n", device.toLatin1().constData());

                    MidiPort* mp = &midiPorts[idx];
                    if(id)
                        mp->setPortId(id);

                    mp->setInstrument(registerMidiInstrument(instrument));
                    mp->setDefaultInChannels(dic);
                    mp->setDefaultOutChannels(doc);

                    //Indicate the port was found in the song file, even if no device is assigned to it.
                    mp->setFoundInSongFile(true);

                    if (!patchSequences.isEmpty())
                    {
                        for (int i = 0; i < patchSequences.size(); ++i)
                        {
                            mp->appendPatchSequence(patchSequences.at(i));
                        }
                    }
                    if(!presets.isEmpty())
                    {
                        for(int i = 0; i < presets.size(); ++i)
                        {
                            QPair<int, QString> pair = presets.at(i);
                            mp->addPreset(pair.first, pair.second);
                        }
                    }

                    if (dev)
                    {
                        dev->setOpenFlags(openFlags);
                        midiSeq->msgSetMidiDevice(mp, dev);
                        dev->setCacheNRPN(cachenrpn);
                    }
                    losMidiPorts.insert(mp->id(), mp);
                    return;
                }
            default:
                break;
        }
    }
}/*}}}*/
예제 #9
0
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;
        }
    }
}