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