[audacity4blind] New plug-in: International morse Code generator

  • From: "David R. Sky" <davidsky@xxxxxxxxxxxxxx>
  • To: audacity4blind@xxxxxxxxxxxxx
  • Date: Fri, 13 Jul 2007 16:28:09 -0700 (PDT)

morse.ny: International morse Code generator plug-in

 Generates the Morse di-dah-dit tone patterns for text you type
into the edit fields.

Unusual initial caveat: The first time you use morse.ny in each
Audacity session, it only generates one or two morse code
characters. Undo the generated sound [control+z], then use the
plug-in again. Occasionally this doesn't work either so undo the
generated sound again, then click on the debug button instead of
the okay button. The Audacity development team is aware of this
unusual problem.

Copy morse.ny into your Audacity plug-ins folder. Next time you
open Audacity you'll find 'International Morse Code' under the
generate menu.

Variables:

1. 0=generate Morse code 1 or 2=display Morse phrases
Set this value to 0 to generate Morse code. There are some short Morse code phrases [from 1 to 4 Morse
characters] so
set this value to 1 or 2 to see various Morse phrases listed on
screen. Six of the so-called prosigns do not have the usual silent
space between the two Morse characters, prepend these prosigns with
a # number sign character, as displayed on page 1 of the help
files.

2. Tone frequency [hz]
Frequency of the generated tone, default 1kilohertz.

3. Unit time [milliseconds]
Morse "a" is di-dah, "b" is dah-di-di-dit, and so on.
Dit tones are 1 unit of time in duration, dah tones are 3 units of
time in duration. Silent space between elements of a Morse
character is one unit time, silent space between Morse characters
is 3 units, and silent space between Morse words is 7 units. The default unit time value is 100 milliseconds.

4. Volume [percent]
From a low volume of 10 percent of maximum, to 100 percent full
volume.

5 through 9: String input fields
In each of these fields you can enter text to convert into morse
code. Blank lines are ignored, and one Morse "space" character is
inserted between lines of text. You can enter letters, numbers, and
a variety of punctuation listed at the top of the plug-in display.
Punctuation marks not used in Morse do not generate any tones.

Written by David R. Sky, july 13, 2007.
Thanks very much to the website
http://morsecode.scphillips.com/./morse.html
for Morse code information.
Released under terms of the GNU Public License
http://www.opensource.org/licenses/gpl-license.php

--
David R. Sky
http://www.shellworld.net/~davidsky/
;nyquist plug-in

;version 2

;type generate

;name "International Morse code..."

;action "Generating Morse code..."

;info "morse.ny by David R. Sky www.shellworld.net/~davidsky/nyquist.htm 
\nThanks to http://morsecode.scphillips.com/./morse.html for Morse code 
information.\nCurrently, this plug-in only generates one or two Morse 
characters the first time you use it.\nUndo the result [control+z] then repeat 
the process.\nSometimes this does not work, click on the 'debug' button instead 
of 'okay'.\nYou can generate Morse letters, numbers, and the following 
punctuation marks:\nquotation mark ' apostrophe () parentheses , comma - hyphen 
. dot \n/ forward slash : colon = equals sign ? question mark @ at 
sign\nReleased under terms of the GNU Public License"



;control action "0=generate Morse code 1 or 2=display Morse phrases" int "" 0 0 
2

;control freq "Tone frequency [hz]" int "" 1000 100 10000

;control unit-t "Unit time [milliseconds]" int "" 100 20 500

;control vol "Volume [percent]" int "" 90 10 100

;control line1 "1:" string "" "a b c d e f g h i j k l m n o p q r s t u v w x 
y z"

;control line2 "2:" string "" "0 1 2 3 4 5 6 7 8 9"

;control line3 "3:" string "" ""  

;control line4 "4:" string "" ""  

;control line5 "5:" string "" ""  



; International Morse code generator morse.ny by David R. Sky, July 13, 2007.

; http://www.shellworld.net/~davidsky/nyquist.htm

; Thanks very much to the website _International Morse Code_ at

; http://morsecode.scphillips.com/./morse.html

; for the dits and dahs of the alphabet, numbers and punctuation.

; Released under terms of the GNU Public License

; http://www.opensource.org/licenses/gpl-license.php 



#|

morse.ny: International morse Code generator plug-in



 Generates the Morse di-dah-dit tone patterns for text you type

into the edit fields.



Unusual initial caveat: The first time you use morse.ny in each

Audacity session, it only generates one or two morse code

characters. Undo the generated sound [control+z], then use the

plug-in again. Occasionally this doesn't work either so undo the

generated sound again, then click on the debug button instead of

the okay button. The Audacity development team is aware of this

unusual problem.



Copy morse.ny into your Audacity plug-ins folder. Next time you

open Audacity you'll find 'International Morse Code' under the

