Exemplo n.º 1
0
bool
EmbedSoundInst::reachedCustomEnd() const
{
    if (_outPoint == std::numeric_limits<unsigned long>::max()) return false;
    if (playbackPosition() >= _outPoint) return true;
    return false;
}
Exemplo n.º 2
0
void
EmbedSoundInst::decodeNextBlock()
{
    assert(!decodingCompleted());

    // this value is arbitrary, things would also work
    // with a smaller value, but 2^16 seems fast enough
    // to decode not to bother further streamlining it
    // See https://savannah.gnu.org/bugs/?25456 for a testcase
    // showing the benefit of chunked decoding.
    const std::uint32_t chunkSize = 65535;

    std::uint32_t inputSize = _soundDef.size() - decodingPosition;
    if ( inputSize > chunkSize ) inputSize = chunkSize;

#ifdef GNASH_DEBUG_SOUNDS_DECODING
    log_debug("  decoding %d bytes", inputSize);
#endif

    assert(inputSize);
    const std::uint8_t* input = _soundDef.data(decodingPosition);

    std::uint32_t consumed = 0;
    std::uint32_t decodedDataSize = 0;
    std::uint8_t* decodedData = decoder().decode(input, inputSize,
            decodedDataSize, consumed);

    decodingPosition += consumed;

    assert(!(decodedDataSize%2));

    // @todo I hope there are no alignment issues in this cast from int8_t* to int16_t* !
    std::int16_t* samples = reinterpret_cast<std::int16_t*>(decodedData);
    unsigned int nSamples = decodedDataSize/2;

#ifdef GNASH_DEBUG_MIXING
    log_debug("  applying volume/envelope to %d bytes (%d samples)"
            "of decoded data", decodedDataSize, nSamples);
#endif

    // Adjust volume
    if (_soundDef.volume != 100) {
        adjustVolume(samples, samples + nSamples, _soundDef.volume/100.0);
    }

    /// @todo is use of envelopes really mutually exclusive with
    ///       setting the volume ??
    else if (envelopes) {
        unsigned int firstSample = playbackPosition() / 2;
        applyEnvelopes(samples, nSamples, firstSample, *envelopes);
    }

#ifdef GNASH_DEBUG_MIXING
    log_debug("  appending %d bytes to decoded buffer", decodedDataSize);
#endif


    // decodedData ownership transferred here
    appendDecodedData(SimpleBuffer(decodedDataSize, decodedData));
}
Exemplo n.º 3
0
/*
 * Play the current position of the loop
 */
void Midilooper_Loop::play() {
    unsigned int _position = playbackPosition();
    
    if (_position != _last_position) {
        for (int i = 0; i < _current_instruction_position; i++) {
            unsigned int check_time = _instruction_times[i];
            if (check_time >= _last_position && check_time < _position) {
                 _instructions[i].run();
            }
        }
        
        _last_position = _position;
    }
}