From 981b9521eadc49bf30b8f06a47335df3bea1d4f5 Mon Sep 17 00:00:00 2001 From: Vitaly Novichkov Date: Fri, 27 Apr 2018 02:41:58 +0300 Subject: Fixed MSVC build --- src/chips/opl_chip_base.h | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/chips/opl_chip_base.h b/src/chips/opl_chip_base.h index 75dd903..fb9b9e9 100644 --- a/src/chips/opl_chip_base.h +++ b/src/chips/opl_chip_base.h @@ -4,8 +4,7 @@ #include #include -/* TODO: MSVC: Use MSVC versioing instead of this to detect does it supports those C++11 keywords or not */ -#if __cplusplus <= 199711L +#if !defined(_MSC_VER) && (__cplusplus <= 199711L) #define final #define override #endif -- cgit v1.2.3 From 649c9dcc2ba53a0be994318999beb905c0c14528 Mon Sep 17 00:00:00 2001 From: Vitaly Novichkov Date: Fri, 27 Apr 2018 02:42:29 +0300 Subject: Fixed MinGW-w64 build of DosBox emulator --- src/chips/dosbox/dbopl.cpp | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/chips/dosbox/dbopl.cpp b/src/chips/dosbox/dbopl.cpp index 8834524..3e21772 100644 --- a/src/chips/dosbox/dbopl.cpp +++ b/src/chips/dosbox/dbopl.cpp @@ -1875,8 +1875,8 @@ namespace DBOPL if(i >= 16) index += 9; - Bitu blah = reinterpret_cast(&(chip->chan[ index ])); - ChanOffsetTable[i] = blah; + intptr_t blah = reinterpret_cast(&(chip->chan[ index ])); + ChanOffsetTable[i] = static_cast(blah); } //Same for operators @@ -1895,9 +1895,9 @@ namespace DBOPL chNum += 16 - 12; Bitu opNum = (i % 8) / 3; - DBOPL::Channel *chan = 0; - Bitu blah = reinterpret_cast(&(chan->op[opNum])); - OpOffsetTable[i] = ChanOffsetTable[ chNum ] + blah; + DBOPL::Channel *chan = NULL; + intptr_t blah = reinterpret_cast(&(chan->op[opNum])); + OpOffsetTable[i] = static_cast((intptr_t)ChanOffsetTable[ chNum ] + blah); } #if 0 -- cgit v1.2.3 From 8077db2dda93a18116ea48344b5480aef08f59fa Mon Sep 17 00:00:00 2001 From: Vitaly Novichkov Date: Sun, 29 Apr 2018 15:49:43 +0300 Subject: ADLMIDIPlay: Added ability to use different sample format --- utils/midiplay/adlmidiplay.cpp | 98 +++++++++++++++++++++++++++++++++++++----- 1 file changed, 87 insertions(+), 11 deletions(-) diff --git a/utils/midiplay/adlmidiplay.cpp b/utils/midiplay/adlmidiplay.cpp index 9489bfa..961df1e 100644 --- a/utils/midiplay/adlmidiplay.cpp +++ b/utils/midiplay/adlmidiplay.cpp @@ -102,24 +102,46 @@ public: } }; -typedef std::deque AudioBuff; +typedef std::deque AudioBuff; static AudioBuff g_audioBuffer; static MutexType g_audioBuffer_lock; +static ADLMIDI_AudioFormat g_audioFormat; static void SDL_AudioCallbackX(void *, Uint8 *stream, int len) { SDL_LockAudio(); - short *target = (short *) stream; + //short *target = (short *) stream; g_audioBuffer_lock.Lock(); - unsigned ate = (unsigned)len / 2; // number of shorts + unsigned ate = len; // number of bytes if(ate > g_audioBuffer.size()) ate = (unsigned)g_audioBuffer.size(); for(unsigned a = 0; a < ate; ++a) - target[a] = g_audioBuffer[a]; + stream[a] = g_audioBuffer[a]; g_audioBuffer.erase(g_audioBuffer.begin(), g_audioBuffer.begin() + ate); g_audioBuffer_lock.Unlock(); SDL_UnlockAudio(); } + +static const char *SDLAudioToStr(int format) +{ + switch(format) + { + case AUDIO_S8: + return "S8"; + case AUDIO_U8: + return "U8"; + case AUDIO_S16: + return "S16"; + case AUDIO_U16: + return "U16"; + case AUDIO_S32: + return "S32"; + case AUDIO_F32: + return "F32"; + default: + return "UNK"; + } +} #endif//OUTPUT_WAVE_ONLY #endif //HARDWARE_OPL3 @@ -290,6 +312,9 @@ int main(int argc, char **argv) #endif #ifndef HARDWARE_OPL3 int emulator = ADLMIDI_EMU_NUKED; + g_audioFormat.type = ADLMIDI_SampleType_S16; + g_audioFormat.containerSize = sizeof(Sint16); + g_audioFormat.sampleOffset = sizeof(Sint16) * 2; #endif while(argc > 2) @@ -303,7 +328,55 @@ int main(int argc, char **argv) #ifndef OUTPUT_WAVE_ONLY else if(!std::strcmp("-w", argv[2])) + { + //Current Wave output implementation allows only SINT16 output + g_audioFormat.type = ADLMIDI_SampleType_S16; + g_audioFormat.containerSize = sizeof(Sint16); + g_audioFormat.sampleOffset = sizeof(Sint16) * 2; recordWave = true;//Record library output into WAV file + } + else if(!std::strcmp("-s8", argv[2]) && !recordWave) + { + spec.format = AUDIO_S8; + g_audioFormat.type = ADLMIDI_SampleType_S8; + g_audioFormat.containerSize = sizeof(Sint8); + g_audioFormat.sampleOffset = sizeof(Sint8) * 2; + } + else if(!std::strcmp("-u8", argv[2]) && !recordWave) + { + spec.format = AUDIO_U8; + g_audioFormat.type = ADLMIDI_SampleType_U8; + g_audioFormat.containerSize = sizeof(Uint8); + g_audioFormat.sampleOffset = sizeof(Uint8) * 2; + } + else if(!std::strcmp("-s16", argv[2]) && !recordWave) + { + spec.format = AUDIO_S16; + g_audioFormat.type = ADLMIDI_SampleType_S16; + g_audioFormat.containerSize = sizeof(Sint16); + g_audioFormat.sampleOffset = sizeof(Sint16) * 2; + } + else if(!std::strcmp("-u16", argv[2]) && !recordWave) + { + spec.format = AUDIO_U16; + g_audioFormat.type = ADLMIDI_SampleType_U16; + g_audioFormat.containerSize = sizeof(Uint16); + g_audioFormat.sampleOffset = sizeof(Uint16) * 2; + } + else if(!std::strcmp("-s32", argv[2]) && !recordWave) + { + spec.format = AUDIO_S32; + g_audioFormat.type = ADLMIDI_SampleType_S32; + g_audioFormat.containerSize = sizeof(Sint32); + g_audioFormat.sampleOffset = sizeof(Sint32) * 2; + } + else if(!std::strcmp("-f32", argv[2]) && !recordWave) + { + spec.format = AUDIO_F32; + g_audioFormat.type = ADLMIDI_SampleType_F32; + g_audioFormat.containerSize = sizeof(float); + g_audioFormat.sampleOffset = sizeof(float) * 2; + } #endif else if(!std::strcmp("-t", argv[2])) @@ -368,10 +441,10 @@ int main(int argc, char **argv) } if(spec.samples != obtained.samples) { - std::fprintf(stderr, " - Audio wanted (samples=%u,rate=%u,channels=%u);\n" - " - Audio obtained (samples=%u,rate=%u,channels=%u)\n", - spec.samples, spec.freq, spec.channels, - obtained.samples, obtained.freq, obtained.channels); + std::fprintf(stderr, " - Audio wanted (format=%s,samples=%u,rate=%u,channels=%u);\n" + " - Audio obtained (format=%s,samples=%u,rate=%u,channels=%u)\n", + SDLAudioToStr(spec.format), spec.samples, spec.freq, spec.channels, + SDLAudioToStr(spec.format), obtained.samples, obtained.freq, obtained.channels); } } #endif @@ -509,8 +582,11 @@ int main(int argc, char **argv) while(!stop) { #ifndef HARDWARE_OPL3 - short buff[4096]; - size_t got = (size_t)adl_play(myDevice, 4096, buff); + Uint8 buff[16384]; + size_t got = (size_t)adl_playFormat(myDevice, 4096, + buff, + buff + g_audioFormat.containerSize, + &g_audioFormat) * g_audioFormat.containerSize; if(got <= 0) break; #endif @@ -530,7 +606,7 @@ int main(int argc, char **argv) g_audioBuffer_lock.Unlock(); const SDL_AudioSpec &spec = obtained; - while(g_audioBuffer.size() > spec.samples + (spec.freq * 2) * OurHeadRoomLength) + while(g_audioBuffer.size() > spec.samples + (spec.freq * g_audioFormat.sampleOffset) * OurHeadRoomLength) { SDL_Delay(1); } -- cgit v1.2.3 From 2f45b595400ca25f2ea79cfd518c33e964af9811 Mon Sep 17 00:00:00 2001 From: Vitaly Novichkov Date: Sun, 29 Apr 2018 16:33:22 +0300 Subject: ADLMIDIPlay: Small fix of obtained output information --- utils/midiplay/adlmidiplay.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/utils/midiplay/adlmidiplay.cpp b/utils/midiplay/adlmidiplay.cpp index 961df1e..d1e9895 100644 --- a/utils/midiplay/adlmidiplay.cpp +++ b/utils/midiplay/adlmidiplay.cpp @@ -444,7 +444,7 @@ int main(int argc, char **argv) std::fprintf(stderr, " - Audio wanted (format=%s,samples=%u,rate=%u,channels=%u);\n" " - Audio obtained (format=%s,samples=%u,rate=%u,channels=%u)\n", SDLAudioToStr(spec.format), spec.samples, spec.freq, spec.channels, - SDLAudioToStr(spec.format), obtained.samples, obtained.freq, obtained.channels); + SDLAudioToStr(obtained.format), obtained.samples, obtained.freq, obtained.channels); } } #endif -- cgit v1.2.3 From 2ea7a5f8f70ae255f0f1f05f788ffafaebf1b163 Mon Sep 17 00:00:00 2001 From: Vitaly Novichkov Date: Sun, 29 Apr 2018 16:36:19 +0300 Subject: Added type casting into CopySamplesTransformed --- src/adlmidi.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/adlmidi.cpp b/src/adlmidi.cpp index 5d7b13b..bf03285 100644 --- a/src/adlmidi.cpp +++ b/src/adlmidi.cpp @@ -631,8 +631,8 @@ static void CopySamplesTransformed(ADL_UInt8 *dstLeft, ADL_UInt8 *dstRight, cons Ret(&transform)(int32_t)) { for(size_t i = 0; i < frameCount; ++i) { - *(Dst *)(dstLeft + (i * sampleOffset)) = transform(src[2 * i]); - *(Dst *)(dstRight + (i * sampleOffset)) = transform(src[(2 * i) + 1]); + *(Dst *)(dstLeft + (i * sampleOffset)) = (Dst)transform(src[2 * i]); + *(Dst *)(dstRight + (i * sampleOffset)) = (Dst)transform(src[(2 * i) + 1]); } } -- cgit v1.2.3 From 7bfbd8525a0f52746b6b1e8b5aca7fdf5226b058 Mon Sep 17 00:00:00 2001 From: Vitaly Novichkov Date: Sun, 29 Apr 2018 16:36:41 +0300 Subject: Use code of adl_cvtS8 in adl_cvtU8 directly --- src/adlmidi_private.hpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/adlmidi_private.hpp b/src/adlmidi_private.hpp index fc54457..9fd6f97 100644 --- a/src/adlmidi_private.hpp +++ b/src/adlmidi_private.hpp @@ -168,7 +168,7 @@ inline int32_t adl_cvtU16(int32_t x) } inline int32_t adl_cvtU8(int32_t x) { - return adl_cvtS8(x) - INT8_MIN; + return (adl_cvtS16(x) / 256) - INT8_MIN; } inline int32_t adl_cvtU24(int32_t x) { -- cgit v1.2.3 From 2cd773bca61b913804734a884618f5bfbfc306ed Mon Sep 17 00:00:00 2001 From: Vitaly Novichkov Date: Sun, 29 Apr 2018 16:43:09 +0300 Subject: ADLMIDIPlay: Fill g_audioFormat from obtained sample format value To avoid distorted sound because wanted and obtained sample format is different. --- utils/midiplay/adlmidiplay.cpp | 71 ++++++++++++++++++++++++------------------ 1 file changed, 41 insertions(+), 30 deletions(-) diff --git a/utils/midiplay/adlmidiplay.cpp b/utils/midiplay/adlmidiplay.cpp index d1e9895..a591626 100644 --- a/utils/midiplay/adlmidiplay.cpp +++ b/utils/midiplay/adlmidiplay.cpp @@ -132,12 +132,20 @@ static const char *SDLAudioToStr(int format) return "U8"; case AUDIO_S16: return "S16"; + case AUDIO_S16MSB: + return "S16MSB"; case AUDIO_U16: return "U16"; + case AUDIO_U16MSB: + return "U16MSB"; case AUDIO_S32: return "S32"; + case AUDIO_S32MSB: + return "S32MSB"; case AUDIO_F32: return "F32"; + case AUDIO_F32MSB: + return "F32MSB"; default: return "UNK"; } @@ -336,47 +344,17 @@ int main(int argc, char **argv) recordWave = true;//Record library output into WAV file } else if(!std::strcmp("-s8", argv[2]) && !recordWave) - { spec.format = AUDIO_S8; - g_audioFormat.type = ADLMIDI_SampleType_S8; - g_audioFormat.containerSize = sizeof(Sint8); - g_audioFormat.sampleOffset = sizeof(Sint8) * 2; - } else if(!std::strcmp("-u8", argv[2]) && !recordWave) - { spec.format = AUDIO_U8; - g_audioFormat.type = ADLMIDI_SampleType_U8; - g_audioFormat.containerSize = sizeof(Uint8); - g_audioFormat.sampleOffset = sizeof(Uint8) * 2; - } else if(!std::strcmp("-s16", argv[2]) && !recordWave) - { spec.format = AUDIO_S16; - g_audioFormat.type = ADLMIDI_SampleType_S16; - g_audioFormat.containerSize = sizeof(Sint16); - g_audioFormat.sampleOffset = sizeof(Sint16) * 2; - } else if(!std::strcmp("-u16", argv[2]) && !recordWave) - { spec.format = AUDIO_U16; - g_audioFormat.type = ADLMIDI_SampleType_U16; - g_audioFormat.containerSize = sizeof(Uint16); - g_audioFormat.sampleOffset = sizeof(Uint16) * 2; - } else if(!std::strcmp("-s32", argv[2]) && !recordWave) - { spec.format = AUDIO_S32; - g_audioFormat.type = ADLMIDI_SampleType_S32; - g_audioFormat.containerSize = sizeof(Sint32); - g_audioFormat.sampleOffset = sizeof(Sint32) * 2; - } else if(!std::strcmp("-f32", argv[2]) && !recordWave) - { spec.format = AUDIO_F32; - g_audioFormat.type = ADLMIDI_SampleType_F32; - g_audioFormat.containerSize = sizeof(float); - g_audioFormat.sampleOffset = sizeof(float) * 2; - } #endif else if(!std::strcmp("-t", argv[2])) @@ -446,6 +424,39 @@ int main(int argc, char **argv) SDLAudioToStr(spec.format), spec.samples, spec.freq, spec.channels, SDLAudioToStr(obtained.format), obtained.samples, obtained.freq, obtained.channels); } + switch(obtained.format) + { + case AUDIO_S8: + g_audioFormat.type = ADLMIDI_SampleType_S8; + g_audioFormat.containerSize = sizeof(Sint8); + g_audioFormat.sampleOffset = sizeof(Sint8) * 2; + break; + case AUDIO_U8: + g_audioFormat.type = ADLMIDI_SampleType_U8; + g_audioFormat.containerSize = sizeof(Uint8); + g_audioFormat.sampleOffset = sizeof(Uint8) * 2; + break; + case AUDIO_S16: + g_audioFormat.type = ADLMIDI_SampleType_S16; + g_audioFormat.containerSize = sizeof(Sint16); + g_audioFormat.sampleOffset = sizeof(Sint16) * 2; + break; + case AUDIO_U16: + g_audioFormat.type = ADLMIDI_SampleType_U16; + g_audioFormat.containerSize = sizeof(Uint16); + g_audioFormat.sampleOffset = sizeof(Uint16) * 2; + break; + case AUDIO_S32: + g_audioFormat.type = ADLMIDI_SampleType_S32; + g_audioFormat.containerSize = sizeof(Sint32); + g_audioFormat.sampleOffset = sizeof(Sint32) * 2; + break; + case AUDIO_F32: + g_audioFormat.type = ADLMIDI_SampleType_F32; + g_audioFormat.containerSize = sizeof(float); + g_audioFormat.sampleOffset = sizeof(float) * 2; + break; + } } #endif -- cgit v1.2.3 From 49ab43701d5c5800fda3543a9697e5aab2da2638 Mon Sep 17 00:00:00 2001 From: Vitaly Novichkov Date: Tue, 1 May 2018 20:01:56 +0300 Subject: Re-calculate measure delays in my 4-op bank --- .../wopl_files/GM-By-J.A.Nguyen-and-Wohlstand.wopl | Bin 16983 -> 16983 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/fm_banks/wopl_files/GM-By-J.A.Nguyen-and-Wohlstand.wopl b/fm_banks/wopl_files/GM-By-J.A.Nguyen-and-Wohlstand.wopl index b0ebd97..6ec13ea 100644 Binary files a/fm_banks/wopl_files/GM-By-J.A.Nguyen-and-Wohlstand.wopl and b/fm_banks/wopl_files/GM-By-J.A.Nguyen-and-Wohlstand.wopl differ -- cgit v1.2.3