generate menu.



Variables:



1. 0=generate Morse code 1 or 2=display Morse phrases

Set this value to 0 to generate Morse code. 

There are some short Morse code phrases [from 1 to 4 Morse

characters] so

set this value to 1 or 2 to see various Morse phrases listed on

screen. Six of the so-called prosigns do not have the usual silent

space between the two Morse characters, prepend these prosigns with

a # number sign character, as displayed on page 1 of the help

files. 



2. Tone frequency [hz]

Frequency of the generated tone, default 1kilohertz.



3. Unit time [milliseconds]

Morse "a" is di-dah, "b" is dah-di-di-dit, and so on.

Dit tones are 1 unit of time in duration, dah tones are 3 units of

time in duration. Silent space between elements of a Morse

character is one unit time, silent space between Morse characters

is 3 units, and silent space between Morse words is 7 units. 

The default unit time value is 100 milliseconds.



4. Volume [percent]

From a low volume of 10 percent of maximum, to 100 percent full

volume.



5 through 9: String input fields

In each of these fields you can enter text to convert into morse

code. Blank lines are ignored, and one Morse "space" character is

inserted between lines of text. You can enter letters, numbers, and

a variety of punctuation listed at the top of the plug-in display.

Punctuation marks not used in Morse do not generate any tones.



Written by David R. Sky, july 13, 2007.

Thanks very much to the website

http://morsecode.scphillips.com/./morse.html

for Morse code information.

Released under terms of the GNU Public License

http://www.opensource.org/licenses/gpl-license.php 

|#





; dit tone 1 unit

; dah tone 3 units

; silence between components of a Morse character 1 unit

; silence between characters 3 units

; silence between words 7 units



