Writing sampler device drivers

Sonor has been written to accept a wide range of samplers, by allowing sample device drivers to be loaded into Sonor. The format of a device driver is simple:

00..03Sampler special word (e.g. "MSMP" for MIDI Sampler")
03..1BSampler name, zero terminated (e.g. "MIDI/Sampler")
1C..1FWord to place into R10 on entry.
20..22Maximum sample frequency (>100,000 is none)
23Preserved flags, set to zero.
24..27Branch to initialise, or MOV PC,R14 if none.
28..2BBranch to finish, or MOV PC,R14 if none.
2C..Code to take a sample.

Registers on entry to initialise, finish and sample to take:

R3 is pointer to IOC;

R4 is pointer to translation table (4096 bytes), or 0 for no translation;

R10 is word at offset &1C;

R14 is link register back to sampling code (return using MOV PC,R14)

R2 is return value.

R0,R1,R3,R4,R10 and R11 must be preserved on exit.

If R4 is 0 on entry, then R2 must be between 0 and 255 as unsigned byte. If R4 is non-zero on entry, then R4 points to a unsigned linear to logarithmic table of 4096 bytes long.

An example code (using AAsm), for the Vertical Twist MIDI/Sampler card:

=”MSMP•; Special word
=”MIDI/Sampler (econet)•,0
DCD&33a0000; Pointer to A/D conv.
DCD90000; 90KHz? tops
MOVpc,lr; Has no initialisation
MOVpc,lr; Nor any finalisation
LDRBr2,[r10]; Read the byte
TEQr4,#0; Is there a transtable?
; Yep, so convert it
MOVpc,lr; Return

There is no filetype for device drivers allocated. They are loaded either using the Sonor_LoadDevice SWI, or by using *Sonor_LoadDevice:

*Sonor_LoadDevice [-] <filename>

If the '-' is present, then Sonor will not load the device driver if it has already been installed. Otherwise, Sonor will remove the old device, and replace it with the new one.

You can modify the !Run of your Sonor to automatically install your device driver when you load Sonor. You should use the Drivers directory, and the line

Sonor_LoadDevice - <Obey$Dir>.Devices.<YourDevice>

is inserted after the SonorSound module is loaded. Only do this to a backup copy of Sonor.