I have been trying to replicate a feature of NAudio that allows the processing of user input when it is available to be processed and fed into a Google API as a byte[] Buffer.
_waveIn.DataAvailable += ProcessAudio;
The ProcessAudio method passes the Audio Buffer to the Google API
private void ProcessAudio(object sender, WaveInEventArgs e)
{
if (canSend)
{
WriteAudioData(e.Buffer);
}
}
Then passing the Buffer to Google API works fine.
However, with a UWP App the NAudio does not work and so I am trying to use the Audio Graph API to do the same thing but I want to access the audio data as byte[] not byte*
The following is taken from the example I have been following:
unsafe private AudioFrame ProcessAudioFrame(AudioMediaFrame audioMediaFrame)
{
using (AudioFrame audioFrame = audioMediaFrame.GetAudioFrame())
using (AudioBuffer buffer = audioFrame.LockBuffer(AudioBufferAccessMode.Read))
using (IMemoryBufferReference reference = buffer.CreateReference())
{
byte* dataInBytes;
uint capacityInBytes;
((IMemoryBufferByteAccess)reference).GetBuffer(out dataInBytes, out capacityInBytes);
}
}
The issue is getting the dataInBytes as a byte Array and not as dataInBytes*.
Then I will similarly use the byte array and pass it through to the API.
So my question is, is what I am thinking of doing correct and how could I use the Audio Graph API to help solve this?
Thanks