473,503 Members | 2,082 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(1920 microseconds) not
milliseconds as in Beep.

can u help me?

thanx
Ahmed Fat-hi

Nov 16 '05 #1
1 1700
> 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
31791
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
8732
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...
19
56571
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...
8
9112
by: Marcia Gulesian | last post by:
How can I create a beep in javascript (I.E. 5.5 +) ?
2
2281
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...
4
6845
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()...
4
2858
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...
5
29030
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...
6
11426
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
7091
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
7342
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...
1
5018
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4680
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...
0
3171
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...
0
3162
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1516
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 ...
1
741
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
391
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...

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.