nobuyukinyuu / gdsmod

Godot Module Replayer
MIT License
36 stars 0 forks source link

Use the player inside a real game #8

Open fsoft72 opened 4 years ago

fsoft72 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

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 commented 4 years ago

Hello Nobuyuki,

thank you for your kind reply :-) I am just starting now writing my game and as soon as I'll arrive to the tracker I'll write to you.

Thanks! Fabio

On Tue, Nov 5, 2019 at 3:35 PM Nobuyuki notifications@github.com wrote:

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!

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/nobuyukinyuu/gdsmod/issues/8?email_source=notifications&email_token=AAVWNV3Z62V3MKBTI4RXKY3QSGAE3A5CNFSM4JI7CQE2YY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGOEDC5JPA#issuecomment-549835964, or unsubscribe https://github.com/notifications/unsubscribe-auth/AAVWNV4LVBYRUOESNR2YJDLQSGAE3ANCNFSM4JI7CQEQ .

--

Ciao, Fabio

konsumer commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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 commented 3 years ago

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()