“Hardware sound” is the generic name given to the envelope generator. It is probably the most used of the “advanced” tricks of the AY/YM. However, mastering it is not that easy, especially if you’re not aware of the high limitations it has. You should read the first tutorial of this website about understanding the PSG beforehand, but since you’re here (and I’m a nice person), here’s a little summary:
- There is only one hardware envelope generator. This is the most important of all these bullet points.
- The generator can be used on any channels, i.e. one or more.
- If using the generator on more than one channel, all these channels will use the same hardware envelope and hardware period (the software period remains their own).
- The generator is only changing the volume of the channel(s), according to its own period.
- When using the generator, the volume of the channel is managed only by the generator, you cannot set a volume on your own anymore.
- There are 8 different shapes (or curves), looping, looping in reverse, or staling. But they always go from 0 to 15 or the opposite, which is probably the biggest limitation. There are no build-in ADSR curves like on more advanced PSGs, and you cannot make a curve go from 5 to 10. No, no, no.
- Once the envelope starts, it can be started again at any time (technically, by feeding the PSG with the same curve number again). It is what we call retrig.
- The goal of the PSG engineer was probably to relieve the developer from changing the volume by himself. Sadly, the generator is so limited there is no incentive to use it as-is in a song. Unless…
- You are involved in a size-coding production.
- You want to trigger a long decaying hardware sound while loading a file! As Zik did in the great Ghost Nop demo…
- Software periods are encoded on 12 bits, hardware periods on 16, so they are technically more accurate.
- Remember the PSG deals with periods, not frequencies. The higher the frequency, the lower the period. This has some very real consequences: the period is just a decreasing integer counter: when it reaches 0, the PSG starts a new cycle, hopefully producing a sound at the right frequency. But what if the counter is not accurate enough, and the real frequency lies between period 45 and 46? Well, no luck here, the sound will be out of key. Faster PSG (such as the YM running at 2 Mhz) will have less problems than a slow CPC PSG (1 Mhz), but it will have problems anyway.
So now you’ve understood it, the envelope generator is pretty limited, but its real strength resides in tricking it into something it wasn’t designed for.
As seen in the tutorial mentioned above, by synchronizing the period of a square generator and the envelope generator (typically with a ratio of 2^x, with x = 4 or 5 being the most common. That is, the hardware period is 8 or 16 times faster than the software one), we get a square sound that is modulated by another waveform, creating a whole new sound:
Simple sounds for starters
Let’s start the journey with the simplest, classical, yet very nice, “curve 8 (descending sawtooth), ratio 4”. In the Instrument Editor (IE), it would look like this:

There is only one looping column. The sound type indicates “software to hardware” (square to hardware envelope), meaning that the primary period (the software period) comes from the music score (i.e. the notes of your music), and the secondary period (the hardware period) is calculated from it. Other sound types are explained below. The envelope, as you can see by the little drawing, is the descending sawtooth, using a ratio of 4.
And by going from octave 1 to 5, it would sound like this:
Inaccuracy?
The four first notes sound great, but awww, the fifth really bad. Why? Because the higher the note, the smaller the period, so the bigger the possible inaccuracy. You hear the “mwwwaaaaaah” sound that we like so much? Well, it happens because of the inaccuracy! So a bit of it is ok, but too much is meh!
Let’s dive a bit into numbers. The software period is calculated in real-time, but you can find it in your CPC manual too (what a great book it was!).
The hardware period is the software period divided by 2⁴ (=16), as stated before, because we use a ratio of 4.
Note | Software period (1 Mhz PSG) | Hardware period, theoretical | Hardware period (1 Mhz PSG) | Error |
C-1 | 1911 | 119.4375 | 119 | 0.4375 |
C-2 | 956 | 59.75 | 60 | 0.25 |
C-3 | 478 | 29.875 | 30 | 0.125 |
C-4 | 239 | 14.9375 | 15 | 0.0625 |
C-5 | 119 | 7.4375 | 7 | 0.4375 |
The player doesn’t use decimal numbers, because the PSG doesn’t, so it rounds to the higher integer. As you can see, nothing is perfect and the error value goes high or down according to the notes. The funny thing is that the error value for C-1 and C-5 is the same, but C-1 sounds good and C-5 does not. Why? Because the period of C-1 is higher, so there is less room in the signal for the error to be heard.
Interestingly, here is the same sound with a 2 Mhz PSG, so twice faster than that of the CPC, like you would find on Atari ST (though they have a YM, not an AY!):
It sounds mostly much more accurate (less “mwwwwwaaah”), especially the last note. And the periods look like this:
Note | Software period (2 Mhz PSG) | Hardware period, theoretical | Hardware period (2 Mhz PSG) | Error |
C-1 | 3822 | 238.875 | 239 | 0.125 |
C-2 | 1911 | 119.4375 | 119 | 0.4375 |
C-3 | 956 | 59.75 | 60 | 0.25 |
C-4 | 478 | 29.875 | 30 | 0.125 |
C-5 | 239 | 14.9375 | 15 | 0.0625 |
Interestingly, the notes with most errors aren’t the same as with the CPC. And their software period is much higher, making the error less noticeable.
Did you notice that for the same note (C-1 for example), the periods are doubled! Since the ST YM is more accurate, you can imagine that the range of the periods are stretched across the 12 bits of the software period, thus giving more accuracy.
Solutions against inaccuracy?
Is there something we can do against it? Well, yes and no.
- The CPC is the slowest of the pack: its AY runs at 1 Mhz, so the periods must be smaller to produce higher-pitched sounds: calculation with small numbers will provoke miscalculations. So one solution is to change your hardware! This might not be the solution you’re asking for…
- You can change the frequency reference in your subsong properties. This is not something we usually do (on CPC), but that I’ve seen on Spectrum… and in some Dave Rogers’ songs. By changing the frequency of the reference note (C-4), from 440 to another one, you might find that the error is shifted and it might be useful to your song. It also involves using another period table, which takes more memory if you need several specific tables for various songs. Also, people with the perfect pitch ability will cringe, but hey…
- By decreasing the ratio, you have less inaccuracy. But it won’t sound the same… Sometimes you will use one ratio for a specific note to counter an off-key sound. The listener might not notice.
- Adding a vibrato or some effect might hide the inaccuracy, as we’ll see below.
Other basic sounds
The most basic thing you can do is simply change the waveform and the ratio:
- The two sawtooth curves are more “aggressive”.
- The two triangle curves sound smooth and are perfect for more ambient sounds.
Which to choose between two curves of the same type? There is no difference when using them stand-alone, so they are interchangeable most of the time.
For now, here is a different bass line using, with a ratio of 5, first the sawtooth curve, then the triangle curve. Notice how the second is less aggressive:
Alternating curves and ratio
Creating original sounds isn’t complicated, and one way of doing it is by changing quickly the curve and/or the ratio. Here is an interesting answer to “what two curves of the same type are for”?

