Showing changes from revision #6 to #7:
Added | Removed | Changed
The Scheduler is used to queue Sound system SWIs. Its most common use is to play sequences of notes, and a simplified interface is provided for this purpose.
A beat counter is used which is reset every time it reaches the end of a bar. Both its tempo and the number of beats to the bar can be programmed.
The Scheduler registers itself with the DMA Handler (SoundDMA) by passing its address using Sound_Configure. At this address there must be a pointer to the code for the Scheduler:
Offset | Contents |
---|---|
+0 | Pointer to scheduler |
On entry, the following registers are passed by the DMA Handler (SoundDMA):
Entry | |
---|---|
R12 | Pointer to Scheduler (value of R4 in Sound_Configure) |
R13 | IRQ stack |
R14 | Return address |
Exit | |
---|---|
R1-R7 | Preserved |
Although the Scheduler is principally designed for queuing sound commands it can be used to issue other SWIs. Thus it could be used to control, for example, an external instrument interface (such as a Musical Instrument Digital Interface (MIDI) expansion podule), or a screen-based music editor with real-time score replay.
Extreme care must be used with the Scheduler, as it has limitations. R2 – R7 are always cleared when the SWI is issued, and the error-returning form (‘X’ form) of the SWI is forced. Return parameters are discarded. If pointers are to be passed in R0 or R1 then the data they address must be preserved until the SWI is called. If a SWI will not work within these limitations it must not be called by the Scheduler.
The Scheduler implements the queue as a circular chain of records. A stack listing the free slots is also kept. The number of free slots varies not only according to how many events are queued, but also to how the events are ‘clustered’.
The queue is always accessed through the SWI calls provided, and so its precise format is not defined.
Every centisecond the beat counter is advanced according to the tempo value and any events that fall within the period are activated in strict queuing order. Voice and parameter change events are processed and the Sound Channel Control Block for each Voice Generator updated as necessary by the Channel Handler, before fill requests are issued to the relevant Voice Generator.
The scheduler is entered in IRQ mode, with IRQs disabled.