
Casio CT and MT deep dive
The venerable D938GD/D937GD/CTD109 based keyboards from Casio, they are a lot more fun than they let on.
From the outside they look like simple ROMplers, it even says "PCM" on the front!
Looks are deceiving however as internally there's a rather complex softsynth that can use samples, FM and even an early Phase Distortion called "Triangle Modulation". Yeah... Casio CZ style synthesis perhaps?
And it has envelopes that are defined by points, rather than ADSR, which allows for insanely complex envelopes.
So lets reverse-engineer the sound engine and make the presets customizable, shall we?
CT-380 ROM DUMP: download here.
MT-540 tech info: Weltenschule page.
THIS PAGE IS A WORK IN PROGRESS!
The Hidden Synth
The CT and MT series of keyboards were (one of) the first fully digital Casio keyboards, marketed as "Tone Bank". Instead of trying to stuff hundreds of presets onto ROM these new keyboards featured only 10 to 30 presets but with the ability to layer two of them. This lead to some marketing blurbs as "200 tones!" etc, because they tended to advertise the preset combinations as unique presets rather than just layers. A bit of false advertising, but you gotta make the line go up I guess.
There is quite a bit of hardware variation within these series, but there's a bunch of them that used the same hardware and special synthesis engine. As far as I know these are the MT-240, MT-540, MT-640, CT-370, CT-380, CT-460, CT-637, CT-650 and CT-670. Hohner also rebranded some of them as the PSK-30, PSK-50 and PSK-55.
The Casio Loopy gaming console/PC also uses a CTD109/D937 sound chip and it looks like they basically stuffed a CT-670 in there, but without the keyboard and buttons of course, that is controlled by the CPU via MIDI. Very janky way of doing it and it only allows the games to use the preset sounds but... It works. This also means a lot of info can be found via the various emulations of the Loopy.
I have the CT-380 and I love it. Also want to buy more... Both as backup and research.
These are one of the best sounding "toy" keyboards, with very dynamic and rich stereo sounds. The samples seem high quality with very little aliasing or grainy noise. Some samples are surprisingly realistic and detailed, such as the piano (which uses 7 split zones/samples!) and cymbals. Other presets sound a lot like synthesis, rather than samples.
Lets unravel the reasons for these great sounds.
The PCM samples:
Both the CT as MT series (mostly) use the D938GD sound chip, along with one or two external 16-bit ROMs and a 16-bit stereo DAC. You can see the ROM and DAC of my CT-380 in the photo.
It uses uncompressed 16-bit samples, with a 21276Hz sample rate. The DAC is an LC7880, which is a 16-bit multi-stage DAC that employs various techniques to generate two analog signals. This DAC can do samplerates up to 88.2KHz, but I'm not sure what actual rate it's running at.
The samples can come in two main forms:
- Full sample, such as the piano, bass and drums.
- Short waveform sample, such as the vibraphone.
Samples are always linear interpolated by the sound engine. It seems a full 16-bit word is used for the interpolation as the patents describe the addressing consisting of a 16-bit integer and 16-bit decimal. The integer being the current ROM address and the decimal being the interpolation to the next ROM address.
The samples are pretty standard playback most of the time, but Casio did create a system that scans through the sample in a sort of "wiggle" pattern. This is described in patent "US4442745 - Long duration aperiodic musical waveform generator".
You can see a drawing from that patent to the left, with an example waveform and example scanning pattern. Using this technique only the attack and sustain (and optionally release) portions of a sound need to be sampled & combined into one very short sample.
Despite the sample being so short it can be extended indefinitely and without any obvious repeats. A great example of this is the cymbal and vibraphone sounds which can last a very long time without sounding unnatural. It does seem this system is not always employed, the piano for example seems to be more standard sample playback without any looping or wiggles.
It's all pretty sweet, but it's also all pretty semi-standard stuff for a ROMpler.
For some reason Casio decided to pull out all the stops and go a lot further with more synthesis techniques and truly crazy envelopes.
FM and TM synthesis:
The sound chip also has build in Frequency Modulation and... Triangle Modulation. Both use the same operator-based structure and seem to be primarily 2-operator based. Though more operators are possible as described in the patents.
To the left you can see the standard setup for the FM or TM synthesis.
We got OP2 as a modulator with feedback and OP1 as a carrier that is modulated by OP2.
For the FM synthesis it's very standard, though what's interesting is that the operator waveform used is stored in external ROM, thus any single-cycle waveform is possible. Since this waveform is not interpolated there are 3 versions of it on the ROM at different pitches. This way you don't get horrible aliasing in the higher notes.
Aside from the sine wave I also see many other of these waveforms on the ROM, but more on that later.
The Triangle Modulation is an interesting technique, that reminds me a lot of the Phase Distortion employed by Casio's CZ synthesizers. It's (probably) not the same, perhaps a predecessor, but still very interesting.
It generates waveforms by modulating a monotonous carrier function with a sine (or other) wave - decoding the signal by mirroring it at a triangular wave which is stored in ROM. I see many potential waveform candidates on the ROM, so I wonder which ones are used for TM.
When modulation depth is zero a clean (sine) wave is generated. As the depth increases the waveform becomes more distorted and more harmonics are generated. This generates more harmonics than FM does because at high modulation the wave peaks fold back into the opposite direction.
As I said it does remind a lot of Phase Distortion. Having made my own CZ clone (with upgrades) in the form of Dradique I recognize some of the techniques described in the patent, but it does seem to be a simplified precursor to the actual PD we got in the CZ synths. Still... Very cool!
The envelopes:
Envelopes are not ADSR, but instead are defined as "targets" and "rates". They can also have multiple defined loop points. Crazy.
The target values are 16-bit and define the offset to the next envelope point. The envelope will count to that point before moving onto the next. This target value is defined as "delta Y" in the patents.
The rate values are defined as 24-bit fixed point with 16 bits for the integer and 8 bits for the decimal. You can see these in the ROM as this "wiggly" envelope esque shape. It starts out logaritmic, until it reaches 32767 (halfway through 16-bit value) then it stays flat for a while before going into an exponential curve to max value.
I'm not sure what the reason for this is, probably to give a certain curve to the envelopes to make them sound more natural/analog?
Either way the rate determines if the envelope counts up or down to its next target value. This is defined as "delta X" in the patents.
Internally the volume envelope seems to be more complex, using the above described fixed point data and having a separate defined table for addressing the fixed point data. The pitch envelope instead seems to just use two 16-bit tables for the target and rate respectively.
The ROM Contents
TODO: this may take a while...
I only have the CT-380 and only ROM dumps of the CT-380 and MT-540, so this information will be entirely based on those. However most CT and MT keyboards have very similar sound sets so the ROMs will be largely the same. The parameter address spaces are likely the same too.
All analysis has been done with my WaveArrayGen software and REAPER.
The CT-380 ROM: 262144 words of 16-bits. About half of it is used by the piano and drums.
ROM contains (TODO: proper ROM map):
- boot config values
- tables for envelopes and pitches
- preset parameter values
- uncompressed 16-bit PCM samples (single-cycle waveforms, short wave samples or full samples)
- demo song data
- rhythm patterns data
Preset params (TODO: proper parameter map and preset values list):
Some presets can use two waveforms & params, I always see 2 address counters too so I suspect a 2 oscillator architecture.
- type: PCM, DPCM, TM, FM (multiple can be selected so prolly bitmasked)
- Key pitch offset data, used to address different versions of a sample for different notes.
- start address (2 words)
- end address (2 words)
- loop address (2 words)
- envelope targets for env delta-Y
Sample types:
- PCM long sample for simple playback, variable length
- Waveform sample for looped/wiggle playback, variable length but shorter
- Single-cycle waveform, 192 samples long but can be longer such as 1151 samples, 3 octaves, for FM/TM(?). Sometimes there isn't 3 octaves such as for Brass Ens, Flute and E Piano (uses 2 waveforms).
Making the Presets Programmable
TODO: this may take a while...
Prototype programmer:
Using two 32k 8-bit SRAMs to emulate the lower 32k 16-bit of the ROM. Use 4 8-bit tri-state buffers to gate the address and data buses to the mainboard.
More memory can be used but it's not needed for the prototype as all preset params and some of the preset waveforms are within 32k.
If all presets need to be fully modifiable including all samples the full 262144 words space needs to be emulated, which means 16 32k 8-bit SRAMs are needed...
Or an embedded board that has enough speed and memory to emulate the ROM with access times of ~150ns. OE is low for around 280ns. This concurs with the patent that describes the interrupt process taking that long.
The SRAMs are loaded with data by an Arduino on boot or when a parameter is changed. The Arduino sets its pins to input/high-impedance when idle.
Bus gating and CE is controlled via a logic OR gate, active low so if any of these are high the programmer is disconnected:
- front panel switch to turn the custom sounds on/off by switching between high and low.
- address bits A15, A16 and A17, when these are low it means the lower 32k is being addressed.
- Arduino needs to disconnect the buses from the main board to do its thing.
32K space presets including their samples in the CT-380 ROM, 16 total:
- Pipe Organ
- Brass Ens
- Brass Ens Pad
- Accordion
- Strings
- Strings Pad
- Sine Bass
- Bass
- Slap Bass
- Bells
- Dist Guitar 1
- Dist Guitar 2
- OD guitar
- OD guitar Pad
- Magic
- Magic Perc
All preset parameters and envelopes are within 32K but only the above also have their samples in that space.