Home All Groups Group Topic Archive Search About
Author
21 Mar 2009 6:21 PM
Lorin
What can I do to replace the BEEP Api?
VB6 on Vista PC.
Want the same kind of frequency control, etc.

Author
21 Mar 2009 6:38 PM
Jim Mack
Lorin wrote:
> What can I do to replace the BEEP Api?
> VB6 on Vista PC.
> Want the same kind of frequency control, etc.

Gotta wonder why, but it's fairly easy.

You can generate WAV images on the fly (in byte arrays) and use the
PlaySound API with them. If you can decide in advance what you need,
you can place WAV images into a resource and play them from there.

Our Stamina library (www.mdxi.com) offers sound functions (e.g.
DxWaveMulti) that create these ad hoc WAVs in microseconds. Pure VB
code can do almost as well.

--
   Jim Mack
   Twisted tees at http://www.cafepress.com/2050inc
   "We sew confusion"
Author
21 Mar 2009 8:27 PM
Abhishek
can you wav lib generated sound of any frequency ? I need sound/wav files of
particular frequency (non hearable by humans) to use in a mosquito repellent
software :)
Author
21 Mar 2009 10:06 PM
Jim Mack
Abhishek wrote:
> can you wav lib generated sound of any frequency ? I need sound/wav
> files of particular frequency (non hearable by humans) to use in a
> mosquito repellent software :)

Yes, up to the Nyquist limit -- roughly half the sampling frequency.
So at 48000 samples/sec, the highest frequency would be about 24kHz,
which is above what (most) humans can hear.

I don't have a RIFF/WAVE header spec in front of me, but I'm pretty
sure that sampling can be set to higher values than 48K. Whether MS
software will play it, or sounds cards and transducers will reproduce
it, is another matter.

Actually, now that I look at our spec... the published routines are
all preset to stereo 11025Hz, making the highest frequency about 5kHz.
But if you need it, I'd raise the limits to whatever you require. It's
just constants in the ASM source code.

--
        Jim
Author
21 Mar 2009 11:09 PM
Abhishek
I want to produce sound between range of 16000Hz to 20000Hz. can your dll do
it, how much your dll costs or it can be done thought the Win API directly ?

produce sound between 16000Hz to 20000Hz using WinAPI and output to
speakers. (though humans wont be able to hear it)
or
record wav of this frequency and play then in standard way.

can anyone help me out on this?

thanks.
Author
22 Mar 2009 12:15 AM
Jim Mack
Abhishek wrote:
> I want to produce sound between range of 16000Hz to 20000Hz. can
> your dll do it, how much your dll costs or it can be done thought
> the Win API directly ?

Let's keep commerce out of the group. Drop me a note at the obvious
address and we'll discuss it offline.

> produce sound between 16000Hz to 20000Hz using WinAPI and output to
> speakers. (though humans wont be able to hear it)
> or
> record wav of this frequency and play then in standard way.
>
> can anyone help me out on this?

I'm sure there are examples of how to create a WAV file in VB floating
around. If you don't find one, ask again and I'll send some sample
code. It's a bit wordy for a posting.

--
   Jim Mack
   Twisted tees at http://www.cafepress.com/2050inc
   "We sew confusion"
Author
23 Mar 2009 4:04 PM
Schmidt
"Abhishek" <m*@server.com> schrieb im Newsbeitrag
news:%239lFvonqJHA.5624@TK2MSFTNGP02.phx.gbl...

> I want to produce sound between range of 16000Hz to 20000Hz.

If you want to take a look at a DirectX8-based example -
here is one:
<http://groups.google.de/group/microsoft.public.vb.winapi/browse_frm/thread/
dcaa418f98906a10/6f57197320819663?q=vb+sss+directsound#6f57197320819663

Just play around with it - and then rip of the pieces you
want (and adapt the frequencies to your needs).

