From f0825e4e0d00e11ac6982da41b424f0865cd53b6 Mon Sep 17 00:00:00 2001
From: Wohlstand <[EMAIL REDACTED]>
Date: Wed, 4 Oct 2023 13:39:15 +0300
Subject: [PATCH 01/12] CMake: Disable ENABLE_UBSAN by default
It should not being always enabled. It should being enabled when it really needed for local debugging. Not all compilers actually support it.
Issue #52
---
CMakeLists.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 6e0e288..4607183 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -64,7 +64,7 @@ endif()
option(BUILD_SHARED_LIBS "Build shared library (set to OFF for static library)" ON)
-option(ENABLE_UBSAN "Enable Undefined Behavior Sanitizer error-checking" ON)
+option(ENABLE_UBSAN "Enable Undefined Behavior Sanitizer error-checking" OFF)
option(BUILD_FRAMEWORK "Build framework instead of dylib (on macOS)" OFF)
From d651a7d7ea6d0923fcd539a76a888ddb7c938669 Mon Sep 17 00:00:00 2001
From: Leandro Nini <drfiemost@users.noreply.github.com>
Date: Wed, 4 Oct 2023 12:39:41 +0200
Subject: [PATCH 02/12] Enable CI build
---
.github/workflows/CI-build.yml | 49 ++++++++++++++++++++++++++++++++++
1 file changed, 49 insertions(+)
create mode 100644 .github/workflows/CI-build.yml
diff --git a/.github/workflows/CI-build.yml b/.github/workflows/CI-build.yml
new file mode 100644
index 0000000..dbba77c
--- /dev/null
+++ b/.github/workflows/CI-build.yml
@@ -0,0 +1,49 @@
+name: C/C++ CI
+
+on:
+ push:
+ branches: [ "master" ]
+ pull_request:
+ branches: [ "master" ]
+
+jobs:
+ build:
+ name: ${{ matrix.platform }} (${{ matrix.configuration }})
+ runs-on: ${{ matrix.os }}
+ strategy:
+ matrix:
+ generator:
+ - Ninja
+ - Xcode
+ configuration: [Debug, Release]
+ include:
+ - generator: Ninja
+ platform: Linux
+ os: ubuntu-latest
+ - generator: Xcode
+ platform: macOS
+ os: macos-latest
+
+ steps:
+ - uses: actions/checkout@v3
+ - name: Install dependencies (Linux)
+ if: runner.os == 'Linux'
+ run: |
+ sudo apt-get update
+ sudo apt-get install build-essential g++ cmake ninja-build libsdl2-dev
+ - name: Install dependencies (macOS)
+ if: runner.os == 'macOS'
+ env:
+ HOMEBREW_NO_ANALYTICS: 1
+ HOMEBREW_NO_INSTALL_CLEANUP: 1
+ run: |
+ unset HOMEBREW_NO_INSTALL_FROM_API
+ brew update
+ brew upgrade || true
+ brew install sdl2
+ - name: Build
+ run: |
+ mkdir build
+ cd build
+ cmake -G ${{ matrix.generator }} -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} -DENABLE_UBSAN=OFF ..
+ cmake --build .
From 653fbf5cd8ef6228d2989d9932ad61fa3b6eb6e1 Mon Sep 17 00:00:00 2001
From: Wohlstand <admin@wohlnet.ru>
Date: Wed, 4 Oct 2023 15:24:14 +0300
Subject: [PATCH 03/12] blaarg_common.h: Fixed the MSVC 2015 condition
The 1910 is the olderst version for MSVC 2017, so, it should be >= rather than >.
https://github.com/libgme/game-music-emu/commit/8d5b61f3a5c9c50c3be9b1121d2d79502eee6b4e#commitcomment-129106531
---
gme/blargg_common.h | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/gme/blargg_common.h b/gme/blargg_common.h
index a67753f..d1877d7 100644
--- a/gme/blargg_common.h
+++ b/gme/blargg_common.h
@@ -27,7 +27,7 @@
#define STATIC_CAST(T,expr) ((T) (expr))
#endif
-#if !defined(_MSC_VER) || _MSC_VER > 1910
+#if !defined(_MSC_VER) || _MSC_VER >= 1910
#define blaarg_static_assert(cond, msg) static_assert(cond, msg)
#else
#define blaarg_static_assert(cond, msg) assert(cond)
From 64606e067a00692573db990bf7f8d2bc11162d2e Mon Sep 17 00:00:00 2001
From: Leandro Nini <drfiemost@users.noreply.github.com>
Date: Wed, 4 Oct 2023 15:37:09 +0200
Subject: [PATCH 04/12] Split workflow based on OS
---
.github/workflows/CI-Linux.yml | 31 +++++++++++++++++++
.../workflows/{CI-build.yml => CI-MacOS.yml} | 21 +++----------
2 files changed, 35 insertions(+), 17 deletions(-)
create mode 100755 .github/workflows/CI-Linux.yml
rename .github/workflows/{CI-build.yml => CI-MacOS.yml} (54%)
mode change 100644 => 100755
diff --git a/.github/workflows/CI-Linux.yml b/.github/workflows/CI-Linux.yml
new file mode 100755
index 0000000..187408b
--- /dev/null
+++ b/.github/workflows/CI-Linux.yml
@@ -0,0 +1,31 @@
+name: CI Linux
+
+on:
+ push:
+ branches: [ "master" ]
+ pull_request:
+ branches: [ "master" ]
+
+jobs:
+ build:
+ name: Linux (${{ matrix.configuration }})
+ runs-on: ${{ matrix.os }}
+ strategy:
+ matrix:
+ configuration: [Debug, Release]
+ include:
+ - generator: Ninja
+ os: ubuntu-latest
+
+ steps:
+ - uses: actions/checkout@v3
+ - name: Install dependencies
+ run: |
+ sudo apt-get update
+ sudo apt-get install build-essential g++ cmake ninja-build libsdl2-dev
+ - name: Build
+ run: |
+ mkdir build
+ cd build
+ cmake -G ${{ matrix.generator }} -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} ..
+ cmake --build .
diff --git a/.github/workflows/CI-build.yml b/.github/workflows/CI-MacOS.yml
old mode 100644
new mode 100755
similarity index 54%
rename from .github/workflows/CI-build.yml
rename to .github/workflows/CI-MacOS.yml
index dbba77c..00646cf
--- a/.github/workflows/CI-build.yml
+++ b/.github/workflows/CI-MacOS.yml
@@ -1,4 +1,4 @@
-name: C/C++ CI
+name: CI macOS
on:
push:
@@ -8,31 +8,18 @@ on:
jobs:
build:
- name: ${{ matrix.platform }} (${{ matrix.configuration }})
+ name: macOS (${{ matrix.configuration }})
runs-on: ${{ matrix.os }}
strategy:
matrix:
- generator:
- - Ninja
- - Xcode
configuration: [Debug, Release]
include:
- - generator: Ninja
- platform: Linux
- os: ubuntu-latest
- generator: Xcode
- platform: macOS
os: macos-latest
steps:
- uses: actions/checkout@v3
- - name: Install dependencies (Linux)
- if: runner.os == 'Linux'
- run: |
- sudo apt-get update
- sudo apt-get install build-essential g++ cmake ninja-build libsdl2-dev
- - name: Install dependencies (macOS)
- if: runner.os == 'macOS'
+ - name: Install dependencies
env:
HOMEBREW_NO_ANALYTICS: 1
HOMEBREW_NO_INSTALL_CLEANUP: 1
@@ -45,5 +32,5 @@ jobs:
run: |
mkdir build
cd build
- cmake -G ${{ matrix.generator }} -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} -DENABLE_UBSAN=OFF ..
+ cmake -G ${{ matrix.generator }} -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} ..
cmake --build .
From ee327d7807babd872e54c5f2a9f253b5be544f1c Mon Sep 17 00:00:00 2001
From: Leandro Nini <drfiemost@users.noreply.github.com>
Date: Wed, 4 Oct 2023 18:52:43 +0200
Subject: [PATCH 05/12] Added Windows CI build
---
.github/workflows/CI-Windows.yml | 40 ++++++++++++++++++++++++++++++++
1 file changed, 40 insertions(+)
create mode 100644 .github/workflows/CI-Windows.yml
diff --git a/.github/workflows/CI-Windows.yml b/.github/workflows/CI-Windows.yml
new file mode 100644
index 0000000..1922508
--- /dev/null
+++ b/.github/workflows/CI-Windows.yml
@@ -0,0 +1,40 @@
+name: CI Windows
+
+on:
+ push:
+ branches: [ "master" ]
+ pull_request:
+ branches: [ "master" ]
+
+jobs:
+ build:
+ name: Windows (${{ matrix.configuration }})
+ runs-on: ${{ matrix.os }}
+ strategy:
+ matrix:
+ configuration: [Debug, Release]
+ include:
+ - generator: Visual Studio 17 2022
+ os: windows-latest
+ env:
+ VS_PATH: C:\Program Files (x86)\Microsoft Visual Studio\2022\Community\
+ MSBUILD_PATH: C:\Program Files (x86)\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\
+
+ steps:
+ - uses: actions/checkout@v3
+ - name: Install dependencies
+ run: |
+ choco install -y --no-progress cmake --install-arguments="ADD_CMAKE_TO_PATH=System"
+ choco install -y --no-progress visualstudio2022community
+ - name: Install SDL2
+ shell: powershell
+ run: |
+ Invoke-WebRequest -Uri "https://www.libsdl.org/release/SDL2-devel-2.26.5-VC.zip" -OutFile "SDL2-devel-2.26.5-VC.zip"
+ Expand-Archive -Path SDL2-devel-2.26.5-VC.zip
+ echo "SDL2_DIR=$(pwd)\SDL2-devel-2.26.5-VC\SDL2-2.26.5\" >>${env:GITHUB_ENV}
+ - name: Build
+ run: |
+ mkdir build
+ cd build
+ cmake -G "${{ matrix.generator }}" -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} ..
+ cmake --build .
From a7336734065ed1cb10bde9a585c01c4741ea1eac Mon Sep 17 00:00:00 2001
From: Leandro Nini <drfiemost@users.noreply.github.com>
Date: Thu, 5 Oct 2023 12:39:16 +0200
Subject: [PATCH 06/12] Update CI-Windows.yml
Upgrade SDL2 version and fetch it from github
---
.github/workflows/CI-Windows.yml | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/.github/workflows/CI-Windows.yml b/.github/workflows/CI-Windows.yml
index 1922508..046f52b 100644
--- a/.github/workflows/CI-Windows.yml
+++ b/.github/workflows/CI-Windows.yml
@@ -29,9 +29,9 @@ jobs:
- name: Install SDL2
shell: powershell
run: |
- Invoke-WebRequest -Uri "https://www.libsdl.org/release/SDL2-devel-2.26.5-VC.zip" -OutFile "SDL2-devel-2.26.5-VC.zip"
- Expand-Archive -Path SDL2-devel-2.26.5-VC.zip
- echo "SDL2_DIR=$(pwd)\SDL2-devel-2.26.5-VC\SDL2-2.26.5\" >>${env:GITHUB_ENV}
+ Invoke-WebRequest -Uri "https://github.com/libsdl-org/SDL/releases/download/release-2.28.4/SDL2-devel-2.28.4-VC.zip" -OutFile "SDL2-devel-2.28.4-VC.zip"
+ Expand-Archive -Path SDL2-devel-2.28.4-VC.zip
+ echo "SDL2_DIR=$(pwd)\SDL2-devel-2.28.4-VC\SDL2-2.28.4\" >>${env:GITHUB_ENV}
- name: Build
run: |
mkdir build
From d398c501d490691df04bd0cc1ee6ea498855575b Mon Sep 17 00:00:00 2001
From: Leandro Nini <drfiemost@users.noreply.github.com>
Date: Thu, 5 Oct 2023 12:39:57 +0200
Subject: [PATCH 07/12] Add MinGW CI workflow
---
.github/workflows/CI-MinGW.yml | 39 ++++++++++++++++++++++++++++++++++
1 file changed, 39 insertions(+)
create mode 100644 .github/workflows/CI-MinGW.yml
diff --git a/.github/workflows/CI-MinGW.yml b/.github/workflows/CI-MinGW.yml
new file mode 100644
index 0000000..f350de5
--- /dev/null
+++ b/.github/workflows/CI-MinGW.yml
@@ -0,0 +1,39 @@
+name: CI MinGW
+
+on:
+ push:
+ branches: [ "master" ]
+ pull_request:
+ branches: [ "master" ]
+
+jobs:
+ build:
+ name: Linux (${{ matrix.configuration }})
+ runs-on: ${{ matrix.os }}
+ strategy:
+ matrix:
+ configuration: [Debug, Release]
+ include:
+ - generator: MSYS Makefiles
+ os: windows-latest
+ defaults:
+ run:
+ shell: msys2 {0}
+
+ steps:
+ - uses: msys2/setup-msys2@v2
+ with:
+ update: true
+ install: >-
+ git
+ base-devel
+ mingw-w64-x86_64-toolchain
+ mingw-w64-x86_64-cmake
+ mingw-w64-x86_64-SDL2
+ - uses: actions/checkout@v3
+ - name: Build
+ run: |
+ mkdir build
+ cd build
+ cmake -G "${{ matrix.generator }}" -DCMAKE_BUILD_TYPE=${{ matrix.configuration }} ..
+ cmake --build .
From 2cb59e4c888856d822a876bd953b3ed8db9c9ec4 Mon Sep 17 00:00:00 2001
From: Wohlstand <admin@wohlnet.ru>
Date: Thu, 5 Oct 2023 14:04:35 +0300
Subject: [PATCH 08/12] gme.h: Don't specify the BLARGG_EXPORT on types
Fixes the warning.
---
gme/gme.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/gme/gme.h b/gme/gme.h
index 9332f9c..efa3239 100644
--- a/gme/gme.h
+++ b/gme/gme.h
@@ -123,7 +123,7 @@ BLARGG_EXPORT gme_err_t gme_track_info( Music_Emu const*, gme_info_t** out, int
/* Frees track information */
BLARGG_EXPORT void gme_free_info( gme_info_t* );
-struct BLARGG_EXPORT gme_info_t
+struct gme_info_t
{
/* times in milliseconds; -1 if unknown */
int length; /* total length, if file specifies it */
@@ -185,7 +185,7 @@ BLARGG_EXPORT void gme_disable_echo( Music_Emu*, int disable );
/* Frequency equalizer parameters (see gme.txt) */
/* Implementers: If modified, also adjust Music_Emu::make_equalizer as needed */
-typedef struct BLARGG_EXPORT gme_equalizer_t
+typedef struct gme_equalizer_t
{
double treble; /* -50.0 = muffled, 0 = flat, +5.0 = extra-crisp */
double bass; /* 1 = full bass, 90 = average, 16000 = almost no bass */
From 770f46a8035523a490087d2bfa29502c1d21e593 Mon Sep 17 00:00:00 2001
From: Wohlstand <admin@wohlnet.ru>
Date: Fri, 6 Oct 2023 00:30:00 +0300
Subject: [PATCH 09/12] CMake: Fixed the wrong header search result
---
cmake/FindUNRAR.cmake | 12 +++++++-----
1 file changed, 7 insertions(+), 5 deletions(-)
diff --git a/cmake/FindUNRAR.cmake b/cmake/FindUNRAR.cmake
index 5eafdcc..462cd2b 100644
--- a/cmake/FindUNRAR.cmake
+++ b/cmake/FindUNRAR.cmake
@@ -21,16 +21,18 @@ set(UNRAR_NAMES_DEBUG unrar)
# Try each search configuration.
foreach(search ${_UNRAR_SEARCHES})
- find_path(UNRAR_INCLUDE_DIR NAMES unrar.h ${${search}} PATH_SUFFIXES include unrar)
+ find_path(UNRAR_INCLUDE_DIR_UNRAR_H NAMES unrar.h ${${search}} PATH_SUFFIXES include unrar)
endforeach()
-if(UNRAR_INCLUDE_DIR)
+if(UNRAR_INCLUDE_DIR_UNRAR_H)
set(RAR_HDR_UNRAR_H 1)
+ set(UNRAR_INCLUDE_DIR ${UNRAR_INCLUDE_DIR_UNRAR_H})
else()
foreach(search ${_UNRAR_SEARCHES})
- find_path(UNRAR_INCLUDE_DIR NAMES dll.hpp ${${search}} PATH_SUFFIXES include unrar)
+ find_path(UNRAR_INCLUDE_DIR_DLL_HPP NAMES dll.hpp ${${search}} PATH_SUFFIXES include unrar)
endforeach()
- if(UNRAR_INCLUDE_DIR)
+ if(UNRAR_INCLUDE_DIR_DLL_HPP)
set(RAR_HDR_DLL_HPP 1)
+ set(UNRAR_INCLUDE_DIR ${UNRAR_INCLUDE_DIR_DLL_HPP})
endif()
endif()
@@ -48,7 +50,7 @@ endif()
unset(UNRAR_NAMES)
unset(UNRAR_NAMES_DEBUG)
-mark_as_advanced(UNRAR_INCLUDE_DIR)
+mark_as_advanced(UNRAR_INCLUDE_DIR UNRAR_INCLUDE_DIR_UNRAR_H UNRAR_INCLUDE_DIR_DLL_HPP)
if(UNRAR_INCLUDE_DIR AND EXISTS "${UNRAR_INCLUDE_DIR}/version.hpp")
file(STRINGS "${UNRAR_INCLUDE_DIR}/version.hpp" UNRAR_H REGEX "^#define RARVER_.*$")
From c9545500f172d4f7c09d303974e54d5f15455b83 Mon Sep 17 00:00:00 2001
From: Wohlstand <admin@wohlnet.ru>
Date: Fri, 6 Oct 2023 00:30:43 +0300
Subject: [PATCH 10/12] Fixed the minimum version CMake warning And also, put
the mimimum version definition at the first line, otherwise, another warning
gets popped up
---
CMakeLists.txt | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/CMakeLists.txt b/CMakeLists.txt
index 7bb4b20..b924655 100644
--- a/CMakeLists.txt
+++ b/CMakeLists.txt
@@ -1,6 +1,6 @@
# CMake project definition file.
+cmake_minimum_required(VERSION 3.0...3.5 FATAL_ERROR)
project(libgme)
-cmake_minimum_required(VERSION 3.0 FATAL_ERROR)
include (TestBigEndian)
include (CheckCXXCompilerFlag)
From cae71005d53086d85c5458fa140013bea9886714 Mon Sep 17 00:00:00 2001
From: Mike Will <myQwil@gmail.com>
Date: Wed, 11 Oct 2023 00:42:19 -0400
Subject: [PATCH 11/12] Add a multi-channel example
Similar to `demo`, `demo_multi` writes 10 seconds of audio to
`out.wav`, but it sends all even-numbered voices to the left channel
and all odd-numbered voices to the right channel.
---
demo/CMakeLists.txt | 4 ++
demo/basics_multi.c | 89 +++++++++++++++++++++++++++++++++++++++++++++
2 files changed, 93 insertions(+)
create mode 100644 demo/basics_multi.c
diff --git a/demo/CMakeLists.txt b/demo/CMakeLists.txt
index 6e18f1e..b4453f7 100644
--- a/demo/CMakeLists.txt
+++ b/demo/CMakeLists.txt
@@ -28,6 +28,10 @@ add_custom_command(TARGET demo_mem
target_link_libraries(demo_mem gme)
+
+add_executable(demo_multi Wave_Writer.cpp basics_multi.c)
+target_link_libraries(demo_multi gme)
+
#
# Testing
#
diff --git a/demo/basics_multi.c b/demo/basics_multi.c
new file mode 100644
index 0000000..7205778
--- /dev/null
+++ b/demo/basics_multi.c
@@ -0,0 +1,89 @@
+/* C example that opens a game music file and records 10 seconds to "out.wav" */
+
+#include "gme/gme.h"
+
+#include "Wave_Writer.h" /* wave_ functions for writing sound file */
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+
+void handle_error( const char *str )
+{
+ if ( str )
+ {
+ printf( "Error: %s\n", str ); getchar();
+ exit( EXIT_FAILURE );
+ }
+}
+
+short avg( short *ptr, int n )
+{
+ int sum = 0, i = n;
+ while ( i-- )
+ sum += ptr[i];
+ return sum / n;
+}
+
+int main( int argc, char *argv[] )
+{
+ const char *filename = "test.nsf"; /* Default file to open */
+ if ( argc >= 2 )
+ filename = argv[1];
+
+ int sample_rate = 44100; /* number of samples per second */
+ /* index of track to play (0 = first) */
+ int track = argc >= 3 ? atoi(argv[2]) : 0;
+
+ /* Open music file in new multi-channel emulator */
+ gme_type_t file_type = gme_identify_extension( filename );
+ Music_Emu* emu = gme_new_emu_multi_channel( file_type, sample_rate );
+ handle_error( gme_load_file( emu, filename ) );
+
+ /* Start track */
+ handle_error( gme_start_track( emu, track ) );
+
+ /* Begin writing to wave file */
+ wave_open( sample_rate, "out.wav" );
+ wave_enable_stereo();
+
+ const int frames = 64;
+ const int voices = 8;
+ const int channels = 2;
+ const int buf_size = frames * voices * channels;
+
+ /* Record 10 seconds of track */
+ while ( gme_tell( emu ) < 10 * 1000L )
+ {
+ /* Sample buffer */
+ short buf [buf_size], *in = buf, *out = buf;
+
+ /* Fill sample buffer */
+ handle_error( gme_play( emu, buf_size, buf ) );
+
+ /* Render frames for stereo output by sending
+ even-numbered voices to the left channel, and
+ odd-numbered voices to the right channel */
+ for ( int f = frames; f--; out += channels )
+ {
+ int i = 0;
+ short ch [channels];
+ memset( ch, 0, channels * sizeof( short ) );
+ for ( int v = voices; v--; in += channels )
+ {
+ ch[i] += avg( in, channels );
+ i = ( ++i >= channels ) ? 0 : i;
+ }
+ for ( int c = channels; c--; )
+ out[c] = ch[c];
+ }
+
+ /* Write samples to wave file */
+ wave_write( buf, frames * channels );
+ }
+
+ /* Cleanup */
+ gme_delete( emu );
+ wave_close();
+
+ return 0;
+}
From 25d90251e945b582652ec67847839e96250b9371 Mon Sep 17 00:00:00 2001
From: Wohlstand <admin@wohlnet.ru>
Date: Mon, 23 Oct 2023 18:12:06 +0300
Subject: [PATCH 12/12] Added a notice of move to GitHub
---
README.md | 14 ++++++++++++++
1 file changed, 14 insertions(+)
create mode 100644 README.md
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..64054c7
--- /dev/null
+++ b/README.md
@@ -0,0 +1,14 @@
+------------
+⚠️**THIS REPOSITORY HAS BEEN MIGRATED TO GitHub!**⚠️
+
+This repository is **de-facto abandoned** and may contain outdated information.
+
+Repository has been moved to a new place here:
+
+* https://github.com/libgme/game-music-emu
+
+**See details:**
+
+* [Issue 45 (Chances of moving to Github)](https://bitbucket.org/mpyne/game-music-emu/issues/45)
+* [Pull-Request 40 (Preparation for moving to GitHub, updating info)](https://bitbucket.org/mpyne/game-music-emu/pull-requests/40)
+------------