diff options
-rw-r--r-- | Alc/ALc.c | 10 | ||||
-rw-r--r-- | Alc/ALu.c | 11 | ||||
-rw-r--r-- | OpenAL32/Include/alSource.h | 5 | ||||
-rw-r--r-- | OpenAL32/alSource.c | 36 |
4 files changed, 55 insertions, 7 deletions
@@ -523,6 +523,8 @@ static const ALCenums enumeration[] = { DECL(AL_UNPACK_BLOCK_ALIGNMENT_SOFT), DECL(AL_PACK_BLOCK_ALIGNMENT_SOFT), + DECL(AL_STEREO_ANGLES), + DECL(AL_UNUSED), DECL(AL_PENDING), DECL(AL_PROCESSED), @@ -712,10 +714,10 @@ static const ALchar alExtList[] = "AL_EXT_ALAW AL_EXT_BFORMAT AL_EXT_DOUBLE AL_EXT_EXPONENT_DISTANCE " "AL_EXT_FLOAT32 AL_EXT_IMA4 AL_EXT_LINEAR_DISTANCE AL_EXT_MCFORMATS " "AL_EXT_MULAW AL_EXT_MULAW_BFORMAT AL_EXT_MULAW_MCFORMATS AL_EXT_OFFSET " - "AL_EXT_source_distance_model AL_LOKI_quadriphonic AL_SOFT_block_alignment " - "AL_SOFT_buffer_samples AL_SOFT_buffer_sub_data AL_SOFT_deferred_updates " - "AL_SOFT_direct_channels AL_SOFT_loop_points AL_SOFT_MSADPCM " - "AL_SOFT_source_latency AL_SOFT_source_length"; + "AL_EXT_source_distance_model AL_EXT_STEREO_ANGLES AL_LOKI_quadriphonic " + "AL_SOFT_block_alignment AL_SOFT_buffer_samples AL_SOFT_buffer_sub_data " + "AL_SOFT_deferred_updates AL_SOFT_direct_channels AL_SOFT_loop_points " + "AL_SOFT_MSADPCM AL_SOFT_source_latency AL_SOFT_source_length"; static ATOMIC(ALCenum) LastNullDeviceError = ATOMIC_INIT_STATIC(ALC_NO_ERROR); @@ -303,9 +303,6 @@ ALvoid CalcNonAttnSourceParams(ALvoice *voice, const ALsource *ALSource, const A { static const struct ChanMap MonoMap[1] = { { FrontCenter, 0.0f, 0.0f } - }, StereoMap[2] = { - { FrontLeft, DEG2RAD(-30.0f), DEG2RAD(0.0f) }, - { FrontRight, DEG2RAD( 30.0f), DEG2RAD(0.0f) } }, RearMap[2] = { { BackLeft, DEG2RAD(-150.0f), DEG2RAD(0.0f) }, { BackRight, DEG2RAD( 150.0f), DEG2RAD(0.0f) } @@ -352,6 +349,10 @@ ALvoid CalcNonAttnSourceParams(ALvoice *voice, const ALsource *ALSource, const A ALuint NumSends, Frequency; ALboolean Relative; const struct ChanMap *chans = NULL; + struct ChanMap StereoMap[2] = { + { FrontLeft, DEG2RAD(-30.0f), DEG2RAD(0.0f) }, + { FrontRight, DEG2RAD( 30.0f), DEG2RAD(0.0f) } + }; ALuint num_channels = 0; ALboolean DirectChannels; ALboolean isbformat = AL_FALSE; @@ -373,6 +374,10 @@ ALvoid CalcNonAttnSourceParams(ALvoice *voice, const ALsource *ALSource, const A Relative = ALSource->HeadRelative; DirectChannels = ALSource->DirectChannels; + /* Convert counter-clockwise to clockwise. */ + StereoMap[0].angle = -ALSource->StereoPan[0]; + StereoMap[1].angle = -ALSource->StereoPan[1]; + voice->Direct.OutBuffer = Device->Dry.Buffer; voice->Direct.OutChannels = Device->Dry.NumChannels; for(i = 0;i < NumSends;i++) diff --git a/OpenAL32/Include/alSource.h b/OpenAL32/Include/alSource.h index bf589e8d..b7c08fcd 100644 --- a/OpenAL32/Include/alSource.h +++ b/OpenAL32/Include/alSource.h @@ -76,6 +76,11 @@ typedef struct ALsource { volatile ALfloat RoomRolloffFactor; volatile ALfloat DopplerFactor; + /* NOTE: Stereo pan angles are specified in radians, counter-clockwise + * rather than clockwise. + */ + volatile ALfloat StereoPan[2]; + volatile ALfloat Radius; /** diff --git a/OpenAL32/alSource.c b/OpenAL32/alSource.c index 250c9d1e..d7b68185 100644 --- a/OpenAL32/alSource.c +++ b/OpenAL32/alSource.c @@ -104,6 +104,9 @@ typedef enum SourceProp { srcSampleOffsetLatencySOFT = AL_SAMPLE_OFFSET_LATENCY_SOFT, srcSecOffsetLatencySOFT = AL_SEC_OFFSET_LATENCY_SOFT, + /* AL_EXT_STEREO_ANGLES */ + srcAngles = AL_STEREO_ANGLES, + /* AL_EXT_BFORMAT */ srcOrientation = AL_ORIENTATION, } SourceProp; @@ -157,6 +160,7 @@ static ALint FloatValsByProp(ALenum prop) case AL_SAMPLE_RW_OFFSETS_SOFT: case AL_BYTE_RW_OFFSETS_SOFT: + case AL_STEREO_ANGLES: return 2; case AL_POSITION: @@ -221,6 +225,7 @@ static ALint DoubleValsByProp(ALenum prop) case AL_SAMPLE_RW_OFFSETS_SOFT: case AL_BYTE_RW_OFFSETS_SOFT: case AL_SEC_OFFSET_LATENCY_SOFT: + case AL_STEREO_ANGLES: return 2; case AL_POSITION: @@ -299,6 +304,8 @@ static ALint IntValsByProp(ALenum prop) break; /* i64 only */ case AL_SEC_OFFSET_LATENCY_SOFT: break; /* Double only */ + case AL_STEREO_ANGLES: + break; /* Float/double only */ } return 0; } @@ -359,6 +366,8 @@ static ALint Int64ValsByProp(ALenum prop) case AL_SEC_OFFSET_LATENCY_SOFT: break; /* Double only */ + case AL_STEREO_ANGLES: + break; /* Float/double only */ } return 0; } @@ -507,6 +516,17 @@ static ALboolean SetSourcefv(ALsource *Source, ALCcontext *Context, SourceProp p return AL_TRUE; + case AL_STEREO_ANGLES: + CHECKVAL(isfinite(values[0]) && isfinite(values[1])); + + LockContext(Context); + Source->StereoPan[0] = values[0]; + Source->StereoPan[1] = values[1]; + UnlockContext(Context); + ATOMIC_STORE(&Source->NeedsUpdate, AL_TRUE); + return AL_TRUE; + + case AL_POSITION: CHECKVAL(isfinite(values[0]) && isfinite(values[1]) && isfinite(values[2])); @@ -830,6 +850,7 @@ static ALboolean SetSourceiv(ALsource *Source, ALCcontext *Context, SourceProp p case AL_SAMPLE_OFFSET_LATENCY_SOFT: case AL_SEC_OFFSET_LATENCY_SOFT: + case AL_STEREO_ANGLES: break; } @@ -931,6 +952,7 @@ static ALboolean SetSourcei64v(ALsource *Source, ALCcontext *Context, SourceProp return SetSourcefv(Source, Context, (int)prop, fvals); case AL_SEC_OFFSET_LATENCY_SOFT: + case AL_STEREO_ANGLES: break; } @@ -1054,6 +1076,13 @@ static ALboolean GetSourcedv(ALsource *Source, ALCcontext *Context, SourceProp p UnlockContext(Context); return AL_TRUE; + case AL_STEREO_ANGLES: + LockContext(Context); + values[0] = Source->StereoPan[0]; + values[1] = Source->StereoPan[1]; + UnlockContext(Context); + return AL_TRUE; + case AL_POSITION: LockContext(Context); values[0] = Source->Position.v[0]; @@ -1325,6 +1354,8 @@ static ALboolean GetSourceiv(ALsource *Source, ALCcontext *Context, SourceProp p break; /* i64 only */ case AL_SEC_OFFSET_LATENCY_SOFT: break; /* Double only */ + case AL_STEREO_ANGLES: + break; /* Float/double only */ case AL_DIRECT_FILTER: case AL_AUXILIARY_SEND_FILTER: @@ -1446,6 +1477,8 @@ static ALboolean GetSourcei64v(ALsource *Source, ALCcontext *Context, SourceProp case AL_SEC_OFFSET_LATENCY_SOFT: break; /* Double only */ + case AL_STEREO_ANGLES: + break; /* Float/double only */ } ERR("Unexpected property: 0x%04x\n", prop); @@ -2530,6 +2563,9 @@ static ALvoid InitSourceParams(ALsource *Source) Source->DopplerFactor = 1.0f; Source->DirectChannels = AL_FALSE; + Source->StereoPan[0] = DEG2RAD( 30.0f); + Source->StereoPan[1] = DEG2RAD(-30.0f); + Source->Radius = 0.0f; Source->DistanceModel = DefaultDistanceModel; |