Showing changes from revision #9 to #10:
Added | Removed | Changed
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.
On entry, the following registers are passed from SoundDMA:
Register | Contents |
---|---|
R6 | -ve if updated Level0 (e.g. channel configuration has changed) |
R8 | Sample period in µS |
R9 | Pointer to |
R10 | Buffer end address (exclusive) |
R11 | Interleave increment (1, 2, 4 or 8) |
R12 | Buffer start address (inclusive) |
When calling the Voice Generators, the following registers should be defined:
Register | Contents |
---|---|
R6 | -ve if updated Level0 |
R7 | Channel number (0-7) |
R8 | Sample period in µS |
R9 | Pointer to Sound Channel Control Block |
R10 | Buffer end address for this channel (exclusive) |
R11 | Interleave increment (1, 2, 4 or 8) |
R12 | Buffer start address for this channel (inclusive) |
Voice generator routines should be entered in IRQ mode with IRQs enabled. The return address should be on the stack. Voice generator routines do not need to preserve any registers except R13.
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. The table lookup can be performed as follows:
LDRB log,[table,linear,LSR #19]
The table takes into account the current volume setting (as set by Sound_Volume). This is the same table as is accessed by Sound_SoundLog. Note that this table 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 current volume setting. Voice Generators which operate on log sample data should use this table to adjust their overall volume. This is the same table as is accessed by Sound_LogScale. This table is not used by the 16-bit sound system.
When the default channel handler of SoundChannels is in use, the pitch accumulator/oscillator for a channel will be initialised by any calls to Sound_Control (or related SWIs). The buffer fill count will also be initialised, based around the specified duration of the sound. The timbre accumulator/oscillator is not used.