Results 1 to 6 of 6

Thread: Can't hear WAVE file. No sound, no errors.

  1. #1

    Thread Starter
    New Member
    Join Date
    Sep 2025
    Posts
    5

    Can't hear WAVE file. No sound, no errors.

    Hi,

    I'm sure this has been done to death but I need some help to play a WAVE file.

    I'm using Windows 11 and VB.NET 2026.

    Code:
    Try
        'My.Computer.Audio.Play("e:\MyStuff\TestTone.wav", AudioPlayMode.WaitToComplete)
        My.Computer.Audio.Play(A, AudioPlayMode.WaitToComplete)
    Catch ex As Exception
        Stop
    End Try

    If tried both a file and a byte array, no luck.

    Any ideas?

  2. #2

    Thread Starter
    New Member
    Join Date
    Sep 2025
    Posts
    5

    Re: Can't hear WAVE file. No sound, no errors.

    Perhaps a bit more information.

    Decades ago I used a database called Clipper and it had a neat function that played a specified pitch for a specified duration.
    I wanted that ability in VB.NET.

    I created a function that creates a WAV file with a specified pitch and duration. PlayPitch(440, 1)
    Everything works except the play function.

    If I use Windows Explorer I can click on the file and I can hear the sound.

    Weird huh?

  3. #3

    Thread Starter
    New Member
    Join Date
    Sep 2025
    Posts
    5

    Re: Can't hear WAVE file. No sound, no errors.

    Hi Folks,

    A little sheepish here, I found the problem. I had a parameter wrong in the format chunk.
    After a great deal of detective work I found the issue.
    IT WORKS!


    I'm still confused as the original file played in the media player but not VB.NET

  4. #4
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,413

    Re: Can't hear WAVE file. No sound, no errors.

    VB.Net wave players are temperamental, but the rule is they must be PCM wav files. I’m not sure what caused your file not working though…

  5. #5
    eXtreme Programmer .paul.'s Avatar
    Join Date
    May 2007
    Location
    Chelmsford UK
    Posts
    26,413

    Re: Can't hear WAVE file. No sound, no errors.

    Just as a matter of curiosity, how are you creating the wav file? Do you mind sharing?

  6. #6
    Hyperactive Member -Franky-'s Avatar
    Join Date
    Dec 2022
    Location
    Bremen Germany
    Posts
    476

    Re: Can't hear WAVE file. No sound, no errors.

    If possible, you should avoid using the `My` namespace in VB.NET. This namespace does not exist in C#, which means your code would not be convertible to C#. It would be better to use the `System.Media` namespace instead of `My.Computer.Audio`. Alternatively, you also have the option of using Media Foundation for playback.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width