From: Jason Main Newsgroups: rec.games.programmer,comp.ai.games,comp.os.msdos.djgpp Subject: Re: Smart stereo sound effects Date: Mon, 22 Dec 1997 16:05:23 -0700 Organization: hp Lines: 34 Message-ID: <349EF233.65C0@hpbs1079.fooultrabar.boi.hp.com> References: <349AA5AA DOT 5372 AT oce DOT nl> <349DF2E5 DOT 2848 AT ns DOT sympatico DOT ca> NNTP-Posting-Host: hpb14677.boi.hp.com Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit To: djgpp AT delorie DOT com DJ-Gateway: from newsgroup comp.os.msdos.djgpp Precedence: bulk Klaas wrote: > > > My problem is that a lot of events happen, some on the visible area of > > the screen, some others not visible. > > In case of an event how can I decide if I must play the according > > soundeffect (depending on the position of the vehicle in relation to the > > visible area) > > My guess would be to see if the explosion is with the screen ie. > if ObjX > ScreenLeft and ObjX < ScreenLeft + ScreenWidth and (Y > tests...) > (play sound) > > > How is the volume altered in relation to the distance and position of > > the event. > > well, most games just play the sound at a certain loudness if the event > is on the screen, and very faintly otherwise (example: Z) Though, I > suppose teh volume could be scaled using pythagorean distance: > > sqr((ObjX-CurX)^2 + (ObjY-CurY)^2) (where CurX/Y are player's position) > then scale that value from your lowest desired volume to your highest, > then > to compute final volume, subtract it from highest desired volume. It is much beter to use the inversed squared distance (IE vol = 1/ ((y1-y2)^2 + (x1-x2)^2). This is more acurate and faster as well as it eliminates the sqrt. > > > Is it possible to include surround soundeffects? > Yes! The one catch is that to do this over the midi channal you have to have a wavetable card. For the digital chanal its just a matter of mixing a couple of pre filtered sources.