Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Custom audiostream boilerplate not compiling. #6170

Open
wetbadger opened this issue Sep 12, 2022 · 2 comments
Open

Custom audiostream boilerplate not compiling. #6170

wetbadger opened this issue Sep 12, 2022 · 2 comments
Labels
area:contributing Issues and PRs related to the Contributing/Development section of the documentation bug

Comments

@wetbadger
Copy link

Your Godot version:

3.6-beta, Also tried with 3.4.5

Issue description:

I was following the tutorial here: https://docs.godotengine.org/en/3.6/development/cpp/custom_audiostreams.html, but the files don't compile.

scons -j8 platform=linuxbsd
scons: Reading SConscript files ...
Platform "linuxbsd" is still called "x11" in Godot 3.x. Building for platform "x11".
Warning: Speech Dispatcher development libraries not found. Disabling Text-to-Speech support.
Note: Building a debug binary (which will run slowly). Use `target=release_debug` to build an optimized release binary.
Warning: module 'x11' uses a deprecated `can_build` signature in its config.py file, it should be `can_build(env, platform)`.
Checking for C header file mntent.h... (cached) yes
scons: done reading SConscript files.
scons: Building targets ...
[ 30%] Compiling ==> modules/audiostream/audiostream.cpp
[ 30%] Compiling ==> modules/audiostream/audiostreamplayer.cpp
[ 46%] modules/audiostream/audiostream.cpp: In member function 'virtual Ref<AudioStreamPlayback> AudioStreamMyTone::instance_playback()':
modules/audiostream/audiostream.cpp:10:13: error: 'AudioStreamPlaybackMyTone' was not declared in this scope; did you mean 'AudioStreamPlaybackResampled'?
   10 |         Ref<AudioStreamPlaybackMyTone> talking_tree;
      |             ^~~~~~~~~~~~~~~~~~~~~~~~~~
      |             AudioStreamPlaybackResampled
modules/audiostream/audiostream.cpp:10:39: error: template argument 1 is invalid
   10 |         Ref<AudioStreamPlaybackMyTone> talking_tree;
      |                                       ^
modules/audiostream/audiostream.cpp:11:22: error: request for member 'instance' in 'talking_tree', which is of non-class type 'int'
   11 |         talking_tree.instance();
      |                      ^~~~~~~~
modules/audiostream/audiostream.cpp:12:21: error: base operand of '->' is not a pointer
   12 |         talking_tree->base = Ref<AudioStreamMyTone>(this);
      |                     ^~
modules/audiostream/audiostream.cpp:13:16: error: could not convert 'talking_tree' from 'int' to 'Ref<AudioStreamPlayback>'
   13 |         return talking_tree;
      |                ^~~~~~~~~~~~
      |                |
      |                int
[ 46%] In file included from modules/audiostream/audiostreamplayer.cpp:3:
modules/audiostream/audiostreamplayer.h:21:13: error: 'AudioStreamMyTone' was not declared in this scope
   21 |         Ref<AudioStreamMyTone> base;
      |             ^~~~~~~~~~~~~~~~~~
modules/audiostream/audiostreamplayer.h:21:31: error: template argument 1 is invalid
   21 |         Ref<AudioStreamMyTone> base;
      |                               ^
[ 46%] modules/audiostream/audiostreamplayer.cpp: In constructor 'AudioStreamPlaybackMyTone::AudioStreamPlaybackMyTone()':
modules/audiostream/audiostreamplayer.cpp:12:9: error: 'zeromem' was not declared in this scope
   12 |         zeromem(pcm_buffer, PCM_BUFFER_SIZE);
      |         ^~~~~~~
modules/audiostream/audiostreamplayer.cpp: In member function 'virtual void AudioStreamPlaybackMyTone::stop()':
modules/audiostream/audiostreamplayer.cpp:23:13: error: base operand of '->' is not a pointer
   23 |         base->reset();
      |             ^~
modules/audiostream/audiostreamplayer.cpp: In member function 'virtual void AudioStreamPlaybackMyTone::seek(float)':
modules/audiostream/audiostreamplayer.cpp:34:13: error: base operand of '->' is not a pointer
   34 |         base->set_position(uint64_t(p_time * base->mix_rate) << MIX_FRAC_BITS);
      |             ^~
modules/audiostream/audiostreamplayer.cpp:34:50: error: base operand of '->' is not a pointer
   34 |         base->set_position(uint64_t(p_time * base->mix_rate) << MIX_FRAC_BITS);
      |                                                  ^~
modules/audiostream/audiostreamplayer.cpp:30:15: warning: unused variable 'max' [-Wunused-variable]
   30 |         float max = get_length();
      |               ^~~
[ 46%] modules/audiostream/audiostreamplayer.cpp: In member function 'virtual void AudioStreamPlaybackMyTone::mix(AudioFrame*, float, int)':
modules/audiostream/audiostreamplayer.cpp:41:9: error: 'zeromem' was not declared in this scope
   41 |         zeromem(pcm_buffer, PCM_BUFFER_SIZE);
      |         ^~~~~~~
modules/audiostream/audiostreamplayer.cpp:43:13: error: base operand of '->' is not a pointer
   43 |         base->gen_tone(buf, p_frames);
      |             ^~
[ 60%] Compiling ==> platform/osx/export/export.cpp
[ 60%] Compiling ==> platform/osx/export/lipo.cpp
[ 60%] Compiling ==> platform/osx/export/macho.cpp
[ 60%] Compiling ==> platform/osx/export/plist.cpp
[ 60%] Compiling ==> platform/uwp/export/export.cpp
[ 60%] Compiling ==> platform/windows/export/export.cpp
scons: *** [modules/audiostream/audiostream.x11.tools.64.o] Error 1
scons: *** [modules/audiostream/audiostreamplayer.x11.tools.64.o] Error 1
scons: building terminated because of errors.
[Time elapsed: 00:00:05.713]

The SCsub, config.py, and register_types files are set up according to this: https://docs.godotengine.org/en/3.6/development/cpp/custom_modules_in_cpp.html#doc-custom-modules-in-c

I'm no C++ expert. Why is AudioStreamPlaybackMyTone not declared in this scope? In audiostream_mytone.h it looks like it is declared as "friend class AudioStreamPlaybackMyTone"

I have tried changing the folder name to something other than audiostream, as well as changing AudioStreamMyTone and AudioStreamPlaybackMyTone to see if there was some conflict with existing AudioStream object.

Could the documentation be improved?

URL to the documentation page (if already existing):

https://docs.godotengine.org/en/3.6/development/cpp/custom_audiostreams.html

@YuriSizov YuriSizov added bug and removed enhancement labels Sep 12, 2022
@skyace65 skyace65 added the area:contributing Issues and PRs related to the Contributing/Development section of the documentation label Dec 28, 2022
@hungrymonkey
Copy link
Contributor

hungrymonkey commented Mar 16, 2023

Hi OP, I was the one who wrote the docs. The documentation hasn't been updated in years.

https://docs.godotengine.org/en/3.6/development/cpp/custom_modules_in_cpp.html

The compiler is probably not finding the files. I see upstream have move many of the internal container types.

It seems like they move the reference counted container object

https://github.com/godotengine/godot/blob/master/core/object/ref_counted.h
godotengine/godot@180e5d3
https://github.com/godotengine/godot/blob/32a29977fbc030ad0d41b3b8eb3b165864cd5833/core/io/resource.h

I currently do not have any motivation to update the docs.

@hungrymonkey
Copy link
Contributor

https://github.com/godotengine/godot/tree/1d14c054a12dacdc193b589e4afb0ef319ee2aae/servers/audio

I would recommend you look at playback resample. I based a good chunk of my original doc on it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:contributing Issues and PRs related to the Contributing/Development section of the documentation bug
Projects
None yet
Development

No branches or pull requests

4 participants