Simple value change sensor

Studiowaves
Studiowaves Member Posts: 640 Advisor
edited October 22 in Building With Reaktor

Thought I'd pass this on. It's a sensor that detects a change in value. This example sends out a reset command to something else. But here's how it works using the previous event module. "Previous event". Stores the incoming event value and outputs the previously stored value. As can be seen "Time" is the incoming value, in my case it comes from a panel control. So whenever the control is changed the new value doesn't equal the old value for one clock cycle. When a change is detected a single clock reset is generated. Not that the reset needs to be the end result, but it certainly does detect a new value and generates a single cycle flag. Hope it comes in handy, it's pretty simple thanks to the Previous Event module.


Tagged:

Comments

  • colB
    colB Member Posts: 988 Guru

    No, that's not what it does,

    What your code does is, if there are two sequential 'time' events with different values, then the sample rate clock sends a stream of events at sample rate until there is a time event with the same value as the last. Probably not ideal to be sending the audio clock stream at a reset control?

    If you replaced that SR.C with Time, it would likely do what you think it does. However, it still wouldn't be guaranteed to do what you expect during initialisation.

    What you seem to need is a dup filter, There are a selection of those in the library. They are basically the same thing but with initialisation handled properly.

    The ones with ' are optimised, but not 100% guaranteed at initialisation - read the descriptions! The ' versions are normally the best choice ;)

  • Studiowaves
    Studiowaves Member Posts: 640 Advisor

    The time input is carried on the audio clock. Sorry, I should have said so. Remember how they reset the delay modules so they produced no sound until the time of the delay was exhausted after a reset. That's what this does. This code works as follows: whenever a new time value enters the "previous event" module the previous value is sent out and remains out until the next audio clock. During the one cycle delay period the comparator realizes there is a difference and momentarily connects the serial clock to it's upper or true output. The comparator then switches it off on the following clock cycle. Obviously the "previous event" is functioning as a single cycle audio delay but the output of the comparator does not run a chain of audio events downstream, only one clock is passed to the reset during the one cycle delay. You can preload an initial value on startup on the bottom input of the pe module. The problem there is it reloads that value whenever the ensemble is stopped or possibly when a switch is used too. So I chose to use an audio clock on the front panel dial for the time. That guarantees proper initialization right there. But you have a good point, I might be able to use event input for the time control and follow it by dup filter that resets the delay and come out ahead on cpu usage. Good idea, but at least I found a way to do it from a signal carried on the audio clock and shared it. It might come in handy. Later and thanks for the response. I sure have learned a lot in this forum.

  • Studiowaves
    Studiowaves Member Posts: 640 Advisor

    Can I connect the output of the dup filter to the reset on those delays directly or would I need something like an event merge in between. The resets accept a clock event without a value. I'll try it I guess. Talk Later, thanks again.

  • colB
    colB Member Posts: 988 Guru

    The reset on those delays needs to have a value of zero, use a latch.

  • Studiowaves
    Studiowaves Member Posts: 640 Advisor


    Yeah, True. This might work. I'm pretty sure the ES module sets a true router output on startup. So it should reset the delay. On the other hand the event merge may send out a reset on startup if the bottom input is open. If so leave it open and connect the dup flt to the top of the merge. The two pics might be identical?


  • Studiowaves
    Studiowaves Member Posts: 640 Advisor
    edited April 2023

    I can't get it to work with an event duplicate filter while using an event input for the panel dial. I just added a latch with a zero input on the dup flt below. Seems like it should work. Any ideas?


  • colB
    colB Member Posts: 988 Guru

    why are you making it so complicated?

    Something like this should work just fine, unless there is other external context you have not explained?


  • Studiowaves
    Studiowaves Member Posts: 640 Advisor

    Actually I think it does work, there's something else happening afterwards that's not clear yet. The single pulse with the audio input and the original circuit above works fine. Something is out of sync or something.

This discussion has been closed.
Back To Top