Skip to content
joric edited this page Aug 17, 2020 · 36 revisions

Welcome to the libpt3 wiki!

This is in a testing stage, no library, just a bunch of code and benchmarks, but you can use it.

Benchmarks

Results so far (use bash benchmark.sh 2>results.txt):

shiru, pt3 reader, ts: 0, frames: 5376, loop: 384
0.000000 seconds
zxssk, pt3 reader, ts: 0, frames: 5376, loop: 0
0.000000 seconds
ayemu, ay render, frames: 5376, writing wav...
0.203125 seconds
shiru, ay render, frames: 5376, writing wav...
0.125000 seconds

Shiru player is far from accurate but it's 40% faster (!)

Looks like Shiru uses 16 volume leves instead of 32, that might speed up the mixing. But envelopes are absolutely broken.

Using separate variables for each channel instead of loops appear to affect rendering time as well. Code overhead is so small that unrolled loops make a lot of difference. Example:

Replacing this:

if (ay->tone[0].count >= (ay->reg[0] | (ay->reg[1] << 8))) {
	ay->tone[0].count = 0;
	ay->tone[0].state ^= 1;
}
if (ay->tone[1].count >= (ay->reg[2] | (ay->reg[3] << 8))) {
	ay->tone[1].count = 0;
	ay->tone[1].state ^= 1;
}
if (ay->tone[2].count >= (ay->reg[4] | (ay->reg[5] << 8))) {
	ay->tone[2].count = 0;
	ay->tone[2].state ^= 1;
}

With this:

for (int i=0; i<3; ++i) {
	if (ay->tone[i].count >= (ay->reg[i*2+0] | (ay->reg[i*2+1] << 8))) {
		ay->tone[i].count = 0;
		ay->tone[i].state ^= 1;
	}
}

Makes the whole rendering loop about 5% slower (at least with gcc -O3 on x86).

TODO

  • 100% match AY register data for all the pt3 parsers
  • fix envelope generation in the shiru ay rendering code
  • move mixer code out of the ChipTacts_per_outcount loop
  • optimize for mono output (don't need stereo mixer for mono)

References

Clone this wiki locally