Wohlstand / libADLMIDI

A Software MIDI Synthesizer library with OPL3 (YMF262) emulator
GNU Lesser General Public License v3.0
170 stars 17 forks source link

genadldata causes conversion warnings #247

Closed mmontag closed 7 months ago

mmontag commented 2 years ago

Hi, after changing the banks.ini and running cmake .. -DWITH_GENADLDATA, now I am seeing thousands of warnings like this:

/Users/montag/src/chip-player-js/libADLMIDI/src/adldata.cpp:1248:18: warning: implicit conversion from 'long' to 'uint16_t' (aka 'unsigned short') changes value from 8589938446 to 3854 [-Wconstant-conversion]
        {12,0,0,0,0x1,0,0x200000F0E,0x9C40,0xA85,{1799,1800,1801,1802} },
        ~               ^~~~~~~~~~~

here is a snippet of adldata.cpp before:

const BanksDump::InstrumentEntry g_embeddedBanksInstruments[] =
{
    {0,0,0,0,0,0,0x808,0x2314,0x189,{0,1}},
    {0,0,0,0,0,0,0x808,0x23E2,0x189,{2,3}},
    {0,0,0,0,0,0,0x808,0x23F0,0x2D0,{4,5}},
    {0,0,0,0,0,0,0x606,0x245A,0x190,{6,7}},

after:

const BanksDump::InstrumentEntry g_embeddedBanksInstruments[] =
{
    {0,0,0,0,0,0,0x200000808,0x2314,0x189,{0,1}},
    {0,0,0,0,0,0,0x200000808,0x23E2,0x189,{2,3}},
    {0,0,0,0,0,0,0x200000808,0x23F0,0x2D0,{4,5}},
    {0,0,0,0,0,0,0x200000606,0x245A,0x190,{6,7}},
Wohlstand commented 2 years ago

The old "adldata.cpp" is no longer relevant, you need to use "inst_db.cpp" instead, the adldata.cpp can be freely removed :wink:

Wohlstand commented 2 years ago

Since the moment, the whole database format has been changed, mainly to allow it to store multi banks (banks with instruments more than 128:128 GM), and make them more compact than before.

mmontag commented 2 years ago

ok, I haven't updated in a while, I will do that. Quick q. Does the bank IDs in the banks.ini need to be contiguous? (e.g., [bank-0], [bank-1], [bank-2], etc.)

Wohlstand commented 2 years ago

Quick q. Does the bank IDs in the banks.ini need to be contiguous? (e.g., [bank-0], [bank-1], [bank-2], etc.)

Yes, they should be continuous, it's array, not a hash table

Wohlstand commented 2 years ago

Also, in recent times I added some new nice banks you would take into your list (and yeah, drop any incomplete with missing instruments and any non-GM banks), for example, the MSAdLib bank that was used in the AdLib and SoundBlaster 1 and 1.2 drivers at Windows 3.1, now this bank at libADLMIDI in a form of WOPL file.

mmontag commented 2 years ago

Hi, I updated to latest from master and I am still getting hundreds of conversion warnings:

image

I am statically compiling libADLMIDI source as part of my emscripten build, so this would be an issue. Hmm...

mmontag commented 2 years ago

(I assume I will need to replace adldata.cpp with inst_db.cpp)

mmontag commented 2 years ago
/Users/montag/src/chip-player-js/libADLMIDI/utils/gen_adldata/progs_cache.cpp:171:36: warning: format specifies type 'unsigned long' but the argument has type 'uint_fast16_t' (aka 'unsigned short') [-Wformat]
                                   be.bankSetup,
                                   ^~~~~~~~~~~~
/Users/montag/src/chip-player-js/libADLMIDI/utils/gen_adldata/progs_cache.cpp:227:41: warning: format specifies type 'size_t' (aka 'unsigned long') but the argument has type 'uint_fast32_t' (aka 'unsigned int') [-Wformat]
            std::fprintf(out, "q(%zu)", be.bankId);
                                 ~~~    ^~~~~~~~~
                                 %u
/Users/montag/src/chip-player-js/libADLMIDI/utils/gen_adldata/progs_cache.cpp:295:55: warning: format specifies type 'unsigned long' but the argument has type 'uint_fast32_t' (aka 'unsigned int') [-Wformat]
                     (be.instFlags == 0 ? "" : "0x"), be.instFlags, // for compactness, don't print "0x" when is zero
                                                      ^~~~~~~~~~~~
/Users/montag/src/chip-player-js/libADLMIDI/utils/gen_adldata/progs_cache.cpp:297:52: warning: format specifies type 'unsigned long' but the argument has type 'uint_fast16_t' (aka 'unsigned short') [-Wformat]
                     (be.fbConn == 0 ? "" : "0x"), be.fbConn,
                                                   ^~~~~~~~~
/Users/montag/src/chip-player-js/libADLMIDI/utils/gen_adldata/progs_cache.cpp:298:57: warning: format specifies type 'unsigned long' but the argument has type 'int_fast64_t' (aka 'long long') [-Wformat]
                     (be.delay_on_ms == 0 ? "" : "0x"), be.delay_on_ms,
                                                        ^~~~~~~~~~~~~~
/Users/montag/src/chip-player-js/libADLMIDI/utils/gen_adldata/progs_cache.cpp:299:58: warning: format specifies type 'unsigned long' but the argument has type 'int_fast64_t' (aka 'long long') [-Wformat]
                     (be.delay_off_ms == 0 ? "" : "0x"), be.delay_off_ms);
                                                         ^~~~~~~~~~~~~~~
/Users/montag/src/chip-player-js/libADLMIDI/utils/gen_adldata/progs_cache.cpp:303:26: warning: format specifies type 'long' but the argument has type 'int_fast32_t' (aka 'int') [-Wformat]
                         be.ops[0], be.ops[1], be.ops[2], be.ops[3]);
                         ^~~~~~~~~
