Hi folks,
A significant DSP speed-up without memory problems.
Once again the link to the distortion tutorial, where the
usage of the
shape function is explained by Roger Dannenberg:
http://www.audacit
y-forum.de/download/edgar/nyquist/nyquist-doc/examples/rbd/0
2-distortion.htm
It has turned out that creating a sound from a shape
function stored in
an array is much easier than I had expected. By using
'snd-from-array'
there is no need to transform the array into a wavetable
first. The
following is in principle the same game like with the DSP
plugin from
a few days ago.
I have written a basic sceleton with in the middle of the
code a line:
(- 1.0 (* step-size i))
This line produces a shape function, which inverts the
Audacity track
[turns the wavform 'upside-down']. The DSP function is
stored in an
array, where the y axis [represented by the array values] is
from -1.0
to +1.0, while on the x axis the left limit [-1.0] is at
array index 0
[zero] while the right limit [+1.0] is array index
'array-size'.
On the x axis there are 'array-size' steps from the left
[-1.0] to the
right [+1.0] limit, the size of a single step is stored in
the variable
'step-size'. Both values [array-size and step-size] are
automatically
computed out of the actual sample frequency of the Audacity
track. The
zero point of the x axis is at an offset of (/ array-size
2.0).
All you need to do is to transform your DSP function into
appropriate
array values and start the plugin, which runs lightspeed
faster than
the single-step DSP code via the XLISP object system. There
also is no
memory allocation problem with this plugin any more, so you
can use it
to write plugins for practical work on Audacity tracks on
any length
without being afraid of memory limits.
There also are options to show the transformation function
as a sound
from the array in the Audacity track and to display the
values of the
'array-size' and 'step-size' variables in an pop-up window.
--- start of the plugin code ---
;nyquist plug-in
;version 3
;type process
;name "Shape..."
;action "Performing Shape Effect..."
;control what "Choose:" choice "Apply
effect,Show function,Show variables" 0
(setf *gc-flag* nil) ; no garbage collector messages
please
;; *sound-srate* is the sample frequency of the Audacity
track
;; array-size is the number of all steps from -1.0 to
+1.0
;; step-size is the size of a single step
;; Because 0 [zero] in physics is NOT a positive number like
wrongly
;; handled in most computer programming languages we need a
sound of
;; two seconds length PLUS one sample
;; because *sound-srate* is a float but arrays cannot be
initialized
;; by using floats we must use the truncate function to make
array-size
;; become an integer
(setf array-size (+ (* (truncate *sound-srate*) 2) 1))
(setf step-size (/ 1.0 *sound-srate*))
;; make shape-array a local variable so the memory can be
freed
;; if neccessary during the shape transformation process
;;
(when (< what 2)
(let ((shape-array (make-array array-size)))
;; fill the array with the transformation data
(dotimes (i array-size)
(setf (aref shape-array i)
;;
;; replace the following line with your own
function[s]
;;
(- 1.0 (* step-size i))
))
;; turn the filled array into a sound
(setf *shape* (snd-from-array 0.0 *sound-srate*
shape-array))))
(defun shape-transform (snd)
(shape snd *shape* 1.0))
(cond ((= what 0) (shape-transform s))
((= what 1) *shape*)
((= what 2) (format nil "Array size: ~a~%Step
size: ~a~%"
array-size step-size)))
--- end of the plugin code ---
have fun,
- edgar
--
The author of this email does not necessarily endorse the
following advertisements, which are the sole responsibility
of the advertiser:
____________________________________________________________
_________
Der WEB.DE SmartSurfer hilft bis zu 70% Ihrer Onlinekosten
zu sparen!
http://smartsurfer.web.de/?mc=100071&dis
tributionid=000000000066
------------------------------------------------------------
-------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
a>
_______________________________________________
Audacity-nyquist mailing list
Audacity-nyquist lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/audaci
ty-nyquist
|