diff options
author | Vitaly Novichkov <admin@wohlnet.ru> | 2018-05-01 20:02:09 +0300 |
---|---|---|
committer | Vitaly Novichkov <admin@wohlnet.ru> | 2018-05-01 20:02:09 +0300 |
commit | 5a194eb263125e5505cca3ec0256c7efa348eaa4 (patch) | |
tree | f655dd29013d0cf41d04ba5bb81e8750c9a4fcc1 | |
parent | 7fd5752dd5f22bdbe175744f33ad998e43f755cf (diff) | |
parent | 49ab43701d5c5800fda3543a9697e5aab2da2638 (diff) | |
download | libADLMIDI-5a194eb263125e5505cca3ec0256c7efa348eaa4.tar.gz libADLMIDI-5a194eb263125e5505cca3ec0256c7efa348eaa4.tar.bz2 libADLMIDI-5a194eb263125e5505cca3ec0256c7efa348eaa4.zip |
Merge branch 'master' into stable
-rw-r--r-- | fm_banks/wopl_files/GM-By-J.A.Nguyen-and-Wohlstand.wopl | bin | 16983 -> 16983 bytes | |||
-rw-r--r-- | src/adlmidi.cpp | 4 | ||||
-rw-r--r-- | src/adlmidi_private.hpp | 2 | ||||
-rw-r--r-- | src/chips/dosbox/dbopl.cpp | 10 | ||||
-rw-r--r-- | src/chips/opl_chip_base.h | 3 | ||||
-rw-r--r-- | utils/midiplay/adlmidiplay.cpp | 109 |
6 files changed, 107 insertions, 21 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 Binary files differindex b0ebd97..6ec13ea 100644 --- 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 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]); } } 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) { 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<Bitu>(&(chip->chan[ index ])); - ChanOffsetTable[i] = blah; + intptr_t blah = reinterpret_cast<intptr_t>(&(chip->chan[ index ])); + ChanOffsetTable[i] = static_cast<Bit16u>(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<Bitu>(&(chan->op[opNum])); - OpOffsetTable[i] = ChanOffsetTable[ chNum ] + blah; + DBOPL::Channel *chan = NULL; + intptr_t blah = reinterpret_cast<intptr_t>(&(chan->op[opNum])); + OpOffsetTable[i] = static_cast<Bit16u>((intptr_t)ChanOffsetTable[ chNum ] + blah); } #if 0 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 <stdint.h> #include <stddef.h> -/* 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 diff --git a/utils/midiplay/adlmidiplay.cpp b/utils/midiplay/adlmidiplay.cpp index 9489bfa..a591626 100644 --- a/utils/midiplay/adlmidiplay.cpp +++ b/utils/midiplay/adlmidiplay.cpp @@ -102,24 +102,54 @@ public: } }; -typedef std::deque<int16_t> AudioBuff; +typedef std::deque<uint8_t> 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_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"; + } +} #endif//OUTPUT_WAVE_ONLY #endif //HARDWARE_OPL3 @@ -290,6 +320,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 +336,25 @@ 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; + else if(!std::strcmp("-u8", argv[2]) && !recordWave) + spec.format = AUDIO_U8; + else if(!std::strcmp("-s16", argv[2]) && !recordWave) + spec.format = AUDIO_S16; + else if(!std::strcmp("-u16", argv[2]) && !recordWave) + spec.format = AUDIO_U16; + else if(!std::strcmp("-s32", argv[2]) && !recordWave) + spec.format = AUDIO_S32; + else if(!std::strcmp("-f32", argv[2]) && !recordWave) + spec.format = AUDIO_F32; #endif else if(!std::strcmp("-t", argv[2])) @@ -368,10 +419,43 @@ 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(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 @@ -509,8 +593,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 +617,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); } |