SN76489 best sample playback?

discussion of beeb/electron applications, languages, utils and educational s/w
cmorley
Posts: 662
Joined: Sat Jul 30, 2016 7:11 pm
Location: Oxford
Contact:

SN76489 best sample playback?

Post by cmorley » Thu May 10, 2018 6:20 pm

Hi All,

From people's experience what gives the best quality for sample playback on the Beeb? The two basic schemes with the SN76489 are PWM and PCM... PWM whistles and PCM has low bitdepth because of the 16 log volume settings per tone generator. N.B. I don't have the CPU budget to get better bit depth using all three tone gens.

It's a shame you can't use a 6522 one shot timer to do the sound chip WE pulse.

Chris

puppeh
Posts: 16
Joined: Tue Sep 27, 2016 9:48 pm
Contact:

Re: SN76489 best sample playback?

Post by puppeh » Thu May 10, 2018 6:47 pm

"VIA" used 3 channels of (logarithmic) PCM volume to attempt to produce higher bit-depth sample playback. The assumption is that the volumes of the three channels are added together linearly to produce >4 bits of sample depth. IIRC I tried two things:
  • Precomputing a table of three summed logarithmic volumes for 3 channels. This didn't work - changing three channels to different levels for each sample drowned out the played-back sound with "glitch" noise.
  • Using a look-ahead search to do the same summing-together trick, but with each new sample only changing one channel at once. The idea is that the "other two" channels are already in the right place for a change in the first channel to produce the right step difference between the previous sample and the current one. This worked beautifully, IMNSHO.
There are some unanswered questions -- are the assumptions correct? Why does changing the volume (of a square wave) let you play back samples at all? (The average speaker cone position should be "in the middle", regardless). Are the channels really added linearly?

Anyway: I guess folks here will have seen https://www.youtube.com/watch?v=TMEtjLur4uM. The conversion routine is at https://github.com/crtc-demos/bbc-telet ... dio/tab.ml.

One downside is that playback is kind of quiet. I think PWM can go louder, with worse quality, but I've never experimented with that.

puppeh
Posts: 16
Joined: Tue Sep 27, 2016 9:48 pm
Contact:

Re: SN76489 best sample playback?

Post by puppeh » Thu May 10, 2018 6:50 pm

(Oops, missed the bit about CPU budget. Feel free to ignore me :-)).

cmorley
Posts: 662
Joined: Sat Jul 30, 2016 7:11 pm
Location: Oxford
Contact:

Re: SN76489 best sample playback?

Post by cmorley » Thu May 10, 2018 7:52 pm

puppeh wrote:(Oops, missed the bit about CPU budget. Feel free to ignore me :-)).
I wondered about something like you've described/done. What sample rate (tone channel update rate) did you use? If the strategy gets better quality for a lower tone channel update rate then it is worth it. The other thing I will try because it is easy is PCM with dither.

I use your 6502 gcc port by the way. I've got Matt Godbolt's compiler explorer set up with it to look at the code it generates. I didn't dig too deep so it doesn't link C to asm for the 6502. A topic for a different thread.

puppeh
Posts: 16
Joined: Tue Sep 27, 2016 9:48 pm
Contact:

Re: SN76489 best sample playback?

Post by puppeh » Thu May 10, 2018 9:39 pm

