public override void Init() { RC.ClearColor = new float4(0, 0, 0, 1); Mesh = new Cube(); var sp = Shaders.GetDiffuseColorShader(RC); RC.SetShader(sp); _vColor = RC.GetShaderParam(sp, "color"); RC.SetShaderParam(_vColor, new float4(0.8f, 0.1f, 0.1f, 1)); // sound by http://www.soundjay.com _audio1 = Audio.Instance.LoadFile("AssetStorage/beep.ogg"); // excerpt from "the final rewind" by tryad (http://www.tryad.org) - cc-by-sa _audio2 = Audio.Instance.LoadFile("AssetStorage/music.ogg"); _state = 0; _testID = 1; _timeStep = 1.0f; _curTime = 2.0f; _tests = new Tests(); }
public bool Test7(IAudioStreamImp audio, int state) { if (state == 0) { Debug.WriteLine("Test #7: individual panning from right to left"); } if (state == 2) { audio.Play(); } if (state >= 2 && state < 19) { audio.Panning = 100 - ((state - 2) * 12.5f); Debug.WriteLine("----> individual panning set to: " + audio.Panning); } if (state != 19) { return(false); } audio.Stop(); return(true); }
public bool Test6(IAudioStreamImp audio, int state) { if (state == 0) { Debug.WriteLine("Test #6: global panning from left to right"); } if (state == 2) { audio.Play(); } if (state >= 2 && state < 19) { Audio.Instance.SetPanning(-100 + ((state - 2) * 12.5f)); Debug.WriteLine("----> global panning set to: " + audio.Panning); } if (state != 19) { return(false); } audio.Stop(); Audio.Instance.SetPanning(0); return(true); }
public bool Test1(IAudioStreamImp audio, int state) { if (state == 0) { Debug.WriteLine("Test #1: play, pause, stop and global stop"); } if (state == 2) { Debug.WriteLine("----> play for five seconds"); audio.Play(); } if (state == 7) { Debug.WriteLine("----> pause music for two seconds"); audio.Pause(); } if (state == 9) { Debug.WriteLine("----> play music for five seconds"); audio.Play(); } if (state == 14) { Debug.WriteLine("----> stop music for two seconds"); audio.Stop(); } if (state == 16) { Debug.WriteLine("----> play music for five seconds"); audio.Play(); } if (state == 21) { Debug.WriteLine("----> global stop for two seconds"); Audio.Instance.Stop(); } if (state == 23) { Debug.WriteLine("----> play music for five seconds"); audio.Play(); } if (state != 28) { return(false); } audio.Stop(); return(true); }
public bool Test2(IAudioStreamImp audio, int state) { if (state == 0) { Debug.WriteLine("Test #2: lower global volume from 100 to 0"); } if (state >= 2) { Audio.Instance.SetVolume(100 - ((state - 2) * 20)); Debug.WriteLine("----> global volume set to: " + Audio.Instance.GetVolume()); audio.Play(); } return(state == 7); }
public bool Test3(IAudioStreamImp audio, int state) { if (state == 0) { Audio.Instance.SetVolume(100); audio.Volume = 0; Debug.WriteLine("Test #3: raise individual volume from 0 to 100"); } if (state >= 2) { audio.Volume = ((state - 2) * 20); Debug.WriteLine("----> individual volume set to: " + audio.Volume); audio.Play(); } return(state == 7); }
public bool Test5(IAudioStreamImp audio, int state) { if (state == 0) { Debug.WriteLine("Test #5: looping for 2 seconds with loop as parameter"); } if (state == 2) { audio.Play(true); } if (state != 4) { return(false); } audio.Loop = false; return(true); }
public bool Test4(IAudioStreamImp audio, int state) { if (state == 0) { Debug.WriteLine("Test #4: looping for 2 seconds with loop as attribute"); } if (state == 2) { audio.Loop = true; audio.Play(); } if (state != 4) { return(false); } audio.Loop = false; return(true); }
///// <summary> ///// Loads a sound file from hard drive. ///// </summary> ///// <param name="fileName">Full path name of the file with datatype ending, e.g. "C\:sound.ogg". A path can be absolute or relative.</param> ///// <param name="streaming">if set to <c>true</c> [streaming].</param> ///// <returns>An IAudioStreamImp instance is returned if the file path was correctly resolved.</returns> //public IAudioStreamImp LoadFile(string fileName, bool streaming) //{ // if (Path.GetExtension(fileName) == ".mp3") // throw new Exception("MP3 files are not supported. Please consider using OGG files instead."); // // sound already loaded? // SoundBuffer tmpSndBuffer = null; // if (!streaming) // foreach ( // var audioStream in // _allStreams.Where(audioStream => !audioStream.IsStream && audioStream.FileName == fileName)) // { // tmpSndBuffer = audioStream.OutputBuffer; // break; // } // IAudioStreamImp tmpAudioStreamImp = tmpSndBuffer == null // ? new AudioStreamImp(fileName, streaming) // : new AudioStreamImp(fileName, tmpSndBuffer); // _allStreams.Add((AudioStreamImp) tmpAudioStreamImp); // return tmpAudioStreamImp; //} /// <summary> /// Open a sound file from the given stream. /// </summary> /// <returns>An IAudioStreamImp instance is returned if the file path was correctly resolved.</returns> public IAudioStreamImp OpenFromStream(string id, Stream stream, bool streaming) { // Sound already loaded? SoundBuffer tmpSndBuffer = null; if (!streaming) { foreach ( var audioStream in _allStreams.Where(audioStream => !audioStream.IsStream && audioStream.FileName == id)) { tmpSndBuffer = audioStream.OutputBuffer; break; } } IAudioStreamImp tmpAudioStreamImp = tmpSndBuffer == null ? new AudioStreamImp(id, streaming) : new AudioStreamImp(id, tmpSndBuffer); _allStreams.Add((AudioStreamImp)tmpAudioStreamImp); return(tmpAudioStreamImp); }