diff options
author | sanine <sanine.not@pm.me> | 2022-08-29 00:00:51 -0500 |
---|---|---|
committer | sanine <sanine.not@pm.me> | 2022-08-29 00:00:51 -0500 |
commit | b9761d521087e23ee7a83b854d356b1fa07fe06e (patch) | |
tree | adf5097346448c30687ba22b3496ef877c3b38e9 /src/channel.test.c | |
parent | a0e405532e276bc1b2c9cae0e44295b17d987151 (diff) |
add channel_set_volume and channel_set_pan
Diffstat (limited to 'src/channel.test.c')
-rw-r--r-- | src/channel.test.c | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/src/channel.test.c b/src/channel.test.c index 4fddf45..2c5cdad 100644 --- a/src/channel.test.c +++ b/src/channel.test.c @@ -103,6 +103,50 @@ void test_channel_resume() } +void test_channel_set_volume() +{ + struct channel_t chan; + chan.volume = 255; + + channel_set_volume(&chan, 0.0f); + lily_assert_int_equal(chan.volume, 0); + channel_set_volume(&chan, 0.5f); + lily_assert_int_equal(chan.volume, 127); + channel_set_volume(&chan, 1.0f); + lily_assert_int_equal(chan.volume, 255); + + /* oob */ + channel_set_volume(&chan, -1.0f); + lily_assert_int_equal(chan.volume, 0); + channel_set_volume(&chan, 2.0f); + lily_assert_int_equal(chan.volume, 255); +} + + +void test_channel_set_pan() +{ + struct channel_t chan; + chan.pan = 255; + + channel_set_pan(&chan, -1.0f); + lily_assert_int_equal(chan.pan, -128); + channel_set_pan(&chan, -0.5f); + lily_assert_int_equal(chan.pan, -64); + channel_set_pan(&chan, 0.0f); + lily_assert_int_equal(chan.pan, 0); + channel_set_pan(&chan, 0.5f); + lily_assert_int_equal(chan.pan, 64); + channel_set_pan(&chan, 1.0f); + lily_assert_int_equal(chan.pan, 128); + + /* oob */ + channel_set_pan(&chan, -10.0f); + lily_assert_int_equal(chan.pan, -128); + channel_set_pan(&chan, 2.0f); + lily_assert_int_equal(chan.pan, 128); +} + + /* get_next_sample tests */ void test_channel_get_next_sample_inactive() { @@ -217,6 +261,8 @@ void suite_channel() lily_run_test(test_channel_reset); lily_run_test(test_channel_pause); lily_run_test(test_channel_resume); + lily_run_test(test_channel_set_volume); + lily_run_test(test_channel_set_pan); lily_run_test(test_channel_get_next_sample_inactive); lily_run_test(test_channel_get_next_sample_paused); |