This does not work as expected.
load_prc_file_data("", "audio-library-name p3openal_audio");
I get a message:
:audio: NullAudioManager
this only works through the Config.prc file.
I can add a custom prc file, too, cannot specify an audio library. Only valid from folder etc.
The essence lies in the folder itself, if you place a user prc, then it will normally install the audio library.
rdb
December 9, 2019, 8:26am
2
I think this needs to be specified before Panda loads the Audio subsystem. If Panda has already initialized the audio library, then it is too late to change this setting.
Then it turns out that I cannot get rid of the automatic loading of Config.prc, as you suggested in this post:
I thought about it, but did not find in what place this can be done.
And yes, the blindness has passed, I found.
--help (print the help message you're reading now)
--verbose (print out more information)
--runtime (build a runtime build instead of an SDK build)
--tests (run the test suite)
--installer (build an installer)
--wheel (build a pip-installable .whl)
--optimize X (optimization level can be 1,2,3,4)
--version X …
If I disable it during compilation, when it is not clear to me how I can specify the audio library. I think that the situation with the file is easily corrected if you delete the code that automatically downloads files from the folder, etc. Of course, it is strange that initialization is performed linearly, why not initialize after receiving all the variables?
rdb
February 22, 2020, 11:19am
4
I think you can specify audio-library-name after importing the Panda library, just before the audio manager is created (which is probably done by the ShowBase constructor.
Let me know if this is not true, then I can look into fixing this.
I actually use C++, not Python.
rdb
February 22, 2020, 8:09pm
6
It’s really the same story for C++. You can change it right until the moment you create a new AudioManager.
//#pragma comment(linker, "/SUBSYSTEM:windows /ENTRY:mainCRTStartup")
#include "pandaFramework.h"
#include "pandaSystem.h"
#include "load_prc_file.h"
#include "audioManager.h"
char confauto[] = R"(load-file-type egg pandaegg
load-audio-type * p3ffmpeg
load-video-type * p3ffmpeg
egg-object-type-portal <Scalar> portal { 1 }
egg-object-type-polylight <Scalar> polylight { 1 }
egg-object-type-seq24 <Switch> { 1 } <Scalar> fps { 24 }
egg-object-type-seq12 <Switch> { 1 } <Scalar> fps { 12 }
egg-object-type-indexed <Scalar> indexed { 1 }
egg-object-type-seq10 <Switch> { 1 } <Scalar> fps { 10 }
egg-object-type-seq8 <Switch> { 1 } <Scalar> fps { 8 }
egg-object-type-seq6 <Switch> { 1 } <Scalar> fps { 6 }
egg-object-type-seq4 <Switch> { 1 } <Scalar> fps { 4 }
egg-object-type-seq2 <Switch> { 1 } <Scalar> fps { 2 }
egg-object-type-binary <Scalar> alpha { binary }
egg-object-type-dual <Scalar> alpha { dual }
egg-object-type-glass <Scalar> alpha { blend_no_occlude }
egg-object-type-model <Model> { 1 }
egg-object-type-dcs <DCS> { 1 }
egg-object-type-notouch <DCS> { no_touch }
egg-object-type-barrier <Collide> { Polyset descend }
egg-object-type-sphere <Collide> { Sphere descend }
egg-object-type-invsphere <Collide> { InvSphere descend }
egg-object-type-tube <Collide> { Tube descend }
egg-object-type-trigger <Collide> { Polyset descend intangible }
egg-object-type-trigger-sphere <Collide> { Sphere descend intangible }
egg-object-type-floor <Collide> { Polyset descend level }
egg-object-type-dupefloor <Collide> { Polyset keep descend level }
egg-object-type-bubble <Collide> { Sphere keep descend }
egg-object-type-ghost <Scalar> collide-mask { 0 }
egg-object-type-glow <Scalar> blend { add }
egg-object-type-direct-widget <Scalar> collide-mask { 0x80000000 } <Collide> { Polyset descend }
cull-bin gui-popup 60 unsorted
default-model-extension .egg)";
char config[] = R"(load-display pandagl
audio-library-name p3openal_audio
win-origin -2 -2
framebuffer-hardware #t
depth-bits 1
color-bits 1 1 1
alpha-bits 0
stencil-bits 0
multisamples 0
notify-level warning
default-directnotify-level warning
model-path $MAIN_DIR
use-movietexture #t
#model-cache-dir
model-cache-dir $MAIN_DIR/../cache/models
gl-coordinate-system default
gl-version 3 2
textures-auto-power-2 1
textures-power-2 down)";
int main(int argc, char *argv[]) {
load_prc_file_data("file_auto", confauto);
load_prc_file_data("file_ig", config);
PandaFramework framework;
framework.open_framework(argc, argv);
framework.set_window_title("Demo");
WindowFramework *window = framework.open_window();
PT(AudioManager) AM = AudioManager::create_AudioManager();
PT(AudioSound) mySound = AM->get_sound("../data/sounds/sound.ogg");
mySound->play();
framework.main_loop();
framework.close_framework();
return 0;
}
Hmm it works in some miraculous way. Although I get the message again:
warning: I can’t automatically find the configuration files in the directory named “< Auto>etc”.
When deleting the etc folder.