I am trying to make something like,i am recording a sound and on the basis of sound (pitch,frequency,not sure) the image should move.
I am able to achieve recording, also i image sequence in place, but seperately. I am not sure how to link that,just for the information, i am trying to achieve something like mouth mover app: app url here
My question is , how can i move/animate image on the basis of sound frequency.
Thanks
Swiss scientists use sound waves to levitate and manipulate objects, such as water droplets and a particle of sodium, in mid-air. Scientists have been able to use the power of sound to levitate small items — including insects and fish — for decades.
Previous research has already shown that levitation using soundwaves is possible. Objects can be held and moved in mid-air using the force from high intensity ultrasound waves (which have a frequency higher than humans can hear) to hold something in place, known as acoustic levitation.
Levitation occurs at positions 5-10 cm above the sound source, for driving frequencies from 40 Hz to 80 Hz (particularly around the nonlinear harmonics of the nearly 20 Hz Helmholtz resonance), and during periods of time from 1 minute, up to 3-4 minutes.
Objects larger than two thirds of the sound's wavelength are too large to be levitated -- the field isn't big enough to support them. The higher the frequency of the sound, the smaller the diameter of the objects it's possible to levitate. Objects that are the right size to levitate must also be of the right mass.
Acoustic levitation uses sound waves to hold objects in mid-air. We are all familiar with the power of sound to make us dance and change our moods, but sound can also exert a physical force that is strong enough to levitate objects.
I am done with the solution.Used Dirac and problem solved.
Edit:
What is it?
DiracAudioPlayer is a new set of Cocoa classes that wrap the entire Dirac functionality in a convenient way, exposing an API that is similar to what AVAudioPlayer offers. Note that this is not an AVAudioPlayer subclass. Following are the core features and a description of the API.
DiracAudioPlayer Core Features
DiracAudioPlayer is a set of classes that allow file based playback of a variety of audio formats (including MPMediaItems) while simultaneously changing speed and pitch of the audio file in real time. Version 3.6 consists of DiracAudioPlayerBase (the base class taking care of file IO and playback), DiracAudioPlayer (wrapping the Dirac Core API) and DiracFxAudioPlayer (wrapping the DiracFx API).
Make sure you include all 3 classes in your project as well as the "ExtAudioFile" and "util" folders, and add Accelerate.framework and CoreAudio.framework to the project. On MacOS X you will have to add the AudioUnit.framework as well, on iOS you will have to add AudioToolbox.framework, AVFoundation.framework, MediaPlayer.framework and CoreMedia.framework instead.
DiracAudioPlayer is…
…an Apple-compatible class to play back time stretched audio that works on both iOS (version 4 and higher) and MacOS X (version 10.6 and higher) …very easy to use …fully ARC compatible …delivered to you including the full source code
DiracAudioPlayer API
Version 3.6 released in November 2012 offers the following calls:
- (id) initWithContentsOfURL:(NSURL*)inUrl channels:(int)channels error: (NSError **)error;
Initializes and returns an audio player for playing a designated sound file. A URL identifying the sound file to play. The audio data must be in a format supported by Core Audio. Pass in the address of a nil-initialized NSError object. If an error occurs, upon return the NSError object describes the error. To use an item from the user's iPod library supply the URL that you get via MPMediaItem's MPMediaItemPropertyAssetURL property as inUrl. Note that FairPlay protected content can NOT be processed.
- (void) setDelegate:(id)delegate;
- (id) delegate;
Set/get delegate of the class. If you implement the delegate protocol, DiracAudioPlayer will call your implementation of
- (void)diracPlayerDidFinishPlaying:(DiracAudioPlayerBase *)player successfully:(BOOL)flag
When it is done playing
- (void) changeDuration:(float)duration;
- (void) changePitch:(float)pitch;
Change playback speed and pitch
- (NSInteger) numberOfLoops;
- (void) setNumberOfLoops:(NSInteger)loops;
A value of 0, which is the default, means to play the sound once. Set a positive integer value to specify the number of times to return to the start and play again. For example, specifying a value of 1 results in a total of two plays of the sound. Set any negative integer value to loop the sound indefinitely until you call the stop method.
- (void) updateMeters;
Must be called prior to calling -peakPowerForChannel in order to update its internal measurements
- (float) peakPowerForChannel:(NSUInteger)channelNumber;
A floating-point representation, in decibels, of a given audio channel’s current peak power. A return value of 0 dB indicates full scale, or maximum power; a return value of -160 dB indicates minimum power (that is, near silence). If the signal provided to the audio player exceeds ±full scale, then the return value may exceed 0 (that is, it may enter the positive range). To obtain a current peak power value, you must call the updateMeters method before calling this method.
- (BOOL) prepareToPlay;
Starts the Dirac processing thread and prepares the sound file for playback. If you don't call this explicitly it will be called when calling -play
- (NSUInteger) numberOfChannels;
The number of audio channels in the sound associated with the audio player. (read-only)
- (NSTimeInterval) fileDuration;
Returns the total duration, in seconds, of the sound associated with the audio player. (read-only)
- (NSTimeInterval) currentTime;
- (void) setCurrentTime:(NSTimeInterval)time
Returns the current play time in the input file. Note that if you apply time stretching, -currentTime will reflect the slowed down time depending on the time stretch factor.
IMPORTANT CHANGE: In previous versions this value returned the total play time independent of the position in the file. Please update your code accordingly to reflect the change
Setting this property causes playback to fast forward or rewind to the specified play time.
- (void) play;
Plays a sound asynchronously. Returns YES on success, or NO on failure. Calling this method implicitly calls the -prepareToPlay method if the audio player is not already prepared to play.
- (NSURL*) url;
The URL for the sound associated with the audio player. (read-only)
- (void) setVolume:(float)volume;
- (float) volume;
The playback gain for the audio player, ranging from 0.0 through 1.0.
- (BOOL) playing;
A Boolean value that indicates whether the audio player is playing (YES) or not (NO). (read-only). To find out when playback has stopped, use the diracPlayerDidFinishPlaying:successfully: delegate method.
- (void) pause;
Pauses playback; sound remains ready to resume playback from where it left off. Calling pause leaves the audio player prepared to play; it does not release the audio hardware that was acquired upon calling -play or -prepareToPlay.
- (void) stop;
Stops playback and undoes the setup needed for playback. Calling this method, or allowing a sound to finish playing, undoes the setup performed upon calling the -play or -prepareToPlay methods.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With