+window.wavesurfer = Object.create(WaveSurfer)
+
 randomColor = (alpha) ->
   'rgba(' + [
     ~ ~(Math.random() * 255)

      region.play()
    return
  wavesurfer.on 'region-click', editAnnotation
  #wavesurfer.on('region-dblclick', splitRegion);
  wavesurfer.on 'region-updated', saveRegions
  wavesurfer.on 'region-removed', saveRegions
  wavesurfer.on 'region-in', showNote

    form.reset()
  return

wavesurfer.setMarker = (time, text) ->
  time ||= wavesurfer.getCurrentTime()
  text ||= ''
  wavesurfer.addRegion(start: round100(time), drag: true, resize: false, data: { type: 'segment_item', note: text }, color: 'rgba(0,0,0,0.5)')

regionsArray = ->
  mapped = Object.keys(wavesurfer.regions.list).map((id) ->
    region = wavesurfer.regions.list[id]
    {
