After importing audio into unity, the file is playing back slightly slower and at a slightly lower pitch - unity3d

I have tried converting the audio file prior to importing into unity to both 44.1k and 48k sample rates and they sounds identical when played back in unity (slowed down and pitched down). I have tried this with a .wav file and a .aif at both sample rates mentioned above and it sounds the same. Any ideas why this is happening?

Related

Unity something went wrong when play too many audio clips simultaneously

I'm making a rhythm game, and I use 'AudioSource.PlayOneShot()' function to play the hit sound when the player hits the note. I downloaded a beatmap from Osu!Mania to test my game.
I found when there's too many audio clips playing simultaneously (20 audio clips or more per second), the audio output becomes stuttered, disorder, and the audio clips played earlier will temporarily be muted until the number of simultaneous audio clips playing is cut down to a certain amount...
It's common in difficult levels of rhythm games (play many audio clips simultaneously), I'm wondering how to solve this problem.
The problem exists on Windows whether on the Editor or not, and the FPS is OK when the problem happened.
Sorry for poor English.
The expected performance is playing many audio clips simultaneously fluently.
Okay... I've found the solution myself.
Open Edit->Project Settings->Audio,
and change the setting 'Max Real Voices' and 'Max Virtual Voices'.

Audio disappears in Unity after Project Setting change

I have a Audio Source linked to an Audio Listener looping some music. The problem with the audio is that I cannot hear anything. There are no error messages. I have tried muting the audio and then undoing it. I have also tried to restart Unity and adjusting the values on the Audio Source including pitch, volume, and looping, but the problem continues on. What is even more confusing is that when I started a project, the audio was working well, and then I did some adjusting on the Project Settings: Physics, the audio suddenly stopped. I do not have any code involved in the audio. When I tried to add another Audio Source and testing it to see if the Audio Source is the problem, it still creates no sound. I believe the problem lies nowhere near the Audio Source (though I might be wrong :D). Is there any other way to mute audio that I have missed? Thanks for any help.
Check that the Global Volume Setting under Project settings > Audio and that it is not set to 0. That worked for me.

Make unity play high frequency audio exact like the original wav file for hearing test

I am making a unity hearing test, I already manage to do all the code to play the audios, the problem is that unity is changing the way the files are played, for eg one of the files is 18000 Hz, when I open the file and play out of unity it is imposible to me hear anything, but if I play in unity I can hear it very clearly, what can be messing with the audio?
I am keeping the original audio sample rate and my audio sourcer is with default settings, here is the code to play the audio:
void PlayAudio(AudioClip auc) {
aus.PlayOneShot(auc, 1);
}`
here is the audio source:
as you can see normal settings
Thanks for hearing me
I faced a similar problem and used this script for simple sinewave generation
For audio files I chose FMOD

Play mp3 file smoothly upon dragging a scroll using AVToolbox or openAL

I have been facing this since so many days but I have not reach to any conclusion.
My problem is : I want to play an mp3 file but not simply by clicking on a play button.
It is this way I want to play it.
*There is a slider that I can drag using finger, I want that the mp3 should play with the frequency with which I am dragging the finger (or speed with which I am dragging my finger, so that it will give an effect of fast forwarding (funny type of voice)) or if I drag slider slowyly the output will be slow *
The problem is the output of the sound is not coming out smooth. its very distorted and disturbed voice.
I want the outuput to be smoother.
Please help. Any suggestions please. Presently I am using AVAudioPlayer and passing the time value based upon slider input to play the file. (It does not seems to be feasible though).
I feel that it is possible using openAL only and no other way. Because using openAL we can modify the frequency of the sound file (pitch)
CAN SOME ONE PLEASE REFER ME A LINK TO openAL implementation for iPhone . I have never played a sound file using openAL
Help!!
You won't be able to do it with AVAudioPlayer, as it does not support pitch operations.
You can load and decode the entire track into memory for playback with OpenAL (which supports pitch), or you can do realtime loading/decoding and pitch changing using Audio Units (MUCH lower level, and more complicated, though).

Audio Toolbox playback only plays part of output buffers

I'm working on a project which is using Audio Toolbox for recording and playback of PCM data, and I'm having trouble with playback. In the simulator, I can record and play audio just fine, using a custom class to handle storing and sourcing PCM bytes for the recording and playback buffers as needed. On device (iPhone (3.0.1) and iPod 2G (3.1.2)) recording works fine, the audio files produced are correct, but in-app playback stutters, like it's only playing part of each playback buffer. My buffers are one second long, and I've got 3 buffers, which are preloaded before playback starts; stuttering occurs during those first 3 seconds as well, which I think rules out a latency problem.
I've written Audio Toolbox code before that worked, and I'm not doing anything strange here except that I'm using my own class to source PCM data instead of AudioFileReadBytes()
I know the data that comes out of my source is good, because it plays right in the sim, and it writes to disk as a correct audio file
I've played around with sample rates a bit; I'm normally using 11025Hz sampling to cut down on file size (it's all voice, so it sounds fine). at 44100Hz, but with the same size of buffers, I get the same stuttering problem, but the audio segments come a lot faster, about 4 times faster. That's why I think it's only playing part of each buffer.
The only reason I can conceive that it would only play part of each buffer is a latency problem... like the audio toolbox code is running out of full buffers while I'm still filling an empty one. But that would cause it to play the preloaded buffers correctly, and then start stuttering, and that doesn't happen, it stutters the whole way through
I've tried humongous buffers, like 10MB buffers, and I just get silence and a single stutter of audio at the end of playback. I've also tried preloading more buffers than normal, like 10 seconds worth of audio, and it behaves the same.
The audio session is being set with AVAudioSession, not the Audio Toolbox calls, and it's being set to the Playback category for playback
I have no idea how to try and attack this problem, it makes no sense to me that it works fine on the simulator but not the device.
Code for the playing callback and the set up for the audio queue services: http://pastebin.com/mfaa546c
It turns out that the use of NSData's GetBytes:length: was causing the problem. The buffer filled with that method was playing incorrectly. However, doing a memcpy from that buffer to another buffer would prevent the problem.