/Users/montag/src/chip-player-js/libADLMIDI/utils/gen_adldata/progs_cache.cpp:303:37: warning: format specifies type 'long' but the argument has type 'int_fast32_t' (aka 'int') [-Wformat]
                         be.ops[0], be.ops[1], be.ops[2], be.ops[3]);
                                    ^~~~~~~~~
/Users/montag/src/chip-player-js/libADLMIDI/utils/gen_adldata/progs_cache.cpp:303:48: warning: format specifies type 'long' but the argument has type 'int_fast32_t' (aka 'int') [-Wformat]
                         be.ops[0], be.ops[1], be.ops[2], be.ops[3]);
                                               ^~~~~~~~~
/Users/montag/src/chip-player-js/libADLMIDI/utils/gen_adldata/progs_cache.cpp:303:59: warning: format specifies type 'long' but the argument has type 'int_fast32_t' (aka 'int') [-Wformat]
                         be.ops[0], be.ops[1], be.ops[2], be.ops[3]);
                                                          ^~~~~~~~~
/Users/montag/src/chip-player-js/libADLMIDI/utils/gen_adldata/progs_cache.cpp:306:26: warning: format specifies type 'long' but the argument has type 'int_fast32_t' (aka 'int') [-Wformat]
                         be.ops[0], be.ops[1]);
                         ^~~~~~~~~
/Users/montag/src/chip-player-js/libADLMIDI/utils/gen_adldata/progs_cache.cpp:306:37: warning: format specifies type 'long' but the argument has type 'int_fast32_t' (aka 'int') [-Wformat]
                         be.ops[0], be.ops[1]);
                                    ^~~~~~~~~
/Users/montag/src/chip-player-js/libADLMIDI/utils/gen_adldata/progs_cache.cpp:327:22: warning: format specifies type 'unsigned long' but the argument has type 'uint_fast32_t' (aka 'unsigned int') [-Wformat]
                     be.d_E862,
                     ^~~~~~~~~
/Users/montag/src/chip-player-js/libADLMIDI/utils/gen_adldata/progs_cache.cpp:328:50: warning: format specifies type 'unsigned long' but the argument has type 'uint_fast32_t' (aka 'unsigned int') [-Wformat]
                     (be.d_40 == 0 ? "" : "0x"), be.d_40);
                                                 ^~~~~~~
14 warnings generated.
mmontag commented 2 years ago

I fixed with this:

diff --git a/libADLMIDI/utils/gen_adldata/progs_cache.cpp b/libADLMIDI/utils/gen_adldata/progs_cache.cpp
index 9e430dfa..5b553232 100644
--- a/libADLMIDI/utils/gen_adldata/progs_cache.cpp
+++ b/libADLMIDI/utils/gen_adldata/progs_cache.cpp
@@ -164,9 +164,9 @@ void BanksDump::exportBanks(const std::string &outPath, bool donntOverride, cons
     for(const BankEntry &be : banks)
     {
 #ifndef ADL_GENDATA_MINIFY
-        std::fprintf(out, "\t{0x%04lX, %zu, %zu, \"%s\", ",
+        std::fprintf(out, "\t{0x%04X, %zu, %zu, \"%s\", ",
 #else
-        std::fprintf(out, "{0x%04lX,%zu,%zu,\"%s\",",
+        std::fprintf(out, "{0x%04X,%zu,%zu,\"%s\",",
 #endif
                                    be.bankSetup,
                                    be.melodic.size(),
@@ -224,9 +224,9 @@ void BanksDump::exportBanks(const std::string &outPath, bool donntOverride, cons
 #endif

 #ifdef ADL_GENDATA_MINIFY
-            std::fprintf(out, "q(%zu)", be.bankId);
+            std::fprintf(out, "q(%du)", be.bankId);
 #else
-            std::fprintf(out, "g_embeddedBanks[%zu].title", be.bankId);
+            std::fprintf(out, "g_embeddedBanks[%du].title", be.bankId);
 #endif
         }
         std::fprintf(out, ",\n\tNULL"); // Make a null entry as finalizer
@@ -266,7 +266,7 @@ void BanksDump::exportBanks(const std::string &outPath, bool donntOverride, cons
                 std::fprintf(out, ",");
             else
                 commaNeeded = true;
-            std::fprintf(out, "%ld", be.instruments[i]);
+            std::fprintf(out, "%d", be.instruments[i]);
         }
         std::fprintf(out, "}");

@@ -287,7 +287,7 @@ void BanksDump::exportBanks(const std::string &outPath, bool donntOverride, cons
 #ifndef ADL_GENDATA_MINIFY
         std::fprintf(out, "\t");
 #endif
-        std::fprintf(out, "{%d,%d,%d,%u,%s%lX,%d,%s%lX,%s%lX,%s%lX,",
+        std::fprintf(out, "{%d,%d,%d,%u,%s%X,%d,%s%X,%s%llX,%s%llX,",
                      be.noteOffset1,
                      be.noteOffset2,
                      be.midiVelocityOffset,
@@ -299,10 +299,10 @@ void BanksDump::exportBanks(const std::string &outPath, bool donntOverride, cons
                      (be.delay_off_ms == 0 ? "" : "0x"), be.delay_off_ms);

         if(opsCount == 4)
-            std::fprintf(out, "{%ld,%ld,%ld,%ld} ",
+            std::fprintf(out, "{%d,%d,%d,%d} ",
                          be.ops[0], be.ops[1], be.ops[2], be.ops[3]);
         else
-            std::fprintf(out, "{%ld,%ld}",
+            std::fprintf(out, "{%d,%d}",
                          be.ops[0], be.ops[1]);

         std::fprintf(out, "},");
@@ -323,7 +323,7 @@ void BanksDump::exportBanks(const std::string &outPath, bool donntOverride, cons
         if(operatorEntryCounter == 0)
             std::fprintf(out, "\t");
 #endif
-        std::fprintf(out, "{0x%07lX,%s%02lX},",
+        std::fprintf(out, "{0x%07X,%s%02X},",
                      be.d_E862,
                      (be.d_40 == 0 ? "" : "0x"), be.d_40);
 #ifndef ADL_GENDATA_MINIFY
Wohlstand commented 7 months ago

I forgot to note: that the gen_adldata tool is intended to be a HOST tool, not intented to be used with cross-compilation toolchains. However, this needs a tweak at the CMake side, so, make the way to build gen_adldata as a host tool when cross-compliation is used, and then run the tool on the host, and then, build a library using a cross compiler.

Wohlstand commented 7 months ago

Closing as abandoned. If something needed, please re-open and give a note.