;control widget documentation?

classic Classic list List threaded Threaded
26 messages Options
12
Reply | Threaded
Open this post in threaded view
|

;control widget documentation?

Stevethefiddle
I notice that the word "rate" can be used as a parameter with slider widgets;
for example, the following plug-in will display the current sample rate:

;nyquist plug-in
;version 1
;type generate
;name "Show-SampleRate..."
;action "show ..."
;info "Show Sample Rate"
;control n "Sample Rate" int "Hz" rate 0 1000000

Is this documented anywhere?
Are there any other words that can be used in this way?
Reply | Threaded
Open this post in threaded view
|

Re: ;control widget documentation?

Paul Beach-2-3
Rate, Tempo, seem to be commands for Adagio Midi commands. It is not
likely that I would use a plug-in for music compostions.

Computer music, change key, tempo etc., regarding a theme sounds like
so:

http://www.proviewlandscape.com/liss/rushes%20and%20swamp.mp3

Rate
The !RATE command scales all times including those specified in
hundredths of seconds. A rate of 100 means no change, 200 means twice as
fast, and 50 means half as fast. For example, to make a piece play 10%
faster, you can add the following command at the beginning of the score:
!RATE 110

!RATE and !TEMPO commands combine, so
!RATE 200
!TEMPO 70

will play 70 beats per minute at double the normal speed, or 140 beats
per minute. Like !TEMPO, the time of the !RATE command is added to the
time attribute of all following notes up to the next !TEMPO or !RATE
command.

On Tue, 8 Jun 2010 17:28:32 -0700 (PDT), "Stevethefiddle"
<[hidden email]> said:

>
> I notice that the word "rate" can be used as a parameter with slider
> widgets;
> for example, the following plug-in will display the current sample rate:
>
> ;nyquist plug-in
> ;version 1
> ;type generate
> ;name "Show-SampleRate..."
> ;action "show ..."
> ;info "Show Sample Rate"
> ;control n "Sample Rate" int "Hz" rate 0 1000000
>
> Is this documented anywhere?
> Are there any other words that can be used in this way?
> --
> View this message in context:
> http://audacity.238276.n2.nabble.com/control-widget-documentation-tp5156108p5156108.html
> Sent from the audacity-nyquist mailing list archive at Nabble.com.
>
> ------------------------------------------------------------------------------
> ThinkGeek and WIRED's GeekDad team up for the Ultimate
> GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
> lucky parental unit.  See the prize list and enter to win:
> http://p.sf.net/sfu/thinkgeek-promo
> _______________________________________________
> Audacity-nyquist mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/audacity-nyquist
--
  paul beach
  [hidden email]


------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit.  See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Audacity-nyquist mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-nyquist
Reply | Threaded
Open this post in threaded view
|

Re: ;control widget documentation?

Stevethefiddle
Thanks for your reply Paul, but in this context I do not think that it refers to Adagio.
If you run the code that I posted you will see that "rate" when used in a ";control" line is equivalent to the current sample rate.

My question is that I can find no documentation about this (I would be happy to write something up on the Audacity wiki if anyone is able to provide definitive information about it).

I would also like to know if there are any other "keywords" that are specific to ";control".

Perhaps there are some comments in the source code about this, but I don't know what part of the source code is responsible for this.

I would have thought that someone must know the answer, but perhaps it was written by someone that is no longer involved with Audacity Nyquist. Any information would be much appreciated.

Steve
Reply | Threaded
Open this post in threaded view
|

Re: ;control widget documentation?

Paul Beach-2-3
Nyquist-Audacity impliments some instructions that have a MIDI name.
[rest, pitch = midi number, and so on]. This is limited, for example,
SINE cannot be use like hzosc.

I am trying rate, [ !rate 50 ]  cuts the tempo in half, a half note
should become a quarter note.

(seq
(rate 50 (sine 60 .2))
(sine 62 .1)
)


error: unbound function - RATE
if continued: try evaluating symbol again
Function: #<FSubr-LET*: #e40bd4>
Arguments:
  ((FIRST%SOUND (RATE 50 (SINE 60 0.2))) (S%RATE (GET-SRATES
  FIRST%SOUND)))
  (COND ((ARRAYP FIRST%SOUND) (SND-MULTISEQ (PROG1 FIRST%SOUND (SETF
  FIRST%SOUND NIL)) (FUNCTION (LAMBDA (T0) (FORMAT T "MULTISEQ's 2nd
  behavior: ~A~%" (QUOTE (SINE 62 0.1))) (WITH%ENVIRONMENT (QUOTE ((0 1
  NIL) 1 -1e+021 0 0 1e+021 2205 44100)) (AT-ABS T0 (FORCE-SRATES S%RATE
  (SINE 62 0.1)))))))) (T (SND-SEQ (PROG1 FIRST%SOUND (SETF FIRST%SOUND
  NIL)) (FUNCTION (LAMBDA (T0) (WITH%ENVIRONMENT (QUOTE ((0 1 NIL) 1
  -1e+021 0 0 1e+021 2205 44100)) (AT-ABS T0 (FORCE-SRATE S%RATE (SINE
  62 0.1)))))))))
--
  paul beach
  [hidden email]


------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit.  See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Audacity-nyquist mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-nyquist
rbd
Reply | Threaded
Open this post in threaded view
|

Re: ;control widget documentation?

rbd
paul beach wrote:
> Nyquist-Audacity impliments some instructions that have a MIDI name.
> [rest, pitch = midi number, and so on]. This is limited, for example,
> SINE cannot be use like hzosc.
>  
I don't understand your point. Very few functions in Nyquist are
identical. How would you expect SINE and HZOSC to be alike and in what
way do they fail to meet that expectation?
> I am trying rate, [ !rate 50 ]  cuts the tempo in half, a half note
> should become a quarter note.
>  
This notation comes from Adagio, an ascii notation for music that was
introduced in the CMU Midi Toolkit and ported to Nyquist in connection
with functions for standard MIDI file reading and writing. The rate
notation in Adagio is unrelated to Nyquist or XLISP.

> (seq
> (rate 50 (sine 60 .2))
> (sine 62 .1)
> )
>
>
> error: unbound function - RATE
> if continued: try evaluating symbol again
> Function: #<FSubr-LET*: #e40bd4>
> Arguments:
>   ((FIRST%SOUND (RATE 50 (SINE 60 0.2))) (S%RATE (GET-SRATES
>   FIRST%SOUND)))
>   (COND ((ARRAYP FIRST%SOUND) (SND-MULTISEQ (PROG1 FIRST%SOUND (SETF
>   FIRST%SOUND NIL)) (FUNCTION (LAMBDA (T0) (FORMAT T "MULTISEQ's 2nd
>   behavior: ~A~%" (QUOTE (SINE 62 0.1))) (WITH%ENVIRONMENT (QUOTE ((0 1
>   NIL) 1 -1e+021 0 0 1e+021 2205 44100)) (AT-ABS T0 (FORCE-SRATES S%RATE
>   (SINE 62 0.1)))))))) (T (SND-SEQ (PROG1 FIRST%SOUND (SETF FIRST%SOUND
>   NIL)) (FUNCTION (LAMBDA (T0) (WITH%ENVIRONMENT (QUOTE ((0 1 NIL) 1
>   -1e+021 0 0 1e+021 2205 44100)) (AT-ABS T0 (FORCE-SRATE S%RATE (SINE
>   62 0.1)))))))))
>  

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit.  See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Audacity-nyquist mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-nyquist
Reply | Threaded
Open this post in threaded view
|

Re: ;control widget documentation?

edgar-rft
In reply to this post by Stevethefiddle

Still unanswered question: the Audacity "rate" variable

The "rate" variable never was documented because it is a typical
Audacity short-brainer causing more problems than it does any good.

The "rate" variable only works only inside the header lines of an
Audacity Nyquist plugin, it represents the sample frequency of the
first selected Audacity track.

The "rate" variable badly messes-up things as soon as you apply a
Nyquist effect to more than only one selected Audacity tracks,
where the Audacity tracks have different sample rates.

The "rate" variable is only set once, before the plugin code is
applied to the first selected Audacity track, but in contrast to
the Nyquist *sound-srate* variable, the Audacity "rate" variable
NEVER gets updated with subsequent audio tracks.

It works much better if you specify a frequency either directly in
Hertz or in "percent" of the track's sample-rate and then compute
the exact "percents" in Herts out of the Nyquist *sound-srate*
variable for each track separately.

In one sentence: forget the "rate" variable as fast as you can.

- edgar



Original message was:

I notice that the word "rate" can be used as a parameter with slider widgets;
for example, the following plug-in will display the current sample rate:

;nyquist plug-in
;version 1
;type generate
;name "Show-SampleRate..."
;action "show ..."
;info "Show Sample Rate"
;control n "Sample Rate" int "Hz" rate 0 1000000

Is this documented anywhere?
Are there any other words that can be used in this way?




------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit.  See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Audacity-nyquist mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-nyquist
Reply | Threaded
Open this post in threaded view
|

FM signal sweep

Paul Beach-2-3
In reply to this post by Paul Beach-2-3
I want to convert a Generate, to an Effect plug-in. But fmosc does not
take a signal parameter. It is possible to FM sweep the signal?

(fmosc c  (pwl-list bi-list)) ; binomial filter
--
  paul beach
  [hidden email]


------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit.  See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Audacity-nyquist mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-nyquist
Reply | Threaded
Open this post in threaded view
|

Re: FM signal sweep

edgar-rft
 > Paul Beach wrote:
 >
 > I want to convert a Generate, to an Effect plug-in. But fmosc does
 > not take a signal parameter. It is possible to FM sweep the signal?
 >
 > (fmosc c  (pwl-list bi-list)) ; binomial filter

Could we have the complete context please?
And what are the exact Nyquist error messages?

Asks

- edgar

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit.  See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Audacity-nyquist mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-nyquist
Reply | Threaded
Open this post in threaded view
|

Re: FM signal sweep

Paul Beach-2-3
Transpose is a handy instruction to change the frequency in semitones.
Shift an a-note up an octave,
(transpose 12 (hzosc 220)) ; 12 semitones = an 8ve

But it has no Effect on a sinewave.
Generate plug-in, or Nyquist prompt:
(transpose 12 s)
does nothing and returns no error message.
--
  paul beach
  [hidden email]


------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit.  See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Audacity-nyquist mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-nyquist
rbd
Reply | Threaded
Open this post in threaded view
|

Re: FM signal sweep

rbd
Yes, that is correct and matches the documentation, except that I would
say (as does documentation) that transpose changes the environment in
which behaviors are evaluated, not sounds themselves. -Roger

paul beach wrote:
> Transpose is a handy instruction to change the frequency in semitones.
> Shift an a-note up an octave,
> (transpose 12 (hzosc 220)) ; 12 semitones = an 8ve
>
> But it has no Effect on a sinewave.
> Generate plug-in, or Nyquist prompt:
> (transpose 12 s)
> does nothing and returns no error message.
>  

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit.  See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Audacity-nyquist mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-nyquist
Reply | Threaded
Open this post in threaded view
|

utilities

Paul Beach-2-3
In reply to this post by Paul Beach-2-3
I don't see a mod function in the documentation; and presume it would be
done like this:

; mod ( n, d ) = n - d * int (n/d)

; 22 mod 5 = 2

(- 22 (* 5 (/ 22 5)))
Output 2
--
  paul beach
  [hidden email]


------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit.  See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Audacity-nyquist mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-nyquist
Reply | Threaded
Open this post in threaded view
|

Re: utilities

