Add Waveform Options to Isochronic Modulator Plug-in

Share your Audacity/Nyquist plug-ins here, or test drive the latest plug-ins submitted by Audacity users.

After testing a plug-in from this forum, please post feedback for the plug-in author.

Add Waveform Options to Isochronic Modulator Plug-in

Permanent link to this post Posted by GendeDios » Tue Sep 14, 2010 9:34 pm

[
Hi.
I've found very interest The "Pulse Width" and "fade" control, I've tried add to this plugin the waveform option but really it leaves my hands, I don't have the knowledge to complete the code.

this is what I managed to modify:

Code: Select all

;nyquist plug-in
;version 1
;type process
;categories "http://lv2plug.in/ns/lv2core#ModulatorPlugin"
;name "IsoMod2..."
;action "Modulating..."
;info "Isochronic Modulator by Steve Daulton. GPL v.2\nhttp://easyspacepro.com\n\n'Pulse Width' controls the length of each pulse.\n'Fade Time' adjusts the fade in/out speed of the pulses.\nThe modulation speed/depth transforms gradually from\nthe initial settings to the final settings.\n\nPlug-in provided as an audio processing effect.\nThe author does not endorse or claim any relevance\nto the theory or practice of brainwave entertainment."

;control wave "Tremolo Shape" choice "sine,triangle,sawtooth,inverse sawtooth,square" 0
;control pw "Pulse Width [50%=Square]" real "%" 40 0 100
;control ft "Fade Time" real "%" 15 0 100
;control startf "Initial Modulation Frequency" real "Hz" 7 1 40
;control endf "Final Modulation Frequency" real "Hz" 2 1 40
;control starta "Initial Modulation Depth" int "%" 100 0 100
;control enda "Final Modulation Depth" int "%" 100 0 100

(setq pw (/ pw 100.0))
(setq  ft (/ ft 400.0))
(setq ft (* ft (min pw (- 1 pw)) 2))

; set tremolo *waveform*
(setq *waveform* (cond
   ((= wave 0) ; sine
   *sine-table*)
   ((= wave 1) ; triangle
   *tri-table*)
   ((= wave 2) ; sawtooth
   (abs-env (list (pwl 0 -1 .995  1 1 -1 1) (hz-to-step 1.0) t)))
   ((= wave 3) ; inverse sawtooth
   (abs-env (list (pwl 0 1 .995  -1 1 1 1) (hz-to-step 1.0) t)))
   (t ; square
   (abs-env (list (pwl ft 1 (- pw ft) 1 (+ pw ft) -1 (- 1 ft) -1 1 0)(hz-to-step 1.0) t)))   ;; doesn't work

;; Function to generate sweep tone
(defun sweep (sf ef)
     (mult 0.5 (sum 1.0 (fmlfo (pwlv sf 1.0 ef) *waveform*))))

(let* ((starta (/ starta 100.0))
   (enda (/ enda 100.0))
   (wet (pwlv starta 1 enda))
   (dry (sum 1 (mult wet -1))))
   (mult s (sum dry (mult wet (sweep startf endf)))))



Help me with sinewave form please.
Attached example for sine wave.
thank you.
]
Attachments
SineIsochronic.flac
(127.93 KiB) Downloaded 132 times
GendeDios
 
Posts: 32
Joined: Mon May 03, 2010 7:39 pm

Re: Add Waveform Options to Isochronic Modulator Plug-in

Permanent link to this post Posted by steve » Tue Sep 14, 2010 11:19 pm

The "Pulse Width" code will not work with the other waveforms.
The way that it works with the "Square wave" is that the code creates a custom waveform:
Code: Select all
(pwl ft 1 (- pw ft) 1 (+ pw ft) -1 (- 1 ft) -1 1 0)

This simply creates a line that goes up, then along a bit, then down, then along a bit and then up again.

The pwl function is described here: http://www.cs.cmu.edu/~rbd/doc/nyquist/ ... l#index376

On the other hand, the sine waveform is created using a predefined wavetable that is built into Nyquist, so the shape of the wave is fixed.
To create a series of sine pulses (as in your example) requires that space is inserted between each cycle of the waveform - I presume that you created the SineIsochronic.flac file by inserting silence manually?

The alternative method would be to create a custom wave shape for "sine pulses". This could probably be achieved by generating a single cycle sine wave, and adding it to a longer length of silence. The length of the silence would determine the spaces between the pulses. This custom curve would then be used to create a *wavetable* for the tremolo oscillator (fmlfo).

Your code for having the other waveforms as well as the pulse waveform is very nearly right. You've just missed a couple of parentheses off the end of line 33 (I'm forever making errors like that :) )

