コード例 #1
0
void CConfigInfo::addInstrument( unsigned int nInstrumentID )
{
	QString strUserInstruemt;
	strUserInstruemt = QString("%1").arg(nInstrumentID);

	addInstrument(strUserInstruemt);
}
コード例 #2
0
ファイル: AudioDevice.cpp プロジェクト: EQ4/RosegardenW
void
AudioDevice::createInstruments()
{
    for (uint i = 0; i < AudioInstrumentCount; ++i) {
        Instrument *instrument = new Instrument
        (AudioInstrumentBase + i, Instrument::Audio, "", i, this);
        addInstrument(instrument);
    }
    renameInstruments();
}
コード例 #3
0
ファイル: MidiDevice.cpp プロジェクト: EQ4/RosegardenW
void
MidiDevice::createInstruments(InstrumentId base)
{
    for (int i = 0; i < 16; ++i) {
        Instrument *instrument = new Instrument
            (base + i, Instrument::Midi, "", i, this);
        instrument->setFixedChannel();
        addInstrument(instrument);
    }
    renameInstruments();
}
コード例 #4
0
ファイル: MidiDevice.cpp プロジェクト: tedfelix/rosegarden
void
MidiDevice::createInstruments(InstrumentId base)
{
    for (int i = 0; i < 16; ++i) {
        Instrument *instrument = new Instrument
            (base + i, Instrument::Midi, "", i, this);
        instrument->setFixedChannel();
        // ??? Since we don't have a connection yet, this makes
        //     little sense.
        //instrument->sendChannelSetup();
        addInstrument(instrument);
    }
    renameInstruments();
}
コード例 #5
0
	void MainWindow::addInstrument_FDS()
	{
		addInstrument(SNDCHIP_FDS);
	}
コード例 #6
0
	void MainWindow::addInstrument_MMC5()
	{
		addInstrument(SNDCHIP_MMC5);
	}
コード例 #7
0
	void MainWindow::addInstrument_VRC7()
	{
		addInstrument(SNDCHIP_VRC7);
	}
コード例 #8
0
	void MainWindow::addInstrument_2A03()
	{
		addInstrument(SNDCHIP_NONE);
	}
