Added playSound() and csoundbox.h
This commit is contained in:
20
csoundbox.c
20
csoundbox.c
@@ -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;
|
||||
}
|
||||
|
2
csoundbox.h
Normal file
2
csoundbox.h
Normal file
@@ -0,0 +1,2 @@
|
||||
|
||||
void playSound(char *path);
|
Reference in New Issue
Block a user