code: def match_notes(
          ref_intervals, ref_pitches, ref_velocities, est_intervals, est_pitches,
          est_velocities, onset_tolerance=0.05, pitch_tolerance=50.0,
          offset_ratio=0.2, offset_min_tolerance=0.05, strict=False,
          velocity_tolerance=0.1):
      matching = transcription.match_notes(
          ref_intervals, ref_pitches, est_intervals, est_pitches,
          onset_tolerance, pitch_tolerance, offset_ratio, offset_min_tolerance,
          strict)
      min_velocity, max_velocity = np.min(ref_velocities), np.max(ref_velocities)
      velocity_range = max(1, max_velocity - min_velocity)
      ref_velocities = (ref_velocities - min_velocity)/float(velocity_range)
      matching = np.array(matching)
      if matching.size == 0:
          return []
      ref_matched_velocities = ref_velocities[matching[:, 0]]
      est_matched_velocities = est_velocities[matching[:, 1]]
      slope, intercept = np.linalg.lstsq(
          np.vstack([est_matched_velocities,
                     np.ones(len(est_matched_velocities))]).T,
          ref_matched_velocities)[0]
      est_matched_velocities = slope*est_matched_velocities + intercept
      velocity_diff = np.abs(est_matched_velocities - ref_matched_velocities)
      velocity_within_tolerance = (velocity_diff < velocity_tolerance)
      matching = matching[velocity_within_tolerance]
      matching = [tuple(_) for _ in matching]
      return matching