コード例 #9
0
ファイル: cff.cpp プロジェクト: stohrendorf/ppplay
bool CffPlayer::load(const std::string& filename)
{
    FileStream f(filename);
    if(!f)
        return false;
    const uint8_t conv_inst[11] = { 2, 1, 10, 9, 4, 3, 6, 5, 0, 8, 7 };
    const std::array<uint16_t, 12> conv_note = { 0x16B, 0x181, 0x198, 0x1B0, 0x1CA,
        0x1E5, 0x202, 0x220, 0x241, 0x263,
        0x287, 0x2AE };

    // '<CUD-FM-File>' - signed ?
    f >> m_header;
    if(memcmp(m_header.id, "<CUD-FM-File>"
              "\x1A\xDE\xE0",
              16))
    {
        return false;
    }

    std::vector<uint8_t> module(0x10000);

    // packed ?
    if(m_header.packed)
    {
        std::unique_ptr<cff_unpacker> unpacker{ new cff_unpacker() };

        std::vector<uint8_t> packedModule;
        packedModule.resize(m_header.size + 4, 0);

        f.read(packedModule.data(), m_header.size);
        unpacker->unpack(packedModule, module);

        if(module.empty())
        {
            return false;
        }

        if(memcmp(&module[0x5E1], "CUD-FM-File - SEND A POSTCARD -", 31))
        {
            return false;
        }
    }
    else
    {
        f.read(module.data(), m_header.size);
    }

    // init CmodPlayer
    realloc_patterns(36, 64, 9);
    init_notetable(conv_note);
    init_trackord();

    // load instruments
    for(int i = 0; i < 47; i++)
    {
        memcpy(&m_instruments[i], &module[i * 32], sizeof(cff_instrument));

        for(int j = 0; j < 11; j++)
            addInstrument().data[conv_inst[j]] = m_instruments[i].data[j];

        m_instruments[i].name[20] = 0;
    }

    // number of patterns
    const auto patternCount = module[0x5E0];

    // load title & author
    m_title = stringncpy(reinterpret_cast<const char*>(&module[0x614]), 20);
    m_author = stringncpy(reinterpret_cast<const char*>(&module[0x600]), 20);

    // load orders
    {
        static constexpr auto OrderDataOffset = 0x628;
        for(int i = 0; i < 64; i++)
        {
            if(module[OrderDataOffset + i] & 0x80)
                break;

            addOrder(module[OrderDataOffset + i]);
        }
    }

    // load tracks
    int t = 0;
    for(int i = 0; i < patternCount; i++)
    {
        uint8_t old_event_byte2[9];

        memset(old_event_byte2, 0, 9);

        for(int channel = 0; channel < 9; channel++)
        {
            for(int row = 0; row < 64; row++)
            {
                const cff_event* event = reinterpret_cast<const cff_event *>(&module[0x669 + ((i * 64 + row) * 9 + channel) * 3]);
                PatternCell& cell = patternCell(t, row);

                // convert note
                if(event->byte0 == 0x6D)
                    cell.note = 127;
                else if(event->byte0)
                    cell.note = event->byte0;

                if(event->byte2)
                    old_event_byte2[channel] = event->byte2;

                // convert effect
                switch(event->byte1)
                {
                    case 'I': // set instrument
                        cell.instrument = event->byte2 + 1;
                        cell.hiNybble = cell.loNybble = 0;
                        break;

                    case 'H': // set tempo
                        cell.command = Command::SetTempo;
                        if(event->byte2 < 16)
                        {
                            cell.hiNybble = 0x07;
                            cell.loNybble = 0x0D;
                        }
                        break;

                    case 'A': // set speed
                        cell.command = Command::RADSpeed;
                        cell.hiNybble = event->byte2 >> 4;
                        cell.loNybble = event->byte2 & 15;
                        break;

                    case 'L': // pattern break
                        cell.command = Command::PatternBreak;
                        cell.hiNybble = event->byte2 >> 4;
                        cell.loNybble = event->byte2 & 15;
                        break;

                    case 'K': // order jump
                        cell.command = Command::OrderJump;
                        cell.hiNybble = event->byte2 >> 4;
                        cell.loNybble = event->byte2 & 15;
                        break;

                    case 'M': // set vibrato/tremolo
                        cell.command = Command::OplTremoloVibrato;
                        cell.hiNybble = event->byte2 >> 4;
                        cell.loNybble = event->byte2 & 15;
                        break;

                    case 'C': // set modulator volume
                        cell.command = Command::ModulatorVolume;
                        cell.hiNybble = (0x3F - event->byte2) >> 4;
                        cell.loNybble = (0x3F - event->byte2) & 15;
                        break;

                    case 'G': // set carrier volume
                        cell.command = Command::CarrierVolume;
                        cell.hiNybble = (0x3F - event->byte2) >> 4;
                        cell.loNybble = (0x3F - event->byte2) & 15;
                        break;

                    case 'B': // set carrier waveform
                        cell.command = Command::WaveForm;
                        cell.hiNybble = event->byte2;
                        cell.loNybble = 0x0F;
                        break;

                    case 'E': // fine frequency slide down
                        cell.command = Command::FineSlideDown;
                        cell.hiNybble = old_event_byte2[channel] >> 4;
                        cell.loNybble = old_event_byte2[channel] & 15;
                        break;

                    case 'F': // fine frequency slide up
                        cell.command = Command::FineSlideUp;
                        cell.hiNybble = old_event_byte2[channel] >> 4;
                        cell.loNybble = old_event_byte2[channel] & 15;
                        break;

                    case 'D': // fine volume slide
                        if(old_event_byte2[channel] & 15)
                        {
                            // slide down
                            cell.command = Command::SFXFineVolumeDown;
                            cell.loNybble = old_event_byte2[channel] & 15;
                        }
                        else
                        {
                            // slide up
                            cell.command = Command::SFXFineVolumeUp;
                            cell.loNybble = old_event_byte2[channel] >> 4;
                        }
                        break;

                    case 'J': // arpeggio
                        cell.hiNybble = old_event_byte2[channel] >> 4;
                        cell.loNybble = old_event_byte2[channel] & 15;
                        break;
                }
            }

            t++;
        }
    }

    // order loop
    setRestartOrder(0);

    // default tempo
    setInitialTempo(0x7D);

    rewind(0);

    return true;
}
コード例 #10
0
void ramCommunicationManager::updateWithOscMessage(const ofxOscMessage &m) {
    if (!dynamic_cast<ofxUIToggle*>(mainPanel.getWidget("Enable"))->getValue()) return;

    const std::string addr = m.getAddress();
    const std::string name = m.getArgAsString(0);

    int index = 0;
    int assIdx = -1;

    bool isExist = false;
    for (int i = 0; i < Instruments.size(); i++) {
        if (name == Instruments[i]->getName())
        {
            index   = i;
            isExist = true;
        }
    }

    if (!isExist) index = addInstrument(name);


    if (addr == RAM_OSC_ADDR_COMMUNICATE_NOTEON) {
        bVisible = true;
        Instruments[index]->getFloat("velocity") = m.getArgAsFloat(1);
        velocities[index]->setValue(m.getArgAsFloat(1));
        assIdx = 0;

        for (int j = 0; j < assigns.size(); j++) {
            if (assigns[j].Found &&
                    assigns[j].Pindex == index &&
                    assigns[j].Pposition == assIdx)
                assigns[j].Changed = true;
        }
    }

    else if (addr == RAM_OSC_ADDR_COMMUNICATE_NOTEOFF) {
        bVisible = true;
        Instruments[index]->getFloat("velocity") = 0.0;
        velocities[index]->setValue(0.0);
        assIdx = 0;

        for (int j = 0; j < assigns.size(); j++) {
            if (assigns[j].Found &&
                    assigns[j].Pindex == index &&
                    assigns[j].Pposition == assIdx)
                assigns[j].Changed = true;
        }
    }

    else if (addr == RAM_OSC_ADDR_COMMUNICATE_CC) {
        bVisible = true;
        int ccNum = m.getNumArgs();
        for (int i = 0; i < ccNum - 1; i++) {
            string ccLabel = "cc" + ofToString(i);

            if (Instruments[index]->contains(ccLabel))
            {

                Instruments[index]->getFloat(ccLabel) = m.getArgAsFloat(i+1);
                ccs[index][i]->setValue(m.getArgAsFloat(i+1));
                assIdx = i;

                for (int j = 0; j < assigns.size(); j++) {
                    if (assigns[j].Found &&
                            assigns[j].Pindex == index &&
                            assigns[j].Pposition == assIdx)
                        assigns[j].Changed = true;
                }
            }
            else
            {
                Instruments[index]->add((*new ofParameter<float>).set(ccLabel,
                                        m.getArgAsFloat(i+1),0.0,1.0));
                refleshInstruments();
            }

        }

    }

}