MAX_FRACTION) || (!is_valid_note($note_val))) { continue; } if($rhythm_length + (MAX_FRACTION / $note_val) > $rhythm_length_max) { continue; } $rhythm_length += MAX_FRACTION / $note_val; if($notes_modifiers[$i] & 0b0111) { $notes_final[] = PERCUSSION_CLAP . $note_val; } else { $notes_final[] = PERCUSSION_REST . $note_val; } if($rhythm_length == $rhythm_length_max) { $notes_final[] = "|"; $rhythm_length = 0; $bars_count++; } } $id_hashed = md5($id_hashed); } while($bars_count < $bars); $notes_final = implode(" ", $notes_final); $rest_padding = array_fill(0, $time_explode[0], PERCUSSION_REST . $time_explode[1]); $rest_padding[0] = $rest_padding[0] . "\\$dynamic_rhythm"; $rest_padding = implode(" ", $rest_padding); $beats_one_bar = array_fill(1, $time_explode[0] - 1, PERCUSSION_BEAT . $time_explode[1]); array_unshift($beats_one_bar, PERCUSSION_BEAT_ACCENT . $time_explode[1] . "\\$dynamic_beat"); array_push($beats_one_bar, "|"); $beats = implode(" ", array_fill(0, $bars_count + 2, implode(" ", $beats_one_bar))); $file_content = sprintf( LILYPOND_FORMAT, $time, $tempo, $notes_final, $rest_padding, $beats ); $file_name = md5($file_content); file_put_contents( OUTPUT_FOLDER . $file_name . ".ly", $file_content); exec(sprintf("lilypond --png -o %1\$s %1\$s$file_name.ly && convert %1\$s$file_name.png -trim %1\$s$file_name.png", OUTPUT_FOLDER)); echo(render( "./templates/index.tpl.php", $locale, array( "id" => $id, "time" => $time, "tempo" => $tempo, "bars" => $bars, "file_name" => $file_name, "dynamic_beat" => $dynamic_beat, "dynamic_rhythm" => $dynamic_rhythm, ) )); ?>