Beeb SOUND weirdness

Discuss all aspects of programming here. From 8-bit through to modern architectures.
Post Reply
User avatar
ctr
Posts: 154
Joined: Wed Jul 16, 2014 2:53 pm
Contact:

Beeb SOUND weirdness

Post by ctr » Sun Aug 05, 2018 5:02 pm

When I play the same note on two different channels I get two different pitches.

I've tried this on beebem, b-em and b2 with consistent results but not a real beeb. Can anyone reproduce it? It's surprising that these emulators all do this, but I'd also be surprised if a real beeb worked like this.

The following code switches between two notes that should be the same pitch, but they are not:

Code: Select all

   10REPEAT
   20SOUND&11,-15,150,11
   30K%=INKEY(50)  
   40SOUND&12,-15,150,11
   50K%=INKEY(50)
   60UNTILFALSE
If you change line 40 to use a pitch of 151 instead of 150 then they do sound the same.

Edited to add ssd.
Attachments
pitch.ssd
(1 KiB) Downloaded 3 times
Last edited by ctr on Sun Aug 05, 2018 5:12 pm, edited 1 time in total.

User avatar
BigEd
Posts: 1964
Joined: Sun Jan 24, 2010 10:24 am
Location: West
Contact:

Re: Beeb SOUND weirdness

Post by BigEd » Sun Aug 05, 2018 6:14 pm

I think I read recently in another thread that the MOS detunes one note if you play the same pitch on different channels, so you get a fatter sound. JSBeeb is doing the same thing as the others, I think.

User avatar
ctr
Posts: 154
Joined: Wed Jul 16, 2014 2:53 pm
Contact:

Re: Beeb SOUND weirdness

Post by ctr » Sun Aug 05, 2018 10:30 pm

Cheers, with this clue I went looking in the MOS.

Having calculated the 10-bit frequency period value to write to the chip (in &83D and &83E) the code at &ED6F adds in a constant channel fudge factor from a lookup table at &C441. (Confusingly, the channel number is represented by a value in X between 4 and 7.) This is 0 for channels 0 and 1, 1 for channel 2 and 2 for channel 3.

In the region of middle C an offset of 1 is about 1/26 of a semitone. At higher frequencies it's closer to a quarter of a semitone (which is the unit of pitch in the SOUND statement), so 150 on channel 1 does produce the same output as 151 on channel 2.
Last edited by ctr on Tue Aug 07, 2018 10:37 pm, edited 1 time in total.

User avatar
BigEd
Posts: 1964
Joined: Sun Jan 24, 2010 10:24 am
Location: West
Contact:

Re: Beeb SOUND weirdness

Post by BigEd » Mon Aug 06, 2018 6:42 am

Good digging! (I tried to find where I'd got the info from, and failed.)

I think this finding reinforces the idea that this kind of sound chip isn't especially musical, and hints at why Bob Yannes was able to do better, with the SID.

User avatar
Rich Talbot-Watkins
Posts: 1299
Joined: Thu Jan 13, 2005 5:20 pm
Location: Palma, Mallorca
Contact:

Re: Beeb SOUND weirdness

Post by Rich Talbot-Watkins » Mon Aug 06, 2018 10:30 am

What a peculiar feature! And, as you say, pretty terrible too, if it doesn't scale with the frequency, so that higher notes are detuned more than lower ones. I think that's an OS 1.20 misfire (and they could've saved themselves some space by not doing that as well!).

User avatar
Rich Talbot-Watkins
Posts: 1299
Joined: Thu Jan 13, 2005 5:20 pm
Location: Palma, Mallorca
Contact:

Re: Beeb SOUND weirdness

Post by Rich Talbot-Watkins » Mon Aug 06, 2018 11:05 am

BigEd wrote:
Mon Aug 06, 2018 6:42 am
Good digging! (I tried to find where I'd got the info from, and failed.)
I'd be interested to know where this observation was first made. It is documented in that famous OS 1.20 disassembly, in as much as the lookup table's purpose is correctly described, although the code which uses it makes no comments as to what it's doing.
BigEd wrote:
Mon Aug 06, 2018 6:42 am
I think this finding reinforces the idea that this kind of sound chip isn't especially musical, and hints at why Bob Yannes was able to do better, with the SID.
I think the SN76489 is a fairly capable chip (for its time), and was certainly able to hold a tune well - the Sega Master System used this exact chip, for example. However, on the Beeb, it's clocked too high, which means that it's not able to reproduce low pitches well and ends up sounding a bit like a musical box half the time. If it had been clocked at half the speed it would've sounded better (although it would also have been twice as slow to access).

There were certainly worse sound chips in that era, e.g. the AY 8910 that the Oric, Spectrum 128, CPC and others used, which only had 3 channels. But the SID blew them both out of the water of course. And my very favourite sound chips of the era were the Yamaha FM chips, particularly the later ones which were programmable rather than just playing back presets, like in the Sega Megadrive. I actually even prefer the sound of FM synthesis to more contemporary PCM based techniques.

User avatar
Richard Russell
Posts: 351
Joined: Sun Feb 27, 2011 10:35 am
Location: Downham Market, Norfolk
Contact:

Re: Beeb SOUND weirdness

Post by Richard Russell » Mon Aug 06, 2018 2:09 pm

Rich Talbot-Watkins wrote:
Mon Aug 06, 2018 11:05 am
There were certainly worse sound chips in that era, e.g. the AY 8910 that the Oric, Spectrum 128, CPC and others used, which only had 3 channels.
In BBC BASIC for Windows and BBC BASIC for SDL 2.0 I've incorporated the option of reconfiguring SOUND channel 0 as a fourth 'tone' channel rather than a noise channel. I find that very helpful, especially as there's a lot of four-voice music around but not so much three-voice, and working out which one to drop requires musical experience! Here's a four-voice example supplied with BBCSDL (it runs equally well in Windows, Linux, Mac OS, Raspberry Pi, Android and iOS). Blatant off-topic plug! :evil:

Richard.

User avatar
Rich Talbot-Watkins
Posts: 1299
Joined: Thu Jan 13, 2005 5:20 pm
Location: Palma, Mallorca
Contact:

Re: Beeb SOUND weirdness

Post by Rich Talbot-Watkins » Mon Aug 06, 2018 4:18 pm

Sounds good. I'd probably have extended it all the way to support 16 channels - I mean, why not, right? I'd also extend ENVELOPE to allow for different waveforms and so on. When you're synthesising the sound yourself, there are no limits really!

Post Reply