edgar-rft
paul beach asked:

 > I don't see a mod function in the documentation; and presume
 > it would be done like this:
 >
 > ; mod ( n, d ) = n - d * int (n/d)
 >
 > ; 22 mod 5 = 2
 >
 > (- 22 (* 5 (/ 22 5)))
 > Output 2

I have no particular knowledge how it works in SAL,
but XLISP has a REM function, see:

http://www.audacity-forum.de/download/edgar/nyquist/nyquist-doc/xlisp/xlisp-ref/xlisp-ref-217.htm

If you see in XLISP:

(rem expr1 expr2 ...)

then this should work in SAL like this:

rem(expr1, expr2, ...)

I know that REM is not 100% equal to MOD but as far
as I know there is no MOD function in XLISP or SAL.

- edgar








--
The author of this email does not necessarily endorse the following
advertisements, which are the sole responsibility of the advertiser:


------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit.  See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Audacity-nyquist mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-nyquist
Reply | Threaded
Open this post in threaded view
|

Number theory with Nyquist.

Paul Beach-2-3
Rem seems to be more general than mod. Should be useful for multiple
congruences,(the so-called Chinese remainder theory). Also there is a
(gcd a b), meaning greatest common divisor. Even though there is no MOD
statement, LISP seems to be superior with respect to NUMBER theory. Some
topics would be, primitive roots, quadratic residues, congruence.

Just checking that (rem a b) is the same as modulus:

Nyquist prompt:

(rem 22 5)     ; ==  22 mod 5

Output =2

Much better than this,

(- 22 (* 5 (/ 22 5))) ; no error checking!

Thank you very much.

On Thu, 24 Jun 2010 20:21:54 +0200, "edgar" <[hidden email]> said:

> paul beach asked:
>
>  > I don't see a mod function in the documentation; and presume
>  > it would be done like this:
>  >
>  > ; mod ( n, d ) = n - d * int (n/d)
>  >
>  > ; 22 mod 5 = 2
>  >
>  > (- 22 (* 5 (/ 22 5)))
>  > Output 2
>
> I have no particular knowledge how it works in SAL,
> but XLISP has a REM function, see:
>
> http://www.audacity-forum.de/download/edgar/nyquist/nyquist-doc/xlisp/xlisp-ref/xlisp-ref-217.htm
>
> If you see in XLISP:
>
> (rem expr1 expr2 ...)
>
> then this should work in SAL like this:
>
> rem(expr1, expr2, ...)
>
> I know that REM is not 100% equal to MOD but as far
> as I know there is no MOD function in XLISP or SAL.
>
> - edgar
>
>
>
>
>
>
>
>
> --
> The author of this email does not necessarily endorse the following
> advertisements, which are the sole responsibility of the advertiser:
>
>
> ------------------------------------------------------------------------------
> ThinkGeek and WIRED's GeekDad team up for the Ultimate
> GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
> lucky parental unit.  See the prize list and enter to win:
> http://p.sf.net/sfu/thinkgeek-promo
> _______________________________________________
> Audacity-nyquist mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/audacity-nyquist
--
  paul beach
  [hidden email]


------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit.  See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Audacity-nyquist mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-nyquist
Reply | Threaded
Open this post in threaded view
|

Re: Number theory with Nyquist.

edgar-rft
paul beach wrote:

 > Rem seems to be more general than mod. Should be useful for multiple
 > congruences,(the so-called Chinese remainder theory). Also there is a
 > (gcd a b), meaning greatest common divisor. Even though there is no MOD
 > statement, LISP seems to be superior with respect to NUMBER theory. Some
 > topics would be, primitive roots, quadratic residues, congruence.
 >
 > Just checking that (rem a b) is the same as modulus:
 >
 > Nyquist prompt:
 >
 > (rem 22 5)     ; ==  22 mod 5
 >
 > Output =2
 >
 > Much better than this,
 >
 > (- 22 (* 5 (/ 22 5))) ; no error checking!

I am not a really good mathematician to tell the truth,
but here is what the Common Lisp Standard says about the
difference between REM and MOD:

http://www.lispworks.com/documentation/HyperSpec/Body/f_mod_r.htm#rem

In one sentence: REM and MOD differ in their handling of
positive and negative numbers.

If both number have the same sign, both functions behave the same:

(rem 1 5) => 1
(mod 1 5) => 1

(rem -1 -5) => -1
(mod -1 -5) => -1

But if both numbers have unequal signs:

(rem -1 5) => -1
(mod -1 5) => 4

(rem 1 -5) => 1
(mod 1 -5) => -4

I'm afraid if this is important to you than there will be
no other way than to write a real-math solution.

I will try now to write a Lisp version out of these examples:
http://en.wikipedia.org/wiki/Modulo_operation

But do not expect too much...

- edgar



















--
The author of this email does not necessarily endorse the following
advertisements, which are the sole responsibility of the advertiser:


------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit.  See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Audacity-nyquist mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-nyquist
Reply | Threaded
Open this post in threaded view
|

Re: Number theory with Nyquist.

edgar-rft
In reply to this post by Paul Beach-2-3
Hi Paul,

After realizing that REM in XLISP is limited to integers only,
it was quite easy to write the missing MOD function:

(defun mod (x y)
   (cond ((not (integerp x)) (error "MOD - bad argument type" x))
         ((not (integerp y)) (error "MOD - bad argument type" y))
         ((zerop y) (error "MOD - division by zero"))
         ((or (and (>= x 0) (< y 0))  ; x is positive, y is negative
              (and (< x 0) (> y 0)))  ; x is negative, y is positive
          (+ x y))         ; unequal signs
         (t (rem x y))))   ; equal signs

With equal signs:

(rem 1 5) => 1
(mod 1 5) => 1

(rem -1 -5) => -1
(mod -1 -5) => -1

With unequal signs:

(rem -1 5) => -1
(mod -1 5) => 4

(rem 1 -5) => 1
(mod 1 -5) => -4

- edgar













--
The author of this email does not necessarily endorse the following
advertisements, which are the sole responsibility of the advertiser:


------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit.  See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Audacity-nyquist mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-nyquist
Reply | Threaded
Open this post in threaded view
|

Re: Number theory with Nyquist.

edgar-rft
In reply to this post by Paul Beach-2-3
As I said: I'm not a really good mathematician. The previous
MOD function only worked with one-digit numbers correctly.

Here's a better version:

(defun mod (x y)
   (cond ((not (integerp x)) (error "MOD - bad argument type" x))
         ((not (integerp y)) (error "MOD - bad argument type" y))
         ((zerop y) (error "MOD - division by zero"))
         ((or (and (>= x 0) (< y 0))  ; x is positive, y is negative
              (and (< x 0) (> y 0)))  ; x is negative, y is positive
          (+ (rem x y) y))  ; unequal signs
         (t (rem x y))))    ; equal signs


- edgar










--
The author of this email does not necessarily endorse the following
advertisements, which are the sole responsibility of the advertiser:


------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit.  See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Audacity-nyquist mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-nyquist
Reply | Threaded
Open this post in threaded view
|

Re: Number theory with Nyquist.

Paul Beach-2-3
Edgar, thank you for observations and code, but ...

Usually, writers prefer not to bother with a negative sign. Also, it is
also a bit awkward in Nyquist.

(1 mod 5) = 1 or -4.  Both mean the same, what you call an equivalance
relation. A minus sign is sometimes wanted, say for Legendre symbols.
But that is another topic. Changes to the source code, of course, can't
be taken lightly.  

Example: All primes are of the form,

4*k + 1
or
4*k - 1 = 4*k + 3

Nyquist is "corrected" to reject decimals. But if you look in a Number
theory book, there is usually a section, 'Decimal fractions'.


Thanks again, Paul

On Thu, 24 Jun 2010 23:54:00 +0200, "edgar" <[hidden email]> said:

> As I said: I'm not a really good mathematician. The previous
> MOD function only worked with one-digit numbers correctly.
>
> Here's a better version:
>
> (defun mod (x y)
>    (cond ((not (integerp x)) (error "MOD - bad argument type" x))
>          ((not (integerp y)) (error "MOD - bad argument type" y))
>          ((zerop y) (error "MOD - division by zero"))
>          ((or (and (>= x 0) (< y 0))  ; x is positive, y is negative
>               (and (< x 0) (> y 0)))  ; x is negative, y is positive
>           (+ (rem x y) y))  ; unequal signs
>          (t (rem x y))))    ; equal signs
>
>
> - edgar
>
>
>
>
>
>
>
>
>
>
> --
> The author of this email does not necessarily endorse the following
> advertisements, which are the sole responsibility of the advertiser:
>
>
> ------------------------------------------------------------------------------
> ThinkGeek and WIRED's GeekDad team up for the Ultimate
> GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
> lucky parental unit.  See the prize list and enter to win:
> http://p.sf.net/sfu/thinkgeek-promo
> _______________________________________________
> Audacity-nyquist mailing list
> [hidden email]
> https://lists.sourceforge.net/lists/listinfo/audacity-nyquist
--
  paul beach
  [hidden email]


------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit.  See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Audacity-nyquist mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-nyquist
Reply | Threaded
Open this post in threaded view
|

Number theory with Nyquist-remark #2

Paul Beach-2-3
I am happy with the source code, (last eMail). However, these
improvements could be made in a future version of Nyquist.

(rem-minus a b ) ; see Edgar's code.
(rem-decimal a b)

-paul
--
  paul beach
  [hidden email]


------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit.  See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Audacity-nyquist mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-nyquist
Reply | Threaded
Open this post in threaded view
|

Re: Number theory with Nyquist.

edgar-rft
In reply to this post by Paul Beach-2-3
Hi Paul (and all others),

As it turned out today, there was still a special case missing,
if the first argument is zero, the reault must be zero too.

Hopefully the final version:

(defun mod (x y)
   (cond ((not (integerp x)) (error "MOD - bad argument type" x))
         ((not (integerp y)) (error "MOD - bad argument type" y))
         ((zerop y) (error "MOD - division by zero"))
         ((zerop x) 0)  ; if x is zero, the result is zero
         ((or (and (> x 0) (> y 0))   ; x and y are positive
              (and (< x 0) (< y 0)))  ; x and y are negative
          (rem x y))             ; equal signs
         (t (+ (rem x y) y))))   ; unequal signs


- edgar








--
The author of this email does not necessarily endorse the following
advertisements, which are the sole responsibility of the advertiser:


------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit.  See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Audacity-nyquist mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-nyquist
rbd
Reply | Threaded
Open this post in threaded view
|

Re: Number theory with Nyquist.

rbd
In reply to this post by Paul Beach-2-3
I took a quick look at the XLISP implementation, and REM is directly
implemented by calling C's % operator on integers. It looks like REM
raises an error on FLONUM arguments.

SAL allows you to call REM as a function, e.g. rem(5, 2), or use the "%"
operator, e.g. 5 % 2.

-Roger

paul beach wrote:

> Rem seems to be more general than mod. Should be useful for multiple
> congruences,(the so-called Chinese remainder theory). Also there is a
> (gcd a b), meaning greatest common divisor. Even though there is no MOD
> statement, LISP seems to be superior with respect to NUMBER theory. Some
> topics would be, primitive roots, quadratic residues, congruence.
>
> Just checking that (rem a b) is the same as modulus:
>
> ...
>  

------------------------------------------------------------------------------
ThinkGeek and WIRED's GeekDad team up for the Ultimate
GeekDad Father's Day Giveaway. ONE MASSIVE PRIZE to the
lucky parental unit.  See the prize list and enter to win:
http://p.sf.net/sfu/thinkgeek-promo
_______________________________________________
Audacity-nyquist mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/audacity-nyquist
12