REQ: R1 MF ("Blue box") Tone Generator

Using Nyquist scripts in Audacity.
Post and download new plug-ins.

If you require help using Audacity, please post on the forum board relevant to your operating system:
Windows
Mac OS X
GNU/Linux and Unix-like

Re: REQ: R1 MF ("Blue box") Tone Generator

Permanent link to this post Posted by Annabelle3985 » Wed Oct 28, 2015 9:24 pm

steve wrote:
Annabelle3985 wrote:How's this?

That's got rid of the spaces at the start of the lines.

Normally when writing LISP code (and Nyquist is a type of LISP code), some lines are indented by spaces so that the code is more readable (for sighted users). I realise that can be difficult, and of no benefit, if you can't see the code, so don't worry about indenting the code. If necessary I can add appropriate indentation for any plug-ins that we wish to upload to the Audacity wiki.

The code is still incomplete, so it still does not run. Specifically, in the first line of Nyquist code you have:

(setf low (if (member key

but "key" has not been defined. I'm guessing that "key" would be an input variable, but currently there are no input controls.


I actually tried to format it sort of the same way as the DTMF Tones Plugin, but of course I changed the frequency parameters to match those of the R1MF Tones. By the way, could you please explain what you mean when you say "Input Controls"? Key has not been defined? I'm confused!
Annabelle3985
 
Posts: 53
Joined: Sat Oct 24, 2015 1:17 am
Operating System: Windows 7

Re: REQ: R1 MF ("Blue box") Tone Generator

Permanent link to this post Posted by steve » Wed Oct 28, 2015 10:59 pm

Annabelle3985 wrote:By the way, could you please explain what you mean when you say "Input Controls"? Key has not been defined?

At the top of your code it says:

(if (member key '(#\1 #\2 #\4 #\7)) ...

The function "member" looks for an expression in a list (see: http://www.audacity-forum.de/download/e ... ef-171.htm)
So your "IF" statement is saying, "if the value of key is in the list of characters 1, 2, 4, 7, then do something, else do something else". The problem is that the value of "key" has not be defined.

Who wrote that code?
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Site Admin
 
Posts: 45302
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: REQ: R1 MF ("Blue box") Tone Generator

Permanent link to this post Posted by Annabelle3985 » Wed Oct 28, 2015 11:07 pm

Compare the code I made to the code I loosely based it on.
Attachments
dtmf.ny
(3.09 KiB) Downloaded 43 times
Annabelle3985
 
Posts: 53
Joined: Sat Oct 24, 2015 1:17 am
Operating System: Windows 7

Re: REQ: R1 MF ("Blue box") Tone Generator

Permanent link to this post Posted by steve » Wed Oct 28, 2015 11:23 pm

In David's code he has defined a function with 5 parameters. See the line:

(defun dtmf (key volume tl twist sl)

That is the start of the "function definition". He has named the function "dtmf" and the 5 "arguments" are "key", volume", "tl", "twist" and "sl".
This function is called in the final line:

(dtmf (char keys i) volume tl twist sl)

See that the "function call" passes 5 values to the function. These are "(char keys i)", "volume", "tl", "twist" and "sl". So the first parameter in the function, which is called "key" is given the value of (char keys i).

Within SEQREP (which is a loop structure), the value of "i" acts as a counter, so each time it loops, (char keys i) takes the next character from "keys", where "keys" is a "string" (a text value) that is set by the first control:

;control keys "Tone string" string "" "180audacity"
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Site Admin
 
Posts: 45302
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: REQ: R1 MF ("Blue box") Tone Generator

Permanent link to this post Posted by Annabelle3985 » Thu Oct 29, 2015 12:45 am

Try this out, and see if there's something I'm forgetting.
Attachments
R1MF Tones.ny
(1.42 KiB) Downloaded 44 times
Annabelle3985
 
Posts: 53
Joined: Sat Oct 24, 2015 1:17 am
Operating System: Windows 7

Re: REQ: R1 MF ("Blue box") Tone Generator

Permanent link to this post Posted by steve » Thu Oct 29, 2015 2:06 am

You can't use #\KP or #\ST because the "#\" is for specifying a single character. You could use #\K and #\S instead.

There were a number of mismatched parentheses (the closing brackets not matching up correctly with the open brackets). Perhaps Robert could give some tips for checking that the parentheses are correctly matched.

You have a repeat of (r1mf (char keys i) volume tl twist sl) at the end of the file that should not be present.

You missed out a few "IF" statements.

In the part where you set the volume to zero if the character is not one of the full list of characters, you have #\4 twice.

The "Twist" control is not increasing the volume of the high tone, it is decreasing the volume of the low tone.

Attached is your file with the above corrections. I also put some spaces in and indented some lines so that I could read the code more easily.
R1MF Tones-4.ny
(1.72 KiB) Downloaded 45 times


Note that in this version, when you test to see if the character is a "K" or and "S", the characters are case sensitive. It might be worth also checking against lower case "k" and lower case "s".

Stylistically it would be better to use the "CASE" statements rather than nesting lots of "IF" statements (and it would make the code easier to read and less prone to mismatched parentheses).
See; http://www.audacity-forum.de/download/e ... ef-047.htm

Congratulations, with just a little tweaking it works :)
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Site Admin
 
Posts: 45302
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: REQ: R1 MF ("Blue box") Tone Generator

Permanent link to this post Posted by Annabelle3985 » Thu Oct 29, 2015 4:16 am

steve wrote:You can't use #\KP or #\ST because the "#\" is for specifying a single character. You could use #\K and #\S instead.

There were a number of mismatched parentheses (the closing brackets not matching up correctly with the open brackets). Perhaps Robert could give some tips for checking that the parentheses are correctly matched.

You have a repeat of (r1mf (char keys i) volume tl twist sl) at the end of the file that should not be present.

You missed out a few "IF" statements.

In the part where you set the volume to zero if the character is not one of the full list of characters, you have #\4 twice.

The "Twist" control is not increasing the volume of the high tone, it is decreasing the volume of the low tone.

Attached is your file with the above corrections. I also put some spaces in and indented some lines so that I could read the code more easily.
The attachment R1MF Tones-4.ny is no longer available


Note that in this version, when you test to see if the character is a "K" or and "S", the characters are case sensitive. It might be worth also checking against lower case "k" and lower case "s".

Stylistically it would be better to use the "CASE" statements rather than nesting lots of "IF" statements (and it would make the code easier to read and less prone to mismatched parentheses).
See; http://www.audacity-forum.de/download/e ... ef-047.htm

Congratulations, with just a little tweaking it works :)

As the originator of this post puts it, "The KP tone must being 100 ms long, plus or minus 10 ms; and the digit and ST tones must be 68 ms long, plus or minus 7 ms. There must be 68 ms of silence
between each signal, plus or minus 7 ms.". How would I configure that, I wonder? Could you tell me which parameters to fix so I can make the plugin completed all the way?
Attachments
R1MF Tones.ny
(2.06 KiB) Downloaded 38 times
Annabelle3985
 
Posts: 53
Joined: Sat Oct 24, 2015 1:17 am
Operating System: Windows 7

Re: REQ: R1 MF ("Blue box") Tone Generator

Permanent link to this post Posted by steve » Thu Oct 29, 2015 12:14 pm

Annabelle3985 wrote:As the originator of this post puts it, "The KP tone must being 100 ms long, plus or minus 10 ms; and the digit and ST tones must be 68 ms long, plus or minus 7 ms. There must be 68 ms of silence between each signal, plus or minus 7 ms.". How would I configure that, I wonder? Could you tell me which parameters to fix so I can make the plugin completed all the way?

As "KP" is always at the beginning and "ST" at the end, I'd suggest that you make them "options" rather than requiring them to be entered in the text input. So for controls:
Code: Select all
;control keys "Tone string" string "" "7149642437"
;control kp-st "KP and ST tones" choice "KP and ST,KP only,ST only,Neither" 0
;control tl "Tone duration [milliseconds]" int "" 100 1 1000
;control sl "Silence duration after tone [milliseconds]" int "" 100 0 1000
;control twist "Twist [decrease volume of low tone in each tone; dB]" real "" 0.0 0.0 4.0
;control volume "Volume [percent]" int "" 80 1 100


You would then remove the "K" and "S" characters from the character lists (so the lists are now numeric characters only).
Then replace the final line of the code with something like:

Code: Select all
(let ((numeric (seqrep (i (length keys)) (r1mf (char keys i) volume tl twist sl)))
      (kp (mult volume (sim (osc (hz-to-step  1100) 0.1)
                            (osc (hz-to-step  1700) 0.1))))
      (st (mult volume (sim (osc (hz-to-step  1500) 0.068)
                            (osc (hz-to-step  1700) 0.068)))))
  (case kp-st
    (0 (seq kp (s-rest sl) (cue numeric) (cue st)))
    (1 (seq kp (s-rest sl) (cue numeric)))
    (2 (seq numeric (cue st) (s-rest sl)))
    (t numeric)))
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Site Admin
 
Posts: 45302
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

Re: REQ: R1 MF ("Blue box") Tone Generator

Permanent link to this post Posted by Annabelle3985 » Thu Oct 29, 2015 2:36 pm

BellCurve wrote:I've been an Audacity user for quite a while now, and I've used it for a multitude of projects. Lovely program it is.

Of late, I've come into a project when I need to use the old Bell System MF tones. I have the barest idea of how to use the Nyquist language, so I have no idea how to write the plugin myself. I had the idea of modifying the DTMF generator, but I have no idea how to go about doing it (also, there's the fact that the DTMF system doesn't generate in the same manner as the Bell (R1) MF system).


For anyone who is interested in helping out by writing this generator, here's the pertinent information regarding the Bell MF signalling system (which is the same as the ITU "R1" signalling scheme).

The tones used by the system are:
  1. KP 1100 Hz + 1700 Hz
  2. ST 1500 Hz + 1700 Hz
  3. 1 700 Hz + 900 Hz
  4. 2 700 Hz + 1100 Hz
  5. 3 900 Hz + 1100 Hz
  6. 4 700 Hz + 1300 Hz
  7. 5 900 Hz + 1300 Hz
  8. 6 1100 Hz + 1300 Hz
  9. 7 700 Hz + 1500 Hz
  10. 8 900 Hz + 1500 Hz
  11. 9 1100 Hz + 1500 Hz
  12. 0 1300 Hz + 1500 Hz
(If you'll notice, the digit tones of the MF system follow a two of five code, with the 700, 900, 1100, 1300 and 1500 values corresponding to 0, 1, 2, 4, 7; the KP (start of pulsing) tone and ST (end of pulsing) tone use the 1700 tone plus 2 and 7, respectively. The European R2 MF signalling system uses the other combinations of 1700 with 0, 1, and 4 for more tones, but nevermind the R2 system.)

The KP tone must being 100 ms long, plus or minus 10 ms; and the digit and ST tones must be 68 ms long, plus or minus 7 ms. There must be 68 ms of silence between each signal, plus or minus 7 ms. Transmissions start with KP, and end with ST, tones are sent "en bloc", so no pauses.

I.e. a number dialed as "1 (pause) 800 (pause) 555 (pause) 1212", would be sent as "KP 18005551212 ST" (where the spaces are only inserted for clarity).


In terms of input to the generator, all that is really needed is the input of the number to be generated (with KP and ST generated automatically), and the volume.


Thanks to any one who is willing to take on this task, I wish I could be of more help.


I've compiled a plugin for R1MF Tones, and it works. Here it is.
Attachments
R1MF Tones.ny
(2.62 KiB) Downloaded 44 times
Annabelle3985
 
Posts: 53
Joined: Sat Oct 24, 2015 1:17 am
Operating System: Windows 7

Re: REQ: R1 MF ("Blue box") Tone Generator

Permanent link to this post Posted by steve » Thu Oct 29, 2015 4:49 pm

There's still a few "#\K" and "#\S" characters that should be deleted, for example, line 28.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Site Admin
 
Posts: 45302
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

PreviousNext

Return to Nyquist



Who is online

Users browsing this forum: No registered users and 3 guests