I just wanted to wish everyone a Merry Christmas... and much
peace for the New Year.
I've been a little bogged down in refactoring the file
save/restore (serialization) code... which is an ugly beast.
Meanwhile, based on a conversation on the Hydrogen list I
created a real-time safe string class in composite-labs.
It may one day be used for Logging in Composite.
SERIALIZATION
-------------
When moving the Instrument/Sample instances into the Sampler
class (so that they are wholly owned and operated by the
Sampler)... this really jacks up the assumptions made when
saving and loading songs, drumkits, etc. At the same time,
saving and loading files requires that all audio processing
stop while it happens.
I'm refactoring the serialization code so that songs and
samples can be loaded without interrupting audio processing.
I'm also breaking it up to reuse code better. (The same
code was copied in 2 or 3 places to do the same task.) I'm
also setting it up with a scheme that allows the Sampler to
own the Instruments.
I originally planned to write tests for the old
serialization code, and then refactor. That was taking too
long, too -- and the tests will mostly need to be rewritten
when I'm done, anyway.
It's not fun, and it's been busy lately, so this part is
going slower than I expect.
REAL-TIME SAFE STRINGS
----------------------
The logging in Composite is done using QStrings, which are
not safe for use in real-time code.[1] A discussion on
Hydrogen inspired me to create the template class RtString<>
in composite-labs[2].
As it happens, it's also very fast. It's 3x faster than
std::string, 6x faster than QString, and almost as fast as
using snprintf() on a char[] string (it's 25% slower).
It remains to be seen if this makes its way into Composite.
At the moment, I'm supposed to be working on Serialization
and plug-in code... not RT-safe logging. :-)
Merry Christmas,
Gabriel
[1] The constructors (QString::Qstring()) and the assignment
operator (QString::operator=()) have been found to /not/
be realtime safe. Also, it is known that it allocates
all memory for the strings dynamically (on the heap),
which is a real-time programming violation. Composite
works around it by having an integer log-level check
in the ERRORLOG() macros. Therefore it's only a
violation if the logging level is set high.
[2] http://gitorious.org/composite/composite-labs/trees/master/200912-rtstring