Gaspard Bucher wrote:
I am writing a real-time data processing tool (data in ---> pattern
recognition ---> midi out) called rubyk (site: http://rubyk.org trac:
http://dev.rubyk.org). The first idea was to embed ruby (thus the name
rubyk).
I did some testing with a first "pure ruby" implementation of the
signal sending mechanism and it works fine but is erratic (very hard
to have stable tempo), probably due to ruby's GC messing in the way.
So I wrote a C++ core and thought I would embed ruby. But then the
garbage collector's "inconvenient pause" would happen again (with less
objects though).
Will ruby work fine for real-time midi ? Or am I better off using Lua
? I really like ruby and would prefer going this route, but I do not
want to be limited to a "rubato" style of music.
So the questions are:
1. I need to loop at a minimum of 300Hz. Will ruby GC be fast enough ?
2. Is there a way to disable GC without leaking memory ?
3. Would Lua be a better fit ?
4. Python uses reference counting so no "mark & sweep" pause. But I do
not want to use Python, so please do not tell me Python would be
great.
Many thanks for your answers.
Gaspard
I'm not quite sure *exactly* what it is you're trying to do here, but my rough guess is that it's real-time multimedia. Judging by some of the other things on the site -- support vector machines, BLAS, etc. -- I think you probably know enough to code the whole thing in C or C++, and if you can do so, that's what I'd recommend.
In fact, I'd recommend getting one of the Linux audio distributions, like JAD or Studio 64, and getting the real "hard real-time" (as hard real-time as Linux can get, anyhow) libraries up and running. I've mostly looked at Studio 64 because I have a 64-bit machine, but JAD is also good. Both are Debian Linux based and have special kernel patches and other software for low-latency audio processing.
Lua is probably a good bit faster than Ruby, but I don't know how much of the application has to be in the scripting language and how much in close-to-the-metal C/C++. I really don't think you want a garbage-collected language for this, although I'm sure it's possible to use one if the heavy lifting is done in a low-level library.
Speaking of low-level libraries, since you're looking at BLAS, LAPACK, support vector machines, etc., you might want to install Atlas (Automatically Tuned Linear Algebra Subroutines). They just released 3.8.0 and it's hand tuned to most modern chips. On my dual-core Athlon64 X2 2200+ I've gotten close to 10 GFLOPS on 32-bit operations!