/** * Produce various sound effects on supplied stereo channel(s) * Override currently playing sound only if lower or same priority */ void SoundHandler::playSound(int16 sound, byte priority) { // uint32 dwVolume; // Left, right volume of sound sound_pt sound_p; // Sound data uint16 size; // Size of data static byte curPriority = 0; // Priority of currently playing sound // Sound disabled if (!_vm->_config.soundFl || !_vm->_mixer->isReady()) return; syncVolume(); // // See if last wave still playing - if so, check priority // if (waveOutUnprepareHeader(hwav, lphdr, sizeof(WAVEHDR)) == WAVERR_STILLPLAYING) // if (priority < curPriority) // Don't override unless priority >= current // return; // else // Stop_sound(); curPriority = priority; // Get sound data if ((sound_p = _vm->_file->getSound(sound, &size)) == 0) return; Audio::AudioStream *stream = Audio::makeRawStream(sound_p, size, 11025, Audio::FLAG_UNSIGNED); _vm->_mixer->playStream(Audio::Mixer::kSFXSoundType, &_soundHandle, stream); }
void SoundGenMIDI::play(int resnum) { MIDISound *track; stop(); _isGM = true; track = (MIDISound *)_vm->_game.sounds[resnum]; // Convert AGI Sound data to MIDI int midiMusicSize = convertSND2MIDI(track->_data, &_midiData); MidiParser *parser = MidiParser::createParser_SMF(); if (parser->loadMusic(_midiData, midiMusicSize)) { parser->setTrack(0); parser->setMidiDriver(this); parser->setTimerRate(_driver->getBaseTempo()); parser->property(MidiParser::mpCenterPitchWheelOnUnload, 1); _parser = parser; syncVolume(); _isPlaying = true; } else { delete parser; } }
void DeviceWidget::setDevice(IMMDevice * device) { dvp->device = device; device->Activate(__uuidof(IAudioEndpointVolume), CLSCTX_ALL, NULL, (void**)&dvp->endpoint_volume); syncMute(); syncVolume(); if (dvp->endpoint_volume != NULL) dvp->endpoint_volume->RegisterControlChangeNotify(vol_object); }
void MusicPlayer::playSMF(int track, bool loop) { Common::StackLock lock(_mutex); if (_isPlaying && track == _track) { debugC(2, kDraciSoundDebugLevel, "Already plaing track %d", track); return; } stop(); _isGM = true; // Load MIDI resource data Common::File musicFile; Common::String musicFileName = Common::String::format(_pathMask.c_str(), track); musicFile.open(musicFileName.c_str()); if (!musicFile.isOpen()) { debugC(2, kDraciSoundDebugLevel, "Cannot open track %d", track); return; } int midiMusicSize = musicFile.size(); free(_midiData); _midiData = (byte *)malloc(midiMusicSize); musicFile.read(_midiData, midiMusicSize); musicFile.close(); MidiParser *parser = MidiParser::createParser_SMF(); if (parser->loadMusic(_midiData, midiMusicSize)) { parser->setTrack(0); parser->setMidiDriver(this); parser->setTimerRate(_driver->getBaseTempo()); parser->property(MidiParser::mpCenterPitchWheelOnUnload, 1); _parser = parser; syncVolume(); _isLooping = loop; _isPlaying = true; _track = track; debugC(2, kDraciSoundDebugLevel, "Playing track %d", track); } else { debugC(2, kDraciSoundDebugLevel, "Cannot play track %d", track); delete parser; } }
/** * Produce various sound effects on supplied stereo channel(s) * Override currently playing sound only if lower or same priority */ void SoundHandler::playSound(int16 sound, const byte priority) { // uint32 dwVolume; // Left, right volume of sound sound_pt sound_p; // Sound data uint16 size; // Size of data // Sound disabled if (!_vm->_config.soundFl || !_vm->_mixer->isReady()) return; syncVolume(); _curPriority = priority; // Get sound data if ((sound_p = _vm->_file->getSound(sound, &size)) == 0) return; Audio::AudioStream *stream = Audio::makeRawStream(sound_p, size, 11025, Audio::FLAG_UNSIGNED); _vm->_mixer->playStream(Audio::Mixer::kSFXSoundType, &_soundHandle, stream); }
void MidiPlayer::play(uint8 *stream, uint16 size) { debugC(3, kDebugMusic, "MidiPlayer::play"); if (!stream) { stop(); return; } stop(); _midiData = (uint8 *)malloc(size); if (_midiData) { memcpy(_midiData, stream, size); _mutex.lock(); syncVolume(); _parser->loadMusic(_midiData, size); _parser->setTrack(0); _isLooping = false; _isPlaying = true; _mutex.unlock(); } }
void MidiPlayer::play(uint8 *stream, uint16 size) { debugC(3, kDebugMusic, "MidiPlayer::play"); Common::StackLock lock(_mutex); stop(); if (!stream) return; _midiData = (uint8 *)malloc(size); if (_midiData) { memcpy(_midiData, stream, size); syncVolume(); // FIXME: syncVolume calls setVolume which in turn also locks the mutex! ugh _parser = MidiParser::createParser_SMF(); _parser->loadMusic(_midiData, size); _parser->setTrack(0); _parser->setMidiDriver(this); _parser->setTimerRate(_driver->getBaseTempo()); _isLooping = false; _isPlaying = true; } }