(audio_notes, start_times, end_times, velocities, sr=16000)
return audio_clip
Combine audio from multiple notes into a single audio clip.

  Args:
    audio_notes: Array of audio [n_notes, audio_samples].
    start_times: Array of note starts in seconds [n_notes].
    end_times: Array of note ends in seconds [n_notes].
    velocities: Array of velocity values [n_notes].
    sr: Integer, sample rate.

  Returns:
    audio_clip: Array of combined audio clip [audio_samples]
Combine audio from multiple notes into a single audio clip.
Combine audio from multiple notes into a single audio clip .
def combine_notes(audio_notes, start_times, end_times, velocities, sr=16000):
  """Combine audio from multiple notes into a single audio clip.

  Args:
    audio_notes: Array of audio [n_notes, audio_samples].
    start_times: Array of note starts in seconds [n_notes].
    end_times: Array of note ends in seconds [n_notes].
    velocities: Array of velocity values [n_notes].
    sr: Integer, sample rate.

  Returns:
    audio_clip: Array of combined audio clip [audio_samples]
  """
  n_notes = len(audio_notes)
  clip_length = end_times.max() + MAX_NOTE_LENGTH
  audio_clip = np.zeros(int(clip_length) * sr)

  for t_start, t_end, vel, i in zip(
      start_times, end_times, velocities, range(n_notes)):
    # Generate an amplitude envelope
    t_note_length = t_end - t_start
    envelope = get_envelope(t_note_length)
    length = len(envelope)
    audio_note = audio_notes[i, :length] * envelope
    # Normalize
    audio_note /= audio_note.max()
    audio_note *= (vel / MAX_VELOCITY)
    # Add to clip buffer
    clip_start = int(t_start * sr)
    clip_end = clip_start + length
    audio_clip[clip_start:clip_end] += audio_note

  # Normalize
  audio_clip /= audio_clip.max()
  audio_clip /= 2.0
  return audio_clip
def combine_notes ( audio_notes , start_times , end_times , velocities , sr = 16000 ) : n_notes = len ( audio_notes ) clip_length = end_times . max ( ) + MAX_NOTE_LENGTH audio_clip = np . zeros ( int ( clip_length ) * sr ) for t_start , t_end , vel , i in zip ( start_times , end_times , velocities , range ( n_notes ) ) : # Generate an amplitude envelope t_note_length = t_end - t_start envelope = get_envelope ( t_note_length ) length = len ( envelope ) audio_note = audio_notes [ i , : length ] * envelope # Normalize audio_note /= audio_note . max ( ) audio_note *= ( vel / MAX_VELOCITY ) # Add to clip buffer clip_start = int ( t_start * sr ) clip_end = clip_start + length audio_clip [ clip_start : clip_end ] += audio_note # Normalize audio_clip /= audio_clip . max ( ) audio_clip /= 2.0 return audio_clip