L
L
Lishout2017-10-06 16:31:10
Audio
Lishout, 2017-10-06 16:31:10

How to simultaneously play (N)BufferedWaveProvider and control volume level for each in NAudio?

(N) - the number of providers, supposedly no more than 20.
The situation is as follows, I have (N) BufferedWaveProvider.
In these providers, I write the bytes received over the network.
I need to somehow start playing them, and also control the volume level for each BufferedWaveProvider.
Tried each BufferedWaveProvider to allocate its own WaveOut, but this way the sound is controlled for the entire application, and not for a specific provider in particular.
I have no idea how this can be checked.

Answer the question

In order to leave comments, you need to log in

1 answer(s)
L
Lishout, 2017-10-07
@Lishout

Resolved the issue.
Just threw the received bytes into a function.

private unsafe void VolumeSetter(byte[] destBuffer, int bytesRead, short loudnessDivider)
        {
            fixed (byte* pDestBuffer = &destBuffer[0])
            {
                short* pfDestBuffer = (short*)pDestBuffer;
                int samplesRead = bytesRead / 2;
                for (int n = 0; n < samplesRead; n++)
                {
                    pfDestBuffer[n] /= loudnessDivider;
                }
            }
        }

Everything turned out to be quite simple, it was necessary to read the materiel.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question