/// <summary> /// サウンドソースをキャッシュから取得し、なければファイルを読み込みます。 /// </summary> private ISoundSource GetSoundSource(string filename) { // 音声のフルパスを取得します。 var filepath = Path.GetFullPath(filename); if (!File.Exists(filepath)) { return(null); } // irrKlangは日本語のファイル名が読めないので、 // ストリームから再生する。 var fileid = GetFileId(filepath); var source = engine.GetSoundSource(fileid, false); if (source == null) { source = LoadSoundSource(filepath); if (source == null) { return(null); } } return(source); }
public void Load(string file) { Stop(); if (_engine == null) { _engine = new ISoundEngine(); } _currentPlayback = _engine.Play2D(file, false, false); if (_currentPlayback != null) { _currentPlayback.Volume = Volume; _currentPlayback.setSoundStopEventReceiver(this); TrackDuration = TimeSpan.FromMilliseconds(_currentPlayback.PlayLength); OnPlaybackPositionChanged(TimeSpan.FromSeconds(0)); var info = _engine.GetSoundSource(file).AudioFormat; Channels = info.ChannelCount; BytesPerSecond = info.BytesPerSecond; SampleRate = info.SampleRate; NotifyPlayBackStateChanged(); } else { NotifyPlayBackStateChanged(); throw new Exception(string.Format("Error loading file '{0}' for playback", file)); } }
private void SongSet(string filePath, float pitch, bool startPaused) { Song?.Stop(); SongData = _engine.GetSoundSource(filePath); Song = _engine.Play2D(SongData, true, startPaused, true); if (Song != null) { Song.PlaybackSpeed = pitch; Song.PlayPosition = 0; } }
public void Load(Sound sound) { sound.iSourceSource = soundEngine.GetSoundSource(sound.FileName, true); switch (sound.Is3D) { case true: sound.iSound = soundEngine.Play3D(sound.iSourceSource, sound.Position.x, sound.Position.y, sound.Position.z, sound.Loop, sound.Stopped, false); break; default: sound.iSound = soundEngine.Play2D(sound.iSourceSource, sound.Loop, sound.Stopped, false); break; } StopAllSounds(); }
public ISoundSource Load(string filename) { return(engine.GetSoundSource(Path.Combine(Application.StartupPath, Path.Combine(Core.ContentRoot, filename)), true)); }