/// <summary> /// Initializes a new instance of the <see cref="AudioPlayer"/> class. /// </summary> /// <param name="pipeline">The pipeline to add the component to.</param> /// <param name="configuration">The component configuration.</param> public AudioPlayer(Pipeline pipeline, AudioPlayerConfiguration configuration) : base(pipeline) { pipeline.RegisterPipelineStartHandler(this, this.OnPipelineStart); pipeline.RegisterPipelineStopHandler(this, this.OnPipelineStop); this.pipeline = pipeline; this.configuration = configuration; this.frameSize = this.configuration.Format.Channels * configuration.Format.BitsPerSample / 8; }
/// <summary> /// Initializes a new instance of the <see cref="AudioPlayer"/> class. /// </summary> /// <param name="pipeline">The pipeline to add the component to.</param> /// <param name="configuration">The component configuration.</param> /// <param name="name">An optional name for this component.</param> public AudioPlayer(Pipeline pipeline, AudioPlayerConfiguration configuration, string name = nameof(AudioPlayer)) : base(pipeline, name) { pipeline.PipelineRun += (s, e) => this.OnPipelineRun(); this.In.Unsubscribed += _ => this.OnUnsubscribed(); this.pipeline = pipeline; this.configuration = configuration; this.frameSize = this.configuration.Format.Channels * configuration.Format.BitsPerSample / 8; }
/// <summary> /// Initializes a new instance of the <see cref="AudioPlayer"/> class. /// </summary> /// <param name="pipeline">The pipeline to add the component to.</param> /// <param name="configuration">The component configuration.</param> public AudioPlayer(Pipeline pipeline, AudioPlayerConfiguration configuration) : base(pipeline) { this.pipeline = pipeline; this.configuration = configuration; this.currentInputFormat = configuration.InputFormat; this.AudioLevelInput = pipeline.CreateReceiver <double>(this, this.SetAudioLevel, nameof(this.AudioLevelInput)); this.AudioLevel = pipeline.CreateEmitter <double>(this, nameof(this.AudioLevel)); this.wasapiRender = new WasapiRender(); this.wasapiRender.Initialize(configuration.DeviceName); if (configuration.AudioLevel >= 0) { this.wasapiRender.AudioLevel = configuration.AudioLevel; } }
/// <summary> /// Initializes a new instance of the <see cref="AudioPlayer"/> class. /// </summary> /// <param name="pipeline">The pipeline to add the component to.</param> /// <param name="configuration">The component configuration.</param> public AudioPlayer(Pipeline pipeline, AudioPlayerConfiguration configuration) : base(pipeline) { this.pipeline = pipeline; this.configuration = configuration; this.currentInputFormat = configuration.InputFormat; this.AudioLevelInput = pipeline.CreateReceiver <double>(this, this.SetAudioLevel, nameof(this.AudioLevelInput)); this.AudioLevel = pipeline.CreateEmitter <double>(this, nameof(this.AudioLevel)); this.audioRenderDevice = new AudioRenderer(); this.audioRenderDevice.Initialize(configuration.DeviceName); this.pipeline.PipelineCompletionEvent += this.OnPipelineCompletionEvent; if (configuration.AudioLevel >= 0) { this.audioRenderDevice.AudioLevel = configuration.AudioLevel; } }
/// <summary> /// Initializes a new instance of the <see cref="AudioPlayer"/> class. /// </summary> /// <param name="pipeline">The pipeline to add the component to.</param> /// <param name="configuration">The component configuration.</param> public AudioPlayer(Pipeline pipeline, AudioPlayerConfiguration configuration) : base(pipeline) { pipeline.RegisterPipelineStartHandler(this, this.OnPipelineStart); pipeline.RegisterPipelineStopHandler(this, this.OnPipelineStop); this.pipeline = pipeline; this.configuration = configuration; this.currentInputFormat = configuration.InputFormat; this.AudioLevelInput = pipeline.CreateReceiver <double>(this, this.SetAudioLevel, nameof(this.AudioLevelInput)); this.AudioLevel = pipeline.CreateEmitter <double>(this, nameof(this.AudioLevel)); this.wasapiRender = new WasapiRender(); this.wasapiRender.Initialize(configuration.DeviceName); this.pipeline.PipelineCompletionEvent += this.OnPipelineCompletionEvent; if (configuration.AudioLevel >= 0) { this.wasapiRender.AudioLevel = configuration.AudioLevel; } }