Change pitch of audio during playback on iPhone [duplicate] - iphone

This question already has answers here:
Real-time Pitch Shifting on the iPhone
(5 answers)
Closed 7 years ago.
What is the best way to accomplish this?
From what I have read so far, it seems you have to setup IO Remote (which is a pain itself). Do you need to do a FFT? Are there any examples out there?
Can I just speed up / slow down playback?
Thanks

OpenAL lets you pitch-shift with the AL_PITCH source property. Maybe you could run your audio through OpenAL and use that.

I've never developed for an iPhone, but if you have sufficient control over the buffer sent to the audiodevice, then you could do the following:
say you have a buffer read from an audiofile, if you send only every even sample to the audiodevice (probably put in some other buffer which is passed to some function), then it will double the frequency and half the time to play the file.
If you want something in between you need to compute in between samples or resample the audiofile = interpolate values between successive samples.

Related

Perform real time FFT from Apple Watch microphone [closed]

Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
I'm developing an app that would be listening waiting for a certain frequency to be detected by the microphone. As far as I researched, I think the best way to do this is by performing a Fast Fourier Transform to the real time audio signal (if anyone think there's a better way to do it, I would love to hear from you). It works fine on iOS but I can't find a way to make it work on watchOS
I implemented the famous tempi-fft with no problems on iOS and Swift 5, the problems comes with different libraries not present or limited on watchOS SDK, as I can't use AudioUnit, AURenderCallback to detect new data on buffer, can't adjust the preferred buffer duration and sample rate to the AudioSession on WatchOS, etc. I'm not an expert at all with the 'audio engineering' side, so I don't know how to approach this. I researched a lot but i didn't find implementations on watchOS for this.
I only found this project AccelerateWatch, but this was uploaded years ago when Accelerate framework was not available on watchOS yet.
Any help on this would be greatly appreciated.
I have a chromatic tuner app for the Apple Watch in the iOS App Store that does exactly this, running completely inside the Apple Watch component.
Both the iOS app and the watchOS Watch app component use an AVAudioInputNode installTapOnBus to acquire AVAudioPCMBuffer microphone sample buffers in near real-time. Then the apps feed blocks of the audio sample data to either Goertzel routines or Accelerate framework vDSP FFT functions for further frequency analysis. Then the app does further processing on the FFT frequency data to detect and estimate audio pitch (which is often very different from the FFT frequency magnitude peak). The watchOS display is then animated at frame rate using SpriteKit to output the results.

iPhone audio frequency [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
How to detect sound frequency for particular sound in iphone?
I am seeking a way to find the frequency of mic input.
I can record my voice or a sin noise in a temporary file.
For the recording I am using the AVFoundation framework.
I used this framework to find the peak of the signal.
What can I do to find the frequency of the signal?
There is a quite good example project from Apple. Here is the link to the aurioTouch2 sample app:
https://developer.apple.com/library/ios/samplecode/aurioTouch2/Introduction/Intro.html
I guess you need to start using the CoreAudio Library instead of the AVFoundation. To get the frequency you probably need to use a FFT (Fast Fourier Transformation). This is done in the example above. It even visualizes a Spectogram (Frequency over time).
Or maybe this stackoverflow posts could help you:
Get Frequency for Audio Input on iPhone

iPhone sound manipulation [duplicate]

So I have been looking around for some time now on a way to produce a variable tone on the iPhone using OpenAL, the issue being the Apple has deprecated the ALUT part of OpenAL that has the alutCreateBufferWaveform that would be perfect for this. I was wondering if anyone had any idea how to make a tone generator using OpenAL on the iPhone SDK. All I need is the ability to produce a certain frequency tone consistantly over and over again.
This is a last resort so sorry if it sounds kind of stupid.
This isn't exactly what you are looking for, but it can create a similar effect.
I used this tutorial
http://benbritten.com/2008/11/06/openal-sound-on-the-iphone/
to create an engine that could play a prerecorded sound at different levels. So even though I have to play the sound from an existing *.caf file, I can modulate the pitch and control looping so it produces any frequency, length, or volume I'm looking for.

Talking Tom Cat Clone App [duplicate]

This question already has answers here:
Closed 10 years ago.
Possible Duplicate:
iPhone voice changer
I want to make an applications similar to Talking Tom Cat, But i am not able to identify the approach for sound.
How I can convert my sound into cat sound?
Look up independent time pitch stretching of audio. It's a digital signal processing technique. One method that can be used is the phase vocoder technique of sound analysis/resynthesis in conjunction with resampling. There seem to be a couple companies selling libraries to do suitable time pitch modification.
The technique to convert a normal voice into a squeaky voice is called time-scale modification of speech. One way is to take the speech and reduce the pitch by a certain amount. Another approach is to stretch/compress the speech so that the frequencies in the voice get scaled by an appropriate amount. These are techniques in digital signal processing.
the great link to download the sample code that provides all your needs,here also refer here for gaining more knowledge regarding your question.
In the init method of the Sample Code of HelloWorldLayer.mm ,u can see three float values as
time = 0.7;
pitch = 0.8;
formant = pow(2., 0./12.);
just adjust the pitch value to 1.9,it would be really a nice cat sound!!!

Real-time Pitch Shifting on the iPhone

I have a children's iPhone application that I am writing and I need to be able to shift the pitch of a sound sample using Core Audio. Does anyone have any example code I could look at where this is done. There are many music and game apps in the app store that do this so I know I am not the first one. However, I cannot find any examples of it being done.
you can use dirac-2 from dsp dimension for pitch shifting on the iphone. quote: -
"DIRAC2 is available as both a commercial object library offering unlimited sample rates and phase locked multichannel support and as a free single channel, 44.1/48kHz LE version."
use the soundtouch open source project to change pitch
Here is the link : http://www.surina.net/soundtouch/
Once you add soundtouch to your project, you have to give the input sound file path, output sound file path and pitch change as the input.
Since it takes more time to process your sound its better to modify soundtouch so that when you record the voice, directly give the data for processing. It will make your application better.
I know it's too late for the person who asked but it is really a valuable link (As I found) for any one else who is looking for the solution of the same problem.
So Here we have latest DIRAC3 with it's own audio player classes which will take care of run time pitch and speed(explore for god knows what more) shifting. Run the sample and have huge round of applause for that.
Try Dirac - it's the best technology out there and it's available on Win, Linux, MacOS X and iOS. We're using it in all our products (and a couple of others do as well, search for "Capo" on the App Store). They're at version 3 now which has seen a huge increase in performance since previous versions. Hope this helps.
See: Related question
How much control over pitch do you need... could you precalculate all the different sounds?
If the answer is yes, then you can just pick the right sounds and play them.
You could also use Audio Converter Services in conjunction with AVAudioPlayer, which will allow you to resample the audio (which will effectively repitch them, though they'll change duration).
Alternatively, as the related question points out, you could use OpenAL and AL_PITCH