Esempio n. 1
0
void ReplayAudioIngest::emit_frame(channel_entry &ch) {
    BlockSet bset;
    size_t i;
    if (ch.fifo->fill_samples( ) < fft_size) {
        throw std::runtime_error("cannot emit frame, not enough samples");
    }

    /* take FFT of ch.fifo->data( ) into ch.current_frame */
    fft->compute(ch.current_frame, ch.fifo->data( ));

    /* subtract phase of last_frame from phase of current_frame to get output_frame */
    for (i = 0; i < fft_size; i++) {
        output_frame[i] = std::polar(
            std::abs(ch.current_frame[i]),
            std::arg(ch.current_frame[i]) - std::arg(ch.last_frame[i])
        );
    }

    /* 
     * swap last_frame and current_frame pointers 
     * (this makes current_frame the next last_frame)
     */
    std::swap(ch.last_frame, ch.current_frame);

    /* write output_frame to buffer */
    bset.add_block(REPLAY_PVOC_BLOCK, output_frame, fft_size);
    bset.add_block("Debug001", ch.fifo->data( ), fft_size);
    ch.buffer->write_blockset(bset);
    ch.fifo->pop_samples(fft_hop);
}
Esempio n. 2
0
timecode_t ReplayBuffer::write_frame(const ReplayFrameData &data) {
    BlockSet blkset;

    if (data.video_size == 0) {
        throw std::runtime_error("Tried to write empty frame");
    }

    if (data.video_size > 0) {
        blkset.add_block(
            REPLAY_VIDEO_BLOCK,
            data.video_data,
            data.video_size
        );
    }
    if (data.thumbnail_size > 0) {
        blkset.add_block(
            REPLAY_THUMBNAIL_BLOCK,
            data.thumbnail_data,
            data.thumbnail_size
        );
    }
    if (data.audio != NULL) {
        blkset.add_object(REPLAY_AUDIO_BLOCK, *(data.audio));
    }

    return write_blockset(blkset);
}