Created
October 29, 2017 22:24
-
-
Save Jacajack/ee5bb24ee0c5298dfd5d035f1e1ff9a9 to your computer and use it in GitHub Desktop.
Scilab script for calculating AVR synth comparator values
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clear | |
fcpu = 20000000; | |
prescaler = 1; | |
samplesize = 16; | |
noterange = 1:88; | |
//Calculate timer frequency | |
ftimer = fcpu / prescaler; | |
//Calculate note frequencies | |
fnote = []; | |
for i = noterange do | |
fnote( i ) = ( 2 ^ ( 1 / 12 ) ) ^ ( i - 49 ) * 440; | |
end | |
//Calculate comparator values | |
compv = []; | |
for i = noterange do | |
compv( i ) = ftimer / fnote( i ) / samplesize; | |
end | |
//Print data in form of C array | |
printf( "\n{\n" ); | |
for i = noterange do | |
printf( "\t%5d, //[%02d] - %0.2fHz\n", round( compv( i ) ), i, fnote( i ) ); | |
end | |
printf( "}\n" ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment