Rockbox Technical Forums
Support and General Use => Plugins/Viewers => Topic started by: inflam52 on May 06, 2020, 05:32:58 PM
-
I'd like to build a small sequencer plugin in Lua but I'm having a hard time finding the functions needed. I've been digging through the source and documentation without any luck. I'm fairly new to developing for Rockbox so I may be overlooking something. I have a couple of questions and any help would be much appreciated:
1. Is there a way to playback 2 or more audio files at the same time? I noticed a few mixer functions but not sure if those could be used.
2. Is there any way to access the midi plugin functions in Lua (like synth - initSynth)? I noticed there is a "beep_play" function for generating a square wave but it seems pretty basic and doesn't look to support polyphony.
It would be great to do something in the spirit of the beatbox.c plugin that was abandoned several years ago. Also, if I'm missing documentation any help be great there too. I've just been using https://www.rockbox.org/wiki/PluginLua#API_list (https://www.rockbox.org/wiki/PluginLua#API_list) along with the source. The graphics API seem pretty well documented so I don't think I'll have issues there.
Thanks!
-
Most of the Mixer functions haven't been broken out
I'm not sure if lua is fast enough to keep the buffers fed.. maybe
Playback of audio files is pretty limited as well I just recently got that working, but there is definitely no way to get two to play as of right now
Feel free to add functions as you see fit just be aware the more ram used for functions the less ram to actually run programs with
--Also be aware after you hit the *limit* playback is stopped so lua can use its buffer as ram as well
RB functions aren't able to be called directly from lua they have to go through a translation layer first
https://github.com/Rockbox/rockbox/blob/master/apps/plugins/lua/rocklib.c <--
*limit* differs between targets
-
Thanks for the reply @Bilgus!
Good info to know. Merging 2 audio files in Lua unlikely too?
-
Realtime mixing is only feasible from native code (i.e. C).
-
That makes sense @__builtin
I guess this type of app would best be developed in C instead of Lua. Might just be worthwhile picking up where the beatbox.c plugin left off.
-
I suppose you could write your own mixer functions in c and then script them from Lua.
-
Personally I'd rather write the whole app in C -- lua scripts are fast to develop, test, customize but SLOW compared to C I love the idea of a lua front end and c functions together but we don't have the ability to load precompiled (.so) files (I don't have the skillz (desire?) necessary to implement dynamic loading for them in rockbox)
That leaves adding them to the binary :/