PDA

View Full Version : Sine Wave Audio Sound Generator



jignesh142
10-18-2012, 05:00 AM
Is it possible to generate sine wave sound of custom frequency in excel vba?
without beep function?

GarysStudent
10-18-2012, 05:34 PM
With Beep:

Public Declare Function Beep Lib "kernel32" (ByVal dwFreq As Long, ByVal dwDuration As Long) As Long

Sub BeepTest(Nfreq As Long)
Beep Nfreq, 900
End Sub

Sub MAIN()
Call BeepTest(1200)
End Sub

Change the 1200 for your desired frequency.

jignesh142
10-18-2012, 08:36 PM
Well i am aware of the beep function

I want to generate sine wave sound without beep function

mikerickson
10-18-2012, 11:40 PM
Why avoid the beep function?
Does the sound made with that method not do what you want it to?
or do something that you don't want?

Also, there are websites that will create a .wav file of any sine wave that you specify. Would downloading a particular file and having Excel play that file suit your needs?

http://www.audiocheck.net/audiofrequencysignalgenerator_sinetone.php

jignesh142
10-22-2012, 12:24 AM
well,
the beep function does not play from speakers and does not have good sound quality
for building some musical program you need some files needs to play via speaker. we can play wav file by sndplaysound function but you dont have control on frequency and duration

JatinD
12-13-2013, 05:08 AM
Hi Jignesh,

It is possible.
I have a journal on this topic. Jatin D., T. S. Sheshadri and Dr. N.Ramesh, “Sinusoidal Sound Generators Using Excel”, The Journal of Acoustical Society of India, vol. 36, No. 1, pp. 39-48, 2009.
If you require any help. You can send me a mail...

SamT
12-13-2013, 02:24 PM
JatinD,

Glad you joined, and thank you for the reference.

We would like you to hold the discussion with Jignesh here in this thread so that future guests and members can benefit from it.

Thank you for the consideration of our desires.

JohnF
06-29-2014, 04:56 PM
I have a request similar to Jignesh. I'm generating song melodies algorithmically in Mac Excel and wish to hear them played - in any way possible. The note pitches and durations are simple sequences of numbers. Is there some way I can convert this data into a Midi file so that I can play it in Garageband or on some other player? Or play it directly in Excel by writing some VBA code?

mikerickson
07-11-2014, 11:59 AM
JohnF,
Does your use of Garageband imply that you are on a Mac?
There are ways that VBA can tell another program "play the specified file", but no way for VBA to directly play music files. (Or convert duration and pitches to sound.)

It might be easier to use VBA to algorithmically generate the song melodies, export that information to a file and then have the other software take it from that point on.

I'm curious to hear these algorithmic melodies, do you have any YouTube or ... of your music?

JohnF
07-11-2014, 07:47 PM
JohnF,
Does your use of Garageband imply that you are on a Mac?
There are ways that VBA can tell another program "play the specified file", but no way for VBA to directly play music files. (Or convert duration and pitches to sound.)

It might be easier to use VBA to algorithmically generate the song melodies, export that information to a file and then have the other software take it from that point on.

I'm curious to hear these algorithmic melodies, do you have any YouTube or ... of your music?

Yes, I'm on a Mac. I'm using Excel to generate number sequences representing note pitches and durations to go with simple chord progressions. I'm thinking I'll construct Midi files and hopefully be able to play them in Garageband. I don't have anything you can listen to yet.

mikerickson
07-11-2014, 11:14 PM
Unfortunatly, AppleScript tells me that GarageBand is not scriptable.