Used file formats

Before we'll continue with writing scripts, please let me tell you some words about the file formats the CapiSuite core uses.

CapiSuite always reads and saves files in the native format as they are be expected and given by the CAPI ISDN drivers. This preserves it from having to convert everything from and to other formats thus reducing unnecessary overhead.

As these formats aren't that well-known and you will need special tools to convert or view/play them, I'll give you a short overview of how you can do this.

Most likely, your scripts will convert the special ISDN file formats to well-known ones for sending them to you via e-mail for example. Nevertheless, I'd advice you to store the received and sent files in the native CapiSuite formats somewhere. This will protect you from losing data in the case the conversion fails and will help you in debugging problems which may arise with your scripts.

All tools which I refer to here are described in the section called “Software”. See there for informations how to get them.

ISDN transmits voice data as waves with a sample-rate of 8kHz in mono. To save bandwith, a compression called A-Law is used (at least in Europe, other countries like the USA use u-Law which is quite similar to A-Law). For any reason beyond my understanding, they use a bit-reversed form of A-Law called "inversed A-Law".

There are two possible ways to create A-Law files.

The first one is to call your computer with your phone (either use the default answering machine script and configure it as described in the section called “Configuration for the answering machine” or write a simple script yourself). Now, record whatever you want and take the created output file (when you use the default scripts please take the file from the user_dir, not the attachment of the mail as this is already converted) and use it.

You eventually want to trim the recorded file and remove unwanted noise and silence at the beginning and the end. This can easily be done by sox and play (both come together with the sox package).

sox is used to convert a file while play is used to just play it. Both support the same effects including the trim option. Both also detect what type of file you are using by looking at the suffix of your file name. So all your inversed A-Law files should be named like something.la (.la is the inversed form of .al which stands for A-Law).

So let's first try to find the optimal values for the trim effect by calling play:

play myfile.la trim <start-offset> <duration>

Now play around with start-offset and duration (both given in seconds) until you know the right values. If you found them, you can use sox to actually produce the needed file:

sox myfile.la outfile.la trim <start-offset> <duration>

You'll now get a file named outfile.la which should contain what you want.

The second way to create an inversed A-Law file is to record a normal WAV-file with your favourite sound-tools and convert it to the destination format using sox. You'll get the best results when your WAV file already is in 8kHz, mono, 8 bit format. sox is able to convert other waves if necessary but this usually will result in worse quality. You should also normalize your sound file to about 50% of the maximum amplitude.

You can convert WAV to inversed A-Law by calling (thx to Carsten Heesch for the tip):

sox myfile.wav -r 8000 -c 1 -b outfile.la resample -ql

CAPI-compliant drivers will expect and provide fax files in a so called Structured Fax File (SFF). As this seems to be a CAPI-specific format, there are not much tools out there for GNU/Linux which are capable of handling it. Finally I found some small tools written by Peter Schäfer, which we can use here.

CapiSuite is also able to receive color fax files which will be stored in a special file format I called CFF.