public static FMOD.Studio.EventDescription GetEventDescription(string idString) { FMOD.Studio.EventDescription desc = null; if (!events.TryGetValue(idString, out desc)) { if (sFMODSystem == null) { if (!LoadAllBanks()) { return(null); } } FMOD.GUID id = new FMOD.GUID(); if (!ERRCHECK(FMOD.Studio.Util.ParseID(idString, out id))) { return(null); } FMOD.RESULT res = FMODEditorExtension.sFMODSystem.getEvent(id, FMOD.Studio.LOADING_MODE.BEGIN_NOW, out desc); if (res == FMOD.RESULT.ERR_EVENT_NOTFOUND || desc == null || !desc.isValid() || !ERRCHECK(res)) { return(null); } events[idString] = desc; } return(desc); }
public List <KeyValuePair <FMOD.GUID, string> > GetDeviceList() { List <KeyValuePair <FMOD.GUID, string> > result = new List <KeyValuePair <FMOD.GUID, string> >(); int numdrivers = 0; system.getNumDrivers(ref numdrivers); for (int i = 0; i < numdrivers; i++) { StringBuilder namebuilder = new StringBuilder(200); FMOD.GUID guid = new FMOD.GUID(); system.getDriverInfo(i, namebuilder, namebuilder.Capacity, ref guid); result.Add(new KeyValuePair <FMOD.GUID, string>(guid, namebuilder.ToString())); } return(result); }
public FMOD.Studio.EventInstance getEvent(string path) { FMOD.Studio.EventInstance instance = null; if (string.IsNullOrEmpty(path)) { Debug.LogError("Empty event path!"); return(null); } if (eventDescriptions.ContainsKey(path)) { ERRCHECK(eventDescriptions[path].createInstance(out instance)); } else { FMOD.GUID id = new FMOD.GUID(); if (path.StartsWith("{")) { ERRCHECK(FMOD.Studio.Util.ParseID(path, out id)); } else if (path.StartsWith("/")) { ERRCHECK(system.lookupEventID(path, out id)); } else { Debug.LogError("Expected event path to start with '/'"); } FMOD.Studio.EventDescription desc = null; ERRCHECK(system.getEvent(id, FMOD.Studio.LOADING_MODE.BEGIN_NOW, out desc)); eventDescriptions.Add(path, desc); ERRCHECK(desc.createInstance(out instance)); } // Debug.Log("get event: " + (instance != null ? "suceeded!!" : "failed!!")); //PAS return(instance); }
public static FMOD.Studio.EventDescription GetEventDescription(string idString) { FMOD.Studio.EventDescription desc = null; if (!events.TryGetValue(idString, out desc)) { if (sFMODSystem == null) { LoadAllBanks(); } FMOD.GUID id = new FMOD.GUID(); ERRCHECK(FMOD.Studio.Util.ParseID(idString, out id)); FMOD.RESULT res = FMODEditorExtension.sFMODSystem.getEvent(id, FMOD.Studio.LOADING_MODE.BEGIN_NOW, out desc); if (res == FMOD.RESULT.OK && desc != null && desc.isValid()) { events[idString] = desc; } } return(desc); }
/// <summary> /// Gets the event description. /// </summary> /// <param name="path">The path.</param> /// <returns></returns> public FMOD.Studio.EventDescription GetEventDescription(string path) { EventDescription eventDescription; if (eventDescriptions.ContainsKey(path)) { eventDescription = eventDescriptions[path]; } else { FMOD.GUID id = new FMOD.GUID(); if (path.StartsWith("{")) { Logger.ErrorCheck(FMOD.Studio.Util.ParseID(path, out id)); } else if (path.StartsWith("event:")) { Logger.ErrorCheck(system.LookupID(path, out id)); } else { Logger.LogError("Expected event path to start with 'event:/'"); } Logger.ErrorCheck(system.GetEvent(id, FMOD.Studio.LoadingMode.BeginNow, out eventDescription)); if (eventDescription != null && eventDescription.IsValid()) { eventDescriptions.Add(path, eventDescription); } else { Logger.LogError("Could not get event " + id + " for " + path); } } return(eventDescription); }
//This function is called by the loadSystem function. It sets up FMOD for the rest of //the program, like an "init" of sorts. Most of this code is boilerplate that is used in //every FMOD application. private FMOD.System fmodSetup() { FMOD.System t_system = new FMOD.System(); FMOD.RESULT result = new FMOD.RESULT(); uint version = 0; int numDrivers = 0; FMOD.SPEAKERMODE speakerMode = FMOD.SPEAKERMODE.STEREO; FMOD.CAPS caps = FMOD.CAPS.NONE; StringBuilder name = null; // Create FMOD interface object result = FMOD.Factory.System_Create(ref t_system); FMODErrorCheck(result); // Check version result = t_system.getVersion(ref version); FMODErrorCheck(result); if (version < FMOD.VERSION.number) { Console.WriteLine("Error! You are using an old version of FMOD " + version + ". This program requires " + FMOD.VERSION.number); return null; } //Check Sound Cards, if none, disable sound result = t_system.getNumDrivers(ref numDrivers); FMODErrorCheck(result); if (numDrivers == 0) { result = t_system.setOutput(FMOD.OUTPUTTYPE.NOSOUND); FMODErrorCheck(result); } // At least one sound card else { // Get the capabilities of the default (0) sound card result = t_system.getDriverCaps(0, ref caps, ref zero, ref speakerMode); FMODErrorCheck(result); // Set the speaker mode to match that in Control Panel result = t_system.setSpeakerMode(speakerMode); FMODErrorCheck(result); // Increase buffer size if user has Acceleration slider set to off if (FMOD.CAPS.HARDWARE_EMULATED.Equals(true)) { result = t_system.setDSPBufferSize(1024, 10); FMODErrorCheck(result); } // Get name of driver FMOD.GUID temp = new FMOD.GUID(); result = t_system.getDriverInfo(0, name, 256, ref temp); FMODErrorCheck(result); } System.IntPtr temp2 = new System.IntPtr(); // Initialise FMOD result = t_system.init(100, FMOD.INITFLAGS.NORMAL, temp2); // If the selected speaker mode isn't supported by this sound card, switch it back to stereo if (result == FMOD.RESULT.ERR_OUTPUT_CREATEBUFFER) { result = t_system.setSpeakerMode(FMOD.SPEAKERMODE.STEREO); FMODErrorCheck(result); result = t_system.init(100, FMOD.INITFLAGS.NORMAL, temp2); } FMODErrorCheck(result); return t_system; }
private static extern RESULT FMOD_EventSystem_GetEventByGUID(IntPtr eventsystem, ref GUID guid, EVENT_MODE mode, ref IntPtr _event);
public RESULT getEventByGUID(ref GUID guid, EVENT_MODE mode, ref Event _event) { RESULT result = RESULT.OK; IntPtr eventraw = new IntPtr(); Event eventnew = null; try { result = FMOD_EventSystem_GetEventByGUID(eventsystemraw, ref guid, mode, ref eventraw); } catch { result = RESULT.ERR_INVALID_PARAM; } if (result != RESULT.OK) { return result; } if (_event == null) { eventnew = new Event(); eventnew.setRaw(eventraw); _event = eventnew; } else { _event.setRaw(eventraw); } return result; }
public void Initialize(FMOD.Event e, FmodEventGroup eventGroup, int indexInGroup, FmodEventAsset asset) { #if UNITY_EDITOR FMOD.EVENT_INFO info = new FMOD.EVENT_INFO(); FMOD.GUID guid = new FMOD.GUID(); FMOD.EventParameter param = null; FMOD.RESULT result = FMOD.RESULT.OK; FmodEventParameter toAdd = null; IntPtr name = new IntPtr(0); int numParameters = 0; int index = 0; Initialize(eventGroup, indexInGroup, asset); int size = System.Runtime.InteropServices.Marshal.SizeOf(typeof(FMOD.GUID)); info.guid = System.Runtime.InteropServices.Marshal.AllocHGlobal(size); result = e.getInfo(ref index, ref name, ref info); ERRCHECK(result); m_name = System.Runtime.InteropServices.Marshal.PtrToStringAnsi(name); this.name = m_name; guid = (FMOD.GUID)System.Runtime.InteropServices.Marshal.PtrToStructure(info.guid, typeof(FMOD.GUID)); m_guidString = "{" + String.Format("{0:x8}-{1:x4}-{2:x4}-{3:x2}{4:x2}-{5:x2}{6:x2}{7:x2}{8:x2}{9:x2}{10:x2}", guid.Data1, guid.Data2, guid.Data3, guid.Data4[0], guid.Data4[1], guid.Data4[2], guid.Data4[3], guid.Data4[4], guid.Data4[5], guid.Data4[6], guid.Data4[7] ) + "}"; int mode = 0; IntPtr modePtr = System.Runtime.InteropServices.Marshal.AllocHGlobal(sizeof(int)); e.getPropertyByIndex((int)FMOD.EVENTPROPERTY.MODE, modePtr, false); mode = System.Runtime.InteropServices.Marshal.ReadInt32(modePtr); System.Runtime.InteropServices.Marshal.FreeHGlobal(modePtr); m_sourceType = (SourceType)mode; if (m_sourceType == SourceType.SOURCE_3D) { IntPtr range; float[] tmp = new float[1]; int[] tmpInt = new int[1]; range = System.Runtime.InteropServices.Marshal.AllocHGlobal(sizeof(int)); result = e.getPropertyByIndex((int)FMOD.EVENTPROPERTY._3D_ROLLOFF, range, false); ERRCHECK(result); System.Runtime.InteropServices.Marshal.Copy(range, tmpInt, 0, 1); if (tmpInt[0] == (int)FMOD.MODE._3D_CUSTOMROLLOFF) { m_rolloffType = RolloffType.CUSTOM; } else if (tmpInt[0] == (int)FMOD.MODE._3D_INVERSEROLLOFF) { m_rolloffType = RolloffType.INVERSE; } else if (tmpInt[0] == (int)FMOD.MODE._3D_LINEARROLLOFF) { m_rolloffType = RolloffType.LINEAR; } else if (tmpInt[0] == (int)FMOD.MODE._3D_LINEARSQUAREROLLOFF) { m_rolloffType = RolloffType.LINEARSQUARE; } else if (tmpInt[0] == (int)FMOD.MODE._3D_LOGROLLOFF) { m_rolloffType = RolloffType.LOGARITHMIC; } System.Runtime.InteropServices.Marshal.FreeHGlobal(range); range = System.Runtime.InteropServices.Marshal.AllocHGlobal(sizeof(float)); result = e.getPropertyByIndex((int)FMOD.EVENTPROPERTY._3D_MINDISTANCE, range, false); ERRCHECK(result); System.Runtime.InteropServices.Marshal.Copy(range, tmp, 0, 1); m_minRange = tmp[0]; System.Runtime.InteropServices.Marshal.FreeHGlobal(range); range = System.Runtime.InteropServices.Marshal.AllocHGlobal(sizeof(float)); result = e.getPropertyByIndex((int)FMOD.EVENTPROPERTY._3D_MAXDISTANCE, range, false); ERRCHECK(result); System.Runtime.InteropServices.Marshal.Copy(range, tmp, 0, 1); m_maxRange = tmp[0]; System.Runtime.InteropServices.Marshal.FreeHGlobal(range); } e.getNumParameters(ref numParameters); for (int k = 0; k < numParameters; k++) { e.getParameterByIndex(k, ref param); toAdd = FmodEventParameter.CreateInstance("FmodEventParameter") as FmodEventParameter; toAdd.Initialize(param, this); m_parameters.Add(toAdd); } m_wasLoaded = true; #endif }
/// <summary> /// Initialize the FMOD sound system. /// </summary> private void InitFMOD() { try { FMODExec(FMOD.Factory.System_Create(ref system)); uint version = 0; FMODExec(system.getVersion(ref version)); if (version < FMOD.VERSION.number) throw new MediaException("You are using an old version of FMOD " + version.ToString("X") + ". This program requires " + FMOD.VERSION.number.ToString("X") + "."); // Assume no special hardware capabilities except 5.1 surround sound. FMOD.CAPS caps = FMOD.CAPS.NONE; FMOD.SPEAKERMODE speakermode = FMOD.SPEAKERMODE._5POINT1; // Fancy param checking on Linux can cause init to fail try { // Get the capabilities of the driver. int minfrequency = 0, maxfrequency = 0; FMODExec(system.getDriverCaps(0, ref caps, ref minfrequency, ref maxfrequency, ref speakermode)); // Set FMOD speaker mode to what the driver supports. FMODExec(system.setSpeakerMode(speakermode)); } catch {} // Forcing the ALSA sound system on Linux seems to avoid a CPU loop // LK - this causes fails on OSX and many linux distros //if (System.Environment.OSVersion.Platform == PlatformID.Unix) // FMODExec(system.setOutput(FMOD.OUTPUTTYPE.ALSA)); // The user has the 'Acceleration' slider set to off, which // is really bad for latency. At 48khz, the latency between // issuing an fmod command and hearing it will now be about 213ms. if ((caps & FMOD.CAPS.HARDWARE_EMULATED) == FMOD.CAPS.HARDWARE_EMULATED) { FMODExec(system.setDSPBufferSize(1024, 10)); } try { StringBuilder name = new StringBuilder(128); // Get driver information so we can check for a wierd one. FMOD.GUID guid = new FMOD.GUID(); FMODExec(system.getDriverInfo(0, name, 128, ref guid)); // Sigmatel sound devices crackle for some reason if the format is pcm 16bit. // pcm floating point output seems to solve it. if (name.ToString().IndexOf("SigmaTel") != -1) { FMODExec(system.setSoftwareFormat( 48000, FMOD.SOUND_FORMAT.PCMFLOAT, 0, 0, FMOD.DSP_RESAMPLER.LINEAR) ); } } catch {} // Try to initialize with all those settings, and Max 32 channels. FMOD.RESULT result = system.init(32, FMOD.INITFLAG.NORMAL, (IntPtr)null); if (result == FMOD.RESULT.ERR_OUTPUT_CREATEBUFFER) { // Can not handle surround sound - back to Stereo. FMODExec(system.setSpeakerMode(FMOD.SPEAKERMODE.STEREO)); // And init again. FMODExec(system.init( 32, FMOD.INITFLAG.NORMAL, (IntPtr)null) ); } // Set real-world effect scales. FMODExec(system.set3DSettings( 1.0f, // Doppler scale 1.0f, // Distance scale is meters 1.0f) // Rolloff factor ); soundSystemAvailable = true; Logger.Log("Initialized FMOD Ex", Helpers.LogLevel.Debug); } catch (Exception ex) { Logger.Log("Failed to initialize the sound system: ", Helpers.LogLevel.Warning, ex); } }
private static extern RESULT FMOD5_System_GetRecordDriverInfo (IntPtr system, int id, StringBuilder name, [MarshalAs(UnmanagedType.LPWStr)]StringBuilder nameW, int namelen, out GUID guid, out int systemrate, out SPEAKERMODE speakermode, out int speakermodechannels);
public RESULT getDriverInfo (int id, StringBuilder name, [MarshalAs(UnmanagedType.LPWStr)]StringBuilder namew, int namelen, ref GUID guid, ref int systemrate, ref SPEAKERMODE speakermode, ref int speakermodechannels) { return FMOD_System_GetDriverInfo(systemraw, id, name, namew, namelen, ref guid, ref systemrate, ref speakermode, ref speakermodechannels); }
public RESULT getRecordDriverInfo(int id, StringBuilder name, int namelen, ref GUID guid) { return FMOD_System_GetRecordDriverInfo(systemraw, id, name, namelen, ref guid); }
public RESULT getRecordDriverInfo(int id, StringBuilder name, int namelen, out GUID guid, out int systemrate, out SPEAKERMODE speakermode, out int speakermodechannels) { IntPtr stringMem = Marshal.AllocHGlobal(name.Capacity); RESULT result = FMOD_System_GetRecordDriverInfo(rawPtr, id, stringMem, namelen, out guid, out systemrate, out speakermode, out speakermodechannels); StringMarshalHelper.NativeToBuilder(name, stringMem); Marshal.FreeHGlobal(stringMem); return result; }
private static void CreateDeviceList() { if (m_deviceList.Count <= 0) { System system = null; Factory.System_Create(ref system); int numdrivers = 0; system.getNumDrivers(ref numdrivers); if (numdrivers > 0) { system.getNumDrivers(ref numdrivers); StringBuilder name = new StringBuilder(0x100); for (int i = 0; i < numdrivers; i++) { GUID guid = new GUID(); system.getDriverInfo(i, name, name.Capacity, ref guid); m_deviceList.Add(name.ToString()); } } system.release(); } }
public void LoadMixerBuses() { FMOD.Studio.MixerStrip[] mixerStrips; FMOD.Studio.Bank bank; FMOD.Studio.MixerStrip mixerStrip; FMODStudioSystem studioSystem = FMODStudioSystem.Instance; FMOD.GUID guid = new FMOD.GUID(); if (studioSystem.System == null) { Debug.LogError("Cannot find Studio System."); return; } studioSystem.System.LookupID("bank:/Master Bank", out guid); studioSystem.System.GetBank(guid, out bank); if (bank == null) { Debug.LogError("Cannot find Master Bank."); return; } bank.GetMixerStripList(out mixerStrips); Dictionary <String, MixerProperty> mixerDictionary = new Dictionary <string, MixerProperty>(mixerStrips.Length); if (mixerProperties == null) { mixerProperties = new List <MixerProperty>(mixerStrips.Length); } else { foreach (MixerProperty property in this.mixerProperties) { mixerDictionary.Add(property.BusName, property); } } string path; bool muteLevel; float faderLevel; bool mixerListExists = this.mixerProperties != null; for (int i = 0; i < mixerStrips.Length; i++) { mixerStrips[i].GetPath(out path); studioSystem.System.LookupID(path, out guid); studioSystem.System.GetMixerStrip(guid, FMOD.Studio.LoadingMode.BeginNow, out mixerStrip); mixerStrip.GetMute(out muteLevel); mixerStrip.GetFaderLevel(out faderLevel); if (path == "bus:/") { path = "Master"; } else { path = path.Replace("bus:/", string.Empty); } if (mixerListExists) { MixerProperty property = mixerDictionary[path]; property.MixerStrip = mixerStrip; property.Volume = faderLevel; property.IsEnabled = !muteLevel; } else { this.mixerProperties.Add(new MixerProperty(mixerStrip, !muteLevel, path, faderLevel)); } } this.mixerProperties.Sort(); }
//This function is called by the loadSystem function. It sets up FMOD for the rest of //the program, like an "init" of sorts. Most of this code is boilerplate that is used in //every FMOD application. private FMOD.System fmodSetup() { FMOD.System t_system = new FMOD.System(); FMOD.RESULT result = new FMOD.RESULT(); uint version = 0; int numDrivers = 0; FMOD.SPEAKERMODE speakerMode = FMOD.SPEAKERMODE.STEREO; FMOD.CAPS caps = FMOD.CAPS.NONE; StringBuilder name = null; // Create FMOD interface object result = FMOD.Factory.System_Create(ref t_system); FMODErrorCheck(result); // Check version result = t_system.getVersion(ref version); FMODErrorCheck(result); if (version < FMOD.VERSION.number) { Console.WriteLine("Error! You are using an old version of FMOD " + version + ". This program requires " + FMOD.VERSION.number); return(null); } //Check Sound Cards, if none, disable sound result = t_system.getNumDrivers(ref numDrivers); FMODErrorCheck(result); if (numDrivers == 0) { result = t_system.setOutput(FMOD.OUTPUTTYPE.NOSOUND); FMODErrorCheck(result); } // At least one sound card else { // Get the capabilities of the default (0) sound card result = t_system.getDriverCaps(0, ref caps, ref zero, ref speakerMode); FMODErrorCheck(result); // Set the speaker mode to match that in Control Panel result = t_system.setSpeakerMode(speakerMode); FMODErrorCheck(result); // Increase buffer size if user has Acceleration slider set to off if (FMOD.CAPS.HARDWARE_EMULATED.Equals(true)) { result = t_system.setDSPBufferSize(1024, 10); FMODErrorCheck(result); } // Get name of driver FMOD.GUID temp = new FMOD.GUID(); result = t_system.getDriverInfo(0, name, 256, ref temp); FMODErrorCheck(result); } System.IntPtr temp2 = new System.IntPtr(); // Initialise FMOD result = t_system.init(100, FMOD.INITFLAGS.NORMAL, temp2); // If the selected speaker mode isn't supported by this sound card, switch it back to stereo if (result == FMOD.RESULT.ERR_OUTPUT_CREATEBUFFER) { result = t_system.setSpeakerMode(FMOD.SPEAKERMODE.STEREO); FMODErrorCheck(result); result = t_system.init(100, FMOD.INITFLAGS.NORMAL, temp2); } FMODErrorCheck(result); return(t_system); }
private static extern RESULT FMOD_System_GetDriverInfo (IntPtr system, int id, StringBuilder name, [MarshalAs(UnmanagedType.LPWStr)]StringBuilder namew, int namelen, ref GUID guid, ref int systemrate, ref SPEAKERMODE speakermode, ref int speakermodechannels);
public RESULT getRecordDriverInfo(int id, [MarshalAs(UnmanagedType.LPWStr)]StringBuilder name, int namelen, ref GUID guid) { //use multibyte version return FMOD_System_GetRecordDriverInfoW(systemraw, id, name, namelen, ref guid); }
/// <summary> /// Initialize the FMOD sound system. /// </summary> private void InitFMOD() { try { FMODExec(FMOD.Factory.System_Create(ref system)); uint version = 0; FMODExec(system.getVersion(ref version)); if (version < FMOD.VERSION.number) { throw new MediaException("You are using an old version of FMOD " + version.ToString("X") + ". This program requires " + FMOD.VERSION.number.ToString("X") + "."); } // Assume no special hardware capabilities except 5.1 surround sound. FMOD.CAPS caps = FMOD.CAPS.NONE; FMOD.SPEAKERMODE speakermode = FMOD.SPEAKERMODE._5POINT1; // Try to detect soud system used if (System.Environment.OSVersion.Platform == PlatformID.Unix || System.Environment.OSVersion.Platform == PlatformID.MacOSX) { bool audioOK = false; var res = system.setOutput(FMOD.OUTPUTTYPE.COREAUDIO); if (res == RESULT.OK) { audioOK = true; } if (!audioOK) { res = system.setOutput(FMOD.OUTPUTTYPE.PULSEAUDIO); if (res == RESULT.OK) { audioOK = true; } } if (!audioOK) { res = system.setOutput(FMOD.OUTPUTTYPE.ALSA); if (res == RESULT.OK) { audioOK = true; } } if (!audioOK) { res = system.setOutput(FMOD.OUTPUTTYPE.OSS); if (res == RESULT.OK) { audioOK = true; } } if (!audioOK) { res = system.setOutput(FMOD.OUTPUTTYPE.AUTODETECT); if (res == RESULT.OK) { audioOK = true; } } } FMOD.OUTPUTTYPE outputType = OUTPUTTYPE.UNKNOWN; FMODExec(system.getOutput(ref outputType)); // Fancy param checking on Linux can cause init to fail try { // Get the capabilities of the driver. int outputRate = 0; FMODExec(system.getDriverCaps(0, ref caps, ref outputRate, ref speakermode)); // Set FMOD speaker mode to what the driver supports. FMODExec(system.setSpeakerMode(speakermode)); } catch {} // The user has the 'Acceleration' slider set to off, which // is really bad for latency. At 48khz, the latency between // issuing an fmod command and hearing it will now be about 213ms. if ((caps & FMOD.CAPS.HARDWARE_EMULATED) == FMOD.CAPS.HARDWARE_EMULATED) { FMODExec(system.setDSPBufferSize(1024, 10)); } try { StringBuilder name = new StringBuilder(128); // Get driver information so we can check for a wierd one. FMOD.GUID guid = new FMOD.GUID(); FMODExec(system.getDriverInfo(0, name, 128, ref guid)); // Sigmatel sound devices crackle for some reason if the format is pcm 16bit. // pcm floating point output seems to solve it. if (name.ToString().IndexOf("SigmaTel") != -1) { FMODExec(system.setSoftwareFormat( 48000, FMOD.SOUND_FORMAT.PCMFLOAT, 0, 0, FMOD.DSP_RESAMPLER.LINEAR) ); } } catch {} // Try to initialize with all those settings, and Max 32 channels. FMOD.RESULT result = system.init(32, FMOD.INITFLAGS.NORMAL, (IntPtr)null); if (result == FMOD.RESULT.ERR_OUTPUT_CREATEBUFFER) { // Can not handle surround sound - back to Stereo. FMODExec(system.setSpeakerMode(FMOD.SPEAKERMODE.STEREO)); // And init again. FMODExec(system.init( 32, FMOD.INITFLAGS.NORMAL, (IntPtr)null) ); } else if (result != FMOD.RESULT.OK) { throw(new Exception(result.ToString())); } // Set real-world effect scales. FMODExec(system.set3DSettings( 1.0f, // Doppler scale 1.0f, // Distance scale is meters 1.0f) // Rolloff factor ); soundSystemAvailable = true; Logger.Log("Initialized FMOD Ex: " + outputType.ToString(), Helpers.LogLevel.Debug); } catch (Exception ex) { Logger.Log("Failed to initialize the sound system: " + ex.ToString(), Helpers.LogLevel.Warning); } }
private static extern RESULT FMOD_System_GetRecordDriverInfoW(IntPtr system, int id, [MarshalAs(UnmanagedType.LPWStr)]StringBuilder name, int namelen, ref GUID guid);
public RESULT getRecordDriverInfo(int id, StringBuilder name, int namelen, out GUID guid, out int systemrate, out SPEAKERMODE speakermode, out int speakermodechannels) { return FMOD_System_GetRecordDriverInfo(rawPtr, id, name, null, namelen, out guid, out systemrate, out speakermode, out speakermodechannels); }
private static extern RESULT FMOD_System_GetRecordDriverInfo (IntPtr system, int id, IntPtr name, int namelen, out GUID guid, out int systemrate, out SPEAKERMODE speakermode, out int speakermodechannels);
public FMOD.Studio.EventInstance GetEvent(string path) { FMOD.Studio.EventInstance instance = null; if (string.IsNullOrEmpty(path)) { FMOD.Studio.UnityUtil.LogError("Empty event path!"); return null; } if (eventDescriptions.ContainsKey(path)) { ERRCHECK(eventDescriptions[path].createInstance(out instance)); } else { FMOD.GUID id = new FMOD.GUID(); if (path.StartsWith("{")) { ERRCHECK(FMOD.Studio.Util.ParseID(path, out id)); } else if (path.StartsWith("event:")) { ERRCHECK(system.lookupID(path, out id)); } else { FMOD.Studio.UnityUtil.LogError("Expected event path to start with 'event:/'"); } FMOD.Studio.EventDescription desc = null; ERRCHECK(system.getEvent(id, FMOD.Studio.LOADING_MODE.BEGIN_NOW, out desc)); if (desc != null && desc.isValid()) { eventDescriptions.Add(path, desc); ERRCHECK(desc.createInstance(out instance)); } } if (instance == null) { FMOD.Studio.UnityUtil.Log("GetEvent FAILED: \"path\""); } return instance; }
private static extern RESULT FMOD_System_GetRecordDriverInfo(IntPtr system, int id, StringBuilder name, int namelen, ref GUID guid);
private static void CreateDeviceList() { if(m_deviceList.Count > 0) return; // Create a bare system object to get the driver count FMODSystem system = null; RESULT result = Factory.System_Create(ref system); if (result == RESULT.ERR_FILE_BAD) MessageBox.Show("Error creating audio device: 32/64 bit incompatibility."); int driverCount = 0; system.getNumDrivers(ref driverCount); if(driverCount > 0) { // There are audio devices available // Create device list system.getNumDrivers(ref driverCount); StringBuilder sb = new StringBuilder(256); int i; for(i = 0; i < driverCount; i++) { GUID GUID = new GUID(); system.getDriverInfo(i, sb, sb.Capacity, ref GUID); m_deviceList.Add(sb.ToString()); } } system.release(); }