I managed to find some samples, although I’m not sure how good they are. Anyhow, I created a simple instrument that will play back the recorded sample, along side the synthesised sound so I could compare them. The synth sounds goes out the left channel while the sample is fed out the right. The code looks like this:
instr 2
//graph said piano sound was with 70% PWM
aOut vco2 p5, cpsmidinn(p4), 2, .7
//send signal through high-pass filter
aOut butterhp aOut, 60
//chain low pass filters for more slope
aLp tone aOut, chnget:i("cutoff")
aLp tone aOut, chnget:i("cutoff")
//play original samples
a1, a2 diskin2 "122673__acollier123__piano-g-low-short.wav", 1, 0, 0
//create env follower for original sample
aEnv follow a1, .01
//output needs some scaling
outs aLp*aEnv*chnget:k("gain"), a1
//display waveform
display aLp, .1, 2
endin
The code is pretty simple as you can see. The first thing I do is create a square wave with a 70% duty cycle, as per the site you linked. I then send it through a high-pass filter as the sample I’m working with has no energy below 60/70Hz. I then chain the signal through 2 low pass filters. You can try with just one, but two gives a better roll-off. The the sample is loaded from disk. As I don’t want to bother working out the ADSR elements right now, I use the follow
opcode to generate a simple envelope from the sample. I then apply a bit of amplitude scaling before outputting and displaying the waveform.
In the Cabbage patcher I load Voxengo’s free SPAN FFT plugin. This gives me a nice way of viewing the similarities between the left and right channels. As you can see, it’s not perfect, but for 10 minutes of work it’s not that bad.
I’m not sure how much success one might have modelling this, without actually having access to the device. Here’s the full instrument code.
CASIO-VL-1.csd (1.5 KB)