SDXFrameWork  0.07
SDXFrameWork
 全て クラス ネームスペース 関数 変数 列挙型 列挙型の値 ページ
Sound.h
1 #pragma once//☀SDL
2 #include <Multimedia/SDX.h>
3 
4 namespace SDX
5 {
7 enum class PlayType
8 {
9  Normal = 0,
10  Back = 0,
11  Loop = -1,
12 };
13 
16 class Sound
17 {
18 private:
19  SoundHandle handle;
20 public:
21 
22  Sound(){}
23 
25  Sound(const char *ファイル名 , double 音量 = 1.0)
26  {
27  Load(ファイル名);
28  }
29 
31  int Load(const char *ファイル名 , double 音量 = 1.0)
32  {
33  handle = Mix_LoadWAV(ファイル名);
34  if( !handle ) return false;
35 
36  Mix_VolumeChunk(handle, int(音量 * 128));
37  return true;
38  }
39 
41  bool Release()
42  {
43  Mix_FreeChunk(handle);
44  return true;
45  }
46 
48  SoundHandle GetHandle() const
49  {
50  return this->handle;
51  }
52 
54  bool Play(PlayType 再生方法 = PlayType::Back , bool 先頭から再生 = true) const
55  {
56  static int channel = 0;
57  Mix_PlayChannel(0, handle, (int)再生方法);
58  channel = (++channel) % 2;
59  return true;
60  }
61 
63  bool Check() const
64  {
65  return false;
66  }
67 
69  bool Stop()
70  {
71  return false;
72  }
73 
75  bool SetPan(int 音声パン)
76  {
77  return false;
78  }
79 
81  bool SetVolume(double 音量)
82  {
83  Mix_VolumeChunk(handle, int(音量 * 128));
84  return true;
85  }
86 
89  bool SetFrequency(int 再生周波数)
90  {
91  return false;
92  }
93 
95  bool SetLoopPos(int ループ位置)
96  {
97  return false;
98  }
99 
102  bool SetLoopSamplePos(int ループ周波数)
103  {
104  return false;
105  }
106 };
107 }
bool SetLoopSamplePos(int ループ周波数)
サンプリング周波数でループ位置を設定[DXLIB].
Definition: Sound.h:102
効果音用音声を表すクラス.
Definition: Sound.h:16
bool Play(PlayType 再生方法=PlayType::Back, bool 先頭から再生=true) const
音声ファイルを再生.
Definition: Sound.h:54
再生中、他の処理を止めない
bool SetPan(int 音声パン)
音声パンを設定[DXLIB].
Definition: Sound.h:75
再生中、他の処理を止める
bool SetFrequency(int 再生周波数)
再生周波数を設定[DXLIB].
Definition: Sound.h:89
bool Check() const
再生中か判定[DXLIB].
Definition: Sound.h:63
Sound(const char *ファイル名, double 音量=1.0)
音声ファイルをメモリに読み込む.
Definition: Sound.h:25
SoundHandle GetHandle() const
ハンドルを取得.
Definition: Sound.h:48
int Load(const char *ファイル名, double 音量=1.0)
音声ファイルをメモリに読み込む.
Definition: Sound.h:31
bool SetVolume(double 音量)
音量を0~1.0の範囲で設定.
Definition: Sound.h:81
bool Release()
音声ファイルをメモリから開放.
Definition: Sound.h:41
bool SetLoopPos(int ループ位置)
ミリ秒単位でループ位置を設定[DXLIB].
Definition: Sound.h:95
bool Stop()
再生を停止[DXLIB].
Definition: Sound.h:69
他の処理を止めず、繰り返す
PlayType
音声の再生方式.
Definition: Sound.h:7