当前位置: 首页>>代码示例>>C++>>正文


C++ MidiDevice::replaceBankList方法代码示例

本文整理汇总了C++中MidiDevice::replaceBankList方法的典型用法代码示例。如果您正苦于以下问题:C++ MidiDevice::replaceBankList方法的具体用法?C++ MidiDevice::replaceBankList怎么用?C++ MidiDevice::replaceBankList使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在MidiDevice的用法示例。


在下文中一共展示了MidiDevice::replaceBankList方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1:

void
ModifyDeviceCommand::unexecute()
{
    Device *device = m_studio->getDevice(m_device);
    if (!device) {
        std::cerr << "ERROR: ModifyDeviceCommand::unexecute(): no such device as " << m_device << std::endl;
        return;
    }

    MidiDevice *midiDevice = dynamic_cast<MidiDevice *>(device);
    if (!midiDevice) {
        std::cerr << "ERROR: ModifyDeviceCommand::unexecute(): device " << m_device << " is not a MIDI device" << std::endl;
        return;
    }

    if (m_rename)
        midiDevice->setName(m_oldName);
    midiDevice->replaceBankList(m_oldBankList);
    midiDevice->replaceProgramList(m_oldProgramList);
    midiDevice->replaceControlParameters(m_oldControlList);
    midiDevice->replaceKeyMappingList(m_oldKeyMappingList);
    midiDevice->setLibrarian(m_oldLibrarianName, m_oldLibrarianEmail);
    if (m_changeVariation)
        midiDevice->setVariationType(m_oldVariationType);

    InstrumentList instruments = midiDevice->getAllInstruments();
    for (size_t i = 0; i < instruments.size(); ++i) {
        instruments[i]->setProgram(m_oldInstrumentPrograms[i]);
    }

    // ??? Instead of this kludge, we should be calling a Studio::hasChanged()
    //     which would then notify all observers (e.g. MIPP) who, in turn,
    //     would update themselves.
    RosegardenMainWindow::self()->uiUpdateKludge();
}
开发者ID:EQ4,项目名称:RosegardenW,代码行数:35,代码来源:ModifyDeviceCommand.cpp

示例2: program

bool
ImportDeviceDialog::importFromSF2(QString filename)
{
    SF2PatchExtractor::Device sf2device;
    try {
        sf2device = SF2PatchExtractor::read( qstrtostr(filename) );

        // These exceptions shouldn't happen -- the isSF2File call before this
        // one should have weeded them out
    } catch (SF2PatchExtractor::FileNotFoundException e) {
        return false;
    } catch (SF2PatchExtractor::WrongFileFormatException e) {
        return false;
    }

    std::vector<MidiBank> banks;
    std::vector<MidiProgram> programs;

    for (SF2PatchExtractor::Device::const_iterator i = sf2device.begin();
            i != sf2device.end(); ++i) {

        int bankNumber = i->first;
        const SF2PatchExtractor::Bank &sf2bank = i->second;

        int msb = bankNumber / 128;
        int lsb = bankNumber % 128;

        MidiBank bank
        (msb == 1, msb, lsb,
         qstrtostr(tr("Bank %1:%2").arg(msb).arg(lsb)));

        banks.push_back(bank);

        for (SF2PatchExtractor::Bank::const_iterator j = sf2bank.begin();
                j != sf2bank.end(); ++j) {

            MidiProgram program(bank, j->first, j->second);
            programs.push_back(program);
        }
    }

    // This is a temporary device, so we can use device and instrument
    // IDs that other devices in the Studio may also be using without
    // expecting any problems
    MidiDevice *device = new MidiDevice
        (0, MidiInstrumentBase, "", MidiDevice::Play);
    device->replaceBankList(banks);
    device->replaceProgramList(programs);
    m_devices.push_back(device);

    return true;
}
开发者ID:EQ4,项目名称:RosegardenW,代码行数:52,代码来源:ImportDeviceDialog.cpp

示例3: bank

bool
ImportDeviceDialog::importFromLSCP(QString filename)
{
    LSCPPatchExtractor::Device lscpDevice;

    lscpDevice = LSCPPatchExtractor::extractContent(filename);
    std::vector<MidiBank> banks;
    std::vector<MidiProgram> programs;

    int comparableBankNumber = -1; //Make sure that first bank is read too by comparing to -1 first (invalid bank number)

    for (LSCPPatchExtractor::Device::const_iterator i = lscpDevice.begin();
    i != lscpDevice.end(); ++i) {

        int bankNumber = (*i).bankNumber; //Local variable bankNumber gets value from struct's member bankNumber

        std::string bankName = (*i).bankName; //Local variable bankName gets value from struct's member bankName
        int msb = bankNumber / 128;
        int lsb = bankNumber % 128;

        MidiBank bank (msb == 1, msb, lsb, bankName);

        if (comparableBankNumber != bankNumber) {
            banks.push_back(bank);
            comparableBankNumber = bankNumber;
        }

        MidiProgram program(bank, (*i).programNumber, (*i).programName);
        programs.push_back(program);
    }

    // This is a temporary device, so we can use device and instrument
    // IDs that other devices in the Studio may also be using without
    // expecting any problems
    MidiDevice *device = new MidiDevice
        (0, MidiInstrumentBase, "", MidiDevice::Play);
    device->replaceBankList(banks);
    device->replaceProgramList(programs);
    m_devices.push_back(device);

    return true;
}
开发者ID:EQ4,项目名称:RosegardenW,代码行数:42,代码来源:ImportDeviceDialog.cpp


注:本文中的MidiDevice::replaceBankList方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。