I've read around that playing WAV files from resources using My.Computer.Audio.Play causes horrid distortion when playing the sound, and I've experienced this myself. I cannot, however, use WaitToComplete, because the sounds are associated with a timer that cannot stop for anything, as it is an official competition timer.

Also, I'm having an issue with the application being extremely slow when loading data from an Excel file. Essentially, the program has a grid of labels with transparent backgrounds (which seems to make the speed issue worse). The program uses the MS Office library to pull data from a spreadsheet, then output cells to one label at a time. This unfortunately, causes the application to nearly freeze, which also stops the timer, which as I said above, cannot happen.

Code snippets are available upon request, and there's a video of the issue from long ago HERE (4:55).

Thanks in advance!

Edited 6 Years Ago by Turaiel: n/a

Use ADO.NET oledb provider to read Excel data.

Thanks a bunch. I'll give it a try. The Office Interop has been crashing a lot on me recently, and it's super slow. Should I be loading these values in a separate thread, so that it doesn't lock up the timer?

Also, did you have any ideas on how to correct the sound issue?

Basically, you want the timer to keep looping until .wav file finished?
If so, set the timer to the length of the .wav file's sound.

Basically, you want the timer to keep looping until .wav file finished?
If so, set the timer to the length of the .wav file's sound.

The timer is the control timer for the competition. It must be in 1000 ms increments

I am now using ACE OLEDB in a separate thread to get data, and I haven't had any sound issues for a while.

Do you added a System.Windows.Forms.Application.Doevents() after each action (open, close, read a cell, etc...)?

This will help the timer not to stop.

About the problem with the audio, did you tryed PlaySound API to play the sound asynchronous?

<Flags()> Public Enum PlaySoundFlags As Integer
        SND_SYNC = &H0 ' play synchronously (default) 
        SND_ASYNC = &H1 ' play asynchronously 
        SND_NODEFAULT = &H2 ' silence (!default) if sound not found 
        SND_MEMORY = &H4 ' pszSound points to a memory file 
        SND_LOOP = &H8 ' loop the sound until next sndPlaySound 
        SND_NOSTOP = &H10 ' don't stop any currently playing sound 
        SND_NOWAIT = &H2000 ' don't wait if the driver is busy 
        SND_ALIAS = &H10000 ' name is a registry alias 
        SND_ALIAS_ID = &H110000 ' alias is a predefined ID 
        SND_FILENAME = &H20000 ' name is file name 
        SND_RESOURCE = &H40004 ' name is resource name or atom 
    End Enum
    Private Declare Auto Function PlaySound Lib "winmm.dll" Alias "PlaySound" (ByVal lpszSoundName As _
String, ByVal hModule As Integer, ByVal dwFlags As Integer) As Integer
    Public Sub PlayWavFile(ByVal WaveFileName As String)
        Try
		PlaySound(WaveFileName, 0, PlaySoundFlags.SND_FILENAME Or PlaySoundFlags.SND_ASYNC)
        Catch ex As Exception
        End Try
    End Sub

Hope this helps

This article has been dead for over six months. Start a new discussion instead.