Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. Visual Basic
  4. Sine Wave Sound

Sine Wave Sound

Scheduled Pinned Locked Moved Visual Basic
questionhelp
8 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • J Offline
    J Offline
    jignesh142
    wrote on last edited by
    #1

    How can i generate the sine wave sound in VB? I want to generate the sine wave sound for customized duration and customized frequency Any help?

    J N 2 Replies Last reply
    0
    • J jignesh142

      How can i generate the sine wave sound in VB? I want to generate the sine wave sound for customized duration and customized frequency Any help?

      J Offline
      J Offline
      javadadabi
      wrote on last edited by
      #2

      Hello search for fmod sound engine(fmod.dll) usage.

      1 Reply Last reply
      0
      • J jignesh142

        How can i generate the sine wave sound in VB? I want to generate the sine wave sound for customized duration and customized frequency Any help?

        N Offline
        N Offline
        Nick Otten
        wrote on last edited by
        #3

        Hello, declare:

        Private Declare Function MakeSound Lib "kernel32" (ByVal soundFrequency As Int32, ByVal soundDuration As Int32) As Int32

        after that you can call for the MakeSound([frequency in hz],[duration in ms]) function and the computer will generate the tone trough its speakers.

        J 1 Reply Last reply
        0
        • N Nick Otten

          Hello, declare:

          Private Declare Function MakeSound Lib "kernel32" (ByVal soundFrequency As Int32, ByVal soundDuration As Int32) As Int32

          after that you can call for the MakeSound([frequency in hz],[duration in ms]) function and the computer will generate the tone trough its speakers.

          J Offline
          J Offline
          jignesh142
          wrote on last edited by
          #4

          i want to do something like this Option Explicit Option Base 1 Private Sub CommandButton1_Click() Dim Sc(3) as integer Dim Frequency=440 Dim Duration = 1000 ' in millisecond Sc(1)=1 Sc(2)=1.125 Sc(3)=1.2 For i = 1 to 3 ' some code is required to play the sine wave sound for above frequency and duration next i End

          N 1 Reply Last reply
          0
          • J jignesh142

            i want to do something like this Option Explicit Option Base 1 Private Sub CommandButton1_Click() Dim Sc(3) as integer Dim Frequency=440 Dim Duration = 1000 ' in millisecond Sc(1)=1 Sc(2)=1.125 Sc(3)=1.2 For i = 1 to 3 ' some code is required to play the sine wave sound for above frequency and duration next i End

            N Offline
            N Offline
            Nick Otten
            wrote on last edited by
            #5

            try this:

            Option Explicit
            Option Base 1

            Public Class NameYourClass

            Private Declare Function Beep Lib "kernel32" (ByVal soundFrequency As Int32, ByVal soundDuration As Int32) As Int32

            Private Sub CommandButton1_Click()
            Dim Sc(3) as integer
            Dim Frequency as int32 = 440
            Dim Duration as int32 = 1000 ' in millisecond
            Sc(1)=1
            Sc(2)=1.125
            Sc(3)=1.2

            For i = 1 to 3
            Beep(Frequency, Duration)
            next i
            End sub
            End Class

            note: i just putted a class around it so you could see where to paste what.

            J 1 Reply Last reply
            0
            • N Nick Otten

              try this:

              Option Explicit
              Option Base 1

              Public Class NameYourClass

              Private Declare Function Beep Lib "kernel32" (ByVal soundFrequency As Int32, ByVal soundDuration As Int32) As Int32

              Private Sub CommandButton1_Click()
              Dim Sc(3) as integer
              Dim Frequency as int32 = 440
              Dim Duration as int32 = 1000 ' in millisecond
              Sc(1)=1
              Sc(2)=1.125
              Sc(3)=1.2

              For i = 1 to 3
              Beep(Frequency, Duration)
              next i
              End sub
              End Class

              note: i just putted a class around it so you could see where to paste what.

              J Offline
              J Offline
              jignesh142
              wrote on last edited by
              #6

              hi nick Actually i don't want to use the beep function but to generate the sine wave sound

              N J 2 Replies Last reply
              0
              • J jignesh142

                hi nick Actually i don't want to use the beep function but to generate the sine wave sound

                N Offline
                N Offline
                Nick Otten
                wrote on last edited by
                #7

                isnt that just a very long beep? note that the kernel32 beep isnt the .net beep (the .net beep will give you the windows error 'klunk' while the kernel32 beep will generate a tone with the given amount of hertz during the given amount of milliseconds) but now that i think about it, not sure how it works with the 'wave' part.. did i quick google for ya and found this[^] its in vb6 a bit old...and not directly what you need. but it might be able to help you (or so i think)

                1 Reply Last reply
                0
                • J jignesh142

                  hi nick Actually i don't want to use the beep function but to generate the sine wave sound

                  J Offline
                  J Offline
                  javadadabi
                  wrote on last edited by
                  #8

                  see www.3dstate.com about using fmod functionality for 3d games.spacially horn sample.

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups