Mail Archives: djgpp/1997/06/28/16:49:47

Date: Thu, 26 Jun 1997 10:14:29 -0600
From: xorxe AT asturies DOT org
Subject: Sound Programming
Newsgroups: comp.os.msdos.djgpp
Message-ID: <>
Reply-To: xorxe AT asturies DOT org
Organization: Deja News Usenet Posting Service
Lines: 97
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp


I've done a little program which plays a wav file, with some
routines from creative labs site (for Watcom C) and after some
little changes now it works... but not as well as I'd like.

The program runs well (and without clicks) on a Pentium, but if
I run the program on my 486-33 it plays the wav file with some
noises in the background if the file is 16-bit and with horrible
noises if the file is 8-bit.

So it seems to be a problem of speed on the ISR handler routine,
which is totally in C (no assembly)... but Allegro and MikMod sources
doesn't use assembler language enough and they do not make this
kind of noise (MikMod makes some clicks on my 486... on my pentium
I've not try it yet)

Here's the parts I think that may cause the noises:

void DMAISR()
    int IntStatus;


    if (DMA_16bit)
        outp(Base + dspMixerAddr, 0x82);
        IntStatus = inp(Base + dspMixerData);

        if (IntStatus & 2)
            inp(Base + dspDMA16Ack);
        inp(Base + dspDMA8Ack);

    if( Intr_num > 8 )
        outp(PIC2MODE, PICEOI);
    outp(PIC1MODE, PICEOI);

    if( End_of_data== TRUE ) EndPlay= TRUE;

void FillBuffer()
    UCHAR *bufptr;

    if( bytes_left_in_data_buf>0 ) {

      bufptr = DMA_buffer + DMA_buf_to_fill*BUFSIZE/2;

      memcpy( bufptr, data_buf, BUFSIZE/2 );
      DMA_buf_to_fill ^= 1;

      data_buf               += BUFSIZE/2;
      bytes_left_in_data_buf -= BUFSIZE/2;
    else End_of_data= TRUE;

int main(void)

       cprintf("Nș bytes= %6d\r",bytes_left_in_data_buf);


I've got some hypothesis:

(1) I'm doing something wrong (sure!!)
(2) Code generated isn't fast enough (I don't believe this can be)
(3) cprintf function is sloooooow and it's the cause of all the
    noises (if I remove this line, then the noises are reduced to
    a click when starts to play the file)

If I'm right and the last hypothesis is the correct... but can I do?
I want to use functions from the standard library as cprintf...

Does not the ISR activated when the cprintf is executing?
Near pointers can be the cause?
Must I do all the buffer swapping on assembly?
is there life after death? ;-)

xorxe AT asturies DOT org

-------------------==== Posted via Deja News ====-----------------------     Search, Read, Post to Usenet

- Raw text -

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