/// <summary> /// Closes the synth output and disposes all resources. /// </summary> public void Close() { _finished = true; _context.Stop(); _circularBuffer.Clear(); _context.Dispose(); }
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); }
public void Stop() { _finished = true; _paused = false; _context.Stop(); _circularBuffer.Clear(); }
public void Stop() { _finished = true; _paused = false; _seekTime = null; if (_source != null) { _source.stop(0); } _source = null; _circularBuffer.Clear(); _audioNode.disconnect(0); }
/// <summary> /// Closes the synth output and disposes all resources. /// </summary> public void Close() { _context.Stop(); _circularBuffer.Clear(); _context.Dispose(); }
public void ResetSamples() { _circularBuffer.Clear(); }