Panda3D
 All Classes Functions Variables Enumerations
config_audio.cxx
1 // Filename: config_audio.cxx
2 // Created by: cary (22Sep00)
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 "config_audio.h"
16 #include "dconfig.h"
17 #include "filterProperties.h"
18 #include "audioLoadRequest.h"
19 #include "audioManager.h"
20 #include "audioSound.h"
21 #include "nullAudioManager.h"
22 #include "nullAudioSound.h"
23 #include "string_utils.h"
24 
25 Configure(config_audio);
26 NotifyCategoryDef(audio, "");
27 
28 ConfigVariableBool audio_active
29 ("audio-active", true);
30 
31 ConfigVariableInt audio_cache_limit
32 ("audio-cache-limit", 15,
33  PRC_DESC("The number of sounds in the cache."));
34 
35 ConfigVariableString audio_library_name
36 ("audio-library-name", "null");
37 
38 ConfigVariableDouble audio_volume
39 ("audio-volume", 1.0f);
40 
41 // Config variables for OpenAL:
42 
43 ConfigVariableDouble audio_doppler_factor
44 ("audio-doppler-factor", 1.0f);
45 
46 ConfigVariableDouble audio_distance_factor
47 ("audio-distance-factor", 1.0f);
48 
49 ConfigVariableDouble audio_drop_off_factor
50 ("audio-drop-off-factor", 1.0f);
51 
52 ConfigVariableDouble audio_buffering_seconds
53 ("audio-buffering-seconds", 3.0f,
54  PRC_DESC("Controls the amount of audio buffering when streaming audio. "
55  "If you are playing a streaming sound, and any single frame "
56  "takes longer than this, the audio will stutter. Caution: "
57  "buffering streaming audio takes a lot of memory. For example, "
58  "5 seconds of stereo audio at 44,100 samples/sec takes one "
59  "megabyte. The 3-second default is intentionally high, favoring "
60  "correctness over efficiency, but for a commercial application "
61  "you may wish to lower this."));
62 
63 ConfigVariableInt audio_preload_threshold
64 ("audio-preload-threshold", 1000000,
65  PRC_DESC("If the decompressed size of a sound file exceeds this amount, "
66  "then Panda3D will not attempt to store that sound file in RAM. "
67  "Instead, it will stream the sound file from disk. It is not "
68  "practical to stream multiple sound-files from disk at the same "
69  "time - the hard drive seek time makes it stutter."));
70 
71 // Unknown
72 
73 ConfigVariableInt audio_min_hw_channels
74 ("audio-min-hw-channels", 15,
75 PRC_DESC("Guarantee this many channels on the local sound card, or just "
76  "play EVERYTHING in software."));
77 
78 // Config variables for Fmod:
79 
80 ConfigVariableInt fmod_number_of_sound_channels
81 ("fmod-number-of-sound-channels", 128,
82  PRC_DESC("Guarantee this many channels you will have with FMOD. AKA the max number of sounds you can play at one time.") );
83 
84 ConfigVariableBool fmod_use_surround_sound
85 ("fmod-use-surround-sound", false,
86  PRC_DESC("Determines if an FMOD Flavor of PANDA use 5.1 Surround Sound or not. "
87  "This variable is deprecated and should not be used. Use the enum "
88  "variable fmod-speaker-mode instead."));
89 
91 ("fmod-speaker-mode", FSM_unspecified,
92  PRC_DESC("Sets the speaker configuration that the FMOD sound system will use. "
93  "Options: raw, mono, stereo, quad, surround, 5.1 and 7.1. "));
94 
95 
96 // Config variables for Miles:
97 
98 ConfigVariableBool audio_software_midi
99 ("audio-software-midi", true);
100 
101 ConfigVariableFilename audio_dls_file
102 ("audio-dls-file", Filename(),
103  PRC_DESC("Specifies a DLS file that defines an instrument set to load "
104  "for MIDI file playback. If this is not specified, the sound "
105  "interface will try to use the system default DLS file, if "
106  "one is available; the likely success of this depends on the "
107  "operating system."));
108 
109 ConfigVariableBool audio_play_midi
110 ("audio-play-midi", true);
111 
112 ConfigVariableBool audio_play_wave
113 ("audio-play-wave", true);
114 
115 ConfigVariableBool audio_play_mp3
116 ("audio-play-mp3", true);
117 
118 ConfigVariableInt audio_output_rate
119 ("audio-output-rate", 22050);
120 
121 ConfigVariableInt audio_output_bits
122 ("audio-output-bits", 16);
123 
124 ConfigVariableInt audio_output_channels
125 ("audio-output-channels", 2);
126 
127 ConfigureFn(config_audio) {
128  FilterProperties::init_type();
129  AudioLoadRequest::init_type();
130  AudioManager::init_type();
131  AudioSound::init_type();
132  NullAudioManager::init_type();
133  NullAudioSound::init_type();
134 }
135 
136 ostream &
137 operator << (ostream &out, FmodSpeakerMode sm) {
138  switch (sm) {
139  case FSM_raw:
140  return out << "raw";
141  case FSM_mono:
142  return out << "mono";
143  case FSM_stereo:
144  return out << "stereo";
145  case FSM_quad:
146  return out << "quad";
147  case FSM_surround:
148  return out << "surround";
149  case FSM_5point1:
150  return out << "5.1";
151  case FSM_7point1:
152  return out << "7.1";
153  case FSM_unspecified:
154  return out;
155  }
156 
157  return out << "**invalid FmodSpeakerMode (" << (int)sm << ")**";
158 }
159 
160 istream &
161 operator >> (istream &in, FmodSpeakerMode &sm) {
162  string word;
163  in >> word;
164 
165  if (word.size() == 0) {
166  sm = FSM_unspecified;
167  } else if (cmp_nocase(word, "raw") == 0) {
168  sm = FSM_raw;
169  } else if (cmp_nocase(word, "mono") == 0) {
170  sm = FSM_mono;
171  } else if (cmp_nocase(word, "stereo") == 0) {
172  sm = FSM_stereo;
173  } else if (cmp_nocase(word, "quad") == 0) {
174  sm = FSM_quad;
175  } else if (cmp_nocase(word, "surround") == 0) {
176  sm = FSM_surround;
177  } else if (cmp_nocase(word, "5point1") == 0 ||
178  cmp_nocase(word, "5.1") == 0) {
179  sm = FSM_5point1;
180  } else if (cmp_nocase(word, "7point1") == 0 ||
181  cmp_nocase(word, "7.1") == 0) {
182  sm = FSM_7point1;
183 
184  } else {
185  audio_cat->error() << "Invalid FmodSpeakerMode value: " << word << "\n";
186  sm = FSM_unspecified;
187  }
188 
189  return in;
190 }
This is a convenience class to specialize ConfigVariable as a Filename type.
This is a convenience class to specialize ConfigVariable as a boolean type.
This is a convenience class to specialize ConfigVariable as a floating-point type.
The name of a file, such as a texture file or an Egg file.
Definition: filename.h:44
This is a convenience class to specialize ConfigVariable as a string type.
This class specializes ConfigVariable as an enumerated type.
This is a convenience class to specialize ConfigVariable as an integer type.