add: formatting, cleaning of notes

Signed-off-by: Tobias Reisinger <tobias@msrg.cc>
This commit is contained in:
Tobias Reisinger 2020-03-07 16:22:08 +01:00
parent ed101c6b4f
commit edbb9d45c6
6 changed files with 102 additions and 19 deletions

51
lib/fix_notation.php Normal file
View file

@ -0,0 +1,51 @@
<?php
function fix_notation($unfixed, $unfixed_mod)
{
$fixed = [];
$fixed_mod = [];
for($i = 0; $i < count($unfixed); $i++)
{
if(is_string($unfixed[$i]) && $unfixed[$i] == LY_BAR_SEPARATOR)
{
$fixed[] = LY_BAR_SEPARATOR;
$fixed_mod[] = $unfixed_mod[$i];
continue;
}
if($unfixed[$i] == 0)
{
continue;
}
if(modifier_is_rest($unfixed_mod[$i]))
{
$fixed[] = PERCUSSION_REST . strval($unfixed[$i]);
$fixed_mod[] = $unfixed_mod[$i];
continue;
}
if(
($unfixed[$i + 1] != BAR_SEPARATOR) &&
modifier_is_rest($unfixed_mod[$i + 1])
)
{
if($unfixed[$i] * 2 == $unfixed[$i + 1])
{
$fixed[] = PERCUSSION_CLAP . strval($unfixed[$i]) . LY_DOT;
$fixed_mod[] = $unfixed_mod[$i];
$unfixed[$i + 1] = 0;
continue;
}
if($unfixed[$i] == $unfixed[$i + 1])
{
$fixed[] = PERCUSSION_CLAP . strval($unfixed[$i] / 2);
$fixed_mod[] = $unfixed_mod[$i];
$unfixed[$i + 1] = 0;;
continue;
}
}
$fixed[] = PERCUSSION_CLAP . strval($unfixed[$i]);
$fixed_mod[] = $unfixed_mod[$i];
}
return array($fixed, $fixed_mod);
}
?>