Description
Some users on Discord have recently been using a metric to measure a song's complexity: average notes per second (or average note density). This can be implemented as part of the SongStats
calculation and displayed on the song's page, as it's a really interesting metric.
courtesy: @KaliumI
Considerations
Notes per tick vs. notes per second
A tick is a relative measurement, and varies according to the song's tick speed. A second is always a second, regardless of the song's speed. As such, with notes per second, two songs with different speeds can be compared in the same time unit. This, however, would give a 'boost'/'advantage' to faster songs, giving them a larger score since they have more throughput and can play notes faster.
Notes per tick would be useful to overcome this, as it wouldn't be 'biased' towards faster songs - regardless of the tempo, it shows the average amount of notes per column of the song, regardless of the speed at which they go by.
As such, both metrics are useful, each in their own circumstance.
Tempo changes
For notes per tick, tempo changes don't matter. It can be calculated as simply as: notes_per_tick = note_count / song_length
.
For notes per second, however, the tempo of the song must be taken into account. Without tempo changes into play, it'd be as easy as: notes_per_second = note_count / (song_length / song_tempo)
.
However, with tempo changes in the equation, the average density has to be calculated for each 'tempo segment' (vertical slice of the song that plays at a certain tempo). Following this, all the densities have to be multiplied by the number of ticks they last for, and the whole sum divided by the number of ticks in the song. The SongStatsGenerator
class already features helper methods to calculate tempo segments: