public Task OnAudioBufferReceived(object audioBuffer32bitJson) { var buffer = AudioInterop. ConvertJSFloat32ArrayToManaged(audioBuffer32bitJson, AudioAmplify); OnProcessAudioBuffer(buffer); if (_bFirstRenderHandled) { OnAudioBufferProcessed(); } return(Task.CompletedTask); }
public Task OnAudioBufferReceived(object audioBuffer32bitJson) { var sw = new Stopwatch(); sw.Start(); var buffer = AudioInterop. ConvertJSFloat32ArrayToManaged(audioBuffer32bitJson, AudioAmplify); _audioFilter.CreateSpectrum(buffer); _spectrumBuffer ??= new double[SpectrumSize]; _audioFilter.CompressPreviousSpectrum(_spectrumBuffer, 0, _audioFilter.MaximumBandValue / 2); // we don't care about the upper-half of the bands sw.Stop(); if (_bFirstRenderHandled) { OnAudioBufferProcessed(sw.ElapsedMilliseconds); } return(Task.CompletedTask); }