beep without delay

Hi,

How do you generate a beep sound without a delay?

I have the following code.

sound(3500);
delay(100);
nosound();

I would like to generate different beep sounds without using the delay
function.

Is this possible? Is there some source code for generating different beep
sounds?

What are the best frequency values to pass for sound()?

TIA

Augie

I just tried the sound thing (I’ve never used it before). Without a delay,
it processes the nosound function too quickly, so a delay(1) was needed to
allow the sound to go through.

What you might do to get a smaller timeout (only way I can think of right
now) is to set up some timer that calls a timer handler (or triggers a
proxy) and within the handling of the request do a nosound(). The timers
have nanosecond timing values, so you might get shorter “delays” that way…

Hope this helps,
R B Adler

“Augie Henriques” <augiehenriques@hotmail.com> wrote in message
news:9f3g28$3du$1@inn.qnx.com

Hi,

How do you generate a beep sound without a delay?

I have the following code.

sound(3500);
delay(100);
nosound();

I would like to generate different beep sounds without using the delay
function.

Is this possible? Is there some source code for generating different beep
sounds?

What are the best frequency values to pass for sound()?

TIA

Augie

“R B Adler” <cococr@cs.rpi.edu> wrote in message
news:9f3k6d$60c$1@inn.qnx.com

I just tried the sound thing (I’ve never used it before). Without a
delay,
it processes the nosound function too quickly, so a delay(1) was needed to
allow the sound to go through.

What you might do to get a smaller timeout (only way I can think of right
now) is to set up some timer that calls a timer handler (or triggers a
proxy) and within the handling of the request do a nosound(). The timers
have nanosecond timing values, so you might get shorter “delays” that
way…

Thanks for the ideas.

I was aware of the timer/proxy solution. This option is not workable in my
app. I’m thinking there is got to be another way?

Maybe I can write directly to the hardware?

TIA

Augie

Hope this helps,
R B Adler

“Augie Henriques” <> augiehenriques@hotmail.com> > wrote in message
news:9f3g28$3du$> 1@inn.qnx.com> …
Hi,

How do you generate a beep sound without a delay?

I have the following code.

sound(3500);
delay(100);
nosound();

I would like to generate different beep sounds without using the delay
function.

Is this possible? Is there some source code for generating different
beep
sounds?

What are the best frequency values to pass for sound()?

TIA

Augie
\

I presume that you do not want the delay because
your process must not stop for this long a period.
There are numerous work arounds. Here are two.


THE FORK


void play_sound()
{
if (fork() == 0)
{
sound(3500);
delay(100);
nosound();
exit(0);
}
}

This is probably overkill, and the overhead is a little
bit much. Here is an alternative. Create a separate
process that looks like this:

main()
{
qnx_name_attach(…);
while(1)
{
pid = Receive(0,NULL,0);
Reply(pid,0,NULL)
sound(3500);
delay(100);
nosound();
}
}

Your process just needs the following code:

void play_sound()
{
pid = qnx_name_locate(…)
Send(pid,NULL,NULL,0,0);
}



Previously, Augie Henriques wrote in qdn.public.qnx4:

Hi,

How do you generate a beep sound without a delay?

I have the following code.

sound(3500);
delay(100);
nosound();

I would like to generate different beep sounds without using the delay
function.

Is this possible? Is there some source code for generating different beep
sounds?

What are the best frequency values to pass for sound()?

TIA

Augie
\


Mitchell Schoenbrun --------- maschoen@pobox.com

May I suggest the following variation on Mitchell’s code:

void play_sound()
{
static pid;
if (0 == pid) pid = qnx_name_locate(…);
Send(pid, 0,0,0,0);
}


Mitchell Schoenbrun wrote:

I presume that you do not want the delay because
your process must not stop for this long a period.
There are numerous work arounds. Here are two.

THE FORK

void play_sound()
{
if (fork() == 0)
{
sound(3500);
delay(100);
nosound();
exit(0);
}
}

This is probably overkill, and the overhead is a little
bit much. Here is an alternative. Create a separate
process that looks like this:

main()
{
qnx_name_attach(…);
while(1)
{
pid = Receive(0,NULL,0);
Reply(pid,0,NULL)
sound(3500);
delay(100);
nosound();
}
}

Your process just needs the following code:

void play_sound()
{
pid = qnx_name_locate(…)
Send(pid,NULL,NULL,0,0);
}

Previously, Augie Henriques wrote in qdn.public.qnx4:
Hi,

How do you generate a beep sound without a delay?

I have the following code.

sound(3500);
delay(100);
nosound();

I would like to generate different beep sounds without using the delay
function.

Is this possible? Is there some source code for generating different beep
sounds?

What are the best frequency values to pass for sound()?

TIA

Augie



\

Mitchell Schoenbrun --------- > maschoen@pobox.com

Oops, that should be

static pid_t pid;

Dean Douthat wrote:

May I suggest the following variation on Mitchell’s code:

void play_sound()
{
static pid;
if (0 == pid) pid = qnx_name_locate(…);
Send(pid, 0,0,0,0);
}

Mitchell Schoenbrun wrote:

I presume that you do not want the delay because
your process must not stop for this long a period.
There are numerous work arounds. Here are two.

THE FORK

void play_sound()
{
if (fork() == 0)
{
sound(3500);
delay(100);
nosound();
exit(0);
}
}

This is probably overkill, and the overhead is a little
bit much. Here is an alternative. Create a separate
process that looks like this:

main()
{
qnx_name_attach(…);
while(1)
{
pid = Receive(0,NULL,0);
Reply(pid,0,NULL)
sound(3500);
delay(100);
nosound();
}
}

Your process just needs the following code:

void play_sound()
{
pid = qnx_name_locate(…)
Send(pid,NULL,NULL,0,0);
}

Previously, Augie Henriques wrote in qdn.public.qnx4:
Hi,

How do you generate a beep sound without a delay?

I have the following code.

sound(3500);
delay(100);
nosound();

I would like to generate different beep sounds without using the delay
function.

Is this possible? Is there some source code for generating different beep
sounds?

What are the best frequency values to pass for sound()?

TIA

Augie



\

Mitchell Schoenbrun --------- > maschoen@pobox.com

Mitchell Schoenbrun wrote:

This is probably overkill, and the overhead is a little
bit much. Here is an alternative. Create a separate
process that looks like this:

main()
{
qnx_name_attach(…);
while(1)
{
pid = Receive(0,NULL,0);
Reply(pid,0,NULL)
sound(3500);
delay(100);
nosound();
}
}

Your process just needs the following code:

void play_sound()
{
pid = qnx_name_locate(…)
Send(pid,NULL,NULL,0,0);
}

I once implemented it that way, by writing a “sound”-server task. You
can send a sound message to it containing frequency and duration. It
then starts the sound and a timer to stop it. This has the advantage,
that you can implement, that a following sound message interrupts the
currently “running” sound without having to wait until it is finished
(as you would, if using delay).

chris

Hi,

You may want to trigger a proxy (non-blocking) rather then sending a message which will put your client
into send and reply blocked states.

pid = qnx_name_locate(…);
proxy_pid = qnx_proxy_attach(pid,…);



Trigger(proxy_pid); /* request sound form server process */

Regards,

Joe

Mitchell Schoenbrun <maschoen@pobox.com> wrote:

I presume that you do not want the delay because
your process must not stop for this long a period.
There are numerous work arounds. Here are two.



THE FORK



void play_sound()
{
if (fork() == 0)
{
sound(3500);
delay(100);
nosound();
exit(0);
}
}

This is probably overkill, and the overhead is a little
bit much. Here is an alternative. Create a separate
process that looks like this:

main()
{
qnx_name_attach(…);
while(1)
{
pid = Receive(0,NULL,0);
Reply(pid,0,NULL)
sound(3500);
delay(100);
nosound();
}
}

Your process just needs the following code:

void play_sound()
{
pid = qnx_name_locate(…)
Send(pid,NULL,NULL,0,0);
}



Previously, Augie Henriques wrote in qdn.public.qnx4:
Hi,

How do you generate a beep sound without a delay?

I have the following code.

sound(3500);
delay(100);
nosound();

I would like to generate different beep sounds without using the delay
function.

Is this possible? Is there some source code for generating different beep
sounds?

What are the best frequency values to pass for sound()?

TIA

Augie



\

Mitchell Schoenbrun --------- > maschoen@pobox.com

“Dean Douthat” <ddouthat@faac.com> wrote in message
news:3B163229.41E983A4@faac.com

May I suggest the following variation on Mitchell’s code:

void play_sound()
{
static pid;
if (0 == pid) pid = qnx_name_locate(…);
Send(pid, 0,0,0,0);
}

I like to use

static pid_t pid = -1;

if ( pid == -1 )
pid = qnx_name_locate(…)

if ( pid != -1 ) {
ret = Send
if ( ret == -1 && errno = “nosuchprocess” )
pid = -1
}

That way if the “sound server” was stop and restarted you would not
have to restart this program as it would reconnect to it.

Mitchell Schoenbrun wrote:

I presume that you do not want the delay because
your process must not stop for this long a period.
There are numerous work arounds. Here are two.

THE FORK

void play_sound()
{
if (fork() == 0)
{
sound(3500);
delay(100);
nosound();
exit(0);
}
}

This is probably overkill, and the overhead is a little
bit much. Here is an alternative. Create a separate
process that looks like this:

main()
{
qnx_name_attach(…);
while(1)
{
pid = Receive(0,NULL,0);
Reply(pid,0,NULL)
sound(3500);
delay(100);
nosound();
}
}

Your process just needs the following code:

void play_sound()
{
pid = qnx_name_locate(…)
Send(pid,NULL,NULL,0,0);
}

Previously, Augie Henriques wrote in qdn.public.qnx4:
Hi,

How do you generate a beep sound without a delay?

I have the following code.

sound(3500);
delay(100);
nosound();

I would like to generate different beep sounds without using the delay
function.

Is this possible? Is there some source code for generating different
beep
sounds?

What are the best frequency values to pass for sound()?

TIA

Augie



\

Mitchell Schoenbrun --------- > maschoen@pobox.com

I have used a loop like this for years. It works great for exactly the
reason that Mario states.

My library goes one further though. I have a list of server nodes.
Whenever it tries to do a name locate it tries the next node on the list of
servers. This way if a process is connected to a server on node X and node
X goes down the client application can invisibly connect to a server on node
Y. Providing the server’s don’t need prior static information, which in my
case, they do not.


Bill Caroselli - Sattel Global Networks
1-818-709-6201 ext 122



“Mario Charest” <mcharest@deletezinformatic.com> wrote in message
news:9f61sn$oet$1@inn.qnx.com

“Dean Douthat” <> ddouthat@faac.com> > wrote in message
news:> 3B163229.41E983A4@faac.com> …
May I suggest the following variation on Mitchell’s code:

void play_sound()
{
static pid;
if (0 == pid) pid = qnx_name_locate(…);
Send(pid, 0,0,0,0);
}

I like to use

static pid_t pid = -1;

if ( pid == -1 )
pid = qnx_name_locate(…)

if ( pid != -1 ) {
ret = Send
if ( ret == -1 && errno = “nosuchprocess” )
pid = -1
}

That way if the “sound server” was stop and restarted you would not
have to restart this program as it would reconnect to it.


Mitchell Schoenbrun wrote:

I presume that you do not want the delay because
your process must not stop for this long a period.
There are numerous work arounds. Here are two.

THE FORK

void play_sound()
{
if (fork() == 0)
{
sound(3500);
delay(100);
nosound();
exit(0);
}
}

This is probably overkill, and the overhead is a little
bit much. Here is an alternative. Create a separate
process that looks like this:

main()
{
qnx_name_attach(…);
while(1)
{
pid = Receive(0,NULL,0);
Reply(pid,0,NULL)
sound(3500);
delay(100);
nosound();
}
}

Your process just needs the following code:

void play_sound()
{
pid = qnx_name_locate(…)
Send(pid,NULL,NULL,0,0);
}

Previously, Augie Henriques wrote in qdn.public.qnx4:
Hi,

How do you generate a beep sound without a delay?

I have the following code.

sound(3500);
delay(100);
nosound();

I would like to generate different beep sounds without using the
delay
function.

Is this possible? Is there some source code for generating
different
beep
sounds?

What are the best frequency values to pass for sound()?

TIA

Augie



\

Mitchell Schoenbrun --------- > maschoen@pobox.com

Bill Caroselli <Bill@sattel.com> wrote:

I have used a loop like this for years. It works great for exactly the
reason that Mario states.

My library goes one further though. I have a list of server nodes.
Whenever it tries to do a name locate it tries the next node on the list of
servers. This way if a process is connected to a server on node X and node
X goes down the client application can invisibly connect to a server on node
Y. Providing the server’s don’t need prior static information, which in my
case, they do not.

Of course, for the original solution… beeping… you don’t want to
run down a list of server nodes… it could result in beeping from
some unexpected or inappropriate places.

-David

QNX Training Services
dagibbs@qnx.com

Well we seem to have beat this death, here’s
a recap to see if this dead horse has anything
else to sayt.

