473,387 Members | 1,534 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

How to create a sound at specific frequency?

Does anyone know how can i create a sound in vb.net that will be a
specific frequency? I can't find anything online that helps.

Thanks very much for your help!

John

Jul 20 '06 #1
5 10197
Does anyone know how can i create a sound in vb.net that will be a
specific frequency? I can't find anything online that helps.
' Beep (winbase.h) plays a sound in hertz for a duration in milliseconds
' This function is named BeepApi because Beep is a vb reserved word
Public Declare Function BeepApi Lib "kernel32" Alias "Beep" ( _
ByVal dwFreq As Integer, _
ByVal dwDuration As Integer) _
As Integer

Jul 20 '06 #2
AMercer wrote:
Public Declare Function BeepApi Lib "kernel32" Alias "Beep" ( _
ByVal dwFreq As Integer, _
ByVal dwDuration As Integer) _
As Integer
And if you don't want to use p/invoke you can use:

System.Console.Beep(_frequency, _duration)

Jul 21 '06 #3
Thank you for your replies. I tried that earlier. The problem with
this method is that the beep is sounded via the internal PC speaker,
not the external speakers, and the quality is very bad.

Does anyone know how to get the sound to come out of the external
speakers?

Thanks!
John

johnb41 wrote:
Does anyone know how can i create a sound in vb.net that will be a
specific frequency? I can't find anything online that helps.

Thanks very much for your help!

John
Jul 21 '06 #4
johnb41 wrote:
Does anyone know how to get the sound to come out of the external
speakers?
You mean through the sound card?

If you're using .Net 2.0, you can import the System.Media namespace and
then call:

SystemSounds.Beep.Play()

What is played depends on the sound scheme setup in the control panel.

Jul 21 '06 #5
Thank you for your replies. I tried that earlier. The problem with
this method is that the beep is sounded via the internal PC speaker,
not the external speakers, and the quality is very bad.

Does anyone know how to get the sound to come out of the external
speakers?
At web site

http://ccrma.stanford.edu/CCRMA/Cour...ts/WaveFormat/

is a description of the layout of a .wav file. You could generate such a
structure with digitized sinusoid values in the 'data' area, and feed that
data to

Private Declare Function PlaySound Lib "winmm" Alias "PlaySoundA" ( _
ByVal pszSound() As Byte, _
ByVal hMod As Integer, _
ByVal fdwSound As Integer) _
As Integer

Use 0 for hMod, and use &h4 for fdwSound (constant SND_MEMORY). Pass the
wave array you build in pszSound.

Sounds like some effort, but it should work.

Jul 21 '06 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Chris | last post by:
I want a program that can "draw" sound. Imagine drawing a graph of frequency against time - and then being able to play it over the computer speakers. Can this be done in Python? As a...
4
by: Julia | last post by:
Hi, My system uses Mail Client component the Mail Client can either wrap exchange or pop3\SMTP server functions in order to do that I declared an abstract named class MailClient and create...
11
by: Prashant | last post by:
Hi, I have a huge problem. I have a data file which looks something like this -: ..1 .5 .9 -1 .2 .5 ...... ..2 .9 .1 .4 .3 -1 ...... ..2 .4 .5 .7 .6 .2 ...... ........
1
by: jack | last post by:
Hi all Im learning guitar and implanning to make just a hobby software of ly own. but for this first i need to know how to create sound like midi from csharp.. then later should be progressed to...
2
by: Angel Of Death | last post by:
I have a method. It takes some XML as a parameter. Depending on the content of the XML it should create a specific object and call a KNOWN method. So: public void PersistXml(string XmlData){} ...
1
by: strancho | last post by:
hi guys: i am rather new to C++. By using beep(hz, duration), I figured out a way to drive computer speaker. However, my project requires me to create sound from the sound card. Do you happen...
1
by: c# | last post by:
I have a typed-dataset of items that need to be written to an xml file in a specific format. Writing the Xml file is the easy part. How difficult is it to write an output with the following...
2
by: Gandalf | last post by:
I need to create sound with Javascript. Until now all the code I have been trying doesn't work width Firefox. can some one please show me how to do it, or give me a link to a good article? ...
5
by: harish2rock | last post by:
Hi..Me just a beginner in c++ programming. I have come acroos a program which is as follows : I have to prepare a file which contains the information in block format. as an example, the file...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.