Olaf
Author
24 Mar 2009 12:20 AM
Jim Mack
Abhishek wrote:
> I want to produce sound between range of 16000Hz to 20000Hz. can
> your dll do it, how much your dll costs or it can be done thought
> the Win API directly ?
>
> produce sound between 16000Hz to 20000Hz using WinAPI and output to
> speakers. (though humans wont be able to hear it)
> or
> record wav of this frequency and play then in standard way.
>
> can anyone help me out on this?

I decided to polish up a class I've been using internally for a while,
and make it available for free use.

So there's an AX DLL at http://www.mdxi.com/other/ToneGen.zip along
with an example / testbed project.

I've done tons of this kind of stuff, including square waves, triangle
waves, quadrature (90/180/270), cosine-ramp frequency sweeps,
table-driven video-locked generators, etc. This DLL just does sine
waves.

Let me know if you can hear 20 kHz. (-:

--
   Jim Mack
   Twisted tees at http://www.cafepress.com/2050inc
   "We sew confusion"
Author
24 Mar 2009 12:54 PM
Rick Raisley
Show quote Hide quote
"Jim Mack" <jmack@mdxi.nospam.com> wrote in message
news:uZCbSZBrJHA.3584@TK2MSFTNGP05.phx.gbl...
> Abhishek wrote:
>> I want to produce sound between range of 16000Hz to 20000Hz. can
>> your dll do it, how much your dll costs or it can be done thought
>> the Win API directly ?
>>
>> produce sound between 16000Hz to 20000Hz using WinAPI and output to
>> speakers. (though humans wont be able to hear it)
>> or
>> record wav of this frequency and play then in standard way.
>>
>> can anyone help me out on this?
>
> I decided to polish up a class I've been using internally for a while,
> and make it available for free use.
>
> So there's an AX DLL at http://www.mdxi.com/other/ToneGen.zip along
> with an example / testbed project.
>
> I've done tons of this kind of stuff, including square waves, triangle
> waves, quadrature (90/180/270), cosine-ramp frequency sweeps,
> table-driven video-locked generators, etc. This DLL just does sine
> waves.
>
> Let me know if you can hear 20 kHz. (-:
>

And if we can't, then that means it's working, right?  ;-)

I can't hear that, and a 30-ish girl around me at work can hear it, but very
softly. But I annoyed the hell out of her with 16 kHz, which basically I
can't hear.  lol!

Anyhow, very nice. I like the different frequencies to the left and right,
so you can get a "throbbing" when they're close, but not the same. I can use
this, I'm sure. Thanks again!  ;-)

--
Regards,

Rick Raisley
heavymetal-A-T-bellsouth-D-O-T-net
Author
24 Mar 2009 1:38 PM
Rick Raisley
Jim, I notice when using your code that calling the sound does not wait
until it is done playing. I looped together some rising sounds, each 200 ms
long, expecting to hear a steadily increasing frequency. But it kind of
muddled together. Apparently, calling a 200 ms (or 1000 ms, whatever) sound
returns to the program immediately, while the sound continues to play. Now,
that's not unexpected, but it means you can't string several play commands
together, and have it sound like a "song".

I could add a Sleep command, to delay the duration of the note, but my guess
is that it will result in no sound playing for a brief period. Still, that
might be fine.

Is there anything within the DLL that could optionally keep code from
returning to the calling routine until the sound is done playing?

--
Regards,

Rick Raisley
heavymetal-A-T-bellsouth-D-O-T-net

Show quoteHide quote
"Jim Mack" <jmack@mdxi.nospam.com> wrote in message
news:uZCbSZBrJHA.3584@TK2MSFTNGP05.phx.gbl...
> Abhishek wrote:
>> I want to produce sound between range of 16000Hz to 20000Hz. can
>> your dll do it, how much your dll costs or it can be done thought
>> the Win API directly ?
>>
>> produce sound between 16000Hz to 20000Hz using WinAPI and output to
>> speakers. (though humans wont be able to hear it)
>> or
>> record wav of this frequency and play then in standard way.
>>
>> can anyone help me out on this?
>
> I decided to polish up a class I've been using internally for a while,
> and make it available for free use.
>
> So there's an AX DLL at http://www.mdxi.com/other/ToneGen.zip along
> with an example / testbed project.
>
> I've done tons of this kind of stuff, including square waves, triangle
> waves, quadrature (90/180/270), cosine-ramp frequency sweeps,
> table-driven video-locked generators, etc. This DLL just does sine
> waves.
>
> Let me know if you can hear 20 kHz. (-:
>
> --
>   Jim Mack
>   Twisted tees at http://www.cafepress.com/2050inc
>   "We sew confusion"
>
Author
24 Mar 2009 3:11 PM
Jim Mack
Rick Raisley wrote:
Show quoteHide quote
> Jim, I notice when using your code that calling the sound does not
> wait until it is done playing. I looped together some rising
> sounds, each 200 ms long, expecting to hear a steadily increasing
> frequency. But it kind of muddled together. Apparently, calling a
> 200 ms (or 1000 ms, whatever) sound returns to the program
> immediately, while the sound continues to play. Now, that's not
> unexpected, but it means you can't string several play commands
> together, and have it sound like a "song".
>
> I could add a Sleep command, to delay the duration of the note, but
> my guess is that it will result in no sound playing for a brief
> period. Still, that might be fine.
>
> Is there anything within the DLL that could optionally keep code
> from returning to the calling routine until the sound is done
> playing?

Internally, the DLL uses PlaySound with the SND_ASNYC flag, which is
normally what you want. I could add an option to play sync or async,
but it's just as easy for you to do it. The .Play method is mainly a
fillip - the real power is in the .Generate method.

First, Declare PlaySound yourself, and the SND_MEMORY flag.

Then, use the DLL to .Generate each sound, and save the returned
buffers in local byte arrays. See the file save example code for
inspiration.

When you want to play a series of sounds, make your own calls to
PlaySound using the stored buffers in any sequence. You can use a
Variant array to hold a series of byte arrays, BTW.

Also, I believe PlaySound works just as well with a series of
concatenated WAV images. If so you could just string out a set of
..SoundBuffers into one big array.

  Private Const SND_ASYNC As Long = 1   ' leave this out
  Private Const SND_MEMORY As Long = 4

  Private Declare Function PlaySound Lib "winmm" _
     Alias "PlaySoundA" (ByRef snd As Byte, _
     ByVal hFil As Long, ByVal flags As Long) As Long

  PlaySound bytBuffer(0), 0, SND_MEMORY 'Or SND_ASYNC

--
   Jim Mack
   Twisted tees at http://www.cafepress.com/2050inc
   "We sew confusion"
Author
24 Mar 2009 4:21 PM
Larry Serflaten
"Rick Raisley" <heavymetal-A-T-bellsouth-D-O-Tnet> wrote

>  "Jim Mack" wrote:
> > I decided to polish up a class I've been using internally for a while,
> > and make it available for free use.

> Is there anything within the DLL that could optionally keep code from
> returning to the calling routine until the sound is done playing?

It also would have been nice to have Object Browser comments for
the different properties.  Limits, acceptable values, explainations,
that sort of thing, right there in the Object Browser....

Show quoteHide quote
:-)
LFS
Author
24 Mar 2009 5:04 PM
Jim Mack
Larry Serflaten wrote:
Show quoteHide quote
> "Rick Raisley" <heavymetal-A-T-bellsouth-D-O-Tnet> wrote
>
>>  "Jim Mack" wrote:
>>> I decided to polish up a class I've been using internally for a
>>> while, and make it available for free use.
>
>> Is there anything within the DLL that could optionally keep code
>> from returning to the calling routine until the sound is done
>> playing?
>
> It also would have been nice to have Object Browser comments for
> the different properties.  Limits, acceptable values, explainations,
> that sort of thing, right there in the Object Browser....
>
> :-)