The speed has to be set to 4, less would sound to harsh, but it really depends on what sound you want.
Sound types
So far, and in most hardware sound examples, we’ve used the sound type “software to hardware”, because it’s the most typical and, well, it works fine 99% of the time!
But let’s delve a little more and explore the other possibilities. First, you should read the sound types and what they are up to.
Hardware-only sound type
This is not an often used sound type, but it has a very unique personality. When used, the software square wave is not produced at all. So only the hardware envelope is generated. This has two major consequences:
- It sounds much softer than the classical soft-to-hard, which is why it can be overwhelmed if used along loud instruments.
- Since there are no other signal to be coupled with, it cannot be desynced. So it is a stable, mwaaaah-less sound.
The two sounds use the shape triangle and sawtooth, respectively:
![]() | ![]() |
But this sound type may not be suited to high-pitched sounds, as inaccuracy strikes it badly.
Hardware-to-software sound type
This sound type is like software-to-hardware, but the hardware period is calculated first from the music score, then the software period is multiplied by the desired ratio. As a multiplication is used, there is no rounding, so no inaccuracy, so no mwwwwaaaaahh sound. Just like hardware-only, it is a perfectly stable sound, but with both the software and hardware sound.

Going into higher-pitched sound will sound off-key. Why, you think, as you thought the hardware period was more accurate? Yes indeed, but by multiply it with a ratio, we may actually miss the right software period. If we take the C-1 note from the table above as an example, the hardware period is 119, which we multiply by 16, giving 1904. Ah! But the software period should be 1911! So there, we are off-key.
Also, the sound may feel a bit flat as-is, so what about adding our very own controlled mwwaaahhh? It is simple: add a pitch value in the secondary section. It will be added to the software period! Indeed, in a hardware-to-software sound type, the primary section relates to the hardware, the second to the software:

Software-to-hardware sound type
Last but not least, this sound type is for rather specific needs. Both period calculations are independent, so you can for example, force a hardware period, or add an arpeggio to the hardware period only. It allows you to go beyond the “ratio rule” that was performed in the soft-to-hard and hard-to-soft sound types.
One first example is indeed forcing the hardware period, which Ben Daglish was famous for in most of his songs.
The first part is done by forcing the hardware period to 1, the second to 2:
![]() | ![]() |
Another unique possibility with this sound type is setting one of the period to its own, via a arpeggio, thus creating some kind of polyphony:
Such sound is built like this:


This is not the sound you hear every day!
Hardware melody
Musicians have a tendency to use the hardware envelope only for bass, because, as we’ve seen in our example earlier, high frequencies don’t sound good. That’s not always the case!
The problem is the ratio that is too high. But if you set it to a lower value, you can do great stuff. Here is a raw example using the low ratio of 1, sawtooth, starting at C-0, going octaves higher, and playing a melody:

