next up previous contents
Next: What could be heard Up: Hearing the sounds of Previous: Listen to your heart:   Contents

Some tools to handle sounds

There are a lot of people dedicated to sound processing in all its different aspects. I think that there is something like a continuum

Sound > ECG > EEG/Sleep > EMG

And what does the sign ">" mean? In my humble opinion it means more people, cheaper devices, more free applications, more data available, more sophisticated algorithms, more processing tools... in summary, a more developed field. Being the processing of these signals very similar (they use similar amplifiers, converters, storing devices, processing means...), besides taking example from our bigger brothers, we could borrow some tools to handle our signals.

So, we are going to use a very useful tool designed to manipulate sounds: Sox - Sound eXchange

We begin with the file st7121j0.wav; this file is the result of accelerating 400 times the signal EEG Pz-Oz of the file st7121j0.rec.

We remember its spectrogram in the figure 8.1

Figure 8.1: The spectrogram of the signals EEG Pz-Oz, which we are going to modify
\includegraphics[width=13cm]{figures/figure21.eps}

Now we can present Sox

 
~> sox -h
sox: Version 12.17.4

Usage: [ gopts ] [ fopts ] ifile [ fopts ] ofile [ effect [ effopts ] ]

gopts: -e -h -p -v volume -V

fopts: -r rate -c channels -s/-u/-U/-A/-a/-i/-g/-f -b/-w/-l/-d -x

effect: avg band bandpass bandreject chorus compand copy dcshift deemph earwax 
echo echos fade filter flanger highp highpass lowp lowpass map mask pan phaser 
pitch polyphase rate resample reverb reverse silence speed stat stretch swap 
synth trim vibro vol 

effopts: depends on effect

Supported file formats: aiff al au auto avr cdr cvs dat vms hcom la lu maud
 mp3 nul ossdsp prc raw sb sf sl smp sndt sph sunau 8svx sw txw ub ul uw voc 
vorbis wav wve

A lot of options. We can use some of them on our file. First of all we can try to modify the speed of the st7121j0.wav. This is the command

 
> sox st7121j0.wav changedspeed.wav speed .5
sox: SPEED: 136 values clipped...

We changed the acceleration from 400x to 200x and the the result is shown in figure 8.2

Figure 8.2: We reduced the reproduction speed by a factor of 0.5. You can see that the duration doubled and the sleep spindles (and the whole frequency content) appear at half of the original frequency
\includegraphics[width=13cm]{figures/figure22.eps}

The main effect is the change of the axis structure. Now the file lasts double the time of the original file and the frequencies are half of those of the original. Our hearing organ can hear a limited range of frequencies. If we have a signal that can be represented by a spectrogram or other time-frequency maps, it can be heard by changing the speed of reproduction. It is what we are doing from the beginning of the tutorial. Once we have a sound file, we can easily modify the speed at which we hear it. Wavesurfer allows to do this by doing right click > properties > Sound and modifying the sampling rate. So we do not need to make new conversion from EDF files if we want to hear the same signals at different speeds.

But sometimes we want to change the sampling rate without changing the frequencies present in the signal

 
> sox st7121j0.wav -r 20000 changedrate.wav
> sox st7121j0.wav -r 20000 changedrate2.wav resample -ql

Both methods change the rate. This is the difference

      resample [ -qs | -q | -ql ] [ rolloff [ beta ] ]
                 Translate input sampling rate to output sampling
                 rate  via  simulated  analog  filtration.   This
                 method  is slower than rate, but gives much better 
                 results.

We can see the result in figure 8.3

Figure 8.3: In this file we reduced the sampling rate without modifying the frequencies
\includegraphics[width=13cm]{figures/figure23.eps}

The result is similar to the original file. If we look at the sampling rate (right click > properties > Sound) we can see that the sampling rate is 20000. Since computers usually have the upper frequency limit at around 50000 Hz, we could accelerate with more freedom our signal.

Now we can try some filtering. If we want to hear the frequencies between 0 and 2 Hz we could use

 
> sox st7121j0.wav lowpass.wav lowpass 800

The result can be seen in figure 8.4

Figure 8.4: In this file we applied a low pass filter at 800 Hz
\includegraphics[width=13cm]{figures/figure24.eps}

Finally we could try a bandpass filter to stress the sleep spindles

 
> sox st7121j0.wav bandpass.wav bandpass 5000 500

The result can be seen in figure 8.5

Figure 8.5: In this file we applied a bandpass filter to stress the sleep spindles
\includegraphics[width=13cm]{figures/figure25.eps}

There are a lot of processing tools of sounds at the finger of your tips. Sox has a lot of possibilities not described here, Wavesurfer has a lot of possibilities not described... You could try them with your own signals or with signals downloaded from the Internet.

Finally, it is possible that you need to compress a file. One interesting open compressed format is Ogg. You can see the Ogg FAQ

 
> oggenc st7121j0.wav
Opening with wav module: WAV file reader
Encoding "st7121j0.wav" to
         "st7121j0.ogg"
at quality 3.00
        [ 99.7%] [ 0m00s remaining] |

Done encoding file "st7121j0.ogg"

        File length:  1m 33.0s
        Elapsed time: 0m 04.7s
        Rate:         19.6860
        Average bitrate: 57.8 kb/s

> ls st7121j0.wav st7121j0.ogg -l
-rw-r--r--  1 je users  677174 2004-10-21 01:23 st7121j0.ogg
-rw-r--r--  1 je users 7458044 2004-10-20 17:09 st7121j0.wav

Notice that the file is compressed by a factor of 10. Ogg files can also be handled by Wavesurfer.

 
> sox st7121j0.wav st7121j0.ogg
Channels: 1  Rate: 40000
> ls st7121j0.wav st7121j0.ogg -l
-rw-r--r--  1 je users  677189 2004-10-21 01:32 st7121j0.ogg
-rw-r--r--  1 je users 7458044 2004-10-20 17:09 st7121j0.wav


next up previous contents
Next: What could be heard Up: Hearing the sounds of Previous: Listen to your heart:   Contents
je 2006-10-13