Mercurial > audio-send
view Alc/alcDedicated.c @ 1:c41d773a85fb
moved org files, ignored html files
author | Robert McIntyre <rlm@mit.edu> |
---|---|
date | Tue, 25 Oct 2011 13:03:35 -0700 |
parents | f9476ff7637e |
children |
line wrap: on
line source
1 /**2 * OpenAL cross platform audio library3 * Copyright (C) 2011 by Chris Robinson.4 * This library is free software; you can redistribute it and/or5 * modify it under the terms of the GNU Library General Public6 * License as published by the Free Software Foundation; either7 * version 2 of the License, or (at your option) any later version.8 *9 * This library is distributed in the hope that it will be useful,10 * but WITHOUT ANY WARRANTY; without even the implied warranty of11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU12 * Library General Public License for more details.13 *14 * You should have received a copy of the GNU Library General Public15 * License along with this library; if not, write to the16 * Free Software Foundation, Inc., 59 Temple Place - Suite 330,17 * Boston, MA 02111-1307, USA.18 * Or go to http://www.gnu.org/copyleft/lgpl.html19 */21 #include "config.h"23 #include <stdlib.h>25 #include "alMain.h"26 #include "alFilter.h"27 #include "alAuxEffectSlot.h"28 #include "alError.h"29 #include "alu.h"32 typedef struct ALdedicatedState {33 // Must be first in all effects!34 ALeffectState state;36 ALfloat gains[MAXCHANNELS];37 } ALdedicatedState;40 static ALvoid DedicatedDestroy(ALeffectState *effect)41 {42 ALdedicatedState *state = (ALdedicatedState*)effect;43 free(state);44 }46 static ALboolean DedicatedDeviceUpdate(ALeffectState *effect, ALCdevice *Device)47 {48 (void)effect;49 (void)Device;50 return AL_TRUE;51 }53 static ALvoid DedicatedDLGUpdate(ALeffectState *effect, ALCcontext *Context, const ALeffectslot *Slot)54 {55 ALdedicatedState *state = (ALdedicatedState*)effect;56 ALCdevice *device = Context->Device;57 const ALfloat *SpeakerGain;58 ALfloat Gain;59 ALint pos;60 ALsizei s;62 pos = aluCart2LUTpos(1.0f, 0.0f);63 SpeakerGain = device->PanningLUT[pos];65 Gain = Slot->Gain * Slot->effect.Params.Dedicated.Gain;66 for(s = 0;s < MAXCHANNELS;s++)67 state->gains[s] = SpeakerGain[s] * Gain;68 }70 static ALvoid DedicatedLFEUpdate(ALeffectState *effect, ALCcontext *Context, const ALeffectslot *Slot)71 {72 ALdedicatedState *state = (ALdedicatedState*)effect;73 ALfloat Gain;74 ALsizei s;75 (void)Context;77 Gain = Slot->Gain * Slot->effect.Params.Dedicated.Gain;78 for(s = 0;s < MAXCHANNELS;s++)79 state->gains[s] = 0.0f;80 state->gains[LFE] = Gain;81 }83 static ALvoid DedicatedProcess(ALeffectState *effect, const ALeffectslot *Slot, ALuint SamplesToDo, const ALfloat *SamplesIn, ALfloat (*SamplesOut)[MAXCHANNELS])84 {85 ALdedicatedState *state = (ALdedicatedState*)effect;86 const ALfloat *gains = state->gains;87 ALuint i, s;88 (void)Slot;90 for(i = 0;i < SamplesToDo;i++)91 {92 ALfloat sample;94 sample = SamplesIn[i];95 for(s = 0;s < MAXCHANNELS;s++)96 SamplesOut[i][s] = sample * gains[s];97 }98 }100 ALeffectState *DedicatedDLGCreate(void)101 {102 ALdedicatedState *state;103 ALsizei s;105 state = malloc(sizeof(*state));106 if(!state)107 return NULL;109 state->state.Destroy = DedicatedDestroy;110 state->state.DeviceUpdate = DedicatedDeviceUpdate;111 state->state.Update = DedicatedDLGUpdate;112 state->state.Process = DedicatedProcess;114 for(s = 0;s < MAXCHANNELS;s++)115 state->gains[s] = 0.0f;117 return &state->state;118 }120 ALeffectState *DedicatedLFECreate(void)121 {122 ALdedicatedState *state;123 ALsizei s;125 state = malloc(sizeof(*state));126 if(!state)127 return NULL;129 state->state.Destroy = DedicatedDestroy;130 state->state.DeviceUpdate = DedicatedDeviceUpdate;131 state->state.Update = DedicatedLFEUpdate;132 state->state.Process = DedicatedProcess;134 for(s = 0;s < MAXCHANNELS;s++)135 state->gains[s] = 0.0f;137 return &state->state;138 }