http://7800.8bitdev.org/index.php?title=Perceptualtuningkey.c&feed=atom&action=history
Perceptualtuningkey.c - Revision history
2024-03-28T23:24:05Z
Revision history for this page on the wiki
MediaWiki 1.28.0
http://7800.8bitdev.org/index.php?title=Perceptualtuningkey.c&diff=66&oldid=prev
MSaarna at 07:23, 7 November 2015
2015-11-07T07:23:43Z
<p></p>
<table class="diff diff-contentalign-left" data-mw="interface">
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr style='vertical-align: top;' lang='en'>
<td colspan='2' style="background-color: white; color:black; text-align: center;">← Older revision</td>
<td colspan='2' style="background-color: white; color:black; text-align: center;">Revision as of 07:23, 7 November 2015</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l97" >Line 97:</td>
<td colspan="2" class="diff-lineno">Line 97:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div> 15720, //c=4,f=0</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div> 15720, //c=4,f=0</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div> 0 };</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div> 0 };</div></td></tr>
<tr><td colspan="2"> </td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div><ins style="font-weight: bold; text-decoration: none;"></ins></div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>  char *TIAparams[] = {</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>  char *TIAparams[] = {</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div> "c=6,f=31",</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div> "c=6,f=31",</div></td></tr>
</table>
MSaarna
http://7800.8bitdev.org/index.php?title=Perceptualtuningkey.c&diff=65&oldid=prev
MSaarna at 07:22, 7 November 2015
2015-11-07T07:22:59Z
<p></p>
<table class="diff diff-contentalign-left" data-mw="interface">
<col class='diff-marker' />
<col class='diff-content' />
<col class='diff-marker' />
<col class='diff-content' />
<tr style='vertical-align: top;' lang='en'>
<td colspan='2' style="background-color: white; color:black; text-align: center;">← Older revision</td>
<td colspan='2' style="background-color: white; color:black; text-align: center;">Revision as of 07:22, 7 November 2015</td>
</tr><tr><td colspan="2" class="diff-lineno" id="mw-diff-left-l9" >Line 9:</td>
<td colspan="2" class="diff-lineno">Line 9:</td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>  // time. However it's provided for those who might wish to validate, tinker,</div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>  // time. However it's provided for those who might wish to validate, tinker,</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>  // or adapt. Consider this source Public Domain. The author accepts no  </div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>  // or adapt. Consider this source Public Domain. The author accepts no  </div></td></tr>
<tr><td class='diff-marker'>−</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #ffe49c; vertical-align: top; white-space: pre-wrap;"><div>  // liability resulting from the program's use.</div></td><td class='diff-marker'>+</td><td style="color:black; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #a3d3ff; vertical-align: top; white-space: pre-wrap;"><div>  // liability resulting from the program's use<ins class="diffchange diffchange-inline">, and offers no warranty</ins>.</div></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"></td></tr>
<tr><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>  #include <stdio.h></div></td><td class='diff-marker'> </td><td style="background-color: #f9f9f9; color: #333333; font-size: 88%; border-style: solid; border-width: 1px 1px 1px 4px; border-radius: 0.33em; border-color: #e6e6e6; vertical-align: top; white-space: pre-wrap;"><div>  #include <stdio.h></div></td></tr>
</table>
MSaarna
http://7800.8bitdev.org/index.php?title=Perceptualtuningkey.c&diff=64&oldid=prev
MSaarna: Created page with "<pre> // perceptualtuningkey.c // By Mike Saarna // Searches the TIA frequncies for a key that has the most in-tune // Major Third, Perfect Fourth, Perfect Fifth, Octave..."
2015-11-07T07:22:40Z
<p>Created page with "<pre> // perceptualtuningkey.c // By Mike Saarna // Searches the TIA frequncies for a key that has the most in-tune // Major Third, Perfect Fourth, Perfect Fifth, Octave..."</p>
<p><b>New page</b></p><div><pre><br />
// perceptualtuningkey.c<br />
// By Mike Saarna<br />
<br />
// Searches the TIA frequncies for a key that has the most in-tune<br />
// Major Third, Perfect Fourth, Perfect Fifth, Octave relationships.<br />
<br />
// The program identified A3 as the strongest match, and will do so every <br />
// time. However it's provided for those who might wish to validate, tinker,<br />
// or adapt. Consider this source Public Domain. The author accepts no <br />
// liability resulting from the program's use.<br />
<br />
#include <stdio.h><br />
#include <stdlib.h><br />
#include <math.h><br />
<br />
float TIAfrequencies[] = {<br />
31.7, //c=6,f=31 <br />
32.7, //c=6,f=30<br />
33.8, //c=6,f=29<br />
35, //c=6,f=28<br />
36.2, //c=6,f=27<br />
37.6, //c=6,f=26<br />
39, //c=6,f=25<br />
40.6, //c=6,f=24<br />
42.3, //c=6,f=23<br />
44.1, //c=6,f=22<br />
46.1, //c=6,f=21<br />
48.3, //c=6,f=20<br />
50.7, //c=6,f=19<br />
53.4, //c=6,f=18<br />
56.3, //c=6,f=17<br />
59.7, //c=6,f=16<br />
63.4, //c=6,f=15<br />
67.6, //c=6,f=14<br />
72.4, //c=6,f=13<br />
78, //c=6,f=12<br />
84.5, //c=6,f=11<br />
92.2, //c=6,f=10<br />
101.4, //c=6,f=9<br />
112.7, //c=6,f=8<br />
126.8, //c=6,f=7<br />
144.9, //c=6,f=6<br />
163.8, //c=12,f=31<br />
169, //c=12,f=30<br />
174.7, //c=12,f=29<br />
180.7, //c=12,f=28<br />
187.1, //c=12,f=27<br />
194.1, //c=12,f=26<br />
201.5, //c=12,f=25<br />
209.6, //c=12,f=24<br />
218.3, //c=12,f=23<br />
227.8, //c=12,f=22<br />
238.2, //c=12,f=21<br />
249.5, //c=12,f=20<br />
262, //c=12,f=19<br />
275.8, //c=12,f=18<br />
291.1, //c=12,f=17<br />
308.2, //c=12,f=16<br />
327.5, //c=12,f=15<br />
349.3, //c=12,f=14<br />
374.3, //c=12,f=13<br />
403.1, //c=12,f=12<br />
436.7, //c=12,f=11<br />
476.4, //c=12,f=10<br />
491.3, //c=4,f=31<br />
507.1, //c=4,f=30<br />
524, //c=4,f=29<br />
542.1, //c=4,f=28<br />
561.4, //c=4,f=27<br />
582.2, //c=4,f=26<br />
604.6, //c=4,f=25<br />
628.8, //c=4,f=24<br />
655, //c=4,f=23<br />
683.5, //c=4,f=22<br />
714.5, //c=4,f=21<br />
748.6, //c=4,f=20<br />
786, //c=4,f=19<br />
827.4, //c=4,f=18<br />
873.3, //c=4,f=17<br />
924.7, //c=4,f=16<br />
982.5, //c=4,f=15<br />
1048, //c=4,f=14<br />
1122.9, //c=4,f=13<br />
1209.2, //c=4,f=12<br />
1310, //c=4,f=11<br />
1429.1, //c=4,f=10<br />
1572, //c=4,f=9<br />
1746.7, //c=4,f=8<br />
1965, //c=4,f=7<br />
2245.7, //c=4,f=6<br />
2620, //c=4,f=5<br />
3144, //c=4,f=4<br />
3930, //c=4,f=3<br />
5240, //c=4,f=2<br />
7860, //c=4,f=1<br />
15720, //c=4,f=0<br />
0 };<br />
char *TIAparams[] = {<br />
"c=6,f=31",<br />
"c=6,f=30",<br />
"c=6,f=29",<br />
"c=6,f=28",<br />
"c=6,f=27",<br />
"c=6,f=26",<br />
"c=6,f=25",<br />
"c=6,f=24",<br />
"c=6,f=23",<br />
"c=6,f=22",<br />
"c=6,f=21",<br />
"c=6,f=20",<br />
"c=6,f=19",<br />
"c=6,f=18",<br />
"c=6,f=17",<br />
"c=6,f=16",<br />
"c=6,f=15",<br />
"c=6,f=14",<br />
"c=6,f=13",<br />
"c=6,f=12",<br />
"c=6,f=11",<br />
"c=6,f=10",<br />
"c=6,f=9",<br />
"c=6,f=8",<br />
"c=6,f=7",<br />
"c=6,f=6",<br />
"c=12,f=31",<br />
"c=12,f=30",<br />
"c=12,f=29",<br />
"c=12,f=28",<br />
"c=12,f=27",<br />
"c=12,f=26",<br />
"c=12,f=25",<br />
"c=12,f=24",<br />
"c=12,f=23",<br />
"c=12,f=22",<br />
"c=12,f=21",<br />
"c=12,f=20",<br />
"c=12,f=19",<br />
"c=12,f=18",<br />
"c=12,f=17",<br />
"c=12,f=16",<br />
"c=12,f=15",<br />
"c=12,f=14",<br />
"c=12,f=13",<br />
"c=12,f=12",<br />
"c=12,f=11",<br />
"c=12,f=10",<br />
"c=4,f=31",<br />
"c=4,f=30",<br />
"c=4,f=29",<br />
"c=4,f=28",<br />
"c=4,f=27",<br />
"c=4,f=26",<br />
"c=4,f=25",<br />
"c=4,f=24",<br />
"c=4,f=23",<br />
"c=4,f=22",<br />
"c=4,f=21",<br />
"c=4,f=20",<br />
"c=4,f=19",<br />
"c=4,f=18",<br />
"c=4,f=17",<br />
"c=4,f=16",<br />
"c=4,f=15",<br />
"c=4,f=14",<br />
"c=4,f=13",<br />
"c=4,f=12",<br />
"c=4,f=11",<br />
"c=4,f=10",<br />
"c=4,f=9",<br />
"c=4,f=8",<br />
"c=4,f=7",<br />
"c=4,f=6",<br />
"c=4,f=5",<br />
"c=4,f=4",<br />
"c=4,f=3",<br />
"c=4,f=2",<br />
"c=4,f=1",<br />
"c=4,f=0",<br />
0 };<br />
<br />
<br />
float findvals[] = {<br />
0.840909091 * 1, //a<br />
0.890909091 * 1, //a#<br />
0.943863636 * 1, //b<br />
1.0 * 1, //c <br />
1.059454545 * 1, //c#<br />
1.122454545 * 1, //d<br />
1.189181818 * 1, //d#<br />
1.25990909 * 1, //e<br />
1.334818182 * 1, //f<br />
1.414181818 * 1, //f#<br />
1.498272726 * 1, //g<br />
1.587363636 * 1, //g#<br />
<br />
0.840909091 * 2, //a<br />
0.890909091 * 2, //a#<br />
0.943863636 * 2, //b<br />
1.0 * 2, //c <br />
1.059454545 * 2, //c#<br />
1.122454545 * 2, //d<br />
1.189181818 * 2, //d#<br />
1.25990909 * 2, //e<br />
1.334818182 * 2, //f<br />
1.414181818 * 2, //f#<br />
1.498272726 * 2, //g<br />
1.587363636 * 2, //g#<br />
<br />
0.840909091 * 3, //a<br />
0.890909091 * 3, //a#<br />
0.943863636 * 3, //b<br />
1.0 * 3, //c <br />
1.059454545 * 3, //c#<br />
1.122454545 * 3, //d<br />
1.189181818 * 3, //d#<br />
1.25990909 * 3, //e<br />
1.334818182 * 3, //f<br />
1.414181818 * 3, //f#<br />
1.498272726 * 3, //g<br />
1.587363636 * 3 //g#<br />
<br />
<br />
};<br />
<br />
float findweights[] = {<br />
// C major<br />
<br />
1.0, //a<br />
1.0, //a#<br />
1.0, //b<br />
32.0, //c - unison<br />
1.0, //c#<br />
1.0, //d<br />
1.0, //d#<br />
32.0, //e - major third<br />
32.0, //f - perfect fourth<br />
1.0, //f#<br />
32.0, //g - perfect fifth<br />
1.0, //g#<br />
<br />
1.0, //a<br />
1.0, //a#<br />
1.0, //b<br />
16.0, //c - unison<br />
1.0, //c#<br />
1.0, //d<br />
1.0, //d#<br />
16.0, //e -major third<br />
16.0, //f -perfect routth<br />
1.0, //f#<br />
16.0, //g - perfect fifth<br />
1.0, //g#<br />
<br />
1.0, //a<br />
1.0, //a#<br />
1.0, //b<br />
8.0, //c - unison<br />
1.0, //c#<br />
1.0, //d<br />
1.0, //d#<br />
2.0, //e -major third<br />
2.0, //f -perfect fourth<br />
1.0, //f#<br />
2.0, //g - perfect fifth<br />
1.0, //g#<br />
};<br />
<br />
char *intervals[] = {<br />
"(major sixth)",<br />
"(minor seventh)",<br />
"(major seventh)",<br />
"unison",<br />
"(minor second)",<br />
"(major second)",<br />
"(minor third)",<br />
"major third",<br />
"perfect fourth",<br />
"(tritone)",<br />
"perfect fifth",<br />
"(minor sixth)",<br />
"(major sixth)",<br />
"(minor seventh)",<br />
"(major seventh)",<br />
"octave",<br />
"(minor second)",<br />
"(major second)",<br />
"(minor third)",<br />
"major third",<br />
"perfect fourth",<br />
"(tritone)",<br />
"perfect fifth",<br />
"(minor sixth)",<br />
"(major sixth)",<br />
"(minor seventh)",<br />
"(major seventh)",<br />
"octave",<br />
"(minor second)",<br />
"(major second)",<br />
"(minor third)",<br />
"major third",<br />
"perfect fourth",<br />
"(tritone)",<br />
"perfect fifth",<br />
"(minor sixth)",<br />
"(major sixth)",<br />
"(minor seventh)",<br />
"(major seventh)",<br />
"octave"<br />
};<br />
<br />
<br />
int main()<br />
{<br />
int s,t,freq,lastval;<br />
int tiaindex;<br />
for(t=0;TIAfrequencies[t]!=0;t++);<br />
lastval=t;<br />
<br />
float passminimum, totalminimum, target,current;<br />
float minimumscore; int minimumindex; <br />
<br />
minimumscore=10000;<br />
for(s=0;s<(lastval-1);s++)<br />
{<br />
printf("Weight for f=%f\n",TIAfrequencies[s]);<br />
totalminimum=0;<br />
for(freq=0;freq<28;freq++)<br />
{<br />
target=TIAfrequencies[s]*findvals[freq];<br />
passminimum=100000;<br />
for(t=0;t<lastval;t++)<br />
{<br />
current=fabs(TIAfrequencies[t]-target);<br />
if(current<passminimum)<br />
{<br />
passminimum=current;<br />
tiaindex=t;<br />
}<br />
}<br />
totalminimum=totalminimum+(passminimum*findweights[freq]);<br />
printf(" %f\t%f\t%s\t%s\n",TIAfrequencies[tiaindex],(passminimum/TIAfrequencies[s])*100,TIAparams[tiaindex],intervals[freq]);<br />
}<br />
printf(" %f distortion : %f Hz \n\n",totalminimum/TIAfrequencies[s],TIAfrequencies[s]);<br />
if(minimumscore>(totalminimum/TIAfrequencies[s]))<br />
{<br />
minimumscore=totalminimum/TIAfrequencies[s];<br />
minimumindex=s;<br />
}<br />
}<br />
printf("The least distortion found was %f for %f Hz \n\n",minimumscore,TIAfrequencies[minimumindex]);<br />
exit(0);<br />
}<br />
</pre></div>
MSaarna