Reworking the music


When I first started porting Spellbound to the MSX, I took the ZX Spectrum 48K as the main reference for both the graphics and the game logic. Once I had a working version, I decided to add the original background music (that wasn't present in the 48K version). The most logical version to take the music from was the Spectrum 128K and that's exactly what I did.

However, as a long-term musician, after listening the music for hours I felt something was wrong with it. The voices seemed not well synchronized, some accidental notes sounded a bit weird and the whole arrangement was a mess. I verified that all these issues were in the 128K version already and were not caused by a new bug. So, I decided to listen to other versions of the excellent tune composed by Rob Hubbard to understand what was going on. Here are my findings:

MSX/Spectrum versions are 2 semitones lower

The original score (the C64 one) is in E-minor, while the MSX version sounds in D-minor. That's exactly two semitones lower. However, the Amstrad CPC version (since it's Z80-based, its almost identical to ZX and MSX) is in the correct key.

What's happening here?

This issue is a well-known one: the Z80 version was coded in an Amstrad CPC and then ported to the ZX Spectrum 128K. The AY-3-8910 sound chip (also known as PSG) used by the CPC, ZX and MSX is synced to the main Z80 clock, but this clock is slightly faster on the CPC (4 MHz) than the MSX and Spectrum (3.57 MHz). In the world of music, a faster frequency means a higher pitch. The difference between 4 and 3.57 MHz is enough to cause an undesired 2-semitone transposition. 

The fix is very easy. The playback routine includes a look-up table to convert musical notes to its frequency, and it's stored in the PSG register format (the greater the number, the lower the frequency). If we apply an inverse cross-multiplication to each value in the table, we will get the necessary values to raise the music score by 2 semitones. Thus, F' = (F * 3.579545) / 4.

BEFORE AFTER
D4 dw #17B E4 dw #153
D#4 dw #166 F4 dw #140
E4 dw #152 F#4 dw #12E
F4 dw #13F G4 dw #11D
F#4 dw #12D G#4 dw #10D
G4 dw #11C A4 dw #FE
G#4 dw #10C Bb4 dw #EF
A4 dw #0FD B4 dw #E2
Bb4 dw #0EF C5 dw #D5
B4 dw #0E1 C#5 dw #C9

Extreme legato (notes are 'glued')

Normally, music notes are articulated (in a similar way syllables work in a speech). Thus, the beginning of a note is somehow differentiated from the tail by changing its amplitude, pitch or timbre or just by adding a small gap between notes. When there is no noticeable (or little) separation between notes, it is called legato. It is an expressive technique well known by any music performer. 

However, this can affect the melody in a bad way. If the legato is total, short consecutive notes are indistinguishable from one long note. This is exactly what happens to the Z80 version of Spellbound's background music:

  sounds identical to 

This is why the melody is a bit confusing. Try to learn and sing this tune and you will be in trouble.

How can this be solved? Sadly, the playback routine is designed to set a frequency during a given number of interrupts (each interrupt lasts for 20ms in a 50 Hz system) but no changes are made to amplitude (volume) of the note. This makes impossible to fix the problem just by editing the music data. A new playback routine and a new data format are required to rewrite the tune properly.

Or not.

What if we take advantage of the PSG capabilities? This chip has a volume envelope/LFO feature that can help sculpt notes without any software modification. Let's try the experiment:

What do we have now?

The bass-line sounds clearly defined revealing a new rhythmic pattern that had always been there but it wasn't noticeable because of the legato. However, this reveals new problems as well. With the rhythmic pattern, we  now have sort of a metronome. It is quite clear that the main melody has tons of encoding mistakes. When the main phrase is played for the second time, now the bass voice is clearly unsynced to the main melody. What a mess...

At this point, it is clear that a full rework of the music is needed. Not an easy task since all the disassembled data is organized in a structure of chunks/pointers that require further analysis.

To be continued...


Get Spellbound MSX

Leave a comment

Log in with itch.io to leave a comment.