aboutsummaryrefslogtreecommitdiffhomepage
path: root/test/test_audio.cpp
diff options
context:
space:
mode:
authorSebastien Alaiwan <[email protected]>2014-10-14 21:16:16 +0200
committerSebastien Alaiwan <[email protected]>2014-10-14 21:16:16 +0200
commit4c5618878f7e65096142c504d1eaa25038195ff8 (patch)
treee2a43e460e8ca4da3c5ce4af99d46c8fe92ed419 /test/test_audio.cpp
parenta0aa1de44886d0b788feb2695734b4612ad7eac0 (diff)
downloadcubeb-4c5618878f7e65096142c504d1eaa25038195ff8.tar.gz
cubeb-4c5618878f7e65096142c504d1eaa25038195ff8.zip
jack backend: handle cubeb_stream_set_volume correctly. Add corresponding test to test_audio.
Diffstat (limited to 'test/test_audio.cpp')
-rw-r--r--test/test_audio.cpp75
1 files changed, 73 insertions, 2 deletions
diff --git a/test/test_audio.cpp b/test/test_audio.cpp
index a7b2fb4..22b51ba 100644
--- a/test/test_audio.cpp
+++ b/test/test_audio.cpp
@@ -121,7 +121,7 @@ int run_test(int num_channels, int sampling_rate, int is_float)
cubeb_stream *stream = NULL;
const char * backend_id = NULL;
- ret = cubeb_init(&ctx, "Cubeb audio test");
+ ret = cubeb_init(&ctx, "Cubeb audio test: channels");
if (ret != CUBEB_OK) {
fprintf(stderr, "Error initializing cubeb library\n");
goto cleanup;
@@ -167,7 +167,71 @@ cleanup:
return ret;
}
-int main(int argc, char *argv[])
+int run_panning_volume_test()
+{
+ int ret = CUBEB_OK;
+
+ cubeb *ctx = NULL;
+ synth_state* synth = NULL;
+ cubeb_stream *stream = NULL;
+
+ ret = cubeb_init(&ctx, "Cubeb audio test");
+ if (ret != CUBEB_OK) {
+ fprintf(stderr, "Error initializing cubeb library\n");
+ goto cleanup;
+ }
+
+ cubeb_stream_params params;
+ params.format = CUBEB_SAMPLE_S16NE;
+ params.rate = 44100;
+ params.channels = 2;
+
+ synth = synth_create(params.channels, params.rate);
+ if (synth == NULL) {
+ fprintf(stderr, "Out of memory\n");
+ goto cleanup;
+ }
+
+ ret = cubeb_stream_init(ctx, &stream, "test tone", params,
+ 100, data_cb_short, state_cb, synth);
+ if (ret != CUBEB_OK) {
+ fprintf(stderr, "Error initializing cubeb stream: %d\n", ret);
+ goto cleanup;
+ }
+
+ fprintf(stderr, "Testing: volume\n");
+ for(int i=0;i <= 4; ++i)
+ {
+ fprintf(stderr, "Volume: %d%%\n", i*25);
+
+ cubeb_stream_set_volume(stream, i/4.0f);
+ cubeb_stream_start(stream);
+ delay(400);
+ cubeb_stream_stop(stream);
+ delay(100);
+ }
+
+ fprintf(stderr, "Testing: panning\n");
+ for(int i=-4;i <= 4; ++i)
+ {
+ fprintf(stderr, "Panning: %.2f%%\n", i/4.0f);
+
+ cubeb_stream_set_panning(stream, i/4.0f);
+ cubeb_stream_start(stream);
+ delay(400);
+ cubeb_stream_stop(stream);
+ delay(100);
+ }
+
+cleanup:
+ cubeb_stream_destroy(stream);
+ cubeb_destroy(ctx);
+ synth_destroy(synth);
+
+ return ret;
+}
+
+void run_channel_rate_test()
{
int channel_values[] = {
1,
@@ -192,6 +256,13 @@ int main(int argc, char *argv[])
assert(run_test(channel_values[j], freq_values[i], 1) == CUBEB_OK);
}
}
+}
+
+
+int main(int argc, char *argv[])
+{
+ assert(run_panning_volume_test() == CUBEB_OK);
+ run_channel_rate_test();
return CUBEB_OK;
}