Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 624935
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T19:15:17+00:00 2026-05-13T19:15:17+00:00

I’d like to be able to output audio from Haskell. I’m currently using GHC

  • 0

I’d like to be able to output audio from Haskell. I’m currently using GHC 6.10 on OS X (Snow Leopard). I’ve tried building the jack library (using JackOSX) and the PortAudio library, but neither of them seemed effective. Is there a relatively simple way to do live audio output from a Haskell program on a Mac?

Edit: Clarity

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T19:15:17+00:00Added an answer on May 13, 2026 at 7:15 pm

    I’ve been using PortAudio successfully.

    I took some excerpts from my toy program to make a very simple “echo” example, below:

    (run with headphones. this is a feedback loop from the mic to the speakers and may become very loud after a few feedback rounds)

    import Control.Monad (forever)
    import Data.Int (Int16)
    import Foreign.Ptr (nullPtr)
    import Sound.PortAudio
    
    initPortAudio :: Int -> IO (PaStream Int16)
    initPortAudio blockSize = do
      Right NoError <- initialize
      Just micDevIdx <- getDefaultInputDevice
      Just spkDevIdx <- getDefaultOutputDevice
      Right paStream <-
        openStream
        (Just (StreamParameters micDevIdx 1 PaInt16 0.1 nullPtr))
        (Just (StreamParameters spkDevIdx 1 PaInt16 0.1 nullPtr))
        44100 blockSize
        :: IO (Either String (PaStream Int16))
      Right NoError <- startStream paStream
      let zeroBlock = replicate blockSize [0]
      Right NoError <- writeStream paStream zeroBlock blockSize
      return paStream
    
    main :: IO ()
    main = do
      paStream <- initPortAudio blockSize
      forever $ do
        Right numSampsAvail <- getStreamReadAvailable paStream
        Right curSamps <- readStream paStream 1 numSampsAvail
        Right NoError <- writeStream paStream curSamps numSampsAvail
        return ()
      where
        blockSize = 0x800
    

    Works here in Leopard with GHC 6.10.4.

    My own toy program actually only uses audio input, and it outputs zeros to audio output (without doing that PortAudio complains).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
We're building an app, our first using Rails 3, and we're having to build
I am currently running into a problem where an element is coming back from
I would like to count the length of a string with PHP. The string
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I've got a string that has curly quotes in it. I'd like to replace
I am reading a book about Javascript and jQuery and using one of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.