# Physics 203 at Portland State 2014

### Site Tools

digital_sound_project
A PCRE internal error occured. This might be caused by a faulty plugin

====== Differences ====== This shows you the differences between two versions of the page.

digital_sound_project [2014/05/25 18:46]
wikimanager [Software]
digital_sound_project [2014/06/04 03:53] (current)
Line 1: Line 1:
======Digitizing the sound====== ======Digitizing the sound======
-==By Alisha Harrington, Christopher Hernandez, ​and Aaron Heston==+==By Alisha Harrington, Christopher Hernandez, Aaron Heston, and Samia Maurice==
==in collaboration with Prof. Nicholas Kuzma== ==in collaboration with Prof. Nicholas Kuzma==

Line 257: Line 257:
=====Data===== =====Data=====
+  - {{ :​projects:​wave_2_graph.png?​200|}} I have been following the directions for the digital sound project for a Windows computer. This graph of a wave was generated (see figure on the right); however, I haven'​t recorded anything. In fact, I haven'​t figured out how to record anything at all like the examples on this wiki page. I am hoping someone can tell me how to proceed.
+    * **Answer**: What makes you think you haven'​t recorded anything? I think you did!  I can see some noises and a loud bang in the beginning. It looks like a recording. If you post your saved IGOR experiment (assuming the file is not more than a few MB - it shouldn'​t be with just one recording), we can listen to the sound. ​
+      * Probably you haven'​t made any sound while recording: ​ why not repeat the recording step again, but this time,
+      * as soon as you hit "​Enter"​ on the ''​SoundInRecord wave2''​ command, start singing a note, like "​Eeeeeeeeeeee",​ for about 3 seconds. ​
+        * No need to plot again, - the existing plot of wave2 will update automatically.
+      * Also, try playing back your recording by entering ''​playsound wave2''​ into command window. Do you hear your "​Eeeeeeee"?​
+  - Okay,I did record a sound. I would like to post it so we can hear it and you can give me suggestions for experimenting with it or with additional sounds. However, when I tried to upload the file I received this message " Upload denied. This file extension is forbidden!"​
+    * **Answer**: Good job! Sorry I didn't realize you cannot upload igor files to the wiki.  One workaround is to change the extension from pxp to txt, that might work - I am not sure. You can also email me the pxp file as an attachment.
+      * I think you are on the right track. You should learn how to zoom in and out on the plot in Igor (by dragging a box with the left button of a mouse and then clicking inside the box) - do it repeatedly until you see the individual oscillations (See figure below). ​ You can zoom all the way out by pressing ''​Ctrl-A''​. Look at the fine details of your plots. ​ ''​Wave2''​ sounds like a piano note - do you have an electric piano or a piano app on your phone? ​ I can also hear a dog barking and people talking outside - all this information is contained in the column of numbers that you recorded - I wonder which digits contain which sound. {{ :​projects:​sound:​clipping.png?​nolink |}}
+      * Anyways, if you zoom in on the beginning part of wave2, as shown here on the second plot of the same ''​wave2'',​ you will see that the amplitude is unnaturally constant for a while (before it starts dropping off), and the oscillations look more like square waves rather than sine waves. This tells me that your sound was too loud for the range of your recorder - that is, the actual sound was decaying in amplitude all along from the start, but the recorder was pegged at the maximum of what it can record (that is, "​clipping your sound"​) until the sound decayed enough to "​fit"​ into the range of the recorder. Does it make sense? ​  Try to repeat the same recording, but either make the sound quieter, or move the laptop away from the source so that there is some attenuation (or even do what humans do - cover your microphone (if you know which hole it is on the laptop) with a cloth or a towel.)
+      * Another tool (besides zooming in on the time course of the signal) is to look at the spectrum - this wiki page explains how to do this. For your beautiful piano-like tone, this should give a very nice thin line in the spectrum, if you are not clipping with your recorder. If you are clipping, like in ''​wave2''​ now, the spectrum will have extra stuff - the musicians can tell it's clipping because it sounds more "​metallic"​ or even "​buzzing"​. ​ You can dedicate the entire project to the effect of clipping - compare clipped and not clipped sound (the perceived impression, the time plots, and the spectra).  ​
+  - I have collected some initial data and recordings. In my file:
+    * ''​Wave2''​ is a medium volume sound directly adjacent to the microphone.
+      * Wave 2 obviously translates poorly and exhibits clipping.
+    * ''​Wave3''​ is a soft volume sound directly adjacent to the microphone.
+      * Wave 3 sounds ok despite its close proximity to the microphone.
+    * ''​Wave4''​ is a sound of varying volume at typical lapotop distance (my final data will have a constant pitch, this was just for my own
+    * But I have graphed all three spectra according to your directions, and they look nearly identical. What do I need to do to discern meaningful data from these graphs? ​
+    * **Answer**: To compare the spectra directly, plot them on the same graph by <​code>​display wave2_fft,​wave3_fft,​wave4_fft;​
+ModifyGraph log(left)=1,​rgb(wave3_fft)=(0,​0,​65535),​rgb(wave4_fft)=(0,​0,​0);​
+SetAxis bottom 0,​4000</​code>​
+      * Actually, somehow all your fourier transforms are the same!   ​That'​s why they look the same! They ended up being identical.
+        * Do them again: <​code>​FFT/​MAGS /​DEST=wave2_fft wave2;
+FFT/MAGS /​DEST=wave3_fft wave3;
+FFT/MAGS /​DEST=wave4_fft wave4;</​code> ​
+        *Look at the most recent plot you just plotted. ​ Now you see differences.
+      * Also makes sense to plot the time-traces on the same plot: <​code>​display wave2,​wave3,​wave4;​
+ModifyGraph rgb(wave2)=(65535,​40000,​40000),​rgb(wave3)=(0,​0,​65535),​rgb(wave4)=(0,​0,​0);​
+SetAxis bottom 0,​.04</​code> ​
+        * This highlights the striking differences in intensity.
+  -  The other thing is I have been looking at Fourier series calculations and have seen the use of integrals when looking at the Fourier coefficients. Should I be concerned about this?
+    * **Answer**: there are two kinds of Fourier transforms: [[wp>​Fourier transform|continuous]] (liked by theorists) and [[wp>​Discrete Fourier transform|discrete]] (used in numerical computations). The two kinds are closely related, and in the limit of small grid spacing (small dwell time $\Delta t$) they approximately give the same results. But, the continuous transform uses integrals, whereas the discrete one uses simple sums.  You don't need to worry about this too much, just use it as a tool that already works. When you write about it, just say that it decomposes the time-dependent signal into a linear superposition of pure sine and cosine waves at various frequencies on a frequency grid, and gives you the combined amplitude at each frequency, as a function of the point on the frequency grid.
+  - Is there a way to copy and paste the plots from Igor pro into a document or is there another way to display the plots in a document?
+    * **Answer**: You can use
+      * "​screenshots"​ (will work for any screen content, not just IGOR plots) ​
+        * explained in [[white_noise_project#​software_and_data_analysis|the white noise project, Software and data analysis, Item 10]] <- click on the green link
+      * Or, in IGOR, after clicking on your graph, go to the ''​File''​ menu, ''​Save Graphics...''​ submenu, and select ​
+        * the format (PNG or JPEG_
+        * resolution (Other DPI, then 300)
+        * file name -- the name of the picture file that IGOR will create for you
+        * path (home -- will save in the same directory on your computer where you have saved your .pxp experiment
+        * force overwrite -- if you already have that picture file and want to improve it
+      * Then just insert the picture file into your report as picture
+
+====Tips and suggestions====
+  - You can simulate clipping by using the following commands (assuming you want to clip ''​wave2''​ that already exists):
+    * the function ''​=min(...,​...)''​ returns the smaller of the two arguments
+    * the function ''​=max(...,​...)''​ returns the larger of the two arguments
+    * before you start, you need to set up your ''​low''​ and ''​high''​ variables fist: <​code>​Wavestats/​Q wave2; print V_min,V_max // this line finds the min and max of wave2
+Variable/G clip_perc=80 // this creates a variable for storing the clipping percentage
+Variable/G low=clip_perc*V_min/​100,​high=clip_perc*V_max/​100 // sets low and high thresholds for clipping</​code>​
+      * Here the ''​%%//​%%''​ is the "​comment"​ symbol, it tells IGOR to ignore the remainder of the line, allowing you to comment your code
+    * now create another wave and combine the ''​min()''​ and ''​max()''​ as ''​max(low,​min(high,​...))'':​ <​code>​Duplicate/​O wave2,​wave2_clipped // create an identical wave2_clipped first
+wave2_clipped=max(low,​min(high,​wave2)) // now do the clipping</​code>​ to limit the values in wave2_clipped to be within the [low,high] range
+    * you can achieve different levels of clipping by setting ''​clip_perc''​ closer to 0 (more severe clipping) or closer to 100 (more gentle)
+    * you can display the clipped wave as a plot, calculate and display its spectrum, and play it to listen how it sounds

=====References and Footnotes===== =====References and Footnotes=====