public void Open() { _finished = false; _circularBuffer = new CircularSampleBuffer(BufferSize * BufferCount); _context = new DirectSoundOut(100); _context.Init(this); OnReadyChanged(true); }
public void Open() { _finished = false; _circularBuffer = new CircularSampleBuffer(BufferSize * BufferCount); JsContext.JsCode("window.AudioContext = window.AudioContext || window.webkitAudioContext"); _context = new AudioContext(); _latency = (BufferSize * 1000) / (2 * _context.sampleRate); // 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 = GenerateSound; OnReadyChanged(true); }