Maybe you could upload/attach a sample piano sound.
The easiest way would be to use a player with zx sound emulation (google it).
The original sound chip has 3 voices (so tie 7 fingers back onto your palm…)
The waveform generated is a square pulse.
You could duplicate your melody, shift pitch them such that they have the right partial spectrum (and amplitude).
Additionally, you have to limit the dynamic range to 4 bits. Easily done in the Nyquist prompt.
(quantize s 16)
Each voice can have a pseudo noise mixed to it.
That’s also a square pulse with variable pulse width.
It is clear that a piano produces a totally different harmonic content than a square wave.
It means that we should firstly extract the fundamental frequencies of your melody and then replace the whole tune with notes that are built up from square waves. Quite hard to do in order to sound authentic.
As I mentioned before, a Emulation will give the most realistic results.
The following Sound chip Emulator can handle different media types. Some tracker it works with are listed on the site. http://bulba.untergrund.net/emulator_e.htm
It will Need some reading and experimenting to achieve the desired result.
Here’s an interesting function to Play with (similar principle as decimator)
The first number after ‘reduce’ is the amount of samples that are averaged and the second one tells how many samples you want to advance (and skip if it is greater than samples).
high values (20 and 40 for example) give produce interesting bass lines, which really Sound “Retro”. Pac-man greets…
(defun reduce (sig samples step)
(force-srate 44100 (snd-avg sig samples step op-average)))
(multichan-expand 'reduce s 10 20)