Added playSound() and csoundbox.h

This commit is contained in:
2017-12-13 17:55:44 +01:00
parent edc9b40636
commit eac1c224c1
2 changed files with 10 additions and 12 deletions

View File

@@ -2,17 +2,19 @@
#include <mpg123.h>
#include <stdlib.h>
#include <stdio.h>
#include "csoundbox.h"
#define BITS 8
void exitfunction(void) {
printf("Exiting csoundbox.\n");
}
int main(int argc, char *argv[])
{
mpg123_handle *mh;
return 0;
}
void playSound(char *path) {
mpg123_handle *mh;
unsigned char *buffer;
size_t buffer_size;
size_t done;
@@ -24,10 +26,6 @@ int main(int argc, char *argv[])
ao_sample_format format;
int channels, encoding;
long rate;
atexit(exitfunction);
if(argc < 2)
exit(0);
/* initializations */
ao_initialize();
@@ -38,7 +36,7 @@ int main(int argc, char *argv[])
buffer = (unsigned char*) malloc(buffer_size * sizeof(unsigned char));
/* open the file and get the decoding format */
mpg123_open(mh, argv[1]);
mpg123_open(mh, path);
mpg123_getformat(mh, &rate, &channels, &encoding);
/* set the output format and open the output device */
@@ -60,6 +58,4 @@ int main(int argc, char *argv[])
mpg123_delete(mh);
mpg123_exit();
ao_shutdown();
return 0;
}