private Yanesdk.Sound.Sound LoadMusicByPath(string path) { Yanesdk.Sound.Sound musics = new Yanesdk.Sound.Sound(); YanesdkResult result = musics.Load(path, -1); if (result == YanesdkResult.NoError) { musics.Loop = -1; return musics; } else { throw new Exception("BGM�u" + path + "�v���ǂݍ��߂܂���"); } }
private Yanesdk.Sound.Sound LoadMusicByPath(string path) { Yanesdk.Sound.Sound musics = new Yanesdk.Sound.Sound(); YanesdkResult result = musics.Load(path, -1); if (result == YanesdkResult.NoError) { musics.Loop = -1; return(musics); } else { throw new Exception("BGM「" + path + "」が読み込めません><"); } }
private Yanesdk.Sound.Sound LoadSoundByPath(string path) { Yanesdk.Sound.Sound sound = new Yanesdk.Sound.Sound(); YanesdkResult result = sound.Load(path); if (result == YanesdkResult.NoError) { sound.Volume = 0.75f; return(sound); } else { throw new Exception("効果音「" + path + "」が読み込めません><"); } }
/// <summary> /// 現在再生しているチャンクを停止させる /// </summary> /// <param name="name"></param> /// <returns></returns> public YanesdkResult Stop(Sound s) { if (s == music) { // SDL.Mix_PauseMusic(); // Mix_HaltMusic(); SDL.Mix_HaltMusic(); music = null; } if (chunk == null) return YanesdkResult.PreconditionError; for(int i=0;i<8;++i) { if(s == chunk[i]) { // SDL.Mix_Pause(i); // ↑これだと IsPlayingでtrueが戻ってきてしまう。 SDL.Mix_HaltChannel(i); // ↑なのでバッファを破棄する必要がある。 chunk[i] = null; } } return YanesdkResult.NoError; }
/// <summary> /// 現在一時停止させているチャンクを再生させる /// /// 一時停止させている間にVolumeが変更されている可能性があるので /// そのへんを考慮して再開。 /// </summary> /// <param name="name"></param> /// <returns></returns> public YanesdkResult Resume(Sound s) { if (s == music) { SetVolume(0, s.Volume); SDL.Mix_ResumeMusic(); } if (chunk == null) return YanesdkResult.PreconditionError; for (int i = 0; i < 8; ++i) { if (s == chunk[i]) { SetVolume(i+1, s.Volume); SDL.Mix_Resume(i); break; } } return YanesdkResult.NoError; }
/// <summary> /// 現在再生しているチャンクを停止させる /// </summary> /// <param name="name"></param> /// <returns></returns> public YanesdkResult Pause(Sound s) { if (s == music) { SDL.Mix_PauseMusic(); // Mix_HaltMusic(); // バッファは破棄しないなりよ } if (chunk == null) return YanesdkResult.PreconditionError; for (int i = 0; i < 8; ++i) { if (s == chunk[i]) { SDL.Mix_Pause(i); // バッファは破棄しないなりよ } } return YanesdkResult.NoError; }
/// <summary> /// 現在再生していないチャンクを探す /// </summary> /// <param name="name"></param> /// <returns></returns> public int GetEmptyChunk(Sound s) { if (NoSound || chunk == null) return 0; for(int i=0;i<8;++i) { if (SDL.Mix_Playing(i) == 0) { // chunk[i] = s; // ↑ここでやる必要ぜんぜんねーな return i; } } return 0; // 空きが無いので0番を潰すかぁ..(´Д`) }
/// <summary> /// 現在再生しているチャンクを停止させる /// </summary> /// <param name="name"></param> /// <param name="speed"></param> /// <returns></returns> public YanesdkResult StopFade(Sound s, int speed) { int hr = 0; if (s == music) { hr = SDL.Mix_FadeOutMusic(speed); music = null; } if (chunk == null) return YanesdkResult.PreconditionError; for(int i=0;i<8;++i){ if (s == chunk[i]) { hr = SDL.Mix_FadeOutChannel(i,speed); chunk[i] = null; } } return hr == 0 ? YanesdkResult.NoError : YanesdkResult.SdlError; }
private Sound LoadSoundByPath(string path) { Sound sound = new Sound(); YanesdkResult result = sound.Load(path); if (result == YanesdkResult.NoError) { if (path.IndexOf("voice") != -1) { sound.Volume = 0.9f; } else { sound.Volume = 0.4f; } return sound; } else { throw new Exception("���ʉ��u" + path + "�v����[�h�ł��܂���"); } }
private Sound LoadMusicByPath(string path) { Sound sound = new Sound(); YanesdkResult result = sound.Load(path, -1); if (result == YanesdkResult.NoError) { if (path.IndexOf("title") != -1 || path.IndexOf("clear") != -1 || path.IndexOf("ending") != -1) { sound.Loop = 0; } else { sound.Loop = -1; } return sound; } else { throw new Exception("BGM�u" + path + "�v����[�h�ł��܂���"); } }
private Yanesdk.Sound.Sound LoadSoundByPath(string path) { Yanesdk.Sound.Sound sound = new Yanesdk.Sound.Sound(); YanesdkResult result = sound.Load(path); if (result == YanesdkResult.NoError) { sound.Volume = 0.75f; return sound; } else { throw new Exception("���ʉ��u" + path + "�v���ǂݍ��߂܂���"); } }
public void PlaySound(Sound sound) { sounds[(int)sound].Play(); }