Skip to content

Commit 67a7c39

Browse files
committed
Add some missing functions
1 parent 88d3ccb commit 67a7c39

File tree

3 files changed

+73
-1
lines changed

3 files changed

+73
-1
lines changed

CMakeLists.txt

+3-1
Original file line numberDiff line numberDiff line change
@@ -114,8 +114,10 @@ else()
114114
set(CMAKE_CXX_FLAGS_DEBUG "")
115115
set(CMAKE_C_FLAGS_DEBUG "")
116116

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

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

src/audio_stream_mpt.cpp

+51
Original file line numberDiff line numberDiff line change
@@ -457,6 +457,16 @@ const PackedByteArray& AudioStreamMPT::get_data() const {
457457
return this->data;
458458
}
459459

460+
void AudioStreamMPT::select_subsong(int32_t subsong) {
461+
CHECK_MOD_LOADED_RETV();
462+
this->mpt_module->select_subsong(subsong);
463+
}
464+
465+
int32_t AudioStreamMPT::get_selected_subsong() const {
466+
CHECK_MOD_LOADED_RET(0);
467+
return this->mpt_module->get_selected_subsong();
468+
}
469+
460470
TypedArray<String> AudioStreamMPT::get_channel_names() const {
461471
CHECK_MOD_LOADED_RET(TypedArray<String>());
462472
TypedArray<String> result;
@@ -582,6 +592,31 @@ TypedArray<String> AudioStreamMPT::get_subsong_names() const {
582592
return result;
583593
}
584594

595+
uint8_t AudioStreamMPT::get_pattern_row_channel_command(int32_t pattern, int32_t row, int32_t channel, CommandIndex command) const {
596+
CHECK_MOD_LOADED_RET(0);
597+
return this->mpt_module->get_pattern_row_channel_command(pattern, row, channel, (int)command);
598+
}
599+
600+
String AudioStreamMPT::format_pattern_row_channel_command(int32_t pattern, int32_t row, int32_t channel, CommandIndex command) const {
601+
CHECK_MOD_LOADED_RET("");
602+
return this->mpt_module->format_pattern_row_channel_command(pattern, row, channel, (int)command).c_str();
603+
}
604+
605+
String AudioStreamMPT::highlight_pattern_row_channel_command(int32_t pattern, int32_t row, int32_t channel, CommandIndex command) const {
606+
CHECK_MOD_LOADED_RET("");
607+
return this->mpt_module->highlight_pattern_row_channel_command(pattern, row, channel, (int)command).c_str();
608+
}
609+
610+
String AudioStreamMPT::format_pattern_row_channel(int32_t pattern, int32_t row, int32_t channel, int64_t width, bool pad) const {
611+
CHECK_MOD_LOADED_RET("");
612+
return this->mpt_module->format_pattern_row_channel(pattern, row, channel, (size_t)width, pad).c_str();
613+
}
614+
615+
String AudioStreamMPT::highlight_pattern_row_channel(int32_t pattern, int32_t row, int32_t channel, int64_t width, bool pad) const {
616+
CHECK_MOD_LOADED_RET("");
617+
return this->mpt_module->highlight_pattern_row_channel(pattern, row, channel, (size_t)width, pad).c_str();
618+
}
619+
585620
Error AudioStreamMPT::get_module_error() const {
586621
return module_error;
587622
}
@@ -618,6 +653,9 @@ void AudioStreamMPT::_bind_methods() {
618653
ClassDB::bind_method(D_METHOD("set_data", "data"), &AudioStreamMPT::set_data);
619654
ClassDB::bind_method(D_METHOD("get_data"), &AudioStreamMPT::get_data);
620655

656+
ClassDB::bind_method(D_METHOD("select_subsong", "subsong"), &AudioStreamMPT::select_subsong);
657+
ClassDB::bind_method(D_METHOD("get_selected_subsong"), &AudioStreamMPT::get_selected_subsong);
658+
621659
ClassDB::bind_method(D_METHOD("get_channel_names"), &AudioStreamMPT::get_channel_names);
622660
ClassDB::bind_method(D_METHOD("get_instrument_names"), &AudioStreamMPT::get_instrument_names);
623661

@@ -645,6 +683,12 @@ void AudioStreamMPT::_bind_methods() {
645683
ClassDB::bind_method(D_METHOD("get_sample_names"), &AudioStreamMPT::get_sample_names);
646684
ClassDB::bind_method(D_METHOD("get_subsong_names"), &AudioStreamMPT::get_subsong_names);
647685

686+
ClassDB::bind_method(D_METHOD("get_pattern_row_channel_command", "pattern", "row", "channel", "command"), &AudioStreamMPT::get_pattern_row_channel_command);
687+
ClassDB::bind_method(D_METHOD("format_pattern_row_channel_command", "pattern", "row", "channel", "command"), &AudioStreamMPT::format_pattern_row_channel_command);
688+
ClassDB::bind_method(D_METHOD("highlight_pattern_row_channel_command", "pattern", "row", "channel", "command"), &AudioStreamMPT::highlight_pattern_row_channel_command);
689+
ClassDB::bind_method(D_METHOD("format_pattern_row_channel", "pattern", "row", "channel", "width", "pad"), &AudioStreamMPT::format_pattern_row_channel);
690+
ClassDB::bind_method(D_METHOD("highlight_pattern_row_channel", "pattern", "row", "channel", "width", "pad"), &AudioStreamMPT::highlight_pattern_row_channel);
691+
648692
ClassDB::bind_method(D_METHOD("get_module_error"), &AudioStreamMPT::get_module_error);
649693

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

654698
BIND_ENUM_CONSTANT(LOOP_DISABLED);
655699
BIND_ENUM_CONSTANT(LOOP_ENABLED);
700+
701+
BIND_ENUM_CONSTANT(COMMAND_NOTE);
702+
BIND_ENUM_CONSTANT(COMMAND_INSTRUMENT);
703+
BIND_ENUM_CONSTANT(COMMAND_VOLUMEFFECT);
704+
BIND_ENUM_CONSTANT(COMMAND_EFFECT);
705+
BIND_ENUM_CONSTANT(COMMAND_VOLUME);
706+
BIND_ENUM_CONSTANT(COMMAND_PARAMETER);
656707
}
657708

658709
AudioStreamMPT::AudioStreamMPT() {

src/audio_stream_mpt.h

+19
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,15 @@ class AudioStreamMPT : public AudioStream {
112112
LOOP_DISABLED,
113113
LOOP_ENABLED
114114
};
115+
116+
enum CommandIndex {
117+
COMMAND_NOTE = 0,
118+
COMMAND_INSTRUMENT = 1,
119+
COMMAND_VOLUMEFFECT = 2,
120+
COMMAND_EFFECT = 3,
121+
COMMAND_VOLUME = 4,
122+
COMMAND_PARAMETER = 5
123+
};
115124
private:
116125
LoopMode loop_mode = LoopMode::LOOP_DISABLED;
117126
bool stereo = true;
@@ -158,6 +167,9 @@ class AudioStreamMPT : public AudioStream {
158167
int32_t get_num_patterns() const;
159168
int32_t get_num_samples() const;
160169
int32_t get_num_subsongs() const;
170+
171+
void select_subsong(int32_t subsong);
172+
int32_t get_selected_subsong() const;
161173

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

183+
uint8_t get_pattern_row_channel_command(int32_t pattern, int32_t row, int32_t channel, CommandIndex command) const;
184+
String format_pattern_row_channel_command(int32_t pattern, int32_t row, int32_t channel, CommandIndex command) const;
185+
String highlight_pattern_row_channel_command(int32_t pattern, int32_t row, int32_t channel, CommandIndex command) const;
186+
String format_pattern_row_channel(int32_t pattern, int32_t row, int32_t channel, int64_t width = 0, bool pad = true) const;
187+
String highlight_pattern_row_channel(int32_t pattern, int32_t row, int32_t channel, int64_t width = 0, bool pad = true) const;
188+
171189
Error get_module_error() const;
172190

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

180198
VARIANT_ENUM_CAST(AudioStreamMPT::LoopMode)
199+
VARIANT_ENUM_CAST(AudioStreamMPT::CommandIndex)
181200

182201
#endif // AUDIO_STREAM_MPT_H

0 commit comments

Comments
 (0)