#include <SFML/Audio/Export.h>
#include <SFML/Audio/Types.h>
#include <SFML/System/Time.h>
#include <stddef.h>
Go to the source code of this file.
Typedefs | |
typedef sfBool(* | sfSoundRecorderStartCallback) (void *) |
Type of the callback used when starting a capture. More... | |
typedef sfBool(* | sfSoundRecorderProcessCallback) (const sfInt16 *, size_t, void *) |
Type of the callback used to process audio data. More... | |
typedef void(* | sfSoundRecorderStopCallback) (void *) |
Type of the callback used when stopping a capture. More... | |
Functions | |
CSFML_AUDIO_API sfSoundRecorder * | sfSoundRecorder_create (sfSoundRecorderStartCallback onStart, sfSoundRecorderProcessCallback onProcess, sfSoundRecorderStopCallback onStop, void *userData) |
Construct a new sound recorder from callback functions. More... | |
CSFML_AUDIO_API void | sfSoundRecorder_destroy (sfSoundRecorder *soundRecorder) |
Destroy a sound recorder. More... | |
CSFML_AUDIO_API sfBool | sfSoundRecorder_start (sfSoundRecorder *soundRecorder, unsigned int sampleRate) |
Start the capture of a sound recorder. More... | |
CSFML_AUDIO_API void | sfSoundRecorder_stop (sfSoundRecorder *soundRecorder) |
Stop the capture of a sound recorder. More... | |
CSFML_AUDIO_API unsigned int | sfSoundRecorder_getSampleRate (const sfSoundRecorder *soundRecorder) |
Get the sample rate of a sound recorder. More... | |
CSFML_AUDIO_API sfBool | sfSoundRecorder_isAvailable (void) |
Check if the system supports audio capture. More... | |
CSFML_AUDIO_API void | sfSoundRecorder_setProcessingInterval (sfSoundRecorder *soundRecorder, sfTime interval) |
Set the processing interval. More... | |
CSFML_AUDIO_API const char ** | sfSoundRecorder_getAvailableDevices (size_t *count) |
Get a list of the names of all availabe audio capture devices. More... | |
CSFML_AUDIO_API const char * | sfSoundRecorder_getDefaultDevice () |
Get the name of the default audio capture device. More... | |
CSFML_AUDIO_API sfBool | sfSoundRecorder_setDevice (sfSoundRecorder *soundRecorder, const char *name) |
Set the audio capture device. More... | |
CSFML_AUDIO_API const char * | sfSoundRecorder_getDevice (sfSoundRecorder *soundRecorder) |
Get the name of the current audio capture device. More... | |
CSFML_AUDIO_API void | sfSoundRecorder_setChannelCount (sfSoundRecorder *soundRecorder, unsigned int channelCount) |
Set the channel count of the audio capture device. More... | |
CSFML_AUDIO_API unsigned int | sfSoundRecorder_getChannelCount (const sfSoundRecorder *soundRecorder) |
Get the number of channels used by this recorder. More... | |
Type of the callback used to process audio data.
Definition at line 38 of file SoundRecorder.h.
typedef sfBool(* sfSoundRecorderStartCallback) (void *) |
Type of the callback used when starting a capture.
Definition at line 37 of file SoundRecorder.h.
typedef void(* sfSoundRecorderStopCallback) (void *) |
Type of the callback used when stopping a capture.
Definition at line 39 of file SoundRecorder.h.
CSFML_AUDIO_API sfSoundRecorder* sfSoundRecorder_create | ( | sfSoundRecorderStartCallback | onStart, |
sfSoundRecorderProcessCallback | onProcess, | ||
sfSoundRecorderStopCallback | onStop, | ||
void * | userData | ||
) |
Construct a new sound recorder from callback functions.
onStart | Callback function which will be called when a new capture starts (can be NULL) |
onProcess | Callback function which will be called each time there's audio data to process |
onStop | Callback function which will be called when the current capture stops (can be NULL) |
userData | Data to pass to the callback function (can be NULL) |
CSFML_AUDIO_API void sfSoundRecorder_destroy | ( | sfSoundRecorder * | soundRecorder | ) |
Destroy a sound recorder.
soundRecorder | Sound recorder to destroy |
CSFML_AUDIO_API const char** sfSoundRecorder_getAvailableDevices | ( | size_t * | count | ) |
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 NULL is returned.
count | Pointer to a variable that will be filled with the number of modes in the array |
CSFML_AUDIO_API unsigned int sfSoundRecorder_getChannelCount | ( | const sfSoundRecorder * | soundRecorder | ) |
Get the number of channels used by this recorder.
Currently only mono and stereo are supported, so the value is either 1 (for mono) or 2 (for stereo).
CSFML_AUDIO_API const char* sfSoundRecorder_getDefaultDevice | ( | ) |
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.
CSFML_AUDIO_API const char* sfSoundRecorder_getDevice | ( | sfSoundRecorder * | soundRecorder | ) |
Get the name of the current audio capture device.
soundRecorder | Sound recorder object |
CSFML_AUDIO_API unsigned int sfSoundRecorder_getSampleRate | ( | const sfSoundRecorder * | soundRecorder | ) |
Get the sample rate of a sound recorder.
The sample rate defines the number of audio samples captured per second. The higher, the better the quality (for example, 44100 samples/sec is CD quality).
soundRecorder | Sound recorder object |
CSFML_AUDIO_API sfBool sfSoundRecorder_isAvailable | ( | void | ) |
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 sfSoundRecorder will fail.
CSFML_AUDIO_API void sfSoundRecorder_setChannelCount | ( | sfSoundRecorder * | soundRecorder, |
unsigned int | channelCount | ||
) |
Set the channel count of the audio capture device.
This method allows you to specify the number of channels used for recording. Currently only 16-bit mono and 16-bit stereo are supported.
channelCount | Number of channels. Currently only mono (1) and stereo (2) are supported. |
CSFML_AUDIO_API sfBool sfSoundRecorder_setDevice | ( | sfSoundRecorder * | soundRecorder, |
const char * | name | ||
) |
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.
soundRecorder | Sound recorder object |
name | The name of the audio capture device |
CSFML_AUDIO_API void sfSoundRecorder_setProcessingInterval | ( | sfSoundRecorder * | soundRecorder, |
sfTime | interval | ||
) |
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.
soundRecorder | Sound recorder object |
interval | Processing interval |
CSFML_AUDIO_API sfBool sfSoundRecorder_start | ( | sfSoundRecorder * | soundRecorder, |
unsigned int | sampleRate | ||
) |
Start the capture of a sound recorder.
The sampleRate 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.
soundRecorder | Sound recorder object |
sampleRate | Desired capture rate, in number of samples per second |
CSFML_AUDIO_API void sfSoundRecorder_stop | ( | sfSoundRecorder * | soundRecorder | ) |
Stop the capture of a sound recorder.
soundRecorder | Sound recorder object |