void StageNode::GUIRequest_cb(const boost::shared_ptr<std_msgs::String const>& msg) { #if NEW_GUI_ACCESS ROS_INFO_STREAM(msg->data); if (msg->data=="screenshot") Screenshot(); else if (msg->data=="footprints") Footprints(); else if (msg->data.substr(0,7)=="speedup") { std::vector<std::string> pp; boost::split(pp, msg->data, boost::is_any_of("_")); float s=1.0; if (pp.size()>1) { s = atof(pp[1].c_str()); if (s<1e-6) s=1.0; } Speedup(s); } #endif }
// Volume 0-I2X (1) int CAudioChannel::Start (short nSound, int nSoundClass, fix nVolume, int nPan, int bLooping, int nLoopStart, int nLoopEnd, int nSoundObj, int nSpeed, const char *pszWAV, CFixVector* vPos) { CSoundSample* soundP = NULL; int bPersistent = (nSoundObj > -1) || bLooping || (nVolume > I2X (1)); if (!(pszWAV && *pszWAV && gameOpts->sound.bUseSDLMixer)) { if (nSound < 0) return -1; if (!gameData.pig.sound.nSoundFiles [gameStates.sound.bD1Sound]) return -1; soundP = gameData.pig.sound.sounds [gameStates.sound.bD1Sound] + nSound % gameData.pig.sound.nSoundFiles [gameStates.sound.bD1Sound]; if (!(soundP->data [soundP->bCustom].Buffer () && soundP->nLength [soundP->bCustom])) return -1; } if (m_info.bPlaying) { m_info.bPlaying = 0; if (m_info.nSoundObj > -1) audio.EndSoundObject (m_info.nSoundObj); if (soundQueue.Channel () == audio.FreeChannel ()) soundQueue.End (); } #if USE_OPENAL if (m_info.source == 0xFFFFFFFF) { CFloatVector fPos; DigiALError (); alGenSources (1, &m_info.source); if (DigiALError ()) return -1; alSourcei (m_info.source, AL_BUFFER, soundP->buffer); if (DigiALError ()) return -1; alSourcef (m_info.source, AL_GAIN, ((nVolume < I2X (1)) ? X2F (nVolume) : 1) * 2 * X2F (m_info.nVolume)); alSourcei (m_info.source, AL_LOOPING, (ALuint) ((nSoundObj > -1) || bLooping || (nVolume > I2X (1)))); fPos.Assign (vPos ? *vPos : OBJECTS [LOCALPLAYER.nObject].nPosition.vPos); alSourcefv (m_info.source, AL_POSITION, reinterpret_cast<ALfloat*> (fPos)); alSource3f (m_info.source, AL_VELOCITY, 0, 0, 0); alSource3f (m_info.source, AL_DIRECTION, 0, 0, 0); if (DigiALError ()) return -1; alSourcePlay (m_info.source); if (DigiALError ()) return -1; } #endif #if USE_SDL_MIXER if (gameOpts->sound.bUseSDLMixer) { if (m_info.mixChunkP) { Mix_HaltChannel (m_info.nChannel); if (m_info.bBuiltIn) m_info.bBuiltIn = 0; else Mix_FreeChunk (m_info.mixChunkP); m_info.mixChunkP = NULL; } } #endif if (m_info.bResampled) { m_info.sample.Destroy (); m_info.bResampled = 0; } #if USE_SDL_MIXER if (gameOpts->sound.bUseSDLMixer) { //resample to two channels m_info.nChannel = audio.FreeChannel (); if (pszWAV && *pszWAV) { if (!(m_info.mixChunkP = LoadAddonSound (pszWAV, &m_info.bBuiltIn))) return -1; } else { int l; if (soundP->bHires) { l = soundP->nLength [soundP->bCustom]; m_info.sample.SetBuffer (soundP->data [soundP->bCustom].Buffer (), 1, l); m_info.mixChunkP = Mix_QuickLoad_WAV (reinterpret_cast<Uint8*> (m_info.sample.Buffer ())); } else { if (gameOpts->sound.bHires [0]) return -1; //cannot mix hires and standard sounds l = Resample (soundP, gameStates.sound.bD1Sound && (gameOpts->sound.digiSampleRate != SAMPLE_RATE_11K), songManager.MP3 ()); if (l <= 0) return -1; if (nSpeed < I2X (1)) l = Speedup (soundP, nSpeed); #if MAKE_WAV m_info.mixChunkP = Mix_QuickLoad_WAV (reinterpret_cast<Uint8*> (m_info.sample.Buffer ())); #else m_info.mixChunkP = Mix_QuickLoad_RAW (reinterpret_cast<Uint8*> (m_info.sample.Buffer ()), l); #endif } } Mix_VolPan (m_info.nChannel, nVolume, nPan); Mix_PlayChannel (m_info.nChannel, m_info.mixChunkP, bLooping ? -1 : nLoopEnd - nLoopStart); } else #else if (pszWAV && *pszWAV) return -1; #endif { if (gameStates.sound.bD1Sound && (gameOpts->sound.digiSampleRate != SAMPLE_RATE_11K)) { int l = Resample (soundP, 0, 0); if (l <= 0) return -1; m_info.nLength = l; } else { m_info.sample.SetBuffer (soundP->data [soundP->bCustom].Buffer (), 1, m_info.nLength = soundP->nLength [soundP->bCustom]); } if (nSpeed < I2X (1)) Speedup (soundP, nSpeed); } m_info.nVolume = FixMul (audio.Volume (), nVolume); m_info.nPan = nPan; m_info.nPosition = 0; m_info.nSoundObj = nSoundObj; m_info.nSoundClass = nSoundClass; m_info.bLooped = bLooping; #if USE_OPENAL m_info.loops = bLooping ? -1 : nLoopEnd - nLoopStart + 1; #endif m_info.nSound = nSound; m_info.bPersistent = 0; m_info.bPlaying = 1; m_info.bPersistent = bPersistent; return audio.FreeChannel (); }