CI of Logic from binary.

This commit is contained in:
ApfelTeeSaft
2026-07-09 07:40:42 +02:00
parent 390f5fc2ec
commit 746245c084
50 changed files with 7113 additions and 11 deletions
+13 -3
View File
@@ -1,3 +1,11 @@
# native/CMakeLists.txt - top-level native build for the reconstructed project.
#
# Design:
# * libg -> reconstructed Supercell "Titan" engine (native/src/libg/**) - the big target.
# * libcr -> built from the OWNED source (native/third_party/libcr/**); never decompiled.
# * libfmod-> NOT built here; the official prebuilt arm64/v7a .so is dropped into jniLibs
# (or a compatibility shim in native/compatibility/fmod_shim provides its symbols).
cmake_minimum_required(VERSION 3.22)
project(cr_native LANGUAGES C CXX)
@@ -5,6 +13,7 @@ set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_POSITION_INDEPENDENT_CODE ON)
# ---- libg (reconstructed engine) ----
file(GLOB_RECURSE LIBG_SRC CONFIGURE_DEPENDS
"${CMAKE_CURRENT_SOURCE_DIR}/src/libg/*.c"
"${CMAKE_CURRENT_SOURCE_DIR}/src/libg/*.cpp")
@@ -24,10 +33,10 @@ if(LIBG_SRC)
endif()
endif()
else()
message(STATUS "native: src/libg not populated yet (Phase 7/8). Skipping target 'g'.")
message(STATUS "native: src/libg not populated yet Skipping target 'g'.")
endif()
# libcr is part of a custom shared library from classic royale
# ---- libcr (owned source) ----
file(GLOB_RECURSE LIBCR_SRC CONFIGURE_DEPENDS
"${CMAKE_CURRENT_SOURCE_DIR}/third_party/libcr/*.c"
"${CMAKE_CURRENT_SOURCE_DIR}/third_party/libcr/*.cpp")
@@ -38,9 +47,10 @@ if(LIBCR_SRC)
target_link_libraries(cr PRIVATE log z android m dl)
endif()
else()
message(STATUS "native: third_party/libcr not present yet. Drop the OWNED libcr source here (Phase 12).")
message(STATUS "native: third_party/libcr not present yet. Drop the OWNED libcr source here")
endif()
# ---- optional FMOD compatibility shim (fallback when no licensed FMOD binary) ----
file(GLOB_RECURSE FMOD_SHIM_SRC CONFIGURE_DEPENDS
"${CMAKE_CURRENT_SOURCE_DIR}/compatibility/fmod_shim/*.cpp")
if(FMOD_SHIM_SRC AND NOT EXISTS "${CMAKE_CURRENT_SOURCE_DIR}/third_party/fmod/${ANDROID_ABI}/libfmod.so")
@@ -0,0 +1,12 @@
// fmod_stub.cpp - minimal arm64/v7a stand-in for libfmod.so (audio disabled).
//
// The real FMOD library is proprietary and only shipped as a 32-bit binary in the original APK.
// This stub provides just enough for the APK to LOAD on 64-bit devices: JNI_OnLoad + the two
// org.fmod.MediaCodec native methods the Java side may bind. Audio is silent until the official
// FMOD arm64 build (fetch_fmod.sh) or a real shim is dropped into native/third_party/fmod/.
#include <jni.h>
extern "C" {
jint JNI_OnLoad(JavaVM*, void*) { return JNI_VERSION_1_6; }
JNIEXPORT jlong JNICALL Java_org_fmod_MediaCodec_fmodGetSize(JNIEnv*, jclass, jlong) { return 0; }
JNIEXPORT jint JNICALL Java_org_fmod_MediaCodec_fmodReadAt(JNIEnv*, jclass, jlong, jlong, jbyteArray, jint, jint) { return 0; }
}
+20
View File
@@ -0,0 +1,20 @@
// audio.h - public entry points of libg.so's Titan sound system (FMOD glue).
// Reconstructed for functional equivalence from radare2 disassembly of the original 32-bit libg.so.
// The two functions below back the named JNI exports GameApp.soundSystemStart / soundSystemStop;
// titan_jni.cpp forwards to them so the FMOD dependency stays localized to the audio module.
#pragma once
#include <jni.h>
namespace titan {
// GameApp.soundSystemStart() - Android lifecycle "audio resumed" handler.
// Mutex-guarded; if the FMOD system exists and audio is currently suspended, queries the Java
// side (GameApp.isPlayingUserMusic) and resumes the FMOD mixer. (JNI method is static -> obj is
// the jclass; unused for the static up-call.)
void soundSystemStart(JNIEnv* env, jobject obj);
// GameApp.soundSystemStop() - Android lifecycle "audio paused" handler.
// Mutex-guarded; if the FMOD system exists and is not already suspended, suspends the FMOD mixer.
void soundSystemStop(JNIEnv* env, jobject obj);
} // namespace titan
+61
View File
@@ -0,0 +1,61 @@
// engine.h - interface for the Titan engine core (the reconstruction target inside libg.so).
//
// The JNI boundary (native/src/libg/jni/titan_jni.cpp) forwards lifecycle / input / GL-config calls
// into this interface. The real implementation is recovered from the stripped ARMv7 libg.so.
//
// 64-bit note: the Java side hands the engine a `jlong` handle in createGameMain(...) and
// locationChanged(...). Store native pointers in that jlong (NOT jint) - it is already 64-bit-wide,
// which is what makes this boundary arm64-safe. See analysis/JNI_MAP.md.
#pragma once
#include <jni.h>
#include <cstdint>
#include <string>
namespace titan {
// Pixel/surface configuration the Java GLSurfaceView queries before creating the EGL context.
struct SurfaceConfig {
int surfaceFormat = 4; // getSurfaceFormat() (RGBA_8888-ish; placeholder)
int depthBits = 16; // getDepthBits()
int stencilBits = 8; // getStencilBits()
int allowedRotations = 0;// getAllowedScreenRotations()
};
class Engine {
public:
static Engine& instance();
// Called from JNI_OnLoad; caches the JavaVM for engine->Java up-calls.
void onJniLoad(JavaVM* vm);
// --- lifecycle (GameApp native methods) ---
// createGameMain(AssetManager, docPath, ..., handle, w, h, ...): boots the engine and returns a
// status/config string. Returns "" from the stub. `handle` is the 64-bit native handle carrier.
std::string createGameMain(JNIEnv* env, jobject assetManager,
const std::string& docPath, const std::string& a2,
const std::string& a3, jlong handle,
int w, int h, int i2, int i3);
bool init(int w, int h, const std::string& path);
void start(const std::string& arg);
void stop();
void deinit();
bool update(); // per-frame tick
// --- input ---
void setTouch(int id, int action, int x, int y);
void clearTouches();
// --- GL surface config queries ---
SurfaceConfig surfaceConfig() const;
private:
Engine() = default;
JavaVM* vm_ = nullptr;
bool booted_ = false;
};
} // namespace titan
// Exposed to the JNI layer (defined in titan_jni.cpp): the cached JavaVM.
extern "C" JavaVM* titan_get_vm();
+44
View File
@@ -0,0 +1,44 @@
// engine_structs.h - recovered engine data-structure layouts
//
// Structs are recovered from field-access offsets observed in the disassembly (radare2). Field names
// are mechanical (field_<offset>); only the offsets/sizes are asserted - semantic meaning is inferred
// separately and only when there is evidence. Do NOT assume purpose from these names.
#pragma once
#include <cstdint>
namespace titan {
// struct_unknown_1 - IDENTIFIED (was "unknown state struct"): this is the engine's custom
// **small-string-optimized String** class. The sub_1fe*/sub_1f7*/sub_200*
// cluster are its methods. Evidence:
// * sub_1fe43c zero-inits it -> an empty inline string (null at the inline buffer).
// * sub_1f7160 tests `field_4 + 1 < 9` (i.e. length < 8) -> the **SSO discriminant**.
// * fcn_001f712c (data accessor) returns `isSSO ? &field_8 : *(char**)&field_8`.
// * fcn_00200064 uses `field_4` as the **length** in a memcmp-based match.
// So: field_4 = length; field_8 = the inline SSO buffer OR (when length>=8) a heap `char*`.
//
// ARCH-INDEPENDENT model (function-matching, not byte-matching). The original 32-bit binary unions
// the heap pointer with the inline buffer at +0x08; on arm64 a pointer is 8 bytes, so we model that
// union with correct widths (a truncated int32 pointer would crash on 64-bit). field_0/field_4 keep
// their offsets; the SSO union replaces the +0x08.. bytes. The inline buffer is sized generously
// (holds the original's short strings; only `length < 8` ever uses it - see titan_string_is_sso).
struct struct_unknown_1 {
int32_t field_0; // +0x00 capacity/flags (role TBD; zeroed at init)
int32_t field_4; // +0x04 **length** (chars)
union {
char* heap; // heap buffer when length >= 8
char sso[16]; // inline characters when length < 8
};
};
// String helpers (functional model). isSSO/data() mirror sub_1f7160 / fcn_001f712c exactly.
inline bool titan_string_is_sso(const struct_unknown_1* s) { return s->field_4 < 8; }
inline char* titan_string_data(struct_unknown_1* s) {
return titan_string_is_sso(s) ? s->sso : s->heap;
}
inline const char* titan_string_data(const struct_unknown_1* s) {
return titan_string_is_sso(s) ? s->sso : s->heap;
}
inline int titan_string_length(const struct_unknown_1* s) { return s->field_4; }
} // namespace titan
+82
View File
@@ -0,0 +1,82 @@
// file_handle.h - reconstruction of libg.so's dual-mode file abstraction (Titan engine).
//
// The engine reads data through a single FileHandle that transparently backs onto EITHER a bundled
// APK asset (AAsset*, via the NDK asset manager) OR an external/downloaded file (FILE*, via stdio).
// This matches a Clash-Royale-style client that downloads asset patches to internal storage and
// falls back to the copy bundled in the APK. Every operation branches on which backend is live.
//
// This is shared infrastructure: the audio (FMOD file callbacks), texture/asset loading, and config
// readers all go through it. Reconstructed for functional equivalence from radare2 disassembly of
// the original 32-bit libg.so. Placeholder fcn_<addr> names.
//
// Struct layout recovered from the field accesses across seek/read/getLength/close:
// +0x00 FILE* fp - stdio backend (0 when asset-backed)
// +0x04 AAsset* asset - asset backend (0 when stdio-backed); this pointer is the discriminant
#pragma once
#include <cstdio>
#include <cstddef>
// AAsset/AAssetManager + their C API. On device we use the real NDK header (resolves against
// libandroid.so, already NEEDED); on the host we forward-declare the opaque handles and the four C
// functions so the boundary type-checks without the NDK present.
#if defined(__ANDROID__)
#include <android/asset_manager.h>
#else
extern "C" {
struct AAsset;
struct AAssetManager;
int AAsset_read(AAsset* asset, void* buf, size_t count);
long AAsset_seek(AAsset* asset, long offset, int whence);
long AAsset_getLength(AAsset* asset);
void AAsset_close(AAsset* asset);
AAsset* AAssetManager_open(AAssetManager* mgr, const char* filename, int mode);
}
#endif
namespace titan {
// The dual-mode file handle (8 bytes touched by the reconstructed ops).
struct FileHandle {
FILE* fp; // +0x00 stdio backend
AAsset* asset; // +0x04 asset backend (non-null => asset-backed)
};
// fcn_0022af80 - constructor/reset: zero both backend pointers, return self.
FileHandle* fcn_0022af80(FileHandle* fh);
// fcn_00229484 - read: asset ? AAsset_read(asset, buf, count) : fread(buf, size, count, fp).
// (The asset branch treats `count` as a byte length - callers are byte-oriented, size==1.)
int fcn_00229484(FileHandle* fh, void* buf, unsigned size, unsigned count);
// fcn_0022b2f4 - seek: asset ? AAsset_seek(asset, off, whence) : fseek(fp, off, whence).
long fcn_0022b2f4(FileHandle* fh, long offset, int whence);
// fcn_00229410 - length: asset ? AAsset_getLength(asset) : fstat(fileno(fp)).st_size.
long fcn_00229410(FileHandle* fh);
// fcn_002294e0 - close backends in place: close whichever handle is open and null it.
void fcn_002294e0(FileHandle* fh);
// fcn_0022b204 - close + reset (public close): fcn_002294e0 then fcn_0022af80.
FileHandle* fcn_0022b204(FileHandle* fh);
// fcn_002293dc - is-open predicate: asset ? true : (fp != nullptr).
bool fcn_002293dc(FileHandle* fh);
// fcn_0022af94 - open(path, mode): pick the backend and open. Function-matching reconstruction:
// prefer an external/patched file (fopen) and fall back to the bundled APK asset
// (AAssetManager_open). See file_handle.cpp for why try-external-then-asset yields the original's
// backend selection for real paths.
FileHandle* fcn_0022af94(FileHandle* fh, const char* path, const char* mode);
// fcn_0022b154 - open-wrapper: reset(fh) then open(fh, path, mode).
FileHandle* fcn_0022b154(FileHandle* fh, const char* path, const char* mode);
// fcn_0022b18c - getc(): next byte as int, or -1 (EOF). asset ? AAsset_read(1 byte) : fgetc(fp).
int fcn_0022b18c(FileHandle* fh);
// The engine's global AAssetManager* (obtained via AAssetManager_fromJava in createGameMain). The
// createGameMain reconstruction publishes it here; until then asset opens return null (handled).
void titan_set_asset_manager(AAssetManager* mgr);
} // namespace titan
+44
View File
@@ -0,0 +1,44 @@
// primitives.h - reconstructed core engine primitives of libg.so (Titan).
//
// These are the small utility functions the engine's JNI roots call most often (see CALL_GRAPH.md).
// They are reconstructed for FUNCTIONAL EQUIVALENCE from radare2 evidence (imported symbols + string
// references), not byte-for-byte. Names stay as sub_<addr> placeholders.
//
// sub_20d578 debug mutex LOCK (evidence: pthread_mutex_lock + "Trying to set mutex lock from
// %s but its already locked from %s")
// sub_20d650 debug mutex UNLOCK (evidence: pthread_mutex_unlock + "mutexUnlock called when mutex
// is not even locked")
// sub_20d828 JNI GetMethodID (evidence: string "getJMethod"; JNIEnv vtable deref at +0x14 area)
// sub_2116f4 monotonic time (evidence: clock_gettime)
#pragma once
#include <jni.h>
#include <cstdint>
#include <pthread.h>
namespace titan {
// A debug/owner-tracked recursive-safe mutex, matching the two helpers' observed behaviour
// (warn-on-conflict lock, warn-on-unlocked unlock). The original stores an owner label per mutex.
struct DebugMutex {
pthread_mutex_t m = PTHREAD_MUTEX_INITIALIZER;
const char* owner = nullptr; // caller label of the current holder (TODO: exact storage)
bool locked = false;
};
bool sub_20d578(DebugMutex& mtx, const char* caller = nullptr); // lock; returns acquired (bool)
void sub_20d650(DebugMutex& mtx); // unlock
bool sub_20d62c(DebugMutex& mtx); // lock wrapper returning success bool (&1)
jmethodID sub_20d828(JNIEnv* env, jobject obj, const char* name, const char* sig); // GetMethodID helper
int64_t sub_2116f4(); // monotonic time, nanoseconds
// JNI method-id cache (engine->Java up-call bridge). createGameMain pre-caches ~81 method ids at
// boot via sub_20de14 -> sub_20dbb8 ("cacheJMethod"). Reconstructed for functional equivalence:
// resolve a (static or instance) methodID on a class and store it so up-call sites can retrieve it.
// sub_20dbb8(env, clazz, name, sig, isStatic) cache + return a method id
// sub_20de14(env, clazz, name, sig) wrapper: sub_20dbb8(..., isStatic=true)
jmethodID sub_20dbb8(JNIEnv* env, jclass clazz, const char* name, const char* sig, bool isStatic);
jmethodID sub_20de14(JNIEnv* env, jclass clazz, const char* name, const char* sig);
// Retrieve a previously cached method id (by name+sig), or nullptr.
jmethodID titan_cached_method(const char* name, const char* sig);
} // namespace titan
+20
View File
@@ -0,0 +1,20 @@
// titan_log.h - portable logging.
// On Android it routes to logcat (tag "Titan"); on a host build it goes to stderr, so the
// skeleton can be syntax/host-compiled without the NDK (see tools/scripts/verify_native_host.sh).
#pragma once
#if defined(__ANDROID__)
# include <android/log.h>
# define TITAN_LOGI(...) __android_log_print(ANDROID_LOG_INFO, "Titan", __VA_ARGS__)
# define TITAN_LOGW(...) __android_log_print(ANDROID_LOG_WARN, "Titan", __VA_ARGS__)
# define TITAN_LOGE(...) __android_log_print(ANDROID_LOG_ERROR, "Titan", __VA_ARGS__)
#else
# include <cstdio>
# define TITAN_LOGI(...) do { std::fprintf(stderr, "[Titan][I] "); std::fprintf(stderr, __VA_ARGS__); std::fprintf(stderr, "\n"); } while (0)
# define TITAN_LOGW(...) do { std::fprintf(stderr, "[Titan][W] "); std::fprintf(stderr, __VA_ARGS__); std::fprintf(stderr, "\n"); } while (0)
# define TITAN_LOGE(...) do { std::fprintf(stderr, "[Titan][E] "); std::fprintf(stderr, __VA_ARGS__); std::fprintf(stderr, "\n"); } while (0)
#endif
// Marks a reconstructed function whose behaviour is not yet recovered from the ARMv7 libg.so.
// Deliberately loud (once-per-call) so unreconstructed paths are obvious at runtime.
#define TITAN_TODO(name) TITAN_LOGW("TODO: %s not yet reconstructed (stub)", name)
+90
View File
@@ -0,0 +1,90 @@
// audio.cpp - reconstruction of libg.so's FMOD audio glue (Titan sound system).
// Function-matching reconstruction from radare2 disassembly, built against the real FMOD 1.05.11
// C API the project supplies (native/third_party/fmod).
//
// This module owns the reconstructed audio functions, so it makes the rebuilt libg.so depend on
// libfmod.so (NEEDED) exactly like the original. The two named JNI exports GameApp.soundSystemStart
// and GameApp.soundSystemStop forward here (see titan_jni.cpp); the FMOD::System* setter lets the
// (future) sound-init reconstruction publish the created system so start/stop become live.
#include "fmod.h"
#include "audio.h"
#include "primitives.h"
namespace titan {
// --- Recovered engine audio globals ------------------------------------------------------------
// In the original these are PIC/GOT-relative globals (slots near offsets 0x8dee4 / 0x8dee8 of the
// GOT). Roles recovered from how soundSystemStart/Stop read & write them:
// * g_fmodSystem - the top-level FMOD::System* (== the value passed as `this` to
// mixerResume/mixerSuspend, and the non-null gate both methods check).
// Null until the sound-init path creates it (via fcn_00209968).
// * g_audioSuspended - the "mixer suspended" flag: soundSystemStop sets it, soundSystemStart
// clears it; each method is a no-op if already in the target state.
// * g_userMusicPlaying- last GameApp.isPlayingUserMusic() result, cached on resume.
static FMOD_SYSTEM* g_fmodSystem = nullptr;
static bool g_audioSuspended = false;
static bool g_userMusicPlaying = false;
// The debug mutex guarding the sound lifecycle (soundSystemStart/Stop both lock it with their own
// name as the owner label - see the mutex primitives).
static DebugMutex g_soundMutex;
// fcn_00209968 - thin wrapper over the FMOD C API system factory.
// Disasm (22 bytes): moves its argument into place and tail-calls FMOD_System_Create(outSystem),
// returning its FMOD_RESULT. The engine calls this to obtain the top-level FMOD::System handle
// before initialising the sound system (System::init / setFileSystem / createChannelGroup are
// separate glue functions, reconstructed as the audio subsystem is traced).
FMOD_RESULT fcn_00209968(FMOD_SYSTEM** outSystem) {
return FMOD_System_Create(outSystem);
}
// Publish the created FMOD system so the lifecycle handlers below go live. Until sound-init is
// reconstructed g_fmodSystem stays null and start/stop are safe no-ops (matching a device with no
// audio initialised yet). Kept internal-linkage-free so the init reconstruction can call it.
void titan_set_fmod_system(FMOD_SYSTEM* sys) { g_fmodSystem = sys; }
// fcn_00209980 - the FMOD ERRCHECK helper the sound-init calls after every FMOD API call (29 call
// sites). In this release build it compiled down to a no-op: the disassembly only spills its two
// arguments (the FMOD_RESULT and a context value) to the stack and returns - the error-logging body
// was stripped. Reconstructed as the equivalent no-op so the call sites stay faithful.
void fcn_00209980(FMOD_RESULT /*result*/, int /*context*/) { /* release build: no-op */ }
// Java_com_supercell_titan_GameApp_soundSystemStart @ 0x20a524 (named export).
// Reconstructed control flow:
// lock(mutex,"soundSystemStart"); cache env;
// if (g_fmodSystem && g_audioSuspended) {
// g_userMusicPlaying = GameApp.isPlayingUserMusic(); // static up-call, respects user music
// FMOD mixerResume(g_fmodSystem);
// g_audioSuspended = false;
// }
// if (locked) unlock(mutex);
void soundSystemStart(JNIEnv* env, jobject /*clazz*/) {
const bool locked = sub_20d62c(g_soundMutex);
if (g_fmodSystem && g_audioSuspended) {
// Query the user's own music state so game audio politely resumes around it. The original
// routes this through the engine's cached-method helper; a direct static up-call is
// functionally identical (isPlayingUserMusic is `public static boolean ()Z`).
if (jclass cls = env->FindClass("com/supercell/titan/GameApp")) {
if (jmethodID mid = env->GetStaticMethodID(cls, "isPlayingUserMusic", "()Z"))
g_userMusicPlaying = env->CallStaticBooleanMethod(cls, mid) != JNI_FALSE;
if (env->ExceptionCheck()) env->ExceptionClear();
env->DeleteLocalRef(cls);
}
FMOD_System_MixerResume(g_fmodSystem);
g_audioSuspended = false;
}
if (locked) sub_20d650(g_soundMutex);
}
// Java_com_supercell_titan_GameApp_soundSystemStop @ 0x20a644 (named export).
// Mirror of start: lock; if (g_fmodSystem && !g_audioSuspended) { mixerSuspend; g_audioSuspended = true; } unlock.
void soundSystemStop(JNIEnv* /*env*/, jobject /*clazz*/) {
const bool locked = sub_20d62c(g_soundMutex);
if (g_fmodSystem && !g_audioSuspended) {
FMOD_System_MixerSuspend(g_fmodSystem);
g_audioSuspended = true;
}
if (locked) sub_20d650(g_soundMutex);
}
} // namespace titan
+74
View File
@@ -0,0 +1,74 @@
// fmod_filesystem.cpp - reconstruction of the engine's FMOD file-system callbacks (Titan audio).
//
// SoundSystem::init installs these on the FMOD system via System::setFileSystem so FMOD reads sound
// data through the engine's own dual-mode FileHandle (bundled AAsset | external FILE*) instead of
// stdio. They are thin adapters: each validates the handle and delegates to a FileHandle op
// (file_handle.cpp). Reconstructed for functional equivalence from radare2 disassembly of the
// original 32-bit libg.so; the FMOD_RESULT codes match the original exactly (null handle ->
// FMOD_ERR_INVALID_PARAM 0x1f; short read -> FMOD_ERR_FILE_EOF 0x10).
//
// The open callback (0x209458) allocates+opens a FileHandle and is reconstructed together with
// FileHandle::open (0x22af94) once that backend-picker is finished; these three (read/seek/close)
// build only on the already-reconstructed FileHandle ops.
#include "fmod.h"
#include "file_handle.h"
#include <cstdio> // SEEK_SET
#include <new>
namespace titan {
// fcn_00209458 @0x209458 - FMOD_FILE_OPEN_CALLBACK.
// Disasm: if (!name) { *filesize=0; *handle=0; return FILE_NOTFOUND(0x12); } fh = new FileHandle(8);
// FileHandle::open(fh, name, "rb"); if (isOpen) { *filesize = getLength(fh); *handle = fh; return OK; }
// else { (fh is dropped) *filesize=0; *handle=0; return FILE_NOTFOUND; }. We delete fh on the failure
// path (the original leaks it there) - observably identical (returns not-found), just leak-free.
FMOD_RESULT fcn_00209458(const char* name, unsigned int* filesize, void** handle, void* /*userdata*/) {
if (name) {
FileHandle* fh = new FileHandle;
fcn_0022b154(fh, name, "rb");
if (fcn_002293dc(fh)) { // opened successfully
if (filesize) *filesize = static_cast<unsigned int>(fcn_00229410(fh));
if (handle) *handle = fh;
return FMOD_OK;
}
delete fh;
}
if (filesize) *filesize = 0;
if (handle) *handle = nullptr;
return FMOD_ERR_FILE_NOTFOUND;
}
// fcn_0020953c @0x20953c - FMOD_FILE_READ_CALLBACK.
// Disasm: if (!handle) return INVALID_PARAM; if (bytesread) { n = FileHandle::read(handle, buf, 1,
// sizebytes); *bytesread = n; return n == sizebytes ? OK : FILE_EOF; } return OK.
FMOD_RESULT fcn_0020953c(void* handle, void* buffer, unsigned int sizebytes,
unsigned int* bytesread, void* /*userdata*/) {
if (!handle) return FMOD_ERR_INVALID_PARAM;
if (bytesread) {
int n = fcn_00229484(static_cast<FileHandle*>(handle), buffer, 1, sizebytes);
*bytesread = static_cast<unsigned int>(n);
return (*bytesread == sizebytes) ? FMOD_OK : FMOD_ERR_FILE_EOF;
}
return FMOD_OK;
}
// fcn_002095ac @0x2095ac - FMOD_FILE_SEEK_CALLBACK.
// Disasm: if (!handle) return INVALID_PARAM; FileHandle::seek(handle, pos, SEEK_SET); return OK.
FMOD_RESULT fcn_002095ac(void* handle, unsigned int pos, void* /*userdata*/) {
if (!handle) return FMOD_ERR_INVALID_PARAM;
fcn_0022b2f4(static_cast<FileHandle*>(handle), static_cast<long>(pos), SEEK_SET);
return FMOD_OK;
}
// fcn_002094e0 @0x2094e0 - FMOD_FILE_CLOSE_CALLBACK.
// Disasm: if (!handle) return INVALID_PARAM; FileHandle::close(handle); operator delete(handle);
// return OK. The delete is the counterpart to the open callback's `new FileHandle`.
FMOD_RESULT fcn_002094e0(void* handle, void* /*userdata*/) {
if (!handle) return FMOD_ERR_INVALID_PARAM;
FileHandle* fh = static_cast<FileHandle*>(handle);
fcn_0022b204(fh);
delete fh;
return FMOD_OK;
}
} // namespace titan
+64
View File
@@ -0,0 +1,64 @@
// engine_stub.cpp - TODO-stub implementation of the Titan engine core interface (engine.h).
#include "engine.h"
#include "titan_log.h"
#include "primitives.h"
namespace titan {
// Reconstructed engine-wide debug mutex (guarded by sub_20d578/sub_20d650) and last-frame timestamp.
static DebugMutex g_engineMutex;
static int64_t g_lastFrameNs = 0;
Engine& Engine::instance() {
static Engine e;
return e;
}
void Engine::onJniLoad(JavaVM* vm) {
vm_ = vm;
TITAN_LOGI("Engine::onJniLoad (stub) - JavaVM cached");
}
std::string Engine::createGameMain(JNIEnv* /*env*/, jobject /*assetManager*/,
const std::string& docPath, const std::string& /*a2*/,
const std::string& /*a3*/, jlong /*handle*/,
int w, int h, int /*i2*/, int /*i3*/) {
TITAN_TODO("Engine::createGameMain");
// Reconstructed primitives are live here: guard boot with the engine mutex, seed the frame clock.
sub_20d578(g_engineMutex, "Engine::createGameMain");
TITAN_LOGI("createGameMain(stub): docPath='%s' %dx%d", docPath.c_str(), w, h);
booted_ = true;
g_lastFrameNs = sub_2116f4();
sub_20d650(g_engineMutex);
return std::string(); // original returns a status/config string
}
bool Engine::init(int w, int h, const std::string& /*path*/) {
TITAN_TODO("Engine::init");
(void)w; (void)h;
return booted_;
}
void Engine::start(const std::string& /*arg*/) { TITAN_TODO("Engine::start"); }
void Engine::stop() { TITAN_TODO("Engine::stop"); }
void Engine::deinit() { TITAN_TODO("Engine::deinit"); booted_ = false; }
bool Engine::update() {
// Per-frame tick. Returning true = "keep running". The stub renders nothing, but drives the
// reconstructed monotonic clock (sub_2116f4) the same way the real update() paces frames.
if (booted_) {
const int64_t now = sub_2116f4();
(void)(now - g_lastFrameNs); // frame delta (unused until the renderer is reconstructed)
g_lastFrameNs = now;
}
return booted_;
}
void Engine::setTouch(int /*id*/, int /*action*/, int /*x*/, int /*y*/) { /* TODO: input queue */ }
void Engine::clearTouches() { /* TODO: input queue */ }
SurfaceConfig Engine::surfaceConfig() const {
return SurfaceConfig{}; // sane GLES2 defaults until the real values are recovered
}
} // namespace titan
+101
View File
@@ -0,0 +1,101 @@
// primitives.cpp - functional reconstruction of libg.so's core engine primitives.
// See primitives.h for the radare2 evidence behind each.
// Reconstructed for functional equivalence; internals inferred from imports/strings, not byte-exact.
#include "primitives.h"
#include "titan_log.h"
#include <ctime>
#include <string>
#include <vector>
namespace titan {
// sub_20d578 - debug mutex LOCK; returns whether it acquired (bool).
// Evidence: pthread_mutex_lock + format string "Trying to set mutex lock from %s but its already
// locked from %s". Returns a status the callers use as a bool (see sub_20d62c: `and r0,r0,1`).
bool sub_20d578(DebugMutex& mtx, const char* caller) {
if (mtx.locked && mtx.owner && caller && mtx.owner != caller) {
TITAN_LOGW("Trying to set mutex lock from %s but its already locked from %s",
caller ? caller : "?", mtx.owner);
}
bool ok = (pthread_mutex_lock(&mtx.m) == 0);
mtx.owner = caller;
mtx.locked = true;
return ok;
}
// sub_20d62c - lock wrapper that returns the acquire status as a normalized bool.
// Evidence: calls sub_20d578 then `and r0, r0, 1` on the byte result. Called 9x across the JNI roots.
bool sub_20d62c(DebugMutex& mtx) {
return sub_20d578(mtx) & 1;
}
// sub_20d650 - debug mutex UNLOCK.
// Evidence: pthread_mutex_unlock + "mutexUnlock called when mutex is not even locked".
void sub_20d650(DebugMutex& mtx) {
if (!mtx.locked) {
TITAN_LOGW("mutexUnlock called when mutex is not even locked");
return;
}
mtx.locked = false;
mtx.owner = nullptr;
pthread_mutex_unlock(&mtx.m);
}
// sub_20d828 - JNI GetMethodID helper.
// Evidence: string "getJMethod"; the function dereferences the JNIEnv function table. Functionally
// this resolves a method id (and the original likely logs/caches on failure). TODO: confirm caching
// + whether it uses a cached jclass.
jmethodID sub_20d828(JNIEnv* env, jobject obj, const char* name, const char* sig) {
if (!env || !obj) return nullptr;
jclass cls = env->GetObjectClass(obj);
jmethodID mid = env->GetMethodID(cls, name, sig);
if (!mid) {
TITAN_LOGW("getJMethod: %s%s not found", name ? name : "?", sig ? sig : "");
if (env->ExceptionCheck()) env->ExceptionClear();
}
env->DeleteLocalRef(cls);
return mid;
}
// sub_2116f4 - monotonic timestamp in nanoseconds.
// Evidence: clock_gettime. The engine uses this for frame pacing (called from update()).
int64_t sub_2116f4() {
struct timespec ts;
clock_gettime(CLOCK_MONOTONIC, &ts);
return static_cast<int64_t>(ts.tv_sec) * 1000000000LL + ts.tv_nsec;
}
// --- engine->Java method-id cache (createGameMain pre-caches ~81 up-call method ids) ---
// Evidence: sub_20dbb8 references "cacheJMethod"; sub_20de14 forwards to it with a fixed flag=1.
// Functional reconstruction: resolve a static/instance jmethodID and store it (as a global ref keyed
// by name+sig) so the reconstructed engine->Java up-call sites can look it up. The original indexes
// the cache internally; keying by name+sig here is functionally equivalent for retrieval.
struct CachedMethod { std::string name, sig; jmethodID mid; };
static std::vector<CachedMethod> g_methodCache;
jmethodID sub_20dbb8(JNIEnv* env, jclass clazz, const char* name, const char* sig, bool isStatic) {
if (!env || !clazz || !name || !sig) return nullptr;
jmethodID mid = isStatic ? env->GetStaticMethodID(clazz, name, sig)
: env->GetMethodID(clazz, name, sig);
if (!mid) {
TITAN_LOGW("cacheJMethod: %s%s (%s) not found", name, sig, isStatic ? "static" : "instance");
if (env->ExceptionCheck()) env->ExceptionClear();
return nullptr;
}
g_methodCache.push_back({name, sig, mid});
return mid;
}
// sub_20de14 - the flag=1 wrapper (caches a static method id).
jmethodID sub_20de14(JNIEnv* env, jclass clazz, const char* name, const char* sig) {
return sub_20dbb8(env, clazz, name, sig, /*isStatic=*/true);
}
jmethodID titan_cached_method(const char* name, const char* sig) {
if (!name || !sig) return nullptr;
for (const auto& c : g_methodCache)
if (c.name == name && c.sig == sig) return c.mid;
return nullptr;
}
} // namespace titan
@@ -0,0 +1,27 @@
// sub_1fe_cluster.cpp - reconstruction of the sub_1fe*/sub_1f7* cluster, now IDENTIFIED as the
// engine's custom SSO String class (see STRING_CLASS.md; struct_unknown_1 is the String). These two
// are its default constructor and its SSO discriminant.
// Function-matching reconstruction from radare2 disassembly (not byte-matching). Placeholder names.
#include "engine_structs.h"
namespace titan {
// sub_1fe43c - String default constructor: empty inline (SSO) string. Returns the object (r0
// preserved to return). Disasm zeroes the whole struct; functionally: length 0 + null-terminated
// inline buffer. (Zeroing the union nulls both the heap pointer and the inline buffer's first bytes.)
struct_unknown_1* sub_1fe43c(struct_unknown_1* self) {
self->field_0 = 0;
self->field_4 = 0; // length = 0
self->heap = nullptr;
self->sso[0] = 0; // inline buffer: "" (null at [0])
return self;
}
// sub_1f7160 - String::isSSO. field_4 is the length; returns true iff length < 8, i.e. the characters
// are stored inline (small-string optimization) rather than on the heap. Disasm: r0 = self->field_4;
// r0 += 1; return (r0 < 9). Returns 0/1.
int sub_1f7160(const struct_unknown_1* self) {
return (self->field_4 + 1 < 9) ? 1 : 0;
}
} // namespace titan
+96
View File
@@ -0,0 +1,96 @@
// titan_string.cpp - reconstruction of the engine's custom SSO String class methods.
//
// struct_unknown_1 (engine_structs.h) is the engine's small-string-optimized String: field_4 is the
// length, and field_8 is either the inline SSO buffer (when length < 8) or a heap char* (otherwise).
// See STRING_CLASS.md. Reconstructed for functional equivalence from radare2 disassembly of the
// original 32-bit libg.so. These are foundational: paths, names, and config keys all flow through
// them, so `FileHandle::open`'s backend decision is a set of these String comparisons.
#include "engine_structs.h"
#include <cstring>
#include <new>
namespace titan {
// Forward decl of the default ctor (sub_1fe_cluster.cpp).
struct_unknown_1* sub_1fe43c(struct_unknown_1* self);
int sub_1f7160(const struct_unknown_1* self);
// fcn_001f712c @0x1f712c - String::data(): SSO-aware pointer to the characters.
// Disasm: r = sub_1f7160(this) (1 when SSO); SSO ? return &field_8 (inline) : return *(char**)&field_8.
const char* fcn_001f712c(const struct_unknown_1* self) {
return titan_string_data(self);
}
// fcn_001fe504 @0x1fe504 - String::data() (a second copy the compiler emitted; identical to 0x1f712c):
// isSSO ? inline buffer : heap pointer.
char* fcn_001fe504(struct_unknown_1* self) {
return titan_string_data(self);
}
// fcn_001f7044 @0x1f7044 - String::c_str(): thin wrapper that tail-calls String::data().
const char* fcn_001f7044(struct_unknown_1* self) {
return titan_string_data(self);
}
// fcn_00200064 @0x200064 - String::matchAt(ptr, len, offset): true iff the `len` bytes at `offset`
// equal `ptr`. Disasm: if (length - offset < len) return false; else memcmp(data()+offset, ptr, len)==0.
bool fcn_00200064(const struct_unknown_1* self, const void* ptr, int len, int offset) {
if (titan_string_length(self) - offset < len)
return false;
return std::memcmp(titan_string_data(self) + offset, ptr, static_cast<size_t>(len)) == 0;
}
// fcn_0020010c @0x20010c - String::startsWith(const char* s): matchAt(s, strlen(s), 0).
bool fcn_0020010c(const struct_unknown_1* self, const char* s) {
return fcn_00200064(self, s, static_cast<int>(std::strlen(s)), 0);
}
// fcn_002000d8 @0x2000d8 - String::startsWith(const String& other): matchAt(other.data(), other.length(), 0).
bool fcn_002000d8(const struct_unknown_1* self, const struct_unknown_1* other) {
return fcn_00200064(self, titan_string_data(other), titan_string_length(other), 0);
}
// fcn_001fea7c @0x1fea7c - String::assign(const char* s): set the string to a copy of s.
// Disasm: len = strlen(s); reserve len+1; strncpy(data(), s, len); data()[len] = 0. The reserve step
// picks the SSO inline buffer for short strings (length < 8) or a heap allocation otherwise - the
// same discriminant sub_1f7160 reads back. Modelled arch-independently over the union.
struct_unknown_1* fcn_001fea7c(struct_unknown_1* self, const char* s) {
int len = static_cast<int>(std::strlen(s));
self->field_4 = len; // length
char* dst;
if (titan_string_is_sso(self)) { // length < 8 -> inline
dst = self->sso;
} else { // heap-allocated buffer of len+1
self->heap = static_cast<char*>(::operator new(static_cast<size_t>(len) + 1));
dst = self->heap;
}
std::strncpy(dst, s, static_cast<size_t>(len));
dst[len] = 0;
return self;
}
// fcn_001feb70 @0x1feb70 - String(const char* s): default-construct, then assign(s).
struct_unknown_1* fcn_001feb70(struct_unknown_1* self, const char* s) {
sub_1fe43c(self);
return fcn_001fea7c(self, s);
}
// fcn_001fe9b8 @0x1fe9b8 - ~String(): free the heap buffer if the string is heap-backed, then reset.
// Disasm: if (!isSSO && heap != 0) operator delete(heap); default-ctor(self).
struct_unknown_1* fcn_001fe9b8(struct_unknown_1* self) {
if (!sub_1f7160(self) && self->heap) // sub_1f7160 == isSSO; delete only when heap-backed
::operator delete(self->heap);
return sub_1fe43c(self);
}
// fcn_001feb9c @0x1feb9c - String copy-construct: make dst a copy of src's characters.
// Disasm: reserve dst for src->length+1; strcpy(dst.data(), src.data()); dst->field_0 = src->field_0.
// Assumes dst is freshly default-constructed (copy ctor). Modelled as a content copy via assign;
// field_0 (capacity/flags, role unconfirmed) is copied too, matching the original store.
struct_unknown_1* fcn_001feb9c(struct_unknown_1* dst, const struct_unknown_1* src) {
fcn_001fea7c(dst, titan_string_data(src));
dst->field_0 = src->field_0;
return dst;
}
} // namespace titan
@@ -0,0 +1,37 @@
// vtable_obj_510108.cpp - small standalone engine functions in the 0x2114xx cluster.
//
// CORRECTION (see VTABLE_RECOVERY.md): these were initially grouped as "the methods of the class
// whose vtable is 0x510108", but slot 0 of that vtable is std::bad_exception::~bad_exception()
// (0x3d2770) - i.e. 0x510108 is an STL exception-type vtable, and these 0x2114xx functions are
// adjacent game code, NOT that class's virtuals. The class association is therefore RETRACTED; the
// vtable-recovery methodology needs an STL-vs-game boundary check (a vtable whose slot 0 is a
// std::*::~*() belongs to the runtime, not the engine).
//
// The function BODIES below remain correct - they are read directly from the disassembly and
// reconstructed for functional equivalence. They are simply small standalone helpers of unknown
// role, not a recovered class.
//
// ABI note: the original is armeabi-v7a soft-float, so a `float` argument arrives in r0 (the disasm
// does `vmov s0, r0`); expressed as a normal `float` parameter, the compiler emits the correct ABI
// for both v7a (soft-float) and arm64 (hard-float).
//
// ABI note: the original is armeabi-v7a soft-float, so the `float` argument arrives in r0 (the
// disasm does `vmov s0, r0`); expressed as a normal `float` parameter here, the compiler emits the
// correct ABI for both v7a (soft-float) and arm64 (hard-float).
#include <cstdint>
namespace titan {
// vtable slot -> 0x211420 / 0x211448 (two identical entries): scale the input by 2.
// Disasm: vmov s0, r0; s2 = 2.0f; s0 = s0 * s2; return s0. e.g. radius -> diameter.
float fcn_00211420(float x) { return x * 2.0f; }
float fcn_00211448(float x) { return x * 2.0f; }
// vtable slots -> 0x211484 / 0x211494: no-op hooks (save arg, return). Empty virtual overrides.
void fcn_00211484(void* /*self*/) { }
void fcn_00211494(void* /*self*/) { }
// vtable slot -> 0x2114a4: constant-zero predicate/getter. Disasm: movs r0, 0; return.
int fcn_002114a4(void* /*self*/) { return 0; }
} // namespace titan
+107
View File
@@ -0,0 +1,107 @@
// file_handle.cpp - reconstruction of libg.so's dual-mode file abstraction (see file_handle.h).
// Function-matching reconstruction from radare2 disassembly of the original 32-bit libg.so; each op
// branches on FileHandle::asset exactly like the original (asset-backed vs stdio-backed).
#include "file_handle.h"
#include <sys/stat.h>
#ifndef AASSET_MODE_RANDOM
#define AASSET_MODE_RANDOM 1 // matches <android/asset_manager.h>; defined for the host build too
#endif
namespace titan {
// Engine global: the AAssetManager* the app hands the engine at startup.
static AAssetManager* g_assetManager = nullptr;
void titan_set_asset_manager(AAssetManager* mgr) { g_assetManager = mgr; }
// fcn_0022af80 @0x22af80 (18 B) - ctor/reset: fh->fp = 0; fh->asset = 0; return fh.
FileHandle* fcn_0022af80(FileHandle* fh) {
fh->fp = nullptr;
fh->asset = nullptr;
return fh;
}
// fcn_00229484 @0x229484 (92 B) - read.
int fcn_00229484(FileHandle* fh, void* buf, unsigned size, unsigned count) {
int result;
if (fh->asset)
result = AAsset_read(fh->asset, buf, count); // asset branch: 3-arg AAsset_read(asset,buf,count)
else
result = static_cast<int>(fread(buf, size, count, fh->fp)); // stdio branch: fread(buf,size,count,fp)
return result;
}
// fcn_0022b2f4 @0x22b2f4 (80 B) - seek.
long fcn_0022b2f4(FileHandle* fh, long offset, int whence) {
if (fh->asset)
return AAsset_seek(fh->asset, offset, whence);
return fseek(fh->fp, offset, whence);
}
// fcn_00229410 @0x229410 (208 B) - length.
long fcn_00229410(FileHandle* fh) {
if (fh->asset)
return AAsset_getLength(fh->asset);
struct stat st; // stdio branch: fstat the underlying fd, take st_size
if (fstat(fileno(fh->fp), &st) != 0)
return 0;
return static_cast<long>(st.st_size);
}
// fcn_002294e0 @0x2294e0 (74 B) - close backends in place, nulling each after close.
void fcn_002294e0(FileHandle* fh) {
if (fh->asset) { AAsset_close(fh->asset); fh->asset = nullptr; }
if (fh->fp) { fclose(fh->fp); fh->fp = nullptr; }
}
// fcn_0022b204 @0x22b204 (32 B) - public close: close backends then reset the struct.
FileHandle* fcn_0022b204(FileHandle* fh) {
fcn_002294e0(fh);
return fcn_0022af80(fh);
}
// fcn_002293dc @0x2293dc (52 B) - is-open predicate.
bool fcn_002293dc(FileHandle* fh) {
if (fh->asset) return true;
return fh->fp != nullptr;
}
// fcn_0022af94 @0x22af94 - open(path, mode). FUNCTION-MATCHING reconstruction (not byte): the
// original builds the path and picks fopen vs AAssetManager_open from prefix comparisons against
// runtime dirs. The observable result is: an external/patched file wins over the bundled asset.
// "Try fopen first, fall back to the asset" reproduces that selection for real paths - a relative
// asset path (e.g. "sc/ui.sc") is not present on the filesystem so it falls through to AAsset, while
// an absolute external/cache path is not an asset - so each path resolves to the same backend the
// original chose, with external overriding bundled.
FileHandle* fcn_0022af94(FileHandle* fh, const char* path, const char* mode) {
fcn_0022af80(fh); // reset both backends
if (FILE* f = std::fopen(path, mode ? mode : "rb")) {
fh->fp = f; // external / patched file
return fh;
}
const char* p = path;
while (*p == '/') ++p; // strip leading '/', as the original does
if (g_assetManager)
fh->asset = AAssetManager_open(g_assetManager, p, AASSET_MODE_RANDOM); // bundled APK asset
return fh;
}
// fcn_0022b154 @0x22b154 - open-wrapper: reset then open.
FileHandle* fcn_0022b154(FileHandle* fh, const char* path, const char* mode) {
fcn_0022af80(fh);
return fcn_0022af94(fh, path, mode);
}
// fcn_0022b18c @0x22b18c (152 B) - getc(): read one byte, return it (0..255) or -1 at EOF.
// Disasm: asset ? AAsset_read(asset, &c, 1) : fgetc(fp). fgetc already returns int/EOF; the asset
// branch reads a single byte and reports EOF when nothing was read.
int fcn_0022b18c(FileHandle* fh) {
if (fh->asset) {
unsigned char c;
int n = AAsset_read(fh->asset, &c, 1);
return (n == 1) ? static_cast<int>(c) : -1;
}
return std::fgetc(fh->fp);
}
} // namespace titan
+362
View File
@@ -0,0 +1,362 @@
// titan_jni.cpp - JNI boundary for libg.so (Supercell "Titan" engine).
//
// STATUS: reconstructed JNI SKELETON. All 60 Java_com_supercell_titan_* entry points
// libg.so must export are present with the EXACT signatures the Java side declares, so the rebuilt
// library satisfies name-based JNI binding and the whole APK links + loads. Core GameApp lifecycle/
// input/GL-config calls forward into the titan::Engine interface (engine.h)
#include <jni.h>
#include <string>
#include "titan_log.h"
#include "engine.h"
#include "audio.h" // reconstructed soundSystemStart/Stop (FMOD glue)
static JavaVM* g_vm = nullptr;
extern "C" JavaVM* titan_get_vm() { return g_vm; }
extern "C" {
// JNI_OnLoad - reconstructed (functional). Confirmed against libg.so @0x20de40 (radare2):
// * builds 0x00010006 = JNI_VERSION_1_6 and returns it;
// * calls JavaVM::GetEnv (caches the JavaVM);
// * the original ALSO caches the GameApp jclass + method IDs for engine->Java up-calls (it
// references "backButtonPressed" etc.). Here those are resolved lazily via sub_20d828
// (jniGetMethod); eager pre-caching is deferred until the up-call sites are reconstructed
jint JNI_OnLoad(JavaVM* vm, void* /*reserved*/) {
g_vm = vm;
JNIEnv* env = nullptr;
if (vm->GetEnv(reinterpret_cast<void**>(&env), JNI_VERSION_1_6) != JNI_OK) return JNI_ERR;
TITAN_LOGI("JNI_OnLoad: Titan engine (reconstructed) loaded");
titan::Engine::instance().onJniLoad(vm);
return JNI_VERSION_1_6;
}
// ---- com.supercell.titan.GameApp ----
JNIEXPORT jboolean JNICALL Java_com_supercell_titan_GameApp_backButtonPressed(
JNIEnv* env, jclass clazz) { // ()Z
(void)env; (void)clazz;
TITAN_TODO("Java_com_supercell_titan_GameApp_backButtonPressed");
return JNI_FALSE;
}
JNIEXPORT void JNICALL Java_com_supercell_titan_GameApp_clearTouches(
JNIEnv* env, jclass clazz) { // ()V
(void)clazz; (void)env;
titan::Engine::instance().clearTouches();
}
JNIEXPORT jstring JNICALL Java_com_supercell_titan_GameApp_createGameMain(
JNIEnv* env, jclass clazz, jobject a0, jstring a1, jstring a2, jstring a3, jlong a4, jint a5, jint a6, jint a7, jint a8) { // (Landroid/content/res/AssetManager;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;JIIII)Ljava/lang/String;
(void)clazz; (void)env;
// (AssetManager, docPath, a2, a3, handle, w, h, i2, i3) -> status string
const char* doc = a1 ? env->GetStringUTFChars(a1, nullptr) : "";
const char* s2 = a2 ? env->GetStringUTFChars(a2, nullptr) : "";
const char* s3 = a3 ? env->GetStringUTFChars(a3, nullptr) : "";
std::string status = titan::Engine::instance().createGameMain(env, a0, doc?doc:"", s2?s2:"", s3?s3:"", a4, a5, a6, a7, a8);
if (a1 && doc) env->ReleaseStringUTFChars(a1, doc);
if (a2 && s2) env->ReleaseStringUTFChars(a2, s2);
if (a3 && s3) env->ReleaseStringUTFChars(a3, s3);
return env->NewStringUTF(status.c_str());
}
JNIEXPORT void JNICALL Java_com_supercell_titan_GameApp_deinit(
JNIEnv* env, jclass clazz) { // ()V
(void)clazz; (void)env;
titan::Engine::instance().deinit();
}
JNIEXPORT void JNICALL Java_com_supercell_titan_GameApp_dialogDismissed(
JNIEnv* env, jclass clazz, jint a0, jint a1) { // (II)V
(void)env; (void)clazz; (void)a0; (void)a1;
TITAN_TODO("Java_com_supercell_titan_GameApp_dialogDismissed");
}
JNIEXPORT jint JNICALL Java_com_supercell_titan_GameApp_getAllowedScreenRotations(
JNIEnv* env, jclass clazz) { // ()I
(void)clazz; (void)env;
return titan::Engine::instance().surfaceConfig().allowedRotations;
}
JNIEXPORT jint JNICALL Java_com_supercell_titan_GameApp_getDepthBits(
JNIEnv* env, jclass clazz) { // ()I
(void)clazz; (void)env;
return titan::Engine::instance().surfaceConfig().depthBits;
}
JNIEXPORT jstring JNICALL Java_com_supercell_titan_GameApp_getFontPath(
JNIEnv* env, jclass clazz, jstring a0) { // (Ljava/lang/String;)Ljava/lang/String;
(void)env; (void)clazz; (void)a0;
TITAN_TODO("Java_com_supercell_titan_GameApp_getFontPath");
return nullptr;
}
JNIEXPORT jint JNICALL Java_com_supercell_titan_GameApp_getStencilBits(
JNIEnv* env, jclass clazz) { // ()I
(void)clazz; (void)env;
return titan::Engine::instance().surfaceConfig().stencilBits;
}
JNIEXPORT jint JNICALL Java_com_supercell_titan_GameApp_getSurfaceFormat(
JNIEnv* env, jclass clazz) { // ()I
(void)clazz; (void)env;
return titan::Engine::instance().surfaceConfig().surfaceFormat;
}
JNIEXPORT void JNICALL Java_com_supercell_titan_GameApp_handleDeeplinkURL(
JNIEnv* env, jclass clazz, jstring a0) { // (Ljava/lang/String;)V
(void)env; (void)clazz; (void)a0;
TITAN_TODO("Java_com_supercell_titan_GameApp_handleDeeplinkURL");
}
JNIEXPORT jboolean JNICALL Java_com_supercell_titan_GameApp_init(
JNIEnv* env, jclass clazz, jint a0, jint a1, jstring a2) { // (IILjava/lang/String;)Z
(void)clazz; (void)env;
const char* p = a2 ? env->GetStringUTFChars(a2, nullptr) : "";
bool ok = titan::Engine::instance().init(a0, a1, p ? p : "");
if (a2 && p) env->ReleaseStringUTFChars(a2, p);
return ok ? JNI_TRUE : JNI_FALSE;
}
JNIEXPORT void JNICALL Java_com_supercell_titan_GameApp_inputKeyboardDismissed(
JNIEnv* env, jclass clazz) { // ()V
(void)env; (void)clazz;
TITAN_TODO("Java_com_supercell_titan_GameApp_inputKeyboardDismissed");
}
JNIEXPORT void JNICALL Java_com_supercell_titan_GameApp_inputOkPressed(
JNIEnv* env, jclass clazz) { // ()V
(void)env; (void)clazz;
TITAN_TODO("Java_com_supercell_titan_GameApp_inputOkPressed");
}
JNIEXPORT void JNICALL Java_com_supercell_titan_GameApp_inputSelectionChanged(
JNIEnv* env, jclass clazz, jint a0, jint a1) { // (II)V
(void)env; (void)clazz; (void)a0; (void)a1;
TITAN_TODO("Java_com_supercell_titan_GameApp_inputSelectionChanged");
}
JNIEXPORT void JNICALL Java_com_supercell_titan_GameApp_inputTextChanged(
JNIEnv* env, jclass clazz, jstring a0) { // (Ljava/lang/String;)V
(void)env; (void)clazz; (void)a0;
TITAN_TODO("Java_com_supercell_titan_GameApp_inputTextChanged");
}
JNIEXPORT void JNICALL Java_com_supercell_titan_GameApp_keyboardSizeChanged(
JNIEnv* env, jclass clazz, jfloat a0, jfloat a1) { // (FF)V
(void)env; (void)clazz; (void)a0; (void)a1;
TITAN_TODO("Java_com_supercell_titan_GameApp_keyboardSizeChanged");
}
JNIEXPORT void JNICALL Java_com_supercell_titan_GameApp_logDebuggerException(
JNIEnv* env, jclass clazz, jstring a0) { // (Ljava/lang/String;)V
(void)env; (void)clazz; (void)a0;
TITAN_TODO("Java_com_supercell_titan_GameApp_logDebuggerException");
}
JNIEXPORT void JNICALL Java_com_supercell_titan_GameApp_setPushNotificationValues(
JNIEnv* env, jclass clazz, jint a0, jstring a1, jstring a2) { // (ILjava/lang/String;Ljava/lang/String;)V
(void)env; (void)clazz; (void)a0; (void)a1; (void)a2;
TITAN_TODO("Java_com_supercell_titan_GameApp_setPushNotificationValues");
}
JNIEXPORT void JNICALL Java_com_supercell_titan_GameApp_setTencentDiffLogin(
JNIEnv* env, jclass clazz) { // ()V
(void)env; (void)clazz;
TITAN_TODO("Java_com_supercell_titan_GameApp_setTencentDiffLogin");
}
JNIEXPORT void JNICALL Java_com_supercell_titan_GameApp_setTencentLaunchParameter(
JNIEnv* env, jclass clazz, jstring a0, jint a1, jstring a2) { // (Ljava/lang/String;ILjava/lang/String;)V
(void)env; (void)clazz; (void)a0; (void)a1; (void)a2;
TITAN_TODO("Java_com_supercell_titan_GameApp_setTencentLaunchParameter");
}
JNIEXPORT void JNICALL Java_com_supercell_titan_GameApp_setTencentLoggedOut(
JNIEnv* env, jclass clazz, jint a0) { // (I)V
(void)env; (void)clazz; (void)a0;
TITAN_TODO("Java_com_supercell_titan_GameApp_setTencentLoggedOut");
}
JNIEXPORT void JNICALL Java_com_supercell_titan_GameApp_setTencentLogin(
JNIEnv* env, jclass clazz, jstring a0, jstring a1, jint a2) { // (Ljava/lang/String;Ljava/lang/String;I)V
(void)env; (void)clazz; (void)a0; (void)a1; (void)a2;
TITAN_TODO("Java_com_supercell_titan_GameApp_setTencentLogin");
}
JNIEXPORT void JNICALL Java_com_supercell_titan_GameApp_setTencentShareResult(
JNIEnv* env, jclass clazz, jint a0) { // (I)V
(void)env; (void)clazz; (void)a0;
TITAN_TODO("Java_com_supercell_titan_GameApp_setTencentShareResult");
}
JNIEXPORT void JNICALL Java_com_supercell_titan_GameApp_setTencentUserInfo(
JNIEnv* env, jclass clazz, jstring a0) { // (Ljava/lang/String;)V
(void)env; (void)clazz; (void)a0;
TITAN_TODO("Java_com_supercell_titan_GameApp_setTencentUserInfo");
}
JNIEXPORT void JNICALL Java_com_supercell_titan_GameApp_setTencentWaiting(
JNIEnv* env, jclass clazz, jboolean a0) { // (Z)V
(void)env; (void)clazz; (void)a0;
TITAN_TODO("Java_com_supercell_titan_GameApp_setTencentWaiting");
}
JNIEXPORT void JNICALL Java_com_supercell_titan_GameApp_setTouch(
JNIEnv* env, jclass clazz, jint a0, jint a1, jint a2, jint a3) { // (IIII)V
(void)clazz; (void)env;
titan::Engine::instance().setTouch(a0, a1, a2, a3);
}
JNIEXPORT void JNICALL Java_com_supercell_titan_GameApp_soundSystemStart(
JNIEnv* env, jclass clazz) { // ()V
titan::soundSystemStart(env, clazz); // reconstructed FMOD mixer-resume (audio.cpp)
}
JNIEXPORT void JNICALL Java_com_supercell_titan_GameApp_soundSystemStop(
JNIEnv* env, jclass clazz) { // ()V
titan::soundSystemStop(env, clazz); // reconstructed FMOD mixer-suspend (audio.cpp)
}
JNIEXPORT void JNICALL Java_com_supercell_titan_GameApp_start(
JNIEnv* env, jclass clazz, jstring a0) { // (Ljava/lang/String;)V
(void)clazz; (void)env;
const char* s = a0 ? env->GetStringUTFChars(a0, nullptr) : "";
titan::Engine::instance().start(s ? s : "");
if (a0 && s) env->ReleaseStringUTFChars(a0, s);
}
JNIEXPORT void JNICALL Java_com_supercell_titan_GameApp_stop(
JNIEnv* env, jclass clazz) { // ()V
(void)clazz; (void)env;
titan::Engine::instance().stop();
}
JNIEXPORT jboolean JNICALL Java_com_supercell_titan_GameApp_update(
JNIEnv* env, jclass clazz) { // ()Z
(void)clazz; (void)env;
return titan::Engine::instance().update() ? JNI_TRUE : JNI_FALSE;
}
// ---- com.supercell.titan.GoogleServiceClient ----
JNIEXPORT void JNICALL Java_com_supercell_titan_GoogleServiceClient_onSignIn(
JNIEnv* env, jclass clazz) { // ()V
(void)env; (void)clazz;
TITAN_TODO("Java_com_supercell_titan_GoogleServiceClient_onSignIn");
}
JNIEXPORT void JNICALL Java_com_supercell_titan_GoogleServiceClient_onSignInCanceled(
JNIEnv* env, jclass clazz) { // ()V
(void)env; (void)clazz;
TITAN_TODO("Java_com_supercell_titan_GoogleServiceClient_onSignInCanceled");
}
JNIEXPORT void JNICALL Java_com_supercell_titan_GoogleServiceClient_onSignInFailed(
JNIEnv* env, jclass clazz) { // ()V
(void)env; (void)clazz;
TITAN_TODO("Java_com_supercell_titan_GoogleServiceClient_onSignInFailed");
}
JNIEXPORT void JNICALL Java_com_supercell_titan_GoogleServiceClient_onSignOut(
JNIEnv* env, jclass clazz) { // ()V
(void)env; (void)clazz;
TITAN_TODO("Java_com_supercell_titan_GoogleServiceClient_onSignOut");
}
JNIEXPORT void JNICALL Java_com_supercell_titan_GoogleServiceClient_updateNativeInstance(
JNIEnv* env, jclass clazz, jobject a0) { // (Lcom/supercell/titan/GoogleServiceClient;)V
(void)env; (void)clazz; (void)a0;
TITAN_TODO("Java_com_supercell_titan_GoogleServiceClient_updateNativeInstance");
}
// ---- com.supercell.titan.LocationService ----
JNIEXPORT void JNICALL Java_com_supercell_titan_LocationService_locationChanged(
JNIEnv* env, jclass clazz, jlong a0, jdouble a1, jdouble a2) { // (JDD)V
(void)env; (void)clazz; (void)a0; (void)a1; (void)a2;
TITAN_TODO("Java_com_supercell_titan_LocationService_locationChanged");
}
// ---- com.supercell.titan.NativeFacebookManager ----
JNIEXPORT void JNICALL Java_com_supercell_titan_NativeFacebookManager_facebookFriends(
JNIEnv* env, jclass clazz, jstring a0) { // (Ljava/lang/String;)V
(void)env; (void)clazz; (void)a0;
TITAN_TODO("Java_com_supercell_titan_NativeFacebookManager_facebookFriends");
}
JNIEXPORT void JNICALL Java_com_supercell_titan_NativeFacebookManager_facebookLinkStatistics(
JNIEnv* env, jclass clazz, jboolean a0, jint a1, jstring a2) { // (ZILjava/lang/String;)V
(void)env; (void)clazz; (void)a0; (void)a1; (void)a2;
TITAN_TODO("Java_com_supercell_titan_NativeFacebookManager_facebookLinkStatistics");
}
JNIEXPORT void JNICALL Java_com_supercell_titan_NativeFacebookManager_facebookLogged(
JNIEnv* env, jclass clazz, jstring a0, jstring a1) { // (Ljava/lang/String;Ljava/lang/String;)V
(void)env; (void)clazz; (void)a0; (void)a1;
TITAN_TODO("Java_com_supercell_titan_NativeFacebookManager_facebookLogged");
}
JNIEXPORT void JNICALL Java_com_supercell_titan_NativeFacebookManager_facebookLoginFailedWithError(
JNIEnv* env, jclass clazz, jstring a0, jstring a1) { // (Ljava/lang/String;Ljava/lang/String;)V
(void)env; (void)clazz; (void)a0; (void)a1;
TITAN_TODO("Java_com_supercell_titan_NativeFacebookManager_facebookLoginFailedWithError");
}
JNIEXPORT void JNICALL Java_com_supercell_titan_NativeFacebookManager_facebookLogout(
JNIEnv* env, jclass clazz) { // ()V
(void)env; (void)clazz;
TITAN_TODO("Java_com_supercell_titan_NativeFacebookManager_facebookLogout");
}
JNIEXPORT void JNICALL Java_com_supercell_titan_NativeFacebookManager_facebookReceivedAppRequest(
JNIEnv* env, jclass clazz, jstring a0) { // (Ljava/lang/String;)V
(void)env; (void)clazz; (void)a0;
TITAN_TODO("Java_com_supercell_titan_NativeFacebookManager_facebookReceivedAppRequest");
}
JNIEXPORT void JNICALL Java_com_supercell_titan_NativeFacebookManager_facebookSentAppRequest(
JNIEnv* env, jclass clazz, jstring a0, jstring a1) { // (Ljava/lang/String;Ljava/lang/String;)V
(void)env; (void)clazz; (void)a0; (void)a1;
TITAN_TODO("Java_com_supercell_titan_NativeFacebookManager_facebookSentAppRequest");
}
JNIEXPORT void JNICALL Java_com_supercell_titan_NativeFacebookManager_facebookUserInfo(
JNIEnv* env, jclass clazz, jstring a0) { // (Ljava/lang/String;)V
(void)env; (void)clazz; (void)a0;
TITAN_TODO("Java_com_supercell_titan_NativeFacebookManager_facebookUserInfo");
}
// ---- com.supercell.titan.NativeHTTPClientManager ----
JNIEXPORT void JNICALL Java_com_supercell_titan_NativeHTTPClientManager_getFinished(
JNIEnv* env, jclass clazz, jboolean a0, jint a1, jbyteArray a2, jint a3) { // (ZI[BI)V
(void)env; (void)clazz; (void)a0; (void)a1; (void)a2; (void)a3;
TITAN_TODO("Java_com_supercell_titan_NativeHTTPClientManager_getFinished");
}
JNIEXPORT void JNICALL Java_com_supercell_titan_NativeHTTPClientManager_postFinished(
JNIEnv* env, jclass clazz, jboolean a0, jint a1, jbyteArray a2, jint a3) { // (ZI[BI)V
(void)env; (void)clazz; (void)a0; (void)a1; (void)a2; (void)a3;
TITAN_TODO("Java_com_supercell_titan_NativeHTTPClientManager_postFinished");
}
// ---- com.supercell.titan.PurchaseManager ----
JNIEXPORT void JNICALL Java_com_supercell_titan_PurchaseManager_billingKunlunPurchaseWindowClosed(
JNIEnv* env, jclass clazz, jstring a0, jstring a1, jint a2) { // (Ljava/lang/String;Ljava/lang/String;I)V
(void)env; (void)clazz; (void)a0; (void)a1; (void)a2;
TITAN_TODO("Java_com_supercell_titan_PurchaseManager_billingKunlunPurchaseWindowClosed");
}
JNIEXPORT void JNICALL Java_com_supercell_titan_PurchaseManager_billingProductBought(
JNIEnv* env, jclass clazz, jstring a0, jstring a1, jstring a2, jstring a3, jstring a4, jboolean a5) { // (Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Z)V
(void)env; (void)clazz; (void)a0; (void)a1; (void)a2; (void)a3; (void)a4; (void)a5;
TITAN_TODO("Java_com_supercell_titan_PurchaseManager_billingProductBought");
}
JNIEXPORT void JNICALL Java_com_supercell_titan_PurchaseManager_billingProductCanceled(
JNIEnv* env, jclass clazz, jstring a0) { // (Ljava/lang/String;)V
(void)env; (void)clazz; (void)a0;
TITAN_TODO("Java_com_supercell_titan_PurchaseManager_billingProductCanceled");
}
JNIEXPORT void JNICALL Java_com_supercell_titan_PurchaseManager_billingProductFailed(
JNIEnv* env, jclass clazz, jstring a0, jstring a1, jint a2) { // (Ljava/lang/String;Ljava/lang/String;I)V
(void)env; (void)clazz; (void)a0; (void)a1; (void)a2;
TITAN_TODO("Java_com_supercell_titan_PurchaseManager_billingProductFailed");
}
JNIEXPORT void JNICALL Java_com_supercell_titan_PurchaseManager_billingSetMarketplace(
JNIEnv* env, jclass clazz, jstring a0) { // (Ljava/lang/String;)V
(void)env; (void)clazz; (void)a0;
TITAN_TODO("Java_com_supercell_titan_PurchaseManager_billingSetMarketplace");
}
JNIEXPORT void JNICALL Java_com_supercell_titan_PurchaseManager_sendPurchasingEvent(
JNIEnv* env, jclass clazz, jstring a0) { // (Ljava/lang/String;)V
(void)env; (void)clazz; (void)a0;
TITAN_TODO("Java_com_supercell_titan_PurchaseManager_sendPurchasingEvent");
}
JNIEXPORT void JNICALL Java_com_supercell_titan_PurchaseManager_updateBillingProductDetails(
JNIEnv* env, jclass clazz, jstring a0, jstring a1, jint a2) { // (Ljava/lang/String;Ljava/lang/String;I)V
(void)env; (void)clazz; (void)a0; (void)a1; (void)a2;
TITAN_TODO("Java_com_supercell_titan_PurchaseManager_updateBillingProductDetails");
}
// ---- com.supercell.titan.TitanWebView ----
JNIEXPORT void JNICALL Java_com_supercell_titan_TitanWebView_onPageFinished(
JNIEnv* env, jclass clazz, jstring a0) { // (Ljava/lang/String;)V
(void)env; (void)clazz; (void)a0;
TITAN_TODO("Java_com_supercell_titan_TitanWebView_onPageFinished");
}
JNIEXPORT void JNICALL Java_com_supercell_titan_TitanWebView_onPageStarted(
JNIEnv* env, jclass clazz, jstring a0) { // (Ljava/lang/String;)V
(void)env; (void)clazz; (void)a0;
TITAN_TODO("Java_com_supercell_titan_TitanWebView_onPageStarted");
}
JNIEXPORT void JNICALL Java_com_supercell_titan_TitanWebView_onReceivedError(
JNIEnv* env, jclass clazz, jstring a0) { // (Ljava/lang/String;)V
(void)env; (void)clazz; (void)a0;
TITAN_TODO("Java_com_supercell_titan_TitanWebView_onReceivedError");
}
JNIEXPORT void JNICALL Java_com_supercell_titan_TitanWebView_onSwipeRight(
JNIEnv* env, jclass clazz) { // ()V
(void)env; (void)clazz;
TITAN_TODO("Java_com_supercell_titan_TitanWebView_onSwipeRight");
}
JNIEXPORT jboolean JNICALL Java_com_supercell_titan_TitanWebView_shouldOverrideUrlLoading(
JNIEnv* env, jclass clazz, jstring a0) { // (Ljava/lang/String;)Z
(void)env; (void)clazz; (void)a0;
TITAN_TODO("Java_com_supercell_titan_TitanWebView_shouldOverrideUrlLoading");
return JNI_FALSE;
}
} // extern "C"
+121
View File
@@ -0,0 +1,121 @@
// test_reconstruction.cpp - behavioral tests for the reconstructed libg native code.
//
// Compiled for the HOST (x86_64) and run directly. Because the reconstruction is arch-independent
// C++, this exercises the exact logic that ships in the arm64/v7a .so - so it validates the
// *function-matching* claim behaviourally, not just that the code compiles. Covers the String class
// (SSO + heap) and the dual-mode FileHandle (stdio backend; the AAsset backend needs a device).
#include "engine_structs.h"
#include "file_handle.h"
#include <cstdio>
#include <cstring>
#include <cstdlib>
using namespace titan;
// Host stubs for the NDK AAsset C API. These tests exercise the stdio (FILE*) backend only, so the
// asset branch is never taken; the stubs merely satisfy the linker (on device these live in
// libandroid.so). Signatures must match the forward declarations in file_handle.h.
extern "C" {
int AAsset_read(AAsset*, void*, size_t) { return -1; }
long AAsset_seek(AAsset*, long, int) { return -1; }
long AAsset_getLength(AAsset*) { return 0; }
void AAsset_close(AAsset*) {}
AAsset* AAssetManager_open(AAssetManager*, const char*, int) { return nullptr; }
}
// Reconstructed String methods (defined in titan_string.cpp / sub_1fe_cluster.cpp).
namespace titan {
struct_unknown_1* sub_1fe43c(struct_unknown_1*);
int sub_1f7160(const struct_unknown_1*);
const char* fcn_001f712c(const struct_unknown_1*);
bool fcn_00200064(const struct_unknown_1*, const void*, int, int);
bool fcn_0020010c(const struct_unknown_1*, const char*);
bool fcn_002000d8(const struct_unknown_1*, const struct_unknown_1*);
struct_unknown_1* fcn_001fea7c(struct_unknown_1*, const char*);
struct_unknown_1* fcn_001feb70(struct_unknown_1*, const char*);
struct_unknown_1* fcn_001fe9b8(struct_unknown_1*);
struct_unknown_1* fcn_001feb9c(struct_unknown_1*, const struct_unknown_1*);
const char* fcn_001f7044(struct_unknown_1*);
}
static int g_fail = 0, g_pass = 0;
#define CHECK(cond, msg) do { if (cond) { ++g_pass; } else { ++g_fail; \
std::printf(" FAIL: %s\n", msg); } } while (0)
static void test_string_sso() {
std::printf("[String] short string (SSO path)\n");
struct_unknown_1 s;
fcn_001feb70(&s, "hello"); // String("hello")
CHECK(titan_string_length(&s) == 5, "length==5");
CHECK(sub_1f7160(&s) == 1, "isSSO (len<8)");
CHECK(std::strcmp(fcn_001f712c(&s), "hello") == 0, "data()==\"hello\"");
CHECK(std::strcmp(fcn_001f7044(&s), "hello") == 0, "c_str()==\"hello\"");
CHECK(fcn_0020010c(&s, "he") == true, "startsWith(\"he\")");
CHECK(fcn_0020010c(&s, "xy") == false, "!startsWith(\"xy\")");
CHECK(fcn_00200064(&s, "ll", 2, 2) == true, "matchAt(2,\"ll\")");
fcn_001fe9b8(&s); // ~String (no heap to free)
}
static void test_string_heap() {
std::printf("[String] long string (heap path)\n");
struct_unknown_1 s;
const char* L = "this_is_a_long_string_over_8_chars";
fcn_001feb70(&s, L);
CHECK(titan_string_length(&s) == (int)std::strlen(L), "length matches");
CHECK(sub_1f7160(&s) == 0, "!isSSO (len>=8 -> heap)");
CHECK(std::strcmp(fcn_001f712c(&s), L) == 0, "heap data() matches");
CHECK(fcn_0020010c(&s, "this_is") == true, "startsWith prefix");
struct_unknown_1 c; // copy-ctor
sub_1fe43c(&c);
fcn_001feb9c(&c, &s);
CHECK(std::strcmp(fcn_001f712c(&c), L) == 0, "copy has same content");
CHECK(fcn_002000d8(&s, &c) == true, "startsWith(String copy)");
fcn_001fe9b8(&c);
fcn_001fe9b8(&s); // frees heap (no crash / leak-clean)
std::printf(" (heap alloc/free exercised)\n");
}
static void test_filehandle_stdio() {
std::printf("[FileHandle] stdio backend (read/seek/getLength/getc/close)\n");
char tmpl[] = "/tmp/titan_fh_XXXXXX";
int fd = mkstemp(tmpl);
CHECK(fd >= 0, "temp file created");
const char* payload = "Hello\nWorld"; // 11 bytes
FILE* w = fdopen(fd, "wb"); std::fwrite(payload, 1, 11, w); std::fclose(w);
FileHandle fh;
fcn_0022af94(&fh, tmpl, "rb"); // open (falls to fopen: real file)
CHECK(fcn_002293dc(&fh) == true, "isOpen after open");
CHECK(fh.fp != nullptr && fh.asset == nullptr, "stdio backend selected");
CHECK(fcn_00229410(&fh) == 11, "getLength==11");
char buf[6] = {0};
int n = fcn_00229484(&fh, buf, 1, 5); // read 5 bytes
CHECK(n == 5 && std::memcmp(buf, "Hello", 5) == 0, "read 5 == \"Hello\"");
fcn_0022b2f4(&fh, 6, SEEK_SET); // seek past the '\n'
CHECK(fcn_0022b18c(&fh) == 'W', "getc after seek == 'W'");
fcn_002294e0(&fh); // closeImpl
CHECK(fh.fp == nullptr, "fp nulled after close");
std::remove(tmpl);
}
static void test_filehandle_missing() {
std::printf("[FileHandle] missing file (no backend, isOpen false)\n");
FileHandle fh;
fcn_0022af94(&fh, "/no/such/titan/path.dat", "rb"); // fopen fails; no asset mgr -> nothing
CHECK(fcn_002293dc(&fh) == false, "isOpen false for missing file");
fcn_0022b204(&fh); // close+reset is safe on empty
}
int main() {
std::printf("== reconstructed libg behavioral tests ==\n");
test_string_sso();
test_string_heap();
test_filehandle_stdio();
test_filehandle_missing();
std::printf("\n== %d passed, %d failed ==\n", g_pass, g_fail);
return g_fail == 0 ? 0 : 1;
}
Binary file not shown.
Binary file not shown.
+717
View File
@@ -0,0 +1,717 @@
/*$ preserve start $*/
/* ======================================================================================== */
/* FMOD Studio Low Level API - C header file. */
/* Copyright (c), Firelight Technologies Pty, Ltd. 2012-2015. */
/* */
/* Use this header in conjunction with fmod_common.h (which contains all the constants / */
/* callbacks) to develop using C interface. */
/* ======================================================================================== */
#ifndef _FMOD_H
#define _FMOD_H
#include "fmod_common.h"
/* ========================================================================================== */
/* FUNCTION PROTOTYPES */
/* ========================================================================================== */
#ifdef __cplusplus
extern "C"
{
#endif
/*
FMOD global system functions (optional).
*/
FMOD_RESULT F_API FMOD_Memory_Initialize (void *poolmem, int poollen, FMOD_MEMORY_ALLOC_CALLBACK useralloc, FMOD_MEMORY_REALLOC_CALLBACK userrealloc, FMOD_MEMORY_FREE_CALLBACK userfree, FMOD_MEMORY_TYPE memtypeflags);
FMOD_RESULT F_API FMOD_Memory_GetStats (int *currentalloced, int *maxalloced, FMOD_BOOL blocking);
FMOD_RESULT F_API FMOD_Debug_Initialize (FMOD_DEBUG_FLAGS flags, FMOD_DEBUG_MODE mode, FMOD_DEBUG_CALLBACK callback, const char *filename);
FMOD_RESULT F_API FMOD_File_SetDiskBusy (int busy);
FMOD_RESULT F_API FMOD_File_GetDiskBusy (int *busy);
/*
FMOD System factory functions. Use this to create an FMOD System Instance. below you will see FMOD_System_Init/Close to get started.
*/
FMOD_RESULT F_API FMOD_System_Create (FMOD_SYSTEM **system);
FMOD_RESULT F_API FMOD_System_Release (FMOD_SYSTEM *system);
/*$ preserve end $*/
/*
'System' API
*/
/*
Setup functions.
*/
FMOD_RESULT F_API FMOD_System_SetOutput (FMOD_SYSTEM *system, FMOD_OUTPUTTYPE output);
FMOD_RESULT F_API FMOD_System_GetOutput (FMOD_SYSTEM *system, FMOD_OUTPUTTYPE *output);
FMOD_RESULT F_API FMOD_System_GetNumDrivers (FMOD_SYSTEM *system, int *numdrivers);
FMOD_RESULT F_API FMOD_System_GetDriverInfo (FMOD_SYSTEM *system, int id, char *name, int namelen, FMOD_GUID *guid, int *systemrate, FMOD_SPEAKERMODE *speakermode, int *speakermodechannels);
FMOD_RESULT F_API FMOD_System_SetDriver (FMOD_SYSTEM *system, int driver);
FMOD_RESULT F_API FMOD_System_GetDriver (FMOD_SYSTEM *system, int *driver);
FMOD_RESULT F_API FMOD_System_SetSoftwareChannels (FMOD_SYSTEM *system, int numsoftwarechannels);
FMOD_RESULT F_API FMOD_System_GetSoftwareChannels (FMOD_SYSTEM *system, int *numsoftwarechannels);
FMOD_RESULT F_API FMOD_System_SetSoftwareFormat (FMOD_SYSTEM *system, int samplerate, FMOD_SPEAKERMODE speakermode, int numrawspeakers);
FMOD_RESULT F_API FMOD_System_GetSoftwareFormat (FMOD_SYSTEM *system, int *samplerate, FMOD_SPEAKERMODE *speakermode, int *numrawspeakers);
FMOD_RESULT F_API FMOD_System_SetDSPBufferSize (FMOD_SYSTEM *system, unsigned int bufferlength, int numbuffers);
FMOD_RESULT F_API FMOD_System_GetDSPBufferSize (FMOD_SYSTEM *system, unsigned int *bufferlength, int *numbuffers);
FMOD_RESULT F_API FMOD_System_SetFileSystem (FMOD_SYSTEM *system, FMOD_FILE_OPEN_CALLBACK useropen, FMOD_FILE_CLOSE_CALLBACK userclose, FMOD_FILE_READ_CALLBACK userread, FMOD_FILE_SEEK_CALLBACK userseek, FMOD_FILE_ASYNCREAD_CALLBACK userasyncread, FMOD_FILE_ASYNCCANCEL_CALLBACK userasynccancel, int blockalign);
FMOD_RESULT F_API FMOD_System_AttachFileSystem (FMOD_SYSTEM *system, FMOD_FILE_OPEN_CALLBACK useropen, FMOD_FILE_CLOSE_CALLBACK userclose, FMOD_FILE_READ_CALLBACK userread, FMOD_FILE_SEEK_CALLBACK userseek);
FMOD_RESULT F_API FMOD_System_SetAdvancedSettings (FMOD_SYSTEM *system, FMOD_ADVANCEDSETTINGS *settings);
FMOD_RESULT F_API FMOD_System_GetAdvancedSettings (FMOD_SYSTEM *system, FMOD_ADVANCEDSETTINGS *settings);
FMOD_RESULT F_API FMOD_System_SetCallback (FMOD_SYSTEM *system, FMOD_SYSTEM_CALLBACK callback, FMOD_SYSTEM_CALLBACK_TYPE callbackmask);
/*
Plug-in support.
*/
FMOD_RESULT F_API FMOD_System_SetPluginPath (FMOD_SYSTEM *system, const char *path);
FMOD_RESULT F_API FMOD_System_LoadPlugin (FMOD_SYSTEM *system, const char *filename, unsigned int *handle, unsigned int priority);
FMOD_RESULT F_API FMOD_System_UnloadPlugin (FMOD_SYSTEM *system, unsigned int handle);
FMOD_RESULT F_API FMOD_System_GetNumPlugins (FMOD_SYSTEM *system, FMOD_PLUGINTYPE plugintype, int *numplugins);
FMOD_RESULT F_API FMOD_System_GetPluginHandle (FMOD_SYSTEM *system, FMOD_PLUGINTYPE plugintype, int index, unsigned int *handle);
FMOD_RESULT F_API FMOD_System_GetPluginInfo (FMOD_SYSTEM *system, unsigned int handle, FMOD_PLUGINTYPE *plugintype, char *name, int namelen, unsigned int *version);
FMOD_RESULT F_API FMOD_System_SetOutputByPlugin (FMOD_SYSTEM *system, unsigned int handle);
FMOD_RESULT F_API FMOD_System_GetOutputByPlugin (FMOD_SYSTEM *system, unsigned int *handle);
FMOD_RESULT F_API FMOD_System_CreateDSPByPlugin (FMOD_SYSTEM *system, unsigned int handle, FMOD_DSP **dsp);
FMOD_RESULT F_API FMOD_System_GetDSPInfoByPlugin (FMOD_SYSTEM *system, unsigned int handle, const FMOD_DSP_DESCRIPTION **description);
FMOD_RESULT F_API FMOD_System_RegisterCodec (FMOD_SYSTEM *system, FMOD_CODEC_DESCRIPTION *description, unsigned int *handle, unsigned int priority);
FMOD_RESULT F_API FMOD_System_RegisterDSP (FMOD_SYSTEM *system, const FMOD_DSP_DESCRIPTION *description, unsigned int *handle);
FMOD_RESULT F_API FMOD_System_RegisterOutput (FMOD_SYSTEM *system, const FMOD_OUTPUT_DESCRIPTION *description, unsigned int *handle);
/*
Init/Close.
*/
FMOD_RESULT F_API FMOD_System_Init (FMOD_SYSTEM *system, int maxchannels, FMOD_INITFLAGS flags, void *extradriverdata);
FMOD_RESULT F_API FMOD_System_Close (FMOD_SYSTEM *system);
/*
General post-init system functions.
*/
FMOD_RESULT F_API FMOD_System_Update (FMOD_SYSTEM *system);
FMOD_RESULT F_API FMOD_System_SetSpeakerPosition (FMOD_SYSTEM *system, FMOD_SPEAKER speaker, float x, float y, FMOD_BOOL active);
FMOD_RESULT F_API FMOD_System_GetSpeakerPosition (FMOD_SYSTEM *system, FMOD_SPEAKER speaker, float *x, float *y, FMOD_BOOL *active);
FMOD_RESULT F_API FMOD_System_SetStreamBufferSize (FMOD_SYSTEM *system, unsigned int filebuffersize, FMOD_TIMEUNIT filebuffersizetype);
FMOD_RESULT F_API FMOD_System_GetStreamBufferSize (FMOD_SYSTEM *system, unsigned int *filebuffersize, FMOD_TIMEUNIT *filebuffersizetype);
FMOD_RESULT F_API FMOD_System_Set3DSettings (FMOD_SYSTEM *system, float dopplerscale, float distancefactor, float rolloffscale);
FMOD_RESULT F_API FMOD_System_Get3DSettings (FMOD_SYSTEM *system, float *dopplerscale, float *distancefactor, float *rolloffscale);
FMOD_RESULT F_API FMOD_System_Set3DNumListeners (FMOD_SYSTEM *system, int numlisteners);
FMOD_RESULT F_API FMOD_System_Get3DNumListeners (FMOD_SYSTEM *system, int *numlisteners);
FMOD_RESULT F_API FMOD_System_Set3DListenerAttributes (FMOD_SYSTEM *system, int listener, const FMOD_VECTOR *pos, const FMOD_VECTOR *vel, const FMOD_VECTOR *forward, const FMOD_VECTOR *up);
FMOD_RESULT F_API FMOD_System_Get3DListenerAttributes (FMOD_SYSTEM *system, int listener, FMOD_VECTOR *pos, FMOD_VECTOR *vel, FMOD_VECTOR *forward, FMOD_VECTOR *up);
FMOD_RESULT F_API FMOD_System_Set3DRolloffCallback (FMOD_SYSTEM *system, FMOD_3D_ROLLOFF_CALLBACK callback);
FMOD_RESULT F_API FMOD_System_MixerSuspend (FMOD_SYSTEM *system);
FMOD_RESULT F_API FMOD_System_MixerResume (FMOD_SYSTEM *system);
/*
System information functions.
*/
FMOD_RESULT F_API FMOD_System_GetVersion (FMOD_SYSTEM *system, unsigned int *version);
FMOD_RESULT F_API FMOD_System_GetOutputHandle (FMOD_SYSTEM *system, void **handle);
FMOD_RESULT F_API FMOD_System_GetChannelsPlaying (FMOD_SYSTEM *system, int *channels);
FMOD_RESULT F_API FMOD_System_GetCPUUsage (FMOD_SYSTEM *system, float *dsp, float *stream, float *geometry, float *update, float *total);
FMOD_RESULT F_API FMOD_System_GetSoundRAM (FMOD_SYSTEM *system, int *currentalloced, int *maxalloced, int *total);
/*
Sound/DSP/Channel/FX creation and retrieval.
*/
FMOD_RESULT F_API FMOD_System_CreateSound (FMOD_SYSTEM *system, const char *name_or_data, FMOD_MODE mode, FMOD_CREATESOUNDEXINFO *exinfo, FMOD_SOUND **sound);
FMOD_RESULT F_API FMOD_System_CreateStream (FMOD_SYSTEM *system, const char *name_or_data, FMOD_MODE mode, FMOD_CREATESOUNDEXINFO *exinfo, FMOD_SOUND **sound);
FMOD_RESULT F_API FMOD_System_CreateDSP (FMOD_SYSTEM *system, const FMOD_DSP_DESCRIPTION *description, FMOD_DSP **dsp);
FMOD_RESULT F_API FMOD_System_CreateDSPByType (FMOD_SYSTEM *system, FMOD_DSP_TYPE type, FMOD_DSP **dsp);
FMOD_RESULT F_API FMOD_System_CreateChannelGroup (FMOD_SYSTEM *system, const char *name, FMOD_CHANNELGROUP **channelgroup);
FMOD_RESULT F_API FMOD_System_CreateSoundGroup (FMOD_SYSTEM *system, const char *name, FMOD_SOUNDGROUP **soundgroup);
FMOD_RESULT F_API FMOD_System_CreateReverb3D (FMOD_SYSTEM *system, FMOD_REVERB3D **reverb);
FMOD_RESULT F_API FMOD_System_PlaySound (FMOD_SYSTEM *system, FMOD_SOUND *sound, FMOD_CHANNELGROUP *channelgroup, FMOD_BOOL paused, FMOD_CHANNEL **channel);
FMOD_RESULT F_API FMOD_System_PlayDSP (FMOD_SYSTEM *system, FMOD_DSP *dsp, FMOD_CHANNELGROUP *channelgroup, FMOD_BOOL paused, FMOD_CHANNEL **channel);
FMOD_RESULT F_API FMOD_System_GetChannel (FMOD_SYSTEM *system, int channelid, FMOD_CHANNEL **channel);
FMOD_RESULT F_API FMOD_System_GetMasterChannelGroup (FMOD_SYSTEM *system, FMOD_CHANNELGROUP **channelgroup);
FMOD_RESULT F_API FMOD_System_GetMasterSoundGroup (FMOD_SYSTEM *system, FMOD_SOUNDGROUP **soundgroup);
/*
Routing to ports.
*/
FMOD_RESULT F_API FMOD_System_AttachChannelGroupToPort (FMOD_SYSTEM *system, FMOD_PORT_TYPE portType, FMOD_PORT_INDEX portIndex, FMOD_CHANNELGROUP *channelgroup, FMOD_BOOL passThru);
FMOD_RESULT F_API FMOD_System_DetachChannelGroupFromPort(FMOD_SYSTEM *system, FMOD_CHANNELGROUP *channelgroup);
/*
Reverb API.
*/
FMOD_RESULT F_API FMOD_System_SetReverbProperties (FMOD_SYSTEM *system, int instance, const FMOD_REVERB_PROPERTIES *prop);
FMOD_RESULT F_API FMOD_System_GetReverbProperties (FMOD_SYSTEM *system, int instance, FMOD_REVERB_PROPERTIES *prop);
/*
System level DSP functionality.
*/
FMOD_RESULT F_API FMOD_System_LockDSP (FMOD_SYSTEM *system);
FMOD_RESULT F_API FMOD_System_UnlockDSP (FMOD_SYSTEM *system);
/*
Recording API.
*/
FMOD_RESULT F_API FMOD_System_GetRecordNumDrivers (FMOD_SYSTEM *system, int *numdrivers);
FMOD_RESULT F_API FMOD_System_GetRecordDriverInfo (FMOD_SYSTEM *system, int id, char *name, int namelen, FMOD_GUID *guid, int *systemrate, FMOD_SPEAKERMODE *speakermode, int *speakermodechannels);
FMOD_RESULT F_API FMOD_System_GetRecordPosition (FMOD_SYSTEM *system, int id, unsigned int *position);
FMOD_RESULT F_API FMOD_System_RecordStart (FMOD_SYSTEM *system, int id, FMOD_SOUND *sound, FMOD_BOOL loop);
FMOD_RESULT F_API FMOD_System_RecordStop (FMOD_SYSTEM *system, int id);
FMOD_RESULT F_API FMOD_System_IsRecording (FMOD_SYSTEM *system, int id, FMOD_BOOL *recording);
/*
Geometry API.
*/
FMOD_RESULT F_API FMOD_System_CreateGeometry (FMOD_SYSTEM *system, int maxpolygons, int maxvertices, FMOD_GEOMETRY **geometry);
FMOD_RESULT F_API FMOD_System_SetGeometrySettings (FMOD_SYSTEM *system, float maxworldsize);
FMOD_RESULT F_API FMOD_System_GetGeometrySettings (FMOD_SYSTEM *system, float *maxworldsize);
FMOD_RESULT F_API FMOD_System_LoadGeometry (FMOD_SYSTEM *system, const void *data, int datasize, FMOD_GEOMETRY **geometry);
FMOD_RESULT F_API FMOD_System_GetGeometryOcclusion (FMOD_SYSTEM *system, const FMOD_VECTOR *listener, const FMOD_VECTOR *source, float *direct, float *reverb);
/*
Network functions.
*/
FMOD_RESULT F_API FMOD_System_SetNetworkProxy (FMOD_SYSTEM *system, const char *proxy);
FMOD_RESULT F_API FMOD_System_GetNetworkProxy (FMOD_SYSTEM *system, char *proxy, int proxylen);
FMOD_RESULT F_API FMOD_System_SetNetworkTimeout (FMOD_SYSTEM *system, int timeout);
FMOD_RESULT F_API FMOD_System_GetNetworkTimeout (FMOD_SYSTEM *system, int *timeout);
/*
Userdata set/get.
*/
FMOD_RESULT F_API FMOD_System_SetUserData (FMOD_SYSTEM *system, void *userdata);
FMOD_RESULT F_API FMOD_System_GetUserData (FMOD_SYSTEM *system, void **userdata);
/*
'Sound' API
*/
FMOD_RESULT F_API FMOD_Sound_Release (FMOD_SOUND *sound);
FMOD_RESULT F_API FMOD_Sound_GetSystemObject (FMOD_SOUND *sound, FMOD_SYSTEM **system);
/*
Standard sound manipulation functions.
*/
FMOD_RESULT F_API FMOD_Sound_Lock (FMOD_SOUND *sound, unsigned int offset, unsigned int length, void **ptr1, void **ptr2, unsigned int *len1, unsigned int *len2);
FMOD_RESULT F_API FMOD_Sound_Unlock (FMOD_SOUND *sound, void *ptr1, void *ptr2, unsigned int len1, unsigned int len2);
FMOD_RESULT F_API FMOD_Sound_SetDefaults (FMOD_SOUND *sound, float frequency, int priority);
FMOD_RESULT F_API FMOD_Sound_GetDefaults (FMOD_SOUND *sound, float *frequency, int *priority);
FMOD_RESULT F_API FMOD_Sound_Set3DMinMaxDistance (FMOD_SOUND *sound, float min, float max);
FMOD_RESULT F_API FMOD_Sound_Get3DMinMaxDistance (FMOD_SOUND *sound, float *min, float *max);
FMOD_RESULT F_API FMOD_Sound_Set3DConeSettings (FMOD_SOUND *sound, float insideconeangle, float outsideconeangle, float outsidevolume);
FMOD_RESULT F_API FMOD_Sound_Get3DConeSettings (FMOD_SOUND *sound, float *insideconeangle, float *outsideconeangle, float *outsidevolume);
FMOD_RESULT F_API FMOD_Sound_Set3DCustomRolloff (FMOD_SOUND *sound, FMOD_VECTOR *points, int numpoints);
FMOD_RESULT F_API FMOD_Sound_Get3DCustomRolloff (FMOD_SOUND *sound, FMOD_VECTOR **points, int *numpoints);
FMOD_RESULT F_API FMOD_Sound_SetSubSound (FMOD_SOUND *sound, int index, FMOD_SOUND *subsound);
FMOD_RESULT F_API FMOD_Sound_GetSubSound (FMOD_SOUND *sound, int index, FMOD_SOUND **subsound);
FMOD_RESULT F_API FMOD_Sound_GetSubSoundParent (FMOD_SOUND *sound, FMOD_SOUND **parentsound);
FMOD_RESULT F_API FMOD_Sound_GetName (FMOD_SOUND *sound, char *name, int namelen);
FMOD_RESULT F_API FMOD_Sound_GetLength (FMOD_SOUND *sound, unsigned int *length, FMOD_TIMEUNIT lengthtype);
FMOD_RESULT F_API FMOD_Sound_GetFormat (FMOD_SOUND *sound, FMOD_SOUND_TYPE *type, FMOD_SOUND_FORMAT *format, int *channels, int *bits);
FMOD_RESULT F_API FMOD_Sound_GetNumSubSounds (FMOD_SOUND *sound, int *numsubsounds);
FMOD_RESULT F_API FMOD_Sound_GetNumTags (FMOD_SOUND *sound, int *numtags, int *numtagsupdated);
FMOD_RESULT F_API FMOD_Sound_GetTag (FMOD_SOUND *sound, const char *name, int index, FMOD_TAG *tag);
FMOD_RESULT F_API FMOD_Sound_GetOpenState (FMOD_SOUND *sound, FMOD_OPENSTATE *openstate, unsigned int *percentbuffered, FMOD_BOOL *starving, FMOD_BOOL *diskbusy);
FMOD_RESULT F_API FMOD_Sound_ReadData (FMOD_SOUND *sound, void *buffer, unsigned int lenbytes, unsigned int *read);
FMOD_RESULT F_API FMOD_Sound_SeekData (FMOD_SOUND *sound, unsigned int pcm);
FMOD_RESULT F_API FMOD_Sound_SetSoundGroup (FMOD_SOUND *sound, FMOD_SOUNDGROUP *soundgroup);
FMOD_RESULT F_API FMOD_Sound_GetSoundGroup (FMOD_SOUND *sound, FMOD_SOUNDGROUP **soundgroup);
/*
Synchronization point API. These points can come from markers embedded in wav files, and can also generate channel callbacks.
*/
FMOD_RESULT F_API FMOD_Sound_GetNumSyncPoints (FMOD_SOUND *sound, int *numsyncpoints);
FMOD_RESULT F_API FMOD_Sound_GetSyncPoint (FMOD_SOUND *sound, int index, FMOD_SYNCPOINT **point);
FMOD_RESULT F_API FMOD_Sound_GetSyncPointInfo (FMOD_SOUND *sound, FMOD_SYNCPOINT *point, char *name, int namelen, unsigned int *offset, FMOD_TIMEUNIT offsettype);
FMOD_RESULT F_API FMOD_Sound_AddSyncPoint (FMOD_SOUND *sound, unsigned int offset, FMOD_TIMEUNIT offsettype, const char *name, FMOD_SYNCPOINT **point);
FMOD_RESULT F_API FMOD_Sound_DeleteSyncPoint (FMOD_SOUND *sound, FMOD_SYNCPOINT *point);
/*
Functions also in Channel class but here they are the 'default' to save having to change it in Channel all the time.
*/
FMOD_RESULT F_API FMOD_Sound_SetMode (FMOD_SOUND *sound, FMOD_MODE mode);
FMOD_RESULT F_API FMOD_Sound_GetMode (FMOD_SOUND *sound, FMOD_MODE *mode);
FMOD_RESULT F_API FMOD_Sound_SetLoopCount (FMOD_SOUND *sound, int loopcount);
FMOD_RESULT F_API FMOD_Sound_GetLoopCount (FMOD_SOUND *sound, int *loopcount);
FMOD_RESULT F_API FMOD_Sound_SetLoopPoints (FMOD_SOUND *sound, unsigned int loopstart, FMOD_TIMEUNIT loopstarttype, unsigned int loopend, FMOD_TIMEUNIT loopendtype);
FMOD_RESULT F_API FMOD_Sound_GetLoopPoints (FMOD_SOUND *sound, unsigned int *loopstart, FMOD_TIMEUNIT loopstarttype, unsigned int *loopend, FMOD_TIMEUNIT loopendtype);
/*
For MOD/S3M/XM/IT/MID sequenced formats only.
*/
FMOD_RESULT F_API FMOD_Sound_GetMusicNumChannels (FMOD_SOUND *sound, int *numchannels);
FMOD_RESULT F_API FMOD_Sound_SetMusicChannelVolume (FMOD_SOUND *sound, int channel, float volume);
FMOD_RESULT F_API FMOD_Sound_GetMusicChannelVolume (FMOD_SOUND *sound, int channel, float *volume);
FMOD_RESULT F_API FMOD_Sound_SetMusicSpeed (FMOD_SOUND *sound, float speed);
FMOD_RESULT F_API FMOD_Sound_GetMusicSpeed (FMOD_SOUND *sound, float *speed);
/*
Userdata set/get.
*/
FMOD_RESULT F_API FMOD_Sound_SetUserData (FMOD_SOUND *sound, void *userdata);
FMOD_RESULT F_API FMOD_Sound_GetUserData (FMOD_SOUND *sound, void **userdata);
/*
'Channel' API
*/
FMOD_RESULT F_API FMOD_Channel_GetSystemObject (FMOD_CHANNEL *channel, FMOD_SYSTEM **system);
/*
General control functionality for Channels and ChannelGroups.
*/
FMOD_RESULT F_API FMOD_Channel_Stop (FMOD_CHANNEL *channel);
FMOD_RESULT F_API FMOD_Channel_SetPaused (FMOD_CHANNEL *channel, FMOD_BOOL paused);
FMOD_RESULT F_API FMOD_Channel_GetPaused (FMOD_CHANNEL *channel, FMOD_BOOL *paused);
FMOD_RESULT F_API FMOD_Channel_SetVolume (FMOD_CHANNEL *channel, float volume);
FMOD_RESULT F_API FMOD_Channel_GetVolume (FMOD_CHANNEL *channel, float *volume);
FMOD_RESULT F_API FMOD_Channel_SetVolumeRamp (FMOD_CHANNEL *channel, FMOD_BOOL ramp);
FMOD_RESULT F_API FMOD_Channel_GetVolumeRamp (FMOD_CHANNEL *channel, FMOD_BOOL *ramp);
FMOD_RESULT F_API FMOD_Channel_GetAudibility (FMOD_CHANNEL *channel, float *audibility);
FMOD_RESULT F_API FMOD_Channel_SetPitch (FMOD_CHANNEL *channel, float pitch);
FMOD_RESULT F_API FMOD_Channel_GetPitch (FMOD_CHANNEL *channel, float *pitch);
FMOD_RESULT F_API FMOD_Channel_SetMute (FMOD_CHANNEL *channel, FMOD_BOOL mute);
FMOD_RESULT F_API FMOD_Channel_GetMute (FMOD_CHANNEL *channel, FMOD_BOOL *mute);
FMOD_RESULT F_API FMOD_Channel_SetReverbProperties (FMOD_CHANNEL *channel, int instance, float wet);
FMOD_RESULT F_API FMOD_Channel_GetReverbProperties (FMOD_CHANNEL *channel, int instance, float *wet);
FMOD_RESULT F_API FMOD_Channel_SetLowPassGain (FMOD_CHANNEL *channel, float gain);
FMOD_RESULT F_API FMOD_Channel_GetLowPassGain (FMOD_CHANNEL *channel, float *gain);
FMOD_RESULT F_API FMOD_Channel_SetMode (FMOD_CHANNEL *channel, FMOD_MODE mode);
FMOD_RESULT F_API FMOD_Channel_GetMode (FMOD_CHANNEL *channel, FMOD_MODE *mode);
FMOD_RESULT F_API FMOD_Channel_SetCallback (FMOD_CHANNEL *channel, FMOD_CHANNELCONTROL_CALLBACK callback);
FMOD_RESULT F_API FMOD_Channel_IsPlaying (FMOD_CHANNEL *channel, FMOD_BOOL *isplaying);
/*
Panning and level adjustment.
*/
FMOD_RESULT F_API FMOD_Channel_SetPan (FMOD_CHANNEL *channel, float pan);
FMOD_RESULT F_API FMOD_Channel_SetMixLevelsOutput (FMOD_CHANNEL *channel, float frontleft, float frontright, float center, float lfe, float surroundleft, float surroundright, float backleft, float backright);
FMOD_RESULT F_API FMOD_Channel_SetMixLevelsInput (FMOD_CHANNEL *channel, float *levels, int numlevels);
FMOD_RESULT F_API FMOD_Channel_SetMixMatrix (FMOD_CHANNEL *channel, float *matrix, int outchannels, int inchannels, int inchannel_hop);
FMOD_RESULT F_API FMOD_Channel_GetMixMatrix (FMOD_CHANNEL *channel, float *matrix, int *outchannels, int *inchannels, int inchannel_hop);
/*
Clock based functionality.
*/
FMOD_RESULT F_API FMOD_Channel_GetDSPClock (FMOD_CHANNEL *channel, unsigned long long *dspclock, unsigned long long *parentclock);
FMOD_RESULT F_API FMOD_Channel_SetDelay (FMOD_CHANNEL *channel, unsigned long long dspclock_start, unsigned long long dspclock_end, FMOD_BOOL stopchannels);
FMOD_RESULT F_API FMOD_Channel_GetDelay (FMOD_CHANNEL *channel, unsigned long long *dspclock_start, unsigned long long *dspclock_end, FMOD_BOOL *stopchannels);
FMOD_RESULT F_API FMOD_Channel_AddFadePoint (FMOD_CHANNEL *channel, unsigned long long dspclock, float volume);
FMOD_RESULT F_API FMOD_Channel_SetFadePointRamp (FMOD_CHANNEL *channel, unsigned long long dspclock, float volume);
FMOD_RESULT F_API FMOD_Channel_RemoveFadePoints (FMOD_CHANNEL *channel, unsigned long long dspclock_start, unsigned long long dspclock_end);
FMOD_RESULT F_API FMOD_Channel_GetFadePoints (FMOD_CHANNEL *channel, unsigned int *numpoints, unsigned long long *point_dspclock, float *point_volume);
/*
DSP effects.
*/
FMOD_RESULT F_API FMOD_Channel_GetDSP (FMOD_CHANNEL *channel, int index, FMOD_DSP **dsp);
FMOD_RESULT F_API FMOD_Channel_AddDSP (FMOD_CHANNEL *channel, int index, FMOD_DSP *dsp);
FMOD_RESULT F_API FMOD_Channel_RemoveDSP (FMOD_CHANNEL *channel, FMOD_DSP *dsp);
FMOD_RESULT F_API FMOD_Channel_GetNumDSPs (FMOD_CHANNEL *channel, int *numdsps);
FMOD_RESULT F_API FMOD_Channel_SetDSPIndex (FMOD_CHANNEL *channel, FMOD_DSP *dsp, int index);
FMOD_RESULT F_API FMOD_Channel_GetDSPIndex (FMOD_CHANNEL *channel, FMOD_DSP *dsp, int *index);
FMOD_RESULT F_API FMOD_Channel_OverridePanDSP (FMOD_CHANNEL *channel, FMOD_DSP *pan);
/*
3D functionality.
*/
FMOD_RESULT F_API FMOD_Channel_Set3DAttributes (FMOD_CHANNEL *channel, const FMOD_VECTOR *pos, const FMOD_VECTOR *vel, const FMOD_VECTOR *alt_pan_pos);
FMOD_RESULT F_API FMOD_Channel_Get3DAttributes (FMOD_CHANNEL *channel, FMOD_VECTOR *pos, FMOD_VECTOR *vel, FMOD_VECTOR *alt_pan_pos);
FMOD_RESULT F_API FMOD_Channel_Set3DMinMaxDistance (FMOD_CHANNEL *channel, float mindistance, float maxdistance);
FMOD_RESULT F_API FMOD_Channel_Get3DMinMaxDistance (FMOD_CHANNEL *channel, float *mindistance, float *maxdistance);
FMOD_RESULT F_API FMOD_Channel_Set3DConeSettings (FMOD_CHANNEL *channel, float insideconeangle, float outsideconeangle, float outsidevolume);
FMOD_RESULT F_API FMOD_Channel_Get3DConeSettings (FMOD_CHANNEL *channel, float *insideconeangle, float *outsideconeangle, float *outsidevolume);
FMOD_RESULT F_API FMOD_Channel_Set3DConeOrientation (FMOD_CHANNEL *channel, FMOD_VECTOR *orientation);
FMOD_RESULT F_API FMOD_Channel_Get3DConeOrientation (FMOD_CHANNEL *channel, FMOD_VECTOR *orientation);
FMOD_RESULT F_API FMOD_Channel_Set3DCustomRolloff (FMOD_CHANNEL *channel, FMOD_VECTOR *points, int numpoints);
FMOD_RESULT F_API FMOD_Channel_Get3DCustomRolloff (FMOD_CHANNEL *channel, FMOD_VECTOR **points, int *numpoints);
FMOD_RESULT F_API FMOD_Channel_Set3DOcclusion (FMOD_CHANNEL *channel, float directocclusion, float reverbocclusion);
FMOD_RESULT F_API FMOD_Channel_Get3DOcclusion (FMOD_CHANNEL *channel, float *directocclusion, float *reverbocclusion);
FMOD_RESULT F_API FMOD_Channel_Set3DSpread (FMOD_CHANNEL *channel, float angle);
FMOD_RESULT F_API FMOD_Channel_Get3DSpread (FMOD_CHANNEL *channel, float *angle);
FMOD_RESULT F_API FMOD_Channel_Set3DLevel (FMOD_CHANNEL *channel, float level);
FMOD_RESULT F_API FMOD_Channel_Get3DLevel (FMOD_CHANNEL *channel, float *level);
FMOD_RESULT F_API FMOD_Channel_Set3DDopplerLevel (FMOD_CHANNEL *channel, float level);
FMOD_RESULT F_API FMOD_Channel_Get3DDopplerLevel (FMOD_CHANNEL *channel, float *level);
FMOD_RESULT F_API FMOD_Channel_Set3DDistanceFilter (FMOD_CHANNEL *channel, FMOD_BOOL custom, float customLevel, float centerFreq);
FMOD_RESULT F_API FMOD_Channel_Get3DDistanceFilter (FMOD_CHANNEL *channel, FMOD_BOOL *custom, float *customLevel, float *centerFreq);
/*
Userdata set/get.
*/
FMOD_RESULT F_API FMOD_Channel_SetUserData (FMOD_CHANNEL *channel, void *userdata);
FMOD_RESULT F_API FMOD_Channel_GetUserData (FMOD_CHANNEL *channel, void **userdata);
/*
Channel specific control functionality.
*/
FMOD_RESULT F_API FMOD_Channel_SetFrequency (FMOD_CHANNEL *channel, float frequency);
FMOD_RESULT F_API FMOD_Channel_GetFrequency (FMOD_CHANNEL *channel, float *frequency);
FMOD_RESULT F_API FMOD_Channel_SetPriority (FMOD_CHANNEL *channel, int priority);
FMOD_RESULT F_API FMOD_Channel_GetPriority (FMOD_CHANNEL *channel, int *priority);
FMOD_RESULT F_API FMOD_Channel_SetPosition (FMOD_CHANNEL *channel, unsigned int position, FMOD_TIMEUNIT postype);
FMOD_RESULT F_API FMOD_Channel_GetPosition (FMOD_CHANNEL *channel, unsigned int *position, FMOD_TIMEUNIT postype);
FMOD_RESULT F_API FMOD_Channel_SetChannelGroup (FMOD_CHANNEL *channel, FMOD_CHANNELGROUP *channelgroup);
FMOD_RESULT F_API FMOD_Channel_GetChannelGroup (FMOD_CHANNEL *channel, FMOD_CHANNELGROUP **channelgroup);
FMOD_RESULT F_API FMOD_Channel_SetLoopCount (FMOD_CHANNEL *channel, int loopcount);
FMOD_RESULT F_API FMOD_Channel_GetLoopCount (FMOD_CHANNEL *channel, int *loopcount);
FMOD_RESULT F_API FMOD_Channel_SetLoopPoints (FMOD_CHANNEL *channel, unsigned int loopstart, FMOD_TIMEUNIT loopstarttype, unsigned int loopend, FMOD_TIMEUNIT loopendtype);
FMOD_RESULT F_API FMOD_Channel_GetLoopPoints (FMOD_CHANNEL *channel, unsigned int *loopstart, FMOD_TIMEUNIT loopstarttype, unsigned int *loopend, FMOD_TIMEUNIT loopendtype);
/*
Information only functions.
*/
FMOD_RESULT F_API FMOD_Channel_IsVirtual (FMOD_CHANNEL *channel, FMOD_BOOL *isvirtual);
FMOD_RESULT F_API FMOD_Channel_GetCurrentSound (FMOD_CHANNEL *channel, FMOD_SOUND **sound);
FMOD_RESULT F_API FMOD_Channel_GetIndex (FMOD_CHANNEL *channel, int *index);
/*
'ChannelGroup' API
*/
FMOD_RESULT F_API FMOD_ChannelGroup_GetSystemObject (FMOD_CHANNELGROUP *channelgroup, FMOD_SYSTEM **system);
/*
General control functionality for Channels and ChannelGroups.
*/
FMOD_RESULT F_API FMOD_ChannelGroup_Stop (FMOD_CHANNELGROUP *channelgroup);
FMOD_RESULT F_API FMOD_ChannelGroup_SetPaused (FMOD_CHANNELGROUP *channelgroup, FMOD_BOOL paused);
FMOD_RESULT F_API FMOD_ChannelGroup_GetPaused (FMOD_CHANNELGROUP *channelgroup, FMOD_BOOL *paused);
FMOD_RESULT F_API FMOD_ChannelGroup_SetVolume (FMOD_CHANNELGROUP *channelgroup, float volume);
FMOD_RESULT F_API FMOD_ChannelGroup_GetVolume (FMOD_CHANNELGROUP *channelgroup, float *volume);
FMOD_RESULT F_API FMOD_ChannelGroup_SetVolumeRamp (FMOD_CHANNELGROUP *channelgroup, FMOD_BOOL ramp);
FMOD_RESULT F_API FMOD_ChannelGroup_GetVolumeRamp (FMOD_CHANNELGROUP *channelgroup, FMOD_BOOL *ramp);
FMOD_RESULT F_API FMOD_ChannelGroup_GetAudibility (FMOD_CHANNELGROUP *channelgroup, float *audibility);
FMOD_RESULT F_API FMOD_ChannelGroup_SetPitch (FMOD_CHANNELGROUP *channelgroup, float pitch);
FMOD_RESULT F_API FMOD_ChannelGroup_GetPitch (FMOD_CHANNELGROUP *channelgroup, float *pitch);
FMOD_RESULT F_API FMOD_ChannelGroup_SetMute (FMOD_CHANNELGROUP *channelgroup, FMOD_BOOL mute);
FMOD_RESULT F_API FMOD_ChannelGroup_GetMute (FMOD_CHANNELGROUP *channelgroup, FMOD_BOOL *mute);
FMOD_RESULT F_API FMOD_ChannelGroup_SetReverbProperties (FMOD_CHANNELGROUP *channelgroup, int instance, float wet);
FMOD_RESULT F_API FMOD_ChannelGroup_GetReverbProperties (FMOD_CHANNELGROUP *channelgroup, int instance, float *wet);
FMOD_RESULT F_API FMOD_ChannelGroup_SetLowPassGain (FMOD_CHANNELGROUP *channelgroup, float gain);
FMOD_RESULT F_API FMOD_ChannelGroup_GetLowPassGain (FMOD_CHANNELGROUP *channelgroup, float *gain);
FMOD_RESULT F_API FMOD_ChannelGroup_SetMode (FMOD_CHANNELGROUP *channelgroup, FMOD_MODE mode);
FMOD_RESULT F_API FMOD_ChannelGroup_GetMode (FMOD_CHANNELGROUP *channelgroup, FMOD_MODE *mode);
FMOD_RESULT F_API FMOD_ChannelGroup_SetCallback (FMOD_CHANNELGROUP *channelgroup, FMOD_CHANNELCONTROL_CALLBACK callback);
FMOD_RESULT F_API FMOD_ChannelGroup_IsPlaying (FMOD_CHANNELGROUP *channelgroup, FMOD_BOOL *isplaying);
/*
Panning and level adjustment.
*/
FMOD_RESULT F_API FMOD_ChannelGroup_SetPan (FMOD_CHANNELGROUP *channelgroup, float pan);
FMOD_RESULT F_API FMOD_ChannelGroup_SetMixLevelsOutput (FMOD_CHANNELGROUP *channelgroup, float frontleft, float frontright, float center, float lfe, float surroundleft, float surroundright, float backleft, float backright);
FMOD_RESULT F_API FMOD_ChannelGroup_SetMixLevelsInput (FMOD_CHANNELGROUP *channelgroup, float *levels, int numlevels);
FMOD_RESULT F_API FMOD_ChannelGroup_SetMixMatrix (FMOD_CHANNELGROUP *channelgroup, float *matrix, int outchannels, int inchannels, int inchannel_hop);
FMOD_RESULT F_API FMOD_ChannelGroup_GetMixMatrix (FMOD_CHANNELGROUP *channelgroup, float *matrix, int *outchannels, int *inchannels, int inchannel_hop);
/*
Clock based functionality.
*/
FMOD_RESULT F_API FMOD_ChannelGroup_GetDSPClock (FMOD_CHANNELGROUP *channelgroup, unsigned long long *dspclock, unsigned long long *parentclock);
FMOD_RESULT F_API FMOD_ChannelGroup_SetDelay (FMOD_CHANNELGROUP *channelgroup, unsigned long long dspclock_start, unsigned long long dspclock_end, FMOD_BOOL stopchannels);
FMOD_RESULT F_API FMOD_ChannelGroup_GetDelay (FMOD_CHANNELGROUP *channelgroup, unsigned long long *dspclock_start, unsigned long long *dspclock_end, FMOD_BOOL *stopchannels);
FMOD_RESULT F_API FMOD_ChannelGroup_AddFadePoint (FMOD_CHANNELGROUP *channelgroup, unsigned long long dspclock, float volume);
FMOD_RESULT F_API FMOD_ChannelGroup_SetFadePointRamp (FMOD_CHANNELGROUP *channelgroup, unsigned long long dspclock, float volume);
FMOD_RESULT F_API FMOD_ChannelGroup_RemoveFadePoints (FMOD_CHANNELGROUP *channelgroup, unsigned long long dspclock_start, unsigned long long dspclock_end);
FMOD_RESULT F_API FMOD_ChannelGroup_GetFadePoints (FMOD_CHANNELGROUP *channelgroup, unsigned int *numpoints, unsigned long long *point_dspclock, float *point_volume);
/*
DSP effects.
*/
FMOD_RESULT F_API FMOD_ChannelGroup_GetDSP (FMOD_CHANNELGROUP *channelgroup, int index, FMOD_DSP **dsp);
FMOD_RESULT F_API FMOD_ChannelGroup_AddDSP (FMOD_CHANNELGROUP *channelgroup, int index, FMOD_DSP *dsp);
FMOD_RESULT F_API FMOD_ChannelGroup_RemoveDSP (FMOD_CHANNELGROUP *channelgroup, FMOD_DSP *dsp);
FMOD_RESULT F_API FMOD_ChannelGroup_GetNumDSPs (FMOD_CHANNELGROUP *channelgroup, int *numdsps);
FMOD_RESULT F_API FMOD_ChannelGroup_SetDSPIndex (FMOD_CHANNELGROUP *channelgroup, FMOD_DSP *dsp, int index);
FMOD_RESULT F_API FMOD_ChannelGroup_GetDSPIndex (FMOD_CHANNELGROUP *channelgroup, FMOD_DSP *dsp, int *index);
FMOD_RESULT F_API FMOD_ChannelGroup_OverridePanDSP (FMOD_CHANNELGROUP *channelgroup, FMOD_DSP *pan);
/*
3D functionality.
*/
FMOD_RESULT F_API FMOD_ChannelGroup_Set3DAttributes (FMOD_CHANNELGROUP *channelgroup, const FMOD_VECTOR *pos, const FMOD_VECTOR *vel, const FMOD_VECTOR *alt_pan_pos);
FMOD_RESULT F_API FMOD_ChannelGroup_Get3DAttributes (FMOD_CHANNELGROUP *channelgroup, FMOD_VECTOR *pos, FMOD_VECTOR *vel, FMOD_VECTOR *alt_pan_pos);
FMOD_RESULT F_API FMOD_ChannelGroup_Set3DMinMaxDistance (FMOD_CHANNELGROUP *channelgroup, float mindistance, float maxdistance);
FMOD_RESULT F_API FMOD_ChannelGroup_Get3DMinMaxDistance (FMOD_CHANNELGROUP *channelgroup, float *mindistance, float *maxdistance);
FMOD_RESULT F_API FMOD_ChannelGroup_Set3DConeSettings (FMOD_CHANNELGROUP *channelgroup, float insideconeangle, float outsideconeangle, float outsidevolume);
FMOD_RESULT F_API FMOD_ChannelGroup_Get3DConeSettings (FMOD_CHANNELGROUP *channelgroup, float *insideconeangle, float *outsideconeangle, float *outsidevolume);
FMOD_RESULT F_API FMOD_ChannelGroup_Set3DConeOrientation(FMOD_CHANNELGROUP *channelgroup, FMOD_VECTOR *orientation);
FMOD_RESULT F_API FMOD_ChannelGroup_Get3DConeOrientation(FMOD_CHANNELGROUP *channelgroup, FMOD_VECTOR *orientation);
FMOD_RESULT F_API FMOD_ChannelGroup_Set3DCustomRolloff (FMOD_CHANNELGROUP *channelgroup, FMOD_VECTOR *points, int numpoints);
FMOD_RESULT F_API FMOD_ChannelGroup_Get3DCustomRolloff (FMOD_CHANNELGROUP *channelgroup, FMOD_VECTOR **points, int *numpoints);
FMOD_RESULT F_API FMOD_ChannelGroup_Set3DOcclusion (FMOD_CHANNELGROUP *channelgroup, float directocclusion, float reverbocclusion);
FMOD_RESULT F_API FMOD_ChannelGroup_Get3DOcclusion (FMOD_CHANNELGROUP *channelgroup, float *directocclusion, float *reverbocclusion);
FMOD_RESULT F_API FMOD_ChannelGroup_Set3DSpread (FMOD_CHANNELGROUP *channelgroup, float angle);
FMOD_RESULT F_API FMOD_ChannelGroup_Get3DSpread (FMOD_CHANNELGROUP *channelgroup, float *angle);
FMOD_RESULT F_API FMOD_ChannelGroup_Set3DLevel (FMOD_CHANNELGROUP *channelgroup, float level);
FMOD_RESULT F_API FMOD_ChannelGroup_Get3DLevel (FMOD_CHANNELGROUP *channelgroup, float *level);
FMOD_RESULT F_API FMOD_ChannelGroup_Set3DDopplerLevel (FMOD_CHANNELGROUP *channelgroup, float level);
FMOD_RESULT F_API FMOD_ChannelGroup_Get3DDopplerLevel (FMOD_CHANNELGROUP *channelgroup, float *level);
FMOD_RESULT F_API FMOD_ChannelGroup_Set3DDistanceFilter (FMOD_CHANNELGROUP *channelgroup, FMOD_BOOL custom, float customLevel, float centerFreq);
FMOD_RESULT F_API FMOD_ChannelGroup_Get3DDistanceFilter (FMOD_CHANNELGROUP *channelgroup, FMOD_BOOL *custom, float *customLevel, float *centerFreq);
/*
Userdata set/get.
*/
FMOD_RESULT F_API FMOD_ChannelGroup_SetUserData (FMOD_CHANNELGROUP *channelgroup, void *userdata);
FMOD_RESULT F_API FMOD_ChannelGroup_GetUserData (FMOD_CHANNELGROUP *channelgroup, void **userdata);
FMOD_RESULT F_API FMOD_ChannelGroup_Release (FMOD_CHANNELGROUP *channelgroup);
/*
Nested channel groups.
*/
FMOD_RESULT F_API FMOD_ChannelGroup_AddGroup (FMOD_CHANNELGROUP *channelgroup, FMOD_CHANNELGROUP *group, FMOD_BOOL propagatedspclock, FMOD_DSPCONNECTION **connection);
FMOD_RESULT F_API FMOD_ChannelGroup_GetNumGroups (FMOD_CHANNELGROUP *channelgroup, int *numgroups);
FMOD_RESULT F_API FMOD_ChannelGroup_GetGroup (FMOD_CHANNELGROUP *channelgroup, int index, FMOD_CHANNELGROUP **group);
FMOD_RESULT F_API FMOD_ChannelGroup_GetParentGroup (FMOD_CHANNELGROUP *channelgroup, FMOD_CHANNELGROUP **group);
/*
Information only functions.
*/
FMOD_RESULT F_API FMOD_ChannelGroup_GetName (FMOD_CHANNELGROUP *channelgroup, char *name, int namelen);
FMOD_RESULT F_API FMOD_ChannelGroup_GetNumChannels (FMOD_CHANNELGROUP *channelgroup, int *numchannels);
FMOD_RESULT F_API FMOD_ChannelGroup_GetChannel (FMOD_CHANNELGROUP *channelgroup, int index, FMOD_CHANNEL **channel);
/*
'SoundGroup' API
*/
FMOD_RESULT F_API FMOD_SoundGroup_Release (FMOD_SOUNDGROUP *soundgroup);
FMOD_RESULT F_API FMOD_SoundGroup_GetSystemObject (FMOD_SOUNDGROUP *soundgroup, FMOD_SYSTEM **system);
/*
SoundGroup control functions.
*/
FMOD_RESULT F_API FMOD_SoundGroup_SetMaxAudible (FMOD_SOUNDGROUP *soundgroup, int maxaudible);
FMOD_RESULT F_API FMOD_SoundGroup_GetMaxAudible (FMOD_SOUNDGROUP *soundgroup, int *maxaudible);
FMOD_RESULT F_API FMOD_SoundGroup_SetMaxAudibleBehavior (FMOD_SOUNDGROUP *soundgroup, FMOD_SOUNDGROUP_BEHAVIOR behavior);
FMOD_RESULT F_API FMOD_SoundGroup_GetMaxAudibleBehavior (FMOD_SOUNDGROUP *soundgroup, FMOD_SOUNDGROUP_BEHAVIOR *behavior);
FMOD_RESULT F_API FMOD_SoundGroup_SetMuteFadeSpeed (FMOD_SOUNDGROUP *soundgroup, float speed);
FMOD_RESULT F_API FMOD_SoundGroup_GetMuteFadeSpeed (FMOD_SOUNDGROUP *soundgroup, float *speed);
FMOD_RESULT F_API FMOD_SoundGroup_SetVolume (FMOD_SOUNDGROUP *soundgroup, float volume);
FMOD_RESULT F_API FMOD_SoundGroup_GetVolume (FMOD_SOUNDGROUP *soundgroup, float *volume);
FMOD_RESULT F_API FMOD_SoundGroup_Stop (FMOD_SOUNDGROUP *soundgroup);
/*
Information only functions.
*/
FMOD_RESULT F_API FMOD_SoundGroup_GetName (FMOD_SOUNDGROUP *soundgroup, char *name, int namelen);
FMOD_RESULT F_API FMOD_SoundGroup_GetNumSounds (FMOD_SOUNDGROUP *soundgroup, int *numsounds);
FMOD_RESULT F_API FMOD_SoundGroup_GetSound (FMOD_SOUNDGROUP *soundgroup, int index, FMOD_SOUND **sound);
FMOD_RESULT F_API FMOD_SoundGroup_GetNumPlaying (FMOD_SOUNDGROUP *soundgroup, int *numplaying);
/*
Userdata set/get.
*/
FMOD_RESULT F_API FMOD_SoundGroup_SetUserData (FMOD_SOUNDGROUP *soundgroup, void *userdata);
FMOD_RESULT F_API FMOD_SoundGroup_GetUserData (FMOD_SOUNDGROUP *soundgroup, void **userdata);
/*
'DSP' API
*/
FMOD_RESULT F_API FMOD_DSP_Release (FMOD_DSP *dsp);
FMOD_RESULT F_API FMOD_DSP_GetSystemObject (FMOD_DSP *dsp, FMOD_SYSTEM **system);
/*
Connection / disconnection / input and output enumeration.
*/
FMOD_RESULT F_API FMOD_DSP_AddInput (FMOD_DSP *dsp, FMOD_DSP *input, FMOD_DSPCONNECTION **connection, FMOD_DSPCONNECTION_TYPE type);
FMOD_RESULT F_API FMOD_DSP_DisconnectFrom (FMOD_DSP *dsp, FMOD_DSP *target, FMOD_DSPCONNECTION *connection);
FMOD_RESULT F_API FMOD_DSP_DisconnectAll (FMOD_DSP *dsp, FMOD_BOOL inputs, FMOD_BOOL outputs);
FMOD_RESULT F_API FMOD_DSP_GetNumInputs (FMOD_DSP *dsp, int *numinputs);
FMOD_RESULT F_API FMOD_DSP_GetNumOutputs (FMOD_DSP *dsp, int *numoutputs);
FMOD_RESULT F_API FMOD_DSP_GetInput (FMOD_DSP *dsp, int index, FMOD_DSP **input, FMOD_DSPCONNECTION **inputconnection);
FMOD_RESULT F_API FMOD_DSP_GetOutput (FMOD_DSP *dsp, int index, FMOD_DSP **output, FMOD_DSPCONNECTION **outputconnection);
/*
DSP unit control.
*/
FMOD_RESULT F_API FMOD_DSP_SetActive (FMOD_DSP *dsp, FMOD_BOOL active);
FMOD_RESULT F_API FMOD_DSP_GetActive (FMOD_DSP *dsp, FMOD_BOOL *active);
FMOD_RESULT F_API FMOD_DSP_SetBypass (FMOD_DSP *dsp, FMOD_BOOL bypass);
FMOD_RESULT F_API FMOD_DSP_GetBypass (FMOD_DSP *dsp, FMOD_BOOL *bypass);
FMOD_RESULT F_API FMOD_DSP_SetWetDryMix (FMOD_DSP *dsp, float prewet, float postwet, float dry);
FMOD_RESULT F_API FMOD_DSP_GetWetDryMix (FMOD_DSP *dsp, float *prewet, float *postwet, float *dry);
FMOD_RESULT F_API FMOD_DSP_SetChannelFormat (FMOD_DSP *dsp, FMOD_CHANNELMASK channelmask, int numchannels, FMOD_SPEAKERMODE source_speakermode);
FMOD_RESULT F_API FMOD_DSP_GetChannelFormat (FMOD_DSP *dsp, FMOD_CHANNELMASK *channelmask, int *numchannels, FMOD_SPEAKERMODE *source_speakermode);
FMOD_RESULT F_API FMOD_DSP_GetOutputChannelFormat (FMOD_DSP *dsp, FMOD_CHANNELMASK inmask, int inchannels, FMOD_SPEAKERMODE inspeakermode, FMOD_CHANNELMASK *outmask, int *outchannels, FMOD_SPEAKERMODE *outspeakermode);
FMOD_RESULT F_API FMOD_DSP_Reset (FMOD_DSP *dsp);
/*
DSP parameter control.
*/
FMOD_RESULT F_API FMOD_DSP_SetParameterFloat (FMOD_DSP *dsp, int index, float value);
FMOD_RESULT F_API FMOD_DSP_SetParameterInt (FMOD_DSP *dsp, int index, int value);
FMOD_RESULT F_API FMOD_DSP_SetParameterBool (FMOD_DSP *dsp, int index, FMOD_BOOL value);
FMOD_RESULT F_API FMOD_DSP_SetParameterData (FMOD_DSP *dsp, int index, void *data, unsigned int length);
FMOD_RESULT F_API FMOD_DSP_GetParameterFloat (FMOD_DSP *dsp, int index, float *value, char *valuestr, int valuestrlen);
FMOD_RESULT F_API FMOD_DSP_GetParameterInt (FMOD_DSP *dsp, int index, int *value, char *valuestr, int valuestrlen);
FMOD_RESULT F_API FMOD_DSP_GetParameterBool (FMOD_DSP *dsp, int index, FMOD_BOOL *value, char *valuestr, int valuestrlen);
FMOD_RESULT F_API FMOD_DSP_GetParameterData (FMOD_DSP *dsp, int index, void **data, unsigned int *length, char *valuestr, int valuestrlen);
FMOD_RESULT F_API FMOD_DSP_GetNumParameters (FMOD_DSP *dsp, int *numparams);
FMOD_RESULT F_API FMOD_DSP_GetParameterInfo (FMOD_DSP *dsp, int index, FMOD_DSP_PARAMETER_DESC **desc);
FMOD_RESULT F_API FMOD_DSP_GetDataParameterIndex (FMOD_DSP *dsp, int datatype, int *index);
FMOD_RESULT F_API FMOD_DSP_ShowConfigDialog (FMOD_DSP *dsp, void *hwnd, FMOD_BOOL show);
/*
DSP attributes.
*/
FMOD_RESULT F_API FMOD_DSP_GetInfo (FMOD_DSP *dsp, char *name, unsigned int *version, int *channels, int *configwidth, int *configheight);
FMOD_RESULT F_API FMOD_DSP_GetType (FMOD_DSP *dsp, FMOD_DSP_TYPE *type);
FMOD_RESULT F_API FMOD_DSP_GetIdle (FMOD_DSP *dsp, FMOD_BOOL *idle);
/*
Userdata set/get.
*/
FMOD_RESULT F_API FMOD_DSP_SetUserData (FMOD_DSP *dsp, void *userdata);
FMOD_RESULT F_API FMOD_DSP_GetUserData (FMOD_DSP *dsp, void **userdata);
/*
Metering.
*/
FMOD_RESULT F_API FMOD_DSP_SetMeteringEnabled (FMOD_DSP *dsp, FMOD_BOOL inputEnabled, FMOD_BOOL outputEnabled);
FMOD_RESULT F_API FMOD_DSP_GetMeteringEnabled (FMOD_DSP *dsp, FMOD_BOOL *inputEnabled, FMOD_BOOL *outputEnabled);
FMOD_RESULT F_API FMOD_DSP_GetMeteringInfo (FMOD_DSP *dsp, FMOD_DSP_METERING_INFO *inputInfo, FMOD_DSP_METERING_INFO *outputInfo);
/*
'DSPConnection' API
*/
FMOD_RESULT F_API FMOD_DSPConnection_GetInput (FMOD_DSPCONNECTION *dspconnection, FMOD_DSP **input);
FMOD_RESULT F_API FMOD_DSPConnection_GetOutput (FMOD_DSPCONNECTION *dspconnection, FMOD_DSP **output);
FMOD_RESULT F_API FMOD_DSPConnection_SetMix (FMOD_DSPCONNECTION *dspconnection, float volume);
FMOD_RESULT F_API FMOD_DSPConnection_GetMix (FMOD_DSPCONNECTION *dspconnection, float *volume);
FMOD_RESULT F_API FMOD_DSPConnection_SetMixMatrix (FMOD_DSPCONNECTION *dspconnection, float *matrix, int outchannels, int inchannels, int inchannel_hop);
FMOD_RESULT F_API FMOD_DSPConnection_GetMixMatrix (FMOD_DSPCONNECTION *dspconnection, float *matrix, int *outchannels, int *inchannels, int inchannel_hop);
FMOD_RESULT F_API FMOD_DSPConnection_GetType (FMOD_DSPCONNECTION *dspconnection, FMOD_DSPCONNECTION_TYPE *type);
/*
Userdata set/get.
*/
FMOD_RESULT F_API FMOD_DSPConnection_SetUserData (FMOD_DSPCONNECTION *dspconnection, void *userdata);
FMOD_RESULT F_API FMOD_DSPConnection_GetUserData (FMOD_DSPCONNECTION *dspconnection, void **userdata);
/*
'Geometry' API
*/
FMOD_RESULT F_API FMOD_Geometry_Release (FMOD_GEOMETRY *geometry);
/*
Polygon manipulation.
*/
FMOD_RESULT F_API FMOD_Geometry_AddPolygon (FMOD_GEOMETRY *geometry, float directocclusion, float reverbocclusion, FMOD_BOOL doublesided, int numvertices, const FMOD_VECTOR *vertices, int *polygonindex);
FMOD_RESULT F_API FMOD_Geometry_GetNumPolygons (FMOD_GEOMETRY *geometry, int *numpolygons);
FMOD_RESULT F_API FMOD_Geometry_GetMaxPolygons (FMOD_GEOMETRY *geometry, int *maxpolygons, int *maxvertices);
FMOD_RESULT F_API FMOD_Geometry_GetPolygonNumVertices (FMOD_GEOMETRY *geometry, int index, int *numvertices);
FMOD_RESULT F_API FMOD_Geometry_SetPolygonVertex (FMOD_GEOMETRY *geometry, int index, int vertexindex, const FMOD_VECTOR *vertex);
FMOD_RESULT F_API FMOD_Geometry_GetPolygonVertex (FMOD_GEOMETRY *geometry, int index, int vertexindex, FMOD_VECTOR *vertex);
FMOD_RESULT F_API FMOD_Geometry_SetPolygonAttributes (FMOD_GEOMETRY *geometry, int index, float directocclusion, float reverbocclusion, FMOD_BOOL doublesided);
FMOD_RESULT F_API FMOD_Geometry_GetPolygonAttributes (FMOD_GEOMETRY *geometry, int index, float *directocclusion, float *reverbocclusion, FMOD_BOOL *doublesided);
/*
Object manipulation.
*/
FMOD_RESULT F_API FMOD_Geometry_SetActive (FMOD_GEOMETRY *geometry, FMOD_BOOL active);
FMOD_RESULT F_API FMOD_Geometry_GetActive (FMOD_GEOMETRY *geometry, FMOD_BOOL *active);
FMOD_RESULT F_API FMOD_Geometry_SetRotation (FMOD_GEOMETRY *geometry, const FMOD_VECTOR *forward, const FMOD_VECTOR *up);
FMOD_RESULT F_API FMOD_Geometry_GetRotation (FMOD_GEOMETRY *geometry, FMOD_VECTOR *forward, FMOD_VECTOR *up);
FMOD_RESULT F_API FMOD_Geometry_SetPosition (FMOD_GEOMETRY *geometry, const FMOD_VECTOR *position);
FMOD_RESULT F_API FMOD_Geometry_GetPosition (FMOD_GEOMETRY *geometry, FMOD_VECTOR *position);
FMOD_RESULT F_API FMOD_Geometry_SetScale (FMOD_GEOMETRY *geometry, const FMOD_VECTOR *scale);
FMOD_RESULT F_API FMOD_Geometry_GetScale (FMOD_GEOMETRY *geometry, FMOD_VECTOR *scale);
FMOD_RESULT F_API FMOD_Geometry_Save (FMOD_GEOMETRY *geometry, void *data, int *datasize);
/*
Userdata set/get.
*/
FMOD_RESULT F_API FMOD_Geometry_SetUserData (FMOD_GEOMETRY *geometry, void *userdata);
FMOD_RESULT F_API FMOD_Geometry_GetUserData (FMOD_GEOMETRY *geometry, void **userdata);
/*
'Reverb3D' API
*/
FMOD_RESULT F_API FMOD_Reverb3D_Release (FMOD_REVERB3D *reverb3d);
/*
Reverb manipulation.
*/
FMOD_RESULT F_API FMOD_Reverb3D_Set3DAttributes (FMOD_REVERB3D *reverb3d, const FMOD_VECTOR *position, float mindistance, float maxdistance);
FMOD_RESULT F_API FMOD_Reverb3D_Get3DAttributes (FMOD_REVERB3D *reverb3d, FMOD_VECTOR *position, float *mindistance, float *maxdistance);
FMOD_RESULT F_API FMOD_Reverb3D_SetProperties (FMOD_REVERB3D *reverb3d, const FMOD_REVERB_PROPERTIES *properties);
FMOD_RESULT F_API FMOD_Reverb3D_GetProperties (FMOD_REVERB3D *reverb3d, FMOD_REVERB_PROPERTIES *properties);
FMOD_RESULT F_API FMOD_Reverb3D_SetActive (FMOD_REVERB3D *reverb3d, FMOD_BOOL active);
FMOD_RESULT F_API FMOD_Reverb3D_GetActive (FMOD_REVERB3D *reverb3d, FMOD_BOOL *active);
/*
Userdata set/get.
*/
FMOD_RESULT F_API FMOD_Reverb3D_SetUserData (FMOD_REVERB3D *reverb3d, void *userdata);
FMOD_RESULT F_API FMOD_Reverb3D_GetUserData (FMOD_REVERB3D *reverb3d, void **userdata);
/*$ preserve start $*/
#ifdef __cplusplus
}
#endif
#endif /* _FMOD_H */
/*$ preserve end $*/
+586
View File
@@ -0,0 +1,586 @@
/* ========================================================================================== */
/* FMOD Studio - C++ header file. Copyright (c), Firelight Technologies Pty, Ltd. 2004-2015. */
/* */
/* Use this header in conjunction with fmod_common.h (which contains all the constants / */
/* callbacks) to develop using C++ classes. */
/* ========================================================================================== */
#ifndef _FMOD_HPP
#define _FMOD_HPP
#include "fmod_common.h"
#include "fmod.h"
/*
Constant and defines
*/
/*
FMOD Namespace
*/
namespace FMOD
{
class System;
class Sound;
class Channel;
class ChannelGroup;
class SoundGroup;
class Reverb3D;
class DSP;
class DSPConnection;
class Geometry;
/*
FMOD global system functions (optional).
*/
inline FMOD_RESULT Memory_Initialize (void *poolmem, int poollen, FMOD_MEMORY_ALLOC_CALLBACK useralloc, FMOD_MEMORY_REALLOC_CALLBACK userrealloc, FMOD_MEMORY_FREE_CALLBACK userfree, FMOD_MEMORY_TYPE memtypeflags = FMOD_MEMORY_ALL) { return FMOD_Memory_Initialize(poolmem, poollen, useralloc, userrealloc, userfree, memtypeflags); }
inline FMOD_RESULT Memory_GetStats (int *currentalloced, int *maxalloced, bool blocking = true) { return FMOD_Memory_GetStats(currentalloced, maxalloced, blocking); }
inline FMOD_RESULT Debug_Initialize (FMOD_DEBUG_FLAGS flags, FMOD_DEBUG_MODE mode = FMOD_DEBUG_MODE_TTY, FMOD_DEBUG_CALLBACK callback = 0, const char *filename = 0) { return FMOD_Debug_Initialize(flags, mode, callback, filename); }
inline FMOD_RESULT File_SetDiskBusy (int busy) { return FMOD_File_SetDiskBusy(busy); }
inline FMOD_RESULT File_GetDiskBusy (int *busy) { return FMOD_File_GetDiskBusy(busy); }
/*
FMOD System factory functions.
*/
inline FMOD_RESULT System_Create (System **system) { return FMOD_System_Create((FMOD_SYSTEM **)system); }
/*
'System' API
*/
class System
{
private:
System(); /* Constructor made private so user cannot statically instance a System class.
System_Create must be used. */
public:
FMOD_RESULT F_API release ();
// Setup functions.
FMOD_RESULT F_API setOutput (FMOD_OUTPUTTYPE output);
FMOD_RESULT F_API getOutput (FMOD_OUTPUTTYPE *output);
FMOD_RESULT F_API getNumDrivers (int *numdrivers);
FMOD_RESULT F_API getDriverInfo (int id, char *name, int namelen, FMOD_GUID *guid, int *systemrate, FMOD_SPEAKERMODE *speakermode, int *speakermodechannels);
FMOD_RESULT F_API setDriver (int driver);
FMOD_RESULT F_API getDriver (int *driver);
FMOD_RESULT F_API setSoftwareChannels (int numsoftwarechannels);
FMOD_RESULT F_API getSoftwareChannels (int *numsoftwarechannels);
FMOD_RESULT F_API setSoftwareFormat (int samplerate, FMOD_SPEAKERMODE speakermode, int numrawspeakers);
FMOD_RESULT F_API getSoftwareFormat (int *samplerate, FMOD_SPEAKERMODE *speakermode, int *numrawspeakers);
FMOD_RESULT F_API setDSPBufferSize (unsigned int bufferlength, int numbuffers);
FMOD_RESULT F_API getDSPBufferSize (unsigned int *bufferlength, int *numbuffers);
FMOD_RESULT F_API setFileSystem (FMOD_FILE_OPEN_CALLBACK useropen, FMOD_FILE_CLOSE_CALLBACK userclose, FMOD_FILE_READ_CALLBACK userread, FMOD_FILE_SEEK_CALLBACK userseek, FMOD_FILE_ASYNCREAD_CALLBACK userasyncread, FMOD_FILE_ASYNCCANCEL_CALLBACK userasynccancel, int blockalign);
FMOD_RESULT F_API attachFileSystem (FMOD_FILE_OPEN_CALLBACK useropen, FMOD_FILE_CLOSE_CALLBACK userclose, FMOD_FILE_READ_CALLBACK userread, FMOD_FILE_SEEK_CALLBACK userseek);
FMOD_RESULT F_API setAdvancedSettings (FMOD_ADVANCEDSETTINGS *settings);
FMOD_RESULT F_API getAdvancedSettings (FMOD_ADVANCEDSETTINGS *settings);
FMOD_RESULT F_API setCallback (FMOD_SYSTEM_CALLBACK callback, FMOD_SYSTEM_CALLBACK_TYPE callbackmask = 0xFFFFFFFF);
// Plug-in support.
FMOD_RESULT F_API setPluginPath (const char *path);
FMOD_RESULT F_API loadPlugin (const char *filename, unsigned int *handle, unsigned int priority = 0);
FMOD_RESULT F_API unloadPlugin (unsigned int handle);
FMOD_RESULT F_API getNumPlugins (FMOD_PLUGINTYPE plugintype, int *numplugins);
FMOD_RESULT F_API getPluginHandle (FMOD_PLUGINTYPE plugintype, int index, unsigned int *handle);
FMOD_RESULT F_API getPluginInfo (unsigned int handle, FMOD_PLUGINTYPE *plugintype, char *name, int namelen, unsigned int *version);
FMOD_RESULT F_API setOutputByPlugin (unsigned int handle);
FMOD_RESULT F_API getOutputByPlugin (unsigned int *handle);
FMOD_RESULT F_API createDSPByPlugin (unsigned int handle, DSP **dsp);
FMOD_RESULT F_API getDSPInfoByPlugin (unsigned int handle, const FMOD_DSP_DESCRIPTION **description);
FMOD_RESULT F_API registerCodec (FMOD_CODEC_DESCRIPTION *description, unsigned int *handle, unsigned int priority = 0);
FMOD_RESULT F_API registerDSP (const FMOD_DSP_DESCRIPTION *description, unsigned int *handle);
FMOD_RESULT F_API registerOutput (const FMOD_OUTPUT_DESCRIPTION *description, unsigned int *handle);
// Init/Close.
FMOD_RESULT F_API init (int maxchannels, FMOD_INITFLAGS flags, void *extradriverdata);
FMOD_RESULT F_API close ();
// General post-init system functions.
FMOD_RESULT F_API update (); /* IMPORTANT! CALL THIS ONCE PER FRAME! */
FMOD_RESULT F_API setSpeakerPosition (FMOD_SPEAKER speaker, float x, float y, bool active);
FMOD_RESULT F_API getSpeakerPosition (FMOD_SPEAKER speaker, float *x, float *y, bool *active);
FMOD_RESULT F_API setStreamBufferSize (unsigned int filebuffersize, FMOD_TIMEUNIT filebuffersizetype);
FMOD_RESULT F_API getStreamBufferSize (unsigned int *filebuffersize, FMOD_TIMEUNIT *filebuffersizetype);
FMOD_RESULT F_API set3DSettings (float dopplerscale, float distancefactor, float rolloffscale);
FMOD_RESULT F_API get3DSettings (float *dopplerscale, float *distancefactor, float *rolloffscale);
FMOD_RESULT F_API set3DNumListeners (int numlisteners);
FMOD_RESULT F_API get3DNumListeners (int *numlisteners);
FMOD_RESULT F_API set3DListenerAttributes (int listener, const FMOD_VECTOR *pos, const FMOD_VECTOR *vel, const FMOD_VECTOR *forward, const FMOD_VECTOR *up);
FMOD_RESULT F_API get3DListenerAttributes (int listener, FMOD_VECTOR *pos, FMOD_VECTOR *vel, FMOD_VECTOR *forward, FMOD_VECTOR *up);
FMOD_RESULT F_API set3DRolloffCallback (FMOD_3D_ROLLOFF_CALLBACK callback);
FMOD_RESULT F_API mixerSuspend ();
FMOD_RESULT F_API mixerResume ();
// System information functions.
FMOD_RESULT F_API getVersion (unsigned int *version);
FMOD_RESULT F_API getOutputHandle (void **handle);
FMOD_RESULT F_API getChannelsPlaying (int *channels);
FMOD_RESULT F_API getCPUUsage (float *dsp, float *stream, float *geometry, float *update, float *total);
FMOD_RESULT F_API getSoundRAM (int *currentalloced, int *maxalloced, int *total);
// Sound/DSP/Channel/FX creation and retrieval.
FMOD_RESULT F_API createSound (const char *name_or_data, FMOD_MODE mode, FMOD_CREATESOUNDEXINFO *exinfo, Sound **sound);
FMOD_RESULT F_API createStream (const char *name_or_data, FMOD_MODE mode, FMOD_CREATESOUNDEXINFO *exinfo, Sound **sound);
FMOD_RESULT F_API createDSP (const FMOD_DSP_DESCRIPTION *description, DSP **dsp);
FMOD_RESULT F_API createDSPByType (FMOD_DSP_TYPE type, DSP **dsp);
FMOD_RESULT F_API createChannelGroup (const char *name, ChannelGroup **channelgroup);
FMOD_RESULT F_API createSoundGroup (const char *name, SoundGroup **soundgroup);
FMOD_RESULT F_API createReverb3D (Reverb3D **reverb);
FMOD_RESULT F_API playSound (Sound *sound, ChannelGroup *channelgroup, bool paused, Channel **channel);
FMOD_RESULT F_API playDSP (DSP *dsp, ChannelGroup *channelgroup, bool paused, Channel **channel);
FMOD_RESULT F_API getChannel (int channelid, Channel **channel);
FMOD_RESULT F_API getMasterChannelGroup (ChannelGroup **channelgroup);
FMOD_RESULT F_API getMasterSoundGroup (SoundGroup **soundgroup);
// Routing to ports.
FMOD_RESULT F_API attachChannelGroupToPort (FMOD_PORT_TYPE portType, FMOD_PORT_INDEX portIndex, ChannelGroup *channelgroup, bool passThru = false);
FMOD_RESULT F_API detachChannelGroupFromPort (ChannelGroup *channelgroup);
// Reverb API.
FMOD_RESULT F_API setReverbProperties (int instance, const FMOD_REVERB_PROPERTIES *prop);
FMOD_RESULT F_API getReverbProperties (int instance, FMOD_REVERB_PROPERTIES *prop);
// System level DSP functionality.
FMOD_RESULT F_API lockDSP ();
FMOD_RESULT F_API unlockDSP ();
// Recording API.
FMOD_RESULT F_API getRecordNumDrivers (int *numdrivers);
FMOD_RESULT F_API getRecordDriverInfo (int id, char *name, int namelen, FMOD_GUID *guid, int *systemrate, FMOD_SPEAKERMODE *speakermode, int *speakermodechannels);
FMOD_RESULT F_API getRecordPosition (int id, unsigned int *position);
FMOD_RESULT F_API recordStart (int id, Sound *sound, bool loop);
FMOD_RESULT F_API recordStop (int id);
FMOD_RESULT F_API isRecording (int id, bool *recording);
// Geometry API.
FMOD_RESULT F_API createGeometry (int maxpolygons, int maxvertices, Geometry **geometry);
FMOD_RESULT F_API setGeometrySettings (float maxworldsize);
FMOD_RESULT F_API getGeometrySettings (float *maxworldsize);
FMOD_RESULT F_API loadGeometry (const void *data, int datasize, Geometry **geometry);
FMOD_RESULT F_API getGeometryOcclusion (const FMOD_VECTOR *listener, const FMOD_VECTOR *source, float *direct, float *reverb);
// Network functions.
FMOD_RESULT F_API setNetworkProxy (const char *proxy);
FMOD_RESULT F_API getNetworkProxy (char *proxy, int proxylen);
FMOD_RESULT F_API setNetworkTimeout (int timeout);
FMOD_RESULT F_API getNetworkTimeout (int *timeout);
// Userdata set/get.
FMOD_RESULT F_API setUserData (void *userdata);
FMOD_RESULT F_API getUserData (void **userdata);
};
/*
'Sound' API
*/
class Sound
{
private:
Sound(); /* Constructor made private so user cannot statically instance a Sound class.
Appropriate Sound creation or retrieval function must be used. */
public:
FMOD_RESULT F_API release ();
FMOD_RESULT F_API getSystemObject (System **system);
// Standard sound manipulation functions.
FMOD_RESULT F_API lock (unsigned int offset, unsigned int length, void **ptr1, void **ptr2, unsigned int *len1, unsigned int *len2);
FMOD_RESULT F_API unlock (void *ptr1, void *ptr2, unsigned int len1, unsigned int len2);
FMOD_RESULT F_API setDefaults (float frequency, int priority);
FMOD_RESULT F_API getDefaults (float *frequency, int *priority);
FMOD_RESULT F_API set3DMinMaxDistance (float min, float max);
FMOD_RESULT F_API get3DMinMaxDistance (float *min, float *max);
FMOD_RESULT F_API set3DConeSettings (float insideconeangle, float outsideconeangle, float outsidevolume);
FMOD_RESULT F_API get3DConeSettings (float *insideconeangle, float *outsideconeangle, float *outsidevolume);
FMOD_RESULT F_API set3DCustomRolloff (FMOD_VECTOR *points, int numpoints);
FMOD_RESULT F_API get3DCustomRolloff (FMOD_VECTOR **points, int *numpoints);
FMOD_RESULT F_API setSubSound (int index, Sound *subsound);
FMOD_RESULT F_API getSubSound (int index, Sound **subsound);
FMOD_RESULT F_API getSubSoundParent (Sound **parentsound);
FMOD_RESULT F_API getName (char *name, int namelen);
FMOD_RESULT F_API getLength (unsigned int *length, FMOD_TIMEUNIT lengthtype);
FMOD_RESULT F_API getFormat (FMOD_SOUND_TYPE *type, FMOD_SOUND_FORMAT *format, int *channels, int *bits);
FMOD_RESULT F_API getNumSubSounds (int *numsubsounds);
FMOD_RESULT F_API getNumTags (int *numtags, int *numtagsupdated);
FMOD_RESULT F_API getTag (const char *name, int index, FMOD_TAG *tag);
FMOD_RESULT F_API getOpenState (FMOD_OPENSTATE *openstate, unsigned int *percentbuffered, bool *starving, bool *diskbusy);
FMOD_RESULT F_API readData (void *buffer, unsigned int lenbytes, unsigned int *read);
FMOD_RESULT F_API seekData (unsigned int pcm);
FMOD_RESULT F_API setSoundGroup (SoundGroup *soundgroup);
FMOD_RESULT F_API getSoundGroup (SoundGroup **soundgroup);
// Synchronization point API. These points can come from markers embedded in wav files, and can also generate channel callbacks.
FMOD_RESULT F_API getNumSyncPoints (int *numsyncpoints);
FMOD_RESULT F_API getSyncPoint (int index, FMOD_SYNCPOINT **point);
FMOD_RESULT F_API getSyncPointInfo (FMOD_SYNCPOINT *point, char *name, int namelen, unsigned int *offset, FMOD_TIMEUNIT offsettype);
FMOD_RESULT F_API addSyncPoint (unsigned int offset, FMOD_TIMEUNIT offsettype, const char *name, FMOD_SYNCPOINT **point);
FMOD_RESULT F_API deleteSyncPoint (FMOD_SYNCPOINT *point);
// Functions also in Channel class but here they are the 'default' to save having to change it in Channel all the time.
FMOD_RESULT F_API setMode (FMOD_MODE mode);
FMOD_RESULT F_API getMode (FMOD_MODE *mode);
FMOD_RESULT F_API setLoopCount (int loopcount);
FMOD_RESULT F_API getLoopCount (int *loopcount);
FMOD_RESULT F_API setLoopPoints (unsigned int loopstart, FMOD_TIMEUNIT loopstarttype, unsigned int loopend, FMOD_TIMEUNIT loopendtype);
FMOD_RESULT F_API getLoopPoints (unsigned int *loopstart, FMOD_TIMEUNIT loopstarttype, unsigned int *loopend, FMOD_TIMEUNIT loopendtype);
// For MOD/S3M/XM/IT/MID sequenced formats only.
FMOD_RESULT F_API getMusicNumChannels (int *numchannels);
FMOD_RESULT F_API setMusicChannelVolume (int channel, float volume);
FMOD_RESULT F_API getMusicChannelVolume (int channel, float *volume);
FMOD_RESULT F_API setMusicSpeed (float speed);
FMOD_RESULT F_API getMusicSpeed (float *speed);
// Userdata set/get.
FMOD_RESULT F_API setUserData (void *userdata);
FMOD_RESULT F_API getUserData (void **userdata);
};
/*
'ChannelControl API'. This is a base class for Channel and ChannelGroup so they can share the same functionality. This cannot be used or instansiated explicitly.
*/
class ChannelControl
{
private:
ChannelControl(); /* Constructor made private so user cannot statically instance a Control class. */
public:
FMOD_RESULT F_API getSystemObject (System **system);
// General control functionality for Channels and ChannelGroups.
FMOD_RESULT F_API stop ();
FMOD_RESULT F_API setPaused (bool paused);
FMOD_RESULT F_API getPaused (bool *paused);
FMOD_RESULT F_API setVolume (float volume);
FMOD_RESULT F_API getVolume (float *volume);
FMOD_RESULT F_API setVolumeRamp (bool ramp);
FMOD_RESULT F_API getVolumeRamp (bool *ramp);
FMOD_RESULT F_API getAudibility (float *audibility);
FMOD_RESULT F_API setPitch (float pitch);
FMOD_RESULT F_API getPitch (float *pitch);
FMOD_RESULT F_API setMute (bool mute);
FMOD_RESULT F_API getMute (bool *mute);
FMOD_RESULT F_API setReverbProperties (int instance, float wet);
FMOD_RESULT F_API getReverbProperties (int instance, float *wet);
FMOD_RESULT F_API setLowPassGain (float gain);
FMOD_RESULT F_API getLowPassGain (float *gain);
FMOD_RESULT F_API setMode (FMOD_MODE mode);
FMOD_RESULT F_API getMode (FMOD_MODE *mode);
FMOD_RESULT F_API setCallback (FMOD_CHANNELCONTROL_CALLBACK callback);
FMOD_RESULT F_API isPlaying (bool *isplaying);
// Panning and level adjustment.
// Note all 'set' functions alter a final matrix, this is why the only get function is getMixMatrix, to avoid other get functions returning incorrect/obsolete values.
FMOD_RESULT F_API setPan (float pan);
FMOD_RESULT F_API setMixLevelsOutput (float frontleft, float frontright, float center, float lfe, float surroundleft, float surroundright, float backleft, float backright);
FMOD_RESULT F_API setMixLevelsInput (float *levels, int numlevels);
FMOD_RESULT F_API setMixMatrix (float *matrix, int outchannels, int inchannels, int inchannel_hop = 0);
FMOD_RESULT F_API getMixMatrix (float *matrix, int *outchannels, int *inchannels, int inchannel_hop = 0);
// Clock based functionality.
FMOD_RESULT F_API getDSPClock (unsigned long long *dspclock, unsigned long long *parentclock);
FMOD_RESULT F_API setDelay (unsigned long long dspclock_start, unsigned long long dspclock_end, bool stopchannels = true);
FMOD_RESULT F_API getDelay (unsigned long long *dspclock_start, unsigned long long *dspclock_end, bool *stopchannels = 0);
FMOD_RESULT F_API addFadePoint (unsigned long long dspclock, float volume);
FMOD_RESULT F_API setFadePointRamp (unsigned long long dspclock, float volume);
FMOD_RESULT F_API removeFadePoints (unsigned long long dspclock_start, unsigned long long dspclock_end);
FMOD_RESULT F_API getFadePoints (unsigned int *numpoints, unsigned long long *point_dspclock, float *point_volume);
// DSP effects.
FMOD_RESULT F_API getDSP (int index, DSP **dsp);
FMOD_RESULT F_API addDSP (int index, DSP *dsp);
FMOD_RESULT F_API removeDSP (DSP *dsp);
FMOD_RESULT F_API getNumDSPs (int *numdsps);
FMOD_RESULT F_API setDSPIndex (DSP *dsp, int index);
FMOD_RESULT F_API getDSPIndex (DSP *dsp, int *index);
FMOD_RESULT F_API overridePanDSP (DSP *pan);
// 3D functionality.
FMOD_RESULT F_API set3DAttributes (const FMOD_VECTOR *pos, const FMOD_VECTOR *vel, const FMOD_VECTOR *alt_pan_pos = 0);
FMOD_RESULT F_API get3DAttributes (FMOD_VECTOR *pos, FMOD_VECTOR *vel, FMOD_VECTOR *alt_pan_pos = 0);
FMOD_RESULT F_API set3DMinMaxDistance (float mindistance, float maxdistance);
FMOD_RESULT F_API get3DMinMaxDistance (float *mindistance, float *maxdistance);
FMOD_RESULT F_API set3DConeSettings (float insideconeangle, float outsideconeangle, float outsidevolume);
FMOD_RESULT F_API get3DConeSettings (float *insideconeangle, float *outsideconeangle, float *outsidevolume);
FMOD_RESULT F_API set3DConeOrientation (FMOD_VECTOR *orientation);
FMOD_RESULT F_API get3DConeOrientation (FMOD_VECTOR *orientation);
FMOD_RESULT F_API set3DCustomRolloff (FMOD_VECTOR *points, int numpoints);
FMOD_RESULT F_API get3DCustomRolloff (FMOD_VECTOR **points, int *numpoints);
FMOD_RESULT F_API set3DOcclusion (float directocclusion, float reverbocclusion);
FMOD_RESULT F_API get3DOcclusion (float *directocclusion, float *reverbocclusion);
FMOD_RESULT F_API set3DSpread (float angle);
FMOD_RESULT F_API get3DSpread (float *angle);
FMOD_RESULT F_API set3DLevel (float level);
FMOD_RESULT F_API get3DLevel (float *level);
FMOD_RESULT F_API set3DDopplerLevel (float level);
FMOD_RESULT F_API get3DDopplerLevel (float *level);
FMOD_RESULT F_API set3DDistanceFilter (bool custom, float customLevel, float centerFreq);
FMOD_RESULT F_API get3DDistanceFilter (bool *custom, float *customLevel, float *centerFreq);
// Userdata set/get.
FMOD_RESULT F_API setUserData (void *userdata);
FMOD_RESULT F_API getUserData (void **userdata);
};
/*
'Channel' API.
*/
class Channel : public ChannelControl
{
private:
Channel(); /* Constructor made private so user cannot statically instance a Channel class.
Appropriate Channel creation or retrieval function must be used. */
public:
// Channel specific control functionality.
FMOD_RESULT F_API setFrequency (float frequency);
FMOD_RESULT F_API getFrequency (float *frequency);
FMOD_RESULT F_API setPriority (int priority);
FMOD_RESULT F_API getPriority (int *priority);
FMOD_RESULT F_API setPosition (unsigned int position, FMOD_TIMEUNIT postype);
FMOD_RESULT F_API getPosition (unsigned int *position, FMOD_TIMEUNIT postype);
FMOD_RESULT F_API setChannelGroup (ChannelGroup *channelgroup);
FMOD_RESULT F_API getChannelGroup (ChannelGroup **channelgroup);
FMOD_RESULT F_API setLoopCount (int loopcount);
FMOD_RESULT F_API getLoopCount (int *loopcount);
FMOD_RESULT F_API setLoopPoints (unsigned int loopstart, FMOD_TIMEUNIT loopstarttype, unsigned int loopend, FMOD_TIMEUNIT loopendtype);
FMOD_RESULT F_API getLoopPoints (unsigned int *loopstart, FMOD_TIMEUNIT loopstarttype, unsigned int *loopend, FMOD_TIMEUNIT loopendtype);
// Information only functions.
FMOD_RESULT F_API isVirtual (bool *isvirtual);
FMOD_RESULT F_API getCurrentSound (Sound **sound);
FMOD_RESULT F_API getIndex (int *index);
};
/*
'ChannelGroup' API
*/
class ChannelGroup : public ChannelControl
{
private:
ChannelGroup(); /* Constructor made private so user cannot statically instance a ChannelGroup class.
Appropriate ChannelGroup creation or retrieval function must be used. */
public:
FMOD_RESULT F_API release ();
// Nested channel groups.
FMOD_RESULT F_API addGroup (ChannelGroup *group, bool propagatedspclock = true, DSPConnection **connection = 0);
FMOD_RESULT F_API getNumGroups (int *numgroups);
FMOD_RESULT F_API getGroup (int index, ChannelGroup **group);
FMOD_RESULT F_API getParentGroup (ChannelGroup **group);
// Information only functions.
FMOD_RESULT F_API getName (char *name, int namelen);
FMOD_RESULT F_API getNumChannels (int *numchannels);
FMOD_RESULT F_API getChannel (int index, Channel **channel);
};
/*
'SoundGroup' API
*/
class SoundGroup
{
private:
SoundGroup(); /* Constructor made private so user cannot statically instance a SoundGroup class.
Appropriate SoundGroup creation or retrieval function must be used. */
public:
FMOD_RESULT F_API release ();
FMOD_RESULT F_API getSystemObject (System **system);
// SoundGroup control functions.
FMOD_RESULT F_API setMaxAudible (int maxaudible);
FMOD_RESULT F_API getMaxAudible (int *maxaudible);
FMOD_RESULT F_API setMaxAudibleBehavior (FMOD_SOUNDGROUP_BEHAVIOR behavior);
FMOD_RESULT F_API getMaxAudibleBehavior (FMOD_SOUNDGROUP_BEHAVIOR *behavior);
FMOD_RESULT F_API setMuteFadeSpeed (float speed);
FMOD_RESULT F_API getMuteFadeSpeed (float *speed);
FMOD_RESULT F_API setVolume (float volume);
FMOD_RESULT F_API getVolume (float *volume);
FMOD_RESULT F_API stop ();
// Information only functions.
FMOD_RESULT F_API getName (char *name, int namelen);
FMOD_RESULT F_API getNumSounds (int *numsounds);
FMOD_RESULT F_API getSound (int index, Sound **sound);
FMOD_RESULT F_API getNumPlaying (int *numplaying);
// Userdata set/get.
FMOD_RESULT F_API setUserData (void *userdata);
FMOD_RESULT F_API getUserData (void **userdata);
};
/*
'DSP' API
*/
class DSP
{
private:
DSP(); /* Constructor made private so user cannot statically instance a DSP class.
Appropriate DSP creation or retrieval function must be used. */
public:
FMOD_RESULT F_API release ();
FMOD_RESULT F_API getSystemObject (System **system);
// Connection / disconnection / input and output enumeration.
FMOD_RESULT F_API addInput (DSP *input, DSPConnection **connection = 0, FMOD_DSPCONNECTION_TYPE type = FMOD_DSPCONNECTION_TYPE_STANDARD);
FMOD_RESULT F_API disconnectFrom (DSP *target, DSPConnection *connection = 0);
FMOD_RESULT F_API disconnectAll (bool inputs, bool outputs);
FMOD_RESULT F_API getNumInputs (int *numinputs);
FMOD_RESULT F_API getNumOutputs (int *numoutputs);
FMOD_RESULT F_API getInput (int index, DSP **input, DSPConnection **inputconnection);
FMOD_RESULT F_API getOutput (int index, DSP **output, DSPConnection **outputconnection);
// DSP unit control.
FMOD_RESULT F_API setActive (bool active);
FMOD_RESULT F_API getActive (bool *active);
FMOD_RESULT F_API setBypass (bool bypass);
FMOD_RESULT F_API getBypass (bool *bypass);
FMOD_RESULT F_API setWetDryMix (float prewet, float postwet, float dry);
FMOD_RESULT F_API getWetDryMix (float *prewet, float *postwet, float *dry);
FMOD_RESULT F_API setChannelFormat (FMOD_CHANNELMASK channelmask, int numchannels, FMOD_SPEAKERMODE source_speakermode);
FMOD_RESULT F_API getChannelFormat (FMOD_CHANNELMASK *channelmask, int *numchannels, FMOD_SPEAKERMODE *source_speakermode);
FMOD_RESULT F_API getOutputChannelFormat (FMOD_CHANNELMASK inmask, int inchannels, FMOD_SPEAKERMODE inspeakermode, FMOD_CHANNELMASK *outmask, int *outchannels, FMOD_SPEAKERMODE *outspeakermode);
FMOD_RESULT F_API reset ();
// DSP parameter control.
FMOD_RESULT F_API setParameterFloat (int index, float value);
FMOD_RESULT F_API setParameterInt (int index, int value);
FMOD_RESULT F_API setParameterBool (int index, bool value);
FMOD_RESULT F_API setParameterData (int index, void *data, unsigned int length);
FMOD_RESULT F_API getParameterFloat (int index, float *value, char *valuestr, int valuestrlen);
FMOD_RESULT F_API getParameterInt (int index, int *value, char *valuestr, int valuestrlen);
FMOD_RESULT F_API getParameterBool (int index, bool *value, char *valuestr, int valuestrlen);
FMOD_RESULT F_API getParameterData (int index, void **data, unsigned int *length, char *valuestr, int valuestrlen);
FMOD_RESULT F_API getNumParameters (int *numparams);
FMOD_RESULT F_API getParameterInfo (int index, FMOD_DSP_PARAMETER_DESC **desc);
FMOD_RESULT F_API getDataParameterIndex (int datatype, int *index);
FMOD_RESULT F_API showConfigDialog (void *hwnd, bool show);
// DSP attributes.
FMOD_RESULT F_API getInfo (char *name, unsigned int *version, int *channels, int *configwidth, int *configheight);
FMOD_RESULT F_API getType (FMOD_DSP_TYPE *type);
FMOD_RESULT F_API getIdle (bool *idle);
// Userdata set/get.
FMOD_RESULT F_API setUserData (void *userdata);
FMOD_RESULT F_API getUserData (void **userdata);
// Metering.
FMOD_RESULT F_API setMeteringEnabled (bool inputEnabled, bool outputEnabled);
FMOD_RESULT F_API getMeteringEnabled (bool *inputEnabled, bool *outputEnabled);
FMOD_RESULT F_API getMeteringInfo (FMOD_DSP_METERING_INFO *inputInfo, FMOD_DSP_METERING_INFO *outputInfo);
};
/*
'DSPConnection' API
*/
class DSPConnection
{
private:
DSPConnection(); /* Constructor made private so user cannot statically instance a DSPConnection class.
Appropriate DSPConnection creation or retrieval function must be used. */
public:
FMOD_RESULT F_API getInput (DSP **input);
FMOD_RESULT F_API getOutput (DSP **output);
FMOD_RESULT F_API setMix (float volume);
FMOD_RESULT F_API getMix (float *volume);
FMOD_RESULT F_API setMixMatrix (float *matrix, int outchannels, int inchannels, int inchannel_hop = 0);
FMOD_RESULT F_API getMixMatrix (float *matrix, int *outchannels, int *inchannels, int inchannel_hop = 0);
FMOD_RESULT F_API getType (FMOD_DSPCONNECTION_TYPE *type);
// Userdata set/get.
FMOD_RESULT F_API setUserData (void *userdata);
FMOD_RESULT F_API getUserData (void **userdata);
};
/*
'Geometry' API
*/
class Geometry
{
private:
Geometry(); /* Constructor made private so user cannot statically instance a Geometry class.
Appropriate Geometry creation or retrieval function must be used. */
public:
FMOD_RESULT F_API release ();
// Polygon manipulation.
FMOD_RESULT F_API addPolygon (float directocclusion, float reverbocclusion, bool doublesided, int numvertices, const FMOD_VECTOR *vertices, int *polygonindex);
FMOD_RESULT F_API getNumPolygons (int *numpolygons);
FMOD_RESULT F_API getMaxPolygons (int *maxpolygons, int *maxvertices);
FMOD_RESULT F_API getPolygonNumVertices (int index, int *numvertices);
FMOD_RESULT F_API setPolygonVertex (int index, int vertexindex, const FMOD_VECTOR *vertex);
FMOD_RESULT F_API getPolygonVertex (int index, int vertexindex, FMOD_VECTOR *vertex);
FMOD_RESULT F_API setPolygonAttributes (int index, float directocclusion, float reverbocclusion, bool doublesided);
FMOD_RESULT F_API getPolygonAttributes (int index, float *directocclusion, float *reverbocclusion, bool *doublesided);
// Object manipulation.
FMOD_RESULT F_API setActive (bool active);
FMOD_RESULT F_API getActive (bool *active);
FMOD_RESULT F_API setRotation (const FMOD_VECTOR *forward, const FMOD_VECTOR *up);
FMOD_RESULT F_API getRotation (FMOD_VECTOR *forward, FMOD_VECTOR *up);
FMOD_RESULT F_API setPosition (const FMOD_VECTOR *position);
FMOD_RESULT F_API getPosition (FMOD_VECTOR *position);
FMOD_RESULT F_API setScale (const FMOD_VECTOR *scale);
FMOD_RESULT F_API getScale (FMOD_VECTOR *scale);
FMOD_RESULT F_API save (void *data, int *datasize);
// Userdata set/get.
FMOD_RESULT F_API setUserData (void *userdata);
FMOD_RESULT F_API getUserData (void **userdata);
};
/*
'Reverb' API
*/
class Reverb3D
{
private:
Reverb3D(); /* Constructor made private so user cannot statically instance a Reverb3D class.
Appropriate Reverb creation or retrieval function must be used. */
public:
FMOD_RESULT F_API release ();
// Reverb manipulation.
FMOD_RESULT F_API set3DAttributes (const FMOD_VECTOR *position, float mindistance, float maxdistance);
FMOD_RESULT F_API get3DAttributes (FMOD_VECTOR *position, float *mindistance,float *maxdistance);
FMOD_RESULT F_API setProperties (const FMOD_REVERB_PROPERTIES *properties);
FMOD_RESULT F_API getProperties (FMOD_REVERB_PROPERTIES *properties);
FMOD_RESULT F_API setActive (bool active);
FMOD_RESULT F_API getActive (bool *active);
// Userdata set/get.
FMOD_RESULT F_API setUserData (void *userdata);
FMOD_RESULT F_API getUserData (void **userdata);
};
}
#endif
+179
View File
@@ -0,0 +1,179 @@
/* ======================================================================================================== */
/* FMOD Studio - codec development header file. Copyright (c), Firelight Technologies Pty, Ltd. 2004-2015. */
/* */
/* Use this header if you are wanting to develop your own file format plugin to use with */
/* FMOD's codec system. With this header you can make your own fileformat plugin that FMOD */
/* can register and use. See the documentation and examples on how to make a working plugin. */
/* */
/* ======================================================================================================== */
#ifndef _FMOD_CODEC_H
#define _FMOD_CODEC_H
typedef struct FMOD_CODEC_STATE FMOD_CODEC_STATE;
typedef struct FMOD_CODEC_WAVEFORMAT FMOD_CODEC_WAVEFORMAT;
/*
Codec callbacks
*/
typedef FMOD_RESULT (F_CALLBACK *FMOD_CODEC_OPEN_CALLBACK) (FMOD_CODEC_STATE *codec_state, FMOD_MODE usermode, FMOD_CREATESOUNDEXINFO *userexinfo);
typedef FMOD_RESULT (F_CALLBACK *FMOD_CODEC_CLOSE_CALLBACK) (FMOD_CODEC_STATE *codec_state);
typedef FMOD_RESULT (F_CALLBACK *FMOD_CODEC_READ_CALLBACK) (FMOD_CODEC_STATE *codec_state, void *buffer, unsigned int sizebytes, unsigned int *bytesread);
typedef FMOD_RESULT (F_CALLBACK *FMOD_CODEC_GETLENGTH_CALLBACK) (FMOD_CODEC_STATE *codec_state, unsigned int *length, FMOD_TIMEUNIT lengthtype);
typedef FMOD_RESULT (F_CALLBACK *FMOD_CODEC_SETPOSITION_CALLBACK) (FMOD_CODEC_STATE *codec_state, int subsound, unsigned int position, FMOD_TIMEUNIT postype);
typedef FMOD_RESULT (F_CALLBACK *FMOD_CODEC_GETPOSITION_CALLBACK) (FMOD_CODEC_STATE *codec_state, unsigned int *position, FMOD_TIMEUNIT postype);
typedef FMOD_RESULT (F_CALLBACK *FMOD_CODEC_SOUNDCREATE_CALLBACK) (FMOD_CODEC_STATE *codec_state, int subsound, FMOD_SOUND *sound);
typedef FMOD_RESULT (F_CALLBACK *FMOD_CODEC_METADATA_CALLBACK) (FMOD_CODEC_STATE *codec_state, FMOD_TAGTYPE tagtype, char *name, void *data, unsigned int datalen, FMOD_TAGDATATYPE datatype, int unique);
typedef FMOD_RESULT (F_CALLBACK *FMOD_CODEC_GETWAVEFORMAT_CALLBACK)(FMOD_CODEC_STATE *codec_state, int index, FMOD_CODEC_WAVEFORMAT *waveformat);
/*
[STRUCTURE]
[
[DESCRIPTION]
When creating a codec, declare one of these and provide the relevant callbacks and name for FMOD to use when it opens and reads a file.
[REMARKS]
Members marked with [in] mean the variable can be written to. The user can set the value.<br>
Members marked with [out] mean the variable is modified by FMOD and is for reading purposes only. Do not change this value.<br>
[SEE_ALSO]
FMOD_CODEC_STATE
FMOD_CODEC_WAVEFORMAT
]
*/
typedef struct FMOD_CODEC_DESCRIPTION
{
const char *name; /* [in] Name of the codec. */
unsigned int version; /* [in] Plugin writer's version number. */
int defaultasstream; /* [in] Tells FMOD to open the file as a stream when calling System::createSound, and not a static sample. Should normally be 0 (FALSE), because generally the user wants to decode the file into memory when using System::createSound. Mainly used for formats that decode for a very long time, or could use large amounts of memory when decoded. Usually sequenced formats such as mod/s3m/xm/it/midi fall into this category. It is mainly to stop users that don't know what they're doing from getting FMOD_ERR_MEMORY returned from createSound when they should have in fact called System::createStream or used FMOD_CREATESTREAM in System::createSound. */
FMOD_TIMEUNIT timeunits; /* [in] When setposition codec is called, only these time formats will be passed to the codec. Use bitwise OR to accumulate different types. */
FMOD_CODEC_OPEN_CALLBACK open; /* [in] Open callback for the codec for when FMOD tries to open a sound using this codec. */
FMOD_CODEC_CLOSE_CALLBACK close; /* [in] Close callback for the codec for when FMOD tries to close a sound using this codec. */
FMOD_CODEC_READ_CALLBACK read; /* [in] Read callback for the codec for when FMOD tries to read some data from the file to the destination format (specified in the open callback). */
FMOD_CODEC_GETLENGTH_CALLBACK getlength; /* [in] Callback to return the length of the song in whatever format required when Sound::getLength is called. */
FMOD_CODEC_SETPOSITION_CALLBACK setposition; /* [in] Seek callback for the codec for when FMOD tries to seek within the file with Channel::setPosition. */
FMOD_CODEC_GETPOSITION_CALLBACK getposition; /* [in] Tell callback for the codec for when FMOD tries to get the current position within the with Channel::getPosition. */
FMOD_CODEC_SOUNDCREATE_CALLBACK soundcreate; /* [in] Sound creation callback for the codec when FMOD finishes creating the sound. (So the codec can set more parameters for the related created sound, ie loop points/mode or 3D attributes etc). */
FMOD_CODEC_GETWAVEFORMAT_CALLBACK getwaveformat; /* [in] Callback to tell FMOD about the waveformat of a particular subsound. This is to save memory, rather than saving 1000 FMOD_CODEC_WAVEFORMAT structures in the codec, the codec might have a more optimal way of storing this information. */
} FMOD_CODEC_DESCRIPTION;
/*
[STRUCTURE]
[
[DESCRIPTION]
Set these values marked 'in' to tell fmod what sort of sound to create.<br>
The format, channels and frequency tell FMOD what sort of hardware buffer to create when you initialize your code. So if you wrote an MP3 codec that decoded to stereo 16bit integer PCM, you would specify FMOD_SOUND_FORMAT_PCM16, and channels would be equal to 2.<br>
Members marked as 'out' are set by fmod. Do not modify these. Simply specify 0 for these values when declaring the structure, FMOD will fill in the values for you after creation with the correct function pointers.<br>
[REMARKS]
Members marked with [in] mean the variable can be written to. The user can set the value.<br>
Members marked with [out] mean the variable is modified by FMOD and is for reading purposes only. Do not change this value.<br>
<br>
An FMOD file might be from disk, memory or network, however the file may be opened by the user.<br>
<br>
'numsubsounds' should be 0 if the file is a normal single sound stream or sound. Examples of this would be .WAV, .WMA, .MP3, .AIFF.<br>
'numsubsounds' should be 1+ if the file is a container format, and does not contain wav data itself. Examples of these types would be FSB (contains multiple sounds), MIDI/MOD/S3M/XM/IT (contain instruments).<br>
The arrays of format, channel, frequency, length and blockalign should point to arrays of information based on how many subsounds are in the format. If the number of subsounds is 0 then it should point to 1 of each attribute, the same as if the number of subsounds was 1. If subsounds was 100 for example, each pointer should point to an array of 100 of each attribute.<br>
When a sound has 1 or more subsounds, you must play the individual sounds specified by first obtaining the subsound with Sound::getSubSound.
[SEE_ALSO]
FMOD_SOUND_FORMAT
FMOD_MODE
FMOD_CHANNELMASK
FMOD_CHANNELORDER
FMOD_SPEAKER
FMOD_FILE_READCALLBACK
FMOD_FILE_SEEKCALLBACK
FMOD_CODEC_METADATACALLBACK
Sound::getSubSound
Sound::getNumSubSounds
]
*/
struct FMOD_CODEC_WAVEFORMAT
{
char name[256]; /* [in] Name of sound.*/
FMOD_SOUND_FORMAT format; /* [in] Format for (decompressed) codec output, ie FMOD_SOUND_FORMAT_PCM8, FMOD_SOUND_FORMAT_PCM16.*/
int channels; /* [in] Number of channels used by codec, ie mono = 1, stereo = 2. */
int frequency; /* [in] Default frequency in hz of the codec, ie 44100. */
unsigned int lengthbytes; /* [in] Length in bytes of the source data. */
unsigned int lengthpcm; /* [in] Length in decompressed, PCM samples of the file, ie length in seconds * frequency. Used for Sound::getLength and for memory allocation of static decompressed sample data. */
int blockalign; /* [in] Blockalign in decompressed, PCM samples of the optimal decode chunk size for this format. The codec read callback will be called in multiples of this value. */
int loopstart; /* [in] Loopstart in decompressed, PCM samples of file. */
int loopend; /* [in] Loopend in decompressed, PCM samples of file. */
FMOD_MODE mode; /* [in] Mode to determine whether the sound should by default load as looping, non looping, 2d or 3d. */
FMOD_CHANNELMASK channelmask; /* [in] Defined channel bitmask to describe which speakers the channels in the codec map to, in order of channel count. See fmod_common.h. Leave at 0 to map to the speaker layout defined in FMOD_SPEAKER. */
FMOD_CHANNELORDER channelorder; /* [in] Defined channel order type, to describe where each sound channel should pan for the number of channels specified. See fmod_common.h. Leave at 0 to play in default speaker order. */
float peakvolume; /* [in] Peak volume of sound, or 0 if not used. */
};
/*
[DEFINE]
[
[NAME]
FMOD_CODEC_WAVEFORMAT_VERSION
[DESCRIPTION]
Version number of FMOD_CODEC_WAVEFORMAT structure. Should be set into FMOD_CODEC_STATE in the FMOD_CODEC_OPEN_CALLBACK.
[REMARKS]
[SEE_ALSO]
FMOD_CODEC_STATE
FMOD_CODEC_DESCRIPTION
FMOD_CODEC_OPEN_CALLBACK
]
*/
#define FMOD_CODEC_WAVEFORMAT_VERSION 1
/* [DEFINE_END] */
/*
[STRUCTURE]
[
[DESCRIPTION]
Codec plugin structure that is passed into each callback.
Set these numsubsounds and waveformat members when called in FMOD_CODEC_OPEN_CALLBACK to tell fmod what sort of sound to create.
The format, channels and frequency tell FMOD what sort of hardware buffer to create when you initialize your code. So if you wrote an MP3 codec that decoded to stereo 16bit integer PCM, you would specify FMOD_SOUND_FORMAT_PCM16, and channels would be equal to 2.
[REMARKS]
Members marked with [in] mean the variable can be written to. The user can set the value.<br>
Members marked with [out] mean the variable is modified by FMOD and is for reading purposes only. Do not change this value.<br>
<br>
An FMOD file might be from disk, memory or internet, however the file may be opened by the user.<br>
<br>
'numsubsounds' should be 0 if the file is a normal single sound stream or sound. Examples of this would be .WAV, .WMA, .MP3, .AIFF.<br>
'numsubsounds' should be 1+ if the file is a container format, and does not contain wav data itself. Examples of these types would be FSB (contains multiple sounds), DLS (contain instruments).<br>
The arrays of format, channel, frequency, length and blockalign should point to arrays of information based on how many subsounds are in the format. If the number of subsounds is 0 then it should point to 1 of each attribute, the same as if the number of subsounds was 1. If subsounds was 100 for example, each pointer should point to an array of 100 of each attribute.<br>
When a sound has 1 or more subsounds, you must play the individual sounds specified by first obtaining the subsound with Sound::getSubSound.
[SEE_ALSO]
FMOD_SOUND_FORMAT
FMOD_FILE_READ_CALLBACK
FMOD_FILE_SEEK_CALLBACK
FMOD_CODEC_METADATA_CALLBACK
Sound::getSubSound
Sound::getNumSubSounds
]
*/
struct FMOD_CODEC_STATE
{
int numsubsounds; /* [in] Number of 'subsounds' in this sound. Anything other than 0 makes it a 'container' format (ie DLS/FSB etc which contain 1 or more subsounds). For most normal, single sound codec such as WAV/AIFF/MP3, this should be 0 as they are not a container for subsounds, they are the sound by itself. */
FMOD_CODEC_WAVEFORMAT *waveformat; /* [in] Pointer to an array of format structures containing information about each sample. Can be 0 or NULL if FMOD_CODEC_GETWAVEFORMAT_CALLBACK callback is preferred. The number of entries here must equal the number of subsounds defined in the subsound parameter. If numsubsounds = 0 then there should be 1 instance of this structure. */
void *plugindata; /* [in] Plugin writer created data the codec author wants to attach to this object. */
void *filehandle; /* [out] This will return an internal FMOD file handle to use with the callbacks provided. */
unsigned int filesize; /* [out] This will contain the size of the file in bytes. */
FMOD_FILE_READ_CALLBACK fileread; /* [out] This will return a callable FMOD file function to use from codec. */
FMOD_FILE_SEEK_CALLBACK fileseek; /* [out] This will return a callable FMOD file function to use from codec. */
FMOD_CODEC_METADATA_CALLBACK metadata; /* [out] This will return a callable FMOD metadata function to use from codec. */
int waveformatversion; /* [in] Must be set to FMOD_CODEC_WAVEFORMAT_VERSION in the FMOD_CODEC_OPEN_CALLBACK. */
};
#endif
File diff suppressed because it is too large Load Diff
+783
View File
@@ -0,0 +1,783 @@
/* ========================================================================================== */
/* FMOD Studio - DSP header file. Copyright (c), Firelight Technologies Pty, Ltd. 2004-2015. */
/* */
/* Use this header if you are interested in delving deeper into the FMOD software mixing / */
/* DSP engine. */
/* Also use this header if you are wanting to develop your own DSP plugin to use with FMOD's */
/* dsp system. With this header you can make your own DSP plugin that FMOD can */
/* register and use. See the documentation and examples on how to make a working plugin. */
/* */
/* ========================================================================================== */
#ifndef _FMOD_DSP_H
#define _FMOD_DSP_H
#include "fmod_dsp_effects.h"
typedef struct FMOD_DSP_STATE FMOD_DSP_STATE;
/*
[STRUCTURE]
[
[DESCRIPTION]
Structure for FMOD_DSP_PROCESS_CALLBACK input and output buffers.
[REMARKS]
Members marked with [r] mean the variable is modified by FMOD and is for reading purposes only. Do not change this value.<br>
Members marked with [w] mean the variable can be written to. The user can set the value.<br>
[SEE_ALSO]
FMOD_DSP_DESCRIPTION
]
*/
typedef struct FMOD_DSP_BUFFER_ARRAY
{
int numbuffers; /* [r/w] number of buffers */
int *buffernumchannels; /* [r/w] array of number of channels for each buffer */
FMOD_CHANNELMASK *bufferchannelmask; /* [r/w] array of channel masks for each buffer */
float **buffers; /* [r/w] array of buffers */
FMOD_SPEAKERMODE speakermode; /* [r/w] speaker mode for all buffers in the array */
} FMOD_DSP_BUFFER_ARRAY;
/*
[ENUM]
[
[DESCRIPTION]
Operation type for FMOD_DSP_PROCESS_CALLBACK.
[REMARKS]
A process callback will be called twice per mix for a DSP unit. Once with the FMOD_DSP_PROCESS_QUERY command, then conditionally, FMOD_DSP_PROCESS_PERFORM.<br>
FMOD_DSP_PROCESS_QUERY is to be handled only by filling out the outputarray information, and returning a relevant return code.<br>
It should not really do any logic besides checking and returning one of the following codes:<br>
- FMOD_OK - Meaning yes, it should execute the dsp process function with FMOD_DSP_PROCESS_PERFORM<br>
- FMOD_ERR_DSP_DONTPROCESS - Meaning no, it should skip the process function and not call it with FMOD_DSP_PROCESS_PERFORM.<br>
- FMOD_ERR_DSP_SILENCE - Meaning no, it should skip the process function and not call it with FMOD_DSP_PROCESS_PERFORM, AND, tell the signal chain to follow that it is now idle, so that no more processing happens down the chain.<br>
If audio is to be processed, 'outbufferarray' must be filled with the expected output format, channel count and mask. Mask can be 0.<br>
<br>
FMOD_DSP_PROCESS_PROCESS is to be handled by reading the data from the input, processing it, and writing it to the output. Always write to the output buffer and fill it fully to avoid unpredictable audio output.<br>
Always return FMOD_OK, the return value is ignored from the process stage.
[SEE_ALSO]
FMOD_DSP_DESCRIPTION
]
*/
typedef enum
{
FMOD_DSP_PROCESS_PERFORM, /* Process the incoming audio in 'inbufferarray' and output to 'outbufferarray'. */
FMOD_DSP_PROCESS_QUERY /* The DSP is being queried for the expected output format and whether it needs to process audio or should be bypassed. The function should return FMOD_OK, or FMOD_ERR_DSP_DONTPROCESS or FMOD_ERR_DSP_SILENCE if audio can pass through unprocessed. See remarks for more. If audio is to be processed, 'outbufferarray' must be filled with the expected output format, channel count and mask. */
} FMOD_DSP_PROCESS_OPERATION;
/*
[STRUCTURE]
[
[DESCRIPTION]
Complex number structure used for holding FFT frequency domain-data for FMOD_FFTREAL and FMOD_IFFTREAL DSP callbacks.
[REMARKS]
[SEE_ALSO]
FMOD_DSP_STATE_SYSTEMCALLBACKS
]
*/
typedef struct FMOD_COMPLEX
{
float real; /* Real component */
float imag; /* Imaginary component */
} FMOD_COMPLEX;
/*
[ENUM]
[
[DESCRIPTION]
Flags for the FMOD_PAN_SUM_SURROUND_MATRIX callback.
[REMARKS]
This functionality is experimental, please contact [email protected] for more information.
[SEE_ALSO]
FMOD_DSP_STATE_PAN_CALLBACKS
]
*/
typedef enum
{
FMOD_PAN_SURROUND_DEFAULT = 0,
FMOD_PAN_SURROUND_ROTATION_NOT_BIASED = 1,
FMOD_PAN_SURROUND_FLAGS_FORCEINT = 65536 /* Makes sure this enum is signed 32bit. */
} FMOD_PAN_SURROUND_FLAGS;
/*
DSP callbacks
*/
typedef FMOD_RESULT (F_CALLBACK *FMOD_DSP_CREATE_CALLBACK) (FMOD_DSP_STATE *dsp_state);
typedef FMOD_RESULT (F_CALLBACK *FMOD_DSP_RELEASE_CALLBACK) (FMOD_DSP_STATE *dsp_state);
typedef FMOD_RESULT (F_CALLBACK *FMOD_DSP_RESET_CALLBACK) (FMOD_DSP_STATE *dsp_state);
typedef FMOD_RESULT (F_CALLBACK *FMOD_DSP_SETPOSITION_CALLBACK) (FMOD_DSP_STATE *dsp_state, unsigned int pos);
typedef FMOD_RESULT (F_CALLBACK *FMOD_DSP_READ_CALLBACK) (FMOD_DSP_STATE *dsp_state, float *inbuffer, float *outbuffer, unsigned int length, int inchannels, int *outchannels);
typedef FMOD_RESULT (F_CALLBACK *FMOD_DSP_SHOULDIPROCESS_CALLBACK) (FMOD_DSP_STATE *dsp_state, FMOD_BOOL inputsidle, unsigned int length, FMOD_CHANNELMASK inmask, int inchannels, FMOD_SPEAKERMODE speakermode);
typedef FMOD_RESULT (F_CALLBACK *FMOD_DSP_PROCESS_CALLBACK) (FMOD_DSP_STATE *dsp_state, unsigned int length, const FMOD_DSP_BUFFER_ARRAY *inbufferarray, FMOD_DSP_BUFFER_ARRAY *outbufferarray, FMOD_BOOL inputsidle, FMOD_DSP_PROCESS_OPERATION op);
typedef FMOD_RESULT (F_CALLBACK *FMOD_DSP_SETPARAM_FLOAT_CALLBACK) (FMOD_DSP_STATE *dsp_state, int index, float value);
typedef FMOD_RESULT (F_CALLBACK *FMOD_DSP_SETPARAM_INT_CALLBACK) (FMOD_DSP_STATE *dsp_state, int index, int value);
typedef FMOD_RESULT (F_CALLBACK *FMOD_DSP_SETPARAM_BOOL_CALLBACK) (FMOD_DSP_STATE *dsp_state, int index, FMOD_BOOL value);
typedef FMOD_RESULT (F_CALLBACK *FMOD_DSP_SETPARAM_DATA_CALLBACK) (FMOD_DSP_STATE *dsp_state, int index, void *data, unsigned int length);
typedef FMOD_RESULT (F_CALLBACK *FMOD_DSP_GETPARAM_FLOAT_CALLBACK) (FMOD_DSP_STATE *dsp_state, int index, float *value, char *valuestr);
typedef FMOD_RESULT (F_CALLBACK *FMOD_DSP_GETPARAM_INT_CALLBACK) (FMOD_DSP_STATE *dsp_state, int index, int *value, char *valuestr);
typedef FMOD_RESULT (F_CALLBACK *FMOD_DSP_GETPARAM_BOOL_CALLBACK) (FMOD_DSP_STATE *dsp_state, int index, FMOD_BOOL *value, char *valuestr);
typedef FMOD_RESULT (F_CALLBACK *FMOD_DSP_GETPARAM_DATA_CALLBACK) (FMOD_DSP_STATE *dsp_state, int index, void **data, unsigned int *length, char *valuestr);
typedef FMOD_RESULT (F_CALLBACK *FMOD_DSP_SYSTEM_GETSAMPLERATE) (FMOD_DSP_STATE *dsp_state, int *rate);
typedef FMOD_RESULT (F_CALLBACK *FMOD_DSP_SYSTEM_GETBLOCKSIZE) (FMOD_DSP_STATE *dsp_state, unsigned int *blocksize);
typedef FMOD_RESULT (F_CALLBACK *FMOD_FFTREAL) (FMOD_DSP_STATE* thisdsp, int size, const float *signal, FMOD_COMPLEX* dft, const float *window, int signalhop);
typedef FMOD_RESULT (F_CALLBACK *FMOD_IFFTREAL) (FMOD_DSP_STATE* thisdsp, int size, const FMOD_COMPLEX *dft, float* signal, const float *window, int signalhop);
typedef FMOD_RESULT (F_CALLBACK *FMOD_PAN_SUM_MONO_MATRIX) (FMOD_DSP_STATE *dsp_state, int sourceSpeakerMode, float lowFrequencyGain, float overallGain, float *matrix);
typedef FMOD_RESULT (F_CALLBACK *FMOD_PAN_SUM_STEREO_MATRIX) (FMOD_DSP_STATE *dsp_state, int sourceSpeakerMode, float pan, float lowFrequencyGain, float overallGain, int matrixHop, float *matrix);
typedef FMOD_RESULT (F_CALLBACK *FMOD_PAN_SUM_SURROUND_MATRIX) (FMOD_DSP_STATE *dsp_state, int sourceSpeakerMode, int targetSpeakerMode, float direction, float extent, float rotation, float lowFrequencyGain, float overallGain, int matrixHop, float *matrix, FMOD_PAN_SURROUND_FLAGS flags);
typedef FMOD_RESULT (F_CALLBACK *FMOD_PAN_SUM_MONO_TO_SURROUND_MATRIX) (FMOD_DSP_STATE *dsp_state, int targetSpeakerMode, float direction, float extent, float lowFrequencyGain, float overallGain, int matrixHop, float *matrix);
typedef FMOD_RESULT (F_CALLBACK *FMOD_PAN_SUM_STEREO_TO_SURROUND_MATRIX)(FMOD_DSP_STATE *dsp_state, int targetSpeakerMode, float direction, float extent, float rotation, float lowFrequencyGain, float overallGain, int matrixHop, float *matrix);
typedef FMOD_RESULT (F_CALLBACK *FMOD_PAN_3D_GET_ROLLOFF_GAIN) (FMOD_DSP_STATE *dsp_state, FMOD_DSP_PAN_3D_ROLLOFF_TYPE rolloff, float distance, float mindistance, float maxdistance, float *gain);
/*
[DEFINE]
[
[NAME]
FMOD_DSP_GETPARAM_VALUESTR_LENGTH
[DESCRIPTION]
Length in bytes of the buffer pointed to by the valuestr argument of FMOD_DSP_GETPARAM_XXXX_CALLBACK functions.
[REMARKS]
DSP plugins should not copy more than this number of bytes into the buffer or memory corruption will occur.
[SEE_ALSO]
FMOD_DSP_GETPARAM_FLOAT_CALLBACK
FMOD_DSP_GETPARAM_INT_CALLBACK
FMOD_DSP_GETPARAM_BOOL_CALLBACK
FMOD_DSP_GETPARAM_DATA_CALLBACK
]
*/
#define FMOD_DSP_GETPARAM_VALUESTR_LENGTH 32
/* [DEFINE_END] */
/*
[ENUM]
[
[DESCRIPTION]
DSP parameter types.
[REMARKS]
[SEE_ALSO]
FMOD_DSP_PARAMETER_DESC
]
*/
typedef enum
{
FMOD_DSP_PARAMETER_TYPE_FLOAT,
FMOD_DSP_PARAMETER_TYPE_INT,
FMOD_DSP_PARAMETER_TYPE_BOOL,
FMOD_DSP_PARAMETER_TYPE_DATA,
FMOD_DSP_PARAMETER_TYPE_MAX, /* Maximum number of DSP parameter types. */
FMOD_DSP_PARAMETER_TYPE_FORCEINT = 65536 /* Makes sure this enum is signed 32bit. */
} FMOD_DSP_PARAMETER_TYPE;
/*
[ENUM]
[
[DESCRIPTION]
DSP float parameter mappings. These determine how values are mapped across dials and automation curves.
[REMARKS]
FMOD_DSP_PARAMETER_FLOAT_MAPPING_TYPE_AUTO generates a mapping based on range and units. For example, if the units are in Hertz and the range is with-in the audio spectrum, a Bark scale will be chosen. Logarithmic scales may also be generated for ranges above zero spanning several orders of magnitude.
[SEE_ALSO]
FMOD_DSP_PARAMETER_FLOAT_MAPPING
]
*/
typedef enum
{
FMOD_DSP_PARAMETER_FLOAT_MAPPING_TYPE_LINEAR, /* Values mapped linearly across range. */
FMOD_DSP_PARAMETER_FLOAT_MAPPING_TYPE_AUTO, /* A mapping is automatically chosen based on range and units. See remarks. */
FMOD_DSP_PARAMETER_FLOAT_MAPPING_TYPE_PIECEWISE_LINEAR, /* Values mapped in a piecewise linear fashion defined by FMOD_DSP_PARAMETER_DESC_FLOAT::mapping.piecewiselinearmapping. */
FMOD_DSP_PARAMETER_FLOAT_MAPPING_TYPE_FORCEINT = 65536 /* Makes sure this enum is signed 32bit. */
} FMOD_DSP_PARAMETER_FLOAT_MAPPING_TYPE;
/*
[STRUCTURE]
[
[DESCRIPTION]
Structure to define a mapping for a DSP unit's float parameter.
[REMARKS]
Members marked with [r] mean the variable is modified by FMOD and is for reading purposes only. Do not change this value.<br>
Members marked with [w] mean the variable can be written to. The user can set the value.<br>
[SEE_ALSO]
FMOD_DSP_PARAMETER_FLOAT_MAPPING_TYPE
FMOD_DSP_PARAMETER_DESC_FLOAT
]
*/
typedef struct FMOD_DSP_PARAMETER_FLOAT_MAPPING
{
FMOD_DSP_PARAMETER_FLOAT_MAPPING_TYPE type;
struct
{
int numpoints; /* [w] The number of <position, value> pairs in the piecewise mapping (at least 2). */
float* pointparamvalues; /* [w] The values in the parameter's units for each point */
float* pointpositions; /* [w] The positions along the control's scale (e.g. dial angle) corresponding to each parameter value. The range of this scale is arbitrary and all positions will be relative to the minimum and maximum values (e.g. [0,1,3] is equivalent to [1,2,4] and [2,4,8]). If this array is zero, pointparamvalues will be distributed with equal spacing. */
} piecewiselinearmapping; /* [w] Only required for FMOD_DSP_PARAMETER_FLOAT_MAPPING_TYPE_PIECEWISE_LINEAR type mapping. */
} FMOD_DSP_PARAMETER_FLOAT_MAPPING;
/*
[STRUCTURE]
[
[DESCRIPTION]
Structure to define a float parameter for a DSP unit.
[REMARKS]
Members marked with [r] mean the variable is modified by FMOD and is for reading purposes only. Do not change this value.<br>
Members marked with [w] mean the variable can be written to. The user can set the value.<br>
[SEE_ALSO]
System::createDSP
DSP::setParameterFloat
DSP::getParameterFloat
FMOD_DSP_PARAMETER_DESC
FMOD_DSP_PARAMETER_FLOAT_MAPPING
]
*/
typedef struct FMOD_DSP_PARAMETER_DESC_FLOAT
{
float min; /* [w] Minimum parameter value. */
float max; /* [w] Maximum parameter value. */
float defaultval; /* [w] Default parameter value. */
FMOD_DSP_PARAMETER_FLOAT_MAPPING mapping; /* [w] How the values are distributed across dials and automation curves (e.g. linearly, exponentially etc). */
} FMOD_DSP_PARAMETER_DESC_FLOAT;
/*
[STRUCTURE]
[
[DESCRIPTION]
Structure to define a int parameter for a DSP unit.
[REMARKS]
Members marked with [r] mean the variable is modified by FMOD and is for reading purposes only. Do not change this value.<br>
Members marked with [w] mean the variable can be written to. The user can set the value.<br>
[SEE_ALSO]
System::createDSP
DSP::setParameterInt
DSP::getParameterInt
FMOD_DSP_PARAMETER_DESC
]
*/
typedef struct FMOD_DSP_PARAMETER_DESC_INT
{
int min; /* [w] Minimum parameter value. */
int max; /* [w] Maximum parameter value. */
int defaultval; /* [w] Default parameter value. */
FMOD_BOOL goestoinf; /* [w] Whether the last value represents infiniy. */
const char* const* valuenames; /* [w] Names for each value. There should be as many strings as there are possible values (max - min + 1). Optional. */
} FMOD_DSP_PARAMETER_DESC_INT;
/*
[STRUCTURE]
[
[DESCRIPTION]
Structure to define a boolean parameter for a DSP unit.
[REMARKS]
Members marked with [r] mean the variable is modified by FMOD and is for reading purposes only. Do not change this value.<br>
Members marked with [w] mean the variable can be written to. The user can set the value.<br>
[SEE_ALSO]
System::createDSP
DSP::setParameterBool
DSP::getParameterBool
FMOD_DSP_PARAMETER_DESC
]
*/
typedef struct FMOD_DSP_PARAMETER_DESC_BOOL
{
FMOD_BOOL defaultval; /* [w] Default parameter value. */
const char* const* valuenames; /* [w] Names for false and true, respectively. There should be two strings. Optional. */
} FMOD_DSP_PARAMETER_DESC_BOOL;
/*
[STRUCTURE]
[
[DESCRIPTION]
Structure to define a data parameter for a DSP unit. Use 0 or above for custom types. This parameter will be treated specially by the system if set to one of the FMOD_DSP_PARAMETER_DATA_TYPE values.
[REMARKS]
Members marked with [r] mean the variable is modified by FMOD and is for reading purposes only. Do not change this value.<br>
Members marked with [w] mean the variable can be written to. The user can set the value.<br>
[SEE_ALSO]
System::createDSP
DSP::setParameterData
DSP::getParameterData
FMOD_DSP_PARAMETER_DATA_TYPE
FMOD_DSP_PARAMETER_DESC
]
*/
typedef struct FMOD_DSP_PARAMETER_DESC_DATA
{
int datatype; /* [w] The type of data for this parameter. Use 0 or above for custom types or set to one of the FMOD_DSP_PARAMETER_DATA_TYPE values. */
} FMOD_DSP_PARAMETER_DESC_DATA;
/*
[STRUCTURE]
[
[DESCRIPTION]
Base Structure for DSP parameter descriptions.
[REMARKS]
Members marked with [r] mean the variable is modified by FMOD and is for reading purposes only. Do not change this value.<br>
Members marked with [w] mean the variable can be written to. The user can set the value.<br>
[SEE_ALSO]
System::createDSP
DSP::setParameterFloat
DSP::getParameterFloat
DSP::setParameterInt
DSP::getParameterInt
DSP::setParameterBool
DSP::getParameterBool
DSP::setParameterData
DSP::getParameterData
FMOD_DSP_PARAMETER_DESC_FLOAT
FMOD_DSP_PARAMETER_DESC_INT
FMOD_DSP_PARAMETER_DESC_BOOL
FMOD_DSP_PARAMETER_DESC_DATA
]
*/
typedef struct FMOD_DSP_PARAMETER_DESC
{
FMOD_DSP_PARAMETER_TYPE type; /* [w] Type of this parameter. */
char name[16]; /* [w] Name of the parameter to be displayed (ie "Cutoff frequency"). */
char label[16]; /* [w] Short string to be put next to value to denote the unit type (ie "hz"). */
const char *description; /* [w] Description of the parameter to be displayed as a help item / tooltip for this parameter. */
union
{
FMOD_DSP_PARAMETER_DESC_FLOAT floatdesc; /* [w] Struct containing information about the parameter in floating point format. Use when type is FMOD_DSP_PARAMETER_TYPE_FLOAT. */
FMOD_DSP_PARAMETER_DESC_INT intdesc; /* [w] Struct containing information about the parameter in integer format. Use when type is FMOD_DSP_PARAMETER_TYPE_INT. */
FMOD_DSP_PARAMETER_DESC_BOOL booldesc; /* [w] Struct containing information about the parameter in boolean format. Use when type is FMOD_DSP_PARAMETER_TYPE_BOOL. */
FMOD_DSP_PARAMETER_DESC_DATA datadesc; /* [w] Struct containing information about the parameter in data format. Use when type is FMOD_DSP_PARAMETER_TYPE_DATA. */
};
} FMOD_DSP_PARAMETER_DESC;
/*
[ENUM]
[
[DESCRIPTION]
Built-in types for the 'datatype' member of FMOD_DSP_PARAMETER_DESC_DATA. Data parameters of type other than FMOD_DSP_PARAMETER_DATA_TYPE_USER will be treated specially by the system.
[REMARKS]
[SEE_ALSO]
FMOD_DSP_PARAMETER_DESC_DATA
FMOD_DSP_PARAMETER_OVERALLGAIN
FMOD_DSP_PARAMETER_3DATTRIBUTES
FMOD_DSP_PARAMETER_SIDECHAIN
]
*/
typedef enum
{
FMOD_DSP_PARAMETER_DATA_TYPE_USER = 0, /* The default data type. All user data types should be 0 or above. */
FMOD_DSP_PARAMETER_DATA_TYPE_OVERALLGAIN = -1, /* The data type for FMOD_DSP_PARAMETER_OVERALLGAIN parameters. There should a maximum of one per DSP. */
FMOD_DSP_PARAMETER_DATA_TYPE_3DATTRIBUTES = -2, /* The data type for FMOD_DSP_PARAMETER_3DATTRIBUTES parameters. There should a maximum of one per DSP. */
FMOD_DSP_PARAMETER_DATA_TYPE_SIDECHAIN = -3, /* The data type for FMOD_DSP_PARAMETER_SIDECHAIN parameters. There should a maximum of one per DSP. */
FMOD_DSP_PARAMETER_DATA_TYPE_FFT = -4, /* The data type for FMOD_DSP_PARAMETER_FFT parameters. There should a maximum of one per DSP. */
} FMOD_DSP_PARAMETER_DATA_TYPE;
/*
[STRUCTURE]
[
[DESCRIPTION]
Structure for data parameters of type FMOD_DSP_PARAMETER_DATA_TYPE_OVERALLGAIN.
A parameter of this type is used in effects that affect the overgain of the signal in a predictable way.
This parameter is read by the system to determine the effect's gain for voice virtualization.
[REMARKS]
Members marked with [r] mean the variable is modified by FMOD and is for reading purposes only. Do not change this value.<br>
Members marked with [w] mean the variable can be written to. The user can set the value.<br>
[SEE_ALSO]
FMOD_DSP_PARAMETER_DATA_TYPE
FMOD_DSP_PARAMETER_DESC
]
*/
typedef struct FMOD_DSP_PARAMETER_OVERALLGAIN
{
float linear_gain; /* [r] The overall linear gain of the effect on the direct signal path */
float linear_gain_additive; /* [r] Additive gain, for parallel signal paths */
} FMOD_DSP_PARAMETER_OVERALLGAIN;
/*
[STRUCTURE]
[
[DESCRIPTION]
Structure for data parameters of type FMOD_DSP_PARAMETER_DATA_TYPE_3DATTRIBUTES.
A parameter of this type is used in effects that respond to a sound's 3D position.
The system will set this parameter automatically if a sound's position changes.
[REMARKS]
Members marked with [r] mean the variable is modified by FMOD and is for reading purposes only. Do not change this value.<br>
Members marked with [w] mean the variable can be written to. The user can set the value.<br>
[SEE_ALSO]
FMOD_DSP_PARAMETER_DATA_TYPE
FMOD_DSP_PARAMETER_DESC
]
*/
typedef struct FMOD_DSP_PARAMETER_3DATTRIBUTES
{
FMOD_3D_ATTRIBUTES relative; /* [w] The position of the sound relative to the listener. */
FMOD_3D_ATTRIBUTES absolute; /* [w] The position of the sound in world coordinates. */
} FMOD_DSP_PARAMETER_3DATTRIBUTES;
/*
[STRUCTURE]
[
[DESCRIPTION]
Structure for data parameters of type FMOD_DSP_PARAMETER_DATA_TYPE_SIDECHAIN.
A parameter of this type is declared for effects which support sidechaining.
[REMARKS]
Members marked with [r] mean the variable is modified by FMOD and is for reading purposes only. Do not change this value.<br>
Members marked with [w] mean the variable can be written to. The user can set the value.<br>
[SEE_ALSO]
FMOD_DSP_PARAMETER_DATA_TYPE
FMOD_DSP_PARAMETER_DESC
]
*/
typedef struct FMOD_DSP_PARAMETER_SIDECHAIN
{
FMOD_BOOL sidechainenable; /* [r/w] Whether sidechains are enabled. */
} FMOD_DSP_PARAMETER_SIDECHAIN;
/*
[STRUCTURE]
[
[DESCRIPTION]
Structure for data parameters of type FMOD_DSP_PARAMETER_DATA_TYPE_FFT.
A parameter of this type is declared for the FMOD_DSP_TYPE_FFT effect.
[REMARKS]
Members marked with [r] mean the variable is modified by FMOD and is for reading purposes only. Do not change this value.<br>
Members marked with [w] mean the variable can be written to. The user can set the value.<br>
<br>
Notes on the spectrum data member. Values inside the float buffer are typically between 0 and 1.0.<br>
Each top level array represents one PCM channel of data.<br>
Address data as spectrum[channel][bin]. A bin is 1 fft window entry.<br>
Only read/display half of the buffer typically for analysis as the 2nd half is usually the same data reversed due to the nature of the way FFT works.<br>
[SEE_ALSO]
FMOD_DSP_PARAMETER_DATA_TYPE
FMOD_DSP_PARAMETER_DESC
FMOD_DSP_PARAMETER_DATA_TYPE_FFT
FMOD_DSP_TYPE
FMOD_DSP_FFT
]
*/
typedef struct FMOD_DSP_PARAMETER_FFT
{
int length; /* [r] Number of entries in this spectrum window. Divide this by the output rate to get the hz per entry. */
int numchannels; /* [r] Number of channels in spectrum. */
float *spectrum[32]; /* [r] Per channel spectrum arrays. See remarks for more. */
} FMOD_DSP_PARAMETER_FFT;
/*
Helpers for declaring parameters in custom DSPSs
*/
#define FMOD_DSP_INIT_PARAMDESC_FLOAT(_paramstruct, _name, _label, _description, _min, _max, _defaultval) \
memset(&(_paramstruct), 0, sizeof(_paramstruct)); \
(_paramstruct).type = FMOD_DSP_PARAMETER_TYPE_FLOAT; \
strncpy((_paramstruct).name, _name, 15); \
strncpy((_paramstruct).label, _label, 15); \
(_paramstruct).description = _description; \
(_paramstruct).floatdesc.min = _min; \
(_paramstruct).floatdesc.max = _max; \
(_paramstruct).floatdesc.defaultval = _defaultval; \
(_paramstruct).floatdesc.mapping.type = FMOD_DSP_PARAMETER_FLOAT_MAPPING_TYPE_AUTO;
#define FMOD_DSP_INIT_PARAMDESC_FLOAT_WITH_MAPPING(_paramstruct, _name, _label, _description, _defaultval, _values, _positions); \
memset(&(_paramstruct), 0, sizeof(_paramstruct)); \
(_paramstruct).type = FMOD_DSP_PARAMETER_TYPE_FLOAT; \
strncpy((_paramstruct).name, _name , 15); \
strncpy((_paramstruct).label, _label, 15); \
(_paramstruct).description = _description; \
(_paramstruct).floatdesc.min = _values[0]; \
(_paramstruct).floatdesc.max = _values[sizeof(_values) / sizeof(float) - 1]; \
(_paramstruct).floatdesc.defaultval = _defaultval; \
(_paramstruct).floatdesc.mapping.type = FMOD_DSP_PARAMETER_FLOAT_MAPPING_TYPE_PIECEWISE_LINEAR; \
(_paramstruct).floatdesc.mapping.piecewiselinearmapping.numpoints = sizeof(_values) / sizeof(float); \
(_paramstruct).floatdesc.mapping.piecewiselinearmapping.pointparamvalues = _values; \
(_paramstruct).floatdesc.mapping.piecewiselinearmapping.pointpositions = _positions;
#define FMOD_DSP_INIT_PARAMDESC_INT(_paramstruct, _name, _label, _description, _min, _max, _defaultval, _goestoinf, _valuenames) \
memset(&(_paramstruct), 0, sizeof(_paramstruct)); \
(_paramstruct).type = FMOD_DSP_PARAMETER_TYPE_INT; \
strncpy((_paramstruct).name, _name , 15); \
strncpy((_paramstruct).label, _label, 15); \
(_paramstruct).description = _description; \
(_paramstruct).intdesc.min = _min; \
(_paramstruct).intdesc.max = _max; \
(_paramstruct).intdesc.defaultval = _defaultval; \
(_paramstruct).intdesc.goestoinf = _goestoinf; \
(_paramstruct).intdesc.valuenames = _valuenames;
#define FMOD_DSP_INIT_PARAMDESC_INT_ENUMERATED(_paramstruct, _name, _label, _description, _defaultval, _valuenames) \
memset(&(_paramstruct), 0, sizeof(_paramstruct)); \
(_paramstruct).type = FMOD_DSP_PARAMETER_TYPE_INT; \
strncpy((_paramstruct).name, _name , 15); \
strncpy((_paramstruct).label, _label, 15); \
(_paramstruct).description = _description; \
(_paramstruct).intdesc.min = 0; \
(_paramstruct).intdesc.max = sizeof(_valuenames) / sizeof(char*) - 1; \
(_paramstruct).intdesc.defaultval = _defaultval; \
(_paramstruct).intdesc.goestoinf = false; \
(_paramstruct).intdesc.valuenames = _valuenames;
#define FMOD_DSP_INIT_PARAMDESC_BOOL(_paramstruct, _name, _label, _description, _defaultval, _valuenames) \
memset(&(_paramstruct), 0, sizeof(_paramstruct)); \
(_paramstruct).type = FMOD_DSP_PARAMETER_TYPE_BOOL; \
strncpy((_paramstruct).name, _name , 15); \
strncpy((_paramstruct).label, _label, 15); \
(_paramstruct).description = _description; \
(_paramstruct).booldesc.defaultval = _defaultval; \
(_paramstruct).booldesc.valuenames = _valuenames;
#define FMOD_DSP_INIT_PARAMDESC_DATA(_paramstruct, _name, _label, _description, _datatype) \
memset(&(_paramstruct), 0, sizeof(_paramstruct)); \
(_paramstruct).type = FMOD_DSP_PARAMETER_TYPE_DATA; \
strncpy((_paramstruct).name, _name , 15); \
strncpy((_paramstruct).label, _label, 15); \
(_paramstruct).description = _description; \
(_paramstruct).datadesc.datatype = _datatype;
#define FMOD_PLUGIN_SDK_VERSION 105
/*
[STRUCTURE]
[
[DESCRIPTION]
When creating a DSP unit, declare one of these and provide the relevant callbacks and name for FMOD to use when it creates and uses a DSP unit of this type.
[REMARKS]
Members marked with [r] mean the variable is modified by FMOD and is for reading purposes only. Do not change this value.<br>
Members marked with [w] mean the variable can be written to. The user can set the value.<br>
<br>
There are 2 different ways to change a parameter in this architecture.<br>
One is to use DSP::setParameterFloat / DSP::setParameterInt / DSP::setParameterBool / DSP::setParameterData. This is platform independant and is dynamic, so new unknown plugins can have their parameters enumerated and used.<br>
The other is to use DSP::showConfigDialog. This is platform specific and requires a GUI, and will display a dialog box to configure the plugin.<br>
[SEE_ALSO]
System::createDSP
DSP::setParameterFloat
DSP::setParameterInt
DSP::setParameterBool
DSP::setParameterData
FMOD_DSP_STATE
FMOD_DSP_CREATE_CALLBACK
FMOD_DSP_RELEASE_CALLBACK
FMOD_DSP_RESET_CALLBACK
FMOD_DSP_READ_CALLBACK
FMOD_DSP_PROCESS_CALLBACK
FMOD_DSP_SETPOSITION_CALLBACK
FMOD_DSP_SHOULDIPROCESS_CALLBACK
FMOD_DSP_PARAMETER_DESC
FMOD_DSP_SETPARAM_FLOAT_CALLBACK
FMOD_DSP_SETPARAM_INT_CALLBACK
FMOD_DSP_SETPARAM_BOOL_CALLBACK
FMOD_DSP_SETPARAM_DATA_CALLBACK
FMOD_DSP_GETPARAM_FLOAT_CALLBACK
FMOD_DSP_GETPARAM_INT_CALLBACK
FMOD_DSP_GETPARAM_BOOL_CALLBACK
FMOD_DSP_GETPARAM_DATA_CALLBACK
FMOD_DSP_SHOULDIPROCESS_CALLBACK
]
*/
typedef struct FMOD_DSP_DESCRIPTION
{
unsigned int pluginsdkversion; /* [w] The plugin SDK version this plugin is built for. set to this to FMOD_PLUGIN_SDK_VERSION defined above. */
char name[32]; /* [w] The identifier of the DSP. This will also be used as the name of DSP and shouldn't change between versions. */
unsigned int version; /* [w] Plugin writer's version number. */
int numinputbuffers; /* [w] Number of input buffers to process. Use 0 for DSPs that only generate sound and 1 for effects that process incoming sound. */
int numoutputbuffers; /* [w] Number of audio output buffers. Only one output buffer is currently supported. */
FMOD_DSP_CREATE_CALLBACK create; /* [w] Create callback. This is called when DSP unit is created. Can be null. */
FMOD_DSP_RELEASE_CALLBACK release; /* [w] Release callback. This is called just before the unit is freed so the user can do any cleanup needed for the unit. Can be null. */
FMOD_DSP_RESET_CALLBACK reset; /* [w] Reset callback. This is called by the user to reset any history buffers that may need resetting for a filter, when it is to be used or re-used for the first time to its initial clean state. Use to avoid clicks or artifacts. */
FMOD_DSP_READ_CALLBACK read; /* [w] Read callback. Processing is done here. Can be null. */
FMOD_DSP_PROCESS_CALLBACK process; /* [w] Process callback. Can be specified instead of the read callback if any channel format changes occur between input and output. This also replaces shouldiprocess and should return an error if the effect is to be bypassed. Can be null. */
FMOD_DSP_SETPOSITION_CALLBACK setposition; /* [w] Set position callback. This is called if the unit wants to update its position info but not process data, or reset a cursor position internally if it is reading data from a certain source. Can be null. */
int numparameters; /* [w] Number of parameters used in this filter. The user finds this with DSP::getNumParameters */
FMOD_DSP_PARAMETER_DESC **paramdesc; /* [w] Variable number of parameter structures. */
FMOD_DSP_SETPARAM_FLOAT_CALLBACK setparameterfloat; /* [w] This is called when the user calls DSP::setParameterFloat. Can be null. */
FMOD_DSP_SETPARAM_INT_CALLBACK setparameterint; /* [w] This is called when the user calls DSP::setParameterInt. Can be null. */
FMOD_DSP_SETPARAM_BOOL_CALLBACK setparameterbool; /* [w] This is called when the user calls DSP::setParameterBool. Can be null. */
FMOD_DSP_SETPARAM_DATA_CALLBACK setparameterdata; /* [w] This is called when the user calls DSP::setParameterData. Can be null. */
FMOD_DSP_GETPARAM_FLOAT_CALLBACK getparameterfloat; /* [w] This is called when the user calls DSP::getParameterFloat. Can be null. */
FMOD_DSP_GETPARAM_INT_CALLBACK getparameterint; /* [w] This is called when the user calls DSP::getParameterInt. Can be null. */
FMOD_DSP_GETPARAM_BOOL_CALLBACK getparameterbool; /* [w] This is called when the user calls DSP::getParameterBool. Can be null. */
FMOD_DSP_GETPARAM_DATA_CALLBACK getparameterdata; /* [w] This is called when the user calls DSP::getParameterData. Can be null. */
FMOD_DSP_SHOULDIPROCESS_CALLBACK shouldiprocess; /* [w] This is called before processing. You can detect if inputs are idle and return FMOD_OK to process, or any other error code to avoid processing the effect. Use a count down timer to allow effect tails to process before idling! */
void *userdata; /* [w] Optional. Specify 0 to ignore. This is user data to be attached to the DSP unit during creation. Access via DSP::getUserData. */
} FMOD_DSP_DESCRIPTION;
/*
[STRUCTURE]
[
[DESCRIPTION]
Struct containing DFT callbacks for plugins, to enable a plugin to perform optimized time-frequency domain conversion.
[REMARKS]
Members marked with [r] mean the variable is modified by FMOD and is for reading purposes only. Do not change this value.<br>
Members marked with [w] mean the variable can be written to. The user can set the value.<br>
[SEE_ALSO]
FMOD_DSP_STATE_SYSTEMCALLBACKS
]
*/
typedef struct FMOD_DSP_STATE_DFTCALLBACKS
{
FMOD_FFTREAL fftreal; /* [r] Callback for performing an FFT on a real signal. */
FMOD_IFFTREAL inversefftreal; /* [r] Callback for performing an inverse FFT to get a real signal. */
} FMOD_DSP_STATE_DFTCALLBACKS;
/*
[STRUCTURE]
[
[DESCRIPTION]
Struct containing panning helper callbacks for plugins.
[REMARKS]
These are experimental, please contact [email protected] for more information.
[SEE_ALSO]
FMOD_DSP_STATE_SYSTEMCALLBACKS
FMOD_PAN_SURROUND_FLAGS
]
*/
typedef struct FMOD_DSP_STATE_PAN_CALLBACKS
{
FMOD_PAN_SUM_MONO_MATRIX summonomatrix;
FMOD_PAN_SUM_STEREO_MATRIX sumstereomatrix;
FMOD_PAN_SUM_SURROUND_MATRIX sumsurroundmatrix;
FMOD_PAN_SUM_MONO_TO_SURROUND_MATRIX summonotosurroundmatrix;
FMOD_PAN_SUM_STEREO_TO_SURROUND_MATRIX sumstereotosurroundmatrix;
FMOD_PAN_3D_GET_ROLLOFF_GAIN getrolloffgain;
} FMOD_DSP_STATE_PAN_CALLBACKS;
/*
[STRUCTURE]
[
[DESCRIPTION]
Struct containing System level callbacks for plugins, to enable a plugin to query information about the system or allocate memory using FMOD's (and therefore possibly the game's) allocators.
[REMARKS]
Members marked with [r] mean the variable is modified by FMOD and is for reading purposes only. Do not change this value.<br>
Members marked with [w] mean the variable can be written to. The user can set the value.<br>
[SEE_ALSO]
FMOD_DSP_STATE
FMOD_DSP_STATE_DFTCALLBACKS
FMOD_DSP_STATE_PAN_CALLBACKS
]
*/
typedef struct FMOD_DSP_STATE_SYSTEMCALLBACKS
{
FMOD_MEMORY_ALLOC_CALLBACK alloc; /* [r] Memory allocation callback. Use this for all dynamic memory allocation within the plugin. */
FMOD_MEMORY_REALLOC_CALLBACK realloc; /* [r] Memory reallocation callback. */
FMOD_MEMORY_FREE_CALLBACK free; /* [r] Memory free callback. */
FMOD_DSP_SYSTEM_GETSAMPLERATE getsamplerate; /* [r] Callback for getting the system samplerate. */
FMOD_DSP_SYSTEM_GETBLOCKSIZE getblocksize; /* [r] Callback for getting the system's block size. DSPs will be requested to process blocks of varying length up to this size.*/
FMOD_DSP_STATE_DFTCALLBACKS *dft; /* [r] Struct containing callbacks for performing FFTs and inverse FFTs. */
FMOD_DSP_STATE_PAN_CALLBACKS *pancallbacks; /* [r] Pointer to a structure of callbacks for calculating pan, up-mix and down-mix matrices. */
} FMOD_DSP_STATE_SYSTEMCALLBACKS;
/*
[STRUCTURE]
[
[DESCRIPTION]
DSP plugin structure that is passed into each callback.
[REMARKS]
Members marked with [r] mean the variable is modified by FMOD and is for reading purposes only. Do not change this value.<br>
Members marked with [w] mean the variable can be written to. The user can set the value.<br>
[SEE_ALSO]
FMOD_DSP_DESCRIPTION
FMOD_DSP_STATE_SYSTEMCALLBACKS
]
*/
struct FMOD_DSP_STATE
{
FMOD_DSP *instance; /* [r] Handle to the FMOD_DSP object the callback is associated with. Not to be modified. C++ users cast to FMOD::DSP to use. */
void *plugindata; /* [r/w] Plugin writer created data the output author wants to attach to this object. */
FMOD_CHANNELMASK channelmask; /* [r] Specifies which speakers the DSP effect is active on */
FMOD_SPEAKERMODE source_speakermode; /* [r] Specifies which speaker mode the signal originated for information purposes, ie in case panning needs to be done differently. */
float *sidechaindata; /* [r] The mixed result of all incoming sidechains is stored at this pointer address. */
int sidechainchannels; /* [r] The number of channels of pcm data stored within the sidechain buffer. */
FMOD_DSP_STATE_SYSTEMCALLBACKS *callbacks; /* [r] Struct containing callbacks for system level functionality. */
};
/*
Macro helpers for accessing FMOD_DSP_STATE_SYSTEMCALLBACKS
*/
#define FMOD_DSP_STATE_MEMALLOC(_state, _size, _type, _str) (_state)->callbacks->alloc (_size, _type, _str); /* Pass in the FMOD_DSP_STATE handle, size in bytes to alloc, FMOD_MEMORY_TYPE type and optional char * string to identify where the alloc came from. */
#define FMOD_DSP_STATE_MEMREALLOC(_state, _ptr, _size, _type, _str) (_state)->callbacks->realloc (_ptr, _size, _type, _str); /* Pass in the FMOD_DSP_STATE handle, optional existing memory pointer, size in bytes to alloc, FMOD_MEMORY_TYPE type and optional char * string to identify where the alloc came from. */
#define FMOD_DSP_STATE_MEMFREE(_state, _ptr, _type, _str) (_state)->callbacks->free (_ptr, _type, _str); /* Pass in the FMOD_DSP_STATE handle, existing memory pointer, FMOD_MEMORY_TYPE type and optional char * string to identify where the free came from. */
#define FMOD_DSP_STATE_GETSAMPLERATE(_state, _rate) (_state)->callbacks->getsamplerate (_state, _rate); /* Pass in the FMOD_DSP_STATE handle, and the address of an int to receive the system DSP sample rate. */
#define FMOD_DSP_STATE_GETBLOCKSIZE(_state, _blocksize) (_state)->callbacks->getblocksize (_state, _blocksize); /* Pass in the FMOD_DSP_STATE handle, and the address of an unsigned int to receive the system DSP block size. */
#define FMOD_DSP_STATE_FFTREAL(_state, _size, _signal, _dft, _window, _signalhop) (_state)->callbacks->dft->fftreal (_state, _size, _signal, _dft, _window, _signalhop); /* Pass in the FMOD_DSP_STATE handle, size of the signal and its DFT, a float buffer containing the signal and an FMOD_COMPLEX buffer to store the calculated DFT. */
#define FMOD_DSP_STATE_IFFTREAL(_state, _size, _dft, _signal, _window, _signalhop) (_state)->callbacks->dft->inversefftreal(_state, _size, _dft, _signal, _window, _signalhop); /* Pass in the FMOD_DSP_STATE handle, size of the DFT and its signal, an FMOD_COMPLEX buffer containing the DFT and a float buffer to store the calculated signal. */
/*
[STRUCTURE]
[
[DESCRIPTION]
DSP metering info used for retrieving metering info
[REMARKS]
Members marked with [r] mean the variable is modified by FMOD and is for reading purposes only. Do not change this value.<br>
Members marked with [w] mean the variable can be written to. The user can set the value.<br>
[SEE_ALSO]
FMOD_SPEAKER
]
*/
typedef struct FMOD_DSP_METERING_INFO
{
int numsamples; /* [r] The number of samples considered for this metering info. */
float peaklevel[32]; /* [r] The peak level per channel. */
float rmslevel[32]; /* [r] The rms level per channel. */
short numchannels; /* [r] Number of channels. */
} FMOD_DSP_METERING_INFO;
#endif
+926
View File
@@ -0,0 +1,926 @@
/* ========================================================================================== */
/* FMOD Studio - Built-in effects header file. */
/* Copyright (c), Firelight Technologies Pty, Ltd. 2004-2014. */
/* */
/* In this header you can find parameter structures for FMOD system registered DSP effects */
/* and generators. */
/* */
/* ========================================================================================== */
#ifndef _FMOD_DSP_EFFECTS_H
#define _FMOD_DSP_EFFECTS_H
/*
[ENUM]
[
[DESCRIPTION]
These definitions can be used for creating FMOD defined special effects or DSP units.
[REMARKS]
To get them to be active, first create the unit, then add it somewhere into the DSP network,
either at the front of the network near the soundcard unit to affect the global output
(by using System::getDSPHead), or on a single channel (using Channel::getDSPHead).
[SEE_ALSO]
System::createDSPByType
]
*/
typedef enum
{
FMOD_DSP_TYPE_UNKNOWN, /* This unit was created via a non FMOD plugin so has an unknown purpose. */
FMOD_DSP_TYPE_MIXER, /* This unit does nothing but take inputs and mix them together then feed the result to the soundcard unit. */
FMOD_DSP_TYPE_OSCILLATOR, /* This unit generates sine/square/saw/triangle or noise tones. */
FMOD_DSP_TYPE_LOWPASS, /* This unit filters sound using a high quality, resonant lowpass filter algorithm but consumes more CPU time. */
FMOD_DSP_TYPE_ITLOWPASS, /* This unit filters sound using a resonant lowpass filter algorithm that is used in Impulse Tracker, but with limited cutoff range (0 to 8060hz). */
FMOD_DSP_TYPE_HIGHPASS, /* This unit filters sound using a resonant highpass filter algorithm. */
FMOD_DSP_TYPE_ECHO, /* This unit produces an echo on the sound and fades out at the desired rate. */
FMOD_DSP_TYPE_FADER, /* This unit pans and scales the volume of a unit. */
FMOD_DSP_TYPE_FLANGE, /* This unit produces a flange effect on the sound. */
FMOD_DSP_TYPE_DISTORTION, /* This unit distorts the sound. */
FMOD_DSP_TYPE_NORMALIZE, /* This unit normalizes or amplifies the sound to a certain level. */
FMOD_DSP_TYPE_LIMITER, /* This unit limits the sound to a certain level.*/
FMOD_DSP_TYPE_PARAMEQ, /* This unit attenuates or amplifies a selected frequency range. */
FMOD_DSP_TYPE_PITCHSHIFT, /* This unit bends the pitch of a sound without changing the speed of playback. */
FMOD_DSP_TYPE_CHORUS, /* This unit produces a chorus effect on the sound. */
FMOD_DSP_TYPE_VSTPLUGIN, /* This unit allows the use of Steinberg VST plugins */
FMOD_DSP_TYPE_WINAMPPLUGIN, /* This unit allows the use of Nullsoft Winamp plugins */
FMOD_DSP_TYPE_ITECHO, /* This unit produces an echo on the sound and fades out at the desired rate as is used in Impulse Tracker. */
FMOD_DSP_TYPE_COMPRESSOR, /* This unit implements dynamic compression (linked multichannel, wideband) */
FMOD_DSP_TYPE_SFXREVERB, /* This unit implements SFX reverb */
FMOD_DSP_TYPE_LOWPASS_SIMPLE, /* This unit filters sound using a simple lowpass with no resonance, but has flexible cutoff and is fast. */
FMOD_DSP_TYPE_DELAY, /* This unit produces different delays on individual channels of the sound. */
FMOD_DSP_TYPE_TREMOLO, /* This unit produces a tremolo / chopper effect on the sound. */
FMOD_DSP_TYPE_LADSPAPLUGIN, /* Unsupported / Deprecated. */
FMOD_DSP_TYPE_SEND, /* This unit sends a copy of the signal to a return DSP anywhere in the DSP tree. */
FMOD_DSP_TYPE_RETURN, /* This unit receives signals from a number of send DSPs. */
FMOD_DSP_TYPE_HIGHPASS_SIMPLE, /* This unit filters sound using a simple highpass with no resonance, but has flexible cutoff and is fast. */
FMOD_DSP_TYPE_PAN, /* This unit pans the signal, possibly upmixing or downmixing as well. */
FMOD_DSP_TYPE_THREE_EQ, /* This unit is a three-band equalizer. */
FMOD_DSP_TYPE_FFT, /* This unit simply analyzes the signal and provides spectrum information back through getParameter. */
FMOD_DSP_TYPE_LOUDNESS_METER, /* This unit analyzes the loudness and true peak of the signal. */
FMOD_DSP_TYPE_ENVELOPEFOLLOWER, /* This unit tracks the envelope of the input/sidechain signal. Format to be publicly disclosed soon. */
FMOD_DSP_TYPE_CONVOLUTIONREVERB, /* This unit implements convolution reverb. */
FMOD_DSP_TYPE_MAX, /* Maximum number of pre-defined DSP types. */
FMOD_DSP_TYPE_FORCEINT = 65536 /* Makes sure this enum is signed 32bit. */
} FMOD_DSP_TYPE;
/*
===================================================================================================
FMOD built in effect parameters.
Use DSP::setParameter with these enums for the 'index' parameter.
===================================================================================================
*/
/*
[ENUM]
[
[DESCRIPTION]
Parameter types for the FMOD_DSP_TYPE_OSCILLATOR filter.
[REMARKS]
[SEE_ALSO]
DSP::setParameterFloat
DSP::setParameterInt
DSP::getParameterFloat
DSP::getParameterInt
FMOD_DSP_TYPE
]
*/
typedef enum
{
FMOD_DSP_OSCILLATOR_TYPE, /* (Type:int) - Waveform type. 0 = sine. 1 = square. 2 = sawup. 3 = sawdown. 4 = triangle. 5 = noise. */
FMOD_DSP_OSCILLATOR_RATE /* (Type:float) - Frequency of the sinewave in hz. 1.0 to 22000.0. Default = 220.0. */
} FMOD_DSP_OSCILLATOR;
/*
[ENUM]
[
[DESCRIPTION]
Parameter types for the FMOD_DSP_TYPE_LOWPASS filter.
[REMARKS]
[SEE_ALSO]
DSP::setParameterFloat
DSP::getParameterFloat
FMOD_DSP_TYPE
]
*/
typedef enum
{
FMOD_DSP_LOWPASS_CUTOFF, /* (Type:float) - Lowpass cutoff frequency in hz. 10.0 to 22000.0. Default = 5000.0. */
FMOD_DSP_LOWPASS_RESONANCE /* (Type:float) - Lowpass resonance Q value. 1.0 to 10.0. Default = 1.0. */
} FMOD_DSP_LOWPASS;
/*
[ENUM]
[
[DESCRIPTION]
Parameter types for the FMOD_DSP_TYPE_ITLOWPASS filter.<br>
This is different to the default FMOD_DSP_TYPE_ITLOWPASS filter in that it uses a different quality algorithm and is
the filter used to produce the correct sounding playback in .IT files.<br>
FMOD Studio's .IT playback uses this filter.<br>
[REMARKS]
Note! This filter actually has a limited cutoff frequency below the specified maximum, due to its limited design,
so for a more open range filter use FMOD_DSP_LOWPASS or if you don't mind not having resonance,
FMOD_DSP_LOWPASS_SIMPLE.<br>
The effective maximum cutoff is about 8060hz.
[SEE_ALSO]
DSP::setParameterFloat
DSP::getParameterFloat
FMOD_DSP_TYPE
]
*/
typedef enum
{
FMOD_DSP_ITLOWPASS_CUTOFF, /* (Type:float) - Lowpass cutoff frequency in hz. 1.0 to 22000.0. Default = 5000.0/ */
FMOD_DSP_ITLOWPASS_RESONANCE /* (Type:float) - Lowpass resonance Q value. 0.0 to 127.0. Default = 1.0. */
} FMOD_DSP_ITLOWPASS;
/*
[ENUM]
[
[DESCRIPTION]
Parameter types for the FMOD_DSP_TYPE_HIGHPASS filter.
[REMARKS]
[SEE_ALSO]
DSP::setParameterFloat
DSP::getParameterFloat
FMOD_DSP_TYPE
]
*/
typedef enum
{
FMOD_DSP_HIGHPASS_CUTOFF, /* (Type:float) - Highpass cutoff frequency in hz. 1.0 to output 22000.0. Default = 5000.0. */
FMOD_DSP_HIGHPASS_RESONANCE /* (Type:float) - Highpass resonance Q value. 1.0 to 10.0. Default = 1.0. */
} FMOD_DSP_HIGHPASS;
/*
[ENUM]
[
[DESCRIPTION]
Parameter types for the FMOD_DSP_TYPE_ECHO filter.
[REMARKS]
Note. Every time the delay is changed, the plugin re-allocates the echo buffer. This means the echo will dissapear at that time while it refills its new buffer.<br>
Larger echo delays result in larger amounts of memory allocated.<br>
[SEE_ALSO]
DSP::setParameterFloat
DSP::getParameterFloat
FMOD_DSP_TYPE
]
*/
typedef enum
{
FMOD_DSP_ECHO_DELAY, /* (Type:float) - Echo delay in ms. 10 to 5000. Default = 500. */
FMOD_DSP_ECHO_FEEDBACK, /* (Type:float) - Echo decay per delay. 0 to 100. 100.0 = No decay, 0.0 = total decay (ie simple 1 line delay). Default = 50.0. */
FMOD_DSP_ECHO_DRYLEVEL, /* (Type:float) - Original sound volume in dB. -80.0 to 10.0. Default = 0. */
FMOD_DSP_ECHO_WETLEVEL /* (Type:float) - Volume of echo signal to pass to output in dB. -80.0 to 10.0. Default = 0. */
} FMOD_DSP_ECHO;
/*
[ENUM]
[
[DESCRIPTION]
Parameter types for the FMOD_DSP_TYPE_FLANGE filter.
[REMARKS]
Flange is an effect where the signal is played twice at the same time, and one copy slides back and forth creating a whooshing or flanging effect.<br>
As there are 2 copies of the same signal, by default each signal is given 50% mix, so that the total is not louder than the original unaffected signal.<br>
<br>
Flange depth is a percentage of a 10ms shift from the original signal. Anything above 10ms is not considered flange because to the ear it begins to 'echo' so 10ms is the highest value possible.<br>
[SEE_ALSO]
DSP::setParameterFloat
DSP::getParameterFloat
FMOD_DSP_TYPE
]
*/
typedef enum
{
FMOD_DSP_FLANGE_MIX, /* (Type:float) - Percentage of wet signal in mix. 0 to 100. Default = 50. */
FMOD_DSP_FLANGE_DEPTH, /* (Type:float) - Flange depth (percentage of 40ms delay). 0.01 to 1.0. Default = 1.0. */
FMOD_DSP_FLANGE_RATE /* (Type:float) - Flange speed in hz. 0.0 to 20.0. Default = 0.1. */
} FMOD_DSP_FLANGE;
/*
[ENUM]
[
[DESCRIPTION]
Parameter types for the FMOD_DSP_TYPE_DISTORTION filter.
[REMARKS]
[SEE_ALSO]
DSP::setParameterFloat
DSP::getParameterFloat
FMOD_DSP_TYPE
]
*/
typedef enum
{
FMOD_DSP_DISTORTION_LEVEL /* (Type:float) - Distortion value. 0.0 to 1.0. Default = 0.5. */
} FMOD_DSP_DISTORTION;
/*
[ENUM]
[
[DESCRIPTION]
Parameter types for the FMOD_DSP_TYPE_NORMALIZE filter.
[REMARKS]
Normalize amplifies the sound based on the maximum peaks within the signal.<br>
For example if the maximum peaks in the signal were 50% of the bandwidth, it would scale the whole sound by 2.<br>
The lower threshold value makes the normalizer ignores peaks below a certain point, to avoid over-amplification if a loud signal suddenly came in, and also to avoid amplifying to maximum things like background hiss.<br>
<br>
Because FMOD is a realtime audio processor, it doesn't have the luxury of knowing the peak for the whole sound (ie it can't see into the future), so it has to process data as it comes in.<br>
To avoid very sudden changes in volume level based on small samples of new data, fmod fades towards the desired amplification which makes for smooth gain control. The fadetime parameter can control this.<br>
[SEE_ALSO]
DSP::setParameterFloat
DSP::getParameterFloat
FMOD_DSP_TYPE
]
*/
typedef enum
{
FMOD_DSP_NORMALIZE_FADETIME, /* (Type:float) - Time to ramp the silence to full in ms. 0.0 to 20000.0. Default = 5000.0. */
FMOD_DSP_NORMALIZE_THRESHHOLD, /* (Type:float) - Lower volume range threshold to ignore. 0.0 to 1.0. Default = 0.1. Raise higher to stop amplification of very quiet signals. */
FMOD_DSP_NORMALIZE_MAXAMP /* (Type:float) - Maximum amplification allowed. 1.0 to 100000.0. Default = 20.0. 1.0 = no amplifaction, higher values allow more boost. */
} FMOD_DSP_NORMALIZE;
/*
[ENUM]
[
[DESCRIPTION]
Parameter types for the FMOD_DSP_TYPE_LIMITER filter.
[REMARKS]
[SEE_ALSO]
DSP::setParameterFloat
DSP::getParameterFloat
FMOD_DSP_TYPE
]
*/
typedef enum
{
FMOD_DSP_LIMITER_RELEASETIME, /* (Type:float) - Time to ramp the silence to full in ms. 1.0 to 1000.0. Default = 10.0. */
FMOD_DSP_LIMITER_CEILING, /* (Type:float) - Maximum level of the output signal in dB. -12.0 to 0.0. Default = 0.0. */
FMOD_DSP_LIMITER_MAXIMIZERGAIN, /* (Type:float) - Maximum amplification allowed in dB. 0.0 to 12.0. Default = 0.0. 0.0 = no amplifaction, higher values allow more boost. */
FMOD_DSP_LIMITER_MODE, /* (Type:float) - Channel processing mode. 0 or 1. Default = 0. 0 = Independent (limiter per channel), 1 = Linked*/
} FMOD_DSP_LIMITER;
/*
[ENUM]
[
[DESCRIPTION]
Parameter types for the FMOD_DSP_TYPE_PARAMEQ filter.
[REMARKS]
Parametric EQ is a bandpass filter that attenuates or amplifies a selected frequency and its neighbouring frequencies.<br>
<br>
To create a multi-band EQ create multiple FMOD_DSP_TYPE_PARAMEQ units and set each unit to different frequencies, for example 1000hz, 2000hz, 4000hz, 8000hz, 16000hz with a range of 1 octave each.<br>
<br>
When a frequency has its gain set to 1.0, the sound will be unaffected and represents the original signal exactly.<br>
[SEE_ALSO]
DSP::setParameterFloat
DSP::getParameterFloat
FMOD_DSP_TYPE
]
*/
typedef enum
{
FMOD_DSP_PARAMEQ_CENTER, /* (Type:float) - Frequency center. 20.0 to 22000.0. Default = 8000.0. */
FMOD_DSP_PARAMEQ_BANDWIDTH, /* (Type:float) - Octave range around the center frequency to filter. 0.2 to 5.0. Default = 1.0. */
FMOD_DSP_PARAMEQ_GAIN /* (Type:float) - Frequency Gain in dB. -30 to 30. Default = 0. */
} FMOD_DSP_PARAMEQ;
/*
[ENUM]
[
[DESCRIPTION]
Parameter types for the FMOD_DSP_TYPE_PITCHSHIFT filter.
[REMARKS]
This pitch shifting unit can be used to change the pitch of a sound without speeding it up or slowing it down.<br>
It can also be used for time stretching or scaling, for example if the pitch was doubled, and the frequency of the sound was halved, the pitch of the sound would sound correct but it would be twice as slow.<br>
<br>
<b>Warning!</b> This filter is very computationally expensive! Similar to a vocoder, it requires several overlapping FFT and IFFT's to produce smooth output, and can require around 440mhz for 1 stereo 48khz signal using the default settings.<br>
Reducing the signal to mono will half the cpu usage.<br>
Reducing this will lower audio quality, but what settings to use are largely dependant on the sound being played. A noisy polyphonic signal will need higher fft size compared to a speaking voice for example.<br>
<br>
This pitch shifter is based on the pitch shifter code at http://www.dspdimension.com, written by Stephan M. Bernsee.<br>
The original code is COPYRIGHT 1999-2003 Stephan M. Bernsee <[email protected]>.<br>
<br>
'<i>maxchannels</i>' dictates the amount of memory allocated. By default, the maxchannels value is 0. If FMOD is set to stereo, the pitch shift unit will allocate enough memory for 2 channels. If it is 5.1, it will allocate enough memory for a 6 channel pitch shift, etc.<br>
If the pitch shift effect is only ever applied to the global mix (ie it was added with ChannelGroup::addDSP), then 0 is the value to set as it will be enough to handle all speaker modes.<br>
When the pitch shift is added to a channel (ie Channel::addDSP) then the channel count that comes in could be anything from 1 to 8 possibly. It is only in this case where you might want to increase the channel count above the output's channel count.<br>
If a channel pitch shift is set to a lower number than the sound's channel count that is coming in, it will not pitch shift the sound.<br>
<br>
<b>NOTE!</b> Not supported on PlayStation 3.<br>
[SEE_ALSO]
DSP::setParameterFloat
DSP::getParameterFloat
ChannelGroup::addDSP
FMOD_DSP_TYPE
]
*/
typedef enum
{
FMOD_DSP_PITCHSHIFT_PITCH, /* (Type:float) - Pitch value. 0.5 to 2.0. Default = 1.0. 0.5 = one octave down, 2.0 = one octave up. 1.0 does not change the pitch. */
FMOD_DSP_PITCHSHIFT_FFTSIZE, /* (Type:float) - FFT window size. 256, 512, 1024, 2048, 4096. Default = 1024. Increase this to reduce 'smearing'. This effect is a warbling sound similar to when an mp3 is encoded at very low bitrates. */
FMOD_DSP_PITCHSHIFT_OVERLAP, /* (Type:float) - Removed. Do not use. FMOD now uses 4 overlaps and cannot be changed. */
FMOD_DSP_PITCHSHIFT_MAXCHANNELS /* (Type:float) - Maximum channels supported. 0 to 16. 0 = same as fmod's default output polyphony, 1 = mono, 2 = stereo etc. See remarks for more. Default = 0. It is suggested to leave at 0! */
} FMOD_DSP_PITCHSHIFT;
/*
[ENUM]
[
[DESCRIPTION]
Parameter types for the FMOD_DSP_TYPE_CHORUS filter.
[REMARKS]
Chorous is an effect where the sound is more 'spacious' due to 1 to 3 versions of the sound being played along side the original signal but with the pitch of each copy modulating on a sine wave.<br>
[SEE_ALSO]
DSP::setParameterFloat
DSP::getParameterFloat
FMOD_DSP_TYPE
]
*/
typedef enum
{
FMOD_DSP_CHORUS_MIX, /* (Type:float) - Volume of original signal to pass to output. 0.0 to 100.0. Default = 50.0. */
FMOD_DSP_CHORUS_RATE, /* (Type:float) - Chorus modulation rate in Hz. 0.0 to 20.0. Default = 0.8 Hz. */
FMOD_DSP_CHORUS_DEPTH, /* (Type:float) - Chorus modulation depth. 0.0 to 100.0. Default = 3.0. */
} FMOD_DSP_CHORUS;
/*
[ENUM]
[
[DESCRIPTION]
Parameter types for the FMOD_DSP_TYPE_ITECHO filter.<br>
This is effectively a software based echo filter that emulates the DirectX DMO echo effect. Impulse tracker files can support this, and FMOD will produce the effect on ANY platform, not just those that support DirectX effects!<br>
[REMARKS]
Note. Every time the delay is changed, the plugin re-allocates the echo buffer. This means the echo will dissapear at that time while it refills its new buffer.<br>
Larger echo delays result in larger amounts of memory allocated.<br>
<br>
As this is a stereo filter made mainly for IT playback, it is targeted for stereo signals.<br>
With mono signals only the FMOD_DSP_ITECHO_LEFTDELAY is used.<br>
For multichannel signals (>2) there will be no echo on those channels.<br>
[SEE_ALSO]
DSP::setParameterFloat
DSP::getParameterFloat
FMOD_DSP_TYPE
]
*/
typedef enum
{
FMOD_DSP_ITECHO_WETDRYMIX, /* (Type:float) - Ratio of wet (processed) signal to dry (unprocessed) signal. Must be in the range from 0.0 through 100.0 (all wet). The default value is 50. */
FMOD_DSP_ITECHO_FEEDBACK, /* (Type:float) - Percentage of output fed back into input, in the range from 0.0 through 100.0. The default value is 50. */
FMOD_DSP_ITECHO_LEFTDELAY, /* (Type:float) - Delay for left channel, in milliseconds, in the range from 1.0 through 2000.0. The default value is 500 ms. */
FMOD_DSP_ITECHO_RIGHTDELAY, /* (Type:float) - Delay for right channel, in milliseconds, in the range from 1.0 through 2000.0. The default value is 500 ms. */
FMOD_DSP_ITECHO_PANDELAY /* (Type:float) - Value that specifies whether to swap left and right delays with each successive echo. The default value is zero, meaning no swap. Possible values are defined as 0.0 (equivalent to FALSE) and 1.0 (equivalent to TRUE). CURRENTLY NOT SUPPORTED. */
} FMOD_DSP_ITECHO;
/*
[ENUM]
[
[DESCRIPTION]
Parameter types for the FMOD_DSP_TYPE_COMPRESSOR unit.
This is a simple linked multichannel software limiter that is uniform across the whole spectrum.<br>
[REMARKS]
The limiter is not guaranteed to catch every peak above the threshold level,
because it cannot apply gain reduction instantaneously - the time delay is
determined by the attack time. However setting the attack time too short will
distort the sound, so it is a compromise. High level peaks can be avoided by
using a short attack time - but not too short, and setting the threshold a few
decibels below the critical level.
<br>
[SEE_ALSO]
DSP::setParameterFloat
DSP::getParameterFloat
DSP::setParameterBool
DSP::getParameterBool
FMOD_DSP_TYPE
]
*/
typedef enum
{
FMOD_DSP_COMPRESSOR_THRESHOLD, /* (Type:float) - Threshold level (dB) in the range from -80 through 0. The default value is 0. */
FMOD_DSP_COMPRESSOR_RATIO, /* (Type:float) - Compression Ratio (dB/dB) in the range from 1 to 50. The default value is 2.5. */
FMOD_DSP_COMPRESSOR_ATTACK, /* (Type:float) - Attack time (milliseconds), in the range from 0.1 through 1000. The default value is 20. */
FMOD_DSP_COMPRESSOR_RELEASE, /* (Type:float) - Release time (milliseconds), in the range from 10 through 5000. The default value is 100 */
FMOD_DSP_COMPRESSOR_GAINMAKEUP, /* (Type:float) - Make-up gain (dB) applied after limiting, in the range from 0 through 30. The default value is 0. */
FMOD_DSP_COMPRESSOR_USESIDECHAIN /* (Type:bool) - Whether to analyse the sidechain signal instead of the input signal. The default value is false */
} FMOD_DSP_COMPRESSOR;
/*
[ENUM]
[
[DESCRIPTION]
Parameter types for the FMOD_DSP_TYPE_SFXREVERB unit.<br>
[REMARKS]
This is a high quality I3DL2 based reverb.<br>
On top of the I3DL2 property set, "Dry Level" is also included to allow the dry mix to be changed.<br>
<br>
These properties can be set with presets in FMOD_REVERB_PRESETS.
[SEE_ALSO]
DSP::setParameterFloat
DSP::getParameterFloat
FMOD_DSP_TYPE
FMOD_REVERB_PRESETS
]
*/
typedef enum
{
FMOD_DSP_SFXREVERB_DECAYTIME, /* (Type:float) - Decay Time : Reverberation decay time at low-frequencies in milliseconds. Ranges from 100.0 to 20000.0. Default is 1500. */
FMOD_DSP_SFXREVERB_EARLYDELAY, /* (Type:float) - Early Delay : Delay time of first reflection in milliseconds. Ranges from 0.0 to 300.0. Default is 20. */
FMOD_DSP_SFXREVERB_LATEDELAY, /* (Type:float) - Reverb Delay : Late reverberation delay time relative to first reflection in milliseconds. Ranges from 0.0 to 100.0. Default is 40. */
FMOD_DSP_SFXREVERB_HFREFERENCE, /* (Type:float) - HF Reference : Reference frequency for high-frequency decay in Hz. Ranges from 20.0 to 20000.0. Default is 5000. */
FMOD_DSP_SFXREVERB_HFDECAYRATIO, /* (Type:float) - Decay HF Ratio : High-frequency decay time relative to decay time in percent. Ranges from 10.0 to 100.0. Default is 50. */
FMOD_DSP_SFXREVERB_DIFFUSION, /* (Type:float) - Diffusion : Reverberation diffusion (echo density) in percent. Ranges from 0.0 to 100.0. Default is 100. */
FMOD_DSP_SFXREVERB_DENSITY, /* (Type:float) - Density : Reverberation density (modal density) in percent. Ranges from 0.0 to 100.0. Default is 100. */
FMOD_DSP_SFXREVERB_LOWSHELFFREQUENCY, /* (Type:float) - Low Shelf Frequency : Transition frequency of low-shelf filter in Hz. Ranges from 20.0 to 1000.0. Default is 250. */
FMOD_DSP_SFXREVERB_LOWSHELFGAIN, /* (Type:float) - Low Shelf Gain : Gain of low-shelf filter in dB. Ranges from -36.0 to 12.0. Default is 0. */
FMOD_DSP_SFXREVERB_HIGHCUT, /* (Type:float) - High Cut : Cutoff frequency of low-pass filter in Hz. Ranges from 20.0 to 20000.0. Default is 20000. */
FMOD_DSP_SFXREVERB_EARLYLATEMIX, /* (Type:float) - Early/Late Mix : Blend ratio of late reverb to early reflections in percent. Ranges from 0.0 to 100.0. Default is 50. */
FMOD_DSP_SFXREVERB_WETLEVEL, /* (Type:float) - Wet Level : Reverb signal level in dB. Ranges from -80.0 to 20.0. Default is -6. */
FMOD_DSP_SFXREVERB_DRYLEVEL /* (Type:float) - Dry Level : Dry signal level in dB. Ranges from -80.0 to 20.0. Default is 0. */
} FMOD_DSP_SFXREVERB;
/*
[ENUM]
[
[DESCRIPTION]
Parameter types for the FMOD_DSP_TYPE_LOWPASS_SIMPLE filter.<br>
This is a very simple low pass filter, based on two single-pole RC time-constant modules.
The emphasis is on speed rather than accuracy, so this should not be used for task requiring critical filtering.<br>
[REMARKS]
[SEE_ALSO]
DSP::setParameterFloat
DSP::getParameterFloat
FMOD_DSP_TYPE
]
*/
typedef enum
{
FMOD_DSP_LOWPASS_SIMPLE_CUTOFF /* (Type:float) - Lowpass cutoff frequency in hz. 10.0 to 22000.0. Default = 5000.0 */
} FMOD_DSP_LOWPASS_SIMPLE;
/*
[ENUM]
[
[DESCRIPTION]
Parameter types for the FMOD_DSP_TYPE_DELAY filter.
[REMARKS]
Note. Every time MaxDelay is changed, the plugin re-allocates the delay buffer. This means the delay will dissapear at that time while it refills its new buffer.<br>
A larger MaxDelay results in larger amounts of memory allocated.<br>
Channel delays above MaxDelay will be clipped to MaxDelay and the delay buffer will not be resized.<br>
<br>
<b>NOTE!</b> Not supported on PlayStation 3.
[SEE_ALSO]
DSP::setParameterFloat
DSP::getParameterFloat
FMOD_DSP_TYPE
]
*/
typedef enum
{
FMOD_DSP_DELAY_CH0, /* (Type:float) - Channel #0 Delay in ms. 0 to 10000. Default = 0. */
FMOD_DSP_DELAY_CH1, /* (Type:float) - Channel #1 Delay in ms. 0 to 10000. Default = 0. */
FMOD_DSP_DELAY_CH2, /* (Type:float) - Channel #2 Delay in ms. 0 to 10000. Default = 0. */
FMOD_DSP_DELAY_CH3, /* (Type:float) - Channel #3 Delay in ms. 0 to 10000. Default = 0. */
FMOD_DSP_DELAY_CH4, /* (Type:float) - Channel #4 Delay in ms. 0 to 10000. Default = 0. */
FMOD_DSP_DELAY_CH5, /* (Type:float) - Channel #5 Delay in ms. 0 to 10000. Default = 0. */
FMOD_DSP_DELAY_CH6, /* (Type:float) - Channel #6 Delay in ms. 0 to 10000. Default = 0. */
FMOD_DSP_DELAY_CH7, /* (Type:float) - Channel #7 Delay in ms. 0 to 10000. Default = 0. */
FMOD_DSP_DELAY_CH8, /* (Type:float) - Channel #8 Delay in ms. 0 to 10000. Default = 0. */
FMOD_DSP_DELAY_CH9, /* (Type:float) - Channel #9 Delay in ms. 0 to 10000. Default = 0. */
FMOD_DSP_DELAY_CH10, /* (Type:float) - Channel #10 Delay in ms. 0 to 10000. Default = 0. */
FMOD_DSP_DELAY_CH11, /* (Type:float) - Channel #11 Delay in ms. 0 to 10000. Default = 0. */
FMOD_DSP_DELAY_CH12, /* (Type:float) - Channel #12 Delay in ms. 0 to 10000. Default = 0. */
FMOD_DSP_DELAY_CH13, /* (Type:float) - Channel #13 Delay in ms. 0 to 10000. Default = 0. */
FMOD_DSP_DELAY_CH14, /* (Type:float) - Channel #14 Delay in ms. 0 to 10000. Default = 0. */
FMOD_DSP_DELAY_CH15, /* (Type:float) - Channel #15 Delay in ms. 0 to 10000. Default = 0. */
FMOD_DSP_DELAY_MAXDELAY /* (Type:float) - Maximum delay in ms. 0 to 10000. Default = 10. */
} FMOD_DSP_DELAY;
/*
[ENUM]
[
[DESCRIPTION]
Parameter types for the FMOD_DSP_TYPE_TREMOLO filter.
[REMARKS]
The tremolo effect varies the amplitude of a sound. Depending on the settings, this unit can produce a tremolo, chopper or auto-pan effect.<br>
<br>
The shape of the LFO (low freq. oscillator) can morphed between sine, triangle and sawtooth waves using the FMOD_DSP_TREMOLO_SHAPE and FMOD_DSP_TREMOLO_SKEW parameters.<br>
FMOD_DSP_TREMOLO_DUTY and FMOD_DSP_TREMOLO_SQUARE are useful for a chopper-type effect where the first controls the on-time duration and second controls the flatness of the envelope.<br>
[SEE_ALSO]
DSP::setParameterFloat
DSP::getParameterFloat
FMOD_DSP_TYPE
]
*/
typedef enum
{
FMOD_DSP_TREMOLO_FREQUENCY, /* (Type:float) - LFO frequency in Hz. 0.1 to 20. Default = 5. */
FMOD_DSP_TREMOLO_DEPTH, /* (Type:float) - Tremolo depth. 0 to 1. Default = 1. */
FMOD_DSP_TREMOLO_SHAPE, /* (Type:float) - LFO shape morph between triangle and sine. 0 to 1. Default = 0. */
FMOD_DSP_TREMOLO_SKEW, /* (Type:float) - Time-skewing of LFO cycle. -1 to 1. Default = 0. */
FMOD_DSP_TREMOLO_DUTY, /* (Type:float) - LFO on-time. 0 to 1. Default = 0.5. */
FMOD_DSP_TREMOLO_SQUARE, /* (Type:float) - Flatness of the LFO shape. 0 to 1. Default = 0. */
FMOD_DSP_TREMOLO_PHASE, /* (Type:float) - Instantaneous LFO. 0 to 1. Default = 0. */
FMOD_DSP_TREMOLO_SPREAD /* (Type:float) - Rotation / auto-pan effect. -1 to 1. Default = 0. */
} FMOD_DSP_TREMOLO;
/*
[ENUM]
[
[DESCRIPTION]
Parameter types for the FMOD_DSP_TYPE_SEND DSP.
[REMARKS]
[SEE_ALSO]
DSP::setParameterInt
DSP::getParameterInt
DSP::setParameterFloat
DSP::getParameterFloat
FMOD_DSP_TYPE
]
*/
typedef enum
{
FMOD_DSP_SEND_RETURNID, /* (Type:int) - ID of the Return DSP this send is connected to (integer values only). -1 indicates no connected Return DSP. Default = -1. */
FMOD_DSP_SEND_LEVEL, /* (Type:float) - Send level. 0.0 to 1.0. Default = 1.0 */
} FMOD_DSP_SEND;
/*
[ENUM]
[
[DESCRIPTION]
Parameter types for the FMOD_DSP_TYPE_RETURN DSP.
[REMARKS]
[SEE_ALSO]
DSP::setParameterInt
DSP::getParameterInt
FMOD_DSP_TYPE
]
*/
typedef enum
{
FMOD_DSP_RETURN_ID, /* (Type:int) - [r] ID of this Return DSP. Read-only. Default = -1*/
FMOD_DSP_RETURN_INPUT_FORMAT /* (Type:int) - [r/w] Input format of this return. 0 = mono, 1 = stereo, 2 = 'surround'. Surround = the speaker format of the mixer. Default = 2.*/
} FMOD_DSP_RETURN;
/*
[ENUM]
[
[DESCRIPTION]
Parameter types for the FMOD_DSP_TYPE_HIGHPASS_SIMPLE filter.<br>
This is a very simple single-order high pass filter.
The emphasis is on speed rather than accuracy, so this should not be used for task requiring critical filtering.<br>
[REMARKS]
[SEE_ALSO]
DSP::setParameterFloat
DSP::getParameterFloat
FMOD_DSP_TYPE
]
*/
typedef enum
{
FMOD_DSP_HIGHPASS_SIMPLE_CUTOFF /* (Type:float) - Highpass cutoff frequency in hz. 10.0 to 22000.0. Default = 1000.0 */
} FMOD_DSP_HIGHPASS_SIMPLE;
/*
[ENUM]
[
[DESCRIPTION]
Parameter values for the FMOD_DSP_PAN_SURROUND_FROM_STEREO_MODE parameter of the FMOD_DSP_TYPE_PAN DSP.
[REMARKS]
[SEE_ALSO]
FMOD_DSP_PAN
]
*/
typedef enum
{
FMOD_DSP_PAN_SURROUND_FROM_STEREO_MODE_DISTRIBUTED,
FMOD_DSP_PAN_SURROUND_FROM_STEREO_MODE_DISCRETE
} FMOD_DSP_PAN_SURROUND_FROM_STEREO_MODE_TYPE;
/*
[ENUM]
[
[DESCRIPTION]
Parameter values for the FMOD_DSP_PAN_3D_ROLLOFF parameter of the FMOD_DSP_TYPE_PAN DSP.
[REMARKS]
[SEE_ALSO]
FMOD_DSP_PAN
]
*/
typedef enum
{
FMOD_DSP_PAN_3D_ROLLOFF_LINEARSQUARED,
FMOD_DSP_PAN_3D_ROLLOFF_LINEAR,
FMOD_DSP_PAN_3D_ROLLOFF_INVERSE,
FMOD_DSP_PAN_3D_ROLLOFF_INVERSETAPERED,
FMOD_DSP_PAN_3D_ROLLOFF_CUSTOM
} FMOD_DSP_PAN_3D_ROLLOFF_TYPE;
/*
[ENUM]
[
[DESCRIPTION]
Parameter values for the FMOD_DSP_PAN_3D_EXTENT_MODE parameter of the FMOD_DSP_TYPE_PAN DSP.
[REMARKS]
[SEE_ALSO]
FMOD_DSP_PAN
]
*/
typedef enum
{
FMOD_DSP_PAN_3D_EXTENT_MODE_AUTO,
FMOD_DSP_PAN_3D_EXTENT_MODE_USER,
FMOD_DSP_PAN_3D_EXTENT_MODE_OFF
} FMOD_DSP_PAN_3D_EXTENT_MODE_TYPE;
/*
[ENUM]
[
[DESCRIPTION]
Parameter types for the FMOD_DSP_TYPE_PAN DSP.
[REMARKS]
[SEE_ALSO]
DSP::setParameterFloat
DSP::getParameterFloat
DSP::setParameterInt
DSP::getParameterInt
DSP::setParameterData
DSP::getParameterData
FMOD_DSP_TYPE
]
*/
typedef enum
{
FMOD_DSP_PAN_OUTPUT_FORMAT, /* (Type:float) - Output channel format. 0 = Mono, 1 = Stereo, 2 = Surround. Default = 2 */
FMOD_DSP_PAN_STEREO_POSITION, /* (Type:float) - Stereo pan position STEREO_POSITION_MIN to STEREO_POSITION_MAX. Default = 0.0. */
FMOD_DSP_PAN_SURROUND_DIRECTION, /* (Type:float) - Surround pan direction ROTATION_MIN to ROTATION_MAX. Default = 0.0. */
FMOD_DSP_PAN_SURROUND_EXTENT, /* (Type:float) - Surround pan extent EXTENT_MIN to EXTENT_MAX. Default = 360.0. */
FMOD_DSP_PAN_SURROUND_ROTATION, /* (Type:float) - Surround pan rotation ROTATION_MIN to ROTATION_MAX. Default = 0.0. */
FMOD_DSP_PAN_SURROUND_LFE_LEVEL, /* (Type:float) - Surround pan LFE level SURROUND_LFE_LEVEL_MIN to SURROUND_LFE_LEVEL_MAX. Default = 0.0. */
FMOD_DSP_PAN_SURROUND_FROM_STEREO_MODE, /* (Type:int) - Stereo-To-Surround Mode FMOD_DSP_PAN_SURROUND_FROM_STEREO_MODE_DISTRIBUTED to FMOD_DSP_PAN_SURROUND_FROM_STEREO_MODE_DISCRETE. Default = FMOD_DSP_PAN_SURROUND_FROM_STEREO_MODE_DISCRETE. */
FMOD_DSP_PAN_SURROUND_STEREO_SEPARATION, /* (Type:float) - Stereo-To-Surround Stereo Separation. ROTATION_MIN to ROTATION_MAX. Default = 60.0. */
FMOD_DSP_PAN_SURROUND_STEREO_AXIS, /* (Type:float) - Stereo-To-Surround Stereo Axis. ROTATION_MIN to ROTATION_MAX. Default = 0.0. */
FMOD_DSP_PAN_ENABLED_SURROUND_SPEAKERS, /* (Type:int) - Surround Speakers Enabled. 0 to 0xFFF. Default = 0xFFF. */
FMOD_DSP_PAN_3D_POSITION, /* (Type:data) - 3D Position data of type FMOD_DSP_PARAMETER_DATA_TYPE_3DPOS */
FMOD_DSP_PAN_3D_ROLLOFF, /* (Type:int) - 3D Rolloff FMOD_DSP_PAN_3D_ROLLOFF_LINEARSQUARED to FMOD_DSP_PAN_3D_ROLLOFF_CUSTOM. Default = FMOD_DSP_PAN_3D_ROLLOFF_LINEARSQUARED. */
FMOD_DSP_PAN_3D_MIN_DISTANCE, /* (Type:float) - 3D Min Distance 0.0 to GAME_UNITS_MAX. Default = 1.0. */
FMOD_DSP_PAN_3D_MAX_DISTANCE, /* (Type:float) - 3D Max Distance 0.0 to GAME_UNITS_MAX. Default = 20.0. */
FMOD_DSP_PAN_3D_EXTENT_MODE, /* (Type:int) - 3D Extent Mode FMOD_DSP_PAN_3D_EXTENT_MODE_AUTO to FMOD_DSP_PAN_3D_EXTENT_MODE_OFF. Default = FMOD_DSP_PAN_3D_EXTENT_MODE_AUTO. */
FMOD_DSP_PAN_3D_SOUND_SIZE, /* (Type:float) - 3D Sound Size 0.0 to GAME_UNITS_MAX. Default = 0.0. */
FMOD_DSP_PAN_3D_MIN_EXTENT, /* (Type:float) - 3D Min Extent EXTENT_MIN to EXTENT_MAX. Default = 0.0. */
FMOD_DSP_PAN_3D_PAN_BLEND, /* (Type:float) - 3D Pan Blend PAN_BLEND_MIN to PAN_BLEND_MAX. Default = 0.0. */
FMOD_DSP_PAN_LFE_UPMIX_ENABLED, /* (Type:int) - LFE Upmix Enabled 0 to 1. Default = 0. */
FMOD_DSP_PAN_OVERALL_GAIN /* (Type:data) - Overall Gain data of type FMOD_DSP_PARAMETER_DATA_TYPE_OVERALLGAIN */
} FMOD_DSP_PAN;
/*
[ENUM]
[
[DESCRIPTION]
Parameter values for the FMOD_DSP_THREE_EQ_CROSSOVERSLOPE parameter of the FMOD_DSP_TYPE_THREE_EQ DSP.
[REMARKS]
[SEE_ALSO]
FMOD_DSP_THREE_EQ
]
*/
typedef enum
{
FMOD_DSP_THREE_EQ_CROSSOVERSLOPE_12DB,
FMOD_DSP_THREE_EQ_CROSSOVERSLOPE_24DB,
FMOD_DSP_THREE_EQ_CROSSOVERSLOPE_48DB
} FMOD_DSP_THREE_EQ_CROSSOVERSLOPE_TYPE;
/*
[ENUM]
[
[DESCRIPTION]
Parameter types for the FMOD_DSP_TYPE_THREE_EQ filter.
[REMARKS]
[SEE_ALSO]
DSP::setParameterFloat
DSP::getParameterFloat
DSP::setParameterInt
DSP::getParameterInt
FMOD_DSP_TYPE
FMOD_DSP_THREE_EQ_CROSSOVERSLOPE_TYPE
]
*/
typedef enum
{
FMOD_DSP_THREE_EQ_LOWGAIN, /* (Type:float) - Low frequency gain in dB. -80.0 to 10.0. Default = 0. */
FMOD_DSP_THREE_EQ_MIDGAIN, /* (Type:float) - Mid frequency gain in dB. -80.0 to 10.0. Default = 0. */
FMOD_DSP_THREE_EQ_HIGHGAIN, /* (Type:float) - High frequency gain in dB. -80.0 to 10.0. Default = 0. */
FMOD_DSP_THREE_EQ_LOWCROSSOVER, /* (Type:float) - Low-to-mid crossover frequency in Hz. 10.0 to 22000.0. Default = 400.0. */
FMOD_DSP_THREE_EQ_HIGHCROSSOVER, /* (Type:float) - Mid-to-high crossover frequency in Hz. 10.0 to 22000.0. Default = 4000.0. */
FMOD_DSP_THREE_EQ_CROSSOVERSLOPE /* (Type:int) - Crossover Slope. 0 = 12dB/Octave, 1 = 24dB/Octave, 2 = 48dB/Octave. Default = 1 (24dB/Octave). */
} FMOD_DSP_THREE_EQ;
/*
[ENUM]
[
[DESCRIPTION]
List of windowing methods for the FMOD_DSP_TYPE_FFT unit. Used in spectrum analysis to reduce leakage / transient signals intefering with the analysis.<br>
This is a problem with analysis of continuous signals that only have a small portion of the signal sample (the fft window size).<br>
Windowing the signal with a curve or triangle tapers the sides of the fft window to help alleviate this problem.
[REMARKS]
Cyclic signals such as a sine wave that repeat their cycle in a multiple of the window size do not need windowing.<br>
I.e. If the sine wave repeats every 1024, 512, 256 etc samples and the FMOD fft window is 1024, then the signal would not need windowing.<br>
Not windowing is the same as FMOD_DSP_FFT_WINDOW_RECT, which is the default.<br>
If the cycle of the signal (ie the sine wave) is not a multiple of the window size, it will cause frequency abnormalities, so a different windowing method is needed.<br>
<exclude>
<br>
FMOD_DSP_FFT_WINDOW_RECT.<br>
<img src="..\static\overview\rectangle.gif"></img><br>
<br>
FMOD_DSP_FFT_WINDOW_TRIANGLE.<br>
<img src="..\static\overview\triangle.gif"></img><br>
<br>
FMOD_DSP_FFT_WINDOW_HAMMING.<br>
<img src="..\static\overview\hamming.gif"></img><br>
<br>
FMOD_DSP_FFT_WINDOW_HANNING.<br>
<img src="..\static\overview\hanning.gif"></img><br>
<br>
FMOD_DSP_FFT_WINDOW_BLACKMAN.<br>
<img src="..\static\overview\blackman.gif"></img><br>
<br>
FMOD_DSP_FFT_WINDOW_BLACKMANHARRIS.<br>
<img src="..\static\overview\blackmanharris.gif"></img>
</exclude>
[SEE_ALSO]
FMOD_DSP_FFT
]
*/
typedef enum
{
FMOD_DSP_FFT_WINDOW_RECT, /* w[n] = 1.0 */
FMOD_DSP_FFT_WINDOW_TRIANGLE, /* w[n] = TRI(2n/N) */
FMOD_DSP_FFT_WINDOW_HAMMING, /* w[n] = 0.54 - (0.46 * COS(n/N) ) */
FMOD_DSP_FFT_WINDOW_HANNING, /* w[n] = 0.5 * (1.0 - COS(n/N) ) */
FMOD_DSP_FFT_WINDOW_BLACKMAN, /* w[n] = 0.42 - (0.5 * COS(n/N) ) + (0.08 * COS(2.0 * n/N) ) */
FMOD_DSP_FFT_WINDOW_BLACKMANHARRIS /* w[n] = 0.35875 - (0.48829 * COS(1.0 * n/N)) + (0.14128 * COS(2.0 * n/N)) - (0.01168 * COS(3.0 * n/N)) */
} FMOD_DSP_FFT_WINDOW;
/*
[ENUM]
[
[DESCRIPTION]
Parameter types for the FMOD_DSP_TYPE_FFT dsp effect.
[REMARKS]
Set the attributes for the spectrum analysis with FMOD_DSP_FFT_WINDOWSIZE and FMOD_DSP_FFT_WINDOWTYPE, and retrieve the results with FMOD_DSP_FFT_SPECTRUM and FMOD_DSP_FFT_DOMINANT_FREQ.
FMOD_DSP_FFT_SPECTRUM stores its data in the FMOD_DSP_PARAMETER_DATA_TYPE_FFT. You will need to cast to this structure to get the right data.
[SEE_ALSO]
DSP::setParameterFloat
DSP::getParameterFloat
DSP::setParameterInt
DSP::getParameterInt
DSP::setParameterData
DSP::getParameterData
FMOD_DSP_TYPE
FMOD_DSP_FFT_WINDOW
]
*/
typedef enum
{
FMOD_DSP_FFT_WINDOWSIZE, /* (Type:int) - [r/w] Must be a power of 2 between 128 and 16384. 128, 256, 512, 1024, 2048, 4096, 8192, 16384 are accepted. Default = 2048. */
FMOD_DSP_FFT_WINDOWTYPE, /* (Type:int) - [r/w] Refer to FMOD_DSP_FFT_WINDOW enumeration. Default = FMOD_DSP_FFT_WINDOW_HAMMING. */
FMOD_DSP_FFT_SPECTRUMDATA, /* (Type:data) - [r] Returns the current spectrum values between 0 and 1 for each 'fft bin'. Cast data to FMOD_DSP_PARAMETER_DATA_TYPE_FFT. Divide the niquist rate by the window size to get the hz value per entry. */
FMOD_DSP_FFT_DOMINANT_FREQ /* (Type:float) - [r] Returns the dominant frequencies for each channel. */
} FMOD_DSP_FFT;
/*
[ENUM]
[
[DESCRIPTION]
Parameter types for the FMOD_DSP_TYPE_ENVELOPEFOLLOWER unit.
This is a simple envelope follower for tracking the signal level.<br>
[REMARKS]
This unit does not affect the incoming signal
<br>
[SEE_ALSO]
DSP::setParameterFloat
DSP::getParameterFloat
DSP::setParameterBool
DSP::getParameterBool
FMOD_DSP_TYPE
]
*/
typedef enum
{
FMOD_DSP_ENVELOPEFOLLOWER_ATTACK, /* (Type:float) [r/w] - Attack time (milliseconds), in the range from 0.1 through 1000. The default value is 20. */
FMOD_DSP_ENVELOPEFOLLOWER_RELEASE, /* (Type:float) [r/w] - Release time (milliseconds), in the range from 10 through 5000. The default value is 100 */
FMOD_DSP_ENVELOPEFOLLOWER_ENVELOPE, /* (Type:float) [r] - Current value of the envelope, in the range 0 to 1. Read-only. */
FMOD_DSP_ENVELOPEFOLLOWER_USESIDECHAIN /* (Type:bool) [r/w] - Whether to analyse the sidechain signal instead of the input signal. The default value is false */
} FMOD_DSP_ENVELOPEFOLLOWER;
/*
[ENUM]
[
[DESCRIPTION]
Parameter types for the FMOD_DSP_TYPE_CONVOLUTIONREVERB filter.
[REMARKS]
Convolution Reverb reverb IR.<br>
[SEE_ALSO]
DSP::setParameterFloat
DSP::getParameterFloat
DSP::setParameterData
DSP::getParameterData
FMOD_DSP_TYPE
]
*/
typedef enum
{
FMOD_DSP_CONVOLUTION_REVERB_PARAM_IR, /* (Type:data) - [w] 16-bit reverb IR (short*) with an extra sample prepended to the start which specifies the number of channels. */
FMOD_DSP_CONVOLUTION_REVERB_PARAM_WET, /* (Type:float) - [r/w] Volume of echo signal to pass to output in dB. -80.0 to 10.0. Default = 0. */
FMOD_DSP_CONVOLUTION_REVERB_PARAM_DRY /* (Type:float) - [r/w] Original sound volume in dB. -80.0 to 10.0. Default = 0. */
} FMOD_DSP_CONVOLUTION_REVERB;
#endif
+111
View File
@@ -0,0 +1,111 @@
/*$ preserve start $*/
/* ================================================================================================== */
/* FMOD Studio - Error string header file. Copyright (c), Firelight Technologies Pty, Ltd. 2004-2015. */
/* */
/* Use this header if you want to store or display a string version / english explanation of */
/* the FMOD error codes. */
/* */
/* ================================================================================================== */
#ifndef _FMOD_ERRORS_H
#define _FMOD_ERRORS_H
#include "fmod.h"
#ifdef __GNUC__
static const char *FMOD_ErrorString(FMOD_RESULT errcode) __attribute__((unused));
#endif
static const char *FMOD_ErrorString(FMOD_RESULT errcode)
{
switch (errcode)
{
/*$ preserve end $*/
case FMOD_OK: return "No errors.";
case FMOD_ERR_BADCOMMAND: return "Tried to call a function on a data type that does not allow this type of functionality (ie calling Sound::lock on a streaming sound).";
case FMOD_ERR_CHANNEL_ALLOC: return "Error trying to allocate a channel.";
case FMOD_ERR_CHANNEL_STOLEN: return "The specified channel has been reused to play another sound.";
case FMOD_ERR_DMA: return "DMA Failure. See debug output for more information.";
case FMOD_ERR_DSP_CONNECTION: return "DSP connection error. Connection possibly caused a cyclic dependency or connected dsps with incompatible buffer counts.";
case FMOD_ERR_DSP_DONTPROCESS: return "DSP return code from a DSP process query callback. Tells mixer not to call the process callback and therefore not consume CPU. Use this to optimize the DSP graph.";
case FMOD_ERR_DSP_FORMAT: return "DSP Format error. A DSP unit may have attempted to connect to this network with the wrong format, or a matrix may have been set with the wrong size if the target unit has a specified channel map.";
case FMOD_ERR_DSP_INUSE: return "DSP is already in the mixer's DSP network. It must be removed before being reinserted or released.";
case FMOD_ERR_DSP_NOTFOUND: return "DSP connection error. Couldn't find the DSP unit specified.";
case FMOD_ERR_DSP_RESERVED: return "DSP operation error. Cannot perform operation on this DSP as it is reserved by the system.";
case FMOD_ERR_DSP_SILENCE: return "DSP return code from a DSP process query callback. Tells mixer silence would be produced from read, so go idle and not consume CPU. Use this to optimize the DSP graph.";
case FMOD_ERR_DSP_TYPE: return "DSP operation cannot be performed on a DSP of this type.";
case FMOD_ERR_FILE_BAD: return "Error loading file.";
case FMOD_ERR_FILE_COULDNOTSEEK: return "Couldn't perform seek operation. This is a limitation of the medium (ie netstreams) or the file format.";
case FMOD_ERR_FILE_DISKEJECTED: return "Media was ejected while reading.";
case FMOD_ERR_FILE_EOF: return "End of file unexpectedly reached while trying to read essential data (truncated?).";
case FMOD_ERR_FILE_ENDOFDATA: return "End of current chunk reached while trying to read data.";
case FMOD_ERR_FILE_NOTFOUND: return "File not found.";
case FMOD_ERR_FORMAT: return "Unsupported file or audio format.";
case FMOD_ERR_HEADER_MISMATCH: return "There is a version mismatch between the FMOD header and either the FMOD Studio library or the FMOD Low Level library.";
case FMOD_ERR_HTTP: return "A HTTP error occurred. This is a catch-all for HTTP errors not listed elsewhere.";
case FMOD_ERR_HTTP_ACCESS: return "The specified resource requires authentication or is forbidden.";
case FMOD_ERR_HTTP_PROXY_AUTH: return "Proxy authentication is required to access the specified resource.";
case FMOD_ERR_HTTP_SERVER_ERROR: return "A HTTP server error occurred.";
case FMOD_ERR_HTTP_TIMEOUT: return "The HTTP request timed out.";
case FMOD_ERR_INITIALIZATION: return "FMOD was not initialized correctly to support this function.";
case FMOD_ERR_INITIALIZED: return "Cannot call this command after System::init.";
case FMOD_ERR_INTERNAL: return "An error occurred that wasn't supposed to. Contact support.";
case FMOD_ERR_INVALID_FLOAT: return "Value passed in was a NaN, Inf or denormalized float.";
case FMOD_ERR_INVALID_HANDLE: return "An invalid object handle was used.";
case FMOD_ERR_INVALID_PARAM: return "An invalid parameter was passed to this function.";
case FMOD_ERR_INVALID_POSITION: return "An invalid seek position was passed to this function.";
case FMOD_ERR_INVALID_SPEAKER: return "An invalid speaker was passed to this function based on the current speaker mode.";
case FMOD_ERR_INVALID_SYNCPOINT: return "The syncpoint did not come from this sound handle.";
case FMOD_ERR_INVALID_THREAD: return "Tried to call a function on a thread that is not supported.";
case FMOD_ERR_INVALID_VECTOR: return "The vectors passed in are not unit length, or perpendicular.";
case FMOD_ERR_MAXAUDIBLE: return "Reached maximum audible playback count for this sound's soundgroup.";
case FMOD_ERR_MEMORY: return "Not enough memory or resources.";
case FMOD_ERR_MEMORY_CANTPOINT: return "Can't use FMOD_OPENMEMORY_POINT on non PCM source data, or non mp3/xma/adpcm data if FMOD_CREATECOMPRESSEDSAMPLE was used.";
case FMOD_ERR_NEEDS3D: return "Tried to call a command on a 2d sound when the command was meant for 3d sound.";
case FMOD_ERR_NEEDSHARDWARE: return "Tried to use a feature that requires hardware support.";
case FMOD_ERR_NET_CONNECT: return "Couldn't connect to the specified host.";
case FMOD_ERR_NET_SOCKET_ERROR: return "A socket error occurred. This is a catch-all for socket-related errors not listed elsewhere.";
case FMOD_ERR_NET_URL: return "The specified URL couldn't be resolved.";
case FMOD_ERR_NET_WOULD_BLOCK: return "Operation on a non-blocking socket could not complete immediately.";
case FMOD_ERR_NOTREADY: return "Operation could not be performed because specified sound/DSP connection is not ready.";
case FMOD_ERR_OUTPUT_ALLOCATED: return "Error initializing output device, but more specifically, the output device is already in use and cannot be reused.";
case FMOD_ERR_OUTPUT_CREATEBUFFER: return "Error creating hardware sound buffer.";
case FMOD_ERR_OUTPUT_DRIVERCALL: return "A call to a standard soundcard driver failed, which could possibly mean a bug in the driver or resources were missing or exhausted.";
case FMOD_ERR_OUTPUT_FORMAT: return "Soundcard does not support the specified format.";
case FMOD_ERR_OUTPUT_INIT: return "Error initializing output device.";
case FMOD_ERR_OUTPUT_NODRIVERS: return "The output device has no drivers installed. If pre-init, FMOD_OUTPUT_NOSOUND is selected as the output mode. If post-init, the function just fails.";
case FMOD_ERR_PLUGIN: return "An unspecified error has been returned from a plugin.";
case FMOD_ERR_PLUGIN_MISSING: return "A requested output, dsp unit type or codec was not available.";
case FMOD_ERR_PLUGIN_RESOURCE: return "A resource that the plugin requires cannot be found. (ie the DLS file for MIDI playback)";
case FMOD_ERR_PLUGIN_VERSION: return "A plugin was built with an unsupported SDK version.";
case FMOD_ERR_RECORD: return "An error occurred trying to initialize the recording device.";
case FMOD_ERR_REVERB_CHANNELGROUP: return "Reverb properties cannot be set on this channel because a parent channelgroup owns the reverb connection.";
case FMOD_ERR_REVERB_INSTANCE: return "Specified instance in FMOD_REVERB_PROPERTIES couldn't be set. Most likely because it is an invalid instance number or the reverb doesn't exist.";
case FMOD_ERR_SUBSOUNDS: return "The error occurred because the sound referenced contains subsounds when it shouldn't have, or it doesn't contain subsounds when it should have. The operation may also not be able to be performed on a parent sound.";
case FMOD_ERR_SUBSOUND_ALLOCATED: return "This subsound is already being used by another sound, you cannot have more than one parent to a sound. Null out the other parent's entry first.";
case FMOD_ERR_SUBSOUND_CANTMOVE: return "Shared subsounds cannot be replaced or moved from their parent stream, such as when the parent stream is an FSB file.";
case FMOD_ERR_TAGNOTFOUND: return "The specified tag could not be found or there are no tags.";
case FMOD_ERR_TOOMANYCHANNELS: return "The sound created exceeds the allowable input channel count. This can be increased using the 'maxinputchannels' parameter in System::setSoftwareFormat.";
case FMOD_ERR_TRUNCATED: return "The retrieved string is too long to fit in the supplied buffer and has been truncated.";
case FMOD_ERR_UNIMPLEMENTED: return "Something in FMOD hasn't been implemented when it should be! contact support!";
case FMOD_ERR_UNINITIALIZED: return "This command failed because System::init or System::setDriver was not called.";
case FMOD_ERR_UNSUPPORTED: return "A command issued was not supported by this object. Possibly a plugin without certain callbacks specified.";
case FMOD_ERR_VERSION: return "The version number of this file format is not supported.";
case FMOD_ERR_EVENT_ALREADY_LOADED: return "The specified bank has already been loaded.";
case FMOD_ERR_EVENT_LIVEUPDATE_BUSY: return "The live update connection failed due to the game already being connected.";
case FMOD_ERR_EVENT_LIVEUPDATE_MISMATCH: return "The live update connection failed due to the game data being out of sync with the tool.";
case FMOD_ERR_EVENT_LIVEUPDATE_TIMEOUT: return "The live update connection timed out.";
case FMOD_ERR_EVENT_NOTFOUND: return "The requested event, bus or vca could not be found.";
case FMOD_ERR_STUDIO_UNINITIALIZED: return "The Studio::System object is not yet initialized.";
case FMOD_ERR_STUDIO_NOT_LOADED: return "The specified resource is not loaded, so it can't be unloaded.";
case FMOD_ERR_INVALID_STRING: return "An invalid string was passed to this function.";
case FMOD_ERR_ALREADY_LOCKED: return "The specified resource is already locked.";
case FMOD_ERR_NOT_LOCKED: return "The specified resource is not locked, so it can't be unlocked.";
default : return "Unknown error.";
/*$ preserve start $*/
};
}
#endif
/*$ preserve end $*/
+25
View File
@@ -0,0 +1,25 @@
#ifndef _FMOD_IOS_H
#define _FMOD_IOS_H
/*
[ENUM]
[
[DESCRIPTION]
Control whether the sound will use a the dedicated hardware decoder or a software codec.
[REMARKS]
Every devices has a single hardware decoder and unlimited software decoders.
[SEE_ALSO]
]
*/
typedef enum
{
FMOD_AUDIOQUEUE_CODECPOLICY_DEFAULT, /* Try hardware first, if it's in use or prohibited by audio session, try software. */
FMOD_AUDIOQUEUE_CODECPOLICY_SOFTWAREONLY, /* kAudioQueueHardwareCodecPolicy_UseSoftwareOnly ~ try software, if not available fail. */
FMOD_AUDIOQUEUE_CODECPOLICY_HARDWAREONLY, /* kAudioQueueHardwareCodecPolicy_UseHardwareOnly ~ try hardware, if not available fail. */
FMOD_AUDIOQUEUE_CODECPOLICY_FORCEINT = 65536 /* Makes sure this enum is signed 32bit */
} FMOD_AUDIOQUEUE_CODECPOLICY;
#endif /* _FMOD_IOS_H */
+88
View File
@@ -0,0 +1,88 @@
/* ======================================================================================================== */
/* FMOD Studio - output development header file. Copyright (c), Firelight Technologies Pty, Ltd. 2004-2015. */
/* */
/* Use this header if you are wanting to develop your own output plugin to use with */
/* FMOD's output system. With this header you can make your own output plugin that FMOD */
/* can register and use. See the documentation and examples on how to make a working plugin. */
/* */
/* ======================================================================================================== */
#ifndef _FMOD_OUTPUT_H
#define _FMOD_OUTPUT_H
typedef struct FMOD_OUTPUT_STATE FMOD_OUTPUT_STATE;
/*
Output callbacks
*/
typedef FMOD_RESULT (F_CALLBACK *FMOD_OUTPUT_GETNUMDRIVERS_CALLBACK) (FMOD_OUTPUT_STATE *output_state, int *numdrivers);
typedef FMOD_RESULT (F_CALLBACK *FMOD_OUTPUT_GETDRIVERINFO_CALLBACK) (FMOD_OUTPUT_STATE *output, int id, char *name, int namelen, FMOD_GUID *guid, int *systemrate, FMOD_SPEAKERMODE *speakermode, int *speakermodechannels);
typedef FMOD_RESULT (F_CALLBACK *FMOD_OUTPUT_INIT_CALLBACK) (FMOD_OUTPUT_STATE *output_state, int selecteddriver, FMOD_INITFLAGS flags, int *outputrate, FMOD_SPEAKERMODE *speakermode, int *speakermodechannels, FMOD_SOUND_FORMAT *outputformat, int dspbufferlength, int dspnumbuffers, void *extradriverdata);
typedef FMOD_RESULT (F_CALLBACK *FMOD_OUTPUT_START_CALLBACK) (FMOD_OUTPUT_STATE *output_state);
typedef FMOD_RESULT (F_CALLBACK *FMOD_OUTPUT_STOP_CALLBACK) (FMOD_OUTPUT_STATE *output_state);
typedef FMOD_RESULT (F_CALLBACK *FMOD_OUTPUT_CLOSE_CALLBACK) (FMOD_OUTPUT_STATE *output_state);
typedef FMOD_RESULT (F_CALLBACK *FMOD_OUTPUT_UPDATE_CALLBACK) (FMOD_OUTPUT_STATE *output_state);
typedef FMOD_RESULT (F_CALLBACK *FMOD_OUTPUT_GETHANDLE_CALLBACK) (FMOD_OUTPUT_STATE *output_state, void **handle);
typedef FMOD_RESULT (F_CALLBACK *FMOD_OUTPUT_GETPOSITION_CALLBACK) (FMOD_OUTPUT_STATE *output_state, unsigned int *pcm);
typedef FMOD_RESULT (F_CALLBACK *FMOD_OUTPUT_LOCK_CALLBACK) (FMOD_OUTPUT_STATE *output_state, unsigned int offset, unsigned int length, void **ptr1, void **ptr2, unsigned int *len1, unsigned int *len2);
typedef FMOD_RESULT (F_CALLBACK *FMOD_OUTPUT_UNLOCK_CALLBACK) (FMOD_OUTPUT_STATE *output_state, void *ptr1, void *ptr2, unsigned int len1, unsigned int len2);
typedef FMOD_RESULT (F_CALLBACK *FMOD_OUTPUT_READFROMMIXER) (FMOD_OUTPUT_STATE *output_state, void *buffer, unsigned int length); /* This one is called by plugin through FMOD_OUTPUT_STATE, not set by user as a callback. */
/*
[STRUCTURE]
[
[DESCRIPTION]
When creating an output, declare one of these and provide the relevant callbacks and name for FMOD to use when it opens and reads a file of this type.
[REMARKS]
Members marked with [in] mean the variable can be written to. The user can set the value.<br>
Members marked with [out] mean the variable is modified by FMOD and is for reading purposes only. Do not change this value.<br>
[SEE_ALSO]
FMOD_OUTPUT_STATE
]
*/
typedef struct FMOD_OUTPUT_DESCRIPTION
{
const char *name; /* [in] Name of the output. */
unsigned int version; /* [in] Plugin writer's version number. */
int polling; /* [in] If TRUE (non zero), this tells FMOD to start a thread and call getposition / lock / unlock for feeding data. If 0, the output is probably callback based, so all the plugin needs to do is call readfrommixer to the appropriate pointer. */
FMOD_OUTPUT_GETNUMDRIVERS_CALLBACK getnumdrivers; /* [in] For sound device enumeration. This callback is to give System::getNumDrivers somthing to return. */
FMOD_OUTPUT_GETDRIVERINFO_CALLBACK getdriverinfo; /* [in] For sound device enumeration. This callback is to give System::getDriverName somthing to return. */
FMOD_OUTPUT_INIT_CALLBACK init; /* [in] Initialization function for the output device. This is called from System::init. */
FMOD_OUTPUT_START_CALLBACK start; /* [in] Initialization function for the output device to start accepting audio data from the FMOD software mixer. This is called from System::init. */
FMOD_OUTPUT_STOP_CALLBACK stop; /* [in] Initialization function for the output device to stop accepting audio data from FMOD the software mixer. This is called from System::close. */
FMOD_OUTPUT_CLOSE_CALLBACK close; /* [in] Cleanup / close down function for the output device. This is called from System::close. */
FMOD_OUTPUT_UPDATE_CALLBACK update; /* [in] Update function that is called once a frame by the user. This is called from System::update. */
FMOD_OUTPUT_GETHANDLE_CALLBACK gethandle; /* [in] This is called from System::getOutputHandle. This is just to return a pointer to the internal system device object that the system may be using.*/
FMOD_OUTPUT_GETPOSITION_CALLBACK getposition; /* [in] This is called from the FMOD software mixer thread if 'polling' = true. This returns a position value in samples so that FMOD knows where and when to fill its buffer. */
FMOD_OUTPUT_LOCK_CALLBACK lock; /* [in] This is called from the FMOD software mixer thread if 'polling' = true. This function provides a pointer to data that FMOD can write to when software mixing. */
FMOD_OUTPUT_UNLOCK_CALLBACK unlock; /* [in] This is called from the FMOD software mixer thread if 'polling' = true. This optional function accepts the data that has been mixed and copies it or does whatever it needs to before sending it to the hardware. */
} FMOD_OUTPUT_DESCRIPTION;
/*
[STRUCTURE]
[
[DESCRIPTION]
Output plugin structure that is passed into each callback.
[REMARKS]
Members marked with [in] mean the variable can be written to. The user can set the value.<br>
Members marked with [out] mean the variable is modified by FMOD and is for reading purposes only. Do not change this value.<br>
[SEE_ALSO]
FMOD_OUTPUT_DESCRIPTION
]
*/
struct FMOD_OUTPUT_STATE
{
void *plugindata; /* [in] Plugin writer created data the output author wants to attach to this object. */
FMOD_OUTPUT_READFROMMIXER readfrommixer; /* [out] Function to update mixer and write the result to the provided pointer. Used from callback based output only. Polling based output uses lock/unlock/getposition. */
};
#endif
+2
View File
@@ -1,3 +1,5 @@
#!/usr/bin/env bash
# analyze_dex.sh - regenerate DEX-side facts used in analysis/DEX_ANALYSIS.md.
set -euo pipefail
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJ="$(cd "$HERE/../.." && pwd)"
+64
View File
@@ -0,0 +1,64 @@
#!/usr/bin/env bash
# analyze_libg_callgraph.sh - build the FULL call graph of libg.so from its 60 JNI roots using
# radare2 in a SINGLE session (analyzing each root with `af` then `pdf`), then parse the disassembly
# by pdf's "/ <size>: sym.<name>" headers. This is ~1000x faster than reloading the binary per
# function (the whole 60-root sweep runs in ~2s instead of ~80min)
#
# Requires: radare2 + python3. Reads original_reference/native_libs_original/libg.so.
set -euo pipefail
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJ="$(cd "$HERE/../.." && pwd)"
LIB="$PROJ/original_reference/native_libs_original/libg.so"
OUT="$PROJ/analysis/rawdata/libg_callgraph.txt"
command -v r2 >/dev/null || { echo "radare2 not installed (apt install radare2)"; exit 2; }
[ -f "$LIB" ] || { echo "libg.so missing (run extract_apk.sh)"; exit 2; }
python3 - "$LIB" "$OUT" <<'PY'
import subprocess, re, sys
lib, out = sys.argv[1], sys.argv[2]
# JNI root addresses
rab = subprocess.run(["rabin2","-E",lib], capture_output=True, text=True).stdout.splitlines()
roots = {}
for l in rab:
if "Java_com_supercell_titan_" in l:
p = l.split()
roots[p[-1].split("Java_com_supercell_titan_")[-1]] = p[2]
# one r2 session: seek+af+pdf each root
cmds = "".join(f"s {a}; af; pdf;" for a in roots.values())
o = subprocess.run(["r2","-q","-e","scr.color=0","-e","asm.arch=arm","-e","asm.bits=16",
"-c", cmds, lib], capture_output=True, text=True, timeout=600).stdout.splitlines()
hdr = re.compile(r'^/ (\d+): sym\.Java_com_supercell_titan_(\S+?) ')
call = re.compile(r'\b(bl|blx) (sym\.imp\.[A-Za-z0-9_:]+|0x[0-9a-f]+)')
blocks, cur = {}, None
for ln in o:
m = hdr.match(ln)
if m:
cur = {"size": m.group(1), "callees": {}}; blocks[m.group(2)] = cur
elif cur:
cm = call.search(ln)
if cm:
t = cm.group(2); t = t if t.startswith("sym.imp.") else "sub_"+t[2:]
cur["callees"][t] = cur["callees"].get(t,0)+1
# any root whose af merged/anon -> analyze standalone
for name, a in roots.items():
if name in blocks: continue
oo = subprocess.run(["r2","-q","-e","scr.color=0","-e","asm.arch=arm","-e","asm.bits=16",
"-c", f"s {a}; af; afi~size:; pdf", lib], capture_output=True, text=True).stdout.splitlines()
size = next((x.split()[1] for x in oo if x.strip().startswith("size:")), "?")
cs = {}
for l in oo:
cm = call.search(l)
if cm:
t = cm.group(2); t = t if t.startswith("sym.imp.") else "sub_"+t[2:]
cs[t] = cs.get(t,0)+1
blocks[name] = {"size": size, "callees": cs}
L = ["# libg.so call graph from all 60 JNI roots (radare2 single-session af+pdf).",
"# format: <jni_method> @ <addr> size=<bytes> -> callees (sub_<addr> internal, sym.imp.* imports, xN)"]
for name in sorted(blocks):
b = blocks[name]
cs = " ".join(f"{k}(x{v})" for k,v in sorted(b["callees"].items(), key=lambda kv:-kv[1]))
L.append(f"{name:<42} @ {roots.get(name,'?')} size={b['size']}")
L.append(f" -> {cs or '<none>'}")
open(out,"w").write("\n".join(L)+"\n")
print(f"[+] wrote {out} ({len(blocks)}/60 roots)")
PY
+3
View File
@@ -1,3 +1,6 @@
#!/usr/bin/env bash
# analyze_native_libs.sh - regenerate native-side facts for analysis/NATIVE_LIB_*.md.
# Emits ELF headers, NEEDED, JNI exports, import/export counts, and modern-linker checks.
set -euo pipefail
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJ="$(cd "$HERE/../.." && pwd)"
+118
View File
@@ -0,0 +1,118 @@
#!/usr/bin/env bash
# build_apk_manual.sh - build a signed debug APK WITHOUT Gradle/AGP.
#
# This environment blocks dl.google.com, so the Android Gradle Plugin + AndroidX cannot be fetched.
# But the app is intentionally dependency-free, and the local SDK ships the full build toolchain
# (aapt2, d8, zipalign, apksigner + android-34.jar), so we can build a real APK directly:
# aapt2 compile+link (res -> resources.arsc + R.java) -> javac (app + stubs + R) -> d8 (-> dex)
# -> assemble (dex + assets + jniLibs) -> zipalign -> apksigner.
#
# Usage: build_apk_manual.sh <armeabi-v7a|arm64-v8a|universal> (default armeabi-v7a)
set -euo pipefail
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJ="$(cd "$HERE/../.." && pwd)"
ABI="${1:-armeabi-v7a}"
SDK="${ANDROID_SDK_ROOT:-$PROJ/tools/android-sdk}"
BT="$SDK/build-tools/34.0.0"
ANDROID_JAR="$SDK/platforms/android-34/android.jar"
AAPT2="$BT/aapt2"; D8="$BT/d8"; ZIPALIGN="$BT/zipalign"; APKSIGNER="$BT/apksigner"
for t in "$AAPT2" "$D8" "$ZIPALIGN" "$APKSIGNER" "$ANDROID_JAR"; do
[ -e "$t" ] || { echo "ERROR: missing $t (is the SDK at $SDK?)"; exit 2; }
done
case "$ABI" in
32) ABI=armeabi-v7a;; 64) ABI=arm64-v8a;; both|all) ABI=universal;;
armeabi-v7a|arm64-v8a|universal) ;;
*) echo "invalid ABI '$ABI'"; exit 1;;
esac
case "$ABI" in universal) ABIS=(armeabi-v7a arm64-v8a);; *) ABIS=("$ABI");; esac
OUT="$PROJ/out"; W="$PROJ/.build/manual/$ABI"; rm -rf "$W"; mkdir -p "$W" "$OUT"
APPID="com.oldcrcell.clashroyale"
echo "==> Manual build for ABI=$ABI (appId=$APPID)"
# 1) Resources: compile + link (inject the package aapt2 needs; AGP would inject it from 'namespace')
echo "[1/6] aapt2 compile+link resources"
"$AAPT2" compile --dir "$PROJ/app/src/main/res" -o "$W/res.flata"
sed -e "s|<manifest |<manifest package=\"$APPID\" |" "$PROJ/app/src/main/AndroidManifest.xml" > "$W/AndroidManifest.xml"
"$AAPT2" link -o "$W/base.apk" -I "$ANDROID_JAR" \
--manifest "$W/AndroidManifest.xml" --min-sdk-version 21 --target-sdk-version 34 \
--version-code 155 --version-name 1.9.2 \
-R "$W/res.flata" --java "$W/gen" --auto-add-overlay
# 2) Java -> classes
echo "[2/6] javac (app + stubs + generated R)"
mkdir -p "$W/classes"
find "$PROJ/app/src/main/java" "$PROJ/app/src/stubs/java" "$W/gen" -name '*.java' > "$W/srcs.txt"
javac -d "$W/classes" -cp "$ANDROID_JAR" -source 8 -target 8 -encoding UTF-8 \
-nowarn -Xlint:none @"$W/srcs.txt" 2>"$W/javac.log" || { echo "javac FAILED"; cat "$W/javac.log"; exit 1; }
# 3) classes -> dex
# NOTE: the d8 shipped in build-tools 34.0.0 is a broken 8.2.2-dev build that NPEs on every enum
# class (verified). The app + stubs contain enums, so we dex with dex2jar's jar2dex (classic `dx`),
# which handles them. Code is compiled -source/-target 8 (no Java-8+ language features), so `dx` is
# sufficient. Override with DEXER=d8 to use the SDK d8 once a fixed build-tools is available.
echo "[3/6] jar2dex -> classes.dex"
( cd "$W/classes" && jar cf "$W/classes.jar" . )
DEXER="${DEXER:-dx}"
if [ "$DEXER" = d8 ]; then
"$D8" --min-api 21 --lib "$ANDROID_JAR" --output "$W" "$W/classes.jar"
else
D2J="$PROJ/../tools/dex-tools-v2.4/d2j-jar2dex.sh"
[ -x "$D2J" ] || chmod +x "$D2J" 2>/dev/null || true
bash "$D2J" "$W/classes.jar" -o "$W/classes.dex" >/dev/null 2>"$W/dex.log" \
|| { echo "jar2dex FAILED"; tail -20 "$W/dex.log"; exit 1; }
fi
[ -f "$W/classes.dex" ] || { echo "no classes.dex produced"; exit 1; }
# 4) Assemble: start from the linked resources APK, add dex + assets + native libs
echo "[4/6] assemble APK (dex + assets + jniLibs/$ABI)"
cp "$W/base.apk" "$W/unsigned.apk"
( cd "$W" && zip -q "$W/unsigned.apk" classes.dex )
if [ -d "$PROJ/app/src/main/assets" ]; then
( cd "$PROJ/app/src/main" && find assets -type f | zip -q -X "$W/unsigned.apk" -@ )
fi
# Required libs: libfmod + libg. libcr is OPTIONAL (mod loader; loadLibrary("cr") is caught) -
# it is packaged only if present for the ABI.
for abi in "${ABIS[@]}"; do
d="$PROJ/app/src/main/jniLibs/$abi"
[ -d "$d" ] || { echo "ERROR: jniLibs/$abi missing (need the .so for $abi)"; exit 3; }
for req in libfmod.so libg.so; do
[ -f "$d/$req" ] || { echo "ERROR: $abi/$req missing (required)"; exit 3; }
done
for so in "$d"/*.so; do
[ -e "$so" ] || continue
if [ "$abi" = arm64-v8a ] && ! file -b "$so" | grep -qi '64-bit'; then
echo "ERROR: $abi/$(basename "$so") is not ELF64"; exit 3; fi
done
[ -f "$d/libcr.so" ] || echo " (note: $abi has no libcr.so - optional, omitted)"
done
# copy .so into lib/<abi>/ layout inside the apk
mkdir -p "$W/lib"
for abi in "${ABIS[@]}"; do
mkdir -p "$W/lib/$abi"; cp "$PROJ/app/src/main/jniLibs/$abi"/*.so "$W/lib/$abi/"
done
( cd "$W" && find lib -name '*.so' | zip -q -X "$W/unsigned.apk" -@ )
# 5) zipalign
echo "[5/6] zipalign"
"$ZIPALIGN" -f -p 4 "$W/unsigned.apk" "$W/aligned.apk"
# 6) sign (debug keystore, created if absent)
echo "[6/6] apksigner (debug key)"
KS="${DEBUG_KEYSTORE:-$HOME/.android/debug.keystore}"
if [ ! -f "$KS" ]; then
mkdir -p "$(dirname "$KS")"
keytool -genkeypair -v -keystore "$KS" -storepass android -keypass android \
-alias androiddebugkey -keyalg RSA -keysize 2048 -validity 10000 \
-dname "CN=Android Debug,O=Android,C=US" >/dev/null 2>&1
fi
DEST="$OUT/app-${ABI}-debug.apk"
"$APKSIGNER" sign --ks "$KS" --ks-key-alias androiddebugkey \
--ks-pass pass:android --key-pass pass:android \
--v1-signing-enabled true --v2-signing-enabled true --v3-signing-enabled true \
--out "$DEST" "$W/aligned.apk"
"$APKSIGNER" verify --print-certs "$DEST" >/dev/null && echo " signature OK"
echo "==> BUILT $DEST"
ls -la "$DEST" | awk '{print " size:", $5, "bytes"}'
+5 -1
View File
@@ -1,3 +1,7 @@
#!/usr/bin/env bash
# build_native.sh - build reconstructed native libs for a given ABI via NDK + CMake.
# Usage: build_native.sh <armeabi-v7a|arm64-v8a> [Debug|Release]
# Requires: $ANDROID_NDK_HOME (or $NDK), cmake, ninja.
set -euo pipefail
ABI="${1:?usage: build_native.sh <armeabi-v7a|arm64-v8a> [Debug|Release]}"
CFG="${2:-Debug}"
@@ -8,7 +12,7 @@ JNILIBS="$PROJ/app/src/main/jniLibs/$ABI"
NDK="${ANDROID_NDK_HOME:-${NDK:-}}"
[ -n "$NDK" ] && [ -d "$NDK" ] || { echo "ERROR: set ANDROID_NDK_HOME (see tools/scripts/fetch_ndk.sh)"; exit 2; }
[ -f "$NATIVE/CMakeLists.txt" ] || { echo "ERROR: native/CMakeLists.txt missing (Phase 12+ populates it)"; exit 3; }
[ -f "$NATIVE/CMakeLists.txt" ] || { echo "ERROR: native/CMakeLists.txt missing"; exit 3; }
BUILD="$NATIVE/build/$ABI"
mkdir -p "$BUILD" "$JNILIBS"
+87
View File
@@ -0,0 +1,87 @@
#!/usr/bin/env bash
# build_native_direct.sh - build the required native libs for an ABI using the NDK clang DIRECTLY.
#
# We invoke the NDK's clang++ with a target triple instead of the CMake toolchain, because the NDK's
# build/cmake/ integration is not present in this checkout. Produces the three libs the app loads:
# libg.so - reconstructed Titan JNI skeleton (native/src/libg/**) [REAL reconstruction]
# libfmod.so- official arm64 binary if in native/third_party/fmod/<abi>/, else the fmod stub [stub]
# libcr.so - built from native/third_party/libcr/src if present (SONAME libmod.so), else stub [stub]
#
# Usage: build_native_direct.sh <arm64-v8a|armeabi-v7a> [minApi]
# Output: app/src/main/jniLibs/<abi>/ (for armeabi-v7a it will NOT overwrite the seeded ORIGINAL
# libs unless FORCE_V7A=1 - the original 32-bit engine is higher-fidelity than the skeleton).
set -euo pipefail
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJ="$(cd "$HERE/../.." && pwd)"
ABI="${1:?usage: build_native_direct.sh <arm64-v8a|armeabi-v7a> [minApi]}"
MINAPI="${2:-21}"
NDK="${ANDROID_NDK_HOME:-$PROJ/tools/android-sdk/ndk/26.3.11579264}"
TC="$NDK/toolchains/llvm/prebuilt/linux-x86_64"
CLANGXX="$TC/bin/clang++"; NM="$TC/bin/llvm-nm"
[ -x "$CLANGXX" ] || { echo "NDK clang++ not found at $CLANGXX"; exit 2; }
case "$ABI" in
arm64-v8a) TRIPLE="aarch64-linux-android${MINAPI}";;
armeabi-v7a) TRIPLE="armv7a-linux-androideabi${MINAPI}";;
*) echo "unsupported ABI '$ABI'"; exit 1;;
esac
DEST="$PROJ/app/src/main/jniLibs/$ABI"; mkdir -p "$DEST"
B="$PROJ/.build/native/$ABI"; rm -rf "$B"; mkdir -p "$B"
# -static-libstdc++ links libc++ statically so the reconstructed libg.so is SELF-CONTAINED (no
# NEEDED libc++_shared.so). libc++_shared.so is NOT a system library on Android, and we don't bundle
# it - without static libc++ the app would UnsatisfiedLinkError at load. The original engine linked
# the on-device system libstdc++.so; static libc++ is the modern, bundle-free equivalent.
CXXFLAGS=(--target="$TRIPLE" -fPIC -shared -std=c++17 -O2 -fexceptions -frtti -static-libstdc++
-I "$PROJ/native/include" -I "$PROJ/native/third_party/fmod/include")
echo "==> Native build $ABI ($TRIPLE), NDK r26d clang"
# --- libg: the reconstructed engine JNI skeleton (always rebuilt) ---
# The FMOD 1.05.11 headers are on the include path so the reconstructed audio subsystem compiles.
# We link the real libfmod.so ONLY once libg actually references FMOD (matching the original's
# NEEDED libfmod.so). NOTE: the old FMOD .so has a legacy symbol table modern lld rejects for direct
# linking, so when FMOD calls appear we link via a clean import stub (native/third_party/fmod/import)
# generated by gen_fmod_import.sh; at runtime the real libfmod.so resolves them.
mapfile -t LIBG_SRC < <(find "$PROJ/native/src/libg" -name '*.cpp')
FMOD_LINK=()
if grep -rqlE '\bFMOD_|FMOD::' "$PROJ/native/src/libg" 2>/dev/null; then
IMPORT="$PROJ/native/third_party/fmod/import/$ABI/libfmod.so"
# auto-generate the link-clean FMOD import stub if missing (and the real lib is present)
if [ ! -f "$IMPORT" ] && [ -f "$PROJ/native/third_party/fmod/$ABI/libfmod.so" ]; then
ANDROID_NDK_HOME="$NDK" bash "$HERE/gen_fmod_import.sh" "$ABI" >/dev/null 2>&1 || true
fi
if [ -f "$IMPORT" ]; then FMOD_LINK=(-L "$PROJ/native/third_party/fmod/import/$ABI" -lfmod); \
else echo " (WARN: libg references FMOD but no import stub could be generated)"; fi
fi
"$CLANGXX" "${CXXFLAGS[@]}" "${LIBG_SRC[@]}" "${FMOD_LINK[@]}" -llog -landroid -o "$B/libg.so"
echo " libg.so : $("$NM" -D --defined-only "$B/libg.so" | grep -cE 'Java_com_supercell|JNI_OnLoad') JNI exports"
# --- libfmod: official binary if present, else stub ---
if [ -f "$PROJ/native/third_party/fmod/$ABI/libfmod.so" ]; then
cp "$PROJ/native/third_party/fmod/$ABI/libfmod.so" "$B/libfmod.so"; echo " libfmod.so: official arm64 binary"
else
"$CLANGXX" "${CXXFLAGS[@]}" -Wl,-soname,libfmod.so \
"$PROJ/native/compatibility/fmod_shim/fmod_stub.cpp" -llog -o "$B/libfmod.so"; echo " libfmod.so: STUB (audio disabled)"
fi
# --- libcr: OPTIONAL. Built ONLY if the OWNED source is present (SONAME libmod.so like the original).
# If no source is provided, libcr is simply omitted - the app's System.loadLibrary("cr") is wrapped in
# catch(UnsatisfiedLinkError), so a missing libcr is tolerated (mod features just absent). ---
mapfile -t LIBCR_SRC < <(find "$PROJ/native/third_party/libcr/src" \( -name '*.c' -o -name '*.cpp' \) 2>/dev/null || true)
if [ "${#LIBCR_SRC[@]}" -gt 0 ]; then
"$CLANGXX" "${CXXFLAGS[@]}" -Wl,-soname,libmod.so -I "$PROJ/native/third_party/libcr/include" \
"${LIBCR_SRC[@]}" -llog -lz -landroid -o "$B/libcr.so"; echo " libcr.so : built from OWNED source"
else
echo " libcr.so : (omitted - no source in native/third_party/libcr/src; loadLibrary(\"cr\") is optional)"
fi
# --- publish to jniLibs ---
if [ "$ABI" = armeabi-v7a ] && [ -f "$DEST/libg.so" ] && [ "${FORCE_V7A:-0}" != 1 ]; then
echo " (armeabi-v7a: keeping seeded ORIGINAL libs in jniLibs; set FORCE_V7A=1 to overwrite with reconstruction)"
else
# We fully own this ABI dir - clear the libs we manage so a now-omitted optional lib (e.g. libcr
# when no source is present) does not linger from a previous run.
rm -f "$DEST/libg.so" "$DEST/libfmod.so" "$DEST/libcr.so"
cp "$B"/*.so "$DEST/"
echo " -> published to jniLibs/$ABI/:"; for f in "$DEST"/*.so; do echo " $(basename "$f") [$(file -b "$f" | cut -d, -f1-2)]"; done
fi
+4 -1
View File
@@ -1,10 +1,13 @@
#!/usr/bin/env bash
# build_project.sh - build the Gradle app for a normalized ABI. Called by ../../build.sh.
# Usage: build_project.sh <armeabi-v7a|arm64-v8a|universal>
set -euo pipefail
ABI="${1:?usage: build_project.sh <armeabi-v7a|arm64-v8a|universal>}"
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJ="$(cd "$HERE/../.." && pwd)"
if [ ! -f "$PROJ/settings.gradle" ] && [ ! -f "$PROJ/settings.gradle.kts" ]; then
echo "ERROR: Gradle project not populated yet (Phase 1). Nothing to build."; exit 4
echo "ERROR: Gradle project not populated yet. Nothing to build."; exit 4
fi
GRADLE="$PROJ/gradlew"; [ -x "$GRADLE" ] || GRADLE="$(command -v gradle || true)"
[ -n "$GRADLE" ] || { echo "ERROR: gradle/gradlew not found"; exit 5; }
+7 -2
View File
@@ -1,8 +1,12 @@
#!/usr/bin/env bash
# extract_apk.sh - reproduce all original_reference/ extracts from the source APK.
# Usage: tools/scripts/extract_apk.sh [path/to/app.apk]
# Regenerates: raw_apk_extract/, apktool_output/, jadx_output/, dex_raw/, native_libs_original/
set -euo pipefail
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJ="$(cd "$HERE/../.." && pwd)"
ROOT="$(cd "$PROJ/.." && pwd)"
PROJ="$(cd "$HERE/../.." && pwd)" # reconstructed_android_project/
ROOT="$(cd "$PROJ/.." && pwd)" # repo root (holds the source APK + tools/)
TOOLS="$ROOT/tools"
REF="$PROJ/original_reference"
@@ -12,6 +16,7 @@ APK="${1:-$ROOT/ClassicRoyale-1.7_1.apk}"
echo "[*] Source APK: $APK"
mkdir -p "$REF"/{raw_apk_extract,apktool_output,jadx_output,dex_raw,native_libs_original}
# Preserve pristine copy
cp -f "$APK" "$REF/original.apk"
echo "[*] Raw unzip ..."
+10
View File
@@ -1,3 +1,12 @@
#!/usr/bin/env bash
# fetch_fmod.sh - stage the official FMOD Android SDK (user-licensed) for arm64 replacement.
#
# FMOD is proprietary and REQUIRES a (free) fmod.com developer account; its download links are
# account-gated, so this script cannot silently pull it. Provide one of:
# FMOD_ZIP=/path/to/fmodstudioapi<version>android.tar.gz ./fetch_fmod.sh
# or drop the extracted 'api/core/lib/arm64-v8a/libfmod.so' into native/third_party/fmod/ yourself.
#
# We deliberately do NOT fetch FMOD from unofficial mirrors (license + integrity).
set -euo pipefail
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJ="$(cd "$HERE/../.." && pwd)"
@@ -9,6 +18,7 @@ if [ -z "${FMOD_ZIP:-}" ]; then
[!] No FMOD_ZIP provided.
1) Create a free account at https://www.fmod.com and download "FMOD Engine" for Android.
2) Re-run: FMOD_ZIP=/path/to/fmodstudioapiXXXandroid.tar.gz $0
Fallback: build native/compatibility/fmod_shim (open backend) - see SHARED_LIBRARY_PORTING_PLAN.md.
EOF
exit 2
fi
+3
View File
@@ -1,3 +1,6 @@
#!/usr/bin/env bash
# fetch_ndk.sh - install the Android NDK via sdkmanager (OFFICIAL Google source).
# Prints the ANDROID_NDK_HOME to export.
set -euo pipefail
SDK_ROOT="${ANDROID_SDK_ROOT:-${ANDROID_HOME:-$HOME/android-sdk}}"
NDK_PKG="${NDK_PKG:-ndk;26.3.11579264}" # r26d: clang + libc++, matches libg's STL family
+105
View File
@@ -0,0 +1,105 @@
#!/usr/bin/env bash
# fetch_ndk_portable.sh - portable Android NDK/CMake using portable SDK + Java.
# Installs into the parent folder of this script by default:
# ../android-sdk
# ../java
# No global packages are installed and no shell profile is modified.
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PORTABLE_ROOT="$(cd "${PORTABLE_ROOT:-$SCRIPT_DIR/..}" && pwd)"
SDK_ROOT="${ANDROID_SDK_ROOT:-${ANDROID_HOME:-$PORTABLE_ROOT/android-sdk}}"
JAVA_ROOT="${JAVA_HOME:-$PORTABLE_ROOT/java}"
NDK_PKG="${NDK_PKG:-ndk;26.3.11579264}" # r26d: clang + libc++
CMAKE_PKG="${CMAKE_PKG:-cmake;3.22.1}"
# Android sdkmanager currently works well with JDK 17. Override if needed:
# JDK_MAJOR=21 ./fetch_ndk_portable.sh
JDK_MAJOR="${JDK_MAJOR:-17}"
JDK_API_URL="${JDK_API_URL:-https://api.adoptium.net/v3/binary/latest/${JDK_MAJOR}/ga/linux/x64/jdk/hotspot/normal/eclipse?project=jdk}"
need_cmd() {
command -v "$1" >/dev/null 2>&1 || {
echo "[!] Missing required command: $1" >&2
echo " Install it once with your OS package manager, then rerun this script." >&2
exit 1
}
}
fetch_java() {
if [ -x "$JAVA_ROOT/bin/java" ]; then
echo "[*] Portable Java already exists: $JAVA_ROOT"
return
fi
need_cmd curl
need_cmd tar
echo "[*] Downloading portable Eclipse Temurin JDK $JDK_MAJOR ..."
tmp="$(mktemp -d)"
curl -fL "$JDK_API_URL" -o "$tmp/jdk.tar.gz"
rm -rf "$JAVA_ROOT"
mkdir -p "$JAVA_ROOT"
tar -xzf "$tmp/jdk.tar.gz" -C "$tmp"
jdk_dir="$(find "$tmp" -maxdepth 1 -type d -name 'jdk*' | head -n 1)"
if [ -z "$jdk_dir" ]; then
echo "[!] Could not find extracted JDK directory." >&2
exit 1
fi
shopt -s dotglob
mv "$jdk_dir"/* "$JAVA_ROOT"/
shopt -u dotglob
rm -rf "$tmp"
}
fetch_sdk_if_needed() {
if [ -x "$SDK_ROOT/cmdline-tools/latest/bin/sdkmanager" ]; then
return
fi
if [ -x "$SCRIPT_DIR/fetch_sdk_portable.sh" ]; then
echo "[*] SDK manager not found; running fetch_sdk_portable.sh first ..."
PORTABLE_ROOT="$PORTABLE_ROOT" \
ANDROID_SDK_ROOT="$SDK_ROOT" \
JAVA_HOME="$JAVA_ROOT" \
"$SCRIPT_DIR/fetch_sdk_portable.sh"
elif [ -x "$SCRIPT_DIR/fetch_sdk.sh" ]; then
echo "[*] SDK manager not found; running fetch_sdk.sh first ..."
PORTABLE_ROOT="$PORTABLE_ROOT" \
ANDROID_SDK_ROOT="$SDK_ROOT" \
JAVA_HOME="$JAVA_ROOT" \
"$SCRIPT_DIR/fetch_sdk.sh"
else
echo "[!] sdkmanager not found at: $SDK_ROOT/cmdline-tools/latest/bin/sdkmanager" >&2
echo " Put fetch_sdk_portable.sh next to this script and run again." >&2
exit 1
fi
}
fetch_java
export JAVA_HOME="$JAVA_ROOT"
export PATH="$JAVA_HOME/bin:$PATH"
fetch_sdk_if_needed
SDKM="$SDK_ROOT/cmdline-tools/latest/bin/sdkmanager"
"$SDKM" --sdk_root="$SDK_ROOT" "$NDK_PKG" "$CMAKE_PKG"
NDK_DIR="$SDK_ROOT/ndk/${NDK_PKG#ndk;}"
CMAKE_DIR="$SDK_ROOT/${CMAKE_PKG/;//}"
cat <<OUT
[+] Portable Android NDK ready at: $NDK_DIR
[+] Portable CMake ready at: $CMAKE_DIR
[+] Portable Java ready at: $JAVA_ROOT
Use this in your current shell:
export JAVA_HOME="$JAVA_ROOT"
export ANDROID_SDK_ROOT="$SDK_ROOT"
export ANDROID_HOME="$SDK_ROOT"
export ANDROID_NDK_HOME="$NDK_DIR"
export PATH="\$JAVA_HOME/bin:\$ANDROID_SDK_ROOT/platform-tools:$CMAKE_DIR/bin:\$PATH"
OUT
+4
View File
@@ -1,3 +1,7 @@
#!/usr/bin/env bash
# fetch_sdk.sh - install Android SDK cmdline-tools + platform + build-tools from OFFICIAL Google source.
# Idempotent. Sets nothing permanent; prints the env vars to export.
# Only dl.google.com is used. Do NOT point this at third-party mirrors.
set -euo pipefail
SDK_ROOT="${ANDROID_SDK_ROOT:-${ANDROID_HOME:-$HOME/android-sdk}}"
PLATFORM="${ANDROID_PLATFORM_PKG:-platforms;android-34}"
+98
View File
@@ -0,0 +1,98 @@
#!/usr/bin/env bash
# fetch_sdk_portable.sh - portable Android SDK + portable Java.
# Installs into the parent folder of this script by default:
# ../android-sdk
# ../java
# No global packages are installed and no shell profile is modified.
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PORTABLE_ROOT="$(cd "${PORTABLE_ROOT:-$SCRIPT_DIR/..}" && pwd)"
SDK_ROOT="${ANDROID_SDK_ROOT:-${ANDROID_HOME:-$PORTABLE_ROOT/android-sdk}}"
JAVA_ROOT="${JAVA_HOME:-$PORTABLE_ROOT/java}"
PLATFORM="${ANDROID_PLATFORM_PKG:-platforms;android-34}"
BUILDTOOLS="${ANDROID_BUILDTOOLS_PKG:-build-tools;34.0.0}"
CLT_URL="${CLT_URL:-https://dl.google.com/android/repository/commandlinetools-linux-11076708_latest.zip}"
# Android sdkmanager currently works well with JDK 17. Override if needed:
# JDK_MAJOR=21 ./fetch_sdk_portable.sh
JDK_MAJOR="${JDK_MAJOR:-17}"
JDK_API_URL="${JDK_API_URL:-https://api.adoptium.net/v3/binary/latest/${JDK_MAJOR}/ga/linux/x64/jdk/hotspot/normal/eclipse?project=jdk}"
need_cmd() {
command -v "$1" >/dev/null 2>&1 || {
echo "[!] Missing required command: $1" >&2
echo " Install it once with your OS package manager, then rerun this script." >&2
exit 1
}
}
fetch_java() {
if [ -x "$JAVA_ROOT/bin/java" ]; then
echo "[*] Portable Java already exists: $JAVA_ROOT"
return
fi
need_cmd curl
need_cmd tar
echo "[*] Downloading portable Eclipse Temurin JDK $JDK_MAJOR ..."
tmp="$(mktemp -d)"
curl -fL "$JDK_API_URL" -o "$tmp/jdk.tar.gz"
rm -rf "$JAVA_ROOT"
mkdir -p "$JAVA_ROOT"
tar -xzf "$tmp/jdk.tar.gz" -C "$tmp"
jdk_dir="$(find "$tmp" -maxdepth 1 -type d -name 'jdk*' | head -n 1)"
if [ -z "$jdk_dir" ]; then
echo "[!] Could not find extracted JDK directory." >&2
exit 1
fi
shopt -s dotglob
mv "$jdk_dir"/* "$JAVA_ROOT"/
shopt -u dotglob
rm -rf "$tmp"
}
fetch_cmdline_tools() {
need_cmd curl
need_cmd unzip
mkdir -p "$SDK_ROOT/cmdline-tools"
if [ ! -x "$SDK_ROOT/cmdline-tools/latest/bin/sdkmanager" ]; then
echo "[*] Downloading Android command-line tools (official Google source) ..."
tmp="$(mktemp -d)"
curl -fL "$CLT_URL" -o "$tmp/clt.zip"
unzip -q "$tmp/clt.zip" -d "$tmp"
rm -rf "$SDK_ROOT/cmdline-tools/latest"
mkdir -p "$SDK_ROOT/cmdline-tools/latest"
mv "$tmp/cmdline-tools/"* "$SDK_ROOT/cmdline-tools/latest/"
rm -rf "$tmp"
fi
}
fetch_java
export JAVA_HOME="$JAVA_ROOT"
export PATH="$JAVA_HOME/bin:$PATH"
fetch_cmdline_tools
SDKM="$SDK_ROOT/cmdline-tools/latest/bin/sdkmanager"
yes | "$SDKM" --sdk_root="$SDK_ROOT" --licenses >/dev/null || true
"$SDKM" --sdk_root="$SDK_ROOT" "platform-tools" "$PLATFORM" "$BUILDTOOLS"
BUILD_TOOLS_DIR="$SDK_ROOT/${BUILDTOOLS/;//}"
cat <<OUT
[+] Portable Android SDK ready at: $SDK_ROOT
[+] Portable Java ready at: $JAVA_ROOT
Use this in your current shell:
export JAVA_HOME="$JAVA_ROOT"
export ANDROID_SDK_ROOT="$SDK_ROOT"
export ANDROID_HOME="$SDK_ROOT"
export PATH="\$JAVA_HOME/bin:\$ANDROID_SDK_ROOT/platform-tools:$BUILD_TOOLS_DIR:\$PATH"
OUT
+39
View File
@@ -0,0 +1,39 @@
#!/usr/bin/env bash
# gen_fmod_import.sh - build a LINK-CLEAN FMOD import stub for a given ABI.
#
# The FMOD 1.05.11 prebuilt libfmod.so has a legacy .dynsym (linker markers _bss_start/_edata/_end/...
# placed in the global section out of order) that modern lld refuses to link against directly. Rather
# than patch it, we synthesize a fresh stub .so that EXPORTS the same symbols with a clean table and
# the same SONAME (libfmod.so). The reconstructed libg links against this stub; at RUNTIME the real
# libfmod.so (shipped in the APK) resolves the calls. The stub is never shipped.
#
# Usage: gen_fmod_import.sh <arm64-v8a|armeabi-v7a>
set -euo pipefail
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJ="$(cd "$HERE/../.." && pwd)"
ABI="${1:?usage: gen_fmod_import.sh <arm64-v8a|armeabi-v7a>}"
NDK="${ANDROID_NDK_HOME:-$PROJ/tools/android-sdk/ndk/26.3.11579264}"
TC="$NDK/toolchains/llvm/prebuilt/linux-x86_64"
NM="$TC/bin/llvm-nm"; CC="$TC/bin/clang"
case "$ABI" in arm64-v8a) TRIPLE=aarch64-linux-android21;; armeabi-v7a) TRIPLE=armv7a-linux-androideabi21;; *) echo "bad ABI"; exit 1;; esac
SRC="$PROJ/native/third_party/fmod/$ABI/libfmod.so"
OUT="$PROJ/native/third_party/fmod/import/$ABI"; mkdir -p "$OUT"
[ -f "$SRC" ] || { echo "FMOD lib missing: $SRC"; exit 2; }
ASM="$(mktemp --suffix=.s)"; trap 'rm -f "$ASM"' EXIT
{
echo "// auto-generated FMOD import stub for $ABI - link-only, never shipped"
echo ".text"
# exported code symbols (T) -> global labels in .text
"$NM" -D --defined-only "$SRC" | awk '$2=="T"{print $3}' | while read -r s; do
printf '.globl %s\n.type %s,%%function\n%s:\n' "$s" "$s" "$s"
done
echo ".bss"
# exported data symbols (B/D/R) -> global labels in .bss (skip the legacy linker markers)
"$NM" -D --defined-only "$SRC" | awk '($2=="B"||$2=="D"||$2=="R"){print $3}' \
| grep -vE '^(_bss_end__|__bss_start|__bss_start__|__bss_end__|_edata|_end|__end__|_start|__start)$' \
| while read -r s; do printf '.globl %s\n%s: .zero 8\n' "$s" "$s"; done
} > "$ASM"
"$CC" --target="$TRIPLE" -nostdlib -shared -Wl,-soname,libfmod.so -o "$OUT/libfmod.so" "$ASM"
echo "[+] import stub: $OUT/libfmod.so ($("$NM" -D --defined-only "$OUT/libfmod.so" | grep -c FMOD) FMOD symbols; SONAME libfmod.so)"
+3
View File
@@ -1,3 +1,6 @@
#!/usr/bin/env bash
# package_apk.sh - locate the AGP-produced APK for an ABI and stage it into out/.
# Usage: package_apk.sh <armeabi-v7a|arm64-v8a|universal>
set -euo pipefail
ABI="${1:?usage: package_apk.sh <abi>}"
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
+5
View File
@@ -1,8 +1,13 @@
#!/usr/bin/env bash
# sign_apk.sh - zipalign + apksigner (v1+v2+v3) with a debug key (or user key via env).
# Usage: sign_apk.sh <path/to/app.apk>
# Env (optional): KEYSTORE, KEY_ALIAS, KS_PASS, KEY_PASS (else a debug keystore is created).
set -euo pipefail
APK="${1:?usage: sign_apk.sh <app.apk>}"
[ -f "$APK" ] || { echo "APK not found: $APK"; exit 1; }
need() { command -v "$1" >/dev/null 2>&1 || { echo "ERROR: '$1' not found (install Android build-tools; see analysis/TOOLCHAIN.md)"; exit 7; }; }
# build-tools binaries are versioned; allow override via ZIPALIGN/APKSIGNER env
ZIPALIGN="${ZIPALIGN:-$(command -v zipalign || true)}"
APKSIGNER="${APKSIGNER:-$(command -v apksigner || true)}"
[ -n "$ZIPALIGN" ] || { echo "ERROR: zipalign not found (Android build-tools)"; exit 7; }
+19
View File
@@ -0,0 +1,19 @@
#!/usr/bin/env bash
# sync_assets.sh - populate app/src/main/assets/ with the FULL game asset set from the source APK.
# The large binary asset dirs are gitignored (LFS upload blocked / git-blob bloat), so a fresh
# clone must run this before building. Small text tables are already committed.
# Usage: tools/scripts/sync_assets.sh [path/to/app.apk]
set -euo pipefail
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJ="$(cd "$HERE/../.." && pwd)"
ROOT="$(cd "$PROJ/.." && pwd)"
APK="${1:-$ROOT/ClassicRoyale-1.7_1.apk}"
DEST="$PROJ/app/src/main/assets"
[ -f "$APK" ] || { echo "Source APK not found: $APK (run 'git lfs pull')"; exit 1; }
mkdir -p "$DEST"
echo "[*] Extracting assets/* from $APK -> $DEST"
tmp="$(mktemp -d)"; trap 'rm -rf "$tmp"' EXIT
unzip -qo "$APK" 'assets/*' -d "$tmp"
cp -a "$tmp/assets/." "$DEST/"
echo "[+] Assets synced: $(find "$DEST" -type f | wc -l) files, $(du -sh "$DEST" | cut -f1)"
+24
View File
@@ -0,0 +1,24 @@
#!/usr/bin/env bash
# test_reconstruction.sh - build & run the host behavioral tests for the reconstructed native code.
# Compiles the arch-independent reconstruction sources (String, FileHandle) + the test harness for
# the host and runs them, validating function-matching behaviour (not just compilation).
set -euo pipefail
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJ="$(cd "$HERE/../.." && pwd)"
CXX="${CXX:-g++}"
OUT="$(mktemp -d)"; trap 'rm -rf "$OUT"' EXIT
# The sources under test (arch-independent; no JNI/NDK needed for these units).
SRCS=(
"$PROJ/native/src/libg/engine/titan_string.cpp"
"$PROJ/native/src/libg/engine/sub_1fe_cluster.cpp"
"$PROJ/native/src/libg/io/file_handle.cpp"
"$PROJ/native/test/test_reconstruction.cpp"
)
echo "[*] Building host behavioral tests with $CXX"
"$CXX" -std=c++17 -O0 -g -Wall -Wextra -fsanitize=address,undefined \
-I"$PROJ/native/include" -I"$PROJ/native/third_party/fmod/include" \
"${SRCS[@]}" -o "$OUT/test_reconstruction"
echo "[+] BUILD OK -> running (with ASan+UBSan):"
echo
"$OUT/test_reconstruction"
+34 -4
View File
@@ -1,13 +1,20 @@
#!/usr/bin/env bash
# verify_apk.sh - structural validation of a built APK.
# Checks: zip integrity, dex present, manifest present, per-ABI native libs are the RIGHT ELF class,
# and (for arm64) that ALL required libs (libfmod, libg, libcr) exist as ELF64 AArch64.
# Usage: verify_apk.sh <app.apk> [expected-abi]
set -euo pipefail
APK="${1:?usage: verify_apk.sh <app.apk> [armeabi-v7a|arm64-v8a|universal]}"
EXPECT="${2:-}"
[ -f "$APK" ] || { echo "APK not found: $APK"; exit 1; }
REQUIRED_LIBS=(libfmod.so libg.so libcr.so)
REQUIRED_LIBS=(libfmod.so libg.so) # libcr is OPTIONAL (owned mod; loadLibrary("cr") is caught)
fail=0
echo "[*] Zip integrity"; unzip -tq "$APK" >/dev/null && echo " ok" || { echo " CORRUPT"; fail=1; }
echo "[*] classes.dex present"; unzip -l "$APK" | grep -q 'classes.*\.dex' && echo " ok" || { echo " MISSING dex"; fail=1; }
echo "[*] AndroidManifest present"; unzip -l "$APK" | grep -q 'AndroidManifest.xml' && echo " ok" || { echo " MISSING manifest"; fail=1; }
# Cache the entry listing once (piping a large `unzip -l` into `grep -q` trips SIGPIPE under pipefail).
ENTRIES="$(unzip -Z1 "$APK" 2>/dev/null || true)"
echo "[*] classes.dex present"; printf '%s\n' "$ENTRIES" | grep -q '^classes.*\.dex$' && echo " ok" || { echo " MISSING dex"; fail=1; }
echo "[*] AndroidManifest present"; printf '%s\n' "$ENTRIES" | grep -q '^AndroidManifest.xml$' && echo " ok" || { echo " MISSING manifest"; fail=1; }
echo "[*] Native libs / ABI check"
TMP="$(mktemp -d)"; trap 'rm -rf "$TMP"' EXIT
@@ -18,7 +25,7 @@ for abi in "${ABIS[@]}"; do
echo " ABI $abi:"
case "$abi" in
armeabi-v7a) want="ELF 32-bit.*ARM";;
arm64-v8a) want="ELF 64-bit.*aarch64\|ELF 64-bit.*AArch64\|ELF 64-bit.*ARM aarch64";;
arm64-v8a) want="ELF 64-bit.*aarch64";; # grep -i also matches "AArch64"
*) want=".";;
esac
for f in "$TMP/lib/$abi"/*.so; do
@@ -27,11 +34,34 @@ for abi in "${ABIS[@]}"; do
if echo "$desc" | grep -qiE "$want"; then echo " ok $(basename "$f") [$desc]"
else echo " BAD $(basename "$f") expected /$want/ got: $desc"; fail=1; fi
done
# arm64 completeness gate
if [ "$abi" = "arm64-v8a" ]; then
for req in "${REQUIRED_LIBS[@]}"; do
[ -e "$TMP/lib/$abi/$req" ] || { echo " MISSING required arm64 lib: $req (arm64 INCOMPLETE)"; fail=1; }
done
fi
# Dependency-resolution gate: every NEEDED lib of every bundled .so must be either bundled in the
# APK or a public Android system library. Catches the classic "NEEDED libc++_shared.so but not
# bundled" load failure (libc++_shared is NOT a system lib) before it reaches a device.
READELF="$(command -v llvm-readelf || command -v readelf || true)"
[ -n "$READELF" ] || READELF="$(ls "$PWD"/tools/android-sdk/ndk/*/toolchains/llvm/prebuilt/*/bin/llvm-readelf 2>/dev/null | head -1)"
if [ -n "$READELF" ]; then
# Public system libs available to apps on modern Android (NDK-accessible + legacy libstdc++).
SYSLIBS=" libc.so libm.so libdl.so liblog.so libandroid.so libGLESv1_CM.so libGLESv2.so libGLESv3.so libEGL.so libz.so libjnigraphics.so libOpenSLES.so libOpenMAXAL.so libvulkan.so libstdc++.so libmediandk.so libnativewindow.so libcamera2ndk.so "
BUNDLED=" $(ls "$TMP/lib/$abi"/*.so 2>/dev/null | xargs -n1 basename 2>/dev/null | tr '\n' ' ') "
for f in "$TMP/lib/$abi"/*.so; do
[ -e "$f" ] || continue
while read -r dep; do
[ -n "$dep" ] || continue
if [[ "$BUNDLED" == *" $dep "* ]] || [[ "$SYSLIBS" == *" $dep "* ]]; then :; \
else echo " UNRESOLVED dep: $(basename "$f") needs [$dep] (not bundled, not a system lib)"; fail=1; fi
done < <("$READELF" -d "$f" 2>/dev/null | grep NEEDED | grep -oE '\[[^]]+\]' | tr -d '[]')
done
echo " dep-resolution ok for $abi"
else
echo " (readelf unavailable - skipped dependency-resolution gate)"
fi
done
[ -z "$EXPECT" ] || { [ -d "$TMP/lib/$EXPECT" ] || [ "$EXPECT" = universal ] || { echo "[!] expected ABI '$EXPECT' not in APK"; fail=1; }; }
+39
View File
@@ -0,0 +1,39 @@
#!/usr/bin/env bash
# verify_java_offline.sh - compile the reconstructed Java layer WITHOUT Gradle/AGP, for environments
# where dl.google.com (AGP/AndroidX) is unreachable. Uses the apt Android SDK:
# aapt2 (generate R) + javac against android.jar. Proves the Java sources + SDK stubs compile and
# that the resource set links. It does NOT dex/package (that is the Gradle build's job).
#
# Requires: android-sdk-build-tools + android-sdk-platform-23 (apt), a JDK.
set -euo pipefail
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJ="$(cd "$HERE/../.." && pwd)"
AAPT2="${AAPT2:-/usr/lib/android-sdk/build-tools/debian/aapt2}"
ANDROID_JAR="${ANDROID_JAR:-/usr/lib/android-sdk/platforms/android-23/android.jar}"
[ -x "$AAPT2" ] || { echo "aapt2 not found (apt install android-sdk-build-tools)"; exit 2; }
[ -f "$ANDROID_JAR" ] || { echo "android.jar not found (apt install android-sdk-platform-23)"; exit 2; }
WORK="$(mktemp -d)"; trap 'rm -rf "$WORK"' EXIT
echo "[*] aapt2 compile+link resources -> R.java"
"$AAPT2" compile --dir "$PROJ/app/src/main/res" -o "$WORK/res.flata" >/dev/null
# AGP injects the package from the manifest 'namespace'; standalone aapt2 needs it present, and
# android-23 lacks the API-24 attr resizeableActivity, so strip it for this offline check only.
sed -e 's|<manifest |<manifest package="com.oldcrcell.clashroyale" |' \
-e '/android:resizeableActivity="false"/d' \
"$PROJ/app/src/main/AndroidManifest.xml" > "$WORK/AM.xml"
"$AAPT2" link -o "$WORK/base.apk" -I "$ANDROID_JAR" --manifest "$WORK/AM.xml" \
--min-sdk-version 21 --target-sdk-version 23 -R "$WORK/res.flata" \
--java "$WORK/gen" --auto-add-overlay >/dev/null
echo " R.java: $(find "$WORK/gen" -name R.java)"
echo "[*] javac (app sources + SDK stubs + generated R) against android-23"
find "$PROJ/app/src/main/java" "$PROJ/app/src/stubs/java" "$WORK/gen" -name '*.java' > "$WORK/srcs.txt"
mkdir -p "$WORK/out"
if javac -d "$WORK/out" -cp "$ANDROID_JAR" -encoding UTF-8 @"$WORK/srcs.txt" 2>"$WORK/err.txt"; then
echo "[+] JAVA COMPILE OK - $(find "$WORK/out" -name '*.class' | wc -l) classes"
echo " app sources: $(find "$PROJ/app/src/main/java" -name '*.java' | wc -l), stubs: $(find "$PROJ/app/src/stubs/java" -name '*.java' | wc -l)"
echo " native methods (titan): $(grep -rhE 'native +[A-Za-z].*\(.*\) *;' "$PROJ/app/src/main/java/com/supercell/titan/"*.java | wc -l) (expected 60)"
else
echo "[x] JAVA COMPILE FAILED:"; grep 'error:' "$WORK/err.txt" | head -30; exit 1
fi
+23
View File
@@ -0,0 +1,23 @@
#!/usr/bin/env bash
# verify_native_host.sh - host-compile the reconstructed native skeleton WITHOUT the Android NDK.
# Compiles native/src/libg/** into a host shared object using the JDK's jni.h, purely to syntax/
# type-check the JNI boundary + engine interface in an environment where the NDK is unavailable.
# It does NOT produce an Android .so.
set -euo pipefail
HERE="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
PROJ="$(cd "$HERE/../.." && pwd)"
JH="${JAVA_HOME:-$(dirname "$(dirname "$(readlink -f "$(command -v javac)")")")}"
[ -f "$JH/include/jni.h" ] || { echo "jni.h not found under JAVA_HOME=$JH"; exit 2; }
CXX="${CXX:-g++}"
OUT="$(mktemp -d)"; trap 'rm -rf "$OUT"' EXIT
mapfile -t SRCS < <(find "$PROJ/native/src/libg" -name '*.cpp')
echo "[*] Host-compiling ${#SRCS[@]} native source(s) with $CXX (jni.h from $JH)"
"$CXX" -std=c++17 -fPIC -shared -O0 -Wall -Wextra \
-I"$PROJ/native/include" -I"$PROJ/native/third_party/fmod/include" -I"$JH/include" -I"$JH/include/linux" \
"${SRCS[@]}" -o "$OUT/libg_host.so"
echo "[+] NATIVE HOST COMPILE OK -> libg_host.so"
echo " JNI exports present:"
nm -D --defined-only "$OUT/libg_host.so" 2>/dev/null | grep -cE "Java_com_supercell_titan_|JNI_OnLoad" \
| sed 's/^/ Java_com_supercell_titan_* + JNI_OnLoad = /'
echo " (expected 61: 60 JNI methods + JNI_OnLoad)"