Ejemplo n.º 1
0
    std::vector<AudioChannel*> getAudioEvents( std::vector<AudioChannel*> channels, int bufferPosition,
                                               int bufferEnd, bool addLiveInstruments )
    {
        // clear previous channel contents (note we don't delete the channels anywhere as we re-use them)
        channels.clear();

        int i, l;

        // note we update the channels mix properties here as they might change during playback

        for ( i = 0, l = instruments.size(); i < l; ++i )
        {
            BaseInstrument* instrument      = instruments.at( i );
            AudioChannel* instrumentChannel = instrument->audioChannel;

            instrumentChannel->reset();
            instrumentChannel->mixVolume = instrument->volume;

            if ( !instrumentChannel->muted )
            {
                if ( AudioEngine::playing )
                    collectSequencedEvents( instrument, bufferPosition, bufferEnd );

                if ( addLiveInstruments && instrument->hasLiveEvents() )
                    collectLiveEvents( instrument );

                channels.push_back( instrumentChannel );
            }
        }
        return channels;
    }
Ejemplo n.º 2
0
bool Sequencer::getAudioEvents( std::vector<AudioChannel*>* channels, int bufferPosition,
                                       int bufferSize, bool addLiveInstruments, bool flushChannels )
{
    channels->clear();

    int bufferEnd    = bufferPosition + ( bufferSize - 1 );          // the highest SampleEnd value we'll query
    bool loopStarted = bufferEnd > AudioEngine::max_buffer_position; // whether this request exceeds the min_buffer_position - max_buffer_position range

    int i, l;

    // note we update the channels mix properties here as they might change during playback

    for ( i = 0, l = ( int ) instruments.size(); i < l; ++i )
    {
        BaseInstrument* instrument      = instruments.at( i );
        AudioChannel* instrumentChannel = instrument->audioChannel;

        // clear previous channel contents when requested
        if ( flushChannels )
            instrumentChannel->reset();

        if ( !instrumentChannel->muted )
        {
            if ( playing )
                collectSequencedEvents( instrument, bufferPosition, bufferEnd );

            if ( addLiveInstruments && instrument->hasLiveEvents() )
                collectLiveEvents( instrument );

            channels->push_back( instrumentChannel );
        }
    }
    return loopStarted;
}