Yeah, and some chocolate would be nice. (-:

OK, v1.0.0.1 coming up later today, with TLB adds.

--
        Jim
Author
24 Mar 2009 5:37 PM
Jim Mack
Larry Serflaten wrote:

> It also would have been nice to have Object Browser comments for
> the different properties.  Limits, acceptable values, explainations,
> that sort of thing, right there in the Object Browser....

Done, revision in place. Let me know if it's enough. (-:

--
        Jim
Author
24 Mar 2009 11:00 PM
Larry Serflaten
"Jim Mack" <jmack@mdxi.nospam.com> wrote

> > It also would have been nice to have Object Browser comments for
> > the different properties.  Limits, acceptable values, explainations,
> > that sort of thing, right there in the Object Browser....
>
> Done, revision in place. Let me know if it's enough. (-:

Yes it is a big help to have info right there at your fingertips....

Thanks.
LFS
Author
25 Mar 2009 2:55 PM
Rick Raisley
Thanks very much, Jim. I'll mention a cute experience I had using your
program yesterday:

I was running various frequencies, seeing (okay, hearing) just how well this
old man can hear. I was find through 13 kHz, but then the volume started
going down. By turning the volume way up, I could just barely hear 15 kHz,
so was playing with that and 16 kHz, which I could NOT hear. Just then, a
young girl in our office walked by with both her hands covering her ears,
exclaiming "WHAT'S THAT NOISE!!??"  ;-)

