示例#1
0
  void MxmlWriter::header(const QString title, const QString /* type */,
                          const QString composer, const QString footer,
                          const unsigned int temp)
  {
    // qDebug() << "MxmlWriter::header()"
    //    << "title:" << title
    //    << "type:" << type
    //    << "composer:" << composer
    //    << "footer:" << footer
    //    << "temp:" << temp
    //    ;

    // save tempo for later use
    tempo = temp;

    // write the header
    out << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>" << endl;
    out << "<!DOCTYPE score-partwise PUBLIC "
        << "\"-//Recordare//DTD MusicXML 2.0 Partwise//EN\" "
        << "\"http://www.musicxml.org/dtds/partwise.dtd\">" << endl;
    out << "<score-partwise>" << endl;
    out << "  <work>" << endl;
    out << "    <work-title>" << title << "</work-title>" << endl;
    // TODO work-number is not allowed, replace
    // out << "    <work-number>" << type << "</work-number>" << endl;
    out << "  </work>" << endl;
    out << "  <identification>" << endl;
    out << "    <creator type=\"composer\">" << composer << "</creator>" << endl;
    out << "    <rights>" << footer << "</rights>" << endl;
    out << "    <encoding>" << endl;
    out << "      <software>bww2mxml</software>" << endl;
    // TODO fill in real date
    // out << "      <encoding-date>TBD</encoding-date>" << endl;
    out << "    </encoding>" << endl;
    out << "  </identification>" << endl;
    out << "  <part-list>" << endl;
    out << "    <score-part id=\"P1\">" << endl;
    out << "      <part-name>" << instrumentName() << "</part-name>" << endl;
    out << "      <score-instrument id=\"P1-I1\">" << endl;
    out << "        <instrument-name>" << instrumentName() << "</instrument-name>" << endl;
    out << "      </score-instrument>" << endl;
    out << "      <midi-instrument id=\"P1-I1\">" << endl;
    out << "        <midi-channel>1</midi-channel>" << endl;
    out << "        <midi-program>" << midiProgram() << "</midi-program>" << endl;
    out << "      </midi-instrument>" << endl;
    out << "    </score-part>" << endl;
    out << "  </part-list>" << endl;
    out << "  <part id=\"P1\">" << endl;
  }
示例#2
0
void MsScWriter::header(const QString title, const QString type,
                        const QString composer, const QString footer,
                        const unsigned int temp)
      {
      qDebug() << "MsScWriter::header()"
               << "title:" << title
               << "type:" << type
               << "composer:" << composer
               << "footer:" << footer
               << "temp:" << temp
      ;

      // save tempo for later use
      tempo = temp;

      if (!title.isEmpty()) score->setMetaTag("workTitle", title);
      // TODO re-enable following statement
      // currently disabled because it breaks the bww iotest
      // if (!type.isEmpty()) score->setMetaTag("workNumber", type);
      if (!composer.isEmpty()) score->setMetaTag("composer", composer);
      if (!footer.isEmpty()) score->setMetaTag("copyright", footer);

      //  score->setWorkTitle(title);
      Ms::VBox* vbox  = 0;
      addText(vbox, score, title, Ms::TextStyleType::TITLE);
      addText(vbox, score, type, Ms::TextStyleType::SUBTITLE);
      addText(vbox, score, composer, Ms::TextStyleType::COMPOSER);
      // addText(vbox, score, strPoet, Ms::TextStyleType::POET);
      // addText(vbox, score, strTranslator, Ms::TextStyleType::TRANSLATOR);
      if (vbox) {
            vbox->setTick(0);
            score->measures()->add(vbox);
            }
      if (!footer.isEmpty())
            score->style()->set(Ms::StyleIdx::oddFooterC, footer);

      Ms::Part* part = score->staff(0)->part();
      part->setPlainLongName(instrumentName());
      part->setPartName(instrumentName());
      part->instrument()->setTrackName(instrumentName());
      part->setMidiProgram(midiProgram() - 1);
      }
