Sonor SWIs and *commands

The Sonor module has a number of software interrupts (SWIs) available for use by you. This appendix describes the ones which you are entitled to use. The SWI base number is &48D40, and has the prefix SonorSound_.

SonorSound_Status (&48D40)

On entry:

-

On exit:

R0 is 0 if no sound is being produced
R1 is 0 if next buffer is empty
R2 is sample playing speed
R3 is maximum buffer size
R4 is voice number
R5 is special number (not needed)

This returns the status of the player; it is intended for internal use only.

SonorSound_SendBuffer (&48D41)

On entry:

R0 is pointer to current point in sample
R1 is length
R2 is special number (Not needed)

On exit:

Registers preserved.

This call sends some data to SonorSound's internal buffers; it is intended for internal use only.

SonorSound_SetSpeed (&48D42)

On entry:

R0 is speed (1<<24 is 20.833 KHz at 24MHz VIDC speed)

On exit:

Registers preserved

This call sets the speed of playing; it is intended for internal use only.

SonorSound_Reset (&48D43)

On entry:

-

On exit:

R0 is 0.

This call resets Sonor into a default state. Sound production is turned off. It is intended for internal use only.

SonorSound_Sample (&48D44)

On entry:

R0 is pointer to memory
R1 is length to sample
R2 is period (2,000,000/frequency)
R3 is pointer to translation table (0 if linear values required)

On exit:

Registers preserved.

This call samples into memory, using an optional translation table. The maximum period is 65535, which corresponds to a sample frequency of around 30Hz.

SonorSound_GetOffset (&48D45)

On entry:

-

On exit:

R0 is current pointer in buffer.
R1 corrupted

This call returns the current playing position in the buffer. It is intended for internal use only.

SonorSound_CancelBuffer (&48D46)

On entry:

-

On exit:

Registers preserved.

This call stops sound production, and clears the buffers.

SonorSound_SampleByte (&48D47)

On entry:

-

On exit:

R0 is 8-bit value left shifted two places.

This call returns the current reading from the sampler.

SonorSound_ResetDevice (&48D48)

This call is depreciated. Do not call it.

SonorSound_FIRFilter (&48D49)

On entry:

R0 is pointer to sample
R1 is pointer to end of sample+1
R2 is pointer to linear to logarithmic table (4096 bytes long)
R3 is pointer to logarithmic to linear (256 words long)
R4 is pointer to fixed point elements, 21 of, 16-bit fixed point notation
R5 is hourglass percentage calculation.

On exit:

Registers preserved.

This call performs the FIR filtering. The operation of this call can only be done effectively, if you understand how FIR filters work.

The 16-bit fixed point notation basically means that real values are multiplied by 65536, and converted to integers.

SonorSound_DCT (&48D4A)

On entry:

R0 is pointer to word samples
R1 is pointer to frequency data to be filled in

On exit:

Registers preserved.

This call takes the 64-point DCT of the samples, and stores it into the array pointed to by R1.

SonorSound_Information (&48D4B)

On entry:

R0 is device slot number (0-31, -1 means current)

On exit:

R0 is pointer to device's name (0 if no device loaded in that slot)
R1 is flag (0 means no new devices have been loaded since last SonorSound_Information called)
R2 is device's special word
R3 is device's maximum sample rate.

This call allows you to get information on the current sampler.

SonorSound_SelectDevice (&48D4C)

On entry:

R0 is sampler slot (0-31)

On exit:

Registers preserved

This call allows you to set the device driver up.

SonorSound_LoadDevice (&48D4D)

On entry:

R0 is pointer to filename, or ”- <filename>•.

On exit:

Registers preserved.

This call allows you to load a device into memory. If the filename is preceded by a ”- •, then it will not be loaded into memory if it already exists.

SonorSound_RegisterDevice (&48D4E)

On entry:

R0 is pointer to device

On exit:

Registers preserved.

This call allows you to install a sampler device from memory. The device does not have to be in RMA, as RMA workspace is allocated automatically.

SonorSound_FindDevice (&48D4F)

On entry:

R0 is special word

On exit:

R0 is sampler slot number, or -1 if sampler not installed

This call allows you to find out if a device is registered in memory.

*Commands

In version 1.00, SonorSound only uses the following *command:

*Sonor_LoadDevice [-] <filename>

The '-' is optional, and, if present, will only install in the sampler device if it has not been installed before. The equivalent SWI is SonorSound_LoadDevice (&48D4D).