Results 1 to 13 of 13

Thread: [VB6] - audio(output sound)

  1. #1

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,959

    [VB6] - audio(output sound)

    ok... we can read any image file and put it in a long array variable.. and then show it in a picturebox\form\usercontrol and others that have hdc property.
    ok... we can read wave files(for example) byte a byte and put it in a variable... but how we put it on columns(left... right) (for we ear a sound)?
    (i'm not speak about directx)
    VB6 2D Sprite control

    To live is difficult, but we do it.

  2. #2
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: [VB6] - audio(output sound)

    See if this will be of any help
    Attached Files Attached Files


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

  3. #3

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,959

    Re: [VB6] - audio(output sound)

    Quote Originally Posted by jmsrickland View Post
    See if this will be of any help
    Code:
    Public Sub getAudioSoundFile(s As String)
     On Error Resume Next
     Open s For Binary As #1
     ReDim WavSound(LOF(1) - 1)
     Get #1, , WavSound
     Close #1
    End Sub
    instead catch all sound, i can catch half and play half?
    (why these thread\question??? i have used sndPLaysound() and mciSendString() api functions(for CD Audio, MP3, Wave....)... and i have the same problem: the functions need very time for put the sound on memory, before play it)
    VB6 2D Sprite control

    To live is difficult, but we do it.

  4. #4
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: [VB6] - audio(output sound)

    All of the sounds are loaded first into a byte array then when you press a key on the textbox a sound will be heard.


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

  5. #5

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,959

    Re: [VB6] - audio(output sound)

    Quote Originally Posted by jmsrickland View Post
    All of the sounds are loaded first into a byte array then when you press a key on the textbox a sound will be heard.
    yes.. but imagine that you just need play the sound by steps. because read all file, at once, the cpu needs time. then the user wait some time(depending on file\music size), before the sound be ear.... it's possible ear the sound by steps and faster?
    VB6 2D Sprite control

    To live is difficult, but we do it.

  6. #6
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: [VB6] - audio(output sound)

    This is just a small sample to play WAVE sounds that correspond to the keyboard. You can change it anyway you want to because the sound stuff is all in a Class file so you make the Form code to read and play as you desire


    EDIT

    ..... i can catch half and play half?

    If you are asking if you can load half of a WAVE file and play that half while at same time you load the 2nd half I don't think so because it would be like loading half of a GIF file and show only half of the image. The sound processor needs to have the complete file. Now there is audio streaming which you might want to look up on the net and see if you can find anything about how to do it.
    Last edited by jmsrickland; Aug 18th, 2012 at 05:47 PM.


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

  7. #7

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,959

    Re: [VB6] - audio(output sound)

    Quote Originally Posted by jmsrickland View Post
    This is just a small sample to play WAVE sounds that correspond to the keyboard. You can change it anyway you want to because the sound stuff is all in a Class file so you make the Form code to read and play as you desire
    but the variable put all sound at once. imagine if just put some part of sound, then the cpu needs less time to put it in memory and then play it
    VB6 2D Sprite control

    To live is difficult, but we do it.

  8. #8
    PowerPoster
    Join Date
    Jan 2008
    Posts
    11,074

    Re: [VB6] - audio(output sound)

    Quote Originally Posted by joaquim View Post
    but the variable put all sound at once. imagine if just put some part of sound, then the cpu needs less time to put it in memory and then play it
    That's because it goes through a loop loading all the sound files first. Change the loop to load just what you want

    Code:
     For i = 32 To 126
       Set KeyboardCharacterSound(i) = New AudioSounds
       KeyboardCharacterSound(i).getAudioSoundFile App.Path & "\sounds\" & i & ".wav"
     Next i
    Don't use this loop; just do one or two at a time


    Anything I post is an example only and is not intended to be the only solution, the total solution nor the final solution to your request nor do I claim that it is. If you find it useful then it is entirely up to you to make whatever changes necessary you feel are adequate for your purposes.

  9. #9

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,959

    Re: [VB6] - audio(output sound)

    Quote Originally Posted by jmsrickland View Post
    That's because it goes through a loop loading all the sound files first. Change the loop to load just what you want

    Code:
     For i = 32 To 126
       Set KeyboardCharacterSound(i) = New AudioSounds
       KeyboardCharacterSound(i).getAudioSoundFile App.Path & "\sounds\" & i & ".wav"
     Next i
    Don't use this loop; just do one or two at a time
    thanks
    (sorry, but by forum rules, i can't give you more "points")
    VB6 2D Sprite control

    To live is difficult, but we do it.

  10. #10
    Fanatic Member namrekka's Avatar
    Join Date
    Feb 2005
    Location
    Netherlands
    Posts
    639

    Re: [VB6] - audio(output sound)

    You also can have a look at the "winmm.dll". With the functions "waveOutPrepareHeader" and "waveOutWrite" you can send your created sound to the soundcard.

  11. #11

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,959

    Re: [VB6] - audio(output sound)

    Quote Originally Posted by namrekka View Post
    You also can have a look at the "winmm.dll". With the functions "waveOutPrepareHeader" and "waveOutWrite" you can send your created sound to the soundcard.
    hum... they are more faster, reading a file(before play it), than sndSoundplay() api function?
    VB6 2D Sprite control

    To live is difficult, but we do it.

  12. #12
    Fanatic Member namrekka's Avatar
    Join Date
    Feb 2005
    Location
    Netherlands
    Posts
    639

    Re: [VB6] - audio(output sound)

    Hmmm... not sure about speed. I was more referring to:
    Quote Originally Posted by joaquim View Post
    ok... we can read wave files(for example) byte a byte and put it in a variable... but how we put it on columns(left... right) (for we ear a sound)?
    (i'm not speak about directx)
    You fill up a struct, containing arrays for left and right, (buffer) and pass it to the api. You will get a callback when the buffer can be filled again.
    You can create any sound, like a sine etc, with some math and pass it to the soundcard. You don't need to write to a file first.

  13. #13

    Thread Starter
    PowerPoster joaquim's Avatar
    Join Date
    Apr 2007
    Posts
    3,959

    Re: [VB6] - audio(output sound)

    Quote Originally Posted by namrekka View Post
    Hmmm... not sure about speed. I was more referring to:

    You fill up a struct, containing arrays for left and right, (buffer) and pass it to the api. You will get a callback when the buffer can be filled again.
    You can create any sound, like a sine etc, with some math and pass it to the soundcard. You don't need to write to a file first.
    ok.. thanks
    VB6 2D Sprite control

    To live is difficult, but we do it.

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