delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/06/29/12:10:19

From: Mark Phillips <umphill5 AT cs DOT umanitoba DOT ca>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: audio samples for allegro
Date: Tue, 29 Jun 1999 10:35:43 -0500
Organization: The University of Manitoba
Lines: 22
Message-ID: <Pine.SUN.3.96.990629103202.17886A-100000@silver.cs.umanitoba.ca>
References: <7l8nhi$jl1 AT dfw-ixnews6 DOT ix DOT netcom DOT com> <930642931 DOT 5410 AT www DOT remarq DOT com>
NNTP-Posting-Host: silver.cs.umanitoba.ca
Mime-Version: 1.0
X-Trace: canopus.cc.umanitoba.ca 930670546 26682 130.179.24.6 (29 Jun 1999 15:35:46 GMT)
X-Complaints-To: Postmaster AT cc DOT umanitoba DOT ca
NNTP-Posting-Date: 29 Jun 1999 15:35:46 GMT
In-Reply-To: <930642931.5410@www.remarq.com>
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com
X-Mailing-List: djgpp AT delorie DOT com
X-Unsubscribes-To: listserv AT delorie DOT com

> I don't know about the Allegro audio format but to convert
> signed to unsigned is not difficult: add an offset to all
> samples so that the most negative sample becomes 0.
> 
> Example:
> Signed input in [-128,+127], add 127 to each sample and you
> will get unsigned samples in [0..255].
> 

Or you could just toggle the most significant bit:

for(long i=0; i<bytes_in_buffer; i++)
   byte_buffer[i] ^= 0x80;

But as I remember the original poster asked for 16 bit data so that would
be:

for(long i=0; i<words_in_buffer; i++)
   word_buffer[i] ^= 0x8000;

Mark

- Raw text -


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