Previous topic

bregman module

Next topic

features module

This Page

testsignal module

exception bregman.testsignal.TestSignalError(msg)
Test signal exception class.
bregman.testsignal.balance_signal(sig, balance_type='maxabs')
Perform signal balancing using:
  rms - root mean square
  max - maximum value
  maxabs - maximum absolute value
  norm - Euclidean norm
  none - do nothing [default]

Returns:
  sig - balanced (normalized) signal
bregman.testsignal.default_noise_params()
Returns a new parameter dict for noise generators consisting of:
     'noise_dB':24.0  - relative amplitude of noise to harmonic signal content
     'num_harmonics':1 - how many harmonics (bands) to generate
     'num_points':44100, - how many points to generate
     'cf':441.0 - center frequency in Hertz
     'bw':50.0 - bandwidth in Hertz
     'sr':44100.0 - sample rate in Hertz
bregman.testsignal.default_rhythm_params()
Return signal_params and pattern_params dicts, and a patterns tuple for 
a default rhythm signal such that:
        'sr' : 48000,        # sample rate
        'bw' : [80., 2500., 1000.], # band-widths
        'cf' : [110., 5000., 16000.], # center-frequencies
        'dur': [0.5, 0.5, 0.5] # relative duration of timbre
        'amp': [1.0, 1.0, 1.0] # relative amplitudes of timbres
        'normalize' : 'maxabs' # balance timbre channels 'rms', 'max', 'maxabs', 'norm', 'none'
Example:
 signal_params, rhythm_params, patterns = default_rhythm_params()
 sig = rhythm(signal_params, rhythm_params, patterns)
bregman.testsignal.default_signal_params()
Return a new parameter dict consisting of:
  'f0':441.0,
  'num_points':44100,
  'num_harmonics':1,
  'phase_offset':0.0,
  'sr':44100.0
bregman.testsignal.devils_staircase(num_octaves=7, num_steps=12, step_size=1, hop=4096, overlap=True, center_freq=440, band_width=150, **params)
Generate an auditory illusion of an infinitely ascending/descending sequence of shepard tones
    num_octaves - number of sinusoidal octave bands to generate [7]
    num_steps - how many steps to take in the staircase
    step_size - semitone change per step, can be fractional [1.]
    hop - how many points to generate per step [12]
    overlap - whether the end-points should be cross-faded for overlap-add
    center_freq - where the peak of the spectrum will be [440]
    band_width - how wide a spectral band to use for shepard tones [150]
    **params - signal_params dict, see default_signal_params()
bregman.testsignal.gauss_pdf(n, mu=0.0, sigma=1.0)
Generate a gaussian kernel
 n - number of points to generate
 mu - mean
 sigma - standard deviation
bregman.testsignal.harmonics(afun=<function <lambda> at 0xa24bc6c>, pfun=<function <lambda> at 0xa24bca4>, **params)
Generate a harmonic series using a harmonic weighting function
 afun   - lambda function of one parameter (harmonic index) returning a weight
 pfun   - lambda function of one parameter (harmonic index) returning radian phase offset
 **params - signal_params dict, see default_signal_params()
bregman.testsignal.modulate(sig, env, nsamps)
Signal modulation by an envelope
sig - the full-rate signal
env - the reduced-rate envelope
nsamps - audio samples per envelope frame
bregman.testsignal.noise(noise_fun=<built-in method rand of mtrand.RandomState object at 0x40208420>, **params)
Generate noise according to params dict
    params - parameter dict containing sr, and num_harmonics elements [None=default_noise_params()]
    noise_fun - the noise generating function [pylab.rand]
bregman.testsignal.overlap_add(x, y, wlen)
Overlap-add two sequences x and y by wlen samples
bregman.testsignal.rhythm(signal_params=None, rhythm_params=None, patterns=None)
Generate a multi-timbral rhythm sequence using noise-band timbres 
with center-frequency, bandwidth, and decay time controls

Timbre signal synthesis parameters are specified in 
the signal_params dict:
    ['cf'] - list of center-frequencies for each timbre
    ['bw'] - list of band-widths for each timbre
    ['dur'] - list of timbre durations relative to a quarter note
    ['amp'] - list of timbre relative amplitudes [default 1.0]
    ['sr'] - sample rate of generated audio
    ['tc'] - constant of decay envelope relative to subdivisions:
     The following expression yields a time-constant for decay to -60dB 
     in a given number of beats at the given tempo:
       t = beats * tempo / 60.
       e^( -tc * t ) = 10^( -60dB / 20 )
       tc = -log( 0.001 ) / t           

The rhythm sequence is generated with musical parameters specified in
the rhythm_params dict: 
    ['tempo']  - how fast
    ['subdiv'] - how many pulses to divide a 4/4 bar into

Rhythm sequences are specified in the patterns tuple (p1,p2,...,pn)
   patterns - n-tuple of integers with subdiv-bits onset patterns, 
    one integer element for each timbre

   Parameter constraints:
     Fail if not:
       len(bw) == len(cf) == len(dur) == len(patterns)
bregman.testsignal.shepard(num_octaves=7, center_freq=440, band_width=150, **params)
Generate shepard tones
     num_octaves - number of sinusoidal octave bands to generate [7]
     center_freq - where the peak of the spectrum will be [440]
     band_width - how wide a spectral band to use for shepard tones [150]
     **params - signal_params dict, see default_signal_params()
bregman.testsignal.sinusoid(**params)
Generate a sinusoidal audio signal from signal_params: see default_signal_params() 
  **params - signal_params dict, see default_signal_params()