$shortest_note) || (!is_valid_note($note_val))) { continue; } if($rhythm_length + ($shortest_note / $note_val) > $rhythm_length_max) { continue; } $rhythm_length += $shortest_note / $note_val; $notes_final[] = $note_val; $notes_final_mod[] = $notes_mod[$i]; if($rhythm_length == $rhythm_length_max) { $notes_final[] = "|"; $notes_final_mod[] = $notes_mod[$i]; $rhythm_length = 0; $bars_count++; } } $id_hashed = md5($id_hashed); } while($bars_count < $bars); list($notes_final, $notes_final_mod) = fix_notation($notes_final, $notes_final_mod); list($notes_final, $notes_final_mod) = combine_rests($notes_final, $notes_final_mod); $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", array( "id" => $id, "time" => $time, "tempo" => $tempo, "bars" => $bars, "shortest_note" => $shortest_note, "dynamic_beat" => $dynamic_beat, "dynamic_rhythm" => $dynamic_rhythm, "file_name" => $file_name, ) )); ?>