[Haskell-cafe] FFI woes!

Keean Schupke k.schupke at imperial.ac.uk
Thu Dec 16 13:20:52 EST 2004


In which case I would assume the whole sample is copied to the sound 
cards buffer
before the play call returns, so you don't have to worry and just let it 
be garbage collected.

    Keean

Sebastian Sylvan wrote:

>On Thu, 16 Dec 2004 12:35:55 +0000, Keean Schupke
><k.schupke at imperial.ac.uk> wrote:
>  
>
>>Okay, you want to poll to see if the sound is still playing... This is
>>not very
>>easy to do...
>>
>>You really want to use the low-buffer callback from the soundcard
>>driver to load the next sample into the buffer using DMA. (IE you
>>can pass a function to the driver to call when you sample has been
>>copied completely to the sound-cards memory). This is the way to
>>do it...
>>
>>    play_then_free = do
>>        set_callback (free_sample my_sample)
>>        play_sample my_sample
>>
>>You can see that this provides the interface you want to the user (IE
>>samples are freed once they are finished with)...
>>
>>    Keean.
>>    
>>
>
>
>This is exactly how I do it for the Stream sound type, since this type
>of sound supplies a callback for when it reaches the end. The sound
>sample does not, though.
>(stream is streamed from disk, sound sample is loaded into memory).
>
>/S
>
>
>  
>



More information about the Haskell-Cafe mailing list