VideoOS.Platform.Data.AudioStreamPlayer Class Reference

Streams PCM data from an input stream to the OutgoingSpeakerController. More...

Inheritance diagram for VideoOS.Platform.Data.AudioStreamPlayer:
VideoOS.Platform.Data.IAudioRecorder

Public Member Functions

 AudioStreamPlayer (System.IO.Stream audioStream, bool readFormatFromStream=true)
 Class constructor.
 
override int CalcMeterValue (byte[] data, int dataLength)
 Calculate how much noice is in the audio stream.
 
override void Free ()
 Stops recording, and free resources.
 
override bool Initialize ()
 Call this to initialize. Reads the stream format from the stream input if the readFormatFromStream parameter (from the constructor) equals true.
 
override bool IsRecording ()
 Indicates if it is recording.
 
void ReadFormatFromStream ()
 Read the stream format from the stream input. It is called by the Initialize() function if the readFormatFromStream parameter equals true. Please note that it must be in RIFF / WAVE format.
 
override void StartRecording ()
 Starts recording.
 
override void StopRecording ()
 Stops recording.
 
- Public Member Functions inherited from VideoOS.Platform.Data.IAudioRecorder
delegate void AudioDataReadyEventHandler (object sender, AudioDataEventArgs e)
 Represents the method that will signal Audio Data Ready.
 
virtual void FireAudioDataReadyEvent (byte[] audioData)
 Activates the AudioDataReadyEvent.
 

Properties

virtual short BlockAlign [get, set]
 Set the Block align value. Alternatively call the ReadFormatFromStream.
 
virtual int DataSize [get, set]
 Set the total data size. The Player will stop when this number is reached. Alternatively call the ReadFormatFromStream.
 
virtual int ForwardSampleBlockSize [get, set]
 The number of Samples to forward to the Speaker at a time. Default is OutgoingAudioWaveFormatSamplesPerSecond / 20.
 
double Progress [get]
 If DataSize is set to a value > 0, then it returns a double value 0.0 .. 1.0 indicate the progress of the read process. Otherwise it returns -1.0.
 
- Properties inherited from VideoOS.Platform.Data.IAudioRecorder
virtual int OutgoingAudioWaveFormatSamplesPerSecond [get, set]
 Specify number of samples per second - default is 8000.
 
virtual int OutgoingWaveFormatBitsPerSample [get, set]
 Specify the bits per sample - default is 16.
 
virtual int OutgoingWaveFormatChannels [get, set]
 Number of channels, expected to be 1.
 

Events

EventHandler ProgressCompleteEvent
 This event is fired when the capture / read thread has completed.
 
- Events inherited from VideoOS.Platform.Data.IAudioRecorder
AudioDataReadyEventHandler AudioDataReadyEvent
 Signals Audio Data Ready.
 

Detailed Description

Streams PCM data from an input stream to the OutgoingSpeakerController.

It will pace the reading to match the sample rate except for a prebuffer read = 2 * ForwardSampleBlockSize samples. The default for ForwardSampleBlockSize is OutgoingAudioWaveFormatSamplesPerSecond / 20 = 50 msec of samples.

It assumes by default that the input is a WAV formatted input file and reads the settings from the WAV header, if created like this:

AudioStreamPlayer player = new AudioStreamPlayer(new System.IO.FileStream("MySound.wav"));
_outgoingSpeakerController.Init(player); <br>
_outgoingSpeakerController.ShowLive = true; // Obsolete, not used any more
_outgoingSpeakerController.Connect();
Streams PCM data from an input stream to the OutgoingSpeakerController.
Definition AudioStreamPlayer.cs:41
AudioStreamPlayer(System.IO.Stream audioStream, bool readFormatFromStream=true)
Class constructor.
Definition AudioStreamPlayer.cs:84

It may also be created with a binary stream without WAV header and then configured directly, like in

AudioStreamPlayer player = new AudioStream(myBinaryStream,false);
player.OutgoingWaveFormatChannels = 1;
player.OutgoingWaveFormatBitsPerSample = 16;
player.OutgoingAudioWaveFormatSamplesPerSecond = 8000;
player.BlockAlign = player.OutgoingWaveFormatChannels * player.OutgoingWaveFormatBitsPerSample / 8;
player.DataSize = 0; //To indicate that the number of bytes is unknown.
player.ForwardSampleBlockSize = OutgoingAudioWaveFormatSamplesPerSecond / 20; //==50 msec blocks is good
_outgoingSpeakerController.Init(player); <br>
_outgoingSpeakerController.ShowLive = true; // Obsolete, not used any more
_outgoingSpeakerController.Connect();
virtual int OutgoingAudioWaveFormatSamplesPerSecond
Specify number of samples per second - default is 8000.
Definition IAudioRecorder.cs:43

Constructor & Destructor Documentation

◆ AudioStreamPlayer()

VideoOS.Platform.Data.AudioStreamPlayer.AudioStreamPlayer ( System.IO.Stream audioStream,
bool readFormatFromStream = true )
inline

Class constructor.

Parameters
audioStream
readFormatFromStream

Member Function Documentation

◆ CalcMeterValue()

override int VideoOS.Platform.Data.AudioStreamPlayer.CalcMeterValue ( byte[] data,
int dataLength )
inlinevirtual

Calculate how much noice is in the audio stream.

Parameters
dataThe data received in the AudioDataReadyEvent
dataLengthThe langth
Returns
a value between 0 and 100

Reimplemented from VideoOS.Platform.Data.IAudioRecorder.

◆ Free()

override void VideoOS.Platform.Data.AudioStreamPlayer.Free ( )
inlinevirtual

Stops recording, and free resources.

Reimplemented from VideoOS.Platform.Data.IAudioRecorder.

◆ Initialize()

override bool VideoOS.Platform.Data.AudioStreamPlayer.Initialize ( )
inlinevirtual

Call this to initialize. Reads the stream format from the stream input if the readFormatFromStream parameter (from the constructor) equals true.

Reimplemented from VideoOS.Platform.Data.IAudioRecorder.

◆ IsRecording()

override bool VideoOS.Platform.Data.AudioStreamPlayer.IsRecording ( )
inlinevirtual

Indicates if it is recording.

Returns
True if recording.

Reimplemented from VideoOS.Platform.Data.IAudioRecorder.

◆ ReadFormatFromStream()

void VideoOS.Platform.Data.AudioStreamPlayer.ReadFormatFromStream ( )
inline

Read the stream format from the stream input. It is called by the Initialize() function if the readFormatFromStream parameter equals true. Please note that it must be in RIFF / WAVE format.

Any data chunks that we're not interested in like LIST metadata, will be ignored Multiple fmt/data chunks won't be allowed

◆ StartRecording()

override void VideoOS.Platform.Data.AudioStreamPlayer.StartRecording ( )
inlinevirtual

Starts recording.

Reimplemented from VideoOS.Platform.Data.IAudioRecorder.

◆ StopRecording()

override void VideoOS.Platform.Data.AudioStreamPlayer.StopRecording ( )
inlinevirtual

Stops recording.

Reimplemented from VideoOS.Platform.Data.IAudioRecorder.

Property Documentation

◆ BlockAlign

virtual short VideoOS.Platform.Data.AudioStreamPlayer.BlockAlign
getset

Set the Block align value. Alternatively call the ReadFormatFromStream.

◆ DataSize

virtual int VideoOS.Platform.Data.AudioStreamPlayer.DataSize
getset

Set the total data size. The Player will stop when this number is reached. Alternatively call the ReadFormatFromStream.

◆ ForwardSampleBlockSize

virtual int VideoOS.Platform.Data.AudioStreamPlayer.ForwardSampleBlockSize
getset

The number of Samples to forward to the Speaker at a time. Default is OutgoingAudioWaveFormatSamplesPerSecond / 20.

◆ Progress

double VideoOS.Platform.Data.AudioStreamPlayer.Progress
get

If DataSize is set to a value > 0, then it returns a double value 0.0 .. 1.0 indicate the progress of the read process. Otherwise it returns -1.0.

Event Documentation

◆ ProgressCompleteEvent

EventHandler VideoOS.Platform.Data.AudioStreamPlayer.ProgressCompleteEvent

This event is fired when the capture / read thread has completed.