Hi!

Does someon know how to generate a sinusoidal tone?

Thanks in advance!

Re: Tone generation by William

William
Mon May 09 18:07:49 CDT 2005

"Jan Kowalski" <nemes@poczta.fm> wrote in message
news:d5o7d4$1sk$1@nemesis.news.tpi.pl...
> Does someon know how to generate a sinusoidal tone?

Use Platform/Invoke to call Beep():

[DllImport("kernel32.dll")]
public static extern bool Beep(int frequency, int duration);

Regards,
Will



Re: Tone generation by Michael

Michael
Tue May 10 03:32:33 CDT 2005

On Mon, 9 May 2005 19:07:49 -0400, "William DePalo [MVP VC++]"
<willd.no.spam@mvps.org> wrote:

>"Jan Kowalski" <nemes@poczta.fm> wrote in message
>news:d5o7d4$1sk$1@nemesis.news.tpi.pl...
>> Does someon know how to generate a sinusoidal tone?
>
>Use Platform/Invoke to call Beep():
>
>[DllImport("kernel32.dll")]
>public static extern bool Beep(int frequency, int duration);
>
>Regards,
>Will
>

Will, this won't!

1) This method only plays through the PC's speaker,
and
2) It is NOT a sine wave. It is a distorted square wave.

There are several ways to generate a pure sine wave, none of them use
the framework directly.

The 'easiest' is to record the sine wave that you want to a file, then
play that file.
Look in VS Help under "play sound" for an example.
Or you could use DirectX, or even Midi.
None of these are simple.

Do you need to be able to select the exact frequency and duration on
an extempore basis?

Re: Tone generation by William

William
Tue May 10 12:44:22 CDT 2005

"Michael Gray" <fleetg@newsguy.spam.com> wrote in message
news:str081p6gqf3np9b3vb78cnleisg3d9p2g@4ax.com...
> 2) It is NOT a sine wave. It is a distorted square wave.

I didn't know that, thanks for the correction.

> The 'easiest' is to record the sine wave that you want to a file, then
> play that file.

The wave file format is pretty simple and the mmio... functions are easy to
use so with a little math it shouldn't be hard to create a file on the fly
and loop the playback, no?

Regards,
Will



Re: Tone generation by Michael

Michael
Tue May 10 21:43:13 CDT 2005

On Tue, 10 May 2005 13:44:22 -0400, "William DePalo [MVP VC++]"
<willd.no.spam@mvps.org> wrote:

>"Michael Gray" <fleetg@newsguy.spam.com> wrote in message
>news:str081p6gqf3np9b3vb78cnleisg3d9p2g@4ax.com...
>> 2) It is NOT a sine wave. It is a distorted square wave.
>
>I didn't know that, thanks for the correction.
>
>> The 'easiest' is to record the sine wave that you want to a file, then
>> play that file.
>
>The wave file format is pretty simple and the mmio... functions are easy to
>use so with a little math it shouldn't be hard to create a file on the fly
>and loop the playback, no?
>
>Regards,
>Will
>

For a programmer with a math and computing degree it would be a
peice-of-cake.
Otherwise, I'm not so sure.
In any case, if you are going to the trouble of creating a file, with
the attendant problems of getting the headers etc right, it is much
easier to directly put those numbers into a DirectSound PCM buffer,
and output using DirectSound.
Even this is not simple.

If the frequency of the sound is set to one or two, then generate a
wav file or two using say Cooledit, then play with mmio, or
directsound.

If the frequency needs to be extempore, then you will need to do
something else.

As an example that may be used as a basis for experimentation:
http://www.codeproject.com/audio/SoundGenerator.asp

Michael Gray, BSc, (Math Sci, Computing Sci) MACS, MRSA

Re: Tone generation by William

William
Wed May 11 15:41:53 CDT 2005

"Michael Gray" <fleetg@newsguy.spam.com> wrote in message
news:tjr2815g44mm6gn6kggnlge4u2gjh0ml20@4ax.com...
> For a programmer with a math and computing degree it would be a
> peice-of-cake.

Well, the OP did use the word "sinusoidal" which means he most likely made
it through basic trigonometry at least. :-)

Regards,
Will



Re: Tone generation by Michael

Michael
Sat May 14 01:50:06 CDT 2005

On Wed, 11 May 2005 16:41:53 -0400, "William DePalo [MVP VC++]"
<willd.no.spam@mvps.org> wrote:

>"Michael Gray" <fleetg@newsguy.spam.com> wrote in message
>news:tjr2815g44mm6gn6kggnlge4u2gjh0ml20@4ax.com...
>> For a programmer with a math and computing degree it would be a
>> peice-of-cake.
>
>Well, the OP did use the word "sinusoidal" which means he most likely made
>it through basic trigonometry at least. :-)
>
>Regards,
>Will
>

Quite!
Perhap the OP misread the label on a bottle of nasal decongestant?
;-)