h6. [[Programmer's Reference Manuals]] h6(. » 16 bit linear sound handler h2. 16 bit linear sound handler |_<^{width:4em}. Entry | | |<^. R0 |<^. Workspace (as specified in R2 to [[Sound_LinearHandler 1]]) | |<^. R1 |<^. Base of buffer | |<^. R2 |<^. End of buffer (exclusive) | |/7<^. R3 |<^. Flags: | |<^. Bits 0-2: Buffer state: | |<^. 0 -> Data in buffer is invalid and must be completely overwritten | |<^. 1 -> Buffer contains 8-bit mu-law data that has been converted to 16 bit linear | |<^. 2 -> Data in buffer is all zeroes | |<^. 3-7 -> Reserved | |<^. Bits 3-31: Reserved | |<^. R4 |<^. Sample rate in units of 1/1024Hz | Processor may be in IRQ or SVC mode. Implementation is free to enable interrupts. |_<^{width:4em}. Exit | | |<^. R0-R10 |<^. Corruptible | |<^. R11-R13 |<^. Preserved | h4. Use The 16 bit linear sound handler is the main point of entry for 16 bit sounds within the sound system. Without it, the only sound which will be output will be that produced by the 8 bit sound system. Each time SoundDMA processes a buffer fill interrupt from the hardware, the 16 bit handler will be called in order to allow it to mix its data into the buffer. On entry R1 will point to the base of a 16 byte aligned buffer. Depending on the value in R3 this buffer may: * Contain garbage which the handler must overwrite * Contain the output of the 8 bit sound system. In this case the linear handler is free to choose whether to mix its output into the buffer or overwrite the contents (effectively silencing the 8 bit sound system). * Contain silence, i.e. all zeroes. This state allows for an optimisation to be performed, where if the 16 bit handler knows that it has no data to output it can simply exit immediately without touching the buffer. For each word in the buffer, the low 16 bits provide the right sample and the high 16 bits provide the left sample. Data is signed 2's complement, i.e. &0000 corresponds to silence. In addition to being 16 byte aligned, the buffer is also a multiple of 16 bytes in length. h4. Notes It's recommended that software which wishes to implement its own 16 bit linear handler first tries to register a handler with [[SharedSound]] before falling back to replacing the default 16 bit sound handler. SharedSound allows for a much better user experience, by allowing multiple 16 bit sound sources to be mixed together, along with the legacy 8 bit sound output. The 16 bit linear handler is called before any oversampling or mono-conversion is applied to the sound output. h4. See also * [[Sound_LinearHandler 1]] * [[SharedSound]]