Example #1
0
END_TEST


START_TEST(Note_end_is_reached_correctly_during_note_off)
{
    set_audio_rate(440);
    set_mix_volume(0);
    setup_debug_instrument();
    pause();

    float actual_buf[buf_len] = { 0.0f };
    const int note_off_frame = 70;

    kqt_Handle_fire_event(handle, 0, Note_On_55_Hz);
    check_unexpected_error();
    mix_and_fill(actual_buf, note_off_frame);

    // Note Off
    kqt_Handle_fire_event(handle, 0, "[\"n-\", null]");
    check_unexpected_error();
    mix_and_fill(actual_buf + note_off_frame, buf_len - note_off_frame);

    float expected_buf[buf_len] = { 0.0f };
    float seq_on[] = { 1.0f, 0.5f, 0.5f, 0.5f,
                       0.5f, 0.5f, 0.5f, 0.5f };
    int offset = repeat_seq_local(expected_buf, 8, seq_on);
    float seq_on_tail[] = { 1.0f, 0.5f, 0.5f, 0.5f, 0.5f, 0.5f };
    offset += repeat_seq_local(expected_buf + offset, 1, seq_on_tail);
    float seq_off[] = { -0.5f, -0.5f, -1.0f, -0.5f, -0.5f, -0.5f,
                                      -0.5f, -0.5f, -0.5f, -0.5f };
    repeat_seq_local(expected_buf + offset, 1, seq_off);

    check_buffers_equal(expected_buf, actual_buf, buf_len, 0.0f);
}
Example #2
0
END_TEST


START_TEST(Implicit_note_off_is_triggered_correctly)
{
    set_audio_rate(220);
    set_mix_volume(0);
    setup_debug_instrument();
    pause();

    float actual_buf[buf_len] = { 0.0f };
    const int note_2_frame = 2;

    kqt_Handle_fire_event(handle, 0, Note_On_55_Hz);
    check_unexpected_error();
    mix_and_fill(actual_buf, note_2_frame);

    kqt_Handle_fire_event(handle, 0, Note_On_55_Hz);
    check_unexpected_error();
    mix_and_fill(actual_buf + note_2_frame, buf_len - note_2_frame);

    float expected_buf[buf_len] = { 0.0f };
    float seq_1_on[] = { 1.0f, 0.5f };
    int offset = repeat_seq_local(expected_buf, 1, seq_1_on);
    float seq_1_off[] = { 0.5f, 0.0f, -0.5f, 0.0f };
    offset += repeat_seq_local(expected_buf + offset, 2, seq_1_off);
    float seq_2[] = { 1.0f, 0.5f, 0.5f, 0.5f };
    repeat_seq_local(expected_buf + offset, 8, seq_2);

    check_buffers_equal(expected_buf, actual_buf, buf_len, 0.0f);
}
Example #3
0
END_TEST


START_TEST(Independent_notes_mix_correctly)
{
    set_audio_rate(220);
    set_mix_volume(0);
    setup_debug_instrument();
    pause();

    float actual_buf[buf_len] = { 0.0f };
    const int note_2_frame = 2;

    kqt_Handle_fire_event(handle, 0, Note_On_55_Hz);
    check_unexpected_error();
    mix_and_fill(actual_buf, note_2_frame);

    kqt_Handle_fire_event(handle, 1, Note_On_55_Hz);
    check_unexpected_error();
    mix_and_fill(actual_buf + note_2_frame, buf_len - note_2_frame);

    float expected_buf[buf_len] = { 0.0f };
    float single_seq[] = { 1.0f, 0.5f, 0.5f, 0.5f };
    repeat_seq_local(expected_buf, 10, single_seq);
    for (int i = 40; i >= 0; --i)
        expected_buf[i + note_2_frame] += expected_buf[i];

    check_buffers_equal(expected_buf, actual_buf, buf_len, 0.0f);
}
Example #4
0
END_TEST


START_TEST(Effect_with_double_volume_dsp_and_bypass_triples_volume)
{
    set_audio_rate(220);
    set_mix_volume(0);
    pause();

    set_data("p_control_map.json", "[ [0, 0] ]");
    set_data("control_00/p_manifest.json", "{}");

    make_debug_instrument();

    set_data("au_01/p_manifest.json", "{ \"type\": \"effect\" }");
    set_data("au_01/in_00/p_manifest.json", "{}");
    set_data("au_01/out_00/p_manifest.json", "{}");
    set_data("au_01/proc_00/p_manifest.json", "{ \"type\": \"volume\" }");
    set_data("au_01/proc_00/p_signal_type.json", "\"mixed\"");
    set_data("au_01/proc_00/in_00/p_manifest.json", "{}");
    set_data("au_01/proc_00/out_00/p_manifest.json", "{}");
    set_data("au_01/proc_00/c/p_f_volume.json", "6");
    set_data("au_01/p_connections.json",
            "[ [\"in_00\", \"out_00\"],"
            "  [\"in_00\", \"proc_00/C/in_00\"],"
            "  [\"proc_00/C/out_00\", \"out_00\"] ]");

    set_data("out_00/p_manifest.json", "{}");
    set_data("p_connections.json",
            "[ [\"au_00/out_00\", \"au_01/in_00\"],"
            "  [\"au_01/out_00\", \"out_00\"] ]");

    validate();

    float actual_buf[buf_len] = { 0.0f };
    kqt_Handle_fire_event(handle, 0, Note_On_55_Hz);
    check_unexpected_error();
    mix_and_fill(actual_buf, buf_len);

    float expected_buf[buf_len] = { 0.0f };
    float seq[] = { 3.0f, 1.5f, 1.5f, 1.5f };
    repeat_seq_local(expected_buf, 10, seq);

    check_buffers_equal(expected_buf, actual_buf, buf_len, 0.0f);
}
Example #5
0
END_TEST
#endif


START_TEST(Input_map_maintains_indices)
{
    set_audio_rate(220);
    set_mix_volume(0);
    pause();

    // Set up two debug instruments
    set_data("p_dc_blocker_enabled.json", "false");

    set_data("out_00/p_manifest.json", "{}");
    set_data("p_connections.json",
            "[ [\"au_00/out_00\", \"out_00\"],"
            "  [\"au_01/out_00\", \"out_00\"] ]");

    set_data("p_control_map.json", "[[0, 0], [1, 1]]");
    set_data("control_00/p_manifest.json", "{}");
    set_data("control_01/p_manifest.json", "{}");

    set_data("au_00/p_manifest.json", "{ \"type\": \"instrument\" }");
    set_data("au_00/out_00/p_manifest.json", "{}");
    set_data("au_00/p_connections.json",
            "[ [\"proc_00/C/out_00\", \"out_00\"] ]");

    set_data("au_00/proc_00/p_manifest.json", "{ \"type\": \"debug\" }");
    set_data("au_00/proc_00/p_signal_type.json", "\"voice\"");
    set_data("au_00/proc_00/out_00/p_manifest.json", "{}");

    set_data("au_00/proc_00/c/p_b_single_pulse.json", "true");

    set_data("au_01/p_manifest.json", "{ \"type\": \"instrument\" }");
    set_data("au_01/out_00/p_manifest.json", "{}");
    set_data("au_01/p_connections.json",
            "[ [\"proc_00/C/out_00\", \"out_00\"]"
            ", [\"proc_01/C/out_00\", \"proc_00/C/in_00\"]"
            "]");

    set_data("au_01/proc_00/p_manifest.json", "{ \"type\": \"debug\" }");
    set_data("au_01/proc_00/p_signal_type.json", "\"voice\"");
    set_data("au_01/proc_00/in_00/p_manifest.json", "{}");
    set_data("au_01/proc_00/out_00/p_manifest.json", "{}");

    set_data("au_01/proc_01/p_manifest.json", "{ \"type\": \"pitch\" }");
    set_data("au_01/proc_01/p_signal_type.json", "\"voice\"");
    set_data("au_01/proc_01/out_00/p_manifest.json", "{}");

    validate();
    check_unexpected_error();

    // Test rendering
    float actual_buf[buf_len] = { 0.0f };

    kqt_Handle_fire_event(handle, 0, "[\".a\", 0]");
    kqt_Handle_fire_event(handle, 0, Note_On_55_Hz);
    check_unexpected_error();

    const int note_offset = 10;

    mix_and_fill(actual_buf, note_offset);

    kqt_Handle_fire_event(handle, 1, "[\".a\", 1]");
    kqt_Handle_fire_event(handle, 1, Note_On_55_Hz);
    check_unexpected_error();

    mix_and_fill(actual_buf + note_offset, buf_len - note_offset);

    float expected_buf[buf_len] = { 0.0f };
    expected_buf[0] = 1.0f;
    const float seq[] = { 1.0f, 0.5f, 0.5f, 0.5f };
    repeat_seq_local(expected_buf + note_offset, 10, seq);

    check_buffers_equal(expected_buf, actual_buf, buf_len, 0.0f);
}