electro-music.com   Dedicated to experimental electro-acoustic
and electronic music
 
    Front Page  |  Articles  |  Radio
 |  Media  |  Forum  |  Wiki  |  Links  |  Store
Forum with support of Syndicator RSS
 FAQFAQ   CalendarCalendar   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   LinksLinks
 RegisterRegister   ProfileProfile   Log in to check your private messagesLog in to check your private messages   Log inLog in  Chat RoomChat Room 
Live streaming at radio.electro-music.com

  host / artist show at your time
<on air> EdisonRex Edison's Electronic Review
  Twyndyllyngs Special Monday edition of Chez Mosc
Please visit the chat
 Forum index » Clavia Nord Modular » Nord Modular G2 Discussion
how to detect zero crossing? (and more)
Post new topic   Reply to topic Moderators: Nord Modular Editors
Page 1 of 1 [19 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
Author Message
deknow



Joined: Sep 15, 2004
Posts: 1307
Location: Leominster, MA (USA)
G2 patch files: 15

PostPosted: Thu Jul 28, 2005 11:09 pm    Post subject: how to detect zero crossing? (and more) Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Send e-mail
deknow



Joined: Sep 15, 2004
Posts: 1307
Location: Leominster, MA (USA)
G2 patch files: 15

PostPosted: Thu Jul 28, 2005 11:20 pm    Post subject: Reply with quote  Mark this post and the followings unread

...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
View user's profile Send private message Send e-mail
Wan



Joined: Mar 31, 2004
Posts: 255
Location: Netherlands, Ugchelen
Audio files: 4
G2 patch files: 46

PostPosted: Thu Jul 28, 2005 11:43 pm    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Visit poster's website
deknow



Joined: Sep 15, 2004
Posts: 1307
Location: Leominster, MA (USA)
G2 patch files: 15

PostPosted: Fri Jul 29, 2005 12:00 am    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Send e-mail
Kassen
Janitor
Janitor


Joined: Jul 06, 2004
Posts: 7678
Location: The Hague, NL
G2 patch files: 3

PostPosted: Fri Jul 29, 2005 1:59 am    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Send e-mail Visit poster's website
3phase



Joined: Jul 27, 2004
Posts: 1152
Location: Berlin
Audio files: 13
G2 patch files: 138

PostPosted: Fri Jul 29, 2005 3:07 am    Post subject: Reply with quote  Mark this post and the followings unread

Isnt the pitchtrack module the one that meets the requirements here?
Back to top
View user's profile Send private message Send e-mail Visit poster's website
3phase



Joined: Jul 27, 2004
Posts: 1152
Location: Berlin
Audio files: 13
G2 patch files: 138

PostPosted: Fri Jul 29, 2005 3:29 am    Post subject: Reply with quote  Mark this post and the followings unread

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? Shocked
Back to top
View user's profile Send private message Send e-mail Visit poster's website
3phase



Joined: Jul 27, 2004
Posts: 1152
Location: Berlin
Audio files: 13
G2 patch files: 138

PostPosted: Fri Jul 29, 2005 3:32 am    Post subject: Reply with quote  Mark this post and the followings unread

3phase wrote:
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? Shocked


Ok double rectified and -64 offset

And here the z solution Wink...ohh.no..
It only works when the pitchtracker thiks it is a wave cycle...no chance with static signals... another solution is needed.

edit..Ok..here we go..just rectevier and compare do the job when you quantize the signal before the rectivier..


zerocrossTrg++.pch2
 Description:

Download
 Filename:  zerocrossTrg++.pch2
 Filesize:  3.18 KB
 Downloaded:  655 Time(s)

Back to top
View user's profile Send private message Send e-mail Visit poster's website
Kassen
Janitor
Janitor


Joined: Jul 06, 2004
Posts: 7678
Location: The Hague, NL
G2 patch files: 3

PostPosted: Fri Jul 29, 2005 5:29 am    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Send e-mail Visit poster's website
3phase



Joined: Jul 27, 2004
Posts: 1152
Location: Berlin
Audio files: 13
G2 patch files: 138

PostPosted: Fri Jul 29, 2005 5:35 am    Post subject: Reply with quote  Mark this post and the followings unread

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 Mad ...

Seems to be a more difficult task DSP wise..as it is patchwise...

So next round...
Who can patc a "=" trigger module? Smile
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Kassen
Janitor
Janitor


Joined: Jul 06, 2004
Posts: 7678
Location: The Hague, NL
G2 patch files: 3

PostPosted: Fri Jul 29, 2005 5:46 am    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Send e-mail Visit poster's website
3phase



Joined: Jul 27, 2004
Posts: 1152
Location: Berlin
Audio files: 13
G2 patch files: 138

PostPosted: Fri Jul 29, 2005 6:02 am    Post subject: Reply with quote  Mark this post and the followings unread

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 Wink..but first i need to go out now..its to late to surrive in the studio...to hot...
Back to top
View user's profile Send private message Send e-mail Visit poster's website
Kassen
Janitor
Janitor


Joined: Jul 06, 2004
Posts: 7678
Location: The Hague, NL
G2 patch files: 3

PostPosted: Fri Jul 29, 2005 6:14 am    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Send e-mail Visit poster's website
ian-s



Joined: Apr 01, 2004
Posts: 2575
Location: Auckland, New Zealand
Audio files: 42
G2 patch files: 608

PostPosted: Fri Jul 29, 2005 7:33 am    Post subject: Reply with quote  Mark this post and the followings unread

The window switch makes a good "roughly equal" detector, except that it does not have a bipolar setting Evil or Very Mad
Back to top
View user's profile Send private message
3phase



Joined: Jul 27, 2004
Posts: 1152
Location: Berlin
Audio files: 13
G2 patch files: 138

PostPosted: Fri Jul 29, 2005 11:03 am    Post subject: Reply with quote  Mark this post and the followings unread

g2ian wrote:
The window switch makes a good "roughly equal" detector, except that it does not have a bipolar setting Evil or Very Mad


True..and the problem i had with it in the past will be aswell solved with the note quantizer "trick".
Probably quite a few of my earlier problems will be solved with this. Without the quantizer the timeslot of the event is to short to be realized. The quantizer works like a Process synchronizer this way. A modulo .. its a real helper module Smile...Ive to look for the vavorite modules thread...

Edit..and here is the Bipolar equal value detector...i like easy things Smile...

But pleas note one issue with the G2... look at the pannel layout...I really hate that stupid "source " tag on the G2..I wrote to clavia about it
More than one time since the machine arrived on the market.
If the y would agree in my opinion it would be probably allready changed... Maye there are deeper reasons like an "the synthax has to be followed"...but for me its a waste of a valuable display line and reduces the fun to work with the G2s pannel.
Am i the only one that hates it?


Equal Detector.pch2
 Description:

Download
 Filename:  Equal Detector.pch2
 Filesize:  1.5 KB
 Downloaded:  612 Time(s)

Back to top
View user's profile Send private message Send e-mail Visit poster's website
Rob



Joined: Mar 29, 2004
Posts: 578
Location: The Hague/Netherlands/EC
G2 patch files: 109

PostPosted: Sat Jul 30, 2005 3:16 pm    Post subject: Re: how to detect zero crossing? (and more) Reply with quote  Mark this post and the followings unread

deknow wrote:
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

deknow


There is a circuit that goes by a curious name: 'One and only one'. It about does what you require.
It is made with two flipflops. When the first flipflop is triggered the second flipflop will wait for a trigger and then go high, and on the next trigger on this second input the second flipflop will go low again and settle to wait to be activated again.

It looks like this:
Posted Image, might have been reduced in size. Click Image to view fullscreen.

And an example patch where the output of the second flipflop is used to pass exactly one single cycle of a sine wave oscillator on every 1/16 of the masterclock. Play with the two buttons on the top example in the patch to get an idea how it works, consider the Env to be controlled by the output of the one and only one.


One and only one.pch2
 Description:
Circuit that will pass on exactly one period of a waveform or pulse, after it got activated by a trigger.

Download
 Filename:  One and only one.pch2
 Filesize:  1.29 KB
 Downloaded:  672 Time(s)

Back to top
View user's profile Send private message Send e-mail Visit poster's website
Kassen
Janitor
Janitor


Joined: Jul 06, 2004
Posts: 7678
Location: The Hague, NL
G2 patch files: 3

PostPosted: Sat Jul 30, 2005 4:40 pm    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Send e-mail Visit poster's website
3phase



Joined: Jul 27, 2004
Posts: 1152
Location: Berlin
Audio files: 13
G2 patch files: 138

PostPosted: Sat Jul 30, 2005 6:31 pm    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Send e-mail Visit poster's website
deknow



Joined: Sep 15, 2004
Posts: 1307
Location: Leominster, MA (USA)
G2 patch files: 15

PostPosted: Sun Jul 31, 2005 8:59 am    Post subject: Reply with quote  Mark this post and the followings unread

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
View user's profile Send private message Send e-mail
Display posts from previous:   
Post new topic   Reply to topic Moderators: Nord Modular Editors
Page 1 of 1 [19 Posts]
View unread posts
View new posts in the last week
Mark the topic unread :: View previous topic :: View next topic
 Forum index » Clavia Nord Modular » Nord Modular G2 Discussion
Jump to:  

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You cannot attach files in this forum
You can download files in this forum
e-m mkii

Please support our site. If you click through and buy from
our affiliate partners, we earn a small commission.


Forum with support of Syndicator RSS
Powered by phpBB © 2001, 2005 phpBB Group
Copyright © 2003 through 2009 by electro-music.com - Conditions Of Use