Wavplot
wavplot is simple function to plot .wav file. Why I need it? because I continuously working with .wav file, and I want to plot it directly to get information of sound file via its waveform. Here the code of wavplot function.
function wavplot(wavFile) % wavplot(wavFile) plot waveform and spectrum of wav file % bagus@ep.its.ac.id if nargin>1 fprintf('Usage: wavplot(wavFile \n'); return; end; [y, fs]=wavread(wavFile); plot(y) end
How to use it? it is simple. If you have .wav file, for example it has name tone.wav and you are in the current directory of Matlab command window, you can directly plot it with this function,
wavplot('tone.wav')And it will plot the wav file like the following,
Output of wavplot function |
While wavplot is function to plot wav file, wavplay is function to play wav file. Instead of using "wavread" and then "sound", we can play sound file directly by this function. This function is replacement for built-in Matlab function which only works on Windows OS.
function wavplay(wavFile) % Modified by Bagus Tris Atmaja 2015/04/11 12.47 % bagus@ep.its.ac.id VibrasticLab - ITS if nargin>1 fprintf('Usage: wavplay(wavFile \n'); return; end; [y, fs]=wavread(wavFile); sound(y,fs) end
Using this function is also simple, just write wavfile('filename.wav') in the command window, it will play sound file filename.wav.
Both function are available in Github, as part of VibrasticLab library developed in VibrasticLab, ITS.