# Listener

First install libsndfile!
Then:

    make install

Then run 'setlistener' with as parameter the device to listen to.

    setlistener /dev/dsp

Then, with the left and right arrow keys, move the '|' until the word "<silence>" appears. No, don't you move the '|' to the maximum right, move it to the right until the "<silence>" just constantly appears. Then: remember the value "Current level: ".
Next step is creating the file /usr/local/etc/listener.conf Copy the example listener.conf to the location mentioned above and edit it to suit your needs.
For example:

    wav_path = /home/folkert/recordings
    devname = /dev/dsp
    detect_level = 800
    min_duration = 1
    max_duration = 300
    rec_silence = 5
    sample_rate = 44100
    channels = 1
    compression = ima-adpcm
    format = wav
    from_pipe = 0
    exec = /home/folkert/encode_sample
    prerecord_n_seconds = 3

## format

Format sets what kind of outputfile is generated. Possible are:

Keyword | Description
wav | Microsoft WAV
aiff | Apple/SGI AIFF
au | SUN/NeXT AU
raw | RAW PCM data
svx | Amiga IFF/SVX8/SV16
nist | Sphere NIST
voc | VOC files
ircam | Berkeley/IRCAM/CARL
w64 | Sonic Foundry's 64 bit RIFF/WAV
mat4 | Matlab v4.2/GNU Octave 2.0
mat5 | Matlab v5.0/GNU Octave 2.1
pvf | Portable Voice Format
xi | Fasttracker 2 Extended Instrument
htk | HMM Toolkit format
sds | Midi sample dump standard
avr | Audio Visual Research
wavex | MS WAVE with WAVEFORMATEX

## sample_rate

Sets the samplerate at which the samples are recorded. Be warned: only the rates supported by your soundcard can be entered here!

## rec_silence

When while recording things become silent, don't stop recording immediately but keep recording for 'rec_silence' seconds to see if the sound restarts.

## min_duration

When the sound starts, record at least that many seconds of audio, measured relative to the start of the recoding.
E.g. if the sound only sounds for 3 seconds and you've set this value to 5, still at least 5 seconds of audio will be recorded.

## min_triggers

sets how many samples must be above the threshold (the 'detect_level') before recording starts. The samplerate is set to 44.1kHz so if you set min_duration to 4410, the minimum length (duration) of sound before the recording starts is: 0.1s (or: one tenth of a second).

## max_duration

How long a sample may be before a new file is started.

## one_shot

When set to yes/on/1, listener will exit after the first recorded sample.

## prerecord_n_seconds

How many seconds to record before the sound starts.

## channels

Sets the number of channels to record. default is 1 which is mono, 2 is stereo. Warning: some soundcards don't support mono, listener will then exit with an errormessage.

## compression

sets the compressionmethod. Can be:

- u-law
- a-law
- ima-adpcm
- ms-adpcm
- gsm-6.10
- G721_32 (32kbit)
- G723_24 (24kbit)
- G723_40 (40kbit)

If you omit the compression-line completely, no compression is used.

## from_pipe

sets wether listener is reading from a pipe fed by listenersoundpipe. listenersoundpipe lets you split a sound- device in two so that you can check 2 rooms with only one sound- card. You need to create two pipes and start 2 listener processes, each reading from one pipe.
Set this parameter to yes/on/1 for "pipe-mode", no/off/0 for normal mode.

## exec

selects the script/program to execute after the sample was recorded. This first (and only) parameter for that script is the filename of the sample.

## on_event_start

selects the script/program to execute before the sample was recorded.

## filter

lets you add one or more filters. these will be used when detecting sounds. beware: sound is written to the wav-files BEFORE the filtering is done. See the directory 'filter_lib_example' for an example on how to write a filter for listener.

## amplify

Wether to automatically amplify the sound or not. Use 'on' and 'off' to toggle.

## start_amplify

What amplification to use when the sound starts. This will be adjusted to something more applicable UNLESS 'fixed_amplify' is set to yes.

## max_amplify

Maximum amplification to use.

## fixed_amplify

Wether to ONLY use the amplification factor set with 'start_amplify' (=yes) or let listener do autotuning (=no).
safe_after_filtersets wether to save the audio-data to disk before or after the filtering. Before the filtering gives you the original sound while after gives you the sound after processing with the filter(s).
Enter 'on' or 'off'.
The final step is starting the program:

    listener

and that's it!
Thanks to Hugo Hugo for adding code that enables you to set some parameters from the commandline.
If you have any suggestions or anything else, do not hesitate to contact me at the following e-mail address:
folkert@vanheusden.com