mirror of
https://github.com/ddnet/ddnet.git
synced 2024-11-10 10:08: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)
|
||||
{
|
||||
// panning
|
||||
if(dx > 0)
|
||||
Lvol = ((RangeX-p)*Lvol)/RangeX;
|
||||
else
|
||||
Rvol = ((RangeX-p)*Rvol)/RangeX;
|
||||
if(!(v->m_Flags&ISound::FLAG_NO_PANNING))
|
||||
{
|
||||
if(dx > 0)
|
||||
Lvol = ((RangeX-p)*Lvol)/RangeX;
|
||||
else
|
||||
Rvol = ((RangeX-p)*Rvol)/RangeX;
|
||||
}
|
||||
|
||||
{
|
||||
Lvol *= FalloffX;
|
||||
|
|
|
@ -11,9 +11,10 @@ class ISound : public IInterface
|
|||
public:
|
||||
enum
|
||||
{
|
||||
FLAG_LOOP=1,
|
||||
FLAG_POS=2,
|
||||
FLAG_ALL=3
|
||||
FLAG_LOOP=1<<0,
|
||||
FLAG_POS=1<<1,
|
||||
FLAG_NO_PANNING=1<<2,
|
||||
FLAG_ALL=FLAG_LOOP|FLAG_POS|FLAG_NO_PANNING,
|
||||
};
|
||||
|
||||
enum
|
||||
|
|
|
@ -120,6 +120,7 @@ void CMapSounds::OnRender()
|
|||
// need to enqueue
|
||||
int Flags = 0;
|
||||
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);
|
||||
Sound()->SetVoiceTimeOffset(pSource->m_Voice, offset);
|
||||
|
|
|
@ -1230,7 +1230,7 @@ void CEditor::DoSoundSource(CSoundSource *pSource, int Index)
|
|||
m_Map.m_UndoModified++;
|
||||
|
||||
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;
|
||||
s_Operation = OP_NONE;
|
||||
UI()->SetActiveItem(0);
|
||||
|
|
|
@ -109,6 +109,7 @@ CSoundSource *CLayerSounds::NewSource()
|
|||
pSource->m_Position.y = 0;
|
||||
|
||||
pSource->m_Loop = 1;
|
||||
pSource->m_Pan = 1;
|
||||
pSource->m_TimeDelay = 0;
|
||||
|
||||
pSource->m_PosEnv = -1;
|
||||
|
@ -116,15 +117,16 @@ CSoundSource *CLayerSounds::NewSource()
|
|||
pSource->m_SoundEnv = -1;
|
||||
pSource->m_SoundEnvOffset = 0;
|
||||
|
||||
pSource->m_Falloff = 255;
|
||||
/*
|
||||
pSource->m_Falloff = 80;
|
||||
|
||||
pSource->m_Shape.m_Type = CSoundShape::SHAPE_CIRCLE;
|
||||
pSource->m_Shape.m_Circle.m_Radius = 1500;
|
||||
*/
|
||||
|
||||
/*
|
||||
pSource->m_Shape.m_Type = CSoundShape::SHAPE_RECTANGLE;
|
||||
pSource->m_Shape.m_Rectangle.m_Width = f2fx(1500.0f);
|
||||
pSource->m_Shape.m_Rectangle.m_Height = f2fx(1000.0f);
|
||||
*/
|
||||
|
||||
return pSource;
|
||||
}
|
||||
|
|
|
@ -664,6 +664,7 @@ int CEditor::PopupSource(CEditor *pEditor, CUIRect View)
|
|||
PROP_POS_X=0,
|
||||
PROP_POS_Y,
|
||||
PROP_LOOP,
|
||||
PROP_PAN,
|
||||
PROP_TIME_DELAY,
|
||||
PROP_FALLOFF,
|
||||
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 Y", pSource->m_Position.y/1000, PROPTYPE_INT_SCROLL, -1000000, 1000000},
|
||||
{"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},
|
||||
{"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},
|
||||
|
@ -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_Y) pSource->m_Position.y = NewVal*1000;
|
||||
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_FALLOFF) pSource->m_Falloff = NewVal;
|
||||
if(Prop == PROP_POS_ENV)
|
||||
|
|
|
@ -362,6 +362,7 @@ struct CSoundSource
|
|||
{
|
||||
CPoint m_Position;
|
||||
int m_Loop;
|
||||
int m_Pan; // 0 - no panning, 1 - panning
|
||||
int m_TimeDelay; // in s
|
||||
int m_Falloff; // [0,255] // 0 - No falloff, 255 - full
|
||||
|
||||
|
|
Loading…
Reference in a new issue