I know that feeling!Kamineko wrote:That code was running on an Acer Travelmate C300 laptop running whatever default AC97 stuff Linux (Debian Wheezy) gives me. I don't see much in the way of visible options in the KDE settings and poking around sounds like a good way to fruitlessly waste a fortnight. Having working audio in Linux for me is already a major victory.
Like the filaments in a plasma ball, then?Kamineko wrote:It would look like a strange smooth curve shooting around between the on-screen objects linking them all together. (Though the interconnecting mesh would flicker madly as the best non-wiggly solution changed from frame to frame.)
Anyway... stopped back in because I realised that it's pretty trivial to model the high-pass filter which causes the major drift, but not necessarily so easy to tune the model to match as precisely as you need.
So basically, you've got someone doing this to your data (assuming buffer[0..buffer_size] is all part of the same channel):
Code: Select all
static float capv = 0.0;
for (i = 0; i < buffer_size; i++)
{
capv = capv + (buffer[i] - capv) * 0.01;
buffer[i] = buffer[i] - capv;
}
Anyway... while you're generating your data, you can keep your own model of capv (repeat the first line, above), and whenever you get to a don't-care part of your buffer, you stuff in values that will push capv back towards zero.
Code: Select all
float capv_model = 0.0;
for (i = 0; i < buffer_size; i++)
{
if (buffer[i] == FILLERVALUE)
{
if (capv_model < 0)
buffer[i] = PLUS_LOTS;
else
buffer[i] = MINUS_LOTS;
}
capv_model = capv_model + (buffer[i] - capv_model) * 0.01;
}
Fortunately, because it's a single-pole filter, tuning the model incorrectly doesn't give you wild results. What will happen is that when the model capv reaches 0, the output will start to oscillate between PLUS_LOTS and MINUS_LOTS to keep the model right on zero (because PLUS_LOTS and MINUS_LOTS will make the model cross to the other side of zero instantly). Even if your tuning is out, the _real_ capacitor will be seeing the oscillation between PLUS_LOTS and MINUS_LOTS and seek to their average, which is still zero.
In theory.
Hm... but if you do this separately on two channels, when they start to oscillate they'll draw a diagonal line across the display.
Maybe stop adding filler values when you see capv_model is close to zero.




