Author |
Message |
deknow
Joined: Sep 15, 2004 Posts: 1307 Location: Leominster, MA (USA)
G2 patch files: 15
|
Posted: Thu Jul 28, 2005 11:09 pm Post subject:
how to detect zero crossing? (and more) |
|
|
hey all,
i'm working on a project, and know this can be done, i'm just a little confused (like that's news to anyone!).
i want to use a d flipflop (i think) to send out a logic pulse when both of these 2 conditions are met:
1. sometime after it recieves a logic pulse
2. when an audio signal crosses zero
i think i send the logic pulse to the d input of the flipflop, and come up with some way to detect when the audio crosses zero (either going up or down), and send this to the clock input.
i'm having trouble figuring out the zero crossing detector. do i use a pair of rectifiers to find zero? do i use a pair of compare level? compare signal? i'm on the verge of solving some real problems i've been having, and i'm stumped.
deknow |
|
Back to top
|
|
|
deknow
Joined: Sep 15, 2004 Posts: 1307 Location: Leominster, MA (USA)
G2 patch files: 15
|
Posted: Thu Jul 28, 2005 11:20 pm Post subject:
|
|
|
...i think i figured it out. it's too late to do full testing, but i'll post again tomorow if i'm still having problems.
deknow |
|
Back to top
|
|
|
Wan
Joined: Mar 31, 2004 Posts: 259 Location: Netherlands, Ugchelen
Audio files: 4
G2 patch files: 46
|
Posted: Thu Jul 28, 2005 11:43 pm Post subject:
|
|
|
For zero crossing detection, you did think of the ZeroCnt module? It may be that this solves your problem, but then it may be not.
I thought, i just mention it... _________________ Grtz Wan |
|
Back to top
|
|
|
deknow
Joined: Sep 15, 2004 Posts: 1307 Location: Leominster, MA (USA)
G2 patch files: 15
|
Posted: Fri Jul 29, 2005 12:00 am Post subject:
|
|
|
i thought so too, but the zerocount module ouputs a bipolar control signal (like to control the pitch of an oscillator), not send a gate when the signal crosses zero.
what i think works is using a rectifier to only let the negative part of the audio waveform pass, and then use a complevel (set to zero). since the passed waveform is only negative or zero, and the complevel is only going to go high when the input is greaterthan or equal to zero, it will only trigger on zero.
a clockdivide (by 1) also seems to work.
i'm not sure if this will solve my problem, but i can't fire up the flute until the morning (it's 3am and we have tennants upstairs).
deknow[/quote] |
|
Back to top
|
|
|
Kassen
Janitor
Joined: Jul 06, 2004 Posts: 7678 Location: The Hague, NL
G2 patch files: 3
|
Posted: Fri Jul 29, 2005 1:59 am Post subject:
|
|
|
you could take a logic OR gate, leave one input blank and feed the other your audio. Now it should go high if your signal is positive. If you put a logic pulse over that you'll get a pulse at each positive zero crossing. You could then invert the OR gate and put a pulse over that signal too to pulse at negative zero crossings. Now taking a logical OR over the two of those should get you a pulse at all zero crossings.
Does that help? _________________ Kassen |
|
Back to top
|
|
|
3phase
Joined: Jul 27, 2004 Posts: 1183 Location: Berlin
Audio files: 13
G2 patch files: 141
|
Posted: Fri Jul 29, 2005 3:07 am Post subject:
|
|
|
Isnt the pitchtrack module the one that meets the requirements here? |
|
Back to top
|
|
|
3phase
Joined: Jul 27, 2004 Posts: 1183 Location: Berlin
Audio files: 13
G2 patch files: 141
|
Posted: Fri Jul 29, 2005 3:29 am Post subject:
|
|
|
3phase wrote: | Isnt the pitchtrack module the one that meets the requirements here? |
Just checked it..the pitchtracker trigers on the most negativ point of a wavecycle...regardless how the way is offsett.. So when you really want it to trigger at zero you need something to convert one wave to another where the zerocrossing of the sourcewave becomes the minus point of the resulting wave..
How do we do that? |
|
Back to top
|
|
|
3phase
Joined: Jul 27, 2004 Posts: 1183 Location: Berlin
Audio files: 13
G2 patch files: 141
|
|
Back to top
|
|
|
Kassen
Janitor
Joined: Jul 06, 2004 Posts: 7678 Location: The Hague, NL
G2 patch files: 3
|
Posted: Fri Jul 29, 2005 5:29 am Post subject:
|
|
|
3phase wrote: |
It only works when the pitchtracker thiks it is a wave cycle...no chance with static signals... another solution is needed.
|
Well, yeah, but typically static signals don't cross zero since they are -well- static. My sugestion will trigger once at the start if fed a static signal which could be a problem in realy rare cases but typically people won't try to detect zero crossings of static signals so I don't see that as a big issue. _________________ Kassen |
|
Back to top
|
|
|
3phase
Joined: Jul 27, 2004 Posts: 1183 Location: Berlin
Audio files: 13
G2 patch files: 141
|
Posted: Fri Jul 29, 2005 5:35 am Post subject:
|
|
|
Kassen wrote: | 3phase wrote: |
It only works when the pitchtracker thiks it is a wave cycle...no chance with static signals... another solution is needed.
|
Well, yeah, but typically static signals don't cross zero since they are -well- static. My sugestion will trigger once at the start if fed a static signal which could be a problem in realy rare cases but typically people won't try to detect zero crossings of static signals so I don't see that as a big issue. |
Maybe static signals is the wrong term...The pitchtracker is only working when it gets clean cycles...no cycle no trigger..but...if detecting triggers or switches ther are no cycles..therfore i was using the term static signals..
AC and DC signals ..or audio and control signals...
However..the new circuit works well.. just quantize befor doublepositv rectifie with a compare module set to zero...
Actually i like to see a "=" module on the G2...but when i remember the crashes in earlier reaktor versions when using that function ...
Seems to be a more difficult task DSP wise..as it is patchwise...
So next round...
Who can patc a "=" trigger module? |
|
Back to top
|
|
|
Kassen
Janitor
Joined: Jul 06, 2004 Posts: 7678 Location: The Hague, NL
G2 patch files: 3
|
Posted: Fri Jul 29, 2005 5:46 am Post subject:
|
|
|
Ah, yes, I see, that makes sense.
for a "=" trigger to be usefull you realy need something that detects wether a signal is *close* to another value because in digital systems there is no guarantee at all that when a signal goes from 0 to 1 it will pass through 0.50000 at a moment that gets sampled. What you would do is make somthing that triggers if the input is both lower then 0.51 and higher then 0.49. two compare value modules and a logic gate will do the trick.
I have a Tassman sub-patch that's called "roughly equal" that does exaclty this. _________________ Kassen |
|
Back to top
|
|
|
3phase
Joined: Jul 27, 2004 Posts: 1183 Location: Berlin
Audio files: 13
G2 patch files: 141
|
Posted: Fri Jul 29, 2005 6:02 am Post subject:
|
|
|
Kassen wrote: | Ah, yes, I see, that makes sense.
for a "=" trigger to be usefull you realy need something that detects wether a signal is *close* to another value because in digital systems there is no guarantee at all that when a signal goes from 0 to 1 it will pass through 0.50000 at a moment that gets sampled. What you would do is make somthing that triggers if the input is both lower then 0.51 and higher then 0.49. two compare value modules and a logic gate will do the trick.
I have a Tassman sub-patch that's called "roughly equal" that does exaclty this. |
That it was the note quantizer module set to 1 is for...
This module is pretty important because it can sort quite a bunch of logic module issues that are caused by these rounding errors you mentioned.
To bad that you dont have a G2..you could see it in the patch i just have posted.
Ups have missread you...thought you were stil about the static signals..
The notquantizer might fit anyway ..but first i need to go out now..its to late to surrive in the studio...to hot... |
|
Back to top
|
|
|
Kassen
Janitor
Joined: Jul 06, 2004 Posts: 7678 Location: The Hague, NL
G2 patch files: 3
|
Posted: Fri Jul 29, 2005 6:14 am Post subject:
|
|
|
Yeag, a note quantiser might help but for some aplications it may be too coarse. You also still need the compare modules and the gate so thee's not so much advantage to using one, I think.
It's simply a problem of dynamic signals in digital systems and nothing will get around it. _________________ Kassen |
|
Back to top
|
|
|
ian-s
Joined: Apr 01, 2004 Posts: 2669 Location: Auckland, New Zealand
Audio files: 42
G2 patch files: 626
|
Posted: Fri Jul 29, 2005 7:33 am Post subject:
|
|
|
The window switch makes a good "roughly equal" detector, except that it does not have a bipolar setting |
|
Back to top
|
|
|
3phase
Joined: Jul 27, 2004 Posts: 1183 Location: Berlin
Audio files: 13
G2 patch files: 141
|
|
Back to top
|
|
|
Rob
Joined: Mar 29, 2004 Posts: 580 Location: The Hague/Netherlands/EC
G2 patch files: 109
|
|
Back to top
|
|
|
Kassen
Janitor
Joined: Jul 06, 2004 Posts: 7678 Location: The Hague, NL
G2 patch files: 3
|
Posted: Sat Jul 30, 2005 4:40 pm Post subject:
|
|
|
Another way of dealing with this matter might be to substract the value we want to test for from the dynamic signal, then compare the absolute value of the outcome to a value that indicates (half of) the window size. The advantage of this is that you can then easily modulate the window size. The size of the window may well need to be dynamic and depend on how quickly the dynamic signal is expected to jump around since we want to avoid the situation where the dynamic signal crosses through the window inbetween two steps of the samplerate. This is a especially relevant issue in situation where one is dealing with clocked logic that for some reason runs at a rate signifficantly lower then the audio rate.
I wouldn't bet a life suport system on such constructions but music is just for fun and so "probably in nearly all cases" will do, IMHO. _________________ Kassen |
|
Back to top
|
|
|
3phase
Joined: Jul 27, 2004 Posts: 1183 Location: Berlin
Audio files: 13
G2 patch files: 141
|
Posted: Sat Jul 30, 2005 6:31 pm Post subject:
|
|
|
Kassen wrote: | Another way of dealing with this matter might be to substract the value we want to test for from the dynamic signal, then compare the absolute value of the outcome to a value that indicates (half of) the window size. The advantage of this is that you can then easily modulate the window size. The size of the window may well need to be dynamic and depend on how quickly the dynamic signal is expected to jump around since we want to avoid the situation where the dynamic signal crosses through the window inbetween two steps of the samplerate. This is a especially relevant issue in situation where one is dealing with clocked logic that for some reason runs at a rate signifficantly lower then the audio rate.
I wouldn't bet a life suport system on such constructions but music is just for fun and so "probably in nearly all cases" will do, IMHO. |
In the end the quantize module is the cheapest option..you also could scale the input and output with amplefier modukes if the quantizer step is to wide.. But in real applikations you most of the time want to detect such even number values... Its nice that the G2 started to show many new aspects lately... quite a few peoblems i had in the past have cures now..
Should rework some older patches... but maybe i better wait for the next update..
i wonder if calvia just will add the patchmutator or if tsome other issues will be touches aswell...
I would benefit most with surface related issues like knob exclusion in variation changes or so..
The knobs and variations buttons become more and more part of my keyboard playing...
IN the moment i ve a problem to see a thing as a bug or a feature..
A momentary switch that is pressed during variation change locks in its position... that what appaered first as a bug is actually something that can be used as a playing technique..
On the other hand it can disturb on quick variation changes ...
Bug or feature??? what do you think? |
|
Back to top
|
|
|
deknow
Joined: Sep 15, 2004 Posts: 1307 Location: Leominster, MA (USA)
G2 patch files: 15
|
Posted: Sun Jul 31, 2005 8:59 am Post subject:
|
|
|
thanks everyone...this is ALL very helpful (and also sometimes i misread something that also gives me a good idea). i have to recreate some things that i lost when my engine died on friday before i can start applying this stuff, but i will give an update when i do....again, i really appreciate getting this help.
deknow |
|
Back to top
|
|
|
|