In the last year I have been using Flutter, a cross platform app development framework which is really cool. Somewhat similar to React Native, although instead of depending on native UI components, you write dart code using the Flutter library and it gets compiled to machine code. This lets it be very powerful, performant and flexible. If you haven’t seen Flutter before I’d recommend checking it out!
When I first heard about SOUL Lang when it was announced last year, I thought that creating a Flutter app with a SOUL audio backend would be an amazing way to create audio apps.
Now that the SOUL beta has been released I’m trying to have a go at integrating them together.
There is a feature in beta in Dart called Dart:FFI which lets you call C code directly from Dart, and this can be used in flutter apps. This seems like it could potentially be a great way to make the link between Flutter and SOUL.
There are 2 ideas I had for a useful first step to take:
- Take one of the standalone soul examples from SOUL/examples/standalone, compile it to C++ using the soul generate --cpp command, and try to call this from Flutter thought Dart:ffi
- Try to create something similar to the SOULPatchHostDemo in Flutter
Do either of these seem realistic?
I had a go at idea 1, and the first blocker I hit is the following?:
If I compile a SOUL file, for example ClassicRingtone.soul to a cpp file, i.e. ClassicRingtone.cpp, how can I actually use this cpp file to make sound?
The compiled file has a ClassicRingtone class, which has a render method.
Is the idea that you have to call the render method every so often (e.g. every 10ms) to generate the next chunk of data to send to the speakers?
If so, do you have any idea of a minimal setup for doing this, and how I could do this from Flutter and send the output to the device speakers? Or is the idea that I should be using JUCE to do that?
(I saw this talk at the years ADC about integrating JUCE with React Native, by creating a JUCE app with a react native app inside it, so perhaps the same is possible with Flutter, although I haven’t come across anyone else trying this yet.)