@@ -19,13 +19,13 @@ using namespace godot;
19
19
#define CHECK_MOD_LOADED_RETV () if (!this ->mpt_module) { WARN_PRINT_ED (MOD_NOT_LOADED_MSG); return ; }
20
20
21
21
#define CHECK_INT_LOADED_RET (retval ) CHECK_MOD_LOADED_RET(retval); if (!this ->mpt_interactive) { WARN_PRINT_ED (INT_NOT_LOADED_MSG); return retval; }
22
- #define CHECK_INT_LOADED_RETV () CHECK_MOD_LOADED_RETV(); if (!this ->mpt_module ) { WARN_PRINT_ED (INT_NOT_LOADED_MSG); return ; }
22
+ #define CHECK_INT_LOADED_RETV () CHECK_MOD_LOADED_RETV(); if (!this ->mpt_interactive ) { WARN_PRINT_ED (INT_NOT_LOADED_MSG); return ; }
23
23
24
- #define CHECK_INT2_LOADED_RET (retval ) CHECK_MOD_LOADED_RET(retval); if (!this ->mpt_interactive ) { WARN_PRINT_ED (INT2_NOT_LOADED_MSG); return retval; }
25
- #define CHECK_INT2_LOADED_RETV () CHECK_MOD_LOADED_RETV(); if (!this ->mpt_module ) { WARN_PRINT_ED (INT2_NOT_LOADED_MSG); return ; }
24
+ #define CHECK_INT2_LOADED_RET (retval ) CHECK_MOD_LOADED_RET(retval); if (!this ->mpt_interactive2 ) { WARN_PRINT_ED (INT2_NOT_LOADED_MSG); return retval; }
25
+ #define CHECK_INT2_LOADED_RETV () CHECK_MOD_LOADED_RETV(); if (!this ->mpt_interactive2 ) { WARN_PRINT_ED (INT2_NOT_LOADED_MSG); return ; }
26
26
27
- #define CHECK_INT3_LOADED_RET (retval ) CHECK_MOD_LOADED_RET(retval); if (!this ->mpt_interactive ) { WARN_PRINT_ED (INT3_NOT_LOADED_MSG); return retval; }
28
- #define CHECK_INT3_LOADED_RETV () CHECK_MOD_LOADED_RETV(); if (!this ->mpt_module ) { WARN_PRINT_ED (INT3_NOT_LOADED_MSG); return ; }
27
+ #define CHECK_INT3_LOADED_RET (retval ) CHECK_MOD_LOADED_RET(retval); if (!this ->mpt_interactive3 ) { WARN_PRINT_ED (INT3_NOT_LOADED_MSG); return retval; }
28
+ #define CHECK_INT3_LOADED_RETV () CHECK_MOD_LOADED_RETV(); if (!this ->mpt_interactive3 ) { WARN_PRINT_ED (INT3_NOT_LOADED_MSG); return ; }
29
29
30
30
void AudioStreamPlaybackMPT::_start (double p_from_pos) {
31
31
_seek (p_from_pos);
@@ -285,6 +285,16 @@ double AudioStreamPlaybackMPT::get_note_finetune(int32_t channel) const {
285
285
return this ->mpt_interactive2 ->get_note_finetune (channel);
286
286
}
287
287
288
+ void AudioStreamPlaybackMPT::set_sync_samples (bool p_enable) {
289
+ CHECK_MOD_LOADED_RETV ();
290
+ this ->mpt_module ->ctl_set_boolean (" seek.sync_samples" , p_enable);
291
+ }
292
+
293
+ bool AudioStreamPlaybackMPT::get_sync_samples () const {
294
+ CHECK_MOD_LOADED_RET (true );
295
+ return this ->mpt_module ->ctl_get_boolean (" seek.sync_samples" );
296
+ }
297
+
288
298
int32_t AudioStreamPlaybackMPT::_mix (AudioFrame *p_buffer, double p_rate_scale, int32_t p_frames) {
289
299
if (!this ->mpt_module ) {
290
300
active = false ;
@@ -382,6 +392,9 @@ void AudioStreamPlaybackMPT::_bind_methods() {
382
392
383
393
ClassDB::bind_method (D_METHOD (" set_note_finetune" , " channel" , " finetune" ), &AudioStreamPlaybackMPT::set_note_finetune);
384
394
ClassDB::bind_method (D_METHOD (" get_note_finetune" , " channel" ), &AudioStreamPlaybackMPT::get_note_finetune);
395
+
396
+ ClassDB::bind_method (D_METHOD (" set_sync_samples" , " sync_samples" ), &AudioStreamPlaybackMPT::set_sync_samples);
397
+ ClassDB::bind_method (D_METHOD (" get_sync_samples" ), &AudioStreamPlaybackMPT::get_sync_samples);
385
398
}
386
399
387
400
AudioStreamPlaybackMPT::AudioStreamPlaybackMPT () {}
@@ -423,6 +436,38 @@ bool AudioStreamMPT::_is_monophonic() const {
423
436
return false ;
424
437
}
425
438
439
+ void AudioStreamMPT::set_skip_plugins (bool p_enable) {
440
+ this ->skip_plugins = p_enable;
441
+ }
442
+
443
+ bool AudioStreamMPT::get_skip_plugins () const {
444
+ return this ->skip_plugins ;
445
+ }
446
+
447
+ void AudioStreamMPT::set_skip_subsongs_init (bool p_enable) {
448
+ this ->skip_subsongs_init = p_enable;
449
+ }
450
+
451
+ bool AudioStreamMPT::get_skip_subsongs_init () const {
452
+ return this ->skip_subsongs_init ;
453
+ }
454
+
455
+ void AudioStreamMPT::set_sync_samples (bool p_enable) {
456
+ this ->sync_samples = p_enable;
457
+ }
458
+
459
+ bool AudioStreamMPT::get_sync_samples () const {
460
+ return this ->sync_samples ;
461
+ }
462
+
463
+ std::map<std::string, std::string> AudioStreamMPT::get_initial_ctls () const {
464
+ return std::map<std::string, std::string> {
465
+ { " load.skip_plugins" , this ->skip_plugins ? " 1" : " 0" },
466
+ { " load.skip_subsongs_init" , this ->skip_subsongs_init ? " 1" : " 0" },
467
+ { " seek.sync_samples" , this ->sync_samples ? " 1" : " 0" },
468
+ };
469
+ }
470
+
426
471
void AudioStreamMPT::set_data (const PackedByteArray& p_data) {
427
472
module_error = Error::OK;
428
473
@@ -435,7 +480,7 @@ void AudioStreamMPT::set_data(const PackedByteArray& p_data) {
435
480
436
481
if (this ->mpt_module ) delete mpt_module;
437
482
try {
438
- this ->mpt_module = new openmpt::module (this ->data .ptr (), this ->data .size ());
483
+ this ->mpt_module = new openmpt::module (this ->data .ptr (), this ->data .size (), std::clog, get_initial_ctls () );
439
484
} catch (openmpt::exception & e) {
440
485
module_error = Error::ERR_PARSE_ERROR;
441
486
goto set_empty_module;
@@ -445,7 +490,7 @@ void AudioStreamMPT::set_data(const PackedByteArray& p_data) {
445
490
AudioServer::get_singleton ()->lock ();
446
491
for (AudioStreamPlaybackMPT* playback : open_playback_objects) {
447
492
if (playback->mpt_module ) delete playback->mpt_module ;
448
- playback->mpt_module = new openmpt::module_ext (this ->data .ptr (), this ->data .size ());
493
+ playback->mpt_module = new openmpt::module_ext (this ->data .ptr (), this ->data .size (), std::clog, get_initial_ctls () );
449
494
playback->mpt_interactive = static_cast <openmpt::ext::interactive*>(
450
495
playback->mpt_module ->get_interface (openmpt::ext::interactive_id));
451
496
playback->mpt_interactive2 = static_cast <openmpt::ext::interactive2*>(
@@ -646,7 +691,7 @@ Ref<AudioStreamPlayback> AudioStreamMPT::_instantiate_playback() const {
646
691
Ref<AudioStreamPlaybackMPT> playback;
647
692
playback.instantiate ();
648
693
playback->base = Ref<AudioStreamMPT>(this );
649
- playback->mpt_module = !data.is_empty () ? new openmpt::module_ext (this ->data .ptr (), this ->data .size ()) : nullptr ;
694
+ playback->mpt_module = !data.is_empty () ? new openmpt::module_ext (this ->data .ptr (), this ->data .size (), std::clog, get_initial_ctls () ) : nullptr ;
650
695
if (playback->mpt_module )
651
696
{
652
697
playback->mpt_interactive = static_cast <openmpt::ext::interactive*>(
@@ -671,6 +716,14 @@ void AudioStreamMPT::_bind_methods() {
671
716
ClassDB::bind_method (D_METHOD (" set_stereo" , " stereo" ), &AudioStreamMPT::set_stereo);
672
717
ClassDB::bind_method (D_METHOD (" is_stereo" ), &AudioStreamMPT::is_stereo);
673
718
719
+ ClassDB::bind_method (D_METHOD (" set_skip_plugins" , " skip_plugins" ), &AudioStreamMPT::set_skip_plugins);
720
+ ClassDB::bind_method (D_METHOD (" get_skip_plugins" ), &AudioStreamMPT::get_skip_plugins);
721
+ ClassDB::bind_method (D_METHOD (" set_skip_subsongs_init" , " skip_subsongs_init" ), &AudioStreamMPT::set_skip_subsongs_init);
722
+ ClassDB::bind_method (D_METHOD (" get_skip_subsongs_init" ), &AudioStreamMPT::get_skip_subsongs_init);
723
+
724
+ ClassDB::bind_method (D_METHOD (" set_sync_samples" , " sync_samples" ), &AudioStreamMPT::set_sync_samples);
725
+ ClassDB::bind_method (D_METHOD (" get_sync_samples" ), &AudioStreamMPT::get_sync_samples);
726
+
674
727
ClassDB::bind_method (D_METHOD (" set_data" , " data" ), &AudioStreamMPT::set_data);
675
728
ClassDB::bind_method (D_METHOD (" get_data" ), &AudioStreamMPT::get_data);
676
729
@@ -716,6 +769,10 @@ void AudioStreamMPT::_bind_methods() {
716
769
ADD_PROPERTY (PropertyInfo (Variant::INT, " loop_mode" , PROPERTY_HINT_ENUM, " Disabled,Enabled" ), " set_loop_mode" , " get_loop_mode" );
717
770
ADD_PROPERTY (PropertyInfo (Variant::BOOL, " stereo" ), " set_stereo" , " is_stereo" );
718
771
772
+ ADD_PROPERTY (PropertyInfo (Variant::BOOL, " skip_plugins" ), " set_skip_plugins" , " get_skip_plugins" );
773
+ ADD_PROPERTY (PropertyInfo (Variant::BOOL, " skip_subsongs_init" ), " set_skip_subsongs_init" , " get_skip_subsongs_init" );
774
+ ADD_PROPERTY (PropertyInfo (Variant::BOOL, " sync_samples" ), " set_sync_samples" , " get_sync_samples" );
775
+
719
776
BIND_ENUM_CONSTANT (LOOP_DISABLED);
720
777
BIND_ENUM_CONSTANT (LOOP_ENABLED);
721
778
0 commit comments