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

Use the player inside a real game #8

Open
fsoft72 opened this issue Nov 5, 2019 · 7 comments
Open

Use the player inside a real game #8

fsoft72 opened this issue Nov 5, 2019 · 7 comments

Comments

@fsoft72
Copy link

fsoft72 commented Nov 5, 2019

Hello,

I am starting porting one of my old Amiga games (Quadranoid) on Godot (after 25 years!) and I'd like to use your mod player to play original PRO tracker files.
Is it possible to use your software as a standalone library to play modules?

Thanks! :-)

@nobuyukinyuu
Copy link
Owner

nobuyukinyuu commented Nov 5, 2019

Hello! Thank you for your interest in my project. When writing it, I tried to separate the interface from the implementation the best i could, in the hopes it wouldn't be too difficult to adapt it to a game project if necessary. However, the code hasn't been tested outside of the scene it belongs to, so I couldn't say for sure!

If you check the code you can see most of the classes are in the main file. All of the interface functions are at the top, and the replayer code is below that. Feel free to make your own audio stream generator in another scene and try using the replayer to fill the buffer with data from a mod you've loaded into the replayer. I'll be happy to know the results!

P.S. One more thing to note; the file access routines are not guaranteed to work on every platform in the same way, so to be safe you should load a path from the resource folder, and remember that mods aren't included in the pack file by default, so you'll have to include them when exporting to a real project.

On my puny old i3, gdsmod takes up around 6% cpu to render a mod and fill the sound buffer at runtime. Please set your expectations accordingly. 🙏 Thank you!

@nobuyukinyuu
Copy link
Owner

Ah, and moreover, whether you're able to successfully play a mod from outside the scene or not, please let me know. I may be able to try moving the replayer to its own separate singleton myself if it needs more work to get working in your game than a simple copy-and-paste job to an autoload.

@fsoft72
Copy link
Author

fsoft72 commented Nov 5, 2019 via email

@konsumer
Copy link

I would also like to use it in a game. I really like the idea of using mods instead of big ogg files, and it seems to perform pretty well. Maybe a plugin that provides a new Node-type with an import-plugin (like this would make it easier to use?

I tried digging in, but couldn't quite figure out how to pull the player out of the demo scene. It looks like load_module in ModReplayer.gd will load it, and inject it into an Audiobuffer. Is this right? Maybe I could extend an audio-buffer to a new type and add an import-type in a plugin.

@konsumer
Copy link

Also, as a side-note, I think it will allow mod-files in HTML5 exports, which is great (vs native addons, which only work on specific native targets that they've been compiled for, and cause lots of other issues.)

@konsumer
Copy link

konsumer commented Mar 13, 2021

I think I made some progress using it as a plugin that should define a new AudioStreamSample so it can be attached to a AudioStreamPlayer.

Still can't wire it up to a AudioStreamPlayer, though:

 editor/import/editor_import_plugin.cpp:91 - Condition "!(get_script_instance() && get_script_instance()->has_method("get_import_options"))" is true.
 editor/import/editor_import_plugin.cpp:61 - Condition "!(get_script_instance() && get_script_instance()->has_method("get_preset_count"))" is true. Returned: 0
 Cannot erase nonexistent section "params".
 editor/import/editor_import_plugin.cpp:91 - Condition "!(get_script_instance() && get_script_instance()->has_method("get_import_options"))" is true.
 core/class_db.cpp:540 - Condition "!ti->creation_func" is true. Returned: __null
 Class type: 'AudioStreamGeneratorPlayback' is not instantiable.
 res://addons/gsmod/import_plugin.gd:22 - Invalid call. Nonexistent function 'get_frames_available' in base 'Nil'.
 core/os/file_access.cpp:667 - Condition "!f" is true. Continuing.
 Cannot open file 'res://.import/mdemo4_3.mod-718abadf4df1f2ebca0f0ecf2fe47da5.res'

Maybe someone with more godot-knowledge can see what I'm missing?

gsmod_demo.zip

@konsumer
Copy link

konsumer commented Mar 13, 2021

I decided to go another direction: make a minimal self-contained scene, so I could just drop it into my game.

gsmod_minimal.zip

I'll keep working on a plugin (maybe just a new type that is an instance of the scene, that lets you set the file) but I figured this could be useful to others as-is.

The zip is a demo-project, but you can drop ModPlayer.tscn into your scene, then run code liek this:

func _ready():
  $ModPlayer.load("res://test.mod")
  $ModPlayer.play()

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants