Exemple #1
0
        private void CleanupResources()
        {
            if (_directSoundNotify != null)
            {
                _directSoundNotify.Dispose();
                _directSoundNotify = null;
            }
            if (_secondaryBuffer != null)
            {
                _secondaryBuffer.Stop();
                _secondaryBuffer.Dispose();
                _secondaryBuffer = null;
            }
            if (_primaryBuffer != null)
            {
                _primaryBuffer.Stop();
                _primaryBuffer.Dispose();
                _primaryBuffer = null;
            }

            if (_directSound != null)
            {
                _directSound.Dispose();
                _directSound = null;
            }

            _isInitialized = false;
        }
Exemple #2
0
        /// <summary>
        /// Runs main Visualisation loop.
        /// </summary>
        public void Run()
        {
            var mode   = new SFML.Window.VideoMode(width, height);
            var window = new SFML.Graphics.RenderWindow(mode, visualisation.GetType().ToString());

            window.KeyPressed += Window_KeyPressed;
            window.SetFramerateLimit(FPS);

            // Start the game loop
            while (window.IsOpen)
            {
                visualisation.Update();
                window.Clear();

                // Process events
                window.DispatchEvents();
                visualisation.Draw(window);
                // Finally, display the rendered frame on screen
                window.Display();
            }

            visualisation.Quit();
            soundBuffer.Dispose();
            window.Close();
        }
Exemple #3
0
 /// <summary>
 ///     Liberar recursos del sonido
 /// </summary>
 public void dispose()
 {
     if (SoundBuffer != null && !SoundBuffer.Disposed)
     {
         SoundBuffer.Dispose();
         SoundBuffer = null;
     }
 }
Exemple #4
0
 protected override void OnDestroy()
 {
     buffer.Dispose();
     if (instance?.Exists ?? false)
     {
         instance.Destroy();
     }
     //    bufferWithOffset?.Dispose();
 }
Exemple #5
0
 public static void finalize1()
 {
     ExplosionSound.Dispose();
     LargeExplosionSound.Dispose();
     JetSound.Dispose();
     LockonSound.Dispose();
     AlertSound.Dispose();
     BulletSound.Dispose();
     BulletHitSound.Dispose();
 }
Exemple #6
0
    public void unload()
    {
        bounce.Dispose();
        shatter.Dispose();
        powerup.Dispose();
        ballfall.Dispose();
        speedup.Dispose();
        ching.Dispose();
        die.Dispose();

        for (int i = 0; i < music.Count; i++)
        {
            music[i].Dispose();
        }
    }
Exemple #7
0
        private void AudioThread()
        {
            int lastChunk    = -1;
            int currentChunk = -1;

            Sample[]            buffer         = new Sample[m_ChunkSize];
            FillBufferEventArgs fillBufferArgs = new FillBufferEventArgs(buffer);

            while (!m_Abort)
            {
                int cursor = m_Buffer.CurrentPlayPosition;

                int chunk = cursor / m_ChunkSizeBytes;

                if (chunk == lastChunk)
                {
                    Thread.Sleep(1000 * ((chunk + 1) * m_ChunkSizeBytes - cursor) / m_BytesPerSample / m_SampleRate);
                }
                else
                {
                    // Fill next buffer:
                    currentChunk = (chunk + 1) % m_NumChunks;

                    for (int i = 0; i < buffer.Length; i++)
                    {
                        buffer[i] = Sample.Zero;
                    }

                    FillBuffer(fillBufferArgs);

                    m_Buffer.Write(buffer, currentChunk * m_ChunkSizeBytes, LockFlags.None);
                }
                lastChunk = chunk;
            }

            m_Buffer.Dispose();
        }
Exemple #8
0
        async private Task <byte[]> Prerender(Chart chart, int format = 0, int channel = 2, int sampleRate = 44100)
        {
            var mixed = await Task.Run(() => SampleMixer.Mix(chart, SampleMixer.MixMode.Full, channel, sampleRate));

            var buffer = new SoundBuffer(mixed.GetSamples(), channel, sampleRate);

            byte[] data = null;

            if (format == 0)
            {
                data = await Task.Run(() => buffer.Save <MP3Encoder>());
            }
            else if (format == 1)
            {
                data = await Task.Run(() => buffer.Save <OggEncoder>());
            }
            else
            {
                data = await Task.Run(() => buffer.Save <WavEncoder>());
            }

            foreach (var ev in chart.Events)
            {
                var sound = ev as Event.Sound;
                if (sound == null)
                {
                    continue;
                }

                sound.Payload = null;
                sound.Dispose();
            }

            buffer.Dispose();
            return(data);
        }
Exemple #9
0
 protected override void OnDestroy()
 {
     sound.Dispose();
     program.Dispose();
 }