Offset | Contents |
---|---|
+0 | Pointer to fill code |
+4 | Pointer to overrun fixup code |
+8 | Pointer to linear-to-log table or 0 |
+12 | Pointer to log-scale table or 0 |
The fill code handles fill requests from the DMA Handler (SoundDMA)
It should translate the fill request to a series of calls to the Voice Generators, passing the required buffer offsets so that data from all channels correctly interleaves. Any unused channels within the buffer should be set to zero by the Channel Handler so they are silent.
When calling the Voice Generators, the following registers should be defined:
R6 | -ve if updated Level0 |
R8 | sample period in uS |
R9 | Pointer to Sound Channel Control Block |
R10 | Buffer end address |
R11 | Interleave increment (1, 2, 4 or 8) |
R12 | Buffer start address |
The buffer length is a multiple of 4 words (16 bytes) long, and word aligned and the interleave is dependent on the number of channels.
The Channel Handler maintains a 256 byte SCCB for each channel, which contains parameters and flags used by Voice Generators and an extension area for programmers to pass further data.
The 9 initial words hold values that are normally stored in R0 – R8 inclusive. They are loaded from the SCCB using the instruction LDMIA R9,{R0-R8}
Offset | Contents |
---|---|
+0 | gate bit + channel amplitude (7-bit log) |
+1 | index to voice table |
+2 | instance number for attached voice |
+3 | control/status bit flags |
+4 | phase accumulator pitch oscillator |
+8 | phase accumulator timbre oscillator |
+12 | number of buffer fills left to do (counter) |
+16 | (normally working R4) |
+20 | (normally working R5) |
+24 | (normally working R6) |
+28 | (normally working R7) |
+32 | (normally working R8) |
+36-63 | reserved |
+64-255 | available for users |
The control/status flag byte indicates the state of the voice attached to the channel, and may be used for allocating voices in a polyphonic manner. Each time a Voice Generator completes a buffer fill and returns to the Channel Handler it returns an updated value for the Flags field in R0.
It is the responsibility of the Channel Handler to store the returned flag byte, and to update the other fields of each SCCB as necessary.
The overrun fixup code is no longer supported in RISC OS and is never called.
The pointer to the linear-to-log table holds the address of the base of an 8 Kbyte table which maps 32-bit signed integers directly to 8-bit signed volume-scaled logarithms in a suitable format for output to the VIDC chip. This is not used by the 16-bit sound system, which uses linear values.
The pointer to the log-scale table holds the address of a 256-byte table which scales the amplitude of VIDC-format 8-bit signed logarithms from their maximum range down to a value scaled to the volume setting. Voice Generators should use this table to adjust their overall volume. This is not used by the 16-bit sound system.