Playing Wave files with the Audio routines?
-
Hi, does anyone one know what sort of wave header the My.Computer.Audio Play routines require? I am creating wave files with a basic standard header, which play fine in Windows Media Player, Audacity, VLC etc, but as soon as I try to play them in the program using Play, it says the header is corrupt. These are very low sample rate files. Could that have something to do with it? They are often as low as 600 Hz (Sound files of seismic activity). They are PCM 16 bit uncompressed. The help (VB/MSDN and various other sources) gives very little detail, and anyway details of wave files seems to be difficult to come by unless you are takling music/stereo/44000 sample rate etc. Still working my way trough 13,600 entries on MSDN but nothing relevant sp far!
-
Hi, does anyone one know what sort of wave header the My.Computer.Audio Play routines require? I am creating wave files with a basic standard header, which play fine in Windows Media Player, Audacity, VLC etc, but as soon as I try to play them in the program using Play, it says the header is corrupt. These are very low sample rate files. Could that have something to do with it? They are often as low as 600 Hz (Sound files of seismic activity). They are PCM 16 bit uncompressed. The help (VB/MSDN and various other sources) gives very little detail, and anyway details of wave files seems to be difficult to come by unless you are takling music/stereo/44000 sample rate etc. Still working my way trough 13,600 entries on MSDN but nothing relevant sp far!
Sorry, jumped the gun. I found the answer. Seems to be a bug you can get round with:
Private player As New System.Media.SoundPlayer() Public Sub PlaySound(ByVal sound As Stream) sound.Position = 0 ' Manually rewind stream player.Stream = Nothing ' Then we have to set stream to null player.Stream = sound ' And set it again, to force it to be loaded again... player.Play() ' Yes! We can play the sound! End Sub
Apparently when you use the Audio Play it starts the end of the stream for some reason.