libgui/include/gui/GuiSound.h

72 lines
2.0 KiB
C
Raw Permalink Normal View History

2018-06-21 20:44:58 +02:00
/****************************************************************************
* Copyright (C) 2015 Dimok
*
* 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.
*
* 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/>.
****************************************************************************/
#ifndef GUI_SOUND_H_
#define GUI_SOUND_H_
#include <gui/GuiElement.h>
2018-06-21 20:44:58 +02:00
//!Sound conversion and playback. A wrapper for other sound libraries - ASND, libmad, ltremor, etc
class GuiSound : public GuiElement {
2018-06-21 20:44:58 +02:00
public:
//!Constructor
//!\param sound Pointer to the sound data
//!\param filesize Length of sound data
2020-08-13 12:38:07 +02:00
GuiSound(const char *filepath);
GuiSound(const uint8_t *sound, int32_t length);
2018-06-21 20:44:58 +02:00
//!Destructor
virtual ~GuiSound();
2020-08-13 12:38:07 +02:00
2018-06-21 20:44:58 +02:00
//!Load a file and replace the old one
2020-08-13 12:38:07 +02:00
bool Load(const char *filepath);
2018-06-21 20:44:58 +02:00
//!Load a file and replace the old one
2020-08-13 12:38:07 +02:00
bool Load(const uint8_t *snd, int32_t len);
2018-06-21 20:44:58 +02:00
//!Start sound playback
void Play();
2020-08-13 12:38:07 +02:00
2018-06-21 20:44:58 +02:00
//!Stop sound playback
void Stop();
2020-08-13 12:38:07 +02:00
2018-06-21 20:44:58 +02:00
//!Pause sound playback
void Pause();
2020-08-13 12:38:07 +02:00
2018-06-21 20:44:58 +02:00
//!Resume sound playback
void Resume();
2020-08-13 12:38:07 +02:00
2018-06-21 20:44:58 +02:00
//!Checks if the sound is currently playing
//!\return true if sound is playing, false otherwise
bool IsPlaying();
2020-08-13 12:38:07 +02:00
2018-06-21 20:44:58 +02:00
//!Rewind the music
void Rewind();
2020-08-13 12:38:07 +02:00
2018-06-21 20:44:58 +02:00
//!Set sound volume
//!\param v Sound volume (0-100)
void SetVolume(uint32_t v);
2020-08-13 12:38:07 +02:00
2018-06-21 20:44:58 +02:00
//!\param l Loop (true to loop)
void SetLoop(bool l);
2020-08-13 12:38:07 +02:00
2018-06-21 20:44:58 +02:00
protected:
int32_t voice; //!< Currently assigned ASND voice channel
};
#endif