Skip to content

Commit

Permalink
Custom Audio Support (#778)
Browse files Browse the repository at this point in the history
* Implement custom sequences and the audio editor.

* Fix implicit function declaration `AudioEditor_GetReplacementSeq`

* Fix mac again.

* String and header cleanup

* Oops

* WIP ZIP Sound fonts

* The game opens and audio seems to play correctly. Needs extensive testing.

* Name sequences

* Cleanup the SF importer a little.

* XML Sequences good

* Fix mac

* Destructor

* Bump submodule

* Thread safe queue

* Add WAV decoder

* sequenceMap->mSequenceMap and a string fix

* Streamed sequence importer

* Add s16 sample processing.

* Fix drwave define

* Fix STB

* Reorder the loading to enable custom sound fonts

* New streamed solution

* Bump exporter

* Generate 1 minute long looping sequence.

* Very long sample support (113 minutes or so)

* MP3 Decoding

* Don't byteswap the crc from XML.

* WIP OGG

* add windows cmake stuff (broken) and fixes to OGG

* Just throw more cores at the problem

* Dynamically allocate fontMap

* Re-add OOB read fix from old branch

* FLAC decoder, threads for the other compressed formats

* Remove thread from class

* timings

* cleanup conflicts

* update submodules

* update submodules

* update submodules

* loop or not to loop

* named audio XML

* Update submodules

* format

* format again cause git didnt see it for some reason

* move drlib to submodule

* Update apt-deps.txt

* Fix for new cmake

* fix game interactor

* Update macports-deps.txt

* PR fixes and fix OTRExporter for mac

* format

* format

* ifdef intrin header

* Docs

* use macro for preview

* Small fixes

* format

* fix 2nd day clock town

* Update exporter

* Fix duplicate global in stubs.c

* restore editor to use cvars again sadge

* Format

* warn if more than 255 sequences

* use main seq player to avoid an overflow

* fix the wrong seq playing in the editor again

* 16 bit seqIds

* fix shop crash

* format

* cleanups

* Delete audio collection

* Add entry to modern menu

* Cleanup the audio collection

* fix clock town randomization

* format

* format again

* some fixes for custom audio (#1)

* how I would sort the sequences (#2)

clang

one more

forgot to revert

Co-authored-by: mckinlee <[email protected]>

* Adjustments to ocarina song types

* stereo

* format

* Loop point support

* Part of a PR review

* Remove drlib submodule

* Clarify change

* Format

* Add tag

* switch to find_package

* bump ZAPDTR

* Milk bar day/night fix

* x86 SIMD for aMixImpl

* format

* NEON

* format

* remove | 0x900 causing a crash

* Asan fixes

* add missing define for MSVC

* Clock town fixes

Co-authored-by: mckinlee <[email protected]>

* format

* Fix underscore logic in audio collection

* Use torch sample XML format

* fix font map size and format

* quick fix

* Update exporter

* Opus

* actions packages

* fix it again?

* Fix a few missed 16 bit masks

* Remove unused stubs

* Revert "Fix a few missed 16 bit masks"

This reverts commit 7143c4f.

* Opus decoding

* Fixes for linux and other things

* free opus data

* format

* Update FindOpusFile.cmake

* bria's fix?

* Update BenMenuBar.cpp

* Update BenMenuBar.cpp

* Split ocarina tabs

* better error handling

* Remove unused vectors

* move audio editor to enhancements

* Fix mac again?

* Final cleanups

* Format

* extern C

* Allow custom fanfares to be used in songs

* format

* WIP sf editor support

* Format

* Jacks fixes

* Bump submodule

* Archez's fixes

* Format

---------

Co-authored-by: mckinlee <[email protected]>
Co-authored-by: Archez <[email protected]>
  • Loading branch information
3 people authored Mar 3, 2025
1 parent 38db449 commit 2d0942a
Show file tree
Hide file tree
Showing 86 changed files with 5,397 additions and 6,987 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/apt-deps.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
libusb-dev libusb-1.0-0-dev libsdl2-dev libsdl2-net-dev libpng-dev libglew-dev nlohmann-json3-dev libtinyxml2-dev libspdlog-dev ninja-build
libusb-dev libusb-1.0-0-dev libsdl2-dev libsdl2-net-dev libpng-dev libglew-dev nlohmann-json3-dev libtinyxml2-dev libspdlog-dev ninja-build libogg-dev libopus-dev opus-tools libopusfile-dev libvorbis-dev
2 changes: 1 addition & 1 deletion .github/workflows/macports-deps.txt
Original file line number Diff line number Diff line change
@@ -1 +1 @@
libsdl2 +universal libsdl2_net +universal libpng +universal glew +universal libzip +universal nlohmann-json +universal tinyxml2 +universal
libsdl2 +universal libsdl2_net +universal libpng +universal glew +universal libzip +universal nlohmann-json +universal tinyxml2 +universal libogg +universal libopus +universal opusfile +universal libvorbis +universal
2 changes: 1 addition & 1 deletion .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,4 @@
url = https://github.com/HarbourMasters/OTRExporter.git
[submodule "ZAPDTR"]
path = ZAPDTR
url = https://github.com/louist103/ZAPDTR.git
url = https://github.com/louist103/ZAPDTR.git
61 changes: 61 additions & 0 deletions CMake/FindOgg.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# - Find ogg
# Find the native ogg includes and libraries
#
# OGG_INCLUDE_DIRS - where to find ogg.h, etc.
# OGG_LIBRARIES - List of libraries when using ogg.
# OGG_FOUND - True if ogg found.

if (OGG_INCLUDE_DIR)
# Already in cache, be silent
set(OGG_FIND_QUIETLY TRUE)
endif ()

find_package (PkgConfig QUIET)
pkg_check_modules (PC_OGG QUIET ogg>=1.3.0)

set (OGG_VERSION ${PC_OGG_VERSION})

find_path (OGG_INCLUDE_DIR ogg/ogg.h
HINTS
${PC_OGG_INCLUDEDIR}
${PC_OGG_INCLUDE_DIRS}
${OGG_ROOT}
)
# MSVC built ogg may be named ogg_static.
# The provided project files name the library with the lib prefix.
find_library (OGG_LIBRARY
NAMES
ogg
ogg_static
libogg
libogg_static
HINTS
${PC_OGG_LIBDIR}
${PC_OGG_LIBRARY_DIRS}
${OGG_ROOT}
)
# Handle the QUIETLY and REQUIRED arguments and set OGG_FOUND
# to TRUE if all listed variables are TRUE.
include (FindPackageHandleStandardArgs)
find_package_handle_standard_args (Ogg
REQUIRED_VARS
OGG_LIBRARY
OGG_INCLUDE_DIR
VERSION_VAR
OGG_VERSION
)

if (OGG_FOUND)
set (OGG_LIBRARIES ${OGG_LIBRARY})
set (OGG_INCLUDE_DIRS ${OGG_INCLUDE_DIR})

if(NOT TARGET Ogg::ogg)
add_library(Ogg::ogg UNKNOWN IMPORTED)
set_target_properties(Ogg::ogg PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${OGG_INCLUDE_DIRS}"
IMPORTED_LOCATION "${OGG_LIBRARIES}"
)
endif ()
endif ()

mark_as_advanced (OGG_INCLUDE_DIR OGG_LIBRARY)
44 changes: 44 additions & 0 deletions CMake/FindOpus.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
# - FindOpus.cmake
# Find the native opus includes and libraries
#
# OPUS_INCLUDE_DIRS - where to find opus/opus.h, etc.
# OPUS_LIBRARIES - List of libraries when using libopus(file).
# OPUS_FOUND - True if libopus found.

if(OPUS_INCLUDE_DIR AND OPUS_LIBRARY AND OPUSFILE_LIBRARY)
# Already in cache, be silent
set(OPUS_FIND_QUIETLY TRUE)
endif(OPUS_INCLUDE_DIR AND OPUS_LIBRARY AND OPUSFILE_LIBRARY)

find_path(OPUS_INCLUDE_DIR
NAMES opusfile.h
PATH_SUFFIXES opus
)

# MSVC built opus may be named opus_static
# The provided project files name the library with the lib prefix.
find_library(OPUS_LIBRARY
NAMES opus opus_static libopus libopus_static
)
#find_library(OPUSFILE_LIBRARY
# NAMES opusfile opusfile_static libopusfile libopusfile_static
#)

# Handle the QUIETLY and REQUIRED arguments and set OPUS_FOUND
# to TRUE if all listed variables are TRUE.
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(Opus DEFAULT_MSG
OPUS_LIBRARY OPUS_INCLUDE_DIR
)

if(OPUS_FOUND)
set(OPUS_LIBRARIES ${OPUS_LIBRARY})
set(OPUS_INCLUDE_DIRS ${OPUS_INCLUDE_DIR})
if(NOT TARGET Opus::opus)
add_library(Opus::opus UNKNOWN IMPORTED)
set_target_properties(Opus::opus PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${OPUS_INCLUDE_DIRS}"
IMPORTED_LOCATION "${OPUS_LIBRARIES}"
)
endif()
endif(OPUS_FOUND)
55 changes: 55 additions & 0 deletions CMake/FindOpusFile.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
# FindOpusFile.cmake
# Locate the libopusfile library and its dependencies (libopus and libogg).
# Defines the following variables on success:
# OPUSFILE_FOUND - Indicates if opusfile was found
# OPUSFILE_INCLUDE_DIR - Directory containing opusfile.h
# OPUSFILE_LIBRARY - Path to the opusfile library
# OPUSFILE_LIBRARIES - Full list of libraries to link (opusfile, opus, ogg)

# Search for the OpusFile header
find_path(OPUSFILE_INCLUDE_DIR
NAMES opusfile.h
PATHS /usr/include/opus /usr/local/include/opus /opt/local/include/opus
DOC "Directory where opusfile.h is located"
)

# Search for the OpusFile library
find_library(OPUSFILE_LIBRARY
NAMES opusfile
DOC "Path to the libopusfile library"
)

# Search for the Opus library (dependency of OpusFile)
find_library(OPUS_LIBRARY
NAMES opus
DOC "Path to the libopus library (dependency of libopusfile)"
)

# Search for the Ogg library (dependency of OpusFile)
find_library(OGG_LIBRARY
NAMES ogg
DOC "Path to the libogg library (dependency of libopusfile)"
)

# Check if all required components are found
include(FindPackageHandleStandardArgs)
find_package_handle_standard_args(OpusFile
REQUIRED_VARS OPUSFILE_LIBRARY OPUSFILE_INCLUDE_DIR OPUS_LIBRARY OGG_LIBRARY
VERSION_VAR OPUSFILE_VERSION
)

# Define an imported target if everything is found
if (OPUSFILE_FOUND)
add_library(Opusfile::Opusfile INTERFACE IMPORTED)

set_target_properties(Opusfile::Opusfile PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${OPUSFILE_INCLUDE_DIR}"
INTERFACE_LINK_LIBRARIES "${OPUSFILE_LIBRARY};${OPUS_LIBRARY};${OGG_LIBRARY}"
)

# Optionally expose the include and libraries separately
set(OPUSFILE_LIBRARIES ${OPUSFILE_LIBRARY} ${OPUS_LIBRARY} ${OGG_LIBRARY})
set(OPUSFILE_INCLUDE_DIRS ${OPUSFILE_INCLUDE_DIR})
else()
set(OPUSFILE_FOUND FALSE)
endif()
210 changes: 210 additions & 0 deletions CMake/FindVorbis.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,210 @@
#[=======================================================================[.rst:
FindVorbis
----------
Finds the native vorbis, vorbisenc amd vorbisfile includes and libraries.
Imported Targets
^^^^^^^^^^^^^^^^
This module provides the following imported targets, if found:
``Vorbis::vorbis``
The Vorbis library
``Vorbis::vorbisenc``
The VorbisEnc library
``Vorbis::vorbisfile``
The VorbisFile library
Result Variables
^^^^^^^^^^^^^^^^
This will define the following variables:
``Vorbis_Vorbis_INCLUDE_DIRS``
List of include directories when using vorbis.
``Vorbis_Enc_INCLUDE_DIRS``
List of include directories when using vorbisenc.
``Vorbis_File_INCLUDE_DIRS``
List of include directories when using vorbisfile.
``Vorbis_Vorbis_LIBRARIES``
List of libraries when using vorbis.
``Vorbis_Enc_LIBRARIES``
List of libraries when using vorbisenc.
``Vorbis_File_LIBRARIES``
List of libraries when using vorbisfile.
``Vorbis_FOUND``
True if vorbis and requested components found.
``Vorbis_Vorbis_FOUND``
True if vorbis found.
``Vorbis_Enc_FOUND``
True if vorbisenc found.
``Vorbis_Enc_FOUND``
True if vorbisfile found.
Cache variables
^^^^^^^^^^^^^^^
The following cache variables may also be set:
``Vorbis_Vorbis_INCLUDE_DIR``
The directory containing ``vorbis/vorbis.h``.
``Vorbis_Enc_INCLUDE_DIR``
The directory containing ``vorbis/vorbisenc.h``.
``Vorbis_File_INCLUDE_DIR``
The directory containing ``vorbis/vorbisenc.h``.
``Vorbis_Vorbis_LIBRARY``
The path to the vorbis library.
``Vorbis_Enc_LIBRARY``
The path to the vorbisenc library.
``Vorbis_File_LIBRARY``
The path to the vorbisfile library.
Hints
^^^^^
A user may set ``Vorbis_ROOT`` to a vorbis installation root to tell this module where to look.
#]=======================================================================]

if (Vorbis_Vorbis_INCLUDE_DIR)
# Already in cache, be silent
set (Vorbis_FIND_QUIETLY TRUE)
endif ()

set (Vorbis_Vorbis_FIND_QUIETLY TRUE)
set (Vorbis_Enc_FIND_QUIETLY TRUE)
set (Vorbis_File_FIND_QUIETLY TRUE)

find_package (Ogg QUIET)

find_package (PkgConfig QUIET)
pkg_check_modules (PC_Vorbis_Vorbis QUIET vorbis)
pkg_check_modules (PC_Vorbis_Enc QUIET vorbisenc)
pkg_check_modules (PC_Vorbis_File QUIET vorbisfile)

set (Vorbis_VERSION ${PC_Vorbis_Vorbis_VERSION})

find_path (Vorbis_Vorbis_INCLUDE_DIR vorbis/codec.h
HINTS
${PC_Vorbis_Vorbis_INCLUDEDIR}
${PC_Vorbis_Vorbis_INCLUDE_DIRS}
${Vorbis_ROOT}
)

find_path (Vorbis_Enc_INCLUDE_DIR vorbis/vorbisenc.h
HINTS
${PC_Vorbis_Enc_INCLUDEDIR}
${PC_Vorbis_Enc_INCLUDE_DIRS}
${Vorbis_ROOT}
)

find_path (Vorbis_File_INCLUDE_DIR vorbis/vorbisfile.h
HINTS
${PC_Vorbis_File_INCLUDEDIR}
${PC_Vorbis_File_INCLUDE_DIRS}
${Vorbis_ROOT}
)

find_library (Vorbis_Vorbis_LIBRARY
NAMES
vorbis
vorbis_static
libvorbis
libvorbis_static
HINTS
${PC_Vorbis_Vorbis_LIBDIR}
${PC_Vorbis_Vorbis_LIBRARY_DIRS}
${Vorbis_ROOT}
)

find_library (Vorbis_Enc_LIBRARY
NAMES
vorbisenc
vorbisenc_static
libvorbisenc
libvorbisenc_static
HINTS
${PC_Vorbis_Enc_LIBDIR}
${PC_Vorbis_Enc_LIBRARY_DIRS}
${Vorbis_ROOT}
)

find_library (Vorbis_File_LIBRARY
NAMES
vorbisfile
vorbisfile_static
libvorbisfile
libvorbisfile_static
HINTS
${PC_Vorbis_File_LIBDIR}
${PC_Vorbis_File_LIBRARY_DIRS}
${Vorbis_ROOT}
)

include (FindPackageHandleStandardArgs)

if (Vorbis_Vorbis_LIBRARY AND Vorbis_Vorbis_INCLUDE_DIR AND Ogg_FOUND)
set (Vorbis_Vorbis_FOUND TRUE)
endif ()

if (Vorbis_Enc_LIBRARY AND Vorbis_Enc_INCLUDE_DIR AND Vorbis_Vorbis_FOUND)
set (Vorbis_Enc_FOUND TRUE)
endif ()

if (Vorbis_Vorbis_FOUND AND Vorbis_File_LIBRARY AND Vorbis_File_INCLUDE_DIR)
set (Vorbis_File_FOUND TRUE)
endif ()

find_package_handle_standard_args (Vorbis
REQUIRED_VARS
Vorbis_Vorbis_LIBRARY
Vorbis_Vorbis_INCLUDE_DIR
Ogg_FOUND
HANDLE_COMPONENTS
VERSION_VAR Vorbis_VERSION)


if (Vorbis_Vorbis_FOUND)
set (Vorbis_Vorbis_INCLUDE_DIRS ${VORBIS_INCLUDE_DIR})
set (Vorbis_Vorbis_LIBRARIES ${VORBIS_LIBRARY} ${OGG_LIBRARIES})
if (NOT TARGET Vorbis::vorbis)
add_library (Vorbis::vorbis UNKNOWN IMPORTED)
set_target_properties (Vorbis::vorbis PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${Vorbis_Vorbis_INCLUDE_DIR}"
IMPORTED_LOCATION "${Vorbis_Vorbis_LIBRARY}"
INTERFACE_LINK_LIBRARIES Ogg::ogg
)
endif ()

if (Vorbis_Enc_FOUND)
set (Vorbis_Enc_INCLUDE_DIRS ${Vorbis_Enc_INCLUDE_DIR})
set (Vorbis_Enc_LIBRARIES ${Vorbis_Enc_LIBRARY} ${Vorbis_Enc_LIBRARIES})
if (NOT TARGET Vorbis::vorbisenc)
add_library (Vorbis::vorbisenc UNKNOWN IMPORTED)
set_target_properties (Vorbis::vorbisenc PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${Vorbis_Enc_INCLUDE_DIR}"
IMPORTED_LOCATION "${Vorbis_Enc_LIBRARY}"
INTERFACE_LINK_LIBRARIES Vorbis::vorbis
)
endif ()
endif ()

if (Vorbis_File_FOUND)
set (Vorbis_File_INCLUDE_DIRS ${Vorbis_File_INCLUDE_DIR})
set (Vorbis_File_LIBRARIES ${Vorbis_File_LIBRARY} ${Vorbis_File_LIBRARIES})
if (NOT TARGET Vorbis::vorbisfile)
add_library (Vorbis::vorbisfile UNKNOWN IMPORTED)
set_target_properties (Vorbis::vorbisfile PROPERTIES
INTERFACE_INCLUDE_DIRECTORIES "${Vorbis_File_INCLUDE_DIR}"
IMPORTED_LOCATION "${Vorbis_File_LIBRARY}"
INTERFACE_LINK_LIBRARIES Vorbis::vorbis
)
endif ()
endif ()

endif ()

mark_as_advanced (Vorbis_Vorbis_INCLUDE_DIR Vorbis_Vorbis_LIBRARY)
mark_as_advanced (Vorbis_Enc_INCLUDE_DIR Vorbis_Enc_LIBRARY)
mark_as_advanced (Vorbis_File_INCLUDE_DIR Vorbis_File_LIBRARY)
Loading

0 comments on commit 2d0942a

Please sign in to comment.