Skip to content

Commit

Permalink
- Added orxSoundPointer_SetPanning(), orxObject_SetPanning() & comman…
Browse files Browse the repository at this point in the history
…d Object.SetPanning
  • Loading branch information
iarwain committed Mar 5, 2022
1 parent 3e408d3 commit 69397de
Show file tree
Hide file tree
Showing 4 changed files with 112 additions and 0 deletions.
8 changes: 8 additions & 0 deletions code/include/object/orxObject.h
Original file line number Diff line number Diff line change
Expand Up @@ -912,6 +912,14 @@ extern orxDLLAPI orxSTATUS orxFASTCALL orxObject_SetVolume(orxOBJECT *_pstO
*/
extern orxDLLAPI orxSTATUS orxFASTCALL orxObject_SetPitch(orxOBJECT *_pstObject, orxFLOAT _fPitch);

/** Sets panning of all sounds of an object.
* @param[in] _pstObject Concerned object
* @param[in] _fPanning Sound panning, -1.0f for full left, 0.0f for center, 1.0f for full right
* @param[in] _bMix Left/Right channels will be mixed if orxTRUE or act like a balance otherwise
* @return orxSTATUS_SUCCESS / orxSTATUS_FAILURE
*/
extern orxDLLAPI orxSTATUS orxFASTCALL orxObject_SetPanning(orxOBJECT *_pstObject, orxFLOAT _fPanning, orxBOOL _bMix);

/** Plays all the sounds of an object.
* @param[in] _pstObject Concerned object
* @return orxSTATUS_SUCCESS / orxSTATUS_FAILURE
Expand Down
8 changes: 8 additions & 0 deletions code/include/sound/orxSoundPointer.h
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,14 @@ extern orxDLLAPI orxSTATUS orxFASTCALL orxSoundPointer_SetVolume(orxSOU
*/
extern orxDLLAPI orxSTATUS orxFASTCALL orxSoundPointer_SetPitch(orxSOUNDPOINTER *_pstSoundPointer, orxFLOAT _fPitch);

/** Sets panning of all related sounds
* @param[in] _pstSoundPointer Concerned SoundPointer
* @param[in] _fPanning Sound panning, -1.0f for full left, 0.0f for center, 1.0f for full right
* @param[in] _bMix Left/Right channels will be mixed if orxTRUE or act like a balance otherwise
* @return orxSTATUS_SUCCESS / orxSTATUS_FAILURE
*/
extern orxDLLAPI orxSTATUS orxFASTCALL orxSoundPointer_SetPanning(orxSOUNDPOINTER *_pstSoundPointer, orxFLOAT _fPanning, orxBOOL _bMix);


/** Plays all related sounds
* @param[in] _pstSoundPointer Concerned SoundPointer
Expand Down
61 changes: 61 additions & 0 deletions code/src/object/orxObject.c
Original file line number Diff line number Diff line change
Expand Up @@ -3027,6 +3027,34 @@ void orxFASTCALL orxObject_CommandSetPitch(orxU32 _u32ArgNumber, const orxCOMMAN
return;
}

/** Command: SetPanning
*/
void orxFASTCALL orxObject_CommandSetPanning(orxU32 _u32ArgNumber, const orxCOMMAND_VAR *_astArgList, orxCOMMAND_VAR *_pstResult)
{
orxOBJECT *pstObject;

/* Gets object */
pstObject = orxOBJECT(orxStructure_Get(_astArgList[0].u64Value));

/* Valid? */
if(pstObject != orxNULL)
{
/* Sets its panning */
orxObject_SetPanning(pstObject, _astArgList[1].fValue, (_u32ArgNumber > 2) ? _astArgList[2].bValue : orxFALSE);

/* Updates result */
_pstResult->u64Value = _astArgList[0].u64Value;
}
else
{
/* Updates result */
_pstResult->u64Value = orxU64_UNDEFINED;
}

/* Done! */
return;
}

/** Command: AddFilter
*/
void orxFASTCALL orxObject_CommandAddFilter(orxU32 _u32ArgNumber, const orxCOMMAND_VAR *_astArgList, orxCOMMAND_VAR *_pstResult)
Expand Down Expand Up @@ -3621,6 +3649,8 @@ static orxINLINE void orxObject_RegisterCommands()
orxCOMMAND_REGISTER_CORE_COMMAND(Object, SetVolume, "Object", orxCOMMAND_VAR_TYPE_U64, 2, 0, {"Object", orxCOMMAND_VAR_TYPE_U64}, {"Volume", orxCOMMAND_VAR_TYPE_FLOAT});
/* Command: SetPitch */
orxCOMMAND_REGISTER_CORE_COMMAND(Object, SetPitch, "Object", orxCOMMAND_VAR_TYPE_U64, 2, 0, {"Object", orxCOMMAND_VAR_TYPE_U64}, {"Pitch", orxCOMMAND_VAR_TYPE_FLOAT});
/* Command: SetPanning */
orxCOMMAND_REGISTER_CORE_COMMAND(Object, SetPanning, "Object", orxCOMMAND_VAR_TYPE_U64, 2, 1, {"Object", orxCOMMAND_VAR_TYPE_U64}, {"Panning", orxCOMMAND_VAR_TYPE_FLOAT}, {"Mix = false", orxCOMMAND_VAR_TYPE_BOOL});

/* Command: AddFilter */
orxCOMMAND_REGISTER_CORE_COMMAND(Object, AddFilter, "Object", orxCOMMAND_VAR_TYPE_U64, 2, 0, {"Object", orxCOMMAND_VAR_TYPE_U64}, {"Sound", orxCOMMAND_VAR_TYPE_STRING});
Expand Down Expand Up @@ -3845,6 +3875,8 @@ static orxINLINE void orxObject_UnregisterCommands()
orxCOMMAND_UNREGISTER_CORE_COMMAND(Object, SetVolume);
/* Command: SetPitch */
orxCOMMAND_UNREGISTER_CORE_COMMAND(Object, SetPitch);
/* Command: SetPanning */
orxCOMMAND_UNREGISTER_CORE_COMMAND(Object, SetPanning);

/* Command: SetAnim */
orxCOMMAND_UNREGISTER_CORE_COMMAND(Object, SetAnim);
Expand Down Expand Up @@ -9922,6 +9954,35 @@ orxSTATUS orxFASTCALL orxObject_SetPitch(orxOBJECT *_pstObject, orxFLOAT _fPitch
return eResult;
}

/** Sets panning of all sounds of an object.
* @param[in] _pstObject Concerned object
* @param[in] _fPanning Sound panning, -1.0f for full left, 0.0f for center, 1.0f for full right
* @param[in] _bMix Left/Right channels will be mixed if orxTRUE or act like a balance otherwise
* @return orxSTATUS_SUCCESS / orxSTATUS_FAILURE
*/
orxSTATUS orxFASTCALL orxObject_SetPanning(orxOBJECT *_pstObject, orxFLOAT _fPanning, orxBOOL _bMix)
{
orxSOUNDPOINTER *pstSoundPointer;
orxSTATUS eResult = orxSTATUS_FAILURE;

/* Checks */
orxASSERT(sstObject.u32Flags & orxOBJECT_KU32_STATIC_FLAG_READY);
orxSTRUCTURE_ASSERT(_pstObject);

/* Gets its SoundPointer */
pstSoundPointer = orxOBJECT_GET_STRUCTURE(_pstObject, SOUNDPOINTER);

/* Valid? */
if(pstSoundPointer != orxNULL)
{
/* Set panning to all sounds */
eResult = orxSoundPointer_SetPanning(pstSoundPointer, _fPanning, _bMix);
}

/* Done! */
return eResult;
}

/** Plays all the sounds of an object.
* @param[in] _pstObject Concerned object
* @return orxSTATUS_SUCCESS / orxSTATUS_FAILURE
Expand Down
35 changes: 35 additions & 0 deletions code/src/sound/orxSoundPointer.c
Original file line number Diff line number Diff line change
Expand Up @@ -597,6 +597,41 @@ orxSTATUS orxFASTCALL orxSoundPointer_SetPitch(orxSOUNDPOINTER *_pstSoundPointer
return eResult;
}

/** Sets panning of all related sounds
* @param[in] _pstSoundPointer Concerned SoundPointer
* @param[in] _fPanning Sound panning, -1.0f for full left, 0.0f for center, 1.0f for full right
* @param[in] _bMix Left/Right channels will be mixed if orxTRUE or act like a balance otherwise
* @return orxSTATUS_SUCCESS / orxSTATUS_FAILURE
*/
orxSTATUS orxFASTCALL orxSoundPointer_SetPanning(orxSOUNDPOINTER *_pstSoundPointer, orxFLOAT _fPanning, orxBOOL _bMix)
{
orxU32 i;
orxSTATUS eResult = orxSTATUS_SUCCESS;

/* Checks */
orxASSERT(sstSoundPointer.u32Flags & orxSOUNDPOINTER_KU32_STATIC_FLAG_READY);
orxSTRUCTURE_ASSERT(_pstSoundPointer);

/* For all sounds */
for(i = 0; i < orxSOUNDPOINTER_KU32_SOUND_NUMBER; i++)
{
orxSOUND *pstSound;

/* Gets it */
pstSound = _pstSoundPointer->astSoundList[i].pstSound;

/* Valid? */
if(pstSound != orxNULL)
{
/* Sets its panning */
orxSound_SetPanning(pstSound, _fPanning, _bMix);
}
}

/* Done! */
return eResult;
}

/** Plays all related sounds
* @param[in] _pstSoundPointer Concerned SoundPointer
* @return orxSTATUS_SUCCESS / orxSTATUS_FAILURE
Expand Down

0 comments on commit 69397de

Please sign in to comment.