@checksub_team/peaks_timeline 1.4.17 → 1.4.18
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/package.json +2 -2
- package/peaks.js +132 -73
- package/src/invoker.js +81 -0
- package/src/line.js +7 -7
- package/src/lines.js +7 -7
- package/src/source-group.js +33 -21
- package/src/sources-layer.js +48 -2
- package/src/timeline-zoomview.js +9 -4
- package/src/waveform-shape.js +5 -12
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@checksub_team/peaks_timeline",
|
|
3
|
-
"version": "1.4.
|
|
3
|
+
"version": "1.4.18",
|
|
4
4
|
"description": "JavaScript UI component for displaying audio waveforms",
|
|
5
5
|
"main": "./peaks.js",
|
|
6
6
|
"types": "./peaks.js.d.ts",
|
|
@@ -75,7 +75,7 @@
|
|
|
75
75
|
"eventemitter2": "~6.0.0",
|
|
76
76
|
"konva": "~4.1.3",
|
|
77
77
|
"uuid": "^8.3.2",
|
|
78
|
-
"waveform-data": "~
|
|
78
|
+
"waveform-data": "~4.0.0"
|
|
79
79
|
},
|
|
80
80
|
"bugs": {
|
|
81
81
|
"url": "https://github.com/bbc/peaks.js/issues"
|
package/peaks.js
CHANGED
|
@@ -14338,7 +14338,56 @@ module.exports = function (Utils, Konva) {
|
|
|
14338
14338
|
};
|
|
14339
14339
|
return DefaultSegmentMarker;
|
|
14340
14340
|
}(_dereq_('./utils'), _dereq_('konva'));
|
|
14341
|
-
},{"./utils":
|
|
14341
|
+
},{"./utils":110,"konva":43}],88:[function(_dereq_,module,exports){
|
|
14342
|
+
module.exports = function () {
|
|
14343
|
+
'use strict';
|
|
14344
|
+
function Invoker() {
|
|
14345
|
+
this._throttledFunc = {};
|
|
14346
|
+
}
|
|
14347
|
+
Invoker.prototype.throttle = function (id, func, wait) {
|
|
14348
|
+
var self = this;
|
|
14349
|
+
if (this._throttledFunc[id]) {
|
|
14350
|
+
this._throttledFunc[id].func = func;
|
|
14351
|
+
this._throttledFunc[id].continue = true;
|
|
14352
|
+
} else {
|
|
14353
|
+
this._throttledFunc[id] = {
|
|
14354
|
+
func: func,
|
|
14355
|
+
timer: null,
|
|
14356
|
+
continue: true
|
|
14357
|
+
};
|
|
14358
|
+
this._throttledFunc[id].timer = setInterval(function () {
|
|
14359
|
+
if (self._throttledFunc[id].continue) {
|
|
14360
|
+
func();
|
|
14361
|
+
self._throttledFunc[id].continue = false;
|
|
14362
|
+
} else {
|
|
14363
|
+
clearInterval(self._throttledFunc[id].timer);
|
|
14364
|
+
delete self._throttledFunc[id];
|
|
14365
|
+
}
|
|
14366
|
+
}, wait);
|
|
14367
|
+
}
|
|
14368
|
+
};
|
|
14369
|
+
Invoker.prototype.debounce = function (func, wait, immediate) {
|
|
14370
|
+
var timeout;
|
|
14371
|
+
return function executedFunction() {
|
|
14372
|
+
var _self = this;
|
|
14373
|
+
var args = arguments;
|
|
14374
|
+
function later() {
|
|
14375
|
+
timeout = null;
|
|
14376
|
+
if (!immediate) {
|
|
14377
|
+
func.apply(_self, args);
|
|
14378
|
+
}
|
|
14379
|
+
}
|
|
14380
|
+
var callNow = immediate && !timeout;
|
|
14381
|
+
clearTimeout(timeout);
|
|
14382
|
+
timeout = setTimeout(later, wait);
|
|
14383
|
+
if (callNow) {
|
|
14384
|
+
func.apply(_self, args);
|
|
14385
|
+
}
|
|
14386
|
+
};
|
|
14387
|
+
};
|
|
14388
|
+
return Invoker;
|
|
14389
|
+
}();
|
|
14390
|
+
},{}],89:[function(_dereq_,module,exports){
|
|
14342
14391
|
module.exports = function () {
|
|
14343
14392
|
'use strict';
|
|
14344
14393
|
var nodes = [
|
|
@@ -14421,7 +14470,7 @@ module.exports = function () {
|
|
|
14421
14470
|
};
|
|
14422
14471
|
return KeyboardHandler;
|
|
14423
14472
|
}();
|
|
14424
|
-
},{}],
|
|
14473
|
+
},{}],90:[function(_dereq_,module,exports){
|
|
14425
14474
|
module.exports = function (Konva, Utils) {
|
|
14426
14475
|
'use strict';
|
|
14427
14476
|
function LineIndicator(peaks, view, container) {
|
|
@@ -14642,7 +14691,7 @@ module.exports = function (Konva, Utils) {
|
|
|
14642
14691
|
};
|
|
14643
14692
|
return LineIndicator;
|
|
14644
14693
|
}(_dereq_('konva'), _dereq_('./utils'));
|
|
14645
|
-
},{"./utils":
|
|
14694
|
+
},{"./utils":110,"konva":43}],91:[function(_dereq_,module,exports){
|
|
14646
14695
|
module.exports = function (Konva, Utils) {
|
|
14647
14696
|
'use strict';
|
|
14648
14697
|
function Line(peaks, view, y, id, position) {
|
|
@@ -15048,13 +15097,6 @@ module.exports = function (Konva, Utils) {
|
|
|
15048
15097
|
}
|
|
15049
15098
|
return newXs;
|
|
15050
15099
|
};
|
|
15051
|
-
Line.prototype.rescale = function () {
|
|
15052
|
-
for (var sourceId in this._sourcesGroup) {
|
|
15053
|
-
if (Utils.objectHasProperty(this._sourcesGroup, sourceId)) {
|
|
15054
|
-
this._sourcesGroup[sourceId].rescale();
|
|
15055
|
-
}
|
|
15056
|
-
}
|
|
15057
|
-
};
|
|
15058
15100
|
Line.prototype.updatePosition = function (pos) {
|
|
15059
15101
|
for (var sourceId in this._sources) {
|
|
15060
15102
|
if (Utils.objectHasProperty(this._sources, sourceId)) {
|
|
@@ -15074,7 +15116,7 @@ module.exports = function (Konva, Utils) {
|
|
|
15074
15116
|
};
|
|
15075
15117
|
return Line;
|
|
15076
15118
|
}(_dereq_('konva'), _dereq_('./utils'));
|
|
15077
|
-
},{"./utils":
|
|
15119
|
+
},{"./utils":110,"konva":43}],92:[function(_dereq_,module,exports){
|
|
15078
15120
|
module.exports = function (Line, LineIndicator, Utils) {
|
|
15079
15121
|
'use strict';
|
|
15080
15122
|
function Lines(peaks, view, layer) {
|
|
@@ -15294,13 +15336,6 @@ module.exports = function (Line, LineIndicator, Utils) {
|
|
|
15294
15336
|
Lines.prototype.manageSourceOrder = function (source, newStartX, newEndX) {
|
|
15295
15337
|
return this._linesBySourceId[source.id].manageSourceOrder(source, newStartX, newEndX);
|
|
15296
15338
|
};
|
|
15297
|
-
Lines.prototype.rescale = function () {
|
|
15298
|
-
for (var position in this._linesByPosition) {
|
|
15299
|
-
if (Utils.objectHasProperty(this._linesByPosition, position)) {
|
|
15300
|
-
this._linesByPosition[position].rescale();
|
|
15301
|
-
}
|
|
15302
|
-
}
|
|
15303
|
-
};
|
|
15304
15339
|
Lines.prototype._setInteractions = function (position) {
|
|
15305
15340
|
var line = this._linesByPosition[position];
|
|
15306
15341
|
if (this._areInteractionsOverridden) {
|
|
@@ -15329,7 +15364,7 @@ module.exports = function (Line, LineIndicator, Utils) {
|
|
|
15329
15364
|
};
|
|
15330
15365
|
return Lines;
|
|
15331
15366
|
}(_dereq_('./line'), _dereq_('./line-indicator'), _dereq_('./utils'));
|
|
15332
|
-
},{"./line":
|
|
15367
|
+
},{"./line":91,"./line-indicator":90,"./utils":110}],93:[function(_dereq_,module,exports){
|
|
15333
15368
|
module.exports = function (Colors, EventEmitter, TimelineSegments, TimelineSources, KeyboardHandler, Player, MarkerFactories, TimelineZoomView, Utils) {
|
|
15334
15369
|
'use strict';
|
|
15335
15370
|
function Peaks() {
|
|
@@ -15553,7 +15588,7 @@ module.exports = function (Colors, EventEmitter, TimelineSegments, TimelineSourc
|
|
|
15553
15588
|
};
|
|
15554
15589
|
return Peaks;
|
|
15555
15590
|
}(_dereq_('colors.css'), _dereq_('eventemitter2'), _dereq_('./timeline-segments'), _dereq_('./timeline-sources'), _dereq_('./keyboard-handler'), _dereq_('./player'), _dereq_('./marker-factories'), _dereq_('./timeline-zoomview'), _dereq_('./utils'));
|
|
15556
|
-
},{"./keyboard-handler":
|
|
15591
|
+
},{"./keyboard-handler":89,"./marker-factories":94,"./player":97,"./timeline-segments":107,"./timeline-sources":108,"./timeline-zoomview":109,"./utils":110,"colors.css":1,"eventemitter2":2}],94:[function(_dereq_,module,exports){
|
|
15557
15592
|
module.exports = function (DefaultSegmentMarker, Utils, Konva) {
|
|
15558
15593
|
'use strict';
|
|
15559
15594
|
function createSegmentMarker(options) {
|
|
@@ -15585,7 +15620,7 @@ module.exports = function (DefaultSegmentMarker, Utils, Konva) {
|
|
|
15585
15620
|
createSegmentLabel: createSegmentLabel
|
|
15586
15621
|
};
|
|
15587
15622
|
}(_dereq_('./default-segment-marker'), _dereq_('./utils'), _dereq_('konva'));
|
|
15588
|
-
},{"./default-segment-marker":87,"./utils":
|
|
15623
|
+
},{"./default-segment-marker":87,"./utils":110,"konva":43}],95:[function(_dereq_,module,exports){
|
|
15589
15624
|
module.exports = function (Utils, SourceGroup, Konva) {
|
|
15590
15625
|
'use strict';
|
|
15591
15626
|
var TIME_X_OFFSET = 20;
|
|
@@ -15832,7 +15867,7 @@ module.exports = function (Utils, SourceGroup, Konva) {
|
|
|
15832
15867
|
};
|
|
15833
15868
|
return ModeLayer;
|
|
15834
15869
|
}(_dereq_('./utils'), _dereq_('./source-group'), _dereq_('konva'));
|
|
15835
|
-
},{"./source-group":
|
|
15870
|
+
},{"./source-group":103,"./utils":110,"konva":43}],96:[function(_dereq_,module,exports){
|
|
15836
15871
|
module.exports = function (Konva) {
|
|
15837
15872
|
'use strict';
|
|
15838
15873
|
function getMarkerObject(obj) {
|
|
@@ -15928,7 +15963,7 @@ module.exports = function (Konva) {
|
|
|
15928
15963
|
};
|
|
15929
15964
|
return MouseDragHandler;
|
|
15930
15965
|
}(_dereq_('konva'));
|
|
15931
|
-
},{"konva":43}],
|
|
15966
|
+
},{"konva":43}],97:[function(_dereq_,module,exports){
|
|
15932
15967
|
module.exports = function (Utils) {
|
|
15933
15968
|
'use strict';
|
|
15934
15969
|
function Player(peaks) {
|
|
@@ -16012,7 +16047,7 @@ module.exports = function (Utils) {
|
|
|
16012
16047
|
};
|
|
16013
16048
|
return Player;
|
|
16014
16049
|
}(_dereq_('./utils'));
|
|
16015
|
-
},{"./utils":
|
|
16050
|
+
},{"./utils":110}],98:[function(_dereq_,module,exports){
|
|
16016
16051
|
module.exports = function (Utils, Konva) {
|
|
16017
16052
|
'use strict';
|
|
16018
16053
|
var HANDLE_RADIUS = 10;
|
|
@@ -16252,7 +16287,7 @@ module.exports = function (Utils, Konva) {
|
|
|
16252
16287
|
};
|
|
16253
16288
|
return PlayheadLayer;
|
|
16254
16289
|
}(_dereq_('./utils'), _dereq_('konva'));
|
|
16255
|
-
},{"./utils":
|
|
16290
|
+
},{"./utils":110,"konva":43}],99:[function(_dereq_,module,exports){
|
|
16256
16291
|
module.exports = function (Konva) {
|
|
16257
16292
|
'use strict';
|
|
16258
16293
|
function SegmentMarker(options) {
|
|
@@ -16338,7 +16373,7 @@ module.exports = function (Konva) {
|
|
|
16338
16373
|
};
|
|
16339
16374
|
return SegmentMarker;
|
|
16340
16375
|
}(_dereq_('konva'));
|
|
16341
|
-
},{"konva":43}],
|
|
16376
|
+
},{"konva":43}],100:[function(_dereq_,module,exports){
|
|
16342
16377
|
module.exports = function (Konva, SegmentMarker) {
|
|
16343
16378
|
'use strict';
|
|
16344
16379
|
var SEGMENT_WIDTH = 10;
|
|
@@ -16569,7 +16604,7 @@ module.exports = function (Konva, SegmentMarker) {
|
|
|
16569
16604
|
};
|
|
16570
16605
|
return SegmentShape;
|
|
16571
16606
|
}(_dereq_('konva'), _dereq_('./segment-marker'));
|
|
16572
|
-
},{"./segment-marker":
|
|
16607
|
+
},{"./segment-marker":99,"konva":43}],101:[function(_dereq_,module,exports){
|
|
16573
16608
|
module.exports = function (Utils) {
|
|
16574
16609
|
'use strict';
|
|
16575
16610
|
function validateSegment(peaks, options, context) {
|
|
@@ -16727,7 +16762,7 @@ module.exports = function (Utils) {
|
|
|
16727
16762
|
};
|
|
16728
16763
|
return Segment;
|
|
16729
16764
|
}(_dereq_('./utils'));
|
|
16730
|
-
},{"./utils":
|
|
16765
|
+
},{"./utils":110}],102:[function(_dereq_,module,exports){
|
|
16731
16766
|
module.exports = function (SegmentShape, Utils, Konva) {
|
|
16732
16767
|
'use strict';
|
|
16733
16768
|
function SegmentsGroup(peaks, view, allowEditing) {
|
|
@@ -17180,7 +17215,7 @@ module.exports = function (SegmentShape, Utils, Konva) {
|
|
|
17180
17215
|
};
|
|
17181
17216
|
return SegmentsGroup;
|
|
17182
17217
|
}(_dereq_('./segment-shape'), _dereq_('./utils'), _dereq_('konva'));
|
|
17183
|
-
},{"./segment-shape":
|
|
17218
|
+
},{"./segment-shape":100,"./utils":110,"konva":43}],103:[function(_dereq_,module,exports){
|
|
17184
17219
|
module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
|
|
17185
17220
|
'use strict';
|
|
17186
17221
|
var SPACING_BETWEEN_PREVIEW_AND_BORDER_RATIO = 0.15;
|
|
@@ -17233,21 +17268,6 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
|
|
|
17233
17268
|
this._addHandles(true);
|
|
17234
17269
|
this.setWrapping(source.wrapped);
|
|
17235
17270
|
}
|
|
17236
|
-
SourceGroup.prototype.rescale = function () {
|
|
17237
|
-
this.update();
|
|
17238
|
-
this._previewList.forEach(function (preview) {
|
|
17239
|
-
if (preview.loaded) {
|
|
17240
|
-
switch (preview.type) {
|
|
17241
|
-
case 'audio':
|
|
17242
|
-
preview.group.getChildren()[0].rescale();
|
|
17243
|
-
break;
|
|
17244
|
-
case 'video':
|
|
17245
|
-
case 'image':
|
|
17246
|
-
default:
|
|
17247
|
-
}
|
|
17248
|
-
}
|
|
17249
|
-
});
|
|
17250
|
-
};
|
|
17251
17271
|
SourceGroup.prototype._onSourceGroupDragStart = function () {
|
|
17252
17272
|
this._dragged = true;
|
|
17253
17273
|
this._mouseDownX = this._view.getPointerPosition().x;
|
|
@@ -17659,7 +17679,8 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
|
|
|
17659
17679
|
group: new Konva.Group({
|
|
17660
17680
|
height: this._source.binaryUrl && this._source.previewUrl ? this._source.binaryHeight : this._unwrappedHeight,
|
|
17661
17681
|
listening: false
|
|
17662
|
-
})
|
|
17682
|
+
}),
|
|
17683
|
+
url: url
|
|
17663
17684
|
};
|
|
17664
17685
|
var self = this;
|
|
17665
17686
|
var audioData = this._layer.getLoadedData(url);
|
|
@@ -17686,6 +17707,10 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
|
|
|
17686
17707
|
self._view.setTimeToPixelsMaxZoom(originalWaveformData.sample_rate / self._minScale);
|
|
17687
17708
|
}
|
|
17688
17709
|
self._layer.setLoadedData(url, originalWaveformData);
|
|
17710
|
+
self._layer.setLoadedData(url + '-scaled', {
|
|
17711
|
+
data: originalWaveformData,
|
|
17712
|
+
scale: originalWaveformData.sample_rate / self._minScale
|
|
17713
|
+
});
|
|
17689
17714
|
preview.loaded = true;
|
|
17690
17715
|
self._createAudioPreview(preview, originalWaveformData, redraw);
|
|
17691
17716
|
});
|
|
@@ -17716,20 +17741,26 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
|
|
|
17716
17741
|
SourceGroup.prototype._createAudioPreview = function (preview, waveformData, redraw) {
|
|
17717
17742
|
if (waveformData.hasAudio) {
|
|
17718
17743
|
var waveform = new WaveformShape({
|
|
17744
|
+
layer: this._layer,
|
|
17719
17745
|
view: this._view,
|
|
17720
17746
|
color: this._peaks.options.zoomWaveformColor,
|
|
17721
|
-
waveformData: waveformData,
|
|
17722
17747
|
source: this._source,
|
|
17723
|
-
height: preview.group.height()
|
|
17748
|
+
height: preview.group.height(),
|
|
17749
|
+
url: preview.url
|
|
17724
17750
|
});
|
|
17725
17751
|
preview.group.add(waveform);
|
|
17726
17752
|
this._unwrap.add(preview.group);
|
|
17727
17753
|
if (redraw) {
|
|
17728
|
-
this.
|
|
17754
|
+
this._layer.rescale(true);
|
|
17729
17755
|
}
|
|
17730
17756
|
this._previewList.push(preview);
|
|
17731
17757
|
}
|
|
17732
17758
|
};
|
|
17759
|
+
SourceGroup.prototype.getAudioPreview = function () {
|
|
17760
|
+
return this._previewList.filter(function (preview) {
|
|
17761
|
+
return preview.type === 'audio';
|
|
17762
|
+
});
|
|
17763
|
+
};
|
|
17733
17764
|
SourceGroup.prototype.setSelected = function (isSelected) {
|
|
17734
17765
|
var background = this._unwrap.getChildren(function (node) {
|
|
17735
17766
|
return node.getClassName() === 'Shape';
|
|
@@ -17889,7 +17920,7 @@ module.exports = function (WaveformBuilder, WaveformShape, Utils, Konva) {
|
|
|
17889
17920
|
};
|
|
17890
17921
|
return SourceGroup;
|
|
17891
17922
|
}(_dereq_('./waveform-builder'), _dereq_('./waveform-shape'), _dereq_('./utils'), _dereq_('konva'));
|
|
17892
|
-
},{"./utils":
|
|
17923
|
+
},{"./utils":110,"./waveform-builder":111,"./waveform-shape":112,"konva":43}],104:[function(_dereq_,module,exports){
|
|
17893
17924
|
module.exports = function (Utils) {
|
|
17894
17925
|
'use strict';
|
|
17895
17926
|
function validateSource(peaks, options, context) {
|
|
@@ -18426,8 +18457,8 @@ module.exports = function (Utils) {
|
|
|
18426
18457
|
};
|
|
18427
18458
|
return Source;
|
|
18428
18459
|
}(_dereq_('./utils'));
|
|
18429
|
-
},{"./utils":
|
|
18430
|
-
module.exports = function (SourceGroup, SegmentsGroup, Lines, DataRetriever, Utils, Konva) {
|
|
18460
|
+
},{"./utils":110}],105:[function(_dereq_,module,exports){
|
|
18461
|
+
module.exports = function (SourceGroup, SegmentsGroup, Lines, DataRetriever, Utils, Invoker, Konva) {
|
|
18431
18462
|
'use strict';
|
|
18432
18463
|
function SourcesLayer(peaks, view, allowEditing) {
|
|
18433
18464
|
this._peaks = peaks;
|
|
@@ -18440,6 +18471,7 @@ module.exports = function (SourceGroup, SegmentsGroup, Lines, DataRetriever, Uti
|
|
|
18440
18471
|
this._lines.addToLayer(this);
|
|
18441
18472
|
this._segmentsGroup = new SegmentsGroup(peaks, view, true);
|
|
18442
18473
|
this._loadedData = {};
|
|
18474
|
+
this._debouncedRescale = new Invoker().debounce(this._rescale, 150);
|
|
18443
18475
|
this._peaks.on('sources.add', this._onSourcesAdd.bind(this));
|
|
18444
18476
|
this._peaks.on('sources.destroy', this._onSourcesDestroy.bind(this));
|
|
18445
18477
|
this._peaks.on('sources.show', this._onSourcesShow.bind(this));
|
|
@@ -18699,10 +18731,37 @@ module.exports = function (SourceGroup, SegmentsGroup, Lines, DataRetriever, Uti
|
|
|
18699
18731
|
var startsEarlier = source1.startTime > source2.startTime && source1.startTime < source2.endTime;
|
|
18700
18732
|
return endsLater || startsEarlier;
|
|
18701
18733
|
};
|
|
18702
|
-
SourcesLayer.prototype.rescale = function () {
|
|
18703
|
-
|
|
18734
|
+
SourcesLayer.prototype.rescale = function (debounce) {
|
|
18735
|
+
if (debounce) {
|
|
18736
|
+
this._debouncedRescale();
|
|
18737
|
+
} else {
|
|
18738
|
+
this._rescale();
|
|
18739
|
+
}
|
|
18740
|
+
};
|
|
18741
|
+
SourcesLayer.prototype._rescale = function () {
|
|
18742
|
+
var id, audioPreviews, urls = [], self = this;
|
|
18743
|
+
for (id in this._sourcesGroup) {
|
|
18744
|
+
if (Utils.objectHasProperty(this._sourcesGroup, id)) {
|
|
18745
|
+
audioPreviews = this._sourcesGroup[id].getAudioPreview();
|
|
18746
|
+
audioPreviews.forEach(function (audioPreview) {
|
|
18747
|
+
if (self._shouldResampleAudio(audioPreview.url, urls)) {
|
|
18748
|
+
self._loadedData[audioPreview.url + '-scaled'] = {
|
|
18749
|
+
data: self._resampleAudio(audioPreview.url),
|
|
18750
|
+
scale: self._view.getTimeToPixelsScale()
|
|
18751
|
+
};
|
|
18752
|
+
urls.push(audioPreview.url);
|
|
18753
|
+
}
|
|
18754
|
+
});
|
|
18755
|
+
}
|
|
18756
|
+
}
|
|
18704
18757
|
this._layer.draw();
|
|
18705
18758
|
};
|
|
18759
|
+
SourcesLayer.prototype._shouldResampleAudio = function (audioUrl, urls) {
|
|
18760
|
+
return this._loadedData[audioUrl + '-scaled'] && !urls.includes(audioUrl) && this._loadedData[audioUrl + '-scaled'].scale !== this._view.getTimeToPixelsScale();
|
|
18761
|
+
};
|
|
18762
|
+
SourcesLayer.prototype._resampleAudio = function (audioUrl) {
|
|
18763
|
+
return this._loadedData[audioUrl].resample({ scale: this._loadedData[audioUrl].sample_rate / this._view.getTimeToPixelsScale() });
|
|
18764
|
+
};
|
|
18706
18765
|
SourcesLayer.prototype.destroy = function () {
|
|
18707
18766
|
this._peaks.off('sources.add', this._onSourcesAdd);
|
|
18708
18767
|
this._peaks.off('sources.destroy', this._onSourcesDestroy);
|
|
@@ -18720,8 +18779,8 @@ module.exports = function (SourceGroup, SegmentsGroup, Lines, DataRetriever, Uti
|
|
|
18720
18779
|
return this._lines.linesLength();
|
|
18721
18780
|
};
|
|
18722
18781
|
return SourcesLayer;
|
|
18723
|
-
}(_dereq_('./source-group'), _dereq_('./segments-group'), _dereq_('./lines'), _dereq_('./data-retriever'), _dereq_('./utils'), _dereq_('konva'));
|
|
18724
|
-
},{"./data-retriever":85,"./lines":
|
|
18782
|
+
}(_dereq_('./source-group'), _dereq_('./segments-group'), _dereq_('./lines'), _dereq_('./data-retriever'), _dereq_('./utils'), _dereq_('./invoker'), _dereq_('konva'));
|
|
18783
|
+
},{"./data-retriever":85,"./invoker":88,"./lines":92,"./segments-group":102,"./source-group":103,"./utils":110,"konva":43}],106:[function(_dereq_,module,exports){
|
|
18725
18784
|
module.exports = function (Utils, Konva) {
|
|
18726
18785
|
'use strict';
|
|
18727
18786
|
var LEFT_PADDING = 4;
|
|
@@ -18862,7 +18921,7 @@ module.exports = function (Utils, Konva) {
|
|
|
18862
18921
|
};
|
|
18863
18922
|
return TimelineAxis;
|
|
18864
18923
|
}(_dereq_('./utils'), _dereq_('konva'));
|
|
18865
|
-
},{"./utils":
|
|
18924
|
+
},{"./utils":110,"konva":43}],107:[function(_dereq_,module,exports){
|
|
18866
18925
|
module.exports = function (Colors, Segment, Utils) {
|
|
18867
18926
|
'use strict';
|
|
18868
18927
|
function TimelineSegments(peaks) {
|
|
@@ -19010,7 +19069,7 @@ module.exports = function (Colors, Segment, Utils) {
|
|
|
19010
19069
|
};
|
|
19011
19070
|
return TimelineSegments;
|
|
19012
19071
|
}(_dereq_('colors.css'), _dereq_('./segment'), _dereq_('./utils'));
|
|
19013
|
-
},{"./segment":
|
|
19072
|
+
},{"./segment":101,"./utils":110,"colors.css":1}],108:[function(_dereq_,module,exports){
|
|
19014
19073
|
module.exports = function (Source, Utils) {
|
|
19015
19074
|
'use strict';
|
|
19016
19075
|
function TimelineSources(peaks) {
|
|
@@ -19177,7 +19236,7 @@ module.exports = function (Source, Utils) {
|
|
|
19177
19236
|
};
|
|
19178
19237
|
return TimelineSources;
|
|
19179
19238
|
}(_dereq_('./source'), _dereq_('./utils'));
|
|
19180
|
-
},{"./source":
|
|
19239
|
+
},{"./source":104,"./utils":110}],109:[function(_dereq_,module,exports){
|
|
19181
19240
|
module.exports = function (MouseDragHandler, PlayheadLayer, SourcesLayer, ModeLayer, TimelineAxis, Utils, Konva) {
|
|
19182
19241
|
'use strict';
|
|
19183
19242
|
function TimelineZoomView(container, peaks) {
|
|
@@ -19554,10 +19613,10 @@ module.exports = function (MouseDragHandler, PlayheadLayer, SourcesLayer, ModeLa
|
|
|
19554
19613
|
this._timeToPixelsScale = newScale;
|
|
19555
19614
|
var apexPixel = this.timeToPixels(apexTime);
|
|
19556
19615
|
this.setFrameOffset(apexPixel - playheadOffsetPixels);
|
|
19557
|
-
this.updateTimeline(this._frameOffset);
|
|
19616
|
+
this.updateTimeline(this._frameOffset, undefined, undefined, true);
|
|
19617
|
+
this._sourcesLayer.rescale(true);
|
|
19558
19618
|
this._playheadLayer.zoomLevelChanged();
|
|
19559
19619
|
this._playheadLayer.updatePlayheadTime(currentTime);
|
|
19560
|
-
this._sourcesLayer.rescale();
|
|
19561
19620
|
this._peaks.emit('zoom.update', newScale, prevScale);
|
|
19562
19621
|
return true;
|
|
19563
19622
|
};
|
|
@@ -19630,7 +19689,7 @@ module.exports = function (MouseDragHandler, PlayheadLayer, SourcesLayer, ModeLa
|
|
|
19630
19689
|
TimelineZoomView.prototype.getAmplitudeScale = function () {
|
|
19631
19690
|
return this._amplitudeScale;
|
|
19632
19691
|
};
|
|
19633
|
-
TimelineZoomView.prototype.updateTimeline = function (frameOffset, frameOffsetY, fixPlayhead) {
|
|
19692
|
+
TimelineZoomView.prototype.updateTimeline = function (frameOffset, frameOffsetY, fixPlayhead, ignoreRescale) {
|
|
19634
19693
|
var frameStartTime = null;
|
|
19635
19694
|
var frameEndTime = null;
|
|
19636
19695
|
if (frameOffset !== undefined && frameOffset !== null) {
|
|
@@ -19656,6 +19715,9 @@ module.exports = function (MouseDragHandler, PlayheadLayer, SourcesLayer, ModeLa
|
|
|
19656
19715
|
if (frameEndTime === null) {
|
|
19657
19716
|
frameEndTime = this.pixelsToTime(this._frameOffset + this._width);
|
|
19658
19717
|
}
|
|
19718
|
+
if (!ignoreRescale) {
|
|
19719
|
+
this._sourcesLayer.rescale();
|
|
19720
|
+
}
|
|
19659
19721
|
this._sourcesLayer.updateSources(frameStartTime, frameEndTime);
|
|
19660
19722
|
};
|
|
19661
19723
|
TimelineZoomView.prototype.toggleMainCursor = function (on, type) {
|
|
@@ -19717,7 +19779,7 @@ module.exports = function (MouseDragHandler, PlayheadLayer, SourcesLayer, ModeLa
|
|
|
19717
19779
|
};
|
|
19718
19780
|
return TimelineZoomView;
|
|
19719
19781
|
}(_dereq_('./mouse-drag-handler'), _dereq_('./playhead-layer'), _dereq_('./sources-layer'), _dereq_('./mode-layer'), _dereq_('./timeline-axis'), _dereq_('./utils'), _dereq_('konva'));
|
|
19720
|
-
},{"./mode-layer":
|
|
19782
|
+
},{"./mode-layer":95,"./mouse-drag-handler":96,"./playhead-layer":98,"./sources-layer":105,"./timeline-axis":106,"./utils":110,"konva":43}],110:[function(_dereq_,module,exports){
|
|
19721
19783
|
module.exports = function (UUID) {
|
|
19722
19784
|
'use strict';
|
|
19723
19785
|
if (typeof Number.isFinite !== 'function') {
|
|
@@ -19881,7 +19943,7 @@ module.exports = function (UUID) {
|
|
|
19881
19943
|
}
|
|
19882
19944
|
};
|
|
19883
19945
|
}(_dereq_('uuid'));
|
|
19884
|
-
},{"uuid":62}],
|
|
19946
|
+
},{"uuid":62}],111:[function(_dereq_,module,exports){
|
|
19885
19947
|
module.exports = function (WaveformData, Utils) {
|
|
19886
19948
|
'use strict';
|
|
19887
19949
|
var isXhr2 = 'withCredentials' in new XMLHttpRequest();
|
|
@@ -20073,7 +20135,7 @@ module.exports = function (WaveformData, Utils) {
|
|
|
20073
20135
|
};
|
|
20074
20136
|
return WaveformBuilder;
|
|
20075
20137
|
}(_dereq_('waveform-data'), _dereq_('./utils'));
|
|
20076
|
-
},{"./utils":
|
|
20138
|
+
},{"./utils":110,"waveform-data":84}],112:[function(_dereq_,module,exports){
|
|
20077
20139
|
module.exports = function (Utils, Konva) {
|
|
20078
20140
|
'use strict';
|
|
20079
20141
|
function scaleY(amplitude, height, scale) {
|
|
@@ -20084,24 +20146,21 @@ module.exports = function (Utils, Konva) {
|
|
|
20084
20146
|
}
|
|
20085
20147
|
function WaveformShape(options) {
|
|
20086
20148
|
Konva.Shape.call(this, { fill: options.color });
|
|
20149
|
+
this._layer = options.layer;
|
|
20087
20150
|
this._view = options.view;
|
|
20088
20151
|
this._source = options.source;
|
|
20089
|
-
this._originalWaveformData = options.waveformData;
|
|
20090
|
-
this._waveformData = options.waveformData;
|
|
20091
20152
|
this._height = options.height;
|
|
20092
|
-
this.
|
|
20153
|
+
this._url = options.url + '-scaled';
|
|
20093
20154
|
this.sceneFunc(this._sceneFunc);
|
|
20094
20155
|
this.hitFunc(this._waveformShapeHitFunc);
|
|
20095
20156
|
}
|
|
20096
20157
|
WaveformShape.prototype = Object.create(Konva.Shape.prototype);
|
|
20097
|
-
WaveformShape.prototype.rescale = function () {
|
|
20098
|
-
this._waveformData = this._originalWaveformData.resample({ scale: this._waveformData.sample_rate / this._view.getTimeToPixelsScale() });
|
|
20099
|
-
};
|
|
20100
20158
|
WaveformShape.prototype.setWaveformColor = function (color) {
|
|
20101
20159
|
this.fill(color);
|
|
20102
20160
|
};
|
|
20103
20161
|
WaveformShape.prototype._sceneFunc = function (context) {
|
|
20104
20162
|
var width = this._view.getWidth();
|
|
20163
|
+
var waveformData = this._layer.getLoadedData(this._url).data;
|
|
20105
20164
|
var startPixels = 0, startOffset = 0;
|
|
20106
20165
|
if (this._source) {
|
|
20107
20166
|
startPixels = this._view.timeToPixels(this._source.mediaStartTime) + Math.max(this._view.getFrameOffset() - this._view.timeToPixels(this._source.startTime), 0);
|
|
@@ -20109,9 +20168,9 @@ module.exports = function (Utils, Konva) {
|
|
|
20109
20168
|
}
|
|
20110
20169
|
var endPixels = width;
|
|
20111
20170
|
if (this._source) {
|
|
20112
|
-
endPixels = Math.min(this._view.timeToPixels(this._source.mediaEndTime) - Math.max(this._view.timeToPixels(this._source.endTime) - this._view.getFrameOffset() - this._view.getWidth(), 0),
|
|
20171
|
+
endPixels = Math.min(this._view.timeToPixels(this._source.mediaEndTime) - Math.max(this._view.timeToPixels(this._source.endTime) - this._view.getFrameOffset() - this._view.getWidth(), 0), waveformData.length);
|
|
20113
20172
|
}
|
|
20114
|
-
this._drawWaveform(context,
|
|
20173
|
+
this._drawWaveform(context, waveformData, startPixels, startOffset, endPixels, this._height);
|
|
20115
20174
|
};
|
|
20116
20175
|
WaveformShape.prototype._drawWaveform = function (context, waveformData, startPixels, startOffset, endPixels, height) {
|
|
20117
20176
|
var channels = waveformData.channels;
|
|
@@ -20169,6 +20228,6 @@ module.exports = function (Utils, Konva) {
|
|
|
20169
20228
|
};
|
|
20170
20229
|
return WaveformShape;
|
|
20171
20230
|
}(_dereq_('./utils'), _dereq_('konva'));
|
|
20172
|
-
},{"./utils":
|
|
20231
|
+
},{"./utils":110,"konva":43}]},{},[93])(93)
|
|
20173
20232
|
});
|
|
20174
20233
|
//# sourceMappingURL=peaks.js.map
|
package/src/invoker.js
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @file
|
|
3
|
+
*
|
|
4
|
+
* Defines the {@link invoker} class.
|
|
5
|
+
*
|
|
6
|
+
* @module invoker
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
define([
|
|
10
|
+
], function() {
|
|
11
|
+
'use strict';
|
|
12
|
+
|
|
13
|
+
/**
|
|
14
|
+
* An invoker class for throttling.
|
|
15
|
+
*
|
|
16
|
+
* @class
|
|
17
|
+
* @alias Invoker
|
|
18
|
+
*/
|
|
19
|
+
|
|
20
|
+
function Invoker() {
|
|
21
|
+
this._throttledFunc = {};
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
Invoker.prototype.throttle = function(id, func, wait) {
|
|
25
|
+
var self = this;
|
|
26
|
+
|
|
27
|
+
if (this._throttledFunc[id]) {
|
|
28
|
+
// Already limiting
|
|
29
|
+
this._throttledFunc[id].func = func;
|
|
30
|
+
this._throttledFunc[id].continue = true;
|
|
31
|
+
}
|
|
32
|
+
else {
|
|
33
|
+
// Create a limit
|
|
34
|
+
this._throttledFunc[id] = {
|
|
35
|
+
func: func,
|
|
36
|
+
timer: null,
|
|
37
|
+
continue: true
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
this._throttledFunc[id].timer = setInterval(function() {
|
|
41
|
+
if (self._throttledFunc[id].continue) {
|
|
42
|
+
func();
|
|
43
|
+
self._throttledFunc[id].continue = false;
|
|
44
|
+
}
|
|
45
|
+
else {
|
|
46
|
+
clearInterval(self._throttledFunc[id].timer);
|
|
47
|
+
delete self._throttledFunc[id];
|
|
48
|
+
}
|
|
49
|
+
}, wait);
|
|
50
|
+
}
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
Invoker.prototype.debounce = function(func, wait, immediate) {
|
|
54
|
+
var timeout;
|
|
55
|
+
|
|
56
|
+
return function executedFunction() {
|
|
57
|
+
// eslint-disable-next-line consistent-this
|
|
58
|
+
var _self = this;
|
|
59
|
+
var args = arguments;
|
|
60
|
+
|
|
61
|
+
function later() {
|
|
62
|
+
timeout = null;
|
|
63
|
+
if (!immediate) {
|
|
64
|
+
func.apply(_self, args);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
var callNow = immediate && !timeout;
|
|
69
|
+
|
|
70
|
+
clearTimeout(timeout);
|
|
71
|
+
|
|
72
|
+
timeout = setTimeout(later, wait);
|
|
73
|
+
|
|
74
|
+
if (callNow) {
|
|
75
|
+
func.apply(_self, args);
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
};
|
|
79
|
+
|
|
80
|
+
return Invoker;
|
|
81
|
+
});
|
package/src/line.js
CHANGED
|
@@ -596,13 +596,13 @@ define([
|
|
|
596
596
|
return newXs;
|
|
597
597
|
};
|
|
598
598
|
|
|
599
|
-
Line.prototype.rescale = function() {
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
};
|
|
599
|
+
// Line.prototype.rescale = function() {
|
|
600
|
+
// for (var sourceId in this._sourcesGroup) {
|
|
601
|
+
// if (Utils.objectHasProperty(this._sourcesGroup, sourceId)) {
|
|
602
|
+
// this._sourcesGroup[sourceId].rescale();
|
|
603
|
+
// }
|
|
604
|
+
// }
|
|
605
|
+
// };
|
|
606
606
|
|
|
607
607
|
Line.prototype.updatePosition = function(pos) {
|
|
608
608
|
for (var sourceId in this._sources) {
|
package/src/lines.js
CHANGED
|
@@ -305,13 +305,13 @@ define([
|
|
|
305
305
|
return this._linesBySourceId[source.id].manageSourceOrder(source, newStartX, newEndX);
|
|
306
306
|
};
|
|
307
307
|
|
|
308
|
-
Lines.prototype.rescale = function() {
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
};
|
|
308
|
+
// Lines.prototype.rescale = function() {
|
|
309
|
+
// for (var position in this._linesByPosition) {
|
|
310
|
+
// if (Utils.objectHasProperty(this._linesByPosition, position)) {
|
|
311
|
+
// this._linesByPosition[position].rescale();
|
|
312
|
+
// }
|
|
313
|
+
// }
|
|
314
|
+
// };
|
|
315
315
|
|
|
316
316
|
Lines.prototype._setInteractions = function(position) {
|
|
317
317
|
var line = this._linesByPosition[position];
|
package/src/source-group.js
CHANGED
|
@@ -91,23 +91,23 @@ define([
|
|
|
91
91
|
this.setWrapping(source.wrapped);
|
|
92
92
|
}
|
|
93
93
|
|
|
94
|
-
SourceGroup.prototype.rescale = function() {
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
};
|
|
94
|
+
// SourceGroup.prototype.rescale = function() {
|
|
95
|
+
// this.update();
|
|
96
|
+
|
|
97
|
+
// this._previewList.forEach(function(preview) {
|
|
98
|
+
// if (preview.loaded) {
|
|
99
|
+
// switch (preview.type) {
|
|
100
|
+
// case 'audio':
|
|
101
|
+
// preview.group.getChildren()[0].rescale(true);
|
|
102
|
+
// break;
|
|
103
|
+
// case 'video':
|
|
104
|
+
// case 'image':
|
|
105
|
+
// default:
|
|
106
|
+
// // No resampling
|
|
107
|
+
// }
|
|
108
|
+
// }
|
|
109
|
+
// });
|
|
110
|
+
// };
|
|
111
111
|
|
|
112
112
|
SourceGroup.prototype._onSourceGroupDragStart = function() {
|
|
113
113
|
this._dragged = true;
|
|
@@ -667,7 +667,8 @@ define([
|
|
|
667
667
|
height: this._source.binaryUrl && this._source.previewUrl ?
|
|
668
668
|
this._source.binaryHeight : this._unwrappedHeight,
|
|
669
669
|
listening: false
|
|
670
|
-
})
|
|
670
|
+
}),
|
|
671
|
+
url: url
|
|
671
672
|
};
|
|
672
673
|
|
|
673
674
|
var self = this;
|
|
@@ -706,6 +707,10 @@ define([
|
|
|
706
707
|
}
|
|
707
708
|
|
|
708
709
|
self._layer.setLoadedData(url, originalWaveformData);
|
|
710
|
+
self._layer.setLoadedData(
|
|
711
|
+
url + '-scaled',
|
|
712
|
+
{ data: originalWaveformData, scale: originalWaveformData.sample_rate / self._minScale }
|
|
713
|
+
);
|
|
709
714
|
preview.loaded = true;
|
|
710
715
|
self._createAudioPreview(preview, originalWaveformData, redraw);
|
|
711
716
|
});
|
|
@@ -744,24 +749,31 @@ define([
|
|
|
744
749
|
SourceGroup.prototype._createAudioPreview = function(preview, waveformData, redraw) {
|
|
745
750
|
if (waveformData.hasAudio) {
|
|
746
751
|
var waveform = new WaveformShape({
|
|
752
|
+
layer: this._layer,
|
|
747
753
|
view: this._view,
|
|
748
754
|
color: this._peaks.options.zoomWaveformColor,
|
|
749
|
-
waveformData: waveformData,
|
|
750
755
|
source: this._source,
|
|
751
|
-
height: preview.group.height()
|
|
756
|
+
height: preview.group.height(),
|
|
757
|
+
url: preview.url
|
|
752
758
|
});
|
|
753
759
|
|
|
754
760
|
preview.group.add(waveform);
|
|
755
761
|
this._unwrap.add(preview.group);
|
|
756
762
|
|
|
757
763
|
if (redraw) {
|
|
758
|
-
this.
|
|
764
|
+
this._layer.rescale(true);
|
|
759
765
|
}
|
|
760
766
|
|
|
761
767
|
this._previewList.push(preview);
|
|
762
768
|
}
|
|
763
769
|
};
|
|
764
770
|
|
|
771
|
+
SourceGroup.prototype.getAudioPreview = function() {
|
|
772
|
+
return this._previewList.filter(function(preview) {
|
|
773
|
+
return preview.type === 'audio';
|
|
774
|
+
});
|
|
775
|
+
};
|
|
776
|
+
|
|
765
777
|
SourceGroup.prototype.setSelected = function(isSelected) {
|
|
766
778
|
// update unwrap
|
|
767
779
|
var background = this._unwrap.getChildren(function(node) {
|
package/src/sources-layer.js
CHANGED
|
@@ -12,6 +12,7 @@ define([
|
|
|
12
12
|
'./lines',
|
|
13
13
|
'./data-retriever',
|
|
14
14
|
'./utils',
|
|
15
|
+
'./invoker',
|
|
15
16
|
'konva'
|
|
16
17
|
], function(
|
|
17
18
|
SourceGroup,
|
|
@@ -19,6 +20,7 @@ define([
|
|
|
19
20
|
Lines,
|
|
20
21
|
DataRetriever,
|
|
21
22
|
Utils,
|
|
23
|
+
Invoker,
|
|
22
24
|
Konva) {
|
|
23
25
|
'use strict';
|
|
24
26
|
|
|
@@ -47,6 +49,10 @@ define([
|
|
|
47
49
|
|
|
48
50
|
this._loadedData = {};
|
|
49
51
|
|
|
52
|
+
this._debouncedRescale = new Invoker().debounce(
|
|
53
|
+
this._rescale, 150
|
|
54
|
+
);
|
|
55
|
+
|
|
50
56
|
this._peaks.on('sources.add', this._onSourcesAdd.bind(this));
|
|
51
57
|
this._peaks.on('sources.destroy', this._onSourcesDestroy.bind(this));
|
|
52
58
|
this._peaks.on('sources.show', this._onSourcesShow.bind(this));
|
|
@@ -472,11 +478,51 @@ define([
|
|
|
472
478
|
return endsLater || startsEarlier;
|
|
473
479
|
};
|
|
474
480
|
|
|
475
|
-
SourcesLayer.prototype.rescale = function() {
|
|
476
|
-
this._lines.rescale();
|
|
481
|
+
SourcesLayer.prototype.rescale = function(debounce) {
|
|
482
|
+
// this._lines.rescale();
|
|
483
|
+
if (debounce) {
|
|
484
|
+
this._debouncedRescale();
|
|
485
|
+
}
|
|
486
|
+
else {
|
|
487
|
+
this._rescale();
|
|
488
|
+
}
|
|
489
|
+
};
|
|
490
|
+
|
|
491
|
+
SourcesLayer.prototype._rescale = function() {
|
|
492
|
+
var id, audioPreviews, urls = [], self = this;
|
|
493
|
+
|
|
494
|
+
for (id in this._sourcesGroup) {
|
|
495
|
+
if (Utils.objectHasProperty(this._sourcesGroup, id)) {
|
|
496
|
+
audioPreviews = this._sourcesGroup[id].getAudioPreview();
|
|
497
|
+
|
|
498
|
+
audioPreviews.forEach(function(audioPreview) {
|
|
499
|
+
if (self._shouldResampleAudio(audioPreview.url, urls)) {
|
|
500
|
+
self._loadedData[audioPreview.url + '-scaled'] = {
|
|
501
|
+
data: self._resampleAudio(audioPreview.url),
|
|
502
|
+
scale: self._view.getTimeToPixelsScale()
|
|
503
|
+
};
|
|
504
|
+
|
|
505
|
+
urls.push(audioPreview.url);
|
|
506
|
+
}
|
|
507
|
+
});
|
|
508
|
+
}
|
|
509
|
+
}
|
|
477
510
|
this._layer.draw();
|
|
478
511
|
};
|
|
479
512
|
|
|
513
|
+
SourcesLayer.prototype._shouldResampleAudio = function(audioUrl, urls) {
|
|
514
|
+
return this._loadedData[audioUrl + '-scaled']
|
|
515
|
+
&& !urls.includes(audioUrl)
|
|
516
|
+
&& this._loadedData[audioUrl + '-scaled'].scale !== this._view.getTimeToPixelsScale();
|
|
517
|
+
};
|
|
518
|
+
|
|
519
|
+
SourcesLayer.prototype._resampleAudio = function(audioUrl) {
|
|
520
|
+
return this._loadedData[audioUrl].resample({
|
|
521
|
+
scale: this._loadedData[audioUrl].sample_rate
|
|
522
|
+
/ this._view.getTimeToPixelsScale()
|
|
523
|
+
});
|
|
524
|
+
};
|
|
525
|
+
|
|
480
526
|
SourcesLayer.prototype.destroy = function() {
|
|
481
527
|
this._peaks.off('sources.add', this._onSourcesAdd);
|
|
482
528
|
this._peaks.off('sources.destroy', this._onSourcesDestroy);
|
package/src/timeline-zoomview.js
CHANGED
|
@@ -588,15 +588,15 @@ define([
|
|
|
588
588
|
|
|
589
589
|
this.setFrameOffset(apexPixel - playheadOffsetPixels);
|
|
590
590
|
|
|
591
|
-
this.updateTimeline(this._frameOffset);
|
|
591
|
+
this.updateTimeline(this._frameOffset, undefined, undefined, true);
|
|
592
|
+
|
|
593
|
+
this._sourcesLayer.rescale(true);
|
|
592
594
|
|
|
593
595
|
this._playheadLayer.zoomLevelChanged();
|
|
594
596
|
|
|
595
597
|
// Update the playhead position after zooming.
|
|
596
598
|
this._playheadLayer.updatePlayheadTime(currentTime);
|
|
597
599
|
|
|
598
|
-
this._sourcesLayer.rescale();
|
|
599
|
-
|
|
600
600
|
this._peaks.emit('zoom.update', newScale, prevScale);
|
|
601
601
|
|
|
602
602
|
return true;
|
|
@@ -742,7 +742,8 @@ define([
|
|
|
742
742
|
* @param {Number} frameOffset The new frame offset, in pixels.
|
|
743
743
|
*/
|
|
744
744
|
|
|
745
|
-
TimelineZoomView.prototype.updateTimeline = function(frameOffset, frameOffsetY, fixPlayhead
|
|
745
|
+
TimelineZoomView.prototype.updateTimeline = function(frameOffset, frameOffsetY, fixPlayhead,
|
|
746
|
+
ignoreRescale) {
|
|
746
747
|
var frameStartTime = null;
|
|
747
748
|
var frameEndTime = null;
|
|
748
749
|
|
|
@@ -783,6 +784,10 @@ define([
|
|
|
783
784
|
frameEndTime = this.pixelsToTime(this._frameOffset + this._width);
|
|
784
785
|
}
|
|
785
786
|
|
|
787
|
+
if (!ignoreRescale) {
|
|
788
|
+
this._sourcesLayer.rescale();
|
|
789
|
+
}
|
|
790
|
+
|
|
786
791
|
this._sourcesLayer.updateSources(frameStartTime, frameEndTime);
|
|
787
792
|
};
|
|
788
793
|
|
package/src/waveform-shape.js
CHANGED
|
@@ -54,13 +54,11 @@ define(['./utils', 'konva'], function(Utils, Konva) {
|
|
|
54
54
|
fill: options.color
|
|
55
55
|
});
|
|
56
56
|
|
|
57
|
+
this._layer = options.layer;
|
|
57
58
|
this._view = options.view;
|
|
58
59
|
this._source = options.source;
|
|
59
|
-
this._originalWaveformData = options.waveformData;
|
|
60
|
-
this._waveformData = options.waveformData;
|
|
61
60
|
this._height = options.height;
|
|
62
|
-
|
|
63
|
-
this.rescale();
|
|
61
|
+
this._url = options.url + '-scaled';
|
|
64
62
|
|
|
65
63
|
this.sceneFunc(this._sceneFunc);
|
|
66
64
|
|
|
@@ -69,18 +67,13 @@ define(['./utils', 'konva'], function(Utils, Konva) {
|
|
|
69
67
|
|
|
70
68
|
WaveformShape.prototype = Object.create(Konva.Shape.prototype);
|
|
71
69
|
|
|
72
|
-
WaveformShape.prototype.rescale = function() {
|
|
73
|
-
this._waveformData = this._originalWaveformData.resample({
|
|
74
|
-
scale: this._waveformData.sample_rate / this._view.getTimeToPixelsScale()
|
|
75
|
-
});
|
|
76
|
-
};
|
|
77
|
-
|
|
78
70
|
WaveformShape.prototype.setWaveformColor = function(color) {
|
|
79
71
|
this.fill(color);
|
|
80
72
|
};
|
|
81
73
|
|
|
82
74
|
WaveformShape.prototype._sceneFunc = function(context) {
|
|
83
75
|
var width = this._view.getWidth();
|
|
76
|
+
var waveformData = this._layer.getLoadedData(this._url).data;
|
|
84
77
|
|
|
85
78
|
var startPixels = 0, startOffset = 0;
|
|
86
79
|
|
|
@@ -103,13 +96,13 @@ define(['./utils', 'konva'], function(Utils, Konva) {
|
|
|
103
96
|
- this._view.getWidth(),
|
|
104
97
|
0
|
|
105
98
|
),
|
|
106
|
-
|
|
99
|
+
waveformData.length
|
|
107
100
|
);
|
|
108
101
|
}
|
|
109
102
|
|
|
110
103
|
this._drawWaveform(
|
|
111
104
|
context,
|
|
112
|
-
|
|
105
|
+
waveformData,
|
|
113
106
|
startPixels,
|
|
114
107
|
startOffset,
|
|
115
108
|
endPixels,
|