The latest version of my prototype biofeedback app for Windows and
Linux is available here:
There is nothing too amazing on the outside for people who are hoping
for new features, but I've sorted out a lot of stuff on the inside.
This is still very much a prototype, and you'll probably have to
fiddle with some config values to tune it to your system.
- Audio output is now working, with some FM output to prove it works
- Serial reads can now be done either in their own thread or from the
I had to do a lot of head-scratching to figure out how to get the
three clocks synchronized (computer clock, EEG device clock, and audio
sample clock) especially considering the only available cross-checks
between these clocks may be inaccurate (e.g. processing delays may
mean we handle an incoming packet late, or an outgoing audio block
late), but this is sorted now, I think, and any clock drift is handled
Things you may want to tune in the config file:
The 'buf' setting should be a power of two and gives the audio block
size in samples. 1024 is 1024/44100*1000 == 23.2ms blocks. 512
(12ms) doesn't quite work on my Linux machine. On Windows (W98SE) I
had to up it to 2048 to get smooth audio output.
port COM1 57600;
You may want to try it with 'audio-sync' either present or commented
out. Without it, serial reads are done from their own thread. With
it, they are done along with the audio processing. In theory audio
should get higher priority than anything else, but it doesn't look
like that's always the case. Maybe it's worth trying both ways.
Probably without is better on Windows.
You might want to change the FPS (frames per second) of the displays
if the load is too much.
test-fmsig 50ms 1000+500/100;
This is the audio page (on F11). At the moment there is only some
testing code generating FM audio output. This uses EEG channels 1 and
2 to drive sine-wave oscillators on the left and right stereo outputs.
The centre frequency is 1000Hz here, with frequencies ranging between
1000-500 and 1000+500 (i.e. 500Hz to 1500Hz). The volume level here
is 100 (meaning 100%).
The ms figure tells the audio code how far back in time to look for
the data samples to output. You can set this to 0ms if you like, but
then every single little delay in the system will show up as
disruption in your FM audio output. The idea is to find some delay
value that the jitter rarely exceeds (see F12 screen for jitter
If you're using a 2048-sample audio buffer and 'audio-sync' set, then
you'd need to set it to 100ms or so. Probably it would be a good idea
to get rid of audio-sync, though, in that case.
The FM code does interpolation between the incoming samples, so it
should be pretty smooth. However, listening to this for too long was
giving me a headache and I was glad to turn it off -- you can comment
it out in the config file. However, it does prove that it is working.
I hope to add other audio options and more flexibility in future in
the audio output, for example a hb2.mp3 style output, or maybe a
simple amplitude-modulated noise output.
I don't know if this FM output accurately reproduces the result Joe
Street has achieved through hardware -- perhaps he can tell me if it
needs correcting in any way.
So, no big new features, but I've sorted a few things out.
It is also clear now to me that my modularEEG's outputs vary according
to processor load (I'm powering it from a USB port). This is
especially obvious with the FM feedback, because the pitch rises
everytime something happens that requires some processing
(e.g. switching between F2 and F3), and different screens "sound
different" (F12 is very quiet, for instance). Maybe this is a power
issue in my PC, or maybe a problem in my particular modularEEG (ESR
capacitor problems, perhaps?).
Jim Peters (_)/=\~/_(_) jim@...
(_) /=\ ~/_ (_)
Uazú (_) /=\ ~/_ (_) http://
B'ham, UK (_) ____ /=\ ____ ~/_ ____ (_) uazu.net
Design/view/compare digital filters with Fiview: http://uazu.net/FI