Where to start? Concurrent processes for OF

Hello! First post alert. New to openFrameworks. I come from an electrical engineering aka old school background for programming. Command line compiling, simple makefiles - have never used a real IDE like Visual Studio and have never really coded applications in Windows (I have a windows machine but always used Linux VMs for school stuff). However, it’s time to get with the times because there are very few people out there it seems who are using makefiles to compile these libraries.

I want to make an audio-visual application where certain animations, shapes, and colors are triggered by volume spikes of certain frequencies from the audio. I see that there are a bunch of nice libraries for all the signal processing/animation stuff which is awesome. However, I want this to be a real-time application (analyzes the audio and updates animations on the fly) so it needs to be as efficient as possible in terms of memory usage, speed, and responsiveness. Thank the heavens OF is based in C. Because there are a lot of beefy calculations like audio FFTs and graphical computations I can’t just use a simple loop to get 'er done.

To make this application nice and quick I need to use concurrent programming techniques like forking into multiple processes, using IPCs, and using System Calls in an intelligent way. To emphasize, I want to push my computer’s abilities and resources to its maximum. More performance = more intricate and responsive animations. I am only familiar with the Unix based APIs for this kind of programming which is why I cling to Linux. The issue is I’ve had a hard time finding tutorials on how to install OF on linux bc usually people use Xcode and Visual Studios which I don’t know how make them compatible in linux.

Looking for a place to start. Should I just continue with Visual Studios on my Windows and try and learn the concurrent process APIs for Windows (I heard they are harder to use properly than Unix)? or can anyone direct me to a guide on how to create a build system on Linux (anyone ever use WSL and OF??)

1 Like

Hey welcome!!

OF runs pretty great on Linux.

You can build with Make and Makefiles and use QT Creator ( specific versions in the install guide ) if you prefer an IDE.

The projectGenerator makes it easy to add addons to a project.

I imagine an addon like this would be useful for what you are after:

For downloading OF on linux, I would also recommend starting with the nightly builds of OF on the bottom of the download page ( instead of 0.11.2 ): download | openFrameworks

Hope that helps!

Hi eddie-water,

Welcome to the forum and OF!

I feel familiar when I read your description, old school and stuff. I have used OF on all three systems and sort of like the elegance of the makefile approach.

As I found QT Creator complicated to set up, I wrote a blog post about an altenative approach a long time ago - using an IDE completely respecting makefiles and not needing additional setup. Since then I use Netbeans (yeah, I know… I was confused too.) on Linux. The process got easier if anything with the new versions of Netbeans. As the blog is not really online any more, I’ll send you a Private Message, OK? Maybe it helps.

Have a great day!

1 Like

Hi eddi-water,

For the second part: As you are familiar with Linux I do not think there’s any advance in switching systems. There is only little domains where Linux has drawbacks compared to Windows or the mac IMHO. (The only one I found for my work is the lack of a solution like Syphon/Spout - so if you need to share video with other applications, you might consider Windows. Maybe gstreamer is able to do something similar on Linux, but it was over my head at least).

Anyway my advise would be to do as little system-specific as possible and instead check if there’s an OF-way of doing things. It might help and you can even easily switch systems later. And in my experience OF is heavily optimized most of the time (although I am not a solid programmer, I use is to to get some serious work done in terms of real-time projections).
For example check out ofThread for splitting up processes and so on. The documentation and learning Tab on openframeworks.cc help a lot.

There’s also a link to the addons page. There you find old and abandoned as well as well-maintained addons. I use to look there, as there are some quite efficient solutions. I for example once used ofxPDSP for real time sound analysation on a Raspberry Pi 2. For pixel based stuff there are shader solutions as well as (multiple) openCV addons, well-integrated in OF and so on.

Have a good time using OF!

1 Like

Just to add to the substantial responses above: do not over-design the concurrent stuff. At it’s core, the visual rendering is CPU single-threaded – it is more important to harness the GPU via different types of shaders than to “fork” threads or processes (and have to re-sync them later). Likewise, audio processing/analysis is mostly a single-thread affair – you need to filter the stream in sequence, which makes parallelism difficult. Unless you are trying to run things on a voluntarily constrained embedded platform, real-time CPU audio analysis will not be a burden.

Sketch the thing and get it running. Bend things towards what was your original idea (and discover new ideas along the way). Get acquainted with the profiling tools and you can then identify the true bottlenecks; determine if the required optimization effort is intelligent, and if (and only if) so, work on them concretely.

+1 for Makefiles and command line – i work on linux and macOS and use the same config.make to compile spontaneously on either plaftorm without thinking too much about it.

1 Like

Very helpful, Theo tysm. I installed everything on WSL2 and have been building/running some of the examples. Super cool. Could you explain to me what the benefits of the ‘nightly builds’ are? Also, what are nightly builds in the first place?

TYSM for the private message, love your website you are such a real one. Already feeling the community aspect of OF. I agree with what you said. I would like this to be as system-independent as possible. I have been digging into the ofBook. It’s very well documented.

I agree. What you said about “finding the true” bottlenecks is very profound. Will definitely keep this in mind bc when it comes to concurrency I agree - if it ain’t broke, don’t fix it. No need to get to fancy with it. I just love the idea of concurrency and independent processes

The thing is, I come from an embedded and systems background. My day job is a firmware engineer and I work with all kinds of microprocessors. Devices with limited resources that run bare metal applications or very lightweight RTOS/schedulers. So it’s engraved into my workflow to consider explicit use of memory, event synchronization, assigning priorities to different kinds of tasks, data race prevention. I think all these concepts are fully transferable to artistic coding. As Dasoe mentioned though I guess its in my favor to make the program as system-independent as possible so maybe I should avoid system calls…

However, I understand this is a different kind of development - I have never really developed a gui user application. Also never really used OOP and classes and private functions and all that. More of a data structure guy so this going to be an adventure for me. Maybe I underestimate the power of my laptop’s processor because sometimes this thing gets piping hot just from using Firefox :joy:.

1 Like

Glad to hear you got it working!!
And welcome to the community :slight_smile:

Nightly builds basically are the most up to date OF releases and fix issues that can come up with newer operating system versions. They are less stable than the numbered releases.

I suggested them in your case as we’ve done quite a few linux fixes that have come up since the last release (0.11.2).

Hope that is helpful!