Your line:
Code: Select all
   (abs-env (list (pwl ft 1 (- pw ft) 1 (+ pw ft) -1 (- 1 ft) -1 1 0)(hz-to-step 1.0) t)))   ;; doesn't work

should be:
Code: Select all
   (abs-env (list (pwl ft 1 (- pw ft) 1 (+ pw ft) -1 (- 1 ft) -1 1 0)(hz-to-step 1.0) t)))))   ;; does work


For working with Nyquist you really need a text editor that has parentheses matching. If you're on Windows a really good editor (free) is Notepad++

I'll have a look at sine pulses when I get time, but it's late now.

If you look at how "pwl" works you may be able to work out how to create sawtooth and inverse sawtooth pulses.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Senior Forum Staff
 
Posts: 32940
Joined: Sat Dec 01, 2007 11:43 am

Re: Add Waveform Options to Isochronic Modulator Plug-in

Permanent link to this post Posted by GendeDios » Wed Sep 15, 2010 3:43 am

[

stevethefiddle wrote:The "Pulse Width" code will not work with the other waveforms.
The way that it works with the "Square wave" is that the code creates a custom waveform:
Code: Select all
(pwl ft 1 (- pw ft) 1 (+ pw ft) -1 (- 1 ft) -1 1 0)



Ok, agree, I follow you.


stevethefiddle wrote:On the other hand, the sine waveform is created using a predefined wavetable that is built into Nyquist, so the shape of the wave is fixed.


*sine-table* ...ok.

stevethefiddle wrote:To create a series of sine pulses (as in your example) requires that space is inserted between each cycle of the waveform - I presume that you created the SineIsochronic.flac file by inserting silence manually?


Of course, manually.

stevethefiddle wrote:The alternative method would be to create a custom wave shape for "sine pulses". This could probably be achieved by generating a single cycle sine wave, and adding it to a longer length of silence. The length of the silence would determine the spaces between the pulses. This custom curve would then be used to create a *wavetable* for the tremolo oscillator (fmlfo).


Genial.


stevethefiddle wrote:Your code for having the other waveforms as well as the pulse waveform is very nearly right. You've just missed a couple of parentheses off the end of line 33 (I'm forever making errors like that :) )

Your line:
Code: Select all
   (abs-env (list (pwl ft 1 (- pw ft) 1 (+ pw ft) -1 (- 1 ft) -1 1 0)(hz-to-step 1.0) t)))   ;; doesn't work

should be:
Code: Select all
   (abs-env (list (pwl ft 1 (- pw ft) 1 (+ pw ft) -1 (- 1 ft) -1 1 0)(hz-to-step 1.0) t)))))   ;; does work


For working with Nyquist you really need a text editor that has parentheses matching. If you're on Windows a really good editor (free) is Notepad++


;)

stevethefiddle wrote:I'll have a look at sine pulses when I get time, but it's late now.


Ok, you are very kind thanks Steve.

]
GendeDios
 
Posts: 32
Joined: Mon May 03, 2010 7:39 pm

Re: Add Waveform Options to Isochronic Modulator Plug-in

Permanent link to this post Posted by steve » Wed Sep 15, 2010 4:23 pm

Here's some code that will produce a wavetable with a 50% sine pulse.
Note that unlike the other wavetables this one is all in the positive half of the waveform, so you don't need
Code: Select all
(mult 0.5 (sum 1.0 ..... ))
in the "sweep" function.

Code: Select all
(setq duration 0.5)

(abs-env
   (progn
   ;; half sine wave
   ;(setq si (abs-env (osc (hz-to-step 1.0) duration *sine-table* 0)))

   ;; full sine wave
   (setq si (mult 0.5 (sum 1 (osc (hz-to-step 2.0) duration *sine-table* 270))))

   ;; add silence
   (setq pulse (sim si (s-rest 1)))

   ;; create wavetable
   (setq *waveform* (list pulse (hz-to-step 1) T))))

; test it
;(osc 69 1 *waveform*)
(mult s (fmlfo (pwlv 20 1.0 10) *waveform*))
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Senior Forum Staff
 
Posts: 32940
Joined: Sat Dec 01, 2007 11:43 am

Re: Add Waveform Options to Isochronic Modulator Plug-in

Permanent link to this post Posted by GendeDios » Thu Sep 16, 2010 8:48 pm

