コード例 #1
0
ファイル: AudioSampleLoop.cs プロジェクト: tebjan/NewAudio
            public int Read(float[] buffer, int offset, int count)
            {
                if (input != null)
                {
                    var inputSamples = count * InputChannels / outputChannels;
                    if (inputBuffer == null || inputBuffer.Length != inputSamples)
                    {
                        inputBuffer = new float[inputSamples];
                    }

                    input.Read(inputBuffer, offset, inputSamples);
                }
                else
                {
                    inputBuffer = null;
                }


                if (oversampling <= 1)
                {
                    LoopNormal(buffer, count);
                }
                else
                {
                    LoopOversampling(buffer, count);
                }

                return(count);
            }
コード例 #2
0
ファイル: FFT.cs プロジェクト: tebjan/NewAudio
            public int Read(float[] buffer, int offset, int count)
            {
                if (Input != null)
                {
                    var l = Input.Read(buffer, offset, count);
                    for (int i = 0; i < l; i += Input.WaveFormat.Channels)
                    {
                        Add(buffer[offset + i]);
                    }

                    return(l);
                }

                Spread = null;
                return(count);
            }
コード例 #3
0
            public int Read(float[] b, int offset, int count)
            {
                var samplesToRead = count / channels;

                while (buffer.Count < samplesToRead * channels)
                {
                    if (tempBuffer.Length < samplesToRead * inputChannels)
                    {
                        tempBuffer = new float[samplesToRead * inputChannels];
                    }

                    var dataRead    = input.Read(tempBuffer, offset, samplesToRead * inputChannels);
                    int outputIndex = 0;
                    for (int j = 0; j < dataRead; j++)
                    {
                        buffersMapped[outputIndex].Add(tempBuffer[j]);
                        outputIndex++;
                        outputIndex %= outputChannels;
                    }
                }

                return(buffer.Read(b, offset, count));
            }