/// <summary> /// Initializes a new instance of the <see cref="AudioEngine"/> class with the default audio device. /// </summary> /// <param name="device">Device on which to create the audio engine.</param> /// <param name="sampleRate">The desired sample rate of the audio graph. 0 let the engine choose the best value depending on the hardware.</param> /// <exception cref="AudioInitializationException">Initialization of the audio engine failed. May be due to memory problems or missing audio hardware.</exception> public AudioEngine(AudioDevice device, uint sampleRate = 0) { State = AudioEngineState.Running; AudioSampleRate = sampleRate; audioDevice = device; }
internal override void InitializeAudioEngine(AudioDevice device) { mediaPlayer.Completion += OnMusicCompletion; mediaPlayer.Error += OnMusicError; mediaPlayer.Prepared += OnMusicPrepared; if(nbOfAudioEngineInstances == 0) SoundEffectInstance.CreateAudioTracks(); }
private void AudioEngineImpl(AudioDevice device) { mediaPlayer.Completion += OnMusicCompletion; mediaPlayer.Error += OnMusicError; mediaPlayer.Prepared += OnMusicPrepared; if(nbOfAudioEngineInstances == 0) SoundEffectInstance.CreateAudioTracks(); }
/// <summary> /// Create the Audio Engine on the specified device. /// </summary> /// <param name="device">Device on which to create the audio engine.</param> /// <param name="sampleRate">The desired sample rate of the audio graph. 0 let the engine choose the best value depending on the hardware.</param> /// <remarks>Available devices can be queried by calling static method <see cref="GetAvailableDevices"/></remarks> /// <exception cref="AudioInitializationException">Initialization of the audio engine failed. May be due to memory problems or missing audio hardware.</exception> private AudioEngine(AudioDevice device, uint sampleRate = 0) { if (device != null) throw new NotImplementedException(); State = AudioEngineState.Running; AudioSampleRate = sampleRate; InitializeAudioEngine(device); ++nbOfAudioEngineInstances; }
/// <inheritDoc/> internal override void InitializeAudioEngine(AudioDevice device) { // Initialize SDL Audio part SDL.SDL_InitSubSystem(SDL.SDL_INIT_AUDIO); // Initialize SDL Mixer part SDL_mixer.MIX_InitFlags requestedFlags = SDL_mixer.MIX_InitFlags.MIX_INIT_FLAC | SDL_mixer.MIX_InitFlags.MIX_INIT_MP3 | SDL_mixer.MIX_InitFlags.MIX_INIT_OGG | SDL_mixer.MIX_InitFlags.MIX_INIT_MOD | SDL_mixer.MIX_InitFlags.MIX_INIT_FLUIDSYNTH; int flags = SDL_mixer.Mix_Init(requestedFlags); // TODO: Check `flags' to see if underlying platform supports all formats }
// This region is currently nor implemented nor exposed to the client internal override void InitializeAudioEngine(AudioDevice device) { try { XAudio2 = new XAudio2(); X3DAudio = new X3DAudio(Speakers.Stereo); // only stereo mode currently supported XAudio2.CriticalError += XAudio2OnCriticalError; MasteringVoice = new MasteringVoice(XAudio2, 2, (int)AudioSampleRate); // Let XAudio choose an adequate sampling rate for the platform and the configuration but not number of channels [force to stereo 2-channels]. if (!mediaEngineStarted) { // MediaManager.Startup(); <- MediaManager.Shutdown is buggy (do not set isStartUp to false) so we are forced to directly use MediaFactory.Startup here while sharpDX is not corrected. MediaFactory.Startup(0x20070, 0); mediaEngineStarted = true; } InitImpl(); } catch (DllNotFoundException exp) { State = AudioEngineState.Invalidated; Logger.Warning("One or more of the XAudio and MediaFoundation dlls were not found on the computer. " + "Audio functionalities will not fully work for the current game instance." + "To fix the problem install or repair the installation of XAudio and Media Foundation. [Exception details: {0}]", exp.Message); } catch (SharpDX.SharpDXException exp) { State = AudioEngineState.Invalidated; if (exp.ResultCode == XAudioErrorCodes.ErrorInvalidCall) { Logger.Warning("Initialization of the audio engine failed. This may be due to missing audio hardware or missing audio outputs. [Exception details: {0}]", exp.Message); } else if (exp.ResultCode == 0x8007007E) { Logger.Warning( "Audio engine initialization failed. This is probably due to missing dll on your computer. " + "Please check that XAudio2 and MediaFoundation are correctly installed.[Exception details: {0}]", exp.Message); } else { Logger.Warning("Audio engine initialization failed. [Exception details: {0}]", exp.Message); } } }
private void AudioEngineImpl(AudioDevice device) { if (nbOfAudioEngineInstances == 0) ActivateAudioSession(); }
/// <summary> /// Initialize audio engine for <paramref name="device"/>. /// </summary> /// <param name="device">Device to use for initialization</param> internal abstract void InitializeAudioEngine(AudioDevice device);
internal override void InitializeAudioEngine(AudioDevice device) { if (nbOfAudioEngineInstances == 0) ActivateAudioSession(); }