Skip to content

Commit

Permalink
Software Quality of Implementation
Browse files Browse the repository at this point in the history
  • Loading branch information
gzaffin committed Oct 6, 2024
1 parent ce55834 commit 686d00f
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 40 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ccpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down Expand Up @@ -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'
Expand Down
6 changes: 3 additions & 3 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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})
Expand Down
4 changes: 2 additions & 2 deletions sdlplay.c
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
9 changes: 5 additions & 4 deletions src/mdxmml_ym2151.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -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;
}
Expand All @@ -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);
Expand Down
9 changes: 5 additions & 4 deletions src/pcm8.c
Original file line number Diff line number Diff line change
Expand Up @@ -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[]={
Expand Down Expand Up @@ -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;
}
}

Expand Down Expand Up @@ -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;
Expand Down
46 changes: 22 additions & 24 deletions wavwrite.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

0 comments on commit 686d00f

Please sign in to comment.