Sound on PI

Loren Buck Buchanan buck at drax.gsfc.nasa.gov
Fri Dec 15 02:38:40 AEST 1989


Hi Netlanders,

This is the response to my posting a while back on sound software for the
PI.  I had also made a posting to rec.music.synth asking about references
to sound generation.

Subject:  Sound Generation References

The book "Music Through MIDI" has a couple of chapters that give a
breif introduction to sound and synthesis.

From: "Kevin R. Weiner" <KRW1%LEHIGH.BITNET at IBM1.CC.Lehigh.Edu>
From: Dean Swan <dean at sun.soe.clarkson.edu>

Hal Chamberlin's "Musical Applications of Microprocessors", 2nd Ed.

From: pmy at jeeves.acc.Virginia.EDU (Pete Yadlowsky)

"Computer Music" by Charles Dodge and Tom Jerse is a popular text.

Subject:  Sound on the PI

From: kelaita at wk19.nas.nasa.gov (Paul G. Kelaita)

Buck,

We are probably at about the same stage that you are.

We plan on using the PI's /dev/audio to generate sound from
CFD datasets (eventually tied into a graphics interface).

I got some good example programs fax'ed over from Clint Greene at SGI's hotline,
and he also emailed me the enclosed specs.

Also included is our first test program (it uses the mouse as input)
which gave us a couple chuckles.

Let us know if you find out anything new from SGI, or others.

Good Luck,

Paul "Pup" Kelaita

****************************************************************************

	
	            PERSONAL IRIS AUDIO CHANNEL INFORMATION
	
Line input:

       +/- 2.5 v (input is AC coupled) is full scale to ADC
       ADC is 8-bit, 2's complement
       Input impedance is 22K ohms.
       Input gains not adjustable.

       Frequency response:
           20 Hz -  13 KHz @ 32K/sec sampling rate
           20 Hz - 6.6 KHz @ 16K/sec sampling rate
           20 Hz - 3.3 KHz @  8K/sec sampling rate

Microphone input:

       +/- 3.8 mv (input is AC coupled) is full scale to ADC
       ADC is 8-bit, 2's complement
       Input impedance 330 ohms.
       Designed for use with 300 ohm microphone.
       Input is summed (analog) with line input.

Output:

       With full output gain (0xff) and no load, output swings +/- 4.9 v.
       Reduced output gain linearly reduces swing.
       Output is AC coupled (~4 ohms in series with 220 uf).
       Can directly drive 8 ohm speaker.


--
	

                 | | | |||   Clint Greene     ||| | | | 
            |  | | | | |||  Silicon Graphics  ||| | | | |  |
    |   |   |  | | | | |||   - - - - - - -    ||| | | | |  |  |   |   |
            |  | | | | |||   clint at sgi.com    ||| | | | |  |
                 | | | |||   (415)335-1394    ||| | | |



****************************************************************************

#include <stdio.h>
#include <math.h>
#include <gl.h>
#include <device.h>
#include <sys/audio.h>

#define	PI	3.1415926
#define FREQ	90.
#define	MAXFREQ	4096.
#define	RES	1024

main()

{

   unsigned char	buffer[RES];
   int		i, sound;
   float	deg, max_theta, freq;

   if ((sound = open("/dev/audio", 2)) < 0)  {
      printf ("cant open\n");
      exit(1);
   }

   /*
      set audio duration, rate, gain
   */
   ioctl(sound, AUDIOCDURATION, 5);
   ioctl(sound, AUDIOCSETRATE, 2);
   ioctl(sound, AUDIOCSETOUTGAIN, 255);

   while(1)  {
      freq = (float)getvaluator(MOUSEY) / 1024. * MAXFREQ;
      max_theta	= freq * 360.;
      for (i = 1;  i <= RES;  i++)  {
         deg = max_theta * (float)i / (float)RES;
         buffer[i]	= ((sin(deg * PI / 180.) * .5) + .5) * 255.0;
      }

      write(sound, buffer, RES);
   }

}

****************************************************************************

B Cing U

Buck
Loren "Buck" Buchanan | internet: buck at drax.gsfc.nasa.gov | standard disclaimer
CSC, 1100 West St.    | uucp: ...!ames!dftsrv!drax!buck   | "By the horns of a
Laurel, MD 20707      | phonenet: (301) 497-2531 or 9898  | sky demon..."



More information about the Comp.sys.sgi mailing list