CSV Tools (synctoolbox.feature.csv_tools)

synctoolbox.feature.csv_tools.df_to_pitch_features(df: pandas.core.frame.DataFrame, feature_rate: float, midi_min: int = 21, midi_max: int = 108, transpose: int = 0, ignore_velocity: bool = False, ignore_percussion: bool = False) numpy.ndarray[source]

Computes pitch-based features for a dataframe containing symbolic music. The resulting features have the same format as the output of ‘audio_to_pitch_features’ for audio.

Parameters
  • df (pd.DataFrame) – Dataframe of symbolic music piece. Can be loaded with ‘read_csv_to_df’. WARNING! Column names are supposed to be lowercase.

  • feature_rate (float) – Desired features per second of the output representation

  • midi_min (int) – Minimum MIDI index (indices below midi_min are filled with zero in the output)

  • midi_max (int) – Maximum MIDI index (indices above midi_max are filled with zero in the output)

  • transpose (int) – Number of semi-tones the symbolic information should be transposed

  • ignore_velocity (bool) – If True, STMSP values aren’t set based on MIDI velocities, just uses 0 and 1.

  • ignore_percussion (bool) – Ignores percussion. If True, no features are generated for percussive events.

Returns

f_pitch (np.ndarray) – Matrix of size 128xN containing the extracted pitch-based features

synctoolbox.feature.csv_tools.df_to_pitch_onset_features(df: pandas.core.frame.DataFrame, midi_min: int = 21, midi_max: int = 108, transpose: int = 0, ignore_percussion: bool = False, peak_height_scale_factor: float = 1000000.0) dict[source]

Computes pitch-based onset features for a dataframe containing symbolic music. The resulting features have the same format as the output of ‘audio_to_pitch_onset_features’ for audio.

Parameters
  • df (pd.Dataframe) – Dataframe of symbolic music piece. Can be loaded with ‘read_csv_to_df’. WARNING! Column names are supposed to be lowercase.

  • midi_min (int) – Minimum MIDI index (indices below ‘midi_min’ will raise an error)

  • midi_max (int) – Maximum MIDI index (indices above ‘midi_max’ will raise an error)

  • transpose (int) – Number of semi-tones the midi information should be transposed

  • ignore_percussion (bool) – Ignores percussion. If True, no features are generated for percussive events.

  • peak_height_scale_factor (float) – Scales the midi velocity so the resulting feature values are in a similar range than the peak features from an audio file So 1e6 is more or less arbitrary.

Returns

f_peaks (dict) – A dictionary of onset peaks, see ‘audio_to_pitch_onset_features’ for the exact format

synctoolbox.feature.csv_tools.read_csv_to_df(csv_filepath: str = '', csv_delimiter: str = ';') pandas.core.frame.DataFrame[source]

Reads .csv file containing symbolic music into a pandas DataFrame. Column names are normalized to be lower case.

Parameters
  • csv_filepath (str) – Filepath to the .csv file.

  • csv_delimiter (str) – Delimiter of the .csv file (default: ‘;’)

Returns

df (pd.Dataframe) – Annotations in pandas Dataframe format.