I'm writing an audio program in Haskell using Portaudio. I have a function that generates a list of samples I'd like to play, and I'm trying to play them using the following snippet inside main:
curSamps <- return (chunk 1 (sineWave 440 44100))
forever $ do
Right numSampsAvail <- getStreamWriteAvailable paStream
Right NoError <- writeStream paStream curSamps numSampsAvail
curSamps <- return (drop numSampsAvail curSamps)
sineWave is a function I've created to generate an infinite list of Int16 samples of a sinewave at a specified frequency and sample rate.
When I debug this code, by replacing the audio output code with a putStrLn, it prints all 0s, which is the first sample from the function.
How can I iterate over this list with the audio output functions? I don't think I can use recursion or a map.
Edit: Code copying mistake