Adding a digital trigger on my output channel

Hi,

I am building a Juce application for an experiment, basically: I have the whole program in Qt and I’m able to load a Juce app that creates a ToneGenerator on only one channel. The Qt program sends a signal to the Juce app to set a new frequency when required. What I want now, is to synchronize my audio data with other data streams via triggers: i.e I want to know when the frequency played changed, so in my field we usually send 1 when a change occurs and 0 most of the time.

I’m 3 days old in Juce, and my first approach was to create a Value::ValueSource named Frequency and each time the frequency changes, it uses sendChangeMessage to a Listener. This approach failed, as I am unable to reach through the broadcasted message the listener.

The solution I have for now, is in my ToneGenerator (who inherits from AudioSource), when a new frequency is asked, I write in a second buffer 1…1, and when, again, a new frequency is asked, I write 0…0. I can’t figure out how to only write one 1.

You can find some code I wrote:

TestConsoleTones.h (1.9 KB)
TestConsoleTones.cpp (1.8 KB)
FrequencyValue.cpp (1.1 KB)
FrequencyValue.h (1011 Bytes)

What I really want, when the frequency changes, is to write 1 to the buffer (only one 1) and that my NI DAQ can receive it in its DigitalPort (via Hardware conversion from Analog to Digital).

Flavien