Introduction: Guitar Tuner
Often stringed instruments go out of tune due to regular use. In this Instructable, we are going to build a gadget that you can use to re-tune your instrument.
You'll need following to complete this build:
- Intel Edison with Arduino breakout board
- USB sound card
- A microphone and a speaker
- Grove base shield with button and LCD module
There are two modes of operation
- Visual mode
- In visual mode, you set a target frequency and play the note on your instrument as soon as the target note set is detected, the LCD back light will turn blue from red and also estimated note is displayed on the LCD.
- Audio mode
- This mode is for seasoned musicians. In this mode, a reference note is played back continuously which can be used as a reference to tune your stringed instrument.
Step 1: Configuring Edison
First thing to do is to setup the USB audio card. To connect the USB sound card, you'll need to move the switch near the USB port towards the USB host port as in the attached picture. In this mode, you will have to power the base board with a DC power supply adapter (7V-15V, I used the power adapter that came with Intel Galileo Gen2) .
In the Linux console (refer to this getting started guide if you want to know how you can gain access to the Linux console), type the following command:
Note down by what name your device got recognized. In my setup as "U0xd8c0x13c".
Open up the file "/etc/asound.conf" for editing using "vi"
Press 'i' to start editing the file and enter the following text with replaced by your actual USB audio card name.
In my case, that would be:
This should setup the audio card. To test if your USB audio card gets used as the default audio card, connect external speaker or headphone to the USB sound card. When you execute the following command you should hear some one speak:
Now that the audio card is setup, you'll have to install the port audio.
wget http://www.portaudio.com/archives/pa_stable_v19_20140130.tgz tar zxvf pa_stable_v19_20140130.tgz cd portaudio/ ./configure make make install
Step 2: Hardware Connection
There are only two connections to make on the Grove base shield:
- Button -- Port D6
- LCD -- I2C
Connect a microphone to the mic in of the sound card and an externally powered speaker to sound out of the USB sound card.
Step 3: Using the Application
You need to install git on your Edison to proceed with this step.
Follow this page to add new repos.
Add git from the repo
opkg update opkg install git
Follow these instructions to install the tuner application:
git clone https://github.com/navin-bhaskar/GuitarTuner_EdisonGalileo.git tuner cd tuner make
This should build the tuner application. Start the application by typing the following command:
Setting the target note:
The target note is the note to which you want to tune your instrument to. A single click of the button cycles the notes from "C" through "B" and back again. For example if the target note is "C", a click advances it to "C#" (C sharp or B flat).
There are two modes of operation for this device:
- Visual mode:
- In visual mode, as soon as the target note is detected, the LCD back light changes to blue and also the estimated note is displayed on the LCD
- Audio mode:
- You enter audio mode by long press of the button. The audio mode is exited with single button click
- In this mode, the selected target note is played back in a loop which can be used as a reference for tuning your instrument
You can exit the application any time by hitting "ctrl-c".
This application uses a digital low pass filter to cutoff high frequency noise. On your system if you have installed scipy, then you can use the supplied "filter.py" to generate filter parameters for your needs by changing the cutoff frequency, Fc. Additionally, you might want to increase the order(set to 2 in script), for better performance of the filter but this comes at a performance penalty.
If the application fails with "Invalid sampling rate" then the default sampling rate used by this application is not supported by your audio card. In that case, you'll have to first check for the supported sampling rates for your device.
You can run the following command to know what sampling rates are supported:
Check for "rates" filed and note it down.
Note that in the above command, I know my sound card is card2 from the "aplay -l" output.
Change the sampling rate in "config.h" line 8 using vi.
Navigate to line 8 and replace the number in "#define SAMPLING_RATE (your_sampling_rate)".
Participated in the
Intel® IoT Invitational