コード例 #1
0
 /// <summary>
 /// Closes the synth output and disposes all resources.
 /// </summary>
 public void Close()
 {
     _finished = true;
     _context.Stop();
     _circularBuffer.Clear();
     _context.Dispose();
 }
コード例 #2
0
        public void Play()
        {
            dynamic ctx = _context;

            if (ctx.state == "suspended" || ctx.state == "interrupted")
            {
                ctx.resume();
            }

            // create an empty buffer source (silence)
            _buffer = _context.CreateBuffer(2, BufferSize, _context.SampleRate);

            // create a script processor node which will replace the silence with the generated audio
            _audioNode = _context.CreateScriptProcessor(BufferSize, 0, 2);
            _audioNode.OnAudioProcess = (Action <AudioProcessingEvent>)GenerateSound;

            _circularBuffer.Clear();

            RequestBuffers();
            _finished      = false;
            _source        = _context.CreateBufferSource();
            _source.Buffer = _buffer;
            _source.Loop   = true;
            _source.Connect(_audioNode, 0, 0);
            _source.Start(0);
            _audioNode.Connect(_context.Destination, 0, 0);
        }
コード例 #3
0
 public void Stop()
 {
     _finished = true;
     _paused   = false;
     _context.Stop();
     _circularBuffer.Clear();
 }
コード例 #4
0
 public void Stop()
 {
     _finished = true;
     _paused   = false;
     _seekTime = null;
     if (_source != null)
     {
         _source.stop(0);
     }
     _source = null;
     _circularBuffer.Clear();
     _audioNode.disconnect(0);
 }
コード例 #5
0
 /// <summary>
 /// Closes the synth output and disposes all resources.
 /// </summary>
 public void Close()
 {
     _context.Stop();
     _circularBuffer.Clear();
     _context.Dispose();
 }
コード例 #6
0
 public void ResetSamples()
 {
     _circularBuffer.Clear();
 }