12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619 |
- /*
- SDL_mixer: An audio mixer library based on the SDL library
- Copyright (C) 1997-2013 Sam Lantinga <[email protected]>
- This software is provided 'as-is', without any express or implied
- warranty. In no event will the authors be held liable for any damages
- arising from the use of this software.
- Permission is granted to anyone to use this software for any purpose,
- including commercial applications, and to alter it and redistribute it
- freely, subject to the following restrictions:
- 1. The origin of this software must not be misrepresented; you must not
- claim that you wrote the original software. If you use this software
- in a product, an acknowledgment in the product documentation would be
- appreciated but is not required.
- 2. Altered source versions must be plainly marked as such, and must not be
- misrepresented as being the original software.
- 3. This notice may not be removed or altered from any source distribution.
- This file by Ryan C. Gordon ([email protected])
- These are some internally supported special effects that use SDL_mixer's
- effect callback API. They are meant for speed over quality. :)
- */
- /* $Id$ */
- #include <stdio.h>
- #include <stdlib.h>
- #include <string.h>
- #include "SDL.h"
- #include "SDL_mixer.h"
- #include "SDL_endian.h"
- #define __MIX_INTERNAL_EFFECT__
- #include "effects_internal.h"
- /* profile code:
- #include <sys/time.h>
- #include <unistd.h>
- struct timeval tv1;
- struct timeval tv2;
- gettimeofday(&tv1, NULL);
- ... do your thing here ...
- gettimeofday(&tv2, NULL);
- printf("%ld\n", tv2.tv_usec - tv1.tv_usec);
- */
- /*
- * Positional effects...panning, distance attenuation, etc.
- */
- typedef struct _Eff_positionargs
- {
- volatile float left_f;
- volatile float right_f;
- volatile Uint8 left_u8;
- volatile Uint8 right_u8;
- volatile float left_rear_f;
- volatile float right_rear_f;
- volatile float center_f;
- volatile float lfe_f;
- volatile Uint8 left_rear_u8;
- volatile Uint8 right_rear_u8;
- volatile Uint8 center_u8;
- volatile Uint8 lfe_u8;
- volatile float distance_f;
- volatile Uint8 distance_u8;
- volatile Sint16 room_angle;
- volatile int in_use;
- volatile int channels;
- } position_args;
- static position_args **pos_args_array = NULL;
- static position_args *pos_args_global = NULL;
- static int position_channels = 0;
- void _Eff_PositionDeinit(void)
- {
- int i;
- for (i = 0; i < position_channels; i++) {
- SDL_free(pos_args_array[i]);
- }
- position_channels = 0;
- SDL_free(pos_args_global);
- pos_args_global = NULL;
- SDL_free(pos_args_array);
- pos_args_array = NULL;
- }
- /* This just frees up the callback-specific data. */
- static void _Eff_PositionDone(int channel, void *udata)
- {
- if (channel < 0) {
- if (pos_args_global != NULL) {
- SDL_free(pos_args_global);
- pos_args_global = NULL;
- }
- }
- else if (pos_args_array[channel] != NULL) {
- SDL_free(pos_args_array[channel]);
- pos_args_array[channel] = NULL;
- }
- }
- static void _Eff_position_u8(int chan, void *stream, int len, void *udata)
- {
- volatile position_args *args = (volatile position_args *) udata;
- Uint8 *ptr = (Uint8 *) stream;
- int i;
- /*
- * if there's only a mono channnel (the only way we wouldn't have
- * a len divisible by 2 here), then left_f and right_f are always
- * 1.0, and are therefore throwaways.
- */
- if (len % sizeof (Uint16) != 0) {
- *ptr = (Uint8) (((float) *ptr) * args->distance_f);
- ptr++;
- len--;
- }
- if (args->room_angle == 180)
- for (i = 0; i < len; i += sizeof (Uint8) * 2) {
- /* must adjust the sample so that 0 is the center */
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
- * args->right_f) * args->distance_f) + 128);
- ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
- * args->left_f) * args->distance_f) + 128);
- ptr++;
- }
- else for (i = 0; i < len; i += sizeof (Uint8) * 2) {
- /* must adjust the sample so that 0 is the center */
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
- * args->left_f) * args->distance_f) + 128);
- ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
- * args->right_f) * args->distance_f) + 128);
- ptr++;
- }
- }
- static void _Eff_position_u8_c4(int chan, void *stream, int len, void *udata)
- {
- volatile position_args *args = (volatile position_args *) udata;
- Uint8 *ptr = (Uint8 *) stream;
- int i;
- /*
- * if there's only a mono channnel (the only way we wouldn't have
- * a len divisible by 2 here), then left_f and right_f are always
- * 1.0, and are therefore throwaways.
- */
- if (len % sizeof (Uint16) != 0) {
- *ptr = (Uint8) (((float) *ptr) * args->distance_f);
- ptr++;
- len--;
- }
- if (args->room_angle == 0)
- for (i = 0; i < len; i += sizeof (Uint8) * 6) {
- /* must adjust the sample so that 0 is the center */
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
- * args->left_f) * args->distance_f) + 128);
- ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
- * args->right_f) * args->distance_f) + 128);
- ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
- * args->left_rear_f) * args->distance_f) + 128);
- ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
- * args->right_rear_f) * args->distance_f) + 128);
- ptr++;
- }
- else if (args->room_angle == 90)
- for (i = 0; i < len; i += sizeof (Uint8) * 6) {
- /* must adjust the sample so that 0 is the center */
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
- * args->right_f) * args->distance_f) + 128);
- ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
- * args->right_rear_f) * args->distance_f) + 128);
- ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
- * args->left_f) * args->distance_f) + 128);
- ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
- * args->left_rear_f) * args->distance_f) + 128);
- ptr++;
- }
- else if (args->room_angle == 180)
- for (i = 0; i < len; i += sizeof (Uint8) * 6) {
- /* must adjust the sample so that 0 is the center */
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
- * args->right_rear_f) * args->distance_f) + 128);
- ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
- * args->left_rear_f) * args->distance_f) + 128);
- ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
- * args->right_f) * args->distance_f) + 128);
- ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
- * args->left_f) * args->distance_f) + 128);
- ptr++;
- }
- else if (args->room_angle == 270)
- for (i = 0; i < len; i += sizeof (Uint8) * 6) {
- /* must adjust the sample so that 0 is the center */
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
- * args->left_rear_f) * args->distance_f) + 128);
- ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
- * args->left_f) * args->distance_f) + 128);
- ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
- * args->right_rear_f) * args->distance_f) + 128);
- ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
- * args->right_f) * args->distance_f) + 128);
- ptr++;
- }
- }
- static void _Eff_position_u8_c6(int chan, void *stream, int len, void *udata)
- {
- volatile position_args *args = (volatile position_args *) udata;
- Uint8 *ptr = (Uint8 *) stream;
- int i;
- /*
- * if there's only a mono channnel (the only way we wouldn't have
- * a len divisible by 2 here), then left_f and right_f are always
- * 1.0, and are therefore throwaways.
- */
- if (len % sizeof (Uint16) != 0) {
- *ptr = (Uint8) (((float) *ptr) * args->distance_f);
- ptr++;
- len--;
- }
- if (args->room_angle == 0)
- for (i = 0; i < len; i += sizeof (Uint8) * 6) {
- /* must adjust the sample so that 0 is the center */
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
- * args->left_f) * args->distance_f) + 128);
- ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
- * args->right_f) * args->distance_f) + 128);
- ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
- * args->left_rear_f) * args->distance_f) + 128);
- ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
- * args->right_rear_f) * args->distance_f) + 128);
- ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
- * args->center_f) * args->distance_f) + 128);
- ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
- * args->lfe_f) * args->distance_f) + 128);
- ptr++;
- }
- else if (args->room_angle == 90)
- for (i = 0; i < len; i += sizeof (Uint8) * 6) {
- /* must adjust the sample so that 0 is the center */
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
- * args->right_f) * args->distance_f) + 128);
- ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
- * args->right_rear_f) * args->distance_f) + 128);
- ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
- * args->left_f) * args->distance_f) + 128);
- ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
- * args->left_rear_f) * args->distance_f) + 128);
- ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
- * args->right_rear_f) * args->distance_f/2) + 128)
- + (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
- * args->right_f) * args->distance_f/2) + 128);
- ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
- * args->lfe_f) * args->distance_f) + 128);
- ptr++;
- }
- else if (args->room_angle == 180)
- for (i = 0; i < len; i += sizeof (Uint8) * 6) {
- /* must adjust the sample so that 0 is the center */
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
- * args->right_rear_f) * args->distance_f) + 128);
- ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
- * args->left_rear_f) * args->distance_f) + 128);
- ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
- * args->right_f) * args->distance_f) + 128);
- ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
- * args->left_f) * args->distance_f) + 128);
- ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
- * args->right_rear_f) * args->distance_f/2) + 128)
- + (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
- * args->left_rear_f) * args->distance_f/2) + 128);
- ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
- * args->lfe_f) * args->distance_f) + 128);
- ptr++;
- }
- else if (args->room_angle == 270)
- for (i = 0; i < len; i += sizeof (Uint8) * 6) {
- /* must adjust the sample so that 0 is the center */
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
- * args->left_rear_f) * args->distance_f) + 128);
- ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
- * args->left_f) * args->distance_f) + 128);
- ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
- * args->right_rear_f) * args->distance_f) + 128);
- ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
- * args->right_f) * args->distance_f) + 128);
- ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
- * args->left_f) * args->distance_f/2) + 128)
- + (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
- * args->left_rear_f) * args->distance_f/2) + 128);
- ptr++;
- *ptr = (Uint8) ((Sint8) ((((float) (Sint8) (*ptr - 128))
- * args->lfe_f) * args->distance_f) + 128);
- ptr++;
- }
- }
- /*
- * This one runs about 10.1 times faster than the non-table version, with
- * no loss in quality. It does, however, require 64k of memory for the
- * lookup table. Also, this will only update position information once per
- * call; the non-table version always checks the arguments for each sample,
- * in case the user has called Mix_SetPanning() or whatnot again while this
- * callback is running.
- */
- static void _Eff_position_table_u8(int chan, void *stream, int len, void *udata)
- {
- volatile position_args *args = (volatile position_args *) udata;
- Uint8 *ptr = (Uint8 *) stream;
- Uint32 *p;
- int i;
- Uint8 *l = ((Uint8 *) _Eff_volume_table) + (256 * args->left_u8);
- Uint8 *r = ((Uint8 *) _Eff_volume_table) + (256 * args->right_u8);
- Uint8 *d = ((Uint8 *) _Eff_volume_table) + (256 * args->distance_u8);
- if (args->room_angle == 180) {
- Uint8 *temp = l;
- l = r;
- r = temp;
- }
- /*
- * if there's only a mono channnel, then l[] and r[] are always
- * volume 255, and are therefore throwaways. Still, we have to
- * be sure not to overrun the audio buffer...
- */
- while (len % sizeof (Uint32) != 0) {
- *ptr = d[l[*ptr]];
- ptr++;
- if (args->channels > 1) {
- *ptr = d[r[*ptr]];
- ptr++;
- }
- len -= args->channels;
- }
- p = (Uint32 *) ptr;
- for (i = 0; i < len; i += sizeof (Uint32)) {
- #if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
- *p = (d[l[(*p & 0xFF000000) >> 24]] << 24) |
- (d[r[(*p & 0x00FF0000) >> 16]] << 16) |
- (d[l[(*p & 0x0000FF00) >> 8]] << 8) |
- (d[r[(*p & 0x000000FF) ]] ) ;
- #else
- *p = (d[r[(*p & 0xFF000000) >> 24]] << 24) |
- (d[l[(*p & 0x00FF0000) >> 16]] << 16) |
- (d[r[(*p & 0x0000FF00) >> 8]] << 8) |
- (d[l[(*p & 0x000000FF) ]] ) ;
- #endif
- ++p;
- }
- }
- static void _Eff_position_s8(int chan, void *stream, int len, void *udata)
- {
- volatile position_args *args = (volatile position_args *) udata;
- Sint8 *ptr = (Sint8 *) stream;
- int i;
- /*
- * if there's only a mono channnel (the only way we wouldn't have
- * a len divisible by 2 here), then left_f and right_f are always
- * 1.0, and are therefore throwaways.
- */
- if (len % sizeof (Sint16) != 0) {
- *ptr = (Sint8) (((float) *ptr) * args->distance_f);
- ptr++;
- len--;
- }
- if (args->room_angle == 180)
- for (i = 0; i < len; i += sizeof (Sint8) * 2) {
- *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f);
- ptr++;
- *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f);
- ptr++;
- }
- else
- for (i = 0; i < len; i += sizeof (Sint8) * 2) {
- *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f);
- ptr++;
- *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f);
- ptr++;
- }
- }
- static void _Eff_position_s8_c4(int chan, void *stream, int len, void *udata)
- {
- volatile position_args *args = (volatile position_args *) udata;
- Sint8 *ptr = (Sint8 *) stream;
- int i;
- /*
- * if there's only a mono channnel (the only way we wouldn't have
- * a len divisible by 2 here), then left_f and right_f are always
- * 1.0, and are therefore throwaways.
- */
- if (len % sizeof (Sint16) != 0) {
- *ptr = (Sint8) (((float) *ptr) * args->distance_f);
- ptr++;
- len--;
- }
- for (i = 0; i < len; i += sizeof (Sint8) * 4) {
- switch (args->room_angle) {
- case 0:
- *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); ptr++;
- *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f); ptr++;
- *ptr = (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f); ptr++;
- *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f); ptr++;
- break;
- case 90:
- *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f); ptr++;
- *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f); ptr++;
- *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); ptr++;
- *ptr = (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f); ptr++;
- break;
- case 180:
- *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f); ptr++;
- *ptr = (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f); ptr++;
- *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f); ptr++;
- *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); ptr++;
- break;
- case 270:
- *ptr = (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f); ptr++;
- *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); ptr++;
- *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f); ptr++;
- *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f); ptr++;
- break;
- }
- }
- }
- static void _Eff_position_s8_c6(int chan, void *stream, int len, void *udata)
- {
- volatile position_args *args = (volatile position_args *) udata;
- Sint8 *ptr = (Sint8 *) stream;
- int i;
- /*
- * if there's only a mono channnel (the only way we wouldn't have
- * a len divisible by 2 here), then left_f and right_f are always
- * 1.0, and are therefore throwaways.
- */
- if (len % sizeof (Sint16) != 0) {
- *ptr = (Sint8) (((float) *ptr) * args->distance_f);
- ptr++;
- len--;
- }
- for (i = 0; i < len; i += sizeof (Sint8) * 6) {
- switch (args->room_angle) {
- case 0:
- *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); ptr++;
- *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f); ptr++;
- *ptr = (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f); ptr++;
- *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f); ptr++;
- *ptr = (Sint8)((((float) *ptr) * args->center_f) * args->distance_f); ptr++;
- *ptr = (Sint8)((((float) *ptr) * args->lfe_f) * args->distance_f); ptr++;
- break;
- case 90:
- *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f); ptr++;
- *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f); ptr++;
- *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); ptr++;
- *ptr = (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f); ptr++;
- *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f / 2)
- + (Sint8)((((float) *ptr) * args->right_f) * args->distance_f / 2); ptr++;
- *ptr = (Sint8)((((float) *ptr) * args->lfe_f) * args->distance_f); ptr++;
- break;
- case 180:
- *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f); ptr++;
- *ptr = (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f); ptr++;
- *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f); ptr++;
- *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); ptr++;
- *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f / 2)
- + (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f / 2); ptr++;
- *ptr = (Sint8)((((float) *ptr) * args->lfe_f) * args->distance_f); ptr++;
- break;
- case 270:
- *ptr = (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f); ptr++;
- *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f); ptr++;
- *ptr = (Sint8)((((float) *ptr) * args->right_rear_f) * args->distance_f); ptr++;
- *ptr = (Sint8)((((float) *ptr) * args->right_f) * args->distance_f); ptr++;
- *ptr = (Sint8)((((float) *ptr) * args->left_f) * args->distance_f / 2)
- + (Sint8)((((float) *ptr) * args->left_rear_f) * args->distance_f / 2); ptr++;
- *ptr = (Sint8)((((float) *ptr) * args->lfe_f) * args->distance_f); ptr++;
- break;
- }
- }
- }
- /*
- * This one runs about 10.1 times faster than the non-table version, with
- * no loss in quality. It does, however, require 64k of memory for the
- * lookup table. Also, this will only update position information once per
- * call; the non-table version always checks the arguments for each sample,
- * in case the user has called Mix_SetPanning() or whatnot again while this
- * callback is running.
- */
- static void _Eff_position_table_s8(int chan, void *stream, int len, void *udata)
- {
- volatile position_args *args = (volatile position_args *) udata;
- Sint8 *ptr = (Sint8 *) stream;
- Uint32 *p;
- int i;
- Sint8 *l = ((Sint8 *) _Eff_volume_table) + (256 * args->left_u8);
- Sint8 *r = ((Sint8 *) _Eff_volume_table) + (256 * args->right_u8);
- Sint8 *d = ((Sint8 *) _Eff_volume_table) + (256 * args->distance_u8);
- if (args->room_angle == 180) {
- Sint8 *temp = l;
- l = r;
- r = temp;
- }
- while (len % sizeof (Uint32) != 0) {
- *ptr = d[l[*ptr]];
- ptr++;
- if (args->channels > 1) {
- *ptr = d[r[*ptr]];
- ptr++;
- }
- len -= args->channels;
- }
- p = (Uint32 *) ptr;
- for (i = 0; i < len; i += sizeof (Uint32)) {
- #if (SDL_BYTEORDER == SDL_BIG_ENDIAN)
- *p = (d[l[((Sint16)(Sint8)((*p & 0xFF000000) >> 24))+128]] << 24) |
- (d[r[((Sint16)(Sint8)((*p & 0x00FF0000) >> 16))+128]] << 16) |
- (d[l[((Sint16)(Sint8)((*p & 0x0000FF00) >> 8))+128]] << 8) |
- (d[r[((Sint16)(Sint8)((*p & 0x000000FF) ))+128]] ) ;
- #else
- *p = (d[r[((Sint16)(Sint8)((*p & 0xFF000000) >> 24))+128]] << 24) |
- (d[l[((Sint16)(Sint8)((*p & 0x00FF0000) >> 16))+128]] << 16) |
- (d[r[((Sint16)(Sint8)((*p & 0x0000FF00) >> 8))+128]] << 8) |
- (d[l[((Sint16)(Sint8)((*p & 0x000000FF) ))+128]] ) ;
- #endif
- ++p;
- }
- }
- /* !!! FIXME : Optimize the code for 16-bit samples? */
- static void _Eff_position_u16lsb(int chan, void *stream, int len, void *udata)
- {
- volatile position_args *args = (volatile position_args *) udata;
- Uint16 *ptr = (Uint16 *) stream;
- int i;
- for (i = 0; i < len; i += sizeof (Uint16) * 2) {
- Sint16 sampl = (Sint16) (SDL_SwapLE16(*(ptr+0)) - 32768);
- Sint16 sampr = (Sint16) (SDL_SwapLE16(*(ptr+1)) - 32768);
- Uint16 swapl = (Uint16) ((Sint16) (((float) sampl * args->left_f)
- * args->distance_f) + 32768);
- Uint16 swapr = (Uint16) ((Sint16) (((float) sampr * args->right_f)
- * args->distance_f) + 32768);
- if (args->room_angle == 180) {
- *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
- *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
- }
- else {
- *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
- *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
- }
- }
- }
- static void _Eff_position_u16lsb_c4(int chan, void *stream, int len, void *udata)
- {
- volatile position_args *args = (volatile position_args *) udata;
- Uint16 *ptr = (Uint16 *) stream;
- int i;
- for (i = 0; i < len; i += sizeof (Uint16) * 4) {
- Sint16 sampl = (Sint16) (SDL_SwapLE16(*(ptr+0)) - 32768);
- Sint16 sampr = (Sint16) (SDL_SwapLE16(*(ptr+1)) - 32768);
- Sint16 samplr = (Sint16) (SDL_SwapLE16(*(ptr+2)) - 32768);
- Sint16 samprr = (Sint16) (SDL_SwapLE16(*(ptr+3)) - 32768);
- Uint16 swapl = (Uint16) ((Sint16) (((float) sampl * args->left_f)
- * args->distance_f) + 32768);
- Uint16 swapr = (Uint16) ((Sint16) (((float) sampr * args->right_f)
- * args->distance_f) + 32768);
- Uint16 swaplr = (Uint16) ((Sint16) (((float) samplr * args->left_rear_f)
- * args->distance_f) + 32768);
- Uint16 swaprr = (Uint16) ((Sint16) (((float) samprr * args->right_rear_f)
- * args->distance_f) + 32768);
- switch (args->room_angle) {
- case 0:
- *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
- *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
- *(ptr++) = (Uint16) SDL_SwapLE16(swaplr);
- *(ptr++) = (Uint16) SDL_SwapLE16(swaprr);
- break;
- case 90:
- *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
- *(ptr++) = (Uint16) SDL_SwapLE16(swaprr);
- *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
- *(ptr++) = (Uint16) SDL_SwapLE16(swaplr);
- break;
- case 180:
- *(ptr++) = (Uint16) SDL_SwapLE16(swaprr);
- *(ptr++) = (Uint16) SDL_SwapLE16(swaplr);
- *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
- *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
- break;
- case 270:
- *(ptr++) = (Uint16) SDL_SwapLE16(swaplr);
- *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
- *(ptr++) = (Uint16) SDL_SwapLE16(swaprr);
- *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
- break;
- }
- }
- }
- static void _Eff_position_u16lsb_c6(int chan, void *stream, int len, void *udata)
- {
- volatile position_args *args = (volatile position_args *) udata;
- Uint16 *ptr = (Uint16 *) stream;
- int i;
- for (i = 0; i < len; i += sizeof (Uint16) * 6) {
- Sint16 sampl = (Sint16) (SDL_SwapLE16(*(ptr+0)) - 32768);
- Sint16 sampr = (Sint16) (SDL_SwapLE16(*(ptr+1)) - 32768);
- Sint16 samplr = (Sint16) (SDL_SwapLE16(*(ptr+2)) - 32768);
- Sint16 samprr = (Sint16) (SDL_SwapLE16(*(ptr+3)) - 32768);
- Sint16 sampce = (Sint16) (SDL_SwapLE16(*(ptr+4)) - 32768);
- Sint16 sampwf = (Sint16) (SDL_SwapLE16(*(ptr+5)) - 32768);
- Uint16 swapl = (Uint16) ((Sint16) (((float) sampl * args->left_f)
- * args->distance_f) + 32768);
- Uint16 swapr = (Uint16) ((Sint16) (((float) sampr * args->right_f)
- * args->distance_f) + 32768);
- Uint16 swaplr = (Uint16) ((Sint16) (((float) samplr * args->left_rear_f)
- * args->distance_f) + 32768);
- Uint16 swaprr = (Uint16) ((Sint16) (((float) samprr * args->right_rear_f)
- * args->distance_f) + 32768);
- Uint16 swapce = (Uint16) ((Sint16) (((float) sampce * args->center_f)
- * args->distance_f) + 32768);
- Uint16 swapwf = (Uint16) ((Sint16) (((float) sampwf * args->lfe_f)
- * args->distance_f) + 32768);
- switch (args->room_angle) {
- case 0:
- *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
- *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
- *(ptr++) = (Uint16) SDL_SwapLE16(swaplr);
- *(ptr++) = (Uint16) SDL_SwapLE16(swaprr);
- *(ptr++) = (Uint16) SDL_SwapLE16(swapce);
- *(ptr++) = (Uint16) SDL_SwapLE16(swapwf);
- break;
- case 90:
- *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
- *(ptr++) = (Uint16) SDL_SwapLE16(swaprr);
- *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
- *(ptr++) = (Uint16) SDL_SwapLE16(swaplr);
- *(ptr++) = (Uint16) SDL_SwapLE16(swapr)/2 + (Uint16) SDL_SwapLE16(swaprr)/2;
- *(ptr++) = (Uint16) SDL_SwapLE16(swapwf);
- break;
- case 180:
- *(ptr++) = (Uint16) SDL_SwapLE16(swaprr);
- *(ptr++) = (Uint16) SDL_SwapLE16(swaplr);
- *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
- *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
- *(ptr++) = (Uint16) SDL_SwapLE16(swaprr)/2 + (Uint16) SDL_SwapLE16(swaplr)/2;
- *(ptr++) = (Uint16) SDL_SwapLE16(swapwf);
- break;
- case 270:
- *(ptr++) = (Uint16) SDL_SwapLE16(swaplr);
- *(ptr++) = (Uint16) SDL_SwapLE16(swapl);
- *(ptr++) = (Uint16) SDL_SwapLE16(swaprr);
- *(ptr++) = (Uint16) SDL_SwapLE16(swapr);
- *(ptr++) = (Uint16) SDL_SwapLE16(swapl)/2 + (Uint16) SDL_SwapLE16(swaplr)/2;
- *(ptr++) = (Uint16) SDL_SwapLE16(swapwf);
- break;
- }
- }
- }
- static void _Eff_position_s16lsb(int chan, void *stream, int len, void *udata)
- {
- /* 16 signed bits (lsb) * 2 channels. */
- volatile position_args *args = (volatile position_args *) udata;
- Sint16 *ptr = (Sint16 *) stream;
- int i;
- #if 0
- if (len % (sizeof(Sint16) * 2)) {
- fprintf(stderr,"Not an even number of frames! len=%d\n", len);
- return;
- }
- #endif
- for (i = 0; i < len; i += sizeof (Sint16) * 2) {
- Sint16 swapl = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+0))) *
- args->left_f) * args->distance_f);
- Sint16 swapr = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+1))) *
- args->right_f) * args->distance_f);
- if (args->room_angle == 180) {
- *(ptr++) = (Sint16) SDL_SwapLE16(swapr);
- *(ptr++) = (Sint16) SDL_SwapLE16(swapl);
- }
- else {
- *(ptr++) = (Sint16) SDL_SwapLE16(swapl);
- *(ptr++) = (Sint16) SDL_SwapLE16(swapr);
- }
- }
- }
- static void _Eff_position_s16lsb_c4(int chan, void *stream, int len, void *udata)
- {
- /* 16 signed bits (lsb) * 4 channels. */
- volatile position_args *args = (volatile position_args *) udata;
- Sint16 *ptr = (Sint16 *) stream;
- int i;
- for (i = 0; i < len; i += sizeof (Sint16) * 4) {
- Sint16 swapl = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+0))) *
- args->left_f) * args->distance_f);
- Sint16 swapr = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+1))) *
- args->right_f) * args->distance_f);
- Sint16 swaplr = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+1))) *
- args->left_rear_f) * args->distance_f);
- Sint16 swaprr = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+2))) *
- args->right_rear_f) * args->distance_f);
- switch (args->room_angle) {
- case 0:
- *(ptr++) = (Sint16) SDL_SwapLE16(swapl);
- *(ptr++) = (Sint16) SDL_SwapLE16(swapr);
- *(ptr++) = (Sint16) SDL_SwapLE16(swaplr);
- *(ptr++) = (Sint16) SDL_SwapLE16(swaprr);
- break;
- case 90:
- *(ptr++) = (Sint16) SDL_SwapLE16(swapr);
- *(ptr++) = (Sint16) SDL_SwapLE16(swaprr);
- *(ptr++) = (Sint16) SDL_SwapLE16(swapl);
- *(ptr++) = (Sint16) SDL_SwapLE16(swaplr);
- break;
- case 180:
- *(ptr++) = (Sint16) SDL_SwapLE16(swaprr);
- *(ptr++) = (Sint16) SDL_SwapLE16(swaplr);
- *(ptr++) = (Sint16) SDL_SwapLE16(swapr);
- *(ptr++) = (Sint16) SDL_SwapLE16(swapl);
- break;
- case 270:
- *(ptr++) = (Sint16) SDL_SwapLE16(swaplr);
- *(ptr++) = (Sint16) SDL_SwapLE16(swapl);
- *(ptr++) = (Sint16) SDL_SwapLE16(swaprr);
- *(ptr++) = (Sint16) SDL_SwapLE16(swapr);
- break;
- }
- }
- }
- static void _Eff_position_s16lsb_c6(int chan, void *stream, int len, void *udata)
- {
- /* 16 signed bits (lsb) * 6 channels. */
- volatile position_args *args = (volatile position_args *) udata;
- Sint16 *ptr = (Sint16 *) stream;
- int i;
- for (i = 0; i < len; i += sizeof (Sint16) * 6) {
- Sint16 swapl = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+0))) *
- args->left_f) * args->distance_f);
- Sint16 swapr = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+1))) *
- args->right_f) * args->distance_f);
- Sint16 swaplr = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+2))) *
- args->left_rear_f) * args->distance_f);
- Sint16 swaprr = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+3))) *
- args->right_rear_f) * args->distance_f);
- Sint16 swapce = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+4))) *
- args->center_f) * args->distance_f);
- Sint16 swapwf = (Sint16) ((((float) (Sint16) SDL_SwapLE16(*(ptr+5))) *
- args->lfe_f) * args->distance_f);
- switch (args->room_angle) {
- case 0:
- *(ptr++) = (Sint16) SDL_SwapLE16(swapl);
- *(ptr++) = (Sint16) SDL_SwapLE16(swapr);
- *(ptr++) = (Sint16) SDL_SwapLE16(swaplr);
- *(ptr++) = (Sint16) SDL_SwapLE16(swaprr);
- *(ptr++) = (Sint16) SDL_SwapLE16(swapce);
- *(ptr++) = (Sint16) SDL_SwapLE16(swapwf);
- break;
- case 90:
- *(ptr++) = (Sint16) SDL_SwapLE16(swapr);
- *(ptr++) = (Sint16) SDL_SwapLE16(swaprr);
- *(ptr++) = (Sint16) SDL_SwapLE16(swapl);
- *(ptr++) = (Sint16) SDL_SwapLE16(swaplr);
- *(ptr++) = (Sint16) SDL_SwapLE16(swapr)/2 + (Sint16) SDL_SwapLE16(swaprr)/2;
- *(ptr++) = (Sint16) SDL_SwapLE16(swapwf);
- break;
- case 180:
- *(ptr++) = (Sint16) SDL_SwapLE16(swaprr);
- *(ptr++) = (Sint16) SDL_SwapLE16(swaplr);
- *(ptr++) = (Sint16) SDL_SwapLE16(swapr);
- *(ptr++) = (Sint16) SDL_SwapLE16(swapl);
- *(ptr++) = (Sint16) SDL_SwapLE16(swaprr)/2 + (Sint16) SDL_SwapLE16(swaplr)/2;
- *(ptr++) = (Sint16) SDL_SwapLE16(swapwf);
- break;
- case 270:
- *(ptr++) = (Sint16) SDL_SwapLE16(swaplr);
- *(ptr++) = (Sint16) SDL_SwapLE16(swapl);
- *(ptr++) = (Sint16) SDL_SwapLE16(swaprr);
- *(ptr++) = (Sint16) SDL_SwapLE16(swapr);
- *(ptr++) = (Sint16) SDL_SwapLE16(swapl)/2 + (Sint16) SDL_SwapLE16(swaplr)/2;
- *(ptr++) = (Sint16) SDL_SwapLE16(swapwf);
- break;
- }
- }
- }
- static void _Eff_position_u16msb(int chan, void *stream, int len, void *udata)
- {
- /* 16 signed bits (lsb) * 2 channels. */
- volatile position_args *args = (volatile position_args *) udata;
- Uint16 *ptr = (Uint16 *) stream;
- int i;
- for (i = 0; i < len; i += sizeof (Sint16) * 2) {
- Sint16 sampl = (Sint16) (SDL_SwapBE16(*(ptr+0)) - 32768);
- Sint16 sampr = (Sint16) (SDL_SwapBE16(*(ptr+1)) - 32768);
- Uint16 swapl = (Uint16) ((Sint16) (((float) sampl * args->left_f)
- * args->distance_f) + 32768);
- Uint16 swapr = (Uint16) ((Sint16) (((float) sampr * args->right_f)
- * args->distance_f) + 32768);
- if (args->room_angle == 180) {
- *(ptr++) = (Uint16) SDL_SwapBE16(swapr);
- *(ptr++) = (Uint16) SDL_SwapBE16(swapl);
- }
- else {
- *(ptr++) = (Uint16) SDL_SwapBE16(swapl);
- *(ptr++) = (Uint16) SDL_SwapBE16(swapr);
- }
- }
- }
- static void _Eff_position_u16msb_c4(int chan, void *stream, int len, void *udata)
- {
- /* 16 signed bits (lsb) * 4 channels. */
- volatile position_args *args = (volatile position_args *) udata;
- Uint16 *ptr = (Uint16 *) stream;
- int i;
- for (i = 0; i < len; i += sizeof (Sint16) * 4) {
- Sint16 sampl = (Sint16) (SDL_SwapBE16(*(ptr+0)) - 32768);
- Sint16 sampr = (Sint16) (SDL_SwapBE16(*(ptr+1)) - 32768);
- Sint16 samplr = (Sint16) (SDL_SwapBE16(*(ptr+2)) - 32768);
- Sint16 samprr = (Sint16) (SDL_SwapBE16(*(ptr+3)) - 32768);
- Uint16 swapl = (Uint16) ((Sint16) (((float) sampl * args->left_f)
- * args->distance_f) + 32768);
- Uint16 swapr = (Uint16) ((Sint16) (((float) sampr * args->right_f)
- * args->distance_f) + 32768);
- Uint16 swaplr = (Uint16) ((Sint16) (((float) samplr * args->left_rear_f)
- * args->distance_f) + 32768);
- Uint16 swaprr = (Uint16) ((Sint16) (((float) samprr * args->right_rear_f)
- * args->distance_f) + 32768);
- switch (args->room_angle) {
- case 0:
- *(ptr++) = (Uint16) SDL_SwapBE16(swapl);
- *(ptr++) = (Uint16) SDL_SwapBE16(swapr);
- *(ptr++) = (Uint16) SDL_SwapBE16(swaplr);
- *(ptr++) = (Uint16) SDL_SwapBE16(swaprr);
- break;
- case 90:
- *(ptr++) = (Uint16) SDL_SwapBE16(swapr);
- *(ptr++) = (Uint16) SDL_SwapBE16(swaprr);
- *(ptr++) = (Uint16) SDL_SwapBE16(swapl);
- *(ptr++) = (Uint16) SDL_SwapBE16(swaplr);
- break;
- case 180:
- *(ptr++) = (Uint16) SDL_SwapBE16(swaprr);
- *(ptr++) = (Uint16) SDL_SwapBE16(swaplr);
- *(ptr++) = (Uint16) SDL_SwapBE16(swapr);
- *(ptr++) = (Uint16) SDL_SwapBE16(swapl);
- break;
- case 270:
- *(ptr++) = (Uint16) SDL_SwapBE16(swaplr);
- *(ptr++) = (Uint16) SDL_SwapBE16(swapl);
- *(ptr++) = (Uint16) SDL_SwapBE16(swaprr);
- *(ptr++) = (Uint16) SDL_SwapBE16(swapr);
- break;
- }
- }
- }
- static void _Eff_position_u16msb_c6(int chan, void *stream, int len, void *udata)
- {
- /* 16 signed bits (lsb) * 6 channels. */
- volatile position_args *args = (volatile position_args *) udata;
- Uint16 *ptr = (Uint16 *) stream;
- int i;
- for (i = 0; i < len; i += sizeof (Sint16) * 6) {
- Sint16 sampl = (Sint16) (SDL_SwapBE16(*(ptr+0)) - 32768);
- Sint16 sampr = (Sint16) (SDL_SwapBE16(*(ptr+1)) - 32768);
- Sint16 samplr = (Sint16) (SDL_SwapBE16(*(ptr+2)) - 32768);
- Sint16 samprr = (Sint16) (SDL_SwapBE16(*(ptr+3)) - 32768);
- Sint16 sampce = (Sint16) (SDL_SwapBE16(*(ptr+4)) - 32768);
- Sint16 sampwf = (Sint16) (SDL_SwapBE16(*(ptr+5)) - 32768);
- Uint16 swapl = (Uint16) ((Sint16) (((float) sampl * args->left_f)
- * args->distance_f) + 32768);
- Uint16 swapr = (Uint16) ((Sint16) (((float) sampr * args->right_f)
- * args->distance_f) + 32768);
- Uint16 swaplr = (Uint16) ((Sint16) (((float) samplr * args->left_rear_f)
- * args->distance_f) + 32768);
- Uint16 swaprr = (Uint16) ((Sint16) (((float) samprr * args->right_rear_f)
- * args->distance_f) + 32768);
- Uint16 swapce = (Uint16) ((Sint16) (((float) sampce * args->center_f)
- * args->distance_f) + 32768);
- Uint16 swapwf = (Uint16) ((Sint16) (((float) sampwf * args->lfe_f)
- * args->distance_f) + 32768);
- switch (args->room_angle) {
- case 0:
- *(ptr++) = (Uint16) SDL_SwapBE16(swapl);
- *(ptr++) = (Uint16) SDL_SwapBE16(swapr);
- *(ptr++) = (Uint16) SDL_SwapBE16(swaplr);
- *(ptr++) = (Uint16) SDL_SwapBE16(swaprr);
- *(ptr++) = (Uint16) SDL_SwapBE16(swapce);
- *(ptr++) = (Uint16) SDL_SwapBE16(swapwf);
- break;
- case 90:
- *(ptr++) = (Uint16) SDL_SwapBE16(swapr);
- *(ptr++) = (Uint16) SDL_SwapBE16(swaprr);
- *(ptr++) = (Uint16) SDL_SwapBE16(swapl);
- *(ptr++) = (Uint16) SDL_SwapBE16(swaplr);
- *(ptr++) = (Uint16) SDL_SwapBE16(swapr)/2 + (Uint16) SDL_SwapBE16(swaprr)/2;
- *(ptr++) = (Uint16) SDL_SwapBE16(swapwf);
- break;
- case 180:
- *(ptr++) = (Uint16) SDL_SwapBE16(swaprr);
- *(ptr++) = (Uint16) SDL_SwapBE16(swaplr);
- *(ptr++) = (Uint16) SDL_SwapBE16(swapr);
- *(ptr++) = (Uint16) SDL_SwapBE16(swapl);
- *(ptr++) = (Uint16) SDL_SwapBE16(swaprr)/2 + (Uint16) SDL_SwapBE16(swaplr)/2;
- *(ptr++) = (Uint16) SDL_SwapBE16(swapwf);
- break;
- case 270:
- *(ptr++) = (Uint16) SDL_SwapBE16(swaplr);
- *(ptr++) = (Uint16) SDL_SwapBE16(swapl);
- *(ptr++) = (Uint16) SDL_SwapBE16(swaprr);
- *(ptr++) = (Uint16) SDL_SwapBE16(swapr);
- *(ptr++) = (Uint16) SDL_SwapBE16(swapl)/2 + (Uint16) SDL_SwapBE16(swaplr)/2;
- *(ptr++) = (Uint16) SDL_SwapBE16(swapwf);
- break;
- }
- }
- }
- static void _Eff_position_s16msb(int chan, void *stream, int len, void *udata)
- {
- /* 16 signed bits (lsb) * 2 channels. */
- volatile position_args *args = (volatile position_args *) udata;
- Sint16 *ptr = (Sint16 *) stream;
- int i;
- for (i = 0; i < len; i += sizeof (Sint16) * 2) {
- Sint16 swapl = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+0))) *
- args->left_f) * args->distance_f);
- Sint16 swapr = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+1))) *
- args->right_f) * args->distance_f);
- *(ptr++) = (Sint16) SDL_SwapBE16(swapl);
- *(ptr++) = (Sint16) SDL_SwapBE16(swapr);
- }
- }
- static void _Eff_position_s16msb_c4(int chan, void *stream, int len, void *udata)
- {
- /* 16 signed bits (lsb) * 4 channels. */
- volatile position_args *args = (volatile position_args *) udata;
- Sint16 *ptr = (Sint16 *) stream;
- int i;
- for (i = 0; i < len; i += sizeof (Sint16) * 4) {
- Sint16 swapl = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+0))) *
- args->left_f) * args->distance_f);
- Sint16 swapr = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+1))) *
- args->right_f) * args->distance_f);
- Sint16 swaplr = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+2))) *
- args->left_rear_f) * args->distance_f);
- Sint16 swaprr = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+3))) *
- args->right_rear_f) * args->distance_f);
- switch (args->room_angle) {
- case 0:
- *(ptr++) = (Sint16) SDL_SwapBE16(swapl);
- *(ptr++) = (Sint16) SDL_SwapBE16(swapr);
- *(ptr++) = (Sint16) SDL_SwapBE16(swaplr);
- *(ptr++) = (Sint16) SDL_SwapBE16(swaprr);
- break;
- case 90:
- *(ptr++) = (Sint16) SDL_SwapBE16(swapr);
- *(ptr++) = (Sint16) SDL_SwapBE16(swaprr);
- *(ptr++) = (Sint16) SDL_SwapBE16(swapl);
- *(ptr++) = (Sint16) SDL_SwapBE16(swaplr);
- break;
- case 180:
- *(ptr++) = (Sint16) SDL_SwapBE16(swaprr);
- *(ptr++) = (Sint16) SDL_SwapBE16(swaplr);
- *(ptr++) = (Sint16) SDL_SwapBE16(swapr);
- *(ptr++) = (Sint16) SDL_SwapBE16(swapl);
- break;
- case 270:
- *(ptr++) = (Sint16) SDL_SwapBE16(swaplr);
- *(ptr++) = (Sint16) SDL_SwapBE16(swapl);
- *(ptr++) = (Sint16) SDL_SwapBE16(swaprr);
- *(ptr++) = (Sint16) SDL_SwapBE16(swapr);
- break;
- }
- }
- }
- static void _Eff_position_s16msb_c6(int chan, void *stream, int len, void *udata)
- {
- /* 16 signed bits (lsb) * 6 channels. */
- volatile position_args *args = (volatile position_args *) udata;
- Sint16 *ptr = (Sint16 *) stream;
- int i;
- for (i = 0; i < len; i += sizeof (Sint16) * 6) {
- Sint16 swapl = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+0))) *
- args->left_f) * args->distance_f);
- Sint16 swapr = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+1))) *
- args->right_f) * args->distance_f);
- Sint16 swaplr = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+2))) *
- args->left_rear_f) * args->distance_f);
- Sint16 swaprr = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+3))) *
- args->right_rear_f) * args->distance_f);
- Sint16 swapce = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+4))) *
- args->center_f) * args->distance_f);
- Sint16 swapwf = (Sint16) ((((float) (Sint16) SDL_SwapBE16(*(ptr+5))) *
- args->lfe_f) * args->distance_f);
- switch (args->room_angle) {
- case 0:
- *(ptr++) = (Sint16) SDL_SwapBE16(swapl);
- *(ptr++) = (Sint16) SDL_SwapBE16(swapr);
- *(ptr++) = (Sint16) SDL_SwapBE16(swaplr);
- *(ptr++) = (Sint16) SDL_SwapBE16(swaprr);
- *(ptr++) = (Sint16) SDL_SwapBE16(swapce);
- *(ptr++) = (Sint16) SDL_SwapBE16(swapwf);
- break;
- case 90:
- *(ptr++) = (Sint16) SDL_SwapBE16(swapr);
- *(ptr++) = (Sint16) SDL_SwapBE16(swaprr);
- *(ptr++) = (Sint16) SDL_SwapBE16(swapl);
- *(ptr++) = (Sint16) SDL_SwapBE16(swaplr);
- *(ptr++) = (Sint16) SDL_SwapBE16(swapr)/2 + (Sint16) SDL_SwapBE16(swaprr)/2;
- *(ptr++) = (Sint16) SDL_SwapBE16(swapwf);
- break;
- case 180:
- *(ptr++) = (Sint16) SDL_SwapBE16(swaprr);
- *(ptr++) = (Sint16) SDL_SwapBE16(swaplr);
- *(ptr++) = (Sint16) SDL_SwapBE16(swapr);
- *(ptr++) = (Sint16) SDL_SwapBE16(swapl);
- *(ptr++) = (Sint16) SDL_SwapBE16(swaprr)/2 + (Sint16) SDL_SwapBE16(swaplr)/2;
- *(ptr++) = (Sint16) SDL_SwapBE16(swapwf);
- break;
- case 270:
- *(ptr++) = (Sint16) SDL_SwapBE16(swaplr);
- *(ptr++) = (Sint16) SDL_SwapBE16(swapl);
- *(ptr++) = (Sint16) SDL_SwapBE16(swaprr);
- *(ptr++) = (Sint16) SDL_SwapBE16(swapr);
- *(ptr++) = (Sint16) SDL_SwapBE16(swapl)/2 + (Sint16) SDL_SwapBE16(swaplr)/2;
- *(ptr++) = (Sint16) SDL_SwapBE16(swapwf);
- break;
- }
- }
- }
- static void init_position_args(position_args *args)
- {
- SDL_memset(args, '\0', sizeof (position_args));
- args->in_use = 0;
- args->room_angle = 0;
- args->left_u8 = args->right_u8 = args->distance_u8 = 255;
- args->left_f = args->right_f = args->distance_f = 1.0f;
- args->left_rear_u8 = args->right_rear_u8 = args->center_u8 = args->lfe_u8 = 255;
- args->left_rear_f = args->right_rear_f = args->center_f = args->lfe_f = 1.0f;
- Mix_QuerySpec(NULL, NULL, (int *) &args->channels);
- }
- static position_args *get_position_arg(int channel)
- {
- void *rc;
- int i;
- if (channel < 0) {
- if (pos_args_global == NULL) {
- pos_args_global = SDL_malloc(sizeof (position_args));
- if (pos_args_global == NULL) {
- Mix_SetError("Out of memory");
- return(NULL);
- }
- init_position_args(pos_args_global);
- }
- return(pos_args_global);
- }
- if (channel >= position_channels) {
- rc = SDL_realloc(pos_args_array, (channel + 1) * sizeof (position_args *));
- if (rc == NULL) {
- Mix_SetError("Out of memory");
- return(NULL);
- }
- pos_args_array = (position_args **) rc;
- for (i = position_channels; i <= channel; i++) {
- pos_args_array[i] = NULL;
- }
- position_channels = channel + 1;
- }
- if (pos_args_array[channel] == NULL) {
- pos_args_array[channel] = (position_args *)SDL_malloc(sizeof(position_args));
- if (pos_args_array[channel] == NULL) {
- Mix_SetError("Out of memory");
- return(NULL);
- }
- init_position_args(pos_args_array[channel]);
- }
- return(pos_args_array[channel]);
- }
- static Mix_EffectFunc_t get_position_effect_func(Uint16 format, int channels)
- {
- Mix_EffectFunc_t f = NULL;
- switch (format) {
- case AUDIO_U8:
- switch (channels) {
- case 1:
- case 2:
- f = (_Eff_build_volume_table_u8()) ? _Eff_position_table_u8 :
- _Eff_position_u8;
- break;
- case 4:
- f = _Eff_position_u8_c4;
- break;
- case 6:
- f = _Eff_position_u8_c6;
- break;
- }
- break;
- case AUDIO_S8:
- switch (channels) {
- case 1:
- case 2:
- f = (_Eff_build_volume_table_s8()) ? _Eff_position_table_s8 :
- _Eff_position_s8;
- break;
- case 4:
- f = _Eff_position_s8_c4;
- break;
- case 6:
- f = _Eff_position_s8_c6;
- break;
- }
- break;
- case AUDIO_U16LSB:
- switch (channels) {
- case 1:
- case 2:
- f = _Eff_position_u16lsb;
- break;
- case 4:
- f = _Eff_position_u16lsb_c4;
- break;
- case 6:
- f = _Eff_position_u16lsb_c6;
- break;
- }
- break;
- case AUDIO_S16LSB:
- switch (channels) {
- case 1:
- case 2:
- f = _Eff_position_s16lsb;
- break;
- case 4:
- f = _Eff_position_s16lsb_c4;
- break;
- case 6:
- f = _Eff_position_s16lsb_c6;
- break;
- }
- break;
- case AUDIO_U16MSB:
- switch (channels) {
- case 1:
- case 2:
- f = _Eff_position_u16msb;
- break;
- case 4:
- f = _Eff_position_u16msb_c4;
- break;
- case 6:
- f = _Eff_position_u16msb_c6;
- break;
- }
- break;
- case AUDIO_S16MSB:
- switch (channels) {
- case 1:
- case 2:
- f = _Eff_position_s16msb;
- break;
- case 4:
- f = _Eff_position_s16msb_c4;
- break;
- case 6:
- f = _Eff_position_s16msb_c6;
- break;
- }
- break;
- default:
- Mix_SetError("Unsupported audio format");
- }
- return(f);
- }
- static Uint8 speaker_amplitude[6];
- static void set_amplitudes(int channels, int angle, int room_angle)
- {
- int left = 255, right = 255;
- int left_rear = 255, right_rear = 255, center = 255;
- angle = SDL_abs(angle) % 360; /* make angle between 0 and 359. */
- if (channels == 2)
- {
- /*
- * We only attenuate by position if the angle falls on the far side
- * of center; That is, an angle that's due north would not attenuate
- * either channel. Due west attenuates the right channel to 0.0, and
- * due east attenuates the left channel to 0.0. Slightly east of
- * center attenuates the left channel a little, and the right channel
- * not at all. I think of this as occlusion by one's own head. :)
- *
- * ...so, we split our angle circle into four quadrants...
- */
- if (angle < 90) {
- left = 255 - ((int) (255.0f * (((float) angle) / 89.0f)));
- } else if (angle < 180) {
- left = (int) (255.0f * (((float) (angle - 90)) / 89.0f));
- } else if (angle < 270) {
- right = 255 - ((int) (255.0f * (((float) (angle - 180)) / 89.0f)));
- } else {
- right = (int) (255.0f * (((float) (angle - 270)) / 89.0f));
- }
- }
- if (channels == 4 || channels == 6)
- {
- /*
- * An angle that's due north does not attenuate the center channel.
- * An angle in the first quadrant, 0-90, does not attenuate the RF.
- *
- * ...so, we split our angle circle into 8 ...
- *
- * CE
- * 0
- * LF | RF
- * |
- * 270<-------|----------->90
- * |
- * LR | RR
- * 180
- *
- */
- if (angle < 45) {
- left = ((int) (255.0f * (((float) (180 - angle)) / 179.0f)));
- left_rear = 255 - ((int) (255.0f * (((float) (angle + 45)) / 89.0f)));
- right_rear = 255 - ((int) (255.0f * (((float) (90 - angle)) / 179.0f)));
- } else if (angle < 90) {
- center = ((int) (255.0f * (((float) (225 - angle)) / 179.0f)));
- left = ((int) (255.0f * (((float) (180 - angle)) / 179.0f)));
- left_rear = 255 - ((int) (255.0f * (((float) (135 - angle)) / 89.0f)));
- right_rear = ((int) (255.0f * (((float) (90 + angle)) / 179.0f)));
- } else if (angle < 135) {
- center = ((int) (255.0f * (((float) (225 - angle)) / 179.0f)));
- left = 255 - ((int) (255.0f * (((float) (angle - 45)) / 89.0f)));
- right = ((int) (255.0f * (((float) (270 - angle)) / 179.0f)));
- left_rear = ((int) (255.0f * (((float) (angle)) / 179.0f)));
- } else if (angle < 180) {
- center = 255 - ((int) (255.0f * (((float) (angle - 90)) / 89.0f)));
- left = 255 - ((int) (255.0f * (((float) (225 - angle)) / 89.0f)));
- right = ((int) (255.0f * (((float) (270 - angle)) / 179.0f)));
- left_rear = ((int) (255.0f * (((float) (angle)) / 179.0f)));
- } else if (angle < 225) {
- center = 255 - ((int) (255.0f * (((float) (270 - angle)) / 89.0f)));
- left = ((int) (255.0f * (((float) (angle - 90)) / 179.0f)));
- right = 255 - ((int) (255.0f * (((float) (angle - 135)) / 89.0f)));
- right_rear = ((int) (255.0f * (((float) (360 - angle)) / 179.0f)));
- } else if (angle < 270) {
- center = ((int) (255.0f * (((float) (angle - 135)) / 179.0f)));
- left = ((int) (255.0f * (((float) (angle - 90)) / 179.0f)));
- right = 255 - ((int) (255.0f * (((float) (315 - angle)) / 89.0f)));
- right_rear = ((int) (255.0f * (((float) (360 - angle)) / 179.0f)));
- } else if (angle < 315) {
- center = ((int) (255.0f * (((float) (angle - 135)) / 179.0f)));
- right = ((int) (255.0f * (((float) (angle - 180)) / 179.0f)));
- left_rear = ((int) (255.0f * (((float) (450 - angle)) / 179.0f)));
- right_rear = 255 - ((int) (255.0f * (((float) (angle - 225)) / 89.0f)));
- } else {
- right = ((int) (255.0f * (((float) (angle - 180)) / 179.0f)));
- left_rear = ((int) (255.0f * (((float) (450 - angle)) / 179.0f)));
- right_rear = 255 - ((int) (255.0f * (((float) (405 - angle)) / 89.0f)));
- }
- }
- if (left < 0) left = 0; if (left > 255) left = 255;
- if (right < 0) right = 0; if (right > 255) right = 255;
- if (left_rear < 0) left_rear = 0; if (left_rear > 255) left_rear = 255;
- if (right_rear < 0) right_rear = 0; if (right_rear > 255) right_rear = 255;
- if (center < 0) center = 0; if (center > 255) center = 255;
- if (room_angle == 90) {
- speaker_amplitude[0] = (Uint8)left_rear;
- speaker_amplitude[1] = (Uint8)left;
- speaker_amplitude[2] = (Uint8)right_rear;
- speaker_amplitude[3] = (Uint8)right;
- }
- else if (room_angle == 180) {
- if (channels == 2) {
- speaker_amplitude[0] = (Uint8)right;
- speaker_amplitude[1] = (Uint8)left;
- }
- else {
- speaker_amplitude[0] = (Uint8)right_rear;
- speaker_amplitude[1] = (Uint8)left_rear;
- speaker_amplitude[2] = (Uint8)right;
- speaker_amplitude[3] = (Uint8)left;
- }
- }
- else if (room_angle == 270) {
- speaker_amplitude[0] = (Uint8)right;
- speaker_amplitude[1] = (Uint8)right_rear;
- speaker_amplitude[2] = (Uint8)left;
- speaker_amplitude[3] = (Uint8)left_rear;
- }
- else {
- speaker_amplitude[0] = (Uint8)left;
- speaker_amplitude[1] = (Uint8)right;
- speaker_amplitude[2] = (Uint8)left_rear;
- speaker_amplitude[3] = (Uint8)right_rear;
- }
- speaker_amplitude[4] = (Uint8)center;
- speaker_amplitude[5] = 255;
- }
- int Mix_SetPosition(int channel, Sint16 angle, Uint8 distance);
- int Mix_SetPanning(int channel, Uint8 left, Uint8 right)
- {
- Mix_EffectFunc_t f = NULL;
- int channels;
- Uint16 format;
- position_args *args = NULL;
- int retval = 1;
- Mix_QuerySpec(NULL, &format, &channels);
- if (channels != 2 && channels != 4 && channels != 6) /* it's a no-op; we call that successful. */
- return(1);
- if (channels > 2) {
- /* left = right = 255 => angle = 0, to unregister effect as when channels = 2 */
- /* left = 255 => angle = -90; left = 0 => angle = +89 */
- int angle = 0;
- if ((left != 255) || (right != 255)) {
- angle = (int)left;
- angle = 127 - angle;
- angle = -angle;
- angle = angle * 90 / 128; /* Make it larger for more effect? */
- }
- return( Mix_SetPosition(channel, angle, 0) );
- }
- f = get_position_effect_func(format, channels);
- if (f == NULL)
- return(0);
- SDL_LockAudio();
- args = get_position_arg(channel);
- if (!args) {
- SDL_UnlockAudio();
- return(0);
- }
- /* it's a no-op; unregister the effect, if it's registered. */
- if ((args->distance_u8 == 255) && (left == 255) && (right == 255)) {
- if (args->in_use) {
- retval = _Mix_UnregisterEffect_locked(channel, f);
- SDL_UnlockAudio();
- return(retval);
- } else {
- SDL_UnlockAudio();
- return(1);
- }
- }
- args->left_u8 = left;
- args->left_f = ((float) left) / 255.0f;
- args->right_u8 = right;
- args->right_f = ((float) right) / 255.0f;
- args->room_angle = 0;
- if (!args->in_use) {
- args->in_use = 1;
- retval=_Mix_RegisterEffect_locked(channel, f, _Eff_PositionDone, (void*)args);
- }
- SDL_UnlockAudio();
- return(retval);
- }
- int Mix_SetDistance(int channel, Uint8 distance)
- {
- Mix_EffectFunc_t f = NULL;
- Uint16 format;
- position_args *args = NULL;
- int channels;
- int retval = 1;
- Mix_QuerySpec(NULL, &format, &channels);
- f = get_position_effect_func(format, channels);
- if (f == NULL)
- return(0);
- SDL_LockAudio();
- args = get_position_arg(channel);
- if (!args) {
- SDL_UnlockAudio();
- return(0);
- }
- distance = 255 - distance; /* flip it to our scale. */
- /* it's a no-op; unregister the effect, if it's registered. */
- if ((distance == 255) && (args->left_u8 == 255) && (args->right_u8 == 255)) {
- if (args->in_use) {
- retval = _Mix_UnregisterEffect_locked(channel, f);
- SDL_UnlockAudio();
- return(retval);
- } else {
- SDL_UnlockAudio();
- return(1);
- }
- }
- args->distance_u8 = distance;
- args->distance_f = ((float) distance) / 255.0f;
- if (!args->in_use) {
- args->in_use = 1;
- retval = _Mix_RegisterEffect_locked(channel, f, _Eff_PositionDone, (void *) args);
- }
- SDL_UnlockAudio();
- return(retval);
- }
- int Mix_SetPosition(int channel, Sint16 angle, Uint8 distance)
- {
- Mix_EffectFunc_t f = NULL;
- Uint16 format;
- int channels;
- position_args *args = NULL;
- Sint16 room_angle = 0;
- int retval = 1;
- Mix_QuerySpec(NULL, &format, &channels);
- f = get_position_effect_func(format, channels);
- if (f == NULL)
- return(0);
- angle = SDL_abs(angle) % 360; /* make angle between 0 and 359. */
- SDL_LockAudio();
- args = get_position_arg(channel);
- if (!args) {
- SDL_UnlockAudio();
- return(0);
- }
- /* it's a no-op; unregister the effect, if it's registered. */
- if ((!distance) && (!angle)) {
- if (args->in_use) {
- retval = _Mix_UnregisterEffect_locked(channel, f);
- SDL_UnlockAudio();
- return(retval);
- } else {
- SDL_UnlockAudio();
- return(1);
- }
- }
- if (channels == 2)
- {
- if (angle > 180)
- room_angle = 180; /* exchange left and right channels */
- else room_angle = 0;
- }
- if (channels == 4 || channels == 6)
- {
- if (angle > 315) room_angle = 0;
- else if (angle > 225) room_angle = 270;
- else if (angle > 135) room_angle = 180;
- else if (angle > 45) room_angle = 90;
- else room_angle = 0;
- }
- distance = 255 - distance; /* flip it to scale Mix_SetDistance() uses. */
- set_amplitudes(channels, angle, room_angle);
- args->left_u8 = speaker_amplitude[0];
- args->left_f = ((float) speaker_amplitude[0]) / 255.0f;
- args->right_u8 = speaker_amplitude[1];
- args->right_f = ((float) speaker_amplitude[1]) / 255.0f;
- args->left_rear_u8 = speaker_amplitude[2];
- args->left_rear_f = ((float) speaker_amplitude[2]) / 255.0f;
- args->right_rear_u8 = speaker_amplitude[3];
- args->right_rear_f = ((float) speaker_amplitude[3]) / 255.0f;
- args->center_u8 = speaker_amplitude[4];
- args->center_f = ((float) speaker_amplitude[4]) / 255.0f;
- args->lfe_u8 = speaker_amplitude[5];
- args->lfe_f = ((float) speaker_amplitude[5]) / 255.0f;
- args->distance_u8 = distance;
- args->distance_f = ((float) distance) / 255.0f;
- args->room_angle = room_angle;
- if (!args->in_use) {
- args->in_use = 1;
- retval = _Mix_RegisterEffect_locked(channel, f, _Eff_PositionDone, (void *) args);
- }
- SDL_UnlockAudio();
- return(retval);
- }
- /* end of effects_position.c ... */
|