Morse Code programs for ChucK
by Perry R. Cook, May 2016

Morse Listener!  This takes system mic input
and detects morse tones (or anything at that
frequency).  Run this, plus Morse coder,
and they should communicate.  You need to
get levels set, and avoid reverberation and
noise.  If all gets set well, and the mic
can hear the speaker, it should work.

You can of course run these on two separate
computers!!   See below for more ReadME

Morse Sender Program (note, use the Slower version):
Run using "chuck MorseSlower" (in terminal ideally)

Type characters in and get code out.

Can also pipe a file into it:

cat TestAll.txt | chuck Morse

Enjoy!!!


//  HOWDY!!!  This is a Morse Code Listener/Decoder
//      by Perry R. Cook, for Month of Code, May 2016
//
//  Uses quadrature heterodyne (WOAH!) filter to detect tones.
//   There are lots of ways to do this, like a narrow-
//   bandpass filter.  Turns out that multiplying the
//   signal by sine and cosine at one frequency, running
//   those outputs through a low-pass filter, then taking
//   the magnitude of those (sum of squares), actually IS
//   a very narrow bandpass filter, tuned to that exact freq.
//   We need both sine and cosine to cover all possible 
//   phases (time delay between mic and speaker) we might see.
//   Those of you who know about Fourier Transforms will note
//   that we're computing 1 bin (the one we want) of a DFT.

//   Run this using >   chuck MorseListen.ck
//   while running MorseSlower.ck as well.
//   Adjust volume(s) (make sure mic can "hear" speaker)
//   for lowest error rate.  Try typing "5" and "0" to
//   make sure you get "....." and "-----".  Then have fun!!
//   You can also adjust the THRESHOLD level below.

//   Note that reverb/echoes in the room will mess the timings
//   up, so adjust things just until they work right.  Or
//   go into a less reverberant room.  Note also that you can
//   confuse (or talk to) the MorseListener by just whistling
//   the correct tone. So you shouldn't have noise or music or
//   cats meowing or other stuff going on in the background.
//   Not very robust, but still pretty cool, right?

//   What we've created is actually a MOdulatorDEModulator (MODEM), 
//   which codes ASCII into acoustic beeps, while the receiver
//   receives/detects those beeps and turns them back into ASCII.
//   In fact, we could use 2 tones, one for dots, one for dashes,
//   and make a MODEM that's possibly more robust and faster.  We
//   could even use three tones (silence, dot, dash).
//   We might do that next week!!

