add: shortest note modifier
Signed-off-by: Tobias Reisinger <tobias@msrg.cc>
This commit is contained in:
parent
9d53b7f498
commit
421bcef330
6 changed files with 59 additions and 14 deletions
14
index.php
14
index.php
|
@ -14,6 +14,7 @@ $id = $_GET["id"];
|
|||
$tempo = $_GET["tempo"];
|
||||
$time = $_GET["time"];
|
||||
$bars = intval($_GET["bars"]);
|
||||
$shortest_note = intval($_GET["shortest_note"]);
|
||||
|
||||
$dynamic_beat = $_GET["dynamic_beat"];
|
||||
$dynamic_rhythm = $_GET["dynamic_rhythm"];
|
||||
|
@ -24,14 +25,14 @@ $bars_count = 0;
|
|||
$rhythm_length = 0;
|
||||
|
||||
$time_explode = explode("/", $time, 2);
|
||||
$rhythm_length_max = MAX_FRACTION * (intval($time_explode[0]) / intval($time_explode[1]));
|
||||
$rhythm_length_max = $shortest_note * (intval($time_explode[0]) / intval($time_explode[1]));
|
||||
|
||||
$id_hashed = md5($id);
|
||||
do {
|
||||
$notes_input = [];
|
||||
for($i = 0; $i < strlen($id_hashed); $i+=2)
|
||||
{
|
||||
$notes_input[] = strval(pow(2, (ord(substr($id_hashed, $i)) % intval(log(MAX_FRACTION, 2))) + 1));
|
||||
$notes_input[] = strval(pow(2, (ord(substr($id_hashed, $i)) % intval(log($shortest_note, 2))) + 1));
|
||||
$notes_modifiers[] = ord(substr($id_hashed, $i + 1));
|
||||
}
|
||||
for($i = 0; $i < count($notes_input); $i++)
|
||||
|
@ -41,15 +42,15 @@ do {
|
|||
continue;
|
||||
}
|
||||
$note_val = intval($notes_input[$i]);
|
||||
if(($note_val == 0) || ($note_val > MAX_FRACTION) || (!is_valid_note($note_val)))
|
||||
if(($note_val == 0) || ($note_val > $shortest_note) || (!is_valid_note($note_val)))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if($rhythm_length + (MAX_FRACTION / $note_val) > $rhythm_length_max)
|
||||
if($rhythm_length + ($shortest_note / $note_val) > $rhythm_length_max)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
$rhythm_length += MAX_FRACTION / $note_val;
|
||||
$rhythm_length += $shortest_note / $note_val;
|
||||
|
||||
if($notes_modifiers[$i] & 0b0111)
|
||||
{
|
||||
|
@ -102,9 +103,10 @@ echo(render(
|
|||
"time" => $time,
|
||||
"tempo" => $tempo,
|
||||
"bars" => $bars,
|
||||
"file_name" => $file_name,
|
||||
"shortest_note" => $shortest_note,
|
||||
"dynamic_beat" => $dynamic_beat,
|
||||
"dynamic_rhythm" => $dynamic_rhythm,
|
||||
"file_name" => $file_name,
|
||||
)
|
||||
));
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue