开发者

Capturing audio input from microphone, with Haskell?

开发者 https://www.devze.com 2022-12-22 23:19 出处:网络
Is there a mature library that could enable audio input and output and work within Haskell? (A nice wrapper is fine, of course.)

Is there a mature library that could enable audio input and output and work within Haskell? (A nice wrapper is fine, of course.)

I'm looking for something that can easily capture microphone input and, perhaps, play 开发者_JAVA技巧various audio files as well.


easily capture microphone input and, perhaps, play various audio files as well..

It will strongly depend on your OS platform: there are standard C libraries for this functionality on each OS, and you'll be looking for Haskell bindings to them (e.g. PulseAudio, etc). Look in the Sound category on Hackage:

  • http://hackage.haskell.org/packages/archive/pkg-list.html#cat:sound

E.g. HSndFile for audio file writing, http://hackage.haskell.org/package/HSoundFile


the module pulse-simple exposes bindings to capture sound from the microphone, see the second example at the top of the page;
https://hackage.haskell.org/package/pulse-simple-0.1.13/docs/Sound-Pulse-Simple.html
pulse audio libraries required by cabal are obtainable via cygwin (search "pulse" in the cygwin installer).

there is a also binding to sox, which looks promising. https://hackage.haskell.org/package/sox

im sure there are other api wrappers to be found in hackage sound category.

for linux there is a binding to jack, has "unix" as a dependency, it WILL NOT build on windows...


Just in case you're not familiar with hackage: http://hackage.haskell.org/packages/archive/pkg-list.html

It looks like there is some audio-related stuff there. Not sure if there is anything that will meet your needs. But most "mature" haskell libraries will be there.


You can do it with OpenAL and ALUT. I managed to install both on Windows 8, although it wasn't exactly effortless; ALUT requires the underlying C library to be compiled manually into a DLL.

Installing OpenAL - on the other hand - is as simple as downloading the SDK and typing cabal install OpenAL in the command prompt.

With ALUT, you can create OpenAL buffers from audio files (including WAV) and memory views.

I found an example of recording and audio playback here. It should be fairly straightforward to adapt the code to your needs.

Let me know if I left something out and I'll try to elaborate.

0

精彩评论

暂无评论...
验证码 换一张
取 消