signals#

diffsptk.impulse(order, **kwargs)[source]#

Generate impulse sequence.

See impulse for details.

Parameters:
orderint >= 0 [scalar]

Order of sequence, \(M\).

kwargsadditional keyword arguments

See torch.eye.

Returns:
xTensor [shape=(M+1,)]

Impulse sequence.

Examples

>>> x = diffsptk.impulse(4)
>>> x
tensor([1., 0., 0., 0., 0.])
diffsptk.step(order, value=1, **kwargs)[source]#

Generate step sequence.

See step for details.

Parameters:
orderint >= 0 [scalar]

Order of sequence, \(M\).

valuefloat [scalar]

Step value.

kwargsadditional keyword arguments

See torch.full.

Returns:
xTensor [shape=(M+1,)]

Step sequence.

Examples

>>> x = diffsptk.step(4, 2)
>>> x
tensor([2., 2., 2., 2., 2.])
diffsptk.ramp(arg, end=None, step=1, eps=1e-08, **kwargs)[source]#

Generate ramp sequence.

See ramp for details.

Parameters:
argfloat [scalar]

If end is None end value otherwise start value.

endfloat [scalar]

End value.

stepfloat != 0 [scalar]

Slope.

epsfloat [scalar]

A correction value.

kwargsadditional keyword arguments

See torch.arange.

Returns:
xTensor [shape=(?,)]

Ramp sequence.

Examples

>>> x = diffsptk.ramp(4)
>>> x
tensor([0., 1., 2., 3., 4.])
diffsptk.sin(order, period=None, magnitude=1, **kwargs)[source]#

Generate sinusoidal sequence.

See sin for details.

Parameters:
orderint >= 0 [scalar]

Order of sequence, \(M\).

periodfloat > 0 [scalar]

Period.

magnitudefloat [scalar]

Magnitude.

kwargsadditional keyword arguments

See torch.arange.

Returns:
xTensor [shape=(M+1,)]

Sinusoidal sequence.

Examples

>>> x = diffsptk.sin(4)
>>> x
tensor([ 0.0000,  0.9511,  0.5878, -0.5878, -0.9511])
diffsptk.train(order, frame_period, norm='power', **kwargs)[source]#

Generate pulse sequence.

See train for details.

Parameters:
orderint >= 0 [scalar]

Order of sequence, \(M\).

frame_periodfloat >= 1 [scalar]

Frame period.

norm[‘none’, ‘power’, ‘magnitude’]

Normalization type.

**kwargsadditional keyword arguments

See torch.zeros.

Returns:
xTensor [shape=(M+1,)]

Pulse sequence.

Examples

>>> x = diffsptk.train(5, 2.3)
>>> x
tensor([1.5166, 0.0000, 0.0000, 1.5166, 0.0000, 1.5166])
diffsptk.nrand(*order, mean=0, stdv=1, var=None, **kwargs)[source]#

Generate random number sequence.

See nrand for details.

Parameters:
orderint >= 0 [scalar]

Order of sequence, \(M\).

meanfloat [scalar]

Mean.

stdvfloat >= 0 [scalar]

Standard deviation.

varfloat >= 0 [scalar]

Variance.

**kwargsadditional keyword arguments

See torch.randn.

Returns:
xTensor [shape=(M+1,)]

Random value sequence.

Examples

>>> x = diffsptk.nrand(4)
>>> x
tensor([-0.8603,  0.6743, -0.9178,  1.5382, -0.2574])
>>> x = diffsptk.nrand(2, 4)
>>> x
tensor([[-0.2385, -0.0778, -0.0418, -1.6217,  0.1560],
        [ 1.6646,  0.8429,  0.9357, -0.5123,  0.9571]])