Skip to content

Commit

Permalink
Merge pull request #6 from livibetter/master
Browse files Browse the repository at this point in the history
Fix only one sound played at the same time and Makefile by using Channels
  • Loading branch information
tomykaira committed Aug 8, 2011
2 parents 8f79a83 + 5a21781 commit af6f300
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ SDLCONFIG = -g ${shell sdl-config --cflags --libs}

all: pianistic

pianistic:
$(CC) -o $@ $@.c ${LDLIBS} ${SDLCONFIG}
pianistic: pianistic.c
$(CC) -o $@ $< ${LDLIBS} ${SDLCONFIG}
7 changes: 4 additions & 3 deletions pianistic.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,19 +40,19 @@ int stop = 0;

void event_callback (XPointer, XRecordInterceptData*);
void play (int index);
Mix_Music* sounds[26];
Mix_Chunk *sounds[12];

void loadSounds(){
char path[256];
int letter = 0;
for (;letter < 12; letter ++) {
sprintf(path, "audio/%c.wav", letter + 'a');
sounds[letter] = Mix_LoadMUS(path);
sounds[letter] = Mix_LoadWAV(path);
}
}

void play(int index) {
Mix_PlayMusic(sounds[index%12], 0);
Mix_PlayChannel(index%12, sounds[index%12], 0);
}

int main (int argc, char **argv)
Expand All @@ -69,6 +69,7 @@ int main (int argc, char **argv)
printf("Unable to open audio!\n");
exit(1);
}
Mix_AllocateChannels(12);
loadSounds();

// RECORD
Expand Down

0 comments on commit af6f300

Please sign in to comment.