Panda3D
 All Classes Functions Variables Enumerations
microphoneAudio.cxx
1 // Filename: microphoneAudio.cxx
2 // Created by: jyelon (02Jul07)
3 //
4 ////////////////////////////////////////////////////////////////////
5 //
6 // PANDA 3D SOFTWARE
7 // Copyright (c) Carnegie Mellon University. All rights reserved.
8 //
9 // All use of this software is subject to the terms of the revised BSD
10 // license. You should have received a copy of this license along
11 // with this source code in a file named "LICENSE."
12 //
13 ////////////////////////////////////////////////////////////////////
14 
15 #include "microphoneAudio.h"
16 #include "movieAudioCursor.h"
17 
18 pvector<PT(MicrophoneAudio)> MicrophoneAudio::_all_microphones;
19 TypeHandle MicrophoneAudio::_type_handle;
20 
21 ////////////////////////////////////////////////////////////////////
22 // Function: MicrophoneAudio::Destructor
23 // Access: Published, Virtual
24 // Description:
25 ////////////////////////////////////////////////////////////////////
26 MicrophoneAudio::
27 ~MicrophoneAudio() {
28 }
29 
30 ////////////////////////////////////////////////////////////////////
31 // Function: MicrophoneAudio::find_all_microphones
32 // Access: Public
33 // Description: Scans the hardware for microphones, and pushes them
34 // onto the global list of all microphones.
35 //
36 // There are several implementations of MicrophoneAudio,
37 // including one based on DirectShow, one based on
38 // Linux ALSA, and so forth. These implementations
39 // are contained in one C++ file each, and they export
40 // nothing at all except a single "find_all" function.
41 // Otherwise, they can only be accessed through the
42 // virtual methods of the MicrophoneAudio objects they
43 // create.
44 ////////////////////////////////////////////////////////////////////
47  static bool initialized = false;
48  if (initialized) return;
49  initialized = true;
50 
51 #ifdef HAVE_DIRECTCAM
52  extern void find_all_microphones_ds();
53  find_all_microphones_ds();
54 #endif
55 
56 #ifdef HAVE_ALSA
57  extern void find_all_microphones_alsa();
58  find_all_microphones_alsa();
59 #endif
60 }
61 
62 ////////////////////////////////////////////////////////////////////
63 // Function: MicrophoneAudio::get_num_options
64 // Access: Public
65 // Description: Returns the number of microphone options. An "option"
66 // consists of a device plus a set of configuration
67 // parameters. For example, "Soundblaster Audigy Line in
68 // at 44,100 samples/sec" would be an option.
69 ////////////////////////////////////////////////////////////////////
73  return _all_microphones.size();
74 }
75 
76 ////////////////////////////////////////////////////////////////////
77 // Function: MicrophoneAudio::get_option
78 // Access: Public
79 // Description: Returns the nth microphone option.
80 ////////////////////////////////////////////////////////////////////
82 get_option(int n) {
83  find_all_microphones();
84  nassertr((n >= 0) && (n < (int)_all_microphones.size()), NULL);
85  return _all_microphones[n];
86 }
static void find_all_microphones()
Scans the hardware for microphones, and pushes them onto the global list of all microphones.
Class MicrophoneAudio provides the means to read raw audio samples from a microphone.
static int get_num_options()
Returns the number of microphone options.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:85