Results 1 to 13 of 13

Thread: [VB6] - audio(output sound)

  1. #1
    PowerPoster joaquim's Avatar
    Join Date
    Apr 07
    Posts
    2,494

    [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 08
    Posts
    6,766

    Re: [VB6] - audio(output sound)

    See if this will be of any help
    Attached Files Attached Files
    The better the information you give to begin with and the sooner you reply the sooner you will get help and get your problem resolved


    When I was young and in my prime I used to program all the time but now I'm old and getting gray I only program once a day

  3. #3
    PowerPoster joaquim's Avatar
    Join Date
    Apr 07
    Posts
    2,494

    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 08
    Posts
    6,766

    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.
    The better the information you give to begin with and the sooner you reply the sooner you will get help and get your problem resolved


    When I was young and in my prime I used to program all the time but now I'm old and getting gray I only program once a day

  5. #5
    PowerPoster joaquim's Avatar
    Join Date
    Apr 07
    Posts
    2,494

    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 08
    Posts
    6,766

    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.
    The better the information you give to begin with and the sooner you reply the sooner you will get help and get your problem resolved


    When I was young and in my prime I used to program all the time but now I'm old and getting gray I only program once a day

  7. #7
    PowerPoster joaquim's Avatar
    Join Date
    Apr 07
    Posts
    2,494

    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 08
    Posts
    6,766

    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
    The better the information you give to begin with and the sooner you reply the sooner you will get help and get your problem resolved


    When I was young and in my prime I used to program all the time but now I'm old and getting gray I only program once a day

  9. #9
    PowerPoster joaquim's Avatar
    Join Date
    Apr 07
    Posts
    2,494

    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 05
    Location
    Netherlands
    Posts
    514

    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
    PowerPoster joaquim's Avatar
    Join Date
    Apr 07
    Posts
    2,494

    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 05
    Location
    Netherlands
    Posts
    514

    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
    PowerPoster joaquim's Avatar
    Join Date
    Apr 07
    Posts
    2,494

    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
  •