Problems getting Proper audio from CefSharp Audiostream

Having problems with building or using the CefSharp .NET binding? Ask your CEF-related questions here. Please ask general usage questions on StackOverflow.

Moderator: amaitland

Problems getting Proper audio from CefSharp Audiostream

Postby VRAmbassador » Tue Nov 29, 2022 4:13 pm

Hi Folks. I try to use CefSharp Audiostream to create a WAVE. As i see in params it must be 44100Khz, 1024 Samples and 2 Channels. More Info i do not get. In the comment of the sample is 32bit.
But when i get this RAW Data from a Memorystream and put a WAVEFORM header in front. Sound is overdriven and crackling.

Here is my code
Code: Select all
/*
             * NOTE: data is an array representing the raw PCM data as a floating point type, i.e. 4-byte value(s)
             * Based on noOfFrames and the channels value passed to IAudioHandler.OnAudioStreamStarted
             * you can calculate the size of the data array in bytes.
             *
             * Audio data (PCM, 32-bit, float) will be save to rawAudioFile stream.
             */

            unsafe
            {
                float** channelData = (float**)data.ToPointer();
                int size = channelCount * noOfFrames * 4;
                byte[] samples = new byte[size];
                fixed (byte* pDestByte = samples)
                {
                    float* pDest = (float*)pDestByte;

                    for (int i = 0; i < noOfFrames; i++)
                    {
                        for (int c = 0; c < channelCount; c++)
                        {
                            *pDest++ = channelData[c][i];
                        }
                    }
                }
                //if (BitConverter.ToInt32(samples, 0) != 0)
                //{
                //    rawAudioFile.Write(samples, 0, size);
                //}
                ms.Write(samples, 0, size);

            }


Bellow is a sample in base64 after adding header (You can hear to it using https://base64.guru/converter/decode/audio).

Any help is very welcome. I don't understand that this is not sounding properly. Sounds like to high volume or something. I use CefSharp Nuget 107.1.5 and i'm using the Windows Forms one not the offscreen browser.

Sample:
[sample to large]
uploaded here:
https://drive.google.com/file/d/13sfbnt ... share_link
VRAmbassador
Newbie
 
Posts: 1
Joined: Mon Nov 28, 2022 4:32 pm

Re: Problems getting Proper audio from CefSharp Audiostream

Postby amaitland » Wed Nov 30, 2022 2:38 pm

Might be worth trying with an older version from the time the sample code was added to see if the behaviour is the same, incase you've made some mistake.

You'll probably need to review the Chromium source code to see if anything has changed with the underlying implementation.

Look at the CEF source at https://github.com/chromiumembedded/cef to see which Chromium classes are used then search the Chromium source at https://source.chromium.org/chromium

CefSharp just provides a wrapper around the CEF API, it doesn't provide the actual implementation.
Maintainer of the CefSharp project.
amaitland
Virtuoso
 
Posts: 1290
Joined: Wed Jan 14, 2015 2:35 am


Return to CefSharp Forum

Who is online

Users browsing this forum: No registered users and 8 guests