-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.php
119 lines (102 loc) · 2.86 KB
/
index.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<?php
/*
* vim: ts=3 sw=3 et wrap co=100
*/
// Defines. ////////////////////////////////////////////////////////////////////////////////////////
define('N_NOTES_PER_OCTAVE' , 12);
define('N_OCTAVES_TO_DISPLAY', 4);
define('A440HZ_OCTAVE_NO' , 1);
// Global variables. ///////////////////////////////////////////////////////////////////////////////
$filesCss = array
(
'style.css'
);
$filesJs = array
(
'lib_tom/js/contrib/jquery/1.5/jquery_minified.js',
'lib_tom/js/utils/utils.js' ,
'lib_tom/js/utils/utilsValidator.js' ,
'main.js'
);
// Functions. //////////////////////////////////////////////////////////////////////////////////////
/*
*
*/
function echoHtmlForMusicGrid($indent)
{
$i = &$indent; // Abbreviation.
echo "$i<table>\n";
echo "$i <tbody>\n";
for ($r = 0; $r < N_OCTAVES_TO_DISPLAY * N_NOTES_PER_OCTAVE; ++$r)
{
$classString =
(
($r % N_NOTES_PER_OCTAVE == 0)? ' class=\'topBorderOctaveBoundary\'':
(
(($r + 1) % N_NOTES_PER_OCTAVE == 0)? ' class=\'bottomBorderOctaveBoundary\'': ''
)
);
echo "$i <tr$classString>\n";
for ($c = 0; $c < 128; ++$c)
{
$value = '';
echo
(
($c == 0)?
"$i<th>" . getNoteAbbrevFromRowNo($r) . "</th>\n":
"$i<td>$value</td>\n"
);
}
echo " </tr>\n";
}
echo "$i </tbody>\n";
echo "$i</table>\n";
}
/*
*
*/
function getNoteAbbrevFromRowNo($r)
{
$octaveNo = floor($r / N_NOTES_PER_OCTAVE);
$noteAbbrevByOffset = array('G','F#','F','E#','E','D#','D','C#','C','B','A#','A');
for ($offset = 0; $offset < N_NOTES_PER_OCTAVE; ++$offset)
{
if (($r - $offset) % N_NOTES_PER_OCTAVE == 0)
{
$midiNoteNo =
(
((N_OCTAVES_TO_DISPLAY - $octaveNo) * N_NOTES_PER_OCTAVE) +
((A440HZ_OCTAVE_NO * 12) + 32) - $offset
);
return "$midiNoteNo {$noteAbbrevByOffset[$offset]}";
}
}
}
// HTML code. //////////////////////////////////////////////////////////////////////////////////////
?>
<!DOCTYPE HTML>
<html>
<head>
<title>Funtastical Tunistic Melodical Compositor</title>
<link rel='stylesheet' type='text/css' href='style.css'/>
<?php
$unixTime = time();
foreach ($filesJs as $file) {
echo " <script type='text/javascript' src='$file?$unixTime'></script>\n";
}
foreach ($filesCss as $file) {
echo " <link rel='stylesheet' type='text/css' href='$file?$unixTime'/>\n";
}
?>
</head>
<body>
<h1>Funtastical Tunistic Melodical Compositor</h1>
<?php
echoHtmlForMusicGrid(' ');
?>
<br/>
<input type='button' value='Load'/>
<input type='button' value='Save'/>
<input type='button' value='Play'/>
</body>
</html>