Audio Graphing in Plotly

by Eric_Hill in Circuits > Audio

3228 Views, 7 Favorites, 0 Comments

Audio Graphing in Plotly

9.JPG

This project teaches you how to use MATLAB to record and transfer audio data to Plotly and graph it. You will need the MATLAB software, a microphone, and a Plotly account.

You can see my graph here.

Code in MATLAB

10.JPG
Open up MATLAB.
Create a new Script by pressing ctrl+N or selecting File->New->Script
Save the Script as 'AudioGraph_Plotly.m'
Paste the following code into the Editor and save:
clc;
clear
recObj=audiorecorder;
disp('Recording Audio...');
recordblocking(recObj,3);
disp('Done Recording');
play(recObj);
myRecording=getaudiodata(recObj);
save('AudioData.dat','myRecording','-ascii');
clear;
clc;

Collect Data

recTime.png
F5.png
Console.png
3.JPG
Quick Edit:
You can change the amount of seconds that the program records audio for by changing the line "recordblocking(recObj,3);" where the "3" represents the time (in seconds) that audio will be recorded.

You can now run the program by either pressing F5 or clicking the green Run button.
When the program runs the console window will display "Recording Audio..." followed by "Done Recording" when the audio is no longer being recorded. After this is done, all the audio data will have been stored in a file labeled 'AudioData.dat'.

Moving the Data Into Plotly

4.JPG
5.JPG
7.JPG
8.JPG
9.JPG

Open Plotly and sign in.
Click IMPORT.
Your data should appear in two columns. The left column represents your X values and the right column represents your Y values. Select 'choose as x' for the left column and 'choose as y' for the right column.
On the left side of the screen choose Line Plot and click the blue button labeled "Line Plot".
Your audio data should now be compressed into a waveform that is easily distinguishable.

Now all you need is labels for the x-axis and y-axis and a title and your graph is complete.

If you make an audio graph post it in the comments so everyone can see!

Go a step further:
You can now begin to play with the data to make some pretty cool graphs. Try a bubble graph or changing colors depending on values.