Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8974159
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T18:37:07+00:00 2026-06-15T18:37:07+00:00

I’m having a weird problem when playing a wav file (0.034 seconds long) embedded

  • 0

I’m having a weird problem when playing a wav file (0.034 seconds long) embedded as a resource on my VB.NET application.

My application is supposed to loop the sound asynchronously while the button is pressed and stop the sound when the button is released.

The problem is that there seems to be a delay when the button is pressed and released quickly, especially if it is clicked multiple times in a row.

This delay makes the audio sound choppy and it also hangs the application until the queue of calls to play() and stop() ends.

However, I noticed that if I have an audio player running (playing a sound file or paused, not in stop) simultaneously when running my application, the delay or latency is gone.

The players I have tested have been: Windows Media Player, Windows Media Player Classic – Home Cinema, Foobar2000 and QuickTime.

Here’s the code:

Option Explicit On
Option Strict On

Public Class frmMain

    Private btnPlayPressed As Boolean

    Public Sub New()
        ' This call is required by the designer.
        InitializeComponent()
        ' Add any initialization after the InitializeComponent() call.
        btnPlayPressed = False
    End Sub

    Private Sub btnPlay_MouseDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles btnPlay.MouseDown
        If Not btnPlayPressed Then
            My.Computer.Audio.Play(My.Resources.Beep, AudioPlayMode.BackgroundLoop)
            btnPlayPressed = True
        End If
    End Sub

    Private Sub btnPlay_MouseUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.MouseEventArgs) Handles btnPlay.MouseUp
        If btnPlayPressed Then
            My.Computer.Audio.Stop()
            btnPlayPressed = False
        End If
    End Sub

    Private Sub btnPlay_KeyDown(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles btnPlay.KeyDown
        If e.KeyCode.Equals(Keys.Space) Then
            btnPlay_MouseDown(sender, Nothing)
        End If
    End Sub

    Private Sub btnPlay_KeyUp(ByVal sender As System.Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles btnPlay.KeyUp
        If e.KeyCode.Equals(Keys.Space) Then
            btnPlay_MouseUp(sender, Nothing)
        End If
    End Sub

End Class

I have also used various of the other audio functions available in VB.NET and they all have this problem but I’m sticking with My.Computer.Audio because of it’s simplicity and readability.

Why does having audio players running remove the delay of My.Computer.Audio.play?
Is there a way to remove the delay from within my code?

Other details:
IDE: Visual Studio 2010 Express
OS: Vista sp2 x86/ Windows 7 x64

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T18:37:09+00:00Added an answer on June 15, 2026 at 6:37 pm

    There could be a couple reasons for this. The first might be that other software is specifically lowering the buffer size for playback. When this is done, there is lower delay.

    The second reason might have to do with the sampling rate. If there is a buffer size set in bytes and the sample rate doubles, then that buffer lasts half as long. If you are playing audio in your application at a certain rate, and other software plays at a different rate, then perhaps Windows’ audio mixing service adjusts the buffer differently.

    There is no way to remote delay completely. That’s not how digital audio works. However, you can reduce it significantly by using ASIO or similar.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want use html5's new tag to play a wav file (currently only supported
I've tracked down a weird MySQL problem to the two different ways I was
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I have just tried to save a simple *.rtf file with some websites and
I am currently running into a problem where an element is coming back from
In my XML file chapters tag has more chapter tag.i need to display chapters
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.