scummvm/engines/pink/sound.h

55 lines
1.6 KiB
C
Raw Normal View History

2018-03-15 20:04:49 +00:00
/* ScummVM - Graphic Adventure Engine
*
* ScummVM is the legal property of its developers, whose names
* are too numerous to list here. Please refer to the COPYRIGHT
* file distributed with this source distribution.
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
2018-03-15 20:04:49 +00:00
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
2018-03-15 20:04:49 +00:00
*
*/
#ifndef PINK_SOUND_H
#define PINK_SOUND_H
2018-05-21 09:30:27 +00:00
#include "audio/mixer.h"
2018-06-23 06:54:33 +00:00
#include "audio/timestamp.h"
2018-05-21 09:30:27 +00:00
2018-06-09 17:26:32 +00:00
#include "common/system.h"
2018-03-15 20:04:49 +00:00
2018-06-29 11:26:22 +00:00
#include "pink/constants.h"
2018-06-09 17:26:32 +00:00
namespace Pink {
2018-03-15 20:04:49 +00:00
class Sound {
public:
2018-06-09 17:26:32 +00:00
~Sound() { stop(); }
void play(Common::SeekableReadStream *stream, Audio::Mixer::SoundType type, byte volume = 100, int8 balance = 0, bool isLoop = false);
2018-03-15 20:04:49 +00:00
2020-02-13 20:28:22 +00:00
bool isPlaying() const { return g_system->getMixer()->isSoundHandleActive(_handle); }
2018-03-15 20:04:49 +00:00
2018-06-09 17:26:32 +00:00
void stop() { g_system->getMixer()->stopHandle(_handle); }
2018-03-15 20:04:49 +00:00
2018-06-09 17:26:32 +00:00
void pause(bool paused) { g_system->getMixer()->pauseHandle(_handle, paused); }
2018-03-15 20:04:49 +00:00
2020-02-13 20:28:22 +00:00
uint64 getCurrentSample() const { return (uint64)g_system->getMixer()->getElapsedTime(_handle).msecs() * kSampleRate / 1000; }
2018-03-15 20:04:49 +00:00
private:
2018-05-22 05:03:37 +00:00
Audio::SoundHandle _handle;
2018-03-15 20:04:49 +00:00
};
} // End of namespace Pink
#endif