Introduction: Audio Graphing in Plotly

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.

Step 1: Code in MATLAB

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;

Step 2: Collect Data

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'.

Step 3: Moving the Data Into Plotly

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.

Comments

author
plotlygraphs made it! (author)2014-03-25

Very cool! Do you have a link to the graph? We'd love to see it (sorry if we missed it).

author
searx made it! (author)searx2014-03-26

Title Step with hyperlink

About This Instructable

1,352views

7favorites

License:

Bio: Electrical Engineering Major
More by searx:Sonar Collar for Blind DogsDog Mood Detector (Raspberry Pi)Running Videos on a TI84 Calculator
Add instructable to: