Low level Nyquist programming.

Hello, My name is Eugeni and I’m new in nyquist. I chose Nyquist to make a little job for my university and I would like to learn how to program in Nyquist. specifically, i would know if a can program Nyquist in low level, “near the hardware” or using something like syscalls.

I hope you can help me.

Everything you can say is welcome.

thanks.


Eugeni

Nyquist is a high level language based on XLisp.
I think the DSP primitives are mostly written in C.

Nyquist is available as a standalone version or integrated in Audacity.
The standalone version of Nyquist is available from here: http://www.cs.cmu.edu/~music/music.software.html
The Audacity source code is available from here: http://code.google.com/p/audacity/source/checkout (or you can browse the code here: http://code.google.com/p/audacity/source/browse/audacity-src/trunk

There is some information about extending Nyquist here: http://www.audacity-forum.de/download/edgar/nyquist/nyquist-doc/manual/part14.html#143

Programming in Nyquist itself is relatively simple, but as stated it is a high level language. To get down into the low level “near hardware” stuff you will need to get into the source code.

A good place to start with Nyquist programming is here: http://audacityteam.org/help/nyquist
and here: http://www.audacity-forum.de/download/edgar/nyquist/nyquist-doc/devel/audacity-nyquist-en.htm

From Programar en Nyquist.

I believe Nyquist 3 is supported by Audacity 1.3.8 or later, but not tested much.


Gale

I think that the version of Nyquist in Audacity 1.3.12 is Nyquist 3.03, or to be more precise, a sub-set of Nyquist 3.03 (a few parts of Nyquist are not included in Audacity)

Yes, but the “new” nyquist is not based in LISP , isn’t it? I want to work with the version closest to the hardware, syscalls etc…

Yes, it is still based on XLisp.

The “New” Nyquist has “Sal” added, but you can still use XLisp if you prefer.
I use the XLisp notation because I am more familiar with it than the Sal notation.

When a Nyquist script that is written in Sal is run, the Sal commands are translated into XLisp commands and the XLisp commands.
When a Nyquist script is written in XLisp, the commands are run directly.
You can use either Sal or XLisp.

Ok, and then…It is better to program with the latest version of Nyquist? I found in the previous version a part called “low level functions”, and I think it’s perfect for my work.


thanks.

Eugeni

The “low level functions” are still not very close to the hardware, but they are one layer closer than other functions.
For example, if you use the function (highpass2) in a Nyquist script, this is a high level function that is designed for Nyquist authors to use in their scripts.
If you look in the file “dsprims.lsp” (in the nyquist folder), you will find that the “highpass2” function is defined as:

(defun highpass2 (x hz &optional (q 0.7071))
  (multichan-expand #'nyq:highpass2 x hz q))

so the basis of (highpass2) is the function “nyq:highpass2”

in turn, “nyq:highpass2” is defined as:

(defun nyq:highpass2 (x hz q)
  (let* ((w (* 2.0 Pi (/ hz (snd-srate x))))
         (cw (cos w))
         (sw (sin w))
         (alpha (* sw (sinh (/ 0.5 q))))
         (a0 (+ 1.0 alpha))
         (a1 (* -2.0 cw))
         (a2 (- 1.0 alpha))
         (b1 (- -1.0 cw))
         (b0 (* -0.5 b1))
         (b2 b0))
    (nyq:biquad-m x b0 b1 b2 a0 a1 a2)))

and “nyq:biquad-m” is defined as:

(defun nyq:biquad-m (x b0 b1 b2 a0 a1 a2)
  (nyq:biquad x b0 b1 b2 a0 (- a1) (- a2)))

and “nyq:biquad” is defined as:

(defun nyq:biquad (x b0 b1 b2 a0 a1 a2)
  (let ((a0r (/ 1.0 a0)))
    (snd-biquad x (* a0r b0) (* a0r b1) (* a0r b2) 
                             (* a0r a1) (* a0r a2) 0 0)))

so ultimately it comes down to “snd-biquad” which is the low level function, coded directly into Audacity/Nyquist
The actual source code “snd-biquad” is in /lib-src/libnyquist/nyquist/tran/

See here for descriptions of low level functions: http://www.audacity-forum.de/download/edgar/nyquist/nyquist-doc/manual/part6.html#57