goostengine / goost

A general-purpose, extensible and customizable C++ extension for Godot Engine.
https://goostengine.github.io/
MIT License
481 stars 18 forks source link

Implemented set/get to add resources directly, MidiFile now has internal format enum #159

Closed ghost closed 3 years ago

ghost commented 3 years ago

Changes:

MidiFile

MidiFile has an internal format variable and Format enum that is automatically set at import time.

Format enum: 
    FORMAT_MIDI = 0 
    FORMAT_SF2 = 1

VERY IMPORTANT: You will have to re-import all MidiFile data simply select them all and go to Import tab and click Reimport. Because the old formats stored in .import do not contain format and MidiPlayer will reject them with incorrect format error.

MidiPlayer

MidiPlayer now has 2 additional variables : soundfont and midi which are both MidiFile resources. You can now set them directly: $MidiPlayer.soundfont = preload("res://mysoundfont.sf2") There are two new methods set_soundfont and set_midi The get methods will now return the MidiFile resource rather than the path. To get the path you would need .name or .path or something like that :)

NOTE: It will now throw an error if you try to load the incorrect format. The error is shown in the regular Output window but as red (uses print_error).

The old functions load_soundfont and load_midi are still there and function as a shorthand to set+load but they simply load the resource then call on set_soundfont and set_midi. This means you can safely remove them if you wish as the are purely for convenience at this point. I like em so I'm keeping them :))

Docs

All new parameters have been added to the Docs including the Format enum, format member , Midi members , new set/get functionality and so on. I have added more clarification and descriptions. I have incorporated your changes as well from the previous commits. I also added a list of soundfonts that are completely free that you can look for. And also better explained the different concepts regarding midi.

Enjoy:)

ghost commented 3 years ago

Also YES I cleaned up all the comments and added spaces to all the comments // comment rather than //comment because it was bugging me 🤣

ghost commented 3 years ago

Sorry mispelled correct haha 🍞 I'm so tired. Gotta sleep. The last PR will now display the correct MidiFile resource file and you can load, or quick load that specific resource type 👍

Xrayez commented 3 years ago

Thanks!

Xrayez commented 3 years ago

The old functions load_soundfont and load_midi are still there and function as a shorthand to set+load but they simply load the resource then call on set_soundfont and set_midi. This means you can safely remove them if you wish as the are purely for convenience at this point. I like em so I'm keeping them :))

I think they can be useful for loading MIDI and SoundFont files in exported projects at runtime. I'd add MidiFile.load() function and move import code into that (and make import code use MidiFile.load()), this would be consistent with other classes in Godot such as Image.load().

Moreover, current convenient functions may actually lead to confusion/error when a user tries to load anything from outside res:// path, as ResourceLoader does not handle filesystem paths.