I am working with ijkplayer video player library to play videos in my android app.But when i try to increase the audio speed (e.g 1.5+) it change my audio tone.I looked into the source code of ijkplayer but couldn't figure out the issue. When setting playback rate it calculates pitch and sample rate which seems working to me.I enabled soundtouch for playing audio.Can anyone help me figure out how i can fix this issue. If you need more information please leave a comment.
I'm not familiar with the specific software you are using, but a fundamental aspect of sound is that if you change the rate of the playback, this will change the pitch of the sound. Sound is measured in pulses per unit time, for example, in Hertz, which is waves per second, where 440 Hz is the A note used to tune an orchestra. If you change the rate of playback to speed it up 50%, the resulting sound will vibrate at 660 Hz, which is the E above that A.
If you want to change the playback rate without altering the pitch, this will require additional digital signal processing. The algorithm is a bit too complex for me to explain here. It involves breaking the original signal up into 'granules' and rejoining them. The process is specialized enough that it is something more commonly dealt with at another forum, dedicated to Signal Processing.
Related
I am using the AudioRecord class to record an user's voice through mic. Is there anyway to change the voice or pitch of the user during the recording in progress. If there is no such way, how can I modulate the output audio file and alter its pitch and save the file back. I don't need the solution to alter the pitch while playing the audio. Thanks in advance.
If you don't care about preserving playback speed, then most simple solution is to change playback speed. I.e. you can record a sound in 22050 samples per second rate, and then put it in a file, as if it was recorded in 44100 sps. When file will be played, it will be 2 times faster and, respectively, one octave higher pitch.
If you want to preserve the sampling rate, or you want to change speed in some fractional ration, then you need to apply some resampling algorithm to your sound data.
If you want to change only pitch while preserving playback time, you need to implement some algorithm on your own.
There are a lot of algorithms that allows to change a pitch. They varying on their sound quality.
For my taste, better quality could be obtain by performing FFT-based time stretch algorithm, which will make your sound longer or shorter while preserving pitch. After that apply a resampling algorithm with reciprocal scale, which will change both pitch and speed, and speed will be returned back to original, while pitch will be changed as you want.
I don't think there are solutions in stile "someObject.doEverythingGoodForMe()" that will be work on all platforms.
I have a wav file playing through my speakers. Now I have recorded the sound playing through my speakers using my mic. At the same bit rate and PCM quality values as the playing file. Now I want to exactly sync these two songs.Say for eg: the 15th PCM value in the song playing through the speaker was recorded as the 5th PCM value. I want to detect this and sync the song accordingly. Complexity is not much a concern and I need to do this without human intervention. I know there would be noise and the values wont be the same but I need to just sync these two songs so they play exactly superimpose. I am using mono,16BIt PCM value with a bit rate of 44100.
Because of noise, distortion, echos and other delays, there is no simple solution for your problem. However, generally speaking, the solution to this type of problem is to use Cross Correlation. Broadly speaking, the peak in the cross-correlation will tell you the delay between the two signals.
I am just developing a sample app in unity (as a beginner) so i am stuck at a point, i need to change the sound which is recorded (like in Talking Tom app).
i am done with recording the audio but when i increase the pitch of the sound the speed of the playback is also changed. i need the playback speed is normal only pitch must be changed.
so can anyone help me on this issue.
Thanks in advance
After a bit of researching, I found that what you're trying to do is called "pitch shifting". It involves a lot of math and mucking about with sound packets apparently because changing the pitch of a sound, automatically changes it's playback speed. Getting it back to the speed you want while still keeping the audio at something considered "normal" is no walk in the park.
In any case, since Unity3D uses C#, you might (and I stress the word might) be able to use this open source library to get the sound effect you need. It's based on NAudio (also open source, and C#) so you should theoretically be able to use it, or parts of it in your project.
I am developing a sound related application. I am trying to change the audio sound in to completely different like robot sound or make the audio echo. I tried with soundpool , but no any idea, anyone knows how to achieve that? i need only a basic idea to achieve this, please help. many thanks.
Pitch and echo are 2 different things.
Pitch:
You can alter the pitch by modifing the playback rate. You can do it in 2 ways, with audioTrack and setPlayBackRate or with SoundPool and setRate. Depends on your needs, AudioTrack allow a larger range of pitch (from 1hz to x2) on large files and SoundPool for sound effects and picth can vary between x0.5 and x2.
Echo/reverb:
You can archive this with AudioEffect since API lvl 9 by attaching it to an AudioTrack or MediaPlayer instance.
For a robot effect you want to set a constant pitch for the audio. I.e. do a FFT, move everything into a single frequency bin, and then do an inverse FFT to get back into the time domain.
For an echo effect you could keep a separate buffer which is as long as your desired echo delay. And for every sample do something like the following (pseudo-code):
output = mix(currentSample, echoBuffer[echoPos]*echoVolume)
echoBuffer[echoPos] = mix(currentSample, echoBuffer[echoPos]*echofeedback)
echoPos += 1
Im working on a similar project and i can say that you need to look into DSP (digital signal processing), PCM 16 format and preferably fourier transforms.
It is possible to loopback audio with the AudioRecord class (running a thread constantly filling the buffer on a AudioTrack)
But the delay might be too big for what you are trying to accomplish.
Best of luck in your endevours!
Some really good pointers:
Android AudioRecord class - process live mic audio quickly, set up callback function
I recorded some audio files to use in my app, around 50, so I would like to not record all of them again. I recently used SoundPool to play the audio files on a real device instead of the emulator and you can barely hear them. On the emulator with my PC volume set to max and device to max, I can hear it fine. Should I try to record the files louder or is there another option?
I've found that when targeting mobile devices (and cheap/small laptop speakers for that matter), it is best to do two things to your audio:
Compression: I do not mean data compression, I mean dynamic contrast compression. This will remove some of the level differences between loud and soft parts of the recording, allowing it all to be heard better.
Normalization: When you normalize audio, you take the loudest part of the audio, and scale the entire audio clip up so that the loudest part is at the loudest that can be stored in the audio file.
You can do both of these easily with any audio editing software, such as Audacity.
Finally, you should also keep in mind the reproduceable frequencies on such small speakers.
Most of these speakers are built with speech in mind. Because of this, you will find that they tend to be the loudest in the 700Hz-2.5kHz range.
That is, if your sound effects are low in frequency (think bass), then it will be almost impossible to hear them on a phone's small speaker which cannot reproduce such low frequencies.
If you have more questions on the matter, please visit https://video.stackexchange.com/.
If it is the volume of the recorded files, you can change it using a normalizer like MP3Gain.