Document toolboxDocument toolbox

Randi

Overview

Low frequency noise generator

Discussion

Generates slowly varying random noise using by linearly interpolating between random values. The underlying random noise lies in the range [-1 +1). The module computes a new random value at the rate specified by .freq. If isSmoothed = 1, then linear interpolation is used between values. If isSmoothed = 0, then the output changes instantly effectively generating a square wave with constant period but random amplitudes.

Internally, the module uses a 32-bit linear congruential generator to generate random values. The initial seed of the random number generator is specified by .seed. If .fixCurrentSeed is 1, then the seed is fixed. This means that the prebuild function will not generate a new seed. By default, .fixCurrentSeed equals 0, and thus instances of the generator will produce different outputs.

Type Definition

typedef struct _ModuleRandi { ModuleInstanceDescriptor instance; // Common Audio Weaver module instance structure FLOAT32 freq; // Rate at which random values are generated. INT32 isSmoothed; // Determines whether the random signal interpolates between random values (isSmoothed=1) or steps between random values (isSmoothed=0). FLOAT32 slope; // Slope value for linear interpolation between random values. FLOAT32 level; // The current value of the random signal. INT32 rate; // Starting value for counter, dependent on freq. UINT32 seed; // State of the random number generator. INT32 fixCurrentSeed; // Whether the prebuild function resets the seed or not. 0 = reset, 1 = no reset. INT32 counter; // Counter value is used in slewing between random values. FLOAT32 oneOverRate; // Used in calculating the slope value. } ModuleRandiClass;

Variables

Properties

Name

Type

Usage

isHidden

Default value

Range

Units

freq

float

parameter

0

1000

0.01:24000

Hz

isSmoothed

int

parameter

0

1

0:1

 

slope

float

state

0

random value

Unrestricted

 

level

float

state

0

0

Unrestricted

 

rate

int

state

0

48

Unrestricted

 

seed

uint

state

0

random value

Unrestricted

 

fixCurrentSeed

int

parameter

0

0

0:1

 

counter

int

state

1

48

Unrestricted

 

oneOverRate

float

derived

1

0.02083

Unrestricted

 

Pins

Output Pins

Name: out

Description: audio output

Data type: float

MATLAB Usage

File Name: randi_module.m

M=randi_module(NAME, SR, BLOCKSIZE) Creates a slowly varying random generator based on linear interpolation. This module has a single 1 channel output pin with controllable frequency. The output of the module changes instantly when the frequency is updated. Arguments: NAME - name of the module. SR - sample rate. BLOCKSIZE - number of samples per output channel.

Â