gan/utils/metrics_utils.py [91:108]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    description = """
        The ratio of the average number of notes in a bar, which are in C major key which
        is the most common key found in music to the total number of notes.
    """
    
    def _to_chroma(self, pianoroll):
        """Return the chroma features (not normalized)."""
        if len(pianoroll.shape) != 5:
            raise ValueError("Input pianoroll must have 5 dimensions.")
        remainder = pianoroll.shape[3] % 12
        if remainder:
            pianoroll = np.pad(
                pianoroll, ((0, 0), (0, 0), (0, 0), (0, 12 - remainder), (0, 0)))
        reshaped = np.reshape(
            pianoroll, (-1, pianoroll.shape[1], pianoroll.shape[2], 12,
                        pianoroll.shape[3] // 12 + int(remainder > 0),
                        pianoroll.shape[4]))
        return np.sum(reshaped, 4)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



reinvent-labs/lab-2/utils/metrics_utils.py [45:63]:
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    description = """
        Average number of notes in each bar after projecting to chroma space.
        Chroma features or Pitch Class Profiles are a distribution of the signal’s energy
        across a predefined set of pitch classes.
    """
    
    def _to_chroma(self, pianoroll):
        """Return the chroma features (not normalized)."""
        if len(pianoroll.shape) != 5:
            raise ValueError("Input pianoroll must have 5 dimensions.")
        remainder = pianoroll.shape[3] % 12
        if remainder:
            pianoroll = np.pad(
                pianoroll, ((0, 0), (0, 0), (0, 0), (0, 12 - remainder), (0, 0)))
        reshaped = np.reshape(
            pianoroll, (-1, pianoroll.shape[1], pianoroll.shape[2], 12,
                        pianoroll.shape[3] // 12 + int(remainder > 0),
                        pianoroll.shape[4]))
        return np.sum(reshaped, 4)
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -



