File : PHP/Harmonique.php

<?php
/* Données mathématique de base : */
//Racine 12ème
$a pow(21/12);
//Fréquence du la 3
$la3 440;
//Tableau de note
$not[-9]="Do";
$not[-8]="Do#";
$not[-7]="Ré";
$not[-6]="Ré#";
$not[-5]="Mi";
$not[-4]="Fa";
$not[-3]="Fa#";
$not[-2]="Sol";
$not[-1]="Sol#";
$not[0]="La";
$not[1]="La#";
$not[2]="Si";

echo 
"<?xml version=\"1.0\" encoding=\"iso-8859-1\"?>";
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr">
    <head>
        <!-- STYLE -->
        <style>
        /* General */
        body
        {
            font-size:5px;
        }
        /* Tableaux */
        body table
        {
            background-color: #CCCCCC;
            margin: auto;
        }
        body table td
        {
            border:1px solid #000000;
            background-color: #FFFFFF;
        }
        body table .title
        {
            background-color:#000000;
            color:#FFFFFF;
        }
        /* Notes harmonique */
        body table .f
        {
            background-color: #DDFFFF;
            color:#333333;
        }
        body table th.f
        {
            border:1px solid #000000;
        }
        </style>
        <!-- META -->
        <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
        <!-- TITLE -->
        <title>Harmonique - Calculator</title>
    </head>
    <body class="main">
        <div class="content_box">
            Attention: Ces informations ne sont valable que pour les instruments tempéré. Il s'agit d'une division égale des ton en 2 demis ton de même longueur (et non une séparation en ton chromatique et diatonique)
            <br/>
            <table>
            <tr>
                <th colspan="13" class="title">Fréquences des divers notes</th>
            </tr>
            <tr>
                <th>Game</th>
                <th>DO</th>
                <th>DO#</th>
                <th>RE</th>
                <th>RE#b</th>
                <th>MI</th>
                <th>FA</th>
                <th>FA#</th>
                <th>SOL</th>
                <th>SOL#</th>
                <th>LA</th>
                <th>LA#</th>
                <th>SI</th>
                </tr>
            <?php
            
//Boucle des gammes
            
for($i $i <= $i++)
            {
            
?>
            <tr>
                <th><?php echo $i>0?$i:$i-1;?></th>
                <?php
                
//Boucle des notes
                
for($j 9$j >= -2$j--)
                {
                    
?>
                <td><?php
                            
//Arondi
                            
echo round(
                            
//Décalage de game
                            
pow(2,$i-3)
                            
//Décalage de note
                            
*$la3/pow($a,$j)
                            
//Nombre de chifres après la virgule
                            
2);
                        
?></td>
                <?php
                
}
                
?>
            </tr>
            <?php
            
}
            
?>
            </table>

            <br/>

            <table>
            <tr>
                <th colspan="32" class="title">Fréquences des harmoniques</th>
            </tr>
            <?php
            
/*******************************************************
             * Pause mathématique :                                *
             *  Soit n € R, le rang de l'harmonique                *
             *  Soit (f_n), la suite des fréquences harmonique     *
             *  la_3 * 2^-3      = la_-1                           *
             *  la_3 * a^i       = Décalage de i 1/2ton            *
             *  la_-1*$j         = f_n                             *
             *  f_n/la_3         = a^n                             *
             *  log_a(f_n/la_3)  = n                               *
             *  (int)(n/12 - 3)  = n_game Numéro de game           *
             *  b%12             = n° de 1/2ton en partant de la3  *
             *******************************************************/
            //Boucle des notes
            
for($i $i <= 12$i++)
            {
            
?>
            <tr>
                <th class="not"><?php echo $not[$i%12 9]; ?>-1</th>
                <th class="f"><?php echo round($la3*pow(2,-3)*pow($a,$i-9), 2); ?></th>
                <?php
                
//Boucle exponentiel (Arret quand n_game > 6)
                
for($b 1; (int)(log($b*$la3*pow(2,-3)*pow($a,$i-9))/log($a)/12-3) < 6$b++)
                {
                    
//$fn = b * la_0             * décaler de i
                    
$f_n $b $la3 pow(2,-3) * pow($a,$i-9);
                    
//log_a( f_n )
                    
$n log$f_n )/log($a);
                    
?>
                <td class="not"><?php echo $not[round($n)%12-9]; ?><?php echo (int)($n/12 3);?></td>
                <td class="f"><?php echo round($f_n2); ?></td>
                <?php
                
}
                
?>
            </tr>
            <?php
            
}
            
?>
        </table>
        </div>
    </body>
</html>


Valid XHTML 1.1