示例#3
0
void MsScWriter::header(const QString title, const QString type,
                        const QString composer, const QString footer,
                        const unsigned int temp)
      {
      qDebug() << "MsScWriter::header()"
               << "title:" << title
               << "type:" << type
               << "composer:" << composer
               << "footer:" << footer
               << "temp:" << temp
      ;

      // save tempo for later use
      tempo = temp;

      if (!title.isEmpty()) score->setMetaTag("workTitle", title);
      // TODO re-enable following statement
      // currently disabled because it breaks the bww iotest
      // if (!type.isEmpty()) score->setMetaTag("workNumber", type);
      QString strType = "composer";
      QString strComposer = composer; // TODO: const parameters ctor MusicXmlCreator
      score->addCreator(new MusicXmlCreator(strType, strComposer));
      if (!footer.isEmpty()) score->setMetaTag("copyright", footer);

      //  score->setWorkTitle(title);
      VBox* vbox  = 0;
      addText(vbox, score, title, TEXT_STYLE_TITLE);
      addText(vbox, score, type, TEXT_STYLE_SUBTITLE);
      addText(vbox, score, composer, TEXT_STYLE_COMPOSER);
      // addText(vbox, score, strPoet, TEXT_STYLE_POET);
      // addText(vbox, score, strTranslator, TEXT_STYLE_TRANSLATOR);
      if (vbox) {
            vbox->setTick(0);
            score->measures()->add(vbox);
            }
      if (!footer.isEmpty())
            score->style()->set(ST_oddFooterC, footer);

      Part* part = score->part(0);
      part->setLongName(instrumentName());
      part->setMidiProgram(midiProgram() - 1);
      }
示例#4
0
void
TrackParameterBox::updateInstrument(const Instrument *instrument)
{
    // As with the Device field above, this will rarely change and it is
    // expensive to clear and reload.  So, we should cache enough info to
    // detect a real change.  This would be Instrument names and IDs.

    const DeviceId deviceId = instrument->getDevice()->getId();
    const Device &device = *(m_doc->getStudio().getDevice(deviceId));

    const InstrumentList instrumentList = device.getPresentationInstruments();

    // Generate local instrument name and ID lists to compare against the
    // members.

    std::vector<InstrumentId> instrumentIds;
    std::vector<QString> instrumentNames;

    // For each instrument
    for (size_t instrumentIndex = 0;
         instrumentIndex < instrumentList.size();
         ++instrumentIndex) {
        const Instrument &loopInstrument = *(instrumentList[instrumentIndex]);

        instrumentIds.push_back(loopInstrument.getId());

        QString instrumentName(QObject::tr(loopInstrument.getName().c_str()));
        QString programName(
                QObject::tr(loopInstrument.getProgramName().c_str()));

        if (loopInstrument.getType() == Instrument::SoftSynth) {

            instrumentName.replace(QObject::tr("Synth plugin"), "");

            programName = "";

            AudioPluginInstance *plugin =
                    instrument->getPlugin(Instrument::SYNTH_PLUGIN_POSITION);
            if (plugin)
                programName = strtoqstr(plugin->getDisplayName());
        }

        if (programName != "")
            instrumentName += " (" + programName + ")";

        // cut off the redundant eg. "General MIDI Device" that appears in the
        // combo right above here anyway
        instrumentName = instrumentName.mid(
                instrumentName.indexOf("#"), instrumentName.length());

        instrumentNames.push_back(instrumentName);
    }

    // If there has been an actual change
    if (instrumentIds != m_instrumentIds2  ||
        instrumentNames != m_instrumentNames2) {

        // Update the cache.
        m_instrumentIds2 = instrumentIds;
        m_instrumentNames2 = instrumentNames;

        // Reload the combobox

        m_instrument->clear();

        // For each instrument, add the name to the combobox.
        // ??? If we used a QStringList, we could just call addItems().
        for (size_t instrumentIndex = 0;
             instrumentIndex < m_instrumentNames2.size();
             ++instrumentIndex) {
            m_instrument->addItem(m_instrumentNames2[instrumentIndex]);
        }
    }

    // Find the current instrument in the instrument ID list.

    const InstrumentId instrumentId = instrument->getId();

    // Assume not found.
    int currentIndex = -1;

    // For each Instrument
    for (size_t instrumentIndex = 0;
         instrumentIndex < m_instrumentIds2.size();
         ++instrumentIndex) {
        // If this is the selected Instrument
        if (m_instrumentIds2[instrumentIndex] == instrumentId) {
            currentIndex = instrumentIndex;
            break;
        }
    }

    // Set the index.
    m_instrument->setCurrentIndex(currentIndex);
}