Generate musical patterns with Javascript