detect sound wave-VBForums
Results 1 to 14 of 14

Thread: detect sound wave

  1. #1

    Thread Starter
    New Member
    Join Date
    Nov 2005
    Location
    Australia
    Posts
    4

    detect sound wave

    Help !!! Anyone could tell me how to detect the silent period (no output of sound card)..
    Thanks

  2. #2
    Addicted Member Vegeta's Avatar
    Join Date
    Jul 2002
    Posts
    159

    Re: detect sound wave

    you mean you want a trigger, that fires if there is no data in the output buffer of the sound driver, or simply check it manually?

  3. #3
    The DirectXpert Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,084

    Re: detect sound wave

    I'm sure it has something to do with these wave API's found in this API listing:

    http://www.mentalis.org/apilist/w.shtml

    But I'm sure DirectSound is capable of it. Just never pulled it off before:

    http://directx4vb.vbgamer.com/DirectX4VB/TUT_DX8_DA.asp

  4. #4

    Thread Starter
    New Member
    Join Date
    Nov 2005
    Location
    Australia
    Posts
    4

    Re: detect sound wave

    Quote Originally Posted by Vegeta
    you mean you want a trigger, that fires if there is no data in the output buffer of the sound driver, or simply check it manually?
    Yes, I want to trigger the other program if there is no output of sound card. Have any idea to write the VB code?

  5. #5
    The DirectXpert Jacob Roman's Avatar
    Join Date
    Aug 2004
    Location
    Miami Beach, FL
    Posts
    5,084

    Re: detect sound wave

    If I known, I would have an example program made out for ya. PM CVMichael on this, as he is our DirectSound expert.

  6. #6
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,733

    Re: detect sound wave

    I saw this thread without getting hte PM (This time)

    It should be easy to do, you just record the sound at all times, and make an average of the sound buffer, if it's under a certain percentage (you usually have some static), then execute the triger.

    I don't have time to do it now, but I'll try to write some code later (today hopefully).

    For how long do you think the silence interval will be ?
    And how precise it has to be ?

  7. #7
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,733

    Re: detect sound wave

    OK, here it is...

    In the DXRecord_GotWavData Sub, Modify the constants SilencePercent and NonSilencePercent to the values you need.

    Put the code that executes the other program in the tmrExecute_Timer sub.

    [Edit]
    I changed the attachment, I added an "Extended" version, I think you might like it
    Attached Files Attached Files
    Last edited by CVMichael; Nov 21st, 2005 at 01:56 PM.

  8. #8
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,733

    Re: detect sound wave

    So.. no feedback at all ?

    Is it OK what I did or not ?

    Is your problem solved ?

  9. #9
    New Member
    Join Date
    Jan 2015
    Posts
    3

    Re: detect sound wave

    I would like to celebrate the near 10th anniversary of this post, and at the same time ask if the above code:

    - still works
    - worked initially
    - if you have a copy of the resulting executable file

  10. #10
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,733

    Re: detect sound wave

    - still works - Probably... on a Windows XP computer and VB6... (if you still have it...)
    - worked initially - Of course! I don't post things that don't work
    - if you have a copy of the resulting executable file - I don't have VB6 anymore, so can't compile the code. But the code needs some modification before you compile it (if you read post #7)

  11. #11
    New Member
    Join Date
    Jan 2015
    Posts
    3

    Re: detect sound wave

    Quote Originally Posted by CVMichael View Post
    - still works - Probably... on a Windows XP computer and VB6... (if you still have it...)
    - worked initially - Of course! I don't post things that don't work
    - if you have a copy of the resulting executable file - I don't have VB6 anymore, so can't compile the code. But the code needs some modification before you compile it (if you read post #7)
    Thanks for the answer
    I'm just a user without ANY Visual Basic experience (any version) that would like to run an EXE (or whatever does run) on my Windows 7 that has the feature I'm wanting to have.

    Can these "old" files be used as input on a newer version of Visual Basic ?
    Obviously I don't care about XP, I care about : "Anyone could tell me how to detect the silent period (no output of sound card).", this on a Windows that is supported, this day.

  12. #12
    PowerPoster
    Join Date
    Feb 2002
    Location
    Canada, Toronto
    Posts
    5,733

    Re: detect sound wave

    The code was written for DirectX 8 (for Windows XP), and Windows 7 has DirectX 9.

    You can't convert the code to new-er version because VB6 was the last version of "Classic Visual Basic", next version is Visual Basic .NET and it's difficult to convert. You might as well re-write the code in VB.NET

    So, it won't work on a Windows 7

  13. #13
    New Member
    Join Date
    Jan 2015
    Posts
    3

    Re: detect sound wave

    Quote Originally Posted by CVMichael View Post
    The code was written for DirectX 8 (for Windows XP), and Windows 7 has DirectX 9.

    You can't convert the code to new-er version because VB6 was the last version of "Classic Visual Basic", next version is Visual Basic .NET and it's difficult to convert. You might as well re-write the code in VB.NET

    So, it won't work on a Windows 7
    Too bad ..

    Is there any chance that the same question (in the opening post) still would have an answer, given current OS
    That means, other than the likely possible fact it may be written from scratch in .NET Visual Basic source code ?

    It doesn't have to be VB, as in the end I only need an executable program. Language is not relevant, and note I've never coded 1 line of any Visual Basic

  14. #14
    Hyperactive Member
    Join Date
    Jan 2006
    Posts
    361

    Re: detect sound wave

    That can be done quite easily without directX using WAVEOUT api from the mixer device and inspecting the level of the returned array. It's a toss between VB6 and .Net. VB6 requires a bit of api work (but not all that hard). while .Net does have managed WAVEOUT routines I believe.

    If you don't have VB6 experience, it would probably be best to look at .Net.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Featured


Click Here to Expand Forum to Full Width

Survey posted by VBForums.