// sets the volume of a mixer private void SetVolume(AudioTypes audioType, float value) { if (_masterVolumeMixer == null) { Debug.Log("AudioManager SetVolume ERROR: invalid Master volume mixer"); return; } switch (audioType) { case (AudioTypes.Music): _masterVolumeMixer.SetFloat("MusicVolume", value); break; case (AudioTypes.Sfx): _masterVolumeMixer.SetFloat("SfxVolume", value); break; case (AudioTypes.Master): _masterVolumeMixer.SetFloat("MasterVolume", value); break; default: Debug.Log("AudioManager SetVolume: Default case reached, please contact a developer with this message."); break; } }
public static AudioClip Load(string path) { if (path.Length == 0) { return(Silent); } if (cache.TryGetValue(path, out var clip)) { return(clip); } Main.DebugLog(() => $"Loading {path}"); var extension = Path.GetExtension(path); if (!AudioTypes.ContainsKey(extension)) { throw new Config.ConfigException($"Unsupported file extension for sound file: \"{path}\""); } var audioType = AudioTypes[Path.GetExtension(path)]; var webRequest = UnityWebRequestMultimedia.GetAudioClip(new Uri(path).AbsoluteUri, audioType); var async = webRequest.SendWebRequest(); while (!async.isDone) { } clip = DownloadHandlerAudioClip.GetContent(webRequest); cache[path] = clip; return(clip); }
/// <summary> /// Creates a new SoundTrigger. /// </summary> /// <param name="id">The identifaction name to give the Trigger.</param> /// <param name="bounds">The collision area of the Trigger.</param> /// <param name="delayTime">The amount of time to delay between activations.</param> /// <param name="triggerCount">The amount of times the Trigger can be sprung.</param> /// <param name="soundName">The name of the sound to be played when triggered.</param> /// <param name="playType">The way in which the audio will played.</param> public SoundTrigger(string id, Rectangle bounds, TimeSpan delayTime, int triggerCount, string soundName, AudioTypes playType) : base(id, bounds, delayTime, triggerCount) { this.soundName = soundName; this.playType = playType; }
private AudioTypes GetMatchSound() { var randomSfx = m_Random.NextInt(0, 4); AudioTypes matchSound = AudioTypes.None; switch (randomSfx) { case 0: matchSound = AudioTypes.Match0; break; case 1: matchSound = AudioTypes.Match1; break; case 2: matchSound = AudioTypes.Match2; break; case 3: matchSound = AudioTypes.Match3; break; } return(matchSound); }
/// <summary> /// Creates a new SoundTrigger. /// </summary> /// <param name="id">The identifaction name to give the Trigger.</param> /// <param name="bounds">The collision area of the Trigger.</param> /// <param name="delayTime">The amount of time to delay between activations.</param> /// <param name="triggerCount">The amount of times the Trigger can be sprung.</param> /// <param name="enabled">Wheather or not the Trigger i9s enabled from the start.</param> /// <param name="acceptableCollisionTypes">The only types of objects that, when /// collided with the Trigger can activate it.</param> /// <param name="soundName">The name of the sound to be played when triggered.</param> /// <param name="playType">The way in which the audio will played.</param> public SoundTrigger(string id, Rectangle bounds, TimeSpan delayTime, int triggerCount, bool enabled, List <string> acceptableCollisionTypes, string soundName, AudioTypes playType) : base(id, bounds, delayTime, triggerCount, enabled, acceptableCollisionTypes) { this.soundName = soundName; this.playType = playType; }
private static Entity FindAudioClip(EntityManager entityManager, AudioTypes audioType) { var library = GetAudioLibrary(entityManager); var audioClips = entityManager.GetBuffer <AudioObject>(library); return(FindAudioClip(audioClips, audioType)); }
public static void StopSound(EntityManager entityManager, AudioTypes audioType) { var clipEntity = FindAudioClip(entityManager, audioType); if (clipEntity == Entity.Null) { return; } var audioSourceQuery = entityManager.CreateEntityQuery(typeof(AudioSource)); var audioSources = audioSourceQuery.ToComponentDataArray <AudioSource>(Allocator.TempJob); var audioSourceEntities = audioSourceQuery.ToEntityArray(Allocator.TempJob); for (var i = 0; i < audioSources.Length; i++) { if (audioSources[i].clip != clipEntity) { continue; } entityManager.AddComponent <AudioSourceStop>(audioSourceEntities[i]); } audioSources.Dispose(); audioSourceEntities.Dispose(); }
void Awake() { if (instance == null) { instance = this; } else { Destroy(gameObject); return; } DontDestroyOnLoad(gameObject); InitializeSounds(sounds, Settings.Sounds / 100, 1.0f); InitializeSounds(music, Settings.Music / 1000, 0.0f); musicNum = Random.Range(0, music.Length - 1); //random starting position in list of songs currentSong = music[musicNum]; audioTypes = new AudioTypes[sounds.Length]; for (int i = 0; i < audioTypes.Length; i++) { audioTypes[i] = new AudioTypes(sounds[i].name); } InvokeRepeating("CleanOneShots", 0, 0.05f); audioParent = new GameObject("Audio Sources"); DontDestroyOnLoad(audioParent); }
private bool ReportChannelPosition(Channel?channel, string trackId, AudioTypes audioType, ref int?lastPos) { if (channel.HasValue) { var chn = channel.Value; int?pos = (int?)chn.GetPosition(TimeUnit.Milliseconds); if (pos == lastPos) { return(false); } lastPos = pos; if (pos.HasValue) { SendMessage(new AudioPositionChanged { Id = trackId, Type = audioType, Position = pos.Value }); return(true); } } lastPos = null; return(false); }
private AudioTypes GetFailSounds() { var randomSfx = m_Random.NextInt(0, 4); AudioTypes matchSound = AudioTypes.None; switch (randomSfx) { case 0: matchSound = AudioTypes.Fail0; break; case 1: matchSound = AudioTypes.Fail1; break; case 2: matchSound = AudioTypes.Fail2; break; case 3: matchSound = AudioTypes.Fail3; break; } return(matchSound); }
private LanguageItem(Section section, int offset) { // Load the string ISOLanguage = section.ReadString(offset, 3); // Load the effect Effect = (AudioTypes)section[offset + 3]; }
/// <summary> /// Stops a specific audio clip /// </summary> /// <param name="audioType">The type of audio you want to stop (e.g. jump)</param> /// <param name="entityManager">The EntityManager instance</param> public static void StopAudioType(AudioTypes audioType, EntityManager entityManager) { if (!_isSet) { return; } AudioHanlderSystem.StopAudio(GetAudioID(audioType), entityManager); }
private void OnDestroy() { id = 0; type = AudioTypes.All; source = null; m_loop = false; m_isPaused = false; }
private void Awake() { id = 0; type = AudioTypes.All; source = this.GetComponentDefault <AudioSource>(); source.volume = m_volume; }
/// <summary> /// Erstellt eine neue Sprache. /// </summary> /// <param name="section">Die Rohdaten.</param> /// <param name="offset">Das erste Byte der Beschreibung in den Rohdaten.</param> private LanguageItem(Section section, int offset) { // Load the string ISOLanguage = section.ReadString(offset, 3); // Load the effect Effect = (AudioTypes)section[offset + 3]; }
public static IMusic New(AudioTypes audioType, IDisposableResource parent, string filename) { IMusic api = null; #if XNA if (audioType == AudioTypes.XNA) api = new XNA.Music(parent, filename); #endif if (audioType == AudioTypes.Dumby) api = new Dumby.Music(parent, filename); if (api == null) Debug.ThrowError("MusicAPI", "Unsuported InputType: " + audioType); return api; }
/// <summary> /// Creates a new SoundVolume. /// </summary> /// <param name="id">The unique identifaction name /// to give to the SoundVolume.</param> /// <param name="bounds">The bounds of the SoundVolume.</param> /// <param name="soundName">The name of the sound to be played.</param> public SoundVolume(string id, Eon.Physics2D.Maths.Shapes.Rectangle bounds, string soundName) : base(id, bounds) { this.soundName = soundName; playType = AudioTypes.Ambient; audioOrigin = new Vector3() { X = bounds.Center.X, Y = bounds.Center.Y, Z = 0 }; }
private static Entity FindAudioClip(DynamicBuffer <AudioObject> audioClips, AudioTypes audioType) { var clipIndex = int.MaxValue; for (var i = 0; i < audioClips.Length; i++) { if (audioClips[i].Type == audioType) { clipIndex = i; break; } } return(clipIndex == int.MaxValue ? Entity.Null : audioClips[clipIndex].Clip); }
private static Entity FindAudioClip(EntityManager entityManager, AudioTypes audioType) { var library = GetAudioLibrary(entityManager); var audioClips = entityManager.GetBuffer <AudioObject>(library); var clipIndex = int.MaxValue; for (var i = 0; i < audioClips.Length; i++) { if (audioClips[i].Type == audioType) { clipIndex = i; break; } } return(clipIndex == int.MaxValue ? Entity.Null : audioClips[clipIndex].Clip); }
public static void PlaySound(EntityManager entityManager, AudioTypes audioType, bool shouldLoop = false) { var clipEntity = FindAudioClip(entityManager, audioType); if (clipEntity == Entity.Null) { return; } var sourceEntity = entityManager.CreateEntity(); entityManager.AddComponentData(sourceEntity, new AudioSource() { clip = clipEntity, loop = shouldLoop, volume = 1f }); entityManager.AddComponent <AudioSourceStart>(sourceEntity); }
public static IMusic New(AudioTypes audioType, IDisposableResource parent, string filename) { IMusic api = null; #if XNA if (audioType == AudioTypes.XNA) { api = new XNA.Music(parent, filename); } #endif if (audioType == AudioTypes.Dumby) { api = new Dumby.Music(parent, filename); } if (api == null) { Debug.ThrowError("MusicAPI", "Unsuported InputType: " + audioType); } return(api); }
public static void Register(string[] types) { Types = types; RegistryHelp.SetValue(@"HKCU\Software\Microsoft\Windows\CurrentVersion\App Paths\" + ExeFilename, null, ExePath); RegistryHelp.SetValue(@"HKCR\Applications\" + ExeFilename, "FriendlyAppName", "mpv.net media player"); RegistryHelp.SetValue($@"HKCR\Applications\{ExeFilename}\shell\open\command", null, $"\"{ExePath}\" \"%1\""); RegistryHelp.SetValue(@"HKLM\SOFTWARE\Clients\Media\mpv.net\Capabilities", "ApplicationDescription", "mpv.net media player"); RegistryHelp.SetValue(@"HKLM\SOFTWARE\Clients\Media\mpv.net\Capabilities", "ApplicationName", "mpv.net"); RegistryHelp.SetValue(@"HKCR\SystemFileAssociations\video\OpenWithList\" + ExeFilename, null, ""); RegistryHelp.SetValue(@"HKCR\SystemFileAssociations\audio\OpenWithList\" + ExeFilename, null, ""); RegistryHelp.SetValue(@"HKLM\SOFTWARE\RegisteredApplications", "mpv.net", @"SOFTWARE\Clients\Media\mpv.net\Capabilities"); foreach (string ext in Types) { RegistryHelp.SetValue($@"HKCR\Applications\{ExeFilename}\SupportedTypes", "." + ext, ""); RegistryHelp.SetValue($@"HKCR\" + "." + ext, null, ExeFilenameNoExt + "." + ext); RegistryHelp.SetValue($@"HKCR\" + "." + ext + @"\OpenWithProgIDs", ExeFilenameNoExt + "." + ext, ""); if (VideoTypes.Contains(ext)) { RegistryHelp.SetValue(@"HKCR\" + "." + ext, "PerceivedType", "video"); } if (AudioTypes.Contains(ext)) { RegistryHelp.SetValue(@"HKCR\" + "." + ext, "PerceivedType", "audio"); } if (ImageTypes.Contains(ext)) { RegistryHelp.SetValue(@"HKCR\" + "." + ext, "PerceivedType", "image"); } RegistryHelp.SetValue($@"HKCR\" + ExeFilenameNoExt + "." + ext + @"\shell\open\command", null, $"\"{ExePath}\" \"%1\""); RegistryHelp.SetValue(@"HKLM\SOFTWARE\Clients\Media\mpv.net\Capabilities\FileAssociations", "." + ext, ExeFilenameNoExt + "." + ext); } }
public void SetAudioSize(AudioTypes type, float volume) { switch (type) { case AudioTypes.Bgm: BgMusicVolum = volume; _backgroundAudioSource.volume = volume; break; case AudioTypes.Dubbing: DubbingVolum = volume; _dubbingAudioSource.volume = volume; break; case AudioTypes.Effect: EffectVolume = volume; for (int i = 0; i < _effectAudioSources.Count; i++) { _effectAudioSources[i].volume = volume; } break; } }
public void ChooseAudio(AudioTypes audio) { switch (audio) { case AudioTypes.click: _clickAudio.Play(); break; case AudioTypes.moveDown: _moveDownAudio.Play(); break; case AudioTypes.rotate: _rotateAudio.Play(); break; case AudioTypes.destroyTiles: _destroyTilesAudio.Play(); break; case AudioTypes.lose: _loseAudio.Play(); break; default: break; } }
/// <summary> /// Ermittelt für eine Art von Tonspur alle aktiven Datenströme. /// </summary> /// <param name="type">Die gewünschte Art der Tonspur.</param> /// <param name="selected">Die aktive Auswahl der Tonspuren.</param> /// <param name="requested">Die gewünschten Sprachen.</param> private void ProcessAudioSelection( AudioTypes type, LanguageSelection selected, LanguageSelection requested ) { // Get method for adding streams Func<string, StreamBase> addConsumer; if (type == AudioTypes.MP2) addConsumer = m_TransportStream.AddAudio; else addConsumer = m_TransportStream.AddDolby; // Preset mode selected.LanguageMode = LanguageModes.All; // All audio foreach (var audio in m_OriginalSettings.AudioTracks) if (type == audio.AudioType) { // Check for primary if (requested.LanguageMode == LanguageModes.Primary) { // Register AddConsumer( audio.AudioStream, StreamTypes.Audio, addConsumer( audio.Language.ToISOLanguage() ) ); // Copy over selected.LanguageMode = LanguageModes.Primary; // Remember selected.Languages.Add( audio.Language ); // Done return; } // Regular test if (requested.Contains( audio.Language )) { // Register AddConsumer( audio.AudioStream, StreamTypes.Audio, addConsumer( audio.Language.ToISOLanguage() ) ); // Remember selected.Languages.Add( audio.Language ); } else { // Not all selected.LanguageMode = LanguageModes.Selection; } } // Clear flag if no audio is used if (selected.LanguageMode == LanguageModes.All) if (selected.Languages.Count < 1) selected.LanguageMode = LanguageModes.Selection; }
// observer function called when audio settings values change private void OnAudioChange(AudioTypes audioType, float value) { SetVolume(audioType, value); }
private bool ReportChannelPosition(Channel? channel, string trackId, AudioTypes audioType, ref int? lastPos) { if (channel.HasValue) { var chn = channel.Value; int? pos = (int?)chn.GetPosition(TimeUnit.Milliseconds); if (pos == lastPos) return false; lastPos = pos; if (pos.HasValue) { SendMessage(new AudioPositionChanged { Id = trackId, Type = audioType, Position = pos.Value }); return true; } } lastPos = null; return false; }
public IMultimediaStudyMaterial GetAudio(int Id, AudioTypes audioType) { return(new Audio(audioType)); }
public Audio(AudioTypes audioType) { _audioType = audioType; }
public static ISound New(AudioTypes audioType, IDisposableResource parent, string filename, int instanceCount, bool looped, Loader.LoadedCallbackMethod loadedCallback) { ISound api = null; var soundFormat = SoundFormats.None; string ext = Streams.GetFileExt(filename); switch (ext.ToLower()) { case ".wav": soundFormat = SoundFormats.WAV; break; default: Debug.ThrowError("SoundAPI", string.Format("File 'ext' {0} not supported.", ext)); return(null); } #if WIN32 || WINRT if (soundFormat == SoundFormats.WAV) { if (audioType == AudioTypes.XAudio) { api = new XAudio.SoundWAV(parent, filename, instanceCount, looped, loadedCallback); } } #endif #if XNA if (soundFormat == SoundFormats.WAV) { if (audioType == AudioTypes.XNA) { api = new XNA.SoundWAV(parent, filename, instanceCount, looped, loadedCallback); } } #endif #if OSX || iOS if (soundFormat == SoundFormats.WAV) { if (audioType == AudioTypes.Cocoa) { api = new Cocoa.SoundWAV(parent, filename, instanceCount, looped, loadedCallback); } } #endif #if LINUX if (soundFormat == SoundFormats.WAV) { if (audioType == AudioTypes.OpenAL) { api = new OpenAL.SoundWAV(parent, filename, instanceCount, looped, loadedCallback); } } #endif #if ANDROID if (soundFormat == SoundFormats.WAV) { if (audioType == AudioTypes.Android) { api = new Android.SoundWAV(parent, filename, instanceCount, looped, loadedCallback); } } #endif if (audioType == AudioTypes.Dumby) { api = new Dumby.SoundWAV(parent, filename, instanceCount, looped, loadedCallback); } if (api == null) { Debug.ThrowError("SoundAPI", "Unsuported InputType: " + audioType); } return(api); }
public LanguageItem(string language, AudioTypes effect) { // Remember ISOLanguage = language; Effect = effect; }
private void btnVideo_Click(object sender, EventArgs e) { errProv.Dispose(); try { if (txtFileSamp.Text == "") { throw new Exception("No file chosen."); } else if (!File.Exists(txtFileSamp.Text)) { throw new Exception("That file does not exist, and thus can't be ran."); } string ext = Path.GetExtension(txtFileSamp.Text); if (VideoTypes.Contains(ext.ToLower())) { Video videoFile = new Video(txtFileSamp.Text); videoFile.ViewFile(); } else if (GraphicTypes.Contains(ext.ToLower())) { Graphic graphicFile = new Graphic(txtFileSamp.Text); graphicFile.ViewFile(); } else if (AudioTypes.Contains(ext.ToLower())) { Audio audioFile = new Audio(txtFileSamp.Text); audioFile.ViewFile(); } else if (ArchiveTypes.Contains(ext.ToLower())) { Archive archiveFile = new Archive(txtFileSamp.Text); archiveFile.ViewFile(); } else if (DocumentTypes.Contains(ext.ToLower())) { Document docFile = new Document(txtFileSamp.Text); docFile.ViewFile(); } else { throw new Exception("File type not found: the chosen file type is not supported."); //System.IO.FileInfo newFile = new System.IO.FileInfo(txtFileSamp.Text); //System.IO.FileAttributes b = newFile.Attributes; } } catch (Exception ex) { errProv.SetError(btnDisplay, ex.Message); } }
public static IAudio New(AudioTypes audioTypeFlags, out AudioTypes audioType, IDisposableResource parent) { bool dumby = (audioTypeFlags & AudioTypes.Dumby) != 0; bool xAudio = (audioTypeFlags & AudioTypes.XAudio) != 0; bool xna = (audioTypeFlags & AudioTypes.XNA) != 0; bool cocoa = (audioTypeFlags & AudioTypes.Cocoa) != 0; bool openAL = (audioTypeFlags & AudioTypes.OpenAL) != 0; bool android = (audioTypeFlags & AudioTypes.Android) != 0; bool nacl = (audioTypeFlags & AudioTypes.NaCl) != 0; audioType = AudioTypes.None; Exception lastException = null; IAudio audio = null; while (true) { try { #if WIN32 || WINRT if (xAudio) { xAudio = false; audioType = AudioTypes.XAudio; audio = new Reign.Audio.XAudio.Audio(parent); break; } else #endif #if XNA if (xna) { xna = false; audioType = AudioTypes.XNA; audio = new Reign.Audio.XNA.Audio(parent); break; } else #endif #if OSX || iOS if (cocoa) { cocoa = false; audioType = AudioTypes.Cocoa; audio = new Reign.Audio.Cocoa.Audio(parent); break; } else #endif #if LINUX if (openAL) { openAL = false; audioType = AudioTypes.OpenAL; audio = new Reign.Audio.OpenAL.Audio(parent); break; } else #endif #if ANDROID if (android) { android = false; audioType = AudioTypes.Android; audio = new Reign.Audio.Android.Audio(parent); break; } else #endif #if NaCl if (nacl) { throw new NotImplementedException(); } else #endif if (dumby) { dumby = false; audioType = AudioTypes.Dumby; audio = new Reign.Audio.Dumby.Audio(parent); break; } else { break; } } catch (Exception e) { lastException = e; } } // check for error if (lastException != null) { string ex = lastException == null ? "" : " - Exception: " + lastException.Message; Debug.ThrowError("AudioAPI", "Failed to create Audio API" + ex); audioType = AudioTypes.None; } if (audioType != AudioTypes.None) { DefaultAPI = audioType; } return(audio); }
/// <summary> /// Erstellt eine neue Sprache. /// </summary> /// <param name="language">Die Sprach in <i>ISO</i> Notation.</param> /// <param name="effect">Details zum Imhalt der Sprachkomponente.</param> public LanguageItem(string language, AudioTypes effect) { // Remember ISOLanguage = language; Effect = effect; }
public static void ShowInfo() { try { string performer, title, album, genre, date, duration, text = ""; long fileSize = 0; string path = core.get_property_string("path"); if (path.Contains("://")) { path = core.get_property_string("media-title"); } int width = core.get_property_int("video-params/w"); int height = core.get_property_int("video-params/h"); if (File.Exists(path)) { fileSize = new FileInfo(path).Length; if (AudioTypes.Contains(path.Ext())) { using (MediaInfo mediaInfo = new MediaInfo(path)) { performer = mediaInfo.GetInfo(MediaInfoStreamKind.General, "Performer"); title = mediaInfo.GetInfo(MediaInfoStreamKind.General, "Title"); album = mediaInfo.GetInfo(MediaInfoStreamKind.General, "Album"); genre = mediaInfo.GetInfo(MediaInfoStreamKind.General, "Genre"); date = mediaInfo.GetInfo(MediaInfoStreamKind.General, "Recorded_Date"); duration = mediaInfo.GetInfo(MediaInfoStreamKind.Audio, "Duration/String"); if (performer != "") { text += "Artist: " + performer + "\n"; } if (title != "") { text += "Title: " + title + "\n"; } if (album != "") { text += "Album: " + album + "\n"; } if (genre != "") { text += "Genre: " + genre + "\n"; } if (date != "") { text += "Year: " + date + "\n"; } if (duration != "") { text += "Length: " + duration + "\n"; } text += "Size: " + mediaInfo.GetInfo(MediaInfoStreamKind.General, "FileSize/String") + "\n"; text += "Type: " + path.Ext().ToUpper(); core.commandv("show-text", text, "5000"); return; } } else if (ImageTypes.Contains(path.Ext())) { using (MediaInfo mediaInfo = new MediaInfo(path)) { text = "Width: " + mediaInfo.GetInfo(MediaInfoStreamKind.Image, "Width") + "\n" + "Height: " + mediaInfo.GetInfo(MediaInfoStreamKind.Image, "Height") + "\n" + "Size: " + mediaInfo.GetInfo(MediaInfoStreamKind.General, "FileSize/String") + "\n" + "Type: " + path.Ext().ToUpper(); core.commandv("show-text", text, "5000"); return; } } } TimeSpan position = TimeSpan.FromSeconds(core.get_property_number("time-pos")); TimeSpan duration2 = TimeSpan.FromSeconds(core.get_property_number("duration")); string videoFormat = core.get_property_string("video-format").ToUpper(); string audioCodec = core.get_property_string("audio-codec-name").ToUpper(); text = path.FileName() + "\n" + FormatTime(position.TotalMinutes) + ":" + FormatTime(position.Seconds) + " / " + FormatTime(duration2.TotalMinutes) + ":" + FormatTime(duration2.Seconds) + "\n" + $"{width} x {height}\n"; if (fileSize > 0) { text += Convert.ToInt32(fileSize / 1024.0 / 1024.0) + " MB\n"; } text += $"{videoFormat}\n{audioCodec}"; core.commandv("show-text", text, "5000"); string FormatTime(double value) => ((int)value).ToString("00"); } catch (Exception e) { App.ShowException(e); } }
public static IAudio New(AudioTypes audioTypeFlags, out AudioTypes audioType, IDisposableResource parent) { bool dumby = (audioTypeFlags & AudioTypes.Dumby) != 0; bool xAudio = (audioTypeFlags & AudioTypes.XAudio) != 0; bool xna = (audioTypeFlags & AudioTypes.XNA) != 0; bool cocoa = (audioTypeFlags & AudioTypes.Cocoa) != 0; bool openAL = (audioTypeFlags & AudioTypes.OpenAL) != 0; bool android = (audioTypeFlags & AudioTypes.Android) != 0; bool nacl = (audioTypeFlags & AudioTypes.NaCl) != 0; audioType = AudioTypes.None; Exception lastException = null; IAudio audio = null; while (true) { try { #if WIN32 || WINRT if (xAudio) { xAudio = false; audioType = AudioTypes.XAudio; audio = new Reign.Audio.XAudio.Audio(parent); break; } else #endif #if XNA if (xna) { xna = false; audioType = AudioTypes.XNA; audio = new Reign.Audio.XNA.Audio(parent); break; } else #endif #if OSX || iOS if (cocoa) { cocoa = false; audioType = AudioTypes.Cocoa; audio = new Reign.Audio.Cocoa.Audio(parent); break; } else #endif #if LINUX if (openAL) { openAL = false; audioType = AudioTypes.OpenAL; audio = new Reign.Audio.OpenAL.Audio(parent); break; } else #endif #if ANDROID if (android) { android = false; audioType = AudioTypes.Android; audio = new Reign.Audio.Android.Audio(parent); break; } else #endif #if NaCl if (nacl) { throw new NotImplementedException(); } else #endif if (dumby) { dumby = false; audioType = AudioTypes.Dumby; audio = new Reign.Audio.Dumby.Audio(parent); break; } else break; } catch (Exception e) { lastException = e; } } // check for error if (lastException != null) { string ex = lastException == null ? "" : " - Exception: " + lastException.Message; Debug.ThrowError("AudioAPI", "Failed to create Audio API" + ex); audioType = AudioTypes.None; } if (audioType != AudioTypes.None) DefaultAPI = audioType; return audio; }