Safe Haskell | None |
---|---|
Language | Haskell98 |
SFML.Audio.SoundRecorder
- module SFML.Utils
- type SoundRecorderStartCallback a = Ptr a -> IO CInt
- type SoundRecorderProcessCallback a = Ptr Word16 -> CUInt -> Ptr a -> IO Bool
- type SoundRecorderStopCallback a = Ptr a -> IO ()
- createSoundRecorder :: Ptr (SoundRecorderStartCallback a) -> Ptr (SoundRecorderProcessCallback a) -> Ptr (SoundRecorderStopCallback a) -> Ptr a -> IO (Either SFException SoundRecorder)
- destroy :: SFResource a => a -> IO ()
- startRecording :: SFSoundRecorder a => a -> Int -> IO Bool
- stopRecording :: SFSoundRecorder a => a -> IO ()
- getSampleRate :: SFSampled a => a -> IO Int
- isSoundRecorderAvailable :: IO Bool
- setProcessingInterval :: SoundRecorder -> Time -> IO ()
- getAvailableSoundRecordingDevices :: IO [String]
- getDefaultSoundRecordingDevice :: IO String
- setSoundRecordingDevice :: SoundRecorder -> String -> IO Bool
- getSoundRecordingDevice :: SoundRecorder -> IO String
Documentation
module SFML.Utils
type SoundRecorderStartCallback a = Ptr a -> IO CInt
Type of the callback used when starting a capture.
type SoundRecorderProcessCallback a = Ptr Word16 -> CUInt -> Ptr a -> IO Bool
Type of the callback used to process audio data.
type SoundRecorderStopCallback a = Ptr a -> IO ()
Type of the callback used when stopping a capture.
Arguments
:: Ptr (SoundRecorderStartCallback a) | (onStart) Callback function which will be called when a new capture starts (can be NULL) |
-> Ptr (SoundRecorderProcessCallback a) | (onProcess) Callback function which will be called each time there's audio data to process |
-> Ptr (SoundRecorderStopCallback a) | (onStop) Callback function which will be called when the current capture stops (can be NULL) |
-> Ptr a | Data to pass to the callback function (can be NULL) |
-> IO (Either SFException SoundRecorder) | A new |
Construct a new sound recorder from callback functions.
destroy :: SFResource a => a -> IO ()
Destroy the given SFML resource.
Arguments
:: SFSoundRecorder a | |
=> a | |
-> Int | Desired capture rate, in number of samples per second |
-> IO Bool |
Start the capture of a sound recorder.
The sample rate parameter defines the number of audio samples captured per second. The higher, the better the quality (for example, 44100 samples/sec is CD quality).
This function uses its own thread so that it doesn't block the rest of the program while the capture runs.
Please note that only one capture can happen at the same time.
Return True
if start of capture was successful, False
otherwise.
stopRecording :: SFSoundRecorder a => a -> IO ()
Stop the capture of a sound recorder.
getSampleRate :: SFSampled a => a -> IO Int
Get the sample rate of a sound buffer.
The sample rate is the number of samples played per second. The higher, the better the quality (for example, 44100 samples/s is CD quality).
isSoundRecorderAvailable :: IO Bool
Check if the system supports audio capture.
This function should always be called before using
the audio capture features. If it returns false, then
any attempt to use SoundRecorder
will fail.
Arguments
:: SoundRecorder | |
-> Time | Processing interval |
-> IO () |
Set the processing interval.
The processing interval controls the period between calls to the onProcessSamples function. You may want to use a small interval if you want to process the recorded data in real time, for example.
Note: this is only a hint, the actual period may vary. So don't rely on this parameter to implement precise timing.
The default processing interval is 100 ms.
getAvailableSoundRecordingDevices :: IO [String]
Get a list of the names of all availabe audio capture devices.
This function returns an array of strings (null terminated),
containing the names of all availabe audio capture devices.
If no devices are available then Nothing
is returned.
getDefaultSoundRecordingDevice :: IO String
Get the name of the default audio capture device.
This function returns the name of the default audio capture device. If none is available, NULL is returned.
Arguments
:: SoundRecorder | |
-> String | The name of the audio capture device |
-> IO Bool |
Set the audio capture device.
This function sets the audio capture device to the device with the given name. It can be called on the fly (i.e: while recording). If you do so while recording and opening the device fails, it stops the recording.
Return 'True if it was able to set the requested device, False
otherwise.
getSoundRecordingDevice :: SoundRecorder -> IO String
Get the name of the current audio capture device.