private EqualizerBand(FMOD.System system, DSP dspParamEq, float centerValue, float gainValue, bool active) { this.fmodSystem = system; this.dspEQ = dspParamEq; if (centerValue >= 1000) { this.BandCaption = string.Format("{0}K", (centerValue / 1000)); } else { this.BandCaption = centerValue.ToString(CultureInfo.InvariantCulture); } this.WhenAnyValue(x => x.Gain) .Subscribe(newGain => { if (this.IsActive && this.dspEQ != null) { System.Diagnostics.Debug.WriteLine(">> Gain value: " + newGain); this.dspEQ.setActive(false).ERRCHECK(); this.dspEQ.setParameterFloat((int)FMOD.DSP_PARAMEQ.GAIN, newGain).ERRCHECK(); this.dspEQ.setActive(true).ERRCHECK(); this.fmodSystem.update().ERRCHECK(); } }); this.Gain = gainValue; this.IsActive = active; }
public static DSP FromFmod(FMOD.DSP dsp) { if (dsp == null) { throw new ArgumentNullException(nameof(dsp)); } return(new DSP(dsp)); }
public RESULT createDSPByPlugin(uint handle, out DSP dsp) { dsp = null; IntPtr raw; RESULT result = System.FMOD5_System_CreateDSPByPlugin(this.rawPtr, handle, out raw); dsp = new DSP(raw); return result; }
public RESULT createDSP(ref DSP_DESCRIPTION description, out DSP dsp) { dsp = null; IntPtr raw; RESULT result = System.FMOD5_System_CreateDSP(this.rawPtr, ref description, out raw); dsp = new DSP(raw); return result; }
public RESULT addInput(DSP target, out DSPConnection connection, DSPCONNECTION_TYPE type) { connection = null; IntPtr raw; RESULT result = DSP.FMOD5_DSP_AddInput(this.rawPtr, target.getRaw(), out raw, type); connection = new DSPConnection(raw); return result; }
public RESULT createDSPByType(DSP_TYPE type, out DSP dsp) { dsp = null; IntPtr raw; RESULT result = System.FMOD5_System_CreateDSPByType(this.rawPtr, type, out raw); dsp = new DSP(raw); return result; }
public void Remove() { if (this.dspEQ != null) { var result = this.dspEQ.remove(); result.ERRCHECK(); this.dspEQ = null; } this.IsActive = false; }
public RESULT getInput(int index, out DSP input, out DSPConnection inputconnection) { input = null; inputconnection = null; IntPtr raw; IntPtr raw2; RESULT result = DSP.FMOD5_DSP_GetInput(this.rawPtr, index, out raw, out raw2); input = new DSP(raw); inputconnection = new DSPConnection(raw2); return result; }
public static EqualizerBand GetEqualizerBand(FMOD.System system, bool isActive, float centerValue, float bandwithValue, float gainValue) { FMOD.DSP dspParamEq = null; if (isActive) { if (!system.createDSPByType(FMOD.DSP_TYPE.PARAMEQ, out dspParamEq).ERRCHECK()) { return(null); } FMOD.ChannelGroup masterChannelGroup; if (!system.getMasterChannelGroup(out masterChannelGroup).ERRCHECK()) { return(null); } int numDSPs; if (!masterChannelGroup.getNumDSPs(out numDSPs).ERRCHECK()) { return(null); } if (!masterChannelGroup.addDSP(numDSPs, dspParamEq).ERRCHECK()) { return(null); } if (!dspParamEq.setParameterFloat((int)FMOD.DSP_PARAMEQ.CENTER, centerValue).ERRCHECK()) { return(null); } if (!dspParamEq.setParameterFloat((int)FMOD.DSP_PARAMEQ.BANDWIDTH, bandwithValue).ERRCHECK()) { return(null); } if (!dspParamEq.setParameterFloat((int)FMOD.DSP_PARAMEQ.GAIN, gainValue).ERRCHECK()) { return(null); } if (!dspParamEq.setActive(true).ERRCHECK()) { return(null); } } var band = new EqualizerBand(system, dspParamEq, centerValue, gainValue, isActive); return(band); }
private EqualizerBand(DSP dspParamEq, float centerValue, float gainValue, bool active) { this.dspEQ = dspParamEq; if (centerValue >= 1000) { this.BandCaption = string.Format("{0}K", (centerValue / 1000)); } else { this.BandCaption = centerValue.ToString(CultureInfo.InvariantCulture); } this.gain = gainValue; this.IsActive = active; }
public RESULT getParameterInfo(int index, out DSP_PARAMETER_DESC desc) { IntPtr ptr; RESULT rESULT = DSP.FMOD5_DSP_GetParameterInfo(this.rawPtr, index, out ptr); if (rESULT == RESULT.OK) { desc = (DSP_PARAMETER_DESC)Marshal.PtrToStructure(ptr, typeof(DSP_PARAMETER_DESC)); } else { desc = default(DSP_PARAMETER_DESC); } return(rESULT); }
// Initializes and returns the FMOD GVR Listener Plugin. private static FMOD.DSP Initialize() { // Search through all busses on in banks. int numBanks = 0; FMOD.DSP dsp = new FMOD.DSP(); FMOD.Studio.Bank[] banks = null; RuntimeManager.StudioSystem.getBankCount(out numBanks); RuntimeManager.StudioSystem.getBankList(out banks); for (int currentBank = 0; currentBank < numBanks; ++currentBank) { int numBusses = 0; FMOD.Studio.Bus[] busses = null; banks[currentBank].getBusCount(out numBusses); banks[currentBank].getBusList(out busses); RuntimeManager.StudioSystem.flushCommands(); for (int currentBus = 0; currentBus < numBusses; ++currentBus) { // Make sure the channel group of the current bus is assigned properly. string busPath = null; busses[currentBus].getPath(out busPath); RuntimeManager.StudioSystem.getBus(busPath, out busses[currentBus]); RuntimeManager.StudioSystem.flushCommands(); FMOD.ChannelGroup channelGroup; busses[currentBus].getChannelGroup(out channelGroup); RuntimeManager.StudioSystem.flushCommands(); if (channelGroup.hasHandle()) { int numDsps = 0; channelGroup.getNumDSPs(out numDsps); for (int currentDsp = 0; currentDsp < numDsps; ++currentDsp) { channelGroup.getDSP(currentDsp, out dsp); string dspNameSb; int unusedInt = 0; uint unusedUint = 0; dsp.getInfo(out dspNameSb, out unusedUint, out unusedInt, out unusedInt, out unusedInt); if (dspNameSb.ToString().Equals(listenerPluginName) && dsp.hasHandle()) { return(dsp); } } } } } // Debug.LogError(listenerPluginName + " not found in the FMOD project."); return(dsp); }
public static EqualizerBand GetEqualizerBand(FMOD.System system, bool isActive, float centerValue, float bandwithValue, float gainValue) { FMOD.DSPConnection dspConnTemp = null; FMOD.DSP dspParamEq = null; if (isActive) { var result = system.createDSPByType(FMOD.DSP_TYPE.PARAMEQ, ref dspParamEq); if (!result.ERRCHECK()) { return(null); } result = system.addDSP(dspParamEq, ref dspConnTemp); if (!result.ERRCHECK()) { return(null); } result = dspParamEq.setParameter((int)FMOD.DSP_PARAMEQ.CENTER, centerValue); if (!result.ERRCHECK()) { return(null); } result = dspParamEq.setParameter((int)FMOD.DSP_PARAMEQ.BANDWIDTH, bandwithValue); if (!result.ERRCHECK()) { return(null); } result = dspParamEq.setParameter((int)FMOD.DSP_PARAMEQ.GAIN, gainValue); if (!result.ERRCHECK()) { return(null); } result = dspParamEq.setActive(true); if (!result.ERRCHECK()) { return(null); } } var band = new EqualizerBand(dspParamEq, centerValue, gainValue, isActive); return(band); }
public RESULT getOutput(int index, ref DSP output, ref DSPConnection outputconnection) { RESULT rESULT = RESULT.OK; IntPtr raw = IntPtr.Zero; IntPtr raw2 = IntPtr.Zero; try { rESULT = DSP.FMOD_DSP_GetOutput(dspraw, index, ref raw, ref raw2); } catch { rESULT = RESULT.ERR_INVALID_PARAM; } RESULT result; if (rESULT != RESULT.OK) { result = rESULT; } else { if (output == null) { DSP dSP = new DSP(); dSP.setRaw(raw); output = dSP; } else { output.setRaw(raw); } if (outputconnection == null) { DSPConnection dSPConnection = new DSPConnection(); dSPConnection.setRaw(raw2); outputconnection = dSPConnection; } else { outputconnection.setRaw(raw2); } result = rESULT; } return(result); }
public void Release() { if (this.dspEQ != null) { this.dspEQ.setActive(false).ERRCHECK(); FMOD.ChannelGroup masterChannelGroup = null; this.fmodSystem.getMasterChannelGroup(out masterChannelGroup).ERRCHECK(); masterChannelGroup.removeDSP(this.dspEQ).ERRCHECK(); this.dspEQ.release().ERRCHECK(); this.dspEQ = null; this.fmodSystem = null; } this.IsActive = false; }
public float getRmsLevel(int index) { FMOD.DSP dsp = dsps[index]; FMOD.DSP_METERING_INFO outputMetering; dsp.getMeteringInfo(IntPtr.Zero, out outputMetering); float rms = 0; for (int i = 0; i < outputMetering.numchannels; i++) { rms += outputMetering.rmslevel[i] * outputMetering.rmslevel[i]; } rms = Mathf.Sqrt(rms / (float)outputMetering.numchannels); float db = rms > 0 ? 20.0f * Mathf.Log10(rms * Mathf.Sqrt(2.0f)) : -80.0f; if (db > 10.0f) { db = 10.0f; } return(customMap(index, db)); }
unsafe public static FMOD.RESULT ReadAudioData(ref FMOD.DSP_STATE dspState, IntPtr inbuffer, IntPtr outbuffer, uint length, int inchannels, ref int outchannels) { FMOD.DSP dspInstance = new FMOD.DSP(dspState.instance); float *inb = (float *)inbuffer.ToPointer(); float *outb = (float *)outbuffer.ToPointer(); IntPtr userData; // NOTE: Without this check, Unity crashes! if (dspInstance.getUserData(out userData) == FMOD.RESULT.OK) { float *userBuffer = (float *)userData.ToPointer(); // TODO: See if there is a better way to do this. // Just copy back. for (uint samp = 0; samp < length; samp++) { /* * Feel free to unroll this. */ // TODO: There are at least 2 channels, what do we do? // Do we save the maximum, the average? userBuffer[samp] = inb[(samp * inchannels)]; for (int chan = 0; chan < outchannels; chan++) { long outIdx = (samp * outchannels) + chan; long inIdx = (samp * inchannels) + chan; float value = inb[inIdx]; outb[outIdx] = value; } } } return(FMOD.RESULT.OK); }
public RESULT getOutput (int index, out DSP output, out DSPConnection outputconnection) { output = null; outputconnection = null; IntPtr dspoutputraw; IntPtr dspconnectionraw; RESULT result = FMOD_DSP_GetOutput(rawPtr, index, out dspoutputraw, out dspconnectionraw); output = new DSP(dspoutputraw); outputconnection = new DSPConnection(dspconnectionraw); return result; }
public RESULT getDSPIndex(DSP dsp, out int index) { return FMOD_ChannelGroup_GetDSPIndex(rawPtr, dsp.getRaw(), out index); }
// Connection / disconnection / input and output enumeration. public RESULT addInput(DSP target, out DSPConnection connection) { connection = null; IntPtr dspconnectionraw; RESULT result = FMOD_DSP_AddInput(rawPtr, target.getRaw(), out dspconnectionraw); connection = new DSPConnection(dspconnectionraw); return result; }
public RESULT playDSP (DSP dsp, ChannelGroup channelGroup, bool paused, out Channel channel) { channel = null; IntPtr channelGroupRaw = (channelGroup != null) ? channelGroup.getRaw() : IntPtr.Zero; IntPtr channelraw; RESULT result = FMOD_System_PlayDSP(rawPtr, dsp.getRaw(), channelGroupRaw, paused, out channelraw); channel = new Channel(channelraw); return result; }
public RESULT addDSP(int index, DSP dsp) { return FMOD_ChannelGroup_AddDSP(rawPtr, index, dsp.getRaw()); }
public RESULT getOutput(ref DSP output) { RESULT result = RESULT.OK; IntPtr dspraw = new IntPtr(); DSP dspnew = null; try { result = FMOD_DSPConnection_GetOutput(dspconnectionraw, ref dspraw); } catch { result = RESULT.ERR_INVALID_PARAM; } if (result != RESULT.OK) { return result; } if (output == null) { dspnew = new DSP(); dspnew.setRaw(dspraw); output = dspnew; } else { output.setRaw(dspraw); } return result; }
public RESULT setDSPIndex(DSP dsp, int index) { return(FMOD5_ChannelGroup_SetDSPIndex(handle, dsp.handle, index)); }
public RESULT disconnectFrom(DSP target, DSPConnection connection) { return(FMOD5_DSP_DisconnectFrom(handle, target.handle, connection.handle)); }
public RESULT getOutput(int index, out DSP output, out DSPConnection outputconnection) { return(FMOD5_DSP_GetOutput(handle, index, out output.handle, out outputconnection.handle)); }
public RESULT setBypass(bool bypass) { return(DSP.FMOD5_DSP_SetBypass(this.rawPtr, bypass)); }
public RESULT addInput(DSP target, out DSPConnection connection, DSPCONNECTION_TYPE type) { return(FMOD5_DSP_AddInput(handle, target.handle, out connection.handle, type)); }
public RESULT getDSP(int index, out DSP dsp) { return(FMOD5_ChannelGroup_GetDSP(handle, index, out dsp.handle)); }
public RESULT addDSP(int index, DSP dsp) { return(FMOD5_ChannelGroup_AddDSP(handle, index, dsp.handle)); }
public RESULT getDSPIndex(DSP dsp, out int index) { return(FMOD5_ChannelGroup_GetDSPIndex(handle, dsp.handle, out index)); }
public RESULT getDSPHead(ref DSP dsp) { RESULT result = RESULT.OK; IntPtr dspraw = new IntPtr(); DSP dspnew = null; try { result = FMOD_Channel_GetDSPHead(channelraw, ref dspraw); } catch { result = RESULT.ERR_INVALID_PARAM; } if (result != RESULT.OK) { return result; } dspnew = new DSP(); dspnew.setRaw(dspraw); dsp = dspnew; return result; }
public RESULT getActive(out bool active) { return(DSP.FMOD5_DSP_GetActive(this.rawPtr, out active)); }
public RESULT disconnectFrom(DSP target) { return FMOD_DSP_DisconnectFrom(dspraw, target.getRaw()); }
public RESULT setActive(bool active) { return(DSP.FMOD5_DSP_SetActive(this.rawPtr, active)); }
public RESULT createDSP(ref DSP_DESCRIPTION description, ref DSP dsp) { RESULT result = RESULT.OK; IntPtr dspraw = new IntPtr(); DSP dspnew = null; try { result = FMOD_System_CreateDSP(systemraw, ref description, ref dspraw); } catch { result = RESULT.ERR_INVALID_PARAM; } if (result != RESULT.OK) { return result; } if (dsp == null) { dspnew = new DSP(); dspnew.setRaw(dspraw); dsp = dspnew; } else { dsp.setRaw(dspraw); } return result; }
// System level DSP access. public RESULT getDSPHead(ref DSP dsp) { RESULT result = RESULT.OK; IntPtr dspraw = new IntPtr(); DSP dspnew = null; try { result = FMOD_System_GetDSPHead(systemraw, ref dspraw); } catch { result = RESULT.ERR_INVALID_PARAM; } if (result != RESULT.OK) { return result; } if (dsp == null) { dspnew = new DSP(); dspnew.setRaw(dspraw); dsp = dspnew; } else { dsp.setRaw(dspraw); } return result; }
public RESULT createDSPByType (DSP_TYPE type, out DSP dsp) { dsp = null; IntPtr dspraw; RESULT result = FMOD_System_CreateDSPByType(rawPtr, type, out dspraw); dsp = new DSP(dspraw); return result; }
public RESULT getNumOutputs(out int numoutputs) { return(DSP.FMOD5_DSP_GetNumOutputs(this.rawPtr, out numoutputs)); }
// DSP effects. public RESULT getDSP(int index, out DSP dsp) { dsp = null; IntPtr dspraw; RESULT result = FMOD_ChannelGroup_GetDSP(rawPtr, index, out dspraw); dsp = new DSP(dspraw); return result; }
public RESULT disconnectAll(bool inputs, bool outputs) { return(DSP.FMOD5_DSP_DisconnectAll(this.rawPtr, inputs, outputs)); }
public RESULT removeDSP(DSP dsp) { return FMOD_ChannelGroup_RemoveDSP(rawPtr, dsp.getRaw()); }
public RESULT disconnectFrom(DSP target, DSPConnection connection) { return(DSP.FMOD5_DSP_DisconnectFrom(this.rawPtr, target.getRaw(), connection.getRaw())); }
public RESULT overridePanDSP(DSP pan) { return FMOD_ChannelGroup_OverridePanDSP(rawPtr, pan.getRaw()); }
public RESULT getMeteringInfo(DSP_METERING_INFO inputInfo, DSP_METERING_INFO outputInfo) { return(DSP.FMOD5_DSP_GetMeteringInfo(this.rawPtr, inputInfo, outputInfo)); }
public RESULT getInput (int index, out DSP input, out DSPConnection inputconnection) { input = null; inputconnection = null; IntPtr dspinputraw; IntPtr dspconnectionraw; RESULT result = FMOD_DSP_GetInput(rawPtr, index, out dspinputraw, out dspconnectionraw); input = new DSP(dspinputraw); inputconnection = new DSPConnection(dspconnectionraw); return result; }
public RESULT getMeteringEnabled(out bool inputEnabled, out bool outputEnabled) { return(DSP.FMOD5_DSP_GetMeteringEnabled(this.rawPtr, out inputEnabled, out outputEnabled)); }
public RESULT getOutput (out DSP output) { output = null; IntPtr dspraw; RESULT result = FMOD_DSPConnection_GetOutput(rawPtr, out dspraw); output = new DSP(dspraw); return result; }
public RESULT setMeteringEnabled(bool inputEnabled, bool outputEnabled) { return(DSP.FMOD5_DSP_SetMeteringEnabled(this.rawPtr, inputEnabled, outputEnabled)); }
public RESULT addInput(DSP target, ref DSPConnection connection) { RESULT result = RESULT.OK; IntPtr dspconnectionraw = new IntPtr(); DSPConnection dspconnectionnew = null; try { result = FMOD_DSP_AddInput(dspraw, target.getRaw(), ref dspconnectionraw); } catch { result = RESULT.ERR_INVALID_PARAM; } if (result != RESULT.OK) { return result; } if (connection == null) { dspconnectionnew = new DSPConnection(); dspconnectionnew.setRaw(dspconnectionraw); connection = dspconnectionnew; } else { connection.setRaw(dspconnectionraw); } return result; }
public RESULT getInput (out DSP input) { input = null; IntPtr dspraw; RESULT result = FMOD5_DSPConnection_GetInput(rawPtr, out dspraw); input = new DSP(dspraw); return result; }
public RESULT getInput(int index, ref DSP input, ref DSPConnection inputconnection) { RESULT result = RESULT.OK; IntPtr dsprawnew = new IntPtr(); DSP dspnew = null; IntPtr dspconnectionraw = new IntPtr(); DSPConnection dspconnectionnew = null; try { result = FMOD_DSP_GetInput(dspraw, index, ref dsprawnew, ref dspconnectionraw); } catch { result = RESULT.ERR_INVALID_PARAM; } if (result != RESULT.OK) { return result; } if (input == null) { dspnew = new DSP(); dspnew.setRaw(dsprawnew); input = dspnew; } else { input.setRaw(dsprawnew); } if (inputconnection == null) { dspconnectionnew = new DSPConnection(); dspconnectionnew.setRaw(dspconnectionraw); inputconnection = dspconnectionnew; } else { inputconnection.setRaw(dspconnectionraw); } return result; }
public RESULT createDSPByPlugin(uint handle, out DSP dsp) { dsp = null; IntPtr dspraw; RESULT result = FMOD_System_CreateDSPByPlugin(rawPtr, handle, out dspraw); dsp = new DSP(dspraw); return result; }
public RESULT addDSP(DSP dsp, ref DSPConnection connection) { RESULT result = RESULT.OK; IntPtr dspconnectionraw = new IntPtr(); DSPConnection dspconnectionnew = null; try { result = FMOD_System_AddDSP(systemraw, dsp.getRaw(), ref dspconnectionraw); } catch { result = RESULT.ERR_INVALID_PARAM; } if (result != RESULT.OK) { return result; } if (connection == null) { dspconnectionnew = new DSPConnection(); dspconnectionnew.setRaw(dspconnectionraw); connection = dspconnectionnew; } else { connection.setRaw(dspconnectionraw); } return result; }
public RESULT createDSP (ref DSP_DESCRIPTION description, out DSP dsp) { dsp = null; IntPtr dspraw; RESULT result = FMOD_System_CreateDSP(rawPtr, ref description, out dspraw); dsp = new DSP(dspraw); return result; }
public RESULT createDSPByType(DSP_TYPE type, ref DSP dsp) { RESULT result = RESULT.OK; IntPtr dspraw = new IntPtr(); DSP dspnew = null; try { result = FMOD_System_CreateDSPByType(systemraw, type, ref dspraw); } catch { result = RESULT.ERR_INVALID_PARAM; } if (result != RESULT.OK) { return result; } if (dsp == null) { dspnew = new DSP(); dspnew.setRaw(dspraw); dsp = dspnew; } else { dsp.setRaw(dspraw); } return result; }
public RESULT removeDSP(DSP dsp) { return(FMOD5_ChannelGroup_RemoveDSP(handle, dsp.handle)); }
public RESULT playDSP(CHANNELINDEX channelid, DSP dsp, bool paused, ref Channel channel) { RESULT result = RESULT.OK; IntPtr channelraw; Channel channelnew = null; if (channel != null) { channelraw = channel.getRaw(); } else { channelraw = new IntPtr(); } try { result = FMOD_System_PlayDSP(systemraw, channelid, dsp.getRaw(), (paused ? 1 : 0), ref channelraw); } catch { result = RESULT.ERR_INVALID_PARAM; } if (result != RESULT.OK) { return result; } if (channel == null) { channelnew = new Channel(); channelnew.setRaw(channelraw); channel = channelnew; } else { channel.setRaw(channelraw); } return result; }
private DSP(FMOD.DSP dsp) : this() { FmodDsp = dsp; }