Writing the native module
We need XCode to write the native module, which will use the microphone to record samples and to analyze those samples to calculate the main frequency. As we are not interested in how these calculations are made, we will use an open source library to delegate most of the recording and FFT calculations. The library is named SCListener
and a fork of it can be found at https://github.com/emilioicai/sc_listener.
We need to download the library and add its files to the project following these steps:
- Navigate to the folder where our iOS project is:
<project_folder>/ios/
. - Double-click on
guitarTuner.xcodeproj
, which should open XCode.
- Right-click on the
guitarTuner
folder and click onAdd Files to "guitarTuner"...
:
- Select all the files from the downloaded
SCListener
library:
- Click on
Accept
. You should end up with a file structure in XCode similar to this one:
SCListener
needs the AudioToolbox framework to be installed. Let's do this by clicking on the root of the project...