# Path: note_seq/midi_io.py
# _PRETTY_MIDI_MAJOR_TO_MINOR_OFFSET = 12
# class MIDIConversionError(Exception):
# def midi_to_note_sequence(midi_data):
# def midi_file_to_note_sequence(midi_file):
# def note_sequence_to_midi_file(sequence, output_file,
#                                drop_events_n_seconds_after_last_note=None):
# def note_sequence_to_pretty_midi(
#     sequence, drop_events_n_seconds_after_last_note=None):
# def midi_to_sequence_proto(midi_data):
# def sequence_proto_to_pretty_midi(sequence,
#                                   drop_events_n_seconds_after_last_note=None):
# def midi_file_to_sequence_proto(midi_file):
# def sequence_proto_to_midi_file(sequence, output_file,
#                                 drop_events_n_seconds_after_last_note=None):


from note_seq import midi_io
import numpy as np
  This uses the pretty_midi `synthesize` method. Sound quality will be lower
  than using `fluidsynth` with a good SoundFont.

  Args:
    sequence: A music_pb2.NoteSequence to synthesize.
    sample_rate: An integer audio sampling rate in Hz.
    wave: Function that returns a periodic waveform.

  Returns:
    A 1-D numpy float array containing the synthesized waveform.
  """
  midi = midi_io.note_sequence_to_pretty_midi(sequence)
  return midi.synthesize(fs=sample_rate, wave=wave)


def fluidsynth(sequence, sample_rate, sf2_path=None):
  """Synthesizes audio from a music_pb2.NoteSequence using FluidSynth.

  This uses the pretty_midi `fluidsynth` method. In order to use this synth,
  you must have FluidSynth and pyFluidSynth installed.

  Args:
    sequence: A music_pb2.NoteSequence to synthesize.
    sample_rate: An integer audio sampling rate in Hz.
    sf2_path: A string path to a SoundFont. If None, uses the TimGM6mb.sf2 file
        included with pretty_midi.

  Returns:
    A 1-D numpy float array containing the synthesized waveform.
  """

# Path: note_seq/midi_io.py
# _PRETTY_MIDI_MAJOR_TO_MINOR_OFFSET = 12
# class MIDIConversionError(Exception):
# def midi_to_note_sequence(midi_data):
# def midi_file_to_note_sequence(midi_file):
# def note_sequence_to_midi_file(sequence, output_file,
#                                drop_events_n_seconds_after_last_note=None):
# def note_sequence_to_pretty_midi(
#     sequence, drop_events_n_seconds_after_last_note=None):
# def midi_to_sequence_proto(midi_data):
# def sequence_proto_to_pretty_midi(sequence,
#                                   drop_events_n_seconds_after_last_note=None):
# def midi_file_to_sequence_proto(midi_file):
# def sequence_proto_to_midi_file(sequence, output_file,
#                                 drop_events_n_seconds_after_last_note=None):


# Path: note_seq/midi_synth.py
from note_seq import midi_io
import numpy as np

  This uses the pretty_midi `synthesize` method. Sound quality will be lower
  than using `fluidsynth` with a good SoundFont.

  Args:
    sequence: A music_pb2.NoteSequence to synthesize.
    sample_rate: An integer audio sampling rate in Hz.
    wave: Function that returns a periodic waveform.

  Returns:
    A 1-D numpy float array containing the synthesized waveform.
  """
  midi = midi_io.note_sequence_to_pretty_midi(sequence)
  return midi.synthesize(fs=sample_rate, wave=wave)


def fluidsynth(sequence, sample_rate, sf2_path=None):
  """Synthesizes audio from a music_pb2.NoteSequence using FluidSynth.

  This uses the pretty_midi `fluidsynth` method. In order to use this synth,
  you must have FluidSynth and pyFluidSynth installed.

  Args:
    sequence: A music_pb2.NoteSequence to synthesize.
    sample_rate: An integer audio sampling rate in Hz.
    sf2_path: A string path to a SoundFont. If None, uses the TimGM6mb.sf2 file
        included with pretty_midi.

  Returns:
    A 1-D numpy float array containing the synthesized waveform.
  """

  midi = midi_io.note_sequence_to_pretty_midi(sequence)