#Audio examples 

##Convertitore USB / audio

<pre class="minicom">
arecord -f cd -Ddefault:CARD=LX3000 | aplay -Ddefault:Set &
arecord -f cd -Ddefault:Set | aplay -Ddefault:CARD=LX3000 &
</pre>

Per avere la lista delle schede audio presenti:

<pre class="minicom">
arecord -L
</pre>

##Save 5 second of stereo audio in CD format

<pre class="minicom">
$ arecord -d 5 -f cd first_part.wav
</pre>

##Play a .wav file

<pre class="minicom">
$ aplay first_part.wav
</pre>

##Echo

<pre class="minicom">
$ arecord -f cd | aplay
</pre>

##Combine multiple audio files to single File

With the -m flag, sox adds two input files together to produce its output. 
The example below adds first_part.wav and second_part.wav leaving the 
result in whole_part.wav.

<pre class="minicom">
$ sox -m first_part.wav second_part.wav whole_part.wav
</pre>

##Extract Part of the Audio File

Trim can trim off unwanted audio from the audio file.

<pre class="minicom">
Syntax : sox old.wav new.wav trim [SECOND TO START] [SECONDS DURATION].
</pre>

* SECOND TO START: Starting point in the voice file.
* SECONDS DURATION: Duration of voice file to remove.

The command below will extract first 10 seconds from input.wav and stored it in output.wav

<pre class="minicom">
$ sox input.wav output.wav trim 0 10
</pre>

##Increase and Decrease Volume Using Option -v

Option -v is used to change (increase or decrease ) the volume.
 
###Increase Volume

<pre class="minicom">
$ sox -v 2.0 foo.wav bar.wav
</pre>

###Decrease Volume

If we need to lower the volume on some files, we can lower them by using 
negative numbers. Lower Negative number will get more soft . 
In the following example, the 1st command (-0.5) will be louder 
than the 2nd command (-0.1)

<pre class="minicom">
$ sox -v -0.5 srcfile.wav test05.wav
</pre>

<pre class="minicom">
$ sox -v -0.1 srcfile.wav test01.wav
</pre>

##Get Audio File Information

The stat option can provide lot of statistical information about 
a given audio file. The -e flag tells sox not to generate any 
output other than the statistical information.

<pre class="minicom">
$ sox foo.wav -e stat
Samples read: 3528000
Length (seconds): 40.000000
Scaled by: 2147483647.0
Maximum amplitude: 0.999969
Minimum amplitude: -1.000000
Midline amplitude: -0.000015
Mean norm: 0.217511
Mean amplitude: 0.003408
RMS amplitude: 0.283895
Maximum delta: 1.478455
Minimum delta: 0.000000
Mean delta: 0.115616
RMS delta: 0.161088
Rough frequency: 3982
Volume adjustment: 1.000
</pre>

## Get audio from remote

<pre class="minicom">
$ ssh remote_user@remote_server arecord | aplay
</pre>

#Related links

* [15 Awesome Examples to Manipulate Audio Files Using Sound eXchange (SoX)](http://www.thegeekstuff.com/2009/05/sound-exchange-sox-15-examples-to-manipulate-audio-files/)
* [Utilizzi creativi di aplay e arecord](http://fabrizio.zellini.org/utilizzi-creativi-di-aplay-e-arecord)
