wavesurfer.js 4.5.0 → 5.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGES.md +36 -1
- package/README.md +6 -3
- package/dist/plugin/wavesurfer.cursor.js +39 -34
- package/dist/plugin/wavesurfer.cursor.js.map +1 -1
- package/dist/plugin/wavesurfer.cursor.min.js +2 -2
- package/dist/plugin/wavesurfer.cursor.min.js.map +1 -1
- package/dist/plugin/wavesurfer.elan.js +29 -27
- package/dist/plugin/wavesurfer.elan.js.map +1 -1
- package/dist/plugin/wavesurfer.elan.min.js +2 -2
- package/dist/plugin/wavesurfer.elan.min.js.map +1 -1
- package/dist/plugin/wavesurfer.markers.js +381 -0
- package/dist/plugin/wavesurfer.markers.js.map +1 -0
- package/dist/plugin/wavesurfer.markers.min.js +7 -0
- package/dist/plugin/wavesurfer.markers.min.js.map +1 -0
- package/dist/plugin/wavesurfer.mediasession.js +29 -27
- package/dist/plugin/wavesurfer.mediasession.js.map +1 -1
- package/dist/plugin/wavesurfer.mediasession.min.js +2 -2
- package/dist/plugin/wavesurfer.mediasession.min.js.map +1 -1
- package/dist/plugin/wavesurfer.microphone.js +29 -27
- package/dist/plugin/wavesurfer.microphone.js.map +1 -1
- package/dist/plugin/wavesurfer.microphone.min.js +2 -2
- package/dist/plugin/wavesurfer.microphone.min.js.map +1 -1
- package/dist/plugin/wavesurfer.minimap.js +30 -28
- package/dist/plugin/wavesurfer.minimap.js.map +1 -1
- package/dist/plugin/wavesurfer.minimap.min.js +2 -2
- package/dist/plugin/wavesurfer.minimap.min.js.map +1 -1
- package/dist/plugin/wavesurfer.playhead.js +324 -0
- package/dist/plugin/wavesurfer.playhead.js.map +1 -0
- package/dist/plugin/wavesurfer.playhead.min.js +7 -0
- package/dist/plugin/wavesurfer.playhead.min.js.map +1 -0
- package/dist/plugin/wavesurfer.regions.js +152 -126
- package/dist/plugin/wavesurfer.regions.js.map +1 -1
- package/dist/plugin/wavesurfer.regions.min.js +2 -2
- package/dist/plugin/wavesurfer.regions.min.js.map +1 -1
- package/dist/plugin/wavesurfer.spectrogram.js +97 -89
- package/dist/plugin/wavesurfer.spectrogram.js.map +1 -1
- package/dist/plugin/wavesurfer.spectrogram.min.js +2 -2
- package/dist/plugin/wavesurfer.spectrogram.min.js.map +1 -1
- package/dist/plugin/wavesurfer.timeline.js +46 -32
- package/dist/plugin/wavesurfer.timeline.js.map +1 -1
- package/dist/plugin/wavesurfer.timeline.min.js +2 -2
- package/dist/plugin/wavesurfer.timeline.min.js.map +1 -1
- package/dist/wavesurfer-html-init.js +9 -5
- package/dist/wavesurfer-html-init.js.map +1 -1
- package/dist/wavesurfer-html-init.min.js +2 -2
- package/dist/wavesurfer-html-init.min.js.map +1 -1
- package/dist/wavesurfer.js +350 -166
- package/dist/wavesurfer.js.map +1 -1
- package/dist/wavesurfer.min.js +2 -2
- package/dist/wavesurfer.min.js.map +1 -1
- package/package.json +19 -16
- package/src/drawer.canvasentry.js +16 -0
- package/src/drawer.js +30 -21
- package/src/drawer.multicanvas.js +63 -39
- package/src/plugin/cursor/index.js +3 -1
- package/src/plugin/markers/index.js +282 -0
- package/src/plugin/playhead/index.js +226 -0
- package/src/plugin/regions/index.js +28 -11
- package/src/plugin/regions/region.js +83 -70
- package/src/plugin/spectrogram/index.js +65 -61
- package/src/plugin/timeline/index.js +20 -11
- package/src/util/index.js +1 -0
- package/src/util/orientation.js +98 -0
- package/src/wavesurfer.js +18 -9
- package/src/webaudio.js +10 -9
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["webpack://WaveSurfer.[name]/webpack/universalModuleDefinition","webpack://WaveSurfer.[name]/./src/plugin/regions/index.js","webpack://WaveSurfer.[name]/./src/plugin/regions/region.js","webpack://WaveSurfer.[name]/webpack/bootstrap","webpack://WaveSurfer.[name]/webpack/startup"],"names":["root","factory","exports","module","define","amd","this","RegionsPlugin","params","ws","wavesurfer","util","getRegionSnapToGridValue","value","maxRegions","regionsMinLength","Object","getOwnPropertyNames","Observer","prototype","forEach","key","Region","_onBackendCreated","wrapper","drawer","regions","region","edgeScrollWidth","clientWidth","add","list","_onReady","dragSelection","enableDragSelection","keys","id","updateRender","name","deferInit","staticProps","addRegion","options","initialisedPluginList","initPlugin","clearRegions","clear","disableDragSelection","instance","isReady","once","un","length","wouldExceedMaxRegions","minLength","on","remove","drag","maxScroll","start","touchId","scrollDirection","wrapperRect","slop","container","scroll","scrollParent","scrollSpeed","scrollThreshold","duration","getDuration","pxMove","edgeScroll","e","scrollLeft","Math","min","max","end","handleEvent","update","window","requestAnimationFrame","eventDown","touches","targetTouches","identifier","scrollWidth","getBoundingClientRect","addEventListener","removeEventListener","eventUp","preventClick","fireEvent","document","body","eventMove","startUpdate","endUpdate","x","clientX","left","right","time","getCurrentTime","cur","snapToGridInterval","offset","snapToGridOffset","round","regionsUtils","style","regionsUtil","getId","Number","resize","undefined","Boolean","isResizing","isDragging","loop","color","handleStyle","handleLeftEl","handleRightEl","data","attributes","maxLength","_onRedraw","preventContextMenu","channelIdx","parseInt","regionHeight","marginTop","channelCount","backend","buffer","numberOfChannels","floor","getHeight","formatTimeCallback","bindInOut","render","updateHandlesResize","element","removeChild","s","play","regionEl","createElement","attrname","className","title","formatTime","setAttribute","position","zIndex","height","top","appendChild","css","cursor","width","backgroundColor","handleLeftCss","assign","handleRightCss","bindEvents","map","slice","join","pixelRatio","dur","getWidth","startLimited","endLimited","regionWidth","firedIn","firedOut","onProcess","realTime","preventDefault","stopPropagation","bindDragEvents","startTime","regionLeftHalfTime","regionRightHalfTime","updated","distanceBetweenCursorAndWrapperEdge","regionHalfTimeWidth","adjustment","minPxPerSec","calculatedLeft","calculatedRight","delta","onDrag","onResize","onDown","target","tagName","toLowerCase","classList","contains","onUp","onMove","maxEnd","direction","cursorStyle","__webpack_module_cache__","__webpack_require__","moduleId","__webpack_modules__"],"mappings":";;;;;CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAX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KqH,aAAc,CAAEsC,OAAQ8C,IAC7DzM,KAAKsH,eAAiBtH,KAAKyG,MAAMzG,KAAKsH,cAAe,CAAEqC,OAAQ8C,S,6CClvBnEC,EAA2B,GCE/B,ODCA,SAASC,EAAoBC,GAE5B,GAAGF,EAAyBE,GAC3B,OAAOF,EAAyBE,GAAUhN,QAG3C,IAAIC,EAAS6M,EAAyBE,GAAY,CAGjDhN,QAAS,IAOV,OAHAiN,EAAoBD,GAAU/M,EAAQA,EAAOD,QAAS+M,GAG/C9M,EAAOD,QCjBR+M,CAAoB,K","file":"wavesurfer.regions.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"WaveSurfer\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WaveSurfer\"] = factory();\n\telse\n\t\troot[\"WaveSurfer\"] = root[\"WaveSurfer\"] || {}, root[\"WaveSurfer\"][\"regions\"] = factory();\n})(this, function() {\nreturn ","/**\n * @since 4.0.0 This class has been split\n *\n * @typedef {Object} RegionsPluginParams\n * @property {?boolean} dragSelection Enable creating regions by dragging with\n * the mouse\n * @property {?RegionParams[]} regions Regions that should be added upon\n * initialisation\n * @property {number} slop=2 The sensitivity of the mouse dragging\n * @property {?number} snapToGridInterval Snap the regions to a grid of the specified multiples in seconds\n * @property {?number} snapToGridOffset Shift the snap-to-grid by the specified seconds. May also be negative.\n * @property {?boolean} deferInit Set to true to manually call\n * @property {number[]} maxRegions Maximum number of regions that may be created by the user at one time.\n * `initPlugin('regions')`\n * @property {function} formatTimeCallback Allows custom formating for region tooltip.\n * @property {?number} edgeScrollWidth='5% from container edges' Optional width for edgeScroll to start\n */\n\n/**\n * @typedef {Object} RegionParams\n * @desc The parameters used to describe a region.\n * @example wavesurfer.addRegion(regionParams);\n * @property {string} id=→random The id of the region\n * @property {number} start=0 The start position of the region (in seconds).\n * @property {number} end=0 The end position of the region (in seconds).\n * @property {?boolean} loop Whether to loop the region when played back.\n * @property {boolean} drag=true Allow/disallow dragging the region.\n * @property {boolean} resize=true Allow/disallow resizing the region.\n * @property {string} [color='rgba(0, 0, 0, 0.1)'] HTML color code.\n * @property {?number} channelIdx Select channel to draw the region on (if there are multiple channel waveforms).\n * @property {?object} handleStyle A set of CSS properties used to style the left and right handle.\n * @property {?boolean} preventContextMenu=false Determines whether the context menu is prevented from being opened.\n */\n\nimport {Region} from \"./region.js\";\n\n/**\n * Regions are visual overlays on waveform that can be used to play and loop\n * portions of audio. Regions can be dragged and resized.\n *\n * Visual customization is possible via CSS (using the selectors\n * `.wavesurfer-region` and `.wavesurfer-handle`).\n *\n * @implements {PluginClass}\n * @extends {Observer}\n *\n * @example\n * // es6\n * import RegionsPlugin from 'wavesurfer.regions.js';\n *\n * // commonjs\n * var RegionsPlugin = require('wavesurfer.regions.js');\n *\n * // if you are using <script> tags\n * var RegionsPlugin = window.WaveSurfer.regions;\n *\n * // ... initialising wavesurfer with the plugin\n * var wavesurfer = WaveSurfer.create({\n * // wavesurfer options ...\n * plugins: [\n * RegionsPlugin.create({\n * // plugin options ...\n * })\n * ]\n * });\n */\nexport default class RegionsPlugin {\n /**\n * Regions plugin definition factory\n *\n * This function must be used to create a plugin definition which can be\n * used by wavesurfer to correctly instantiate the plugin.\n *\n * @param {RegionsPluginParams} params parameters use to initialise the plugin\n * @return {PluginDefinition} an object representing the plugin\n */\n static create(params) {\n return {\n name: 'regions',\n deferInit: params && params.deferInit ? params.deferInit : false,\n params: params,\n staticProps: {\n addRegion(options) {\n if (!this.initialisedPluginList.regions) {\n this.initPlugin('regions');\n }\n return this.regions.add(options);\n },\n\n clearRegions() {\n this.regions && this.regions.clear();\n },\n\n enableDragSelection(options) {\n if (!this.initialisedPluginList.regions) {\n this.initPlugin('regions');\n }\n this.regions.enableDragSelection(options);\n },\n\n disableDragSelection() {\n this.regions.disableDragSelection();\n }\n },\n instance: RegionsPlugin\n };\n }\n\n constructor(params, ws) {\n this.params = params;\n this.wavesurfer = ws;\n this.util = {\n ...ws.util,\n getRegionSnapToGridValue: value => {\n return this.getRegionSnapToGridValue(value, params);\n }\n };\n this.maxRegions = params.maxRegions;\n this.regionsMinLength = params.regionsMinLength || null;\n\n // turn the plugin instance into an observer\n const observerPrototypeKeys = Object.getOwnPropertyNames(\n this.util.Observer.prototype\n );\n observerPrototypeKeys.forEach(key => {\n Region.prototype[key] = this.util.Observer.prototype[key];\n });\n this.wavesurfer.Region = Region;\n\n this._onBackendCreated = () => {\n this.wrapper = this.wavesurfer.drawer.wrapper;\n if (this.params.regions) {\n this.params.regions.forEach(region => {\n region.edgeScrollWidth = this.params.edgeScrollWidth || this.wrapper.clientWidth * 0.05;\n this.add(region);\n });\n }\n };\n\n // Id-based hash of regions\n this.list = {};\n this._onReady = () => {\n this.wrapper = this.wavesurfer.drawer.wrapper;\n if (this.params.dragSelection) {\n this.enableDragSelection(this.params);\n }\n Object.keys(this.list).forEach(id => {\n this.list[id].updateRender();\n });\n };\n }\n\n init() {\n // Check if ws is ready\n if (this.wavesurfer.isReady) {\n this._onBackendCreated();\n this._onReady();\n } else {\n this.wavesurfer.once('ready', this._onReady);\n this.wavesurfer.once('backend-created', this._onBackendCreated);\n }\n }\n\n destroy() {\n this.wavesurfer.un('ready', this._onReady);\n this.wavesurfer.un('backend-created', this._onBackendCreated);\n this.disableDragSelection();\n this.clear();\n }\n\n /**\n * check to see if adding a new region would exceed maxRegions\n * @return {boolean} whether we should proceed and create a region\n * @private\n */\n wouldExceedMaxRegions() {\n return (\n this.maxRegions && Object.keys(this.list).length >= this.maxRegions\n );\n }\n\n /**\n * Add a region\n *\n * @param {object} params Region parameters\n * @return {Region} The created region\n */\n add(params) {\n if (this.wouldExceedMaxRegions()) return null;\n\n if (!params.minLength && this.regionsMinLength) {\n params = {...params, minLength: this.regionsMinLength};\n }\n\n const region = new this.wavesurfer.Region(params, this.util, this.wavesurfer);\n\n this.list[region.id] = region;\n\n region.on('remove', () => {\n delete this.list[region.id];\n });\n\n return region;\n }\n\n /**\n * Remove all regions\n */\n clear() {\n Object.keys(this.list).forEach(id => {\n this.list[id].remove();\n });\n }\n\n enableDragSelection(params) {\n this.disableDragSelection();\n\n const slop = params.slop || 2;\n const container = this.wavesurfer.drawer.container;\n const scroll =\n params.scroll !== false && this.wavesurfer.params.scrollParent;\n const scrollSpeed = params.scrollSpeed || 1;\n const scrollThreshold = params.scrollThreshold || 10;\n let drag;\n let duration = this.wavesurfer.getDuration();\n let maxScroll;\n let start;\n let region;\n let touchId;\n let pxMove = 0;\n let scrollDirection;\n let wrapperRect;\n\n // Scroll when the user is dragging within the threshold\n const edgeScroll = e => {\n if (!region || !scrollDirection) {\n return;\n }\n\n // Update scroll position\n let scrollLeft =\n this.wrapper.scrollLeft + scrollSpeed * scrollDirection;\n this.wrapper.scrollLeft = scrollLeft = Math.min(\n maxScroll,\n Math.max(0, scrollLeft)\n );\n\n // Update range\n const end = this.wavesurfer.drawer.handleEvent(e);\n region.update({\n start: Math.min(end * duration, start * duration),\n end: Math.max(end * duration, start * duration)\n });\n\n // Check that there is more to scroll and repeat\n if (scrollLeft < maxScroll && scrollLeft > 0) {\n window.requestAnimationFrame(() => {\n edgeScroll(e);\n });\n }\n };\n\n const eventDown = e => {\n if (e.touches && e.touches.length > 1) {\n return;\n }\n duration = this.wavesurfer.getDuration();\n touchId = e.targetTouches ? e.targetTouches[0].identifier : null;\n\n // Store for scroll calculations\n maxScroll = this.wrapper.scrollWidth - this.wrapper.clientWidth;\n wrapperRect = this.wrapper.getBoundingClientRect();\n\n drag = true;\n start = this.wavesurfer.drawer.handleEvent(e, true);\n region = null;\n scrollDirection = null;\n };\n this.wrapper.addEventListener('mousedown', eventDown);\n this.wrapper.addEventListener('touchstart', eventDown);\n this.on('disable-drag-selection', () => {\n this.wrapper.removeEventListener('touchstart', eventDown);\n this.wrapper.removeEventListener('mousedown', eventDown);\n });\n\n const eventUp = e => {\n if (e.touches && e.touches.length > 1) {\n return;\n }\n\n drag = false;\n pxMove = 0;\n scrollDirection = null;\n\n if (region) {\n this.util.preventClick();\n region.fireEvent('update-end', e);\n this.wavesurfer.fireEvent('region-update-end', region, e);\n }\n\n region = null;\n };\n this.wrapper.addEventListener('mouseleave', eventUp);\n this.wrapper.addEventListener('mouseup', eventUp);\n this.wrapper.addEventListener('touchend', eventUp);\n\n document.body.addEventListener('mouseup', eventUp);\n document.body.addEventListener('touchend', eventUp);\n this.on('disable-drag-selection', () => {\n document.body.removeEventListener('mouseup', eventUp);\n document.body.removeEventListener('touchend', eventUp);\n this.wrapper.removeEventListener('touchend', eventUp);\n this.wrapper.removeEventListener('mouseup', eventUp);\n this.wrapper.removeEventListener('mouseleave', eventUp);\n });\n\n const eventMove = e => {\n if (!drag) {\n return;\n }\n if (++pxMove <= slop) {\n return;\n }\n\n if (e.touches && e.touches.length > 1) {\n return;\n }\n if (e.targetTouches && e.targetTouches[0].identifier != touchId) {\n return;\n }\n\n // auto-create a region during mouse drag, unless region-count would exceed \"maxRegions\"\n if (!region) {\n region = this.add(params || {});\n if (!region) return;\n }\n\n const end = this.wavesurfer.drawer.handleEvent(e);\n const startUpdate = this.wavesurfer.regions.util.getRegionSnapToGridValue(\n start * duration\n );\n const endUpdate = this.wavesurfer.regions.util.getRegionSnapToGridValue(\n end * duration\n );\n region.update({\n start: Math.min(endUpdate, startUpdate),\n end: Math.max(endUpdate, startUpdate)\n });\n\n // If scrolling is enabled\n if (scroll && container.clientWidth < this.wrapper.scrollWidth) {\n // Check threshold based on mouse\n const x = e.clientX - wrapperRect.left;\n if (x <= scrollThreshold) {\n scrollDirection = -1;\n } else if (x >= wrapperRect.right - scrollThreshold) {\n scrollDirection = 1;\n } else {\n scrollDirection = null;\n }\n scrollDirection && edgeScroll(e);\n }\n };\n this.wrapper.addEventListener('mousemove', eventMove);\n this.wrapper.addEventListener('touchmove', eventMove);\n this.on('disable-drag-selection', () => {\n this.wrapper.removeEventListener('touchmove', eventMove);\n this.wrapper.removeEventListener('mousemove', eventMove);\n });\n\n this.wavesurfer.on('region-created', region => {\n if (this.regionsMinLength) {\n region.minLength = this.regionsMinLength;\n }\n });\n }\n\n disableDragSelection() {\n this.fireEvent('disable-drag-selection');\n }\n\n /**\n * Get current region\n *\n * The smallest region that contains the current time. If several such\n * regions exist, take the first. Return `null` if none exist.\n *\n * @returns {Region} The current region\n */\n getCurrentRegion() {\n const time = this.wavesurfer.getCurrentTime();\n let min = null;\n Object.keys(this.list).forEach(id => {\n const cur = this.list[id];\n if (cur.start <= time && cur.end >= time) {\n if (!min || cur.end - cur.start < min.end - min.start) {\n min = cur;\n }\n }\n });\n\n return min;\n }\n\n /**\n * Match the value to the grid, if required\n *\n * If the regions plugin params have a snapToGridInterval set, return the\n * value matching the nearest grid interval. If no snapToGridInterval is set,\n * the passed value will be returned without modification.\n *\n * @param {number} value the value to snap to the grid, if needed\n * @param {Object} params the regions plugin params\n * @returns {number} value\n */\n getRegionSnapToGridValue(value, params) {\n if (params.snapToGridInterval) {\n // the regions should snap to a grid\n const offset = params.snapToGridOffset || 0;\n return (\n Math.round((value - offset) / params.snapToGridInterval) *\n params.snapToGridInterval +\n offset\n );\n }\n\n // no snap-to-grid\n return value;\n }\n}\n","/**\n * @since 4.0.0\n *\n * (Single) Region plugin class\n *\n * Must be turned into an observer before instantiating. This is done in\n * `RegionsPlugin` (main plugin class).\n *\n * @extends {Observer}\n */\nexport class Region {\n constructor(params, regionsUtils, ws) {\n this.wavesurfer = ws;\n this.wrapper = ws.drawer.wrapper;\n this.util = ws.util;\n this.style = this.util.style;\n this.regionsUtil = regionsUtils;\n\n this.id = params.id == null ? ws.util.getId() : params.id;\n this.start = Number(params.start) || 0;\n this.end =\n params.end == null\n ? // small marker-like region\n this.start +\n (4 / this.wrapper.scrollWidth) * this.wavesurfer.getDuration()\n : Number(params.end);\n this.resize =\n params.resize === undefined ? true : Boolean(params.resize);\n this.drag = params.drag === undefined ? true : Boolean(params.drag);\n // reflect resize and drag state of region for region-updated listener\n this.isResizing = false;\n this.isDragging = false;\n this.loop = Boolean(params.loop);\n this.color = params.color || 'rgba(0, 0, 0, 0.1)';\n // The left and right handleStyle properties can be set to 'none' for\n // no styling or can be assigned an object containing CSS properties.\n this.handleStyle = params.handleStyle || {\n left: {},\n right: {}\n };\n this.handleLeftEl = null;\n this.handleRightEl = null;\n this.data = params.data || {};\n this.attributes = params.attributes || {};\n\n this.maxLength = params.maxLength;\n // It assumes the minLength parameter value, or the regionsMinLength parameter value, if the first one not provided\n this.minLength = params.minLength;\n this._onRedraw = () => this.updateRender();\n\n this.scroll = params.scroll !== false && ws.params.scrollParent;\n this.scrollSpeed = params.scrollSpeed || 1;\n this.scrollThreshold = params.scrollThreshold || 10;\n // Determines whether the context menu is prevented from being opened.\n this.preventContextMenu =\n params.preventContextMenu === undefined\n ? false\n : Boolean(params.preventContextMenu);\n\n // select channel ID to set region\n let channelIdx =\n params.channelIdx == null ? -1 : parseInt(params.channelIdx);\n this.regionHeight = '100%';\n this.marginTop = '0px';\n\n if (channelIdx !== -1) {\n let channelCount =\n this.wavesurfer.backend.buffer != null\n ? this.wavesurfer.backend.buffer.numberOfChannels\n : -1;\n if (channelCount >= 0 && channelIdx < channelCount) {\n this.regionHeight = Math.floor((1 / channelCount) * 100) + '%';\n this.marginTop =\n this.wavesurfer.getHeight() * channelIdx + 'px';\n }\n }\n\n this.formatTimeCallback = params.formatTimeCallback;\n this.edgeScrollWidth = params.edgeScrollWidth;\n this.bindInOut();\n this.render();\n this.wavesurfer.on('zoom', this._onRedraw);\n this.wavesurfer.on('redraw', this._onRedraw);\n this.wavesurfer.fireEvent('region-created', this);\n }\n\n /* Update region params. */\n update(params) {\n if (params.start != null) {\n this.start = Number(params.start);\n }\n if (params.end != null) {\n this.end = Number(params.end);\n }\n if (params.loop != null) {\n this.loop = Boolean(params.loop);\n }\n if (params.color != null) {\n this.color = params.color;\n }\n if (params.handleStyle != null) {\n this.handleStyle = params.handleStyle;\n }\n if (params.data != null) {\n this.data = params.data;\n }\n if (params.resize != null) {\n this.resize = Boolean(params.resize);\n this.updateHandlesResize(this.resize);\n }\n if (params.drag != null) {\n this.drag = Boolean(params.drag);\n }\n if (params.maxLength != null) {\n this.maxLength = Number(params.maxLength);\n }\n if (params.minLength != null) {\n this.minLength = Number(params.minLength);\n }\n if (params.attributes != null) {\n this.attributes = params.attributes;\n }\n\n this.updateRender();\n this.fireEvent('update');\n this.wavesurfer.fireEvent('region-updated', this);\n }\n\n /* Remove a single region. */\n remove() {\n if (this.element) {\n this.wrapper.removeChild(this.element);\n this.element = null;\n this.fireEvent('remove');\n this.wavesurfer.un('zoom', this._onRedraw);\n this.wavesurfer.un('redraw', this._onRedraw);\n this.wavesurfer.fireEvent('region-removed', this);\n }\n }\n\n /**\n * Play the audio region.\n * @param {number} start Optional offset to start playing at\n */\n play(start) {\n const s = start || this.start;\n this.wavesurfer.play(s, this.end);\n this.fireEvent('play');\n this.wavesurfer.fireEvent('region-play', this);\n }\n\n /**\n * Play the audio region in a loop.\n * @param {number} start Optional offset to start playing at\n * */\n playLoop(start) {\n this.loop = true;\n this.play(start);\n }\n\n /**\n * Set looping on/off.\n * @param {boolean} loop True if should play in loop\n */\n setLoop(loop) {\n this.loop = loop;\n }\n\n /* Render a region as a DOM element. */\n render() {\n const regionEl = document.createElement('region');\n\n regionEl.className = 'wavesurfer-region';\n regionEl.title = this.formatTime(this.start, this.end);\n regionEl.setAttribute('data-id', this.id);\n\n for (const attrname in this.attributes) {\n regionEl.setAttribute(\n 'data-region-' + attrname,\n this.attributes[attrname]\n );\n }\n\n this.style(regionEl, {\n position: 'absolute',\n zIndex: 2,\n height: this.regionHeight,\n top: this.marginTop\n });\n\n /* Resize handles */\n if (this.resize) {\n this.handleLeftEl = regionEl.appendChild(\n document.createElement('handle')\n );\n this.handleRightEl = regionEl.appendChild(\n document.createElement('handle')\n );\n\n this.handleLeftEl.className = 'wavesurfer-handle wavesurfer-handle-start';\n this.handleRightEl.className = 'wavesurfer-handle wavesurfer-handle-end';\n\n // Default CSS properties for both handles.\n const css = {\n cursor: 'col-resize',\n position: 'absolute',\n top: '0px',\n width: '2px',\n height: '100%',\n backgroundColor: 'rgba(0, 0, 0, 1)'\n };\n\n // Merge CSS properties per handle.\n const handleLeftCss =\n this.handleStyle.left !== 'none'\n ? Object.assign({ left: '0px' }, css, this.handleStyle.left)\n : null;\n const handleRightCss =\n this.handleStyle.right !== 'none'\n ? Object.assign(\n { right: '0px' },\n css,\n this.handleStyle.right\n )\n : null;\n\n if (handleLeftCss) {\n this.style(this.handleLeftEl, handleLeftCss);\n }\n\n if (handleRightCss) {\n this.style(this.handleRightEl, handleRightCss);\n }\n }\n\n this.element = this.wrapper.appendChild(regionEl);\n this.updateRender();\n this.bindEvents(regionEl);\n }\n\n formatTime(start, end) {\n if (this.formatTimeCallback) {\n return this.formatTimeCallback(start, end);\n }\n return (start == end ? [start] : [start, end])\n .map((time) =>\n [\n Math.floor((time % 3600) / 60), // minutes\n ('00' + Math.floor(time % 60)).slice(-2) // seconds\n ].join(':')\n )\n .join('-');\n }\n\n getWidth() {\n return this.wavesurfer.drawer.width / this.wavesurfer.params.pixelRatio;\n }\n\n /* Update element's position, width, color. */\n updateRender() {\n // duration varies during loading process, so don't overwrite important data\n const dur = this.wavesurfer.getDuration();\n const width = this.getWidth();\n\n let startLimited = this.start;\n let endLimited = this.end;\n if (startLimited < 0) {\n startLimited = 0;\n endLimited = endLimited - startLimited;\n }\n if (endLimited > dur) {\n endLimited = dur;\n startLimited = dur - (endLimited - startLimited);\n }\n\n if (this.minLength != null) {\n endLimited = Math.max(startLimited + this.minLength, endLimited);\n }\n\n if (this.maxLength != null) {\n endLimited = Math.min(startLimited + this.maxLength, endLimited);\n }\n\n if (this.element != null) {\n // Calculate the left and width values of the region such that\n // no gaps appear between regions.\n const left = Math.round((startLimited / dur) * width);\n const regionWidth = Math.round((endLimited / dur) * width) - left;\n\n this.style(this.element, {\n left: left + 'px',\n width: regionWidth + 'px',\n backgroundColor: this.color,\n cursor: this.drag ? 'move' : 'default'\n });\n\n for (const attrname in this.attributes) {\n this.element.setAttribute(\n 'data-region-' + attrname,\n this.attributes[attrname]\n );\n }\n\n this.element.title = this.formatTime(this.start, this.end);\n }\n }\n\n /* Bind audio events. */\n bindInOut() {\n this.firedIn = false;\n this.firedOut = false;\n\n const onProcess = (time) => {\n let start = Math.round(this.start * 10) / 10;\n let end = Math.round(this.end * 10) / 10;\n time = Math.round(time * 10) / 10;\n\n if (\n !this.firedOut &&\n this.firedIn &&\n (start > time || end <= time)\n ) {\n this.firedOut = true;\n this.firedIn = false;\n this.fireEvent('out');\n this.wavesurfer.fireEvent('region-out', this);\n }\n if (!this.firedIn && start <= time && end > time) {\n this.firedIn = true;\n this.firedOut = false;\n this.fireEvent('in');\n this.wavesurfer.fireEvent('region-in', this);\n }\n };\n\n this.wavesurfer.backend.on('audioprocess', onProcess);\n\n this.on('remove', () => {\n this.wavesurfer.backend.un('audioprocess', onProcess);\n });\n\n /* Loop playback. */\n this.on('out', () => {\n if (this.loop) {\n const realTime = this.wavesurfer.getCurrentTime();\n if (realTime >= this.start && realTime <= this.end) {\n this.wavesurfer.play(this.start);\n }\n }\n });\n }\n\n /* Bind DOM events. */\n bindEvents() {\n const preventContextMenu = this.preventContextMenu;\n\n this.element.addEventListener('mouseenter', (e) => {\n this.fireEvent('mouseenter', e);\n this.wavesurfer.fireEvent('region-mouseenter', this, e);\n });\n\n this.element.addEventListener('mouseleave', (e) => {\n this.fireEvent('mouseleave', e);\n this.wavesurfer.fireEvent('region-mouseleave', this, e);\n });\n\n this.element.addEventListener('click', (e) => {\n e.preventDefault();\n this.fireEvent('click', e);\n this.wavesurfer.fireEvent('region-click', this, e);\n });\n\n this.element.addEventListener('dblclick', (e) => {\n e.stopPropagation();\n e.preventDefault();\n this.fireEvent('dblclick', e);\n this.wavesurfer.fireEvent('region-dblclick', this, e);\n });\n\n this.element.addEventListener('contextmenu', (e) => {\n if (preventContextMenu) {\n e.preventDefault();\n }\n this.fireEvent('contextmenu', e);\n this.wavesurfer.fireEvent('region-contextmenu', this, e);\n });\n\n /* Drag or resize on mousemove. */\n if (this.drag || this.resize) {\n this.bindDragEvents();\n }\n }\n\n bindDragEvents() {\n const container = this.wavesurfer.drawer.container;\n const scrollSpeed = this.scrollSpeed;\n const scrollThreshold = this.scrollThreshold;\n let startTime;\n let touchId;\n let drag;\n let maxScroll;\n let resize;\n let updated = false;\n let scrollDirection;\n let wrapperRect;\n let regionLeftHalfTime;\n let regionRightHalfTime;\n\n // Scroll when the user is dragging within the threshold\n const edgeScroll = (e) => {\n const duration = this.wavesurfer.getDuration();\n if (!scrollDirection || (!drag && !resize)) {\n return;\n }\n\n const x = e.clientX;\n let distanceBetweenCursorAndWrapperEdge = 0;\n let regionHalfTimeWidth = 0;\n let adjustment = 0;\n\n // Get the currently selected time according to the mouse position\n let time = this.regionsUtil.getRegionSnapToGridValue(\n this.wavesurfer.drawer.handleEvent(e) * duration\n );\n\n if (drag) {\n // Considering the point of contact with the region while edgescrolling\n if (scrollDirection === -1) {\n regionHalfTimeWidth = regionLeftHalfTime * this.wavesurfer.params.minPxPerSec;\n distanceBetweenCursorAndWrapperEdge = x - wrapperRect.left;\n } else {\n regionHalfTimeWidth = regionRightHalfTime * this.wavesurfer.params.minPxPerSec;\n distanceBetweenCursorAndWrapperEdge = wrapperRect.right - x;\n }\n } else {\n // Considering minLength while edgescroll\n let minLength = this.minLength;\n if (!minLength) {\n minLength = 0;\n }\n\n if (resize === 'start') {\n if (time > this.end - minLength) {\n time = this.end - minLength;\n adjustment = scrollSpeed * scrollDirection;\n }\n\n if (time < 0) {\n time = 0;\n }\n } else if (resize === 'end') {\n if (time < this.start + minLength) {\n time = this.start + minLength;\n adjustment = scrollSpeed * scrollDirection;\n }\n\n if (time > duration) {\n time = duration;\n }\n }\n }\n\n // Don't edgescroll if region has reached min or max limit\n if (scrollDirection === -1) {\n if (Math.round(this.wrapper.scrollLeft) === 0) {\n return;\n }\n\n if (Math.round(this.wrapper.scrollLeft - regionHalfTimeWidth + distanceBetweenCursorAndWrapperEdge) <= 0) {\n return;\n }\n } else {\n if (Math.round(this.wrapper.scrollLeft) === maxScroll) {\n return;\n }\n\n if (Math.round(this.wrapper.scrollLeft + regionHalfTimeWidth - distanceBetweenCursorAndWrapperEdge) >= maxScroll) {\n return;\n }\n }\n\n // Update scroll position\n let scrollLeft = this.wrapper.scrollLeft - adjustment + scrollSpeed * scrollDirection;\n\n if (scrollDirection === -1) {\n const calculatedLeft = Math.max(0 + regionHalfTimeWidth - distanceBetweenCursorAndWrapperEdge, scrollLeft);\n this.wrapper.scrollLeft = scrollLeft = calculatedLeft;\n } else {\n const calculatedRight = Math.min(maxScroll - regionHalfTimeWidth + distanceBetweenCursorAndWrapperEdge, scrollLeft);\n this.wrapper.scrollLeft = scrollLeft = calculatedRight;\n }\n\n const delta = time - startTime;\n startTime = time;\n\n // Continue dragging or resizing\n drag ? this.onDrag(delta) : this.onResize(delta, resize);\n\n // Repeat\n window.requestAnimationFrame(() => {\n edgeScroll(e);\n });\n };\n\n const onDown = (e) => {\n const duration = this.wavesurfer.getDuration();\n if (e.touches && e.touches.length > 1) {\n return;\n }\n touchId = e.targetTouches ? e.targetTouches[0].identifier : null;\n\n // stop the event propagation, if this region is resizable or draggable\n // and the event is therefore handled here.\n if (this.drag || this.resize) {\n e.stopPropagation();\n }\n\n // Store the selected startTime we begun dragging or resizing\n startTime = this.regionsUtil.getRegionSnapToGridValue(\n this.wavesurfer.drawer.handleEvent(e, true) * duration\n );\n\n // Store the selected point of contact when we begin dragging\n regionLeftHalfTime = startTime - this.start;\n regionRightHalfTime = this.end - startTime;\n\n // Store for scroll calculations\n maxScroll = this.wrapper.scrollWidth - this.wrapper.clientWidth;\n wrapperRect = this.wrapper.getBoundingClientRect();\n\n this.isResizing = false;\n this.isDragging = false;\n if (e.target.tagName.toLowerCase() === 'handle') {\n this.isResizing = true;\n resize = e.target.classList.contains('wavesurfer-handle-start')\n ? 'start'\n : 'end';\n } else {\n this.isDragging = true;\n drag = true;\n resize = false;\n }\n };\n const onUp = (e) => {\n if (e.touches && e.touches.length > 1) {\n return;\n }\n\n if (drag || resize) {\n this.isDragging = false;\n this.isResizing = false;\n drag = false;\n scrollDirection = null;\n resize = false;\n }\n\n if (updated) {\n updated = false;\n this.util.preventClick();\n this.fireEvent('update-end', e);\n this.wavesurfer.fireEvent('region-update-end', this, e);\n }\n };\n const onMove = (e) => {\n const duration = this.wavesurfer.getDuration();\n\n if (e.touches && e.touches.length > 1) {\n return;\n }\n if (e.targetTouches && e.targetTouches[0].identifier != touchId) {\n return;\n }\n if (!drag && !resize) {\n return;\n }\n\n const oldTime = startTime;\n let time = this.regionsUtil.getRegionSnapToGridValue(\n this.wavesurfer.drawer.handleEvent(e) * duration\n );\n\n if (drag) {\n // To maintain relative cursor start point while dragging\n const maxEnd = this.wavesurfer.getDuration();\n if (time > maxEnd - regionRightHalfTime) {\n time = maxEnd - regionRightHalfTime;\n }\n\n if (time - regionLeftHalfTime < 0) {\n time = regionLeftHalfTime;\n }\n }\n\n if (resize) {\n // To maintain relative cursor start point while resizing\n // we have to handle for minLength\n let minLength = this.minLength;\n if (!minLength) {\n minLength = 0;\n }\n\n if (resize === 'start') {\n if (time > this.end - minLength) {\n time = this.end - minLength;\n }\n\n if (time < 0) {\n time = 0;\n }\n } else if (resize === 'end') {\n if (time < this.start + minLength) {\n time = this.start + minLength;\n }\n\n if (time > duration) {\n time = duration;\n }\n }\n }\n\n let delta = time - startTime;\n startTime = time;\n\n // Drag\n if (this.drag && drag) {\n updated = updated || !!delta;\n this.onDrag(delta);\n }\n\n // Resize\n if (this.resize && resize) {\n updated = updated || !!delta;\n this.onResize(delta, resize);\n }\n\n if (\n this.scroll &&\n container.clientWidth < this.wrapper.scrollWidth\n ) {\n // Triggering edgescroll from within edgeScrollWidth\n if (drag) {\n let x = e.clientX;\n\n // Check direction\n if (x < wrapperRect.left + this.edgeScrollWidth) {\n scrollDirection = -1;\n } else if (x > wrapperRect.right - this.edgeScrollWidth) {\n scrollDirection = 1;\n } else {\n scrollDirection = null;\n }\n } else {\n let x = e.clientX;\n\n // Check direction\n if (x < wrapperRect.left + this.edgeScrollWidth) {\n scrollDirection = -1;\n } else if (x > wrapperRect.right - this.edgeScrollWidth) {\n scrollDirection = 1;\n } else {\n scrollDirection = null;\n }\n }\n\n if (scrollDirection) {\n edgeScroll(e);\n }\n }\n };\n\n this.element.addEventListener('mousedown', onDown);\n this.element.addEventListener('touchstart', onDown);\n\n document.body.addEventListener('mousemove', onMove);\n document.body.addEventListener('touchmove', onMove);\n\n document.body.addEventListener('mouseup', onUp);\n document.body.addEventListener('touchend', onUp);\n\n this.on('remove', () => {\n document.body.removeEventListener('mouseup', onUp);\n document.body.removeEventListener('touchend', onUp);\n document.body.removeEventListener('mousemove', onMove);\n document.body.removeEventListener('touchmove', onMove);\n });\n\n this.wavesurfer.on('destroy', () => {\n document.body.removeEventListener('mouseup', onUp);\n document.body.removeEventListener('touchend', onUp);\n });\n }\n\n onDrag(delta) {\n const maxEnd = this.wavesurfer.getDuration();\n if (this.end + delta > maxEnd) {\n delta = maxEnd - this.end;\n }\n\n if (this.start + delta < 0) {\n delta = this.start * -1;\n }\n\n this.update({\n start: this.start + delta,\n end: this.end + delta\n });\n }\n\n /**\n * @example\n * onResize(-5, 'start') // Moves the start point 5 seconds back\n * onResize(0.5, 'end') // Moves the end point 0.5 seconds forward\n *\n * @param {number} delta How much to add or subtract, given in seconds\n * @param {string} direction 'start 'or 'end'\n */\n onResize(delta, direction) {\n const duration = this.wavesurfer.getDuration();\n if (direction === 'start') {\n // Check if changing the start by the given delta would result in the region being smaller than minLength\n // Ignore cases where we are making the region wider rather than shrinking it\n if (delta > 0 && this.end - (this.start + delta) < this.minLength) {\n delta = this.end - this.minLength - this.start;\n }\n\n if (delta < 0 && (this.start + delta) < 0) {\n delta = this.start * -1;\n }\n\n this.update({\n start: Math.min(this.start + delta, this.end),\n end: Math.max(this.start + delta, this.end)\n });\n } else {\n // Check if changing the end by the given delta would result in the region being smaller than minLength\n // Ignore cases where we are making the region wider rather than shrinking it\n if (delta < 0 && this.end + delta - this.start < this.minLength) {\n delta = this.start + this.minLength - this.end;\n }\n\n if (delta > 0 && (this.end + delta) > duration) {\n delta = duration - this.end;\n }\n\n this.update({\n start: Math.min(this.end + delta, this.start),\n end: Math.max(this.end + delta, this.start)\n });\n }\n }\n\n updateHandlesResize(resize) {\n const cursorStyle = resize ? 'col-resize' : 'auto';\n\n this.handleLeftEl && this.style(this.handleLeftEl, { cursor: cursorStyle });\n this.handleRightEl && this.style(this.handleRightEl, { cursor: cursorStyle });\n }\n}\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tif(__webpack_module_cache__[moduleId]) {\n\t\treturn __webpack_module_cache__[moduleId].exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// module exports must be returned from runtime so entry inlining is disabled\n// startup\n// Load entry module and return exports\nreturn __webpack_require__(23);\n"],"sourceRoot":""}
|
|
1
|
+
{"version":3,"sources":["webpack://WaveSurfer.[name]/webpack/universalModuleDefinition","webpack://WaveSurfer.[name]/./src/plugin/regions/index.js","webpack://WaveSurfer.[name]/./src/plugin/regions/region.js","webpack://WaveSurfer.[name]/webpack/bootstrap","webpack://WaveSurfer.[name]/webpack/startup"],"names":["root","factory","exports","module","define","amd","this","RegionsPlugin","params","ws","wavesurfer","util","getRegionSnapToGridValue","value","maxRegions","regionsMinLength","Object","getOwnPropertyNames","Observer","prototype","forEach","key","Region","_onBackendCreated","wrapper","drawer","orientation","regions","region","edgeScrollWidth","clientWidth","add","list","_onReady","vertical","dragSelection","enableDragSelection","keys","id","updateRender","name","deferInit","staticProps","addRegion","options","initialisedPluginList","initPlugin","clearRegions","clear","disableDragSelection","instance","isReady","once","un","length","wouldExceedMaxRegions","minLength","on","remove","drag","maxScroll","start","touchId","scrollDirection","wrapperRect","slop","container","scroll","scrollParent","scrollSpeed","scrollThreshold","duration","getDuration","pxMove","edgeScroll","e","scrollLeft","Math","min","max","end","handleEvent","update","window","requestAnimationFrame","eventDown","touches","targetTouches","identifier","scrollWidth","withOrientation","getBoundingClientRect","addEventListener","removeEventListener","eventUp","preventClick","fireEvent","document","body","eventMove","event","startUpdate","endUpdate","orientedEvent","x","clientX","left","right","time","getCurrentTime","cur","snapToGridInterval","offset","snapToGridOffset","round","regionsUtils","style","regionsUtil","getId","Number","resize","undefined","Boolean","isResizing","isDragging","loop","color","handleStyle","handleLeftEl","handleRightEl","data","attributes","showTooltip","maxLength","_onRedraw","preventContextMenu","channelIdx","parseInt","regionHeight","marginTop","channelCount","backend","buffer","numberOfChannels","floor","getHeight","formatTimeCallback","bindInOut","render","updateHandlesResize","element","removeChild","domElement","s","play","attrname","appendChild","createElement","className","title","formatTime","setAttribute","position","zIndex","height","top","css","cursor","width","backgroundColor","handleLeftCss","assign","handleRightCss","bindEvents","map","slice","join","pixelRatio","dur","getWidth","startLimited","endLimited","regionWidth","firedIn","firedOut","onProcess","realTime","preventDefault","stopPropagation","bindDragEvents","startTime","regionLeftHalfTime","regionRightHalfTime","updated","distanceBetweenCursorAndWrapperEdge","regionHalfTimeWidth","adjustment","minPxPerSec","wrapperScrollLeft","calculatedLeft","calculatedRight","delta","onDrag","onResize","onDown","target","tagName","toLowerCase","classList","contains","onUp","onMove","maxEnd","passive","direction","cursorStyle","__webpack_module_cache__","__webpack_require__","moduleId","cachedModule","__webpack_modules__"],"mappings":";;;;;CAAA,SAA2CA,EAAMC,GAC1B,iBAAZC,SAA0C,iBAAXC,OACxCA,OAAOD,QAAUD,IACQ,mBAAXG,QAAyBA,O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KAAK4E,OAAO,CACRrB,MAAOgB,KAAKC,IAAIxE,KAAKuD,MAAQ4I,EAAOnM,KAAK0E,KACzCA,IAAKH,KAAKE,IAAIzE,KAAKuD,MAAQ4I,EAAOnM,KAAK0E,SAKvCyH,EAAQ,GAAKnM,KAAK0E,IAAMyH,EAAQnM,KAAKuD,MAAQvD,KAAKkD,YAClDiJ,EAAQnM,KAAKuD,MAAQvD,KAAKkD,UAAYlD,KAAK0E,KAG3CyH,EAAQ,GAAMnM,KAAK0E,IAAMyH,EAASlI,IAClCkI,EAAQlI,EAAWjE,KAAK0E,KAG5B1E,KAAK4E,OAAO,CACRrB,MAAOgB,KAAKC,IAAIxE,KAAK0E,IAAMyH,EAAOnM,KAAKuD,OACvCmB,IAAKH,KAAKE,IAAIzE,KAAK0E,IAAMyH,EAAOnM,KAAKuD,Y,iCAKjD,SAAoB2D,GAChB,IAAI+F,EAEAA,EADA/F,EACclH,KAAK4B,SAAW,aAAe,aAE/B,OAGlB5B,KAAK0H,cAAgB1H,KAAK8G,MAAM9G,KAAK0H,aAAc,CAAEuC,OAAQgD,IAC7DjN,KAAK2H,eAAiB3H,KAAK8G,MAAM9G,KAAK2H,cAAe,CAAEsC,OAAQgD,S,6CC/vBnEC,EAA2B,G,OAG/B,SAASC,EAAoBC,GAE5B,IAAIC,EAAeH,EAAyBE,GAC5C,QAAqBjG,IAAjBkG,EACH,OAAOA,EAAazN,QAGrB,IAAIC,EAASqN,EAAyBE,GAAY,CAGjDxN,QAAS,IAOV,OAHA0N,EAAoBF,GAAUvN,EAAQA,EAAOD,QAASuN,GAG/CtN,EAAOD,QClBWuN,CAAoB,K","file":"wavesurfer.regions.min.js","sourcesContent":["(function webpackUniversalModuleDefinition(root, factory) {\n\tif(typeof exports === 'object' && typeof module === 'object')\n\t\tmodule.exports = factory();\n\telse if(typeof define === 'function' && define.amd)\n\t\tdefine(\"WaveSurfer\", [], factory);\n\telse if(typeof exports === 'object')\n\t\texports[\"WaveSurfer\"] = factory();\n\telse\n\t\troot[\"WaveSurfer\"] = root[\"WaveSurfer\"] || {}, root[\"WaveSurfer\"][\"regions\"] = factory();\n})(this, function() {\nreturn ","/**\n * @since 4.0.0 This class has been split\n *\n * @typedef {Object} RegionsPluginParams\n * @property {?boolean} dragSelection Enable creating regions by dragging with\n * the mouse\n * @property {?RegionParams[]} regions Regions that should be added upon\n * initialisation\n * @property {number} slop=2 The sensitivity of the mouse dragging\n * @property {?number} snapToGridInterval Snap the regions to a grid of the specified multiples in seconds\n * @property {?number} snapToGridOffset Shift the snap-to-grid by the specified seconds. May also be negative.\n * @property {?boolean} deferInit Set to true to manually call\n * @property {number[]} maxRegions Maximum number of regions that may be created by the user at one time.\n * `initPlugin('regions')`\n * @property {function} formatTimeCallback Allows custom formating for region tooltip.\n * @property {?number} edgeScrollWidth='5% from container edges' Optional width for edgeScroll to start\n */\n\n/**\n * @typedef {Object} RegionParams\n * @desc The parameters used to describe a region.\n * @example wavesurfer.addRegion(regionParams);\n * @property {string} id=→random The id of the region\n * @property {number} start=0 The start position of the region (in seconds).\n * @property {number} end=0 The end position of the region (in seconds).\n * @property {?boolean} loop Whether to loop the region when played back.\n * @property {boolean} drag=true Allow/disallow dragging the region.\n * @property {boolean} resize=true Allow/disallow resizing the region.\n * @property {string} [color='rgba(0, 0, 0, 0.1)'] HTML color code.\n * @property {?number} channelIdx Select channel to draw the region on (if there are multiple channel waveforms).\n * @property {?object} handleStyle A set of CSS properties used to style the left and right handle.\n * @property {?boolean} preventContextMenu=false Determines whether the context menu is prevented from being opened.\n * @property {boolean} showTooltip=true Enable/disable tooltip displaying start and end times when hovering over region.\n */\n\nimport {Region} from \"./region.js\";\n\n/**\n * Regions are visual overlays on waveform that can be used to play and loop\n * portions of audio. Regions can be dragged and resized.\n *\n * Visual customization is possible via CSS (using the selectors\n * `.wavesurfer-region` and `.wavesurfer-handle`).\n *\n * @implements {PluginClass}\n * @extends {Observer}\n *\n * @example\n * // es6\n * import RegionsPlugin from 'wavesurfer.regions.js';\n *\n * // commonjs\n * var RegionsPlugin = require('wavesurfer.regions.js');\n *\n * // if you are using <script> tags\n * var RegionsPlugin = window.WaveSurfer.regions;\n *\n * // ... initialising wavesurfer with the plugin\n * var wavesurfer = WaveSurfer.create({\n * // wavesurfer options ...\n * plugins: [\n * RegionsPlugin.create({\n * // plugin options ...\n * })\n * ]\n * });\n */\nexport default class RegionsPlugin {\n /**\n * Regions plugin definition factory\n *\n * This function must be used to create a plugin definition which can be\n * used by wavesurfer to correctly instantiate the plugin.\n *\n * @param {RegionsPluginParams} params parameters use to initialise the plugin\n * @return {PluginDefinition} an object representing the plugin\n */\n static create(params) {\n return {\n name: 'regions',\n deferInit: params && params.deferInit ? params.deferInit : false,\n params: params,\n staticProps: {\n addRegion(options) {\n if (!this.initialisedPluginList.regions) {\n this.initPlugin('regions');\n }\n return this.regions.add(options);\n },\n\n clearRegions() {\n this.regions && this.regions.clear();\n },\n\n enableDragSelection(options) {\n if (!this.initialisedPluginList.regions) {\n this.initPlugin('regions');\n }\n this.regions.enableDragSelection(options);\n },\n\n disableDragSelection() {\n this.regions.disableDragSelection();\n }\n },\n instance: RegionsPlugin\n };\n }\n\n constructor(params, ws) {\n this.params = params;\n this.wavesurfer = ws;\n this.util = {\n ...ws.util,\n getRegionSnapToGridValue: value => {\n return this.getRegionSnapToGridValue(value, params);\n }\n };\n this.maxRegions = params.maxRegions;\n this.regionsMinLength = params.regionsMinLength || null;\n\n // turn the plugin instance into an observer\n const observerPrototypeKeys = Object.getOwnPropertyNames(\n this.util.Observer.prototype\n );\n observerPrototypeKeys.forEach(key => {\n Region.prototype[key] = this.util.Observer.prototype[key];\n });\n this.wavesurfer.Region = Region;\n\n // By default, scroll the container if the user drags a region\n // within 5% of its edge\n const scrollWidthProportion = 0.05;\n this._onBackendCreated = () => {\n this.wrapper = this.wavesurfer.drawer.wrapper;\n this.orientation = this.wavesurfer.drawer.orientation;\n if (this.params.regions) {\n this.params.regions.forEach(region => {\n region.edgeScrollWidth = this.params.edgeScrollWidth ||\n this.wrapper.clientWidth * scrollWidthProportion;\n this.add(region);\n });\n }\n };\n\n // Id-based hash of regions\n this.list = {};\n this._onReady = () => {\n this.wrapper = this.wavesurfer.drawer.wrapper;\n this.vertical = this.wavesurfer.drawer.params.vertical;\n if (this.params.dragSelection) {\n this.enableDragSelection(this.params);\n }\n Object.keys(this.list).forEach(id => {\n this.list[id].updateRender();\n });\n };\n }\n\n init() {\n // Check if ws is ready\n if (this.wavesurfer.isReady) {\n this._onBackendCreated();\n this._onReady();\n } else {\n this.wavesurfer.once('ready', this._onReady);\n this.wavesurfer.once('backend-created', this._onBackendCreated);\n }\n }\n\n destroy() {\n this.wavesurfer.un('ready', this._onReady);\n this.wavesurfer.un('backend-created', this._onBackendCreated);\n this.disableDragSelection();\n this.clear();\n }\n\n /**\n * check to see if adding a new region would exceed maxRegions\n * @return {boolean} whether we should proceed and create a region\n * @private\n */\n wouldExceedMaxRegions() {\n return (\n this.maxRegions && Object.keys(this.list).length >= this.maxRegions\n );\n }\n\n /**\n * Add a region\n *\n * @param {object} params Region parameters\n * @return {Region} The created region\n */\n add(params) {\n if (this.wouldExceedMaxRegions()) {\n return null;\n }\n\n if (!params.minLength && this.regionsMinLength) {\n params = {...params, minLength: this.regionsMinLength};\n }\n\n const region = new this.wavesurfer.Region(params, this.util, this.wavesurfer);\n\n this.list[region.id] = region;\n\n region.on('remove', () => {\n delete this.list[region.id];\n });\n\n return region;\n }\n\n /**\n * Remove all regions\n */\n clear() {\n Object.keys(this.list).forEach(id => {\n this.list[id].remove();\n });\n }\n\n enableDragSelection(params) {\n this.disableDragSelection();\n\n const slop = params.slop || 2;\n const container = this.wavesurfer.drawer.container;\n const scroll =\n params.scroll !== false && this.wavesurfer.params.scrollParent;\n const scrollSpeed = params.scrollSpeed || 1;\n const scrollThreshold = params.scrollThreshold || 10;\n let drag;\n let duration = this.wavesurfer.getDuration();\n let maxScroll;\n let start;\n let region;\n let touchId;\n let pxMove = 0;\n let scrollDirection;\n let wrapperRect;\n\n // Scroll when the user is dragging within the threshold\n const edgeScroll = e => {\n if (!region || !scrollDirection) {\n return;\n }\n\n // Update scroll position\n let scrollLeft =\n this.wrapper.scrollLeft + scrollSpeed * scrollDirection;\n this.wrapper.scrollLeft = scrollLeft = Math.min(\n maxScroll,\n Math.max(0, scrollLeft)\n );\n\n // Update range\n const end = this.wavesurfer.drawer.handleEvent(e);\n region.update({\n start: Math.min(end * duration, start * duration),\n end: Math.max(end * duration, start * duration)\n });\n\n // Check that there is more to scroll and repeat\n if (scrollLeft < maxScroll && scrollLeft > 0) {\n window.requestAnimationFrame(() => {\n edgeScroll(e);\n });\n }\n };\n\n const eventDown = e => {\n if (e.touches && e.touches.length > 1) {\n return;\n }\n duration = this.wavesurfer.getDuration();\n touchId = e.targetTouches ? e.targetTouches[0].identifier : null;\n\n // Store for scroll calculations\n maxScroll = this.wrapper.scrollWidth -\n this.wrapper.clientWidth;\n wrapperRect = this.util.withOrientation(\n this.wrapper.getBoundingClientRect(),\n this.vertical\n );\n\n drag = true;\n start = this.wavesurfer.drawer.handleEvent(e, true);\n region = null;\n scrollDirection = null;\n };\n this.wrapper.addEventListener('mousedown', eventDown);\n this.wrapper.addEventListener('touchstart', eventDown);\n this.on('disable-drag-selection', () => {\n this.wrapper.removeEventListener('touchstart', eventDown);\n this.wrapper.removeEventListener('mousedown', eventDown);\n });\n\n const eventUp = e => {\n if (e.touches && e.touches.length > 1) {\n return;\n }\n\n drag = false;\n pxMove = 0;\n scrollDirection = null;\n\n if (region) {\n this.util.preventClick();\n region.fireEvent('update-end', e);\n this.wavesurfer.fireEvent('region-update-end', region, e);\n }\n\n region = null;\n };\n this.wrapper.addEventListener('mouseleave', eventUp);\n this.wrapper.addEventListener('mouseup', eventUp);\n this.wrapper.addEventListener('touchend', eventUp);\n\n document.body.addEventListener('mouseup', eventUp);\n document.body.addEventListener('touchend', eventUp);\n this.on('disable-drag-selection', () => {\n document.body.removeEventListener('mouseup', eventUp);\n document.body.removeEventListener('touchend', eventUp);\n this.wrapper.removeEventListener('touchend', eventUp);\n this.wrapper.removeEventListener('mouseup', eventUp);\n this.wrapper.removeEventListener('mouseleave', eventUp);\n });\n\n const eventMove = event => {\n if (!drag) {\n return;\n }\n if (++pxMove <= slop) {\n return;\n }\n\n if (event.touches && event.touches.length > 1) {\n return;\n }\n if (event.targetTouches && event.targetTouches[0].identifier != touchId) {\n return;\n }\n\n // auto-create a region during mouse drag, unless region-count would exceed \"maxRegions\"\n if (!region) {\n region = this.add(params || {});\n if (!region) {\n return;\n }\n }\n\n const end = this.wavesurfer.drawer.handleEvent(event);\n const startUpdate = this.wavesurfer.regions.util.getRegionSnapToGridValue(\n start * duration\n );\n const endUpdate = this.wavesurfer.regions.util.getRegionSnapToGridValue(\n end * duration\n );\n region.update({\n start: Math.min(endUpdate, startUpdate),\n end: Math.max(endUpdate, startUpdate)\n });\n\n let orientedEvent = this.util.withOrientation(event, this.vertical);\n\n // If scrolling is enabled\n if (scroll && container.clientWidth < this.wrapper.scrollWidth) {\n // Check threshold based on mouse\n const x = orientedEvent.clientX - wrapperRect.left;\n if (x <= scrollThreshold) {\n scrollDirection = -1;\n } else if (x >= wrapperRect.right - scrollThreshold) {\n scrollDirection = 1;\n } else {\n scrollDirection = null;\n }\n scrollDirection && edgeScroll(event);\n }\n };\n this.wrapper.addEventListener('mousemove', eventMove);\n this.wrapper.addEventListener('touchmove', eventMove);\n this.on('disable-drag-selection', () => {\n this.wrapper.removeEventListener('touchmove', eventMove);\n this.wrapper.removeEventListener('mousemove', eventMove);\n });\n\n this.wavesurfer.on('region-created', region => {\n if (this.regionsMinLength) {\n region.minLength = this.regionsMinLength;\n }\n });\n }\n\n disableDragSelection() {\n this.fireEvent('disable-drag-selection');\n }\n\n /**\n * Get current region\n *\n * The smallest region that contains the current time. If several such\n * regions exist, take the first. Return `null` if none exist.\n *\n * @returns {Region} The current region\n */\n getCurrentRegion() {\n const time = this.wavesurfer.getCurrentTime();\n let min = null;\n Object.keys(this.list).forEach(id => {\n const cur = this.list[id];\n if (cur.start <= time && cur.end >= time) {\n if (!min || cur.end - cur.start < min.end - min.start) {\n min = cur;\n }\n }\n });\n\n return min;\n }\n\n /**\n * Match the value to the grid, if required\n *\n * If the regions plugin params have a snapToGridInterval set, return the\n * value matching the nearest grid interval. If no snapToGridInterval is set,\n * the passed value will be returned without modification.\n *\n * @param {number} value the value to snap to the grid, if needed\n * @param {Object} params the regions plugin params\n * @returns {number} value\n */\n getRegionSnapToGridValue(value, params) {\n if (params.snapToGridInterval) {\n // the regions should snap to a grid\n const offset = params.snapToGridOffset || 0;\n return (\n Math.round((value - offset) / params.snapToGridInterval) *\n params.snapToGridInterval +\n offset\n );\n }\n\n // no snap-to-grid\n return value;\n }\n}\n","/**\n * @since 4.0.0\n *\n * (Single) Region plugin class\n *\n * Must be turned into an observer before instantiating. This is done in\n * `RegionsPlugin` (main plugin class).\n *\n * @extends {Observer}\n */\nexport class Region {\n constructor(params, regionsUtils, ws) {\n this.wavesurfer = ws;\n this.wrapper = ws.drawer.wrapper;\n this.util = ws.util;\n this.style = this.util.style;\n this.regionsUtil = regionsUtils;\n this.vertical = ws.drawer.params.vertical;\n\n this.id = params.id == null ? ws.util.getId() : params.id;\n this.start = Number(params.start) || 0;\n this.end =\n params.end == null\n ? // small marker-like region\n this.start +\n (4 / this.wrapper.scrollWidth) * this.wavesurfer.getDuration()\n : Number(params.end);\n this.resize =\n params.resize === undefined ? true : Boolean(params.resize);\n this.drag = params.drag === undefined ? true : Boolean(params.drag);\n // reflect resize and drag state of region for region-updated listener\n this.isResizing = false;\n this.isDragging = false;\n this.loop = Boolean(params.loop);\n this.color = params.color || 'rgba(0, 0, 0, 0.1)';\n // The left and right handleStyle properties can be set to 'none' for\n // no styling or can be assigned an object containing CSS properties.\n this.handleStyle = params.handleStyle || {\n left: {},\n right: {}\n };\n this.handleLeftEl = null;\n this.handleRightEl = null;\n this.data = params.data || {};\n this.attributes = params.attributes || {};\n this.showTooltip = params.showTooltip ?? true;\n\n this.maxLength = params.maxLength;\n // It assumes the minLength parameter value, or the regionsMinLength parameter value, if the first one not provided\n this.minLength = params.minLength;\n this._onRedraw = () => this.updateRender();\n\n this.scroll = params.scroll !== false && ws.params.scrollParent;\n this.scrollSpeed = params.scrollSpeed || 1;\n this.scrollThreshold = params.scrollThreshold || 10;\n // Determines whether the context menu is prevented from being opened.\n this.preventContextMenu =\n params.preventContextMenu === undefined\n ? false\n : Boolean(params.preventContextMenu);\n\n // select channel ID to set region\n let channelIdx =\n params.channelIdx == null ? -1 : parseInt(params.channelIdx);\n this.regionHeight = '100%';\n this.marginTop = '0px';\n\n if (channelIdx !== -1) {\n let channelCount =\n this.wavesurfer.backend.buffer != null\n ? this.wavesurfer.backend.buffer.numberOfChannels\n : -1;\n if (channelCount >= 0 && channelIdx < channelCount) {\n this.regionHeight = Math.floor((1 / channelCount) * 100) + '%';\n this.marginTop =\n this.wavesurfer.getHeight() * channelIdx + 'px';\n }\n }\n\n this.formatTimeCallback = params.formatTimeCallback;\n this.edgeScrollWidth = params.edgeScrollWidth;\n this.bindInOut();\n this.render();\n this.wavesurfer.on('zoom', this._onRedraw);\n this.wavesurfer.on('redraw', this._onRedraw);\n this.wavesurfer.fireEvent('region-created', this);\n }\n\n /* Update region params. */\n update(params) {\n if (params.start != null) {\n this.start = Number(params.start);\n }\n if (params.end != null) {\n this.end = Number(params.end);\n }\n if (params.loop != null) {\n this.loop = Boolean(params.loop);\n }\n if (params.color != null) {\n this.color = params.color;\n }\n if (params.handleStyle != null) {\n this.handleStyle = params.handleStyle;\n }\n if (params.data != null) {\n this.data = params.data;\n }\n if (params.resize != null) {\n this.resize = Boolean(params.resize);\n this.updateHandlesResize(this.resize);\n }\n if (params.drag != null) {\n this.drag = Boolean(params.drag);\n }\n if (params.maxLength != null) {\n this.maxLength = Number(params.maxLength);\n }\n if (params.minLength != null) {\n this.minLength = Number(params.minLength);\n }\n if (params.attributes != null) {\n this.attributes = params.attributes;\n }\n\n this.updateRender();\n this.fireEvent('update');\n this.wavesurfer.fireEvent('region-updated', this);\n }\n\n /* Remove a single region. */\n remove() {\n if (this.element) {\n this.wrapper.removeChild(this.element.domElement);\n this.element = null;\n this.fireEvent('remove');\n this.wavesurfer.un('zoom', this._onRedraw);\n this.wavesurfer.un('redraw', this._onRedraw);\n this.wavesurfer.fireEvent('region-removed', this);\n }\n }\n\n /**\n * Play the audio region.\n * @param {number} start Optional offset to start playing at\n */\n play(start) {\n const s = start || this.start;\n this.wavesurfer.play(s, this.end);\n this.fireEvent('play');\n this.wavesurfer.fireEvent('region-play', this);\n }\n\n /**\n * Play the audio region in a loop.\n * @param {number} start Optional offset to start playing at\n * */\n playLoop(start) {\n this.loop = true;\n this.play(start);\n }\n\n /**\n * Set looping on/off.\n * @param {boolean} loop True if should play in loop\n */\n setLoop(loop) {\n this.loop = loop;\n }\n\n /* Render a region as a DOM element. */\n render() {\n this.element = this.util.withOrientation(\n this.wrapper.appendChild(document.createElement('region')),\n this.vertical\n );\n\n this.element.className = 'wavesurfer-region';\n if (this.showTooltip) {\n this.element.title = this.formatTime(this.start, this.end);\n }\n this.element.setAttribute('data-id', this.id);\n\n for (const attrname in this.attributes) {\n this.element.setAttribute(\n 'data-region-' + attrname,\n this.attributes[attrname]\n );\n }\n\n this.style(this.element, {\n position: 'absolute',\n zIndex: 2,\n height: this.regionHeight,\n top: this.marginTop\n });\n\n /* Resize handles */\n if (this.resize) {\n this.handleLeftEl = this.util.withOrientation(\n this.element.appendChild(document.createElement('handle')),\n this.vertical\n );\n this.handleRightEl = this.util.withOrientation(\n this.element.appendChild(document.createElement('handle')),\n this.vertical\n );\n\n this.handleLeftEl.className = 'wavesurfer-handle wavesurfer-handle-start';\n this.handleRightEl.className = 'wavesurfer-handle wavesurfer-handle-end';\n\n // Default CSS properties for both handles.\n const css = {\n cursor: this.vertical ? 'row-resize' : 'col-resize',\n position: 'absolute',\n top: '0px',\n width: '2px',\n height: '100%',\n backgroundColor: 'rgba(0, 0, 0, 1)'\n };\n\n // Merge CSS properties per handle.\n const handleLeftCss =\n this.handleStyle.left !== 'none'\n ? Object.assign(\n { left: '0px' },\n css,\n this.handleStyle.left\n )\n : null;\n const handleRightCss =\n this.handleStyle.right !== 'none'\n ? Object.assign(\n { right: '0px' },\n css,\n this.handleStyle.right\n )\n : null;\n\n if (handleLeftCss) {\n this.style(this.handleLeftEl, handleLeftCss);\n }\n\n if (handleRightCss) {\n this.style(this.handleRightEl, handleRightCss);\n }\n }\n\n this.updateRender();\n this.bindEvents();\n }\n\n formatTime(start, end) {\n if (this.formatTimeCallback) {\n return this.formatTimeCallback(start, end);\n }\n return (start == end ? [start] : [start, end])\n .map((time) =>\n [\n Math.floor((time % 3600) / 60), // minutes\n ('00' + Math.floor(time % 60)).slice(-2) // seconds\n ].join(':')\n )\n .join('-');\n }\n\n getWidth() {\n return this.wavesurfer.drawer.width / this.wavesurfer.params.pixelRatio;\n }\n\n /* Update element's position, width, color. */\n updateRender() {\n // duration varies during loading process, so don't overwrite important data\n const dur = this.wavesurfer.getDuration();\n const width = this.getWidth();\n\n let startLimited = this.start;\n let endLimited = this.end;\n if (startLimited < 0) {\n startLimited = 0;\n endLimited = endLimited - startLimited;\n }\n if (endLimited > dur) {\n endLimited = dur;\n startLimited = dur - (endLimited - startLimited);\n }\n\n if (this.minLength != null) {\n endLimited = Math.max(startLimited + this.minLength, endLimited);\n }\n\n if (this.maxLength != null) {\n endLimited = Math.min(startLimited + this.maxLength, endLimited);\n }\n\n if (this.element != null) {\n // Calculate the left and width values of the region such that\n // no gaps appear between regions.\n const left = Math.round((startLimited / dur) * width);\n const regionWidth = Math.round((endLimited / dur) * width) - left;\n\n this.style(this.element, {\n left: left + 'px',\n width: regionWidth + 'px',\n backgroundColor: this.color,\n cursor: this.drag ? 'move' : 'default'\n });\n\n for (const attrname in this.attributes) {\n this.element.setAttribute(\n 'data-region-' + attrname,\n this.attributes[attrname]\n );\n }\n\n if (this.showTooltip) {\n this.element.title = this.formatTime(this.start, this.end);\n }\n }\n }\n\n /* Bind audio events. */\n bindInOut() {\n this.firedIn = false;\n this.firedOut = false;\n\n const onProcess = (time) => {\n let start = Math.round(this.start * 10) / 10;\n let end = Math.round(this.end * 10) / 10;\n time = Math.round(time * 10) / 10;\n\n if (\n !this.firedOut &&\n this.firedIn &&\n (start > time || end <= time)\n ) {\n this.firedOut = true;\n this.firedIn = false;\n this.fireEvent('out');\n this.wavesurfer.fireEvent('region-out', this);\n }\n if (!this.firedIn && start <= time && end > time) {\n this.firedIn = true;\n this.firedOut = false;\n this.fireEvent('in');\n this.wavesurfer.fireEvent('region-in', this);\n }\n };\n\n this.wavesurfer.backend.on('audioprocess', onProcess);\n\n this.on('remove', () => {\n this.wavesurfer.backend.un('audioprocess', onProcess);\n });\n\n /* Loop playback. */\n this.on('out', () => {\n if (this.loop) {\n const realTime = this.wavesurfer.getCurrentTime();\n if (realTime >= this.start && realTime <= this.end) {\n this.wavesurfer.play(this.start);\n }\n }\n });\n }\n\n /* Bind DOM events. */\n bindEvents() {\n const preventContextMenu = this.preventContextMenu;\n\n this.element.addEventListener('mouseenter', (e) => {\n this.fireEvent('mouseenter', e);\n this.wavesurfer.fireEvent('region-mouseenter', this, e);\n });\n\n this.element.addEventListener('mouseleave', (e) => {\n this.fireEvent('mouseleave', e);\n this.wavesurfer.fireEvent('region-mouseleave', this, e);\n });\n\n this.element.addEventListener('click', (e) => {\n e.preventDefault();\n this.fireEvent('click', e);\n this.wavesurfer.fireEvent('region-click', this, e);\n });\n\n this.element.addEventListener('dblclick', (e) => {\n e.stopPropagation();\n e.preventDefault();\n this.fireEvent('dblclick', e);\n this.wavesurfer.fireEvent('region-dblclick', this, e);\n });\n\n this.element.addEventListener('contextmenu', (e) => {\n if (preventContextMenu) {\n e.preventDefault();\n }\n this.fireEvent('contextmenu', e);\n this.wavesurfer.fireEvent('region-contextmenu', this, e);\n });\n\n /* Drag or resize on mousemove. */\n if (this.drag || this.resize) {\n this.bindDragEvents();\n }\n }\n\n bindDragEvents() {\n const container = this.wavesurfer.drawer.container;\n const scrollSpeed = this.scrollSpeed;\n const scrollThreshold = this.scrollThreshold;\n let startTime;\n let touchId;\n let drag;\n let maxScroll;\n let resize;\n let updated = false;\n let scrollDirection;\n let wrapperRect;\n let regionLeftHalfTime;\n let regionRightHalfTime;\n\n // Scroll when the user is dragging within the threshold\n const edgeScroll = (event) => {\n let orientedEvent = this.util.withOrientation(event, this.vertical);\n const duration = this.wavesurfer.getDuration();\n if (!scrollDirection || (!drag && !resize)) {\n return;\n }\n\n const x = orientedEvent.clientX;\n let distanceBetweenCursorAndWrapperEdge = 0;\n let regionHalfTimeWidth = 0;\n let adjustment = 0;\n\n // Get the currently selected time according to the mouse position\n let time = this.regionsUtil.getRegionSnapToGridValue(\n this.wavesurfer.drawer.handleEvent(event) * duration\n );\n\n if (drag) {\n // Considering the point of contact with the region while edgescrolling\n if (scrollDirection === -1) {\n regionHalfTimeWidth = regionLeftHalfTime * this.wavesurfer.params.minPxPerSec;\n distanceBetweenCursorAndWrapperEdge = x - wrapperRect.left;\n } else {\n regionHalfTimeWidth = regionRightHalfTime * this.wavesurfer.params.minPxPerSec;\n distanceBetweenCursorAndWrapperEdge = wrapperRect.right - x;\n }\n } else {\n // Considering minLength while edgescroll\n let minLength = this.minLength;\n if (!minLength) {\n minLength = 0;\n }\n\n if (resize === 'start') {\n if (time > this.end - minLength) {\n time = this.end - minLength;\n adjustment = scrollSpeed * scrollDirection;\n }\n\n if (time < 0) {\n time = 0;\n }\n } else if (resize === 'end') {\n if (time < this.start + minLength) {\n time = this.start + minLength;\n adjustment = scrollSpeed * scrollDirection;\n }\n\n if (time > duration) {\n time = duration;\n }\n }\n }\n\n // Don't edgescroll if region has reached min or max limit\n const wrapperScrollLeft = this.wrapper.scrollLeft;\n\n if (scrollDirection === -1) {\n if (Math.round(wrapperScrollLeft) === 0) {\n return;\n }\n\n if (Math.round(wrapperScrollLeft - regionHalfTimeWidth + distanceBetweenCursorAndWrapperEdge) <= 0) {\n return;\n }\n } else {\n if (Math.round(wrapperScrollLeft) === maxScroll) {\n return;\n }\n\n if (Math.round(wrapperScrollLeft + regionHalfTimeWidth - distanceBetweenCursorAndWrapperEdge) >= maxScroll) {\n return;\n }\n }\n\n // Update scroll position\n let scrollLeft = wrapperScrollLeft - adjustment + scrollSpeed * scrollDirection;\n\n if (scrollDirection === -1) {\n const calculatedLeft = Math.max(0 + regionHalfTimeWidth - distanceBetweenCursorAndWrapperEdge, scrollLeft);\n this.wrapper.scrollLeft = scrollLeft = calculatedLeft;\n } else {\n const calculatedRight = Math.min(maxScroll - regionHalfTimeWidth + distanceBetweenCursorAndWrapperEdge, scrollLeft);\n this.wrapper.scrollLeft = scrollLeft = calculatedRight;\n }\n\n const delta = time - startTime;\n startTime = time;\n\n // Continue dragging or resizing\n drag ? this.onDrag(delta) : this.onResize(delta, resize);\n\n // Repeat\n window.requestAnimationFrame(() => {\n edgeScroll(event);\n });\n };\n\n const onDown = (event) => {\n const duration = this.wavesurfer.getDuration();\n if (event.touches && event.touches.length > 1) {\n return;\n }\n touchId = event.targetTouches ? event.targetTouches[0].identifier : null;\n\n // stop the event propagation, if this region is resizable or draggable\n // and the event is therefore handled here.\n if (this.drag || this.resize) {\n event.stopPropagation();\n }\n\n // Store the selected startTime we begun dragging or resizing\n startTime = this.regionsUtil.getRegionSnapToGridValue(\n this.wavesurfer.drawer.handleEvent(event, true) * duration\n );\n\n // Store the selected point of contact when we begin dragging\n regionLeftHalfTime = startTime - this.start;\n regionRightHalfTime = this.end - startTime;\n\n // Store for scroll calculations\n maxScroll = this.wrapper.scrollWidth - this.wrapper.clientWidth;\n\n wrapperRect = this.util.withOrientation(\n this.wrapper.getBoundingClientRect(),\n this.vertical\n );\n\n this.isResizing = false;\n this.isDragging = false;\n if (event.target.tagName.toLowerCase() === 'handle') {\n this.isResizing = true;\n resize = event.target.classList.contains('wavesurfer-handle-start')\n ? 'start'\n : 'end';\n } else {\n this.isDragging = true;\n drag = true;\n resize = false;\n }\n };\n const onUp = (event) => {\n if (event.touches && event.touches.length > 1) {\n return;\n }\n\n if (drag || resize) {\n this.isDragging = false;\n this.isResizing = false;\n drag = false;\n scrollDirection = null;\n resize = false;\n }\n\n if (updated) {\n updated = false;\n this.util.preventClick();\n this.fireEvent('update-end', event);\n this.wavesurfer.fireEvent('region-update-end', this, event);\n }\n };\n const onMove = (event) => {\n const duration = this.wavesurfer.getDuration();\n let orientedEvent = this.util.withOrientation(event, this.vertical);\n\n if (event.touches && event.touches.length > 1) {\n return;\n }\n if (event.targetTouches && event.targetTouches[0].identifier != touchId) {\n return;\n }\n if (!drag && !resize) {\n return;\n }\n\n const oldTime = startTime;\n let time = this.regionsUtil.getRegionSnapToGridValue(\n this.wavesurfer.drawer.handleEvent(event) * duration\n );\n\n if (drag) {\n // To maintain relative cursor start point while dragging\n const maxEnd = this.wavesurfer.getDuration();\n if (time > maxEnd - regionRightHalfTime) {\n time = maxEnd - regionRightHalfTime;\n }\n\n if (time - regionLeftHalfTime < 0) {\n time = regionLeftHalfTime;\n }\n }\n\n if (resize) {\n // To maintain relative cursor start point while resizing\n // we have to handle for minLength\n let minLength = this.minLength;\n if (!minLength) {\n minLength = 0;\n }\n\n if (resize === 'start') {\n if (time > this.end - minLength) {\n time = this.end - minLength;\n }\n\n if (time < 0) {\n time = 0;\n }\n } else if (resize === 'end') {\n if (time < this.start + minLength) {\n time = this.start + minLength;\n }\n\n if (time > duration) {\n time = duration;\n }\n }\n }\n\n let delta = time - startTime;\n startTime = time;\n\n // Drag\n if (this.drag && drag) {\n updated = updated || !!delta;\n this.onDrag(delta);\n }\n\n // Resize\n if (this.resize && resize) {\n updated = updated || !!delta;\n this.onResize(delta, resize);\n }\n\n if (\n this.scroll && container.clientWidth < this.wrapper.scrollWidth\n ) {\n // Triggering edgescroll from within edgeScrollWidth\n let x = orientedEvent.clientX;\n\n // Check direction\n if (x < wrapperRect.left + this.edgeScrollWidth) {\n scrollDirection = -1;\n } else if (x > wrapperRect.right - this.edgeScrollWidth) {\n scrollDirection = 1;\n } else {\n scrollDirection = null;\n }\n\n if (scrollDirection) {\n edgeScroll(event);\n }\n }\n };\n\n this.element.addEventListener('mousedown', onDown);\n this.element.addEventListener('touchstart', onDown);\n\n document.body.addEventListener('mousemove', onMove);\n document.body.addEventListener('touchmove', onMove, {passive: false});\n\n document.addEventListener('mouseup', onUp);\n document.body.addEventListener('touchend', onUp);\n\n this.on('remove', () => {\n document.removeEventListener('mouseup', onUp);\n document.body.removeEventListener('touchend', onUp);\n document.body.removeEventListener('mousemove', onMove);\n document.body.removeEventListener('touchmove', onMove);\n });\n\n this.wavesurfer.on('destroy', () => {\n document.removeEventListener('mouseup', onUp);\n document.body.removeEventListener('touchend', onUp);\n });\n }\n\n onDrag(delta) {\n const maxEnd = this.wavesurfer.getDuration();\n if (this.end + delta > maxEnd) {\n delta = maxEnd - this.end;\n }\n\n if (this.start + delta < 0) {\n delta = this.start * -1;\n }\n\n this.update({\n start: this.start + delta,\n end: this.end + delta\n });\n }\n\n /**\n * @example\n * onResize(-5, 'start') // Moves the start point 5 seconds back\n * onResize(0.5, 'end') // Moves the end point 0.5 seconds forward\n *\n * @param {number} delta How much to add or subtract, given in seconds\n * @param {string} direction 'start 'or 'end'\n */\n onResize(delta, direction) {\n const duration = this.wavesurfer.getDuration();\n if (direction === 'start') {\n // Check if changing the start by the given delta would result in the region being smaller than minLength\n // Ignore cases where we are making the region wider rather than shrinking it\n if (delta > 0 && this.end - (this.start + delta) < this.minLength) {\n delta = this.end - this.minLength - this.start;\n }\n\n if (delta < 0 && (this.start + delta) < 0) {\n delta = this.start * -1;\n }\n\n this.update({\n start: Math.min(this.start + delta, this.end),\n end: Math.max(this.start + delta, this.end)\n });\n } else {\n // Check if changing the end by the given delta would result in the region being smaller than minLength\n // Ignore cases where we are making the region wider rather than shrinking it\n if (delta < 0 && this.end + delta - this.start < this.minLength) {\n delta = this.start + this.minLength - this.end;\n }\n\n if (delta > 0 && (this.end + delta) > duration) {\n delta = duration - this.end;\n }\n\n this.update({\n start: Math.min(this.end + delta, this.start),\n end: Math.max(this.end + delta, this.start)\n });\n }\n }\n\n updateHandlesResize(resize) {\n let cursorStyle;\n if (resize) {\n cursorStyle = this.vertical ? 'row-resize' : 'col-resize';\n } else {\n cursorStyle = 'auto';\n }\n\n this.handleLeftEl && this.style(this.handleLeftEl, { cursor: cursorStyle });\n this.handleRightEl && this.style(this.handleRightEl, { cursor: cursorStyle });\n }\n}\n","// The module cache\nvar __webpack_module_cache__ = {};\n\n// The require function\nfunction __webpack_require__(moduleId) {\n\t// Check if module is in cache\n\tvar cachedModule = __webpack_module_cache__[moduleId];\n\tif (cachedModule !== undefined) {\n\t\treturn cachedModule.exports;\n\t}\n\t// Create a new module (and put it into the cache)\n\tvar module = __webpack_module_cache__[moduleId] = {\n\t\t// no module.id needed\n\t\t// no module.loaded needed\n\t\texports: {}\n\t};\n\n\t// Execute the module function\n\t__webpack_modules__[moduleId](module, module.exports, __webpack_require__);\n\n\t// Return the exports of the module\n\treturn module.exports;\n}\n\n","// startup\n// Load entry module and return exports\n// This entry module is referenced by other modules so it can't be inlined\nvar __webpack_exports__ = __webpack_require__(23);\n"],"sourceRoot":""}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/*!
|
|
2
|
-
* wavesurfer.js spectrogram plugin
|
|
2
|
+
* wavesurfer.js spectrogram plugin 5.1.0 (2021-06-20)
|
|
3
3
|
* https://wavesurfer-js.org
|
|
4
4
|
* @license BSD-3-Clause
|
|
5
5
|
*/
|
|
@@ -311,31 +311,6 @@ function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _d
|
|
|
311
311
|
* });
|
|
312
312
|
*/
|
|
313
313
|
var SpectrogramPlugin = /*#__PURE__*/function () {
|
|
314
|
-
_createClass(SpectrogramPlugin, null, [{
|
|
315
|
-
key: "create",
|
|
316
|
-
|
|
317
|
-
/**
|
|
318
|
-
* Spectrogram plugin definition factory
|
|
319
|
-
*
|
|
320
|
-
* This function must be used to create a plugin definition which can be
|
|
321
|
-
* used by wavesurfer to correctly instantiate the plugin.
|
|
322
|
-
*
|
|
323
|
-
* @param {SpectrogramPluginParams} params Parameters used to initialise the plugin
|
|
324
|
-
* @return {PluginDefinition} An object representing the plugin.
|
|
325
|
-
*/
|
|
326
|
-
value: function create(params) {
|
|
327
|
-
return {
|
|
328
|
-
name: 'spectrogram',
|
|
329
|
-
deferInit: params && params.deferInit ? params.deferInit : false,
|
|
330
|
-
params: params,
|
|
331
|
-
staticProps: {
|
|
332
|
-
FFT: _fft.default
|
|
333
|
-
},
|
|
334
|
-
instance: SpectrogramPlugin
|
|
335
|
-
};
|
|
336
|
-
}
|
|
337
|
-
}]);
|
|
338
|
-
|
|
339
314
|
function SpectrogramPlugin(params, ws) {
|
|
340
315
|
var _this = this;
|
|
341
316
|
|
|
@@ -525,35 +500,38 @@ var SpectrogramPlugin = /*#__PURE__*/function () {
|
|
|
525
500
|
var width = my.width;
|
|
526
501
|
var pixels = my.resample(frequenciesData);
|
|
527
502
|
var heightFactor = my.buffer ? 2 / my.buffer.numberOfChannels : 1;
|
|
528
|
-
var imageData = spectrCc.createImageData(width, height);
|
|
529
|
-
var i;
|
|
530
|
-
var j;
|
|
531
|
-
var k;
|
|
532
503
|
|
|
533
|
-
|
|
534
|
-
|
|
535
|
-
|
|
536
|
-
|
|
504
|
+
if (spectrCc) {
|
|
505
|
+
var imageData = spectrCc.createImageData(width, height);
|
|
506
|
+
var i;
|
|
507
|
+
var j;
|
|
508
|
+
var k;
|
|
537
509
|
|
|
538
|
-
|
|
539
|
-
|
|
510
|
+
for (i = 0; i < pixels.length; i++) {
|
|
511
|
+
for (j = 0; j < pixels[i].length; j++) {
|
|
512
|
+
var colorMap = my.colorMap[pixels[i][j]];
|
|
513
|
+
/* eslint-disable max-depth */
|
|
514
|
+
|
|
515
|
+
for (k = 0; k < heightFactor; k++) {
|
|
516
|
+
var y = height - j * heightFactor;
|
|
517
|
+
|
|
518
|
+
if (heightFactor === 2 && k === 1) {
|
|
519
|
+
y--;
|
|
520
|
+
}
|
|
540
521
|
|
|
541
|
-
|
|
542
|
-
|
|
522
|
+
var redIndex = y * (width * 4) + i * 4;
|
|
523
|
+
imageData.data[redIndex] = colorMap[0] * 255;
|
|
524
|
+
imageData.data[redIndex + 1] = colorMap[1] * 255;
|
|
525
|
+
imageData.data[redIndex + 2] = colorMap[2] * 255;
|
|
526
|
+
imageData.data[redIndex + 3] = colorMap[3] * 255;
|
|
543
527
|
}
|
|
528
|
+
/* eslint-enable max-depth */
|
|
544
529
|
|
|
545
|
-
var redIndex = y * (width * 4) + i * 4;
|
|
546
|
-
imageData.data[redIndex] = colorMap[0] * 255;
|
|
547
|
-
imageData.data[redIndex + 1] = colorMap[1] * 255;
|
|
548
|
-
imageData.data[redIndex + 2] = colorMap[2] * 255;
|
|
549
|
-
imageData.data[redIndex + 3] = colorMap[3] * 255;
|
|
550
530
|
}
|
|
551
|
-
/* eslint-enable max-depth */
|
|
552
|
-
|
|
553
531
|
}
|
|
554
|
-
}
|
|
555
532
|
|
|
556
|
-
|
|
533
|
+
spectrCc.putImageData(imageData, 0, 0);
|
|
534
|
+
}
|
|
557
535
|
}
|
|
558
536
|
}, {
|
|
559
537
|
key: "getFrequencies",
|
|
@@ -643,44 +621,47 @@ var SpectrogramPlugin = /*#__PURE__*/function () {
|
|
|
643
621
|
|
|
644
622
|
var ctx = this.labelsEl.getContext('2d');
|
|
645
623
|
this.labelsEl.height = this.height;
|
|
646
|
-
this.labelsEl.width = bgWidth;
|
|
647
|
-
|
|
648
|
-
ctx
|
|
649
|
-
|
|
650
|
-
|
|
651
|
-
|
|
652
|
-
|
|
653
|
-
|
|
654
|
-
|
|
655
|
-
|
|
656
|
-
|
|
657
|
-
|
|
658
|
-
|
|
659
|
-
|
|
660
|
-
|
|
661
|
-
|
|
662
|
-
|
|
663
|
-
|
|
664
|
-
|
|
665
|
-
|
|
666
|
-
|
|
667
|
-
|
|
668
|
-
|
|
669
|
-
|
|
670
|
-
|
|
671
|
-
|
|
672
|
-
|
|
673
|
-
|
|
674
|
-
|
|
675
|
-
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
|
|
679
|
-
|
|
680
|
-
|
|
681
|
-
|
|
682
|
-
|
|
683
|
-
|
|
624
|
+
this.labelsEl.width = bgWidth;
|
|
625
|
+
|
|
626
|
+
if (ctx) {
|
|
627
|
+
// fill background
|
|
628
|
+
ctx.fillStyle = bgFill;
|
|
629
|
+
ctx.fillRect(0, 0, bgWidth, getMaxY);
|
|
630
|
+
ctx.fill();
|
|
631
|
+
var i; // render labels
|
|
632
|
+
|
|
633
|
+
for (i = 0; i <= labelIndex; i++) {
|
|
634
|
+
ctx.textAlign = textAlign;
|
|
635
|
+
ctx.textBaseline = 'middle';
|
|
636
|
+
var freq = freqStart + step * i;
|
|
637
|
+
var index = Math.round(freq / (this.sampleRate / 2) * this.fftSamples);
|
|
638
|
+
var label = this.freqType(freq);
|
|
639
|
+
var units = this.unitType(freq);
|
|
640
|
+
var yLabelOffset = 2;
|
|
641
|
+
var x = 16;
|
|
642
|
+
var y = void 0;
|
|
643
|
+
|
|
644
|
+
if (i == 0) {
|
|
645
|
+
y = getMaxY + i - 10; // unit label
|
|
646
|
+
|
|
647
|
+
ctx.fillStyle = textColorUnit;
|
|
648
|
+
ctx.font = fontSizeUnit + ' ' + fontType;
|
|
649
|
+
ctx.fillText(units, x + 24, y); // freq label
|
|
650
|
+
|
|
651
|
+
ctx.fillStyle = textColorFreq;
|
|
652
|
+
ctx.font = fontSizeFreq + ' ' + fontType;
|
|
653
|
+
ctx.fillText(label, x, y);
|
|
654
|
+
} else {
|
|
655
|
+
y = getMaxY - i * 50 + yLabelOffset; // unit label
|
|
656
|
+
|
|
657
|
+
ctx.fillStyle = textColorUnit;
|
|
658
|
+
ctx.font = fontSizeUnit + ' ' + fontType;
|
|
659
|
+
ctx.fillText(units, x + 24, y); // freq label
|
|
660
|
+
|
|
661
|
+
ctx.fillStyle = textColorFreq;
|
|
662
|
+
ctx.font = fontSizeFreq + ' ' + fontType;
|
|
663
|
+
ctx.fillText(label, x, y);
|
|
664
|
+
}
|
|
684
665
|
}
|
|
685
666
|
}
|
|
686
667
|
}
|
|
@@ -738,6 +719,29 @@ var SpectrogramPlugin = /*#__PURE__*/function () {
|
|
|
738
719
|
|
|
739
720
|
return newMatrix;
|
|
740
721
|
}
|
|
722
|
+
}], [{
|
|
723
|
+
key: "create",
|
|
724
|
+
value:
|
|
725
|
+
/**
|
|
726
|
+
* Spectrogram plugin definition factory
|
|
727
|
+
*
|
|
728
|
+
* This function must be used to create a plugin definition which can be
|
|
729
|
+
* used by wavesurfer to correctly instantiate the plugin.
|
|
730
|
+
*
|
|
731
|
+
* @param {SpectrogramPluginParams} params Parameters used to initialise the plugin
|
|
732
|
+
* @return {PluginDefinition} An object representing the plugin.
|
|
733
|
+
*/
|
|
734
|
+
function create(params) {
|
|
735
|
+
return {
|
|
736
|
+
name: 'spectrogram',
|
|
737
|
+
deferInit: params && params.deferInit ? params.deferInit : false,
|
|
738
|
+
params: params,
|
|
739
|
+
staticProps: {
|
|
740
|
+
FFT: _fft.default
|
|
741
|
+
},
|
|
742
|
+
instance: SpectrogramPlugin
|
|
743
|
+
};
|
|
744
|
+
}
|
|
741
745
|
}]);
|
|
742
746
|
|
|
743
747
|
return SpectrogramPlugin;
|
|
@@ -756,8 +760,9 @@ module.exports = exports.default;
|
|
|
756
760
|
/******/ // The require function
|
|
757
761
|
/******/ function __webpack_require__(moduleId) {
|
|
758
762
|
/******/ // Check if module is in cache
|
|
759
|
-
/******/
|
|
760
|
-
/******/
|
|
763
|
+
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
764
|
+
/******/ if (cachedModule !== undefined) {
|
|
765
|
+
/******/ return cachedModule.exports;
|
|
761
766
|
/******/ }
|
|
762
767
|
/******/ // Create a new module (and put it into the cache)
|
|
763
768
|
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
@@ -774,10 +779,13 @@ module.exports = exports.default;
|
|
|
774
779
|
/******/ }
|
|
775
780
|
/******/
|
|
776
781
|
/************************************************************************/
|
|
777
|
-
/******/
|
|
782
|
+
/******/
|
|
778
783
|
/******/ // startup
|
|
779
784
|
/******/ // Load entry module and return exports
|
|
780
|
-
/******/
|
|
785
|
+
/******/ // This entry module is referenced by other modules so it can't be inlined
|
|
786
|
+
/******/ var __webpack_exports__ = __webpack_require__("./src/plugin/spectrogram/index.js");
|
|
787
|
+
/******/
|
|
788
|
+
/******/ return __webpack_exports__;
|
|
781
789
|
/******/ })()
|
|
782
790
|
;
|
|
783
791
|
});
|