Re: Tone generation




"Dave" <noone@xxxxxxxxxxx> ha scritto nel messaggio
news:%23UcHDFg3IHA.1192@xxxxxxxxxxxxxxxxxxxxxxx

"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.

Well done, thanks: I succeeded! So I can deductively say that to obtain n
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


.



Relevant Pages

  • Wanted: Way to play random sounds...
    ... 100 REM play 20 random tones of random duration ... never mind from any sort of high level API that works with 10.3.9 ...
    (comp.sys.mac.programmer.help)
  • Tone generation
    ... triangle waves at given frequency and duration. ... Now I'm searching, without results, for a method to play two or more tones ... open the wave device and write the datablock of the tone. ...
    (microsoft.public.win32.programmer.mmedia)
  • Re: Tone generation
    ... triangle waves at given frequency and duration. ... Now I'm searching, without results, for a method to play two or more tones ... Is there a method to play two tones togeter, opening the wave device only ...
    (microsoft.public.win32.programmer.mmedia)
  • [SLE] Tone generator
    ... Is there such a program out there that will play simple tones? ... example a program where you can enter a frequency and duration and get a ... Check the headers for your unsubscription address For additional commands send e-mail to suse-linux-e-help@suse.com Also check the archives at http://lists.suse.com Please read the FAQs: suse-linux-e-faq@suse.com ...
    (SuSE)
  • Re: just had to try this one more time
    ... Play your favorite music on your stereo, ... Play as many tones per second as possible, ... In most music modern there is always a current chord, ... Learn the major scale, which you will find by trying tones. ...
    (sci.electronics.design)

Loading