diff --git a/.github/workflows/ccpp.yml b/.github/workflows/ccpp.yml index d3696a2..4425fb1 100644 --- a/.github/workflows/ccpp.yml +++ b/.github/workflows/ccpp.yml @@ -11,13 +11,13 @@ jobs: steps: - name: CheckOut - uses: actions/checkout@v1 + uses: actions/checkout@v4.1.1 - name: Install Dependencies [Linux] if: matrix.os == 'ubuntu-latest' run: | sudo apt-get update - sudo apt-get install cmake libsdl2-dev + sudo apt-get install cmake libasound2-dev alsa-base alsa-utils libsdl2-dev - name: Install Dependencies [Darwin] if: matrix.os == 'macos-latest' run: | @@ -49,7 +49,7 @@ jobs: if: matrix.os == 'windows-latest' run: | mkdir build && cd build - cmake -D CMAKE_TOOLCHAIN_FILE=../vcpkg/scripts/buildsystems/vcpkg.cmake .. + cmake -A x64 -T host=x64 -D CMAKE_TOOLCHAIN_FILE=../vcpkg/scripts/buildsystems/vcpkg.cmake .. - name: Build [Linux] if: matrix.os == 'ubuntu-latest' diff --git a/CMakeLists.txt b/CMakeLists.txt index ae3cb85..d26999c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -8,14 +8,14 @@ if(MSVC OR MINGW) cmake_minimum_required(VERSION 3.10) endif() -if(UNIX OR APPLE) +if(LINUX OR APPLE) cmake_minimum_required(VERSION 3.0.2) endif() if(MSVC) find_package(SDL2 CONFIG REQUIRED) endif() -if(UNIX OR MINGW) +if(LINUX OR MINGW) find_package(PkgConfig REQUIRED) pkg_check_modules(SDL2 REQUIRED sdl2) endif() @@ -38,7 +38,7 @@ if(MSVC) target_link_libraries(mdxplay PRIVATE mdxmini SDL2::SDL2 SDL2::SDL2main) endif() -if(UNIX OR MINGW OR APPLE) +if(LINUX OR MINGW OR APPLE) target_link_libraries(mdxplay PRIVATE mdxmini m ${SDL2_LIBRARIES}) target_include_directories(mdxplay PUBLIC ${SDL2_INCLUDE_DIRS} ${CMAKE_CURRENT_SOURCE_DIR}/src) target_compile_options(mdxplay PUBLIC ${SDL2_FLAGS} ${SDL2_FLAGS_OTHERS}) diff --git a/sdlplay.c b/sdlplay.c index 275fbd4..dbd3b22 100644 --- a/sdlplay.c +++ b/sdlplay.c @@ -619,8 +619,8 @@ int audio_main(int argc, char *argv[]) #ifdef _WIN32 #if !defined (__MINGW32__) - freopen("CON", "wt", stdout); - freopen("CON", "wt", stderr); + (void)freopen("CON", "wt", stdout); + (void)freopen("CON", "wt", stderr); #endif #endif diff --git a/src/mdxmml_ym2151.c b/src/mdxmml_ym2151.c index 0525b44..061f0ff 100755 --- a/src/mdxmml_ym2151.c +++ b/src/mdxmml_ym2151.c @@ -219,7 +219,7 @@ mdx_parse_mml_ym2151( MDX_DATA *orig_mdx, PDX_DATA *orig_pdx, songdata *data ) /* timer count */ self->mdx->total_count++; - self->mdx->elapsed_time += 1000*1024*(256 - self->mdx->tempo)/4000; + self->mdx->elapsed_time += (1000.0 * 1024 * (256 - self->mdx->tempo)) / (4000.0); do_pcm8(NULL,-1, data); @@ -334,7 +334,7 @@ mdx_parse_mml_ym2151_async(songdata *data) /* timer count */ self->mdx->total_count++; - self->mdx->elapsed_time += 1000*1024*(256 - self->mdx->tempo)/4000; + self->mdx->elapsed_time += (1000.0 * 1024 * (256 - self->mdx->tempo)) / (4000.0); return FLAG_TRUE; } @@ -346,12 +346,13 @@ int mdx_parse_mml_ym2151_async_get_length(songdata *data) __GETSELF(data) next = 1; + self->mdx->elapsed_time = 0; while(next && self->mdx->elapsed_time < (1200 * 1000000)) { - next = mdx_parse_mml_ym2151_async(data); + next = mdx_parse_mml_ym2151_async(data); } - sec = (int)self->mdx->elapsed_time / 1000000; + sec = (((double)self->mdx->elapsed_time + 500000.0)/ 1000000.0); /* stop */ ym2151_all_note_off(data); diff --git a/src/pcm8.c b/src/pcm8.c index 9263491..cc4723b 100755 --- a/src/pcm8.c +++ b/src/pcm8.c @@ -65,7 +65,8 @@ struct _pcm8_instances { #define PCM8_MAX_FREQ 5 static const int adpcm_freq_list[] = { - 3900, 5200, 7800, 10400, 15600 +/* 3900, 5200, 7800, 10400, 15600 */ + 3906, 5208, 7812, 10416, /*16000*/ 15625 /* from portable_mdx x68sound_adpcm.h */ }; static const unsigned char riff[]={ @@ -253,8 +254,8 @@ int pcm8_close( songdata *data ) if ( free_all == FLAG_TRUE ) { for ( i=1 ; i<=0 ; i-- ) { if ( self->ym2151_voice[i]!=NULL ) { - free( self->ym2151_voice[i] ); - self->ym2151_voice[i]=NULL; + free( self->ym2151_voice[i] ); + self->ym2151_voice[i]=NULL; } } @@ -307,7 +308,7 @@ int pcm8_set_pcm_freq( int ch, int hz, songdata *data ) { if ( hz < 0 ) return 1; if ( hz >= PCM8_MAX_FREQ ) { self->work[ch].adpcm = FLAG_FALSE; - self->work[ch].freq = 15600; + self->work[ch].freq = /*15600*/ 15625; /* from portable_mdx x68sound_adpcm.h */ } else { self->work[ch].freq = adpcm_freq_list[hz]; self->work[ch].adpcm = FLAG_TRUE; diff --git a/wavwrite.h b/wavwrite.h index b55b623..3b64f8e 100644 --- a/wavwrite.h +++ b/wavwrite.h @@ -30,28 +30,26 @@ void write_word(BYTE *p,WORD v) // pcm_bytesize : データの長さ static void audio_write_wav_header(FILE *fp, long freq, long pcm_bytesize) { - BYTE hdr[0x80]; - - if (!fp) - return; - - memcpy(hdr,"RIFF", 4); - write_dword(hdr + 4, pcm_bytesize + 44); - memcpy(hdr + 8,"WAVEfmt ", 8); - write_dword(hdr + 16, 16); // chunk length - write_word(hdr + 20, 01); // pcm id - write_word(hdr + 22, WAV_CH); // ch - write_dword(hdr + 24, freq); // freq - write_dword(hdr + 28, freq * WAV_CH * WAV_BPS); // bytes per sec - write_word(hdr + 32, WAV_CH * WAV_BPS); // bytes per frame - write_word(hdr + 34, WAV_BPS * 8); // bits - - memcpy(hdr + 36, "data",4); - write_dword(hdr + 40, pcm_bytesize); // pcm size - - fseek(fp, 0, SEEK_SET); - fwrite(hdr, 44, 1, fp); - - fseek(fp, 0, SEEK_END); - + if (fp) { + BYTE hdr[0x80]; + + memcpy(hdr, "RIFF", 4); + write_dword(hdr + 4, pcm_bytesize + 44); + memcpy(hdr + 8, "WAVEfmt ", 8); + write_dword(hdr + 16, 16); // chunk length + write_word(hdr + 20, 01); // pcm id + write_word(hdr + 22, WAV_CH); // ch + write_dword(hdr + 24, freq); // freq + write_dword(hdr + 28, freq * WAV_CH * WAV_BPS); // bytes per sec + write_word(hdr + 32, WAV_CH * WAV_BPS); // bytes per frame + write_word(hdr + 34, WAV_BPS * 8); // bits + + memcpy(hdr + 36, "data", 4); + write_dword(hdr + 40, pcm_bytesize); // pcm size + + fseek(fp, 0, SEEK_SET); + fwrite(hdr, 44, 1, fp); + + fseek(fp, 0, SEEK_END); + } }