473,659 Members | 2,920 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Beep function

I need function that generates simple tone with frequency
1562.5 HZ to be played on the audio

device for duration 1920 microseconds.

i can not use the Beep function since it has the following
declaration

BOOL Beep(
DWORD dwFreq, // sound frequency in HZ
DWORD dwDuration // sound duration in milliseconds
);
I can not get the precigion i want because i need the
frequency to be float (1562.5) and i need

the inteval to be in microseconds(19 20 microseconds) not
milliseconds as in Beep.

can u help me?

thanx
Ahmed Fat-hi

Nov 16 '05 #1
1 1720
> I need function that generates simple tone with frequency
1562.5 HZ to be played on the audio
device for duration 1920 microseconds.


To achieve this kind of precision, you have generate this audio wave by
hand.
Prepare the sound buffer for the highest frequency (Fs) supported by your
soundcard (usually 44.1 kHz or 48 kHz).
You need to generate exactly three periods (n) of a wave at the frequency
(Fg) 1562.5 Hz.

Given this:
Fs = 44100 or 48000 Hz
Fg = 1562.5 Hz
n = 3

Required sound buffer size:
s = n * Fs / Fg = 85 or 92 samples

Create the buffer and fill it with required samples of a sine wave:

signed int16 buffer[s];
const int max_amplitude = 16383;
int i;
for (i=0; i < s; i++)
buffer[i] = max_amplitude * sin(i * 2 * pi * Fg / Fs);

Then, using DirectSound or one of the waveOut* functions, play the buffer.

--
pozdrawia
qb****@zdnet.pl
Anything was possible last night. That was the trouble
with last nights. They were always followed by this mornings.
- Terry Pratchett, "Small Gods"

Nov 16 '05 #2

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

Similar topics

6
31812
by: Leo | last post by:
hi there i want python to do a beep. in the docu i found in tkinter the method bell() but the script: import Tkinter Tkinter.bell() gives the error:
2
8750
by: bill_m | last post by:
Has anyone tried to use the .NET Beep function? The following works in VBA: Private Declare Function Beep Lib "Kernel32.dll" _ (ByVal X As Long, ByVal Y As Long) As Long Dim blVal As Boolean Dim dwFreq As Long Dim dwDuration As Long
19
56650
by: Anon Email | last post by:
Hi everyone, Let's see, now. This question is about the capabilities of ANSI C++. I want to write and compile code in ANSI C++ that, when compiled, will make the computer speaker beep; or, at least, SHOULD make the computer speaker beep. I know that whether the computer speaker actually beeps or not is largely dependent on the OS I'm using. But I'm not so much concerned about that (at this stage). I just want to know if ANSI C++...
8
9122
by: Marcia Gulesian | last post by:
How can I create a beep in javascript (I.E. 5.5 +) ?
2
2298
by: Ivo | last post by:
In an Win/IE-only application, some checkboxes and the like have been assigned accesskeys, so pressing alt+w focuses a checkbox, alt+b another. This is very convenient. However, when the checkboxes are hidden, for example because they are in a div styled "display:none", pressing the magic key combination does not work of course, but instead Windows generates an warning beep, a sound. Now I have written a function that will toggle the...
4
6875
by: Rich | last post by:
Hello, I want to use the Beep() to alert users about certain messages but in my workstation I can't get a sound out of it. But Beep works in VB6. What do I need to do? Sub... .... Beep() For i = 0 to 100: Beep(): Next
4
2868
by: adi | last post by:
Hi My application has many automatic features because it is designed to run without any user interfering. In fact, my app will work on a system without a keyboard or a mouse. Anyway, from time to time, the app will perform some tasks. When running certain critical tasks I need to play some speaker sounds while they are processing. The sound should be a sequence of beeps. Just a single beep could be anoying for the human listener. On...
5
29144
by: =?Utf-8?B?UmFmYWVs?= | last post by:
I'm studying C# (I've been a VB developer). I'm making some tests and I need to use Console.Beep(), but it doesn't make any sound, no matter if I try it in VS2008 beta or VS2005. Could anybody tell my some hint abouit it? -- Rafael
6
11434
by: Anz | last post by:
Is there any JavaScript function to generate a Beep sound from system ?, is it possible to make system Beep using JavaScript function ?
0
8428
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8335
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8528
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
5649
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4175
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4335
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2752
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1976
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1737
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.