TIP: Click on subject to list as thread! ANSI
echo: aust_c_here
to: Mark Harris
from: Frank Adam
date: 1996-06-04 20:50:00
subject: C Soundz ..

G'Day Mark,
 
-=> Quoting Mark Harris to Frank Adam <=-

 MH> I messed around with this code, but I cant get the sounds to
 MH> come up automaticaly, without a keypress .. Can you please help me
 MH> again .. Here's a brief example of what I want to do .. I want
 MH> to print out a string, after each char is printed I wont to create a
 MH> clicking sound .. So the out out looks like some one is type it with
 MH> the sounds aswell .. Also, is there a command like WAIT or
 MH> something that'll pause for a few seconds ??
Oh yeah, the old turn my PC into a typewriter or teletype trick:)
Try this.

#include 
#include 

void TType(char*);

int main()
{   
 TType("\nThis is a Borland C example of a sick typewriter");
 return 0;
}

void TType(char *text)
{
 char *ptr = text;
 while(*ptr)   
 {
  sound(100);  /* play with this */
  delay(20);   /* and this */
  putchar(*ptr++);
  nosound();
  delay(90);   /* and this */
  }
}


1. So, we're in the loop, and set a sound. sound(100) in this case. 
2. Ok, the sound is playing, we have to tell it how long, delay(20) will 
set 20 milliseconds, this is Borland's command for WAIT.
3. Then we output the character we're pointing at in MyStr. 
4. Switch off the sound.
5. Another delay here to simulate a pause between characters.
6. Loop away until the end of the string.

See how you go..play around with the values until you get the desired
speed/sound combination.             

Btw, there is another command for WAIT in Borland, sleep(seconds) 
Mostly for longer delays, since both takes an UINT the smallest value is 
1 second and 1 millisecond for sleep() and delay() respectively.
                                 
  L8r Frank (fadam{at}ozemail.com.au).
                                              
___ Blue Wave/DOS v2.21

--- Maximus 3.01
* Origin: The Software Parlour (3:635/544)
SEEN-BY: 50/99 620/243 623/630 632/349 635/503 544 727 711/401 409 410 413
SEEN-BY: 711/430 808 809 932 934 712/515 713/888 714/906 800/1
@PATH: 635/544 50/99 711/808 934

SOURCE: echomail via fidonet.ozzmosis.com

Email questions or comments to sysop@ipingthereforeiam.com
All parts of this website painstakingly hand-crafted in the U.S.A.!
IPTIA BBS/MUD/Terminal/Game Server List, © 2025 IPTIA Consulting™.