void audiomanager::music(char *name, int millis, char *cmd) { if(nosound) return; stopsound(); if(musicvol && *name) { if(cmd[0]) musicdonecmd = newstring(cmd); if(gamemusic->open(name)) { // fade if(millis > 0) { const int fadetime = 1000; gamemusic->fadein(lastmillis, fadetime); gamemusic->fadeout(lastmillis+millis, fadetime); } // play bool loop = cmd && cmd[0]; if(!gamemusic->playback(loop)) { conoutf("could not play music: %s", name); return; } setmusicvol(musicvol); } else conoutf("could not open music: %s", name); } }
void audiomanager::musicpreload(int id) { if(nosound) return; stopsound(); if(musicvol && (id>=M_FLAGGRAB && id<=M_LASTMINUTE2)) { char *name = musics[id]; conoutf("preloading music #%d : %s", id, name); if(gamemusic->open(name)) { defformatstring(whendone)("musicvol %d", musicvol); musicdonecmd = newstring(whendone); //conoutf("when done: %s", musicdonecmd); const int preloadfadetime = 3; gamemusic->fadein(lastmillis, preloadfadetime); gamemusic->fadeout(lastmillis+2*preloadfadetime, preloadfadetime); if(!gamemusic->playback(false)) { conoutf("could not play music: %s", name); return; } setmusicvol(1); // not 0 ! } else conoutf("could not open music: %s", name); } else setmusicvol(musicvol); // call "musicpreload -1" to ensure musicdonecmd runs - but it should w/o that }
void music(char *name) { if (nosound) return; stopsound(); if (soundvol && musicvol) { IString sn; strcpy_s(sn, "packages/"); strcat_s(sn, name); if (mod = Mix_LoadMUS(sn)) { Mix_PlayMusic(mod, -1); Mix_VolumeMusic((musicvol * MAXVOL) / 255); } } }
void cleanup() { recorder::stop(); cleanupserver(); showcursor(true); //#ifdef FAKESHOWCURSOR // if(scursor) SDL_FreeCursor(scursor); // scursor = ncursor = NULL; //#endif SDL_WM_GrabInput(SDL_GRAB_OFF); cleargamma(); freeocta(worldroot); extern void clear_command(); clear_command(); extern void clear_console(); clear_console(); extern void clear_mdls(); clear_mdls(); stopsound(); closelogfile(); SDL_Quit(); }
void music(char *name, char *cmd) { if(nosound) return; stopsound(); if(soundvol && musicvol && *name) { if(cmd[0]) musicdonecmd = newstring(cmd); s_sprintfd(sn)("packages/%s", name); const char *file = findfile(path(sn), "rb"); if((mod = Mix_LoadMUS(file))) { musicfile = newstring(file); Mix_PlayMusic(mod, cmd[0] ? 0 : -1); Mix_VolumeMusic((musicvol*MAXVOL)/255); } else { conoutf(CON_ERROR, "could not play music: %s", sn); } } }
void processUserInput() { // quits the game if player hits the escape key if (keyPressed[K_ESCAPE]) { g_quitGame = true; } else if ((keyPressed[K_RETURN]) && (next == 0) && (charLocation2.X == 24) && (charLocation2.Y == 10)) { Beep(1440, 30); next=98; charLocation.X = 2; charLocation.Y = 2; charLocation2.X = 68; charLocation2.Y = 2; } else if ((keyPressed[K_RETURN]) && (next == 0) && (charLocation2.X == 24) && (charLocation2.Y == 11)) { Beep(1440, 30); next = 99; charLocation.X = 2; charLocation.Y = 23; charLocation2.X = 68; charLocation2.Y = 23; } else if ((keyPressed[K_RETURN]) && (next == 0) && (charLocation2.X == 24) && (charLocation2.Y == 12)) { g_quitGame = true; } else if ((keyPressed[K_SPACE]) && ((next == 100) || (next == 16))) { Beep(1440, 30); next = 0; elapsedTime = 0; stopsound(); charLocation.X = 24; charLocation.Y = 10; charLocation2.X = 24; charLocation2.Y = 10; } else if ((keyPressed[K_SPACE]) && (next == 99)) { Beep(1440, 30); next = 0; charLocation.X = 24; charLocation.Y = 10; charLocation2.X = 24; charLocation2.Y = 10; } activewarp(); activeswap(); }
int xyzsound(short num,short i,long x,long y,long z) { long sndist, cx, cy, cz, j,k; short pitche,pitchs,cs; int voice, sndang, ca, pitch; // if(num != 358) return 0; if( num >= NUM_SOUNDS || FXDevice < 0 || ( (soundm[num]&8) && ud.lockout ) || SoundToggle == 0 || Sound[num].num > 3 || FX_VoiceAvailable(soundpr[num]) == 0 || (ps[myconnectindex].timebeforeexit > 0 && ps[myconnectindex].timebeforeexit <= 26*3) || ps[myconnectindex].gm&MODE_MENU) return -1; if( soundm[num]&128 ) { sound(num); return 0; } if( soundm[num]&4 ) { if(VoiceToggle==0 || (ud.multimode > 1 && PN == APLAYER && sprite[i].yvel != screenpeek && ud.coop != 1) ) return -1; for(j=0;j<NUM_SOUNDS;j++) for(k=0;k<Sound[j].num;k++) if( (Sound[j].num > 0) && (soundm[j]&4) ) return -1; } cx = ps[screenpeek].oposx; cy = ps[screenpeek].oposy; cz = ps[screenpeek].oposz; cs = ps[screenpeek].cursectnum; ca = ps[screenpeek].ang+ps[screenpeek].look_ang; sndist = FindDistance3D((cx-x),(cy-y),(cz-z)>>4); if( i >= 0 && (soundm[num]&16) == 0 && PN == MUSICANDSFX && SLT < 999 && (sector[SECT].lotag&0xff) < 9 ) sndist = divscale14(sndist,(SHT+1)); pitchs = soundps[num]; pitche = soundpe[num]; j = klabs(pitche-pitchs); if(j) { if( pitchs < pitche ) pitch = pitchs + ( rand()%j ); else pitch = pitche + ( rand()%j ); } else pitch = pitchs; sndist += soundvo[num]; if(sndist < 0) sndist = 0; if( sndist && PN != MUSICANDSFX && !cansee(cx,cy,cz-(24<<8),cs,SX,SY,SZ-(24<<8),SECT) ) sndist += sndist>>5; switch(num) { case PIPEBOMB_EXPLODE: case LASERTRIP_EXPLODE: case RPG_EXPLODE: if(sndist > (6144) ) sndist = 6144; if(sector[ps[screenpeek].cursectnum].lotag == 2) pitch -= 1024; break; default: if(sector[ps[screenpeek].cursectnum].lotag == 2 && (soundm[num]&4) == 0) pitch = -768; if( sndist > 31444 && PN != MUSICANDSFX) return -1; break; } if( Sound[num].num > 0 && PN != MUSICANDSFX ) { if( SoundOwner[num][0].i == i ) stopsound(num); else if( Sound[num].num > 1 ) stopsound(num); else if( badguy(&sprite[i]) && sprite[i].extra <= 0 ) stopsound(num); } if( PN == APLAYER && sprite[i].yvel == screenpeek ) { sndang = 0; sndist = 0; } else { sndang = 2048 + ca - getangle(cx-x,cy-y); sndang &= 2047; } if(Sound[num].ptr == 0) { if( loadsound(num) == 0 ) return 0; } else { if (Sound[num].lock < 200) Sound[num].lock = 200; else Sound[num].lock++; } if( soundm[num]&16 ) sndist = 0; if(sndist < ((255-LOUDESTVOLUME)<<6) ) sndist = ((255-LOUDESTVOLUME)<<6); if( soundm[num]&1 ) { if(Sound[num].num > 0) return -1; voice = FX_PlayLoopedAuto( Sound[num].ptr, soundsiz[num], 0, -1, pitch,sndist>>6,sndist>>6,0,soundpr[num],num); } else {
void lidinterrupt(void) { stopsound(); restartsound(1); }
#include "../include/ball_plate.h" #include "../include/wiimote_stuff.h" #include "../include/playsound.h" //************** Wiimote Callback Function ************************/ void cwiid_callback(cwiid_wiimote_t *wiimote, int mesg_count, union cwiid_mesg mesg[], struct timespec *timestamp) { int i, j; for (i=0; i < mesg_count; i++) { if (mesg[i].type == CWIID_MESG_BTN) { if (mesg[i].btn_mesg.buttons & CWIID_BTN_PLUS) { //printf("Plus Button Pressed!!\n"); mode = (mode+1)%4; next_mode++; } if (mesg[i].btn_mesg.buttons & CWIID_BTN_MINUS) { //printf("Minus Button Pressed!!\n"); if (mode == 0) mode = 3; else mode--; next_mode++; } if (mesg[i].btn_mesg.buttons & DOWN_BUTTON) { //printf("Down Button Pressed!!\n"); down_button_pressed = 1; } if (mesg[i].btn_mesg.buttons & UP_BUTTON) { //printf("Up Button Pressed!!\n"); up_button_pressed = 1; } if (mesg[i].btn_mesg.buttons & LEFT_BUTTON) { //printf("Left Button Pressed!!\n"); left_button_pressed = 1; } if (mesg[i].btn_mesg.buttons & RIGHT_BUTTON) { //printf("Right Button Pressed!!\n"); right_button_pressed = 1; } if (mesg[i].btn_mesg.buttons & CWIID_BTN_2) { //printf("2 Button Pressed!!\n"); two_button_pressed = 1; } if (mesg[i].btn_mesg.buttons & CWIID_BTN_1) { //printf("1 Button Pressed!!\n"); one_button_pressed = 1; } if (mesg[i].btn_mesg.buttons & CWIID_BTN_A) { mute++; if (mute%2 ==1) stopsound(); } } } }