cmorley wrote:
puppeh wrote:(Oops, missed the bit about CPU budget. Feel free to ignore me :-)).
I wondered about something like you've described/done. What sample rate (tone channel update rate) did you use? If the strategy gets better quality for a lower tone channel update rate then it is worth it. The other thing I will try because it is easy is PCM with dither.
I think the released/YouTube version is running at 8KHz: the playback code (with different un-commentable playback rates is at https://github.com/crtc-demos/bbc-telet ... y/play.a65). I didn't particularly try to optimise the sample size, so it's one byte per sample: I guess you could get away with 6 bits per sample, but the CPU overhead would grow. (Interleaving the sample playback, GoMMC disc loading and video rendering was kinda fun...)
I use your 6502 gcc port by the way. I've got Matt Godbolt's compiler explorer set up with it to look at the code it generates. I didn't dig too deep so it doesn't link C to asm for the 6502. A topic for a different thread.
Cool, thank you! You'll have to write up how you did the Compiler Explorer thing, that sounds like fun :-). Matt Godbolt mentioned he'd like to try it in an issue request on GitHub, but I've not heard anything about it since...

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

Re: SN76489 best sample playback?

Post by Rich Talbot-Watkins » Fri May 11, 2018 9:41 am

Tangential question - if you have PCM source data (e.g. a .wav file or something), how can this be converted to PWM data? And what's a good way to store and replay PWM data on a Beeb? Essentially just 1 bit data at a higher sample rate, right? I've never really understood why PWM is said to be louder than PCM. I also never understood how it can ever approach anything like decent fidelity. But, that said, I think Exile's sound is PWM and it doesn't sound all that bad.

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

Re: SN76489 best sample playback?

Post by Rich Talbot-Watkins » Fri May 11, 2018 9:49 am

puppeh wrote:There are some unanswered questions -- are the assumptions correct? Why does changing the volume (of a square wave) let you play back samples at all? (The average speaker cone position should be "in the middle", regardless). Are the channels really added linearly?
I have often pondered the same question. I figured either:
  • The speaker cone position goes between 0 and v, instead of -v/2 and +v/2, so the average position ends up as v/2 instead of 0.
  • Inertia prevents the speaker cone from actually physically moving back and forth at 125kHz, so the overall effect is that it stays at a kind of halfway point, like an 'always on'. The volume then modulates this position accordingly.

User avatar
1024MAK
Posts: 7869
Joined: Mon Apr 18, 2011 4:46 pm
Location: Looking forward to summer in Somerset, UK...
Contact:

Re: SN76489 best sample playback?

Post by 1024MAK » Fri May 11, 2018 10:38 am

Rich Talbot-Watkins wrote:I have often pondered the same question. I figured either:
  • The speaker cone position goes between 0 and v, instead of -v/2 and +v/2, so the average position ends up as v/2 instead of 0.
  • Inertia prevents the speaker cone from actually physically moving back and forth at 125kHz, so the overall effect is that it stays at a kind of halfway point, like an 'always on'. The volume then modulates this position accordingly.
Loud speakers are really current operated devices. Whatever the circuit driving it, the end result is that a current flows or does not flow (simple on/off like in a ZX Spectrum) or flows in one direction, then the current decays to zero, followed by current flowing in the opposite direction, which also decays to zero (circuit used in the BBC and Electron). The above assumes you are in the normal audio frequency range. At higher frequencies, the current may not get the chance to decay to zero, as the polarity changes before the charge in the capacitor feeding the speaker has been used up. Hence less energy and less current goes to the loud speaker.

The speaker cone generates a sound wave when it moves in and out, that is, when the magnetic field from the coil changes strength (higher, or lower current compared to it's previous value).
But loud speakers have physical limitations. The larger the speaker, the more limited the highest frequency is, that it can stay in step with the electrical signal. Plus, the coil being an inductor, will also limit the highest frequency.
So if you feed too high a frequency to a loud speaker, the speaker will not be able to move at that frequency, so will hardly move at all. And hence produce no sound.

Mark
For a "Complete BBC Games Archive" visit www.bbcmicro.co.uk NOW!
BeebWiki‬ - for answers to many questions...

ThomasHarte
Posts: 467
Joined: Sat Dec 23, 2000 5:56 pm
Contact:

Re: SN76489 best sample playback?

Post by ThomasHarte » Fri May 11, 2018 2:05 pm

If the CPU constraint weren't in place then to throw out a third possibility: 1-bit pulse density modulation. The name is pretty descriptive: it's a lot like pulse width modulation except that instead of pulsing your 1-bit signal on and off for periods that correspond to the source data, you pick how many times to pulse on and off within a given window based on the sample you want to play back.

It was the scheme used by Super Audio CDs, if anybody remembers those.

Also, as an electronics dunce, I seem to get by fine by mentally modelling all these schemes purely in terms of addition and subtraction of frequencies. The high frequency channel isn't audible because neither the electronics nor your ears can convey frequencies that high. But if you add lower frequency components by modifying the volume then they are audible because they're within range. It's not like there's two stages — determine what of the high-frequency wave is audible, then, separately, adjust the volume of that — there's only one output signal which contains all the acting frequencies in combination but only some of those will survive to perception.

cmorley
Posts: 662
Joined: Sat Jul 30, 2016 7:11 pm
Location: Oxford
Contact:

Re: SN76489 best sample playback?

Post by cmorley » Fri May 11, 2018 2:29 pm

ThomasHarte wrote:If the CPU constraint weren't in place then to throw out a third possibility: 1-bit pulse density modulation
It's worth a try.
I have PCM working, it sounds good but is quiet. Doubling channels improves it a bit at the cost of 2x CPU for a given sample rate! PWM sounds terrible by comparison and not a lot louder.

puppeh
Posts: 16
Joined: Tue Sep 27, 2016 9:48 pm
Contact:

Re: SN76489 best sample playback?

Post by puppeh » Fri May 11, 2018 2:52 pm

Rich Talbot-Watkins wrote:
puppeh wrote:There are some unanswered questions -- are the assumptions correct? Why does changing the volume (of a square wave) let you play back samples at all? (The average speaker cone position should be "in the middle", regardless). Are the channels really added linearly?
I have often pondered the same question. I figured either:
  • The speaker cone position goes between 0 and v, instead of -v/2 and +v/2, so the average position ends up as v/2 instead of 0.
  • Inertia prevents the speaker cone from actually physically moving back and forth at 125kHz, so the overall effect is that it stays at a kind of halfway point, like an 'always on'. The volume then modulates this position accordingly.
Maybe it's like this: the speaker does stay at an average of the midpoint, and at high frequencies, it manages to produce something like a sine wave (or perhaps it doesn't have to actually move, I'm not sure). Now, depending on the point in the waveform, changing volume has the effect of making an instantaneous "step" -- something like a square-wave high/low or low/high transition. In the frequency domain, I think that corresponds to a bunch of higher-frequency harmonics going up to infinity: so, you get a "pop". If the sine wave is crossing zero when the volume change takes place, you probably get nothing.

I think what that would mean is during the usual PCM sample-playing technique, you'd be hearing something like the derivative of the sound wave formed from a series of those pops, modulated by some kind of noise. IIRC that's pretty much what sample playback on the beeb usually sounds like! (I suspect "derivative of sound wave" and "sound wave" sound the same to a human listener.)

Anyway. All speculation. Even if true, I'm not sure it would suggest a method to make sample playback sound better.

cmorley
Posts: 662
Joined: Sat Jul 30, 2016 7:11 pm
Location: Oxford
Contact:

Re: SN76489 best sample playback?

Post by cmorley » Fri May 11, 2018 3:25 pm

The speaker has a DC blocking capacitor so the coil never has DC through it whatever the sound chip puts out (or circuit fault). (Required or the speaker would cook.) The audio amplifier circuit and the electrical and physical characteristics filter out much of the high frequency garbage which are a byproduct of all these schemes.

The SN chip does output a series of step functions. Back in the mid 90s I sampled a single step (amplifier and speaker dynamics included) and put it in my emulator. It played a convolution of all the step functions as the finished audio. The sound is _perfect_ :) I never finished the emulator but did manage to compile it again at the Midland's ABUG after all these years :D

User avatar
tricky
Posts: 2764
Joined: Tue Jun 21, 2011 8:25 am
Contact:

Re: SN76489 best sample playback?

Post by tricky » Fri May 11, 2018 4:53 pm

Sample playback in the usual emulators can sound from different to completely unrecognisable, so always test on Real HW, but then I guess it won't work for people emulating.
Also watch out for emulators that reset the timer when data is sent, I think this is how some of the SN76489 chips work, but not the beeb one AFAIK.
cmorley, if your sound emulation does match HW, maybe you could make it available for inclusion in other emulators or even a standalone one (6502+RAM+SN76489 or SN76489+data+time)?

User avatar
SarahWalker
Posts: 1108
Joined: Fri Jan 14, 2005 3:56 pm
Contact:

Re: SN76489 best sample playback?

Post by SarahWalker » Fri May 11, 2018 6:04 pm

Has anyone successfully tried PWM on the Beeb? My understanding of the SN76489 is that it effectively updates at 4 MHz / 16 or 32, which would add severe quantisation to any PWM signal, limiting output quality.

The quality PCM over multiple voices is limited by the time taken between register writes which gives audible periods of glitched noisy output, where not all voices have been updated to the new output level. As puppeh discovered, changing only one voice per sample eliminates this. This is fairly easy to do when playing pre-processed audio. For generated audio you need to figure out the optimal volume changes on the fly. When I wrote my .MOD player I didn't have the time or memory to do this, so instead I used the sum of 2 voices for every sample, which was quieter but slightly cleaner (and slightly faster!) than 3 voices.

B-em sadly doesn't handle this brilliantly, as it samples sound register state at 15 kHz, meaning the glitch period gets stretched out longer than real hardware and the noise level is consequently higher. One way to improve this would be to update sound emulation at 250 kHz and downsample for output; this would be slower, but could be optimised by only updating when the sound chip is actually written to. I don't know what the current state of other emulators is for sample playback.

cmorley
Posts: 662
Joined: Sat Jul 30, 2016 7:11 pm
Location: Oxford
Contact:

Re: SN76489 best sample playback?

Post by cmorley » Fri May 11, 2018 6:06 pm

Flat out PDM doesn't sound great with music. It can't render the cymbals and drums without horrible artefacts (lots of aliasing). I tried at 100kHz to give it the best chance.

I modified my PCM to use one tone channel for +ve excursions and one for -ve excursions (mapped with the correct log volume levels) and this is the clear winner so far. As loud as doubled up PCM samples but clearer and only uses slightly more volume updates than a single PCM tone channel. I prune updates to tone volumes if there is no change. Sounds good at 44k, 22k, 11k & 7k playback rates.

The pitches change a little as the 6522 clock is 1MHz (volume update granularity) and 1/44100 is not a round number of us... I could resample the audio on a PC to fix that.

cmorley
Posts: 662
Joined: Sat Jul 30, 2016 7:11 pm
Location: Oxford
Contact:

Re: SN76489 best sample playback?

Post by cmorley » Fri May 11, 2018 6:10 pm

SarahWalker wrote:Has anyone successfully tried PWM on the Beeb? My understanding of the SN76489 is that it effectively updates at 4 MHz / 16 or 32, which would add severe quantisation to any PWM signal, limiting output quality.
Yes I tried it today. I tried a PWM frequency upto 80kHz IIRC but it sounded pretty aweful because you have a minimum update time of ~10uS so the means there are some duty cycles you simply can't achieve*. Lower PWM frequency 11-22kHz worked ok but you get nasty whistling artefacts because the PWM fundamental is audible.

Edit: *
e.g. at 10kHz PWM to make the number easier... 100us per cycle
0% = OK. 100% = OK. 10%-90% = OK. But 0-10 and 90-100 is unachievable because you can't update the sound chip fast enough 10us min.

ThomasHarte
Posts: 467
Joined: Sat Dec 23, 2000 5:56 pm
Contact:

Re: SN76489 best sample playback?

Post by ThomasHarte » Fri May 11, 2018 6:39 pm

SarahWalker wrote:Has anyone successfully tried PWM on the Beeb? My understanding of the SN76489 is that it effectively updates at 4 MHz / 16 or 32, which would add severe quantisation to any PWM signal, limiting output quality.
I had always assumed that volume changes take effect immediately, not being bound to the tone-generator clock. Is that not the case? In that comment I'm implicitly assumed a PWM implementation that switches a high-frequency channel between full volume and silent, rather than one that tries to match durations to a generated tone.

I have my emulated SN tied to a ColecoVision only at present though, so there's relatively little to test against. Small cartridges do not lend themselves to extravagant audio.

An additional audio playback option if only my memory weren't so terrible: I read about at least one implementation for some other platform that did the frequency transform of a source file and then applied the necessary psychoacoustics to whittle that down to the three* most significant contributors with some dithering in selection, to reproduce pretty good sampled audio without so tight a loop. The barrier to entry is substantial though.

* or maybe two; I can't remember which chip this was for.

User avatar
SarahWalker
Posts: 1108
Joined: Fri Jan 14, 2005 3:56 pm
Contact:

Re: SN76489 best sample playback?

Post by SarahWalker » Fri May 11, 2018 8:00 pm

ThomasHarte wrote:
SarahWalker wrote:Has anyone successfully tried PWM on the Beeb? My understanding of the SN76489 is that it effectively updates at 4 MHz / 16 or 32, which would add severe quantisation to any PWM signal, limiting output quality.
I had always assumed that volume changes take effect immediately, not being bound to the tone-generator clock. Is that not the case?
I haven't really studied this massively in depth. However the behaviour I've seen when the SN's write signal isn't held for long enough, where it will seem to randomly discard bytes, suggests to me that new data is only latched in at one cycle in 32. Which would have essentially the same effect.

User avatar
simonm
Posts: 209
Joined: Mon May 09, 2016 2:40 pm
Contact:

Re: SN76489 best sample playback?

Post by simonm » Fri May 11, 2018 9:06 pm

Listening in on the high precision audio technicals being discussed here, I'm amused by how little we knew BITD - in fact I think we got pretty lucky with the samples we did on the various yorkshire boys sample demos. It certainly wasn't because we understood the hardware that well. In fact, I believe we built a dodgy veroboard based hardware gizmo from a Mike Cook Micro User article which firehosed 4-bit DAC data over the user port. The playback code was also gleaned from the same article, and had some linear to non-linear 4-bit lookup table for each sample before writing to 3 channels. So not very sophisticated audio processing or CPU optimal at all.
Frankly I think it only worked because the pre-amp was crazy overloaded and we fed it from a walkman line input so our samples were somewhat loud & clipped, which, combined with the Beeb's cheapo 8 ohm speaker meant it sounded vaguely recognisable. :lol:
It's like one of those old school Pink Floyd era analogue mixing desks that cant be reproduced in digital emulators because all the analogue gubbins had wildy variable operating characteristics.

ThomasHarte
Posts: 467
Joined: Sat Dec 23, 2000 5:56 pm
Contact:

Re: SN76489 best sample playback?

Post by ThomasHarte » Fri May 11, 2018 9:07 pm

SarahWalker wrote:
ThomasHarte wrote:
SarahWalker wrote:Has anyone successfully tried PWM on the Beeb? My understanding of the SN76489 is that it effectively updates at 4 MHz / 16 or 32, which would add severe quantisation to any PWM signal, limiting output quality.
I had always assumed that volume changes take effect immediately, not being bound to the tone-generator clock. Is that not the case?
I haven't really studied this massively in depth. However the behaviour I've seen when the SN's write signal isn't held for long enough, where it will seem to randomly discard bytes, suggests to me that new data is only latched in at one cycle in 32. Which would have essentially the same effect.
On the ColecoVision the system clock is 3.58Mhz, the SN is clocked at half that, and writing to the SN is an ordinary Z80 OUT instruction. There's no intermediary with a memory — all that sits between the CPU and the SN is a 74LS128 for mapping from three-bit binary to individual signals. The Z80 machine cycle that signals the writing part of an OUT lasts four cycles, but the write signal is active for only a bit more than 2.5 cycles.

Therefore the SN can definitely accept a very short write signal — 2.5 cycles @ 3.58Mhz. Definitely a lot shorter than 32 cycles, and prone to suggest that the SN can accept a new value within at most 1.25 of its own cycles.

Schematics:
The 74LS128 is slightly to left of centre at the bottom of here. Note AUD_W out. The top of this part shows AUD_W being the direct input to the SN.

The Z80 IO cycle is charted here amongst other places; TW is the single wait cycle that is automatically inserted for IO operations, so it's on the graph.

User avatar
simonm
Posts: 209
Joined: Mon May 09, 2016 2:40 pm
Contact:

Re: SN76489 best sample playback?

Post by simonm » Fri May 11, 2018 9:24 pm

There are some unanswered questions -- are the assumptions correct? Why does changing the volume (of a square wave) let you play back samples at all? (The average speaker cone position should be "in the middle", regardless). Are the channels really added linearly?
I seem to remember that the "trick" is that the SN emits a continuous voltage if tone registers are set to 1, rather than a square wave. So modulating the volume shapes a crude output waveform - essentially just a fancy (and CPU intensive) envelope!

The SN76489 data sheet does say that the outputs are summed. So your assumptions work out nicely Jules!

cmorley
Posts: 662
Joined: Sat Jul 30, 2016 7:11 pm
Location: Oxford
Contact:

Re: SN76489 best sample playback?

Post by cmorley » Fri May 11, 2018 9:25 pm

ThomasHarte wrote: Therefore the SN can definitely accept a very short write signal — 2.5 cycles @ 3.58Mhz. Definitely a lot shorter than 32 cycles, and prone to suggest that the SN can accept a new value within at most 1.25 of its own cycles.

Schematics:
The 74LS128 is slightly to left of centre at the bottom of here. Note AUD_W out. The top of this part shows AUD_W being the direct input to the SN.
Those schematics show the ready output of the sn76489 is connected to the wait on the CPU. The sound chip datasheet says that ready will be held low until the load is complete. So that will get the minimum load time. The CPU will stop until ~wait is released. This could be many bus cycles. The ready is not connected on a BBC so you have to wait the full 8us for reliable latching.

User avatar
simonm
Posts: 209
Joined: Mon May 09, 2016 2:40 pm
Contact:

Re: SN76489 best sample playback?

Post by simonm » Fri May 11, 2018 9:31 pm

Yes, the SN data sheet says this:
7. DATA TRANSFER
The microprocessor selects the SN76489AN by asserting !CE (active low). Unless !CE is asserted, no data transfer can occur. When !CE is asserted, the !WE signal strobes the contents of the data bus to the appropriate control register. The data bus contents must be valid at this time.

The SN76489AN requires approximately 32 clock cycles to load the data into the control register. The open-collector READY output is used to synchronize the microprocessor to this transfer and is pulled low immediately following the leading edge of !CE. It is released to be pulled high (by an external pullup resistor) when the data transfer is complete.
Presumably that 32 clock cycles is whatever clock is driving the SN (4Mhz on a beeb).

User avatar
SarahWalker
Posts: 1108
Joined: Fri Jan 14, 2005 3:56 pm
Contact:

Re: SN76489 best sample playback?

Post by SarahWalker » Fri May 11, 2018 9:35 pm

ThomasHarte wrote:
SarahWalker wrote:
ThomasHarte wrote: I had always assumed that volume changes take effect immediately, not being bound to the tone-generator clock. Is that not the case?
I haven't really studied this massively in depth. However the behaviour I've seen when the SN's write signal isn't held for long enough, where it will seem to randomly discard bytes, suggests to me that new data is only latched in at one cycle in 32. Which would have essentially the same effect.
On the ColecoVision the system clock is 3.58Mhz, the SN is clocked at half that, and writing to the SN is an ordinary Z80 OUT instruction. There's no intermediary with a memory — all that sits between the CPU and the SN is a 74LS128 for mapping from three-bit binary to individual signals. The Z80 machine cycle that signals the writing part of an OUT lasts four cycles, but the write signal is active for only a bit more than 2.5 cycles.

Therefore the SN can definitely accept a very short write signal — 2.5 cycles @ 3.58Mhz. Definitely a lot shorter than 32 cycles, and prone to suggest that the SN can accept a new value within at most 1.25 of its own cycles.
Well on the Beeb you have to manually write to ~WE through the System VIA, and you have to hold it low for at least 8us or you lose data. The OS has a loop in the sound write function to do this, I've verified this with my own coding, it's mentioned in both the AUG and the SN76489AN datasheet. I'm pretty sure I'm not making this up!

User avatar
tricky
Posts: 2764
Joined: Tue Jun 21, 2011 8:25 am
Contact:

Re: SN76489 best sample playback?

Post by tricky » Sat May 12, 2018 6:08 am

I vaguely remember that I played with setting frequency to 1 years ago, but I don't think it works, although I think it does on some other versions of the chip.
On another version, I believe that the bit sequence is reset when setting the noise frequency, so that that can also be used to get a steady output to play samples. I think jsbeeb may model this version, but that and my other memories may be wrong.

User avatar
1024MAK
Posts: 7869
Joined: Mon Apr 18, 2011 4:46 pm
Location: Looking forward to summer in Somerset, UK...
Contact:

Re: SN76489 best sample playback?

Post by 1024MAK » Sat May 12, 2018 9:15 am

There are a number of variants. This Wikipedia page explains the differences ;-)

