public static System_Create ( |
||
system | ||
return | RESULT |
static private 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); if (!sb.ToString().Contains("DAX")) { m_deviceList.Add(sb.ToString()); } } } system.release(); }
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 SoundSystem() { AudioFound = true; sndActiveBGMName = ""; RESULT result = Factory.System_Create(ref _system); if (result != RESULT.OK) { AudioFound = false; return; } uint version = 0; result = System.getVersion(ref version); if (result != RESULT.OK || version < VERSION.number) { AudioFound = false; return; } result = System.init(16, INITFLAGS.NORMAL, (IntPtr)null); if (result != RESULT.OK) { AudioFound = false; return; } ChannelBGM = new Channel(); ChannelBGM.setRaw(new IntPtr()); ChannelBackgroundSFX = new Channel(); ChannelBackgroundSFX.setRaw(new IntPtr()); ChannelGroupSFX = new ChannelGroup(); }
public static fmod GetInstance(int deviceIndex) { if (m_systems.Count == 0) { System system = null; CreateDeviceList(); if (m_deviceList.Count > 0) { int num; for (num = 0; num < m_deviceList.Count; num++) { if (Factory.System_Create(ref system) == RESULT.ERR_OUTPUT_INIT) { m_deviceList.RemoveRange(num, m_deviceList.Count - num); break; } m_systems.Add(system); } string path = Path.Combine(Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName), "sound.params"); int numbuffers = 0; uint filebuffersize = 0x8000; if (File.Exists(path)) { string str2; StreamReader reader = new StreamReader(path); while ((str2 = reader.ReadLine()) != null) { string[] strArray = str2.Split(new char[] { '=' }); string str3 = strArray[0].Trim().ToLower(); if (str3 != null) { if (!(str3 == "dspbuffercount")) { if (str3 == "streambuffersize") { goto Label_0146; } } else { try { numbuffers = Convert.ToInt32(strArray[1].Trim()); } catch { } } } goto Label_0162; Label_0146: try { filebuffersize = Convert.ToUInt32(strArray[1].Trim()); } catch { } Label_0162: ; } reader.Close(); reader.Dispose(); } for (num = 0; num < m_systems.Count; num++) { system = m_systems[num]; system.setDriver(num); if (numbuffers > 0) { system.setDSPBufferSize(0x400, numbuffers); } system.init(0x20, INITFLAGS.NORMAL, IntPtr.Zero); system.setStreamBufferSize(filebuffersize, TIMEUNIT.RAWBYTES); } } } if (deviceIndex == -1) { deviceIndex = 0; } if (deviceIndex < m_systems.Count) { m_refCount++; return(new fmod(m_systems[deviceIndex], deviceIndex)); } return(new fmod(null, -1)); }
static public fmod GetInstance(int deviceIndex = -1) { if (m_systems.Count == 0) { FMODSystem system = null; CreateDeviceList(); if (m_deviceList.Count > 0) { // Create system instances, one for each device int i; for (i = 0; i < m_deviceList.Count; i++) { if (Factory.System_Create(ref system) == RESULT.ERR_OUTPUT_INIT) { // Remove all devices listed at this index and beyond m_deviceList.RemoveRange(i, m_deviceList.Count - i); break; } else { m_systems.Add(system); } } // Initialize all system instances string paramFile = Path.Combine(Path.GetDirectoryName(System.Diagnostics.Process.GetCurrentProcess().MainModule.FileName), "sound.params"); int dspBufferCount = 0; uint streamBufferSize = 32768; // For some parameter tweaking, just in case if (File.Exists(paramFile)) { StreamReader reader = new StreamReader(paramFile); string line; string[] parts; while ((line = reader.ReadLine()) != null) { parts = line.Split('='); switch (parts[0].Trim().ToLower()) { case "dspbuffercount": try { dspBufferCount = Convert.ToInt32(parts[1].Trim()); } catch { } break; case "streambuffersize": try { streamBufferSize = Convert.ToUInt32(parts[1].Trim()); } catch { } break; } } reader.Close(); reader.Dispose(); } for (i = 0; i < m_systems.Count; i++) { system = m_systems[i]; system.setDriver(i); if (dspBufferCount > 0) { // Must be called before init system.setDSPBufferSize(1024, dspBufferCount); } system.init(32, INITFLAGS.NORMAL, IntPtr.Zero); system.setStreamBufferSize(streamBufferSize, TIMEUNIT.RAWBYTES); } } } // Return an instance with the appropriate system instance assignment if (deviceIndex == -1) { deviceIndex = 0; // 0 is always primary device? } if (deviceIndex < m_systems.Count) { m_refCount++; return(new fmod(m_systems[deviceIndex], deviceIndex)); } else { return(new fmod(null, -1)); } }