Sequencer simplified, basically working.
[cantaveria.git] / sfx.c
blob2b030f58b438385643f580075af967d246b988de
1 #include <stdlib.h>
3 #include <loader.h>
4 #include <sfx.h>
6 float* sfx[SFX_COUNT];
7 int sfx_len[SFX_COUNT];
10 int load_sound(char* filename, sfx_id id){
11 /* load a wave file */
12 reader* r = data_open("sounds", filename);
13 if(r==NULL){
14 return -1;
17 int i;
18 for(i=0; i<40; i++){
19 read_byte(r);
22 int N = read_int(r) / 2;
23 float* buffer = malloc(N);
25 for(i=0; i<N; i++){
26 int s = read_short(r);
27 buffer[i] = s / 32767.0f;
30 sfx[id] = buffer;
31 sfx_len[id] = N;
33 loader_close(r);
34 return 0;
37 void play_sound(sfx_id id){