Skip to content

Commit

Permalink
Add some missing functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Dudejoe870 committed Apr 7, 2024
1 parent 88d3ccb commit 67a7c39
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 1 deletion.
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,10 @@ else()
set(CMAKE_CXX_FLAGS_DEBUG "")
set(CMAKE_C_FLAGS_DEBUG "")

set(GODOT_LINKER_FLAGS "-static-libgcc -static-libstdc++ -Wl,--gc-sections,-R,'$$ORIGIN'")
set(GODOT_LINKER_FLAGS "-static-libgcc -static-libstdc++ -Wl,-flto,--gc-sections,-R,'$$ORIGIN'")

set(CMAKE_AR, "gcc-ar")
set(CMAKE_NM, "gcc-nm")
set(CMAKE_RANLIB "gcc-ranlib")
set(GODOT_COMPILE_FLAGS "-fPIC -flto -fvisibility=hidden -fvisibility-inlines-hidden -ffunction-sections -fdata-sections -fexceptions -frtti -pthread")

Expand Down
51 changes: 51 additions & 0 deletions src/audio_stream_mpt.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -457,6 +457,16 @@ const PackedByteArray& AudioStreamMPT::get_data() const {
return this->data;
}

void AudioStreamMPT::select_subsong(int32_t subsong) {
CHECK_MOD_LOADED_RETV();
this->mpt_module->select_subsong(subsong);
}

int32_t AudioStreamMPT::get_selected_subsong() const {
CHECK_MOD_LOADED_RET(0);
return this->mpt_module->get_selected_subsong();
}

