delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/07/17/02:01:18

Message-ID: <37901B1D.7731BB34@vetec.com>
Date: Sat, 17 Jul 1999 00:56:45 -0500
From: Andy Goth <andygoth AT vetec DOT com>
X-Mailer: Mozilla 4.61 [en] (Win95; I)
X-Accept-Language: en
MIME-Version: 1.0
To: djgpp AT delorie DOT com
Subject: Re: Im not shure how to do sound
References: <7mnmco$blq$1 AT autumn DOT news DOT rcn DOT net>
Reply-To: djgpp AT delorie DOT com

> Im confused with using sound in my program here is the source that i wrote:
> 
> #include <iostream.h>
> #include "allegro.h"
> 
> //Availible Res: 300x200, 640x480, 800x600, 1024x768, 1152x864
> 
> #define WIDTH 640
> #define HEIGHT 480
> #define PIC1 "omega.bmp"
> #define SND1 "test.wav"
> 
> int main()
> {
> 
>  BITMAP *allegro;
>  PALLETE pal;
> 
>  allegro_init();
>  install_keyboard();
>  set_gfx_mode(GFX_AUTODETECT, WIDTH, HEIGHT, 0, 0);
>  install_sound (DIGI_AUTODETECT, MIDI_AUTODETECT, NULL);
> 
>     // Load Bitmap Into Memory
>  allegro = load_bitmap(PIC1, pal);
>  set_palette(pal);
> 
>  //Display Bitmap
>  blit(allegro, screen, 0, 0, 0, 0, WIDTH, HEIGHT);
> 
>  readkey();
>  load_sample( SND1 );

load_sample returns a pointer to a SAMPLE.  Declare a SAMPLE* called,
say... sound.

SAMPLE* sound;

Rewrite this part to say:

sound = load_sample(SND1);

>  play_sample(SND1 *, 255, 128, 1000, 0);

No.  SND1 is actually "test.wav".  You want to play the sample that you
loaded.  You want...

play_sample(sound, 255, 128, 1000, 0);

>  stop_sample(SND1 *);

Now, if you stop playing the sound immediately after starting, you'll be
lucky if you hear so much as a pop.  I haven't used Allegro sound much,
but I remember that if I wanted to know when a sound stopped I had to
use the voice functions.

>  fade_out(3);
>  destroy_bitmap(allegro);

Also, destroy_sample(sound); should go here.

>  return 0;
> }
> 
> can someone please tell me what is wrong? i want to get the sound to play at
> the end of the program after a key is pressed.  everything else works great

Maybe you should move this to the Allegro list.  Go to
http://www.talula.demon.co.uk/allegro/maillist.html and read carefully
on how to subscribe (write your subscription request to
listserv AT canvaslink DOT com).

Quote:

To subscribe to one of the lists, write to listserv AT canvaslink DOT com with
the text "subscribe {list} myname" in the body of your message, where
{list} is one of allegro, agp, or conductors.

We've had a lot of trouble with people trying to sign up by writing to
the main list addresses.  Please don't do that.
  ___  _   _ ____  _   _
 / _ \| \ | |  _ \\ \_/ / .--------[ ICQ#: 35256413 ]--------.
| |_| |  \| | | | |\   /  | 01001000011001010110110001101100 |
|  _  | \ \ | | | | | |   | 01101111001011000010000001110111 |
| | | | |\  | |_| | | |   | 01101111011100100110110001100100 |
|_| |_|_| \_|____/  |_|   `--[ mailto:andygoth AT vetec DOT com ]---'
<http://zap.to/andygoth/>           <http://andygoth.cjb.net/>

- Raw text -


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