# Path: note_seq/midi_synth.py
# def synthesize(sequence, sample_rate, wave=np.sin):
# def fluidsynth(sequence, sample_rate, sf2_path=None):


import base64
import collections
import functools
import io
import os
import urllib
import bokeh
import bokeh.plotting
import numpy as np
import pandas as pd
    import google.colab  # pylint:disable=import-outside-toplevel,g-import-not-at-top,unused-import
from IPython import display
from note_seq import midi_synth
from scipy.io import wavfile
  from google.colab.output import _js_builder as js  # pylint:disable=import-outside-toplevel,g-import-not-at-top,protected-access
      widget is rendered.
  """

  normalizer = float(np.iinfo(np.int16).max)
  array_of_ints = np.array(
      np.asarray(array_of_floats) * normalizer, dtype=np.int16)
  memfile = io.BytesIO()
  wavfile.write(memfile, sample_rate, array_of_ints)
  html = """<audio controls {autoplay}>
              <source controls src="data:audio/wav;base64,{base64_wavfile}"
              type="audio/wav" />
              Your browser does not support the audio element.
            </audio>"""
  html = html.format(
      autoplay='autoplay' if autoplay else '',
      base64_wavfile=base64.b64encode(memfile.getvalue()).decode('ascii'))
  memfile.close()
  global _play_id
  _play_id += 1
  if ephemeral:
    element = 'id_%s' % _play_id
    display.display(display.HTML('<div id="%s"> </div>' % element))
    js.Js('document', mode=js.EVAL).getElementById(element).innerHTML = html
  else:
    display.display(display.HTML(html))


def play_sequence(sequence,
                  synth=midi_synth.synthesize,
                  sample_rate=_DEFAULT_SAMPLE_RATE,

# Path: note_seq/midi_synth.py
# def synthesize(sequence, sample_rate, wave=np.sin):
# def fluidsynth(sequence, sample_rate, sf2_path=None):


# Path: note_seq/notebook_utils.py
import base64
import collections
import functools
import io
import os
import urllib
import bokeh
import bokeh.plotting
import numpy as np
import pandas as pd
    import google.colab  # pylint:disable=import-outside-toplevel,g-import-not-at-top,unused-import
from IPython import display
from note_seq import midi_synth
from scipy.io import wavfile
  from google.colab.output import _js_builder as js  # pylint:disable=import-outside-toplevel,g-import-not-at-top,protected-access

      widget is rendered.
  """

  normalizer = float(np.iinfo(np.int16).max)
  array_of_ints = np.array(
      np.asarray(array_of_floats) * normalizer, dtype=np.int16)
  memfile = io.BytesIO()
  wavfile.write(memfile, sample_rate, array_of_ints)
  html = """<audio controls {autoplay}>
              <source controls src="data:audio/wav;base64,{base64_wavfile}"
              type="audio/wav" />
              Your browser does not support the audio element.
            </audio>"""
  html = html.format(
      autoplay='autoplay' if autoplay else '',
      base64_wavfile=base64.b64encode(memfile.getvalue()).decode('ascii'))
  memfile.close()
  global _play_id
  _play_id += 1
  if ephemeral:
    element = 'id_%s' % _play_id
    display.display(display.HTML('<div id="%s"> </div>' % element))
    js.Js('document', mode=js.EVAL).getElementById(element).innerHTML = html
  else:
    display.display(display.HTML(html))


def play_sequence(sequence,
                  synth=midi_synth.synthesize,
                  sample_rate=_DEFAULT_SAMPLE_RATE,

                  colab_ephemeral=True,