Speech Coding¶
Companding (A-law, mu-law) and telephone-band filtering.
v_lin2pcma
¶
V_LIN2PCMA - Convert linear PCM to A-law.
v_lin2pcma
¶
Convert linear signal to A-law PCM values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
array_like
|
Input signal values. |
required |
m
|
int
|
XOR mask value applied to output. Default is 85. |
85
|
s
|
float
|
Scale factor applied to input values. Default is 2017.396342 (ITU G.711 standard: sqrt((1120^2 + 2624^2)/2)). Common scale factors: s=1 : input range +-4096 s=2017.40 : input range +-2.03033976 (default, 0 dBm0) s=4096 : input range +-1 |
2017.396342
|
Returns:
| Name | Type | Description |
|---|---|---|
p |
ndarray
|
A-law PCM values in the range 0 to 255. |
Source code in pyvoicebox/v_lin2pcma.py
v_pcma2lin
¶
V_PCMA2LIN - Convert A-law PCM to linear.
v_pcma2lin
¶
Convert A-law PCM values to linear signal.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
p
|
array_like
|
A-law PCM values in the range 0 to 255. |
required |
m
|
int
|
XOR mask applied to input values. Default is 85. |
85
|
s
|
float
|
Scale factor for output division. Default follows ITU G.711 (equivalent to s = 2017.396342). Common scale factors: s=1 : output range +-4032 s=2017.40 : output range +-1.998616 (default, 0 dBm0) s=4032 : output range +-1 s=4096 : output range +-0.984375 |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
x |
ndarray
|
Linear signal values. |
Source code in pyvoicebox/v_pcma2lin.py
v_lin2pcmu
¶
V_LIN2PCMU - Convert linear to Mu-law PCM.
Attempt at a faithful port of voicebox/v_lin2pcmu.m
v_lin2pcmu
¶
Convert linear signal to Mu-law PCM values.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
x
|
array_like
|
Input signal values. |
required |
s
|
float
|
Scale factor applied to input values. Default is 4004.189931 (ITU G.711 standard: sqrt((2207^2 + 5215^2)/2)). Common scale factors: s=1 : input range +-8159 s=4004.19 : input range +-2.03761563 (default, 0 dBm0) s=8159 : input range +-1 |
4004.189931
|
Returns:
| Name | Type | Description |
|---|---|---|
p |
ndarray
|
Mu-law PCM values in the range 0 to 255. |
Source code in pyvoicebox/v_lin2pcmu.py
v_pcmu2lin
¶
V_PCMU2LIN - Convert Mu-law PCM to linear.
v_pcmu2lin
¶
Convert Mu-law PCM values to linear signal.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
p
|
array_like
|
Mu-law PCM values in the range 0 to 255. |
required |
s
|
float
|
Scale factor for output division. Default follows ITU G.711 (equivalent to s = 4004.189931). Common scale factors: s=1 : output range +-8031 s=4004.19 : output range +-2.005649 (default, 0 dBm0) s=8031 : output range +-1 s=8159 : output range +-0.9843118 |
None
|
Returns:
| Name | Type | Description |
|---|---|---|
x |
ndarray
|
Linear signal values. |
Source code in pyvoicebox/v_pcmu2lin.py
v_potsband
¶
V_POTSBAND - Design 300-3400 Hz telephone bandwidth filter.
v_potsband
¶
Design filter for 300-3400 Hz telephone bandwidth.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fs
|
float
|
Sample frequency in Hz. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
b |
ndarray
|
Numerator coefficients. |
a |
ndarray
|
Denominator coefficients. |