Skip to content

Commit

Permalink
make the default note field informative
Browse files Browse the repository at this point in the history
  • Loading branch information
ReimuNotMoe committed Nov 24, 2022
1 parent c5e1f26 commit d1403c8
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/midi2vgm_opl3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@

#include <cinttypes>

#include <libgen.h> // la flemme

#include <cxxopts.hpp>

#include <adlmidi.h>
Expand All @@ -49,6 +51,9 @@
#error Big endian arch is unsupported for now
#endif

static std::string opt_input, opt_output;
static int opt_bank = -1, opt_vol_model = -1;

std::u16string utf8_to_utf16(std::string const& utf8) {
std::wstring_convert<std::codecvt_utf8_utf16<char16_t>, char16_t> cnv;
std::u16string s = cnv.from_bytes(utf8);
Expand Down Expand Up @@ -119,10 +124,15 @@ class VGMOPL3 final : public OPLChipBaseT<VGMOPL3> {
}

void write_gd3() {
const char note[] = "Created with midi2vgm_opl3 - github.com/SudoMaker/midi2vgm";

if (gd3_info_.notes.empty())
if (gd3_info_.notes.empty()) {
assert(!opt_input.empty());
char note[256];
char *path = strdup(opt_input.c_str());
sprintf(note, "Created with midi2vgm_opl3 - github.com/SudoMaker/midi2vgm\n"
"Filename: %s, Bank: %d, VolModel: %d\n", basename(path), opt_bank, opt_vol_model);
gd3_info_.notes = note;
free(path);
}

auto buf = gd3_info_.serialize();
dbuf_.insert(dbuf_.end(), buf.begin(), buf.end());
Expand Down Expand Up @@ -238,9 +248,7 @@ int main(int argc, char **argv) {

cxxopts::Options options("midi2vgm_opl3", "midi2vgm_opl3 - Convert MIDI files to OPL3 VGM files");

std::string opt_input, opt_output;
GD3Info gd3_info;
int opt_bank, opt_vol_model;

options.add_options("Main")
("h,help", "Show this help")
Expand Down

0 comments on commit d1403c8

Please sign in to comment.