protected void ASIO_AudioAvailable(object sender, AsioAudioAvailableEventArgs e) { if (owner == null) { return; } int samples = e.SamplesPerBuffer; if (ASIOinputSMPS != null) { e.GetAsInterleavedSamples(ASIOinputSMPS); } else { ASIOinputSMPS = e.GetAsInterleavedSamples(); } int offset = 0; if (tempBuf == null) { tempBuf = new double[32]; } if (fromDriver[0].space() < samples) { fromDriverStarted = false; overrun = owner.overrunCounterStart; return; } while (samples > 0) { int N = 32; if (samples < N) { N = samples; } for (int j = 0; j < fromDriverChannels; j++) { for (int i = 0; i < N; i++) { tempBuf[i] = ASIOinputSMPS[offset + j + i * fromDriverChannels]; } fromDriver[j].insert(tempBuf, N); } offset += N * fromDriverChannels; samples -= N; } }
void OnAsioOutAudioAvailable(object sender, AsioAudioAvailableEventArgs e) { #pragma warning disable 618 var samples = e.GetAsInterleavedSamples(); #pragma warning restore 618 writer.WriteSamples(samples, 0, samples.Length); }
private void OnAudioAvailable(object sender, AsioAudioAvailableEventArgs e) { var size = e.SamplesPerBuffer * e.InputBuffers.Length; if (_inBuffer == null || _inBuffer.Length < size) { _inBuffer = new float[size]; _outBuffer = new byte[size * 4]; } var samples = e.GetAsInterleavedSamples(_inBuffer); Buffer.BlockCopy(_inBuffer, 0, _outBuffer, 0, samples * 4); DataAvailable?.Invoke(this, new WaveInEventArgs(_outBuffer, samples * 4)); }
private static void OnAsioOutAudioAvailable(object sender, AsioAudioAvailableEventArgs e) { // fill array with data e.GetAsInterleavedSamples(samples); int sample; int j; // convert sample to short format for (int i = 0; i < samples.Length; i++) { sample = (int)(samples[i] * Math.Pow(2, 15)); j = i * 2; sampleBytes[j] = (byte)sample; sampleBytes[j + 1] = (byte)(sample >> 8); } // add short to buffer bufferedWaveProvider.AddSamples(sampleBytes, 0, sampleBytes.Length); }
private void OnAsioOutAudioAvailable(object sender, AsioAudioAvailableEventArgs e) { float[] samplesBuffer = e.GetAsInterleavedSamples(); Console.WriteLine("STARTED"); Console.WriteLine("SAMPLES_PER_BUFFER:" + e.SamplesPerBuffer.ToString()); Console.WriteLine("INPUT_BUFFERS:" + e.InputBuffers.Length); Console.WriteLine("bytes:" + samplesBuffer.Length); int channelsCount = this.soundService.getCurrentChannelsCount(); if (this.cbRecordFile.Checked) { bool appendToFile = this.isFirstChunk == false; writeInterleavedSamplesToCSV(samplesBuffer, channelsCount, appendToFile); } else { for (int i = 0; i < samplesBuffer.Length; i += channelsCount) { for (int j = 0; j < channelsCount; j++) { Chart chart = this.charts[j]; float signalValue = samplesBuffer[i + j] * Int16.MaxValue; chart.Invoke((MethodInvoker) delegate { int maxIndex = (int)chart.ChartAreas[0].AxisX.Maximum; chart.Series[0].Points.Add(signalValue); int pointsCount = chart.Series[0].Points.Count; if (pointsCount >= maxIndex) { chart.Series[0].Points.RemoveAt(0); chart.ResetAutoValues(); } }); } } } isFirstChunk = false; Console.WriteLine("HANDLED"); }
private void HandleBuffer(object sender, AsioAudioAvailableEventArgs e) { /*byte[] buf = new byte[e.SamplesPerBuffer]; * for (int i = 0; i < e.InputBuffers.Length; i++) * { * //Marshal.Copy(e.InputBuffers[i], e.OutputBuffers, 0, e.InputBuffers.Length); * //also tried to upper one but this way i also couldn't hear anything * Marshal.Copy(e.InputBuffers[i], buf, 0, e.SamplesPerBuffer); * Marshal.Copy(buf, 0, e.OutputBuffers[i], e.SamplesPerBuffer); * } * e.WrittenToOutputBuffers = true;*/ var count = e.GetAsInterleavedSamples(values); //if (e.AsioSampleType == AsioSampleType.Int32LSB16) var samples = new Sample[count]; for (var i = 0; i < count; i++) { samples[i] = new Sample(new[] { values[i] }); } sampleQueue.Add(samples); }
private static void OnAsioOutAudioAvailable(object?sender, AsioAudioAvailableEventArgs e) { Collection.Add(e.GetAsInterleavedSamples()); }
void asioOut_AudioAvailable(object sender, AsioAudioAvailableEventArgs e) { var samples = e.GetAsInterleavedSamples(); writer.WriteSamples(samples, 0, samples.Length); }
private void OnAsioAudioAvailable(object sender, AsioAudioAvailableEventArgs e) { e.GetAsInterleavedSamples(dataSample); OnDataReceived(dataSample); }