music.StimulusPhase¶
- class music.StimulusPhase(stimulus, duration=0.0, ramp=0.0, gain=1.0, label='', parameters=<factory>)[source]¶
Bases:
objectOne phase of a session: a stimulus, for a while, ramped into.
- Attributes:
- stimulus
callable()or array_like What to render. A callable is called with
number_of_samplesandsample_ratealongsideparameters, which is what every generator inmusic.stimulationaccepts, so the session can render it at exactly the length the arrangement needs. An array is taken as it stands.- durationscalar
How long the phase lasts, in seconds, not counting its share of the ramps at either end. Ignored when
stimulusis an array, which brings its own length.- rampscalar
The length in seconds of the transition into this phase: a crossfade with the phase before it, or a fade in from silence for the first phase.
- gainscalar
A factor applied to the phase before it is mixed, for balancing stimuli of different loudness against each other.
- label
str A name for the phase, carried for the reader’s sake and shown in the session’s
repr.- parameters
dict Keyword arguments passed to
stimuluswhen it is a callable.
- stimulus
- Parameters:
Examples
>>> phase = StimulusPhase(stimulus=binaural_beats, duration=0.2, ... ramp=0.05, gain=0.5) >>> phase.duration, phase.ramp, phase.gain (0.2, 0.05, 0.5)
A session builds these for you, so one is rarely written by hand:
>>> session = StimulationSession() >>> session.add(binaural_beats, duration=0.2, ramp=0.05, beat_freq=10) >>> session.phases[0].duration 0.2
- __init__(stimulus, duration=0.0, ramp=0.0, gain=1.0, label='', parameters=<factory>)¶
Methods
__init__(stimulus[, duration, ramp, gain, ...])Attributes