[
Your code is accurate. But I could not merge the varibles ft and pw in. My little knowledge not let me do it.
too, I unknown why modulation deep doesn't work like should be.

This is what I could change:
Code: Select all
;nyquist plug-in
;version 1
;type process
;categories "http://lv2plug.in/ns/lv2core#ModulatorPlugin"
;name "IsoMod3..."
;action "Modulating..."
;info "Isochronic Modulator by Steve Daulton. GPL v.2\nhttp://easyspacepro.com\n\n'Pulse Width' controls the length of each pulse.\n'Fade Time' adjusts the fade in/out speed of the pulses.\nThe modulation speed/depth transforms gradually from\nthe initial settings to the final settings.\n\nPlug-in provided as an audio processing effect.\nThe author does not endorse or claim any relevance\nto the theory or practice of brainwave entertainment."

;control wave "Tremolo Shape" choice "sine,square" 0
;control pw "Pulse Width [50%=Square]" real "%" 40 0 100
;control ft "Fade Time" real "%" 15 0 100
;control startf "Initial Modulation Frequency" real "Hz" 7 1 40
;control endf "Final Modulation Frequency" real "Hz" 2 1 40
;control starta "Initial Modulation Depth" int "%" 100 0 100
;control enda "Final Modulation Depth" int "%" 100 0 100

(setq pw (/ pw 100.0))
(setq  ft (/ ft 400.0))
(setq ft (* ft (min pw (- 1 pw)) 2))

; set tremolo *waveform*
(setq *waveform* (cond
   ((= wave 0) ; sine
   (setq duration 0.5)
   (abs-env
   (progn
   ;; half sine wave
   ;(setq si (abs-env (osc (hz-to-step 1.0) duration *sine-table* 0)))

   ;; full sine wave
   (setq si (mult 0.5 (sum 1 (osc (hz-to-step 2.0) duration *sine-table* 270))))

   ;; add silence
   (setq pulse (sim si (s-rest 1)))

   ;; create wavetable
   (setq *waveform* (list pulse (hz-to-step 1) T)))))
   
   ; test it
   ;(osc 69 1 *waveform*)
   (mult s (fmlfo (pwlv 20 1.0 10) *waveform*))   

   (t ; square
   (abs-env (list (pwl ft 1 (- pw ft) 1 (+ pw ft) -1 (- 1 ft) -1 1 0)(hz-to-step 1.0) t)))))

;; Function to generate sweep tone
(defun sweep (sf ef)
     (mult 0.5 (sum 1.0 (fmlfo (pwlv sf 1.0 ef) *waveform*))))

(let* ((starta (/ starta 100.0))
   (enda (/ enda 100.0))
   (wet (pwlv starta 1 enda))
   (dry (sum 1 (mult wet -1))))
   (mult s (sum dry (mult wet (sweep startf endf)))))


Where put this piece for sine?
Code: Select all
ft 1 (- pw ft) 1 (+ pw ft) -1 (- 1 ft) -1 1 0


Thank you.
]
GendeDios
 
Posts: 32
Joined: Mon May 03, 2010 7:39 pm

Re: Add Waveform Options to Isochronic Modulator Plug-in

Permanent link to this post Posted by GendeDios » Sat Sep 18, 2010 3:56 am

[
I could fix Modulation depth. And thinking ...doesn't necessary modify the pulse width, like this be accurate.

Code: Select all
;control startf "Initial Modulation Frequency" real "Hz" 7 0.1 40
;control endf "Final Modulation Frequency" real "Hz" 14 0.1 40
;control starta "Initial Modulation Depth" int "%" 100 0 100
;control enda "Final Modulation Depth" int "%" 100 0 100



   (setq duration 0.5)
   
   (abs-env
   (progn
   ;; half sine wave
   ;(setq si (abs-env (osc (hz-to-step 1.0) duration *sine-table* 0)))

   ;; full sine wave
   (setq si (mult 0.5 (sum 1 (osc (hz-to-step 2.0) duration *sine-table* 270))))

   ;; add silence
   (setq pulse (sim si (s-rest 1)))

   ;; create wavetable
   (setq *waveform* (list pulse (hz-to-step 1) T))))
   
   ; test it
   ;(osc 69 1 *waveform*)
   (mult s (fmlfo (pwlv 20 1.0 10) *waveform*))   

;; Function to generate sweep tone
(defun sweep (sf ef)
     (mult 0.5 (sum 1.0 (fmlfo (pwlv sf 1.0 ef) *waveform*))))

(let* ((starta (/ starta 50.0))
   (enda (/ enda 50.0))
   (wet (pwlv starta 1 enda))
   (dry (sum 1 (mult wet -1))))
   (mult s (sum dry (mult wet (sweep startf endf)))))


Sine Isochronic Modulator was done as a separate plug-in.
What rule I should follow to publish it like new plugin?

Thanks.
]
GendeDios
 
Posts: 32
Joined: Mon May 03, 2010 7:39 pm

Re: Add Waveform Options to Isochronic Modulator Plug-in

Permanent link to this post Posted by steve » Sat Sep 18, 2010 11:36 am

Congratulations GendeDios, you have made it work :)
So there is now the question of the modulation depth, which you have noticed is not quite correct.

Would you prefer that I just fix it so that you can use the effect, or would you prefer that I explain how the code functions so that you can make your own modifications?

I had not heard of Isochronic beats, but I assume that the sine wave pulses are the best type of modulation? (you don't need the other *waveform* wave shapes?)

GendeDios wrote:What rule I should follow to publish it like new plugin?

Sorry, I don't understand.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Senior Forum Staff
 
Posts: 32940
Joined: Sat Dec 01, 2007 11:43 am

Re: Add Waveform Options to Isochronic Modulator Plug-in

Permanent link to this post Posted by GendeDios » Sat Sep 18, 2010 9:40 pm

[
I love programming, it is my first experience in the field of sound, I'd want to know how work each instruction code, but I have the head in another place, I have planned in the future to collaborate on a project or create a new project that involves using sound free software, in that time I hope to have ready all my knowledge.

I appreciate if you can fix the code, I've task to learn the Nyquist language.

If it's not very complicated and you can do the other *waveform* wave shapes, it would be fantastic, experience the brain entrainment with all possible waveforms is very interesting for me.

"What rule I should follow to publish it like new plugin?" I mean if is there a place to register the new plug-ins and if exist rules for do it.

Thanks for everything
]
GendeDios
 
Posts: 32
Joined: Mon May 03, 2010 7:39 pm

Re: Add Waveform Options to Isochronic Modulator Plug-in

Permanent link to this post Posted by steve » Wed Sep 22, 2010 7:02 pm

Sorry about the delay GendeDios, I've been a bit short of time, but here's some bits that can be used as the modulation wave. You may like to have a play with this and see if you can work out what it's doing and how. I'll get back to you about how to integrate this into the main effect.

Steve

Code: Select all

;control wave "Pulse Type" choice "Sine,Triangle,Square" 0
;control hz "Frequency" real "Hz" 10 0.01 100
;control pw "Pulse Width" real "%" 30 1 100
;control var "Pulse Variation (bias)" real "%" 50 0 100

;limit input variables to sensible range
(defun sanitise (val minv maxv)
  (min (max val minv) maxv))

;; limit max frequency to 1/2 nyquist frequency
(setq pitch (hz-to-step (sanitise hz 0.01 (/ *sound-srate* 4.0))))

;; To prevent aliasing from occurring pulses the pulses must
;; be a reasonable length
(setq pw (/ (sanitise pw 1 100) 100.0))

  ;; avoid division by zero errors
(setq var (sanitise (/ var 100.0) 0.01 0.99))

;;; Define wavetables in functions

;'Sine' pulse wave-table
(defun sinewav (width bias)
  (setf pulse (seq
    (osc (hz-to-step (/  (* 2  bias width))) (* bias width) *sine-table* 270)
    (osc (hz-to-step (/  (* 2 (- 1 bias) width))) (* (- 1 bias) width) *sine-table* 90)))
  (setf pulse (sum 0.5 (mult 0.5 pulse)))
  (abs-env(list (sim pulse (s-rest 1))(hz-to-step 1) T)))

(defun triwav (width bias)
  (setq bias (* 2 (- 0.5 bias)))
  (setq width (/ width 2.0))
  (setq bias (* bias width))
  ;make pulse shape
  (setq pulse (pwl (- width bias) 1 (* width 2) 0 1 0))
  ;make wave-table
  (abs-env (list pulse (hz-to-step 1.0) t))) 

(defun sqwav (pw ft)
  ; fade time = half variation (allow for fade-in + fade-out)
  (setq ft (/ ft 2.0))
  ;fade time as proportion of pulse width
  (setq ft (* pw ft))
  ;make pulse shape
  (setq pulse (pwl ft 1 (- pw ft) 1 pw 0 1 0))
  ;make wave-table
  (abs-env (list pulse (hz-to-step 1.0) t)))

; select required wavetable
(setq *waveform*(case wave
  (0 (sinewav pw var))
  (1 (triwav pw var))
  (T (sqwav pw var))))

(osc pitch 20 *waveform*)
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)
steve
Senior Forum Staff
 
Posts: 32940
Joined: Sat Dec 01, 2007 11:43 am

Re: Add Waveform Options to Isochronic Modulator Plug-in

Permanent link to this post Posted by GendeDios » Thu Sep 23, 2010 6:04 pm

I see that pulse variation (bias) only works to triangle wave, but is great for this wave form.

Don't worry, the issue going genial, I really like. Take all the time you need brother.
GendeDios
 
Posts: 32
Joined: Mon May 03, 2010 7:39 pm

Next

Return to New Plug-Ins



Who is online

Users browsing this forum: No registered users and 3 guests