473,594 Members | 2,663 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Implementing a 'horn' sound.

I'm putting together a C# .Net forms project on win2k. The application
requires some sort of horn sound. I've never implemented any audio in .Net,
so I'm not sure how best to accomplish this.

It's an application that works with a wireless barcode scanner, in a
warehouse environment. The user could be potentially 20 or 30 ft. from the
PC. If the user scans something improperly, the app should sound a 'horn' to
notify the user. I'm trying to accomplish this with the standard sound card
and speakers supplied with the PC.

The optimal solution would be to play my horn sound at a volume level
totally (or at least mostly) independent of any other sounds being played
through the sound card and speakers. But I don't think this can be done -
all wave files, for example, play at the same mixer level in windows. Any
ideas?

AFAIK, I could:
1) use the PlaySound() api to play a .wav file. The downside of this is that
the volume of all windows sounds will be approximately the same as the horn
sound.
2) Use waveOutSetVolum e() in combination with PlaySound() to raise and lower
the wave volume before and after playing the horn sound. The downside is
that the app is increasing the volume of all wave audio while the horn sound
is being played.
3) Create a horn sound that is a MIDI sound and use the MCI APIs to play the
sound. Then the windows mixer can be used to adjust levels between the MIDI
and wave channels.
4) Use a second sound card, and use PlaySound() with this device.

I'm curious:
1) Is there a way to control the relative level of individual wave sounds,
such that I can play a specific wave file something like 10 times louder
than the rest of the windows sounds?
2) Is it possible to create my own mixing device, such that I can play a
wave sound without regard to the rest of the volumes already defined by the
windows mixer?

Any thoughts would be appreciated.

_______________ ___________
Rob Gravereaux
Principal Developer
Glen Road Systems, Inc.
http://www.grsinc.com
Nov 16 '05 #1
4 3469
Robert,
There are ways to control the volume in code, you could increase the
volume to max, play your horn.wav, then return the volume to what it was
before. I don't know what's available in the framework, but look at the
waveoutSetVolum e Win32 API.

--
Floyd Burger
"Robert Gravereaux" <Ro************ ********@grsinc .com> wrote in message
news:ul******** ******@TK2MSFTN GP09.phx.gbl...
I'm putting together a C# .Net forms project on win2k. The application
requires some sort of horn sound. I've never implemented any audio in ..Net, so I'm not sure how best to accomplish this.

It's an application that works with a wireless barcode scanner, in a
warehouse environment. The user could be potentially 20 or 30 ft. from the
PC. If the user scans something improperly, the app should sound a 'horn' to notify the user. I'm trying to accomplish this with the standard sound card and speakers supplied with the PC.

The optimal solution would be to play my horn sound at a volume level
totally (or at least mostly) independent of any other sounds being played
through the sound card and speakers. But I don't think this can be done -
all wave files, for example, play at the same mixer level in windows. Any
ideas?

AFAIK, I could:
1) use the PlaySound() api to play a .wav file. The downside of this is that the volume of all windows sounds will be approximately the same as the horn sound.
2) Use waveOutSetVolum e() in combination with PlaySound() to raise and lower the wave volume before and after playing the horn sound. The downside is
that the app is increasing the volume of all wave audio while the horn sound is being played.
3) Create a horn sound that is a MIDI sound and use the MCI APIs to play the sound. Then the windows mixer can be used to adjust levels between the MIDI and wave channels.
4) Use a second sound card, and use PlaySound() with this device.

I'm curious:
1) Is there a way to control the relative level of individual wave sounds,
such that I can play a specific wave file something like 10 times louder
than the rest of the windows sounds?
2) Is it possible to create my own mixing device, such that I can play a
wave sound without regard to the rest of the volumes already defined by the windows mixer?

Any thoughts would be appreciated.

_______________ ___________
Rob Gravereaux
Principal Developer
Glen Road Systems, Inc.
http://www.grsinc.com

Nov 16 '05 #2
That's certainly an option. The downside is that the volume for all wave
sounds gets modified, including all windows sounds.

I'd rather have a solution that allows me to play a sound at a level totally
independent of the level of any other audio.
"Floyd Burger" <fl***@adelphia .not> wrote in message
news:eQ******** *****@TK2MSFTNG P09.phx.gbl...
Robert,
There are ways to control the volume in code, you could increase the
volume to max, play your horn.wav, then return the volume to what it was
before. I don't know what's available in the framework, but look at the
waveoutSetVolum e Win32 API.

--
Floyd Burger
"Robert Gravereaux" <Ro************ ********@grsinc .com> wrote in message
news:ul******** ******@TK2MSFTN GP09.phx.gbl...
I'm putting together a C# .Net forms project on win2k. The application
requires some sort of horn sound. I've never implemented any audio in .Net,
so I'm not sure how best to accomplish this.

It's an application that works with a wireless barcode scanner, in a
warehouse environment. The user could be potentially 20 or 30 ft. from the PC. If the user scans something improperly, the app should sound a 'horn' to
notify the user. I'm trying to accomplish this with the standard sound

card
and speakers supplied with the PC.

The optimal solution would be to play my horn sound at a volume level
totally (or at least mostly) independent of any other sounds being

played through the sound card and speakers. But I don't think this can be done - all wave files, for example, play at the same mixer level in windows. Any ideas?

AFAIK, I could:
1) use the PlaySound() api to play a .wav file. The downside of this is

that
the volume of all windows sounds will be approximately the same as the

horn
sound.
2) Use waveOutSetVolum e() in combination with PlaySound() to raise and

lower
the wave volume before and after playing the horn sound. The downside is
that the app is increasing the volume of all wave audio while the horn

sound
is being played.
3) Create a horn sound that is a MIDI sound and use the MCI APIs to play

the
sound. Then the windows mixer can be used to adjust levels between the

MIDI
and wave channels.
4) Use a second sound card, and use PlaySound() with this device.

I'm curious:
1) Is there a way to control the relative level of individual wave sounds, such that I can play a specific wave file something like 10 times louder
than the rest of the windows sounds?
2) Is it possible to create my own mixing device, such that I can play a
wave sound without regard to the rest of the volumes already defined by

the
windows mixer?

Any thoughts would be appreciated.

_______________ ___________
Rob Gravereaux
Principal Developer
Glen Road Systems, Inc.
http://www.grsinc.com


Nov 16 '05 #3
Robert,
I haven't played with this before, but it looks like DirectSound can give
you volume control for a specific buffer (your wav file).
http://tinyurl.com/3xsv5 MSDN says there is a managed DirectX9 available.
It won't help much if the operator has turned the system volume down though.
Have you thought about making a secondary horn that's independent of the
system audio system? You could use the serial port to drive it, raise DTR,
which causes the DTR pin to be energized with 5v (.5amp). Using a relay or
transistor you could rig up a car horn or something of that ilk. I use
something similar here, but it drives a electric motor instead of sounding a
horn when DTR is energized.

--
Floyd Burger
"Robert Gravereaux" <Ro************ ********@grsinc .com> wrote in message
news:u3******** ******@TK2MSFTN GP11.phx.gbl...
That's certainly an option. The downside is that the volume for all wave
sounds gets modified, including all windows sounds.

I'd rather have a solution that allows me to play a sound at a level totally independent of the level of any other audio.
"Floyd Burger" <fl***@adelphia .not> wrote in message
news:eQ******** *****@TK2MSFTNG P09.phx.gbl...
Robert,
There are ways to control the volume in code, you could increase the
volume to max, play your horn.wav, then return the volume to what it was
before. I don't know what's available in the framework, but look at the
waveoutSetVolum e Win32 API.

--
Floyd Burger
"Robert Gravereaux" <Ro************ ********@grsinc .com> wrote in message
news:ul******** ******@TK2MSFTN GP09.phx.gbl...
I'm putting together a C# .Net forms project on win2k. The application
requires some sort of horn sound. I've never implemented any audio in .Net,
so I'm not sure how best to accomplish this.

It's an application that works with a wireless barcode scanner, in a
warehouse environment. The user could be potentially 20 or 30 ft. from the
PC. If the user scans something improperly, the app should sound a 'horn'
to
notify the user. I'm trying to accomplish this with the standard sound

card
and speakers supplied with the PC.

The optimal solution would be to play my horn sound at a volume level
totally (or at least mostly) independent of any other sounds being played through the sound card and speakers. But I don't think this can be done - all wave files, for example, play at the same mixer level in windows. Any ideas?

AFAIK, I could:
1) use the PlaySound() api to play a .wav file. The downside of this
is that
the volume of all windows sounds will be approximately the same as the

horn
sound.
2) Use waveOutSetVolum e() in combination with PlaySound() to raise and

lower
the wave volume before and after playing the horn sound. The downside
is that the app is increasing the volume of all wave audio while the horn

sound
is being played.
3) Create a horn sound that is a MIDI sound and use the MCI APIs to play the
sound. Then the windows mixer can be used to adjust levels between the

MIDI
and wave channels.
4) Use a second sound card, and use PlaySound() with this device.

I'm curious:
1) Is there a way to control the relative level of individual wave sounds, such that I can play a specific wave file something like 10 times

louder than the rest of the windows sounds?
2) Is it possible to create my own mixing device, such that I can play a wave sound without regard to the rest of the volumes already defined

by the
windows mixer?

Any thoughts would be appreciated.

_______________ ___________
Rob Gravereaux
Principal Developer
Glen Road Systems, Inc.
http://www.grsinc.com



Nov 16 '05 #4
I've looked into DirectSound with the managed classes. The volume control is
an attenuation. So a sound can only be made quieter than the associated
mixer levels, not louder.

We've done things in the past using the serial port to drive external
devices. In this case we're trying to do something as simple as possible.
We've got a PC with a sound card & speakers - we figured we could get it to
play a horn type sound without much trouble. We've also got a PLC connected
to the system to control some conveyor, so worst case we'll have the PLC
sound a buzzer. But again that's additional hardware and programming on the
PLC side of things.
"Floyd Burger" <fl***@adelphia .not> wrote in message
news:%2******** ********@TK2MSF TNGP10.phx.gbl. ..
Robert,
I haven't played with this before, but it looks like DirectSound can give you volume control for a specific buffer (your wav file).
http://tinyurl.com/3xsv5 MSDN says there is a managed DirectX9 available.
It won't help much if the operator has turned the system volume down though. Have you thought about making a secondary horn that's independent of the
system audio system? You could use the serial port to drive it, raise DTR, which causes the DTR pin to be energized with 5v (.5amp). Using a relay or
transistor you could rig up a car horn or something of that ilk. I use
something similar here, but it drives a electric motor instead of sounding a horn when DTR is energized.

--
Floyd Burger
"Robert Gravereaux" <Ro************ ********@grsinc .com> wrote in message
news:u3******** ******@TK2MSFTN GP11.phx.gbl...
That's certainly an option. The downside is that the volume for all wave
sounds gets modified, including all windows sounds.

I'd rather have a solution that allows me to play a sound at a level totally
independent of the level of any other audio.
"Floyd Burger" <fl***@adelphia .not> wrote in message
news:eQ******** *****@TK2MSFTNG P09.phx.gbl...
Robert,
There are ways to control the volume in code, you could increase the
volume to max, play your horn.wav, then return the volume to what it was before. I don't know what's available in the framework, but look at the waveoutSetVolum e Win32 API.

--
Floyd Burger
"Robert Gravereaux" <Ro************ ********@grsinc .com> wrote in message news:ul******** ******@TK2MSFTN GP09.phx.gbl...
> I'm putting together a C# .Net forms project on win2k. The application > requires some sort of horn sound. I've never implemented any audio in .Net,
> so I'm not sure how best to accomplish this.
>
> It's an application that works with a wireless barcode scanner, in a
> warehouse environment. The user could be potentially 20 or 30 ft. from
the
> PC. If the user scans something improperly, the app should sound a 'horn'
to
> notify the user. I'm trying to accomplish this with the standard
sound card
> and speakers supplied with the PC.
>
> The optimal solution would be to play my horn sound at a volume level > totally (or at least mostly) independent of any other sounds being

played
> through the sound card and speakers. But I don't think this can be

done -
> all wave files, for example, play at the same mixer level in windows.
Any
> ideas?
>
> AFAIK, I could:
> 1) use the PlaySound() api to play a .wav file. The downside of this

is that
> the volume of all windows sounds will be approximately the same as
the horn
> sound.
> 2) Use waveOutSetVolum e() in combination with PlaySound() to raise and lower
> the wave volume before and after playing the horn sound. The downside is > that the app is increasing the volume of all wave audio while the
horn sound
> is being played.
> 3) Create a horn sound that is a MIDI sound and use the MCI APIs to
play the
> sound. Then the windows mixer can be used to adjust levels between the MIDI
> and wave channels.
> 4) Use a second sound card, and use PlaySound() with this device.
>
> I'm curious:
> 1) Is there a way to control the relative level of individual wave

sounds,
> such that I can play a specific wave file something like 10 times louder > than the rest of the windows sounds?
> 2) Is it possible to create my own mixing device, such that I can
play a > wave sound without regard to the rest of the volumes already defined by the
> windows mixer?
>
> Any thoughts would be appreciated.
>
> _______________ ___________
> Rob Gravereaux
> Principal Developer
> Glen Road Systems, Inc.
> http://www.grsinc.com
>
>



Nov 16 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3590
by: cppaddict | last post by:
I have a design question which I am posting here because the implementation will be in C++ and I think there may be C++ specific language constructs (eg, friends) that might be relevant to the solution. I am implementing the Mediator pattern to create an event-driven app. The Collaborators (which watch for various events and which all have a reference to the Mediator object) will call handleEvent(Event e) on the Mediator object when...
1
1767
by: (Pete Cresswell) | last post by:
I'm starting on an app part of which will be a port from a humongous Excel spreadsheet and I will have to duplicate some functions. Among them are a couple that sound pretty basic and, I suspect, may be available directly in VBA: STDEV and AVERAGE. Others, I suspect, I'm going to need specs from the client for: ROR (Rate of Return) PERCENTRANK (who knows...)
1
3169
by: Marco Krechting | last post by:
Hi All, I have a database with the timer function set to warn the user that arecord is due to expire. Is there a Win API that I can use so a loud warning will go off. Not this simpel beep in access but a really, like Virus Alert kind of warning? Regards Marco
1
7994
by: Lam | last post by:
how can I play sound file in a .aspx page written in C#? I try to use the code like the following. But whenI call the play function play("sound.wav", this.SND_ASYNC) my computer give out "be" sound instead playing the file (same code works fine in a windows application written in c# , that mean there is nothing wrong with my sound card.) thanks ----------------------------------------------------------------------------...
4
1635
by: Larry Serflaten | last post by:
I'm adding a bit of sound to a simple game I've got going, and I want to have several sounds on at the same time, so I go looking to use the MCISendString commands and find they CRASH MY COMPUTER after moderate use. After a bit of searching the web for what I might be doing wrong I find the work around is to bring in the old MultiMedia ActiveX control from the .Com world and use it, so I added the three I need and no more crashes.....
6
2975
by: =?Utf-8?B?VmVybm9uIFBlcHBlcnM=?= | last post by:
I have an application that is designed for using with a bar code scanner. I want the user to know that the scan was complete and the data was entered, so I am playing a system sound after data entry. The data is being put into a text box, and a Return is sent after the data. I use the keypress event to capture the Return, and save the data. Then, I play the system sound, clear the text box, and set the focus back to the text box for the...
6
5860
by: csharpula csharp | last post by:
Hello , I would like to build a tree structure in c# using the arraylist or hash table. what is the best way to implement it if I want to add children and to print my tree. Thank you! *** Sent via Developersdex http://www.developersdex.com ***
13
5025
by: Tristan Wibberley | last post by:
Hi I've got implementing overloaded operator new and delete pretty much down. Just got to meet the alignment requirements of the class on which the operator is overloaded. But how does one implement operator new/delete I can't see a way to indicate, on delete, how many objects must be destroyed (or how big the space is) - alternatively I can't figure out what are the alignment requirements so that the implementation, after calling my...
4
4574
by: kid joe | last post by:
Hello I've got interested in learning some basic sound programming bits in C... mainly I want to know how to go about accessing the sound devices - reading from them mainly - in windows and linux... I'd kind of like to be able to do it without a whole bunch of extra garbage added in there - by this I mean that I know in windows there are a million sound programming packages that make the whole process "easier" - there are also a few in...
0
7880
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8255
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8374
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8010
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8242
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5413
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
3868
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
3903
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1486
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.