-
Notifications
You must be signed in to change notification settings - Fork 72
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
created audioclips having the wrong time length. #4
Comments
I think I know what the issue is here... When recording you set the time, but if the record audio clip is shorter then the full audio gets converted including the empty space. This should be timed so only the recorded time gets processed. I have some newer revisions of the code in another library which rectify this issue, but need to include changes back here #5 https://github.com/Unity3dAzure/UnityWebSocketDemo/blob/master/Assets/BingSpeech/MicRecorder.cs |
I'm not sure if this is related, but I ran into an issue where stereo wav files were twice the number of samples they should be once the AudioClip is created. I tracked it down to the offending line: Line 79 in 23e532a
For stereo files In other words let's say you have a file that is 1000 samples in duration. In a stereo file you will have 2000 total samples (1000 left, 1000 right). I replaced it with this line that takes the number of channels into account and allocates the correct number of samples in the AudioClip regardless of channel count: AudioClip audioClip = AudioClip.Create (name, data.Length / channels, (int)channels, sampleRate, false); Not sure if this is related to this issue, but it is an issue nonetheless and an easy fix. Hope this helps. |
Thank you @CymaticLabs for pointing out this issue, this really saved me a lot of time spent looking. Line 207 in 23e532a
should be changed to: int fileSize = audioClip.samples * BlockSize_16Bit * audioClip.channels + headerSize; // BlockSize (bitDepth) Line 307 in 23e532a
should be changed to: int subchunk2Size = Convert.ToInt32 (audioClip.samples * BlockSize_16Bit * audioClip.channels); // BlockSize (bitDepth) This makes the data writer keep the amount of channels in account and makes sure that all data is written to a bite stream. |
audio clips created using this are filled with a long period of silence in the file. silence can sometimes be longer that the original audio. this is persistent with many .wav files i have tried. Looking into it further. the file seems to be doubling in length with half being silence. e.g. the first half of the audio clip is the full audio and the second half is just silence.
The text was updated successfully, but these errors were encountered: