Skip to content

Commit 4d763cf

Browse files
Merge pull request #76 from charlesneimog/fix-75
fix #75
2 parents ad66336 + 72c8652 commit 4d763cf

File tree

9 files changed

+72
-37
lines changed

9 files changed

+72
-37
lines changed

examples/src/ambi_bin/ambi_bin.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -314,7 +314,8 @@ void ambi_bin_initCodec
314314
pData->progressBar0_1 = 0.95f;
315315
float_complex* decMtx;
316316
decMtx = calloc1d(HYBRID_BANDS*NUM_EARS*nSH, sizeof(float_complex));
317-
switch(pData->method){
317+
AMBI_BIN_DECODING_METHODS method = pData->method;
318+
switch(method){
318319
default:
319320
case DECODING_METHOD_LS:
320321
getBinauralAmbiDecoderMtx(pars->hrtf_fb, pars->hrir_dirs_deg, pars->N_hrir_dirs, HYBRID_BANDS,

examples/src/ambi_dec/ambi_dec.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,8 @@ void ambi_dec_initCodec
274274
/* calculate loudspeaker decoding matrices */
275275
for( d=0; d<NUM_DECODERS; d++){
276276
M_dec_tmp = malloc1d(nLoudspeakers * max_nSH * sizeof(float));
277-
switch(pData->dec_method[d]){
277+
AMBI_DEC_DECODING_METHODS dec_method = pData->dec_method[d];
278+
switch(dec_method){
278279
case DECODING_METHOD_SAD:
279280
getLoudspeakerDecoderMtx((float*)loudpkrs_dirs_deg_local, nLoudspeakers, LOUDSPEAKER_DECODER_SAD, masterOrder, 0, M_dec_tmp);
280281
break;

examples/src/array2sh/array2sh_internal.c

Lines changed: 38 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -268,9 +268,11 @@ void array2sh_calculate_sht_matrix
268268
/* Compute modal responses */
269269
free(pData->bN);
270270
pData->bN = malloc1d((HYBRID_BANDS)*(order+1)*sizeof(double_complex));
271-
switch(arraySpecs->arrayType){
272-
case ARRAY_CYLINDRICAL:
273-
switch (arraySpecs->weightType){
271+
ARRAY2SH_ARRAY_TYPES arrayType = arraySpecs->arrayType;
272+
switch(arrayType){
273+
case ARRAY_CYLINDRICAL: {
274+
ARRAY2SH_WEIGHT_TYPES weightType = arraySpecs->weightType;
275+
switch (weightType){
274276
case WEIGHT_RIGID_OMNI: cylModalCoeffs(order, kr, HYBRID_BANDS, ARRAY_CONSTRUCTION_RIGID, pData->bN); break;
275277
case WEIGHT_RIGID_CARD: saf_print_error("weightType is not supported"); break;
276278
case WEIGHT_RIGID_DIPOLE: saf_print_error("weightType is not supported"); break;
@@ -279,8 +281,10 @@ void array2sh_calculate_sht_matrix
279281
case WEIGHT_OPEN_DIPOLE: saf_print_error("weightType is not supported"); break;
280282
}
281283
break;
282-
case ARRAY_SPHERICAL:
283-
switch (arraySpecs->weightType){
284+
}
285+
case ARRAY_SPHERICAL: {
286+
ARRAY2SH_WEIGHT_TYPES weightType = arraySpecs->weightType;
287+
switch (weightType){
284288
case WEIGHT_OPEN_OMNI: sphModalCoeffs(order, kr, HYBRID_BANDS, ARRAY_CONSTRUCTION_OPEN, 1.0, pData->bN); break;
285289
case WEIGHT_OPEN_CARD: sphModalCoeffs(order, kr, HYBRID_BANDS, ARRAY_CONSTRUCTION_OPEN_DIRECTIONAL, 0.5, pData->bN); break;
286290
case WEIGHT_OPEN_DIPOLE: sphModalCoeffs(order, kr, HYBRID_BANDS, ARRAY_CONSTRUCTION_OPEN_DIRECTIONAL, 0.0, pData->bN); break;
@@ -303,6 +307,7 @@ void array2sh_calculate_sht_matrix
303307
break;
304308
}
305309
break;
310+
}
306311
}
307312

308313
for(band=0; band<HYBRID_BANDS; band++)
@@ -364,7 +369,8 @@ void array2sh_calculate_sht_matrix
364369
double_complex Hs[HYBRID_BANDS][MAX_SH_ORDER+1];
365370

366371
/* find suitable cut-off frequencies */
367-
switch (arraySpecs->weightType){
372+
ARRAY2SH_WEIGHT_TYPES weightType = arraySpecs->weightType;
373+
switch (weightType){
368374
case WEIGHT_OPEN_OMNI: sphArrayNoiseThreshold(order, arraySpecs->Q, arraySpecs->r, pData->c, ARRAY_CONSTRUCTION_OPEN, 1.0, pData->regPar, f_lim); break;
369375
case WEIGHT_OPEN_CARD: sphArrayNoiseThreshold(order, arraySpecs->Q, arraySpecs->r, pData->c, ARRAY_CONSTRUCTION_OPEN_DIRECTIONAL, 0.5, pData->regPar, f_lim); break;
370376
case WEIGHT_OPEN_DIPOLE: sphArrayNoiseThreshold(order, arraySpecs->Q, arraySpecs->r, pData->c, ARRAY_CONSTRUCTION_OPEN_DIRECTIONAL, 0.0, pData->regPar, f_lim); break;
@@ -398,9 +404,11 @@ void array2sh_calculate_sht_matrix
398404
/* compute inverse radial response */
399405
free(pData->bN);
400406
pData->bN = malloc1d((HYBRID_BANDS)*(order+1)*sizeof(double_complex));
401-
switch(arraySpecs->arrayType){
402-
case ARRAY_CYLINDRICAL:
403-
switch (arraySpecs->weightType){
407+
ARRAY2SH_ARRAY_TYPES arrayType = arraySpecs->arrayType;
408+
switch(arrayType){
409+
case ARRAY_CYLINDRICAL:{
410+
ARRAY2SH_WEIGHT_TYPES weightType = arraySpecs->arrayType;
411+
switch (weightType){
404412
case WEIGHT_RIGID_OMNI: cylModalCoeffs(order, kr, HYBRID_BANDS, ARRAY_CONSTRUCTION_RIGID, pData->bN); break;
405413
case WEIGHT_RIGID_CARD: /* not supported */ break;
406414
case WEIGHT_RIGID_DIPOLE: /* not supported */ break;
@@ -409,8 +417,10 @@ void array2sh_calculate_sht_matrix
409417
case WEIGHT_OPEN_DIPOLE: /* not supported */ break;
410418
}
411419
break;
412-
case ARRAY_SPHERICAL:
413-
switch (arraySpecs->weightType){
420+
}
421+
case ARRAY_SPHERICAL:{
422+
ARRAY2SH_WEIGHT_TYPES weightType = arraySpecs->arrayType;
423+
switch (weightType){
414424
case WEIGHT_OPEN_OMNI: sphModalCoeffs(order, kr, HYBRID_BANDS, ARRAY_CONSTRUCTION_OPEN, 1.0, pData->bN); break;
415425
case WEIGHT_OPEN_CARD: sphModalCoeffs(order, kr, HYBRID_BANDS, ARRAY_CONSTRUCTION_OPEN_DIRECTIONAL, 0.5, pData->bN); break;
416426
case WEIGHT_OPEN_DIPOLE: sphModalCoeffs(order, kr, HYBRID_BANDS, ARRAY_CONSTRUCTION_OPEN_DIRECTIONAL, 0.0, pData->bN); break;
@@ -433,6 +443,7 @@ void array2sh_calculate_sht_matrix
433443
break;
434444
}
435445
break;
446+
}
436447
}
437448

438449
/* direct inverse (only required for GUI) */
@@ -544,12 +555,14 @@ void array2sh_apply_diff_EQ(void* const hA2sh)
544555
}
545556

546557
/* Get theoretical diffuse coherence matrix */
547-
switch(arraySpecs->arrayType){
558+
ARRAY2SH_ARRAY_TYPES arrayType = arraySpecs->arrayType;
559+
switch(arrayType){
548560
case ARRAY_CYLINDRICAL:
549561
return; /* Unsupported */
550562
break;
551-
case ARRAY_SPHERICAL:
552-
switch (arraySpecs->weightType){
563+
case ARRAY_SPHERICAL:{
564+
ARRAY2SH_WEIGHT_TYPES weightType = arraySpecs->weightType;
565+
switch (weightType){
553566
case WEIGHT_RIGID_OMNI: /* Does not handle the case where kr != kR ! */
554567
sphDiffCohMtxTheory(array_order, (float*)sensorCoords_rad_local, arraySpecs->Q, ARRAY_CONSTRUCTION_RIGID, 1.0, kr, HYBRID_BANDS, dM_diffcoh);
555568
break;
@@ -570,6 +583,7 @@ void array2sh_apply_diff_EQ(void* const hA2sh)
570583
break;
571584
}
572585
break;
586+
}
573587
}
574588

575589
/* determine band index for the spatial aliasing limit */
@@ -671,9 +685,11 @@ void array2sh_evaluateSHTfilters(void* hA2sh)
671685
kR[band] = 2.0*SAF_PId*(pData->freqVector[band])*(arraySpecs->R)/pData->c;
672686
}
673687
H_array = malloc1d((HYBRID_BANDS) * (arraySpecs->Q) * 812*sizeof(float_complex));
674-
switch(arraySpecs->arrayType){
675-
case ARRAY_SPHERICAL:
676-
switch(arraySpecs->weightType){
688+
ARRAY2SH_ARRAY_TYPES arrayType = arraySpecs->arrayType;
689+
switch(arrayType){
690+
case ARRAY_SPHERICAL:{
691+
ARRAY2SH_WEIGHT_TYPES weightType = arraySpecs->weightType;
692+
switch(weightType){
677693
default:
678694
case WEIGHT_RIGID_OMNI:
679695
simulateSphArray(simOrder, kr, kR, HYBRID_BANDS, (float*)arraySpecs->sensorCoords_rad, arraySpecs->Q,
@@ -701,9 +717,10 @@ void array2sh_evaluateSHTfilters(void* hA2sh)
701717
break;
702718
}
703719
break;
704-
705-
case ARRAY_CYLINDRICAL:
706-
switch(arraySpecs->weightType){
720+
}
721+
case ARRAY_CYLINDRICAL:{
722+
ARRAY2SH_WEIGHT_TYPES weightType = arraySpecs->weightType;
723+
switch(weightType){
707724
default:
708725
case WEIGHT_RIGID_OMNI:
709726
case WEIGHT_RIGID_CARD:
@@ -717,6 +734,7 @@ void array2sh_evaluateSHTfilters(void* hA2sh)
717734
break;
718735
}
719736
break;
737+
}
720738
}
721739

722740
strcpy(pData->progressBarText,"Evaluating encoding performance");

examples/src/beamformer/beamformer.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,8 @@ void beamformer_process
141141
for(bi=0; bi<nBeams; bi++){
142142
if(pData->recalc_beamWeights[bi]){
143143
memset(pData->beamWeights[bi], 0, MAX_NUM_SH_SIGNALS*sizeof(float));
144-
switch(pData->beamType){
144+
STATIC_BEAM_TYPES beamType = pData->beamType;
145+
switch(beamType){
145146
case STATIC_BEAM_TYPE_CARDIOID: beamWeightsCardioid2Spherical(beamOrder, c_n); break;
146147
case STATIC_BEAM_TYPE_HYPERCARDIOID: beamWeightsHypercardioid2Spherical(beamOrder, c_n); break;
147148
case STATIC_BEAM_TYPE_MAX_EV: beamWeightsMaxEV(beamOrder, c_n); break;

examples/src/dirass/dirass.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -665,14 +665,16 @@ int dirass_getPmap(void* const hDir, float** grid_dirs, float** pmap, int* nDirs
665665
(*pmap) = pData->pmap_grid[pData->dispSlotIdx-1 < 0 ? NUM_DISP_SLOTS-1 : pData->dispSlotIdx-1];
666666
(*nDirs) = pars->interp_nDirs;
667667
(*pmapWidth) = pData->dispWidth;
668-
switch(pData->HFOVoption){
668+
HFOV_OPTIONS HFOVoption = pData->HFOVoption;
669+
switch(HFOVoption){
669670
default:
670671
case HFOV_360: (*hfov) = 360; break;
671672
case HFOV_180: (*hfov) = 180; break;
672673
case HFOV_90: (*hfov) = 90; break;
673674
case HFOV_60: (*hfov) = 60; break;
674675
}
675-
switch(pData->aspectRatioOption){
676+
ASPECT_RATIO_OPTIONS aspectRatioOption = pData->aspectRatioOption;
677+
switch(aspectRatioOption){
676678
default:
677679
case ASPECT_RATIO_2_1: (*aspectRatio) = 2.0f; break;
678680
case ASPECT_RATIO_16_9: (*aspectRatio) = 16.0f/9.0f; break;

examples/src/dirass/dirass_internal.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,8 @@ void dirass_initAna(void* const hDir)
6666
pData->progressBar0_1 = 0.4f;
6767

6868
/* Determine scanning grid */
69-
switch(pData->gridOption){
69+
DIRASS_GRID_OPTIONS gridOption = pData->gridOption;
70+
switch(gridOption){
7071
case T_DESIGN_3: /* 6 points */
7172
td_degree = 3;
7273
pars->grid_dirs_deg = (float*)__HANDLES_Tdesign_dirs_deg[td_degree-1];
@@ -129,14 +130,17 @@ void dirass_initAna(void* const hDir)
129130
}
130131

131132
/* generate interpolation table for current display config */
132-
switch(pData->HFOVoption){
133+
HFOV_OPTIONS HFOVoption = pData->HFOVoption;
134+
switch(HFOVoption){
133135
default:
134136
case HFOV_360: hfov = 360.0f; break;
135137
case HFOV_180: hfov = 180.0f; break;
136138
case HFOV_90: hfov = 90.0f; break;
137139
case HFOV_60: hfov = 60.0f; break;
138140
}
139-
switch(pData->aspectRatioOption){
141+
142+
ASPECT_RATIO_OPTIONS aspectRatioOption = pData->aspectRatioOption;
143+
switch(aspectRatioOption){
140144
default:
141145
case ASPECT_RATIO_2_1: aspectRatio = 2.0f; break;
142146
case ASPECT_RATIO_16_9: aspectRatio = 16.0f/9.0f; break;
@@ -174,7 +178,8 @@ void dirass_initAna(void* const hDir)
174178
A_xyz = malloc1d(nSH_order*nSH_sec*3*sizeof(float_complex));
175179
c_n = malloc1d((order_sec+1)*sizeof(float));
176180
computeVelCoeffsMtx(order_sec, A_xyz);
177-
switch(pData->beamType){
181+
STATIC_BEAM_TYPES beamType = pData->beamType;
182+
switch(beamType){
178183
case STATIC_BEAM_TYPE_CARDIOID: beamWeightsCardioid2Spherical(order_sec, c_n); break;
179184
case STATIC_BEAM_TYPE_HYPERCARDIOID: beamWeightsHypercardioid2Spherical(order_sec, c_n); break;
180185
case STATIC_BEAM_TYPE_MAX_EV: beamWeightsMaxEV(order_sec, c_n); break;
@@ -192,7 +197,7 @@ void dirass_initAna(void* const hDir)
192197

193198
/* get regular beamforming weights */
194199
c_n = malloc1d((order+1)*sizeof(float));
195-
switch(pData->beamType){
200+
switch(beamType){
196201
case STATIC_BEAM_TYPE_CARDIOID: beamWeightsCardioid2Spherical(order, c_n); break;
197202
case STATIC_BEAM_TYPE_HYPERCARDIOID: beamWeightsHypercardioid2Spherical(order, c_n); break;
198203
case STATIC_BEAM_TYPE_MAX_EV: beamWeightsMaxEV(order, c_n); break;
@@ -206,7 +211,7 @@ void dirass_initAna(void* const hDir)
206211

207212
/* beamforming weights for upscaled */
208213
c_n = malloc1d((order_up+1)*sizeof(float));
209-
switch(pData->beamType){
214+
switch(beamType){
210215
case STATIC_BEAM_TYPE_CARDIOID: beamWeightsCardioid2Spherical(order_up, c_n); break;
211216
case STATIC_BEAM_TYPE_HYPERCARDIOID: beamWeightsHypercardioid2Spherical(order_up, c_n); break;
212217
case STATIC_BEAM_TYPE_MAX_EV: beamWeightsMaxEV(order_up, c_n); break;

examples/src/pitch_shifter/pitch_shifter.c

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,9 @@ void pitch_shifter_initCodec
130130
smb_pitchShift_destroy(&(pData->hSmb));
131131

132132
/* Config */
133-
switch(pData->osamp_option){
133+
134+
PITCH_SHIFTER_OSAMP_OPTIONS osamp_option = pData->osamp_option;
135+
switch(osamp_option){
134136
default:
135137
/* fall through */
136138
case PITCH_SHIFTER_OSAMP_2: osamp = 2; break;
@@ -139,7 +141,8 @@ void pitch_shifter_initCodec
139141
case PITCH_SHIFTER_OSAMP_16: osamp = 16; break;
140142
case PITCH_SHIFTER_OSAMP_32: osamp = 32; break;
141143
}
142-
switch(pData->fftsize_option){
144+
PITCH_SHIFTER_FFTSIZE_OPTIONS fftsize_option = pData->fftsize_option;
145+
switch(fftsize_option){
143146
default:
144147
/* fall through */
145148
case PITCH_SHIFTER_FFTSIZE_512: fftSize = 512; break;

examples/src/powermap/powermap.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -728,13 +728,15 @@ int powermap_getPmap(void* const hPm, float** grid_dirs, float** pmap, int* nDir
728728
(*pmap) = pData->pmap_grid[pData->dispSlotIdx-1 < 0 ? NUM_DISP_SLOTS-1 : pData->dispSlotIdx-1];
729729
(*nDirs) = pars->interp_nDirs;
730730
(*pmapWidth) = pData->dispWidth;
731-
switch(pData->HFOVoption){
731+
HFOV_OPTIONS HFOVoption = pData->HFOVoption;
732+
switch(HFOVoption){
732733
default:
733734
case HFOV_360:
734735
(*hfov) = 360;
735736
break;
736737
}
737-
switch(pData->aspectRatioOption){
738+
ASPECT_RATIO_OPTIONS aspectRatioOption = pData->aspectRatioOption;
739+
switch(aspectRatioOption){
738740
default:
739741
case ASPECT_RATIO_2_1:
740742
(*aspectRatio) = 2;

examples/src/powermap/powermap_internal.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,11 +75,13 @@ void powermap_initAna(void* const hPm)
7575

7676
if(pData->isFirstInit){
7777
/* generate interpolation table for current display settings */
78-
switch(pData->HFOVoption){
78+
HFOV_OPTIONS HFOVoption = pData->HFOVoption;
79+
switch(HFOVoption){
7980
default:
8081
case HFOV_360: hfov = 360.0f; break;
8182
}
82-
switch(pData->aspectRatioOption){
83+
ASPECT_RATIO_OPTIONS aspectRatioOption = pData->aspectRatioOption;
84+
switch(aspectRatioOption){
8385
default:
8486
case ASPECT_RATIO_2_1: aspectRatio = 2.0f; break;
8587
}

0 commit comments

Comments
 (0)