Exemplo n.º 1
0
void AudioTrack::writeProperties(int level, Xml& xml) const
{
	Track::writeProperties(level, xml);
	xml.intTag(level, "prefader", prefader());
	xml.intTag(level, "sendMetronome", sendMetronome());
	xml.intTag(level, "automation", int(automationType()));
	if (hasAuxSend())
	{
		QHashIterator<qint64, AuxInfo> iter(_auxSend);
		while (iter.hasNext())
		{
			iter.next();
			Track* t = song->findTrackByIdAndType(iter.key(), Track::AUDIO_AUX);
			//Write it out only if the AUX track still exists
			if(t)
			{
				bool pre = iter.value().first;
				double val = iter.value().second;
				QString s("<auxSend trackId=\"%1\" pre=\"%2\">%3</auxSend>\n");
				xml.nput(level, s.arg(iter.key()).arg(pre).arg(val).toAscii().constData());
			}
		}
	}
    if (_wantsAutomation == false)
    {
        // _wantsAutomation is only set on fake midi automation tracks. on those, we don't need to save the plugins (synth) config
        for (ciPluginI ip = _efxPipe->begin(); ip != _efxPipe->end(); ++ip)
        {
            if (*ip)
                (*ip)->writeConfiguration(level, xml);
        }
    }
	for (ciCtrlList icl = _controller.begin(); icl != _controller.end(); ++icl)
	{
		const CtrlList* cl = icl->second;

		QString s= QString("controller id=\"%1\" cur=\"%2\"").arg(cl->id()).arg(cl->curVal()).toAscii().constData();
		s += QString(" color=\"%1\" visible=\"%2\"").arg(cl->color().name()).arg(cl->isVisible());
		xml.tag(level++, s.toAscii().constData());
		int i = 0;
		for (ciCtrl ic = cl->begin(); ic != cl->end(); ++ic)
		{
			QString s("%1 %2, ");
			xml.nput(level, s.arg(ic->second.getFrame()).arg(ic->second.val).toAscii().constData());
			++i;
			if (i >= 4)
			{
				xml.put(level, "");
				i = 0;
			}
		}
		if (i)
			xml.put(level, "");
        xml.etag(--level, "controller");
	}
}
Exemplo n.º 2
0
void KeyMap::write(int level, Xml& xml)/*{{{*/
{
    xml.nput(level, "<KeyMap key=\"%d\"", key);

    xml.nput(" program=\"%d\"", program);
    xml.nput(" hasProgram=\"%d\"", hasProgram);

    xml.nput(" comment=\"%s\"", Xml::xmlString(comment).toLatin1().constData());

    xml.nput(" pname=\"%s\"", Xml::xmlString(pname).toLatin1().constData());

    xml.put(" />");
}/*}}}*/
Exemplo n.º 3
0
void MidiInstrument::write(int level, Xml& xml)
      {
      xml.header();
      xml.tag(level, "muse version=\"1.0\"");
      level++;
      xml.nput(level, "<MidiInstrument name=\"%s\"", Xml::xmlString(iname()).toLatin1().constData());
      
      if(_nullvalue != -1)
      {
        QString nv; 
        nv.setNum(_nullvalue);
        xml.nput(" nullparam=\"%s\"", nv.toLatin1().constData());
      }  
      xml.put(">");

      level++;
      for (ciPatchGroup g = pg.begin(); g != pg.end(); ++g) {
            PatchGroup* pgp = *g;
            const PatchList& pl = pgp->patches;
            xml.tag(level, "PatchGroup name=\"%s\"", Xml::xmlString(pgp->name).toLatin1().constData());
            level++;
            for (ciPatch p = pl.begin(); p != pl.end(); ++p)
                  (*p)->write(level, xml);
            level--;
            xml.etag(level, "PatchGroup");
            }
      for (iMidiController ic = _controller->begin(); ic != _controller->end(); ++ic)
            ic->second->write(level, xml);
      if(!_sysex.isEmpty())
      {
        int j = _sysex.size();
        for(int i = 0; i < j; ++i)
          _sysex.at(i)->write(level, xml);
      }
      
      xml.tag(level++, "Init");
      for(ciEvent ev=_midiInit->begin(); ev != _midiInit->end(); ++ev)
        ev->second.write(level, xml, MusECore::Pos(0, true));
      xml.etag(--level, "Init");
      
      // -------------
      // TODO: What about _midiReset, _midiState, and _initScript ?
      // -------------
      
      writeDrummaps(level, xml);
      
      level--;
      xml.etag(level, "MidiInstrument");
      level--;
      xml.etag(level, "muse");
      }
Exemplo n.º 4
0
Arquivo: pos.cpp Projeto: UIKit0/lmuse
void PosLen::write(int level, Xml& xml, const char* name) const
      {
      xml.nput(level++, "<%s ", name);

      switch(type()) {
            case TICKS:
                  xml.nput("tick=\"%d\" len=\"%d\"", tick(), _lenTick);
                  break;
            case FRAMES:
                  xml.nput("sample=\"%d\" len=\"%d\"", frame(), _lenFrame);
                  break;
            }
      xml.put(" />", name);
      }
Exemplo n.º 5
0
Arquivo: pos.cpp Projeto: UIKit0/lmuse
void Pos::write(int level, Xml& xml, const char* name) const
      {
      xml.nput(level++, "<%s ", name);

      switch(_type) {
            case TICKS:
                  xml.nput("tick=\"%d\"", _tick);
                  break;
            case FRAMES:
                  xml.nput("frame=\"%d\"", _frame);
                  break;
            }
      xml.put(" />", name);
      }
Exemplo n.º 6
0
void CtrlListList::write(int level, Xml& xml) const
{
  for (ciCtrlList icl = begin(); icl != end(); ++icl) {
        const CtrlList* cl = icl->second;

        QString s= QString("controller id=\"%1\" cur=\"%2\"").arg(cl->id()).arg(cl->curVal()).toAscii().constData();
        s += QString(" color=\"%1\" visible=\"%2\"").arg(cl->color().name()).arg(cl->isVisible());
        xml.tag(level++, s.toAscii().constData());
        int i = 0;
        for (ciCtrl ic = cl->begin(); ic != cl->end(); ++ic) {
              QString s("%1 %2, ");
              xml.nput(level, s.arg(ic->second.frame).arg(ic->second.val).toAscii().constData());
              ++i;
              if (i >= 4) {
                    xml.put(level, "");
                    i = 0;
                    }
              }
        if (i)
              xml.put(level, "");
        xml.etag(level--, "controller");
        }
  
  _midi_controls.write(level, xml);
}
Exemplo n.º 7
0
void Patch::write(int level, Xml& xml)
      {
            xml.nput(level, "<Patch name=\"%s\"", Xml::xmlString(name).toLatin1().constData());
            //if(typ != -1)
            //  xml.nput(" mode=\"%d\"", typ);  // Obsolete

            if(hbank != -1)
              xml.nput(" hbank=\"%d\"", hbank);

            if(lbank != -1)
              xml.nput(" lbank=\"%d\"", lbank);

            xml.nput(" prog=\"%d\"", prog);

            if(drum)
              xml.nput(" drum=\"%d\"", int(drum));
            xml.put(" />");
      }
Exemplo n.º 8
0
void MidiInstrument::write(int level, Xml& xml)
{
    xml.header();
    xml.tag(level, "los version=\"1.0\"");
    level++;
    xml.nput(level, "<MidiInstrument name=\"%s\" panValue=\"%f\"",
            Xml::xmlString(iname()).toLatin1().constData(), m_panValue);

    if (_nullvalue != -1)
    {
        QString nv;
        nv.setNum(_nullvalue);
        xml.nput(" nullparam=\"%s\"", nv.toLatin1().constData());
    }
    xml.put(">");

    // -------------
    // What about Init, Reset, State, and InitScript ?
    // -------------

    level++;
    for (ciPatchGroup g = pg.begin(); g != pg.end(); ++g)
    {
        PatchGroup* pgp = *g;
        const PatchList& pl = pgp->patches;
        xml.tag(level, "PatchGroup name=\"%s\"", Xml::xmlString(pgp->name).toLatin1().constData());
        level++;
        for (ciPatch p = pl.begin(); p != pl.end(); ++p)
            (*p)->write(level, xml);
        level--;
        xml.etag(level, "PatchGroup");
    }
    for (iMidiController ic = _controller->begin(); ic != _controller->end(); ++ic)
        ic->second->write(level, xml);
    for(QHash<int, KeyMap*>::const_iterator km = m_keymaps.begin(); km != m_keymaps.end(); ++km)
    {
        KeyMap *m = km.value();
        m->write(level, xml);
    }
    level--;
    xml.etag(level, "MidiInstrument");
    level--;
    xml.etag(level, "los");
}
Exemplo n.º 9
0
void SysEx::write(int level, Xml& xml)
      {
            xml.nput(level, "<SysEx name=\"%s\">\n", Xml::xmlString(name).toLatin1().constData());

            level++;
            if(!comment.isEmpty())
              xml.strTag(level, "comment", Xml::xmlString(comment).toLatin1().constData());
            if(dataLen > 0 && data)
              xml.strTag(level, "data", sysex2string(dataLen, data));

            xml.etag(level, "SysEx");
      }
