summaryrefslogtreecommitdiff
path: root/examples/mp3.c
diff options
context:
space:
mode:
authorsanine <sanine.not@pm.me>2022-09-06 23:21:20 -0500
committersanine <sanine.not@pm.me>2022-09-06 23:21:20 -0500
commit500dd00fb11efdd19aef924b0d8ff0b370c28d33 (patch)
treed89b17563866950f02ec948b37dea6364b4ac0dc /examples/mp3.c
parent7c678ce0266c66bb1b4d52bd70fb2351019e8ecd (diff)
implement mp3 loading
Diffstat (limited to 'examples/mp3.c')
-rw-r--r--examples/mp3.c31
1 files changed, 31 insertions, 0 deletions
diff --git a/examples/mp3.c b/examples/mp3.c
new file mode 100644
index 0000000..7560bf1
--- /dev/null
+++ b/examples/mp3.c
@@ -0,0 +1,31 @@
+#include <stdio.h>
+#include <stdlib.h>
+#include <math.h>
+#include <mossrose.h>
+#include <portaudio.h>
+
+#define SAMPLE_RATE 44100
+#define N_CHANNELS 8
+
+int main()
+{
+ int err = mossrose_init(SAMPLE_RATE, N_CHANNELS, true);
+ if (err != 0)
+ fprintf(stderr, "FAILED TO INITIALIZE MOSSROSE\n");
+
+ struct mossrose_sound_t *mono = mossrose_load_mp3("sine-mono.mp3");
+ struct mossrose_sound_t *stereo = mossrose_load_mp3("weird-stereo.mp3");
+
+ int chan = mossrose_play(mono, -1, 1);
+ Pa_Sleep(1000);
+ chan = mossrose_play(stereo, -1, 1);
+ Pa_Sleep(1000);
+
+ mossrose_terminate();
+ free(mono->left);
+ free(mono);
+ free(stereo->left);
+ free(stereo->right);
+ free(stereo);
+ return 0;
+}