{"id":38,"date":"2012-04-26T10:41:25","date_gmt":"2012-04-26T10:41:25","guid":{"rendered":"http:\/\/azfreeos.wordpress.com\/?p=38"},"modified":"2013-09-27T14:43:33","modified_gmt":"2013-09-27T14:43:33","slug":"editing-sound-wave-file-using-octave","status":"publish","type":"post","link":"https:\/\/dosen.unila.ac.id\/ahmadzakaria\/2012\/04\/26\/editing-sound-wave-file-using-octave\/","title":{"rendered":"Editing sound wave file using octave"},"content":{"rendered":"<p>Manipulate sound files (sound wave files or *.wav files) often we need if we want to process the file is either for the purposes of reducing the file size as well as to learn or to filter the files in accordance with the purposes such as to see the frequency of sound waves that propagate in concrete, reduce noise and so on.<\/p>\n<p>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).<\/p>\n<p>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,<\/p>\n<div>\n<hr \/>\n<\/div>\n<p style=\"text-align: center\"><a href=\"https:\/\/dosen.unila.ac.id\/wp-content\/uploads\/sites\/21\/2012\/04\/suara-audacity.jpg\"><img fetchpriority=\"high\" decoding=\"async\" alt=\"\" src=\"https:\/\/dosen.unila.ac.id\/wp-content\/uploads\/sites\/21\/2012\/04\/suara-audacity.jpg?w=300\" width=\"320\" height=\"180\" border=\"0\" \/><\/a><\/p>\n<div>\n<p style=\"text-align: center\">Figure 1. Display the Audacity program<\/p>\n<\/div>\n<div><\/div>\n<div>\n<p>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,<\/p>\n<\/div>\n<div><\/div>\n<p style=\"text-align: center\"><a href=\"http:\/\/azfreeos.files.wordpress.com\/2012\/04\/save-audacity.jpg\"><img decoding=\"async\" alt=\"\" src=\"http:\/\/azfreeos.files.wordpress.com\/2012\/04\/save-audacity.jpg?w=300\" width=\"320\" height=\"180\" border=\"0\" \/><\/a><\/p>\n<div><\/div>\n<div>\n<p style=\"text-align: center\">Figure 2. Audacity export sound file to format *.wav<\/p>\n<\/div>\n<div><\/div>\n<div><\/div>\n<div>\n<p>Next, files *.wav can be opened by using a program such as\u00a0 follows,<\/p>\n<\/div>\n<div><\/div>\n<p style=\"text-align: center\"><a href=\"https:\/\/dosen.unila.ac.id\/wp-content\/uploads\/sites\/21\/2012\/04\/wave-sweep.jpg\"><img decoding=\"async\" alt=\"\" src=\"https:\/\/dosen.unila.ac.id\/wp-content\/uploads\/sites\/21\/2012\/04\/wave-sweep.jpg?w=300\" width=\"320\" height=\"180\" border=\"0\" \/><\/a><\/p>\n<div>\n<p style=\"text-align: center\">Figure 3. Open file *. wav using Sweep program.<\/p>\n<\/div>\n<div><\/div>\n<div>\n<p>Furthermore by using Sweep, files *.wav in save \/ save as to the format of *. mat5 like the following image,<\/p>\n<\/div>\n<p style=\"text-align: center\"><a href=\"http:\/\/azfreeos.files.wordpress.com\/2012\/04\/wave2mat5.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" alt=\"\" src=\"http:\/\/azfreeos.files.wordpress.com\/2012\/04\/wave2mat5.jpg?w=300\" width=\"320\" height=\"180\" border=\"0\" \/><\/a><\/p>\n<p style=\"text-align: center\">Figure 4. Save the file to the format *.wav *. mat5<\/p>\n<p style=\"text-align: left\">to use the sweep program\u00a0Next *. mat5 can be opened by using the script the following octave,<\/p>\n<p>\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2013 file \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014<\/p>\n<p>#! \/usr\/bin\/octave -qf<\/p>\n<p>load(\u2019sam1-023-01.mat5\u2032);<\/p>\n<p>x = wavedata(1:10000);<\/p>\n<p>s = samplerate ;<\/p>\n<p>file = fopen(\u201dsam1-023-01.txt\u201d,\u201dw+\u201d);<\/p>\n<p>fprintf(file,\u201dsampling rate (Hz) = %20.15fn\u201d,s);<\/p>\n<p>fprintf(file,\u2019%fn\u2019,x);<\/p>\n<p>plot(x);<\/p>\n<p>xlabel(\u2019time\u2019);<\/p>\n<p>ylabel(\u201damplitude\u201d);<\/p>\n<p>print -deps sam1-023-01.pdf<\/p>\n<p>\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2013 file \u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014\u2014<\/p>\n<p>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\u00a0<strong>chmod<\/strong>\u00a0to be executed by using the command as follows:<\/p>\n<p>abuadnan@abuadnan-laptop:~$\u00a0<strong>chmod +x baca_wave.m<\/strong><\/p>\n<p>Here the file name to read a file *. mat5 is baca_wave. m.<\/p>\n<p>After that to read *. mat5 can be done command as follows:<\/p>\n<p>abuadnan@abuadnan-laptop:~$\u00a0<strong>.\/baca_wave.m<\/strong><\/p>\n<p>The result corresponds to a command written in the script that creates ASCII file with the name &#8220;sam1-023-01. txt&#8221; and a pdf file with the name &#8220;sam1-023-01. pdf&#8221;.<\/p>\n<p>Examples of the results of the script octave can be seen as following picture,<\/p>\n<p><a href=\"http:\/\/azfreeos.files.wordpress.com\/2012\/04\/sam1-023-01.jpg\"><img loading=\"lazy\" decoding=\"async\" class=\"aligncenter\" alt=\"\" src=\"http:\/\/azfreeos.files.wordpress.com\/2012\/04\/sam1-023-01.jpg?w=300\" width=\"320\" height=\"239\" border=\"0\" \/><\/a><\/p>\n<p style=\"text-align: center\">Figure 5. Example file output from the script octave (sound waves)<\/p>\n<p>Sample files for processing sound files can be downloaded from\u00a0<a href=\"https:\/\/dosen.unila.ac.id\/wp-content\/uploads\/sites\/21\/2013\/09\/sam1-023-01.zip\" target=\"_blank\">here<\/a>\u00a0(1.1 MB).<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Manipulate sound files (sound wave files or *.wav files) often we need if we want to process the file is either for the purposes of reducing the file size as &hellip; <a class=\"readmore\" href=\"https:\/\/dosen.unila.ac.id\/ahmadzakaria\/2012\/04\/26\/editing-sound-wave-file-using-octave\/\">Continue Reading &rarr;<\/a><\/p>\n","protected":false},"author":21,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[23],"tags":[],"class_list":["post-38","post","type-post","status-publish","format-standard","hentry","category-octave"],"_links":{"self":[{"href":"https:\/\/dosen.unila.ac.id\/ahmadzakaria\/wp-json\/wp\/v2\/posts\/38"}],"collection":[{"href":"https:\/\/dosen.unila.ac.id\/ahmadzakaria\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/dosen.unila.ac.id\/ahmadzakaria\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/dosen.unila.ac.id\/ahmadzakaria\/wp-json\/wp\/v2\/users\/21"}],"replies":[{"embeddable":true,"href":"https:\/\/dosen.unila.ac.id\/ahmadzakaria\/wp-json\/wp\/v2\/comments?post=38"}],"version-history":[{"count":0,"href":"https:\/\/dosen.unila.ac.id\/ahmadzakaria\/wp-json\/wp\/v2\/posts\/38\/revisions"}],"wp:attachment":[{"href":"https:\/\/dosen.unila.ac.id\/ahmadzakaria\/wp-json\/wp\/v2\/media?parent=38"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/dosen.unila.ac.id\/ahmadzakaria\/wp-json\/wp\/v2\/categories?post=38"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/dosen.unila.ac.id\/ahmadzakaria\/wp-json\/wp\/v2\/tags?post=38"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}