Fix keyframe waveforms after data point changes

This commit is contained in:
JannisX11 2020-09-27 18:16:13 +02:00
parent 9cac4af541
commit 3900ac3f94
3 changed files with 20 additions and 20 deletions

View File

@ -892,8 +892,8 @@
>
<i class="material-icons keyframe_icon_smaller" v-if="keyframe.interpolation == 'catmullrom'">lens</i>
<i class="material-icons" v-else>stop</i>
<svg class="keyframe_waveform" v-if="keyframe.channel == 'sound' && keyframe.file && waveforms[keyframe.file]" :style="{width: waveforms[keyframe.file].duration * size}">
<polygon :points="getWaveformPoints(waveforms[keyframe.file].samples, size)"></polygon>
<svg class="keyframe_waveform" v-if="keyframe.channel == 'sound' && keyframe.data_points[0].file && waveforms[keyframe.data_points[0].file]" :style="{width: waveforms[keyframe.data_points[0].file].duration * size}">
<polygon :points="getWaveformPoints(waveforms[keyframe.data_points[0].file].samples, size)"></polygon>
</svg>
</keyframe>
</div>

View File

@ -970,20 +970,20 @@ class EffectAnimator extends GeneralAnimator {
this.sound.forEach(kf => {
var diff = kf.time - Timeline.time;
if (diff >= 0 && diff < (1/60) * (Timeline.playback_speed/100)) {
if (kf.file && !kf.cooldown) {
var media = new Audio(kf.file);
window._media = media
media.volume = Math.clamp(settings.volume.value/100, 0, 1);
media.play();
Timeline.playing_sounds.push(media);
media.onended = function() {
Timeline.playing_sounds.remove(media);
}
if (kf.data_points[0]?.file && !kf.cooldown) {
var media = new Audio(kf.data_points[0]?.file);
window._media = media
media.volume = Math.clamp(settings.volume.value/100, 0, 1);
media.play().catch(() => {});
Timeline.playing_sounds.push(media);
media.onended = function() {
Timeline.playing_sounds.remove(media);
}
kf.cooldown = true;
setTimeout(() => {
delete kf.cooldown;
}, 400)
kf.cooldown = true;
setTimeout(() => {
delete kf.cooldown;
}, 400)
}
}
})
@ -992,14 +992,14 @@ class EffectAnimator extends GeneralAnimator {
startPreviousSounds() {
if (!this.muted.sound) {
this.sound.forEach(kf => {
if (kf.file && !kf.cooldown) {
if (kf.data_points[0]?.file && !kf.cooldown) {
var diff = kf.time - Timeline.time;
if (diff < 0 && Timeline.waveforms[kf.file] && Timeline.waveforms[kf.file].duration > -diff) {
var media = new Audio(kf.file);
if (diff < 0 && Timeline.waveforms[kf.data_points[0]?.file] && Timeline.waveforms[kf.data_points[0]?.file].duration > -diff) {
var media = new Audio(kf.data_points[0]?.file);
window._media = media
media.volume = Math.clamp(settings.volume.value/100, 0, 1);
media.currentTime = -diff;
media.play();
media.play().catch(() => {});
Timeline.playing_sounds.push(media);
media.onended = function() {
Timeline.playing_sounds.remove(media);

View File

@ -671,7 +671,7 @@ BARS.defineActions(function() {
resource_id: 'animation_audio',
extensions: ['ogg'],
type: 'Audio File',
startpath: Timeline.selected[0].file
startpath: Timeline.selected[0].data_points[0]?.file
}, function(files) {
// Todo: move to panel