Exemple #1
0
Device_state* new_Compress_pstate(
        const Device* device, int32_t audio_rate, int32_t audio_buffer_size)
{
    rassert(device != NULL);
    rassert(audio_rate > 0);
    rassert(audio_buffer_size >= 0);

    Compress_pstate* cpstate = memory_alloc_item(Compress_pstate);
    if (cpstate == NULL)
        return NULL;

    if (!Proc_state_init(&cpstate->parent, device, audio_rate, audio_buffer_size))
    {
        del_Device_state((Device_state*)cpstate);
        return NULL;
    }

    cpstate->parent.destroy = del_Compress_pstate;
    cpstate->parent.reset = Compress_pstate_reset;
    cpstate->parent.render_mixed = Compress_pstate_render_mixed;

    for (int ch = 0; ch < 2; ++ch)
        Compress_state_init(&cpstate->cstates[ch]);

    return (Device_state*)cpstate;
}
Exemple #2
0
Device_state* new_Delay_pstate(
        const Device* device, int32_t audio_rate, int32_t audio_buffer_size)
{
    assert(device != NULL);
    assert(audio_rate > 0);
    assert(audio_buffer_size >= 0);

    Delay_pstate* dpstate = memory_alloc_item(Delay_pstate);
    if (dpstate == NULL)
        return NULL;

    if (!Proc_state_init(&dpstate->parent, device, audio_rate, audio_buffer_size))
    {
        memory_free(dpstate);
        return NULL;
    }

    dpstate->parent.destroy = del_Delay_pstate;
    dpstate->parent.set_audio_rate = Delay_pstate_set_audio_rate;
    dpstate->parent.reset = Delay_pstate_reset;
    dpstate->parent.render_mixed = Delay_pstate_render_mixed;
    dpstate->parent.clear_history = Delay_pstate_clear_history;
    dpstate->buf_pos = 0;

    for (int i = 0; i < KQT_BUFFERS_MAX; ++i)
        dpstate->bufs[i] = NULL;

    const Proc_delay* delay = (const Proc_delay*)device->dimpl;

    const int32_t delay_buf_size = delay->max_delay * audio_rate + 1;

    for (int i = 0; i < KQT_BUFFERS_MAX; ++i)
    {
        dpstate->bufs[i] = new_Work_buffer(delay_buf_size);
        if (dpstate->bufs[i] == NULL)
        {
            del_Device_state(&dpstate->parent.parent);
            return NULL;
        }
    }

    return &dpstate->parent.parent;
}
Exemple #3
0
Device_state* new_Noise_pstate(
        const Device* device, int32_t audio_rate, int32_t audio_buffer_size)
{
    rassert(device != NULL);
    rassert(audio_rate > 0);
    rassert(audio_buffer_size >= 0);

    Noise_pstate* noise_state = memory_alloc_item(Noise_pstate);
    if (noise_state == NULL)
        return NULL;

    if (!Proc_state_init(&noise_state->parent, device, audio_rate, audio_buffer_size))
    {
        memory_free(noise_state);
        return NULL;
    }

    noise_state->order = 0;

    return &noise_state->parent.parent;
}
Exemple #4
0
Device_state* new_Freeverb_pstate(
        const Device* device, int32_t audio_rate, int32_t audio_buffer_size)
{
    assert(device != NULL);
    assert(audio_rate > 0);
    assert(audio_buffer_size >= 0);

    Freeverb_pstate* fpstate = memory_alloc_item(Freeverb_pstate);
    if (fpstate == NULL)
        return NULL;

    if (!Proc_state_init(&fpstate->parent, device, audio_rate, audio_buffer_size))
    {
        memory_free(fpstate);
        return NULL;
    }

    fpstate->parent.destroy = del_Freeverb_pstate;
    fpstate->parent.set_audio_rate = Freeverb_pstate_set_audio_rate;
    fpstate->parent.reset = Freeverb_pstate_reset;
    fpstate->parent.render_mixed = Freeverb_pstate_render_mixed;
    fpstate->parent.clear_history = Freeverb_pstate_clear_history;

    for (int ch = 0; ch < 2; ++ch)
    {
        for (int i = 0; i < FREEVERB_COMBS; ++i)
            fpstate->combs[ch][i] = NULL;

        for (int i = 0; i < FREEVERB_ALLPASSES; ++i)
            fpstate->allpasses[ch][i] = NULL;
    }

    for (int i = 0; i < FREEVERB_COMBS; ++i)
    {
        const uint32_t left_size = max(1, comb_tuning[i] * audio_rate);

        fpstate->combs[0][i] = new_Freeverb_comb(left_size);
        if (fpstate->combs[0][i] == NULL)
        {
            del_Device_state(&fpstate->parent.parent);
            return NULL;
        }

        const uint32_t right_size = max(
                1, (comb_tuning[i] + stereo_spread) * audio_rate);

        fpstate->combs[1][i] = new_Freeverb_comb(right_size);
        if (fpstate->combs[1][i] == NULL)
        {
            del_Device_state(&fpstate->parent.parent);
            return NULL;
        }
    }

    for (int i = 0; i < FREEVERB_ALLPASSES; ++i)
    {
        const uint32_t left_size = max(1, allpass_tuning[i] * audio_rate);

        if (fpstate->allpasses[0][i] == NULL)
        {
            fpstate->allpasses[0][i] = new_Freeverb_allpass(left_size);
            if (fpstate->allpasses[0][i] == NULL)
            {
                del_Device_state(&fpstate->parent.parent);
                return NULL;
            }
        }

        const uint32_t right_size = max(
                1, (allpass_tuning[i] + stereo_spread) * audio_rate);

        if (fpstate->allpasses[1][i] == NULL)
        {
            fpstate->allpasses[1][i] = new_Freeverb_allpass(right_size);
            if (fpstate->allpasses[1][i] == NULL)
            {
                del_Device_state(&fpstate->parent.parent);
                return NULL;
            }
        }
    }

    return &fpstate->parent.parent;
}