473,396 Members | 1,891 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

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 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
4 3445
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
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...
1
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,...
1
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...
1
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"...
4
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...
6
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...
6
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! ***...
13
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...
4
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...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
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,...
0
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...
0
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.