Example #1
0
static void Rangemap_pstate_render_mixed(
        Device_state* dstate,
        Device_thread_state* proc_ts,
        const Work_buffers* wbs,
        int32_t buf_start,
        int32_t buf_stop,
        double tempo)
{
    rassert(dstate != NULL);
    rassert(proc_ts != NULL);
    rassert(wbs != NULL);
    rassert(isfinite(tempo));
    rassert(tempo > 0);

    const Proc_rangemap* rangemap = (const Proc_rangemap*)dstate->device->dimpl;

    float mul = 0;
    float add = 0;
    get_scalars(
            &mul,
            &add,
            rangemap->from_min, rangemap->from_max,
            rangemap->min_to, rangemap->max_to);

    const double range_min = min(rangemap->min_to, rangemap->max_to);
    const double range_max = max(rangemap->min_to, rangemap->max_to);

    const float min_val = (float)(rangemap->clamp_dest_min ? range_min : -INFINITY);
    const float max_val = (float)(rangemap->clamp_dest_max ? range_max : INFINITY);

    // TODO: Support all ports?
    //       We should only enable the support if we are 100% sure that
    //       we don't need parameter input streams
    for (int port = 0; port < 2; ++port)
    {
        Work_buffer* out_wb =
            Device_thread_state_get_mixed_buffer(proc_ts, DEVICE_PORT_TYPE_SEND, port);
        if (out_wb == NULL)
            continue;

        const Work_buffer* in_wb = Device_thread_state_get_mixed_buffer(
                proc_ts, DEVICE_PORT_TYPE_RECV, port);
        if (in_wb == NULL)
            continue;

        apply_range(in_wb, out_wb, buf_start, buf_stop, mul, add, min_val, max_val);
    }

    return;
}
Example #2
0
void Voice_state_mix_signals(
        Voice_state* vstate,
        Proc_state* proc_state,
        Device_thread_state* proc_ts,
        int32_t buf_start,
        int32_t buf_stop)
{
    rassert(vstate != NULL);
    rassert(proc_state != NULL);
    rassert(proc_ts != NULL);
    rassert(buf_start >= 0);
    rassert(buf_stop >= buf_start);

    for (int32_t port = 0; port < KQT_DEVICE_PORTS_MAX; ++port)
    {
        Work_buffer* mixed_buffer =
            Device_thread_state_get_mixed_buffer(proc_ts, DEVICE_PORT_TYPE_SEND, port);
        if (mixed_buffer == NULL)
            continue;

        const Work_buffer* voice_buffer =
            Device_thread_state_get_voice_buffer(proc_ts, DEVICE_PORT_TYPE_SEND, port);
        rassert(voice_buffer != NULL);

        Work_buffer_mix(mixed_buffer, voice_buffer, buf_start, buf_stop);
        Device_thread_state_mark_mixed_audio(proc_ts);
    }

    return;
}
Example #3
0
float* Device_thread_state_get_mixed_buffer_contents_mut(
        const Device_thread_state* ts, Device_port_type type, int port)
{
    rassert(ts != NULL);
    rassert(type < DEVICE_PORT_TYPES);
    rassert(port >= 0);
    rassert(port < KQT_DEVICE_PORTS_MAX);

    Work_buffer* wb = Device_thread_state_get_mixed_buffer(ts, type, port);
    if (wb == NULL)
        return NULL;

    return Work_buffer_get_contents_mut(wb);
}
Example #4
0
static void Compress_pstate_render_mixed(
        Device_state* dstate,
        Device_thread_state* proc_ts,
        const Work_buffers* wbs,
        int32_t buf_start,
        int32_t buf_stop,
        double tempo)
{
    rassert(dstate != NULL);
    rassert(proc_ts != NULL);
    rassert(wbs != NULL);
    rassert(isfinite(tempo));
    rassert(tempo > 0);

    const Proc_compress* compress = (const Proc_compress*)dstate->device->dimpl;

    Compress_pstate* cpstate = (Compress_pstate*)dstate;

    // Get audio input buffers
    const Work_buffer* in_wbs[2] =
    {
        Device_thread_state_get_mixed_buffer(
                proc_ts, DEVICE_PORT_TYPE_RECV, PORT_IN_AUDIO_L),
        Device_thread_state_get_mixed_buffer(
                proc_ts, DEVICE_PORT_TYPE_RECV, PORT_IN_AUDIO_R),
    };

    // Get audio output buffers
    Work_buffer* out_wbs[2] =
    {
        Device_thread_state_get_mixed_buffer(
                proc_ts, DEVICE_PORT_TYPE_SEND, PORT_OUT_AUDIO_L),
        Device_thread_state_get_mixed_buffer(
                proc_ts, DEVICE_PORT_TYPE_SEND, PORT_OUT_AUDIO_R),
    };

    // Get level buffers
    Work_buffer* level_wbs[2] =
    {
        Work_buffers_get_buffer_mut(wbs, COMPRESS_WB_LEVEL_L),
        Work_buffers_get_buffer_mut(wbs, COMPRESS_WB_LEVEL_R),
    };

    // Get gain buffer
    Work_buffer* gain_wb = Device_thread_state_get_mixed_buffer(
            proc_ts, DEVICE_PORT_TYPE_SEND, PORT_OUT_GAIN);
    if (gain_wb == NULL)
        gain_wb = Work_buffers_get_buffer_mut(wbs, COMPRESS_WB_GAIN);

    Compress_states_update(
            cpstate->cstates,
            compress,
            gain_wb,
            level_wbs,
            in_wbs,
            buf_start,
            buf_stop,
            dstate->audio_rate);

    write_audio(out_wbs, gain_wb, in_wbs, buf_start, buf_stop);

    return;
}