<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	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/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Jean&#039;s Page &#187; audio</title>
	<atom:link href="http://jeanbruenn.info/category/audio/feed/" rel="self" type="application/rss+xml" />
	<link>http://jeanbruenn.info</link>
	<description>so what?</description>
	<lastBuildDate>Fri, 13 Apr 2012 20:50:04 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
		<item>
		<title>Stereo to (fake-)Surround</title>
		<link>http://jeanbruenn.info/2011/10/22/stereo-to-fake-surround/</link>
		<comments>http://jeanbruenn.info/2011/10/22/stereo-to-fake-surround/#comments</comments>
		<pubDate>Sat, 22 Oct 2011 18:48:56 +0000</pubDate>
		<dc:creator>Jean</dc:creator>
				<category><![CDATA[audio]]></category>

		<guid isPermaLink="false">http://jeanbruenn.info/?p=1077</guid>
		<description><![CDATA[Before I re-created my blog, I&#8217;ve written two articles about a pseudo-possibility for a stereo to surround conversation. I merged both and rewrote the article and hopefully this will help some people. Please note that I&#8217;m not an audio-engineer and that I might miss the needed background, this article is based on information I found [...]]]></description>
			<content:encoded><![CDATA[<p>Before I re-created my blog, I&#8217;ve written two articles about a pseudo-possibility for a stereo to surround conversation. I merged both and rewrote the article and hopefully this will help some people. Please note that I&#8217;m not an audio-engineer and that I might miss the needed background, this article is based on information I found in the world wide web, my personal taste and things I&#8217;ve noticed by research/trying. All sources I&#8217;ve used are linked at the bottom of this article.<br />
<span id="more-1077"></span><br />
<b>note</b>: this article is work in progress. I might change a few things. I re-added Jay&#8217;s comment because it contains useful information. Hope he&#8217;s fine with that <img src='http://jeanbruenn.info/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<p>In a perfect world five dot one (5.1) would mean, that we&#8217;ll have sounds from behind (rear/surround speakers), sounds from the left and right (front left, front right speaker) vocals from the front (center speaker) and bass from the LFE channel (subwoofer). Notice that the “positional” estimation is important. So if we watch a movie, and someone is obviously speaking behind someone, we should hear that sound from the back (from the rear speakers). “Vocals” as in Speech should come from all directions, so if someone is talking on the left → the left speaker should output that. At least, that&#8217;s how I would (mis)-understand “Surround”.</p>
<p>As we aren&#8217;t in a perfect world, this is somewhat different. I checked the 6-channel sound files of a few dvds and the one of the openmovie sintel. The front left and right channels aren&#8217;t containing ANY vocals or they&#8217;re sounding like in a big hall, very quiet not easy to hear. First I thought it is related to the &#8220;haas&#8221;-effect, which says, what you hear first, tells you where the sound comes from. So if you hear something from front-left first (doesn&#8217;t matter whether vocal or not – might be some high tone) you&#8217;re thinking the vocals are coming from the left. I cannot tell if that is true. I found a small post in doom9 forums which might explain that behavior. http://forum.doom9.org/showthread.php?p=717044#post717044 ← that&#8217;s, why you&#8217;ll sometimes think there aren&#8217;t any vocals on the left and right channel. That&#8217;s because they&#8217;re just containing the difference as the center-channel contains the sum. </p>
<p>While trying around doing such upconversations it turned out (a few people on the net reported similar results) that it seems to be easier/better to do that conversation in steps, e.g.: stereo → quadrophonic → surround instead of stereo → surround. But: That might be personal taste.</p>
<p>Anyway. We have a stereo file, 48kHz, 16Bit. Due to it beeing stereo, we know it has 2 channels: left and right. We can create one additional channel out of them without much trouble. The center-channel. That channel is a mix of the left and the right channel with 50% volume of each:</p>
<pre>    sox -S -V -c 2 source.wav -c 1 combined.wav mixer 0.5,0.5
    normalize combined.wav</pre>
<p>That channel can be used now to create the new left and right channels. We&#8217;re inverting the specific channel, so that they&#8217;ll only contain the differences:</p>
<pre>    sox -S -V -c 2 stereo.wav -c 1 sleft.wav mixer -l
    sox -S -V -c 2 stereo.wav -c 1 sright.wav mixer -r
    sox -S -V -M -c 1 -v -1 sright.wav -c 1 center.wav -c 1 right.wav
    normalize right.wav
    sox -S -V -M -c 1 -v -1 sleft.wav -c 1 center.wav -c 1 left.wav
    normalize left.wav</pre>
<p>The “-v -1” causes an invert. The -M is used to merge both files (the inverted left / right and the center channel) that way, only the differences are left. Now we can over to our “surround” part. Let&#8217;s first talk about frequencies:</p>
<p>Most of the information I found about frequencies aren&#8217;t identical. While one says deep bass is between 20 and 60 Hz another says it&#8217;s between 20 and 40 Hz. Deep high tones between 3 and 12 kHz, another says between 2 and 3.5 kHz. Here, a simplified variant (which might not be correct)</p>
<ul>
<li><em>20 Hz &#8211; 20 kHz</em> human hear-able range (the older, the lower the max., likely you&#8217;ll hear up to a max. of 16 to 18 kHz)</li>
<li><em>80 Hz &#8211; 12 kHz</em> voice / speech (there are also pages telling it&#8217;s up to 8 kHz)</li>
<li><em>300 Hz &#8211; 3,4 kHz</em> voice / speech on analog phones</li>
<li><em>20 Hz &#8211; 200 Hz</em> bass</li>
<li><em>200 Hz &#8211; 2 kHz</em> middles</li>
<li><em>2 kHz &#8211; 12 kHz</em> high tones</li>
<li><em>12 kHz &#8211; 20 kHz</em> upper high tones</li>
</ul>
<p>20 Hz – 80 or 100 Hz bass which you can&#8217;t locate (so for this frequencies it shouldn&#8217;t matter, where the subwoofer is located)</p>
<p>You&#8217;ll see, that&#8217;s not as easy as one might think. However, let&#8217;s take a look at some speakers. Averaged and rounded results of a few speakers I took a look at:</p>
<ul>
<li><em>high tone speakers (7):</em> 2000 (2342) Hz – 20 kHz (21285)</li>
<li><em>middle tone speakers (5):</em> 400 (375) Hz – 13 kHz (12800)</li>
<li><em>deep/low tone speakers (30):</em> 40 (39) Hz – 6 kHz (5961)</li>
<li><em>subwoofer (9):</em> 40 (35) Hz – 200 Hz (232) ← the expensive ones I checked, range to 120 Hz and 150 Hz</li>
</ul>
<p>All these frequencies might help us with our surround audio file. For example: The real low frequencies are there for the subwoofer, we don&#8217;t need them on every speaker. To reduce the “load” of our other speakers, we&#8217;ll limit the frequencies. Then: The center-speaker should be optimized for our vocals. Thus it shouldn&#8217;t contain too high frequencies to not cause distortion there. We&#8217;ll need a frequency filter again. Our rear-speakers won&#8217;t benefit from high frequencies. So&#8230; With all the above kept in mind, my suggestion is:</p>
<ul>
<li><em>front left, right:</em> 80 Hz &#8211; 20 kHz</li>
<li><em>center:</em> 80 Hz &#8211; 12 kHz</li>
<li><em>surround left, right:</em> 100 Hz &#8211; 6 kHz</li>
<li><em>lfe:</em> 20 Hz &#8211; 200 Hz</li>
</ul>
<p>The next step would be to create the other channels and to add the frequency-limitations.</p>
<pre>    sox -S -V -c 1 left.wav -c 1 left-sr.wav sinc 100-6000 reverb
    sox -S -V -c 1 right.wav -c 1 right-sr.wav sinc 100-6000 reverb
    sox -S -V -c 1 combined.wav -c 1 center.wav sinc 80-12000
    sox -S -V -c 1 combined.wav -c 1 lfe.wav sinc 20-200
    sox -S -V -c 1 left.wav -c 1 left-fr.wav sinc 80-20000
    sox -S -V -c 1 right.wav -c 1 right-fr.wav sinc 80-20000</pre>
<p>Now we have all channels. Now we&#8217;ll just add a delay of 15ms to the rear speakers and we&#8217;ll put the whole stuff together. That&#8217;s all <img src='http://jeanbruenn.info/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
<pre>    multimux -d 0,0,15,15,0,0 \
     left-fr.wav right-fr.wav \
     left-sr.wav right-sr.wav \
     center.wav lfe.wav > final.wav</pre>
<p>As the Comment of Jay (thanks) states &#8211; The LFE Channel is not simply a subwoofer channel &#8211; Its for effects. So you might want to just remove the vocals instead of doing lowpass filtering and limiting the frequencies</p>
<p>Remember, our source has only 2 channels (left and right) &#8211; For 4 channel input or 6 channels input this whole document is not very helpful. I&#8217;m trying to make &#8220;surround&#8221; out of &#8220;stereo&#8221; &#8211; So i have to &#8220;guess&#8221; to &#8220;try&#8221; and to &#8220;hope&#8221; <img src='http://jeanbruenn.info/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> </p>
<p><strong>the whole script to do the conversation</strong></p>
<pre>#!/bin/bash

###
# stereo 2 surround
###

inFile="$1";
outFile="$2";
debug="$3";

# todo ...
#if [ ! -z sox ]; then
#echo "sox"
#  run=0;
#fi

#if [ ! -x multimux ]; then
#echo "multimux"
#  run=0;
#fi

#if [ ! -x soxi ]; then
#echo "soxi"
#  run=0;
#fi

#if [ ! -x normalize ]; then
#echo "normalize"
#  run=0;
#fi

# default parameter
soxParm="";
normParm="-q";

# debug parameter
if [ $debug -eq 1 ]; then
  soxParm="-V -S";
  normParm="-v";
fi

if [ $run -eq 0 ]; then
  echo "Error: Requirenment missing: normalize multimux, sox or soxi";
else
  echo " Preparing Source";
  normalize $normParm $inFile;
  rate=$(soxi $inFile | grep "Sample Rate" | awk '{ print $4; }');
  # if rate is 44100, we'll most likely have stuff from an audio-cd,
  # which we want to deemph at least i assume so
  if [ $rate -eq 44100 ]; then
    echo " + Source is 44.1kHz, De-Emphasing &#038; Resampling...";
    sox $soxParm -c 2 $inFile source.wav deemph rate -v -a 48000
  else
    sox $soxParm -c 2 $inFile source.wav rate -v -a 48000
  fi
  # create combined channel
  sox $soxParm -c 2 source.wav -c 1 combined.wav mixer 0.5,0.5
  normalize $normParm combined.wav
  # create pre- left and right channels
  sox $soxParm -c 2 source.wav -c 1 sleft.wav mixer -l
  sox $soxParm -c 2 source.wav -c 1 sright.wav mixer -r
  sox $soxParm -M -c 1 -v -1 sright.wav -c 1 combined.wav -c 1 right.wav
  normalize $normParm right.wav
  sox $soxParm -M -c 1 -v -1 sleft.wav -c 1 combined.wav -c 1 left.wav
  normalize $normParm left.wav
  # frequency games
  sox $soxParm -c 1 left.wav -c 1 ls.wav sinc 100-6000 reverb
  sox $soxParm -c 1 right.wav -c 1 rs.wav sinc 100-6000 reverb
  sox $soxParm -c 1 combined.wav -c 1 c.wav sinc 80-12000
  sox $soxParm -c 1 combined.wav -c 1 lfe.wav sinc 20-200
  sox $soxParm -c 1 left.wav -c 1 lf.wav sinc 80-20000
  sox $soxParm -c 1 right.wav -c 1 rf.wav sinc 80-20000
  # normalize it in batch-mode
  normalize $normParm -b ls.wav rs.wav c.wav lfe.wav lf.wav rf.wav
  # let's mux it
  multimux -d 0,0,15,15,0,0 lf.wav rf.wav ls.wav rs.wav c.wav lfe.wav > $outFile
  # cleanup
  rm left.wav right.wav combined.wav source.wav sleft.wav sright.wav
fi</pre>
<p><strong>Hopefully useful links</strong><br />
You&#8217;re visiting those pages on your own risk. I took a look over them, but i can&#8217;t assure that those pages are &#8220;good&#8221;, &#8220;correct&#8221; or anything else.</p>
<ul style="list-style-type: none;">
<li style="list-style-type: none;"><img src="http://jeanbruenn.info/images/lang/lang_en.png" /> <a href="http://www.5dot1.com/articles/stereo_to_surround_sound.html">stereo to surround sound</a></li>
<li style="list-style-type: none;"><img src="http://jeanbruenn.info/images/lang/lang_en.png" /> <a href="http://forum.doom9.org/showthread.php?t=83752">Doom9: GUIDE LIST: Stereo-to-Surround Conversion Guides</a></li>
<li style="list-style-type: none;"><img src="http://jeanbruenn.info/images/lang/lang_en.png" /> <a href="http://en.wikipedia.org/wiki/Stereophonic_sound">Wikipedia: Stereophonic Sound</a></li>
<li style="list-style-type: none;"><img src="http://jeanbruenn.info/images/lang/lang_en.png" /> <a href="http://musichack.wordpress.com/gw-tutorials/center-channel-extractionisolation/">Musichack Tutorials: center channel extraction/isolation</a></li>
<li style="list-style-type: none;"><img src="http://jeanbruenn.info/images/lang/lang_en.png" /> <a href="http://www.sintel.org/">OpenMovie: Sintel</a> (I used their sound for testing)</li>
<li style="list-style-type: none;"><img src="http://jeanbruenn.info/images/lang/lang_de.png" /> <a href="http://de.wikipedia.org/wiki/Quadrophonie">Wikipedia: Quadrophonie</a></li>
<li style="list-style-type: none;"><img src="http://jeanbruenn.info/images/lang/lang_de.png" /> <a href="http://de.wikipedia.org/wiki/Mehrkanal-Tonsystem">Wikipedia: Mehrkanal-Tonsystem</a></li>
<li style="list-style-type: none;"><img src="http://jeanbruenn.info/images/lang/lang_en.png" /> <a href="http://www.howtogeek.com/61250/how-to-isolate-and-save-vocals-from-music-tracks-using-audacity/">How to isolate and save vocals from music tracks using audacity</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://jeanbruenn.info/2011/10/22/stereo-to-fake-surround/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Linux Audio Network&#8217;ed #1 (nas)</title>
		<link>http://jeanbruenn.info/2011/04/27/linux-audio-networked-1-nas/</link>
		<comments>http://jeanbruenn.info/2011/04/27/linux-audio-networked-1-nas/#comments</comments>
		<pubDate>Wed, 27 Apr 2011 09:29:42 +0000</pubDate>
		<dc:creator>Jean</dc:creator>
				<category><![CDATA[audio]]></category>

		<guid isPermaLink="false">http://jeanbruenn.info/new/?p=531</guid>
		<description><![CDATA[I&#8217;m building a home-server (fileserver, development box, audio server) and currently i&#8217;m at the audio stuff. After google&#8217;ing a bit i found two variants to do what i want: PulseAudio and NAS. NAS seemed to be the simpliest approach and it works quite well. I&#8217;m just a bit unhappy that i didn&#8217;t found out how [...]]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m building a home-server (fileserver, development box, audio server) and currently i&#8217;m at the audio stuff. After google&#8217;ing a bit i found two variants to do what i want: PulseAudio and NAS. NAS seemed to be the simpliest approach and it works quite well. I&#8217;m just a bit unhappy that i didn&#8217;t found out how (or whether its possible at all) to use 5.1 Sound with it. Also it seems to be that it can&#8217;t play 48kHz music properly (getting all sorts of buffer underuns, 44.1kHz and below is fine).<br />
<span id="more-531"></span><br />
The following Guides are for Lunar Linux, no idea how it works on different distributions, however should be except for installing the same.</p>
<pre>lin -cr nas</pre>
<p>will install nas on the server. do the same on your other box(es) you just don&#8217;t need to start nasd on them on boot. Then take a look on the server at /etc/config.d/nas and replace -local with -aa (so that any client is allowed to connect, i guess you&#8217;ll secure it later using iptables or something else) &#8211; Then go into the configuration file and remove input and output sections completly (keeping them resulted in crashing nasd here). Right after doing so restart nasd using</p>
<pre>/etc/init.d/nas restart</pre>
<p>Now you can try on your other box whether it&#8217;s working. Basically you&#8217;re running the au* commands with -audio protocol/ip:port for example, if the network audio server is on 192.168.2.25 and running with the default port 8000 you&#8217;d use: -audio tcp/192.168.2.25:8000</p>
<pre>
wdp@lyra ~ $ auinfo -audio tcp/192.168.2.25:8000                                    ù                                                                                                                      Audio Server:
Audio Server:           tcp/192.168.2.25:8000                                       ù                                                                                                                                        Version Number:
Version Number:         2.2                                                         ù                                                                                               Vendor:
Vendor:                 Network Audio System Release 1.9.2 - VoxWare                ù                                                                                                                                          Vendor Release:
Vendor Release:         1                                                           ù                                                                                                                                       Min Sample Rate:
Min Sample Rate:        5000                                                        )#  ð6c·¸>{#¸>{#¸>{#                                                                                                                                   Max Sample Rate:
Max Sample Rate:        44100
Max Tracks:             32
Number of Formats:      7
Formats:                ULAW8  LinearUnsigned8  LinearSigned8
                        LinearSigned16MSB  LinearUnsigned16MSB
                        LinearSigned16LSB  LinearUnsigned16LSB
Number of Elem Types:   12
Element Types:          ImportClient  ImportDevice  ImportBucket
                        ImportWaveForm  Bundle  MultiplyConstant  AddConstant
                        Sum  ExportClient  ExportDevice  ExportBucket
                        ExportMonitor
Number of Wave Forms:   2
Wave Forms:             Square  Sine
Number of Actions:      3
Actions:                ChangeState  SendNotify  Noop
Number of Devices:      3
    Device 0:
        Changable:      Gain  LineMode
        ID:             0x23
        Kind:           PhysicalInput
        Use:            Import
        Format:         LinearSigned16LSB
        Num Tracks:     2
        Access:         Import  List
        Description:    "Stereo Channel Input"
        Min Rate:       5000
        Max Rate:       44100
        Location:       Left  Right  External
        Gain Percent:   50
        Num Children:   0
    Device 1:
        Changable:      Gain
        ID:             0x22
        Kind:           PhysicalOutput
        Use:            Export
        Format:         LinearSigned16LSB
        Num Tracks:     2
        Access:         Export  List
        Description:    "Stereo Channel Output"
        Min Rate:       5000
        Max Rate:       44100
        Location:       Center  Internal
        Gain Percent:   0
        Num Children:   1
        Children:       0x21
    Device 2:
        Changable:      Gain
        ID:             0x21
        Kind:           PhysicalOutput
        Use:            Export
        Format:         LinearSigned16LSB
        Num Tracks:     1
        Access:         Export  List
        Description:    "Mono Channel Output"
        Min Rate:       5000

        Max Rate:       44100
        Location:       Center  Internal
        Gain Percent:   0
        Num Children:   0
Number of Buckets:      0
</pre>
<p>Looks good eh? Now play some wav using auplay:</p>
<pre>auplay -audio tcp/192.168.2.25:8000 your.wav</pre>
<p>But yeah, that&#8217;s just a wav &#8211; We want to play mp3 flac ogg etc. Happily mplayer got a nas audio output plugin. So you can do the following:</p>
<pre>export AUDIOSERVER="tcp/192.168.2.25:8000"
mplayer -channels 2 -af resample=44100 -ao nas your-weird-music-file.flac</pre>
<p>Should work for ogg, flac, mp3, and videos and everything else. But again: higher than 44100hz wasn&#8217;t working here, got buffer underruns. And i have no idea how to use my 5.1 System on the sound server with nas &#8211; So my next try will be Pulse-Audio in the hope that that&#8217;ll do it.</p>
]]></content:encoded>
			<wfw:commentRss>http://jeanbruenn.info/2011/04/27/linux-audio-networked-1-nas/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

