<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Digital Sound</title>
	<atom:link href="http://beej.us/blog/2010/01/digital-sound/feed/" rel="self" type="application/rss+xml" />
	<link>http://beej.us/blog/2010/01/digital-sound/</link>
	<description>Tech and Programming Fun</description>
	<lastBuildDate>Tue, 07 Feb 2012 18:52:43 +0000</lastBuildDate>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
	<item>
		<title>By: ChineseGeek</title>
		<link>http://beej.us/blog/2010/01/digital-sound/comment-page-1/#comment-557</link>
		<dc:creator>ChineseGeek</dc:creator>
		<pubDate>Tue, 09 Mar 2010 00:50:36 +0000</pubDate>
		<guid isPermaLink="false">http://beej.us/blog/?p=363#comment-557</guid>
		<description>Hi, thank you for your quick answer!!! I was reading around, and i found this libsndfile library to manipulate .wav files in C. I&#039;m working on it, i&#039;ll let u know how it ends!!! By the way, excellent post about parallel programming... I don&#039;t know how i didn&#039;t find your blog earlier! Instantly added in my google reader!</description>
		<content:encoded><![CDATA[<p>Hi, thank you for your quick answer!!! I was reading around, and i found this libsndfile library to manipulate .wav files in C. I&#8217;m working on it, i&#8217;ll let u know how it ends!!! By the way, excellent post about parallel programming&#8230; I don&#8217;t know how i didn&#8217;t find your blog earlier! Instantly added in my google reader!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: beej</title>
		<link>http://beej.us/blog/2010/01/digital-sound/comment-page-1/#comment-537</link>
		<dc:creator>beej</dc:creator>
		<pubDate>Sun, 07 Mar 2010 02:58:00 +0000</pubDate>
		<guid isPermaLink="false">http://beej.us/blog/?p=363#comment-537</guid>
		<description>&lt;a href=&quot;#comment-536&quot; rel=&quot;nofollow&quot;&gt;@ChineseGeek&lt;/a&gt; The answer really depends on the language and libraries you have that you can use. In Flash and ActionScript, you just make a method call and it gives you back an array with all the samples in it.  In other languages, there are libraries to accomplish the same thing, whether you&#039;re reading in a WAV or a MP3.  If you&#039;re ambitious, you can take the C code up there that writes a WAV file and convert it to a reader... but I&#039;d recommend finding a library to do the same thing.

But the exact numbers in the array could be different depending on the library and how it represents the data.  What&#039;s important is the numbers represent a range from the minimum sample value to the maximum. Sometimes WAVs represent that as a number from 0 to 255; other times it&#039;s a number from -32768 to 32767. In ActionScript, they represent the numbers as -1.0 to 1.0.

You can remap from one range to another with simple math as needed.</description>
		<content:encoded><![CDATA[<p><a href="#comment-536" rel="nofollow">@ChineseGeek</a> The answer really depends on the language and libraries you have that you can use. In Flash and ActionScript, you just make a method call and it gives you back an array with all the samples in it.  In other languages, there are libraries to accomplish the same thing, whether you&#8217;re reading in a WAV or a MP3.  If you&#8217;re ambitious, you can take the C code up there that writes a WAV file and convert it to a reader&#8230; but I&#8217;d recommend finding a library to do the same thing.</p>
<p>But the exact numbers in the array could be different depending on the library and how it represents the data.  What&#8217;s important is the numbers represent a range from the minimum sample value to the maximum. Sometimes WAVs represent that as a number from 0 to 255; other times it&#8217;s a number from -32768 to 32767. In ActionScript, they represent the numbers as -1.0 to 1.0.</p>
<p>You can remap from one range to another with simple math as needed.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: ChineseGeek</title>
		<link>http://beej.us/blog/2010/01/digital-sound/comment-page-1/#comment-536</link>
		<dc:creator>ChineseGeek</dc:creator>
		<pubDate>Sun, 07 Mar 2010 00:34:36 +0000</pubDate>
		<guid isPermaLink="false">http://beej.us/blog/?p=363#comment-536</guid>
		<description>Hi, do you know how can I get the samples from an audio file? Following your example (the blue wave), i need to storage in an array the values [-.38, -0.80, -0.48, 0.28, ...]. I would really appreciate if you can help me! By the way, great blog!!!</description>
		<content:encoded><![CDATA[<p>Hi, do you know how can I get the samples from an audio file? Following your example (the blue wave), i need to storage in an array the values [-.38, -0.80, -0.48, 0.28, ...]. I would really appreciate if you can help me! By the way, great blog!!!</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: matt</title>
		<link>http://beej.us/blog/2010/01/digital-sound/comment-page-1/#comment-343</link>
		<dc:creator>matt</dc:creator>
		<pubDate>Tue, 16 Feb 2010 22:56:03 +0000</pubDate>
		<guid isPermaLink="false">http://beej.us/blog/?p=363#comment-343</guid>
		<description>ya totally beej, you did a good job explaining quantization and sampling in the PCM format. there are other extremely interesting ways sound is converted digitally as well. others have mentioned the benefits of higher resolutions including aliasing and stereo imaging and stuff, but there is also a 1bit 1.4Mhz samplerate (about i think) direct stream digital format. i think most all audio interfaces use this format to create a binary format before being written in PCM to your hard drive or output. the way i like to think of phase is like two people holding a jump rope at each end.. then one person makes a motion on it, and it will travel around the center as it spins in phase. and the way i like to think of sample rate is how many sine waves are used to approximate a 3d shape in 1 square second. quantization then is equal to how well a polyhedral structure you can create to approximate the 3d shape of sound. all wav files are essentially just 44 thousand or more sine waves approximating sharp edges with circles. i look forward to your aforementioned rocket science.</description>
		<content:encoded><![CDATA[<p>ya totally beej, you did a good job explaining quantization and sampling in the PCM format. there are other extremely interesting ways sound is converted digitally as well. others have mentioned the benefits of higher resolutions including aliasing and stereo imaging and stuff, but there is also a 1bit 1.4Mhz samplerate (about i think) direct stream digital format. i think most all audio interfaces use this format to create a binary format before being written in PCM to your hard drive or output. the way i like to think of phase is like two people holding a jump rope at each end.. then one person makes a motion on it, and it will travel around the center as it spins in phase. and the way i like to think of sample rate is how many sine waves are used to approximate a 3d shape in 1 square second. quantization then is equal to how well a polyhedral structure you can create to approximate the 3d shape of sound. all wav files are essentially just 44 thousand or more sine waves approximating sharp edges with circles. i look forward to your aforementioned rocket science.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: beej</title>
		<link>http://beej.us/blog/2010/01/digital-sound/comment-page-1/#comment-309</link>
		<dc:creator>beej</dc:creator>
		<pubDate>Sat, 13 Feb 2010 19:05:16 +0000</pubDate>
		<guid isPermaLink="false">http://beej.us/blog/?p=363#comment-309</guid>
		<description>&lt;a href=&quot;#comment-300&quot; rel=&quot;nofollow&quot;&gt;@Dan Brickley&lt;/a&gt; Ok, ok... I put up a chunk of code that shows how the dialtone generator does its thing, basically. I was just being lazy. :-)</description>
		<content:encoded><![CDATA[<p><a href="#comment-300" rel="nofollow">@Dan Brickley</a> Ok, ok&#8230; I put up a chunk of code that shows how the dialtone generator does its thing, basically. I was just being lazy. :-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan Brickley</title>
		<link>http://beej.us/blog/2010/01/digital-sound/comment-page-1/#comment-300</link>
		<dc:creator>Dan Brickley</dc:creator>
		<pubDate>Sat, 13 Feb 2010 09:32:06 +0000</pubDate>
		<guid isPermaLink="false">http://beej.us/blog/?p=363#comment-300</guid>
		<description>@beej thanks. I took a look at the C already (compiled/ran it locally) but couldn&#039;t yet figure out enough of the underlying maths to understand how I might blend two sounds together. Hence the interest in the Flash. But I&#039;ll probably get it if I stare at the code long enough :)</description>
		<content:encoded><![CDATA[<p>@beej thanks. I took a look at the C already (compiled/ran it locally) but couldn&#8217;t yet figure out enough of the underlying maths to understand how I might blend two sounds together. Hence the interest in the Flash. But I&#8217;ll probably get it if I stare at the code long enough :)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: beej</title>
		<link>http://beej.us/blog/2010/01/digital-sound/comment-page-1/#comment-290</link>
		<dc:creator>beej</dc:creator>
		<pubDate>Sat, 13 Feb 2010 01:14:45 +0000</pubDate>
		<guid isPermaLink="false">http://beej.us/blog/?p=363#comment-290</guid>
		<description>&lt;a href=&quot;#comment-274&quot; rel=&quot;nofollow&quot;&gt;@Dan Brickley&lt;/a&gt; The Flash source is kinda ugly, so I&#039;m not putting it up. :) The sound generation part of it is very similar to the example in the Adobe Flex docs for &lt;a href=&quot;http://livedocs.adobe.com/flex/3/langref/flash/events/SampleDataEvent.html#includeExamplesSummary&quot; target=&quot;_blank&quot; rel=&quot;nofollow&quot;&gt;SampleDataEvent&lt;/a&gt;, though. (In that example, they write the sample twice, one for the left channel, and one for the right.)

And up there in the blog post, I have a C source that generates a WAV file with a sine wave sound in it.</description>
		<content:encoded><![CDATA[<p><a href="#comment-274" rel="nofollow">@Dan Brickley</a> The Flash source is kinda ugly, so I&#8217;m not putting it up. :) The sound generation part of it is very similar to the example in the Adobe Flex docs for <a href="http://livedocs.adobe.com/flex/3/langref/flash/events/SampleDataEvent.html#includeExamplesSummary" target="_blank" rel="nofollow">SampleDataEvent</a>, though. (In that example, they write the sample twice, one for the left channel, and one for the right.)</p>
<p>And up there in the blog post, I have a C source that generates a WAV file with a sine wave sound in it.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: beej</title>
		<link>http://beej.us/blog/2010/01/digital-sound/comment-page-1/#comment-289</link>
		<dc:creator>beej</dc:creator>
		<pubDate>Sat, 13 Feb 2010 00:59:15 +0000</pubDate>
		<guid isPermaLink="false">http://beej.us/blog/?p=363#comment-289</guid>
		<description>&lt;a href=&quot;#comment-288&quot; rel=&quot;nofollow&quot;&gt;@Conor&lt;/a&gt; Imagine a worst case, where we&#039;re sampling it at 2.001 times per cycle and we&#039;ve sampled a zero--our samples will gradually drift off zero... Yeah, it looks nasty.  And, like Wikipedia says, a signal below the Nyquist Frequency can &quot;fold&quot; above it, too.  What fun!

But I don&#039;t actually know the answer to your question, as it&#039;s way past my knowledge of or expertise in the matter.

In the movie &quot;The Great Train Robbery&quot;, when the thief Agar was asked how he&#039;d obtained copies of the four well-guarded keys which opened the train safe, he answered, &quot;With incredible skill.&quot; I&#039;m sure that&#039;s what sound guys use to reconstruct signals near the Nyquist Frequency. :-)</description>
		<content:encoded><![CDATA[<p><a href="#comment-288" rel="nofollow">@Conor</a> Imagine a worst case, where we&#8217;re sampling it at 2.001 times per cycle and we&#8217;ve sampled a zero&#8211;our samples will gradually drift off zero&#8230; Yeah, it looks nasty.  And, like Wikipedia says, a signal below the Nyquist Frequency can &#8220;fold&#8221; above it, too.  What fun!</p>
<p>But I don&#8217;t actually know the answer to your question, as it&#8217;s way past my knowledge of or expertise in the matter.</p>
<p>In the movie &#8220;The Great Train Robbery&#8221;, when the thief Agar was asked how he&#8217;d obtained copies of the four well-guarded keys which opened the train safe, he answered, &#8220;With incredible skill.&#8221; I&#8217;m sure that&#8217;s what sound guys use to reconstruct signals near the Nyquist Frequency. :-)</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Conor</title>
		<link>http://beej.us/blog/2010/01/digital-sound/comment-page-1/#comment-288</link>
		<dc:creator>Conor</dc:creator>
		<pubDate>Fri, 12 Feb 2010 23:56:38 +0000</pubDate>
		<guid isPermaLink="false">http://beej.us/blog/?p=363#comment-288</guid>
		<description>If -as Nyquist says - we sample a 20 kHz sine wave 2.205 times per second (at 44.1 kHz sample rate), and per chance one of those samples happens to be at zero amplitude, the resultant waveform would look nothing like a sine wave, and would be most &#039;un-musical.&#039;  How / why does 44.1 digital audio sound reasonably good &#039;on the high end&#039; when the high frequencies are sampled so infrequently?</description>
		<content:encoded><![CDATA[<p>If -as Nyquist says &#8211; we sample a 20 kHz sine wave 2.205 times per second (at 44.1 kHz sample rate), and per chance one of those samples happens to be at zero amplitude, the resultant waveform would look nothing like a sine wave, and would be most &#8216;un-musical.&#8217;  How / why does 44.1 digital audio sound reasonably good &#8216;on the high end&#8217; when the high frequencies are sampled so infrequently?</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dan Brickley</title>
		<link>http://beej.us/blog/2010/01/digital-sound/comment-page-1/#comment-274</link>
		<dc:creator>Dan Brickley</dc:creator>
		<pubDate>Fri, 12 Feb 2010 10:58:38 +0000</pubDate>
		<guid isPermaLink="false">http://beej.us/blog/?p=363#comment-274</guid>
		<description>This is great, thanks for taking the time to write this up. If I re-read it all a few times, it might even sink in.

Is the Flash app src available? or something similar in C?

What got me googling this stuff? Possibly mad idea - so sanity check welcomed. I want to find a way to encode short strings (URIs like xmpp:user@gmail.com/) in audio, such that it could be used as a more music alternative to qrcodes or bluetooth for device discovery. Would need a way of encoding something like 50 A-Z + punctuation chars in a reasonably melodic audio loop. Then a media centre could broadcast it&#039;s xmpp: address to all devices in &#039;earshot&#039;, and iphones etc could find them without being on the same LAN. A friend told me the audio part is &#039;trivial&#039;, which I didn&#039;t entirely believe, but that&#039;s what landed me on this page :)</description>
		<content:encoded><![CDATA[<p>This is great, thanks for taking the time to write this up. If I re-read it all a few times, it might even sink in.</p>
<p>Is the Flash app src available? or something similar in C?</p>
<p>What got me googling this stuff? Possibly mad idea &#8211; so sanity check welcomed. I want to find a way to encode short strings (URIs like xmpp:user@gmail.com/) in audio, such that it could be used as a more music alternative to qrcodes or bluetooth for device discovery. Would need a way of encoding something like 50 A-Z + punctuation chars in a reasonably melodic audio loop. Then a media centre could broadcast it&#8217;s xmpp: address to all devices in &#8216;earshot&#8217;, and iphones etc could find them without being on the same LAN. A friend told me the audio part is &#8216;trivial&#8217;, which I didn&#8217;t entirely believe, but that&#8217;s what landed me on this page :)</p>
]]></content:encoded>
	</item>
</channel>
</rss>

