I am working on a "test your hearing application".
I know that half the amplitude is -6db.
I would like to know that when 1.0 is maximum volume using the AVAudioPlayer class, will setting the volume to 0.5 means that it plays at 50%, meaning a drop in relative db to -6db, if we used an ideal earphone?
That is an excellent question.
I wouldn't be surprised if the range in AVAudioPlayer more closely matches that of the "standard leveling scale" for popular music.
Notice here that 0dB is pretty far up linearly in the range. This is based on the history of the VU meter as described in Level Practices (Part 2) and seen in this picture:
So, I don't know for sure, but my guess would be that AVAudioPlayer more closely matches these ranges. You could always plug headphone jack of our iOS device into an application like Audacity, Logic, or Pro Tools and actually measure the signal coming out of your app as you sweep through the volume range in AVAudioPlayer.
Related
Sorry for my weak english
I've got some aif or MP3 tunes for plaing loud on the iPhone,
and I need to do some 'sound change' detections,
such I would use for some visualisations (jumping man or other)
how to do it 'easy' on iPhone or how to do it 'fine'?
should I do fft or such, or something different?
I have seen some sound visualisations back then but all they
seem not to much good (they seem not to be much clear in reactions on
music change).
Thanks
What are you currently using for playback? I would use audio queues or audio units - both give you access to buffers of audio samples as they're passed through to the hardware. At that point it's a matter of detecting peaks in the sound above a certain threshold, which you can do in a variety of different ways.
An FFT will not help you because you're interested in the time-domain waveform of the sound (its amplitude over time) not its frequency-domain characteristics (the relative strengths of different frequencies in different time windows.)
I need to create an audio loudness (decibel) detector. To clarify, I am not trying to find the volume at which the iPhone is playing, but instead the volume of its surrounding in decibels. How can I do this?
It can be done using AVAudioRecorder: http://b2cloud.com.au/tutorial/obtaining-decibels-from-the-ios-microphone
Use one of the Audio Queue or Audio Unit APIs to record low latency audio, run the samples through a DSP filter to weight the spectrum for the particular type or color of loudness you want to measure, then calibrate the mic on all the particular models of iOS devices you want to run your detector on against calibrated sound sources, perhaps in an anechoic chamber.
HI,
Is there any way to adjust the speed of the song being played by the MPMusicPlayerController?
I've searched everywhere but didn't find anything useful. If there is no way to do it where can I find an example which does it with other components? Some say OpenAL, but I can't find any clear way to use the iPod library with this and change the speed of the song...
Mainly the thing I need is:
The user chooses a song from the iPod library trough MPMusicPlayerController
You have 2 buttons: Slow Down & Speed Up
If the user presses "Slow Down" the speed of the song is slowed down by lets say 5% or something. "Speed Up" visa-versa.
I really hope someone can help me with this!
Thanks in advance!
You could do this as of iOS 3.2 and later -
[musicPlayer play];
[musicPlayer setCurrentPlaybackRate:2.0];
Ref: https://developer.apple.com/library/ios/documentation/mediaplayer/reference/MPMediaPlayback_protocol/Reference/Reference.html#//apple_ref/occ/intfp/MPMediaPlayback/currentPlaybackRate
You can use AVAudioPlayer and AVPlayer for the above purpose.
They have a rate property which can set the speed of the song.
[AVPlayer setRate:1.25]; // 25% faster
However, AVPlayer cannot change the speed by 5% but 25% and AVAudioPlayer works for iOS 5 and above.
If you wish to go for other alternative then Dirac is the best option. Try DIRAC 3 LE which is free.
Use this Link to get an idea on how to use Dirac. For more information, let me know.
#girish_vr
No, you can't do this using only the MPMusicPlayerController.
If you don't mind the pitch going up and down proportional to the speed changes, then you can use the OpenAL resampler after converting your sound file to raw PCM sample files or buffers.
If you don't want the pitch to change, what you are looking for is DSP time pitch stretching/modification/correction techniques. OpenAL can't do this, but there are commercial DSP libraries (DIRAC may be one) available that can do this on iOS. You could also try writing your own phase vocoder, but this is non-trivial digital signal processing code.
Within my iPhone application, how would I recognize the noise that a clap makes?
If you're talking about recognizing the sound of a clap, SCListener is a great and easy-to-use class that gives you simple audio levels. Then it's just a question of measuring peaks or even just high values.
In the new iPhone 3GS commercial, Apple shows voice control with a cool blue waveform animation. Is this visual effect for rendering the waveforms (or maybe just volumes) available as an API call or source code somewhere? (Not the voice control part, just the audio visualization)
I think you could get the sound info from AVAudioPlayer's averagePowerForChannel: method, but how would you show the waves moving up and down?
Thanks!
John,
That code that you found for drawing the sine wave is great. This sample code from Apple shows a sound meter with live audio recording. With those two resources, you should be on track to make the visual waveform.
The waveform in the apple commercials is very clearly just a plain old sine wave that looks like it's got its amplitude modulated by the volume of the input.