Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
Libretro
libretro-gme
Commits
f594700b
Commit
f594700b
authored
Mar 20, 2022
by
Larry Koubiak
Browse files
Merge branch 'master' into dev
parents
6b0d103b
f3a74b62
Pipeline
#95269
failed with stages
in 1 minute and 9 seconds
Changes
271
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
.gitlab-ci.yml
View file @
f594700b
...
...
@@ -21,6 +21,18 @@ include:
-
project
:
'
libretro-infrastructure/ci-templates'
file
:
'
/windows-i686-mingw.yml'
# Windows msvc10 64-bit
-
project
:
'
libretro-infrastructure/ci-templates'
file
:
'
/windows-x64-msvc10-msys2.yml'
# Windows msvc10 32-bit
-
project
:
'
libretro-infrastructure/ci-templates'
file
:
'
/windows-i686-msvc10-msys2.yml'
# Windows msvc05 32-bit
-
project
:
'
libretro-infrastructure/ci-templates'
file
:
'
/windows-i686-msvc05-msys2.yml'
# Linux 64-bit
-
project
:
'
libretro-infrastructure/ci-templates'
file
:
'
/linux-x64.yml'
...
...
@@ -42,7 +54,11 @@ include:
-
project
:
'
libretro-infrastructure/ci-templates'
file
:
'
/android-jni.yml'
# iOS 9
# iOS
-
project
:
'
libretro-infrastructure/ci-templates'
file
:
'
/ios-arm64.yml'
# iOS (armv7)
-
project
:
'
libretro-infrastructure/ci-templates'
file
:
'
/ios9.yml'
...
...
@@ -76,6 +92,10 @@ include:
-
project
:
'
libretro-infrastructure/ci-templates'
file
:
'
/libnx-static.yml'
# tvOS (AppleTV)
-
project
:
'
libretro-infrastructure/ci-templates'
file
:
'
/tvos-arm64.yml'
#################################### MISC ##################################
# Emscripten
-
project
:
'
libretro-infrastructure/ci-templates'
...
...
@@ -104,6 +124,24 @@ libretro-build-windows-i686:
-
.libretro-windows-i686-mingw-make-default
-
.core-defs
# Windows msvc10 64-bit
libretro-build-windows-msvc10-x64
:
extends
:
-
.libretro-windows-x64-msvc10-msys2-make-default
-
.core-defs
# Windows msvc10 32-bit
libretro-build-windows-msvc10-i686
:
extends
:
-
.libretro-windows-i686-msvc10-msys2-make-default
-
.core-defs
# Windows msvc05 32-bit
libretro-build-windows-msvc05-i686
:
extends
:
-
.libretro-windows-i686-msvc05-msys2-make-default
-
.core-defs
# Linux 64-bit
libretro-build-linux-x64
:
extends
:
...
...
@@ -153,11 +191,23 @@ android-x86:
-
.libretro-android-jni-x86
-
.core-defs
# iOS 9
libretro-build-ios-9
:
# iOS
libretro-build-ios-arm64
:
extends
:
-
.libretro-ios-arm64-make-default
-
.core-defs
# iOS (armv7) [iOS 9 and up]
libretro-build-ios9
:
extends
:
-
.libretro-ios9-make-default
-
.core-defs
# tvOS
libretro-build-tvos-arm64
:
extends
:
-
.libretro-tvos-arm64-make-default
-
.core-defs
################################### CONSOLES #################################
# PlayStation Portable
...
...
Makefile
View file @
f594700b
...
...
@@ -145,14 +145,18 @@ else ifeq ($(platform), vita)
STATIC_LINKING
=
1
# Lightweight PS3 Homebrew SDK
else
ifeq
($(platform), psl1ght)
else
if
n
eq
(
,$(filter
$(platform),
ps3
psl1ght)
)
TARGET
:=
$(TARGET_NAME)
_libretro_
$(platform)
.a
CC
=
$(PS3DEV)
/ppu/bin/ppu-gcc
$(EXE_EXT)
CXX
=
$(PS3DEV)
/ppu/bin/ppu-g++
$(EXE_EXT)
AR
=
$(PS3DEV)
/ppu/bin/ppu-ar
$(EXE_EXT)
CFLAGS
+=
-DIOAPI_NO_64
CXXFLAGS
+=
-DIOAPI_NO_64
CC
=
$(PS3DEV)
/ppu/bin/ppu-
$(COMMONLV)
gcc
$(EXE_EXT)
CXX
=
$(PS3DEV)
/ppu/bin/ppu-
$(COMMONLV)
g++
$(EXE_EXT)
AR
=
$(PS3DEV)
/ppu/bin/ppu-
$(COMMONLV)
ar
$(EXE_EXT)
CFLAGS
+=
-DIOAPI_NO_64
-D__PS3__
CXXFLAGS
+=
-DIOAPI_NO_64
-D__PS3__
STATIC_LINKING
=
1
ifeq
($(platform), psl1ght)
CFLAGS
+=
-D__PSL1GHT__
CXXFLAGS
+=
-D__PSL1GHT__
endif
# Xbox 360
else
ifeq
($(platform), xenon)
...
...
@@ -245,6 +249,7 @@ else ifeq ($(platform), emscripten)
CXX
=
em++
AR
=
emar
INCFLAGS_PLATFORM
+=
-D_XOPEN_SOURCE
# Windows MSVC 2010 x64
else
ifeq
($(platform), windows_msvc2010_x64)
CC
=
cl.exe
...
...
@@ -255,20 +260,21 @@ PATH := $(PATH):$(shell IFS=$$'\n'; cygpath "$(VS100COMNTOOLS)../IDE")
LIB
:=
$(
shell
IFS
=
$$
'\n'
;
cygpath
"
$(VS100COMNTOOLS)
../../VC/lib/amd64"
)
INCLUDE
:=
$(
shell
IFS
=
$$
'\n'
;
cygpath
"
$(VS100COMNTOOLS)
../../VC/include"
)
WindowsSdkDir
:=
$(
shell
reg query
"HKLM
\S
OFTWARE
\M
icrosoft
\M
icrosoft SDKs
\W
indows
\v
7.0A"
-v
"InstallationFolder"
|
grep
-o
'[A-Z]:\\.*'
)
lib/x64
WindowsSdkDir
?=
$(
shell
reg query
"HKLM
\S
OFTWARE
\M
icrosoft
\M
icrosoft SDKs
\W
indows
\v
7.1A"
-v
"InstallationFolder"
|
grep
-o
'[A-Z]:\\.*'
)
lib/x64
WindowsSdkDirInc
:=
$(
shell
reg query
"HKLM
\S
OFTWARE
\M
icrosoft
\M
icrosoft SDKs
\W
indows
\v
7.0A"
-v
"InstallationFolder"
|
grep
-o
'[A-Z]:\\.*'
)
Include
WindowsSdkDirInc
?=
$(
shell
reg query
"HKLM
\S
OFTWARE
\M
icrosoft
\M
icrosoft SDKs
\W
indows
\v
7.1A"
-v
"InstallationFolder"
|
grep
-o
'[A-Z]:\\.*'
)
Include
WindowsSdkDir
:=
$(
shell
reg query
"HKLM
\S
OFTWARE
\M
icrosoft
\M
icrosoft SDKs
\W
indows
\v
7.1A"
-v
"InstallationFolder"
|
grep
-o
'[A-Z]:\\.*'
)
WindowsSdkDir
?=
$(
shell
reg query
"HKLM
\S
OFTWARE
\M
icrosoft
\M
icrosoft SDKs
\W
indows
\v
7.0A"
-v
"InstallationFolder"
|
grep
-o
'[A-Z]:\\.*'
)
WindowsSDKIncludeDir
:=
$(
shell
cygpath
-w
"
$(WindowsSdkDir)
\I
nclude"
)
WindowsSDKGlIncludeDir
:=
$(
shell
cygpath
-w
"
$(WindowsSdkDir)
\I
nclude
\g
l"
)
WindowsSDKLibDir
:=
$(
shell
cygpath
-w
"
$(WindowsSdkDir)
\L
ib
\x
64"
)
INCFLAGS_PLATFORM
=
-I
"
$(WindowsS
dkDirInc
)
"
export
INCLUDE
:=
$(INCLUDE)
export
LIB
:=
$(LIB)
;
$(WindowsS
dk
Dir)
INCFLAGS_PLATFORM
=
-I
"
$(WindowsS
DKIncludeDir
)
"
export
INCLUDE
:=
$(INCLUDE)
;
$(WindowsSDKIncludeDir)
;
$(WindowsSDKGlIncludeDir)
export
LIB
:=
$(LIB)
;
$(WindowsS
DKLib
Dir)
TARGET
:=
$(TARGET_NAME)
_libretro.dll
PSS_STYLE
:=
2
LDFLAGS
+=
-DLL
LIBS
=
# Windows MSVC 2010 x86
else
ifeq
($(platform), windows_msvc2010_x86)
CC
=
cl.exe
...
...
@@ -279,16 +285,19 @@ PATH := $(PATH):$(shell IFS=$$'\n'; cygpath "$(VS100COMNTOOLS)../IDE")
LIB
:=
$(
shell
IFS
=
$$
'\n'
;
cygpath
-w
"
$(VS100COMNTOOLS)
../../VC/lib"
)
INCLUDE
:=
$(
shell
IFS
=
$$
'\n'
;
cygpath
"
$(VS100COMNTOOLS)
../../VC/include"
)
WindowsSdkDir
:=
$(
shell
reg query
"HKLM
\S
OFTWARE
\M
icrosoft
\M
icrosoft SDKs
\W
indows
\v
7.
0
A"
-v
"InstallationFolder"
|
grep
-o
'[A-Z]:\\.*'
)
lib
WindowsSdkDir
?=
$(
shell
reg query
"HKLM
\S
OFTWARE
\M
icrosoft
\M
icrosoft SDKs
\W
indows
\v
7.
1
A"
-v
"InstallationFolder"
|
grep
-o
'[A-Z]:\\.*'
)
lib
WindowsSdkDir
:=
$(
shell
reg query
"HKLM
\S
OFTWARE
\M
icrosoft
\M
icrosoft SDKs
\W
indows
\v
7.
1
A"
-v
"InstallationFolder"
|
grep
-o
'[A-Z]:\\.*'
)
WindowsSdkDir
?=
$(
shell
reg query
"HKLM
\S
OFTWARE
\M
icrosoft
\M
icrosoft SDKs
\W
indows
\v
7.
0
A"
-v
"InstallationFolder"
|
grep
-o
'[A-Z]:\\.*'
)
WindowsSdkDirInc
:=
$(
shell
reg query
"HKLM
\S
OFTWARE
\M
icrosoft
\M
icrosoft SDKs
\W
indows
\v
7.0A"
-v
"InstallationFolder"
|
grep
-o
'[A-Z]:\\.*'
)
Include
WindowsSdkDirInc
?=
$(
shell
reg query
"HKLM
\S
OFTWARE
\M
icrosoft
\M
icrosoft SDKs
\W
indows
\v
7.1A"
-v
"InstallationFolder"
|
grep
-o
'[A-Z]:\\.*'
)
Include
WindowsSDKIncludeDir
:=
$(
shell
cygpath
-w
"
$(WindowsSdkDir)
\I
nclude"
)
WindowsSDKGlIncludeDir
:=
$(
shell
cygpath
-w
"
$(WindowsSdkDir)
\I
nclude
\g
l"
)
WindowsSDKLibDir
:=
$(
shell
cygpath
-w
"
$(WindowsSdkDir)
\L
ib"
)
INCFLAGS_PLATFORM
=
-I
"
$(WindowsS
dkDirInc
)
"
export
INCLUDE
:=
$(INCLUDE)
export
LIB
:=
$(LIB)
;
$(WindowsS
dk
Dir)
INCFLAGS_PLATFORM
=
-I
"
$(WindowsS
DKIncludeDir
)
"
export
INCLUDE
:=
$(INCLUDE)
;
$(WindowsSDKIncludeDir)
;
$(WindowsSDKGlIncludeDir)
export
LIB
:=
$(LIB)
;
$(WindowsS
DKLib
Dir)
TARGET
:=
$(TARGET_NAME)
_libretro.dll
PSS_STYLE
:=
2
LDFLAGS
+=
-DLL
...
...
@@ -305,10 +314,17 @@ INCLUDE := $(shell IFS=$$'\n'; cygpath "$(VS80COMNTOOLS)../../VC/include")
LIB
:=
$(
shell
IFS
=
$$
'\n'
;
cygpath
-w
"
$(VS80COMNTOOLS)
../../VC/lib"
)
BIN
:=
$(
shell
IFS
=
$$
'\n'
;
cygpath
"
$(VS80COMNTOOLS)
../../VC/bin"
)
WindowsSdkDir
:=
$(
INETSDK
)
WindowsSdkDir
:=
$(
shell
reg query
"HKLM
\S
OFTWARE
\M
icrosoft
\M
icrosoftSDK
\I
nstalledSDKs
\8
F9E5EF3-A9A5-491B-A889-C58EFFECE8B3"
-v
"Install Dir"
|
grep
-o
'[A-Z]:\\.*'
)
export
INCLUDE
:=
$(INCLUDE)
;
$(INETSDK)
/Include
;
libretro-common/include/compat/msvc
export
LIB
:=
$(LIB)
;
$(WindowsSdkDir)
;
$(INETSDK)
/Lib
WindowsSDKIncludeDir
:=
$(
shell
cygpath
-w
"
$(WindowsSdkDir)
\I
nclude"
)
WindowsSDKAtlIncludeDir
:=
$(
shell
cygpath
-w
"
$(WindowsSdkDir)
\I
nclude
\a
tl"
)
WindowsSDKCrtIncludeDir
:=
$(
shell
cygpath
-w
"
$(WindowsSdkDir)
\I
nclude
\c
rt"
)
WindowsSDKGlIncludeDir
:=
$(
shell
cygpath
-w
"
$(WindowsSdkDir)
\I
nclude
\g
l"
)
WindowsSDKMfcIncludeDir
:=
$(
shell
cygpath
-w
"
$(WindowsSdkDir)
\I
nclude
\m
fc"
)
WindowsSDKLibDir
:=
$(
shell
cygpath
-w
"
$(WindowsSdkDir)
\L
ib"
)
export
INCLUDE
:=
$(INCLUDE)
;
$(WindowsSDKIncludeDir)
;
$(WindowsSDKAtlIncludeDir)
;
$(WindowsSDKCrtIncludeDir)
;
$(WindowsSDKGlIncludeDir)
;
$(WindowsSDKMfcIncludeDir)
;
libretro-common/include/compat/msvc
export
LIB
:=
$(LIB)
;
$(WindowsSDKLibDir)
TARGET
:=
$(TARGET_NAME)
_libretro.dll
PSS_STYLE
:=
2
LDFLAGS
+=
-DLL
...
...
@@ -465,6 +481,20 @@ endif
CFLAGS
+=
-Wall
$(INCFLAGS)
$(INCFLAGS_PLATFORM)
CXXFLAGS
+=
-Wall
$(INCFLAGS)
$(INCFLAGS_PLATFORM)
ifeq
($(DEBUG),1)
CFLAGS
+=
-O0
-g
endif
ifneq
(,$(findstring msvc,$(platform)))
ifeq
($(DEBUG),1)
CFLAGS
+=
-MTd
CFLAGS
+=
-MTd
else
CFLAGS
+=
-MT
CFLAGS
+=
-MT
endif
endif
ifeq
(,$(findstring msvc,$(platform)))
LDFLAGS
+=
-shared
endif
...
...
Makefile.common
View file @
f594700b
...
...
@@ -65,7 +65,6 @@ SOURCES_C := $(CORE_DIR)/src/libretro.c \
$(CORE_DIR)
/src/graphics.c
\
$(CORE_DIR)
/src/player.c
\
$(CORE_DIR)
/src/playlist.c
\
$(CORE_DIR)
/src/log.c
\
$(CORE_DIR)
/src/fileformat.c
\
$(DEPS_DIR)
/zlib-1.2.8/adler32.c
\
$(DEPS_DIR)
/zlib-1.2.8/crc32.c
\
...
...
@@ -80,10 +79,21 @@ SOURCES_C := $(CORE_DIR)/src/libretro.c \
$(DEPS_DIR)
/zlib-1.2.8/gzlib.c
\
$(DEPS_DIR)
/zlib-1.2.8/gzread.c
\
$(DEPS_DIR)
/zlib-1.2.8/gzwrite.c
\
$(DEPS_DIR)
/zlib-1.2.8/trees.c
\
$(DEPS_DIR)
/libretro-common/compat/compat_snprintf.c
\
$(DEPS_DIR)
/libretro-common/compat/compat_posix_string.c
\
$(DEPS_DIR)
/libretro-common/compat/compat_strcasestr.c
\
$(DEPS_DIR)
/libretro-common/compat/compat_strl.c
\
$(DEPS_DIR)
/libretro-common/file/file_path.c
\
$(DEPS_DIR)
/libretro-common/string/stdstring.c
$(DEPS_DIR)
/zlib-1.2.8/trees.c
ifneq
($(STATIC_LINKING), 1)
SOURCES_C
+=
\
$(LIBRETRO_COMM_DIR)
/compat/compat_strcasestr.c
\
$(LIBRETRO_COMM_DIR)
/encodings/encoding_utf.c
\
$(LIBRETRO_COMM_DIR)
/compat/compat_snprintf.c
\
$(LIBRETRO_COMM_DIR)
/compat/compat_strl.c
\
$(LIBRETRO_COMM_DIR)
/compat/compat_posix_string.c
\
$(LIBRETRO_COMM_DIR)
/compat/fopen_utf8.c
\
$(LIBRETRO_COMM_DIR)
/streams/file_stream.c
\
$(LIBRETRO_COMM_DIR)
/streams/file_stream_transforms.c
\
$(LIBRETRO_COMM_DIR)
/string/stdstring.c
\
$(LIBRETRO_COMM_DIR)
/vfs/vfs_implementation.c
\
$(LIBRETRO_COMM_DIR)
/file/file_path.c
\
$(LIBRETRO_COMM_DIR)
/file/file_path_io.c
\
$(LIBRETRO_COMM_DIR)
/time/rtime.c
endif
deps/game-music-emu/demo/CMakeLists.txt
deleted
100644 → 0
View file @
6b0d103b
# Rules for building the demo. Doesn't use an installed gme if you've already
# installed the project so if you're copying these rules you probably don't
# even need these next two lines if you're building against system-installed
# gme.
include_directories
(
${
CMAKE_SOURCE_DIR
}
/gme
${
CMAKE_SOURCE_DIR
}
)
link_directories
(
${
CMAKE_BINARY_DIR
}
/gme
)
add_executable
(
demo Wave_Writer.cpp basics.c
)
# Add command to copy build file over.
add_custom_command
(
TARGET demo
POST_BUILD
COMMAND cmake -E copy
"
${
CMAKE_SOURCE_DIR
}
/test.nsf"
${
CMAKE_CURRENT_BINARY_DIR
}
COMMENT
"Add convenience copy of test.nsf file for demo application"
VERBATIM
)
# VERBATIM is essentially required, "please use correct command line kthx"
target_link_libraries
(
demo gme
)
deps/game-music-emu/demo/Wave_Writer.cpp
deleted
100644 → 0
View file @
6b0d103b
// Game_Music_Emu 0.6.0. http://www.slack.net/~ant/
#include "Wave_Writer.h"
#include <assert.h>
#include <stdlib.h>
/* Copyright (C) 2003-2006 by Shay Green. Permission is hereby granted, free
of charge, to any person obtaining a copy of this software and associated
documentation files (the "Software"), to deal in the Software without
restriction, including without limitation the rights to use, copy, modify,
merge, publish, distribute, sublicense, and/or sell copies of the Software, and
to permit persons to whom the Software is furnished to do so, subject to the
following conditions: The above copyright notice and this permission notice
shall be included in all copies or substantial portions of the Software. THE
SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
const
int
header_size
=
0x2C
;
static
void
exit_with_error
(
const
char
*
str
)
{
printf
(
"Error: %s
\n
"
,
str
);
getchar
();
exit
(
EXIT_FAILURE
);
}
Wave_Writer
::
Wave_Writer
(
long
sample_rate
,
const
char
*
filename
)
{
sample_count_
=
0
;
rate
=
sample_rate
;
buf_pos
=
header_size
;
chan_count
=
1
;
buf
=
(
unsigned
char
*
)
malloc
(
buf_size
*
sizeof
*
buf
);
if
(
!
buf
)
exit_with_error
(
"Out of memory"
);
file
=
fopen
(
filename
,
"wb"
);
if
(
!
file
)
exit_with_error
(
"Couldn't open WAVE file for writing"
);
setvbuf
(
file
,
0
,
_IOFBF
,
32
*
1024L
);
}
void
Wave_Writer
::
flush
()
{
if
(
buf_pos
&&
!
fwrite
(
buf
,
buf_pos
,
1
,
file
)
)
exit_with_error
(
"Couldn't write WAVE data"
);
buf_pos
=
0
;
}
void
Wave_Writer
::
write
(
const
sample_t
*
in
,
long
remain
,
int
skip
)
{
sample_count_
+=
remain
;
while
(
remain
)
{
if
(
buf_pos
>=
buf_size
)
flush
();
long
n
=
(
buf_size
-
buf_pos
)
/
sizeof
(
sample_t
);
if
(
n
>
remain
)
n
=
remain
;
remain
-=
n
;
// convert to lsb first format
unsigned
char
*
p
=
&
buf
[
buf_pos
];
while
(
n
--
)
{
int
s
=
*
in
;
in
+=
skip
;
*
p
++
=
(
unsigned
char
)
s
;
*
p
++
=
(
unsigned
char
)
(
s
>>
8
);
}
buf_pos
=
p
-
buf
;
assert
(
buf_pos
<=
buf_size
);
}
}
void
Wave_Writer
::
write
(
const
float
*
in
,
long
remain
,
int
skip
)
{
sample_count_
+=
remain
;
while
(
remain
)
{
if
(
buf_pos
>=
buf_size
)
flush
();
long
n
=
(
buf_size
-
buf_pos
)
/
sizeof
(
sample_t
);
if
(
n
>
remain
)
n
=
remain
;
remain
-=
n
;
// convert to lsb first format
unsigned
char
*
p
=
&
buf
[
buf_pos
];
while
(
n
--
)
{
long
s
=
(
long
)
(
*
in
*
0x7FFF
);
in
+=
skip
;
if
(
(
short
)
s
!=
s
)
s
=
0x7FFF
-
(
s
>>
24
);
// clamp to 16 bits
*
p
++
=
(
unsigned
char
)
s
;
*
p
++
=
(
unsigned
char
)
(
s
>>
8
);
}
buf_pos
=
p
-
buf
;
assert
(
buf_pos
<=
buf_size
);
}
}
void
Wave_Writer
::
close
()
{
if
(
file
)
{
flush
();
// generate header
long
ds
=
sample_count_
*
sizeof
(
sample_t
);
long
rs
=
header_size
-
8
+
ds
;
int
frame_size
=
chan_count
*
sizeof
(
sample_t
);
long
bps
=
rate
*
frame_size
;
unsigned
char
header
[
header_size
]
=
{
'R'
,
'I'
,
'F'
,
'F'
,
rs
,
rs
>>
8
,
// length of rest of file
rs
>>
16
,
rs
>>
24
,
'W'
,
'A'
,
'V'
,
'E'
,
'f'
,
'm'
,
't'
,
' '
,
0x10
,
0
,
0
,
0
,
// size of fmt chunk
1
,
0
,
// uncompressed format
chan_count
,
0
,
// channel count
rate
,
rate
>>
8
,
// sample rate
rate
>>
16
,
rate
>>
24
,
bps
,
bps
>>
8
,
// bytes per second
bps
>>
16
,
bps
>>
24
,
frame_size
,
0
,
// bytes per sample frame
16
,
0
,
// bits per sample
'd'
,
'a'
,
't'
,
'a'
,
ds
,
ds
>>
8
,
ds
>>
16
,
ds
>>
24
// size of sample data
// ... // sample data
};
// write header
fseek
(
file
,
0
,
SEEK_SET
);
fwrite
(
header
,
sizeof
header
,
1
,
file
);
fclose
(
file
);
file
=
0
;
free
(
buf
);
}
}
Wave_Writer
::~
Wave_Writer
()
{
close
();
}
// C interface
static
Wave_Writer
*
ww
;
void
wave_open
(
long
sample_rate
,
const
char
*
filename
)
{
ww
=
new
Wave_Writer
(
sample_rate
,
filename
);
assert
(
ww
);
}
void
wave_enable_stereo
()
{
ww
->
enable_stereo
();
}
long
wave_sample_count
()
{
return
ww
->
sample_count
();
}
void
wave_write
(
const
short
*
buf
,
long
count
)
{
ww
->
write
(
buf
,
count
);
}
void
wave_close
()
{
delete
ww
;
ww
=
0
;
}
deps/game-music-emu/demo/Wave_Writer.h
deleted
100644 → 0
View file @
6b0d103b
/* WAVE sound file writer for recording 16-bit output during program development */
#ifndef WAVE_WRITER_H
#define WAVE_WRITER_H
#ifdef __cplusplus
extern
"C"
{
#endif
/* C interface */
void
wave_open
(
long
sample_rate
,
const
char
*
filename
);
void
wave_enable_stereo
(
void
);
void
wave_write
(
const
short
*
buf
,
long
count
);
long
wave_sample_count
(
void
);
void
wave_close
(
void
);
#ifdef __cplusplus
}
#endif
#ifdef __cplusplus
#include <stddef.h>
#include <stdio.h>
/* C++ interface */
class
Wave_Writer
{
public:
typedef
short
sample_t
;
// Create sound file with given sample rate (in Hz) and filename.
// Exits program if there's an error.
Wave_Writer
(
long
sample_rate
,
char
const
*
filename
=
"out.wav"
);
// Enable stereo output
void
enable_stereo
();
// Append 'count' samples to file. Use every 'skip'th source sample; allows
// one channel of stereo sample pairs to be written by specifying a skip of 2.
void
write
(
const
sample_t
*
,
long
count
,
int
skip
=
1
);
// Append 'count' floating-point samples to file. Use every 'skip'th source sample;
// allows one channel of stereo sample pairs to be written by specifying a skip of 2.
void
write
(
const
float
*
,
long
count
,
int
skip
=
1
);
// Number of samples written so far
long
sample_count
()
const
;
// Finish writing sound file and close it
void
close
();
~
Wave_Writer
();
public:
// Deprecated
void
stereo
(
bool
b
)
{
chan_count
=
b
?
2
:
1
;
}
private:
enum
{
buf_size
=
32768
*
2
};
unsigned
char
*
buf
;
FILE
*
file
;
long
sample_count_
;
long
rate
;
long
buf_pos
;
int
chan_count
;
void
flush
();
};
inline
void
Wave_Writer
::
enable_stereo
()
{
chan_count
=
2
;
}
inline
long
Wave_Writer
::
sample_count
()
const
{
return
sample_count_
;
}
#endif
#endif
deps/game-music-emu/demo/basics.c
deleted
100644 → 0
View file @
6b0d103b
/* 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>
void
handle_error
(
const
char
*
str
);
int
main
(
int
argc
,
char
*
argv
[])
{
const
char
*
filename
=
"test.nsf"
;
/* Default file to open */
if
(
argc
>=
2
)
filename
=
argv
[
1
];
long
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 emulator */
Music_Emu
*
emu
;
handle_error
(
gme_open_file
(
filename
,
&
emu
,
sample_rate
)
);
/* Start track */
handle_error
(
gme_start_track
(
emu
,
track
)
);
/* Begin writing to wave file */
wave_open
(
sample_rate
,
"out.wav"
);
wave_enable_stereo
();
/* Record 10 seconds of track */
while
(
gme_tell
(
emu
)
<
10
*
1000L
)
{
/* Sample buffer */
#define buf_size 1024
/* can be any multiple of 2 */
short
buf
[
buf_size
];
/* Fill sample buffer */
handle_error
(
gme_play
(
emu
,
buf_size
,
buf
)
);
/* Write samples to wave file */
wave_write
(
buf
,
buf_size
);
}
/* Cleanup */
gme_delete
(
emu
);
wave_close
();
return
0
;
}
void
handle_error
(
const
char
*
str
)
{
if
(
str
)
{
printf
(
"Error: %s
\n
"
,
str
);
getchar
();
exit
(
EXIT_FAILURE
);
}
}
deps/game-music-emu/demo/cpp_basics.cpp
deleted
100644 → 0
View file @
6b0d103b
// C++ example that opens a game music file and records 10 seconds to "out.wav"
#include "gme/Music_Emu.h"
#include "Wave_Writer.h"
#include <stdlib.h>
#include <stdio.h>
void
handle_error
(
const
char
*
str
);
int
main
(
int
argc
,
char
*
argv
[])
{
const
char
*
filename
=
"test.nsf"
;
/* Default file to open */
if
(
argc
>=
2
)
filename
=
argv
[
1
];
long
sample_rate
=
44100
;
// number of samples per second
// index of track to play (0 = first)
int
track
=
argc
>=
3
?
atoi
(
argv
[
2
])
:
0
;
// Determine file type