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.5 KiB
C
Raw 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 <string>
#include <vector>
2017-01-21 17:27:46 +01:00
#include <stdio.h>
2017-02-10 23:03:33 +01:00
#include <SDL2/SDL_mixer.h>
2017-02-10 00:14:28 +01:00
#include "blupi.h"
2017-01-21 17:27:46 +01:00
#define MAXSOUND 100
#define MAXVOLUME 20
#define MAXBLUPI 100
2017-01-21 17:27:46 +01:00
class CSound
{
public:
CSound();
~CSound();
bool Create();
void SetState (bool bState);
bool GetEnable();
void SetAudioVolume (Sint32 volume);
Sint32 GetAudioVolume();
void SetMidiVolume (Sint32 volume);
Sint32 GetMidiVolume();
void CacheAll();
bool Cache (Sint32 channel, const std::string &pFilename);
2017-02-28 21:49:15 +01:00
void FlushAll ();
void Flush (Sint32 channel);
bool Play (Sint32 channel, Sint32 volume = 0, Uint8 panLeft = 255,
Uint8 panRight = 255);
bool PlayImage (Sint32 channel, POINT pos, Sint32 rank = -1);
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);
2017-01-21 17:27:46 +01:00
protected:
bool m_bState;
bool m_bStopped;
Mix_Music *m_pMusic;
Mix_Chunk *m_lpSDL[MAXSOUND];
std::vector<std::string> m_sndFiles;
Sint16 m_channelBlupi[MAXBLUPI];
std::string m_MIDIFilename;
Sint32 m_audioVolume;
Sint32 m_midiVolume;
Sint32 m_lastMidiVolume;
Sint32 m_nbSuspendSkip;
2017-01-21 17:27:46 +01:00
};
/////////////////////////////////////////////////////////////////////////////