Skip to content

Commit 58017b5

Browse files
Some cleaning : C code, some Python comment, picture placement.
1 parent ecf6a58 commit 58017b5

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

content/learning-paths/embedded-and-microcontrollers/cmsisdsp-dev-with-python/how-to-4.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,10 +62,9 @@ vad = np.array([[w]*(winLength-winOverlap) for w in cleaned]).flatten()
6262
ax.plot(data)
6363
ax.plot(vad)
6464
```
65-
The reference implementation works. You can now implement the same version using CMSIS-DSP.
66-
6765
![vad alt-text#center](vad.png "Figure 3. VAD")
6866

67+
The reference implementation works. You can now implement the same version using CMSIS-DSP.
6968

7069
### CMSIS-DSP Q15 VAD
7170

content/learning-paths/embedded-and-microcontrollers/cmsisdsp-dev-with-python/how-to-5.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,8 +134,6 @@ The FFT length must be a power of 2. The slice length is not necessarily a power
134134
```python
135135
class NoiseSuppressionReference(NoiseSuppression):
136136
def __init__(self,slices):
137-
# In a better version this could be computed from the signal length by taking the
138-
# smaller power of two greater than the signal length.
139137
NoiseSuppression.__init__(self,slices)
140138

141139
# Compute the vad signal

content/learning-paths/embedded-and-microcontrollers/cmsisdsp-dev-with-python/how-to-7.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,10 @@ def rescale(self,w):
2929
```
3030
#### C Version
3131

32-
3332
```C
33+
#include "dsp/basic_math_functions.h"
34+
#include "dsp/statistics_functions.h"
35+
3436
arm_status rescale(q15_t *w, uint32_t nb,q15_t *the_max)
3537
{
3638
uint32_t index;
@@ -46,7 +48,7 @@ arm_status rescale(q15_t *w, uint32_t nb,q15_t *the_max)
4648
status = arm_divide_q15(0x7FFF,*the_max,&quotient,&the_shift);
4749
if (status == ARM_MATH_SUCCESS)
4850
{
49-
arm_scale_q15(w,quotient,the_shift,w,nb);
51+
arm_scale_q15(w,quotient,(int8_t)the_shift,w,nb);
5052
}
5153
}
5254

@@ -82,20 +84,24 @@ def signal_energy_q15(window):
8284

8385
#### C version
8486
```C
85-
int16_t signal_energy_q15(q15_t *window,unit32_t nb)
87+
#include "dsp/basic_math_functions.h"
88+
#include "dsp/fast_math_functions.h"
89+
#include "dsp/statistics_functions.h"
90+
91+
int16_t signal_energy_q15(q15_t *window,uint32_t nb)
8692
{
8793
q15_t mean,neg_mean;
8894
arm_mean_q15(window,nb,&mean);
8995

90-
arm_negate_q15(&mean,&mean,1);
96+
arm_negate_q15(&mean,&neg_mean,1);
9197

9298
arm_offset_q15(window,neg_mean,window,nb);
9399

94100
q63_t energy_q63;
95101
q15_t energy;
96102
arm_power_q15(window,nb,&energy_q63);
97103

98-
energy=(q15_t)_SSAT((q31_t)(energy_q63>>20),16);
104+
energy=(q15_t)__SSAT((q31_t)(energy_q63>>20),16);
99105

100106
// Fixed point format of result is on 16 bit
101107
// but the specific format has not been identified
@@ -105,7 +111,7 @@ int16_t signal_energy_q15(q15_t *window,unit32_t nb)
105111

106112
arm_vlog_q15(&energy,&dB,1);
107113

108-
return(dB)
114+
return(dB);
109115
}
110116
```
111117

0 commit comments

Comments
 (0)