예제 #1
0
파일: AudioPlayer.cs 프로젝트: xiangzhi/psi
        /// <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;
            }
        }
예제 #2
0
        /// <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;
            }
        }
예제 #3
0
파일: AudioPlayer.cs 프로젝트: xiangzhi/psi
 /// <summary>
 /// Gets a list of available audio render devices.
 /// </summary>
 /// <returns>
 /// An array of available render device names.
 /// </returns>
 public static string[] GetAvailableDevices()
 {
     return(WasapiRender.GetAvailableRenderDevices());
 }
예제 #4
0
파일: AudioPlayer.cs 프로젝트: xiangzhi/psi
 /// <summary>
 /// Disposes the <see cref="AudioPlayer"/> object.
 /// </summary>
 public void Dispose()
 {
     this.StopRendering();
     this.wasapiRender.Dispose();
     this.wasapiRender = null;
 }
예제 #5
0
 /// <summary>
 /// Disposes the <see cref="AudioPlayer"/> object.
 /// </summary>
 public void Dispose()
 {
     this.OnPipelineStop();
     this.wasapiRender.Dispose();
     this.wasapiRender = null;
 }