Example #1
0
 public override void Dispose()
 {
     var sound = CurrentLoop;
     CurrentLoop = null;
     ExitLooper = true;
     LoopThread.Join();
     base.Dispose();
 }
Example #2
0
 public virtual void Dispose()
 {
     if (_Frames != null) {
         for (int i = 0; i < _Frames.Length; i++) {
             _Frames [i].Dispose ();
             _Frames [i] = null;
         }
         _Frames = null;
     }
     _Sound = null;
 }
Example #3
0
 public void SetLoop(object loop_me, bool restart = false)
 {
     lock (CurrentLoopLock) {
         Sound new_loop = Sound.Get (loop_me);
         bool change = (new_loop != CurrentLoop);
         ResetLooper = change || restart;
         if(ResetLooper)
         {
             if(CurrentLoop != null)
                 CurrentLoop.Stop();
             if(change)
                 CurrentLoop = new_loop;
         }
     }
 }
Example #4
0
        protected static Sound LoadWaveFileAbsolute(string title, string file_path)
        {
            if(!System.IO.File.Exists(file_path))
                throw new FileNotFoundException("File missing: ", file_path);
            int buffer_id = AL.GenBuffer();
            int source_id = AL.GenSource();
            //            if(XRam.IsInitialized)
            //                XRam.SetBufferMode(1, ref buffer_id, XRamExtension.XRamStorage.Hardware);

            int channels, bits_per_sample, sample_rate;
            byte[] sound_data = LoadWave(File.Open(file_path, FileMode.Open), out channels, out bits_per_sample, out sample_rate);
            AL.BufferData(buffer_id, GetSoundFormat(channels, bits_per_sample), sound_data, sound_data.Length, sample_rate);
            AL.Source(source_id, ALSourcei.Buffer, buffer_id);
            double duration = (double)sound_data.Length / (double)(sample_rate * channels * bits_per_sample / 8);
            return (Sound)(Sounds[title] = new Sound(buffer_id, source_id, duration));
        }