From Fam. Leemput [wjj.leemput@home.nl]  on 12/12/2003

Hi Bruce,

The sound-recorder can be downloaded from the net for example on: 
http://www.ibiblio.org/pub/Linux/apps/sound/recorders/
There are some more locations where you can download this.
So its not really neccessary to include this but some people dont like 
to compile programs by themself. But they kan use the rpm if available 
or do the ./configure, make , make install stuff.
The reason i included multimon binary is because i changed 2 small C 
programs in the multimon distribution. The original program will give 
lots of output and we are only interested in de DTMF\n string. However 
the other possibility is that they download the multimon distribution, 
overwrite the 2 c programs (unixinput.c, demod_dtmf.c) and do a make 
which create the multimon binary. I attached the 2 programs i changed.
On the other hand the binary is just 43K big but compiled only for Linux 
system.
The 2 .pl files are not ment to use inside the MH loop but 
phonelogger.pl could be easy integrated in the main loop and the 
an_recording.pl could be run as a externel program (run_process 
methode?) because it need some time to do DTMF decoding and MP3 conversion.
The reason why i didn't put it in the MH loop is because im running the
program on an other small linux machine. It communicates via a TCP 
socket to the MH main program. Al other modules like Answermachine, IVR 
and GUI will do the same. With the IVR module im able to control the 
lights, aplliances and answermachine retrieving via ordinary DTMF 
telephone. I will send this project when i finished the docs. Its 
voicemodem and CPAN ivrs.pm based.

If you like you can include the 2 .pl files and the c changes in the 
distribution. It works great overhere. Maby somebody wants to modify it 
to include it in the MH loop?

Thanks,

Walter

socket handler in MH for phone-recorder

in mh.ini
server_telnet_pio_port=1239

