Okay, three classes and a module.
sched_note(sample [, pitch=1, volume=1, delay=0, chan=self.channel]) -> duration
None
or not supplied, defaults to the same channel the agent is
running in.
This returns the expected duration of the sound, in seconds.
sched_note_pan(sample [, pan=0, pitch=1, volume=1, delay=0, chan=self.channel]) -> duration
stereo
module.
The sound is loaded from the file sample (which is relative to
$BOODLER_SOUND_PATH). The pitch is given as a multiple of the
sound's original frequency; the volume is given as a fraction
of the sound's original volume. The delay is a time (in seconds)
to delay before the note is played. The channel, if None
or not
supplied, defaults to the same channel the agent is running in.
This returns the expected duration of the sound, in seconds.
sched_note_duration(sample, duration [, pitch=1, volume=1, delay=0, chan=self.channel]) -> duration
The sound is loaded from the file sample (which is relative to
$BOODLER_SOUND_PATH). The pitch is given as a multiple of the
sound's original frequency; the volume is given as a fraction
of the sound's original volume. The delay is a time (in seconds)
to delay before the note is played. The channel, if None
or not
supplied, defaults to the same channel the agent is running in.
This returns the expected duration of the sound, in seconds. Due to the way sounds are looped, this may be slightly longer than the given duration.
sched_note_params(sample [, param=value, param=value...]) -> duration
The valid arguments, and their default values:
pitch = 1
(original pitch)
volume = 1
(full volume)
delay = 0
(play immediately)
pan = None
(no stereo shift)
duration = 0
(exactly once through the sound)
chan = None
(play in agent's own channel)
post_agent(agent [, chan=self.channel])
None
or not supplied, defaults to the same channel that self is running
in.
The posted agent must be an instance of the EventAgent
class.
It must have a watch_events
field, which lists the
events which it is interested in. This field must be a string,
a list of strings, or a function such that agent.watch_events()
return a string or list of strings.
send_event(event)
The event should be a tuple of strings, or a string (which will be split into a tuple at whitespace).
sched_agent(agent [, delay=0, chan=self.channel])
None
or not supplied,
defaults to the same channel that self is running in.
resched([delay, chan=self.channel])
None
or not supplied, defaults to the same channel that self is
running in.
If delay is not supplied, it defaults to the delay used when this agent was first scheduled. Note that if this value was zero, you will probably cause an infinite loop.
new_channel([startvolume=1, parent=self.channel]) -> channel
None
or not supplied, it will be a subchannel of
the channel that the agent (self) is running in.
new_channel_pan([pan=stereo.default(), startvolume=1, parent=self.channel]) -> channel
stereo
module.) The startvolume is the volume the channel
is initially set to; this will affect all sounds played in the
channel and any subchannels. The new channel will be a subchannel
of parent -- if None
or not supplied, it will be a subchannel of
the channel that the agent (self) is running in.
get_root_channel() -> channel
run()
getname() -> string
self.name
, if that is defined.
post_agent(self)
run()
post_agent(self)
. In most cases, you will
not want to override this.
receive(event)
EventAgent
must override this method.
The event is a tuple of one or more strings.
unpost()
Agent.new_channel()
and
destroyed with the channel.stop()
method.
stop()
If any notes are playing with non-zero volume, their termination
may cause undesirable clicks and pops. It is best to set the volume
of a channel to zero before stopping it. (The FadeOutAgent
class
can be used for this.)
Due to the way sound generation is buffered, when an agent calls
channel.stop()
, the channel may be stopped slightly later than
it ought to be.
get_root_channel() -> channel
set_volume(newvolume [, interval=0.005])
The volume change begins immediately, and occurs smoothly over the interval given (in seconds). If no value is given, the interval defaults to 0.005 (five milliseconds), which is short enough that it will sound instantaneous. (You should not use an interval shorter than 0.005; it can cause undesirable clicks and pops.)
Due to the way the volume code is written (a cheap and dirty hack),
two volume changes scheduled too close together on the same channel
(within about one second) can interfere with each other. The earlier
one may be ignored entirely in favor of the later. Therefore, you
should not rely on rapid sequences of set_volume()
calls for your
sound effects. Set volumes on individual notes instead, or else
create several channels.
These functions are for creating stereo panning description objects.
A stereo object is a stereo shift, a contraction, or a combination of
these. (See Soundscape Basics.)
Stereo objects can be passed
to new_channel_pan()
or sched_note_pan()
.
Note that in the current implementation, stereo objects are represented
by simple tuples, or by None
(for the default stereo position).
You should not rely on this remaining true. I may get cleverer in a future
release, and re-implement them as a Python class. Use the utility
functions.
default() -> stereo
shift(pos) -> stereo
scale(size) -> stereo
fixed(pos) -> stereo
fixed(pos)
is equivalent to
compose(shift(pos), scale(0))
.
You figure it out.
compose(stereo1, stereo2) -> stereo
cast(obj) -> stereo
None
, this returns the
default stereo position. If obj is a number, this returns a simple
stereo shift -- no scaling. If obj is a stereo object, this returns
it (or an equivalent object).