Re: Tone generation
- From: "Fabio De Dominicis" <f.dedominicis@xxxxxxxx>
- Date: Sat, 5 Jul 2008 00:35:48 +0100
"Dave" <noone@xxxxxxxxxxx> ha scritto nel messaggio
news:%23UcHDFg3IHA.1192@xxxxxxxxxxxxxxxxxxxxxxx
Well done, thanks: I succeeded! So I can deductively say that to obtain n
"Fabio De Dominicis" <f.dedominicis@xxxxxxxx> wrote in message
news:486e0a59$0$41665$4fafbaef@xxxxxxxxxxxxxxxxxxxxxx
Hi all,
I succeeded creating a simple procedure to make and play sine, square or
triangle waves at given frequency and duration.
Now I'm searching, without results, for a method to play two or more
tones
together. I tried to open two instances of my little program, passing
different frequences, and effectively it plays two tones together, but
every
.exe file should: open the wave device and write the datablock of the
tone.
Is there a method to play two tones togeter, opening the wave device only
a
time in te program?
Thanks
P.S.: In the perspective that I'll create a class to play tones, what do
you
think about tone duration handling? Should I use a timer in the class to
handle duration? Should I directly prepare a datablock for a tone with a
specified duration? Or should I just implementate playtone and stoptone,
and
let the user to handle a timer for playing and stopping tones, to
simulate
specified duration?
Thanks again
Fabio De Dominicis
to play 2 tones from one program you just add them sample by sample and
divide by 2.
tones together, it's enough to sum them sample by sample and to divide the
result by n.
Ok, now.....
I'm introducing loop in my program, using the waveout interface loop flags.
I have a problem:
during looping, I hear some ticks during the sound. Sure the ticks are
caused from looping (in the moment that the sound finishes and restart
again). Can I avoid this ticks?
Here is the code I use to generate sine waves, I post here the procedure to
fill a buffer, sent after through the waveoutwrite api.
It generates 2 tones together, but if I set looping flags, I hear ticks:
VOID FillBuffer (PBYTE pBuffer, int iFreq){
double fAngle, angle1;
int f1=iFreq+220;
int i ;
for (i = 0 ; i < 4096 ; i++){
pBuffer[i] = (BYTE) 127 + (127 * sin(fAngle) + 127 * sin(angle1))/2;
fAngle += 2 * 3.14 * iFreq / 11025;
if (fAngle > 2 * 3.14) fAngle -= 2 * 3.14 ;
angle1 += 2 * 3.14 * f1 / 11025;
if (angle1> 2 * 3.14) angle1 -= 2 * 3.14;
}
}
What I should adjust to avoid ticks?
Thanks
.
- Follow-Ups:
- Re: Tone generation
- From: Bob Masta
- Re: Tone generation
- From: Dave
- Re: Tone generation
- References:
- Tone generation
- From: Fabio De Dominicis
- Re: Tone generation
- From: Dave
- Tone generation
- Prev by Date: Re: Tone generation
- Next by Date: Re: Tone generation
- Previous by thread: Re: Tone generation
- Next by thread: Re: Tone generation
- Index(es):
Relevant Pages
|
Loading