#######################################################
# PIO socket server
# will only get data if there is a change in PIO ports
#######################################################
$telnet_server_pio = new  Socket_Item(undef, undef, server_telnet_pio');
   my $handle_telnet_server_pio = handle $telnet_server_pio;
   if (my $msg = said $telnet_server_pio) {
   chomp $msg;
   print "$Time_Date received data from PIO: $msg\n";

     if ($msg =~ /P00.1/) {
     &do_offhook_seq;
     print $handle_telnet_server_pio "ok $msg\n";
     }

     elsif ($msg =~ /P00.0/) {
     &do_onhook_seq;
     print $handle_telnet_server_pio "ok $msg\n";
     }

     elsif ($msg =~ /^get_phone_status/) {
       if (inactive $timer_007) {
       print $handle_telnet_server_pio "Outgoing\n";
       }
       else {
       print $handle_telnet_server_pio "$PhoneModemStringSav\n";
       }
     }
   }


Bruce Winter wrote:
> Walter,
> 
> Got your tar file, thanks.   I see Sound-recorder and Multimon can be
> downloaded from the net, so hows about include your .pl files, but leave out
> the 2 larger binaries, to cut down on the size a bit?
> 
> Looks like a pretty powerful system!
> 
> Bruce
> 
> 
>>-----Original Message-----
>>From: Fam. Leemput [mailto:wjj.leemput@home.nl]
>>Sent: Friday, December 12, 2003 4:06 PM
>>To: bruce@misterhouse.net; Misterhouse Gebruikersgroep
>>Cc: n1gp@comcast.net; seweryni@erols.com
>>Subject: DTMF decoder and Phone recorder code finished
>>
>>
>>Hi Bruce and others,
>>
>>I just finished the quick and dirty documentation from my soundcard DTMF
>>decoder/phone recorder project.
>>Here is the preliminary documentation. Could be better but its getting
>>late :-)
>>Included is a tar.gz file with the code and the DTMF decoder binary.
>>Hopefully, this is usefull for some people. Maybe it can be included in
>>the next release?
>>
>>
>>-------------------------
>>Purpose:
>>-Logging from Incoming/Outgoing telephone callername/number
>>-Recording from incoming/outgoing telephone calls
>>-Playing recorded Phonecalls on ordinary MP3 player with
>>callername/number in MP3 tag info
>>
>>Hardware requirements:
>>-PC
>>-Any soundcard working on Linux
>>-Telephone to Mic-input interface
>>-I/O card for detecting telephone ON/OFF hook status or other methods
>>
>>Software requirements:
>>-an_recording.pl (wil do the actual DTMF decoding on background) is
>>included
>>-Linux distribution (Could be working on Windows but need many adaptions)
>>-CPAN perl modules (http://cpan.org)
>>  MP3::Info;
>>  DBI
>>  Audio::Mixer
>>-Commandline Sound-recorder by B. Warmerdam (Could be any commandline
>>wav recorder but i included this one)
>>-MP3 player for example XMMS (http://www.xmms.org)
>>-Multimon DTMF decoder on
>>(http://www.baycom.org/~tom/ham/linux/multimon.html) The most important
>>piece of software. Believe it or not but this is the only one i found
>>running under Linux after 3 hours Google. But it works great,Thanks to
>>the autor. I included the multimon binary i compiled myself with some
>>modification as i needed only a DTMF string and nothing more. Never run
>>this on the commandprompt without any options, this will lock up your
>>computer. Use the options i gave in my script.
>>-Mysql, only needed when called/caller name is required
>>(http://www.mysql.com)
>>
>>Description:
>>I didn't want to purchase special DTMF decode hardware as a software
>>solution is
>>cheaper and more flexible. The maingoal was to make it work on a
>>ordinary soundcard and do the DTMF decoding stuff with special software.
>>Dont expect a working out of the box program, you have to modify this
>>for your own needs.
>>Take care of the file paths i have used, you have to adapt this also.
>>For me its working very well but you have to implement this in your own
>>environment.
>>
>>In a nutshell this is how it works:
>>The Telephone to mic-input is connected to the Mic-input from the
>>soundcard.
>>I have a PC I/O card which will detect a telephone OFFHOOK by taking a
>>relay from my PABX which can be done in several other ways. The only
>>important thing is to have a signal which detects ON/OFF hook from your
>>telephone. This could be solved in various ways and i don't want to go
>>into this.
>>
>>I'm using the excellent program Misterhouse as the main program. I wrote
>>MH code for the most of the common automation tasks in my house. I also
>>wrote external modules like a IVR, answermachine, GUI and this Telephone
>>logging system which communicates via the MH socket method. This is done
>>as the modules have to exchange information to MH and back.
>>The Telephone logging module is also written in Perl.
>>I will describe a callcase from a telephone call:
>>
>>-Telephone goes OFFHOOK
>>-Perl Audiomixer will set the mic-input level from the soundcard (DTMF
>>decoding wil only work when the level is ok and is not distorted, you
>>have to experiment with this but you can use the level meter in most GUI
>>audiomixers to check the recording level)
>>-A commandline soundrecorder is started in the background en records the
>>telephone call into a wav-file (You have to sample with 22Khz else DTMF
>>decoding doesn't work so keep the default options in this program.
>>-Starttime is copied into the filename of the wavfile.
>>-Detecting if this is a incoming or outgoing call. If its a incoming
>>call then the callerid is taken via the MH socket (Callerid modem within
>>the MH program) You dont have to create any socket with the MH program
>>but for me its handy to check if this is a incoming or outgoing call as
>>the info is already available within MH.
>>-Telephone goes ONHOOK
>>-Recording is stopped by sending a kill signal to the soundrecorder.
>>-Callerid is copied in the filename from the recorded WAV file if it was
>>a incoming call.
>>-A new script is started in the background which is doing the most
>>tricky part, DTMF decoding. In this script the C program from Thomas
>>Sailer "multimon" is called only when it was a outgoing call. This
>>program is used by radioamateurs but its working great for our purpose,
>>DTMF decoding. I modified the program to output only the callerid and
>>nothing more.
>>-Multimon will analyse the recorded WAV file and will produce a string
>>with the called telephonenumber.
>>-The called number string is searched in a MYSQL database. If it finds
>>something it will present a callername else it will try to find with the
>>netnumber the city. (If you dont want or have a SQL database you dont
>>have to do this but its very handy else you only will have the telephone
>>numbers and not the names. Ofcourse you can make also use of the
>>standard callerid code which is in the MH distribution)
>>-The WAV file is converted to MP3 format with the program "lame",
>>This is done for saving diskspace and the MP3 tags possibility. (also
>>other wav->MP3 converters will work but this is the most populair one)
>>-Then the callername, number and start and stoptime is saved in the MP3
>>tags with the CPAN module MP3::Info (very handy as the caller/called
>>name, number and start/stoptime is written to the MP3 tags. With this
>>the MP3 file is complete with all relevant recording information.
>>-A playlist is generated on date sequence. Also a incoming and outgoing
>>call list is updated so i can go to the MH IA5 webinterface to see
>>incoming and outgoing calls with there names and numbers and time.
>>-Then its easy, just run xmms with the playlist and then you will see
>>the callername, callernumber, incoming or outgoing call and the stop and
>>starttime. You will also hear the conversation.
>>
>>Best regards,
>>Walter
