private float[] ReadChannelDataFromUnderlyingMixerStream(int mixerStream, int secondsToRead, int sampleRate)
        {
            float[]        buffer           = new float[sampleRate * DefaultBufferLengthInSeconds];
            int            totalBytesToRead = secondsToRead == 0 ? int.MaxValue : secondsToRead * sampleRate * 4;
            int            totalBytesRead   = 0;
            List <float[]> chunks           = new List <float[]>();

            while (totalBytesRead < totalBytesToRead)
            {
                // get re-sampled/mono data
                int bytesRead = bassServiceProxy.ChannelGetData(mixerStream, buffer, buffer.Length * 4);

                if (bytesRead == -1)
                {
                    throw new BassAudioServiceException(bassServiceProxy.GetLastError());
                }

                if (bytesRead == 0)
                {
                    break;
                }

                totalBytesRead += bytesRead;

                float[] chunk;

                if (totalBytesRead > totalBytesToRead)
                {
                    chunk = new float[(totalBytesToRead - (totalBytesRead - bytesRead)) / 4];
                    Array.Copy(buffer, chunk, (totalBytesToRead - (totalBytesRead - bytesRead)) / 4);
                }
                else
                {
                    chunk = new float[bytesRead / 4]; // each float contains 4 bytes
                    Array.Copy(buffer, chunk, bytesRead / 4);
                }

                chunks.Add(chunk);
            }

            if (totalBytesRead < (secondsToRead * sampleRate * 4))
            {
                throw new BassAudioServiceException(
                          "Could not read requested number of seconds " + secondsToRead + ", audio file is not that long");
            }

            return(ConcatenateChunksOfSamples(chunks));
        }
 public int GetNextSamples(float[] buffer)
 {
     return(proxy.ChannelGetData(source, buffer, buffer.Length * 4));
 }