Write in a text file every 10 seconds

Hello,
I’m a newbie with JUCE.
I create a plugin who analyse data and I want to write my result in a text file.
So I created a file and a fileoutputstream. My problem is the following:
I want to write in a file every 10 seconds. However I need to write in it without open the GUI of the plugin.
In my current version, I need to open the GUI then timerCallBack() is running and write in my file. So I already achieved to write in my file. My only problem is to write at the right moment (every 10 seconds for example).
My File is created in my AudioProcessor, my FileOutputStream in my AudioProcessorEditor, so I currently I use my timerCallBack from my AudioProcessorEditor
Have you any idea to write every 10seconds in a file without open my plugin GUI?
Thanks a lot,
Léo

I may be missing something, but can’t you simply make your AudioProcessor inherit Timer and implement the timerCallback there?

1 Like

You describe the problem (and solution) in your question – it’s a matter of scope.

Rail

Thanks a lot for your quick answer!
I will try and do that!
Léo

@daniel is it recommended for the AudioProcessor to inherit from Timer?

At least it is not a problem. The AudioProcessor has methods, that are running on the audio thread (mostly processBlock()) and methods, that are called from the message thread.

It is up to you to make sure, that data which is accessed from both threads is properly synchronised or decoupled (atomic, FIFO, etc.)

For someone who doesn’t know anything about what you are saying. What would be a great place to start to learn this?