delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1997/04/30/08:05:30

From: Shawn Hargreaves <shawn AT talula DOT demon DOT co DOT uk>
To: djgpp AT delorie DOT com, chris AT psychologie DOT uni-leipzig DOT de,
frank AT psychologie DOT uni-leipzig DOT de
MMDF-Warning: Parse error in original version of preceding line at punt-2.mail.demon.net
Subject: Re: Please help 16-bit sound
Date: Wed, 30 Apr 1997 10:06:17 +0100
MIME-Version: 1.0
Message-ID: <862399671.0910832.0@[194.129.18.166]>

Christian Kaernbach writes:
> I need 16-bit sound (on an SB16 or SB64 sound card).
> I downloaded allegro 2.2 and tried, but to me it seems allegro can  
> only do 8 bit sound. Am I mistaken? (e.g. allegro.h says at the  
> definition of SAMPLE that SAMPLE->bits is always 8). 

Allegro lives somewhere in the gap between 8 and 16 bit samples. It stores
them in memory in 8 bit format (actually my work-in-progress can work with
16 bit data as well, but that's not working very well yet), but uses 16 bit
mixing code. The mixing is done with a 12 bit lookup table to amplify the
waveform (this is needed to implement volume and panning effects), and they
are mixed into a 16 bit buffer. On an SB16 this output buffer is then
transferred directly to the soundcard, while for older cards it is reduced
to 8 bit format with another lookup table.

This means that your input waveforms are restricted to 8 bits (or 12 in my
current version), but the extra resolution of a 16 bit card is used for
mixing multiple samples and altering the volume and pan. Playing 16 bit
data directly is tricky, because it would lead to overflow problems when
multiple samples were played simultaneously, and also I can't see how to
amplify such waveforms without doing a multiply per sample (the lookup
table I currently use would be prohibitively large for 16 bit inputs!).

> I just want to calculate some wave form in system memory and play it  
> to the sound card. It should be 16 bit, 44.1 kHz stereo.

If you just want to dump a single 16 bit waveform to the soundcard, you
could easily modify the sound code from Allegro. Edit sound.c, find the
_mix_some_samples() function, and replace my code that loops through the
list of active voices with something of your own that will just copy your
data across into the soundcard buffer...


--
Shawn Hargreaves - shawn AT talula DOT demon DOT co DOT uk - http://www.talula.demon.co.uk
"Beauty is a French phonetic corruption of a short cloth neck ornament"

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019