Mark
For a "Complete BBC Games Archive" visit www.bbcmicro.co.uk NOW!
BeebWiki‬ - for answers to many questions...

User avatar
SarahWalker
Posts: 1108
Joined: Fri Jan 14, 2005 3:56 pm
Contact:

Re: SN76489 best sample playback?

Post by SarahWalker » Sat May 12, 2018 10:56 am

The SN76489AN used in most (all?) BBCs does indeed reset the bit sequence when writing to the noise control register. I know the NCR 8496 does not (this is required by the LucasArts Tandy music driver), not sure about the other chips.

User avatar
1024MAK
Posts: 7869
Joined: Mon Apr 18, 2011 4:46 pm
Location: Looking forward to summer in Somerset, UK...
Contact:

Re: SN76489 best sample playback?

Post by 1024MAK » Sat May 12, 2018 11:33 am

Photos from three different issue 7 Beebs:-
IMG_7050.JPG
SN76489AN in an issue 7 BBC B
IMG_7049.JPG
SN76489AN in an issue 7 BBC B
IMG_7048.JPG
SN76489AN in an issue 7 BBC B
The earliest Beeb I have is an issue 3, but that one is somewhere in storage...

Mark
For a "Complete BBC Games Archive" visit www.bbcmicro.co.uk NOW!
BeebWiki‬ - for answers to many questions...

