[message about 16-bit sound calls, initially for the benefit of Alfons Adriaensen, written by me (mca1001@cam.ac.uk) because I should've been busy with something important and I didn't want to be] #include "It's not big, it's not clever and I'm not proud of it." [the CD_ReadAudio program mention may be of interest, too. I have plans for it, but if you want a taster, look in ftp://mca1001.robinson.cam.ac.uk/pub/ http://mca1001.robinson.cam.ac.uk/~mca1001/proglet.html ] Well a while ago I wrote a program to read raw audio data from a CD, process it and play the results through the 16bit sound. It needs a fair bit more work before I can release it, but I can tell you that writing 16bit sound drivers seemed a lot easier than how I remember the 8 bit system - this could be down to the fact that I'm older and wiser, but that's not very likely! 8-) > What are the available sample frequencies ? etc. etc.. Well, there's a SWI Sound_SampleRate &40146 r0=reason code 0 - read number of available sample rates 1 - read current sample rate index number and corresponding sample rate 2 - convert sample rate index number to sample rate 3 - set current sample rate index number r0=0 : returns r1 = number of sample rates available, "nsr". These are in the range 1 to nsr. r0=1 : returns r1 = sample rate index (1 to nsr) r2 = corresponding rate in units of 1/1024 Hz r0=2 : entry r1 = sample rate index to read (1 - nsr) returns r2 = sample rate, units of 1/1024 Hz eg. 20kHz = 20480000 r0=3 : entry r1 = new sample rate index (1-nsr) returns r1,r2 = previous sample rate index & value You're supposed to enumerate the available rates (they increase monotonically with sample index number), and then choose the nearest to what you want. The rates I have available are: 5120000 6400000 7111111 8000000 9142857 10666666 11289600 11636363 12800000 14222222 16000000 18285714 21333333 22579200 25600000 28444444 32000000 36571428 42666666 45158400 51200000 ie. 5kHz to 50kHz, including the standard 48uS and the exact CD rate, 44.100kHz. You can also set the rate the old way using Sound_Configure R2, but the new way is preferred for 16 bit systems. You'll also need SWI Sound_Mode &40144 r0=0 : returns r0 = 0 (8 bit sound only, r1 = 0) or 1 (16 bit or 8 bit by emulation) in which case,r1 = CMOS configuration bits (details available if you need them, but mainly oversampling etc.) r0=1 : entry r1 = 0 (disable automatic oversampling) 1 (enable 2x oversampling for sample rates below 25kHz, using about 3% processor overhead) returns r1 = previous state SWI Sound_LinearHandler &40145 r0=0 : returns r1 = pointer to current handler, or 0 for none r2 = parameter passed in R0 to current handler, or -1 r0=1 : entry r1 = pointer to new handler or 0 to remove r2 = parameter to pass in R0 or -1 if removing handler returns previous values as for reason code r0=0 "only one linear handler can be registered with SoundDMA at any time, so only register your handler immediately before making a noise and re-register the previous handler when you finish" the linear handler itself has to fill a buffer with stereo pairs of 4 bytes: they are signed (2's complement) with rigt channel in bits 0-15, left in bits 16-31. The PRM doesn't stress the need for efficiency at all - I guess having an ARM 610 minimum means you can be lazy. 8-) Linear Handler entry conditions: r0 = parameter set by Sound_LinearHandler in R2 r1 = pointer to quad-word aligned sound DMA buffer r2 = pointer to word immediately after the buffer r3 = flags: bits 0-2 initial buffer state: 0 - data in buffer is invalid, must be overwritten 1 - data in buffer has been converted from multiple channels of 8bit and is not all zero. "all linear handlers should allow the user to configure whether 8bit emulation data is overwritten or whether the new data is merged in" 2 - buffer is full of zeroes all other values and bits reserved r4 = sample rate for playback in units of 1/1024 Hz Handler may be called in IRQ or SVC mode. on exit: r0-r10 may be corrupted r11-r13 must be preserved processor mode must be preserved on exit Interrupts may be enabled during handler as I said, I've got some (rather grubby) bits of code, you're welcome if you want them. Let me know if you need any more data. Matthew #8-) If somebody wants to take this text under their wing and archive it, feel free - it'll vanish without trace after June. [I'm now matthew@fruitcake.demon.co.uk, and you can find more drivel at http://www.fruitcake.demon.co.uk/ MCA 11/09/97]