Yes I oversimplified the qnx_name_locate() stuff.
There are two issues to deal with it. One is
that if the process dies and comes back to life
with another pid, you want some mechanism to
re-find the admin. If you want to do this
very efficiently then you implement code that
only gets the pid the first time, and then
subsequently if a Send() fails.

You also might want to watch out for repeated
qnx_name_locate()'s across a network without
a qnx_vc_detach() or you will run out of VC’s
eventually.

A smart sound generator with frequency and period
options is good.

If your process is usually Receive blocked, you
could also set a timer to trigger a proxy for when
you want the sound to stop.

One comment probably deserves some reflection.

You may want to trigger a proxy (non-blocking) rather then
sending a message which will put your client into send and
reply blocked states.

This got me thinking. I don’t really buy the non-blocking
point here. The admin that you send to could use proxy
triggering timers also, so hopefully the admin would almost
always be ready to receive your message and reply
immediatly. It would take more kernel work however,
but if you are willing to call Trigger(), you are
probably no worse off then calling Send() and waiting
for Receive() and Reply(). You are still stuck giving
up control to the OS for however brief a period and if
you don’t want to do this you are stuck. Or are you?

Here’s what I had in mind. Attach an interrupt handler
to the timer interrupt 0. Turn on sound and set a counter.
The interrupt handler counts down, and when it gets to zero,
stop the sound.

Even this is not perfect. The firing of the interrupt, and
running of your code and others is not insignificant, and
may be even more than Trigger() but it should at least be
extremely predictable.


Previously, Hardware Support Account wrote in qdn.public.qnx4:

Hi,

You may want to trigger a proxy (non-blocking) rather then sending a message which will put your client
into send and reply blocked states.

pid = qnx_name_locate(…);
proxy_pid = qnx_proxy_attach(pid,…);
.
.
.
Trigger(proxy_pid); /* request sound form server process */

Regards,

Joe

Mitchell Schoenbrun --------- maschoen@pobox.com

David Gibbs wrote:

Bill Caroselli <> Bill@sattel.com> > wrote:
I have used a loop like this for years. It works great for exactly the
reason that Mario states.

My library goes one further though. I have a list of server nodes.
Whenever it tries to do a name locate it tries the next node on the list of
servers. This way if a process is connected to a server on node X and node
X goes down the client application can invisibly connect to a server on node
Y. Providing the server’s don’t need prior static information, which in my
case, they do not.

Of course, for the original solution… beeping… you don’t want to
run down a list of server nodes… it could result in beeping from
some unexpected or inappropriate places.

Can be a good way to annoy your neighbors. :sunglasses:


-David

QNX Training Services
dagibbs@qnx.com

“Dean Douthat” <ddouthat@faac.com> wrote in message
news:3B16B9D1.489EB022@faac.com

David Gibbs wrote:

Of course, for the original solution… beeping… you don’t want to
run down a list of server nodes… it could result in beeping from
some unexpected or inappropriate places.

Can be a good way to annoy your neighbors. > :sunglasses:

I was thinking more of a generic client/server model, rather than the beep
application at hand.


Bill Caroselli - Sattel Global Networks
1-818-709-6201 ext 122

Previously, Heinz-Dieter Sander wrote in qdn.public.qnx4:

“Hugh Brown” <> hsbrown@qnx.com> > wrote in message
news:> Voyager.010529113308.1286A@node90.ott.qnx.com> …
Previously, Heinz-Dieter Sander wrote in qdn.public.qnx4:
I’ve also tested between 2 machines without running our applications and
had
no problems in this configuration.

One difference is, that we have cyclic broadcast transfers with our
applications running.

We cannot figure out the conditions to reproduce the problem. Fact is,
that
the systems sometimes is totally dead within some minutes after opening
the
10base2 connection, so it’s very hard to analyse the problem.


I have had 2 systems running all night with the 10base2 connector removed
and have had no hangups at all. I re-connected them this morning and both
systems continued running. I’m afraid that there is nothing else I can do
unless you can give me a reproducable case without your applications.
You can try running a shell at a high priority to see if you can find
which application is causing the hangup.


We noticed that the systems are still serving hardware interrupts, so it is
possible that a process with a high priority (Net.ether1000, Socklet??) may
block the system working in a infinite loop.

I recall similar problems several year ago with Net.ether1000. It would run at a high priority when unpluged trying to reestablish a connection.


David L. Hawley D.L. Hawley and Associates