User avatar
tricky
Posts: 2764
Joined: Tue Jun 21, 2011 8:25 am
Contact:

Re: SN76489 best sample playback?

Post by tricky » Sat May 12, 2018 11:48 am

SarahWalker wrote:The SN76489AN used in most (all?) BBCs does indeed reset the bit sequence when writing to the noise control register. I know the NCR 8496 does not (this is required by the LucasArts Tandy music driver), not sure about the other chips.
Most then as I have one that doesn't and seems to be factory fitted.

ThomasHarte
Posts: 467
Joined: Sat Dec 23, 2000 5:56 pm
Contact:

Re: SN76489 best sample playback?

Post by ThomasHarte » Sat May 12, 2018 4:04 pm

cmorley wrote:
ThomasHarte wrote: Therefore the SN can definitely accept a very short write signal — 2.5 cycles @ 3.58Mhz. Definitely a lot shorter than 32 cycles, and prone to suggest that the SN can accept a new value within at most 1.25 of its own cycles.

Schematics:
The 74LS128 is slightly to left of centre at the bottom of here. Note AUD_W out. The top of this part shows AUD_W being the direct input to the SN.
Those schematics show the ready output of the sn76489 is connected to the wait on the CPU. The sound chip datasheet says that ready will be held low until the load is complete. So that will get the minimum load time. The CPU will stop until ~wait is released. This could be many bus cycles. The ready is not connected on a BBC so you have to wait the full 8us for reliable latching.
Agreed; I had completely missed that connection.

The data sheet is actually completely explicit, on its front page: "Part SN76494N is identical to the SN76489A except that the maximum clock input frequency is 500kHZ. A "divide-by-eight" stage is deleted from the input circuitry and only 4 clock pulses are required to load the data, compared to 32 pulses for the SN76489AN"
Last edited by ThomasHarte on Sun May 13, 2018 3:36 pm, edited 1 time in total.

Post Reply