1

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

7..
  • 15
  • 4
  • Why you want to access the audio data as byte[] not byte* ? I think you could converter byte* to byte[]. For more detail you could assess this [replay](https://stackoverflow.com/a/17569560/7254781). – CoCaIceDew Feb 25 '19 at 07:06
  • Did you get this issue resolved? Would be glad to see the solution. – chenz Sep 10 '19 at 04:51

0 Answers0