delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1999/07/16/13:20:30

From: Mark Phillips <umphill5 AT cs DOT umanitoba DOT ca>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: Im not shure how to do sound
Date: Fri, 16 Jul 1999 11:49:12 -0500
Organization: The University of Manitoba
Lines: 65
Message-ID: <Pine.SUN.3.96.990716114459.8058A-100000@silver.cs.umanitoba.ca>
References: <7mnmco$blq$1 AT autumn DOT news DOT rcn DOT net>
NNTP-Posting-Host: silver.cs.umanitoba.ca
Mime-Version: 1.0
X-Trace: canopus.cc.umanitoba.ca 932143758 12620 130.179.24.6 (16 Jul 1999 16:49:18 GMT)
X-Complaints-To: Postmaster AT cc DOT umanitoba DOT ca
NNTP-Posting-Date: 16 Jul 1999 16:49:18 GMT
In-Reply-To: <7mnmco$blq$1@autumn.news.rcn.net>
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

Sound uses a type SAMPLE wich works very similar to the way BITMAP does.
Try this:

SAMPLE *my_sample;

my_sample = load_sample( SND1 );
play_sample(my_sample);

I think that's right.  Unfortunately there's no way to tell when the sound
is finished playing, so you might have to do another readkey() after this.
If you really don't want to have that readkey() at the end you could try
adding a delay equal to the length of the sample but that is really
sketchy so don't do it.

Mark


> 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 );
>  play_sample(SND1 *, 255, 128, 1000, 0);
>  stop_sample(SND1 *);
>  fade_out(3);
>  destroy_bitmap(allegro);
> 
>  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
> 

- Raw text -


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