Xref: utzoo comp.sys.ibm.pc:52328 rec.games.programmer:1932 Path: utzoo!attcan!uunet!cs.utexas.edu!sdd.hp.com!zaphod.mps.ohio-state.edu!usc!apple!metaphor!dragon!djh From: djh@dragon.metaphor.com (Dallas J. Hodgson) Newsgroups: comp.sys.ibm.pc,rec.games.programmer Subject: Re: Quality of PC sampled sound Keywords: samples, sound, IBM-PC, Amiga Message-ID: <1207@metaphor.Metaphor.COM> Date: 11 Jun 90 19:11:50 GMT References: <1990Jun7.173911.424@cbnews.att.com> Sender: news@metaphor.Metaphor.COM Reply-To: djh@dragon.metaphor.com (Dallas J. Hodgson) Distribution: na Organization: Metaphor Computer Systems, Mountain View, CA Lines: 61 I recently wrote a few support routines for reproducing sampled sound on the PC. I used a Mimetics digitizer to capture the samples (8-bit, around 14KHz) into an Amiga, and compressed the bits like so: for each byte that exceeds the 0 crossing, output a "1" bit else output a "0" bit. This stream of bits would get bit-packed into a byte stream, translated into "C" source, (a large static array) and subsequently shifted out into the speaker port of a PS/2. My player looks like this: PlaySample(buffer,size,speed) unsigned char *buffer; unsigned short size; short speed; { char x; /* must be unsigned! */ unsigned char tmp; unsigned short bitctr,dly; /* Samples are stored internally as bit-packed values; each PCM value appears in Bit 7 down to bit 0, the starting again in the next byte. Packing the bytes this way gives us an easy way to check the each bit (via the sign) before it gets shifted out. */ while (size--) { x = *buffer++; bitctr=0; do { tmp=inp(0x61); if (x < 0) { /* bit 7 set? */ if (!(tmp & 2)) outp(0x61,tmp | 2); } else { if (tmp & 2) outp(0x61,tmp & 0xFD); } x<<=1; bitctr++; for (dly=0;dly