SFML-2.3.2.4: SFML bindings

Safe HaskellNone
LanguageHaskell98

SFML.Audio.SoundRecorder

Synopsis

Documentation

module SFML.Utils

type SoundRecorderStartCallback a = Ptr a -> IO CInt Source

Type of the callback used when starting a capture.

type SoundRecorderProcessCallback a = Ptr Word16 -> CUInt -> Ptr a -> IO Bool Source

Type of the callback used to process audio data.

type SoundRecorderStopCallback a = Ptr a -> IO () Source

Type of the callback used when stopping a capture.

createSoundRecorder Source

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 SoundRecorder object (Nothing if failed)

Construct a new sound recorder from callback functions.

destroy :: SFResource a => a -> IO () Source

Destroy the given SFML resource.

startRecording Source

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 () Source

Stop the capture of a sound recorder.

getSampleRate :: SFSampled a => a -> IO Int Source

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 Source

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.

setProcessingInterval Source

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] Source

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 Source

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.

setSoundRecordingDevice Source

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 Source

Get the name of the current audio capture device.