annotate Alc/alcDedicated.c @ 29:cdf320cb5949

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