[Haskell-beginners] Problem reading sound data from mic with TChan
Martin Vlk
martin at vlkk.cz
Sun Dec 20 17:24:18 UTC 2015
Hi, I am working on a little toy project related to controlling graphics
display based on data from the computer microphone.
I am basing the whole thing on concepts from game programming, so I have
a main loop which reads inputs, updates the world state and generates
outputs.
As part of inputs there is microphone. I read data from it using the
pulse-simple library. The "simpleRead" function blocks if there is not
enough data available so I can't use it directly in the main loop or I
risk delays.
So I figured I'll use a separate thread to read from the mic and write
data into a TChan. The main loop in separate thread then can read from
the TChan as needed and test for availability of data to avoid delaying
the main loop.
Here is my current code: http://lpaste.net/147522
The data is written into TChan in the "handleMic" function and read from
the TChan on line 85.
The problem I have is that the TChan never seems to contain any data
when I read from it and that confuses me. Why?
Does anyone see where is my problem?
Many Thanks
Martin
More information about the Beginners
mailing list