I'm new to iOS programming and I don't know where to start. I found code examples how to read frequencies from the microphone with AudioKit framework. But this is not what I am looking for. Is it possible to retrieving frequency of the currently playing song in real time without using a microphone? Thank you for help.
Asked
Active
Viewed 565 times
-1
-
Your question is not very clear, What are you trying to actually achieve here? You need an input of some sort, so if it is not taken from an external hardware source such as a microphone then you need an audio file. Once you have an audio source then you can use AudioKit to extract data from the source – Scriptable Mar 26 '19 at 18:21
-
I would like to use audio stream source which appears e.g. when you play music from Music app. My goal is receiving "main" (I do not know if it's a good word) audio stream and constantly showing actual frequency in program. – Madrox24 Mar 26 '19 at 18:34
-
You are trying to do too many things at once. Divide your project into several steps and solve them one by one. The first step could be to figure out how the currently playing song can be accessed at all. Next, find out which Frameworks Apple offers for audio processing. Read the documentation and example code, try to integrate it in your application. Once you have direct access to the audio stream, try to build a frequency analysis. Stack Overflow is helpful if you are stuck with details. For broader questions, look for answers in online tutorials or books. – Theo Mar 26 '19 at 19:15
1 Answers
0
The iOS security sandbox prevents apps from capturing general audio output of any other app, such as the Music app.
Certain music apps, such as GarageBand might share inter-app audio, but this isn't supported by the majority of apps that output "songs".
An app might play the "song" itself, via an AVAudioPlayer, and tap the AVPlayer's output to get raw sample data for spectral frequency and pitch analysis (two very different things, by-the-way).

hotpaw2
- 70,107
- 14
- 90
- 153
-
Thank you for the answer, it saved me a lot of frustration. Once I play song through AVAudioPlayer, how can I get frequency? I can't find any example how to achieve this. – Madrox24 Mar 26 '19 at 19:01
-
firstly you need to get the source, as I said. this could be a URL or a file. once you have that you can play with AVAudioPlayer or analyse it. Generally your question seems too broad and has likely been asked before. Take a look at: https://stackoverflow.com/questions/11686625/get-hz-frequency-from-audio-stream-on-iphone – Scriptable Mar 26 '19 at 19:21
-
Asking how to get a “frequency” is way too ambiguous, as audio frequency spectral decomposition and musical pitch are not the same thing. The question might even be a current machine learning research topic. – hotpaw2 Mar 27 '19 at 04:17