Guess my ears aren't the only thing that's old.  lol!

--
Regards,

Rick Raisley
heavymetal-A-T-bellsouth-D-O-T-net

Show quoteHide quote
"Jim Mack" <jmack@mdxi.nospam.com> wrote in message
news:%23yQu4cKrJHA.1208@TK2MSFTNGP04.phx.gbl...
> Larry Serflaten wrote:
>
>> It also would have been nice to have Object Browser comments for
>> the different properties.  Limits, acceptable values, explainations,
>> that sort of thing, right there in the Object Browser....
>
> Done, revision in place. Let me know if it's enough. (-:
>
> --
>        Jim
>
Author
25 Mar 2009 4:18 PM
Nobody
"Rick Raisley" <heavymetal-A-T-bellsouth-D-O-Tnet> wrote in message
news:%23UKA3mVrJHA.3584@TK2MSFTNGP05.phx.gbl...
> Thanks very much, Jim. I'll mention a cute experience I had using your
> program yesterday:
>
> I was running various frequencies, seeing (okay, hearing) just how well
> this old man can hear. I was find through 13 kHz, but then the volume
> started going down. By turning the volume way up, I could just barely hear
> 15 kHz, so was playing with that and 16 kHz, which I could NOT hear. Just
> then, a young girl in our office walked by with both her hands covering
> her ears, exclaiming "WHAT'S THAT NOISE!!??"  ;-)

You could use Audacity which is a free audio editor. It has a Generate menu
to generate any frequency in various shapes.

http://en.wikipedia.org/wiki/Audacity
http://audacity.sourceforge.net/
Author
25 Mar 2009 6:25 PM
Michael Williams
"Rick Raisley" <heavymetal-A-T-bellsouth-D-O-Tnet> wrote in message
news:%23UKA3mVrJHA.3584@TK2MSFTNGP05.phx.gbl...

> I was running various frequencies, seeing (okay, hearing) just
> how well this old man can hear. I was fine through 13 kHz,
> but then the volume started going down. By turning the volume
> way up, I could just barely hear 15 kHz, so was playing with
> that and 16 kHz, which I could NOT hear. Just then, a young
> girl in our office walked by with both her hands covering her
> ears, exclaiming "WHAT'S THAT NOISE!!??"  ;-)
> Guess my ears aren't the only thing that's old.  lol!

You think that's bad? I can hear up to 11 kHz in one ear and only 8 kHz in
the other!

Mike
Author
24 Mar 2009 4:38 PM
Abhishek
thanks a lot for the code :P

and as far as my tests are concerned. I can hear 16 kHz but not 20 kHz. I am
24 yrs old.

any possibility to get source code of that dll ?

thanks,


Show quoteHide quote
"Jim Mack" <jmack@mdxi.nospam.com> wrote in message
news:uZCbSZBrJHA.3584@TK2MSFTNGP05.phx.gbl...
| Abhishek wrote:
| > I want to produce sound between range of 16000Hz to 20000Hz. can
| > your dll do it, how much your dll costs or it can be done thought
| > the Win API directly ?
| >
| > produce sound between 16000Hz to 20000Hz using WinAPI and output to
| > speakers. (though humans wont be able to hear it)
| > or
| > record wav of this frequency and play then in standard way.
| >
| > can anyone help me out on this?
|
| I decided to polish up a class I've been using internally for a while,
| and make it available for free use.
|
| So there's an AX DLL at http://www.mdxi.com/other/ToneGen.zip along
| with an example / testbed project.
|
| I've done tons of this kind of stuff, including square waves, triangle
| waves, quadrature (90/180/270), cosine-ramp frequency sweeps,
| table-driven video-locked generators, etc. This DLL just does sine
| waves.
|
| Let me know if you can hear 20 kHz. (-:
|
| --
|   Jim Mack
|   Twisted tees at http://www.cafepress.com/2050inc
|   "We sew confusion"
|
Author
21 Mar 2009 11:16 PM
Michael Williams
"Jim Mack" <jmack@mdxi.nospam.com> wrote in message
news:uMPQRFnqJHA.1504@TK2MSFTNGP03.phx.gbl...

> I don't have a RIFF/WAVE header spec in front of me,
> but I'm pretty sure that sampling can be set to higher
> values than 48K. Whether MS software will play it,
> or sounds cards and transducers will reproduce
> it, is another matter.

I'm not sure what the limit is but out of curiosity I've just created a 16
bit mono 1 KHz sine wave at a sample rate of one million samples per second
and it plays just fine (using sndPlaySound) on my system which has a
standard cheap motherboard sound chip, although that's about as high as I
can go with it. I was actually quite surprised that such a high sample rate
played okay and of course it is massively more than the OP would require.

Mike
Author
22 Mar 2009 12:10 AM
Jim Mack
Michael Williams wrote:
Show quoteHide quote
> "Jim Mack" <jmack@mdxi.nospam.com> wrote in message
> news:uMPQRFnqJHA.1504@TK2MSFTNGP03.phx.gbl...
>
>> I don't have a RIFF/WAVE header spec in front of me,
>> but I'm pretty sure that sampling can be set to higher
>> values than 48K. Whether MS software will play it,
>> or sounds cards and transducers will reproduce
>> it, is another matter.
>
> I'm not sure what the limit is but out of curiosity I've just
> created a 16 bit mono 1 KHz sine wave at a sample rate of one
> million samples per second and it plays just fine (using
> sndPlaySound) on my system which has a standard cheap motherboard
> sound chip, although that's about as high as I can go with it. I
> was actually quite surprised that such a high sample rate played
> okay and of course it is massively more than the OP would require.

Right -- the test of the whole chain would be to create a sound sample
at (say) 96K, of a 40khZ tone. If the sound makes it through the
system (as seen on a scope), there's the answer. But I suspect every
system is different -- most sound cards are probably spec'd with a
20kHz top end.

--
        Jim
Author
22 Mar 2009 9:29 AM
Michael Williams
"Jim Mack" <jmack@mdxi.nospam.com> wrote in message
news:%23ly8sKoqJHA.528@TK2MSFTNGP06.phx.gbl...

> Right -- the test of the whole chain would be to create a sound sample
> at (say) 96K, of a 40khZ tone. If the sound makes it through the
> system (as seen on a scope), there's the answer. But I suspect every
> system is different -- most sound cards are probably spec'd with a
> 20kHz top end.

Quite probably, and most typical speakers as well, so he should be okay for
the frequencies he is talking about (I think he mentioned 16 to 20 KHz). And
of course since the OP only wants the high frequencies for scaring
mosquitoes, who won't particularly be interested in hi fi reproduction (!),
he will probably be able to use considerably more than 20 KHz before the
response drops off to an unusable level. As you've said, he would need to
conduct a proper test using proper measuring equipment to be certain. It's
at times like this that I wish I had kept all the equipment I had many years
ago when my hobby was electronics, but sadly that's all gone now :-(  Out of
interest I've just carried out a few tests in which I created and played
sounds at various frequencies (using the typical CD 44.1 KHz sample rate)
and it showed that the frequency response of my own hearing is quite poor. I
knew it would be of course because I am 66 years of age and at that age the
frequency response will have dropped off considerably from my younger days,
but I was surprised that one of my ears was so bad that I could not hear any
sound at all above about 7 KHz (with the other ear being about 11 KHz). I'm
sure most people here will fare better than that? Youngsters of course will
be way above those levels, with some of them possibly even becoming annoyed
by the 16 KHz frequency he mentioned, and mosquitoes will be dancing in the
aisles ;-)

