Announcement

Collapse
No announcement yet.

Default Sound Device Frequency Generation

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Default Sound Device Frequency Generation

    I'm fairly new to PowerBasic, and haven't programmed Windows in 10 years, so please don't assume I know anything at all.

    I need to take control of the default audio device in windows, and tell it to play a certain frequency.

    At the end of the day, I'll be using PowerBasic to generate audio tests to use in our Chinese factory when doing Q/A on speaker systems. I'll be generating frequency sweeps, doing impulse response, etc.

    But for now, I need to make a sound! I think once I get that far, I'll be on my way.

    I assume I need to interface with some windows library and make calls to that... But as a new Power Basic user, even that is something a quick example would really help me out.

    Thanks a lot.

    Tom

  • #2
    Here's a EuroSiren I wrote. This may help get you started.
    Code:
    #INCLUDE "win32api.inc"
    
    FUNCTION PBMAIN () AS LONG
        LOCAL COUNT AS LONG
    
        DO
        IF INKEY$ = CHR$(27) THEN EXIT LOOP
        INCR COUNT
        IF COUNT > 5 THEN EXIT LOOP
        winbeep  500,300
        winbeep 1000,300
        LOOP
    
        END FUNCTION
    In as far as "taking control".....Hmmm...Even if it's possible, you may want to reconsider your options.
    There are no atheists in a fox hole or the morning of a math test.
    If my flag offends you, I'll help you pack.

    Comment


    • #3
      Not Sound Card

      Thanks for the reply. I actually had seen this from my initial search of the forum. Very fun!

      It only uses the PC's internal chassis speaker, however. I'm after something that accesses the Windows Default Audio Device, which could be your USB Headset, your sound card, etc.

      Comment


      • #4
        Tom,
        for an example of creating arbitrary frequencies of your choice , see here:
        http://www.powerbasic.com/support/pb...81&postcount=5

        Paul.

        Comment


        • #5
          PBCC Windows sounds

          Tom,
          You can use any AVI file in PBCC with this command

          PlaySound "Anyfile.avi", 0, %SND_ASYNC

          I use it to play standard Windows warning sounds in my graphic Console programs
          Old QB45 Programmer

          Comment


          • #6
            Originally posted by Tom Carlson View Post
            It only uses the PC's internal chassis speaker, however...
            Hmmm, It plays just fine on my PC's speakers. What kind of setup are you working with?

            Also, as noted, you can also use MCISENDSTRING and/or PLAYSOUND. Plenty of examples in the source code forum.

            Enjoy.
            There are no atheists in a fox hole or the morning of a math test.
            If my flag offends you, I'll help you pack.

            Comment


            • #7
              Mel and Guy,

              Thanks! I had seen playsound, but discarded it as not relevant to my problem. I didn't know it could play from memory as well as a file.

              At some point, I would like to record, control volume, and do other audio device related activities, but for now, I can generate frequency sweeps with this, much less painfully (I've been reading directx stuff) then I had feared.

              Thanks!

              Comment


              • #8
                At some point, I would like to record, control volume, and do other audio device related activities
                See: http://www.powerbasic.com/support/pb...light=mixerapi
                Regards,
                Peter

                Comment


                • #9
                  Peter,

                  Great program! Is there any chance that you include a dialog to select the sound card? My pc has three of them, one on board and two USB. This is very deep to me ...
                  "The trouble with quotes on the Internet is that you can never know if they are genuine." - Abraham Lincoln.

                  Comment


                  • #10
                    Posted an adapted version: http://www.powerbasic.com/support/pb...11&postcount=7
                    Regards,
                    Peter

                    Comment


                    • #11
                      Peter,

                      Great work, thanks!

                      Edited:

                      Ooops! See the results with:
                      1- on board sound
                      2- on board and one USB card
                      3- on board and two USB cards (same brand)
                      Attached Files
                      Last edited by Arthur Gomide; 18 Apr 2009, 04:08 PM.
                      "The trouble with quotes on the Internet is that you can never know if they are genuine." - Abraham Lincoln.

                      Comment


                      • #12
                        According to Patrice Terrier it seems that Vista and Windows 7 no longer support the MixerApi...
                        (I never tried; I'm using W2K overhere...)
                        Regards,
                        Peter

                        Comment


                        • #13
                          The info of Mr. Patrice Terrier is relevant but I'm using XP SP3.
                          "The trouble with quotes on the Internet is that you can never know if they are genuine." - Abraham Lincoln.

                          Comment

                          Working...
                          X