(cond

((= action 1) ; display first page of morse phrases

(format nil "Morse code phrases - page 1 of 2 

~% ~%

prosigns: phrases - Morse equivalent

(these first 5 prosigns do not have the usual space between the

letters, so use the initial # number sign to identify

these phrases for this plug-in.) 

~% ~%

End of message - #ar

Wait - #as

Break in the text - #BT (or #TV)

Going off the air ('clear') - #cl

End of transmission - #sk

~% ~%

Other phrases - Morse equivalent 

~% ~%

Over - K

Roger - R

See you later - CUL

Be seeing you - BCNU

You're - UR

Signal report - RST

Best regards - 73

Love and kisses - 88 ~%")  ; end format

) ; end display of page 1 of Morse phrases



((= action 2) ; end display of page 2 of Morse phrases

(format nil "Morse code phrases - page 2 of 2 

~% ~%

phrase - 'Q code' Morse equivalent 

~% ~%

I acknowledge receipt - qsl

Do you acknowledge? - QSL?

Wait - QRX

Should I wait? - QRX?

I am ready to copy - QRV

Are you ready to copy? - QRV?

The frequency is in use - QRL

Is the frequency in use? - QRL?

My location is... - QTH

What is your location? - QTH? ~%") ; end format

) ; end display of page 2 of Morse phrases



(t ; generate morse code

(let* (

(unit-t (* unit-t 0.001))

(vol (* vol 0.01))

(freq (hz-to-step freq))

(string-list (list line1 line2 line3 line4 line5))

(text "")

after-#

(v vol) 

(f freq)

tm

(incr 0)) ; end let* args





; function to concatenate string inputs

; which have text

(defun concat (text str)

(cond



; if the text string has no text yet but input string does,

; concatenate empty text with input string, with no initial space

; [concatenating the first string input which has text]

((and (= (length text) 0) (> (length str) 0))

(strcat text str))



; it's been determined that the text string has text,

; concatenate it with input string if input string has text,

; separated by a space

((> (length str) 0)

(strcat text " " str))



; otherwise just return the text string

(t text)

) ; end cond

) ; end defun concat





; concatenate string inputs which have text

(dotimes (i (length string-list))

(setf text (concat text (nth i string-list))))



; convert all letters to upper case

(setf text (string-upcase text))



; append one space to the end of text

(setf text (strcat text " "))





; function to generate one unit time of tone

(defun t1 

(&optional (v vol) (f freq) (tm unit-t))

(mult (pwl 0 0 0.005 v (- tm 0.005) v tm 0 tm)

(osc f tm)))





; function to generate three units time of tone

(defun t3 

(&optional (v vol) (f freq) (tm (* unit-t 3)))

(mult (pwl 0 0 0.005 v (- tm 0.005) v tm 0 tm)

(osc f tm)))





; function to generate zero silence

; returned when undefined morse character is called for

; with exception of # character, which prepends certain prosigns

(defun s0 ()

(s-rest 0))





; function to generate one unit time of silence

(defun s1 (&optional (tm unit-t))

(s-rest tm))





; function to generate three units time of silence

(defun s3 (&optional (tm (* unit-t 3)))

(s-rest tm))





; function to generate 4 units time of silence:

; it was easier to append an s3 function 

; to each morse character,

; so a character space [ASCII 32] of 4 rather than 7 units

; was simpler to add after each word

(defun s4 (&optional (tm (* unit-t 4)))

(s-rest tm))





; function to return ar - "end of message"

; #ar in string inputs

(defun ar ()

(seq (t1) (s1) (t3) (s1) (t1) (s1) (t3) (s1) (t1) (s3)))





; function to return as - "wait"

; #as in string inputs

(defun as ()

(seq  (t1) (s1) (t3) (s1) (t1) (s1) (t1) (s1) (t1) (s3)))





; function to return bt - "break in the text"

; #bt in string inputs

(defun bt ()

(seq (t3) (s1) (t1) (s1) (t1) (s1) (t1) (s1) (t3) (s3)))





; function to return tv - "break in the text"

; #tv in string inputs

(defun tv ()

(seq (t3) (s1) (t1) (s1) (t1) (s1) (t1) (s1) (t3) (s3)))





; function to return cl - "going off the air" or "clear"

; #cl in string inputs

(defun cl ()

(seq (t3) (s1) (t1) (s1) (t3) (s1) (t1) (s1) (t1) (s1) (t3) (s1) (t1) (s1) (t1) 
(s3)))





; function to return sk - "end of transmission"

; #sk in string inputs

(defun sk ()

(seq (t1) (s1) (t1) (s1) (t1) (s1) (t3) (s1) (t1) (s1) (t3) (s3)))





; function to get Morse dit-dah stream from master Morse list

; input char ASCII number, output LISP stream

(defun get-morse (char-number)

(nth char-number (list 

"(s0)" "(s0)" "(s0)" "(s0)" "(s0)" "(s0)" "(s0)" "(s0)" "(s0)"

"(s0)" "(s0)" "(s0)" "(s0)" ; ^a through ^m 

"(s0)" "(s0)" "(s0)" "(s0)" "(s0)" "(s0)" "(s0)" "(s0)" "(s0)"

"(s0)" "(s0)" "(s0)" "(s0)" ; ^n through ^z 

"(s0)" "(s0)" "(s0)" "(s0)" "(s0)" "(s0)" 

"(seq (s1) (s3))" ; space [ASCII 32]

"(s0)"

"(seq (t1) (s1) (t3) (s1) (t1) (s1) (t1) (s1) (t3) (s1) (t1) (s3))" ; " 34

"(validate-# i text)" ; initial # for 6 prosigns

"(s0)"

"(s0)"

"(s0)"

"(seq (t1) (s1) (t3) (s1) (t3) (s1) (t3) (s1) (t3) (s1) (t1) (s3))" ; ' 39

"(seq (t3) (s1) (t1) (s1) (t3) (s1) (t3) (s1) (t1) (s1) (t3) (s3))" ; ( 40

"(seq (t3) (s1) (t1) (s1) (t3) (s1) (t3) (s1) (t1) (s1) (t3) (s3))" ; ) 41

"(s0)"

"(s0)"

"(seq (t3) (s1) (t3) (s1) (t1) (s1) (t1) (s1) (t3) (s1) (t3) (s3))" ; , 44

"(seq (t3) (s1) (t1) (s1) (t1) (s1) (t1) (s1) (t1) (s1) (t3) (s3))" ; - 45

"(seq (t1) (s1) (t3) (s1) (t1) (s1) (t3) (s1) (t1) (s1) (t3) (s3))" ; . 46

"(seq (t3) (s1) (t1) (s1) (t1) (s1) (t3) (s1) (t1) (s3))" ; / 47

"(seq (t3) (s1) (t3) (s1) (t3) (s1) (t3) (s1) (t3) (s3))" ; 0 48

"(seq (t1) (s1) (t3) (s1) (t3) (s1) (t3) (s1) (t3) (s3))" ; (t1) (s1) 49

"(seq (t1) (s1) (t1) (s1) (t3) (s1) (t3) (s1) (t3) (s3))" ; 2 50

"(seq (t1) (s1) (t1) (s1) (t1) (s1) (t3) (s1) (t3) (s3))" ; (t3) (s1) 51

"(seq (t1) (s1) (t1) (s1) (t1) (s1) (t1) (s1) (t3) (s3))" ; 4 52

"(seq (t1) (s1) (t1) (s1) (t1) (s1) (t1) (s1) (t1) (s3))" ; 5 53

"(seq (t3) (s1) (t1) (s1) (t1) (s1) (t1) (s1) (t1) (s3))" ; 6 54

"(seq (t3) (s1) (t3) (s1) (t1) (s1) (t1) (s1) (t1) (s3))" ; 7 55

"(seq (t3) (s1) (t3) (s1) (t3) (s1) (t1) (s1) (t1) (s3))" ; 8 56

"(seq (t3) (s1) (t3) (s1) (t3) (s1) (t3) (s1) (t1) (s3))" ; 9 57

"(seq (t3) (s1) (t3) (s1) (t3) (s1) (t1) (s1) (t1) (s1) (t1) (s3))" ; : 58

"(s0)"

"(s0)"

"(seq (t3) (s1) (t1) (s1) (t1) (s1) (t1) (s1) (t3) (s3))" ; = 61

"(s0)"

"(seq (t1) (s1) (t1) (s1) (t3) (s1) (t3) (s1) (t1) (s1) (t1) (s3))" ; ? 63

"(seq (t1) (s1) (t3) (s1) (t3) (s1) (t1) (s1) (t3) (s1) (t1) (s3))" ; @ 64

"(seq (t1) (s1) (t3) (s3))" ; A

"(seq (t3) (s1) (t1) (s1) (t1) (s1) (t1) (s3))" ; B

"(seq (t3) (s1) (t1) (s1) (t3) (s1) (t1) (s3))" ; C

"(seq (t3) (s1) (t1) (s1) (t1) (s3))" ; D

"(seq (t1) (s3))" ; E

"(seq (t1) (s1) (t1) (s1) (t3) (s1) (t1) (s3))" ; F

"(seq (t3) (s1) (t3) (s1) (t1) (s3))" ; G

"(seq (t1) (s1) (t1) (s1) (t1) (s1) (t1) (s3))" ; H

"(seq (t1) (s1) (t1) (s3))" ; I

"(seq (t1) (s1) (t3) (s1) (t3) (s1) (t3) (s3))" ; J

"(seq (t3) (s1) (t1) (s1) (t3) (s3))" ; K

"(seq (t1) (s1) (t3) (s1) (t1) (s1) (t1) (s3))" ; L

"(seq (t3) (s1) (t3) (s3))" ; M

"(seq (t3) (s1) (t1) (s3))" ; N

"(seq (t3) (s1) (t3) (s1) (t3) (s3))" ; O

"(seq (t1) (s1) (t3) (s1) (t3) (s1) (t1) (s3))" ; P

"(seq (t3) (s1) (t3) (s1) (t1) (s1) (t3) (s3))" ; Q

"(seq (t1) (s1) (t3) (s1) (t1) (s3))" ; R

"(seq (t1) (s1) (t1) (s1) (t1) (s3))" ; S

"(seq (t3) (s3))" ; T

"(seq (t1) (s1) (t1) (s1) (t3) (s3))" ; U

"(seq (t1) (s1) (t1) (s1) (t1) (s1) (t3) (s3))" ; V

"(seq (t1) (s1) (t3) (s1) (t3) (s3))" ; W

"(seq (t3) (s1) (t1) (s1) (t1) (s1)  (t3) (s3))" ; X

"(seq (t3) (s1) (t1) (s1)  (t3) (s1) (t3) (s3))" ; Y

"(seq (t3) (s1) (t3) (s1) (t1) (s1)  (t1) (s3))" ; Z 90

"(s0)"

"(s0)"

"(s0)"

"(s0)"

"(s0)"

"(s0)"

) ; end list of morse character function strings

) ; end nth char-number

) ; end defun get-morse





; function to validate that the two characters after any # char

; are one of the six valid prosigns

; which do not have 3 unit-time space between the two characters

; if valid, returns the morse code for the prosign,

; otherwise return zero silence

(defun validate-# (i text)

; get the two characters after the #

(setf after-# (subseq text (+ i 1 incr) (+ i 3 incr)))



(cond

((string= after-# "AR") 

(setf incr (+ incr 2))

(setf text (strcat text "!!")) 

(ar))



((string= after-# "AS") 

(setf incr (+ incr 2))

(setf text (strcat text "!!"))  

(as))



((string= after-# "BT") 

(setf incr (+ incr 2))

(setf text (strcat text "!!"))  

(bt))



((string= after-# "TV") 

(setf incr (+ incr 2))

(setf text (strcat text "!!"))  

(tv))



((string= after-# "CL") 

(setf incr (+ incr 2))

(setf text (strcat text "!!"))  

(cl))



((string= after-# "SK") 

(setf incr (+ incr 2))

(setf text (strcat text "!!"))  

(sk))



(t (s0)) ; if no valid prosign, return zero silence

) ; end cond

) ; end defun validate-#





; generate Morse code

(seqrep (i (length text))

(eval (read (make-string-input-stream 

(get-morse (char-code (char text (+ i incr))))

))) ; end eval, read, make-string-input-stream

) ; end seqrep i

) ; end let

) ; end t

) ; end cond

Other related posts:

  • » [audacity4blind] New plug-in: International morse Code generator