1
0
mirror of https://github.com/blupi-games/planetblupi synced 2024-12-30 10:15:36 +01:00
planetblupi/src/sound.h

83 lines
2.4 KiB
C
Raw Permalink Normal View History

2017-08-03 22:51:40 +02:00
/*
* This file is part of the planetblupi source code
* Copyright (C) 1997, Daniel Roux & EPSITEC SA
* Copyright (C) 2017, Mathieu Schroeter
* http://epsitec.ch; http://www.blupi.org; http://github.com/blupi-games
*
* 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://gnu.org/licenses
*/
2017-01-21 17:27:46 +01:00
#pragma once
#include <set>
2017-08-04 00:21:47 +02:00
#include <stdio.h>
#include <string>
#include <vector>
#include <SDL2/SDL_mixer.h>
2017-02-10 00:14:28 +01:00
#include "blupi.h"
2017-01-21 17:27:46 +01:00
2017-08-04 00:21:47 +02:00
#define MAXSOUND 100
#define MAXVOLUME 20
#define MAXBLUPI 100
2017-01-21 17:27:46 +01:00
class CSound
{
public:
2017-08-04 00:21:47 +02:00
CSound ();
~CSound ();
2017-08-04 00:21:47 +02:00
bool Create ();
void SetState (bool bState);
bool GetEnable ();
2017-08-04 00:21:47 +02:00
void SetAudioVolume (Sint32 volume);
Sint32 GetAudioVolume ();
void SetMidiVolume (Sint32 volume);
Sint32 GetMidiVolume ();
2017-08-04 00:21:47 +02:00
void CacheAll ();
bool Cache (Sint32 channel, const std::string & pFilename);
void FlushAll ();
void Flush (Sint32 channel);
2017-08-04 00:21:47 +02:00
bool Play (
Sint32 channel, Sint32 volume = 0, Uint8 panLeft = 255,
Uint8 panRight = 255);
2017-08-21 22:08:25 +02:00
bool PlayImage (Sounds channel, Point pos, Sint32 rank = -1);
2017-08-04 00:21:47 +02:00
bool PlayMusic (const std::string & lpszMIDIFilename);
bool RestartMusic ();
void SuspendMusic ();
void StopMusic ();
bool IsPlayingMusic ();
bool IsStoppedOnDemand ();
void AdaptVolumeMusic ();
void SetSuspendSkip (Sint32 nb);
bool StopAllSounds (bool immediat, const std::set<Sint32> * except = nullptr);
2017-01-21 17:27:46 +01:00
protected:
2017-08-04 00:21:47 +02:00
bool m_bState;
bool m_bStopped;
Mix_Music * m_pMusic;
Mix_Chunk * m_lpSDL[MAXSOUND];
std::vector<std::string> m_sndFiles;
Sounds m_channelBlupi[MAXBLUPI];
2017-08-04 00:21:47 +02:00
std::string m_MIDIFilename;
Sint32 m_audioVolume;
Sint32 m_midiVolume;
Sint32 m_lastMidiVolume;
Sint32 m_nbSuspendSkip;
2017-01-21 17:27:46 +01:00
};