This time, I try to share my experience for users of Linux, how to manipulate a sound file (*.wav) using octave in linux (I use linux ubuntu version 10.04).
First of all, we record sound which we will take, it can use the program Audacity or Sweep on linux. This time I use the program Audacity like the following,
Figure 1. Display the Audacity program
File obtained from the audacity can be saved or exported in a variety of file types like mp3, mp2, wma, amr, wav, and so on. In this case the file is saved in wav / export format such as the following image,
2. Audacity export sound file to format *.wav
Next, files *.wav can be opened by using a program such as follows,
Figure 3. Open file *. wav using Sweep program.
Furthermore by using Sweep, files *.wav in save / save as to the format of *. mat5 like the following image,
Figure 4. Save the file to the format *.wav *. mat5 to use the sweep program
Next *. mat5 can be opened by using the script the following octave,
—————————————– file ————————————————————————
#! /usr/bin/octave -qfload(’sam1-023-01.mat5′);
x = wavedata(1:10000);
s = samplerate ;
file = fopen(”sam1-023-01.txt”,”w+”);
fprintf(file,”sampling rate (Hz) = %20.15fn”,s);
fprintf(file,’%fn’,x);
plot(x);
xlabel(’time’);
ylabel(”amplitude”);
print -deps sam1-023-01.pdf
—————————————– file ————————————————————————
The above Script can be written in a file with a name that has the extension m (*.m) just to indicate that this octave file. This File should be created it to be able to chmod to be executed by using the command as follows:
abuadnan@abuadnan-laptop:~$ chmod +x baca_wave.m
Here the file name to read a file *. mat5 is baca_wave. m.
abuadnan@abuadnan-laptop:~$ ./baca_wave.m
The result corresponds to a command written in the script that creates ASCII file with the name "sam1-023-01. txt" and a pdf file with the name "sam1-023-01. pdf".
Examples of the results of the script octave can be seen as following picture,
Figure 5. Example file output from the script octave (sound waves)
Sample files for processing sound files can be downloaded from here (1.1 MB).
No comments:
Post a Comment