34 #if defined(__APPLE__) 35 #include <GLUT/glut.h> 65 int16_t* cancelled,
void *unknown) {
75 int left = num_samples - first;
109 glClear(GL_COLOR_BUFFER_BIT);
110 glMatrixMode(GL_MODELVIEW);
126 for(mic = 0; mic < 4; mic++) {
127 glBegin(GL_LINE_STRIP);
128 glColor4f(1.0f, 1.0f, 1.0f, 0.7f);
130 glVertex3f(x, ((
float)
win_h * (
float)(2*mic + 1) / 8. ) + (
float)(state.
buffers[mic][(base_idx + i) % state.
max_samples]) * ((
float)
win_h/4) /2147483647. , 0);
141 glViewport(0, 0, w, h);
142 glMatrixMode(GL_PROJECTION);
144 glOrtho(0.0, (
float)w, (
float)h, 0.0, -1.0, 1.0);
145 glMatrixMode(GL_MODELVIEW);
159 int main(
int argc,
char** argv) {
161 printf(
"freenect_init() failed\n");
168 printf (
"Number of devices found: %d\n", nr_devices);
169 if (nr_devices < 1) {
174 int user_device_number = 0;
176 printf(
"Could not open device\n");
198 printf(
"pthread_create failed\n");
202 printf(
"This is the libfreenect microphone waveform viewer. Press 'q' to quit or spacebar to pause/unpause the view.\n");
204 glutInit(&argc, argv);
205 glutInitDisplayMode(GLUT_DOUBLE | GLUT_RGBA | GLUT_ALPHA );
206 glutInitWindowSize(800, 600);
207 glutInitWindowPosition(0, 0);
208 glutCreateWindow(
"Microphones");
209 glClearColor(0.0, 0.0, 0.0, 0.0);
211 glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
static freenect_context * f_ctx
void freenect_select_subdevices(freenect_context *ctx, freenect_device_flags subdevs)
pthread_cond_t audiobuf_cond
FREENECTAPI int freenect_stop_audio(freenect_device *dev)
void Reshape(int w, int h)
int freenect_num_devices(freenect_context *ctx)
int freenect_shutdown(freenect_context *ctx)
void in_callback(freenect_device *dev, int num_samples, int32_t *mic1, int32_t *mic2, int32_t *mic3, int32_t *mic4, int16_t *cancelled, void *unknown)
void freenect_set_log_level(freenect_context *ctx, freenect_loglevel level)
FREENECTAPI void freenect_set_audio_in_callback(freenect_device *dev, freenect_audio_in_cb callback)
void * freenect_get_user(freenect_device *dev)
static freenect_device * f_dev
void * freenect_threadfunc(void *arg)
FREENECTAPI int freenect_start_audio(freenect_device *dev)
int freenect_close_device(freenect_device *dev)
pthread_t freenect_thread
int freenect_open_device(freenect_context *ctx, freenect_device **dev, int index)
int main(int argc, char **argv)
void Keyboard(unsigned char key, int x, int y)
pthread_mutex_t audiobuf_mutex
int freenect_process_events(freenect_context *ctx)
void freenect_set_user(freenect_device *dev, void *user)
int freenect_init(freenect_context **ctx, freenect_usb_context *usb_ctx)