Exemplo n.º 10
0
void Patch::write(int level, Xml& xml)
{
    xml.nput(level, "<Patch name=\"%s\"", Xml::xmlString(name).toLatin1().constData());
    if (typ != -1)
        xml.nput(" mode=\"%d\"", typ);

    if (hbank != -1)
        xml.nput(" hbank=\"%d\"", hbank);

    if (lbank != -1)
        xml.nput(" lbank=\"%d\"", lbank);

    xml.nput(" prog=\"%d\"", prog);

    if (drum)
        xml.nput(" drum=\"%d\"", int(drum));
    if(!keys.isEmpty())
    {
        QString keyString;
        for(int i = 0; i < keys.size(); ++i)
        {
            keyString.append(QString::number(keys.at(i)));
            if(i < (keys.size() - 1))
                keyString.append(" ");
        }
        xml.nput(" keys=\"%s\"", keyString.toUtf8().constData());
    }
    if(!keyswitches.isEmpty())
    {
        QString keyString;
        for(int i = 0; i < keyswitches.size(); ++i)
        {
            keyString.append(QString::number(keyswitches.at(i)));
            if(i < (keyswitches.size() - 1))
                keyString.append(" ");
        }
        xml.nput(" keyswitches=\"%s\"", keyString.toUtf8().constData());
    }
    xml.put(" />");
}
Exemplo n.º 11
0
void MidiInstrument::writeDrummaps(int level, Xml& xml) const
{
  xml.tag(level++, "Drummaps");

  for (std::list<patch_drummap_mapping_t>::const_iterator it=patch_drummap_mapping.begin();
       it!=patch_drummap_mapping.end(); it++)
  {
    xml.tag(level++, "entry");

    const patch_collection_t* ap = &it->affected_patches;
    QString tmp="<patch_collection ";
    if (ap->first_program==ap->last_program)
      tmp+="prog=\""+QString::number(ap->first_program)+"\" ";
    else if (! (ap->first_program==0 && ap->last_program>=127))
      tmp+="prog=\""+QString::number(ap->first_program)+"-"+QString::number(ap->last_program)+"\" ";

    if (ap->first_lbank==ap->last_lbank)
      tmp+="lbank=\""+QString::number(ap->first_lbank)+"\" ";
    else if (! (ap->first_lbank==0 && ap->last_lbank>=127))
      tmp+="lbank=\""+QString::number(ap->first_lbank)+"-"+QString::number(ap->last_lbank)+"\" ";

    if (ap->first_hbank==ap->last_hbank)
      tmp+="hbank=\""+QString::number(ap->first_hbank)+"\" ";
    else if (! (ap->first_hbank==0 && ap->last_hbank>=127))
      tmp+="hbank=\""+QString::number(ap->first_hbank)+"-"+QString::number(ap->last_hbank)+"\" ";

    tmp+="/>\n";

    xml.nput(level, tmp.toLatin1().data());

    write_new_style_drummap(level, xml, "drummap", it->drummap);

    xml.etag(--level, "entry");
  }

  xml.etag(--level, "Drummaps");
}
Exemplo n.º 12
0
void Patch::write(int level, Xml& xml)/*{{{*/
{
    xml.nput(level, "<Patch name=\"%s\"", Xml::xmlString(name).toLatin1().constData());
    if (typ != -1)
        xml.nput(" mode=\"%d\"", typ);

    if (hbank != -1)
        xml.nput(" hbank=\"%d\"", hbank);

    if (lbank != -1)
        xml.nput(" lbank=\"%d\"", lbank);

    xml.nput(" prog=\"%d\"", prog);

    if (drum)
        xml.nput(" drum=\"%d\"", int(drum));

    if(!QString(filename).isEmpty())
        xml.nput(" filename=\"%s\"", Xml::xmlString(filename).toLatin1().constData());
    if(!QString(engine).isEmpty())
        xml.nput(" engine=\"%s\"", Xml::xmlString(engine).toLatin1().constData());
    if(loadmode != -1)
        xml.nput(" loadmode=\"%d\"", loadmode);
    if(index != -1)
        xml.nput(" index=\"%d\"", index);
    xml.nput(" volume=\"%f\"", volume);

    if(!keys.isEmpty())
    {
        QString keyString;
        for(int i = 0; i < keys.size(); ++i)
        {
            keyString.append(QString::number(keys.at(i)));
            if(i < (keys.size() - 1))
                keyString.append(" ");
        }
        xml.nput(" keys=\"%s\"", keyString.toUtf8().constData());
    }
    if(!keyswitches.isEmpty())
    {
        QString keyString;
        for(int i = 0; i < keyswitches.size(); ++i)
        {
            keyString.append(QString::number(keyswitches.at(i)));
            if(i < (keyswitches.size() - 1))
                keyString.append(" ");
        }
        xml.nput(" keyswitches=\"%s\"", keyString.toUtf8().constData());
    }
    if(!comments.empty())
    {
        QString c;
        QHashIterator<int, QString> it(comments);
        while(it.hasNext())
        {
            it.next();
            QString val = QString::number(it.key()).append("@@:@@").append(it.value());
            c.append(val).append(" ");
        }
        xml.nput(" comments=\"%s\"", c.toUtf8().constData());
    }
    xml.put(" />");
}/*}}}*/
Exemplo n.º 13
0
void MidiController::write(int level, Xml& xml) const
{
      ControllerType t = midiControllerType(_num);
      if(t == Velo)
        return;
        
      QString type(int2ctrlType(t));

      int h = (_num >> 8) & 0x7f;
      int l = _num & 0x7f;

      QString sl;
      if (isPerNoteController())
            sl = "pitch";
      else
            sl.setNum(l);

      xml.nput(level, "<Controller name=\"%s\"", Xml::xmlString(_name).toLatin1().constData());
      if(t != Controller7)
        xml.nput(" type=\"%s\"", type.toLatin1().constData());
      
      int mn = 0;
      int mx = 0; 
      switch (t) 
      {
            case RPN:
            case NRPN:
                  xml.nput(" h=\"%d\"", h);
                  xml.nput(" l=\"%s\"", sl.toLatin1().constData());
                  mx = 127;
                  break;
            case Controller7:
                  xml.nput(" l=\"%s\"", sl.toLatin1().constData());
                  mx = 127;
                  break;
            case Controller14:
            case RPN14:
            case NRPN14:
                  xml.nput(" h=\"%d\"", h);
                  xml.nput(" l=\"%s\"", sl.toLatin1().constData());
                  mx = 16383;
                  break;
            case Pitch:
                  mn = -8192;
                  mx = 8191;
                  break;
            case PolyAftertouch:
                  mn = 0;
                  mx = 127;
                  break;
            case Aftertouch: 
                  mn = 0;
                  mx = 127;
                  break;
            case Program:
            case Velo:        // Cannot happen
                  break;
      }
      
      if(t == Program)
      {
        if(_initVal != CTRL_VAL_UNKNOWN && _initVal != 0xffffff)
          xml.nput(" init=\"0x%x\"", _initVal);
      }
      else
      {
        if(_minVal != mn)     
          xml.nput(" min=\"%d\"", _minVal);
        if(_maxVal != mx)     
          xml.nput(" max=\"%d\"", _maxVal);
        
        if(_initVal != CTRL_VAL_UNKNOWN)     
          xml.nput(" init=\"%d\"", _initVal);
      }

      if(_showInTracks != (ShowInDrum | ShowInMidi))
          xml.nput(" showType=\"%d\"", _showInTracks);
        
      xml.put(" />");
}
Exemplo n.º 14
0
void MidiEventBase::write(int level, Xml& xml, const Pos& offset, bool /*forcePath*/) const
{
	xml.nput(level++, "<event tick=\"%d\"", tick() + offset.tick());
	switch (type())
	{
		case Note:
			xml.nput(" len=\"%d\"", lenTick());
			break;
		default:
			xml.nput(" type=\"%d\"", type());
			break;
	}

	// Changed by T356. BUG: *.oom does not save meta event types - ID: 2879426
	if (a)
		xml.nput(" a=\"%d\"", a);
	if (b)
		xml.nput(" b=\"%d\"", b);
	if (c)
		xml.nput(" c=\"%d\"", c);

	if (edata.dataLen)
	{
		xml.nput(" datalen=\"%d\">\n", edata.dataLen);
		xml.nput(level, "");
		for (int i = 0; i < edata.dataLen; ++i)
			xml.nput("%02x ", edata.data[i] & 0xff);
		xml.nput("\n");
		xml.tag(level, "/event");
	}
	else
	{
		//if (a)
		//      xml.nput(" a=\"%d\"", a);
		//if (b)
		//      xml.nput(" b=\"%d\"", b);
		//if (c)
		//      xml.nput(" c=\"%d\"", c);
		xml.nput(" />\n");
	}
}