@@ -1140,30 +1140,30 @@ def test_note_frequency_per_instrument(
11401140 return is_valid , note_freq_per_instrument
11411141
11421142
1143- def test_min_length (
1144- midi_dict : MidiDict , min_seconds : int
1143+ def test_length (
1144+ midi_dict : MidiDict ,
1145+ min_length_s : int ,
1146+ max_length_s : int ,
11451147) -> tuple [bool , float ]:
11461148 """Tests the min length is above a threshold.
11471149
11481150 Args:
11491151 midi_dict (MidiDict): MidiDict to test.
1150- min_seconds (int): Minimum length threshold in seconds.
1152+ min_length_s (int): Minimum length threshold in seconds.
1153+ max_length_s (int): Maximum length threshold in seconds.
11511154
11521155 Returns:
1153- bool: True if longer than minimum length , else False.
1156+ bool: True if within thresholds , else False.
11541157 float: Length in seconds.
11551158 """
11561159
11571160 if not midi_dict .note_msgs :
11581161 return False , 0.0
11591162
1160- total_duration_ms = get_duration_ms (
1161- start_tick = midi_dict .note_msgs [0 ]["data" ]["start" ],
1162- end_tick = midi_dict .note_msgs [- 1 ]["data" ]["end" ],
1163- tempo_msgs = midi_dict .tempo_msgs ,
1164- ticks_per_beat = midi_dict .ticks_per_beat ,
1163+ total_duration_ms = midi_dict .tick_to_ms (
1164+ midi_dict .note_msgs [- 1 ]["data" ]["end" ]
11651165 )
1166- is_valid = total_duration_ms / 1e3 >= min_seconds
1166+ is_valid = min_length_s <= total_duration_ms / 1e3 <= max_length_s
11671167
11681168 return is_valid , total_duration_ms / 1e3
11691169
@@ -1749,7 +1749,7 @@ def get_test_fn(
17491749 "max_instruments" : test_max_instruments ,
17501750 "total_note_frequency" : test_note_frequency ,
17511751 "note_frequency_per_instrument" : test_note_frequency_per_instrument ,
1752- "min_length " : test_min_length ,
1752+ "length " : test_length ,
17531753 "mean_note_len" : test_mean_note_len ,
17541754 "mean_note_velocity" : test_mean_note_velocity ,
17551755 "silent_interval" : test_silent_interval ,
0 commit comments