eventList¶
Lists of events can be made into a JS object that can be manipulated.
eventList.create()¶
Is used to create an event, usually assigned to a variable:
then we can play it repeatedly (by calling play() on it):
The play() can take two optional parameters,
the first one is a when for the complete list, taken from the time of the action, so we can place the performance in the future. The second is a list of events, basically a JS list of lists, such as:
as can be seen, there is an outer lists which holds two events, which are
themselves lists (of attributes). One fundamental aspect is that the event list
passed to play() replaces the existing events (if any have been added) in the
object.
eventList.add()¶
events to the end of the list. This can take any number of events (as
create() did).
eventList.remove()¶
remove an event with a given index from the list, or the last event (if no
index is given).
eventList.insert()¶
insert one or more events into the object, after position pos.
eventList.repeat()¶
We can also repeat an eventList any number of times, when seconds later
from the action,
Both eventList.play() and eventList.repeat() return the end time of the
playback. So we can use that information to schedule other events. For example,
this code plays an event list, adds two events to it and then schedule to
repeat that longer sequence for three times after the end of the first play()
action,
let sequence = eventList.create([C4, 0.1, 0, 1],
[E4, 0.2, 1, 1],
[G4, 0.4, 2, 1]);
let end = sequence.play();
sequence.add([C1, 0.1, 3, 3], [C1, 0.1, 0, 4]);
sequence.repeat(3, end);
One consequence of all these ideas is that we have introduced the idea that a
play() action may have different forms, depending on which context it is
being invoked, which at the moment can be
-
The global litePlay.js context:
play() -
An instrument object :
organ.play() -
An eventList:
eventList.play()
With events and eventLists we can construct compositions and performances with precise relative timing between events, which is something desirable in musical activities.