Some notes don’t sound right, so you may be limited, but there is one trick to correct that: using a vibrato to “hide” the inaccuracy. Read on…
Add some effects!
Many musicians simply don’t think about adding effects to the hardware bass. There are some reasons why:
- They lack imagination.
- Their software simply doesn’t allow changing the hardware period every tick.
- Their software doesn’t automatically calculate the hardware period from the software one, so adding a vibrato, for example, wouldn’t sound good.
A good thing such musicians have now discovered AT 🙂 !
Adding vibrato
Let’s add a vibrato to a hardware bass:
Not bad, he? The tricky part is to get the amount of vibrato right. Here is the pitch table I used:

As you can see, it uses quite large values. If I’d used smaller ones, you wouldn’t have heard the vibrato. However, such pitch will not sound right for high-pitched sound. So you will probably have to create several vibratos according to the frequency of your notes. The higher the pitch, the smaller the vibrato frequency range.
Here is a hardware melody with a small vibrato (you don’t want to hear it with the large vibrato above!):

On top of sounding rather original, the vibrato helps hide the lack of accuracy of the periods, so it’s a good trick to play melodies without them sounding too cringy.
Adding arpeggio
One other effect that I almost never heard (besides in my own songs) and that we presented in an example above, is an arpeggio coupled with hardware sounds. It is so effective!

Two things to notice:
- Most of the times, such sounds will not sound right at full speed. Here, I used a speed of 3, though faster speeds may give yet another special effect.
- I suggest that such arpeggio should however be encoded within the instrument itself, not besides using an arpeggio table. Why? Because in order to sound good, the ratio often must be adapted to the octave/semitone change, and it’s much easier to tweak that in one place.
Here is another example using a full chord:

Attack attack!
One thing you may have noticed while playing with hardware sound is that it might lack a bit of “attack”. Sure, the generated volume keeps changing, but the average volume is the same, so the start of the sound may not be as noticeable as if you’d created a simple software sound with the good old 15-14-13-13-13 curve. There are at least two tricks to it.
Attack with another type of sound
AT gives you the possibility of starting your sound with something, but not loop on it afterwards. One thing I often do is start my hardware sound with a software frame:

Notice that the sound loops only on the second column. Depending on your sound, you may need to make an octave jump on the software period, but that’s up to you to test.
Retrig
As said at the top of this page, the hardware envelope can be restarted at any time. This is called retrig, and AT gives you two ways of doing it. Both are explained here, so I won’t write the explanations again, but here is how it sounds like:
You can also add retrig on any column, such as the chord we saw earlier, and see what happens. It might sound good… or bad!
Hardware sound on multiple channels
This is a lengthy subject which I will only scratch here, as many experimentation can still be done.
As we’ve seen, there is only one hardware generator, but it can be applied on as many channels as you want. The hardware period and envelope will be the same on every channel. If the software periods are synchronized, all will be fine. If not, it will probably sound bad, yet some musicians managed to produce interesting things with that.
Priority
AT manages its channels from the first to the last (I’m talking about the index, not the stereo positioning. Some PSGs have their channel 1 on the right). It means that, in the user interface, the track on the left has less priority than the one on the right. So if one sound in the channel 1 uses a hardware sound, and the channel 2 another one, they will both use the hardware period and envelope of the channel 2. This notion is important if you want to mess with using several hardware sounds.
Several channels test
Let’s try to have several hardware sounds! We’ll start with something simple:

From line 0
to 4
, we add the same hardware sound to all channels. This sounds right, because the notes are the same, so both software and hardware periods are in sync.
On line 6
, the leading channel (the third one, with the highest priority) goes to octave 3: it still sounds right because the hardware period, though doubled too, is still a multiple of the software periods of all the channels.
Trouble comes on line 8
: the first channel uses another software period, but the hardware period doesn’t change accordingly: the third channel has priority and won’t accept that. So the channel 1 sounds like crap.
Same thing on line A
: the second channel gets in trouble too.
Then the miracle happens on line C
: the third channel uses the same software/hardware period as the two other channels, which are now in sync.
Harmony through desync
There are a few cases where channels can naturally sound right with multiple hardware sounds:

Sounds nice, eh? Such “miracles” can be found by testing, or probably by calculation, which I’m not interested in doing (!). This kind of relates to what we did before with one channel only, using the sound type “software and hardware”.
Alternating channels
One trick I also used but actually never saw anywhere (should I patent it?), is to quickly alternate the hardware between the three channels. Only one at a time will use it, so there will be no desync, but it still adds an original sound to the music. Here is an example from the menu music I did for Axelay’s Star Sabre 128k (which you can find in the AT package, in the STarKos folder):
The lead sound looks like this on channel 1…

… and on channel 3:

And the bass on channel 2 produces its hardware bass on ticks 4 and 5. No clash, and it sounds original and great!
Bonus
As a bonus of what can be done through experimentation, here a four-channel sound using three channels of hardware sound, from Sparklite’s Amstrad Export 2005 cheat part demo:
It may not be the typical sound you’d use in a song, but it sure proves that many things can still be done!
Wrapping up
This is the end of this tutorial, which, I think covers most of what can be done with AT! Now go experiment, have fun, and create great music!