TomRB22 commited on
Commit
3231a82
1 Parent(s): 3cb28e5

Added an exception

Browse files
Files changed (1) hide show
  1. audio.py +5 -1
audio.py CHANGED
@@ -33,7 +33,7 @@ _SCALING_FACTORS = pd.Series(
33
  def midi_to_notes(midi_file: str) -> pd.DataFrame:
34
  """
35
  Convert midi file to "song map" (dataframe where each note is broken
36
- into its components).
37
 
38
  Parameters
39
  ----------
@@ -53,6 +53,10 @@ def midi_to_notes(midi_file: str) -> pd.DataFrame:
53
 
54
  # Sort the notes by start time
55
  sorted_notes = sorted(instrument.notes, key=lambda note: note.start)
 
 
 
 
56
  prev_start = sorted_notes[0].start
57
 
58
  # Separate each individual note in pitch, step and duration
 
33
  def midi_to_notes(midi_file: str) -> pd.DataFrame:
34
  """
35
  Convert midi file to "song map" (dataframe where each note is broken
36
+ into its components). The song must have at least 3501 notes.
37
 
38
  Parameters
39
  ----------
 
53
 
54
  # Sort the notes by start time
55
  sorted_notes = sorted(instrument.notes, key=lambda note: note.start)
56
+
57
+ if len(sorted_notes) < 3501:
58
+ raise ValueError("Song must have at least 3501 notes.")
59
+
60
  prev_start = sorted_notes[0].start
61
 
62
  # Separate each individual note in pitch, step and duration