So I tried to shrink this program even more. There are those two lookup tables in there, one with frequencies of the notes and one with octaves. By sorting the notes and replacing the frequencies with a simple formula (Wolfram Alpha helped me to come up with it), I got:
120 + (354 + a * 6363 + a * a * 293) // 1000
Very happy with it, I put it in my program. BAM! 500 bytes larger.Why? Well, I blame 16-bit division and modulo that i had to use...
Discussions
Become a Hackaday.io Member
Create an account to leave a comment. Already have an account? Log In.
Looks like a clever solution... what about using that, or similar, to calculate a table that's loaded into RAM?
Are you sure? yes | no
Ah, just saw your previous log... yeah might be difficult to beat those tables.
Are you sure? yes | no
The problem is that the code to generate them is larger than the tables :-) I could probably rewrite that to calculate the polynominal iteratively instead of using multiplication and division (something like the Bresenham's algorithms), but I think it's still not worth it for 8 bytes.
Are you sure? yes | no