Page 2 of 3

Re: Molding a tone to a given audio sample (matching silence

Posted: Fri May 01, 2009 7:12 pm
by Trebor
seanybob wrote: I went ahead and tried this. I played with the settings quite a bit, but the best I could get it to do was to silence the unwanted tones in the front, and half of them in the end - it had no effect on those in between the signals I want to keep, or the first half of the end.
I didn’t quite appreciate how unlike audio your signals are: 19KHz is inaudible to most people, and your pulses are only about a millisecond long.

Ggate was designed to deal with audio, this may explain why it could not silence parts of your signal : its response time may not be quick enough to cope with millisecond pulses.
seanybob wrote:I'll keep playing around with it.
For your purposes the attack and fade times on GGate should both be set to "zero", only experimenting with threshold value.
If that doesnt work then its down to Nyquist code, or possibly a hardware solution with a quicker respose time like a transistor gate.

[Re: hardware solution: I’ve seen similar pulse width modulation done with cheapo 555 timers, although the output was square not sine.
e.g http://www.dprg.org/tutorials/2005-11a/index.html, http://www.eleinmec.com/article.asp?28]

Half-wave rectification ?

Posted: Fri May 01, 2009 7:50 pm
by Trebor
If you performed half-wave rectification on the square wave before using Steve’s Amplitude Modulation code that may help.
Here is a bit of Nyquist code which allegedly performs half-wave rectification returning only the positive half cycles of signal …
; pos neg and rectify functions by Steven Jones
; http://www.shellworld.net/~davidsky/sj-plugs.htm

; Return only the positive half cycles of signal
(defun pos (signal)
(if (arrayp signal)
(vector (s-max (aref signal 0) 0.0) (s-max (aref signal 1) 0.0))
(s-max signal 0.0)))
http://n2.nabble.com/New-plug-in:-Self- ... 93146.html

May contain a clue to the solution.

Re: Molding a tone to a given audio sample (matching silence

Posted: Tue May 05, 2009 11:49 pm
by seanybob
Been working on this issue for several days now. Don't have much progress to report. I started coding other LISP programs though (to get me more familiar with the language) so expect progress soon.

Let me know if any new thoughts strike you :)

Positive Half Wave Rectification, Eureka !

Posted: Wed May 06, 2009 2:07 pm
by Trebor
I have butchered one of David Sky's plugins to produce the positive half wave rectification required, (guess where I have applied it in this waveform)
HalfWaveRectified.png
HalfWaveRectified.png (41.17 KiB) Viewed 2223 times
I have attached a zip file containing the aforementioned butchered plugin which I have called "Half Wave Rectifier (+ve)" which should appear on the (unsorted*) effects list after you extract the file (unzip) and place the "HalfWaveRectifier(Pos).NY" file in Audacity's plug in folder then restart Audacity.

After half wave rectification you will still have to apply Steve's Amplitude modulation code to create your pulses.

(* Audacity 1.3)

It does work ...

Posted: Wed May 06, 2009 2:42 pm
by Trebor
From top to bottom:
1000Hz square wave,
Half wave rectified 1000Hz square wave,
19KHz "sine",
19KHz "sine" amplitude modulated by the rectified 1000Hz square wave.
1ms_Pulses_of_19KHz.png
1ms_Pulses_of_19KHz.png (16.67 KiB) Viewed 2225 times
[I put "sine" in quotes because at a sample rate of 44.1KHz a 19KHz sine wave is more like triangular waveform].

Re: Molding a tone to a given audio sample (matching silence

Posted: Wed May 06, 2009 3:23 pm
by seanybob
Trebor, I love you. Nuff said.

:P On a more serious note, Thank you!!! I'll be testing this out today. You've been a great help Trebor!

Re: Molding a tone to a given audio sample (matching silence

Posted: Wed May 06, 2009 6:06 pm
by seanybob
It works like a charm :)

Thanks again Trebor!

Re: Molding a tone to a given audio sample (matching silence

Posted: Wed May 06, 2009 7:39 pm
by steve
Sorry I missed this one - been off-line due to a broadband fault :(

Interesting to see the solution that you guys have come up with.
An alternative method would have been to modify the low frequency wave by using a combination of multiplying, and addition / subtraction and the "clip" function so that the modified low frequency wave had a maximum amplitude of 1.0 and a minimum amplitude of 0.0

Multiplying this modified low frequency wave with the high frequency wave would then produce the required modulation.

Re: Molding a tone to a given audio sample (matching silence

Posted: Fri May 08, 2009 1:07 pm
by steve
Here's a single line of code that should do the job:

Code: Select all

(mult (aref s 1)(sum 0.5 (scale 50 (clip (aref s 0) 0.01))))

Re: Molding a tone to a given audio sample (matching silence

Posted: Sun Aug 23, 2009 11:16 pm
by Storer
Was just looking at this thread and noticed the rather complex code for a half-wave rectifier.

There is already such a function built into Nyquist: (s-max sound1 sound2). This takes two sounds (mono or multi-channel), or a sound and a FLONUM (or two FLONUM's for that matter) and for corresponding samples in the sounds, it returns the maximum. So the expression (s-max s 0.0) will replace all the negative valued samples with zero.

To grab only the negative side of the signal, use (s-min s 0.0).