Skip to content

Instantly share code, notes, and snippets.

@loveemu
Created January 24, 2015 09:30
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save loveemu/64e42378fc92c14d30b5 to your computer and use it in GitHub Desktop.
Save loveemu/64e42378fc92c14d30b5 to your computer and use it in GitHub Desktop.
Personal Patch for GBAMusRiper v2.2
diff -rdu src/gba_mus_riper.cpp src_patched/gba_mus_riper.cpp
--- src/gba_mus_riper.cpp 2014-12-22 07:03:19.000000000 +0900
+++ src_patched/gba_mus_riper.cpp 2015-01-24 18:17:27.764686700 +0900
@@ -33,6 +33,7 @@
static bool rc = false;
static bool sb = false;
static bool raw = false;
+static bool force_output_unused = false;
static uint32_t song_tbl_ptr = 0;
static const int sample_rates[] = {-1, 5734, 7884, 10512, 13379, 15768, 18157, 21024, 26758, 31536, 36314, 40137, 42048};
@@ -53,6 +54,7 @@
" velocities and without simulating vibratos.\n"
"-adr : Force adress of the song table manually. This is required for manually dumping music data\n"
" from ROMs where the location can't be detected automatically.\n"
+ "-f : Force exporting unused instruments.\n"
);
exit(0);
}
@@ -111,6 +113,8 @@
sb = true;
else if(!strcmp(args[i], "-raw"))
raw = true;
+ else if(!strcmp(args[i], "-f"))
+ force_output_unused = true;
else
{ // Convert given address to binary, use it instead of automatically detected one
song_tbl_ptr = strtoul(args[i], 0, 0);
@@ -292,6 +296,7 @@
if(sample_rate) sf_rip_args += " -s" + std::to_string(sample_rate);
if(main_volume) sf_rip_args += " -mv" + std::to_string(main_volume);
if(gm) sf_rip_args += " -gm";
+ if(force_output_unused) sf_rip_args += " -f";
sf_rip_args += " 0x" + hex(*j);
// printf("DEBUG : Goint to call system(%s)\n", sf_rip_args.c_str());
@@ -308,6 +313,7 @@
if(main_volume) sf_rip_args += " -mv" + std::to_string(main_volume);
// Pass -gm argument if necessary
if(gm) sf_rip_args += " -gm";
+ if(force_output_unused) sf_rip_args += " -f";
// Make sound banks addresses list.
for(bank_t j=sound_bank_list.begin(); j != sound_bank_list.end(); ++j)
diff -rdu src/midi.cpp src_patched/midi.cpp
--- src/midi.cpp 2014-10-26 04:51:38.000000000 +0900
+++ src_patched/midi.cpp 2015-01-24 17:58:38.807114100 +0900
@@ -206,13 +206,11 @@
{
last_rpn_type[chn] = type;
last_type[chn] = 0;
- add_event(CONTROLLER, chn, 100, type&0x7f);
- add_event(CONTROLLER, chn, 101, type>>7);
}
+ add_event(CONTROLLER, chn, 101, type>>7);
+ add_event(CONTROLLER, chn, 100, type&0x7f);
add_event(CONTROLLER, chn, 6, value >> 7);
-
- if((value & 0x7f) != 0)
- add_event(CONTROLLER, chn, 38, value & 0x7f);
+ add_event(CONTROLLER, chn, 38, value & 0x7f);
}
//Add NRPN event
@@ -222,12 +220,11 @@
{
last_nrpn_type[chn] = type;
last_type[chn] = 1;
- add_event(CONTROLLER, chn, 98, type&0x7f);
- add_event(CONTROLLER, chn, 99, type>>7);
}
+ add_event(CONTROLLER, chn, 99, type>>7);
+ add_event(CONTROLLER, chn, 98, type&0x7f);
add_event(CONTROLLER, chn, 6, value >> 7);
- if((value & 0x7f) != 0)
- add_event(CONTROLLER, chn, 38, value & 0x7f);
+ add_event(CONTROLLER, chn, 38, value & 0x7f);
}
void MIDI::add_marker(const char *text)
diff -rdu src/sound_font_riper.cpp src_patched/sound_font_riper.cpp
--- src/sound_font_riper.cpp 2015-01-24 17:56:13.000000000 +0900
+++ src_patched/sound_font_riper.cpp 2015-01-24 17:57:02.448602700 +0900
@@ -28,6 +28,7 @@
static bool verbose_output_to_file = false;
static bool change_sample_rate = false;
static bool gm_preset_names = false;
+static bool force_output_unused = false;
static unsigned int sample_rate = 22050;
static std::set<uint32_t> addresses;
@@ -49,6 +50,7 @@
"-v : verbose : Display info about the sound font in text format. If -v is followed by a file name,\n"
" info is output to the specified file instead.\n"
"-s : Sampling rate for samples. Default : 22050 Hz\n"
+ "-f : Force exporting unused instruments.\n"
"-gm : Give General MIDI names to presets. Note that this will only change the names and will NOT\n"
" magically turn the soundfont into a General MIDI compliant soundfont.\n"
"-mv : Main volume for sample instruments. Range : 1-15. Game Boy channels are unnaffected.\n"
@@ -225,7 +227,7 @@
static void verbose_instrument(const inst_data inst, bool recursive)
{
// Do nothing with unused instruments
- if(inst.word0 == 0x3c01 && inst.word1 == 0x02 && inst.word2 == 0x0F0000) return;
+ if(!force_output_unused && inst.word0 == 0x3c01 && inst.word1 == 0x02 && inst.word2 == 0x0F0000) return;
uint8_t instr_type = inst.word0 & 0xff;
fprintf(out_txt, " Type : 0x%x ", instr_type);
@@ -483,7 +485,12 @@
}
}
}
-
+
+ else if(argv[i][1] == 'f')
+ {
+ force_output_unused = true;
+ }
+
// Change sampling rate if -s is encountered
else if(argv[i][1] == 's')
{
@@ -572,7 +579,8 @@
print("\nBank : " + std::to_string(current_bank) + ", Instrument : " + std::to_string(current_instrument) + " @0x" + hex(current_address));
// Ignore unused instruments
- if(instr_data[current_instrument].word0 == 0x3c01
+ if(!force_output_unused
+ && instr_data[current_instrument].word0 == 0x3c01
&& instr_data[current_instrument].word1 == 0x02
&& instr_data[current_instrument].word2 == 0x0F0000)
{
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment