void SoundChannel::play(uint32 id, uint32 volume, uint16 heading, uint16 attenuation, uint unk1, uint unk2, uint unk3, SoundType type) { // TODO: Should stop and start again if (_playing) return; // Load the name of the sound from its id _name = _vm->_db->getSoundName(id); _volume = volume; // Open the file to a stream _stream = makeAudioStream(_name); if (!_stream) return; uint16 mixerVolume = _volume * Audio::Mixer::kMaxChannelVolume / 100; // Play the sound g_system->getMixer()->playStream(Audio::Mixer::kSFXSoundType, &_handle, _stream, -1, mixerVolume); // Update state _id = id; _type = type; _playing = true; _vm->_state->setVar(id, 1); }
void Sound::play() { Audio::RewindableAudioStream *rewindableStream = makeAudioStream(); if (!rewindableStream) { return; } Audio::AudioStream *playStream; if (_looping) { playStream = Audio::makeLoopingAudioStream(rewindableStream, 0); } else { playStream = rewindableStream; } g_system->getMixer()->playStream(getMixerSoundType(), &_handle, playStream, -1, _volume * Audio::Mixer::kMaxChannelVolume); }
ChannelHandle SoundManager::playSoundFile(Common::SeekableReadStream *wavStream, SoundType type, bool loop) { checkReady(); if (!wavStream) throw Common::Exception("No stream"); AudioStream *audioStream = makeAudioStream(wavStream); if (loop) { RewindableAudioStream *reAudStream = dynamic_cast<RewindableAudioStream *>(audioStream); if (!reAudStream) warning("SoundManager::playSoundFile(): The input stream cannot be rewound, this will not loop."); else audioStream = makeLoopingAudioStream(reAudStream, 0); } return playAudioStream(audioStream, type); }
void RawSound::playSound(uint sound, uint loopSound, Audio::Mixer::SoundType type, Audio::SoundHandle *handle, bool loop, int vol) { // Sound looping and volume are ignored. _mixer->playStream(type, handle, makeAudioStream(sound)); }