Skip to content

Commit

Permalink
feature: Advanced Transitions with MIDI files (v0.3.0 milestone) (#31)
Browse files Browse the repository at this point in the history
* feature: add MidiFile for holding the metadat about transitions for the associated audio file

* feature: invert dependencies and move scheduling code directly to the `MusicTheme`; Engine became only an aggregate of objects, Channel became a command processor

* Fix compilation errors

* Cleanup code after last changes

* Add Transition class and new Daedalus classes for music definition

* Add virtual destructors to inheritance roots

* Add transiton executors, add Daedalus externals to control additional parameters

* Add a jingle suuport for transition

* Add docs for v0.3.0 changes
  • Loading branch information
piotrmacha authored May 28, 2024
1 parent 68d1dbb commit 1d76bdc
Show file tree
Hide file tree
Showing 74 changed files with 2,521 additions and 818 deletions.
5 changes: 4 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ target_sources(plugin PRIVATE ${PLUGIN_SOURCES} "${CMAKE_CURRENT_BINARY_DIR}/ver
add_compile_options(plugin PRIVATE /W4 /WX)
target_compile_definitions(plugin PRIVATE _UNION_API_DLL __G1 __G1A __G2 __G2A)
target_include_directories(plugin PRIVATE "src/" "${CMAKE_BINARY_DIR}/src/")
target_link_libraries(plugin PRIVATE union-api gothic-api bass)
target_link_libraries(plugin PRIVATE union-api gothic-api bass_all)

install(FILES $<TARGET_RUNTIME_DLLS:plugin> "${CMAKE_BINARY_DIR}/zBassMusic.dll" TYPE BIN)
install(FILES $<TARGET_RUNTIME_DLLS:plugin> "${CMAKE_BINARY_DIR}/UnionAPI.dll" TYPE BIN)
Expand Down Expand Up @@ -72,6 +72,9 @@ if (DEFINED ENV{COPY_DLL_TARGET})
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/zBassMusic.dll" "$ENV{COPY_DLL_TARGET}/Autorun/zBassMusic.dll"
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_BINARY_DIR}/UnionAPI.dll" "$ENV{COPY_DLL_TARGET}/Autorun/UnionAPI.dll"
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/dependencies/bass/lib/bass.dll" "$ENV{COPY_DLL_TARGET}/bass.dll"
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/dependencies/bass/lib/bassmidi.dll" "$ENV{COPY_DLL_TARGET}/bassmidi.dll"
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/dependencies/bass/lib/bassopus.dll" "$ENV{COPY_DLL_TARGET}/bassopus.dll"
COMMAND ${CMAKE_COMMAND} -E copy "${CMAKE_SOURCE_DIR}/dependencies/bass/lib/bassflac.dll" "$ENV{COPY_DLL_TARGET}/bassflac.dll"
DEPENDS plugin
COMMENT "Copy plugin to target directory: $ENV{COPY_DLL_TARGET}")
endif ()
18 changes: 18 additions & 0 deletions cmake/bass.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,21 @@ add_library(bass SHARED IMPORTED)
set_property(TARGET bass PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${BASS_DIR}/include")
set_property(TARGET bass PROPERTY IMPORTED_LOCATION "${BASS_DIR}/lib/bass.dll")
set_property(TARGET bass PROPERTY IMPORTED_IMPLIB "${BASS_DIR}/lib/bass.lib")

add_library(bassmidi SHARED IMPORTED)
set_property(TARGET bassmidi PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${BASS_DIR}/include")
set_property(TARGET bassmidi PROPERTY IMPORTED_LOCATION "${BASS_DIR}/lib/bassmidi.dll")
set_property(TARGET bassmidi PROPERTY IMPORTED_IMPLIB "${BASS_DIR}/lib/bassmidi.lib")

add_library(bassopus SHARED IMPORTED)
set_property(TARGET bassopus PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${BASS_DIR}/include")
set_property(TARGET bassopus PROPERTY IMPORTED_LOCATION "${BASS_DIR}/lib/bassopus.dll")
set_property(TARGET bassopus PROPERTY IMPORTED_IMPLIB "${BASS_DIR}/lib/bassopus.lib")

add_library(bassflac SHARED IMPORTED)
set_property(TARGET bassflac PROPERTY INTERFACE_INCLUDE_DIRECTORIES "${BASS_DIR}/include")
set_property(TARGET bassflac PROPERTY IMPORTED_LOCATION "${BASS_DIR}/lib/bassflac.dll")
set_property(TARGET bassflac PROPERTY IMPORTED_IMPLIB "${BASS_DIR}/lib/bassflac.lib")

add_library(bass_all INTERFACE)
target_link_libraries(bass_all INTERFACE bass bassmidi bassopus bassflac)
98 changes: 98 additions & 0 deletions dependencies/bass/include/bassflac.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/*
BASSFLAC 2.4 C/C++ header file
Copyright (c) 2004-2017 Un4seen Developments Ltd.
See the BASSFLAC.CHM file for more detailed documentation
*/

#ifndef BASSFLAC_H
#define BASSFLAC_H

#include "bass.h"

#if BASSVERSION!=0x204
#error conflicting BASS and BASSFLAC versions
#endif

#ifdef __cplusplus
extern "C" {
#endif

#ifndef BASSFLACDEF
#define BASSFLACDEF(f) WINAPI f
#endif

// BASS_CHANNELINFO type
#define BASS_CTYPE_STREAM_FLAC 0x10900
#define BASS_CTYPE_STREAM_FLAC_OGG 0x10901

// Additional tag types
#define BASS_TAG_FLAC_CUE 12 // cuesheet : TAG_FLAC_CUE structure
#define BASS_TAG_FLAC_PICTURE 0x12000 // + index #, picture : TAG_FLAC_PICTURE structure
#define BASS_TAG_FLAC_METADATA 0x12400 // + index #, application metadata : TAG_FLAC_METADATA structure

typedef struct {
DWORD apic; // ID3v2 "APIC" picture type
const char *mime; // mime type
const char *desc; // description
DWORD width;
DWORD height;
DWORD depth;
DWORD colors;
DWORD length; // data length
const void *data;
} TAG_FLAC_PICTURE;

typedef struct {
QWORD offset; // index offset relative to track offset (samples)
DWORD number; // index number
} TAG_FLAC_CUE_TRACK_INDEX;

typedef struct {
QWORD offset; // track offset (samples)
DWORD number; // track number
const char *isrc; // ISRC
DWORD flags;
DWORD nindexes; // number of indexes
const TAG_FLAC_CUE_TRACK_INDEX *indexes; // the indexes
} TAG_FLAC_CUE_TRACK;

typedef struct {
const char *catalog; // media catalog number
DWORD leadin; // lead-in (samples)
BOOL iscd; // a CD?
DWORD ntracks; // number of tracks
const TAG_FLAC_CUE_TRACK *tracks; // the tracks
} TAG_FLAC_CUE;

// TAG_FLAC_CUE_TRACK flags
#define TAG_FLAC_CUE_TRACK_DATA 1 // data track
#define TAG_FLAC_CUE_TRACK_PRE 2 // pre-emphasis

typedef struct {
char id[4];
DWORD length; // data length
const void *data;
} TAG_FLAC_METADATA;

HSTREAM BASSFLACDEF(BASS_FLAC_StreamCreateFile)(BOOL mem, const void *file, QWORD offset, QWORD length, DWORD flags);
HSTREAM BASSFLACDEF(BASS_FLAC_StreamCreateURL)(const char *url, DWORD offset, DWORD flags, DOWNLOADPROC *proc, void *user);
HSTREAM BASSFLACDEF(BASS_FLAC_StreamCreateFileUser)(DWORD system, DWORD flags, const BASS_FILEPROCS *procs, void *user);

#ifdef __cplusplus
}

#ifdef _WIN32
static inline HSTREAM BASS_FLAC_StreamCreateFile(BOOL mem, const WCHAR *file, QWORD offset, QWORD length, DWORD flags)
{
return BASS_FLAC_StreamCreateFile(mem, (const void*)file, offset, length, flags|BASS_UNICODE);
}

static inline HSTREAM BASS_FLAC_StreamCreateURL(const WCHAR *url, DWORD offset, DWORD flags, DOWNLOADPROC *proc, void *user)
{
return BASS_FLAC_StreamCreateURL((const char*)url, offset, flags|BASS_UNICODE, proc, user);
}
#endif
#endif

#endif
Loading

0 comments on commit 1d76bdc

Please sign in to comment.