refactor(legacy): remove unused waveform related code (#3003)
Co-authored-by: Thomas Göttgens <tgoettgens@mail.com> Co-authored-by: Kyle Robbertze <paddatrapper@users.noreply.github.com>
This commit is contained in:
parent
a556b73d2a
commit
064c435b09
|
@ -43,7 +43,7 @@
|
||||||
"css/show_analytics.css": "4393c521308277447afabe8791779bf1",
|
"css/show_analytics.css": "4393c521308277447afabe8791779bf1",
|
||||||
"css/showbuilder.css": "4421c01b5c2dfb03f8d06dd6023b4bd7",
|
"css/showbuilder.css": "4421c01b5c2dfb03f8d06dd6023b4bd7",
|
||||||
"css/station_podcast.css": "88e9b38ead71eddc69ef50bfc8cb2d0d",
|
"css/station_podcast.css": "88e9b38ead71eddc69ef50bfc8cb2d0d",
|
||||||
"css/styles.css": "29ce2292b2c007e86d192d0deeaf88ad",
|
"css/styles.css": "f38f7f24c3895c146babbb56a6534730",
|
||||||
"css/tipsy/jquery.tipsy.css": "b13517583583f83ed7d5fc067a0c9372",
|
"css/tipsy/jquery.tipsy.css": "b13517583583f83ed7d5fc067a0c9372",
|
||||||
"css/tracktypes.css": "94c94817a8505ff4dfcd090987859a7e",
|
"css/tracktypes.css": "94c94817a8505ff4dfcd090987859a7e",
|
||||||
"css/users.css": "94c94817a8505ff4dfcd090987859a7e",
|
"css/users.css": "94c94817a8505ff4dfcd090987859a7e",
|
||||||
|
@ -180,12 +180,9 @@
|
||||||
"js/waveformplaylist/playout.js": "7dfc5fe760f3c6739e38499df7b61e47",
|
"js/waveformplaylist/playout.js": "7dfc5fe760f3c6739e38499df7b61e47",
|
||||||
"js/waveformplaylist/time_scale.js": "74e0e17e1c8cd597449220c98de408ba",
|
"js/waveformplaylist/time_scale.js": "74e0e17e1c8cd597449220c98de408ba",
|
||||||
"js/waveformplaylist/track.js": "5456e6081ffedf55a9e38571bc178781",
|
"js/waveformplaylist/track.js": "5456e6081ffedf55a9e38571bc178781",
|
||||||
"js/waveformplaylist/track_render.js": "e371b582b23e4b618e039f096d2f0570",
|
|
||||||
"js/wavesurfer/cursor.js": "8ed17a7437f3ec84972d15d0073249b2",
|
"js/wavesurfer/cursor.js": "8ed17a7437f3ec84972d15d0073249b2",
|
||||||
"js/wavesurfer/cursor.min.js": "831165862b629e615cf59112fa00d963",
|
"js/wavesurfer/cursor.min.js": "831165862b629e615cf59112fa00d963",
|
||||||
"js/wavesurfer/libretime.js": "17133cacf09fc204a572b56c99d44278",
|
"js/wavesurfer/libretime.js": "dfaefa6d32657faa77af6145d9d191ae",
|
||||||
"js/wavesurfer/minimap.js": "c17dd315386006bb3cffdabb5f715c7b",
|
|
||||||
"js/wavesurfer/minimap.min.js": "90b2f2d1d1b4eb189d1a9c3c27dcb4f7",
|
|
||||||
"js/wavesurfer/regions.js": "aafe4f696d3da50c976d11e472fd56d1",
|
"js/wavesurfer/regions.js": "aafe4f696d3da50c976d11e472fd56d1",
|
||||||
"js/wavesurfer/regions.min.js": "2ed2f8b5880beee568942000a6139e85",
|
"js/wavesurfer/regions.min.js": "2ed2f8b5880beee568942000a6139e85",
|
||||||
"js/wavesurfer/timeline.js": "0bd70779070513c2a4f34237a0f9f573",
|
"js/wavesurfer/timeline.js": "0bd70779070513c2a4f34237a0f9f573",
|
||||||
|
|
|
@ -190,14 +190,6 @@ class Application_Form_EditAudioMD extends Zend_Form
|
||||||
]);
|
]);
|
||||||
$this->addElement($mood);
|
$this->addElement($mood);
|
||||||
|
|
||||||
// Add replay gain field
|
|
||||||
$replay_gain = new Zend_Form_Element_Hidden('replay_gain');
|
|
||||||
$replay_gain->class = 'input_text replay_gain_' . $p_id;
|
|
||||||
$replay_gain->setLabel(_('Replay Gain:'))
|
|
||||||
->addDecorator('HtmlTag', ['tag' => 'div', 'style' => 'display:none'])
|
|
||||||
->removeDecorator('Label');
|
|
||||||
$this->addElement($replay_gain);
|
|
||||||
|
|
||||||
// Add bmp field
|
// Add bmp field
|
||||||
$bpm = new Zend_Form_Element_Text('bpm');
|
$bpm = new Zend_Form_Element_Text('bpm');
|
||||||
$bpm->class = 'input_text';
|
$bpm->class = 'input_text';
|
||||||
|
|
|
@ -1,12 +1,6 @@
|
||||||
<?php $get_artwork = FileDataHelper::getArtworkData($this->artwork, 256);
|
<?php $get_artwork = FileDataHelper::getArtworkData($this->artwork, 256);
|
||||||
|
|
||||||
$baseUrl = Config::getBasePath();
|
$baseUrl = Config::getBasePath();
|
||||||
|
|
||||||
$get_replay_gain = Application_Model_Preference::getReplayGainModifier();
|
|
||||||
if (!Application_Model_Preference::GetEnableReplayGain() ) {
|
|
||||||
$get_replay_gain = 0;
|
|
||||||
}
|
|
||||||
$analogMeter = true;
|
|
||||||
?>
|
?>
|
||||||
<div class="ui-widget ui-widget-content block-shadow simple-formblock clearfix padded-strong edit-md-dialog">
|
<div class="ui-widget ui-widget-content block-shadow simple-formblock clearfix padded-strong edit-md-dialog">
|
||||||
<div class="track-edit-header" style="top:15px">
|
<div class="track-edit-header" style="top:15px">
|
||||||
|
@ -45,8 +39,8 @@ $analogMeter = true;
|
||||||
</div>
|
</div>
|
||||||
<div style="height: 160px;"></div>
|
<div style="height: 160px;"></div>
|
||||||
<?php echo $this->form; ?>
|
<?php echo $this->form; ?>
|
||||||
<div class="collapsible-header closed"><span class="arrow-icon"></span><?php echo _("Visual Waveform Editor"); ?></div>
|
<div class="collapsible-header collapsible-header-<?php echo $this->id;?> closed"><span class="arrow-icon"></span><?php echo _("Cue Point Editor"); ?></div>
|
||||||
<div class="visual-waveform-editor" style="clear:both;padding:18px 24px 0 0;">
|
<div class="visual-waveform-editor visual-waveform-editor-<?php echo $this->id;?>" style="clear:both;padding:18px 24px 0 0;">
|
||||||
<div class="controls">
|
<div class="controls">
|
||||||
<div class="row">
|
<div class="row">
|
||||||
<div class="col-sm-7">
|
<div class="col-sm-7">
|
||||||
|
@ -88,54 +82,45 @@ $analogMeter = true;
|
||||||
<div id="track-waveform-<?php echo $this->id; ?>"></div>
|
<div id="track-waveform-<?php echo $this->id; ?>"></div>
|
||||||
<div id="timeline-<?php echo $this->id; ?>"></div>
|
<div id="timeline-<?php echo $this->id; ?>"></div>
|
||||||
</div>
|
</div>
|
||||||
<input type="hidden" id="volume-<?php echo $this->id; ?>" type="range" min="0" max="1" value="1" step="0.1">
|
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
<script>
|
<script>
|
||||||
//waveform
|
//waveform
|
||||||
var track_id = <?php echo $this->id; ?>;
|
renderWaveform(<?php echo $this->id; ?>, '#track-waveform-<?php echo $this->id; ?>', baseUrl + 'api/get-media/file/<?php echo $this->id; ?>', '<?php echo $this->cuein; ?>', '<?php echo $this->cueout; ?>');
|
||||||
var selector_id = "#track-waveform-"+<?php echo $this->id; ?>;
|
|
||||||
var url = baseUrl + 'api/get-media/file/<?php echo $this->id; ?>';
|
|
||||||
var cuein = '<?php echo $this->cuein; ?>';
|
|
||||||
var cueout = '<?php echo $this->cueout; ?>';
|
|
||||||
var gain_level = deciSteps(<?php echo $this->replay_gain; ?>);
|
|
||||||
var default_gain = <?php echo $get_replay_gain; ?>;
|
|
||||||
var eTrack = renderWaveform(track_id, selector_id, url, cuein, cueout, gain_level, default_gain);
|
|
||||||
|
|
||||||
$(document).ready(function() {
|
$(document).ready(function() {
|
||||||
|
|
||||||
$(".collapsible-header")
|
$(".collapsible-header-<?php echo $this->id;?>")
|
||||||
.off("click")
|
.off("click")
|
||||||
.on("click", function () {
|
.on("click", function () {
|
||||||
$(this).toggleClass("visible");
|
$(this).toggleClass("visible");
|
||||||
$(".visual-waveform-editor").toggle();
|
$(".visual-waveform-editor-<?php echo $this->id;?>").toggle();
|
||||||
$(".editor_pane_wrapper").animate({
|
$(".editor_pane_wrapper").animate({
|
||||||
scrollTop: $(".collapsible-header").offset().top * 2
|
scrollTop: $(".collapsible-header-<?php echo $this->id;?>").offset().top * 2
|
||||||
}, 500);
|
}, 500);
|
||||||
|
wavesurfer["t<?php echo $this->id; ?>"].drawer.containerWidth = wavesurfer["t<?php echo $this->id; ?>"].drawer.container.clientWidth;
|
||||||
|
wavesurfer["t<?php echo $this->id; ?>"].zoom(Number($(".zoom-slider-<?php echo $this->id; ?>").value));
|
||||||
});
|
});
|
||||||
|
|
||||||
// Counter field edit
|
// Counter field edit
|
||||||
$(document).on('change', '#tracktimerinput-<?php echo $this->id; ?>', 'input', function(event) {
|
$(document).on('change', '#tracktimerinput-<?php echo $this->id; ?>', 'input', function(event) {
|
||||||
|
event.preventDefault();
|
||||||
|
event.stopPropagation();
|
||||||
|
var val = $(this).val();
|
||||||
|
wavesurfer["t<?php echo $this->id; ?>"].setCurrentTime(val);
|
||||||
|
}).on('keypress keydown', '#tracktimerinput-<?php echo $this->id; ?>', 'input', function(event) {
|
||||||
|
if (event.key === 'Enter' || event.keyCode === 13 || event.keyCode === 10) {
|
||||||
|
var val = $(this).val();
|
||||||
|
wavesurfer["t<?php echo $this->id; ?>"].setCurrentTime(val);
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
var val = $(this).val();
|
event.stopImmediatePropagation();
|
||||||
eTrack.setCurrentTime(val);
|
return false;
|
||||||
}).on('keypress keydown', '#tracktimerinput-<?php echo $this->id; ?>', 'input', function(event) {
|
}
|
||||||
if (event.key === 'Enter' || event.keyCode === 13 || event.keyCode === 10) {
|
|
||||||
var val = $(this).val();
|
|
||||||
eTrack.setCurrentTime(val);
|
|
||||||
event.preventDefault();
|
|
||||||
event.stopPropagation();
|
|
||||||
event.stopImmediatePropagation();
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
//Gain Knob
|
|
||||||
$("#volume-<?php echo $this->id; ?>").val(deciSteps(<?php echo $this->replay_gain; ?>));
|
|
||||||
|
|
||||||
$(document).on('change', '.cuein_<?php echo $this->id; ?>', 'input', function(event) {
|
$(document).on('change', '.cuein_<?php echo $this->id; ?>', 'input', function(event) {
|
||||||
console.log('cuein input');
|
console.log('cuein input');
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
|
@ -144,9 +129,9 @@ $analogMeter = true;
|
||||||
var a = val.split(':');
|
var a = val.split(':');
|
||||||
var startseconds = (+a[0]) * 60 * 60 + (+a[1]) * 60 + (+a[2]);
|
var startseconds = (+a[0]) * 60 * 60 + (+a[1]) * 60 + (+a[2]);
|
||||||
console.log(startseconds);
|
console.log(startseconds);
|
||||||
var region = eTrack.regions.list[track_id];
|
var region = wavesurfer["t<?php echo $this->id; ?>"].regions.list[<?php echo $this->id; ?>];
|
||||||
region.update({start: startseconds});
|
region.update({start: startseconds});
|
||||||
$('#track-playedit-'+track_id).attr('onClick', 'wavesurfer["t'+ track_id +'"].play('+ region.start +', '+ region.end +');');
|
$('#track-playedit-<?php echo $this->id; ?>').attr('onClick', 'wavesurfer["t'+ <?php echo $this->id; ?> +'"].play('+ region.start +', '+ region.end +');');
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on('change', '.cueout_<?php echo $this->id; ?>', 'input', function(event) {
|
$(document).on('change', '.cueout_<?php echo $this->id; ?>', 'input', function(event) {
|
||||||
|
@ -156,31 +141,31 @@ $analogMeter = true;
|
||||||
var val = $(this).val();
|
var val = $(this).val();
|
||||||
var b = val.split(':');
|
var b = val.split(':');
|
||||||
var endseconds = (+b[0]) * 60 * 60 + (+b[1]) * 60 + (+b[2]);
|
var endseconds = (+b[0]) * 60 * 60 + (+b[1]) * 60 + (+b[2]);
|
||||||
var region = eTrack.regions.list[track_id];
|
var region = wavesurfer["t<?php echo $this->id; ?>"].regions.list[<?php echo $this->id; ?>];
|
||||||
region.update({end: endseconds});
|
region.update({end: endseconds});
|
||||||
$('#track-playedit-'+track_id).attr('onClick', 'wavesurfer["t'+ track_id +'"].play('+ region.start +', '+ region.end +');');
|
$('#track-playedit-<?php echo $this->id; ?>').attr('onClick', 'wavesurfer["t'+ <?php echo $this->id; ?> +'"].play('+ region.start +', '+ region.end +');');
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on('click', '#cuein-set-<?php echo $this->id; ?>', 'button', function(event) {
|
$(document).on('click', '#cuein-set-<?php echo $this->id; ?>', 'button', function(event) {
|
||||||
console.log('cuein button');
|
console.log('cuein button');
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
var val = eTrack.getCurrentTime();
|
var val = wavesurfer["t<?php echo $this->id; ?>"].getCurrentTime();
|
||||||
var region = eTrack.regions.list[track_id];
|
var region = wavesurfer["t<?php echo $this->id; ?>"].regions.list[<?php echo $this->id; ?>];
|
||||||
region.update({start: val});
|
region.update({start: val});
|
||||||
document.getElementsByClassName("cuein_"+track_id)[0].value = toHHMMSS(region.start);
|
document.getElementsByClassName("cuein_<?php echo $this->id; ?>")[0].value = toHHMMSS(region.start);
|
||||||
$('#track-playedit-'+track_id).attr('onClick', 'wavesurfer["t'+ track_id +'"].play('+ region.start +', '+ region.end +');');
|
$('#track-playedit-<?php echo $this->id; ?>').attr('onClick', 'wavesurfer["t'+ <?php echo $this->id; ?> +'"].play('+ region.start +', '+ region.end +');');
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on('click', '#cueout-set-<?php echo $this->id; ?>', 'button', function(event) {
|
$(document).on('click', '#cueout-set-<?php echo $this->id; ?>', 'button', function(event) {
|
||||||
console.log('cueout button')
|
console.log('cueout button')
|
||||||
event.preventDefault();
|
event.preventDefault();
|
||||||
event.stopPropagation();
|
event.stopPropagation();
|
||||||
var val = eTrack.getCurrentTime();
|
var val = wavesurfer["t<?php echo $this->id; ?>"].getCurrentTime();
|
||||||
var region = eTrack.regions.list[track_id];
|
var region = wavesurfer["t<?php echo $this->id; ?>"].regions.list[<?php echo $this->id; ?>];
|
||||||
region.update({end: val});
|
region.update({end: val});
|
||||||
document.getElementsByClassName("cueout_"+track_id)[0].value = toHHMMSS(region.end);
|
document.getElementsByClassName("cueout_<?php echo $this->id; ?>")[0].value = toHHMMSS(region.end);
|
||||||
$('#track-playedit-'+track_id).attr('onClick', 'wavesurfer["t'+ track_id +'"].play('+ region.start +', '+ region.end +');');
|
$('#track-playedit-<?php echo $this->id; ?>').attr('onClick', 'wavesurfer["t'+ <?php echo $this->id; ?> +'"].play('+ region.start +', '+ region.end +');');
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
</script>
|
</script>
|
||||||
|
|
|
@ -4363,44 +4363,19 @@ body.droppable .artwork-upload .artwork-preview {
|
||||||
width: 480px;
|
width: 480px;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* -webkit-appearance: none;
|
.visual-waveform-editor textarea,
|
||||||
-moz-appearance: none;
|
.visual-waveform-editor input,
|
||||||
-ms-appearance: none;
|
.visual-waveform-editor input:focus,
|
||||||
appearance: none; */
|
.visual-waveform-editor select:focus,
|
||||||
textarea,
|
.visual-waveform-editor textarea:focus,
|
||||||
input {
|
.visual-waveform-editor button:focus {
|
||||||
outline: none;
|
outline: none;
|
||||||
}
|
} */
|
||||||
|
|
||||||
input:focus,
|
.visual-waveform-editor li {
|
||||||
select:focus,
|
|
||||||
textarea:focus,
|
|
||||||
button:focus {
|
|
||||||
outline: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.navtt {
|
|
||||||
margin-bottom: 18px;
|
|
||||||
margin-left: 0;
|
|
||||||
list-style: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.navtt > li > a {
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
|
|
||||||
li {
|
|
||||||
line-height: 18px;
|
line-height: 18px;
|
||||||
}
|
}
|
||||||
|
|
||||||
.navtt-content.active {
|
|
||||||
display: block;
|
|
||||||
}
|
|
||||||
|
|
||||||
.navtt-content.hide {
|
|
||||||
display: none;
|
|
||||||
}
|
|
||||||
|
|
||||||
.btn-control-player {
|
.btn-control-player {
|
||||||
padding: 5px 7px 5px 10px;
|
padding: 5px 7px 5px 10px;
|
||||||
font-size: 14px;
|
font-size: 14px;
|
||||||
|
|
|
@ -1,449 +0,0 @@
|
||||||
'use strict';
|
|
||||||
|
|
||||||
var WaveformDrawer = function() {
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
WaveformDrawer.prototype.init = function(container, config) {
|
|
||||||
|
|
||||||
makePublisher(this);
|
|
||||||
|
|
||||||
this.config = config;
|
|
||||||
this.container = container;
|
|
||||||
this.channels = []; //array of canvases, contexts, 1 for each channel displayed.
|
|
||||||
|
|
||||||
var theme = this.config.getUITheme();
|
|
||||||
|
|
||||||
if (this.loaderStates[theme] !== undefined) {
|
|
||||||
this.loaderStates = this.loaderStates[theme];
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
this.loaderStates = this.loaderStates["default"];
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
WaveformDrawer.prototype.loaderStates = {
|
|
||||||
"bootstrap": {
|
|
||||||
"downloading": "progress progress-warning",
|
|
||||||
"decoding": "progress progress-success progress-striped active",
|
|
||||||
"loader": "bar"
|
|
||||||
},
|
|
||||||
|
|
||||||
"jQueryUI": {
|
|
||||||
"downloading": "ui-progressbar ui-widget ui-widget-content ui-corner-all",
|
|
||||||
"decoding": "ui-progressbar ui-widget ui-widget-content ui-corner-all",
|
|
||||||
"loader": "ui-progressbar-value ui-widget-header ui-corner-left"
|
|
||||||
},
|
|
||||||
|
|
||||||
"default": {
|
|
||||||
"downloading": "progress",
|
|
||||||
"decoding": "decoding",
|
|
||||||
"loader": "bar"
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
WaveformDrawer.prototype.getPeaks = function(buffer, cues) {
|
|
||||||
|
|
||||||
// Frames per pixel
|
|
||||||
var res = this.config.getResolution(),
|
|
||||||
peaks = [],
|
|
||||||
i, c, p, l,
|
|
||||||
chanLength = cues.cueout - cues.cuein,
|
|
||||||
pixels = Math.ceil(chanLength / res),
|
|
||||||
numChan = buffer.numberOfChannels,
|
|
||||||
weight = 1 / (numChan),
|
|
||||||
makeMono = this.config.isDisplayMono(),
|
|
||||||
chan,
|
|
||||||
start,
|
|
||||||
end,
|
|
||||||
vals,
|
|
||||||
max,
|
|
||||||
min,
|
|
||||||
maxPeak = -Infinity; //used to scale the waveform on the canvas.
|
|
||||||
|
|
||||||
for (i = 0; i < pixels; i++) {
|
|
||||||
|
|
||||||
peaks[i] = [];
|
|
||||||
|
|
||||||
for (c = 0; c < numChan; c++) {
|
|
||||||
|
|
||||||
chan = buffer.getChannelData(c);
|
|
||||||
chan = chan.subarray(cues.cuein, cues.cueout);
|
|
||||||
|
|
||||||
start = i * res;
|
|
||||||
end = (i + 1) * res > chanLength ? chanLength : (i + 1) * res;
|
|
||||||
vals = chan.subarray(start, end);
|
|
||||||
max = -Infinity;
|
|
||||||
min = Infinity;
|
|
||||||
|
|
||||||
for (p = 0, l = vals.length; p < l; p++) {
|
|
||||||
if (vals[p] > max){
|
|
||||||
max = vals[p];
|
|
||||||
}
|
|
||||||
if (vals[p] < min){
|
|
||||||
min = vals[p];
|
|
||||||
}
|
|
||||||
}
|
|
||||||
peaks[i].push({max:max, min:min});
|
|
||||||
maxPeak = Math.max.apply(Math, [maxPeak, Math.abs(max), Math.abs(min)]);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (makeMono) {
|
|
||||||
max = min = 0;
|
|
||||||
|
|
||||||
for (c = 0 ; c < numChan; c++) {
|
|
||||||
max = max + weight * peaks[i][c].max;
|
|
||||||
min = min + weight * peaks[i][c].min;
|
|
||||||
}
|
|
||||||
|
|
||||||
peaks[i] = []; //need to clear out old stuff (maybe we should keep it for toggling views?).
|
|
||||||
peaks[i].push({max:max, min:min});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
this.maxPeak = maxPeak;
|
|
||||||
this.peaks = peaks;
|
|
||||||
};
|
|
||||||
|
|
||||||
WaveformDrawer.prototype.setTimeShift = function(pixels) {
|
|
||||||
var i, len;
|
|
||||||
|
|
||||||
for (i = 0, len = this.channels.length; i < len; i++) {
|
|
||||||
this.channels[i].div.style.left = pixels+"px";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
WaveformDrawer.prototype.updateLoader = function(percent) {
|
|
||||||
this.loader.style.width = percent+"%";
|
|
||||||
};
|
|
||||||
|
|
||||||
WaveformDrawer.prototype.setLoaderState = function(state) {
|
|
||||||
this.progressDiv.className = this.loaderStates[state];
|
|
||||||
};
|
|
||||||
|
|
||||||
WaveformDrawer.prototype.drawLoading = function() {
|
|
||||||
var div,
|
|
||||||
loader;
|
|
||||||
|
|
||||||
this.height = this.config.getWaveHeight();
|
|
||||||
|
|
||||||
div = document.createElement("div");
|
|
||||||
div.style.height = this.height+"px";
|
|
||||||
|
|
||||||
loader = document.createElement("div");
|
|
||||||
loader.style.height = "10px";
|
|
||||||
loader.className = this.loaderStates["loader"];
|
|
||||||
|
|
||||||
div.appendChild(loader);
|
|
||||||
|
|
||||||
this.progressDiv = div;
|
|
||||||
this.loader = loader;
|
|
||||||
|
|
||||||
this.setLoaderState("downloading");
|
|
||||||
this.updateLoader(0);
|
|
||||||
|
|
||||||
this.container.appendChild(div);
|
|
||||||
};
|
|
||||||
|
|
||||||
WaveformDrawer.prototype.drawBuffer = function(buffer, pixelOffset, cues) {
|
|
||||||
var canv,
|
|
||||||
div,
|
|
||||||
i,
|
|
||||||
top = 0,
|
|
||||||
left = 0,
|
|
||||||
makeMono = this.config.isDisplayMono(),
|
|
||||||
res = this.config.getResolution(),
|
|
||||||
numChan = makeMono? 1 : buffer.numberOfChannels,
|
|
||||||
numSamples = cues.cueout - cues.cuein + 1,
|
|
||||||
fragment = document.createDocumentFragment(),
|
|
||||||
wrapperHeight;
|
|
||||||
|
|
||||||
this.container.innerHTML = "";
|
|
||||||
this.channels = [];
|
|
||||||
|
|
||||||
//width and height is per waveform canvas.
|
|
||||||
this.width = Math.ceil(numSamples / res);
|
|
||||||
this.height = this.config.getWaveHeight();
|
|
||||||
|
|
||||||
for (i = 0; i < numChan; i++) {
|
|
||||||
|
|
||||||
div = document.createElement("div");
|
|
||||||
div.classList.add("channel");
|
|
||||||
div.classList.add("channel-"+i);
|
|
||||||
div.style.width = this.width+"px";
|
|
||||||
div.style.height = this.height+"px";
|
|
||||||
div.style.top = top+"px";
|
|
||||||
div.style.left = left+"px";
|
|
||||||
|
|
||||||
canv = document.createElement("canvas");
|
|
||||||
canv.setAttribute('width', this.width);
|
|
||||||
canv.setAttribute('height', this.height);
|
|
||||||
|
|
||||||
this.channels.push({
|
|
||||||
canvas: canv,
|
|
||||||
context: canv.getContext('2d'),
|
|
||||||
div: div
|
|
||||||
});
|
|
||||||
|
|
||||||
div.appendChild(canv);
|
|
||||||
fragment.appendChild(div);
|
|
||||||
|
|
||||||
top = top + this.height;
|
|
||||||
}
|
|
||||||
|
|
||||||
wrapperHeight = numChan * this.height;
|
|
||||||
this.container.style.height = wrapperHeight+"px";
|
|
||||||
this.container.appendChild(fragment);
|
|
||||||
|
|
||||||
|
|
||||||
this.getPeaks(buffer, cues);
|
|
||||||
this.updateEditor();
|
|
||||||
|
|
||||||
this.setTimeShift(pixelOffset);
|
|
||||||
};
|
|
||||||
|
|
||||||
WaveformDrawer.prototype.drawFrame = function(chanNum, index, peaks, maxPeak, cursorPos, pixelOffset) {
|
|
||||||
var x, y, w, h, max, min,
|
|
||||||
h2 = this.height / 2,
|
|
||||||
cc = this.channels[chanNum].context,
|
|
||||||
colors = this.config.getColorScheme();
|
|
||||||
|
|
||||||
max = (peaks.max / maxPeak) * h2;
|
|
||||||
min = (peaks.min / maxPeak) * h2;
|
|
||||||
|
|
||||||
w = 1;
|
|
||||||
x = index * w;
|
|
||||||
y = Math.round(h2 - max);
|
|
||||||
h = Math.ceil(max - min);
|
|
||||||
|
|
||||||
//to prevent blank space when there is basically silence in the track.
|
|
||||||
h = h === 0 ? 1 : h;
|
|
||||||
|
|
||||||
if (cursorPos >= (x + pixelOffset)) {
|
|
||||||
cc.fillStyle = colors.progressColor;
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
cc.fillStyle = colors.waveColor;
|
|
||||||
}
|
|
||||||
|
|
||||||
cc.fillRect(x, y, w, h);
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
start, end are optional parameters to only redraw part of the canvas.
|
|
||||||
*/
|
|
||||||
WaveformDrawer.prototype.draw = function(cursorPos, pixelOffset, start, end) {
|
|
||||||
var that = this,
|
|
||||||
peaks = this.peaks,
|
|
||||||
i = (start) ? start - pixelOffset : 0,
|
|
||||||
len = (end) ? end - pixelOffset + 1 : peaks.length;
|
|
||||||
|
|
||||||
if (i < 0 && len < 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i < 0) {
|
|
||||||
i = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (len > peaks.length) {
|
|
||||||
len = peaks.length;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.clear(i, len);
|
|
||||||
|
|
||||||
for (; i < len; i++) {
|
|
||||||
|
|
||||||
peaks[i].forEach(function(peak, chanNum) {
|
|
||||||
that.drawFrame(chanNum, i, peak, that.maxPeak, cursorPos, pixelOffset);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
If start/end are set clear only part of the canvas.
|
|
||||||
*/
|
|
||||||
WaveformDrawer.prototype.clear = function(start, end) {
|
|
||||||
var i, len,
|
|
||||||
width = end - start;
|
|
||||||
|
|
||||||
for (i = 0, len = this.channels.length; i < len; i++) {
|
|
||||||
this.channels[i].context.clearRect(start, 0, width, this.height);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
WaveformDrawer.prototype.updateEditor = function(cursorPos, pixelOffset, start, end, highlighted, selected) {
|
|
||||||
var i, len,
|
|
||||||
fragment = document.createDocumentFragment();
|
|
||||||
|
|
||||||
this.container.innerHTML = "";
|
|
||||||
|
|
||||||
this.draw(cursorPos, pixelOffset, start, end);
|
|
||||||
|
|
||||||
if (highlighted === true && selected !== undefined) {
|
|
||||||
var border = (selected.end - selected.start === 0) ? true : false;
|
|
||||||
this.drawHighlight(selected.start, selected.end, border);
|
|
||||||
}
|
|
||||||
|
|
||||||
for (i = 0, len = this.channels.length; i < len; i++) {
|
|
||||||
fragment.appendChild(this.channels[i].div);
|
|
||||||
}
|
|
||||||
|
|
||||||
this.container.appendChild(fragment);
|
|
||||||
};
|
|
||||||
|
|
||||||
/*
|
|
||||||
start, end in pixels.
|
|
||||||
*/
|
|
||||||
WaveformDrawer.prototype.drawHighlight = function(start, end, isBorder) {
|
|
||||||
var i, len,
|
|
||||||
colors = this.config.getColorScheme(),
|
|
||||||
fillStyle,
|
|
||||||
ctx,
|
|
||||||
width = end - start + 1;
|
|
||||||
|
|
||||||
fillStyle = (isBorder) ? colors.selectBorderColor : colors.selectBackgroundColor;
|
|
||||||
|
|
||||||
for (i = 0, len = this.channels.length; i < len; i++) {
|
|
||||||
ctx = this.channels[i].context;
|
|
||||||
ctx.fillStyle = fillStyle;
|
|
||||||
ctx.fillRect(start, 0, width, this.height);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
WaveformDrawer.prototype.sCurveFadeIn = function sCurveFadeIn(ctx, width) {
|
|
||||||
return Curves.createSCurveBuffer(width, (Math.PI/2));
|
|
||||||
};
|
|
||||||
|
|
||||||
WaveformDrawer.prototype.sCurveFadeOut = function sCurveFadeOut(ctx, width) {
|
|
||||||
return Curves.createSCurveBuffer(width, -(Math.PI/2));
|
|
||||||
};
|
|
||||||
|
|
||||||
WaveformDrawer.prototype.logarithmicFadeIn = function logarithmicFadeIn(ctx, width) {
|
|
||||||
return Curves.createLogarithmicBuffer(width, 10, 1);
|
|
||||||
};
|
|
||||||
|
|
||||||
WaveformDrawer.prototype.logarithmicFadeOut = function logarithmicFadeOut(ctx, width) {
|
|
||||||
return Curves.createLogarithmicBuffer(width, 10, -1);
|
|
||||||
};
|
|
||||||
|
|
||||||
WaveformDrawer.prototype.exponentialFadeIn = function exponentialFadeIn(ctx, width) {
|
|
||||||
return Curves.createExponentialBuffer(width, 1);
|
|
||||||
};
|
|
||||||
|
|
||||||
WaveformDrawer.prototype.exponentialFadeOut = function exponentialFadeOut(ctx, width) {
|
|
||||||
return Curves.createExponentialBuffer(width, -1);
|
|
||||||
};
|
|
||||||
|
|
||||||
WaveformDrawer.prototype.linearFadeIn = function linearFadeIn(ctx, width) {
|
|
||||||
return Curves.createLinearBuffer(width, 1);
|
|
||||||
};
|
|
||||||
|
|
||||||
WaveformDrawer.prototype.linearFadeOut = function linearFadeOut(ctx, width) {
|
|
||||||
return Curves.createLinearBuffer(width, -1);
|
|
||||||
};
|
|
||||||
|
|
||||||
WaveformDrawer.prototype.drawFadeCurve = function(ctx, shape, type, width) {
|
|
||||||
var method = shape+type,
|
|
||||||
fn = this[method],
|
|
||||||
colors = this.config.getColorScheme(),
|
|
||||||
curve,
|
|
||||||
i, len,
|
|
||||||
cHeight = this.height,
|
|
||||||
y;
|
|
||||||
|
|
||||||
ctx.strokeStyle = colors.fadeColor;
|
|
||||||
|
|
||||||
curve = fn.call(this, ctx, width);
|
|
||||||
|
|
||||||
y = cHeight - curve[0] * cHeight;
|
|
||||||
ctx.beginPath();
|
|
||||||
ctx.moveTo(0, y);
|
|
||||||
|
|
||||||
for (i = 1, len = curve.length; i < len; i++) {
|
|
||||||
y = cHeight - curve[i] * cHeight;
|
|
||||||
ctx.lineTo(i, y);
|
|
||||||
}
|
|
||||||
ctx.stroke();
|
|
||||||
};
|
|
||||||
|
|
||||||
WaveformDrawer.prototype.removeFade = function(id) {
|
|
||||||
var fadeClass = "playlist-fade-"+id,
|
|
||||||
el, els,
|
|
||||||
i,len;
|
|
||||||
|
|
||||||
els = this.container.getElementsByClassName(fadeClass);
|
|
||||||
len = els.length;
|
|
||||||
|
|
||||||
//DOM NodeList is live, use a decrementing counter.
|
|
||||||
if (len > 0) {
|
|
||||||
for (i = len-1; i >= 0; i--) {
|
|
||||||
el = els[i];
|
|
||||||
el.parentNode.removeChild(el);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
WaveformDrawer.prototype.drawFade = function(id, type, shape, start, end) {
|
|
||||||
var div,
|
|
||||||
canv,
|
|
||||||
width,
|
|
||||||
left,
|
|
||||||
fragment = document.createDocumentFragment(),
|
|
||||||
i, len,
|
|
||||||
dup,
|
|
||||||
ctx,
|
|
||||||
tmpCtx;
|
|
||||||
|
|
||||||
if ((end - start) === 0) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
width = ~~(end - start + 1);
|
|
||||||
left = start;
|
|
||||||
|
|
||||||
div = document.createElement("div");
|
|
||||||
div.classList.add("playlist-fade");
|
|
||||||
div.classList.add("playlist-fade-"+id);
|
|
||||||
div.style.width = width+"px";
|
|
||||||
div.style.height = this.height+"px";
|
|
||||||
div.style.top = 0;
|
|
||||||
div.style.left = left+"px";
|
|
||||||
|
|
||||||
canv = document.createElement("canvas");
|
|
||||||
canv.setAttribute('width', width);
|
|
||||||
canv.setAttribute('height', this.height);
|
|
||||||
ctx = canv.getContext('2d');
|
|
||||||
|
|
||||||
this.drawFadeCurve(ctx, shape, type, width);
|
|
||||||
|
|
||||||
div.appendChild(canv);
|
|
||||||
fragment.appendChild(div);
|
|
||||||
|
|
||||||
for (i = 0, len = this.channels.length; i < len; i++) {
|
|
||||||
dup = fragment.cloneNode(true);
|
|
||||||
tmpCtx = dup.querySelector('canvas').getContext('2d');
|
|
||||||
tmpCtx.drawImage(canv, 0, 0);
|
|
||||||
|
|
||||||
this.channels[i].div.appendChild(dup);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
WaveformDrawer.prototype.drawFades = function(fades) {
|
|
||||||
var id,
|
|
||||||
fade,
|
|
||||||
startPix,
|
|
||||||
endPix,
|
|
||||||
SR = this.config.getSampleRate(),
|
|
||||||
res = this.config.getResolution();
|
|
||||||
|
|
||||||
for (id in fades) {
|
|
||||||
fade = fades[id];
|
|
||||||
|
|
||||||
if (fades.hasOwnProperty(id)) {
|
|
||||||
startPix = fade.start * SR / res;
|
|
||||||
endPix = fade.end * SR / res;
|
|
||||||
this.drawFade(id, fade.type, fade.shape, startPix, endPix);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
};
|
|
|
@ -4,19 +4,14 @@ var wavesurfer = [];
|
||||||
|
|
||||||
window.addEventListener("load",()=>{
|
window.addEventListener("load",()=>{
|
||||||
let op=window.inputKnobsOptions||{};
|
let op=window.inputKnobsOptions||{};
|
||||||
op.knobWidth=op.knobWidth||op.knobDiameter||64;
|
|
||||||
op.knobHeight=op.knobHeight||op.knobDiameter||64;
|
|
||||||
op.sliderWidth=op.sliderWidth||op.sliderDiameter||128;
|
op.sliderWidth=op.sliderWidth||op.sliderDiameter||128;
|
||||||
op.sliderHeight=op.sliderHeight||op.sliderDiameter||20;
|
op.sliderHeight=op.sliderHeight||op.sliderDiameter||20;
|
||||||
op.switchWidth=op.switchWidth||op.switchDiameter||24;
|
|
||||||
op.switchHeight=op.switchHeight||op.switchDiameter||24;
|
|
||||||
op.fgcolor=op.fgcolor||"#f00";
|
op.fgcolor=op.fgcolor||"#f00";
|
||||||
op.bgcolor=op.bgcolor||"#000";
|
op.bgcolor=op.bgcolor||"#000";
|
||||||
op.knobMode=op.knobMode||"linear";
|
|
||||||
op.sliderMode=op.sliderMode||"relative";
|
op.sliderMode=op.sliderMode||"relative";
|
||||||
let styles=document.createElement("style");
|
let styles=document.createElement("style");
|
||||||
styles.innerHTML=
|
styles.innerHTML=
|
||||||
`input[type=range].input-knob,input[type=range].input-slider{
|
`input[type=range].input-slider{
|
||||||
-webkit-appearance:none;
|
-webkit-appearance:none;
|
||||||
-moz-appearance:none;
|
-moz-appearance:none;
|
||||||
border:none;
|
border:none;
|
||||||
|
@ -28,52 +23,24 @@ window.addEventListener("load",()=>{
|
||||||
background-color:transparent;
|
background-color:transparent;
|
||||||
touch-action:none;
|
touch-action:none;
|
||||||
}
|
}
|
||||||
input[type=range].input-knob{
|
|
||||||
width:${op.knobWidth}px; height:${op.knobHeight}px;
|
|
||||||
}
|
|
||||||
input[type=range].input-slider{
|
input[type=range].input-slider{
|
||||||
width:${op.sliderWidth}px; height:${op.sliderHeight}px;
|
width:${op.sliderWidth}px; height:${op.sliderHeight}px;
|
||||||
}
|
}
|
||||||
input[type=range].input-knob::-webkit-slider-thumb,input[type=range].input-slider::-webkit-slider-thumb{
|
input[type=range].input-slider::-webkit-slider-thumb{
|
||||||
-webkit-appearance:none;
|
-webkit-appearance:none;
|
||||||
opacity:0;
|
opacity:0;
|
||||||
}
|
}
|
||||||
input[type=range].input-knob::-moz-range-thumb,input[type=range].input-slider::-moz-range-thumb{
|
input[type=range].input-slider::-moz-range-thumb{
|
||||||
-moz-appearance:none;
|
-moz-appearance:none;
|
||||||
height:0;
|
height:0;
|
||||||
border:none;
|
border:none;
|
||||||
}
|
}
|
||||||
input[type=range].input-knob::-moz-range-track,input[type=range].input-slider::-moz-range-track{
|
input[type=range].input-slider::-moz-range-track{
|
||||||
-moz-appearance:none;
|
-moz-appearance:none;
|
||||||
height:0;
|
height:0;
|
||||||
border:none;
|
border:none;
|
||||||
}
|
|
||||||
input[type=checkbox].input-switch,input[type=radio].input-switch {
|
|
||||||
width:${op.switchWidth}px;
|
|
||||||
height:${op.switchHeight}px;
|
|
||||||
-webkit-appearance:none;
|
|
||||||
-moz-appearance:none;
|
|
||||||
background-size:100% 200%;
|
|
||||||
background-position:0% 0%;
|
|
||||||
background-repeat:no-repeat;
|
|
||||||
border:none;
|
|
||||||
border-radius:0;
|
|
||||||
background-color:transparent;
|
|
||||||
}
|
|
||||||
input[type=checkbox].input-switch:checked,input[type=radio].input-switch:checked {
|
|
||||||
background-position:0% 100%;
|
|
||||||
}`;
|
}`;
|
||||||
document.head.appendChild(styles);
|
document.head.appendChild(styles);
|
||||||
let makeKnobFrames=(fr,fg,bg)=>{
|
|
||||||
let r=
|
|
||||||
`<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="64" height="${fr*64}" viewBox="0 0 64 ${fr*64}" preserveAspectRatio="none">
|
|
||||||
<defs><g id="K"><circle cx="32" cy="32" r="30" fill="${bg}"/>
|
|
||||||
<line x1="32" y1="28" x2="32" y2="7" stroke-linecap="round" stroke-width="6" stroke="${fg}"/></g></defs>
|
|
||||||
<use xlink:href="#K" transform="rotate(-135,32,32)"/>`;
|
|
||||||
for(let i=1;i<fr;++i)
|
|
||||||
r+=`<use xlink:href="#K" transform="translate(0,${64*i}) rotate(${-135+270*i/fr},32,32)"/>`;
|
|
||||||
return r+"</svg>";
|
|
||||||
}
|
|
||||||
let makeHSliderFrames=(fr,fg,bg,w,h)=>{
|
let makeHSliderFrames=(fr,fg,bg,w,h)=>{
|
||||||
let r=
|
let r=
|
||||||
`<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="${w}" height="${fr*h}" viewBox="0 0 ${w} ${fr*h}" preserveAspectRatio="none">
|
`<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="${w}" height="${fr*h}" viewBox="0 0 ${w} ${fr*h}" preserveAspectRatio="none">
|
||||||
|
@ -85,46 +52,6 @@ input[type=checkbox].input-switch:checked,input[type=radio].input-switch:checked
|
||||||
}
|
}
|
||||||
return r+"</svg>";
|
return r+"</svg>";
|
||||||
}
|
}
|
||||||
let makeVSliderFrames=(fr,fg,bg,w,h)=>{
|
|
||||||
let r=
|
|
||||||
`<svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" width="${w}" height="${fr*h}" viewBox="0 0 ${w} ${fr*h}" preserveAspectRatio="none">
|
|
||||||
<defs><rect id="B" x="0" y="0" width="${w}" height="${h}" rx="${w/2}" ry="${w/2}" fill="${bg}"/>
|
|
||||||
<circle id="K" x="0" y="0" r="${w/2*0.9}" fill="${fg}"/></defs>`;
|
|
||||||
for(let i=0;i<fr;++i){
|
|
||||||
r+=`<use xlink:href="#B" transform="translate(0,${h*i})"/>`;
|
|
||||||
r+=`<use xlink:href="#K" transform="translate(${w/2} ${h*(i+1)-w/2-i*(h-w)/100})"/>`;
|
|
||||||
}
|
|
||||||
return r+"</svg>";
|
|
||||||
}
|
|
||||||
let initSwitches=(el)=>{
|
|
||||||
let w,h,d,fg,bg;
|
|
||||||
if(el.inputKnobs)
|
|
||||||
return;
|
|
||||||
el.inputKnobs={};
|
|
||||||
el.refresh=()=>{
|
|
||||||
let src=el.getAttribute("data-src");
|
|
||||||
d=+el.getAttribute("data-diameter");
|
|
||||||
let st=document.defaultView.getComputedStyle(el,null);
|
|
||||||
w=parseFloat(el.getAttribute("data-width")||d||st.width);
|
|
||||||
h=parseFloat(el.getAttribute("data-height")||d||st.height);
|
|
||||||
bg=el.getAttribute("data-bgcolor")||op.bgcolor;
|
|
||||||
fg=el.getAttribute("data-fgcolor")||op.fgcolor;
|
|
||||||
el.style.width=w+"px";
|
|
||||||
el.style.height=h+"px";
|
|
||||||
if(src)
|
|
||||||
el.style.backgroundImage="url("+src+")";
|
|
||||||
else {
|
|
||||||
let minwh=Math.min(w,h);
|
|
||||||
let svg=
|
|
||||||
`<svg xmlns="http://www.w3.org/2000/svg" width="${w}" height="${h*2}" viewBox="0 0 ${w} ${h*2}" preserveAspectRatio="none">
|
|
||||||
<g><rect fill="${bg}" x="1" y="1" width="${w-2}" height="${h-2}" rx="${minwh*0.25}" ry="${minwh*0.25}"/>
|
|
||||||
<rect fill="${bg}" x="1" y="${h+1}" width="${w-2}" height="${h-2}" rx="${minwh*0.25}" ry="${minwh*0.25}"/>
|
|
||||||
<circle fill="${fg}" cx="${w*0.5}" cy="${h*1.5}" r="${minwh*0.25}"/></g></svg>`;
|
|
||||||
el.style.backgroundImage="url(data:image/svg+xml;base64,"+btoa(svg)+")";
|
|
||||||
}
|
|
||||||
};
|
|
||||||
el.refresh();
|
|
||||||
};
|
|
||||||
let initKnobs=(el)=>{
|
let initKnobs=(el)=>{
|
||||||
let w,h,d,fg,bg;
|
let w,h,d,fg,bg;
|
||||||
if(el.inputKnobs){
|
if(el.inputKnobs){
|
||||||
|
@ -140,22 +67,9 @@ input[type=checkbox].input-switch:checked,input[type=radio].input-switch:checked
|
||||||
bg=el.getAttribute("data-bgcolor")||op.bgcolor;
|
bg=el.getAttribute("data-bgcolor")||op.bgcolor;
|
||||||
fg=el.getAttribute("data-fgcolor")||op.fgcolor;
|
fg=el.getAttribute("data-fgcolor")||op.fgcolor;
|
||||||
ik.sensex=ik.sensey=200;
|
ik.sensex=ik.sensey=200;
|
||||||
if(el.className.indexOf("input-knob")>=0)
|
ik.sensex=w-h;
|
||||||
ik.itype="k";
|
ik.sensey=Infinity;
|
||||||
else{
|
el.style.backgroundSize="auto 100%";
|
||||||
if(w>=h){
|
|
||||||
ik.itype="h";
|
|
||||||
ik.sensex=w-h;
|
|
||||||
ik.sensey=Infinity;
|
|
||||||
el.style.backgroundSize="auto 100%";
|
|
||||||
}
|
|
||||||
else{
|
|
||||||
ik.itype="v";
|
|
||||||
ik.sensex="Infinity";
|
|
||||||
ik.sensey=h-w;
|
|
||||||
el.style.backgroundSize="100% auto";
|
|
||||||
}
|
|
||||||
}
|
|
||||||
el.style.width=w+"px";
|
el.style.width=w+"px";
|
||||||
el.style.height=h+"px";
|
el.style.height=h+"px";
|
||||||
ik.frameheight=h;
|
ik.frameheight=h;
|
||||||
|
@ -169,18 +83,11 @@ input[type=checkbox].input-switch:checked,input[type=radio].input-switch:checked
|
||||||
ik.sprites=0;
|
ik.sprites=0;
|
||||||
if(ik.sprites>=1)
|
if(ik.sprites>=1)
|
||||||
el.style.backgroundSize=`100% ${(ik.sprites+1)*100}%`;
|
el.style.backgroundSize=`100% ${(ik.sprites+1)*100}%`;
|
||||||
else if(ik.itype!="k"){
|
el.style.backgroundColor=bg;
|
||||||
el.style.backgroundColor=bg;
|
el.style.borderRadius=Math.min(w,h)*0.25+"px";
|
||||||
el.style.borderRadius=Math.min(w,h)*0.25+"px";
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else{
|
else{
|
||||||
let svg;
|
let svg=makeHSliderFrames(101,fg,bg,w,h);
|
||||||
switch(ik.itype){
|
|
||||||
case "k": svg=makeKnobFrames(101,fg,bg); break;
|
|
||||||
case "h": svg=makeHSliderFrames(101,fg,bg,w,h); break;
|
|
||||||
case "v": svg=makeVSliderFrames(101,fg,bg,w,h); break;
|
|
||||||
}
|
|
||||||
ik.sprites=100;
|
ik.sprites=100;
|
||||||
el.style.backgroundImage="url(data:image/svg+xml;base64,"+btoa(svg)+")";
|
el.style.backgroundImage="url(data:image/svg+xml;base64,"+btoa(svg)+")";
|
||||||
el.style.backgroundSize=`100% ${(ik.sprites+1)*100}%`;
|
el.style.backgroundSize=`100% ${(ik.sprites+1)*100}%`;
|
||||||
|
@ -209,12 +116,7 @@ input[type=checkbox].input-switch:checked,input[type=radio].input-switch:checked
|
||||||
let rc=el.getBoundingClientRect();
|
let rc=el.getBoundingClientRect();
|
||||||
let cx=(rc.left+rc.right)*0.5,cy=(rc.top+rc.bottom)*0.5;
|
let cx=(rc.left+rc.right)*0.5,cy=(rc.top+rc.bottom)*0.5;
|
||||||
let dx=ev.clientX,dy=ev.clientY;
|
let dx=ev.clientX,dy=ev.clientY;
|
||||||
let da=Math.atan2(ev.clientX-cx,cy-ev.clientY);
|
if(op.sliderMode=="abs"){
|
||||||
if(ik.itype=="k"&&op.knobMode=="circularabs"){
|
|
||||||
dv=ik.valrange.min+(da/Math.PI*0.75+0.5)*(ik.valrange.max-ik.valrange.min);
|
|
||||||
el.setValue(dv);
|
|
||||||
}
|
|
||||||
if(ik.itype!="k"&&op.sliderMode=="abs"){
|
|
||||||
dv=(ik.valrange.min+ik.valrange.max)*0.5+((dx-cx)/ik.sensex-(dy-cy)/ik.sensey)*(ik.valrange.max-ik.valrange.min);
|
dv=(ik.valrange.min+ik.valrange.max)*0.5+((dx-cx)/ik.sensex-(dy-cy)/ik.sensey)*(ik.valrange.max-ik.valrange.min);
|
||||||
el.setValue(dv);
|
el.setValue(dv);
|
||||||
}
|
}
|
||||||
|
@ -235,40 +137,10 @@ input[type=checkbox].input-switch:checked,input[type=radio].input-switch:checked
|
||||||
if(ev.touches)
|
if(ev.touches)
|
||||||
ev = ev.touches[0];
|
ev = ev.touches[0];
|
||||||
let dx=ev.clientX-ik.dragfrom.x,dy=ev.clientY-ik.dragfrom.y;
|
let dx=ev.clientX-ik.dragfrom.x,dy=ev.clientY-ik.dragfrom.y;
|
||||||
let da=Math.atan2(ev.clientX-cx,cy-ev.clientY);
|
dv=(dx/ik.sensex-dy/ik.sensey)*(ik.valrange.max-ik.valrange.min);
|
||||||
switch(ik.itype){
|
if(ev.shiftKey)
|
||||||
case "k":
|
dv*=0.2;
|
||||||
switch(op.knobMode){
|
el.setValue(ik.dragfrom.v+dv);
|
||||||
case "linear":
|
|
||||||
dv=(dx/ik.sensex-dy/ik.sensey)*(ik.valrange.max-ik.valrange.min);
|
|
||||||
if(ev.shiftKey)
|
|
||||||
dv*=0.2;
|
|
||||||
el.setValue(ik.dragfrom.v+dv);
|
|
||||||
break;
|
|
||||||
case "circularabs":
|
|
||||||
if(!ev.shiftKey){
|
|
||||||
dv=ik.valrange.min+(da/Math.PI*0.75+0.5)*(ik.valrange.max-ik.valrange.min);
|
|
||||||
el.setValue(dv);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
case "circularrel":
|
|
||||||
if(da>ik.dragfrom.a+Math.PI) da-=Math.PI*2;
|
|
||||||
if(da<ik.dragfrom.a-Math.PI) da+=Math.PI*2;
|
|
||||||
da-=ik.dragfrom.a;
|
|
||||||
dv=da/Math.PI/1.5*(ik.valrange.max-ik.valrange.min);
|
|
||||||
if(ev.shiftKey)
|
|
||||||
dv*=0.2;
|
|
||||||
el.setValue(ik.dragfrom.v+dv);
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case "h":
|
|
||||||
case "v":
|
|
||||||
dv=(dx/ik.sensex-dy/ik.sensey)*(ik.valrange.max-ik.valrange.min);
|
|
||||||
if(ev.shiftKey)
|
|
||||||
dv*=0.2;
|
|
||||||
el.setValue(ik.dragfrom.v+dv);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
};
|
};
|
||||||
ik.pointerup=()=>{
|
ik.pointerup=()=>{
|
||||||
document.removeEventListener("mousemove",ik.pointermove);
|
document.removeEventListener("mousemove",ik.pointermove);
|
||||||
|
@ -300,19 +172,8 @@ input[type=checkbox].input-switch:checked,input[type=radio].input-switch:checked
|
||||||
let v=(el.value-ik.valrange.min)/(ik.valrange.max-ik.valrange.min);
|
let v=(el.value-ik.valrange.min)/(ik.valrange.max-ik.valrange.min);
|
||||||
if(ik.sprites>=1)
|
if(ik.sprites>=1)
|
||||||
el.style.backgroundPosition="0px "+(-((v*ik.sprites)|0)*ik.frameheight)+"px";
|
el.style.backgroundPosition="0px "+(-((v*ik.sprites)|0)*ik.frameheight)+"px";
|
||||||
else{
|
else
|
||||||
switch(ik.itype){
|
el.style.backgroundPosition=((w-h)*v)+"px 0px";
|
||||||
case "k":
|
|
||||||
el.style.transform="rotate("+(270*v-135)+"deg)";
|
|
||||||
break;
|
|
||||||
case "h":
|
|
||||||
el.style.backgroundPosition=((w-h)*v)+"px 0px";
|
|
||||||
break;
|
|
||||||
case "v":
|
|
||||||
el.style.backgroundPosition="0px "+(h-w)*(1-v)+"px";
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
ik.valueold=el.value;
|
ik.valueold=el.value;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
@ -325,13 +186,9 @@ input[type=checkbox].input-switch:checked,input[type=radio].input-switch:checked
|
||||||
el.addEventListener("click",function (event){ event.stopPropagation(); });
|
el.addEventListener("click",function (event){ event.stopPropagation(); });
|
||||||
}
|
}
|
||||||
let refreshque=()=>{
|
let refreshque=()=>{
|
||||||
let elem=document.querySelectorAll("input.input-knob,input.input-slider");
|
let elem=document.querySelectorAll("input.input-slider");
|
||||||
for(let i=0;i<elem.length;++i)
|
for(let i=0;i<elem.length;++i)
|
||||||
procque.push([initKnobs,elem[i]]);
|
procque.push([initKnobs,elem[i]]);
|
||||||
elem=document.querySelectorAll("input[type=checkbox].input-switch,input[type=radio].input-switch");
|
|
||||||
for(let i=0;i<elem.length;++i){
|
|
||||||
procque.push([initSwitches,elem[i]]);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
let procque=[];
|
let procque=[];
|
||||||
refreshque();
|
refreshque();
|
||||||
|
@ -497,7 +354,7 @@ function secondaryLabelInterval(pxPerSec) {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
function renderWaveform(track_id, selector_id, url, cuein, cueout, gain_level, default_gain) {
|
function renderWaveform(track_id, selector_id, url, cuein, cueout) {
|
||||||
|
|
||||||
var trackid = "t"+track_id;
|
var trackid = "t"+track_id;
|
||||||
var a = cuein.split(':'); // split it at the colons
|
var a = cuein.split(':'); // split it at the colons
|
||||||
|
@ -613,15 +470,5 @@ function renderWaveform(track_id, selector_id, url, cuein, cueout, gain_level, d
|
||||||
//Volume to Gain deciSteps(gainNum(gain_level))
|
//Volume to Gain deciSteps(gainNum(gain_level))
|
||||||
eTrack.setVolume(0.6);
|
eTrack.setVolume(0.6);
|
||||||
|
|
||||||
document.querySelector("#volume-"+ track_id).value = eTrack.getVolume();
|
|
||||||
|
|
||||||
var volumeInput = document.querySelector("#volume-"+ track_id);
|
|
||||||
|
|
||||||
var onChangeVolume = function (e) {
|
|
||||||
//eTrack.setVolume(e.target.value);
|
|
||||||
};
|
|
||||||
volumeInput.addEventListener('input', onChangeVolume);
|
|
||||||
volumeInput.addEventListener('change', onChangeVolume);
|
|
||||||
|
|
||||||
return eTrack;
|
return eTrack;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,424 +0,0 @@
|
||||||
/*!
|
|
||||||
* wavesurfer.js minimap plugin 4.6.0 (2024-02-05)
|
|
||||||
* https://wavesurfer-js.org
|
|
||||||
* @license BSD-3-Clause
|
|
||||||
*/
|
|
||||||
(function webpackUniversalModuleDefinition(root, factory) {
|
|
||||||
if(typeof exports === 'object' && typeof module === 'object')
|
|
||||||
module.exports = factory();
|
|
||||||
else if(typeof define === 'function' && define.amd)
|
|
||||||
define("WaveSurfer", [], factory);
|
|
||||||
else if(typeof exports === 'object')
|
|
||||||
exports["WaveSurfer"] = factory();
|
|
||||||
else
|
|
||||||
root["WaveSurfer"] = root["WaveSurfer"] || {}, root["WaveSurfer"]["minimap"] = factory();
|
|
||||||
})(this, () => {
|
|
||||||
return /******/ (() => { // webpackBootstrap
|
|
||||||
/******/ "use strict";
|
|
||||||
/******/ var __webpack_modules__ = ({
|
|
||||||
|
|
||||||
/***/ "./src/plugin/minimap/index.js":
|
|
||||||
/*!*************************************!*\
|
|
||||||
!*** ./src/plugin/minimap/index.js ***!
|
|
||||||
\*************************************/
|
|
||||||
/***/ ((module, exports) => {
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Object.defineProperty(exports, "__esModule", ({
|
|
||||||
value: true
|
|
||||||
}));
|
|
||||||
exports["default"] = void 0;
|
|
||||||
function _typeof(o) { "@babel/helpers - typeof"; return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function (o) { return typeof o; } : function (o) { return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o; }, _typeof(o); }
|
|
||||||
function _classCallCheck(instance, Constructor) { if (!(instance instanceof Constructor)) { throw new TypeError("Cannot call a class as a function"); } }
|
|
||||||
function _defineProperties(target, props) { for (var i = 0; i < props.length; i++) { var descriptor = props[i]; descriptor.enumerable = descriptor.enumerable || false; descriptor.configurable = true; if ("value" in descriptor) descriptor.writable = true; Object.defineProperty(target, _toPropertyKey(descriptor.key), descriptor); } }
|
|
||||||
function _createClass(Constructor, protoProps, staticProps) { if (protoProps) _defineProperties(Constructor.prototype, protoProps); if (staticProps) _defineProperties(Constructor, staticProps); Object.defineProperty(Constructor, "prototype", { writable: false }); return Constructor; }
|
|
||||||
function _toPropertyKey(t) { var i = _toPrimitive(t, "string"); return "symbol" == _typeof(i) ? i : String(i); }
|
|
||||||
function _toPrimitive(t, r) { if ("object" != _typeof(t) || !t) return t; var e = t[Symbol.toPrimitive]; if (void 0 !== e) { var i = e.call(t, r || "default"); if ("object" != _typeof(i)) return i; throw new TypeError("@@toPrimitive must return a primitive value."); } return ("string" === r ? String : Number)(t); }
|
|
||||||
/*eslint no-console: ["error", { allow: ["warn"] }] */
|
|
||||||
/**
|
|
||||||
* @typedef {Object} MinimapPluginParams
|
|
||||||
* @desc Extends the `WavesurferParams` wavesurfer was initialised with
|
|
||||||
* @property {?string|HTMLElement} container CSS selector or HTML element where
|
|
||||||
* the map should be rendered. By default it is simply appended
|
|
||||||
* after the waveform.
|
|
||||||
* @property {?boolean} deferInit Set to true to manually call
|
|
||||||
* `initPlugin('minimap')`
|
|
||||||
*/
|
|
||||||
/**
|
|
||||||
* Renders a smaller version waveform as a minimap of the main waveform.
|
|
||||||
*
|
|
||||||
* @implements {PluginClass}
|
|
||||||
* @extends {Observer}
|
|
||||||
* @example
|
|
||||||
* // es6
|
|
||||||
* import MinimapPlugin from 'wavesurfer.minimap.js';
|
|
||||||
*
|
|
||||||
* // commonjs
|
|
||||||
* var MinimapPlugin = require('wavesurfer.minimap.js');
|
|
||||||
*
|
|
||||||
* // if you are using <script> tags
|
|
||||||
* var MinimapPlugin = window.WaveSurfer.minimap;
|
|
||||||
*
|
|
||||||
* // ... initialising wavesurfer with the plugin
|
|
||||||
* var wavesurfer = WaveSurfer.create({
|
|
||||||
* // wavesurfer options ...
|
|
||||||
* plugins: [
|
|
||||||
* MinimapPlugin.create({
|
|
||||||
* // plugin options ...
|
|
||||||
* })
|
|
||||||
* ]
|
|
||||||
* });
|
|
||||||
*/
|
|
||||||
var MinimapPlugin = exports["default"] = /*#__PURE__*/function () {
|
|
||||||
function MinimapPlugin(params, ws) {
|
|
||||||
var _this = this;
|
|
||||||
_classCallCheck(this, MinimapPlugin);
|
|
||||||
this.params = Object.assign({}, ws.params, {
|
|
||||||
showRegions: false,
|
|
||||||
regionsPluginName: params.regionsPluginName || 'regions',
|
|
||||||
showOverview: false,
|
|
||||||
overviewBorderColor: 'green',
|
|
||||||
overviewBorderSize: 2,
|
|
||||||
// the container should be different
|
|
||||||
container: false,
|
|
||||||
height: Math.max(Math.round(ws.params.height / 4), 20)
|
|
||||||
}, params, {
|
|
||||||
scrollParent: false,
|
|
||||||
fillParent: true
|
|
||||||
});
|
|
||||||
// if container is a selector, get the element
|
|
||||||
if (typeof params.container === 'string') {
|
|
||||||
var el = document.querySelector(params.container);
|
|
||||||
if (!el) {
|
|
||||||
console.warn("Wavesurfer minimap container ".concat(params.container, " was not found! The minimap will be automatically appended below the waveform."));
|
|
||||||
}
|
|
||||||
this.params.container = el;
|
|
||||||
}
|
|
||||||
// if no container is specified add a new element and insert it
|
|
||||||
if (!params.container) {
|
|
||||||
this.params.container = ws.util.style(document.createElement('minimap'), {
|
|
||||||
display: 'block'
|
|
||||||
});
|
|
||||||
}
|
|
||||||
this.drawer = new ws.Drawer(this.params.container, this.params);
|
|
||||||
this.wavesurfer = ws;
|
|
||||||
this.util = ws.util;
|
|
||||||
/**
|
|
||||||
* Minimap needs to listen for the `ready` and `waveform-ready` events
|
|
||||||
* to work with the `MediaElement` backend. The moment the `ready` event
|
|
||||||
* is called is different (and peaks would not load).
|
|
||||||
*
|
|
||||||
* @type {string}
|
|
||||||
* @see https://github.com/katspaugh/wavesurfer.js/issues/736
|
|
||||||
*/
|
|
||||||
this.renderEvent = ws.params.backend === 'MediaElement' ? 'waveform-ready' : 'ready';
|
|
||||||
this.overviewRegion = null;
|
|
||||||
this.regionsPlugin = this.wavesurfer[this.params.regionsPluginName];
|
|
||||||
this.drawer.createWrapper();
|
|
||||||
this.createElements();
|
|
||||||
var isInitialised = false;
|
|
||||||
|
|
||||||
// ws ready event listener
|
|
||||||
this._onShouldRender = function () {
|
|
||||||
// only bind the events in the first run
|
|
||||||
if (!isInitialised) {
|
|
||||||
_this.bindWavesurferEvents();
|
|
||||||
_this.bindMinimapEvents();
|
|
||||||
isInitialised = true;
|
|
||||||
}
|
|
||||||
// if there is no such element, append it to the container (below
|
|
||||||
// the waveform)
|
|
||||||
if (!document.body.contains(_this.params.container)) {
|
|
||||||
ws.container.insertBefore(_this.params.container, null);
|
|
||||||
}
|
|
||||||
if (_this.regionsPlugin && _this.params.showRegions) {
|
|
||||||
_this.regions();
|
|
||||||
}
|
|
||||||
_this.render();
|
|
||||||
};
|
|
||||||
this._onAudioprocess = function (currentTime) {
|
|
||||||
_this.drawer.progress(_this.wavesurfer.backend.getPlayedPercents());
|
|
||||||
};
|
|
||||||
|
|
||||||
// ws seek event listener
|
|
||||||
this._onSeek = function () {
|
|
||||||
return _this.drawer.progress(ws.backend.getPlayedPercents());
|
|
||||||
};
|
|
||||||
|
|
||||||
// event listeners for the overview region
|
|
||||||
this._onScroll = function (e) {
|
|
||||||
if (!_this.draggingOverview) {
|
|
||||||
_this.moveOverviewRegion(e.target.scrollLeft / _this.ratio);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
this._onMouseover = function (e) {
|
|
||||||
if (_this.draggingOverview) {
|
|
||||||
_this.draggingOverview = false;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
var prevWidth = 0;
|
|
||||||
this._onResize = ws.util.debounce(function () {
|
|
||||||
if (prevWidth != _this.drawer.wrapper.clientWidth) {
|
|
||||||
prevWidth = _this.drawer.wrapper.clientWidth;
|
|
||||||
_this.render();
|
|
||||||
_this.drawer.progress(_this.wavesurfer.backend.getPlayedPercents());
|
|
||||||
}
|
|
||||||
});
|
|
||||||
this._onZoom = function (e) {
|
|
||||||
_this.render();
|
|
||||||
};
|
|
||||||
this.wavesurfer.on('zoom', this._onZoom);
|
|
||||||
}
|
|
||||||
_createClass(MinimapPlugin, [{
|
|
||||||
key: "init",
|
|
||||||
value: function init() {
|
|
||||||
if (this.wavesurfer.isReady) {
|
|
||||||
this._onShouldRender();
|
|
||||||
}
|
|
||||||
this.wavesurfer.on(this.renderEvent, this._onShouldRender);
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
key: "destroy",
|
|
||||||
value: function destroy() {
|
|
||||||
window.removeEventListener('resize', this._onResize, true);
|
|
||||||
window.removeEventListener('orientationchange', this._onResize, true);
|
|
||||||
this.wavesurfer.drawer.wrapper.removeEventListener('mouseover', this._onMouseover);
|
|
||||||
this.wavesurfer.un(this.renderEvent, this._onShouldRender);
|
|
||||||
this.wavesurfer.un('seek', this._onSeek);
|
|
||||||
this.wavesurfer.un('scroll', this._onScroll);
|
|
||||||
this.wavesurfer.un('audioprocess', this._onAudioprocess);
|
|
||||||
this.wavesurfer.un('zoom', this._onZoom);
|
|
||||||
this.drawer.destroy();
|
|
||||||
this.overviewRegion = null;
|
|
||||||
this.unAll();
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
key: "regions",
|
|
||||||
value: function regions() {
|
|
||||||
var _this2 = this;
|
|
||||||
this.regions = {};
|
|
||||||
this.wavesurfer.on('region-created', function (region) {
|
|
||||||
_this2.regions[region.id] = region;
|
|
||||||
_this2.drawer.wrapper && _this2.renderRegions();
|
|
||||||
});
|
|
||||||
this.wavesurfer.on('region-updated', function (region) {
|
|
||||||
_this2.regions[region.id] = region;
|
|
||||||
_this2.drawer.wrapper && _this2.renderRegions();
|
|
||||||
});
|
|
||||||
this.wavesurfer.on('region-removed', function (region) {
|
|
||||||
delete _this2.regions[region.id];
|
|
||||||
_this2.drawer.wrapper && _this2.renderRegions();
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
key: "renderRegions",
|
|
||||||
value: function renderRegions() {
|
|
||||||
var _this3 = this;
|
|
||||||
var regionElements = this.drawer.wrapper.querySelectorAll('region');
|
|
||||||
var i;
|
|
||||||
for (i = 0; i < regionElements.length; ++i) {
|
|
||||||
this.drawer.wrapper.removeChild(regionElements[i]);
|
|
||||||
}
|
|
||||||
Object.keys(this.regions).forEach(function (id) {
|
|
||||||
var region = _this3.regions[id];
|
|
||||||
var width = _this3.getWidth() * ((region.end - region.start) / _this3.wavesurfer.getDuration());
|
|
||||||
var left = _this3.getWidth() * (region.start / _this3.wavesurfer.getDuration());
|
|
||||||
var regionElement = _this3.util.style(document.createElement('region'), {
|
|
||||||
height: 'inherit',
|
|
||||||
backgroundColor: region.color,
|
|
||||||
width: width + 'px',
|
|
||||||
left: left + 'px',
|
|
||||||
display: 'block',
|
|
||||||
position: 'absolute'
|
|
||||||
});
|
|
||||||
regionElement.classList.add(id);
|
|
||||||
_this3.drawer.wrapper.appendChild(regionElement);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
key: "createElements",
|
|
||||||
value: function createElements() {
|
|
||||||
this.drawer.createElements();
|
|
||||||
if (this.params.showOverview) {
|
|
||||||
this.overviewRegion = this.util.style(document.createElement('overview'), {
|
|
||||||
top: 0,
|
|
||||||
bottom: 0,
|
|
||||||
width: '0px',
|
|
||||||
display: 'block',
|
|
||||||
position: 'absolute',
|
|
||||||
cursor: 'move',
|
|
||||||
border: this.params.overviewBorderSize + 'px solid ' + this.params.overviewBorderColor,
|
|
||||||
zIndex: 2,
|
|
||||||
opacity: this.params.overviewOpacity
|
|
||||||
});
|
|
||||||
this.drawer.wrapper.appendChild(this.overviewRegion);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
key: "bindWavesurferEvents",
|
|
||||||
value: function bindWavesurferEvents() {
|
|
||||||
window.addEventListener('resize', this._onResize, true);
|
|
||||||
window.addEventListener('orientationchange', this._onResize, true);
|
|
||||||
this.wavesurfer.on('audioprocess', this._onAudioprocess);
|
|
||||||
this.wavesurfer.on('seek', this._onSeek);
|
|
||||||
if (this.params.showOverview) {
|
|
||||||
this.wavesurfer.on('scroll', this._onScroll);
|
|
||||||
this.wavesurfer.drawer.wrapper.addEventListener('mouseover', this._onMouseover);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
key: "bindMinimapEvents",
|
|
||||||
value: function bindMinimapEvents() {
|
|
||||||
var _this4 = this;
|
|
||||||
var positionMouseDown = {
|
|
||||||
clientX: 0,
|
|
||||||
clientY: 0
|
|
||||||
};
|
|
||||||
var relativePositionX = 0;
|
|
||||||
var seek = true;
|
|
||||||
|
|
||||||
// the following event listeners will be destroyed by using
|
|
||||||
// this.unAll() and nullifying the DOM node references after
|
|
||||||
// removing them
|
|
||||||
if (this.params.interact) {
|
|
||||||
this.drawer.wrapper.addEventListener('click', function (event) {
|
|
||||||
_this4.fireEvent('click', event, _this4.drawer.handleEvent(event));
|
|
||||||
});
|
|
||||||
this.on('click', function (event, position) {
|
|
||||||
if (seek) {
|
|
||||||
_this4.drawer.progress(position);
|
|
||||||
_this4.wavesurfer.seekAndCenter(position);
|
|
||||||
} else {
|
|
||||||
seek = true;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
if (this.params.showOverview) {
|
|
||||||
this.overviewRegion.addEventListener('mousedown', function (event) {
|
|
||||||
_this4.draggingOverview = true;
|
|
||||||
relativePositionX = event.layerX;
|
|
||||||
positionMouseDown.clientX = event.clientX;
|
|
||||||
positionMouseDown.clientY = event.clientY;
|
|
||||||
});
|
|
||||||
this.drawer.wrapper.addEventListener('mousemove', function (event) {
|
|
||||||
if (_this4.draggingOverview) {
|
|
||||||
_this4.moveOverviewRegion(event.clientX - _this4.drawer.container.getBoundingClientRect().left - relativePositionX);
|
|
||||||
}
|
|
||||||
});
|
|
||||||
this.drawer.wrapper.addEventListener('mouseup', function (event) {
|
|
||||||
if (positionMouseDown.clientX - event.clientX === 0 && positionMouseDown.clientX - event.clientX === 0) {
|
|
||||||
seek = true;
|
|
||||||
_this4.draggingOverview = false;
|
|
||||||
} else if (_this4.draggingOverview) {
|
|
||||||
seek = false;
|
|
||||||
_this4.draggingOverview = false;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
key: "render",
|
|
||||||
value: function render() {
|
|
||||||
var len = this.drawer.getWidth();
|
|
||||||
var peaks = this.wavesurfer.backend.getPeaks(len, 0, len);
|
|
||||||
this.drawer.drawPeaks(peaks, len, 0, len);
|
|
||||||
this.drawer.progress(this.wavesurfer.backend.getPlayedPercents());
|
|
||||||
if (this.params.showOverview) {
|
|
||||||
//get proportional width of overview region considering the respective
|
|
||||||
//width of the drawers
|
|
||||||
this.ratio = this.wavesurfer.drawer.width / this.drawer.width;
|
|
||||||
this.waveShowedWidth = this.wavesurfer.drawer.width / this.ratio;
|
|
||||||
this.waveWidth = this.wavesurfer.drawer.width;
|
|
||||||
this.overviewWidth = this.drawer.container.offsetWidth / this.ratio;
|
|
||||||
this.overviewPosition = 0;
|
|
||||||
this.moveOverviewRegion(this.wavesurfer.drawer.wrapper.scrollLeft / this.ratio);
|
|
||||||
this.overviewRegion.style.width = this.overviewWidth + 'px';
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
key: "moveOverviewRegion",
|
|
||||||
value: function moveOverviewRegion(pixels) {
|
|
||||||
if (pixels < 0) {
|
|
||||||
this.overviewPosition = 0;
|
|
||||||
} else if (pixels + this.overviewWidth < this.drawer.container.offsetWidth) {
|
|
||||||
this.overviewPosition = pixels;
|
|
||||||
} else {
|
|
||||||
this.overviewPosition = this.drawer.container.offsetWidth - this.overviewWidth;
|
|
||||||
}
|
|
||||||
this.overviewRegion.style.left = this.overviewPosition + 'px';
|
|
||||||
if (this.draggingOverview) {
|
|
||||||
this.wavesurfer.drawer.wrapper.scrollLeft = this.overviewPosition * this.ratio;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}, {
|
|
||||||
key: "getWidth",
|
|
||||||
value: function getWidth() {
|
|
||||||
return this.drawer.width / this.params.pixelRatio;
|
|
||||||
}
|
|
||||||
}], [{
|
|
||||||
key: "create",
|
|
||||||
value:
|
|
||||||
/**
|
|
||||||
* Minimap plugin definition factory
|
|
||||||
*
|
|
||||||
* This function must be used to create a plugin definition which can be
|
|
||||||
* used by wavesurfer to correctly instantiate the plugin.
|
|
||||||
*
|
|
||||||
* @param {MinimapPluginParams} params parameters use to initialise the plugin
|
|
||||||
* @return {PluginDefinition} an object representing the plugin
|
|
||||||
*/
|
|
||||||
function create(params) {
|
|
||||||
return {
|
|
||||||
name: 'minimap',
|
|
||||||
deferInit: params && params.deferInit ? params.deferInit : false,
|
|
||||||
params: params,
|
|
||||||
staticProps: {},
|
|
||||||
instance: MinimapPlugin
|
|
||||||
};
|
|
||||||
}
|
|
||||||
}]);
|
|
||||||
return MinimapPlugin;
|
|
||||||
}();
|
|
||||||
module.exports = exports.default;
|
|
||||||
|
|
||||||
/***/ })
|
|
||||||
|
|
||||||
/******/ });
|
|
||||||
/************************************************************************/
|
|
||||||
/******/ // The module cache
|
|
||||||
/******/ var __webpack_module_cache__ = {};
|
|
||||||
/******/
|
|
||||||
/******/ // The require function
|
|
||||||
/******/ function __webpack_require__(moduleId) {
|
|
||||||
/******/ // Check if module is in cache
|
|
||||||
/******/ var cachedModule = __webpack_module_cache__[moduleId];
|
|
||||||
/******/ if (cachedModule !== undefined) {
|
|
||||||
/******/ return cachedModule.exports;
|
|
||||||
/******/ }
|
|
||||||
/******/ // Create a new module (and put it into the cache)
|
|
||||||
/******/ var module = __webpack_module_cache__[moduleId] = {
|
|
||||||
/******/ // no module.id needed
|
|
||||||
/******/ // no module.loaded needed
|
|
||||||
/******/ exports: {}
|
|
||||||
/******/ };
|
|
||||||
/******/
|
|
||||||
/******/ // Execute the module function
|
|
||||||
/******/ __webpack_modules__[moduleId](module, module.exports, __webpack_require__);
|
|
||||||
/******/
|
|
||||||
/******/ // Return the exports of the module
|
|
||||||
/******/ return module.exports;
|
|
||||||
/******/ }
|
|
||||||
/******/
|
|
||||||
/************************************************************************/
|
|
||||||
/******/
|
|
||||||
/******/ // startup
|
|
||||||
/******/ // Load entry module and return exports
|
|
||||||
/******/ // This entry module is referenced by other modules so it can't be inlined
|
|
||||||
/******/ var __webpack_exports__ = __webpack_require__("./src/plugin/minimap/index.js");
|
|
||||||
/******/
|
|
||||||
/******/ return __webpack_exports__;
|
|
||||||
/******/ })()
|
|
||||||
;
|
|
||||||
});
|
|
||||||
//# sourceMappingURL=wavesurfer.minimap.js.map
|
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue