Пример #1
0
 void resample(float[] tempArray)
 {
     //resampleBuffer = new BigArray<float>( tempArray.Length, tempArray.Length );
     resampleBuffer.Resize(tempArray.Length);
     resampleBuffer.CopyFrom(tempArray, 0, 0, tempArray.Length * 4);
     //Debug.Log( "Resampling from: " + recordedAudio.frequency + ", to: " + this.recordingFrequency );
     AudioUtils.Resample(resampleBuffer, recordedAudio.frequency, this.recordingFrequency);
 }
        private IEnumerator yieldChunks(BigArray <float> data, int chunkSize, float chunkDuration)
        {
            int readHead = 0;

            while (readHead < data.Length)
            {
                int remainder = chunkSize;
                if (readHead + chunkSize >= data.Length)
                {
                    remainder = data.Length - readHead;
                }

                BigArray <float> temp = new BigArray <float>(remainder, 0);
                temp.Resize(remainder);
                temp.CopyFrom(data.Items, readHead * 4, 0, remainder * 4);
                AudioUtils.Resample(temp, testClip.frequency, AudioUtils.GetFrequency(ResampleFrequency));

                bufferReady(temp, AudioUtils.GetFrequency(ResampleFrequency));

                readHead += remainder;

                yield return(new WaitForSeconds(chunkDuration));
            }
        }