Panda3D
microphoneAudio.cxx
Go to the documentation of this file.
1 /**
2  * PANDA 3D SOFTWARE
3  * Copyright (c) Carnegie Mellon University. All rights reserved.
4  *
5  * All use of this software is subject to the terms of the revised BSD
6  * license. You should have received a copy of this license along
7  * with this source code in a file named "LICENSE."
8  *
9  * @file microphoneAudio.cxx
10  * @author jyelon
11  * @date 2007-07-02
12  */
13 
14 #include "microphoneAudio.h"
15 #include "movieAudioCursor.h"
16 
17 pvector<PT(MicrophoneAudio)> MicrophoneAudio::_all_microphones;
18 TypeHandle MicrophoneAudio::_type_handle;
19 
20 /**
21  *
22  */
23 MicrophoneAudio::
24 ~MicrophoneAudio() {
25 }
26 
27 /**
28  * Scans the hardware for microphones, and pushes them onto the global list of
29  * all microphones.
30  *
31  * There are several implementations of MicrophoneAudio, including one based
32  * on DirectShow, one based on Linux ALSA, and so forth. These
33  * implementations are contained in one C++ file each, and they export nothing
34  * at all except a single "find_all" function. Otherwise, they can only be
35  * accessed through the virtual methods of the MicrophoneAudio objects they
36  * create.
37  */
40  static bool initialized = false;
41  if (initialized) return;
42  initialized = true;
43 
44 #ifdef HAVE_DIRECTCAM
45  extern void find_all_microphones_ds();
46  find_all_microphones_ds();
47 #endif
48 
49 #ifdef HAVE_ALSA
50  extern void find_all_microphones_alsa();
51  find_all_microphones_alsa();
52 #endif
53 }
54 
55 /**
56  * Returns the number of microphone options. An "option" consists of a device
57  * plus a set of configuration parameters. For example, "Soundblaster Audigy
58  * Line in at 44,100 samples/sec" would be an option.
59  */
60 int MicrophoneAudio::
61 get_num_options() {
63  return _all_microphones.size();
64 }
65 
66 /**
67  * Returns the nth microphone option.
68  */
69 PT(MicrophoneAudio) MicrophoneAudio::
70 get_option(int n) {
72  nassertr((n >= 0) && (n < (int)_all_microphones.size()), nullptr);
73  return _all_microphones[n];
74 }
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.
This is our own Panda specialization on the default STL vector.
Definition: pvector.h:42
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.
TypeHandle is the identifier used to differentiate C++ class types.
Definition: typeHandle.h:81
PT(MicrophoneAudio) MicrophoneAudio
Returns the nth microphone option.
PANDA 3D SOFTWARE Copyright (c) Carnegie Mellon University.