void RNDEND_unload_assets(void) { glDeleteTextures(1, &rndend_win_gfx); glDeleteTextures(1, &rndend_loss_gfx); destroy_sample(rndend_win_chime); destroy_sample(rndend_loss_chime); }
//Unload sounds from memory void DisposeVoices() { int i; SAMPLE* samp; for(i=0; i<voice_len_music; i++) { if((samp=voice_check(VoicesMusic[i]))!=NULL) //Addionnal check { destroy_sample(samp); } deallocate_voice(VoicesMusic[i]); } for(i=0; i<voice_len_sfx; i++) { if((samp=voice_check(VoicesSfx[i]))!=NULL) //Addionnal check { destroy_sample(samp); } deallocate_voice(VoicesSfx[i]); } free(VoicesMusic); VoicesMusic=NULL; voice_len_music=0; free(VoicesSfx); VoicesSfx=NULL; voice_len_sfx=0; }
// Program starts here int main() { // Setup for first time setup(true); // Run game loop while game running while (!key[KEY_ESC] && gameRunning) { game(); draw(true); } // Destroy images destroy_bitmap(buffer); destroy_bitmap(grid); destroy_bitmap(img_x); destroy_bitmap(img_o); destroy_bitmap(blank); destroy_bitmap(selected[0]); destroy_bitmap(selected[1]); destroy_bitmap(selected[2]); destroy_bitmap(selected[3]); destroy_bitmap(xwin); destroy_bitmap(owin); destroy_bitmap(catsgame); // Destroy sounds destroy_sample(win); destroy_sample(lose); destroy_sample(cat); destroy_sample(place); // End return 0; }
void destroyAll(BITMAP * nave,BITMAP * buffer,BITMAP * alien,BITMAP * gun,BITMAP * init,BITMAP * bg,SAMPLE * sound,SAMPLE * music){ destroy_bitmap(nave); destroy_bitmap(buffer); destroy_bitmap(alien); destroy_bitmap(init); destroy_bitmap(gun); destroy_sample(sound); destroy_sample(music); destroy_bitmap(bg); }
Sonido::~Sonido() { if ( sample ) { destroy_sample(sample); } }
void osd_stop_audio_stream(void) { #ifdef USE_SEAL int i; #endif if (Machine->sample_rate == 0) return; #ifdef USE_SEAL /* stop and release voices */ for (i = 0;i < SOUND_CHANNELS;i++) { if (lpWave[i]) { AStopVoice(hVoice[i]); ADestroyAudioData(lpWave[i]); free(lpWave[i]); lpWave[i] = 0; ADestroyAudioVoice(hVoice[i]); } } #endif #ifdef USE_ALLEGRO voice_stop(myvoice); deallocate_voice(myvoice); destroy_sample(mysample); mysample = 0; #endif stream_playing = 0; }
//Load Sound .wav to memory int AddVoice(const char *filename, int sfx) { SAMPLE *samp; int v; samp=load_sample(filename); if(!samp) return 0; if((v=allocate_voice(samp))==-1) { destroy_sample(samp); return 0; } if(sfx) { voice_len_sfx++; VoicesSfx=(int*)realloc(VoicesSfx,voice_len_sfx*sizeof(int)); VoicesSfx[voice_len_sfx-1]=v; voice_set_volume(v,Effect_volume); } else { voice_len_music++; VoicesMusic=(int*)realloc(VoicesMusic,voice_len_music*sizeof(int)); VoicesMusic[voice_len_music-1]=v; voice_set_volume(v,Music_volume); } return v; }
void Resource::destroy() { std::map<std::string, BITMAP*>::iterator it; for (it = mBitmaps.begin(); it != mBitmaps.end(); it++) { destroy_bitmap((*it).second); } std::map<std::string, SAMPLE*>::iterator it2; for (it2 = mSamples.begin(); it2 != mSamples.end(); it2++) { destroy_sample((*it2).second); } std::map<std::string, Font*>::iterator it3; for (it3 = mFonts.begin(); it3 != mFonts.end(); it3++) { delete (*it3).second; } std::map<std::string, Animation*>::iterator it4; for (it4 = myAnimations.begin(); it4 != myAnimations.end(); it4++) { delete (*it4).second; } }
sound::~sound() { if(prev!=NULL) prev->next=next; if(next!=NULL) next->prev=prev; else sounds->end=prev; destroy_sample(snd); };
void Clean_Music() { if (music) { destroy_sample(music); } }
void Sound::done () { if(!EnableSound) return; for (std::map<std::string, SAMPLE *>::iterator i = Sounds.begin(); i != Sounds.end(); ++i) if (i->second) destroy_sample (i->second); }
void JamulSoundDestroyBuffer(int which) { if (soundbuf[which].sample) { destroy_sample(soundbuf[which].sample); soundbuf[which].sample = NULL; } }
SAMPLE *alogg_create_sample_from_ogg(ALOGG_OGG *ogg) { SAMPLE *sample; char *data; int i, sample_len_bytes, sample_len, size_done, done; /* first we need to calculate the len of the sample in bytes */ sample_len = ov_pcm_total(&(ogg->vf), -1); sample_len_bytes = (sample_len * (ogg->stereo ? 2 : 1)) * 2; /* / 2 = 16 bits */ /* create the sample */ sample = create_sample(16, ogg->stereo, ogg->freq, sample_len); /* return NULL if we were not able to allocate the memory for it */ if (sample == NULL) return NULL; /* we need to stop and rewind the ogg */ alogg_stop_ogg(ogg); alogg_rewind_ogg(ogg); /* set our pointer */ data = (char *)sample->data; /* clear the sample buffer in unsigned format */ { int i; unsigned short *j = (unsigned short *)data; for (i = 0; i < (sample_len_bytes / 2); i++, j++) *j = 0x8000; } /* decode */ done = FALSE; size_done = 0; for (i = sample_len_bytes; !done && (i > 0); i -= size_done) { /* decode */ size_done = ov_read(&(ogg->vf), data, i, 0, 2, 0, &(ogg->current_section)); /* check if the decoding was not successful */ if (size_done < 0) { if (size_done == OV_HOLE) size_done = 0; else { alogg_rewind_ogg(ogg); destroy_sample(sample); return NULL; } } else if (size_done == 0) done = TRUE; data += size_done; } alogg_rewind_ogg(ogg); return sample; }
int _apeg_audio_close(APEG_LAYER *layer) { if(layer->audio.stream) destroy_sample(layer->audio.stream); layer->audio.stream = NULL; layer->audio.voice = -1; return 0; }
TileShop::~TileShop() { for (int i = 0; i < 16; i++) { destroy_bitmap(tiles[i].picture); } destroy_bitmap(pictures); destroy_sample(click); }
void saDestroyChannel( int chan ) { if( lpWave[chan] ){ voice_stop(hVoice[chan]); destroy_sample( lpWave[chan] ); lpWave[chan] = 0; playing[chan] = 0; deallocate_voice(hVoice[chan]); } }
int main( void ) { int depth; /* represents color depth */ /* first, set up Allegro and the graphics mode */ allegro_init(); /* initialize Allegro */ install_keyboard(); /* install the keyboard for Allegro to use */ install_sound( DIGI_AUTODETECT, MIDI_AUTODETECT, NULL ); depth = desktop_color_depth(); /* find out what color depth is on our computer */ if (depth == 0) depth = 32; set_color_depth( depth ); /* set the color depth to depth used by our computer */ set_gfx_mode( GFX_AUTODETECT_WINDOWED, 640, 480, 0, 0 ); /* set graphics mode */ ball = load_bitmap( "ball.bmp", NULL ); /* load the ball bitmap */ bar = load_bitmap( "bar.bmp", NULL); /* load the bar bitmap */ buffer = create_bitmap(SCREEN_W, SCREEN_H);/* create buffer */ boing = load_sample( "boing.wav" ); /* load the sound file */ pongFont = load_font( "pongfont.pcx", NULL, NULL ); /* load the font */ ball_x = SCREEN_W / 2; /* give the ball its initial x-coordinate */ ball_y = SCREEN_H / 2; /* give the ball its initial y-coordinate */ barL_y = SCREEN_H / 2; /* give left paddle its initial y-coordinate */ barR_y = SCREEN_H / 2; /* give right paddle its initial y-coordinate */ scoreL = 0; /* set left player’s score to 0 */ scoreR = 0; /* set right player’s score to 0 */ srand( time( NULL ) ); /* seed the random function ... */ direction = rand() % 4; /* and then make a random initial direction */ while ( !key[KEY_ESC] )/* until the escape key is pressed ... */ { moveBall(); /* move the ball */ respondToKeyboard(); /* respond to keyboard input */ /* now, perform double buffering */ clear_to_color( buffer, makecol( 255, 255, 255 ) ); blit( ball, buffer, 0, 0, ball_x, ball_y, ball->w, ball->h ); blit( bar, buffer, 0, 0, 0, barL_y, bar->w, bar->h ); blit( bar, buffer, 0, 0, 620, barR_y, bar->w, bar->h ); /* draw text onto the buffer */ textprintf_ex( buffer, pongFont, 75, 0, makecol( 0, 0, 0 ), -1, "Left Player Score: %d", scoreL ); textprintf_ex( buffer, pongFont, 400, 0, makecol( 0, 0, 0 ), -1, "Right Player Score: %d", scoreR ); blit( buffer, screen, 0, 0, 0, 0, buffer->w, buffer->h ); clear_bitmap( buffer ); } /* end while */ destroy_bitmap( ball ); /* destroy the ball bitmap */ destroy_bitmap( bar ); /* destroy the bar bitmap */ destroy_bitmap( buffer ); /* destroy the buffer bitmap */ destroy_sample( boing ); /* destroy the boing sound file */ destroy_font( pongFont ); /* destroy the font */ return 0; } /* end function main */
void Abertura (void) { BITMAP *buffer; SAMPLE *som, *grito, *som2, *som3; buffer = create_bitmap(LARGURA, ALTURA); carregaSom_Abertura(&som3, "../audio/thunder.wav"); play_sample(som3, 255, 128, 1000, FALSE); rest (1000); carregaImg_Abertura(&buffer, "../grafics/img01.tga"); highcolor_fade_in_Abertura(buffer, 3); carregaSom_Abertura(&som, "../audio/00.wav"); play_sample(som, 255, 128, 1000, FALSE); carregaSom_Abertura(&som2, "../audio/a_thunder.wav"); play_sample(som2, 255, 128, 1000, FALSE); rest (2500); carregaImg_Abertura(&buffer, "../grafics/img02.tga"); play_sample(som, 255, 128, 1000, FALSE); carregaSom_Abertura(&som, "../audio/01.wav"); play_sample(som, 1000, 128, 1000, FALSE); carregaSom_Abertura(&grito, "../audio/scream05.wav"); play_sample(grito, 255, 128, 1000, FALSE); blit(buffer,screen,0,0,0,0,LARGURA,ALTURA); highcolor_fade_out_Abertura (5); rest(1000); destroy_sample(som); destroy_sample(som2); destroy_sample(som3); destroy_sample(grito); destroy_bitmap(buffer); }
Intro::~Intro() { // Clear memory for( int i = 0; i < 81; i++){ if(images[i]){ destroy_bitmap( images[i]); } } destroy_bitmap( background); destroy_bitmap( title); destroy_bitmap( intro); destroy_sample( introSound); }
void Load_SFX(unsigned char i, const char* directory) { #ifdef DEBUG fprintf(stderr, "Loading sound effect %d (%s) in memory\n", i, directory); #endif if (sfx_id[i]) { destroy_sample(sfx_id[i]); } sfx_id[i] = load_wav(directory); }
Sound::Sample& Sound::Sample::operator = (const Sample& s) { if (&s == this) return *this; filename = s.filename; unique = s.unique; loud = s.loud; quiet = s.quiet; last_was_loud = s.last_was_loud; if (sample) destroy_sample(sample); sample = load_sample(filename.c_str()); return *this; }
Menu::~Menu() { // Destory Bitmaps destroy_bitmap( buffer); destroy_bitmap( menu); destroy_bitmap( menuselect); destroy_bitmap( help); destroy_bitmap( cursor[0]); destroy_bitmap( cursor[1]); destroy_bitmap( levelSelectLeft); destroy_bitmap( levelSelectRight); destroy_bitmap( levelSelectNumber); // Destory Samples destroy_sample( click); destroy_sample( intro); // Fade out highcolor_fade_out(16); // Clean up fmod FSOUND_Close(); }
void Unload_SFX() { int i; #ifdef DEBUG fprintf(stderr, "Free sound effect from memory\n"); #endif for (i=0;i<MAX_SFX;i++) { if (sfx_id[i]) { destroy_sample(sfx_id[i]); } } }
void showIntro() { SAMPLE *copyAmbient = makeSample("Menu_Sounds/Intro Wind.wav"); BITMAP *copyBackground = makeBitmap("Menu_Images/Copyright Intro Screen.bmp"); double startTime; blit(copyBackground, screen, 0,0,0,0,1024,768);//Draw the buffer to the screen play_sample(copyAmbient, 255, 0, 1000, 0); startTime = time(0); while (startTime + 10 > time(0) && !key[KEY_ESC]) { } stop_sample(copyAmbient); destroy_sample(copyAmbient); destroy_bitmap(copyBackground); }
void ResourceHandler::destroy() { std::map<std::string, BITMAP*>::iterator it; for (it = mBitmaps.begin(); it != mBitmaps.end(); it++) { destroy_bitmap((*it).second); } std::map<std::string, SAMPLE*>::iterator it2; for (it2 = mSamples.begin(); it2 != mSamples.end(); it2++) { destroy_sample((*it2).second); } }
void destroy_it(MODULUS *j) { if (song->Music == j) stop_it(); //remove patterns: for (int i=0; i<j->NumPatterns; i++) { free(j->Pattern[i].Note); } if (j->Pattern) free(j->Pattern); //remove instruments; if (j->Instrument) free(j->Instrument); //remove samples; for (int i=0; i<j->NumSamples; i++) { destroy_sample(j->Sample[i].Sample); } if (j->Sample) free(j->Sample); //remove orders: if (j->Order) free(j->Order); //remove channels: for (int i=0; i<64; i++) { if (j->Channel[i].VChannel) { MODULUS_VCHANNEL *vchn = song->Music->Channel[i].VChannel; MODULUS_VCHANNEL *prev = NULL; if (!vchn) continue; for (;;) { deallocate_voice(vchn->voice); prev = vchn; vchn = vchn->next; free(prev); if (!vchn) break; } } } free(j); }
//Unload the bitmap from the memory. Unload sound from memory. ball::~ball() { if (image !=NULL) destroy_bitmap(image); if (swing !=NULL) destroy_sample(swing); if (balllost !=NULL) destroy_bitmap(balllost); if (gameover !=NULL) destroy_bitmap(gameover); if (win !=NULL) destroy_bitmap(win); if (buffer !=NULL) destroy_bitmap(buffer); for (int i=0; i<6; i++) { if (score[i]!= NULL) destroy_bitmap (score[i]); } }
bool som::carregar(string arquivo) { if(!egl_init) return false; string ext = arquivo.substr(arquivo.size()-4,arquivo.size()-1); std::transform(ext.begin(), ext.end(), ext.begin(),static_cast < int(*)(int) > (tolower)); if (ext == ".wav") { tipo = T_WAV; if(smp) { destroy_sample(smp); voice = -1; } smp = load_wav(arquivo.c_str()); if(!smp) { egl_erro("Erro carregando arquivo: " + arquivo); egl_debug = true; return false; } } else { tipo = T_MID; if(mid) { destroy_midi(mid); voice = -1; } mid = load_midi(arquivo.c_str()); if(!mid) { egl_erro("Erro carregando arquivo: " + arquivo); egl_debug = true; return false; } } return true; }
int main( void ) { /* first, set up Allegro and the graphics mode */ allegro_init(); /* initialize Allegro */ install_keyboard(); /* install the keyboard for Allegro to use */ install_sound( DIGI_AUTODETECT, MIDI_AUTODETECT, NULL ); set_color_depth( 16 ); /* set the color depth to 16-bit */ set_gfx_mode( GFX_AUTODETECT, 640, 480, 0, 0 ); /* set graphics mode */ ball = load_bitmap( "ball.bmp", NULL ); /* load the ball bitmap */ bar = load_bitmap( "bar.bmp", NULL); /* load the bar bitmap */ buffer = create_bitmap(SCREEN_W, SCREEN_H);/* create buffer */ boing = load_sample( "boing.wav" ); /* load the sound file */ ball_x = SCREEN_W / 2; /* give the ball its initial x-coordinate */ ball_y = SCREEN_H / 2; /* give the ball its initial y-coordinate */ barL_y = SCREEN_H / 2; /* give left paddle its initial y-coordinate */ barR_y = SCREEN_H / 2; /* give right paddle its initial y-coordinate */ srand( time( NULL ) ); /* seed the random function ... */ direction = rand() % 4; /* and then make a random initial direction */ while ( !key[KEY_ESC] )/* until the escape key is pressed ... */ { moveBall(); /* move the ball */ respondToKeyboard(); /* respond to keyboard input */ /* now, perform double buffering */ clear_to_color( buffer, makecol( 255, 255, 255 ) ); blit( ball, buffer, 0, 0, ball_x, ball_y, ball->w, ball->h ); blit( bar, buffer, 0, 0, 0, barL_y, bar->w, bar->h ); blit( bar, buffer, 0, 0, 620, barR_y, bar->w, bar->h ); blit( buffer, screen, 0, 0, 0, 0, buffer->w, buffer->h ); clear_bitmap( buffer ); } /* end while */ destroy_bitmap( ball ); /* destroy the ball bitmap */ destroy_bitmap( bar ); /* destroy the bar bitmap */ destroy_bitmap( buffer ); /* destroy the buffer bitmap */ destroy_sample( boing ); /* destroy the boing sound file */ return 0; } /* end function main */
void sound_cache_free(char* buffer, bool is_wave) { _sound_cache_mutex.Lock(); #ifdef SOUND_CACHE_DEBUG printf("sound_cache_free(%d %d)\n", (unsigned int)buffer, (unsigned int)is_wave); #endif int i; for (i = 0; i < psp_audio_cachesize; i++) { if (sound_cache_entries[i].data == buffer) { if (sound_cache_entries[i].reference > 0) sound_cache_entries[i].reference--; #ifdef SOUND_CACHE_DEBUG printf("..decreased reference count of slot %d to %d\n", i, sound_cache_entries[i].reference); #endif _sound_cache_mutex.Unlock(); return; } } #ifdef SOUND_CACHE_DEBUG printf("..freeing uncached sound\n"); #endif // Sound is uncached if (i == psp_audio_cachesize) { if (is_wave) destroy_sample((SAMPLE*)buffer); else free(buffer); } _sound_cache_mutex.Unlock(); }