Пример #1
0
/** take a single block from the ringbuffers and send it out the
 *  attached track's ports */
nframes_t
Playback_DS::process ( nframes_t nframes )
{
    THREAD_ASSERT( RT );


    const size_t block_size = nframes * sizeof( sample_t );

//    printf( "process: %lu %lu %lu\n", _frame, _frame + nframes, nframes );

    for ( int i = channels(); i--;  )
    {

        void *buf = track()->output[ i ].buffer( nframes );

        if ( jack_ringbuffer_read( _rb[ i ], (char*)buf, block_size ) < block_size )
        {
            ++_xruns;
            memset( buf, 0, block_size );
            /* FIXME: we need to resync somehow */
        }

        /* TODO: figure out a way to stop IO while muted without losing sync */
        if ( track()->mute() || ( Track::soloing() && ! track()->solo() ) )
            buffer_fill_with_silence( (sample_t*)buf, nframes );
    }

    block_processed();

    /* FIXME: bogus */
    return nframes;
}
Пример #2
0
void
AUX_Module::process ( nframes_t nframes )
{
    if ( !bypass() )
    {
        float g = DB_CO( control_input[0].control_value() );
 
        for ( unsigned int i = 0; i < audio_input.size(); ++i )
        {
            if ( audio_input[i].connected() )
                buffer_copy_and_apply_gain( (sample_t*)jack_output[i].buffer( nframes ), (sample_t*)audio_input[i].buffer(), nframes, g );
        }
    }
    else
    {
        for ( unsigned int i = 0; i < audio_input.size(); ++i )
        {
            if ( audio_input[i].connected() )
                buffer_fill_with_silence( (sample_t*)jack_output[i].buffer( nframes ), nframes );
        }
    }
}
Пример #3
0
/* determine number of output ports, signal if changed.  */
void
Chain::configure_ports ( void )
{
     int nouts = 0;

    client()->lock();

    for ( int i = 0; i < modules(); ++i )
    {
        module( i )->configure_inputs( nouts );
        nouts = module( i )->noutputs();
    }

    unsigned int req_buffers = required_buffers();

    DMESSAGE( "required_buffers = %i", req_buffers );

    if ( scratch_port.size() < req_buffers )
    {
        for ( unsigned int i = scratch_port.size(); i--; )
            free(scratch_port[i].buffer());
        scratch_port.clear();

        for ( unsigned int i = 0; i < req_buffers; ++i )
        {
            Module::Port p( NULL, Module::Port::OUTPUT, Module::Port::AUDIO );
            p.connect_to( buffer_alloc( client()->nframes() ) );
            buffer_fill_with_silence( (sample_t*)p.buffer(), client()->nframes() );
            scratch_port.push_back( p );
        }
    }

    build_process_queue();

    client()->unlock();

    parent()->redraw();
}
Пример #4
0
void
AUX_Module::process ( nframes_t nframes )
{
    if ( unlikely( bypass() ) )
    {
        for ( unsigned int i = 0; i < audio_input.size(); ++i )
        {
            if ( audio_input[i].connected() )
                buffer_fill_with_silence( (sample_t*)aux_audio_output[i].jack_port()->buffer(nframes), nframes );
        }
    }
    else
    {
        float gt = DB_CO( control_input[0].control_value() );
 
        sample_t gainbuf[nframes];
    
        bool use_gainbuf = smoothing.apply( gainbuf, nframes, gt );

        if ( unlikely( use_gainbuf ) )
        {
            for ( unsigned int i = 0; i < audio_input.size(); ++i )
            {
                if ( audio_input[i].connected() )
                    buffer_copy_and_apply_gain_buffer( (sample_t*)aux_audio_output[i].jack_port()->buffer(nframes), (sample_t*)audio_input[i].buffer(), gainbuf, nframes );
            }

        }
        else
        {
            for ( unsigned int i = 0; i < audio_input.size(); ++i )
            {
                if ( audio_input[i].connected() )
                    buffer_copy_and_apply_gain( (sample_t*)aux_audio_output[i].jack_port()->buffer(nframes), (sample_t*)audio_input[i].buffer(), nframes, gt );
            }
        }
    }
}