/// <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, AudioConfiguration configuration) : base(pipeline) { this.pipeline = pipeline; this.configuration = configuration; this.frameSize = configuration.Format.BitsPerSample / 8; }
/// <summary> /// Initializes a new instance of the <see cref="AudioSource"/> class. /// </summary> /// <param name="pipeline">The pipeline to add the component to.</param> /// <param name="configuration">The component configuration.</param> public AudioSource(Pipeline pipeline, AudioConfiguration configuration) { pipeline.RegisterPipelineStartHandler(this, this.OnPipelineStart); pipeline.RegisterPipelineStopHandler(this, this.OnPipelineStop); this.pipeline = pipeline; this.configuration = configuration; this.audioBuffers = pipeline.CreateEmitter <AudioBuffer>(this, "AudioBuffers"); }
/// <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, AudioConfiguration 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> /// Convert supported `AudioConfiguration` to interop `Format`. /// </summary> /// <remarks> /// Only 8-, 16- and 32-bit PCM and 32- or 64-bit float are supported. /// </remarks> /// <param name="config">Audio configuration</param> /// <returns>Converted interop `Format`</returns> internal static Format ConfigurationFormat(AudioConfiguration config) { switch (config.Format.FormatTag) { case WaveFormatTag.WAVE_FORMAT_PCM: switch (config.Format.BitsPerSample) { case 8: return(LinuxAudioInterop.Format.S8); case 16: return(LinuxAudioInterop.Format.S16LE); case 32: return(LinuxAudioInterop.Format.S32LE); default: throw new ArgumentException("Only 8, 16 and 32 bits per sample are supported for PCM."); } case WaveFormatTag.WAVE_FORMAT_IEEE_FLOAT: switch (config.Format.BitsPerSample) { case 32: return(LinuxAudioInterop.Format.F32LE); case 64: return(LinuxAudioInterop.Format.F64LE); default: throw new ArgumentException("Only 16 and 32 bits per sample are supported for IEEE float."); } default: throw new ArgumentException("Only PCM and IEEE Float wave formats supported."); } }
/// <summary> /// Initializes a new instance of the <see cref="AudioSource"/> class. /// </summary> /// <param name="pipeline">The pipeline to add the component to.</param> /// <param name="configuration">The component configuration.</param> public AudioSource(Pipeline pipeline, AudioConfiguration configuration) { this.pipeline = pipeline; this.configuration = configuration; this.audioBuffers = pipeline.CreateEmitter <AudioBuffer>(this, "AudioBuffers"); }