Re: [Haskell-cafe] ANN: Hemkay, the 100% Haskell MOD player

Patai, I asked a similar question about a week ago, inquiring about efficient buffers for audio. I got a good response:
http://thread.gmane.org/gmane.comp.lang.haskell.cafe/67258/focus=67293 Well, the general lesson seems to be that using stream fusion or something analogous is the way to go. In this particular case I don't need any fancy processing, and I have no feedback loops. All I do in my mixing routine is to calculate a weighted (volume+panning) sum of samples and stretch them in time as dictated by their frequency. The song is flattened into a series of play states first, so all the information required for mixing is readily available.
I could try rewriting the mixer to return an iterative generator function instead, which could be passed to an appropriate sound interface. The latter would have to be written once and for all. Gergely -- http://www.fastmail.fm - Does exactly what it says on the tin

Hi Patai, Your message has motivated me to publish my own PortAudio binding, which provides a simpler, more efficient callback-based interface: http://github.com/mietek/portaudio The documentation is incomplete, but along with the example program, it should be enough to get you going: http://github.com/mietek/portaudio/blob/master/examples/Play.hs Best regards, -- Mietek Bąk

The documentation is incomplete, but along with the example program, it should be enough to get you going: http://github.com/mietek/portaudio/blob/master/examples/Play.hs Yes, it looks like something worth giving a go. I'll try it soon, thanks.
Gergely -- http://www.fastmail.fm - The way an email service should be

Hello again,
Your message has motivated me to publish my own PortAudio binding, which provides a simpler, more efficient callback-based interface: http://github.com/mietek/portaudio I tried this, and after rewriting the code a bit, I managed to decrease CPU load by 70-80%, which is not bad for starters. However, I'm getting random segfaults, and I've no idea why.
Here's the modified player module (hpaste kindly rearranged the empty lines for some reason): http://hpaste.org/fastcgi/hpaste.fcgi/view?id=14347 Instead of building a list of samples right away, I use an unfoldr-style generator to fill the buffer, whose initial state is created by mixGenerator, and its stepper function is nextSample. In order to get this working, I renamed your module to avoid conflict with the other PortAudio binding, and I had to change the dependencies in the cabal file to base >= 4 && < 5 because of the exception handling code. There's also some broken MVar-based code to handle the end of the song, you can ignore that for the time being. Gergely -- http://www.fastmail.fm - The professional email service
participants (2)
-
Mietek Bąk
-
Patai Gergely