Hey everyone, I'm creating an app where I record voices. The recordings must be in 16000Hz, but when I play them back, they sound as if they're 8000Hz. This only occurs on iOS. When running in the editor, audio records and plays back in 16000Hz without issue. Has anyone had similar experience?
Sure, I've snipped a bunch of stuff together. Hopefully it's understandable. Basically I have a looping clip being recorded to acting as a buffer. Then when we tap "start", it begins to take samples from the buffer. Each chunk of samples is added to a temp array. When we tap "stop", the temp array is saved to a new Audio Clip. Then we can tap "Play" to have the clip play. Code (CSharp): //This is running constantly, looping as an audio buffer (frequency is 16000) audio.clip = Microphone.Start( _microphone, true, 120, frequency ); //this loops to pull out samples audio.clip.GetData( audioFloats, readHead ); readHead = ( readHead + nFloatsToGet ) % audio.clip.samples; //this takes every chunk of samples and puts them in an array that is saved tArray = new float[sArray.Length + _array.Length]; Array.Copy( sArray, tArray, sArray.Length ); Array.Copy( _array, 0, tArray, sArray.Length, _array.Length ); sArray = tArray; //save the latest data we pulled from the buffer recentClip = AudioClip.Create( "speechPlaybackClip", sArray.Length, 1, 16000, false, false ); recentClip.SetData( sArray, 0 ); //play audio audio.PlayOneShot( Speech.getRecentClip() );