play_sound()

I searched for “delay” in the helpviewer, and found a Example:
"
#include <unistd.h>
#include <stdlib.h>

void play_sound( void )
{

}

void stop_sound( void )
{

}

int main( void )
{
play_sound();
delay( 500 ); /* delay for 1/2 second */
stop_sound();

return EXIT_SUCCESS;

}
"

 But the play_sound() function is void , would anyone add it ? in Turbo C there is a sound() function to play loudspeeker , but in qnx no sound() could be found . the same happened to clrscr() , filelength() ,getch() ,etc. what can i do ? 

 I am anxious for your answers , thanks a lot !  :unamused:

Hello wsforever,

I don’t understand your problem:

  • Have you any questions about delay() ?
  • Or search you a functions to work with the internal loudspeaker etc. ?

Why have you choosen the topic “delay()” ?

If these sound functions don’t exist in QNX, I think it should not very hard to write them, because the hardware does the most part.

I try to find them too, and if they don`t exist, I write them.

Best regards

Fiffi

Thanks , Fiffi !

i am a newer in QNX , i want to use sound(), getch(), clrscr() in my programe, of couse delay() will be used too . but i don’t find them in helpviewer . my english is poor ,so i can’t express my thought exactly !

thanks again !

fiffi , i have changed the topic .:slight_smile:

Hello wsforever,

i am a newer in QNX

I am too, but I have a knowledge about programming, electronics and x86 interna … :smiley:

fiffi , i have changed the topic .

How did you do that ?

I have wrote two functions for the loaudspeaker of an IBM PC compatible x86:

  • sound(): with this function you can play a tone with a frequeny and a length
  • soundt(): with this function you can play a tone (e.g. C of the 3. octave)

The code should only show, how to programm the loundspeaker, and should not be a perfect library.
Therefore i will show you some disadvantages:

  • the delay is not exact, it would be better to use Interrupt 0 or any other solution to get excat
    play times …
  • if you hit CTRL-C or any other keystroke/signal, the tone don’t stops …
  • the code is a C source file, and not an library …

(Such an libary could be your first project for the QNX community)

I hope, I have helped you …

Best regards

Fiffi

How did you do that ?
because the topic is posted by me ,so i can change it just by “edit” .

Thank you for your help very much!

as you say , it can’t be stopped . i have to reboot my computer to keep it "quiet"again :slight_smile:

but now i don’t need to reboot again :
i changed
"
out8(0x42, (freq & 0x00FF) );
buf = (freq & 0x00FF);
out8(0x42, ((freq & 0xFF00) >> 8 )) ;
buf = ((freq & 0xFF00) >> 8 );
"
to
"
out8(0x42, (freq & 0x0000));
buf = (freq & 0x0000);
out8(0x42, ((freq & 0x0000) >> 8 ));
buf = ((freq & 0x0000) >> 8 );
"
complie and excuteit , the world quiet agian .

just a joke , thanks very much !

wsforever