PC Review


Reply
Thread Tools Rate Thread

BEEP while working

 
 
adi
Guest
Posts: n/a
 
      21st Dec 2006
Hi

My application has many automatic features because it is designed to
run without any user interfering.
In fact, my app will work on a system without a keyboard or a mouse.
Anyway, from time to time, the app will perform some tasks. When
running certain critical tasks I need to play some speaker sounds while
they are processing. The sound should be a sequence of beeps. Just a
single beep could be anoying for the human listener.
On the other hand, the tasks will be performed on a random basis and
will take an impossible to determine period of time.
Should I use threads to play these sounds? I so, I fall in another
problem. What if 2 or more tasks will be started at the same time? Is
API's Beep() function thread safe?
It's a problem of design, too.

Any ideea will be appreciated
Thanks.

 
Reply With Quote
 
 
 
 
Ebbe Kristensen
Guest
Posts: n/a
 
      21st Dec 2006
adi wrote:
> Should I use threads to play these sounds? I so, I fall in another
> problem. What if 2 or more tasks will be started at the same time? Is
> API's Beep() function thread safe?
> It's a problem of design, too.


Make one thread that handles the various beep sequences. This thread takes
the beep commands from a *protected* queue. The other threads send their
beep commands to this queue.

- Beep sequences will not interrupt each other.
- It is easy to make a pause between them - just add a silent period after
each sequence
- Since the queue is protected, two or more tasks will never "tread on each
others' toes", the one that comes last will just have to wait a bit until
the first one has finished adding its beep command to the queue.
- Once a beep command has been queued, the task thread can go on doing its
work.

Ebbe


 
Reply With Quote
 
Ignacio Machin \( .NET/ C# MVP \)
Guest
Posts: n/a
 
      21st Dec 2006
Hi,


"adi" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Hi
>
> The sound should be a sequence of beeps.


You can use the Beep function fron the win API

>Just a
> single beep could be anoying for the human listener.


So, you want to annoy somebody?

> On the other hand, the tasks will be performed on a random basis and
> will take an impossible to determine period of time.
> Should I use threads to play these sounds? I so, I fall in another
> problem. What if 2 or more tasks will be started at the same time? Is
> API's Beep() function thread safe?

Yes it should be


btw, is your app running as a win service?



 
Reply With Quote
 
adi
Guest
Posts: n/a
 
      22nd Dec 2006
Hi Ignacio

No, I don't want to annoy anybody, that's why I poited out I need to
play a *sequence of beeps* rather than simply playing a *single beep*
while the tasks are running
That's why I think I should use a separate thread to play the
sequences.
I aggree with Ebbe. I should implement a queue of beep commands. The
only thing is that if several tasks produce such commands in the same
time, the human listener will hear a scrambled sound, something like a
noise, wich also may be annoying.
One solution could be to grant acces to this queue only to one task at
a time. This is fine with me. Anyway, if somebody has another solution,
that it is welcome.

No, my app will not work as a windows service. It's a "simple" win app.

Thanks.



Ignacio Machin ( .NET/ C# MVP ) a scris:
> Hi,
>
>
> "adi" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > Hi
> >
> > The sound should be a sequence of beeps.

>
> You can use the Beep function fron the win API
>
> >Just a
> > single beep could be anoying for the human listener.

>
> So, you want to annoy somebody?
>
> > On the other hand, the tasks will be performed on a random basis and
> > will take an impossible to determine period of time.
> > Should I use threads to play these sounds? I so, I fall in another
> > problem. What if 2 or more tasks will be started at the same time? Is
> > API's Beep() function thread safe?

> Yes it should be
>
>
> btw, is your app running as a win service?


 
Reply With Quote
 
Ebbe Kristensen
Guest
Posts: n/a
 
      22nd Dec 2006
adi wrote:
> I aggree with Ebbe. I should implement a queue of beep commands. The
> only thing is that if several tasks produce such commands in the same
> time, the human listener will hear a scrambled sound, something like a
> noise, wich also may be annoying.


Not necessarily.

Let the beeper thread be the place where the beep sequences are defined. The
threads that need to signal the user enter a simple code in the queue that
tells the beeper thread which sequence to play (i.e. 1 = bip beeep bip, 2 =
beeep beeep etc.).
Thus a beep command in the queue will not be played until the beeper thread
takes out of the queue. And that will not happen before it has finished
playing the previous one. Also, since the beeper thread is in full control,
it can also add a pause between beep sequences.

Ebbe


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Beep Not Working Faraz A. Qureshi Microsoft Excel Programming 7 13th Sep 2009 09:56 PM
Beep not working =?Utf-8?B?QW1pdA==?= Microsoft Access Form Coding 9 30th Mar 2006 03:14 PM
System Produce BEEP BEEP BEEP.... Desmond Microsoft Windows 2000 4 8th Jun 2004 09:38 PM
No POST beep on working machine BP Asus Motherboards 5 20th Mar 2004 12:03 AM
A7V133-VM + PCI video = BEEP BEEP BEEP BEEP? Lost Asus Motherboards 2 13th Nov 2003 05:33 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 03:56 AM.