Refactor and enhance codebase for maintainability

Refactored and reorganized the codebase to improve readability, performance, and maintainability. Introduced new interfaces and structs for better resource management, updated project configuration files, and refactored shader and graphics pipeline management. Improved error handling, code formatting, and removed unused code and namespaces. Updated DLL references and method signatures for consistency and maintainability.
This commit is contained in:
2025-10-22 18:46:39 +09:00
parent 6d1b510ac1
commit d2d9f5feb7
80 changed files with 2836 additions and 2198 deletions

View File

@@ -10,8 +10,6 @@
/* https://fmod.com/docs/2.03/api/plugin-api-dsp.html */
/* =========================================================================================*/
using System;
using System.Text;
using System.Runtime.InteropServices;
namespace Ghost.FMOD.Core
@@ -19,11 +17,11 @@ namespace Ghost.FMOD.Core
[StructLayout(LayoutKind.Sequential)]
public struct DSP_BUFFER_ARRAY
{
public int numbuffers;
public IntPtr buffernumchannels;
public IntPtr bufferchannelmask;
public IntPtr buffers;
public SPEAKERMODE speakermode;
public int numbuffers;
public IntPtr buffernumchannels;
public IntPtr bufferchannelmask;
public IntPtr buffers;
public SPEAKERMODE speakermode;
/*
These properties take advantage of the fact that numbuffers is always zero or one
@@ -31,7 +29,7 @@ namespace Ghost.FMOD.Core
public int numchannels
{
get
get
{
if (buffernumchannels != IntPtr.Zero && numbuffers != 0)
return Marshal.ReadInt32(buffernumchannels);
@@ -85,47 +83,47 @@ namespace Ghost.FMOD.Core
/*
DSP callbacks
*/
public delegate RESULT DSP_CREATE_CALLBACK (ref DSP_STATE dsp_state);
public delegate RESULT DSP_RELEASE_CALLBACK (ref DSP_STATE dsp_state);
public delegate RESULT DSP_RESET_CALLBACK (ref DSP_STATE dsp_state);
public delegate RESULT DSP_SETPOSITION_CALLBACK (ref DSP_STATE dsp_state, uint pos);
public delegate RESULT DSP_READ_CALLBACK (ref DSP_STATE dsp_state, IntPtr inbuffer, IntPtr outbuffer, uint length, int inchannels, ref int outchannels);
public delegate RESULT DSP_SHOULDIPROCESS_CALLBACK (ref DSP_STATE dsp_state, bool inputsidle, uint length, CHANNELMASK inmask, int inchannels, SPEAKERMODE speakermode);
public delegate RESULT DSP_PROCESS_CALLBACK (ref DSP_STATE dsp_state, uint length, ref DSP_BUFFER_ARRAY inbufferarray, ref DSP_BUFFER_ARRAY outbufferarray, bool inputsidle, DSP_PROCESS_OPERATION op);
public delegate RESULT DSP_SETPARAM_FLOAT_CALLBACK (ref DSP_STATE dsp_state, int index, float value);
public delegate RESULT DSP_SETPARAM_INT_CALLBACK (ref DSP_STATE dsp_state, int index, int value);
public delegate RESULT DSP_SETPARAM_BOOL_CALLBACK (ref DSP_STATE dsp_state, int index, bool value);
public delegate RESULT DSP_SETPARAM_DATA_CALLBACK (ref DSP_STATE dsp_state, int index, IntPtr data, uint length);
public delegate RESULT DSP_GETPARAM_FLOAT_CALLBACK (ref DSP_STATE dsp_state, int index, ref float value, IntPtr valuestr);
public delegate RESULT DSP_GETPARAM_INT_CALLBACK (ref DSP_STATE dsp_state, int index, ref int value, IntPtr valuestr);
public delegate RESULT DSP_GETPARAM_BOOL_CALLBACK (ref DSP_STATE dsp_state, int index, ref bool value, IntPtr valuestr);
public delegate RESULT DSP_GETPARAM_DATA_CALLBACK (ref DSP_STATE dsp_state, int index, ref IntPtr data, ref uint length, IntPtr valuestr);
public delegate RESULT DSP_SYSTEM_REGISTER_CALLBACK (ref DSP_STATE dsp_state);
public delegate RESULT DSP_SYSTEM_DEREGISTER_CALLBACK (ref DSP_STATE dsp_state);
public delegate RESULT DSP_SYSTEM_MIX_CALLBACK (ref DSP_STATE dsp_state, int stage);
public delegate RESULT DSP_CREATE_CALLBACK(ref DSP_STATE dsp_state);
public delegate RESULT DSP_RELEASE_CALLBACK(ref DSP_STATE dsp_state);
public delegate RESULT DSP_RESET_CALLBACK(ref DSP_STATE dsp_state);
public delegate RESULT DSP_SETPOSITION_CALLBACK(ref DSP_STATE dsp_state, uint pos);
public delegate RESULT DSP_READ_CALLBACK(ref DSP_STATE dsp_state, IntPtr inbuffer, IntPtr outbuffer, uint length, int inchannels, ref int outchannels);
public delegate RESULT DSP_SHOULDIPROCESS_CALLBACK(ref DSP_STATE dsp_state, bool inputsidle, uint length, CHANNELMASK inmask, int inchannels, SPEAKERMODE speakermode);
public delegate RESULT DSP_PROCESS_CALLBACK(ref DSP_STATE dsp_state, uint length, ref DSP_BUFFER_ARRAY inbufferarray, ref DSP_BUFFER_ARRAY outbufferarray, bool inputsidle, DSP_PROCESS_OPERATION op);
public delegate RESULT DSP_SETPARAM_FLOAT_CALLBACK(ref DSP_STATE dsp_state, int index, float value);
public delegate RESULT DSP_SETPARAM_INT_CALLBACK(ref DSP_STATE dsp_state, int index, int value);
public delegate RESULT DSP_SETPARAM_BOOL_CALLBACK(ref DSP_STATE dsp_state, int index, bool value);
public delegate RESULT DSP_SETPARAM_DATA_CALLBACK(ref DSP_STATE dsp_state, int index, IntPtr data, uint length);
public delegate RESULT DSP_GETPARAM_FLOAT_CALLBACK(ref DSP_STATE dsp_state, int index, ref float value, IntPtr valuestr);
public delegate RESULT DSP_GETPARAM_INT_CALLBACK(ref DSP_STATE dsp_state, int index, ref int value, IntPtr valuestr);
public delegate RESULT DSP_GETPARAM_BOOL_CALLBACK(ref DSP_STATE dsp_state, int index, ref bool value, IntPtr valuestr);
public delegate RESULT DSP_GETPARAM_DATA_CALLBACK(ref DSP_STATE dsp_state, int index, ref IntPtr data, ref uint length, IntPtr valuestr);
public delegate RESULT DSP_SYSTEM_REGISTER_CALLBACK(ref DSP_STATE dsp_state);
public delegate RESULT DSP_SYSTEM_DEREGISTER_CALLBACK(ref DSP_STATE dsp_state);
public delegate RESULT DSP_SYSTEM_MIX_CALLBACK(ref DSP_STATE dsp_state, int stage);
/*
DSP functions
*/
public delegate IntPtr DSP_ALLOC_FUNC (uint size, MEMORY_TYPE type, IntPtr sourcestr);
public delegate IntPtr DSP_REALLOC_FUNC (IntPtr ptr, uint size, MEMORY_TYPE type, IntPtr sourcestr);
public delegate void DSP_FREE_FUNC (IntPtr ptr, MEMORY_TYPE type, IntPtr sourcestr);
public delegate void DSP_LOG_FUNC (DEBUG_FLAGS level, IntPtr file, int line, IntPtr function, IntPtr str);
public delegate RESULT DSP_GETSAMPLERATE_FUNC (ref DSP_STATE dsp_state, ref int rate);
public delegate RESULT DSP_GETBLOCKSIZE_FUNC (ref DSP_STATE dsp_state, ref uint blocksize);
public delegate RESULT DSP_GETSPEAKERMODE_FUNC (ref DSP_STATE dsp_state, ref int speakermode_mixer, ref int speakermode_output);
public delegate RESULT DSP_GETCLOCK_FUNC (ref DSP_STATE dsp_state, out ulong clock, out uint offset, out uint length);
public delegate RESULT DSP_GETLISTENERATTRIBUTES_FUNC (ref DSP_STATE dsp_state, ref int numlisteners, IntPtr attributes);
public delegate RESULT DSP_GETUSERDATA_FUNC (ref DSP_STATE dsp_state, out IntPtr userdata);
public delegate RESULT DSP_DFT_FFTREAL_FUNC (ref DSP_STATE dsp_state, int size, IntPtr signal, IntPtr dft, IntPtr window, int signalhop);
public delegate RESULT DSP_DFT_IFFTREAL_FUNC (ref DSP_STATE dsp_state, int size, IntPtr dft, IntPtr signal, IntPtr window, int signalhop);
public delegate RESULT DSP_PAN_SUMMONOMATRIX_FUNC (ref DSP_STATE dsp_state, int sourceSpeakerMode, float lowFrequencyGain, float overallGain, IntPtr matrix);
public delegate RESULT DSP_PAN_SUMSTEREOMATRIX_FUNC (ref DSP_STATE dsp_state, int sourceSpeakerMode, float pan, float lowFrequencyGain, float overallGain, int matrixHop, IntPtr matrix);
public delegate RESULT DSP_PAN_SUMSURROUNDMATRIX_FUNC (ref DSP_STATE dsp_state, int sourceSpeakerMode, int targetSpeakerMode, float direction, float extent, float rotation, float lowFrequencyGain, float overallGain, int matrixHop, IntPtr matrix, DSP_PAN_SURROUND_FLAGS flags);
public delegate RESULT DSP_PAN_SUMMONOTOSURROUNDMATRIX_FUNC (ref DSP_STATE dsp_state, int targetSpeakerMode, float direction, float extent, float lowFrequencyGain, float overallGain, int matrixHop, IntPtr matrix);
public delegate RESULT DSP_PAN_SUMSTEREOTOSURROUNDMATRIX_FUNC (ref DSP_STATE dsp_state, int targetSpeakerMode, float direction, float extent, float rotation, float lowFrequencyGain, float overallGain, int matrixHop, IntPtr matrix);
public delegate RESULT DSP_PAN_GETROLLOFFGAIN_FUNC (ref DSP_STATE dsp_state, DSP_PAN_3D_ROLLOFF_TYPE rolloff, float distance, float mindistance, float maxdistance, out float gain);
public delegate IntPtr DSP_ALLOC_FUNC(uint size, MEMORY_TYPE type, IntPtr sourcestr);
public delegate IntPtr DSP_REALLOC_FUNC(IntPtr ptr, uint size, MEMORY_TYPE type, IntPtr sourcestr);
public delegate void DSP_FREE_FUNC(IntPtr ptr, MEMORY_TYPE type, IntPtr sourcestr);
public delegate void DSP_LOG_FUNC(DEBUG_FLAGS level, IntPtr file, int line, IntPtr function, IntPtr str);
public delegate RESULT DSP_GETSAMPLERATE_FUNC(ref DSP_STATE dsp_state, ref int rate);
public delegate RESULT DSP_GETBLOCKSIZE_FUNC(ref DSP_STATE dsp_state, ref uint blocksize);
public delegate RESULT DSP_GETSPEAKERMODE_FUNC(ref DSP_STATE dsp_state, ref int speakermode_mixer, ref int speakermode_output);
public delegate RESULT DSP_GETCLOCK_FUNC(ref DSP_STATE dsp_state, out ulong clock, out uint offset, out uint length);
public delegate RESULT DSP_GETLISTENERATTRIBUTES_FUNC(ref DSP_STATE dsp_state, ref int numlisteners, IntPtr attributes);
public delegate RESULT DSP_GETUSERDATA_FUNC(ref DSP_STATE dsp_state, out IntPtr userdata);
public delegate RESULT DSP_DFT_FFTREAL_FUNC(ref DSP_STATE dsp_state, int size, IntPtr signal, IntPtr dft, IntPtr window, int signalhop);
public delegate RESULT DSP_DFT_IFFTREAL_FUNC(ref DSP_STATE dsp_state, int size, IntPtr dft, IntPtr signal, IntPtr window, int signalhop);
public delegate RESULT DSP_PAN_SUMMONOMATRIX_FUNC(ref DSP_STATE dsp_state, int sourceSpeakerMode, float lowFrequencyGain, float overallGain, IntPtr matrix);
public delegate RESULT DSP_PAN_SUMSTEREOMATRIX_FUNC(ref DSP_STATE dsp_state, int sourceSpeakerMode, float pan, float lowFrequencyGain, float overallGain, int matrixHop, IntPtr matrix);
public delegate RESULT DSP_PAN_SUMSURROUNDMATRIX_FUNC(ref DSP_STATE dsp_state, int sourceSpeakerMode, int targetSpeakerMode, float direction, float extent, float rotation, float lowFrequencyGain, float overallGain, int matrixHop, IntPtr matrix, DSP_PAN_SURROUND_FLAGS flags);
public delegate RESULT DSP_PAN_SUMMONOTOSURROUNDMATRIX_FUNC(ref DSP_STATE dsp_state, int targetSpeakerMode, float direction, float extent, float lowFrequencyGain, float overallGain, int matrixHop, IntPtr matrix);
public delegate RESULT DSP_PAN_SUMSTEREOTOSURROUNDMATRIX_FUNC(ref DSP_STATE dsp_state, int targetSpeakerMode, float direction, float extent, float rotation, float lowFrequencyGain, float overallGain, int matrixHop, IntPtr matrix);
public delegate RESULT DSP_PAN_GETROLLOFFGAIN_FUNC(ref DSP_STATE dsp_state, DSP_PAN_3D_ROLLOFF_TYPE rolloff, float distance, float mindistance, float maxdistance, out float gain);
public enum DSP_TYPE : int
@@ -202,71 +200,71 @@ namespace Ghost.FMOD.Core
[StructLayout(LayoutKind.Sequential)]
public struct DSP_PARAMETER_DESC_FLOAT
{
public float min;
public float max;
public float defaultval;
public float min;
public float max;
public float defaultval;
public DSP_PARAMETER_FLOAT_MAPPING mapping;
}
[StructLayout(LayoutKind.Sequential)]
public struct DSP_PARAMETER_DESC_INT
{
public int min;
public int max;
public int defaultval;
public bool goestoinf;
public IntPtr valuenames;
public int min;
public int max;
public int defaultval;
public bool goestoinf;
public IntPtr valuenames;
}
[StructLayout(LayoutKind.Sequential)]
public struct DSP_PARAMETER_DESC_BOOL
{
public bool defaultval;
public IntPtr valuenames;
public bool defaultval;
public IntPtr valuenames;
}
[StructLayout(LayoutKind.Sequential)]
public struct DSP_PARAMETER_DESC_DATA
{
public int datatype;
public int datatype;
}
[StructLayout(LayoutKind.Explicit)]
public struct DSP_PARAMETER_DESC_UNION
{
[FieldOffset(0)]
public DSP_PARAMETER_DESC_FLOAT floatdesc;
public DSP_PARAMETER_DESC_FLOAT floatdesc;
[FieldOffset(0)]
public DSP_PARAMETER_DESC_INT intdesc;
public DSP_PARAMETER_DESC_INT intdesc;
[FieldOffset(0)]
public DSP_PARAMETER_DESC_BOOL booldesc;
public DSP_PARAMETER_DESC_BOOL booldesc;
[FieldOffset(0)]
public DSP_PARAMETER_DESC_DATA datadesc;
public DSP_PARAMETER_DESC_DATA datadesc;
}
[StructLayout(LayoutKind.Sequential)]
public struct DSP_PARAMETER_DESC
{
public DSP_PARAMETER_TYPE type;
public DSP_PARAMETER_TYPE type;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
public byte[] name;
public byte[] name;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 16)]
public byte[] label;
public string description;
public byte[] label;
public string description;
public DSP_PARAMETER_DESC_UNION desc;
}
public enum DSP_PARAMETER_DATA_TYPE
{
DSP_PARAMETER_DATA_TYPE_USER = 0,
DSP_PARAMETER_DATA_TYPE_OVERALLGAIN = -1,
DSP_PARAMETER_DATA_TYPE_3DATTRIBUTES = -2,
DSP_PARAMETER_DATA_TYPE_SIDECHAIN = -3,
DSP_PARAMETER_DATA_TYPE_FFT = -4,
DSP_PARAMETER_DATA_TYPE_3DATTRIBUTES_MULTI = -5,
DSP_PARAMETER_DATA_TYPE_ATTENUATION_RANGE = -6,
DSP_PARAMETER_DATA_TYPE_DYNAMIC_RESPONSE = -7
DSP_PARAMETER_DATA_TYPE_USER = 0,
DSP_PARAMETER_DATA_TYPE_OVERALLGAIN = -1,
DSP_PARAMETER_DATA_TYPE_3DATTRIBUTES = -2,
DSP_PARAMETER_DATA_TYPE_SIDECHAIN = -3,
DSP_PARAMETER_DATA_TYPE_FFT = -4,
DSP_PARAMETER_DATA_TYPE_3DATTRIBUTES_MULTI = -5,
DSP_PARAMETER_DATA_TYPE_ATTENUATION_RANGE = -6,
DSP_PARAMETER_DATA_TYPE_DYNAMIC_RESPONSE = -7
}
[StructLayout(LayoutKind.Sequential)]
@@ -275,38 +273,38 @@ namespace Ghost.FMOD.Core
public float linear_gain;
public float linear_gain_additive;
}
[StructLayout(LayoutKind.Sequential)]
public struct DSP_PARAMETER_3DATTRIBUTES
{
public ATTRIBUTES_3D relative;
public ATTRIBUTES_3D absolute;
}
[StructLayout(LayoutKind.Sequential)]
public struct DSP_PARAMETER_3DATTRIBUTES_MULTI
{
public int numlisteners;
public int numlisteners;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public ATTRIBUTES_3D[] relative;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 8)]
public float[] weight;
public ATTRIBUTES_3D absolute;
}
[StructLayout(LayoutKind.Sequential)]
public struct DSP_PARAMETER_SIDECHAIN
{
public int sidechainenable;
}
[StructLayout(LayoutKind.Sequential)]
public struct DSP_PARAMETER_FFT
{
public int length;
public int numchannels;
[MarshalAs(UnmanagedType.ByValArray,SizeConst=32)]
public int length;
public int numchannels;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
private IntPtr[] spectrum_internal;
public float[][] spectrum
@@ -314,21 +312,21 @@ namespace Ghost.FMOD.Core
get
{
var buffer = new float[numchannels][];
for (int i = 0; i < numchannels; ++i)
for (var i = 0; i < numchannels; ++i)
{
buffer[i] = new float[length];
Marshal.Copy(spectrum_internal[i], buffer[i], 0, length);
}
return buffer;
}
}
public void getSpectrum(ref float[][] buffer)
{
int bufferLength = Math.Min(buffer.Length, numchannels);
for (int i = 0; i < bufferLength; ++i)
var bufferLength = Math.Min(buffer.Length, numchannels);
for (var i = 0; i < bufferLength; ++i)
{
getSpectrum(i, ref buffer[i]);
}
@@ -336,7 +334,7 @@ namespace Ghost.FMOD.Core
public void getSpectrum(int channel, ref float[] buffer)
{
int bufferLength = Math.Min(buffer.Length, length);
var bufferLength = Math.Min(buffer.Length, length);
Marshal.Copy(spectrum_internal[channel], buffer, 0, bufferLength);
}
}
@@ -380,105 +378,114 @@ namespace Ghost.FMOD.Core
[StructLayout(LayoutKind.Sequential)]
public struct DSP_DESCRIPTION
{
public uint pluginsdkversion;
public uint pluginsdkversion;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
public byte[] name;
public uint version;
public int numinputbuffers;
public int numoutputbuffers;
public DSP_CREATE_CALLBACK create;
public DSP_RELEASE_CALLBACK release;
public DSP_RESET_CALLBACK reset;
public DSP_READ_CALLBACK read;
public DSP_PROCESS_CALLBACK process;
public DSP_SETPOSITION_CALLBACK setposition;
public byte[] name;
public uint version;
public int numinputbuffers;
public int numoutputbuffers;
public DSP_CREATE_CALLBACK create;
public DSP_RELEASE_CALLBACK release;
public DSP_RESET_CALLBACK reset;
public DSP_READ_CALLBACK read;
public DSP_PROCESS_CALLBACK process;
public DSP_SETPOSITION_CALLBACK setposition;
public int numparameters;
public IntPtr paramdesc;
public DSP_SETPARAM_FLOAT_CALLBACK setparameterfloat;
public DSP_SETPARAM_INT_CALLBACK setparameterint;
public DSP_SETPARAM_BOOL_CALLBACK setparameterbool;
public DSP_SETPARAM_DATA_CALLBACK setparameterdata;
public DSP_GETPARAM_FLOAT_CALLBACK getparameterfloat;
public DSP_GETPARAM_INT_CALLBACK getparameterint;
public DSP_GETPARAM_BOOL_CALLBACK getparameterbool;
public DSP_GETPARAM_DATA_CALLBACK getparameterdata;
public DSP_SHOULDIPROCESS_CALLBACK shouldiprocess;
public IntPtr userdata;
public int numparameters;
public IntPtr paramdesc;
public DSP_SETPARAM_FLOAT_CALLBACK setparameterfloat;
public DSP_SETPARAM_INT_CALLBACK setparameterint;
public DSP_SETPARAM_BOOL_CALLBACK setparameterbool;
public DSP_SETPARAM_DATA_CALLBACK setparameterdata;
public DSP_GETPARAM_FLOAT_CALLBACK getparameterfloat;
public DSP_GETPARAM_INT_CALLBACK getparameterint;
public DSP_GETPARAM_BOOL_CALLBACK getparameterbool;
public DSP_GETPARAM_DATA_CALLBACK getparameterdata;
public DSP_SHOULDIPROCESS_CALLBACK shouldiprocess;
public IntPtr userdata;
public DSP_SYSTEM_REGISTER_CALLBACK sys_register;
public DSP_SYSTEM_REGISTER_CALLBACK sys_register;
public DSP_SYSTEM_DEREGISTER_CALLBACK sys_deregister;
public DSP_SYSTEM_MIX_CALLBACK sys_mix;
public DSP_SYSTEM_MIX_CALLBACK sys_mix;
}
[StructLayout(LayoutKind.Sequential)]
public struct DSP_STATE_DFT_FUNCTIONS
{
public DSP_DFT_FFTREAL_FUNC fftreal;
public DSP_DFT_FFTREAL_FUNC fftreal;
public DSP_DFT_IFFTREAL_FUNC inversefftreal;
}
[StructLayout(LayoutKind.Sequential)]
public struct DSP_STATE_PAN_FUNCTIONS
{
public DSP_PAN_SUMMONOMATRIX_FUNC summonomatrix;
public DSP_PAN_SUMSTEREOMATRIX_FUNC sumstereomatrix;
public DSP_PAN_SUMSURROUNDMATRIX_FUNC sumsurroundmatrix;
public DSP_PAN_SUMMONOTOSURROUNDMATRIX_FUNC summonotosurroundmatrix;
public DSP_PAN_SUMMONOMATRIX_FUNC summonomatrix;
public DSP_PAN_SUMSTEREOMATRIX_FUNC sumstereomatrix;
public DSP_PAN_SUMSURROUNDMATRIX_FUNC sumsurroundmatrix;
public DSP_PAN_SUMMONOTOSURROUNDMATRIX_FUNC summonotosurroundmatrix;
public DSP_PAN_SUMSTEREOTOSURROUNDMATRIX_FUNC sumstereotosurroundmatrix;
public DSP_PAN_GETROLLOFFGAIN_FUNC getrolloffgain;
public DSP_PAN_GETROLLOFFGAIN_FUNC getrolloffgain;
}
[StructLayout(LayoutKind.Sequential)]
public struct DSP_STATE_FUNCTIONS
{
public DSP_ALLOC_FUNC alloc;
public DSP_REALLOC_FUNC realloc;
public DSP_FREE_FUNC free;
public DSP_GETSAMPLERATE_FUNC getsamplerate;
public DSP_GETBLOCKSIZE_FUNC getblocksize;
public IntPtr dft_internal;
public IntPtr pan_internal;
public DSP_GETSPEAKERMODE_FUNC getspeakermode;
public DSP_GETCLOCK_FUNC getclock;
public DSP_GETLISTENERATTRIBUTES_FUNC getlistenerattributes;
public DSP_LOG_FUNC log;
public DSP_GETUSERDATA_FUNC getuserdata;
public DSP_ALLOC_FUNC alloc;
public DSP_REALLOC_FUNC realloc;
public DSP_FREE_FUNC free;
public DSP_GETSAMPLERATE_FUNC getsamplerate;
public DSP_GETBLOCKSIZE_FUNC getblocksize;
public IntPtr dft_internal;
public IntPtr pan_internal;
public DSP_GETSPEAKERMODE_FUNC getspeakermode;
public DSP_GETCLOCK_FUNC getclock;
public DSP_GETLISTENERATTRIBUTES_FUNC getlistenerattributes;
public DSP_LOG_FUNC log;
public DSP_GETUSERDATA_FUNC getuserdata;
public DSP_STATE_DFT_FUNCTIONS dft
{
get { return Marshal.PtrToStructure<DSP_STATE_DFT_FUNCTIONS>(dft_internal); }
get
{
return Marshal.PtrToStructure<DSP_STATE_DFT_FUNCTIONS>(dft_internal);
}
}
public DSP_STATE_PAN_FUNCTIONS pan
{
get { return Marshal.PtrToStructure<DSP_STATE_PAN_FUNCTIONS>(pan_internal); }
get
{
return Marshal.PtrToStructure<DSP_STATE_PAN_FUNCTIONS>(pan_internal);
}
}
}
[StructLayout(LayoutKind.Sequential)]
public struct DSP_STATE
{
public IntPtr instance;
public IntPtr plugindata;
public uint channelmask;
public int source_speakermode;
public IntPtr sidechaindata;
public int sidechainchannels;
private IntPtr functions_internal;
public int systemobject;
public IntPtr instance;
public IntPtr plugindata;
public uint channelmask;
public int source_speakermode;
public IntPtr sidechaindata;
public int sidechainchannels;
private IntPtr functions_internal;
public int systemobject;
public DSP_STATE_FUNCTIONS functions
{
get { return Marshal.PtrToStructure<DSP_STATE_FUNCTIONS>(functions_internal); }
get
{
return Marshal.PtrToStructure<DSP_STATE_FUNCTIONS>(functions_internal);
}
}
}
[StructLayout(LayoutKind.Sequential)]
public struct DSP_METERING_INFO
{
public int numsamples;
[MarshalAs(UnmanagedType.ByValArray, SizeConst=32)]
public int numsamples;
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
public float[] peaklevel;
[MarshalAs(UnmanagedType.ByValArray, SizeConst=32)]
[MarshalAs(UnmanagedType.ByValArray, SizeConst = 32)]
public float[] rmslevel;
public short numchannels;
}

