vrpn  07.33
Virtual Reality Peripheral Network
vrpn_Sound.C
Go to the documentation of this file.
1 #include <stdio.h> // for fprintf, stderr, printf
2 #include <string.h> // for strlen
3 
4 #include "vrpn_Connection.h" // for vrpn_HANDLERPARAM, etc
5 #include "vrpn_Sound.h"
6 
7 // vrpn_Sound constructor.
9  : vrpn_BaseClass(name, c)
10 {
12 }
13 
15 {
17  d_connection->register_message_type("vrpn_Sound Load_Local");
19  d_connection->register_message_type("vrpn_Sound Load_Remote");
20  unload_sound = d_connection->register_message_type("vrpn_Sound Unload");
21  play_sound = d_connection->register_message_type("vrpn_Sound Play");
22  stop_sound = d_connection->register_message_type("vrpn_Sound Stop");
24  d_connection->register_message_type("vrpn_Sound Status");
25 
27  d_connection->register_message_type("vrpn_Sound Listener_Pose");
29  d_connection->register_message_type("vrpn_Sound Listener_Velocity");
30 
33  d_connection->register_message_type("vrpn_Sound Velocity");
35  d_connection->register_message_type("vrpn_Sound DistInfo");
37  d_connection->register_message_type("vrpn_Sound ConeInfo");
38 
40  d_connection->register_message_type("vrpn_Sound DopFac");
42  set_sound_pitch = d_connection->register_message_type("vrpn_Sound Pitch");
43  set_sound_volume = d_connection->register_message_type("vrpn_Sound Volume");
44 
46  d_connection->register_message_type("vrpn_Sound Load_Model_Local");
48  d_connection->register_message_type("vrpn_Sound Load_Model_Remote");
50  d_connection->register_message_type("vrpn_Sound Load_Poly_Quad");
51  load_polytri =
52  d_connection->register_message_type("vrpn_Sound Load_Poly_Tri");
54  d_connection->register_message_type("vrpn_Sound Load_Material");
56  d_connection->register_message_type("vrpn_Sound Quad_Vertices");
58  d_connection->register_message_type("vrpn_Sound Tri_Vertices");
60  d_connection->register_message_type("vrpn_Sound Poly_OF");
62  d_connection->register_message_type("vrpn_Sound Poly_Material");
63 
64  return 0;
65 }
66 
68 
69 vrpn_int32 vrpn_Sound::encodeSound_local(const char *filename,
70  const vrpn_SoundID id,
71  const vrpn_SoundDef sound, char **buf)
72 {
73  vrpn_int32 len = static_cast<vrpn_int32>(
74  sizeof(vrpn_SoundID) + strlen(filename) + sizeof(vrpn_SoundDef) + 1);
75  vrpn_int32 ret = len;
76  char *mptr;
77  int i;
78 
79  *buf = new char[len];
80 
81  mptr = *buf;
82  vrpn_buffer(&mptr, &len, id);
83 
84  for (i = 0; i < 3; i++)
85  vrpn_buffer(&mptr, &len, sound.pose.position[i]);
86 
87  for (i = 0; i < 4; i++)
88  vrpn_buffer(&mptr, &len, sound.pose.orientation[i]);
89 
90  for (i = 0; i < 4; i++)
91  vrpn_buffer(&mptr, &len, sound.velocity[i]);
92 
93  vrpn_buffer(&mptr, &len, sound.volume);
94 
95  vrpn_buffer(&mptr, &len, sound.max_back_dist);
96  vrpn_buffer(&mptr, &len, sound.min_back_dist);
97  vrpn_buffer(&mptr, &len, sound.max_front_dist);
98  vrpn_buffer(&mptr, &len, sound.min_front_dist);
99 
100  vrpn_buffer(&mptr, &len, sound.cone_inner_angle);
101  vrpn_buffer(&mptr, &len, sound.cone_outer_angle);
102  vrpn_buffer(&mptr, &len, sound.cone_gain);
103  vrpn_buffer(&mptr, &len, sound.dopler_scale);
104  vrpn_buffer(&mptr, &len, sound.equalization_val);
105  vrpn_buffer(&mptr, &len, sound.pitch);
106 
107  vrpn_buffer(&mptr, &len, filename,
108  static_cast<vrpn_int32>(strlen(filename)) + 1);
109 
110  return ret;
111 }
112 
113 // Decodes the file and Client Index number
114 vrpn_int32 vrpn_Sound::decodeSound_local(const char *buf, char **filename,
115  vrpn_SoundID *id, vrpn_SoundDef *sound,
116  const int payload)
117 {
118  const char *mptr = buf;
119  int i;
120 
121  *filename =
122  new char[payload - sizeof(vrpn_SoundID) - sizeof(vrpn_SoundDef)];
123 
124  vrpn_unbuffer(&mptr, id);
125 
126  for (i = 0; i < 3; i++)
127  vrpn_unbuffer(&mptr, &(sound->pose.position[i]));
128 
129  for (i = 0; i < 4; i++)
130  vrpn_unbuffer(&mptr, &(sound->pose.orientation[i]));
131 
132  for (i = 0; i < 4; i++)
133  vrpn_unbuffer(&mptr, &(sound->velocity[i]));
134 
135  vrpn_unbuffer(&mptr, &(sound->volume));
136 
137  vrpn_unbuffer(&mptr, &(sound->max_back_dist));
138  vrpn_unbuffer(&mptr, &(sound->min_back_dist));
139  vrpn_unbuffer(&mptr, &(sound->max_front_dist));
140  vrpn_unbuffer(&mptr, &(sound->min_front_dist));
141 
142  vrpn_unbuffer(&mptr, &(sound->cone_inner_angle));
143  vrpn_unbuffer(&mptr, &(sound->cone_outer_angle));
144  vrpn_unbuffer(&mptr, &(sound->cone_gain));
145  vrpn_unbuffer(&mptr, &(sound->dopler_scale));
146  vrpn_unbuffer(&mptr, &(sound->equalization_val));
147  vrpn_unbuffer(&mptr, &(sound->pitch));
148 
149  vrpn_unbuffer(&mptr, *filename,
150  payload - sizeof(vrpn_SoundID) - sizeof(vrpn_SoundDef));
151 
152  return 0;
153 }
154 
156 vrpn_int32 vrpn_Sound::encodeSound_remote(const char * /*filename*/,
157  const vrpn_SoundID /*id*/,
158  char ** /*buf*/)
159 {
160  return 0;
161 }
163 vrpn_int32 vrpn_Sound::decodeSound_remote(const char * /*buf*/,
164  char ** /*filename*/,
165  vrpn_SoundID * /*id*/,
166  const int /*payload*/)
167 {
168  return 0;
169 }
170 
171 // Encodes the client sound ID
172 vrpn_int32 vrpn_Sound::encodeSoundID(const vrpn_SoundID id, char *buf)
173 {
174  char *mptr = buf;
175  vrpn_int32 len = sizeof(vrpn_SoundID);
176 
177  vrpn_buffer(&mptr, &len, id);
178 
179  return (sizeof(vrpn_SoundID));
180 }
181 
182 // Decodes the client sound ID
183 vrpn_int32 vrpn_Sound::decodeSoundID(const char *buf, vrpn_SoundID *id)
184 {
185  const char *mptr = buf;
186 
187  vrpn_unbuffer(&mptr, id);
188 
189  return 0;
190 }
191 
192 // Sends all the information necessary to play a sound appropriately.
193 // IE, The sounds position, orientation, velocity, volume and repeat count
195  const vrpn_SoundID id,
196  const vrpn_int32 repeat, char *buf)
197 {
198  char *mptr = buf;
199  vrpn_int32 len =
200  sizeof(vrpn_SoundDef) + sizeof(vrpn_SoundID) + sizeof(vrpn_int32);
201  vrpn_int32 ret = len;
202  int i;
203 
204  vrpn_buffer(&mptr, &len, repeat);
205  vrpn_buffer(&mptr, &len, id);
206 
207  for (i = 0; i < 3; i++)
208  vrpn_buffer(&mptr, &len, sound.pose.position[i]);
209 
210  for (i = 0; i < 4; i++)
211  vrpn_buffer(&mptr, &len, sound.pose.orientation[i]);
212 
213  for (i = 0; i < 4; i++)
214  vrpn_buffer(&mptr, &len, sound.velocity[i]);
215 
216  vrpn_buffer(&mptr, &len, sound.volume);
217 
218  vrpn_buffer(&mptr, &len, sound.max_back_dist);
219  vrpn_buffer(&mptr, &len, sound.min_back_dist);
220  vrpn_buffer(&mptr, &len, sound.max_front_dist);
221  vrpn_buffer(&mptr, &len, sound.min_front_dist);
222 
223  vrpn_buffer(&mptr, &len, sound.cone_inner_angle);
224  vrpn_buffer(&mptr, &len, sound.cone_outer_angle);
225  vrpn_buffer(&mptr, &len, sound.cone_gain);
226  vrpn_buffer(&mptr, &len, sound.dopler_scale);
227  vrpn_buffer(&mptr, &len, sound.equalization_val);
228  vrpn_buffer(&mptr, &len, sound.pitch);
229 
230  return ret;
231 }
232 
233 vrpn_int32 vrpn_Sound::decodeSoundDef(const char *buf, vrpn_SoundDef *sound,
234  vrpn_SoundID *id, vrpn_int32 *repeat)
235 {
236  const char *mptr = buf;
237  int i;
238 
239  vrpn_unbuffer(&mptr, repeat);
240  vrpn_unbuffer(&mptr, id);
241 
242  for (i = 0; i < 3; i++)
243  vrpn_unbuffer(&mptr, &(sound->pose.position[i]));
244 
245  for (i = 0; i < 4; i++)
246  vrpn_unbuffer(&mptr, &(sound->pose.orientation[i]));
247 
248  for (i = 0; i < 4; i++)
249  vrpn_unbuffer(&mptr, &(sound->velocity[i]));
250 
251  vrpn_unbuffer(&mptr, &(sound->volume));
252 
253  vrpn_unbuffer(&mptr, &(sound->max_back_dist));
254  vrpn_unbuffer(&mptr, &(sound->min_back_dist));
255  vrpn_unbuffer(&mptr, &(sound->max_front_dist));
256  vrpn_unbuffer(&mptr, &(sound->min_front_dist));
257 
258  vrpn_unbuffer(&mptr, &(sound->cone_inner_angle));
259  vrpn_unbuffer(&mptr, &(sound->cone_outer_angle));
260  vrpn_unbuffer(&mptr, &(sound->cone_gain));
261  vrpn_unbuffer(&mptr, &(sound->dopler_scale));
262  vrpn_unbuffer(&mptr, &(sound->equalization_val));
263  vrpn_unbuffer(&mptr, &(sound->pitch));
264 
265  return 0;
266 }
267 
268 // Sends information about the listener. IE position, orientation and velocity
269 vrpn_int32 vrpn_Sound::encodeListenerPose(const vrpn_PoseDef pose, char *buf)
270 {
271  char *mptr = buf;
272  vrpn_int32 len = sizeof(vrpn_ListenerDef);
273  vrpn_int32 ret = len;
274  int i;
275 
276  for (i = 0; i < 3; i++)
277  vrpn_buffer(&mptr, &len, pose.position[i]);
278 
279  for (i = 0; i < 4; i++)
280  vrpn_buffer(&mptr, &len, pose.orientation[i]);
281 
282  return ret;
283 }
284 
285 vrpn_int32 vrpn_Sound::decodeListenerPose(const char *buf, vrpn_PoseDef *pose)
286 {
287  const char *mptr = buf;
288  int i;
289 
290  for (i = 0; i < 3; i++)
291  vrpn_unbuffer(&mptr, &pose->position[i]);
292 
293  for (i = 0; i < 4; i++)
294  vrpn_unbuffer(&mptr, &pose->orientation[i]);
295 
296  return 0;
297 }
298 
300  const vrpn_int32 repeat, char *buf)
301 {
302  char *mptr = buf;
303  vrpn_int32 len = sizeof(vrpn_SoundID) + sizeof(vrpn_int32);
304  vrpn_int32 ret = len;
305 
306  vrpn_buffer(&mptr, &len, repeat);
307  vrpn_buffer(&mptr, &len, id);
308  return ret;
309 }
310 
311 vrpn_int32 vrpn_Sound::decodeSoundPlay(const char *buf, vrpn_SoundID *id,
312  vrpn_int32 *repeat)
313 {
314  const char *mptr = buf;
315 
316  vrpn_unbuffer(&mptr, repeat);
317  vrpn_unbuffer(&mptr, id);
318  return 0;
319 }
320 
321 vrpn_int32 vrpn_Sound::encodeListenerVelocity(const vrpn_float64 *velocity,
322  char *buf)
323 {
324  char *mptr = buf;
325  vrpn_int32 len = sizeof(vrpn_float64) * 4;
326  vrpn_int32 ret = len;
327  int i;
328 
329  for (i = 0; i < 4; i++)
330  vrpn_buffer(&mptr, &len, velocity[i]);
331 
332  return ret;
333 }
334 
335 vrpn_int32 vrpn_Sound::decodeListenerVelocity(const char *buf,
336  vrpn_float64 *velocity)
337 {
338  const char *mptr = buf;
339 
340  for (int i = 0; i < 4; i++)
341  vrpn_unbuffer(&mptr, &velocity[i]);
342 
343  return 0;
344 }
345 
347  const vrpn_SoundID id, char *buf)
348 {
349  char *mptr = buf;
350  vrpn_int32 len = sizeof(vrpn_SoundID) + sizeof(vrpn_PoseDef);
351  vrpn_int32 ret = len;
352  int i;
353 
354  vrpn_buffer(&mptr, &len, id);
355 
356  for (i = 0; i < 4; i++)
357  vrpn_buffer(&mptr, &len, pose.orientation[i]);
358 
359  for (i = 0; i < 3; i++)
360  vrpn_buffer(&mptr, &len, pose.position[i]);
361 
362  return ret;
363 }
364 
365 vrpn_int32 vrpn_Sound::decodeSoundPose(const char *buf, vrpn_PoseDef *pose,
366  vrpn_SoundID *id)
367 {
368  const char *mptr = buf;
369  int i;
370 
371  vrpn_unbuffer(&mptr, id);
372 
373  for (i = 0; i < 4; i++)
374  vrpn_unbuffer(&mptr, &pose->orientation[i]);
375 
376  for (i = 0; i < 3; i++)
377  vrpn_unbuffer(&mptr, &pose->position[i]);
378 
379  return 0;
380 }
381 
382 vrpn_int32 vrpn_Sound::encodeSoundVelocity(const vrpn_float64 *velocity,
383  const vrpn_SoundID id, char *buf)
384 {
385  char *mptr = buf;
386  vrpn_int32 len = sizeof(vrpn_SoundID) + sizeof(vrpn_float64) * 4;
387  vrpn_int32 ret = len;
388  int i;
389 
390  vrpn_buffer(&mptr, &len, id);
391 
392  for (i = 0; i < 4; i++)
393  vrpn_buffer(&mptr, &len, velocity[i]);
394 
395  return ret;
396 }
397 
398 vrpn_int32 vrpn_Sound::decodeSoundVelocity(const char *buf,
399  vrpn_float64 *velocity,
400  vrpn_SoundID *id)
401 {
402  const char *mptr = buf;
403  int i;
404 
405  vrpn_unbuffer(&mptr, id);
406 
407  for (i = 0; i < 4; i++)
408  vrpn_unbuffer(&mptr, &velocity[i]);
409 
410  return 0;
411 }
412 
413 vrpn_int32 vrpn_Sound::encodeSoundDistInfo(const vrpn_float64 min_back,
414  const vrpn_float64 max_back,
415  const vrpn_float64 min_front,
416  const vrpn_float64 max_front,
417  const vrpn_SoundID id, char *buf)
418 {
419  char *mptr = buf;
420  vrpn_int32 len = sizeof(vrpn_SoundID) + sizeof(vrpn_float64) * 4;
421  vrpn_int32 ret = len;
422 
423  vrpn_buffer(&mptr, &len, id);
424 
425  vrpn_buffer(&mptr, &len, min_back);
426  vrpn_buffer(&mptr, &len, max_back);
427  vrpn_buffer(&mptr, &len, min_front);
428  vrpn_buffer(&mptr, &len, max_front);
429 
430  return ret;
431 }
432 vrpn_int32
433 vrpn_Sound::decodeSoundDistInfo(const char *buf, vrpn_float64 *min_back,
434  vrpn_float64 *max_back, vrpn_float64 *min_front,
435  vrpn_float64 *max_front, vrpn_SoundID *id)
436 {
437  const char *mptr = buf;
438  vrpn_unbuffer(&mptr, id);
439 
440  vrpn_unbuffer(&mptr, min_back);
441  vrpn_unbuffer(&mptr, max_back);
442  vrpn_unbuffer(&mptr, min_front);
443  vrpn_unbuffer(&mptr, max_front);
444 
445  return 0;
446 }
447 
448 vrpn_int32 vrpn_Sound::encodeSoundConeInfo(const vrpn_float64 cone_inner_angle,
449  const vrpn_float64 cone_outer_angle,
450  const vrpn_float64 cone_gain,
451  const vrpn_SoundID id, char *buf)
452 {
453  char *mptr = buf;
454  vrpn_int32 len = sizeof(vrpn_SoundID) + sizeof(vrpn_float64) * 3;
455  vrpn_int32 ret = len;
456 
457  vrpn_buffer(&mptr, &len, id);
458 
459  vrpn_buffer(&mptr, &len, cone_inner_angle);
460  vrpn_buffer(&mptr, &len, cone_outer_angle);
461  vrpn_buffer(&mptr, &len, cone_gain);
462 
463  return ret;
464 }
465 
466 vrpn_int32 vrpn_Sound::decodeSoundConeInfo(const char *buf,
467  vrpn_float64 *cone_inner_angle,
468  vrpn_float64 *cone_outer_angle,
469  vrpn_float64 *cone_gain,
470  vrpn_SoundID *id)
471 {
472  const char *mptr = buf;
473 
474  vrpn_unbuffer(&mptr, id);
475 
476  vrpn_unbuffer(&mptr, cone_inner_angle);
477  vrpn_unbuffer(&mptr, cone_outer_angle);
478  vrpn_unbuffer(&mptr, cone_gain);
479 
480  return 0;
481 }
482 
483 vrpn_int32 vrpn_Sound::encodeSoundDoplerScale(const vrpn_float64 doplerfactor,
484  const vrpn_SoundID id, char *buf)
485 {
486  char *mptr = buf;
487  vrpn_int32 len = sizeof(vrpn_SoundID) + sizeof(vrpn_float64);
488  vrpn_int32 ret = len;
489 
490  vrpn_buffer(&mptr, &len, id);
491 
492  vrpn_buffer(&mptr, &len, doplerfactor);
493 
494  return ret;
495 }
496 
497 vrpn_int32 vrpn_Sound::decodeSoundDoplerScale(const char *buf,
498  vrpn_float64 *doplerfactor,
499  vrpn_SoundID *id)
500 {
501  const char *mptr = buf;
502 
503  vrpn_unbuffer(&mptr, id);
504  vrpn_unbuffer(&mptr, doplerfactor);
505 
506  return 0;
507 }
508 
509 vrpn_int32 vrpn_Sound::encodeSoundEqFactor(const vrpn_float64 eqfactor,
510  const vrpn_SoundID id, char *buf)
511 {
512  char *mptr = buf;
513  vrpn_int32 len = sizeof(vrpn_SoundID) + sizeof(vrpn_float64);
514  vrpn_int32 ret = len;
515 
516  vrpn_buffer(&mptr, &len, id);
517 
518  vrpn_buffer(&mptr, &len, eqfactor);
519 
520  return ret;
521 }
522 
523 vrpn_int32 vrpn_Sound::decodeSoundEqFactor(const char *buf,
524  vrpn_float64 *eqfactor,
525  vrpn_SoundID *id)
526 {
527  const char *mptr = buf;
528 
529  vrpn_unbuffer(&mptr, id);
530 
531  vrpn_unbuffer(&mptr, eqfactor);
532 
533  return 0;
534 }
535 
536 vrpn_int32 vrpn_Sound::encodeSoundPitch(const vrpn_float64 pitch,
537  const vrpn_SoundID id, char *buf)
538 {
539  char *mptr = buf;
540  vrpn_int32 len = sizeof(vrpn_SoundID) + sizeof(vrpn_float64);
541  vrpn_int32 ret = len;
542 
543  vrpn_buffer(&mptr, &len, id);
544 
545  vrpn_buffer(&mptr, &len, pitch);
546 
547  return ret;
548 }
549 
550 vrpn_int32 vrpn_Sound::decodeSoundPitch(const char *buf, vrpn_float64 *pitch,
551  vrpn_SoundID *id)
552 {
553  const char *mptr = buf;
554 
555  vrpn_unbuffer(&mptr, id);
556 
557  vrpn_unbuffer(&mptr, pitch);
558 
559  return 0;
560 }
561 
562 vrpn_int32 vrpn_Sound::encodeSoundVolume(const vrpn_float64 volume,
563  const vrpn_SoundID id, char *buf)
564 {
565  char *mptr = buf;
566  vrpn_int32 len = sizeof(vrpn_SoundID) + sizeof(vrpn_float64);
567  vrpn_int32 ret = len;
568 
569  vrpn_buffer(&mptr, &len, id);
570 
571  vrpn_buffer(&mptr, &len, volume);
572 
573  return ret;
574 }
575 
576 vrpn_int32 vrpn_Sound::decodeSoundVolume(const char *buf, vrpn_float64 *volume,
577  vrpn_SoundID *id)
578 {
579  const char *mptr = buf;
580 
581  vrpn_unbuffer(&mptr, id);
582  vrpn_unbuffer(&mptr, volume);
583 
584  return 0;
585 }
586 
587 vrpn_int32 vrpn_Sound::encodeLoadModel_local(const char *filename, char **buf)
588 {
589  vrpn_int32 len =
590  static_cast<vrpn_int32>(sizeof(vrpn_SoundID) + strlen(filename) + 1);
591  vrpn_int32 ret = len;
592  char *mptr;
593 
594  *buf = new char[strlen(filename) + sizeof(vrpn_SoundID) + 1];
595 
596  mptr = *buf;
597  vrpn_buffer(&mptr, &len, filename,
598  static_cast<vrpn_int32>(strlen(filename)) + 1);
599 
600  return ret;
601 }
602 
603 vrpn_int32 vrpn_Sound::decodeLoadModel_local(const char *buf, char **filename,
604  const int payload)
605 {
606  const char *mptr = buf;
607 
608  *filename = new char[payload - sizeof(vrpn_SoundID)];
609 
610  vrpn_unbuffer(&mptr, *filename, payload - sizeof(vrpn_SoundID));
611 
612  return 0;
613 }
614 
616 vrpn_int32 vrpn_Sound::encodeLoadModel_remote(const char * /*filename*/,
617  char ** /*buf*/)
618 {
619  return 0;
620 }
622 vrpn_int32 vrpn_Sound::decodeLoadModel_remote(const char * /*buf*/,
623  char ** /*filename*/,
624  const int /*payload*/)
625 {
626  return 0;
627 }
628 
629 vrpn_int32 vrpn_Sound::encodeLoadPolyQuad(const vrpn_QuadDef quad, char *buf)
630 {
631  char *mptr = buf;
632  vrpn_int32 len = sizeof(vrpn_QuadDef);
633  vrpn_int32 ret = len;
634  int i;
635 
636  vrpn_buffer(&mptr, &len, quad.subQuad);
637  vrpn_buffer(&mptr, &len, quad.openingFactor);
638  vrpn_buffer(&mptr, &len, quad.tag);
639  for (i = 0; i < 4; i++)
640  for (int j(0); j < 3; j++)
641  vrpn_buffer(&mptr, &len, quad.vertices[i][j]);
642 
644 
645  return ret;
646 }
647 
648 vrpn_int32 vrpn_Sound::decodeLoadPolyQuad(const char *buf, vrpn_QuadDef *quad)
649 {
650  const char *mptr = buf;
651  int i;
652 
653  vrpn_unbuffer(&mptr, &quad->subQuad);
654  vrpn_unbuffer(&mptr, &quad->openingFactor);
655  vrpn_unbuffer(&mptr, &quad->tag);
656  for (i = 0; i < 4; i++)
657  for (int j(0); j < 3; j++)
658  vrpn_unbuffer(&mptr, &quad->vertices[i][j]);
660 
661  return 0;
662 }
663 
664 vrpn_int32 vrpn_Sound::encodeLoadPolyTri(const vrpn_TriDef tri, char *buf)
665 {
666  char *mptr = buf;
667  vrpn_int32 len = sizeof(vrpn_int32) + sizeof(vrpn_TriDef);
668  vrpn_int32 ret = len;
669  int i;
670 
671  vrpn_buffer(&mptr, &len, tri.subTri);
672  vrpn_buffer(&mptr, &len, tri.openingFactor);
673  vrpn_buffer(&mptr, &len, tri.tag);
674  for (i = 0; i < 3; i++)
675  for (int j(0); j < 3; j++)
676  vrpn_buffer(&mptr, &len, tri.vertices[i][j]);
678 
679  return ret;
680 }
681 
682 vrpn_int32 vrpn_Sound::decodeLoadPolyTri(const char *buf, vrpn_TriDef *tri)
683 {
684  const char *mptr = buf;
685  int i;
686 
687  vrpn_unbuffer(&mptr, &tri->subTri);
688  vrpn_unbuffer(&mptr, &tri->openingFactor);
689  vrpn_unbuffer(&mptr, &tri->tag);
690  for (i = 0; i < 3; i++)
691  for (int j(0); j < 3; j++)
692  vrpn_unbuffer(&mptr, &tri->vertices[i][j]);
694 
695  return 0;
696 }
697 
698 vrpn_int32 vrpn_Sound::encodeLoadMaterial(const vrpn_int32 id,
699  const vrpn_MaterialDef material,
700  char *buf)
701 {
702  char *mptr = buf;
703  vrpn_int32 len = sizeof(vrpn_int32) + sizeof(vrpn_MaterialDef);
704  vrpn_int32 ret = len;
705 
706  vrpn_buffer(&mptr, &len, id);
707 
708  vrpn_buffer(&mptr, &len, material.material_name, MAX_MATERIAL_NAME_LENGTH);
709  vrpn_buffer(&mptr, &len, material.transmittance_gain);
710  vrpn_buffer(&mptr, &len, material.transmittance_highfreq);
711  vrpn_buffer(&mptr, &len, material.reflectance_gain);
712  vrpn_buffer(&mptr, &len, material.reflectance_highfreq);
713 
714  return ret;
715 }
716 
717 vrpn_int32 vrpn_Sound::decodeLoadMaterial(const char *buf,
718  vrpn_MaterialDef *material,
719  vrpn_int32 *id)
720 {
721  const char *mptr = buf;
722 
723  vrpn_unbuffer(&mptr, id);
724 
726  vrpn_unbuffer(&mptr, &material->transmittance_gain);
727  vrpn_unbuffer(&mptr, &material->transmittance_highfreq);
728  vrpn_unbuffer(&mptr, &material->reflectance_gain);
729  vrpn_unbuffer(&mptr, &material->reflectance_highfreq);
730 
731  return 0;
732 }
733 
734 vrpn_int32 vrpn_Sound::encodeSetQuadVert(const vrpn_float64 vertices[4][3],
735  const vrpn_int32 tag, char *buf)
736 {
737  char *mptr = buf;
738  vrpn_int32 len = sizeof(vrpn_int32) + sizeof(vrpn_float64) * 12;
739  vrpn_int32 ret = len;
740 
741  vrpn_buffer(&mptr, &len, tag);
742 
743  for (int i = 0; i < 4; i++)
744  for (int j(0); j < 3; j++)
745  vrpn_buffer(&mptr, &len, vertices[i][j]);
746 
747  return ret;
748 }
749 
750 vrpn_int32 vrpn_Sound::decodeSetQuadVert(const char *buf,
751  vrpn_float64 (*vertices)[4][3],
752  vrpn_int32 *tag)
753 {
754  const char *mptr = buf;
755 
756  vrpn_unbuffer(&mptr, tag);
757 
758  for (int i = 0; i < 4; i++)
759  for (int j(0); j < 3; j++)
760  vrpn_unbuffer(&mptr, vertices[i][j]);
761 
762  return 0;
763 }
764 
765 vrpn_int32 vrpn_Sound::encodeSetTriVert(const vrpn_float64 vertices[4][3],
766  const vrpn_int32 tag, char *buf)
767 {
768  char *mptr = buf;
769  vrpn_int32 len = sizeof(vrpn_int32) + sizeof(vrpn_float64) * 9;
770  vrpn_int32 ret = len;
771 
772  vrpn_buffer(&mptr, &len, tag);
773 
774  for (int i = 0; i < 3; i++)
775  for (int j(0); j < 3; j++)
776  vrpn_buffer(&mptr, &len, vertices[i][j]);
777 
778  return ret;
779 }
780 
781 vrpn_int32 vrpn_Sound::decodeSetTriVert(const char *buf,
782  vrpn_float64 (*vertices)[3][3],
783  vrpn_int32 *tag)
784 {
785  const char *mptr = buf;
786 
787  vrpn_unbuffer(&mptr, tag);
788 
789  for (int i = 0; i < 3; i++)
790  for (int j(0); j < 3; j++)
791  vrpn_unbuffer(&mptr, vertices[i][j]);
792 
793  return 0;
794 }
795 
796 vrpn_int32 vrpn_Sound::encodeSetPolyOF(const vrpn_float64 openingfactor,
797  const vrpn_int32 tag, char *buf)
798 {
799  char *mptr = buf;
800  vrpn_int32 len = sizeof(vrpn_SoundID) + sizeof(vrpn_float64);
801  vrpn_int32 ret = len;
802 
803  vrpn_buffer(&mptr, &len, tag);
804 
805  vrpn_buffer(&mptr, &len, openingfactor);
806 
807  return ret;
808 }
809 
810 vrpn_int32 vrpn_Sound::decodeSetPolyOF(const char *buf,
811  vrpn_float64 *openingfactor,
812  vrpn_int32 *tag)
813 {
814  const char *mptr = buf;
815 
816  vrpn_unbuffer(&mptr, tag);
817 
818  vrpn_unbuffer(&mptr, openingfactor);
819 
820  return 0;
821 }
822 
823 vrpn_int32 vrpn_Sound::encodeSetPolyMaterial(const char *material,
824  const vrpn_int32 tag, char *buf)
825 {
826  vrpn_int32 len = sizeof(vrpn_SoundID) + 128;
827  vrpn_int32 ret = len;
828  char *mptr = buf;
829 
830  vrpn_buffer(&mptr, &len, tag);
831  vrpn_buffer(&mptr, &len, material, 128);
832 
833  return ret;
834 }
835 
836 vrpn_int32 vrpn_Sound::decodeSetPolyMaterial(const char *buf, char **material,
837  vrpn_int32 *tag, const int)
838 {
839  const char *mptr = buf;
840 
841  vrpn_unbuffer(&mptr, tag);
842  vrpn_unbuffer(&mptr, *material, 128);
843 
844  return 0;
845 }
846 
847 /********************************************************************************************
848  Begin vrpn_Sound_Client
849  *******************************************************************************************/
851  : vrpn_Sound(name, c)
852  , vrpn_Text_Receiver(name, c)
853 {
855  handle_receiveTextMessage);
856 }
857 
859 
860 /*Sends a play sound message to the server. Sends the id of the sound to play
861  and the repeat value. If 0 then it plays it continuously*/
863  vrpn_int32 repeat)
864 {
865 
866  char buf[sizeof(vrpn_SoundID) + sizeof(vrpn_int32)];
867  vrpn_int32 len;
868 
869  len = encodeSoundPlay(id, repeat, buf);
870 
872 
873  if (vrpn_Sound::d_connection->pack_message(len, timestamp, play_sound,
874  d_sender_id, buf,
876  fprintf(stderr,
877  "vrpn_Sound_Client: cannot write message play: tossing\n");
878 
879  return 0;
880 }
881 
882 /*Stops a playing sound*/
884 {
885  char buf[sizeof(vrpn_SoundID)];
886  vrpn_int32 len;
887 
888  len = encodeSoundID(id, buf);
889 
891 
892  if (vrpn_Sound::d_connection->pack_message(len, timestamp, stop_sound,
893  d_sender_id, buf,
895  fprintf(stderr,
896  "vrpn_Sound_Client: cannot write message play: tossing\n");
897 
898  return 0;
899 }
900 
901 /*Loads a sound file on the server machine for playing. Returns a vrpn_SoundID
902  to
903  be used to refer to that sound from now on*/
905  const vrpn_SoundID id,
906  const vrpn_SoundDef soundDef)
907 {
908  vrpn_int32 len;
909  char *buf;
910 
911  len = encodeSound_local(sound, id, soundDef, &buf);
912 
914 
915  if (vrpn_Sound::d_connection->pack_message(len, timestamp, load_sound_local,
916  d_sender_id, buf,
918  fprintf(stderr,
919  "vrpn_Sound_Client: cannot write message load: tossing\n");
920 
921  delete[] buf;
922  return id;
923 }
924 
925 /*Unloads a sound file on the server side*/
927 {
928  vrpn_int32 len;
929  char buf[sizeof(vrpn_SoundID)];
930 
931  len = encodeSoundID(id, buf);
932 
934 
935  if (vrpn_Sound::d_connection->pack_message(len, timestamp, unload_sound,
936  d_sender_id, buf,
938  fprintf(stderr,
939  "vrpn_Sound_Client: cannot write message unload: tossing\n");
940 
941  return 0;
942 }
943 
945  const vrpn_float64 volume)
946 {
947  char buf[sizeof(vrpn_SoundID) + sizeof(vrpn_float64)];
948  vrpn_int32 len;
949 
950  len = encodeSoundVolume(volume, id, buf);
951 
953 
954  if (vrpn_Sound::d_connection->pack_message(len, timestamp, set_sound_volume,
955  d_sender_id, buf,
957  fprintf(
958  stderr,
959  "vrpn_Sound_Client: cannot write message change status: tossing\n");
960 
961  return 0;
962 }
963 
965  vrpn_float64 position[3],
966  vrpn_float64 orientation[4])
967 {
968  char buf[sizeof(vrpn_PoseDef) + sizeof(vrpn_SoundID)];
969  vrpn_int32 len;
970  vrpn_PoseDef tempdef;
971  int i;
972  for (i = 0; i < 4; i++) {
973  tempdef.orientation[i] = orientation[i];
974  }
975  for (i = 0; i < 3; i++) {
976  tempdef.position[i] = position[i];
977  }
978 
979  len = encodeSoundPose(tempdef, id, buf);
980 
982 
983  if (vrpn_Sound::d_connection->pack_message(len, timestamp, set_sound_pose,
984  d_sender_id, buf,
986  fprintf(
987  stderr,
988  "vrpn_Sound_Client: cannot write message change status: tossing\n");
989  }
990 
991  return 0;
992 }
993 
995  const vrpn_float64 velocity[4])
996 {
997  char buf[sizeof(vrpn_float64) * 4 + sizeof(vrpn_SoundID)];
998  vrpn_int32 len;
999 
1000  len = encodeSoundVelocity(velocity, id, buf);
1001 
1002  vrpn_gettimeofday(&timestamp, NULL);
1003 
1004  if (vrpn_Sound::d_connection->pack_message(len, timestamp,
1007  fprintf(
1008  stderr,
1009  "vrpn_Sound_Client: cannot write message change status: tossing\n");
1010 
1011  return 0;
1012 }
1013 
1015  const vrpn_SoundID id, const vrpn_float64 max_front_dist,
1016  const vrpn_float64 min_front_dist, const vrpn_float64 max_back_dist,
1017  const vrpn_float64 min_back_dist)
1018 {
1019  char buf[sizeof(vrpn_float64) * 4 + sizeof(vrpn_SoundID)];
1020  vrpn_int32 len;
1021 
1022  len = encodeSoundDistInfo(max_front_dist, min_front_dist, max_back_dist,
1023  min_back_dist, id, buf);
1024 
1025  vrpn_gettimeofday(&timestamp, NULL);
1026 
1027  if (vrpn_Sound::d_connection->pack_message(
1030  fprintf(
1031  stderr,
1032  "vrpn_Sound_Client: cannot write message change status: tossing\n");
1033 
1034  return 0;
1035 }
1036 
1038  const vrpn_float64 inner_angle,
1039  const vrpn_float64 outer_angle,
1040  const vrpn_float64 gain)
1041 {
1042 
1043  char buf[sizeof(vrpn_float64) * 3 + sizeof(vrpn_SoundID)];
1044  vrpn_int32 len;
1045 
1046  len = encodeSoundConeInfo(inner_angle, outer_angle, gain, id, buf);
1047 
1048  vrpn_gettimeofday(&timestamp, NULL);
1049 
1050  if (vrpn_Sound::d_connection->pack_message(len, timestamp,
1053  fprintf(
1054  stderr,
1055  "vrpn_Sound_Client: cannot write message change status: tossing\n");
1056 
1057  return 0;
1058 }
1059 
1061  vrpn_float64 dopfactor)
1062 {
1063 
1064  char buf[sizeof(vrpn_float64) + sizeof(vrpn_SoundID)];
1065  vrpn_int32 len;
1066 
1067  len = encodeSoundDoplerScale(dopfactor, id, buf);
1068 
1069  vrpn_gettimeofday(&timestamp, NULL);
1070 
1071  if (vrpn_Sound::d_connection->pack_message(
1074  fprintf(
1075  stderr,
1076  "vrpn_Sound_Client: cannot write message change status: tossing\n");
1077 
1078  return 0;
1079 }
1080 
1082  vrpn_float64 eq_value)
1083 {
1084  char buf[sizeof(vrpn_float64) + sizeof(vrpn_SoundID)];
1085  vrpn_int32 len;
1086 
1087  len = encodeSoundEqFactor(eq_value, id, buf);
1088 
1089  vrpn_gettimeofday(&timestamp, NULL);
1090 
1091  if (vrpn_Sound::d_connection->pack_message(len, timestamp,
1094  fprintf(
1095  stderr,
1096  "vrpn_Sound_Client: cannot write message change status: tossing\n");
1097 
1098  return 0;
1099 }
1100 
1102  vrpn_float64 pitch)
1103 {
1104  char buf[sizeof(vrpn_float64) + sizeof(vrpn_SoundID)];
1105  vrpn_int32 len;
1106 
1107  len = encodeSoundPitch(pitch, id, buf);
1108 
1109  vrpn_gettimeofday(&timestamp, NULL);
1110 
1111  if (vrpn_Sound::d_connection->pack_message(len, timestamp, set_sound_pitch,
1112  d_sender_id, buf,
1114  fprintf(
1115  stderr,
1116  "vrpn_Sound_Client: cannot write message change status: tossing\n");
1117 
1118  return 0;
1119 }
1120 
1121 vrpn_int32 vrpn_Sound_Client::setListenerPose(const vrpn_float64 position[3],
1122  const vrpn_float64 orientation[4])
1123 {
1124  char buf[sizeof(vrpn_PoseDef)];
1125  vrpn_int32 len;
1126  vrpn_PoseDef tempdef;
1127  int i;
1128 
1129  for (i = 0; i < 4; i++) {
1130  tempdef.orientation[i] = orientation[i];
1131  }
1132  for (i = 0; i < 3; i++) {
1133  tempdef.position[i] = position[i];
1134  }
1135 
1136  len = encodeListenerPose(tempdef, buf);
1137 
1138  vrpn_gettimeofday(&timestamp, NULL);
1139 
1140  if (vrpn_Sound::d_connection->pack_message(len, timestamp,
1143  fprintf(
1144  stderr,
1145  "vrpn_Sound_Client: cannot write message change status: tossing\n");
1146 
1147  return 0;
1148 }
1149 
1150 vrpn_int32
1151 vrpn_Sound_Client::setListenerVelocity(const vrpn_float64 velocity[4])
1152 {
1153  char buf[sizeof(vrpn_float64) * 4];
1154  vrpn_int32 len;
1155 
1156  len = encodeListenerVelocity(velocity, buf);
1157 
1158  vrpn_gettimeofday(&timestamp, NULL);
1159 
1160  if (vrpn_Sound::d_connection->pack_message(
1163  fprintf(
1164  stderr,
1165  "vrpn_Sound_Client: cannot write message change status: tossing\n");
1166  }
1167 
1168  return 0;
1169 }
1170 
1171 vrpn_int32 vrpn_Sound_Client::LoadModel_local(const char *filename)
1172 {
1173  vrpn_int32 len;
1174  char *buf;
1175 
1176  len = encodeLoadModel_local(filename, &buf);
1177 
1178  vrpn_gettimeofday(&timestamp, NULL);
1179 
1180  if (vrpn_Sound::d_connection->pack_message(len, timestamp, load_model_local,
1181  d_sender_id, buf,
1183  fprintf(stderr,
1184  "vrpn_Sound_Client: cannot write message load: tossing\n");
1185 
1186  return 1;
1187 }
1188 
1190 vrpn_int32 vrpn_Sound_Client::LoadModel_remote(const char * /*data*/)
1191 {
1192  return 0;
1193 }
1194 
1196 {
1197  vrpn_int32 len;
1198  char buf[sizeof(vrpn_QuadDef)];
1199 
1200  len = encodeLoadPolyQuad(quad, buf);
1201 
1202  vrpn_gettimeofday(&timestamp, NULL);
1203 
1204  if (vrpn_Sound::d_connection->pack_message(len, timestamp, load_polyquad,
1205  d_sender_id, buf,
1207  fprintf(stderr,
1208  "vrpn_Sound_Client: cannot write message load: tossing\n");
1209 
1210  return quad.tag;
1211 }
1212 
1214 {
1215  vrpn_int32 len;
1216  char buf[sizeof(vrpn_TriDef)];
1217 
1218  len = encodeLoadPolyTri(tri, buf);
1219 
1220  vrpn_gettimeofday(&timestamp, NULL);
1221 
1222  if (vrpn_Sound::d_connection->pack_message(len, timestamp, load_polytri,
1223  d_sender_id, buf,
1225  fprintf(stderr,
1226  "vrpn_Sound_Client: cannot write message load: tossing\n");
1227 
1228  return tri.tag;
1229 }
1230 
1231 vrpn_int32 vrpn_Sound_Client::LoadMaterial(const vrpn_int32 id,
1232  const vrpn_MaterialDef material)
1233 {
1234  vrpn_int32 len;
1235  char buf[sizeof(vrpn_MaterialDef) + sizeof(vrpn_int32)];
1236 
1237  len = encodeLoadMaterial(id, material, buf);
1238 
1239  vrpn_gettimeofday(&timestamp, NULL);
1240 
1241  if (vrpn_Sound::d_connection->pack_message(len, timestamp, load_material,
1242  d_sender_id, buf,
1244  fprintf(stderr,
1245  "vrpn_Sound_Client: cannot write message load: tossing\n");
1246 
1247  return id;
1248 }
1249 
1250 vrpn_int32 vrpn_Sound_Client::setPolyOF(const int id, const vrpn_float64 OF)
1251 {
1252  char buf[sizeof(vrpn_int32) + sizeof(vrpn_float64)];
1253  vrpn_int32 len;
1254 
1255  len = encodeSetPolyOF(OF, id, buf);
1256 
1257  vrpn_gettimeofday(&timestamp, NULL);
1258 
1259  if (vrpn_Sound::d_connection->pack_message(
1262  fprintf(
1263  stderr,
1264  "vrpn_Sound_Client: cannot write message change status: tossing\n");
1265 
1266  return 0;
1267 }
1268 
1269 vrpn_int32 vrpn_Sound_Client::setQuadVertices(const int id,
1270  const vrpn_float64 vertices[4][3])
1271 {
1272  char buf[sizeof(vrpn_int32) + sizeof(vrpn_float64) * 12];
1273  vrpn_int32 len;
1274 
1275  len = encodeSetQuadVert(vertices, id, buf);
1276 
1277  vrpn_gettimeofday(&timestamp, NULL);
1278 
1279  if (vrpn_Sound::d_connection->pack_message(
1282  fprintf(
1283  stderr,
1284  "vrpn_Sound_Client: cannot write message change status: tossing\n");
1285 
1286  return 0;
1287 }
1288 
1290  const char *material_name)
1291 {
1292  char buf[sizeof(vrpn_int32) + sizeof(material_name)];
1293  vrpn_int32 len;
1294 
1295  len = encodeSetPolyMaterial(material_name, id, buf);
1296 
1297  vrpn_gettimeofday(&timestamp, NULL);
1298 
1299  if (vrpn_Sound::d_connection->pack_message(len, timestamp,
1302  fprintf(
1303  stderr,
1304  "vrpn_Sound_Client: cannot write message change status: tossing\n");
1305 
1306  return 0;
1307 }
1308 vrpn_int32 vrpn_Sound_Client::setTriVertices(const int id,
1309  const vrpn_float64 vertices[3][3])
1310 {
1311  char buf[sizeof(vrpn_int32) + sizeof(vrpn_float64) * 9];
1312  vrpn_int32 len;
1313 
1314  len = encodeSetTriVert(vertices, id, buf);
1315 
1316  vrpn_gettimeofday(&timestamp, NULL);
1317 
1318  if (vrpn_Sound::d_connection->pack_message(
1321  fprintf(
1322  stderr,
1323  "vrpn_Sound_Client: cannot write message change status: tossing\n");
1324 
1325  return 0;
1326 }
1327 
1329 {
1331  client_mainloop();
1332 }
1333 
1334 void vrpn_Sound_Client::handle_receiveTextMessage(void *userdata,
1335  const vrpn_TEXTCB t)
1336 {
1338  me->receiveTextMessage(t.message, t.type, t.level, t.msg_time);
1339 }
1340 
1341 void vrpn_Sound_Client::receiveTextMessage(const char *message, vrpn_uint32,
1342  vrpn_uint32, struct timeval)
1343 {
1344  printf("Virtual: %s\n", message);
1345  return;
1346 }
1347 
1348 /********************************************************************************************
1349  Begin vrpn_Sound_Server
1350  *******************************************************************************************/
1351 #ifndef VRPN_CLIENT_ONLY
1353  : vrpn_Sound(name, c)
1354  , vrpn_Text_Sender((char *)name, c)
1355 {
1356  /*Register the handlers*/
1357  register_autodeleted_handler(load_sound_local, handle_loadSoundLocal, this,
1358  d_sender_id);
1359  register_autodeleted_handler(load_sound_remote, handle_loadSoundRemote,
1360  this, d_sender_id);
1361  register_autodeleted_handler(unload_sound, handle_unloadSound, this,
1362  d_sender_id);
1363  register_autodeleted_handler(play_sound, handle_playSound, this,
1364  d_sender_id);
1365  register_autodeleted_handler(stop_sound, handle_stopSound, this,
1366  d_sender_id);
1367  register_autodeleted_handler(change_sound_status, handle_changeSoundStatus,
1368  this, d_sender_id);
1369 
1370  register_autodeleted_handler(set_listener_pose, handle_setListenerPose,
1371  this, d_sender_id);
1373  handle_setListenerVelocity, this, d_sender_id);
1374 
1375  register_autodeleted_handler(set_sound_pose, handle_setSoundPose, this,
1376  d_sender_id);
1377  register_autodeleted_handler(set_sound_velocity, handle_setSoundVelocity,
1378  this, d_sender_id);
1380  set_sound_distanceinfo, handle_setSoundDistanceinfo, this, d_sender_id);
1381  register_autodeleted_handler(set_sound_coneinfo, handle_setSoundConeinfo,
1382  this, d_sender_id);
1383 
1385  set_sound_doplerfactor, handle_setSoundDoplerfactor, this, d_sender_id);
1386  register_autodeleted_handler(set_sound_eqvalue, handle_setSoundEqvalue,
1387  this, d_sender_id);
1388  register_autodeleted_handler(set_sound_pitch, handle_setSoundPitch, this,
1389  d_sender_id);
1390  register_autodeleted_handler(set_sound_volume, handle_setSoundVolume, this,
1391  d_sender_id);
1392 
1393  register_autodeleted_handler(load_model_local, handle_loadModelLocal, this,
1394  d_sender_id);
1395  register_autodeleted_handler(load_model_remote, handle_loadModelRemote,
1396  this, d_sender_id);
1397  register_autodeleted_handler(load_polyquad, handle_loadPolyquad, this,
1398  d_sender_id);
1399  register_autodeleted_handler(load_polytri, handle_loadPolytri, this,
1400  d_sender_id);
1401  register_autodeleted_handler(load_material, handle_loadMaterial, this,
1402  d_sender_id);
1404  handle_setPolyquadVertices, this, d_sender_id);
1406  handle_setPolytriVertices, this, d_sender_id);
1408  set_poly_openingfactor, handle_setPolyOpeningfactor, this, d_sender_id);
1409  register_autodeleted_handler(set_poly_material, handle_setPolyMaterial,
1410  this, d_sender_id);
1411 }
1412 
1414 
1415 /******************************************************************************
1416  Callback Handler routines.
1417  ******************************************************************************/
1418 
1419 int vrpn_Sound_Server::handle_loadSoundLocal(void *userdata,
1421 {
1422 
1424  vrpn_SoundID id;
1425  vrpn_SoundDef soundDef;
1426  char *filename;
1427 
1428  me->decodeSound_local((char *)p.buffer, &filename, &id, &soundDef,
1429  p.payload_len);
1430  me->loadSoundLocal(filename, id, soundDef);
1431  delete[] filename;
1432  return 0;
1433 }
1434 
1435 /* not supported */
1436 int vrpn_Sound_Server::handle_loadSoundRemote(void *userdata,
1438 {
1439  return 0;
1440 }
1441 int vrpn_Sound_Server::handle_playSound(void *userdata, vrpn_HANDLERPARAM p)
1442 {
1443 
1445  vrpn_SoundID id;
1446  vrpn_SoundDef soundDef;
1447  vrpn_int32 repeat;
1448 
1449  me->decodeSoundDef((char *)p.buffer, &soundDef, &id, &repeat);
1450  me->playSound(id, repeat, soundDef);
1451  return 0;
1452 }
1453 
1454 int vrpn_Sound_Server::handle_stopSound(void *userdata, vrpn_HANDLERPARAM p)
1455 {
1457  vrpn_SoundID id;
1458 
1459  me->decodeSoundID((char *)p.buffer, &id);
1460  me->stopSound(id);
1461  return 0;
1462 }
1463 
1464 int vrpn_Sound_Server::handle_unloadSound(void *userdata, vrpn_HANDLERPARAM p)
1465 {
1467  vrpn_SoundID id;
1468 
1469  me->decodeSoundID((char *)p.buffer, &id);
1470  me->unloadSound(id);
1471  return 0;
1472 }
1473 
1474 int vrpn_Sound_Server::handle_changeSoundStatus(void *userdata,
1476 {
1478  vrpn_SoundID id;
1479  vrpn_SoundDef soundDef;
1480  vrpn_int32 repeat;
1481 
1482  me->decodeSoundDef((char *)p.buffer, &soundDef, &id, &repeat);
1483  me->changeSoundStatus(id, soundDef);
1484  return 0;
1485 }
1486 
1487 int vrpn_Sound_Server::handle_setListenerPose(void *userdata,
1489 {
1491  vrpn_PoseDef pose;
1492 
1493  me->decodeListenerPose((char *)p.buffer, &pose);
1494  me->setListenerPose(pose);
1495  return 0;
1496 }
1497 
1498 int vrpn_Sound_Server::handle_setListenerVelocity(void *userdata,
1500 {
1502  vrpn_float64 velocity[4];
1503 
1504  me->decodeListenerVelocity((char *)p.buffer, velocity);
1505  me->setListenerVelocity(velocity);
1506  return 0;
1507 }
1508 
1509 int vrpn_Sound_Server::handle_setSoundPose(void *userdata, vrpn_HANDLERPARAM p)
1510 {
1512  vrpn_PoseDef pose;
1513  vrpn_int32 id;
1514 
1515  me->decodeSoundPose((char *)p.buffer, &pose, &id);
1516  me->setSoundPose(id, pose);
1517  return 0;
1518 }
1519 
1520 int vrpn_Sound_Server::handle_setSoundVelocity(void *userdata,
1522 {
1524  vrpn_float64 velocity[4];
1525  vrpn_int32 id;
1526 
1527  me->decodeSoundVelocity((char *)p.buffer, velocity, &id);
1528  me->setSoundVelocity(id, velocity);
1529  return 0;
1530 }
1531 
1532 int vrpn_Sound_Server::handle_setSoundDistanceinfo(void *userdata,
1534 {
1536  vrpn_float64 dist[4];
1537  vrpn_int32 id;
1538  /* order is min_back, max_back, min_front, max_front */
1539  me->decodeSoundDistInfo((char *)p.buffer, &dist[0], &dist[1], &dist[2],
1540  &dist[3], &id);
1541  me->setSoundDistInfo(id, dist);
1542  return 0;
1543 }
1544 
1545 int vrpn_Sound_Server::handle_setSoundConeinfo(void *userdata,
1547 {
1549  vrpn_float64 cinfo[3];
1550  vrpn_int32 id;
1551 
1552  me->decodeSoundConeInfo((char *)p.buffer, &cinfo[0], &cinfo[1], &cinfo[2],
1553  &id);
1554  me->setSoundConeInfo(id, cinfo);
1555  return 0;
1556 }
1557 
1558 int vrpn_Sound_Server::handle_setSoundDoplerfactor(void *userdata,
1560 {
1562  vrpn_float64 df;
1563  vrpn_int32 id;
1564 
1565  me->decodeSoundDoplerScale((char *)p.buffer, &df, &id);
1566  me->setSoundDoplerFactor(id, df);
1567  return 0;
1568 }
1569 
1570 int vrpn_Sound_Server::handle_setSoundEqvalue(void *userdata,
1572 {
1574  vrpn_float64 val;
1575  vrpn_int32 id;
1576 
1577  me->decodeSoundEqFactor((char *)p.buffer, &val, &id);
1578  me->setSoundEqValue(id, val);
1579  return 0;
1580 }
1581 
1582 int vrpn_Sound_Server::handle_setSoundPitch(void *userdata, vrpn_HANDLERPARAM p)
1583 {
1585  vrpn_float64 pitch;
1586  vrpn_int32 id;
1587 
1588  me->decodeSoundPitch((char *)p.buffer, &pitch, &id);
1589  me->setSoundPitch(id, pitch);
1590  return 0;
1591 }
1592 
1593 int vrpn_Sound_Server::handle_setSoundVolume(void *userdata,
1595 {
1597  vrpn_float64 vol;
1598  vrpn_int32 id;
1599 
1600  me->decodeSoundVolume((char *)p.buffer, &vol, &id);
1601  me->setSoundVolume(id, vol);
1602  return 0;
1603 }
1604 
1605 int vrpn_Sound_Server::handle_loadModelLocal(void *userdata,
1607 {
1609  char *filename;
1610 
1611  me->decodeLoadModel_local((char *)p.buffer, &filename, p.payload_len);
1612  me->loadModelLocal(filename);
1613  delete[] filename;
1614  return 0;
1615 }
1616 
1617 /* not handled yet */
1618 int vrpn_Sound_Server::handle_loadModelRemote(void *userdata,
1620 {
1621  return 0;
1622 }
1623 
1624 int vrpn_Sound_Server::handle_loadPolyquad(void *userdata, vrpn_HANDLERPARAM p)
1625 {
1627  vrpn_QuadDef quad;
1628 
1629  me->decodeLoadPolyQuad((char *)p.buffer, &quad);
1630  me->loadPolyQuad(&quad);
1631  return 0;
1632 }
1633 
1634 int vrpn_Sound_Server::handle_loadPolytri(void *userdata, vrpn_HANDLERPARAM p)
1635 {
1637  vrpn_TriDef tri;
1638 
1639  me->decodeLoadPolyTri((char *)p.buffer, &tri);
1640  me->loadPolyTri(&tri);
1641  return 0;
1642 }
1643 
1644 int vrpn_Sound_Server::handle_loadMaterial(void *userdata, vrpn_HANDLERPARAM p)
1645 {
1647  vrpn_MaterialDef material;
1648  vrpn_int32 id;
1649 
1650  me->decodeLoadMaterial((char *)p.buffer, &material, &id);
1651 
1652  me->loadMaterial(&material, id);
1653  return 0;
1654 }
1655 
1656 int vrpn_Sound_Server::handle_setPolyquadVertices(void *userdata,
1658 {
1660  vrpn_float64(*vertices)[4][3] = NULL;
1661  vrpn_int32 id;
1662 
1663  me->decodeSetQuadVert((char *)p.buffer, vertices, &id);
1664  me->setPolyQuadVertices(*vertices, id);
1665  return 0;
1666 }
1667 
1668 int vrpn_Sound_Server::handle_setPolytriVertices(void *userdata,
1670 {
1672  vrpn_float64(*vertices)[3][3] = NULL;
1673  vrpn_int32 id;
1674 
1675  me->decodeSetTriVert((char *)p.buffer, vertices, &id);
1676  me->setPolyTriVertices(*vertices, id);
1677  return 0;
1678 }
1679 
1680 int vrpn_Sound_Server::handle_setPolyOpeningfactor(void *userdata,
1682 {
1684  vrpn_float64 of;
1685  vrpn_int32 id;
1686 
1687  me->decodeSetPolyOF((char *)p.buffer, &of, &id);
1688  me->setPolyOF(of, id);
1689  return 0;
1690 }
1691 
1692 int vrpn_Sound_Server::handle_setPolyMaterial(void *userdata,
1694 {
1696  char **material = NULL;
1697  vrpn_int32 id;
1698 
1699  me->decodeSetPolyMaterial((char *)p.buffer, material, &id, p.payload_len);
1700  me->setPolyMaterial(*material, id);
1701  return 0;
1702 }
1703 
1704 #endif /*#ifndef VRPN_CLIENT_ONLY */
vrpn_Sound::load_material
vrpn_int32 load_material
Definition: vrpn_Sound.h:128
vrpn_Sound_Server::playSound
virtual void playSound(vrpn_SoundID id, vrpn_int32 repeat, vrpn_SoundDef soundDef)=0
vrpn_Sound_Client::setTriVertices
vrpn_int32 setTriVertices(const int id, const vrpn_float64 vertices[3][3])
Definition: vrpn_Sound.C:1308
vrpn_TriDef::vertices
vrpn_float64 vertices[3][3]
Definition: vrpn_Sound.h:91
vrpn_BaseClassUnique::register_autodeleted_handler
int register_autodeleted_handler(vrpn_int32 type, vrpn_MESSAGEHANDLER handler, void *userdata, vrpn_int32 sender=vrpn_ANY_SENDER)
Registers a handler with the connection, and remembers to delete at destruction.
Definition: vrpn_BaseClass.C:503
vrpn_Sound_Server::vrpn_Sound_Server
vrpn_Sound_Server(const char *name, vrpn_Connection *c)
Definition: vrpn_Sound.C:1352
vrpn_Sound::decodeSoundConeInfo
vrpn_int32 decodeSoundConeInfo(const char *buf, vrpn_float64 *cone_inner_angle, vrpn_float64 *cone_outer_angle, vrpn_float64 *cone_gain, vrpn_SoundID *id)
Definition: vrpn_Sound.C:466
vrpn_Sound_Server::setListenerPose
virtual void setListenerPose(vrpn_PoseDef pose)=0
vrpn_Sound_Server::changeSoundStatus
virtual void changeSoundStatus(vrpn_SoundID id, vrpn_SoundDef soundDef)=0
vrpn_BaseClassUnique::client_mainloop
void client_mainloop(void)
Handles functions that all clients should provide in their mainloop() (warning of no server,...
Definition: vrpn_BaseClass.C:637
vrpn_Sound::encodeLoadModel_remote
vrpn_int32 encodeLoadModel_remote(const char *filename, char **buf)
Definition: vrpn_Sound.C:616
vrpn_SoundDef
Definition: vrpn_Sound.h:37
vrpn_Sound_Client::setSoundVelocity
vrpn_int32 setSoundVelocity(const vrpn_SoundID id, const vrpn_float64 velocity[4])
Definition: vrpn_Sound.C:994
vrpn_Sound_Server::~vrpn_Sound_Server
~vrpn_Sound_Server()
Definition: vrpn_Sound.C:1413
vrpn_SoundDef::pose
vrpn_PoseDef pose
Definition: vrpn_Sound.h:38
vrpn_SoundDef::dopler_scale
vrpn_float64 dopler_scale
Definition: vrpn_Sound.h:47
vrpn_TEXTCB::level
vrpn_uint32 level
Definition: vrpn_Text.h:25
vrpn_Sound::encodeSoundEqFactor
vrpn_int32 encodeSoundEqFactor(const vrpn_float64 eqfactor, const vrpn_SoundID id, char *buf)
Definition: vrpn_Sound.C:509
vrpn_TriDef
Definition: vrpn_Sound.h:87
vrpn_Sound_Server::loadPolyQuad
virtual void loadPolyQuad(vrpn_QuadDef *quad)=0
vrpn_Sound::load_model_local
vrpn_int32 load_model_local
Definition: vrpn_Sound.h:124
vrpn_Sound::set_listener_pose
vrpn_int32 set_listener_pose
Definition: vrpn_Sound.h:112
vrpn_Sound_Client::setPolyMaterialName
vrpn_int32 setPolyMaterialName(const int id, const char *materialname)
Definition: vrpn_Sound.C:1289
vrpn_Sound::set_sound_doplerfactor
vrpn_int32 set_sound_doplerfactor
Definition: vrpn_Sound.h:119
vrpn_TriDef::openingFactor
vrpn_float64 openingFactor
Definition: vrpn_Sound.h:89
vrpn_QuadDef::subQuad
vrpn_int32 subQuad
Definition: vrpn_Sound.h:80
vrpn_Sound::decodeLoadModel_local
vrpn_int32 decodeLoadModel_local(const char *buf, char **filename, const int payload)
Definition: vrpn_Sound.C:603
vrpn_SoundDef::min_back_dist
vrpn_float64 min_back_dist
Definition: vrpn_Sound.h:43
vrpn_PoseDef
Definition: vrpn_Sound.h:26
vrpn_Sound_Client::setQuadVertices
vrpn_int32 setQuadVertices(const int id, const vrpn_float64 vertices[4][3])
Definition: vrpn_Sound.C:1269
vrpn_Sound_Server::loadPolyTri
virtual void loadPolyTri(vrpn_TriDef *tri)=0
vrpn_Sound_Server::setPolyMaterial
virtual void setPolyMaterial(const char *material, vrpn_int32 tag)=0
vrpn_Sound_Server::setSoundVelocity
virtual void setSoundVelocity(vrpn_SoundID id, vrpn_float64 *velocity)=0
vrpn_Sound::decodeSetPolyMaterial
vrpn_int32 decodeSetPolyMaterial(const char *buf, char **material, vrpn_int32 *tag, const int payload)
Definition: vrpn_Sound.C:836
vrpn_BaseClassUnique::userdata
void * userdata
Definition: vrpn_BaseClass.h:287
vrpn_Sound_Server::unloadSound
virtual void unloadSound(vrpn_SoundID id)=0
vrpn_Sound::encodeListenerPose
vrpn_int32 encodeListenerPose(const vrpn_PoseDef pose, char *buf)
Definition: vrpn_Sound.C:269
vrpn_Sound_Server::setSoundDistInfo
virtual void setSoundDistInfo(vrpn_SoundID id, vrpn_float64 *distinfo)=0
vrpn_Sound_Server::setSoundDoplerFactor
virtual void setSoundDoplerFactor(vrpn_SoundID id, vrpn_float64 doplerfactor)=0
vrpn_MaterialDef::reflectance_highfreq
vrpn_float64 reflectance_highfreq
Definition: vrpn_Sound.h:76
vrpn_QuadDef
Definition: vrpn_Sound.h:79
vrpn_Text_Receiver
Allows a user to handle text messages directly, in addition too having the.
Definition: vrpn_Text.h:68
vrpn_Sound::decodeSetQuadVert
vrpn_int32 decodeSetQuadVert(const char *buf, vrpn_float64(*vertices)[4][3], vrpn_int32 *tag)
Definition: vrpn_Sound.C:750
vrpn_QuadDef::openingFactor
vrpn_float64 openingFactor
Definition: vrpn_Sound.h:81
vrpn_QuadDef::tag
vrpn_int32 tag
Definition: vrpn_Sound.h:82
vrpn_Sound_Client::LoadModel_remote
vrpn_int32 LoadModel_remote(const char *data)
Definition: vrpn_Sound.C:1190
vrpn_Text_Sender
Allows a user to send text messages from a device (usually,.
Definition: vrpn_Text.h:39
vrpn_SoundDef::velocity
vrpn_float64 velocity[4]
Definition: vrpn_Sound.h:39
vrpn_MaterialDef::transmittance_gain
vrpn_float64 transmittance_gain
Definition: vrpn_Sound.h:73
vrpn_Sound::decodeSoundPose
vrpn_int32 decodeSoundPose(const char *buf, vrpn_PoseDef *pose, vrpn_SoundID *id)
Definition: vrpn_Sound.C:365
vrpn_HANDLERPARAM::payload_len
vrpn_int32 payload_len
Definition: vrpn_Connection.h:48
vrpn_Sound::decodeListenerPose
vrpn_int32 decodeListenerPose(const char *buf, vrpn_PoseDef *pose)
Definition: vrpn_Sound.C:285
vrpn_Sound_Client::stopSound
vrpn_int32 stopSound(const vrpn_SoundID id)
Definition: vrpn_Sound.C:883
vrpn_Sound_Client::LoadPolyQuad
vrpn_int32 LoadPolyQuad(const vrpn_QuadDef quad)
Definition: vrpn_Sound.C:1195
vrpn_TriDef::tag
vrpn_int32 tag
Definition: vrpn_Sound.h:90
vrpn_Sound::encodeLoadPolyTri
vrpn_int32 encodeLoadPolyTri(const vrpn_TriDef tri, char *buf)
Definition: vrpn_Sound.C:664
vrpn_Sound::play_sound
vrpn_int32 play_sound
Definition: vrpn_Sound.h:107
vrpn_Sound::decodeSoundVolume
vrpn_int32 decodeSoundVolume(const char *buf, vrpn_float64 *volume, vrpn_SoundID *id)
Definition: vrpn_Sound.C:576
vrpn_Sound::encodeSetPolyOF
vrpn_int32 encodeSetPolyOF(const vrpn_float64 openingfactor, const vrpn_int32 tag, char *buf)
Definition: vrpn_Sound.C:796
vrpn_Sound::decodeSetPolyOF
vrpn_int32 decodeSetPolyOF(const char *buf, vrpn_float64 *openingfactor, vrpn_int32 *tag)
Definition: vrpn_Sound.C:810
vrpn_Sound::decodeLoadModel_remote
vrpn_int32 decodeLoadModel_remote(const char *buf, char **filename, const int payload)
Definition: vrpn_Sound.C:622
vrpn_Sound_Server::setListenerVelocity
virtual void setListenerVelocity(vrpn_float64 *velocity)=0
vrpn_SoundDef::min_front_dist
vrpn_float64 min_front_dist
Definition: vrpn_Sound.h:41
vrpn_Sound::encodeLoadMaterial
vrpn_int32 encodeLoadMaterial(const vrpn_int32 id, const vrpn_MaterialDef material, char *buf)
Definition: vrpn_Sound.C:698
vrpn_Sound::decodeSound_remote
vrpn_int32 decodeSound_remote(const char *buf, char **filename, vrpn_SoundID *id, const int payload)
Definition: vrpn_Sound.C:163
vrpn_Sound::encodeSoundPlay
vrpn_int32 encodeSoundPlay(const vrpn_SoundID id, const vrpn_int32 repeat, char *buf)
Definition: vrpn_Sound.C:299
vrpn_unbuffer
VRPN_API int vrpn_unbuffer(const char **buffer, timeval *t)
Utility routine for taking a struct timeval from a buffer that was sent as a message.
Definition: vrpn_Shared.C:312
vrpn_MaterialDef::transmittance_highfreq
vrpn_float64 transmittance_highfreq
Definition: vrpn_Sound.h:74
vrpn_Sound::encodeSoundID
vrpn_int32 encodeSoundID(const vrpn_SoundID id, char *buf)
Definition: vrpn_Sound.C:172
vrpn_Sound::encodeSoundConeInfo
vrpn_int32 encodeSoundConeInfo(const vrpn_float64 cone_inner_angle, const vrpn_float64 cone_outer_angle, const vrpn_float64 cone_gain, const vrpn_SoundID id, char *buf)
Definition: vrpn_Sound.C:448
vrpn_Sound::encodeSoundDistInfo
vrpn_int32 encodeSoundDistInfo(const vrpn_float64 min_back, const vrpn_float64 max_back, const vrpn_float64 min_front, const vrpn_float64 max_front, const vrpn_SoundID id, char *buf)
Definition: vrpn_Sound.C:413
vrpn_Sound_Server::loadSoundLocal
virtual void loadSoundLocal(char *filename, vrpn_SoundID id, vrpn_SoundDef soundDef)=0
vrpn_Sound::decodeLoadPolyTri
vrpn_int32 decodeLoadPolyTri(const char *buf, vrpn_TriDef *tri)
Definition: vrpn_Sound.C:682
vrpn_BaseClassUnique::d_connection
vrpn_Connection * d_connection
Connection that this object talks to.
Definition: vrpn_BaseClass.h:224
vrpn_Sound::load_sound_local
vrpn_int32 load_sound_local
Definition: vrpn_Sound.h:103
vrpn_HANDLERPARAM::buffer
const char * buffer
Definition: vrpn_Connection.h:49
vrpn_Sound_Client::setListenerVelocity
vrpn_int32 setListenerVelocity(const vrpn_float64 velocity[4])
Definition: vrpn_Sound.C:1151
vrpn_Connection::register_message_type
virtual vrpn_int32 register_message_type(const char *name)
Definition: vrpn_Connection.C:5074
vrpn_Sound::decodeSoundPitch
vrpn_int32 decodeSoundPitch(const char *buf, vrpn_float64 *pitch, vrpn_SoundID *id)
Definition: vrpn_Sound.C:550
vrpn_Sound::encodeSetPolyMaterial
vrpn_int32 encodeSetPolyMaterial(const char *material, const vrpn_int32 tag, char *buf)
Definition: vrpn_Sound.C:823
vrpn_Sound_Client::LoadMaterial
vrpn_int32 LoadMaterial(const vrpn_int32 id, const vrpn_MaterialDef material)
Definition: vrpn_Sound.C:1231
vrpn_Sound_Client::vrpn_Sound_Client
vrpn_Sound_Client(const char *name, vrpn_Connection *c)
Definition: vrpn_Sound.C:850
vrpn_CONNECTION_RELIABLE
const vrpn_uint32 vrpn_CONNECTION_RELIABLE
Classes of service for messages, specify multiple by ORing them together Priority of satisfying these...
Definition: vrpn_Connection.h:120
vrpn_SoundDef::cone_gain
vrpn_float64 cone_gain
Definition: vrpn_Sound.h:46
vrpn_Text_Receiver::register_message_handler
virtual int register_message_handler(void *userdata, vrpn_TEXTHANDLER handler)
Definition: vrpn_Text.h:72
vrpn_Sound_Client::setSoundConeInfo
vrpn_int32 setSoundConeInfo(const vrpn_SoundID id, const vrpn_float64 inner_angle, const vrpn_float64 outer_angle, const vrpn_float64 gain)
Definition: vrpn_Sound.C:1037
vrpn_HANDLERPARAM
This structure is what is passed to a vrpn_Connection message callback.
Definition: vrpn_Connection.h:44
vrpn_Sound_Client::playSound
vrpn_int32 playSound(const vrpn_SoundID id, vrpn_int32 repeat)
Definition: vrpn_Sound.C:862
vrpn_Sound_Client::setSoundDistances
vrpn_int32 setSoundDistances(const vrpn_SoundID id, const vrpn_float64 max_front_dist, const vrpn_float64 min_front_dist, const vrpn_float64 max_back_dist, const vrpn_float64 min_back_dist)
Definition: vrpn_Sound.C:1014
vrpn_Sound::timestamp
struct timeval timestamp
Definition: vrpn_Sound.h:136
vrpn_Sound::unload_sound
vrpn_int32 unload_sound
Definition: vrpn_Sound.h:106
vrpn_QuadDef::vertices
vrpn_float64 vertices[4][3]
Definition: vrpn_Sound.h:83
vrpn_Sound::set_polyquad_vertices
vrpn_int32 set_polyquad_vertices
Definition: vrpn_Sound.h:129
vrpn_Sound::decodeSoundID
vrpn_int32 decodeSoundID(const char *buf, vrpn_SoundID *id)
Definition: vrpn_Sound.C:183
vrpn_SoundDef::pitch
vrpn_float64 pitch
Definition: vrpn_Sound.h:49
vrpn_BaseClassUnique::d_sender_id
vrpn_int32 d_sender_id
Sender ID registered with the connection.
Definition: vrpn_BaseClass.h:228
vrpn_Sound::set_sound_pose
vrpn_int32 set_sound_pose
Definition: vrpn_Sound.h:115
vrpn_Sound_Client::loadSound
vrpn_SoundID loadSound(const char *sound, const vrpn_SoundID id, const vrpn_SoundDef soundDef)
Definition: vrpn_Sound.C:904
vrpn_Sound_Server::setSoundConeInfo
virtual void setSoundConeInfo(vrpn_SoundID id, vrpn_float64 *coneinfo)=0
vrpn_Sound::encodeSound_local
vrpn_int32 encodeSound_local(const char *filename, const vrpn_SoundID id, const vrpn_SoundDef soundDef, char **buf)
Definition: vrpn_Sound.C:69
vrpn_Sound::set_sound_eqvalue
vrpn_int32 set_sound_eqvalue
Definition: vrpn_Sound.h:120
vrpn_Sound_Server::stopSound
virtual void stopSound(vrpn_SoundID id)=0
vrpn_Sound::load_polyquad
vrpn_int32 load_polyquad
Definition: vrpn_Sound.h:126
vrpn_Sound::decodeSoundEqFactor
vrpn_int32 decodeSoundEqFactor(const char *buf, vrpn_float64 *eqfactor, vrpn_SoundID *id)
Definition: vrpn_Sound.C:523
vrpn_SoundID
vrpn_int32 vrpn_SoundID
Definition: vrpn_Sound.h:24
vrpn_Sound::set_sound_distanceinfo
vrpn_int32 set_sound_distanceinfo
Definition: vrpn_Sound.h:117
vrpn_Sound::decodeLoadPolyQuad
vrpn_int32 decodeLoadPolyQuad(const char *buf, vrpn_QuadDef *quad)
Definition: vrpn_Sound.C:648
vrpn_Sound_Server::setSoundPitch
virtual void setSoundPitch(vrpn_SoundID id, vrpn_float64 pitch)=0
vrpn_Connection::mainloop
virtual int mainloop(const struct timeval *timeout=NULL)=0
Call each time through program main loop to handle receiving any incoming messages and sending any pa...
vrpn_Sound::decodeListenerVelocity
vrpn_int32 decodeListenerVelocity(const char *buf, vrpn_float64 *velocity)
Definition: vrpn_Sound.C:335
vrpn_PoseDef::position
vrpn_float64 position[3]
Definition: vrpn_Sound.h:27
vrpn_Sound::decodeLoadMaterial
vrpn_int32 decodeLoadMaterial(const char *buf, vrpn_MaterialDef *material, vrpn_int32 *id)
Definition: vrpn_Sound.C:717
vrpn_SoundDef::cone_outer_angle
vrpn_float64 cone_outer_angle
Definition: vrpn_Sound.h:45
vrpn_Connection
Generic connection class not specific to the transport mechanism.
Definition: vrpn_Connection.h:510
vrpn_Connection.h
vrpn_Sound::decodeSoundDoplerScale
vrpn_int32 decodeSoundDoplerScale(const char *buf, vrpn_float64 *doplerfactor, vrpn_SoundID *id)
Definition: vrpn_Sound.C:497
vrpn_Sound_Client::mainloop
virtual void mainloop()
Called once through each main loop iteration to handle updates. Remote object mainloop() should call ...
Definition: vrpn_Sound.C:1328
vrpn_Sound_Client::setSoundPitch
vrpn_int32 setSoundPitch(const vrpn_SoundID id, vrpn_float64 pitch)
Definition: vrpn_Sound.C:1101
vrpn_TriDef::material_name
char material_name[MAX_MATERIAL_NAME_LENGTH]
Definition: vrpn_Sound.h:92
vrpn_TEXTCB
Structure passed back to user-level code from a vrpn_Text_Receiver.
Definition: vrpn_Text.h:21
vrpn_Sound_Server::loadMaterial
virtual void loadMaterial(vrpn_MaterialDef *material, vrpn_int32 id)=0
vrpn_gettimeofday
#define vrpn_gettimeofday
Definition: vrpn_Shared.h:89
vrpn_Sound_Client::setSoundVolume
vrpn_int32 setSoundVolume(const vrpn_SoundID id, const vrpn_float64 volume)
Definition: vrpn_Sound.C:944
vrpn_Sound_Server::setSoundEqValue
virtual void setSoundEqValue(vrpn_SoundID id, vrpn_float64 eqvalue)=0
vrpn_SoundDef::equalization_val
vrpn_float64 equalization_val
Definition: vrpn_Sound.h:48
vrpn_Sound::encodeSoundPose
vrpn_int32 encodeSoundPose(const vrpn_PoseDef pose, const vrpn_SoundID id, char *buf)
Definition: vrpn_Sound.C:346
vrpn_Sound_Client::receiveTextMessage
virtual void receiveTextMessage(const char *message, vrpn_uint32 type, vrpn_uint32 level, struct timeval msg_time)
Definition: vrpn_Sound.C:1341
vrpn_SoundDef::volume
vrpn_float32 volume
Definition: vrpn_Sound.h:50
vrpn_Sound::set_sound_velocity
vrpn_int32 set_sound_velocity
Definition: vrpn_Sound.h:116
vrpn_Sound::encodeSoundVolume
vrpn_int32 encodeSoundVolume(const vrpn_float64 volume, const vrpn_SoundID id, char *buf)
Definition: vrpn_Sound.C:562
vrpn_Sound::set_sound_volume
vrpn_int32 set_sound_volume
Definition: vrpn_Sound.h:122
vrpn_Sound::set_sound_coneinfo
vrpn_int32 set_sound_coneinfo
Definition: vrpn_Sound.h:118
vrpn_Sound_Server::setPolyQuadVertices
virtual void setPolyQuadVertices(vrpn_float64 vertices[4][3], const vrpn_int32 id)=0
vrpn_Sound::~vrpn_Sound
~vrpn_Sound()
Definition: vrpn_Sound.C:67
vrpn_MaterialDef::material_name
char material_name[MAX_MATERIAL_NAME_LENGTH]
Definition: vrpn_Sound.h:72
vrpn_Sound_Client::setSoundDopScale
vrpn_int32 setSoundDopScale(const vrpn_SoundID id, vrpn_float64 dopfactor)
Definition: vrpn_Sound.C:1060
vrpn_Sound_Client::~vrpn_Sound_Client
~vrpn_Sound_Client()
Definition: vrpn_Sound.C:858
vrpn_Sound_Client::setListenerPose
vrpn_int32 setListenerPose(const vrpn_float64 position[3], const vrpn_float64 orientation[4])
Definition: vrpn_Sound.C:1121
vrpn_Sound_Client::setSoundEqValue
vrpn_int32 setSoundEqValue(const vrpn_SoundID id, vrpn_float64 eq_value)
Definition: vrpn_Sound.C:1081
vrpn_Sound_Client::LoadPolyTri
vrpn_int32 LoadPolyTri(const vrpn_TriDef tri)
Definition: vrpn_Sound.C:1213
vrpn_Sound::load_model_remote
vrpn_int32 load_model_remote
Definition: vrpn_Sound.h:125
vrpn_Sound_Client
Definition: vrpn_Sound.h:256
vrpn_Sound::encodeSoundDoplerScale
vrpn_int32 encodeSoundDoplerScale(const vrpn_float64 doplerfactor, const vrpn_SoundID id, char *buf)
Definition: vrpn_Sound.C:483
vrpn_Sound::register_types
int register_types(void)
Register the types of messages this device sends/receives. Return 0 on success, -1 on fail.
Definition: vrpn_Sound.C:14
vrpn_Sound::encodeLoadModel_local
vrpn_int32 encodeLoadModel_local(const char *filename, char **buf)
Definition: vrpn_Sound.C:587
vrpn_Sound::encodeSoundVelocity
vrpn_int32 encodeSoundVelocity(const vrpn_float64 *velocity, const vrpn_SoundID id, char *buf)
Definition: vrpn_Sound.C:382
vrpn_Sound::encodeSetQuadVert
vrpn_int32 encodeSetQuadVert(const vrpn_float64 vertices[4][3], const vrpn_int32 tag, char *buf)
Definition: vrpn_Sound.C:734
MAX_MATERIAL_NAME_LENGTH
#define MAX_MATERIAL_NAME_LENGTH
Definition: vrpn_Sound.h:16
vrpn_Sound::encodeSoundPitch
vrpn_int32 encodeSoundPitch(const vrpn_float64 pitch, const vrpn_SoundID id, char *buf)
Definition: vrpn_Sound.C:536
vrpn_Sound::decodeSoundDef
vrpn_int32 decodeSoundDef(const char *buf, vrpn_SoundDef *sound, vrpn_SoundID *id, vrpn_int32 *repeat)
Definition: vrpn_Sound.C:233
vrpn_Sound::encodeSound_remote
vrpn_int32 encodeSound_remote(const char *filename, const vrpn_SoundID id, char **buf)
Definition: vrpn_Sound.C:156
vrpn_Sound_Client::setSoundPose
vrpn_int32 setSoundPose(const vrpn_SoundID id, vrpn_float64 position[3], vrpn_float64 orientation[4])
Definition: vrpn_Sound.C:964
vrpn_BaseClass::init
virtual int init(void)
Initialize things that the constructor can't. Returns 0 on success, -1 on failure.
Definition: vrpn_BaseClass.C:363
vrpn_Sound::set_listener_velocity
vrpn_int32 set_listener_velocity
Definition: vrpn_Sound.h:114
vrpn_Sound::decodeSoundDistInfo
vrpn_int32 decodeSoundDistInfo(const char *buf, vrpn_float64 *min_back, vrpn_float64 *max_back, vrpn_float64 *min_front, vrpn_float64 *max_front, vrpn_SoundID *id)
Definition: vrpn_Sound.C:433
vrpn_Sound::encodeSetTriVert
vrpn_int32 encodeSetTriVert(const vrpn_float64 vertices[3][3], const vrpn_int32 tag, char *buf)
Definition: vrpn_Sound.C:765
vrpn_Sound_Client::LoadModel_local
vrpn_int32 LoadModel_local(const char *filename)
Definition: vrpn_Sound.C:1171
vrpn_TEXTCB::type
vrpn_TEXT_SEVERITY type
Definition: vrpn_Text.h:24
vrpn_buffer
VRPN_API int vrpn_buffer(char **insertPt, vrpn_int32 *buflen, const timeval t)
Utility routine for placing a timeval struct into a buffer that is to be sent as a message.
Definition: vrpn_Shared.C:241
vrpn_Sound::encodeListenerVelocity
vrpn_int32 encodeListenerVelocity(const vrpn_float64 *velocity, char *buf)
Definition: vrpn_Sound.C:321
vrpn_SoundDef::cone_inner_angle
vrpn_float64 cone_inner_angle
Definition: vrpn_Sound.h:44
vrpn_TriDef::subTri
vrpn_int32 subTri
Definition: vrpn_Sound.h:88
vrpn_SoundDef::max_back_dist
vrpn_float64 max_back_dist
Definition: vrpn_Sound.h:42
vrpn_Sound::load_polytri
vrpn_int32 load_polytri
Definition: vrpn_Sound.h:127
vrpn_Sound_Client::unloadSound
vrpn_int32 unloadSound(const vrpn_SoundID id)
Definition: vrpn_Sound.C:926
vrpn_Sound::set_poly_material
vrpn_int32 set_poly_material
Definition: vrpn_Sound.h:132
vrpn_Sound::set_sound_pitch
vrpn_int32 set_sound_pitch
Definition: vrpn_Sound.h:121
vrpn_MaterialDef::reflectance_gain
vrpn_float64 reflectance_gain
Definition: vrpn_Sound.h:75
vrpn_Sound::set_polytri_vertices
vrpn_int32 set_polytri_vertices
Definition: vrpn_Sound.h:130
vrpn_PoseDef::orientation
vrpn_float64 orientation[4]
Definition: vrpn_Sound.h:28
vrpn_Sound::vrpn_Sound
vrpn_Sound(const char *name, vrpn_Connection *c)
Definition: vrpn_Sound.C:8
vrpn_Sound::set_poly_openingfactor
vrpn_int32 set_poly_openingfactor
Definition: vrpn_Sound.h:131
vrpn_Sound_Server::setPolyTriVertices
virtual void setPolyTriVertices(vrpn_float64 vertices[3][3], const vrpn_int32 id)=0
vrpn_Sound::change_sound_status
vrpn_int32 change_sound_status
Definition: vrpn_Sound.h:110
vrpn_MaterialDef
Definition: vrpn_Sound.h:71
vrpn_QuadDef::material_name
char material_name[MAX_MATERIAL_NAME_LENGTH]
Definition: vrpn_Sound.h:84
vrpn_ListenerDef
Definition: vrpn_Sound.h:66
vrpn_Sound::encodeSoundDef
vrpn_int32 encodeSoundDef(const vrpn_SoundDef sound, const vrpn_SoundID id, const vrpn_int32 repeat, char *buf)
Definition: vrpn_Sound.C:194
vrpn_SoundDef::max_front_dist
vrpn_float64 max_front_dist
Definition: vrpn_Sound.h:40
vrpn_Sound::decodeSound_local
vrpn_int32 decodeSound_local(const char *buf, char **filename, vrpn_SoundID *id, vrpn_SoundDef *soundDef, const int payload)
Definition: vrpn_Sound.C:114
vrpn_Sound_Server::loadModelLocal
virtual void loadModelLocal(const char *filename)=0
vrpn_Sound::decodeSetTriVert
vrpn_int32 decodeSetTriVert(const char *buf, vrpn_float64(*vertices)[3][3], vrpn_int32 *tag)
Definition: vrpn_Sound.C:781
vrpn_Sound::load_sound_remote
vrpn_int32 load_sound_remote
Definition: vrpn_Sound.h:105
vrpn_Sound::decodeSoundPlay
vrpn_int32 decodeSoundPlay(const char *buf, vrpn_SoundID *id, vrpn_int32 *repeat)
Definition: vrpn_Sound.C:311
vrpn_Sound
Definition: vrpn_Sound.h:95
vrpn_Sound::encodeLoadPolyQuad
vrpn_int32 encodeLoadPolyQuad(const vrpn_QuadDef quad, char *buf)
Definition: vrpn_Sound.C:629
vrpn_TEXTCB::msg_time
struct timeval msg_time
Definition: vrpn_Text.h:22
vrpn_Sound_Server::setSoundPose
virtual void setSoundPose(vrpn_SoundID id, vrpn_PoseDef pose)=0
vrpn_Sound::decodeSoundVelocity
vrpn_int32 decodeSoundVelocity(const char *buf, vrpn_float64 *velocity, vrpn_SoundID *id)
Definition: vrpn_Sound.C:398
vrpn_BaseClass
Class from which all user-level (and other) classes that communicate with vrpn_Connections should der...
Definition: vrpn_BaseClass.h:313
vrpn_TEXTCB::message
char message[vrpn_MAX_TEXT_LEN]
Definition: vrpn_Text.h:23
vrpn_Sound_Client::setPolyOF
vrpn_int32 setPolyOF(const int id, const vrpn_float64 OF)
Definition: vrpn_Sound.C:1250
vrpn_Sound_Server::setSoundVolume
virtual void setSoundVolume(vrpn_SoundID id, vrpn_float64 volume)=0
vrpn_Sound.h
vrpn_Sound::stop_sound
vrpn_int32 stop_sound
Definition: vrpn_Sound.h:108
vrpn_Sound_Server
Definition: vrpn_Sound.h:344
vrpn_Sound_Server::setPolyOF
virtual void setPolyOF(vrpn_float64 OF, vrpn_int32 tag)=0