public ALListener(IAudioErrors errors, IAudioBackend backend) { _errors = errors; _backend = backend; Volume = 0.5f; _location = new AGSLocation (); }
public static IAudioBackend CreateBackend(string filename) { var exlist = new List <Exception>(); foreach (var lazybackend in container.GetExports <Lazy <IAudioBackend> >()) { IAudioBackend backend = null; try { backend = lazybackend.Value; backend.LoadSong(filename); return(backend); } catch (Exception ex) { try { backend.Dispose(); } catch { } exlist.Add(ex); } } throw new Exception($"No backend could be found to play {filename}.\n\n{String.Join("\n\n", exlist)}\n"); }
public ALListener(IAudioErrors errors, IAudioBackend backend) { _errors = errors; _backend = backend; Volume = 0.5f; _location = new AGSLocation(); }
public ALListener(IAudioErrors errors, IAudioBackend backend) { _errors = errors; _backend = backend; Volume = 0.5f; _position = new Position(); }
public SandboxSystem(IAssetStore assetStore, IEngineManager engineManager, ISceneLoader sceneLoader, ISceneManager sceneManager, IAudioBackend audioBackend) { _assetStore = assetStore; _engineManager = engineManager; _sceneLoader = sceneLoader; _sceneManager = sceneManager; _audioPlayer = audioBackend.AudioPlayer; }
public Engine( Configuration configuration, IAudioBackend audioBackend, IInputBackend inputBackend, IRenderingBackend renderingBackend, IGame game) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } if (audioBackend == null) { throw new ArgumentNullException(nameof(audioBackend)); } if (inputBackend == null) { throw new ArgumentNullException(nameof(inputBackend)); } if (renderingBackend == null) { throw new ArgumentNullException(nameof(renderingBackend)); } if (game == null) { throw new ArgumentNullException(nameof(game)); } Log.Info("Initializing engine components."); var containerBuilder = new ContainerBuilder(); CommonModules.RegisterAll(containerBuilder); EngineModules.RegisterAll(containerBuilder); containerBuilder.RegisterInstance(configuration.Core).As <CoreConfiguration>().SingleInstance(); containerBuilder.RegisterInstance(configuration.Physics).As <PhysicsConfiguration>().SingleInstance(); containerBuilder.RegisterInstance(configuration.Rendering).As <RenderingConfiguration>().SingleInstance(); containerBuilder.RegisterInstance(audioBackend).As <IAudioBackend>().SingleInstance(); containerBuilder.RegisterInstance(inputBackend).As <IInputBackend>().SingleInstance(); containerBuilder.RegisterInstance(renderingBackend).As <IRenderingBackend>().SingleInstance(); var componentsRegistry = new ComponentsRegistry(containerBuilder); game.RegisterComponents(componentsRegistry); _container = containerBuilder.Build(); _lifetimeScope = _container.BeginLifetimeScope(); RunStartUpTasks(); _gameLoop = _lifetimeScope.Resolve <IGameLoop>(); _engineManager = _lifetimeScope.Resolve <IEngineManager>(); Log.Info("Engine components initialized."); }
public ALAudioClip(string id, ISoundData soundData, IAudioSystem system, IAudioErrors errors, IAudioBackend backend) { _soundData = soundData; _errors = errors; _backend = backend; ID = id; _buffer = new Lazy<int> (() => generateBuffer()); _system = system; Volume = 1f; Pitch = 1f; }
public ALAudioClip(string id, ISoundData soundData, IAudioSystem system, IAudioErrors errors, IAudioBackend backend) { _soundData = soundData; _errors = errors; _backend = backend; ID = id; _buffer = new Lazy <int> (() => generateBuffer()); _system = system; Volume = 1f; Pitch = 1f; }
public ALSound(int source, float volume, float pitch, bool isLooping, float panning, IAudioErrors errors, IAudioBackend backend) { _tcs = new TaskCompletionSource<object> (null); _backend = backend; _source = source; _volume = volume; _pitch = pitch; _panning = panning; IsLooping = isLooping; _errors = errors; }
public ALSound(int source, float volume, float pitch, bool isLooping, float panning, IAudioErrors errors, IAudioBackend backend) { _tcs = new TaskCompletionSource <object> (null); _backend = backend; _source = source; _volume = volume; _pitch = pitch; _panning = panning; IsLooping = isLooping; _errors = errors; }
public ALAudioClip(string id, ISoundData soundData, IAudioSystem system, IAudioErrors errors, IAudioBackend backend) { _soundData = soundData; _errors = errors; _backend = backend; ID = id; _buffer = new Lazy <int> (() => generateBuffer()); Duration = getDuration(soundData.DataLength, soundData.Channels, soundData.BitsPerSample, soundData.SampleRate); _playingSounds = new AGSConcurrentHashSet <ISound>(); _system = system; Volume = 1f; Pitch = 1f; }
public ALSound(int source, float duration, float volume, float pitch, bool isLooping, float panning, IConcurrentHashSet <string> tags, IAudioErrors errors, IAudioBackend backend) { //Using delegates to avoid heap allocations modifierChangeCallback = onModifierChanged; SoundModifiers = new AGSBindingList <ISoundModifier>(3); SoundModifiers.OnListChanged.Subscribe(onModifiersChanged); Tags = tags; _tcs = new TaskCompletionSource <object> (null); _backend = backend; _source = source; _volume = volume; Duration = duration; _pitch = pitch; _panning = panning; IsLooping = isLooping; _errors = errors; }
/// <summary> /// Completely stops and disposes the player and resets all playback related variables to their defaults. /// </summary> public void StopMusic() { if (!Playing) { return; } //outputDevice.Dispose(); //outputDevice = null; //AudioFile?.Dispose(); //AudioFile = null; currentBackend.Dispose(); currentBackend = null; Playing = false; Paused = false; SongStopped?.Invoke(null, EventArgs.Empty); //position = 0; }
public void SetUp() { _audioBackend = Substitute.For <IAudioBackend>(); _fileSystem = Substitute.For <IFileSystem>(); _assetStore = Substitute.For <IAssetStore>(); const string soundFilePath = "sound.wav"; const SoundFormat soundFormat = SoundFormat.Wav; const string assetFilePath = "sound-asset-path"; var soundAssetContent = new SoundAssetContent { SoundFilePath = soundFilePath }; _assetInfo = new AssetInfo(AssetId.CreateUnique(), AudioAssetTypes.Sound, assetFilePath); var assetData = AssetData.CreateWithJsonContent(_assetInfo.AssetId, _assetInfo.AssetType, soundAssetContent); var memoryStream = new MemoryStream(); assetData.Save(memoryStream); memoryStream.Position = 0; var assetFile = Substitute.For <IFile>(); assetFile.OpenRead().Returns(memoryStream); _fileSystem.GetFile(assetFilePath).Returns(assetFile); var soundFile = Substitute.For <IFile>(); var stream = Substitute.For <Stream>(); soundFile.OpenRead().Returns(stream); _fileSystem.GetFile(soundFilePath).Returns(soundFile); _sound = Substitute.For <ISound>(); _audioBackend.CreateSound(stream, soundFormat).Returns(_sound); _soundAssetLoader = new SoundAssetLoader(_audioBackend, _fileSystem); }
public ALErrors(IAudioBackend backend) { _backend = backend; }
public SandboxSceneBehavior(Scene scene, IAssetStore assetStore, IAudioBackend audioBackend) : base(scene) { _assetStore = assetStore; _audioPlayer = audioBackend.AudioPlayer; }
public SandboxSceneBehaviorFactory(IAssetStore assetStore, IAudioBackend audioBackend) { _assetStore = assetStore; _audioBackend = audioBackend; }
public YoutubePlayer(IAudioBackend backend) { _client = new YoutubeClient(WebHelper.CreateHttpClient()); _backend = backend; }
/// <summary> /// Starts playing the Queue. In order to play a track, you must first add it to the Queue using <see cref="AddQueue(string)"/>. /// </summary> /// <param name="repeat">If true, avoids dequeuing the next track. Not to be used for anything other than the player.</param> public void PlayMusic(bool repeat = false) { if (!repeat && Queue.Count != 0) { FilePath = Queue[QueuePosition]; } QueuePosition++; void PMusic() { //TODO: Check if FilePath is a file //maybe we can use cd://2 for CD track 2, and anything else we can use the NAudio backend? if (true) { currentBackend = new NAudioBackend(FilePath); } currentBackend.Play(); currentBackend.Volume = CurrentVolume; currentBackend.OnPlaybackStopped += OnPlaybackStopped; Playing = true; } try { if (Playing != true) { PMusic(); } else { AvoidNextQueue = true; StopMusic(); PMusic(); } SongChanged?.Invoke(null, EventArgs.Empty); // Now that playback has started without any issues, fire the song changed event. } catch (System.IO.FileNotFoundException) { var args = new PlaybackExceptionEventArgs { Details = "That's not a valid file path!" }; SongException?.Invoke(null, args); } catch (ArgumentException) { var args = new PlaybackExceptionEventArgs { Details = "That's not a valid file path!" }; SongException?.Invoke(null, args); } catch (System.Runtime.InteropServices.COMException) { var args = new PlaybackExceptionEventArgs { Details = "This isn't a valid audio file!" }; SongException?.Invoke(null, args); } catch (FormatException) { var args = new PlaybackExceptionEventArgs { Details = "This audio file might be corrupt!" }; SongException?.Invoke(null, args); } catch (InvalidOperationException) { var args = new PlaybackExceptionEventArgs { Details = "This audio file uses VBR \nor might be corrupt!" }; SongException?.Invoke(null, args); } catch (Exception e) { var args = new PlaybackExceptionEventArgs { Details = $"{e.Message}\n{e.StackTrace}" }; SongException?.Invoke(null, args); } }
public ALAudioSystem(IAudioBackend backend, IAudioListener listener, IAudioErrors errors) { _backend = backend; Listener = listener; _errors = errors; }
public AudioSystem(IAudioBackend audioBackend) { _audioPlayer = audioBackend.AudioPlayer; }
public EntityFactory(IAssetStore assetStore, IAudioBackend audioBackend) { _assetStore = assetStore; _audioPlayer = audioBackend.AudioPlayer; }
public SoundAssetLoader(IAudioBackend audioBackend, IFileSystem fileSystem) { _audioBackend = audioBackend; _fileSystem = fileSystem; }