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