Oh, and to answer your questions directly:
Quote:
Q1) I'm more familair with writing directly to hardware registers of sound chips, rather than doing 'bios' system calls..... Am I going to run into snaggsville here.... IS IT SAFE TO WRITE DIRECTLY TO MEMORY ???? (I'll be going for a BBC B model)
See my post above

Quote:
Q2) Do I need to disable the Native Sound software that might cause conflicts - eg... by not calling any interupt services ?
Yes, if you're going to roll your own sound code, you may as well disable the OS entirely, by simply returning from your IRQ handler with:
Code:
LDA $FC
RTI
instead of JMP()ing to the OS handler address. Then you also have the freedom to use the timers at $FE44-45/48-49 as you wish.
Quote:
Q3) I presume that I will have to roll my own software ASDR envelopes, as we only have a volume and pitch for each of the voices... 3 Square Waves and Noise on the 4th channel ....thats all you get on the BBC... is this right ?
Yes. I always hooked sound update to the VSync interrupt, so that it updates pitch and volume of each channel every 1/50th of a second. The OS sound routines update every 1/100th of a second, but I always found this to be more than necessary!
The noise channel is a curiosity - it has two modes: white(ish) noise, and 'periodic' noise, which in fact is a low-pitched tuned note with a totally different timbre to the square wave tone generators. It's the closest you can get to an alternative waveform on the Beeb, and also because it's much lower in pitch than the other tone generators, it's sometimes used to create a bassline. The limitation of the noise channel is that, when used standalone, it can only be set to three predefined frequencies. However, there's also a mode which allows it to take on the pitch of one of the tone channels - so, at the expense of a one of the other channels (which has to have its volume set to silent), you can create 'tuned' noise.
Quote:
Q4) Is there a frequency / note / values table kicking around ?? (I've not looked to be honest) - I've obviously got a C64 version, but nothing for the bbc for now... I presume this would be in the advanced manual or whatever... (For the c64 - I use 2 bytes per note table entry - a high and low byte value and I cover a few octaves - 12 notes/24 bytes per octave)
As I mentioned above, you can build a table for an octave's worth of data, based on the fact that the pitch is a 10-bit value, where 1023 is the lowest note, and subsequent semitones are reached by dividing this value by 2^(1/12).
In BeebAsm, you could construct a quarter-semitone pitch table (which should be fine-tuned enough for decent sounding pitch envelopes) like this:
Code:
.pitchtablo
FOR n, 0, 47
EQUB (1023 / 2^(n/48)) AND 255
NEXT
.pitchtabhi
FOR n, 0, 47
EQUB (1023 / 2^(n/48)) DIV 256
NEXT
(I'm not sure how to build tables in Swift).
To get the pitch value for higher octaves, just shift this 10-bit value right once for each octave higher.
There's a further optimisation to be made, in that the contents of pitchtabhi are only ever 3 (for n=0..19) or 2 (for n=20..47), so you don't actually need to store pitchtabhi at all - instead just some code like this will do the job:
Code:
; get the moment when the high byte changes from 2 to 3
PitchHiValueChange = INT(48*(LOG1023-LOG768)/LOG2+0.9999)
; calculate pitchtabhi (X = table index (0-47))
lda #2
cpx #PitchHiValueChange
adc #0
eor #1
; result is 2 or 3
Hope this is a little bit of help to get started
Edit: Just remembered that when writing the frequency to the sound chip registers, it's not split into 8 bits low / 2 bits high like those tables above. So you might want to actually split the tables in a more useful way, i.e. 4 bits low / 6 bits high. But then you have to be careful when shifting the values right to reach higher octaves, to ensure that the carry from the high byte reaches bit 3 of the low byte. Remember you have 8us spare every time you write a sound register, which is ideal for doing these kind of calculations

Or to avoid the shifting, you can just extend the table beyond 48 entries, so there's an entry for every note in every octave. But, for 4 octaves, this is 384 bytes of tables, which sounds like a lot on a memory-challenged Beeb!