sound - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

sound

I trying to get this to work, but it stops before the end of the wav file. This is part of a larger program.
I used the same code for several shorter sound effects, ahead of ahead of this one, and those lines work just fine. This is the last line of the program. The wave file is about 9 seconds cut from the original wave file. I am using vb6.0 professional and windows xp. The sound module is as follows:

Public Declare Function sndPlaySound Lib "winmm.dll" Alias "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As Long) As Long

'monsters sing
Private Sub Timer08_Timer() '500ms
Out 888, 176 'turn on automation
sndPlaySound App.Path & "Monster Mash.wav", SND_ASYNC
Out 888, 0 'turn off automation
Timer08.Enabled = False
Utimer01.Enabled = True
End Sub

Comments

  • BitByBit_ThorBitByBit_Thor Posts: 2,444Member
    : I trying to get this to work, but it stops before the end of the wav
    : file. This is part of a larger program.
    : I used the same code for several shorter sound effects, ahead of
    : ahead of this one, and those lines work just fine. This is the last
    : line of the program. The wave file is about 9 seconds cut from the
    : original wave file. I am using vb6.0 professional and windows xp.
    : The sound module is as follows:
    :
    : Public Declare Function sndPlaySound Lib "winmm.dll" Alias
    : "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As
    : Long) As Long
    :
    : 'monsters sing
    : Private Sub Timer08_Timer() '500ms
    : Out 888, 176 'turn on automation
    : sndPlaySound App.Path & "Monster Mash.wav", SND_ASYNC
    : Out 888, 0 'turn off automation
    : Timer08.Enabled = False
    : Utimer01.Enabled = True
    : End Sub
    :
    :

    You're playing it asynchronous, so probably a piece of code somewhere else is causing it to get cut off mid-song. Or perhaps your program terminates before the song has managed to complete? Try running through it with the debugger, to see what code is executed and where the play stops.
    (BTW, what's Out ?)
    Best Regards,
    Richard

    The way I see it... Well, it's all pretty blurry
  • silverfox98201silverfox98201 Posts: 4Member
    : : I trying to get this to work, but it stops before the end of the wav
    : : file. This is part of a larger program.
    : : I used the same code for several shorter sound effects, ahead of
    : : ahead of this one, and those lines work just fine. This is the last
    : : line of the program. The wave file is about 9 seconds cut from the
    : : original wave file. I am using vb6.0 professional and windows xp.
    : : The sound module is as follows:
    : :
    : : Public Declare Function sndPlaySound Lib "winmm.dll" Alias
    : : "sndPlaySoundA" (ByVal lpszSoundName As String, ByVal uFlags As
    : : Long) As Long
    : :
    : : 'monsters sing
    : : Private Sub Timer08_Timer() '500ms
    : : Out 888, 176 'turn on automation
    : : sndPlaySound App.Path & "Monster Mash.wav", SND_ASYNC
    : : Out 888, 0 'turn off automation
    : : Timer08.Enabled = False
    : : Utimer01.Enabled = True
    : : End Sub
    : :
    : :
    :
    : You're playing it asynchronous, so probably a piece of code
    : somewhere else is causing it to get cut off mid-song. Or perhaps
    : your program terminates before the song has managed to complete? Try
    : running through it with the debugger, to see what code is executed
    : and where the play stops.
    : (BTW, what's Out ?)
    : Best Regards,
    : Richard
    :
    : The way I see it... Well, it's all pretty blurry
    .
    Out is an inpout command to turn on and off one of the Parallel port pins. The operate the automations.
    Here,s the compltet program:

    'Override 20 minute timer and start program
    Private Sub cmdOverride_Click()
    utimerCTL1.Enabled = False
    Out 888, 1 'Start lightning pulse
    Timer01.Enabled = True
    End Sub
    'Main program start
    Private Sub cmdStart_Click()
    Out 888, 1 'start lightning pulse
    Timer01.Enabled = True
    End Sub
    'End program
    Private Sub cmdStop_Click()
    End
    End Sub

    'Lightning flashes and play thunder wav
    Private Sub Timer01_Timer() '20ms
    cmdOverride.Caption = "Do Not Press"
    Out 888, 0 'Stop lightning pulse
    sndPlaySound App.Path & "Thunder.wav", SND_ASYNC
    Timer01.Enabled = False
    Out 888, 2 'Start witch head up/eyes on pulse
    Timer02.Enabled = True
    End Sub

    'head up and eyes light and play cackle wav
    Private Sub Timer02_Timer() '20ms
    Out 888, 0 'Stop witch head up/eyes on pulse
    sndPlaySound App.Path & "Cackle.wav", SND_ASYNC
    Timer02.Enabled = False
    Out 888, 2 'Start head down and eyes off pulse
    Timer03.Enabled = True
    End Sub

    'Head lowers/eyes off
    Private Sub Timer03_Timer() '20ms
    Out 888, 0 'Stop head down and eyes off pulse
    Timer03.Enabled = False
    Timer04.Enabled = True
    End Sub

    Private Sub Timer04_Timer() '1 Second
    Out 888, 4 'Start Toumbstone up pulse
    Timer04.Enabled = False
    Timer05.Enabled = True
    End Sub

    'Toumbstone raises
    Private Sub Timer05_Timer() '20ms
    Out 888, 64 'Stop toumbstone up pules
    sndPlaySound App.Path & "Moan.wav", SND_ASYNC
    Timer05.Enabled = False
    Out 888, 4 'Start Toumbstone down
    Timer06.Enabled = True
    End Sub

    'Toumbstone lowers
    Private Sub Timer06_Timer() '20ms
    Out 888, 64 'Stop Toumbstone down pulse
    sndPlaySound App.Path & "Moan2.wav", SND_ASYNC
    Timer06.Enabled = False
    Timer07.Enabled = True
    End Sub

    'Skulls Scream
    Private Sub Timer07_Timer() '250ms
    Out 888, 40 'Timer stops/Screamers start
    sndPlaySound App.Path & "Scream.wav", SND_ASYNC
    Out 888, 0 'Screamers stop
    Timer07.Enabled = False
    Timer08.Enabled = True
    End Sub

    'monsters sing
    Private Sub Timer08_Timer() '500ms
    Out 888, 176
    sndPlaySound App.Path & "Monster Mash.wav", SND_ASYNC
    Out 888, 0 'System reset
    Timer08.Enabled = False
    End Sub





  • BitByBit_ThorBitByBit_Thor Posts: 2,444Member
    : Out is an inpout command to turn on and off one of the Parallel
    : port pins. The operate the automations.
    : Here,s the compltet program:
    :

    The code looks solid.
    One thing I can think of is that perhaps your sound file is corrupted? Does it play the full length in a media player?
    Another thing might be that the sound file is too big and does not fit fully in physical memory (or the sndPlaySound thinks it won't fit). What size is it?

    One remark though: it's advised to not use End to terminate the program, except in extreme cases. Instead, you can use Unload Me to unload the form and cause the program to terminate itself because all forms have been closed.
    Best Regards,
    Richard

    The way I see it... Well, it's all pretty blurry
  • silverfox98201silverfox98201 Posts: 4Member
    : : Out is an inpout command to turn on and off one of the Parallel
    : : port pins. The operate the automations.
    : : Here,s the compltet program:
    : :
    :
    : The code looks solid.
    : One thing I can think of is that perhaps your sound file is
    : corrupted? Does it play the full length in a media player?
    : Another thing might be that the sound file is too big and does not
    : fit fully in physical memory (or the sndPlaySound thinks it won't
    : fit). What size is it?
    :
    : One remark though: it's advised to not use End to terminate the
    : program, except in extreme cases. Instead, you can use Unload Me to
    : unload the form and cause the program to terminate itself because
    : all forms have been closed.
    : Best Regards,
    : Richard
    :
    : The way I see it... Well, it's all pretty blurry

    The file is about 7 megs. It's funny, I have built up this display over the course of 5 years, adding a new character each year. I used my laptop ( with windows me ) to run the program and it worked fine, untill I upgraded to xp.
    I am basically croppin the full song wave down to a shorter
    length with a program called Audacity. I lost my audio files and had to redo them this year and that is when the problem started but it's only with Monster Mash.
    Thanks for all the help. This is the only VB programming i have done much with.
Sign In or Register to comment.