mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-14 03:58:18 +00:00
Merge pull request #111 from cinaera/pr_pan
Add option to enable/disable panning per voice
This commit is contained in:
commit
598c6c9968
|
@ -206,10 +206,13 @@ static void Mix(short *pFinalOut, unsigned Frames)
|
||||||
if(InVoiceField)
|
if(InVoiceField)
|
||||||
{
|
{
|
||||||
// panning
|
// panning
|
||||||
|
if(!(v->m_Flags&ISound::FLAG_NO_PANNING))
|
||||||
|
{
|
||||||
if(dx > 0)
|
if(dx > 0)
|
||||||
Lvol = ((RangeX-p)*Lvol)/RangeX;
|
Lvol = ((RangeX-p)*Lvol)/RangeX;
|
||||||
else
|
else
|
||||||
Rvol = ((RangeX-p)*Rvol)/RangeX;
|
Rvol = ((RangeX-p)*Rvol)/RangeX;
|
||||||
|
}
|
||||||
|
|
||||||
{
|
{
|
||||||
Lvol *= FalloffX;
|
Lvol *= FalloffX;
|
||||||
|
|
|
@ -11,9 +11,10 @@ class ISound : public IInterface
|
||||||
public:
|
public:
|
||||||
enum
|
enum
|
||||||
{
|
{
|
||||||
FLAG_LOOP=1,
|
FLAG_LOOP=1<<0,
|
||||||
FLAG_POS=2,
|
FLAG_POS=1<<1,
|
||||||
FLAG_ALL=3
|
FLAG_NO_PANNING=1<<2,
|
||||||
|
FLAG_ALL=FLAG_LOOP|FLAG_POS|FLAG_NO_PANNING,
|
||||||
};
|
};
|
||||||
|
|
||||||
enum
|
enum
|
||||||
|
|
|
@ -120,6 +120,7 @@ void CMapSounds::OnRender()
|
||||||
// need to enqueue
|
// need to enqueue
|
||||||
int Flags = 0;
|
int Flags = 0;
|
||||||
if(pSource->m_pSource->m_Loop) Flags |= ISound::FLAG_LOOP;
|
if(pSource->m_pSource->m_Loop) Flags |= ISound::FLAG_LOOP;
|
||||||
|
if(!pSource->m_pSource->m_Pan) Flags |= ISound::FLAG_NO_PANNING;
|
||||||
|
|
||||||
pSource->m_Voice = m_pClient->m_pSounds->PlaySampleAt(CSounds::CHN_MAPSOUND, m_aSounds[pSource->m_Sound], 1.0f, vec2(fx2f(pSource->m_pSource->m_Position.x), fx2f(pSource->m_pSource->m_Position.y)), Flags);
|
pSource->m_Voice = m_pClient->m_pSounds->PlaySampleAt(CSounds::CHN_MAPSOUND, m_aSounds[pSource->m_Sound], 1.0f, vec2(fx2f(pSource->m_pSource->m_Position.x), fx2f(pSource->m_pSource->m_Position.y)), Flags);
|
||||||
Sound()->SetVoiceTimeOffset(pSource->m_Voice, offset);
|
Sound()->SetVoiceTimeOffset(pSource->m_Voice, offset);
|
||||||
|
|
|
@ -1230,7 +1230,7 @@ void CEditor::DoSoundSource(CSoundSource *pSource, int Index)
|
||||||
m_Map.m_UndoModified++;
|
m_Map.m_UndoModified++;
|
||||||
|
|
||||||
static int s_SourcePopupID = 0;
|
static int s_SourcePopupID = 0;
|
||||||
UiInvokePopupMenu(&s_SourcePopupID, 0, UI()->MouseX(), UI()->MouseY(), 120, 180, PopupSource);
|
UiInvokePopupMenu(&s_SourcePopupID, 0, UI()->MouseX(), UI()->MouseY(), 120, 200, PopupSource);
|
||||||
m_LockMouse = false;
|
m_LockMouse = false;
|
||||||
s_Operation = OP_NONE;
|
s_Operation = OP_NONE;
|
||||||
UI()->SetActiveItem(0);
|
UI()->SetActiveItem(0);
|
||||||
|
|
|
@ -109,6 +109,7 @@ CSoundSource *CLayerSounds::NewSource()
|
||||||
pSource->m_Position.y = 0;
|
pSource->m_Position.y = 0;
|
||||||
|
|
||||||
pSource->m_Loop = 1;
|
pSource->m_Loop = 1;
|
||||||
|
pSource->m_Pan = 1;
|
||||||
pSource->m_TimeDelay = 0;
|
pSource->m_TimeDelay = 0;
|
||||||
|
|
||||||
pSource->m_PosEnv = -1;
|
pSource->m_PosEnv = -1;
|
||||||
|
@ -116,15 +117,16 @@ CSoundSource *CLayerSounds::NewSource()
|
||||||
pSource->m_SoundEnv = -1;
|
pSource->m_SoundEnv = -1;
|
||||||
pSource->m_SoundEnvOffset = 0;
|
pSource->m_SoundEnvOffset = 0;
|
||||||
|
|
||||||
pSource->m_Falloff = 255;
|
pSource->m_Falloff = 80;
|
||||||
/*
|
|
||||||
pSource->m_Shape.m_Type = CSoundShape::SHAPE_CIRCLE;
|
pSource->m_Shape.m_Type = CSoundShape::SHAPE_CIRCLE;
|
||||||
pSource->m_Shape.m_Circle.m_Radius = 1500;
|
pSource->m_Shape.m_Circle.m_Radius = 1500;
|
||||||
*/
|
|
||||||
|
|
||||||
|
/*
|
||||||
pSource->m_Shape.m_Type = CSoundShape::SHAPE_RECTANGLE;
|
pSource->m_Shape.m_Type = CSoundShape::SHAPE_RECTANGLE;
|
||||||
pSource->m_Shape.m_Rectangle.m_Width = f2fx(1500.0f);
|
pSource->m_Shape.m_Rectangle.m_Width = f2fx(1500.0f);
|
||||||
pSource->m_Shape.m_Rectangle.m_Height = f2fx(1000.0f);
|
pSource->m_Shape.m_Rectangle.m_Height = f2fx(1000.0f);
|
||||||
|
*/
|
||||||
|
|
||||||
return pSource;
|
return pSource;
|
||||||
}
|
}
|
||||||
|
|
|
@ -664,6 +664,7 @@ int CEditor::PopupSource(CEditor *pEditor, CUIRect View)
|
||||||
PROP_POS_X=0,
|
PROP_POS_X=0,
|
||||||
PROP_POS_Y,
|
PROP_POS_Y,
|
||||||
PROP_LOOP,
|
PROP_LOOP,
|
||||||
|
PROP_PAN,
|
||||||
PROP_TIME_DELAY,
|
PROP_TIME_DELAY,
|
||||||
PROP_FALLOFF,
|
PROP_FALLOFF,
|
||||||
PROP_POS_ENV,
|
PROP_POS_ENV,
|
||||||
|
@ -677,6 +678,7 @@ int CEditor::PopupSource(CEditor *pEditor, CUIRect View)
|
||||||
{"Pos X", pSource->m_Position.x/1000, PROPTYPE_INT_SCROLL, -1000000, 1000000},
|
{"Pos X", pSource->m_Position.x/1000, PROPTYPE_INT_SCROLL, -1000000, 1000000},
|
||||||
{"Pos Y", pSource->m_Position.y/1000, PROPTYPE_INT_SCROLL, -1000000, 1000000},
|
{"Pos Y", pSource->m_Position.y/1000, PROPTYPE_INT_SCROLL, -1000000, 1000000},
|
||||||
{"Loop", pSource->m_Loop, PROPTYPE_BOOL, 0, 1},
|
{"Loop", pSource->m_Loop, PROPTYPE_BOOL, 0, 1},
|
||||||
|
{"Pan", pSource->m_Pan, PROPTYPE_BOOL, 0, 1},
|
||||||
{"Delay", pSource->m_TimeDelay, PROPTYPE_INT_SCROLL, 0, 1000000},
|
{"Delay", pSource->m_TimeDelay, PROPTYPE_INT_SCROLL, 0, 1000000},
|
||||||
{"Falloff", pSource->m_Falloff, PROPTYPE_INT_SCROLL, 0, 255},
|
{"Falloff", pSource->m_Falloff, PROPTYPE_INT_SCROLL, 0, 255},
|
||||||
{"Pos. Env", pSource->m_PosEnv+1, PROPTYPE_INT_STEP, 0, pEditor->m_Map.m_lEnvelopes.size()+1},
|
{"Pos. Env", pSource->m_PosEnv+1, PROPTYPE_INT_STEP, 0, pEditor->m_Map.m_lEnvelopes.size()+1},
|
||||||
|
@ -698,6 +700,7 @@ int CEditor::PopupSource(CEditor *pEditor, CUIRect View)
|
||||||
if(Prop == PROP_POS_X) pSource->m_Position.x = NewVal*1000;
|
if(Prop == PROP_POS_X) pSource->m_Position.x = NewVal*1000;
|
||||||
if(Prop == PROP_POS_Y) pSource->m_Position.y = NewVal*1000;
|
if(Prop == PROP_POS_Y) pSource->m_Position.y = NewVal*1000;
|
||||||
if(Prop == PROP_LOOP) pSource->m_Loop = NewVal;
|
if(Prop == PROP_LOOP) pSource->m_Loop = NewVal;
|
||||||
|
if(Prop == PROP_PAN) pSource->m_Pan = NewVal;
|
||||||
if(Prop == PROP_TIME_DELAY) pSource->m_TimeDelay = NewVal;
|
if(Prop == PROP_TIME_DELAY) pSource->m_TimeDelay = NewVal;
|
||||||
if(Prop == PROP_FALLOFF) pSource->m_Falloff = NewVal;
|
if(Prop == PROP_FALLOFF) pSource->m_Falloff = NewVal;
|
||||||
if(Prop == PROP_POS_ENV)
|
if(Prop == PROP_POS_ENV)
|
||||||
|
|
|
@ -362,6 +362,7 @@ struct CSoundSource
|
||||||
{
|
{
|
||||||
CPoint m_Position;
|
CPoint m_Position;
|
||||||
int m_Loop;
|
int m_Loop;
|
||||||
|
int m_Pan; // 0 - no panning, 1 - panning
|
||||||
int m_TimeDelay; // in s
|
int m_TimeDelay; // in s
|
||||||
int m_Falloff; // [0,255] // 0 - No falloff, 255 - full
|
int m_Falloff; // [0,255] // 0 - No falloff, 255 - full
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue