You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

31 lines
716 B

int loadBank(int bank) {
memset(_sample, 0, sizeof(Mix_Chunk*) * NUM_WAVEFORMS);
int result = Mix_OpenAudio(44100, AUDIO_S16SYS, 2, 512);
if( result < 0 ) {
fprintf(stderr, "Unable to open audio: %s\n", SDL_GetError());
exit(-1);
}
result = Mix_AllocateChannels(4);
if( result < 0 ) {
fprintf(stderr, "Unable to allocate mixing channels: %s\n", SDL_GetError());
exit(-1);
}
char waveFileName[17];
for( int i = 0; i < NUM_WAVEFORMS; i++ ) {
sprintf(waveFileName, "banks/BANK%d/%d.wav", bank, i+1);
_sample[i] = Mix_LoadWAV(waveFileName);
if( _sample[i] == NULL ) {
fprintf(stderr, "Unable to load wave file: %s\n", waveFileName);
}
}
return true;
}