Molding a tone to a given audio sample (matching silences)

Effects, Recipes, Interfacing with other software, etc.
Forum rules
If you require help using Audacity, please post on the forum board relevant to your operating system:
Windows
Mac OS X
GNU/Linux and Unix-like
Trebor
Posts: 9954
Joined: Sat Dec 27, 2008 5:22 pm
Operating System: Windows 8 or 8.1

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

Post by Trebor » Fri May 01, 2009 7:12 pm

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]
Last edited by Trebor on Fri May 01, 2009 8:35 pm, edited 1 time in total.

Trebor
Posts: 9954
Joined: Sat Dec 27, 2008 5:22 pm
Operating System: Windows 8 or 8.1

Half-wave rectification ?

Post by Trebor » Fri May 01, 2009 7:50 pm

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.

seanybob
Posts: 12
Joined: Thu Apr 30, 2009 2:20 am
Operating System: Please select

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

Post by seanybob » Tue May 05, 2009 11:49 pm

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 :)

Trebor
Posts: 9954
Joined: Sat Dec 27, 2008 5:22 pm
Operating System: Windows 8 or 8.1

Positive Half Wave Rectification, Eureka !

Post by Trebor » Wed May 06, 2009 2:07 pm

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 2239 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)
Attachments
HalfWaveRectifier(Pos).zip
Zip file of "Half Wave Rectifier (+ve)" plugin for Audacity.
(820 Bytes) Downloaded 116 times
Last edited by Trebor on Wed May 06, 2009 2:47 pm, edited 1 time in total.

Trebor
Posts: 9954
Joined: Sat Dec 27, 2008 5:22 pm
Operating System: Windows 8 or 8.1

It does work ...

Post by Trebor » Wed May 06, 2009 2:42 pm

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 2241 times
[I put "sine" in quotes because at a sample rate of 44.1KHz a 19KHz sine wave is more like triangular waveform].

seanybob
Posts: 12
Joined: Thu Apr 30, 2009 2:20 am
Operating System: Please select

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

Post by seanybob » Wed May 06, 2009 3:23 pm

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!

seanybob
Posts: 12
Joined: Thu Apr 30, 2009 2:20 am
Operating System: Please select

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

Post by seanybob » Wed May 06, 2009 6:06 pm

It works like a charm :)

Thanks again Trebor!

steve
Site Admin
Posts: 81627
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

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

Post by steve » Wed May 06, 2009 7:39 pm

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.
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

steve
Site Admin
Posts: 81627
Joined: Sat Dec 01, 2007 11:43 am
Operating System: Linux *buntu

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

Post by steve » Fri May 08, 2009 1:07 pm

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))))
9/10 questions are answered in the FREQUENTLY ASKED QUESTIONS (FAQ)

Storer
Posts: 91
Joined: Wed Mar 04, 2009 8:02 pm
Operating System: Please select

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

Post by Storer » Sun Aug 23, 2009 11:16 pm

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).
Win XP Pro/SP3 ---- Audacity 1.3.12RC2

Post Reply