SsScene1302Fence::SsScene1302Fence(NeverhoodEngine *vm) : StaticSprite(vm, 0x11122122, 200) { _firstY = _y; if (getGlobalVar(V_FLYTRAP_RING_FENCE)) _y += 152; loadSound(0, 0x7A00400C); loadSound(1, 0x78184098); SetUpdateHandler(&SsScene1302Fence::update); SetMessageHandler(&SsScene1302Fence::handleMessage); SetSpriteUpdate(NULL); }
SsScene2504Button::SsScene2504Button(NeverhoodEngine *vm) : StaticSprite(vm, 1400), _countdown(0), _isSoundPlaying(false) { loadSprite(0x070220D9, kSLFDefDrawOffset | kSLFDefPosition | kSLFDefCollisionBoundsOffset, 400); setVisible(false); loadSound(0, 0x4600204C); loadSound(1, 0x408C0034); loadSound(2, 0x44043000); loadSound(3, 0x44045000); SetMessageHandler(&SsScene2504Button::handleMessage); SetUpdateHandler(&SsScene2504Button::update); }
void keypressSpecial(int key, int x, int y){ if (key == GLUT_KEY_UP) { loadSound("./wav/tick.wav"); playSound(); // if(!collision()) if(allow_movement) { if(camera % 4==3 ) move_block_left(); else if(camera % 4==1 ) move_block_right(); else if (camera % 4==2 ) move_block_down(); else if( camera % 4==0 ) move_block_up(); } // move_block_up(); } if (key== GLUT_KEY_DOWN){ loadSound("./wav/tick.wav"); playSound(); // if(allow_movement) // move_block_down(); if(allow_movement) { if(camera % 4==1 ) move_block_left(); else if(camera % 4==3 ) move_block_right(); else if (camera % 4==0 ) move_block_down(); else if( camera % 4==2 ) move_block_up(); } } if (key== GLUT_KEY_LEFT){ loadSound("./wav/tick.wav"); playSound(); // if(allow_movement) // move_block_left(); if(allow_movement) { if(camera % 4==0 ) move_block_left(); else if(camera % 4==2 ) move_block_right(); else if (camera % 4==3 ) move_block_down(); else if( camera % 4==1 ) move_block_up(); } } if (key== GLUT_KEY_RIGHT){ loadSound("./wav/tick.wav"); playSound(); // if(allow_movement) // move_block_right(); if(allow_movement) { if(camera % 4==2 ) move_block_left(); else if(camera % 4==0 ) move_block_right(); else if (camera % 4==1 ) move_block_down(); else if( camera % 4==3 ) move_block_up(); } } }
SoundManager::SoundManager():m_BackgroundMusic(NULL), m_LaserSound(NULL), m_ZombieSound(NULL){ //Init the sound librairy std::cout << "---------------------------------" << std::endl; std::cout << "SOUND MANAGER : Initialisation" << std::endl; if(Mix_OpenAudio(44100, MIX_DEFAULT_FORMAT, MIX_DEFAULT_CHANNELS, 1024) == -1) { std::cout << "FAILURE : Impossible to init : " << Mix_GetError() << std::endl; }else{ std::cout << "SUCCES" << std::endl; } Mix_AllocateChannels(3); loadSound(&m_LaserSound, "./audio/laser_1.ogg"); loadSound(&m_ZombieSound, "./audio/zombie.ogg"); }
SsScene2609Button::SsScene2609Button(NeverhoodEngine *vm, Scene *parentScene) : StaticSprite(vm, 1400), _parentScene(parentScene), _countdown(0) { SetUpdateHandler(&SsScene2609Button::update); SetMessageHandler(&SsScene2609Button::handleMessage); loadSprite(0x825A6923, kSLFDefDrawOffset | kSLFDefPosition | kSLFDefCollisionBoundsOffset, 400); if (!getGlobalVar(V_WATER_RUNNING)) setVisible(false); loadSound(0, 0x10267160); loadSound(1, 0x7027FD64); loadSound(2, 0x44043000); loadSound(3, 0x44045000); }
AsScene1306Elevator::AsScene1306Elevator(NeverhoodEngine *vm, Scene *parentScene, AnimatedSprite *asElevatorDoor) : AnimatedSprite(vm, 1100), _parentScene(parentScene), _asElevatorDoor(asElevatorDoor), _isUp(false), _isDown(true), _countdown(0) { _x = 320; _y = 240; createSurface1(0x043B0270, 100); startAnimation(0x043B0270, 0, -1); _newStickFrameIndex = 0; loadSound(0, 0x1C100E83); loadSound(1, 0x1C08CEC5); loadSound(2, 0x5D011E87); SetMessageHandler(&AsScene1306Elevator::handleMessage); }
AsScene2402TV::AsScene2402TV(NeverhoodEngine *vm, Klaymen *klaymen) : AnimatedSprite(vm, 1100), _klaymen(klaymen), _countdown1(0), _countdown2(0) { _x = 260; _y = 210; createSurface(100, 127, 90); setDoDeltaX(1); SetMessageHandler(&Sprite::handleMessage); if (!getGlobalVar(V_TV_JOKE_TOLD)) { loadSound(0, 0x58208810); _countdown1 = 48; startAnimation(0x4919397A, 0, -1); _newStickFrameIndex = 0; SetUpdateHandler(&AsScene2402TV::upWait); } else { int16 frameIndex; if (_klaymen->getX() > 320) _currFrameIndex = 29; frameIndex = CLIP<int16>((_klaymen->getX() - _x + 150) / 10, 0, 29); startAnimation(0x050A0103, frameIndex, -1); _newStickFrameIndex = frameIndex; _countdown1 = 0; SetUpdateHandler(&AsScene2402TV::upFocusKlaymen); } }
Sound::Sound( char *filename ) { channel = -1 ; sound = NULL ; loadSound( filename ) ; }
void keypressed(unsigned char key, int x, int y) { if (key == 's') { viewer->pos[2]+=0.05; } if (key == 'w') { viewer->pos[2]-=0.05; } if (key == 'a') { viewer->pos[0]-=0.05; } if (key == 'd') { viewer->pos[0]+=0.05; } if (key == 'b') { viewer->pos[1]+=0.05; } if (key == 'n') { viewer->pos[1]-=0.05; } if (key == 'z') { save_screenshot("a.tga",WIDTH,HEIGHT); } if( key == 'r') {rotate_try(X_axis);} if( key == 't') {rotate_try(Y_axis);} if( key == 'y') {rotate_try(Z_axis);} if (key == 'x') { printf("\n\nYour total score is %d\n",tetris_board->score ); exit(0); } if( key == ' ') { move_block_max_down(); } if (key=='m') { if(music==0){ alSourceStop(source); music=1; } else { loadSound("./wav/theme.wav"); alSourcePlay(source); music=0; } } }
Sound *AudioSquall::loadSound(const char *name) { SquallSound *sound = new SquallSound(this); loadSound(name, *sound); return sound; }
S32 PCMAudioManager::loadSound(const char *assetName) { Property *prop = btGetContext()->appProperties->get("debug_sounds"); BOOL32 debugSounds = FALSE; if (prop) { debugSounds = prop->getBoolValue(); } if (isSoundLoaded(assetName)) { return getSoundId(assetName); } int assetSize = 0; unsigned char *fileData = _platform_load_asset(assetName, &assetSize); S32 sndId = -1; if (fileData) { signed short *decoded; int channels, len; unsigned int sampleRate = 0; len = stb_vorbis_decode_memory(fileData, assetSize, &channels, &sampleRate, &decoded); if (debugSounds) { char buf[1024]; sprintf(buf, "Loaded %s: (%i enc bytes) length=%i channels=%i rate=%i", assetName, assetSize, len, channels, sampleRate); logmsg(buf); } sndId = loadSound(decoded, len * channels, sampleRate, channels, assetName); } _platform_free_asset(fileData); return sndId; }
SoundPtr ALSubsystem::play2D(String name, bool startPaused) { SoundPtr out; if(mAudioBuffers.find(name) == mAudioBuffers.end()) { loadSound(name); if(mAudioBuffers.find(name) == mAudioBuffers.end()) { std::cout<<"Could not play sound, could not find or load audio.\n"; return out; } } if(!hasSources()) { std::cout<<"Could not play sound, no available sound sources.\n"; } else { out.bind(new BufferedSound(getSource(), mAudioBuffers[name], mAudioData[name])); mActiveSounds.push_back(out); if(!startPaused) out->play(); } return out; }
void load(const std::string& filename) { if (filename.length() >= 4 && filename.substr(filename.length() - 4) == ".ogg") { loadSound(filename); } else { loadSprite(filename); } }
static void preCacheSound(char *name) { int i; Mix_Chunk *chunk = NULL; for (i=0;i<soundIndex;i++) { if (strcmpignorecase(sound[i].name, name) == 0) { return; } } if (soundIndex == MAX_SOUNDS) { showErrorAndExit("Ran out of space for sounds"); } chunk = loadSound(name); sound[soundIndex].effect = chunk; STRNCPY(sound[soundIndex].name, name, sizeof(sound[soundIndex].name)); soundIndex++; }
AsScene1105TeddyBear::AsScene1105TeddyBear(NeverhoodEngine *vm, Scene *parentScene) : AnimatedSprite(vm, 1100), _parentScene(parentScene) { createSurface(100, 556, 328); _x = 320; _y = 240; SetUpdateHandler(&AnimatedSprite::update); SetMessageHandler(&AsScene1105TeddyBear::handleMessage); startAnimation(0x65084002, 0, -1); _newStickFrameIndex = 0; setVisible(false); _needRefresh = true; updatePosition(); loadSound(0, 0xCE840261); loadSound(1, 0xCCA41A62); }
SsScene2901LocationButtonLight::SsScene2901LocationButtonLight(NeverhoodEngine *vm, int which, uint index) : StaticSprite(vm, 900), _index(index) { loadSprite(kSsScene2901LocationButtonLightFileHashes1[which * 6 + index], kSLFDefDrawOffset | kSLFDefPosition, 900); setVisible(false); loadSound(0, kSsScene2901LocationButtonLightFileHashes2[_index]); }
void CubeAnim::changeMusic(const int i) { if (i == 1) { _itp++; if (_itp == _paths.end()) _itp = _paths.begin(); } else if (i == -1) { if (_itp == _paths.begin()) { _itp = _paths.end(); _itp--; } else _itp--; } if (_paths.size() == 0) std::cout << "Error on loading" << std::endl; else { if (loadSound(*_itp) == false) return; } }
void AGOSEngine::vc83_playSoundLoop() { uint16 sound = vcReadNextWord(); int16 vol = vcReadNextWord(); int16 pan = vcReadNextWord(); loadSound(sound, pan, vol, Sound::TYPE_SFX5); }
SsScene3010DeadBoltButton::SsScene3010DeadBoltButton(NeverhoodEngine *vm, Scene *parentScene, int buttonIndex, int initCountdown, bool initDisabled) : StaticSprite(vm, 900), _parentScene(parentScene), _buttonLocked(false), _countdown1(0), _countdown2(0), _buttonIndex(buttonIndex) { _buttonEnabled = getSubVar(VA_LOCKS_DISABLED, kScene3010ButtonNameHashes[_buttonIndex]) != 0; createSurface(400, 88, 95); setSprite(kScene3010DeadBoltButtonFileHashes2[_buttonIndex]); if (initDisabled) disableButton(); else if (_buttonEnabled) _countdown1 = initCountdown * 12 + 1; loadSound(0, 0xF4217243); loadSound(1, 0x44049000); loadSound(2, 0x6408107E); SetUpdateHandler(&SsScene3010DeadBoltButton::update); SetMessageHandler(&SsScene3010DeadBoltButton::handleMessage); }
SoundPtr ALSubsystem::play2D(String name, bool startPaused) { SoundPtr out; if(mAudioBuffers.find(name) == mAudioBuffers.end()) { loadSound(name); if(mAudioBuffers.find(name) == mAudioBuffers.end()) { Logger::getPtr()->logMessage("Could not play sound, could not find or load audio."); return out; } } if(!hasSources()) { Logger::getPtr()->logMessage("Could not play sound, no available sound sources."); } else { out.bind(new BufferedSound(getSource(), mAudioBuffers[name])); mActiveSounds.push_back(out); out->setGain(0.f, 1.f, 1.f); if(!startPaused) out->play(); } return out; }
const bool SoundPool::loadSound(const locationStringType path) { sndFileType type = this->strToFileType(path); if (type) return loadSound(path, type); return false; }
int main( int argc, char *argv[] ) { char *path; #ifdef __FreeBSD__ fpsetmask(0); #endif SystemInit(&argc, argv); path = getFullPath("settings.txt"); if(path != 0) initMainGameSettings(path); /* reads defaults from ~/.gltronrc */ else { printf("fatal: could not settings.txt, exiting...\n"); exit(1); } parse_args(argc, argv); /* sound */ #ifdef SOUND printf("initializing sound\n"); initSound(); path = getFullPath("gltron.it"); if(path == 0 || loadSound(path)) printf("error trying to load sound\n"); else { if(game->settings->playMusic) playSound(); free(path); } #endif printf("loading menu\n"); path = getFullPath("menu.txt"); if(path != 0) pMenuList = loadMenuFile(path); else { printf("fatal: could not load menu.txt, exiting...\n"); exit(1); } printf("menu loaded\n"); free(path); initGameStructures(); resetScores(); initData(); setupDisplay(game->screen); switchCallbacks(&guiCallbacks); switchCallbacks(&guiCallbacks); SystemMainLoop(); return 0; }
PlayerProtoss::PlayerProtoss(int x, int direction, int type, const char *name, int n_player) : Player(x, direction, type, name, n_player) { sprite = graphics->load_image(P_PROTOSS_PLAYER); portrait = graphics->load_image(P_PROTOSS_PORTRAIT); comboflash = new Animation(P_PROTOSS_COMBOFLASH, 2, 2, COMBOFLASH_V); s_hit = loadSound(S_PROTOSS_HIT); s_win = loadSound(S_PROTOSS_WIN); s_win2 = loadSound(S_PROTOSS_WIN2); s_lose = loadSound(S_PROTOSS_LOSE); m = 90; if (direction == RIGHT) title = graphics->load_image(P_PROTOSS_TITLE_L); else title = graphics->load_image(P_PROTOSS_TITLE_R); setup(); }
SsScene1105OpenButton::SsScene1105OpenButton(NeverhoodEngine *vm, Scene *parentScene) : StaticSprite(vm, 900), _parentScene(parentScene), _countdown(0), _isClicked(false) { loadSprite(0x8228A46C, kSLFDefDrawOffset | kSLFDefPosition | kSLFDefCollisionBoundsOffset, 400); setVisible(false); loadSound(0, 0x44045140); SetUpdateHandler(&SsScene1105OpenButton::update); SetMessageHandler(&SsScene1105OpenButton::handleMessage); }
bool playSound(const char *filename, int chn, int loop, int ticks) { Mix_Chunk *chk = loadSound(filename); if (!chk) return false; int ret = Mix_PlayChannelTimed(chn, chk, loop, ticks); return ret != -1; }
void playSound(char *name) { int i; Mix_Chunk *chunk = NULL; if (game.audio == FALSE || game.sfxDefaultVolume == 0) { return; } for (i=0;i<soundIndex;i++) { if (strcmpignorecase(sound[i].name, name) == 0) { chunk = sound[i].effect; if (chunk == NULL) { return; } break; } } if (chunk == NULL) { if (soundIndex == MAX_SOUNDS) { showErrorAndExit("Ran out of space for sounds"); } chunk = loadSound(name); sound[soundIndex].effect = chunk; STRNCPY(sound[soundIndex].name, name, sizeof(sound[soundIndex].name)); soundIndex++; if (chunk == NULL) { return; } } Mix_VolumeChunk(chunk, game.sfxDefaultVolume * VOLUME_STEPS); #if DEV == 1 if (game.gameType == REPLAYING) { printf("%f %s\n", (float)game.frames / 60, name); } #endif playSoundChunk(chunk, -1, 0); }
SsScene3011Button::SsScene3011Button(NeverhoodEngine *vm, Scene *parentScene, bool flag) : StaticSprite(vm, 1400), _parentScene(parentScene), _countdown(0) { loadSprite(flag ? 0x11282020 : 0x994D0433, kSLFDefDrawOffset | kSLFDefPosition | kSLFDefCollisionBoundsOffset, 400); setVisible(false); loadSound(0, 0x44061000); SetUpdateHandler(&SsScene3011Button::update); SetMessageHandler(&SsScene3011Button::handleMessage); }
AsScene1302Bridge::AsScene1302Bridge(NeverhoodEngine *vm, Scene *parentScene) : AnimatedSprite(vm, 1100), _parentScene(parentScene) { _x = 320; _y = 240; createSurface1(0x88148150, 500); if (!getGlobalVar(V_FLYTRAP_RING_BRIDGE)) { startAnimation(0x88148150, 0, -1); _newStickFrameIndex = 0; } else { startAnimation(0x88148150, -1, -1); _newStickFrameIndex = STICK_LAST_FRAME; } loadSound(0, 0x68895082); loadSound(1, 0x689BD0C1); SetUpdateHandler(&AnimatedSprite::update); SetMessageHandler(&AsScene1302Bridge::handleMessage); }
SsScene3009FireCannonButton::SsScene3009FireCannonButton(NeverhoodEngine *vm, Scene3009 *parentScene) : StaticSprite(vm, 1400), _parentScene(parentScene), _isClicked(false) { loadSprite(0x120B24B0, kSLFDefDrawOffset | kSLFDefPosition | kSLFDefCollisionBoundsOffset, 400); setVisible(false); SetUpdateHandler(&SsScene3009FireCannonButton::update); SetMessageHandler(&SsScene3009FireCannonButton::handleMessage); loadSound(0, 0x3901B44F); }
void sfSoundPlayer::setFilePath(string inFilePath) { if (inFilePath != "") { filePath = inFilePath; // do not stream small files: they won't play int fileSize = _getFileSize(inFilePath); doStream = (fileSize < 1024 * sfAppSettings::getIntValue("SOUNDFILE_MIN_KBSIZE_FOR_STREAMING") ) ? 0 : 1; loadSound(filePath, doStream); play(); } }