Dinamically access audio in nyquist

What’s the null operation for reconstructing audio:

  • Sample by sample
  • Slice by Slice
    Any example code for this (null) process?:
    audio input—>read sample/slice—>sequenciate read—> sequence output
    || || ||
    audio —> do nothing —> sameaudio

The reason I ask this is because I’m strugling at processing audio in a time dependent manner with sal/lisp, hence I’m being unable to control my effects in a sample dependent way, which prevents me from doing things as fade ins, time warps, or any other automated transition, for example.

; The selected audio is passed to Nyquist in the special variable *track*
; We can assign it to another variable, in this case the variable "audio":
(setf audio *track*)

; Return the value of the "audio" variable

To access individual samples, we can use the function snd-fetch.

Warning: Use a very short selection (less than 0.1 seconds) for testing this or it will be extremely slow.

This code will read successive samples of a mono track and print their values to the debug window:

;debugflags trace
(do ((val (snd-fetch *track*)(snd-fetch *track*)))
    ((not val) "")
  (print val))

I know that, but whatever you name it, it will be still a sound unless you convert it to array with snd-sample, then god guess all the cryptic parameters needed for convert it back to sound after processing, something that python audio does in a crack.

I have a plugin still in development state because I’m having trouble concatenating array slices, and I spent a whole day in it. I’ve been avoiding doing dynamic processing in nyquist for years up to now.

that’s awsome, now put that sample back in sound. And please let me myself handle the loopm don’t feed it to me, I want it hard but simple.

See my answer to your parallel topic.

how do I debug a single value in order to know the environment?
your function does it for me replacing val in the print function for whatever value, but it’s repeated fetch times.

I’ve no idea what you mean. Perhaps you could give an example.

I mean how do I print the value of a variable ?

Say you have a variable “VAR” with a value of 42:
(print var)
will print 42.

Or with a string value:

(setf var "Hello World")
(print var)

will print “Hello World”.

Note that by default, Audacity only displays the return value (the value that is returned by the Nyquist code when the code completes running). To see printed output that is produced as the code runs, you need to look in the Debug window.


(setf val 3)
(print 1)
(print "two")
(print val)

returns the value “3”, which is displayed by Audacity.
In the Debug window you should see: