By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,478 Members | 1,833 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,478 IT Pros & Developers. It's quick & easy.

Implementing a 'horn' sound.

P: n/a
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 waveOutSetVolume() 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
Share this Question
Share on Google+
4 Replies


P: n/a
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
waveoutSetVolume Win32 API.

--
Floyd Burger
"Robert Gravereaux" <Ro********************@grsinc.com> wrote in message
news:ul**************@TK2MSFTNGP09.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 waveOutSetVolume() 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

P: n/a
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*************@TK2MSFTNGP09.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
waveoutSetVolume Win32 API.

--
Floyd Burger
"Robert Gravereaux" <Ro********************@grsinc.com> wrote in message
news:ul**************@TK2MSFTNGP09.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 waveOutSetVolume() 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

P: n/a
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**************@TK2MSFTNGP11.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*************@TK2MSFTNGP09.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
waveoutSetVolume Win32 API.

--
Floyd Burger
"Robert Gravereaux" <Ro********************@grsinc.com> wrote in message
news:ul**************@TK2MSFTNGP09.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 waveOutSetVolume() 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

P: n/a
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****************@TK2MSFTNGP10.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**************@TK2MSFTNGP11.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*************@TK2MSFTNGP09.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 waveoutSetVolume Win32 API.

--
Floyd Burger
"Robert Gravereaux" <Ro********************@grsinc.com> wrote in message news:ul**************@TK2MSFTNGP09.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 waveOutSetVolume() 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 discussion thread is closed

Replies have been disabled for this discussion.