libfreenect 0.1-beta
libfreenect_audio.h File Reference
#include "libfreenect.h"
#include <stdint.h>

Go to the source code of this file.

Classes

struct  freenect_sample_51
 Structure to represent a single 16-bit signed little-endian PCM sample. More...
 

Typedefs

typedef void(* freenect_audio_in_cb) (freenect_device *dev, int num_samples, int32_t *mic1, int32_t *mic2, int32_t *mic3, int32_t *mic4, int16_t *cancelled, void *unknown)
 
typedef void(* freenect_audio_out_cb) (freenect_device *dev, freenect_sample_51 *samples, int *sample_count)
 

Functions

FREENECTAPI void freenect_set_audio_in_callback (freenect_device *dev, freenect_audio_in_cb callback)
 
FREENECTAPI void freenect_set_audio_out_callback (freenect_device *dev, freenect_audio_out_cb callback)
 
FREENECTAPI int freenect_start_audio (freenect_device *dev)
 
FREENECTAPI int freenect_stop_audio (freenect_device *dev)
 

Typedef Documentation

◆ freenect_audio_in_cb

typedef void(* freenect_audio_in_cb) (freenect_device *dev, int num_samples, int32_t *mic1, int32_t *mic2, int32_t *mic3, int32_t *mic4, int16_t *cancelled, void *unknown)

Typedef for "you wanted this microphone data, here it is" event callbacks. TODO: Timestamp details The format of the unknown stream is as of yet undetermined.

Parameters
devDevice which triggered this callback
num_samplesNumber of samples provided in each of the audio data arrays (mic[1-4] and cancelled)
mic1Microphone data for the leftmost microphone: 32-bit PCM little-endian samples at 16kHz.
mic2Microphone data for the left-middle microphone: 32-bit PCM little-endian samples at 16kHz.
mic3Microphone data for the right-middle microphone: 32-bit PCM little-endian samples at 16kHz.
mic4Microphone data for the rightmost microphone: 32-bit PCM little-endian samples at 16kHz.
cancelledNoise-cancelled audio data: 16-bit PCM little-endian samples at 16kHz.

◆ freenect_audio_out_cb

typedef void(* freenect_audio_out_cb) (freenect_device *dev, freenect_sample_51 *samples, int *sample_count)

Typedef for "you're playing audio, the library needs you to fill up the outgoing audio buffer" event callbacks The library will request samples at a rate of 48000Hz.

Parameters
devDevice this callback was triggered for
samplesPointer to the memory where the library expects you to copy the next sample_count freenect_sample_51's to.
sample_countBidirectional. in: maximum number of samples the driver wants (don't copy in more than this, you'll clobber memory). out: actual number of samples provided to the driver.

Function Documentation

◆ freenect_set_audio_in_callback()

FREENECTAPI void freenect_set_audio_in_callback ( freenect_device * dev,
freenect_audio_in_cb callback )

Set the audio in callback. This is the function called when the library has new microphone samples. It will be called approximately 62.5 times per second (16kHz sample rate, expect 512 samples/callback)

Parameters
devDevice for which to set the callback
callbackCallback function to set

◆ freenect_set_audio_out_callback()

FREENECTAPI void freenect_set_audio_out_callback ( freenect_device * dev,
freenect_audio_out_cb callback )

Set the audio out callback. This is the "tell me what audio you're about to play through the speakers so the Kinect can subtract it out" callback for a given device. If you choose not set an audio_out_callback, the library will send silence to the Kinect for you - it requires data either way.

Parameters
devDevice for which to set the callback
callbackCallback function to set

◆ freenect_start_audio()

FREENECTAPI int freenect_start_audio ( freenect_device * dev)

Start streaming audio for the specified device.

Parameters
devDevice for which to start audio streaming
Returns
0 on success, < 0 if error

◆ freenect_stop_audio()

FREENECTAPI int freenect_stop_audio ( freenect_device * dev)

Stop streaming audio for the specified device.

Parameters
devDevice for which to stop audio streaming
Returns
0 on success, < 0 if error