示例#1
0
MappedInstrument::MappedInstrument(const Instrument &instr):
        m_type(instr.getType()),
        m_id(instr.getId()),
        m_name(instr.getName()),
        m_device((instr.getDevice())->getId()),
        m_audioChannels(instr.getAudioChannels())
{}
示例#2
0
// Make the channel ready to play on.  Send the program, etc.
// @author Tom Breton (Tehom)
void
TrackInfo::makeChannelReady(Studio &studio)
{
#ifdef DEBUG_CONTROL_BLOCK
    RG_DEBUG << "TrackInfo::makeChannelReady()"
             << endl;
#endif
    Instrument *instrument =
        studio.getInstrumentById(m_instrumentId);

    // If we have deleted a device, we may get a NULL instrument.  In
    // that case, we can't do much.
    if (!instrument) {
        return;
    }

    // We can get non-Midi instruments here.  There's nothing to do
    // for them.  For fixed, sendChannelSetup is slightly wrong, but
    // could be adapted and parameterized by trackId.
    if ((instrument->getType() == Instrument::Midi)
            && !m_useFixedChannel) {
        // Re-acquire channel.  It may change if instrument's program
        // became percussion or became non-percussion.
        Device* device = instrument->getDevice();
        Q_CHECK_PTR(device);
        AllocateChannels *allocator = device->getAllocator();
        if (allocator) {
            m_thruChannel =
                allocator->reallocateThruChannel(*instrument, m_thruChannel);
            // If somehow we got here without having a channel, we
            // have one now.
            m_hasThruChannel = true;
#ifdef DEBUG_CONTROL_BLOCK
            RG_DEBUG << "TrackInfo::makeChannelReady() now has channel"
                     << m_hasThruChannel
                     << endl;
#endif
        }
        // This is how Midi instrument readies a fixed channel.
        StudioControl::sendChannelSetup(instrument, m_thruChannel);
    }
    m_isThruChannelReady = true;
}