[comp.sys.hp] HP 300 Beeper

mjb%hoosier.utah.edu.uucp@utah-gr.UUCP (Mark J. Bradakis) (02/20/88)

Here's what I dug out of my news archive for the series 300 tone generator.
Have fun.

mjb.
-----


From: tgl@zog.cs.cmu.edu (Tom Lane)
Newsgroups: comp.sys.hp
Subject: Re: Guts of the tone generator on the 320 system
Message-ID: <1024@zog.cs.cmu.edu>
Date: 23 Apr 87 00:47:14 GMT
References: <1365@ucbcad.berkeley.edu>
Reply-To: tgl@zog.cs.cmu.edu (Tom Lane)
Distribution: na
Organization: Carnegie-Mellon University, CS/RI
Lines: 56
Keywords: bobcats tones
Posted: Wed Apr 22 19:47:14 1987

In <1365@ucbcad.berkeley.edu> chris@ic.uucp (Chris Guthrie) writes:
>We spent last night playing with the tone generator on our 320s.
>Although we were able to get a number of unique and interesting
>noises out of them, we couldn't figure out the layout of the
>four bytes in the EFTSBP ioctl command (other than the volume and
>timer bits).  Can anyone post the layout of these bytes.  Thanks!

This may not be too accurate 'cuz its based on old documentation
(pre-Series 300) for a different operating system (HP Pascal),
but it's worth a try.

What you have is a TI SN76494 4-voice sound generator; it can make
3 independent square waves plus a noise source.  To control one of
the square wave voices, the format of the 4 bytes is:

byte 1:   1 v1 v0  0 f3 f2 f1 f0
byte 2:   0  0 f9 f8 f7 f6 f5 f4
byte 3:   1 v1 v0  1 a3 a2 a1 a0
byte 4:  d7 d6 d5 d4 d3 d2 d1 d0

where v1-v0 is the voice number (00,01, or 10);
f9..f0 is a 10-bit value defining the frequency;
a3..a0 is a 4-bit value defining the attenuation (volume);
d7..d0 is an 8-bit value defining the duration of the tone.

Note that the voice number must be given in two places.
The f9..f0 value should be 83333 / (desired freq. in Hz);
the a3..a0 value is 0 (maximum volume) to 15 (off), in steps of about 2 dB;
the d7..d0 value is duration in 10-msec units, or 0 to sound
until a countermanding command is given.

For the noise source, the command format is:

byte 1:   1  1  1  0  0 fb n1 n0
byte 2:   1  1  1  0  0 fb n1 n0	(i.e. same as byte 1)
byte 3:   1  1  1  1 a3 a2 a1 a0
byte 4:  d7 d6 d5 d4 d3 d2 d1 d0

(thus, the voice number is "11") where:
fb is 0 for "periodic" noise and 1 for white noise;
n1-n0 control the "noise generator shift rate" as follows:
00  333333/64 Hz
01  333333/128 Hz
10  333333/256 Hz
11  Use voice "10"'s output
(don't ask me what any of that means).
The attenuation and duration are the same as for the other sources.

Somebody please check this out and let the net know if it's OK...
I don't run HP/UX.

				tom lane
-----
ARPA: lane@ZOG.CS.CMU.EDU
UUCP: ...!seismo!zog.cs.cmu.edu!lane
BITNET: lane%zog.cs.cmu.edu@cmuccvma


From utah-gr!utah-cs!ut-sally!seismo!mcvax!ukc!its63b!hwcs!zen!jules Tue Apr 28 12:52:11 MDT 1987
Article 131 of comp.sys.hp:
Path: utah-gr!utah-cs!ut-sally!seismo!mcvax!ukc!its63b!hwcs!zen!jules
>From: jules@zen.UUCP (Julian Perry)
Newsgroups: comp.sys.hp
Subject: Re: Guts of the tone generator on the 320 system
Message-ID: <598@zen.UUCP>
Date: 26 Apr 87 13:00:20 GMT
References: <1365@ucbcad.berkeley.edu>
Reply-To: jules@zen.UUCP (Julian Perry)
Organization: Zengrange Limited, Leeds, England
Lines: 100
Keywords: bobcats tones

In article <1365@ucbcad.berkeley.edu> chris@ic (Chris Guthrie) writes:
>We spent last night playing with the tone generator on our 320s.
>Although we were able to get a number of unique and interesting
>noises out of them, we couldn't figure out the layout of the
>four bytes in the EFTSBP ioctl command (other than the volume and
>timer bits).  Can anyone post the layout of these bytes.  Thanks!
>
>(The EFTSBP is the ioctl command for the rhil device which sends
>four data bytes to the tone generator.  Beyond that, none of my
>documentation details the purpose of those bytes).
>	Chris Guthrie
>	U.C.B.


Here is a small program  which  demonstates  how to use the beeper on an
hp9000s500, I guess it's the same on a 300.

The main  limitation of the  beeper  system  is the  poor  selection  of
frequencies  available  which  limits  its  tunefullness,  but  having 4
channels is really nice.

On a 500 you will need this device  file, as for a 300 I'll let you know
when I get one (along with the 850 etc etc)

crw-rw-rw- 1 root other 41 0xff0000 Apr 7 1986 /dev/hil8042

[Note: On a 320 I used major of 23, minor of 0.]

-----beep.c-----

#include <sys/hilioctl.h>

#define tone 13 
int ton[tone]={189,247,311,330,370,440,450,470,490,510,530,550,570};

int fd;

void
beep(voice,fre,amp,dur)

int    voice;
double fre;
int    amp;
double dur;

{

  struct eft2 bytes;
  int n;

  n = 1.2 * (83333.3 / fre);
  bytes.b[0] = (128 + (32 * voice) + (n % 16));
  bytes.b[1] = n / 16;
  bytes.b[2] = (128 + (32 * voice) + 31 - amp);     
  bytes.b[3] = (unsigned char) (dur * 100.0);
  ioctl(fd,EFTSBP,&bytes);

}

main()
{
  int b=0;
  double root, third, fifth;
  int i,lp;

  fd = open("/dev/hil8042",0);
  for ( lp = 0 ; lp < tone ; ++lp )
  {
    root = ton[lp];
    third = root * 1.26;
    fifth = root * 1.5;
    beep(0,root,15,0.9);
    beep(1,third,15,0.9);
    beep(2,fifth,15,0.9);
    for ( i = 0 ; i < 50000 ; ++i )
      i = i+0;
  }
  for ( lp = tone - 1 ; lp >= 0 ; --lp )
  {
    root = ton[lp];
    third = root * 1.26;
    fifth = root * 1.5;
    beep(0,root,15,0.9);
    beep(1,third,15,0.9);
    beep(2,fifth,15,0.9);
    for ( i = 0 ; i < 50000 ; ++i )
      i = i+0;
  }
  close(fd);

}

--------------

Jules [the noisy]

-- 
IN-REAL-LIFE:  Julian Perry           
E-MAIL:        jules@zen.co.uk || ...!mcvax!ukc!zen.co.uk!jules
PHONE:         +44 532 489048 ext 217
ADDRESS:       Zengrange Limited, Greenfield Road, Leeds, England, LS9 8DB



mjb@hoosier.utah.edu

"We will leave this place an empty stone,
 Or a shining ball we can call our own."