signals#

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

Generate impulse sequence.

See impulse for details.

Parameters:
orderint >= 0

The order of the sequence, \(M\).

**kwargsadditional keyword arguments

See torch.eye.

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

The 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

The order of the sequence, \(M\).

valuefloat

Step value.

**kwargsadditional keyword arguments

See torch.full.

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

The 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

If end is None, this is the end value otherwise start value.

endfloat

The end value.

stepfloat != 0

The slope.

epsfloat

A correction value.

**kwargsadditional keyword arguments

See torch.arange.

Returns:
outTensor [shape=(?,)]

The 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

The order of the sequence, \(M\).

periodfloat > 0

The period.

magnitudefloat

The magnitude.

**kwargsadditional keyword arguments

See torch.arange.

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

The 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

The order of the sequence, \(M\).

frame_periodfloat >= 1

The frame period.

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

The normalization type.

**kwargsadditional keyword arguments

See torch.zeros.

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

The 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

The order of the sequence, \(M\).

meanfloat

The mean.

stdvfloat >= 0

The standard deviation.

varfloat >= 0

The variance. This overrides stdv.

**kwargsadditional keyword arguments

See torch.randn.

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

The 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]])