# shape filter

Hello.
Among Nyquist filters, there is filter “shape”?.
I would like to ask a question:
Is this filter a pulse shaping filter like “Sinc shaped filter” or “Gaussian filter”?
Thank you.

Are you referring to this: http://www.cs.cmu.edu/~rbd/doc/nyquist/part8.html#index453

Hello.
Yes. It is strange. “shape” is presented like a function (“…A waveshaping function.”)

Yes, it’s a function. Think of the verb “to shape something” rather than a noun “a shape”.
The function “shapes” the waveform that it is applied to - in other words it “modifies the shape” of the waveform.

The “table” argument provides a lookup table. The function takes the value of each sample in turn, and looks up the output value in the table.

Thank you.
I wrote this code:

``````(defun mytable ()
(amosc (hz-to-step 440) (hzosc 1)))

(stretch-abs 4 (shape  (osc 55) (mytable) 3.0))
``````

I don’t know if the obtained effect corresponds to an usual use of this function (SHAPE). The result is strange. There are too many harmonics sounds.
Can you indicate to me if the code is correct?
Beforehand thank you.

There are no code errors in that, but I’ve no idea what you are trying to do.

Normally the “shape” table would be very simple, for example:

``````(abs-env (pwlv -1 0.5 -0.8 1.5 0.8 2 1 2.1 1))
``````

which you would then use with an offset of 1.

Try applying that to a sine wave with amplitude 1.0, using this code:

``````(setf shape-table (abs-env (pwlv -1 0.5 -0.8 1.5 0.8 2 1 2.1 1)))
(shape *track* shape-table 1)
``````

Thank you.
I try to understand the following point.
In the presentation of the shape function, R.B. Dannenberg specifies that this function is a waveshaping function.
In this case, it is about synthesis by not linear distortion? If it is the case, the waveshaping should add to the sound of origin complementary harmonics sounds.
But, look at this code:

``````(defun mytone ()
(amosc (hz-to-step 195.997) (hzosc 1.5)))
(defun envshaper ()
(mult (sum 1 (hzosc (const (/ 1.0 2.0) 2) *table* 270)) 0.5))
(stretch-abs 4 (shape (mytone) (envshaper) 1))
``````

I used the function(ENVSHAPER) by borrowing it from R.B. Dannenberg (Shepard Tones Exemple).
The problem is the following one: the wave generated by this code is hardly richer in harmonics than a sinusoidal wave.

My question is the following one: how we can to strengthen the intensity of the harmonics sounds which are created?

On the image to the right the wave distorted by the SHAPE function, to the left a sinusoïdal wave.

For an example of using SHAPE, see here:
https://forum.audacityteam.org/t/distortion-effect/33184/1

Thank you.
The plug- in is interesting to understand how to use the function SHAPE.
I try to understand this passage of Nyquist Reference Manual (shape signal table origin) [LISP]:
“… The output at time t is: table(origin + clip(signal(t)) where clip(x) = max(1, min(-1, x)).”
It seems to me that it is written in SAL. Thus my question is the following one: could you rewrite in LISP this passage?
Beforehand thank you.

It’s not SAL. It is describing the behaviour mathematically.

It is saying, that for each input value 'x", clipped to a range of +/- 1,
the output is looked up from the table, offset by the stated amount.

For example:

If the length of the table waveform = 2, and the “origin” (as in the origin of a graph is where the aces cross) is at 1,
then for an input sample “x” = -0.4, the output value will be read from the table at (offset - 0.4) = 0.6. So the output value is read from the table at time = 0.6

Hello.
Thank you.
From the code of the plugin we can write for example:

``````(defun quantable (val)
(setq val   (round  (- 104 val)))
(abs-env
(quantize (pwlv -1 2 1 2.1 1)  val)))

(abs-env
(shape (osc 55)(quantable 100) 1.0))
``````

We observe that the sound result can be different only by changing the value of “val” one or two units.
But, there is something that I does not understand. What is the utility to use the function ROUND?
If we not use not this function, the sound result, the tone quality of the sound wave is the same.
It is strange.

http://www.cs.cmu.edu/~rbd/doc/nyquist/part8.html#index337

The “steps” argument of “quantize” must be an integer: Nyquist Functions

Thank you.
I would like to quote the NYQUIST Reference Manual (chapter: Table-Lookup Oscillator Functions).
R B Danneberg indicates that we can also use functions (snd-… for exemple (snd-fmosc
There is a problem with this function.
I write this code:

``````(abs-env (normalize
(snd-fmosc (osc 69)   *sound-srate*  440 0. 5 90) ))
``````

The manual indicates for this function:(snd-fmosc s step sr hz t0 fm phase)
It is thus necessary to give a value for the parameter “phase”.
The problem is the following one: it is impossible to give a value which Nyquist prompt accepts.

``````error: bad argument type - 90
Function: #<Subr-SND-FMOSC: #aaca608>
Arguments:
#<Sound: #b2eb6b8>
44100
440
0
5
90
Arguments:
(QUOTE (*WARP* *LOUD* *TRANSPOSE* *SUSTAIN* *START* *STOP* *CONTROL-SRATE* *SOUND-SRATE*))
(LIST (QUOTE (0 1 NIL)) 0 0 1 MIN-START-TIME MAX-STOP-TIME *DEFAULT-CONTROL-SRATE* *DEFAULT-SOUND-SRATE*)
(NORMALIZE (SND-FMOSC (OSC 69) *SOUND-SRATE* 440 0 5 90))
1>
``````

My question is the following one: is there a bug?
Beforehand thank you for your help.

The bugs are in your code:

``````(snd-fmosc s step sr hz t0 fm phase)
``````

You have missed out the “step” parameter, and “fm” must be a sound.

He also says: "You should use fmosc instead "
http://www.cs.cmu.edu/~rbd/doc/nyquist/part8.html#index788

Hello.

``````(defun wiggle (val)
(setq val (+ 0.5 (round (/ val 10.0))))
(abs-env (lfo val 2)))

(abs-env
(shape (osc 55)(wiggle 100) 1.0)))
``````

This code generates a sound wave with the distortion. I observed the sound wave. It is complex in certain places.
If we zoom a lot, we observe that samples appears in a mess to the passages where the wave is the least regular.
I ask myself this novice’s question: why is the generated wave so bitter? Does it come because the generated wave is complex?