2017-06-23 11:24:50 +08:00
|
|
|
#pragma once
|
|
|
|
#include "include.h"
|
|
|
|
#include <memory>
|
|
|
|
#include <string>
|
|
|
|
#include "Audio.h"
|
|
|
|
#include "ErrorViewer.h"
|
2017-07-04 22:38:33 +08:00
|
|
|
#include "RWOP.h"
|
2017-07-01 17:11:06 +08:00
|
|
|
#include "__Plugin.h"
|
2017-07-31 00:18:10 +08:00
|
|
|
namespace MiniEngine
|
|
|
|
{
|
2017-06-23 11:24:50 +08:00
|
|
|
class Sound
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Sound() = default;
|
2017-06-23 14:16:15 +08:00
|
|
|
Sound(const std::string& WAVFilename);
|
2017-07-04 22:38:33 +08:00
|
|
|
Sound(const RWOP& rwop);
|
2017-06-23 14:16:15 +08:00
|
|
|
bool isReady() const;
|
|
|
|
void release();
|
2017-06-23 11:24:50 +08:00
|
|
|
private:
|
|
|
|
std::shared_ptr<Mix_Chunk> _sound;
|
|
|
|
void _set(Mix_Chunk*);
|
|
|
|
void _clear();
|
2017-06-23 14:16:15 +08:00
|
|
|
Mix_Chunk* _get() const;
|
2017-06-23 11:24:50 +08:00
|
|
|
|
2017-06-23 14:16:15 +08:00
|
|
|
friend class Channel;
|
2017-07-01 17:11:06 +08:00
|
|
|
friend class _internal::Plugin;
|
2017-06-23 14:16:15 +08:00
|
|
|
};
|
2017-06-23 11:24:50 +08:00
|
|
|
|
2017-06-23 14:16:15 +08:00
|
|
|
class Channel
|
2017-06-23 11:24:50 +08:00
|
|
|
{
|
|
|
|
public:
|
2017-07-19 18:11:45 +08:00
|
|
|
Channel& playSound(Sound sound,int loops);
|
|
|
|
Channel& fadeIn(Sound sound,int loops,int ms);
|
2017-06-23 11:24:50 +08:00
|
|
|
|
2017-06-23 14:16:15 +08:00
|
|
|
int fadeOut(int ms);
|
|
|
|
void pause();
|
|
|
|
void resume();
|
|
|
|
int stop();
|
2017-06-23 11:24:50 +08:00
|
|
|
|
|
|
|
/// Experimental
|
2017-06-23 14:16:15 +08:00
|
|
|
int setPanning(uint8_t left,uint8_t right);
|
|
|
|
int setPosition(int16_t angle,uint8_t distance);
|
|
|
|
int setDistance(uint8_t distance);
|
|
|
|
int setReverseStereo(int flip);
|
2017-06-23 11:24:50 +08:00
|
|
|
|
|
|
|
/// Experimental: Direct Add/Remove Effect
|
2017-06-23 14:16:15 +08:00
|
|
|
int addEffect(Mix_EffectFunc_t f, Mix_EffectDone_t d, void *arg);
|
|
|
|
int removeEffect(Mix_EffectFunc_t f);
|
|
|
|
int removeAllEffect();
|
|
|
|
protected:
|
|
|
|
Channel();
|
|
|
|
private:
|
|
|
|
void _set(int ChannelID);
|
|
|
|
int _get() const;
|
|
|
|
void _clear();
|
|
|
|
|
|
|
|
int _id;
|
|
|
|
friend class SoundPlayer;
|
|
|
|
};
|
|
|
|
|
|
|
|
class SoundPlayer : public AudioPlayer
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
static int GetDecoderNum();
|
|
|
|
static std::string GetDecoderName(int index);
|
|
|
|
|
|
|
|
SoundPlayer(int NumChannels = 16);
|
2017-07-15 00:12:48 +08:00
|
|
|
Channel playSound(Sound sound, int loops);
|
|
|
|
Channel fadeIn(Sound sound, int loops, int ms);
|
2017-06-23 11:24:50 +08:00
|
|
|
};
|
2017-07-31 00:18:10 +08:00
|
|
|
} /// End of namespace MiniEngine
|
|
|
|
|