Skip to content

Commit 0aae6b6

Browse files
committed
Introduce soloFeature to binauraliser
1 parent 70e87cf commit 0aae6b6

File tree

3 files changed

+49
-2
lines changed

3 files changed

+49
-2
lines changed

examples/include/binauraliser.h

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,20 @@ void binauraliser_setRPYflag(void* const hBin, int newState);
214214
/** NOT IMPLEMENTED YET */
215215
void binauraliser_setInterpMode(void* const hBin, int newMode);
216216

217+
/**
218+
* Sets gain factor for an input source.
219+
*/
220+
void binauraliser_setSourceGain(void* const hBin, int srcIdx, float newGain);
221+
222+
/**
223+
* Set a source to solo.
224+
*/
225+
void binauraliser_setSourceSolo(void* const hBin, int srcIdx);
226+
227+
/**
228+
* Unsolo / unmute all sources.
229+
*/
230+
void binauraliser_setUnSolo(void* const hBin);
217231

218232

219233
/* ========================================================================== */

examples/src/binauraliser/binauraliser.c

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,8 +87,10 @@ void binauraliser_create
8787
pData->codecStatus = CODEC_STATUS_NOT_INITIALISED;
8888
pData->procStatus = PROC_STATUS_NOT_ONGOING;
8989
pData->reInitHRTFsAndGainTables = 1;
90-
for(ch=0; ch<MAX_NUM_INPUTS; ch++)
90+
for(ch=0; ch<MAX_NUM_INPUTS; ch++) {
9191
pData->recalc_hrtf_interpFLAG[ch] = 1;
92+
pData->src_gains[ch] = 1.f;
93+
}
9294
pData->recalc_M_rotFLAG = 1;
9395
}
9496

@@ -214,6 +216,12 @@ void binauraliser_process
214216
for(; i<nSources; i++)
215217
memset(pData->inputFrameTD[i], 0, BINAURALISER_FRAME_SIZE * sizeof(float));
216218

219+
/* Apply source gains */
220+
for (ch = 0; ch < nSources; ch++) {
221+
if(fabsf(pData->src_gains[ch] - 1.f) > 1e-6f)
222+
utility_svsmul(pData->inputFrameTD[ch], &(pData->src_gains[ch]), BINAURALISER_FRAME_SIZE, NULL);
223+
}
224+
217225
/* Apply time-frequency transform (TFT) */
218226
afSTFT_forward_knownDimensions(pData->hSTFT, pData->inputFrameTD, BINAURALISER_FRAME_SIZE, MAX_NUM_INPUTS, TIME_SLOTS, pData->inputframeTF);
219227

@@ -435,6 +443,30 @@ void binauraliser_setInterpMode(void* const hBin, int newMode)
435443
pData->recalc_hrtf_interpFLAG[ch] = 1;
436444
}
437445

446+
void binauraliser_setSourceGain(void* const hAmbi, int srcIdx, float newGain)
447+
{
448+
binauraliser_data *pData = (binauraliser_data*)(hAmbi);
449+
pData->src_gains[srcIdx] = newGain;
450+
}
451+
452+
void binauraliser_setSourceSolo(void* const hAmbi, int srcIdx)
453+
{
454+
binauraliser_data *pData = (binauraliser_data*)(hAmbi);
455+
int i;
456+
for(i=0; i<pData->nSources; i++){
457+
if(i==srcIdx)
458+
pData->src_gains[i] = 1.f;
459+
else
460+
pData->src_gains[i] = 0.f;
461+
}
462+
}
463+
464+
void binauraliser_setUnSolo(void* const hAmbi)
465+
{
466+
binauraliser_data *pData = (binauraliser_data*)(hAmbi);
467+
for(int i=0; i<pData->nSources; i++)
468+
pData->src_gains[i] = 1.f;
469+
}
438470

439471

440472
/* Get Functions */

examples/src/binauraliser/binauraliser_internal.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,8 @@ typedef struct _binauraliser
132132
int bFlipPitch; /**< flag to flip the sign of the pitch rotation angle */
133133
int bFlipRoll; /**< flag to flip the sign of the roll rotation angle */
134134
int useRollPitchYawFlag; /**< rotation order flag, 1: r-p-y, 0: y-p-r */
135-
135+
float src_gains[MAX_NUM_INPUTS]; /**< Gains applied per source */
136+
136137
} binauraliser_data;
137138

138139

0 commit comments

Comments
 (0)