Mike
Author
23 Mar 2009 12:09 PM
Claus Centrino
> Youngsters of course will be way above those levels, with
> some of them possibly even becoming annoyed by the 16 KHz
> frequency he mentioned, and mosquitoes will be dancing in
> the aisles ;-)

In GB they use such high frequencies at shopping centers
after closing time to avoid accumulations of youngsters,
other people which don't hear that are not affected and can
still have an undisturbed look into the shop window. So
hardness of hearing sometimes can be advantageous.
Author
22 Mar 2009 7:21 AM
Abhishek
Declare Function Beep Lib "kernel32" Alias "Beep" (ByVal dwFreq As Long,
ByVal dwDuration As Long) As Long

· dwFreq
Windows NT:
Specifies the frequency, in hertz, of the sound. This parameter must be in
the range 37 through 32,767 (0x25 through 0x7FFF).
Windows 95:
The parameter is ignored.

· dwDuration
Windows NT:
Specifies the duration, in milliseconds, of the sound.
Windows 95:
The parameter is ignored.


Show quoteHide quote
"Lorin" <Lo***@discussions.microsoft.com> wrote in message
news:C7250338-683C-4139-833C-B4D1DAC2F306@microsoft.com...
| What can I do to replace the BEEP Api?
| VB6 on Vista PC.
| Want the same kind of frequency control, etc.
|
Author
23 Mar 2009 2:18 PM
Abhishek
I tried to use this API to generate sound, but it outputs to internal
motherboard speaker, not to the soundcard speaker.


Show quoteHide quote
"Abhishek" <m*@server.com> wrote in message
news:OzOyX7rqJHA.3856@TK2MSFTNGP03.phx.gbl...
| Declare Function Beep Lib "kernel32" Alias "Beep" (ByVal dwFreq As Long,
| ByVal dwDuration As Long) As Long
|
| · dwFreq
| Windows NT:
| Specifies the frequency, in hertz, of the sound. This parameter must be in
| the range 37 through 32,767 (0x25 through 0x7FFF).
| Windows 95:
| The parameter is ignored.
|
| · dwDuration
| Windows NT:
| Specifies the duration, in milliseconds, of the sound.
| Windows 95:
| The parameter is ignored.
|
|
| "Lorin" <Lo***@discussions.microsoft.com> wrote in message
| news:C7250338-683C-4139-833C-B4D1DAC2F306@microsoft.com...
|| What can I do to replace the BEEP Api?
|| VB6 on Vista PC.
|| Want the same kind of frequency control, etc.
||
|
|
Author
23 Mar 2009 5:17 AM
mayayana
You really should use a sound. People who won't
hear a sound played will not want to hear a beep.
If you force them to hear it then you're overriding
their choice not to have sounds. (There is a setting
in the Registry to disable beeps, but I don't know
of any accessible setting in the Sounds applet to
control that setting.)