private void Start() { if (!VRAudioDriver.DriverSet) { System system = null; FMOD_StudioSystem.instance.System.getLowLevelSystem(out system); int num; system.getNumDrivers(out num); StringBuilder[] array = new StringBuilder[num]; Guid[] array2 = new Guid[num]; int[] array3 = new int[num]; SPEAKERMODE[] array4 = new SPEAKERMODE[num]; int[] array5 = new int[num]; for (int i = 0; i < num; i++) { array[i] = new StringBuilder(200); system.getDriverInfo(i, array[i], 200, out array2[i], out array3[i], out array4[i], out array5[i]); UnityEngine.Debug.Log(string.Concat(new object[] { ">>> AUDIO DRIVER ", i, " '", array[i].ToString(), "' GUID='", array2[i], "' rate=", array3[i], " speakerMode=", array4[i], " speakerModeChannel=", array5[i] })); if (array[i].ToString().ToLower().Contains("rift")) { system.setDriver(i); UnityEngine.Debug.Log("[VR] Setting " + array[i].ToString() + " as audio driver"); VRAudioDriver.DriverSet = true; if (!this._logAllAudioDrivers) { break; } } if (array[i].ToString().ToLower().Contains("htc vive")) { system.setDriver(i); UnityEngine.Debug.Log("[VR] Setting " + array[i].ToString() + " as audio driver"); VRAudioDriver.DriverSet = true; if (!this._logAllAudioDrivers) { break; } } } } }
public RecordDriver() { id = -1; name = ""; nameLength = 0; guid = Guid.Empty; systemRate = 0; speakerMode = SPEAKERMODE.DEFAULT; speakerModeChannels = 0; state = DRIVER_STATE.DEFAULT; }
/// <summary> /// Check and fix any problem with hardware. /// </summary> private void CheckDriver() { //Get number of driver available int DriverNumber = 0; CheckError(m_System.getNumDrivers(ref DriverNumber)); //Driver checking #region Solve hardware problems //If there's 0 driver, no sound if (DriverNumber <= 0) { CheckError(m_System.setOutput(OUTPUTTYPE.NOSOUND)); } else { //Get driver capability int MinFreq = 0, MaxFreq = 0; CAPS Capability = CAPS.NONE; SPEAKERMODE Speakermode = SPEAKERMODE.STEREO; CheckError(m_System.getDriverCaps(0, ref Capability, ref MinFreq, ref MaxFreq, ref Speakermode)); //Set spearker mode according to the driver CheckError(m_System.setSpeakerMode(Speakermode)); //Set buffer if not using hardware accceleration if ((Capability & CAPS.HARDWARE_EMULATED) == CAPS.HARDWARE_EMULATED) { CheckError(m_System.setDSPBufferSize(Global.EMULATED_BUFFERSIZE, Global.EMULATED_BUFFERCOUNT)); } //Get user driver data GUID Guid = new GUID(); StringBuilder DriverName = new StringBuilder(Global.MAX_DRIVERNAME); CheckError(m_System.getDriverInfo(0, DriverName, Global.MAX_DRIVERNAME, ref Guid)); //If driver is sigmatel if (DriverName.Equals(new StringBuilder((Global.SIGMATEL_DRIVERNAME)))) { //Fix crackling CheckError(m_System.setSoftwareFormat( Global.SIGMATEL_SAMPLERATE, SOUND_FORMAT.PCMFLOAT, 0, 0, DSP_RESAMPLER.LINEAR)); } } #endregion }
private static extern RESULT FMOD5_System_GetRecordDriverInfo(IntPtr system, int id, IntPtr name, int namelen, out Guid guid, out int systemrate, out SPEAKERMODE speakermode, out int speakermodechannels, out DRIVER_STATE state);
private static extern RESULT FMOD_System_GetDriverCaps(IntPtr system, int id, ref CAPS caps, ref int minfrequency, ref int maxfrequency, ref SPEAKERMODE controlpanelspeakermode);
private static extern RESULT FMOD_DSP_GetOutputChannelFormat (IntPtr dsp, CHANNELMASK inmask, int inchannels, SPEAKERMODE inspeakermode, out CHANNELMASK outmask, out int outchannels, out SPEAKERMODE outspeakermode);
public RESULT setChannelFormat(CHANNELMASK channelmask, int numchannels, SPEAKERMODE source_speakermode) { return FMOD_DSP_SetChannelFormat(rawPtr, channelmask, numchannels, source_speakermode); }
public RESULT getSoftwareFormat (out int samplerate, out SPEAKERMODE speakermode, out int numrawspeakers) { return FMOD_System_GetSoftwareFormat(rawPtr, out samplerate, out speakermode, out numrawspeakers); }
private static extern RESULT FMOD5_System_GetSpeakerModeChannels (IntPtr system, SPEAKERMODE mode, out int channels);
public System(bool enableLiveUpdate = false, OUTPUTTYPE outputType = OUTPUTTYPE.AUTODETECT, int driverIndex = 0, int sampleRate = 48000, SPEAKERMODE speakerMode = SPEAKERMODE.DEFAULT, int numRawSpeakers = 0, uint bufferLength = 1024, int numBuffers = 4) { Ready = false; _system = Utilities.initStudioSystem(enableLiveUpdate, outputType, driverIndex, sampleRate, speakerMode, numRawSpeakers, bufferLength, numBuffers); }
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 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);
private Tuple<string, int, int> GetDriverInfo(int driverIndex) { var name = new StringBuilder(1000); var guid = new Guid(); var samplingRate = 0; var speakerMode = new SPEAKERMODE(); var channelCount = 0; var driverState = new DRIVER_STATE(); this.fmodSystem.getRecordDriverInfo(driverIndex, name, 1000, out guid, out samplingRate, out speakerMode, out channelCount, out driverState); return new Tuple<string, int, int>(name.ToString(), samplingRate, channelCount); }
public RESULT getRecordDriverInfo(int id, out Guid guid, out int systemrate, out SPEAKERMODE speakermode, out int speakermodechannels, out DRIVER_STATE state) { return(FMOD5_System_GetRecordDriverInfo(handle, id, IntPtr.Zero, 0, out guid, out systemrate, out speakermode, out speakermodechannels, out state)); }
public RESULT getRecordDriverInfo(int id, out string name, int namelen, out Guid guid, out int systemrate, out SPEAKERMODE speakermode, out int speakermodechannels, out DRIVER_STATE state) { IntPtr intPtr = Marshal.AllocHGlobal(namelen); RESULT result = FMOD5_System_GetRecordDriverInfo(handle, id, intPtr, namelen, out guid, out systemrate, out speakermode, out speakermodechannels, out state); using (StringHelper.ThreadSafeEncoding threadSafeEncoding = StringHelper.GetFreeHelper()) { name = threadSafeEncoding.stringFromNative(intPtr); } Marshal.FreeHGlobal(intPtr); return(result); }
private static extern RESULT FMOD_System_GetDriverCaps(IntPtr system, int id, ref CAPS caps, ref int controlpaneloutputrate, ref SPEAKERMODE controlpanelspeakermode);
public RESULT getSpeakerModeChannels (SPEAKERMODE mode, out int channels) { return FMOD5_System_GetSpeakerModeChannels(rawPtr, mode, out channels); }
private RESULT Initialize() { initializedSuccessfully = false; RESULT rESULT = RESULT.OK; RESULT rESULT2 = RESULT.OK; Settings settings = Settings.Instance; fmodPlatform = RuntimeUtils.GetCurrentPlatform(); int sampleRate = settings.GetSampleRate(fmodPlatform); int num = Math.Min(settings.GetRealChannels(fmodPlatform), 256); int virtualChannels = settings.GetVirtualChannels(fmodPlatform); SPEAKERMODE speakerMode = (SPEAKERMODE)settings.GetSpeakerMode(fmodPlatform); OUTPUTTYPE output = OUTPUTTYPE.AUTODETECT; FMOD.ADVANCEDSETTINGS settings2 = default(FMOD.ADVANCEDSETTINGS); settings2.randomSeed = (uint)DateTime.Now.Ticks; settings2.maxVorbisCodecs = num; FMOD.Studio.INITFLAGS iNITFLAGS = FMOD.Studio.INITFLAGS.DEFERRED_CALLBACKS; if (settings.IsLiveUpdateEnabled(fmodPlatform)) { iNITFLAGS |= FMOD.Studio.INITFLAGS.LIVEUPDATE; } while (true) { rESULT = FMOD.Studio.System.create(out studioSystem); CheckInitResult(rESULT, "FMOD.Studio.System.create"); rESULT = studioSystem.getLowLevelSystem(out lowlevelSystem); CheckInitResult(rESULT, "FMOD.Studio.System.getLowLevelSystem"); rESULT = lowlevelSystem.setOutput(output); CheckInitResult(rESULT, "FMOD.System.setOutput"); rESULT = lowlevelSystem.setSoftwareChannels(num); CheckInitResult(rESULT, "FMOD.System.setSoftwareChannels"); rESULT = lowlevelSystem.setSoftwareFormat(sampleRate, speakerMode, 0); CheckInitResult(rESULT, "FMOD.System.setSoftwareFormat"); rESULT = lowlevelSystem.setAdvancedSettings(ref settings2); CheckInitResult(rESULT, "FMOD.System.setAdvancedSettings"); rESULT = studioSystem.initialize(virtualChannels, iNITFLAGS, FMOD.INITFLAGS.NORMAL, IntPtr.Zero); if (rESULT != 0 && rESULT2 == RESULT.OK) { rESULT2 = rESULT; output = OUTPUTTYPE.NOSOUND; Debug.LogWarningFormat("FMOD Studio: Studio::System::initialize returned {0}, defaulting to no-sound mode.", rESULT.ToString()); } else { CheckInitResult(rESULT, "Studio::System::initialize"); if ((iNITFLAGS & FMOD.Studio.INITFLAGS.LIVEUPDATE) == FMOD.Studio.INITFLAGS.NORMAL) { break; } studioSystem.flushCommands(); rESULT = studioSystem.update(); if (rESULT != RESULT.ERR_NET_SOCKET_ERROR) { break; } iNITFLAGS = (FMOD.Studio.INITFLAGS)((int)iNITFLAGS & -2); Debug.LogWarning("FMOD Studio: Cannot open network port for Live Update (in-use), restarting with Live Update disabled."); rESULT = studioSystem.release(); CheckInitResult(rESULT, "FMOD.Studio.System.Release"); } } LoadPlugins(settings); LoadBanks(settings); initializedSuccessfully = (rESULT == RESULT.OK); return(rESULT2); }
private static extern RESULT FMOD5_DSP_SetChannelFormat (IntPtr dsp, CHANNELMASK channelmask, int numchannels, SPEAKERMODE source_speakermode);
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); }
private static extern RESULT FMOD_System_GetSoftwareFormat (IntPtr system, out int samplerate, out SPEAKERMODE speakermode, out int numrawspeakers);
public RESULT getSoftwareFormat (ref int samplerate, ref SPEAKERMODE speakermode, ref int numrawspeakers) { return FMOD_System_GetSoftwareFormat(systemraw, ref samplerate, ref speakermode, ref numrawspeakers); }
public RESULT getOutputChannelFormat(CHANNELMASK inmask, int inchannels, SPEAKERMODE inspeakermode, out CHANNELMASK outmask, out int outchannels, out SPEAKERMODE outspeakermode) { return FMOD_DSP_GetOutputChannelFormat(rawPtr, inmask, inchannels, inspeakermode, out outmask, out outchannels, out outspeakermode); }
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 getSpeakerMode(ref SPEAKERMODE speakermode) { return FMOD_System_GetSpeakerMode(systemraw, ref speakermode); }
private static extern RESULT FMOD5_DSP_GetChannelFormat(IntPtr dsp, out CHANNELMASK channelmask, out int numchannels, out SPEAKERMODE source_speakermode);
public RESULT getDriverInfo(int id, out Guid guid, out int systemrate, out SPEAKERMODE speakermode, out int speakermodechannels) { return(FMOD5_System_GetDriverInfo(handle, id, IntPtr.Zero, 0, out guid, out systemrate, out speakermode, out speakermodechannels)); }
private static extern RESULT FMOD5_DSP_GetOutputChannelFormat(IntPtr dsp, CHANNELMASK inmask, int inchannels, SPEAKERMODE inspeakermode, out CHANNELMASK outmask, out int outchannels, out SPEAKERMODE outspeakermode);
/*public static FMOD.Studio.System initStudioSystem(bool enableLiveUpdate = false, OUTPUTTYPE outputType = OUTPUTTYPE.AUTODETECT, int driverIndex = 0) * { * var initFlags = enableLiveUpdate ? FMOD.Studio.INITFLAGS.LIVEUPDATE : FMOD.Studio.INITFLAGS.NORMAL; * * Console.WriteLine("FMODSystem: Initializing"); * // Create the Studio System object. * FMOD.Studio.System system; * checkResult(FMOD.Studio.System.create(out system)); * FMOD.System coreSystem; * system.getCoreSystem(out coreSystem); * coreSystem.setOutput(outputType); * coreSystem.setDriver(driverIndex); * // Initialize FMOD Studio, which will also initialize FMOD Core * checkResult(system.initialize(512, initFlags, FMOD.INITFLAGS.NORMAL, IntPtr.Zero)); * * return system; * }*/ public static FMOD.Studio.System initStudioSystem(bool enableLiveUpdate = false, OUTPUTTYPE outputType = OUTPUTTYPE.AUTODETECT, int driverIndex = 0, int sampleRate = 48000, SPEAKERMODE speakerMode = SPEAKERMODE.DEFAULT, int numRawSpeakers = 0, uint bufferLength = 1024, int numBuffers = 4) { var initFlags = enableLiveUpdate ? FMOD.Studio.INITFLAGS.LIVEUPDATE : FMOD.Studio.INITFLAGS.NORMAL; Console.WriteLine("FMODSystem: Initializing"); // Create the Studio System object. FMOD.Studio.System system; checkResult(FMOD.Studio.System.create(out system)); FMOD.System coreSystem; system.getCoreSystem(out coreSystem); coreSystem.setOutput(outputType); coreSystem.setDriver(driverIndex); coreSystem.setSoftwareFormat(sampleRate, speakerMode, numRawSpeakers); coreSystem.setDSPBufferSize(bufferLength, numBuffers); // Initialize FMOD Studio, which will also initialize FMOD Core checkResult(system.initialize(512, initFlags, FMOD.INITFLAGS.NORMAL, IntPtr.Zero)); return(system); }
public RESULT setChannelFormat(CHANNELMASK channelmask, int numchannels, SPEAKERMODE source_speakermode) { return(FMOD5_DSP_SetChannelFormat(handle, channelmask, numchannels, source_speakermode)); }
public RESULT getDriverCaps(int id, ref CAPS caps, ref int controlpaneloutputrate, ref SPEAKERMODE controlpanelspeakermode) { return FMOD_System_GetDriverCaps(systemraw, id, ref caps, ref controlpaneloutputrate, ref controlpanelspeakermode); }
public RESULT getChannelFormat(out CHANNELMASK channelmask, out int numchannels, out SPEAKERMODE source_speakermode) { return(FMOD5_DSP_GetChannelFormat(handle, out channelmask, out numchannels, out source_speakermode)); }
public RESULT getDefaultMixMatrix (SPEAKERMODE sourcespeakermode, SPEAKERMODE targetspeakermode, float[] matrix, int matrixhop) { return FMOD5_System_GetDefaultMixMatrix(rawPtr, sourcespeakermode, targetspeakermode, matrix, matrixhop); }
public RESULT getOutputChannelFormat(CHANNELMASK inmask, int inchannels, SPEAKERMODE inspeakermode, out CHANNELMASK outmask, out int outchannels, out SPEAKERMODE outspeakermode) { return(FMOD5_DSP_GetOutputChannelFormat(handle, inmask, inchannels, inspeakermode, out outmask, out outchannels, out outspeakermode)); }
private static extern RESULT FMOD5_System_GetDefaultMixMatrix (IntPtr system, SPEAKERMODE sourcespeakermode, SPEAKERMODE targetspeakermode, float[] matrix, int matrixhop);
public RESULT getRecordDriverInfo(int id, StringBuilder name, int namelen, out Guid guid, out int systemrate, out SPEAKERMODE speakermode, out int speakermodechannels, out DRIVER_STATE state) { IntPtr intPtr = Marshal.AllocHGlobal(name.Capacity); RESULT result = System.FMOD5_System_GetRecordDriverInfo(this.rawPtr, id, intPtr, namelen, out guid, out systemrate, out speakermode, out speakermodechannels, out state); StringMarshalHelper.NativeToBuilder(name, intPtr); Marshal.FreeHGlobal(intPtr); return result; }
private static extern RESULT FMOD5_System_GetRecordDriverInfo (IntPtr system, int id, IntPtr name, int namelen, out Guid guid, out int systemrate, out SPEAKERMODE speakermode, out int speakermodechannels, out DRIVER_STATE state);
public RESULT getDefaultMixMatrix(SPEAKERMODE sourcespeakermode, SPEAKERMODE targetspeakermode, float[] matrix, int matrixhop) { return(System.FMOD5_System_GetDefaultMixMatrix(this.rawPtr, sourcespeakermode, targetspeakermode, matrix, matrixhop)); }
public RESULT setSoftwareFormat (int samplerate, SPEAKERMODE speakermode, int numrawspeakers) { return FMOD_System_SetSoftwareFormat(rawPtr, samplerate, speakermode, numrawspeakers); }
public RESULT getSpeakerModeChannels(SPEAKERMODE mode, out int channels) { return(System.FMOD5_System_GetSpeakerModeChannels(this.rawPtr, mode, out channels)); }
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; }
public RESULT getRecordDriverInfo(int id, StringBuilder name, int namelen, out Guid guid, out int systemrate, out SPEAKERMODE speakermode, out int speakermodechannels, out DRIVER_STATE state) { IntPtr intPtr = Marshal.AllocHGlobal(name.Capacity); RESULT result = System.FMOD5_System_GetRecordDriverInfo(this.rawPtr, id, intPtr, namelen, out guid, out systemrate, out speakermode, out speakermodechannels, out state); StringMarshalHelper.NativeToBuilder(name, intPtr); Marshal.FreeHGlobal(intPtr); return(result); }
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);
private static extern RESULT FMOD5_System_GetSoftwareFormat(IntPtr system, out int samplerate, out SPEAKERMODE speakermode, out int numrawspeakers);
public RESULT getChannelFormat(out CHANNELMASK channelmask, out int numchannels, out SPEAKERMODE source_speakermode) { return FMOD_DSP_GetChannelFormat(rawPtr, out channelmask, out numchannels, out source_speakermode); }
public RESULT setSoftwareFormat(int samplerate, SPEAKERMODE speakermode, int numrawspeakers) { return(System.FMOD5_System_SetSoftwareFormat(this.rawPtr, samplerate, speakermode, numrawspeakers)); }
private static extern RESULT FMOD_DSP_GetChannelFormat (IntPtr dsp, out CHANNELMASK channelmask, out int numchannels, out SPEAKERMODE source_speakermode);
private static extern RESULT FMOD5_System_GetDefaultMixMatrix(IntPtr system, SPEAKERMODE sourcespeakermode, SPEAKERMODE targetspeakermode, float[] matrix, int matrixhop);
public RESULT getDriverCaps(int id, ref CAPS caps, ref int minfrequency, ref int maxfrequency, ref SPEAKERMODE controlpanelspeakermode) { return FMOD_System_GetDriverCaps(systemraw, id, ref caps, ref minfrequency, ref maxfrequency, ref controlpanelspeakermode); }
private static extern RESULT FMOD5_System_GetSpeakerModeChannels(IntPtr system, SPEAKERMODE mode, out int channels);
public RESULT setSpeakerMode(SPEAKERMODE speakermode) { return FMOD_System_SetSpeakerMode(systemraw, speakermode); }
public RESULT getSoftwareFormat(out int samplerate, out SPEAKERMODE speakermode, out int numrawspeakers) { return(System.FMOD5_System_GetSoftwareFormat(this.rawPtr, out samplerate, out speakermode, out numrawspeakers)); }
private static extern RESULT FMOD_System_SetSpeakerMode(IntPtr system, SPEAKERMODE speakermode);
public RESULT getSpeakerModeChannels(SPEAKERMODE mode, out int channels) { return(FMOD5_System_GetSpeakerModeChannels(handle, mode, out channels)); }