View File

@@ -17,89 +17,172 @@ namespace Ghost.FMOD.Core
{
switch (errcode)
{
case RESULT.OK: return "No errors.";
case RESULT.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 RESULT.ERR_CHANNEL_ALLOC: return "Error trying to allocate a channel.";
case RESULT.ERR_CHANNEL_STOLEN: return "The specified channel has been reused to play another sound.";
case RESULT.ERR_DMA: return "DMA Failure. See debug output for more information.";
case RESULT.ERR_DSP_CONNECTION: return "DSP connection error. Connection possibly caused a cyclic dependency or connected dsps with incompatible buffer counts.";
case RESULT.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 RESULT.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 RESULT.ERR_DSP_INUSE: return "DSP is already in the mixer's DSP network. It must be removed before being reinserted or released.";
case RESULT.ERR_DSP_NOTFOUND: return "DSP connection error. Couldn't find the DSP unit specified.";
case RESULT.ERR_DSP_RESERVED: return "DSP operation error. Cannot perform operation on this DSP as it is reserved by the system.";
case RESULT.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 RESULT.ERR_DSP_TYPE: return "DSP operation cannot be performed on a DSP of this type.";
case RESULT.ERR_FILE_BAD: return "Error loading file.";
case RESULT.ERR_FILE_COULDNOTSEEK: return "Couldn't perform seek operation. This is a limitation of the medium (ie netstreams) or the file format.";
case RESULT.ERR_FILE_DISKEJECTED: return "Media was ejected while reading.";
case RESULT.ERR_FILE_EOF: return "End of file unexpectedly reached while trying to read essential data (truncated?).";
case RESULT.ERR_FILE_ENDOFDATA: return "End of current chunk reached while trying to read data.";
case RESULT.ERR_FILE_NOTFOUND: return "File not found.";
case RESULT.ERR_FORMAT: return "Unsupported file or audio format.";
case RESULT.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 RESULT.ERR_HTTP: return "A HTTP error occurred. This is a catch-all for HTTP errors not listed elsewhere.";
case RESULT.ERR_HTTP_ACCESS: return "The specified resource requires authentication or is forbidden.";
case RESULT.ERR_HTTP_PROXY_AUTH: return "Proxy authentication is required to access the specified resource.";
case RESULT.ERR_HTTP_SERVER_ERROR: return "A HTTP server error occurred.";
case RESULT.ERR_HTTP_TIMEOUT: return "The HTTP request timed out.";
case RESULT.ERR_INITIALIZATION: return "FMOD was not initialized correctly to support this function.";
case RESULT.ERR_INITIALIZED: return "Cannot call this command after System::init.";
case RESULT.ERR_INTERNAL: return "An error occured in the FMOD system. Use the logging version of FMOD for more information.";
case RESULT.ERR_INVALID_FLOAT: return "Value passed in was a NaN, Inf or denormalized float.";
case RESULT.ERR_INVALID_HANDLE: return "An invalid object handle was used.";
case RESULT.ERR_INVALID_PARAM: return "An invalid parameter was passed to this function.";
case RESULT.ERR_INVALID_POSITION: return "An invalid seek position was passed to this function.";
case RESULT.ERR_INVALID_SPEAKER: return "An invalid speaker was passed to this function based on the current speaker mode.";
case RESULT.ERR_INVALID_SYNCPOINT: return "The syncpoint did not come from this sound handle.";
case RESULT.ERR_INVALID_THREAD: return "Tried to call a function on a thread that is not supported.";
case RESULT.ERR_INVALID_VECTOR: return "The vectors passed in are not unit length, or perpendicular.";
case RESULT.ERR_MAXAUDIBLE: return "Reached maximum audible playback count for this sound's soundgroup.";
case RESULT.ERR_MEMORY: return "Not enough memory or resources.";
case RESULT.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 RESULT.ERR_NEEDS3D: return "Tried to call a command on a 2d sound when the command was meant for 3d sound.";
case RESULT.ERR_NEEDSHARDWARE: return "Tried to use a feature that requires hardware support.";
case RESULT.ERR_NET_CONNECT: return "Couldn't connect to the specified host.";
case RESULT.ERR_NET_SOCKET_ERROR: return "A socket error occurred. This is a catch-all for socket-related errors not listed elsewhere.";
case RESULT.ERR_NET_URL: return "The specified URL couldn't be resolved.";
case RESULT.ERR_NET_WOULD_BLOCK: return "Operation on a non-blocking socket could not complete immediately.";
case RESULT.ERR_NOTREADY: return "Operation could not be performed because specified sound/DSP connection is not ready.";
case RESULT.ERR_OUTPUT_ALLOCATED: return "Error initializing output device, but more specifically, the output device is already in use and cannot be reused.";
case RESULT.ERR_OUTPUT_CREATEBUFFER: return "Error creating hardware sound buffer.";
case RESULT.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 RESULT.ERR_OUTPUT_FORMAT: return "Soundcard does not support the specified format.";
case RESULT.ERR_OUTPUT_INIT: return "Error initializing output device.";
case RESULT.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 RESULT.ERR_PLUGIN: return "An unspecified error has been returned from a plugin.";
case RESULT.ERR_PLUGIN_MISSING: return "A requested output, dsp unit type or codec was not available.";
case RESULT.ERR_PLUGIN_RESOURCE: return "A resource that the plugin requires cannot be allocated or found. (ie the DLS file for MIDI playback)";
case RESULT.ERR_PLUGIN_VERSION: return "A plugin was built with an unsupported SDK version.";
case RESULT.ERR_RECORD: return "An error occurred trying to initialize the recording device.";
case RESULT.ERR_REVERB_CHANNELGROUP: return "Reverb properties cannot be set on this channel because a parent channelgroup owns the reverb connection.";
case RESULT.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 RESULT.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 RESULT.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 RESULT.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 RESULT.ERR_TAGNOTFOUND: return "The specified tag could not be found or there are no tags.";
case RESULT.ERR_TOOMANYCHANNELS: return "The sound created exceeds the allowable input channel count. This can be increased using the 'maxinputchannels' parameter in System::setSoftwareFormat.";
case RESULT.ERR_TRUNCATED: return "The retrieved string is too long to fit in the supplied buffer and has been truncated.";
case RESULT.ERR_UNIMPLEMENTED: return "Something in FMOD hasn't been implemented when it should be. Contact support.";
case RESULT.ERR_UNINITIALIZED: return "This command failed because System::init or System::setDriver was not called.";
case RESULT.ERR_UNSUPPORTED: return "A command issued was not supported by this object. Possibly a plugin without certain callbacks specified.";
case RESULT.ERR_VERSION: return "The version number of this file format is not supported.";
case RESULT.ERR_EVENT_ALREADY_LOADED: return "The specified bank has already been loaded.";
case RESULT.ERR_EVENT_LIVEUPDATE_BUSY: return "The live update connection failed due to the game already being connected.";
case RESULT.ERR_EVENT_LIVEUPDATE_MISMATCH: return "The live update connection failed due to the game data being out of sync with the tool.";
case RESULT.ERR_EVENT_LIVEUPDATE_TIMEOUT: return "The live update connection timed out.";
case RESULT.ERR_EVENT_NOTFOUND: return "The requested event, bus or vca could not be found.";
case RESULT.ERR_STUDIO_UNINITIALIZED: return "The Studio::System object is not yet initialized.";
case RESULT.ERR_STUDIO_NOT_LOADED: return "The specified resource is not loaded, so it can't be unloaded.";
case RESULT.ERR_INVALID_STRING: return "An invalid string was passed to this function.";
case RESULT.ERR_ALREADY_LOCKED: return "The specified resource is already locked.";
case RESULT.ERR_NOT_LOCKED: return "The specified resource is not locked, so it can't be unlocked.";
case RESULT.ERR_RECORD_DISCONNECTED: return "The specified recording driver has been disconnected.";
case RESULT.ERR_TOOMANYSAMPLES: return "The length provided exceed the allowable limit.";
default: return "Unknown error.";
case RESULT.OK:
return "No errors.";
case RESULT.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 RESULT.ERR_CHANNEL_ALLOC:
return "Error trying to allocate a channel.";
case RESULT.ERR_CHANNEL_STOLEN:
return "The specified channel has been reused to play another sound.";
case RESULT.ERR_DMA:
return "DMA Failure. See debug output for more information.";
case RESULT.ERR_DSP_CONNECTION:
return "DSP connection error. Connection possibly caused a cyclic dependency or connected dsps with incompatible buffer counts.";
case RESULT.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 RESULT.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 RESULT.ERR_DSP_INUSE:
return "DSP is already in the mixer's DSP network. It must be removed before being reinserted or released.";
case RESULT.ERR_DSP_NOTFOUND:
return "DSP connection error. Couldn't find the DSP unit specified.";
case RESULT.ERR_DSP_RESERVED:
return "DSP operation error. Cannot perform operation on this DSP as it is reserved by the system.";
case RESULT.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 RESULT.ERR_DSP_TYPE:
return "DSP operation cannot be performed on a DSP of this type.";
case RESULT.ERR_FILE_BAD:
return "Error loading file.";
case RESULT.ERR_FILE_COULDNOTSEEK:
return "Couldn't perform seek operation. This is a limitation of the medium (ie netstreams) or the file format.";
case RESULT.ERR_FILE_DISKEJECTED:
return "Media was ejected while reading.";
case RESULT.ERR_FILE_EOF:
return "End of file unexpectedly reached while trying to read essential data (truncated?).";
case RESULT.ERR_FILE_ENDOFDATA:
return "End of current chunk reached while trying to read data.";
case RESULT.ERR_FILE_NOTFOUND:
return "File not found.";
case RESULT.ERR_FORMAT:
return "Unsupported file or audio format.";
case RESULT.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 RESULT.ERR_HTTP:
return "A HTTP error occurred. This is a catch-all for HTTP errors not listed elsewhere.";
case RESULT.ERR_HTTP_ACCESS:
return "The specified resource requires authentication or is forbidden.";
case RESULT.ERR_HTTP_PROXY_AUTH:
return "Proxy authentication is required to access the specified resource.";
case RESULT.ERR_HTTP_SERVER_ERROR:
return "A HTTP server error occurred.";
case RESULT.ERR_HTTP_TIMEOUT:
return "The HTTP request timed out.";
case RESULT.ERR_INITIALIZATION:
return "FMOD was not initialized correctly to support this function.";
case RESULT.ERR_INITIALIZED:
return "Cannot call this command after System::init.";
case RESULT.ERR_INTERNAL:
return "An error occured in the FMOD system. Use the logging version of FMOD for more information.";
case RESULT.ERR_INVALID_FLOAT:
return "Value passed in was a NaN, Inf or denormalized float.";
case RESULT.ERR_INVALID_HANDLE:
return "An invalid object handle was used.";
case RESULT.ERR_INVALID_PARAM:
return "An invalid parameter was passed to this function.";
case RESULT.ERR_INVALID_POSITION:
return "An invalid seek position was passed to this function.";
case RESULT.ERR_INVALID_SPEAKER:
return "An invalid speaker was passed to this function based on the current speaker mode.";
case RESULT.ERR_INVALID_SYNCPOINT:
return "The syncpoint did not come from this sound handle.";
case RESULT.ERR_INVALID_THREAD:
return "Tried to call a function on a thread that is not supported.";
case RESULT.ERR_INVALID_VECTOR:
return "The vectors passed in are not unit length, or perpendicular.";
case RESULT.ERR_MAXAUDIBLE:
return "Reached maximum audible playback count for this sound's soundgroup.";
case RESULT.ERR_MEMORY:
return "Not enough memory or resources.";
case RESULT.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 RESULT.ERR_NEEDS3D:
return "Tried to call a command on a 2d sound when the command was meant for 3d sound.";
case RESULT.ERR_NEEDSHARDWARE:
return "Tried to use a feature that requires hardware support.";
case RESULT.ERR_NET_CONNECT:
return "Couldn't connect to the specified host.";
case RESULT.ERR_NET_SOCKET_ERROR:
return "A socket error occurred. This is a catch-all for socket-related errors not listed elsewhere.";
case RESULT.ERR_NET_URL:
return "The specified URL couldn't be resolved.";
case RESULT.ERR_NET_WOULD_BLOCK:
return "Operation on a non-blocking socket could not complete immediately.";
case RESULT.ERR_NOTREADY:
return "Operation could not be performed because specified sound/DSP connection is not ready.";
case RESULT.ERR_OUTPUT_ALLOCATED:
return "Error initializing output device, but more specifically, the output device is already in use and cannot be reused.";
case RESULT.ERR_OUTPUT_CREATEBUFFER:
return "Error creating hardware sound buffer.";
case RESULT.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 RESULT.ERR_OUTPUT_FORMAT:
return "Soundcard does not support the specified format.";
case RESULT.ERR_OUTPUT_INIT:
return "Error initializing output device.";
case RESULT.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 RESULT.ERR_PLUGIN:
return "An unspecified error has been returned from a plugin.";
case RESULT.ERR_PLUGIN_MISSING:
return "A requested output, dsp unit type or codec was not available.";
case RESULT.ERR_PLUGIN_RESOURCE:
return "A resource that the plugin requires cannot be allocated or found. (ie the DLS file for MIDI playback)";
case RESULT.ERR_PLUGIN_VERSION:
return "A plugin was built with an unsupported SDK version.";
case RESULT.ERR_RECORD:
return "An error occurred trying to initialize the recording device.";
case RESULT.ERR_REVERB_CHANNELGROUP:
return "Reverb properties cannot be set on this channel because a parent channelgroup owns the reverb connection.";
case RESULT.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 RESULT.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 RESULT.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 RESULT.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 RESULT.ERR_TAGNOTFOUND:
return "The specified tag could not be found or there are no tags.";
case RESULT.ERR_TOOMANYCHANNELS:
return "The sound created exceeds the allowable input channel count. This can be increased using the 'maxinputchannels' parameter in System::setSoftwareFormat.";
case RESULT.ERR_TRUNCATED:
return "The retrieved string is too long to fit in the supplied buffer and has been truncated.";
case RESULT.ERR_UNIMPLEMENTED:
return "Something in FMOD hasn't been implemented when it should be. Contact support.";
case RESULT.ERR_UNINITIALIZED:
return "This command failed because System::init or System::setDriver was not called.";
case RESULT.ERR_UNSUPPORTED:
return "A command issued was not supported by this object. Possibly a plugin without certain callbacks specified.";
case RESULT.ERR_VERSION:
return "The version number of this file format is not supported.";
case RESULT.ERR_EVENT_ALREADY_LOADED:
return "The specified bank has already been loaded.";
case RESULT.ERR_EVENT_LIVEUPDATE_BUSY:
return "The live update connection failed due to the game already being connected.";
case RESULT.ERR_EVENT_LIVEUPDATE_MISMATCH:
return "The live update connection failed due to the game data being out of sync with the tool.";
case RESULT.ERR_EVENT_LIVEUPDATE_TIMEOUT:
return "The live update connection timed out.";
case RESULT.ERR_EVENT_NOTFOUND:
return "The requested event, bus or vca could not be found.";
case RESULT.ERR_STUDIO_UNINITIALIZED:
return "The Studio::System object is not yet initialized.";
case RESULT.ERR_STUDIO_NOT_LOADED:
return "The specified resource is not loaded, so it can't be unloaded.";
case RESULT.ERR_INVALID_STRING:
return "An invalid string was passed to this function.";
case RESULT.ERR_ALREADY_LOCKED:
return "The specified resource is already locked.";
case RESULT.ERR_NOT_LOCKED:
return "The specified resource is not locked, so it can't be unlocked.";
case RESULT.ERR_RECORD_DISCONNECTED:
return "The specified recording driver has been disconnected.";
case RESULT.ERR_TOOMANYSAMPLES:
return "The length provided exceed the allowable limit.";
default:
return "Unknown error.";
}
}
}