|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Beep BeepWhat can I do to replace the BEEP Api?
VB6 on Vista PC. Want the same kind of frequency control, etc. Lorin wrote:
> What can I do to replace the BEEP Api? Gotta wonder why, but it's fairly easy.> VB6 on Vista PC. > Want the same kind of frequency control, etc. 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. 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 :) Abhishek wrote:
> can you wav lib generated sound of any frequency ? I need sound/wav Yes, up to the Nyquist limit -- roughly half the sampling frequency.> files of particular frequency (non hearable by humans) to use in a > mosquito repellent software :) 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 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. Abhishek wrote:
> I want to produce sound between range of 16000Hz to 20000Hz. can Let's keep commerce out of the group. Drop me a note at the obvious> your dll do it, how much your dll costs or it can be done thought > the Win API directly ? address and we'll discuss it offline. > produce sound between 16000Hz to 20000Hz using WinAPI and output to I'm sure there are examples of how to create a WAV file in VB floating> 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? around. If you don't find one, ask again and I'll send some sample code. It's a bit wordy for a posting. "Abhishek" <m*@server.com> schrieb im Newsbeitrag If you want to take a look at a DirectX8-based example -news:%239lFvonqJHA.5624@TK2MSFTNGP02.phx.gbl... > I want to produce sound between range of 16000Hz to 20000Hz. 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 Abhishek wrote:
> I want to produce sound between range of 16000Hz to 20000Hz. can I decided to polish up a class I've been using internally for a while,> 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? 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. (-:
Show quote
Hide quote
"Jim Mack" <jmack@mdxi.nospam.com> wrote in message And if we can't, then that means it's working, right? ;-)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. (-: > 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 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? -- Show quoteHide quoteRegards, Rick Raisley heavymetal-A-T-bellsouth-D-O-T-net "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" > Rick Raisley wrote:
Show quoteHide quote > Jim, I notice when using your code that calling the sound does not Internally, the DLL uses PlaySound with the SND_ASNYC flag, which is> 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? 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 "Rick Raisley" <heavymetal-A-T-bellsouth-D-O-Tnet> wrote It also would have been nice to have Object Browser comments for> "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? the different properties. Limits, acceptable values, explainations, that sort of thing, right there in the Object Browser.... Show quoteHide quote :-) LFS Larry Serflaten wrote:
Show quoteHide quote > "Rick Raisley" <heavymetal-A-T-bellsouth-D-O-Tnet> wrote Yeah, and some chocolate would be nice. (-:> >> "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.... > > :-) OK, v1.0.0.1 coming up later today, with TLB adds. -- Jim Larry Serflaten wrote:
> It also would have been nice to have Object Browser comments for Done, revision in place. Let me know if it's enough. (-:> the different properties. Limits, acceptable values, explainations, > that sort of thing, right there in the Object Browser.... -- Jim "Jim Mack" <jmack@mdxi.nospam.com> wrote Yes it is a big help to have info right there at your fingertips....> > 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. (-: Thanks. LFS 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! -- Show quoteHide quoteRegards, Rick Raisley heavymetal-A-T-bellsouth-D-O-T-net "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 > "Rick Raisley" <heavymetal-A-T-bellsouth-D-O-Tnet> wrote in message You could use Audacity which is a free audio editor. It has a Generate menu 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!!??" ;-) to generate any frequency in various shapes. http://en.wikipedia.org/wiki/Audacity http://audacity.sourceforge.net/ "Rick Raisley" <heavymetal-A-T-bellsouth-D-O-Tnet> wrote in message You think that's bad? I can hear up to 11 kHz in one ear and only 8 kHz in 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! the other! Mike 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" | "Jim Mack" <jmack@mdxi.nospam.com> wrote in message I'm not sure what the limit is but out of curiosity I've just created a 16 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. 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 Michael Williams wrote:
Show quoteHide quote > "Jim Mack" <jmack@mdxi.nospam.com> wrote in message Right -- the test of the whole chain would be to create a sound sample> 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. 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 "Jim Mack" <jmack@mdxi.nospam.com> wrote in message Quite probably, and most typical speakers as well, so he should be okay for 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. 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 > Youngsters of course will be way above those levels, with In GB they use such high frequencies at shopping centers > some of them possibly even becoming annoyed by the 16 KHz > frequency he mentioned, and mosquitoes will be dancing in > the aisles ;-) 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. 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. | 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. || | | 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.) |
|||||||||||||||||||||||