April 26, 2015

zxsp 0.8.pre26: hE(ll)(oo) k(ee)(OO)

Got it?

"Hello Kio !"

Yeah, my Spectrum speaks.

Inspector for the Currah µSpeech digital speech unit
Thanks to the work of Joe Zbiciak and Frank Palazzolo, who had reverse engineered the SP0256 speech processor, i was able to implement an emulation of this chip and then of the Currah µSpeech interface in zxsp.
The SP0256-AL2 contains a cascade of six 2-pole filters, a rom with filter coefficients for British/American language and a micro sequencer, which feeds these values into the filter coefficients. All digital. The output is an 8 bit PWM.

Despite of the very comprehensive informations about the SP0256 chip on their website there were still some bits not clear to me. I filled in the gaps by own tests and looking at what other people did. (not too many of them…) And i emulated the double RC filter after the PWM output. Yeah!

I added an option to switch between the original 8 bit sound and the unrestricted approx. 14 bit output, but i can't hear any difference. :-)

At the bottom of the inspector widget i added a scroller which displays the spoken allophones.

Though most allophones are spoken as expected, i believe some are emulated wrong, e.g. "1" and "Y" sound a little bit like a "bass bump" and "?", spoken as "kw(ee)r(ee)", sounds more like "kneenee". But there is little i can do about this.

I found that there are three pairs of allophone tokens in the µSpeech unit which refer to the same allophone: "(ck)" and "(gg)" which refer to KK2, "(oo)" and "(eau)" for OW and "(aa)" and "(ay)" for allophone EY. On the other side, tokens for two allophones are missing: DH2 and GG2. Given the fact, that "CLEAR" and "CLS" are both spoken as "CLEAR", the µSpeech seemed to be released a little bit fast these days.

Technically the Currah µSpeech isn't a Z80 peripheral. It's more like a 6502 add-on. It uses memory-mapped i/o! I had to extend my Z80 emulation to handle that sort of things…

Final problem was the rom switching for this little beast: It toggle's between it's 2k rom and the ZX Spectrum's internal rom when a RST7, that is, when the regular timer interrupt is executed. Actually, the way i handled rom switching up to now could not handle this: It detected an opcode fetch at address 0x0038 in one rom, switched the rom and restarted the CPU at this address. Then it detected an opcode fetch at address 0x0038 in the other rom, switched the rom and restarted the CPU at this address. And so forth.

A final word about the Blog Editor: It's getting worse every day i write my next post. It's really so bad now, that i write my blog post in a text editor on my Mac and copy&paste it into this editor.


  1. Hi,
    I just recently found out that zxsp is supporting the Currah uSpeech and tried it.
    It's great!
    But unfortunately I haven't been able to start a program that supports uSpeech.
    If I enable uSpeech I cannot load load a game anymore. E.g. I tried with Maziacs from worldofspectrum (tzx and tap). It will not load anymore once that uSpeech is enabled.
    Please help ...

  2. The problem with Maziacs is probably that it is CODE not a PROGRAM.
    you must type LOAD "" CODE to load it.
    I just tested it and it works.
    Greetings, Kio !

  3. Ok. I can load it now. Thank you.
    But I thought it supports the Currah uSpeech, but I don't hear any speech.
    (The Currah emulation as such is working, but not with this game. Or there is no speech in the game...)

    1. yes, i also cannot hear any spoken words in this game.
      Also the ads don't mention µSpeech support and i would have expected that they would do this then. Eventually there is some surprising speaking at the end of the game? If you find a place where it speaks or if someone can prove it speaks on the real device please let me know.

  4. The reason why I'm trying to get this to work is actually because I'm doing some (retro) enhancement to one of my old ZX Spectrum games: I would like to add speech output. But from the documentation of the Currah speech interface I see a big problem the way how it is implemented: It uses the data at top of the physical RAM and I'm using the same area for the interrupt.
    From what I understand is that the Currah uses the SP0256 which itself works with allophones. So I guess all the other magic (rom switching etc.) is just to turn sentences/strings into allophones.
    I don't need that. I would rather like to program the allophones directly.
    Do you know if that is possible?
    Is there some kind of port to write the data to and read when the next allophone can be spoken?
    I have looked the web but there is actually quite little information available.

    1. from the zxsp source:
      this is probably what you need.
      ATTN: these are memory, not i/o addresses!

      // bytes (6 bits) written to this address are played:
      // reading returns the busy state: bit0=1 => busy (either LRQ or SBY)
      #define PLAY_ALLOPHONE_ADDRESS 0x1000
      #define READ_BUSY_STATE_ADDRESS 0x1000

      // writing to $3000 or $3001 set's intonation to low or high
      #define SET_INTONATION_LOW_ADDRESS 0x3000
      #define SET_INTONATION_HIGH_ADDRESS 0x3001

    2. and executing (reading?) address 0x38 toggles the µspeech rom in and out.

  5. That's the information I need.
    Thanks verry much.