TypedArray<String> AudioStreamMPT::get_channel_names() const {
CHECK_MOD_LOADED_RET(TypedArray<String>());
TypedArray<String> result;
Expand Down Expand Up @@ -582,6 +592,31 @@ TypedArray<String> AudioStreamMPT::get_subsong_names() const {
return result;
}

uint8_t AudioStreamMPT::get_pattern_row_channel_command(int32_t pattern, int32_t row, int32_t channel, CommandIndex command) const {
CHECK_MOD_LOADED_RET(0);
return this->mpt_module->get_pattern_row_channel_command(pattern, row, channel, (int)command);
}

String AudioStreamMPT::format_pattern_row_channel_command(int32_t pattern, int32_t row, int32_t channel, CommandIndex command) const {
CHECK_MOD_LOADED_RET("");
return this->mpt_module->format_pattern_row_channel_command(pattern, row, channel, (int)command).c_str();
}

String AudioStreamMPT::highlight_pattern_row_channel_command(int32_t pattern, int32_t row, int32_t channel, CommandIndex command) const {
CHECK_MOD_LOADED_RET("");
return this->mpt_module->highlight_pattern_row_channel_command(pattern, row, channel, (int)command).c_str();
}

String AudioStreamMPT::format_pattern_row_channel(int32_t pattern, int32_t row, int32_t channel, int64_t width, bool pad) const {
CHECK_MOD_LOADED_RET("");
return this->mpt_module->format_pattern_row_channel(pattern, row, channel, (size_t)width, pad).c_str();
}

String AudioStreamMPT::highlight_pattern_row_channel(int32_t pattern, int32_t row, int32_t channel, int64_t width, bool pad) const {
CHECK_MOD_LOADED_RET("");
return this->mpt_module->highlight_pattern_row_channel(pattern, row, channel, (size_t)width, pad).c_str();
}

Error AudioStreamMPT::get_module_error() const {
return module_error;
}
Expand Down Expand Up @@ -618,6 +653,9 @@ void AudioStreamMPT::_bind_methods() {
ClassDB::bind_method(D_METHOD("set_data", "data"), &AudioStreamMPT::set_data);
ClassDB::bind_method(D_METHOD("get_data"), &AudioStreamMPT::get_data);

ClassDB::bind_method(D_METHOD("select_subsong", "subsong"), &AudioStreamMPT::select_subsong);
ClassDB::bind_method(D_METHOD("get_selected_subsong"), &AudioStreamMPT::get_selected_subsong);

ClassDB::bind_method(D_METHOD("get_channel_names"), &AudioStreamMPT::get_channel_names);
ClassDB::bind_method(D_METHOD("get_instrument_names"), &AudioStreamMPT::get_instrument_names);

Expand Down Expand Up @@ -645,6 +683,12 @@ void AudioStreamMPT::_bind_methods() {
ClassDB::bind_method(D_METHOD("get_sample_names"), &AudioStreamMPT::get_sample_names);
ClassDB::bind_method(D_METHOD("get_subsong_names"), &AudioStreamMPT::get_subsong_names);

ClassDB::bind_method(D_METHOD("get_pattern_row_channel_command", "pattern", "row", "channel", "command"), &AudioStreamMPT::get_pattern_row_channel_command);
ClassDB::bind_method(D_METHOD("format_pattern_row_channel_command", "pattern", "row", "channel", "command"), &AudioStreamMPT::format_pattern_row_channel_command);
ClassDB::bind_method(D_METHOD("highlight_pattern_row_channel_command", "pattern", "row", "channel", "command"), &AudioStreamMPT::highlight_pattern_row_channel_command);
ClassDB::bind_method(D_METHOD("format_pattern_row_channel", "pattern", "row", "channel", "width", "pad"), &AudioStreamMPT::format_pattern_row_channel);
ClassDB::bind_method(D_METHOD("highlight_pattern_row_channel", "pattern", "row", "channel", "width", "pad"), &AudioStreamMPT::highlight_pattern_row_channel);

ClassDB::bind_method(D_METHOD("get_module_error"), &AudioStreamMPT::get_module_error);

ADD_PROPERTY(PropertyInfo(Variant::PACKED_BYTE_ARRAY, "data", PROPERTY_HINT_NONE, "", PROPERTY_USAGE_NO_EDITOR), "set_data", "get_data");
Expand All @@ -653,6 +697,13 @@ void AudioStreamMPT::_bind_methods() {

BIND_ENUM_CONSTANT(LOOP_DISABLED);
BIND_ENUM_CONSTANT(LOOP_ENABLED);

BIND_ENUM_CONSTANT(COMMAND_NOTE);
BIND_ENUM_CONSTANT(COMMAND_INSTRUMENT);
BIND_ENUM_CONSTANT(COMMAND_VOLUMEFFECT);
BIND_ENUM_CONSTANT(COMMAND_EFFECT);
BIND_ENUM_CONSTANT(COMMAND_VOLUME);
BIND_ENUM_CONSTANT(COMMAND_PARAMETER);
}

AudioStreamMPT::AudioStreamMPT() {
Expand Down
19 changes: 19 additions & 0 deletions src/audio_stream_mpt.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,15 @@ class AudioStreamMPT : public AudioStream {
LOOP_DISABLED,
LOOP_ENABLED
};

enum CommandIndex {
COMMAND_NOTE = 0,
COMMAND_INSTRUMENT = 1,
COMMAND_VOLUMEFFECT = 2,
COMMAND_EFFECT = 3,
COMMAND_VOLUME = 4,
COMMAND_PARAMETER = 5
};
private:
LoopMode loop_mode = LoopMode::LOOP_DISABLED;
bool stereo = true;
Expand Down Expand Up @@ -158,6 +167,9 @@ class AudioStreamMPT : public AudioStream {
int32_t get_num_patterns() const;
int32_t get_num_samples() const;
int32_t get_num_subsongs() const;

void select_subsong(int32_t subsong);
int32_t get_selected_subsong() const;

TypedArray<String> get_order_names() const;
int32_t get_order_pattern(int32_t order) const;
Expand All @@ -168,6 +180,12 @@ class AudioStreamMPT : public AudioStream {
TypedArray<String> get_sample_names() const;
TypedArray<String> get_subsong_names() const;

uint8_t get_pattern_row_channel_command(int32_t pattern, int32_t row, int32_t channel, CommandIndex command) const;
String format_pattern_row_channel_command(int32_t pattern, int32_t row, int32_t channel, CommandIndex command) const;
String highlight_pattern_row_channel_command(int32_t pattern, int32_t row, int32_t channel, CommandIndex command) const;
String format_pattern_row_channel(int32_t pattern, int32_t row, int32_t channel, int64_t width = 0, bool pad = true) const;
String highlight_pattern_row_channel(int32_t pattern, int32_t row, int32_t channel, int64_t width = 0, bool pad = true) const;

Error get_module_error() const;

virtual Ref<AudioStreamPlayback> _instantiate_playback() const override;
Expand All @@ -178,5 +196,6 @@ class AudioStreamMPT : public AudioStream {
};

VARIANT_ENUM_CAST(AudioStreamMPT::LoopMode)
VARIANT_ENUM_CAST(AudioStreamMPT::CommandIndex)

#endif // AUDIO_STREAM_MPT_H

0 comments on commit 67a7c39

Please sign in to comment.