2022-10-09 05:13:17 +00:00
|
|
|
#ifndef _MUSYX_MUSYX
|
|
|
|
#define _MUSYX_MUSYX
|
2022-04-08 08:30:31 +00:00
|
|
|
|
2023-11-30 06:50:02 +00:00
|
|
|
#include "musyx/platform.h"
|
2023-12-19 02:28:24 +00:00
|
|
|
#include "musyx/version.h"
|
2023-02-27 14:14:29 +00:00
|
|
|
|
2023-02-25 02:11:03 +00:00
|
|
|
#include <math.h>
|
2023-12-19 02:28:24 +00:00
|
|
|
#include <stddef.h>
|
2023-02-25 02:11:03 +00:00
|
|
|
|
2022-08-05 19:46:33 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
extern "C" {
|
|
|
|
#endif
|
|
|
|
|
2023-12-19 02:28:24 +00:00
|
|
|
#if MUSY_TARGET == MUSY_TARGET_DOLPHIN
|
2022-08-05 19:43:46 +00:00
|
|
|
typedef signed char s8;
|
|
|
|
typedef unsigned char u8;
|
|
|
|
typedef signed short s16;
|
|
|
|
typedef unsigned short u16;
|
|
|
|
typedef signed long s32;
|
|
|
|
typedef unsigned long u32;
|
2023-02-19 04:27:24 +00:00
|
|
|
typedef unsigned long long u64;
|
2022-08-05 19:43:46 +00:00
|
|
|
typedef float f32;
|
|
|
|
typedef double f64;
|
2023-12-19 02:28:24 +00:00
|
|
|
#elif MUSY_TARGET == MUSY_TARGET_PC
|
|
|
|
typedef signed char s8;
|
|
|
|
typedef unsigned char u8;
|
|
|
|
typedef signed short s16;
|
|
|
|
typedef unsigned short u16;
|
|
|
|
typedef signed int s32;
|
|
|
|
typedef unsigned int u32;
|
|
|
|
typedef unsigned long long u64;
|
|
|
|
typedef float f32;
|
|
|
|
typedef double f64;
|
|
|
|
#endif
|
2022-08-05 19:43:46 +00:00
|
|
|
|
|
|
|
#ifndef NULL
|
|
|
|
#define NULL 0
|
|
|
|
#endif
|
2022-04-08 08:30:31 +00:00
|
|
|
|
2022-07-27 06:32:31 +00:00
|
|
|
#ifndef bool8
|
2022-07-28 14:00:20 +00:00
|
|
|
typedef unsigned char bool8;
|
2022-07-27 06:32:31 +00:00
|
|
|
#endif
|
2023-01-07 21:24:16 +00:00
|
|
|
#ifndef __cplusplus
|
2023-12-19 02:28:24 +00:00
|
|
|
#if __STDC_VERSION__ <= 199901L
|
2023-06-29 10:56:20 +00:00
|
|
|
typedef unsigned long bool;
|
2023-12-19 02:28:24 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifndef FALSE
|
2022-08-05 19:43:46 +00:00
|
|
|
#define FALSE 0
|
2023-12-19 02:28:24 +00:00
|
|
|
#endif
|
|
|
|
#ifndef TRUE
|
2022-08-05 19:43:46 +00:00
|
|
|
#define TRUE 1
|
|
|
|
#endif
|
2023-12-19 02:28:24 +00:00
|
|
|
#endif
|
2022-08-05 19:43:46 +00:00
|
|
|
|
|
|
|
#define SND_STUDIO_MAXNUM 8
|
|
|
|
|
|
|
|
#define SND_STUDIO_DEFAULT 0
|
|
|
|
#define SND_STUDIO_NONE 0xFF
|
|
|
|
|
|
|
|
#define SYNTH_MAX_VOICES 64
|
|
|
|
|
|
|
|
typedef u32 SND_SEQID;
|
|
|
|
typedef u32 SND_VOICEID;
|
|
|
|
typedef u32 SND_STREAMID;
|
|
|
|
typedef u16 SND_GROUPID;
|
|
|
|
typedef u16 SND_SONGID;
|
|
|
|
typedef u16 SND_FXID;
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
SND_OUTPUTMODE_MONO = 0,
|
|
|
|
SND_OUTPUTMODE_STEREO,
|
2023-12-19 02:28:24 +00:00
|
|
|
SND_OUTPUTMODE_SURROUND
|
2022-08-05 19:43:46 +00:00
|
|
|
} SND_OUTPUTMODE;
|
|
|
|
|
|
|
|
typedef struct SND_PLAYBACKINFO {
|
|
|
|
u32 frq;
|
|
|
|
u8 stereo;
|
|
|
|
u8 bits;
|
|
|
|
s8 deviceName[256];
|
|
|
|
s8 versionText[256];
|
|
|
|
} SND_PLAYBACKINFO;
|
|
|
|
|
|
|
|
typedef struct SND_SEQVOLDEF {
|
|
|
|
u8 track;
|
|
|
|
u8 volGroup;
|
|
|
|
} SND_SEQVOLDEF;
|
2022-07-27 06:32:31 +00:00
|
|
|
|
2023-03-30 02:27:34 +00:00
|
|
|
#define SND_PLAYPARA_DEFAULT 0x00000000
|
|
|
|
#define SND_PLAYPARA_TRACKMUTE 0x00000001
|
|
|
|
#define SND_PLAYPARA_SPEED 0x00000002
|
|
|
|
#define SND_PLAYPARA_VOLUME 0x00000004
|
|
|
|
#define SND_PLAYPARA_SEQVOLDEF 0x00000008
|
|
|
|
#define SND_PLAYPARA_PAUSE 0x00000010
|
|
|
|
|
2023-02-25 02:11:03 +00:00
|
|
|
typedef struct SND_PLAYPARA {
|
2023-12-19 02:28:24 +00:00
|
|
|
u32 flags; // Enable features by using these flags
|
|
|
|
u32 trackMute[2]; // Initial mute settings
|
|
|
|
u16 speed; // Initial speed factor (0x100 = 1:1)
|
|
|
|
struct { // Start volume information
|
2023-02-25 02:11:03 +00:00
|
|
|
u16 time;
|
|
|
|
u8 target;
|
|
|
|
} volume;
|
2023-12-19 02:28:24 +00:00
|
|
|
u8 numSeqVolDef; // Number of non-standart volume group tracks
|
|
|
|
SND_SEQVOLDEF* seqVolDef; // List of tracks and the volume groups to be assigned to them
|
|
|
|
u8 numFaded; // Number of entries to the fade list
|
|
|
|
u8* faded; // Array of u8s containing the volume group IDs that should be affected by the initial
|
|
|
|
// volume setting (default will always be affected)
|
2023-02-25 02:11:03 +00:00
|
|
|
} SND_PLAYPARA;
|
|
|
|
|
2023-12-19 02:28:24 +00:00
|
|
|
#define SND_CROSSFADE_STOP 0 // Stop old song after fadedown
|
|
|
|
#define SND_CROSSFADE_PAUSE 1 // Pause old song after fadedown
|
|
|
|
#define SND_CROSSFADE_CONTINUE 2 // Continue previously paused song as new one
|
|
|
|
#define SND_CROSSFADE_START 0 // Start new song (no continue)
|
|
|
|
#define SND_CROSSFADE_SYNC 4 // Crossfade should start syncronized by sync-controller (104)
|
|
|
|
#define SND_CROSSFADE_PAUSENEW 8 // Pause new song before even starting it
|
|
|
|
#define SND_CROSSFADE_TRACKMUTE 16 // Use trackmute informtion
|
|
|
|
#define SND_CROSSFADE_SPEED 32 // Use speed informtion
|
|
|
|
#define SND_CROSSFADE_MUTE 64 // Old song continues playing & gets muted after fade down
|
|
|
|
#define SND_CROSSFADE_MUTENEW 128 // Mute new song after starting it
|
|
|
|
|
|
|
|
#define SND_CROSSFADE_DEFAULT 0
|
|
|
|
|
|
|
|
typedef struct SND_CROSSFADE {
|
|
|
|
SND_SEQID seqId1;
|
|
|
|
u16 time1;
|
|
|
|
|
|
|
|
SND_SEQID seqId2;
|
|
|
|
u16 time2;
|
|
|
|
void* arr2;
|
|
|
|
SND_GROUPID gid2;
|
|
|
|
SND_SONGID sid2;
|
|
|
|
u8 vol2;
|
|
|
|
u8 studio2;
|
|
|
|
|
|
|
|
u32 trackMute2[2]; // Mute bits (see sndMute())
|
|
|
|
u16 speed2; // Initial speed (of new song)
|
|
|
|
|
|
|
|
u8 flags;
|
|
|
|
} SND_CROSSFADE;
|
|
|
|
|
|
|
|
#define SND_ID_ERROR 0xFFFFFFFF // ID is invalid
|
|
|
|
|
|
|
|
#define SND_USERMUSIC_VOLGROUPS 0xFA
|
|
|
|
#define SND_USERFX_VOLGROUPS 0xFB
|
|
|
|
#define SND_USERALL_VOLGROUPS 0xFC
|
|
|
|
#define SND_MUSIC_VOLGROUPS 0xFD
|
|
|
|
#define SND_FX_VOLGROUPS 0xFE
|
|
|
|
#define SND_ALL_VOLGROUPS 0xFF
|
|
|
|
|
|
|
|
#define SND_MAX_USER_VOLGROUP 20
|
|
|
|
|
|
|
|
bool sndPushGroup(void* prj_data, SND_GROUPID gid, void* samples, void* sampdir, void* pool);
|
|
|
|
bool sndPopGroup(void);
|
|
|
|
|
|
|
|
void sndSetSampleDataUploadCallback(void* (*callback)(u32 offset, u32 bytes), u32 chunkSize);
|
|
|
|
|
2022-08-05 19:43:46 +00:00
|
|
|
typedef struct SND_HOOKS {
|
2023-12-19 02:28:24 +00:00
|
|
|
void* (*malloc)(size_t addr);
|
2022-07-27 06:32:31 +00:00
|
|
|
void (*free)(void* addr);
|
2022-07-27 05:11:36 +00:00
|
|
|
} SND_HOOKS;
|
2022-07-27 06:32:31 +00:00
|
|
|
|
2023-01-07 21:24:16 +00:00
|
|
|
void sndSetHooks(SND_HOOKS* hooks);
|
|
|
|
|
2023-12-19 02:28:24 +00:00
|
|
|
// Misc flags to influence the way the sound system works internally
|
|
|
|
// (support may vary from platform to platform)
|
2022-08-05 19:43:46 +00:00
|
|
|
|
2023-12-19 02:28:24 +00:00
|
|
|
#define SND_FLAGS_DEFAULT 0x00000000
|
|
|
|
#define SND_FLAGS_DEFAULT_STUDIO_DPL2 0x00000001 // Use DPL2 encoding for default studio
|
|
|
|
#define SND_FLAGS_EMITTERGROUPSUSEMAXVOICES \
|
|
|
|
0x00000002 // define this to enable usage of max. voices from FX table for emitter group start
|
|
|
|
// management
|
2022-08-05 19:43:46 +00:00
|
|
|
|
2023-12-19 02:28:24 +00:00
|
|
|
// Platform dependend flags : PC
|
2023-06-21 23:27:28 +00:00
|
|
|
|
2023-12-19 02:28:24 +00:00
|
|
|
#define SND_FLAGS_PC_USE_TIMER \
|
|
|
|
0x00000000 // Use timer driven update system (less performance hit, larger latency)
|
|
|
|
#define SND_FLAGS_PC_USE_THREAD \
|
|
|
|
0x00010000 // Use thread driven update system (larger performance hit, shorter latency)
|
|
|
|
#define SND_FLAGS_PC_USE_PRIMARY 0x00020000 // Use a primary sound buffer for mixing (Win95/98 only)
|
2023-06-21 23:27:28 +00:00
|
|
|
|
2023-12-19 02:28:24 +00:00
|
|
|
#define SND_FLAGS_PC_LATENCY0 0x00000000 // Latency values (see documentation)
|
|
|
|
#define SND_FLAGS_PC_LATENCY1 0x10000000
|
|
|
|
#define SND_FLAGS_PC_LATENCY2 0x20000000
|
|
|
|
#define SND_FLAGS_PC_LATENCY3 0x30000000
|
|
|
|
#define SND_FLAGS_PC_LATENCY4 0x40000000
|
|
|
|
#define SND_FLAGS_PC_LATENCY5 0x50000000
|
|
|
|
#define SND_FLAGS_PC_LATENCY6 0x60000000
|
|
|
|
#define SND_FLAGS_PC_LATENCY7 0x70000000
|
2023-06-21 23:27:28 +00:00
|
|
|
|
2023-12-19 02:28:24 +00:00
|
|
|
s32 sndInit(u8 voices, u8 music, u8 sfx, u8 studios, u32 flags, u32 aramSize);
|
|
|
|
void sndQuit(void);
|
2023-06-21 23:27:28 +00:00
|
|
|
|
2023-12-19 02:28:24 +00:00
|
|
|
bool sndIsInstalled(void);
|
|
|
|
bool sndIsIdle(void);
|
|
|
|
SND_PLAYBACKINFO* sndGetPlayBackInfo(void);
|
2023-06-21 23:27:28 +00:00
|
|
|
|
2023-12-19 02:28:24 +00:00
|
|
|
void sndSetMaxVoices(u8 music, u8 sfx);
|
2023-06-21 23:27:28 +00:00
|
|
|
|
2023-12-19 02:28:24 +00:00
|
|
|
void sndVolume(u8 volume, u16 time, u8 volGroup);
|
|
|
|
void sndMasterVolume(u8 volume, u16 time, u8 music, u8 fx);
|
|
|
|
void sndOutputMode(SND_OUTPUTMODE mode);
|
|
|
|
void sndSilence(void);
|
2023-06-21 23:27:28 +00:00
|
|
|
|
2023-12-19 02:28:24 +00:00
|
|
|
#define SND_PAUSEVOL_NORMAL 127
|
2023-06-21 23:27:28 +00:00
|
|
|
|
2023-12-19 02:28:24 +00:00
|
|
|
void sndPauseVolume(u8 mute_vol, u16 time, u8 volGroup);
|
2023-06-21 23:27:28 +00:00
|
|
|
|
2023-12-19 02:28:24 +00:00
|
|
|
#define SND_MIDICTRL_MODULATION 0x01
|
|
|
|
#define SND_MIDICTRL_VOLUME 0x07
|
|
|
|
#define SND_MIDICTRL_PANNING 0x0A
|
|
|
|
#define SND_MIDICTRL_PEDAL 0x40
|
|
|
|
#define SND_MIDICTRL_PORTAMENTO 0x41
|
|
|
|
#define SND_MIDICTRL_REVERB 0x5B
|
|
|
|
#define SND_MIDICTRL_CHORUS 0x5D
|
2023-06-21 23:27:28 +00:00
|
|
|
|
2023-12-19 02:28:24 +00:00
|
|
|
#define SND_MIDICTRL_PITCHBEND 0x80
|
|
|
|
#define SND_MIDICTRL_SPANNING 0x83
|
|
|
|
#define SND_MIDICTRL_DOPPLER 0x84
|
2023-06-21 23:27:28 +00:00
|
|
|
|
2023-12-19 02:28:24 +00:00
|
|
|
#define SND_SEQVOL_CONTINUE 0
|
|
|
|
#define SND_SEQVOL_STOP 1
|
|
|
|
#define SND_SEQVOL_PAUSE 2
|
|
|
|
#define SND_SEQVOL_MUTE 3
|
|
|
|
#define SND_SEQVOL_MODEMASK 0xF
|
2023-06-21 23:27:28 +00:00
|
|
|
|
2023-12-19 02:28:24 +00:00
|
|
|
#define SND_ID_ERROR 0xFFFFFFFF // ID is invalid
|
2023-06-21 23:27:28 +00:00
|
|
|
|
2023-12-19 02:28:24 +00:00
|
|
|
#define SND_MAX_SEQINSTANCES 8
|
|
|
|
#define SND_SEQ_ERROR_ID 0xFFFFFFFF
|
|
|
|
#define SND_SEQ_CROSSFADE_ID 0x80000000
|
2023-06-21 23:27:28 +00:00
|
|
|
|
2023-12-19 02:28:24 +00:00
|
|
|
#define SND_PAUSEVOL_NORMAL 127
|
|
|
|
#define SND_SEQVOL_CONTINUE 0
|
|
|
|
#define SND_SEQVOL_STOP 1
|
|
|
|
#define SND_SEQVOL_PAUSE 2
|
|
|
|
#define SND_SEQVOL_MUTE 3
|
2023-06-21 23:27:28 +00:00
|
|
|
|
2023-12-19 02:28:24 +00:00
|
|
|
#define sndSeqPlay(sgid, sid, arrfile, para) \
|
|
|
|
sndSeqPlayEx(sgid, sid, arrfile, para, SND_STUDIO_DEFAULT)
|
|
|
|
SND_SEQID sndSeqPlayEx(SND_GROUPID sgid, SND_SONGID sid, void* arrfile, SND_PLAYPARA* para,
|
|
|
|
u8 studio);
|
|
|
|
|
|
|
|
void sndSeqStop(SND_SEQID seqId);
|
|
|
|
void sndSeqPause(SND_SEQID seqId);
|
|
|
|
void sndSeqContinue(SND_SEQID seqId);
|
|
|
|
void sndSeqMute(SND_SEQID seqId, u32 mask1, u32 mask2);
|
|
|
|
void sndSeqSpeed(SND_SEQID seqId, u16 speed);
|
|
|
|
bool sndSeqLoop(SND_SEQID seqId, bool on);
|
|
|
|
bool sndSeqLoopEx(SND_SEQID seqId, u8 track, bool on);
|
|
|
|
u16 sndSeqGetLoopCnt(SND_SEQID seqId);
|
|
|
|
u16 sndSeqGetLoopCntEx(SND_SEQID seqId, u8 track);
|
|
|
|
bool sndSeqGetValid(SND_SEQID seqId);
|
|
|
|
u8 sndSeqGetMidiCtrl(SND_SEQID seqId, u8 channel, u8 ctrl);
|
|
|
|
u16 sndSeqGetMidiCtrl14(SND_SEQID seqId, u8 channel, u8 ctrl);
|
|
|
|
bool sndSeqSetMidiCtrl(SND_SEQID seqId, u8 channel, u8 ctrl, u8 value);
|
|
|
|
bool sndSeqSetMidiCtrl14(SND_SEQID seqId, u8 channel, u8 ctrl, u16 value);
|
|
|
|
|
|
|
|
void sndSeqVolume(u8 volume, u16 time, SND_SEQID seqId, u8 mode);
|
|
|
|
u8 sndSeqGetVolGroup(SND_SEQID seqId);
|
|
|
|
bool sndSeqAssignVolGroup2Track(SND_SEQID seqId, u8 track, u8 vGroup);
|
|
|
|
void sndSeqCrossFade(SND_CROSSFADE* ci, SND_SEQID* new_seqId);
|
|
|
|
bool sndSeqCrossFadeDone(SND_SEQID* new_seqId);
|
2023-06-21 23:27:28 +00:00
|
|
|
|
2023-12-19 02:28:24 +00:00
|
|
|
typedef struct SND_PARAMETER {
|
|
|
|
u8 ctrl;
|
|
|
|
union _paraData {
|
|
|
|
u8 value7;
|
|
|
|
u16 value14;
|
|
|
|
} paraData;
|
|
|
|
} SND_PARAMETER;
|
2023-06-21 23:27:28 +00:00
|
|
|
|
2023-12-19 02:28:24 +00:00
|
|
|
typedef struct SND_PARAMETER_INFO {
|
|
|
|
u8 numPara; // How many MIDI controller values (ID,value - value may be 8-bit or 16-bit!)
|
|
|
|
SND_PARAMETER* paraArray; // Parameter data...
|
|
|
|
} SND_PARAMETER_INFO;
|
2023-06-21 23:27:28 +00:00
|
|
|
|
2023-12-19 02:28:24 +00:00
|
|
|
#define SND_FX_DEFVOL 0xFF
|
|
|
|
#define SND_FX_DEFPAN 0xFF
|
2023-06-21 23:27:28 +00:00
|
|
|
|
2023-12-19 02:28:24 +00:00
|
|
|
#define sndFXStart(fid, vol, pan) sndFXStartEx(fid, vol, pan, SND_STUDIO_DEFAULT)
|
|
|
|
SND_VOICEID sndFXStartEx(SND_FXID fid, u8 vol, u8 pan, u8 studio);
|
|
|
|
SND_VOICEID sndFXStartPara(SND_FXID fid, u8 vol, u8 pan, u8 studio, u8 numPara, ...);
|
|
|
|
SND_VOICEID sndFXStartParaInfo(SND_FXID fid, u8 vol, u8 pan, u8 studio,
|
|
|
|
SND_PARAMETER_INFO* paraInfo);
|
|
|
|
SND_VOICEID sndFXCheck(SND_VOICEID vid);
|
|
|
|
bool sndFXKeyOff(SND_VOICEID vid);
|
|
|
|
bool sndFXCtrl(SND_VOICEID vid, u8 ctrl, u8 value);
|
|
|
|
bool sndFXCtrl14(SND_VOICEID vid, u8 ctrl, u16 value);
|
2023-06-21 23:27:28 +00:00
|
|
|
|
2023-12-19 02:28:24 +00:00
|
|
|
#define SND_MIDICTRL_MODULATION 0x01
|
|
|
|
#define SND_MIDICTRL_VOLUME 0x07
|
|
|
|
#define SND_MIDICTRL_PANNING 0x0A
|
|
|
|
#define SND_MIDICTRL_PEDAL 0x40
|
|
|
|
#define SND_MIDICTRL_PORTAMENTO 0x41
|
|
|
|
#define SND_MIDICTRL_REVERB 0x5B
|
|
|
|
#define SND_MIDICTRL_CHORUS 0x5D
|
2023-06-21 23:27:28 +00:00
|
|
|
|
2023-12-19 02:28:24 +00:00
|
|
|
#define SND_MIDICTRL_PITCHBEND 0x80
|
|
|
|
#define SND_MIDICTRL_SPANNING 0x83
|
|
|
|
#define SND_MIDICTRL_DOPPLER 0x84
|
2023-06-21 23:27:28 +00:00
|
|
|
|
2023-12-19 02:28:24 +00:00
|
|
|
#define sndFXPitchBend(vid, pb) sndFXCtrl14(vid, SND_MIDICTRL_PITCHBEND, pb)
|
|
|
|
#define sndFXModulation(vid, modu) sndFXCtrl14(vid, SND_MIDICTRL_MODULATION, modu)
|
|
|
|
#define sndFXDoppler(vid, doppler) sndFXCtrl14(vid, SND_MIDICTRL_DOPPLER, doppler)
|
2023-06-21 23:27:28 +00:00
|
|
|
|
2023-12-19 02:28:24 +00:00
|
|
|
#define sndFXReverb(vid, reverb) sndFXCtrl(vid, SND_MIDICTRL_REVERB, reverb)
|
|
|
|
#define sndFXChorus(vid, chorus) sndFXCtrl(vid, SND_MIDICTRL_CHORUS, chorus)
|
|
|
|
#define sndFXPedal(vid, pedal) sndFXCtrl(vid, SND_MIDICTRL_PEDAL, pedal)
|
|
|
|
#define sndFXVolume(vid, vol) sndFXCtrl(vid, SND_MIDICTRL_VOLUME, vol)
|
|
|
|
#define sndFXPanning(vid, pan) sndFXCtrl(vid, SND_MIDICTRL_PANNING, pan)
|
|
|
|
#define sndFXSurroundPanning(vid, span) sndFXCtrl(vid, SND_MIDICTRL_SPANNING, span)
|
2023-06-21 23:27:28 +00:00
|
|
|
|
2023-12-19 02:28:24 +00:00
|
|
|
bool sndFXAssignVolGroup2FXId(SND_FXID fid, u8 vGroup);
|
2023-06-21 23:27:28 +00:00
|
|
|
|
2023-12-19 02:28:24 +00:00
|
|
|
// --------------------------------------------------------
|
2023-06-21 23:27:28 +00:00
|
|
|
|
2023-12-19 02:28:24 +00:00
|
|
|
s32 sndReadFlag(u8 num);
|
|
|
|
s32 sndWriteFlag(u8 num, s32 value);
|
2023-06-21 23:27:28 +00:00
|
|
|
|
2023-12-19 02:28:24 +00:00
|
|
|
bool sndSendMessage(SND_VOICEID vid, s32 mesg);
|
|
|
|
void sndSetReceiveMessageCallback(void (*callback)(SND_VOICEID vid, s32 mesg));
|
2023-06-21 23:27:28 +00:00
|
|
|
|
2023-12-19 02:28:24 +00:00
|
|
|
// --------------------------------------------------------
|
2023-06-21 23:27:28 +00:00
|
|
|
|
2023-12-19 02:28:24 +00:00
|
|
|
// Flags
|
|
|
|
#define SND_STREAM_DEFAULT 0x00000000 // Default stream buffer (PCM16)
|
|
|
|
#define SND_STREAM_ADPCM 0x00000001 // ADPCM stream buffer
|
|
|
|
#define SND_STREAM_INACTIVE 0x00010000 // Allocate stream, but do not start it yet
|
|
|
|
#define SND_STREAM_MANUALARAMUPD 0x00020000 // Application will provide manual ARAM buffer updates
|
2023-06-21 23:27:28 +00:00
|
|
|
|
2023-12-19 02:28:24 +00:00
|
|
|
#define SND_STREAM_ADPCM_BLKBYTES 8 // Bytes per ADPCM block
|
|
|
|
#define SND_STREAM_ADPCM_BLKSIZE 14 // Samples per ADPCM block
|
2022-08-11 08:12:35 +00:00
|
|
|
|
2023-12-19 02:28:24 +00:00
|
|
|
// ADPCM info structure
|
|
|
|
typedef struct SND_ADPCMSTREAM_INFO {
|
|
|
|
s16 coefTab[8][2]; // Table of coef. pairs
|
|
|
|
} SND_ADPCMSTREAM_INFO;
|
2022-08-11 08:12:35 +00:00
|
|
|
|
2023-12-19 02:28:24 +00:00
|
|
|
#define sndStreamAlloc(prio, buffer, size, frq, vol, pan, span, fxvol, updateFunction, user) \
|
|
|
|
sndStreamAllocEx(prio, buffer, size, frq, vol, pan, span, fxvol, 0, SND_STUDIO_DEFAULT, \
|
|
|
|
SND_STREAM_DEFAULT, updateFunction, user, NULL)
|
|
|
|
SND_STREAMID sndStreamAllocEx(u8 prio, void* buffer, u32 samples, u32 frq, u8 vol, u8 pan, u8 span,
|
|
|
|
u8 auxa, u8 auxb, u8 studio, u32 flags,
|
|
|
|
u32 (*updateFunction)(void* buffer1, u32 len1, void* buffer2,
|
|
|
|
u32 len2, u32 user),
|
|
|
|
u32 user, SND_ADPCMSTREAM_INFO* adpcmInfo);
|
|
|
|
SND_STREAMID sndStreamAllocStereo(u8 prio, void* lBuffer, void* rBuffer, u32 samples, u32 frq,
|
|
|
|
u8 vol, u8 pan, u8 span, u8 auxa, u8 auxb, u8 studio, u32 flags,
|
|
|
|
u32 (*updateFunction)(void* buffer1, u32 len1, void* buffer2,
|
|
|
|
u32 len2, u32 user),
|
|
|
|
u32 lUser, u32 rUser, SND_ADPCMSTREAM_INFO* adpcmInfoL,
|
|
|
|
SND_ADPCMSTREAM_INFO* adpcmInfoR);
|
|
|
|
u32 sndStreamAllocLength(u32 num, u32 flags);
|
|
|
|
void sndStreamFree(SND_STREAMID stid);
|
|
|
|
void sndStreamMixParameter(SND_STREAMID stid, u8 vol, u8 pan, u8 span, u8 fxvol);
|
|
|
|
void sndStreamMixParameterEx(SND_STREAMID stid, u8 vol, u8 pan, u8 span, u8 auxa, u8 auxb);
|
|
|
|
void sndStreamADPCMParameter(SND_STREAMID stid, SND_ADPCMSTREAM_INFO* adpcmInfo);
|
|
|
|
void sndStreamFrq(SND_STREAMID stid, u32 frq);
|
|
|
|
bool sndStreamActivate(SND_STREAMID stid);
|
|
|
|
void sndStreamDeactivate(SND_STREAMID stid);
|
|
|
|
void sndStreamARAMUpdate(SND_STREAMID stid, u32 off1, u32 len1, u32 off2, u32 len2);
|
|
|
|
u32 sndStreamCallbackFrq(u32 msTime);
|
|
|
|
|
|
|
|
// --------------------------------------------------------
|
|
|
|
|
|
|
|
#define SND_VIRTUALSAMPLE_DEFAULT 0x00000000
|
|
|
|
|
|
|
|
bool sndVirtualSampleAllocateBuffers(u8 numInstances, u32 numSamples, u32 flags);
|
|
|
|
void sndVirtualSampleFreeBuffers(void);
|
|
|
|
|
|
|
|
typedef u16 SND_VSID; // Virtual sample ID
|
|
|
|
typedef u16 SND_INSTID; // Virtual sample instance ID
|
|
|
|
|
|
|
|
typedef struct SND_VIRTUALSAMPLE_INFO {
|
|
|
|
SND_VSID smpID; // ID of sample to be streamed
|
|
|
|
SND_INSTID instID; // ID of this instance of the stream
|
|
|
|
|
|
|
|
union vsData {
|
|
|
|
struct vsUpdate { // Buffer update info
|
|
|
|
u32 off1;
|
|
|
|
u32 len1;
|
|
|
|
u32 off2;
|
|
|
|
u32 len2;
|
|
|
|
} update;
|
|
|
|
} data;
|
|
|
|
} SND_VIRTUALSAMPLE_INFO;
|
2022-08-11 08:12:35 +00:00
|
|
|
|
2023-12-19 02:28:24 +00:00
|
|
|
#define SND_VIRTUALSAMPLE_REASON_INIT 0 // Virtual sample just started playback
|
|
|
|
#define SND_VIRTUALSAMPLE_REASON_UPDATE 1 // Virtual sample is within stream buffer and needs data
|
|
|
|
#define SND_VIRTUALSAMPLE_REASON_STOP 2 // Virtual sample just has been stopped
|
|
|
|
#define SND_VIRTUALSAMPLE_REASON_ARAMDMADONE \
|
|
|
|
3 // Last ARAM update initiated for this virtual sample has finished
|
2022-08-11 08:12:35 +00:00
|
|
|
|
2023-12-19 02:28:24 +00:00
|
|
|
void sndVirtualSampleSetCallback(u32 (*callback)(u8 reason, const SND_VIRTUALSAMPLE_INFO* info));
|
2022-08-11 08:12:35 +00:00
|
|
|
|
2023-12-19 02:28:24 +00:00
|
|
|
void sndVirtualSampleARAMUpdate(SND_INSTID instID, void* base, u32 off1, u32 len1, u32 off2,
|
|
|
|
u32 len2);
|
2022-08-11 08:12:35 +00:00
|
|
|
|
2023-12-19 02:28:24 +00:00
|
|
|
void sndVirtualSampleEndPlayback(SND_INSTID instID, bool sampleEndedNormally);
|
|
|
|
|
|
|
|
#define SND_AUX_BLOCKSIZE 160 // Size of block passed to the AUX FX hanler (in samples)
|
2022-07-27 06:32:31 +00:00
|
|
|
|
2022-07-28 14:00:20 +00:00
|
|
|
#define SND_AUX_REASON_BUFFERUPDATE 0
|
|
|
|
#define SND_AUX_REASON_PARAMETERUPDATE 1
|
|
|
|
|
2023-12-19 02:28:24 +00:00
|
|
|
#define SND_MIDI_NONE 0xFF
|
|
|
|
|
|
|
|
#define SND_AUX_NUMPARAMETERS 4
|
2023-02-19 07:41:18 +00:00
|
|
|
|
2022-07-27 06:32:31 +00:00
|
|
|
typedef struct SND_AUX_INFO {
|
|
|
|
union SND_AUX_DATA {
|
|
|
|
struct SND_AUX_BUFFERUPDATE {
|
|
|
|
s32* left;
|
|
|
|
s32* right;
|
|
|
|
s32* surround;
|
|
|
|
} bufferUpdate;
|
|
|
|
struct SND_AUX_PARAMETERUPDATE {
|
|
|
|
u16 para[SND_AUX_NUMPARAMETERS];
|
|
|
|
} parameterUpdate;
|
|
|
|
} data;
|
|
|
|
} SND_AUX_INFO;
|
|
|
|
|
2023-12-19 02:28:24 +00:00
|
|
|
void sndSetAuxProcessingCallbacks(u8 studio,
|
|
|
|
void (*auxA)(u8 reason, SND_AUX_INFO* info, void* user),
|
|
|
|
void* userA, u8 midiA, SND_SEQID seqIDA,
|
|
|
|
void (*auxB)(u8 reason, SND_AUX_INFO* info, void* user),
|
|
|
|
void* userB, u8 midiB, SND_SEQID seqIDB);
|
|
|
|
|
|
|
|
#define SND_AUXA_PARAMETERS 0
|
|
|
|
#define SND_AUXB_PARAMETERS 1
|
|
|
|
|
|
|
|
void sndUpdateAuxParameter(u8 studio, u16 para[SND_AUX_NUMPARAMETERS], u8 auxBus);
|
|
|
|
|
|
|
|
typedef enum {
|
|
|
|
SND_STUDIO_TYPE_STD = 0,
|
|
|
|
SND_STUDIO_TYPE_DPL2,
|
|
|
|
SND_STUDIO_TYPE_RESERVED1,
|
|
|
|
SND_STUDIO_TYPE_RESERVED2
|
|
|
|
} SND_STUDIO_TYPE;
|
|
|
|
|
|
|
|
#define sndActivateStudio(studio, isMaster) \
|
|
|
|
sndActivateStudioEx(studio, isMaster, SND_STUDIO_TYPE_STD)
|
|
|
|
void sndActivateStudioEx(u8 studio, bool isMaster, SND_STUDIO_TYPE type);
|
|
|
|
void sndChangeStudioMasterMix(u8 studio, bool isMaster);
|
|
|
|
void sndDeactivateStudio(u8 studio);
|
|
|
|
void sndSetITDDefault(u8 studio, bool musicITD, bool sfxITD);
|
|
|
|
|
|
|
|
// Standard Quality Reverb AUX FX
|
|
|
|
|
|
|
|
typedef struct _SND_REVSTD_DELAYLINE {
|
|
|
|
s32 inPoint;
|
|
|
|
s32 outPoint;
|
|
|
|
s32 length;
|
|
|
|
f32* inputs;
|
|
|
|
f32 lastOutput;
|
|
|
|
} _SND_REVSTD_DELAYLINE;
|
|
|
|
|
|
|
|
typedef struct _SND_REVSTD_WORK {
|
|
|
|
_SND_REVSTD_DELAYLINE AP[6];
|
|
|
|
_SND_REVSTD_DELAYLINE C[6];
|
|
|
|
f32 allPassCoeff;
|
|
|
|
f32 combCoef[6];
|
|
|
|
f32 lpLastout[3];
|
|
|
|
f32 level;
|
|
|
|
f32 damping;
|
|
|
|
s32 preDelayTime;
|
|
|
|
f32* preDelayLine[3];
|
|
|
|
f32* preDelayPtr[3];
|
|
|
|
} _SND_REVSTD_WORK;
|
|
|
|
|
|
|
|
typedef struct SND_AUX_REVERBSTD {
|
|
|
|
_SND_REVSTD_WORK rv;
|
|
|
|
bool8 tempDisableFX;
|
|
|
|
|
|
|
|
f32 coloration;
|
|
|
|
f32 mix;
|
|
|
|
f32 time;
|
|
|
|
f32 damping;
|
|
|
|
f32 preDelay;
|
|
|
|
} SND_AUX_REVERBSTD;
|
|
|
|
|
|
|
|
typedef void (*SND_AUX_CALLBACK)(u8 reason, SND_AUX_INFO* info, void* user);
|
|
|
|
void sndAuxCallbackReverbSTD(u8 reason, SND_AUX_INFO* info, void* user);
|
|
|
|
bool sndAuxCallbackPrepareReverbSTD(SND_AUX_REVERBSTD* rev);
|
|
|
|
bool sndAuxCallbackShutdownReverbSTD(SND_AUX_REVERBSTD* rev);
|
|
|
|
bool sndAuxCallbackUpdateSettingsReverbSTD(SND_AUX_REVERBSTD* rev);
|
|
|
|
|
|
|
|
// High Quality Reverb AUX FX
|
|
|
|
//
|
2022-07-27 06:32:31 +00:00
|
|
|
typedef struct _SND_REVHI_DELAYLINE {
|
|
|
|
s32 inPoint;
|
|
|
|
s32 outPoint;
|
|
|
|
s32 length;
|
|
|
|
f32* inputs;
|
|
|
|
f32 lastOutput;
|
|
|
|
} _SND_REVHI_DELAYLINE;
|
|
|
|
|
|
|
|
typedef struct _SND_REVHI_WORK {
|
|
|
|
_SND_REVHI_DELAYLINE AP[9];
|
|
|
|
_SND_REVHI_DELAYLINE C[9];
|
|
|
|
f32 allPassCoeff;
|
|
|
|
f32 combCoef[9];
|
|
|
|
f32 lpLastout[3];
|
|
|
|
f32 level;
|
|
|
|
f32 damping;
|
|
|
|
s32 preDelayTime;
|
|
|
|
f32 crosstalk;
|
|
|
|
f32* preDelayLine[3];
|
|
|
|
f32* preDelayPtr[3];
|
|
|
|
} _SND_REVHI_WORK;
|
|
|
|
|
|
|
|
typedef struct SND_AUX_REVERBHI {
|
|
|
|
_SND_REVHI_WORK rv;
|
|
|
|
bool8 tempDisableFX;
|
|
|
|
|
|
|
|
f32 coloration;
|
|
|
|
f32 mix;
|
|
|
|
f32 time;
|
|
|
|
f32 damping;
|
|
|
|
f32 preDelay;
|
|
|
|
f32 crosstalk;
|
|
|
|
} SND_AUX_REVERBHI;
|
|
|
|
|
2022-07-28 14:00:20 +00:00
|
|
|
void sndAuxCallbackReverbHI(u8 reason, SND_AUX_INFO* info, void* user);
|
2023-06-29 10:56:20 +00:00
|
|
|
bool sndAuxCallbackPrepareReverbHI(SND_AUX_REVERBHI* rev);
|
|
|
|
bool sndAuxCallbackShutdownReverbHI(SND_AUX_REVERBHI* rev);
|
2023-12-19 02:28:24 +00:00
|
|
|
bool sndAuxCallbackUpdateSettingsReverbHI(SND_AUX_REVERBHI* rev);
|
2022-07-28 14:00:20 +00:00
|
|
|
|
2023-12-19 02:28:24 +00:00
|
|
|
// Delay AUX FX
|
|
|
|
//
|
2022-07-28 14:00:20 +00:00
|
|
|
typedef struct SND_AUX_DELAY {
|
|
|
|
u32 currentSize[3];
|
|
|
|
u32 currentPos[3];
|
|
|
|
u32 currentFeedback[3];
|
|
|
|
u32 currentOutput[3];
|
|
|
|
|
|
|
|
s32* left;
|
|
|
|
s32* right;
|
|
|
|
s32* sur;
|
|
|
|
|
2023-12-19 02:28:24 +00:00
|
|
|
// - - - - - - - - - - -
|
|
|
|
|
2022-07-28 14:00:20 +00:00
|
|
|
u32 delay[3]; // Delay buffer length in ms per channel
|
|
|
|
u32 feedback[3]; // Feedback volume in % per channel
|
|
|
|
u32 output[3]; // Output volume in % per channel
|
|
|
|
} SND_AUX_DELAY;
|
|
|
|
|
2022-07-28 15:50:05 +00:00
|
|
|
void sndAuxCallbackDelay(u8 reason, SND_AUX_INFO* info, void* user);
|
2023-12-19 02:28:24 +00:00
|
|
|
bool sndAuxCallbackPrepareDelay(SND_AUX_DELAY* delay);
|
|
|
|
bool sndAuxCallbackShutdownDelay(SND_AUX_DELAY* delay);
|
2022-08-05 19:43:46 +00:00
|
|
|
bool sndAuxCallbackUpdateSettingsDelay(SND_AUX_DELAY* delay);
|
2022-07-28 15:50:05 +00:00
|
|
|
|
2023-12-19 02:28:24 +00:00
|
|
|
// Chorus AUX FX
|
2022-07-28 14:00:20 +00:00
|
|
|
|
2022-12-24 22:54:58 +00:00
|
|
|
typedef struct _SND_CHORUS_SRCINFO {
|
|
|
|
s32* dest;
|
|
|
|
s32* smpBase;
|
|
|
|
s32* old;
|
|
|
|
u32 posLo;
|
|
|
|
u32 posHi;
|
|
|
|
u32 pitchLo;
|
|
|
|
u32 pitchHi;
|
|
|
|
u32 trigger;
|
|
|
|
u32 target;
|
|
|
|
} _SND_CHORUS_SRCINFO;
|
|
|
|
|
2023-12-19 02:28:24 +00:00
|
|
|
#define _SND_CHORUS_NUM_BLOCKS 3
|
|
|
|
|
2022-12-24 22:54:58 +00:00
|
|
|
typedef struct _SND_CHORUS_WORK {
|
|
|
|
s32* lastLeft[_SND_CHORUS_NUM_BLOCKS];
|
|
|
|
s32* lastRight[_SND_CHORUS_NUM_BLOCKS];
|
|
|
|
s32* lastSur[_SND_CHORUS_NUM_BLOCKS];
|
|
|
|
u8 currentLast;
|
|
|
|
s32 oldLeft[4];
|
|
|
|
s32 oldRight[4];
|
|
|
|
s32 oldSur[4];
|
|
|
|
|
|
|
|
u32 currentPosLo;
|
|
|
|
u32 currentPosHi;
|
|
|
|
|
|
|
|
s32 pitchOffset;
|
|
|
|
u32 pitchOffsetPeriodCount;
|
|
|
|
u32 pitchOffsetPeriod;
|
|
|
|
|
|
|
|
_SND_CHORUS_SRCINFO src;
|
|
|
|
} _SND_CHORUS_WORK;
|
|
|
|
|
|
|
|
typedef struct SND_AUX_CHORUS {
|
|
|
|
_SND_CHORUS_WORK work;
|
2023-12-19 02:28:24 +00:00
|
|
|
|
|
|
|
u32 baseDelay; // Base delay of chorus effect in ms
|
|
|
|
u32 variation; // Variation of base delay in ms
|
|
|
|
u32 period; // Period of variational oscilation in ms
|
2022-12-24 22:54:58 +00:00
|
|
|
} SND_AUX_CHORUS;
|
|
|
|
|
|
|
|
void sndAuxCallbackChorus(u8 reason, SND_AUX_INFO* info, void* user);
|
|
|
|
bool sndAuxCallbackPrepareChorus(SND_AUX_CHORUS* ch);
|
|
|
|
bool sndAuxCallbackShutdownChorus(SND_AUX_CHORUS* ch);
|
|
|
|
bool sndAuxCallbackUpdateSettingsChorus(SND_AUX_CHORUS* ch);
|
2023-02-25 02:11:03 +00:00
|
|
|
|
2023-12-19 02:28:24 +00:00
|
|
|
// Studio linkage
|
|
|
|
typedef struct SND_STUDIO_INPUT {
|
|
|
|
u8 vol;
|
|
|
|
u8 volA;
|
|
|
|
u8 volB;
|
|
|
|
u8 srcStudio;
|
|
|
|
} SND_STUDIO_INPUT;
|
2023-03-30 02:27:34 +00:00
|
|
|
|
2023-12-19 02:28:24 +00:00
|
|
|
bool sndAddStudioInput(u8 studio, SND_STUDIO_INPUT* in_desc);
|
|
|
|
bool sndRemoveStudioInput(u8 studio, SND_STUDIO_INPUT* in_desc);
|
2023-03-30 02:27:34 +00:00
|
|
|
|
2023-12-19 02:28:24 +00:00
|
|
|
// 3D API
|
2023-03-30 02:27:34 +00:00
|
|
|
|
2023-12-19 02:28:24 +00:00
|
|
|
typedef struct SND_FVECTOR {
|
|
|
|
f32 x;
|
|
|
|
f32 y;
|
|
|
|
f32 z;
|
|
|
|
} SND_FVECTOR;
|
2023-03-30 02:27:34 +00:00
|
|
|
|
2023-12-19 02:28:24 +00:00
|
|
|
typedef struct SND_FMATRIX {
|
|
|
|
f32 m[3][3];
|
|
|
|
f32 t[3];
|
|
|
|
} SND_FMATRIX;
|
2023-03-30 02:27:34 +00:00
|
|
|
|
2023-12-19 02:28:24 +00:00
|
|
|
typedef struct SND_ROOM {
|
|
|
|
struct SND_ROOM* next;
|
|
|
|
struct SND_ROOM* prev;
|
|
|
|
|
|
|
|
u32 flags;
|
|
|
|
SND_FVECTOR pos; // World "position" of room
|
|
|
|
f32 distance; // Average distance to listeners (squared)
|
|
|
|
|
|
|
|
u8 studio;
|
|
|
|
|
|
|
|
void (*activateReverb)(u8 studio, void* para); // Callbacks to activate/deactivate "reverb" (AuxA)
|
|
|
|
void (*deActivateReverb)(u8 studio); // (NULL -> none)
|
|
|
|
void* user; // Pointer to user data (e.g. "reverb" parameters)
|
|
|
|
|
|
|
|
u32 curMVol; // Current master mix volume (7.16)
|
|
|
|
} SND_ROOM;
|
|
|
|
|
|
|
|
typedef struct SND_DOOR {
|
|
|
|
struct SND_DOOR* next;
|
|
|
|
struct SND_DOOR* prev;
|
|
|
|
|
|
|
|
SND_FVECTOR pos; // Position of door
|
|
|
|
|
|
|
|
f32 open; // State (0=closed, 1=open)
|
|
|
|
f32 dampen; // Dampening when closed (0=none, 1=full)
|
|
|
|
u8 fxVol; // FX mix volume of this door (0-127)
|
|
|
|
|
|
|
|
u8 destStudio; // When active: Studio the input is linked to
|
|
|
|
|
|
|
|
SND_ROOM* a; // Rooms to be linked
|
|
|
|
SND_ROOM* b;
|
|
|
|
|
|
|
|
u32 flags; // Flags
|
|
|
|
|
|
|
|
s16 filterCoef[4]; // Coefs of the 4 tab FIR filter (0x7FFF = 1.0)
|
|
|
|
SND_STUDIO_INPUT input; // Input info (when active)
|
|
|
|
} SND_DOOR;
|
|
|
|
|
|
|
|
#define SND_DOOR_A2B 0x00000000 // Door leads from A to B
|
|
|
|
#define SND_DOOR_B2A 0x00000001 // Door leads from B to A
|
|
|
|
|
|
|
|
#define SND_DOOR_DEFAULT SND_DOOR_A2B
|
|
|
|
|
|
|
|
typedef struct SND_LISTENER {
|
|
|
|
struct SND_LISTENER* next;
|
|
|
|
struct SND_LISTENER* prev;
|
|
|
|
SND_ROOM* room;
|
|
|
|
|
|
|
|
u32 flags;
|
|
|
|
SND_FVECTOR pos;
|
|
|
|
f32 volPosOff; // (reserved for future use)
|
|
|
|
SND_FVECTOR dir; // Speed in units/second
|
|
|
|
SND_FVECTOR heading;
|
|
|
|
SND_FVECTOR right;
|
|
|
|
SND_FVECTOR up;
|
|
|
|
SND_FMATRIX mat;
|
|
|
|
f32 surroundDisFront;
|
|
|
|
f32 surroundDisBack;
|
|
|
|
f32 soundSpeed;
|
|
|
|
f32 vol;
|
|
|
|
} SND_LISTENER;
|
|
|
|
|
|
|
|
#define SND_LISTENER_DEFAULT 0x00000000 // No special features are activated
|
|
|
|
#define SND_LISTENER_DOPPLERFX \
|
|
|
|
0x00000001 // Listener is supposed to be moving fast enough to display Dopller effects
|
|
|
|
|
|
|
|
typedef struct SND_EMITTER {
|
|
|
|
struct SND_EMITTER* next;
|
|
|
|
struct SND_EMITTER* prev;
|
|
|
|
SND_ROOM* room;
|
|
|
|
|
|
|
|
SND_PARAMETER_INFO* paraInfo;
|
|
|
|
|
|
|
|
u32 flags;
|
|
|
|
SND_FVECTOR pos;
|
|
|
|
SND_FVECTOR dir; // Speed in units/second
|
|
|
|
f32 maxDis;
|
|
|
|
f32 maxVol;
|
|
|
|
f32 minVol;
|
|
|
|
f32 volPush; // -1.0f = 1/square -> 0.0 = linear -> 1.0 = square
|
|
|
|
SND_VOICEID vid;
|
|
|
|
u32 group; // Group ID (by default FXID | 0x80000000) used to do volume priorities for continous
|
|
|
|
// emitters
|
|
|
|
SND_FXID fxid;
|
|
|
|
|
|
|
|
u8 studio;
|
|
|
|
|
|
|
|
u8 maxVoices; // Max. voices of the assigned FX
|
|
|
|
|
|
|
|
u16 VolLevelCnt; // Used during continous emitter allocation process
|
|
|
|
f32 fade; // Used to fade-in of continous emitters
|
|
|
|
|
|
|
|
} SND_EMITTER;
|
|
|
|
|
|
|
|
#define SND_EMITTER_DEFAULTKEY 0xFF
|
|
|
|
#define SND_EMITTER_DEFAULTVOL 0xFF
|
|
|
|
|
|
|
|
#define SND_EMITTER_DEFAULT 0x00000000 // No special features are activated
|
|
|
|
#define SND_EMITTER_CONTINOUS \
|
|
|
|
0x00000001 // Parameters should be updated over time (they will be set just once if not set)
|
|
|
|
#define SND_EMITTER_CONTINUOUS \
|
|
|
|
0x00000001 // Parameters should be updated over time (they will be set just once if not set)
|
|
|
|
#define SND_EMITTER_RESTARTABLE \
|
|
|
|
0x00000002 // If the used voice is reallocated, the sound should be restarted as soon as possible
|
|
|
|
#define SND_EMITTER_PAUSABLE \
|
|
|
|
0x00000004 // The sound may be stopped if it is no longer audible (and restarted if the above flag
|
|
|
|
// is set as soon as it's audibel again)
|
|
|
|
#define SND_EMITTER_DOPPLERFX \
|
|
|
|
0x00000008 // Emitter is supposed to be moving fast enough to display Doppler effects
|
|
|
|
#define SND_EMITTER_ITD \
|
|
|
|
0x00000010 // Enable ITD per default. The macro controlling the voice may still overwrite this
|
|
|
|
// setting
|
|
|
|
#define SND_EMITTER_HARDSTART \
|
|
|
|
0x00000020 // By default continous emitters are quickly faded in at startup to avoid pop sounds at
|
|
|
|
// restart. This disables this behavior
|
|
|
|
#define SND_EMITTER_NOSILENTSTART \
|
|
|
|
0x00000040 // Do not start emitter if the volume would be zero (it will be removed from the active
|
|
|
|
// list in this case)
|
|
|
|
|
|
|
|
//
|
|
|
|
// Setup / Change logical rooms
|
|
|
|
//
|
|
|
|
void sndSetup3DStudios(u8 first, u8 num);
|
|
|
|
|
|
|
|
bool sndAddRoom(SND_ROOM* room, SND_FVECTOR* pos, void (*activateReverb)(u8 studio, void* para),
|
|
|
|
void (*deActivateReverb)(u8 studio));
|
|
|
|
bool sndRemoveRoom(SND_ROOM* room);
|
|
|
|
bool sndUpdateRoom(SND_ROOM* room, SND_FVECTOR* pos);
|
|
|
|
|
|
|
|
bool sndAddDoor(SND_DOOR* door, SND_ROOM* a, SND_ROOM* b, SND_FVECTOR* pos, f32 dampen, f32 open,
|
|
|
|
u8 fxVol, s16 filterCoef[4], u32 flags);
|
|
|
|
bool sndRemoveDoor(SND_DOOR* door);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Functions to add emitters to logical rooms
|
|
|
|
//
|
|
|
|
SND_VOICEID sndAddEmitter(SND_EMITTER* em, SND_FVECTOR* pos, SND_FVECTOR* dir, f32 maxDis, f32 comp,
|
|
|
|
u32 flags, SND_FXID fxid, u8 maxVol, u8 minVol, SND_ROOM* room);
|
|
|
|
SND_VOICEID sndAddEmitterEx(SND_EMITTER* em_buffer, SND_FVECTOR* pos, SND_FVECTOR* dir, f32 maxDis,
|
|
|
|
f32 comp, u32 flags, SND_FXID fxid, u16 groupid, u8 maxVol, u8 minVol,
|
|
|
|
SND_ROOM* room);
|
|
|
|
SND_VOICEID sndAddEmitterPara(SND_EMITTER* em, SND_FVECTOR* pos, SND_FVECTOR* dir, f32 maxDis,
|
|
|
|
f32 comp, u32 flags, SND_FXID fxid, u8 maxVol, u8 minVol,
|
|
|
|
SND_ROOM* room, SND_PARAMETER_INFO* para);
|
|
|
|
SND_VOICEID sndAddEmitterParaEx(SND_EMITTER* em_buffer, SND_FVECTOR* pos, SND_FVECTOR* dir,
|
|
|
|
f32 maxDis, f32 comp, u32 flags, SND_FXID fxid, u16 groupid,
|
|
|
|
u8 maxVol, u8 minVol, SND_ROOM* room, SND_PARAMETER_INFO* para);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Listener related functions
|
|
|
|
//
|
|
|
|
bool sndAddListener(SND_LISTENER* li, SND_FVECTOR* pos, SND_FVECTOR* dir, SND_FVECTOR* heading,
|
|
|
|
SND_FVECTOR* up, f32 front_sur, f32 back_sur, f32 soundSpeed, u32 flags, u8 vol,
|
|
|
|
SND_ROOM* room);
|
|
|
|
bool sndAddListenerEx(SND_LISTENER* li, SND_FVECTOR* pos, SND_FVECTOR* dir, SND_FVECTOR* heading,
|
|
|
|
SND_FVECTOR* up, f32 front_sur, f32 back_sur, f32 soundSpeed,
|
|
|
|
f32 volPosOffset, u32 flags, u8 vol, SND_ROOM* room);
|
|
|
|
bool sndUpdateListener(SND_LISTENER* li, SND_FVECTOR* pos, SND_FVECTOR* dir, SND_FVECTOR* heading,
|
|
|
|
SND_FVECTOR* up, u8 vol, SND_ROOM* room);
|
|
|
|
bool sndRemoveListener(SND_LISTENER* li);
|
|
|
|
//
|
|
|
|
// Functions to add emitters directly to a studio
|
|
|
|
//
|
|
|
|
SND_VOICEID sndAddEmitter2Studio(SND_EMITTER* em, SND_FVECTOR* pos, SND_FVECTOR* dir, f32 maxDis,
|
|
|
|
f32 comp, u32 flags, SND_FXID fxid, u8 maxVol, u8 minVol,
|
|
|
|
u8 studio);
|
|
|
|
SND_VOICEID sndAddEmitter2StudioEx(SND_EMITTER* em_buffer, SND_FVECTOR* pos, SND_FVECTOR* dir,
|
|
|
|
f32 maxDis, f32 comp, u32 flags, SND_FXID fxid, u16 groupid,
|
|
|
|
u8 maxVol, u8 minVol, u8 studio);
|
|
|
|
SND_VOICEID sndAddEmitter2StudioPara(SND_EMITTER* em, SND_FVECTOR* pos, SND_FVECTOR* dir,
|
|
|
|
f32 maxDis, f32 comp, u32 flags, SND_FXID fxid, u8 maxVol,
|
|
|
|
u8 minVol, u8 studio, SND_PARAMETER_INFO* para);
|
|
|
|
SND_VOICEID sndAddEmitter2StudioParaEx(SND_EMITTER* em_buffer, SND_FVECTOR* pos, SND_FVECTOR* dir,
|
|
|
|
f32 maxDis, f32 comp, u32 flags, SND_FXID fxid, u16 groupid,
|
|
|
|
u8 maxVol, u8 minVol, u8 studio, SND_PARAMETER_INFO* para);
|
|
|
|
//
|
|
|
|
// Maintain emitters
|
|
|
|
//
|
|
|
|
bool sndUpdateEmitter(SND_EMITTER* em, SND_FVECTOR* pos, SND_FVECTOR* dir, u8 maxVol,
|
|
|
|
SND_ROOM* room);
|
|
|
|
|
|
|
|
bool sndRemoveEmitter(SND_EMITTER* em);
|
|
|
|
|
|
|
|
//
|
|
|
|
// Misc. 3D functions
|
|
|
|
//
|
|
|
|
bool sndCheckEmitter(SND_EMITTER* em);
|
|
|
|
SND_VOICEID sndEmitterVoiceID(SND_EMITTER* em);
|
2023-03-30 02:27:34 +00:00
|
|
|
|
2023-06-23 07:31:12 +00:00
|
|
|
typedef struct SND_3DINFO {
|
|
|
|
u8 vol;
|
|
|
|
u8 pan;
|
|
|
|
u8 span;
|
|
|
|
u16 doppler;
|
|
|
|
} SND_3DINFO;
|
|
|
|
|
|
|
|
void sndGet3DParameters(SND_3DINFO* info, SND_FVECTOR* pos, SND_FVECTOR* dir, f32 maxDis, f32 comp,
|
|
|
|
u8 maxVol, u8 minVol, SND_ROOM* room);
|
|
|
|
|
2023-12-19 02:28:24 +00:00
|
|
|
// ------------------------- Debug Functions -----------------------
|
2023-06-29 23:12:29 +00:00
|
|
|
|
2023-12-19 02:28:24 +00:00
|
|
|
u8 sndDbgGetActiveVoices(void);
|
|
|
|
void* sndConvert32BitSDIRTo64BitSDIR(void* sdir_int);
|
2023-06-29 23:12:29 +00:00
|
|
|
|
2022-04-08 08:30:31 +00:00
|
|
|
#ifdef __cplusplus
|
|
|
|
}
|
|
|
|
#endif
|
2022-10-09 05:13:17 +00:00
|
|
|
#endif // _MUSYX_MUSYX
|