Since this line is commented out:
int block_align = buffer [idx++] | (buffer [idx++] << 8);
you will ran into a "bits per sample" exception.
Adding the two increpements (idx+=2) will solve it.
Fix bug and improve performance of audio data play methode :
- Read only wave/Au raw data from Stream unstead of the whole file
- Play Sound chunk by chunk (chunk size compute at AudioDevice.setFormat call)
this is the best size compute by alsa for the hardware (better than the 4kB arbitrary size)
- Fix the chunk size to play. For Alsa, this size is in fragment, a fragment is one sample per channel
- count the data which are really play by alsa (snd_pcm_writei return a fragment size) and the next
chunk from that count.
Signed-off-by: Florent Valette <[email protected]>
Improve the configuration of the Alsa hardware parameters.
The buffer and chunk size are set to the best suitable size according to wave file
caracteristic, i.e., format, channel and sampling rate.
Add Alsa software parameter.
Alsa becomes in Ready State as soon as there is a data chunk in its ring buffer.
Alsa starts playing data as soon as its buffer is full.
Add a UnderRun recovery method while playing a sound. When a underRun occurs, Alsa
layer need to be re set to Ready State (by calling snd_pcm_prepare) and the data chunk
is re send to Alsa.
Signed-off-by: Florent Valette <[email protected]>
Some wave file had a 'fact' chunk in header's data.
This is specified for non-PCM format but some PCM wave sound file could have one.
These kind of file are played well by System.Media.SoundPlay on win32 system but no
sound is played at all on unix system because the 'data' chunk is not found. This
patch adds support for wave file which have this optional 'fact' chunk in header's data.
It's also read chunk data according to the chunk size.
Signed-off-by: Florent Valette <[email protected]>
Modulo the GUID in the assembly and the GUID embedded in some
field initializers that use the assembly GUID for their name, the
assemblies are idential before and after the patch.
Fixed ctor (Stream) to allow null argument. In LoadFromUri, first
reset mstream to support resetting Stream to null. Support playing
default sound. Allow Stream to be set to null. Reset AudioData and
WaveData when new stream is loaded.
* Win32SoundPlayer.cs: Wrapper for PlaySound Win32 API.
* System.dll.sources: Added Win32SoundPlayer.cs.
* SoundPlayerTest.cs: Added trivial ctor tests. Added test for
Stream property.
svn path=/trunk/mcs/; revision=89112
* AudioData.cs: Reset stream to position 0 before playing (required
when playing the audio in a loop). Part of the fix for bug #338991.
* SoundPlayer.cs: Only create the AudioData once (and reuse it).
Part of the fix for bug #338991.
svn path=/trunk/mcs/; revision=89027
* AudioData.cs, AudioDevice.cs: small (alsa) audio device and
Wav file parsing implementation.
* SoundPlayer.cs, SystemSound.cs: implemented most of the methods.
svn path=/trunk/mcs/; revision=69824