sync letter delays after recording
This commit is contained in:
parent
05c6f3f5f9
commit
be11f015b9
1 changed files with 34 additions and 1 deletions
|
@ -4,6 +4,7 @@ import {
|
||||||
toCssClass,
|
toCssClass,
|
||||||
flattenObject,
|
flattenObject,
|
||||||
deFlattenObject,
|
deFlattenObject,
|
||||||
|
getNestedProperty,
|
||||||
} from './utils.js';
|
} from './utils.js';
|
||||||
|
|
||||||
const LiveBuffer = function() {
|
const LiveBuffer = function() {
|
||||||
|
@ -394,6 +395,38 @@ const Record = function(tp) {
|
||||||
liveUpdater.immediateUpdate(layer, merged);
|
liveUpdater.immediateUpdate(layer, merged);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/// @brief = copies letterDelay value from audio mapping to the recorded value.
|
||||||
|
///
|
||||||
|
/// @param layer - a layer object
|
||||||
|
/// @param propPaths - two dimensional array of strings
|
||||||
|
///
|
||||||
|
/// @return
|
||||||
|
const syncLetterDelays = (layer, propPaths) => {
|
||||||
|
propPaths.forEach((path) => {
|
||||||
|
const oldLetterDelay = getNestedProperty(layer.theatreObject.value.letterDelays, path, true);
|
||||||
|
const isOriginalSequenced = tp.isSequenced(path, layer);
|
||||||
|
const isLetterDelaySequenced = tp.isSequenced(["letterDelays", path], layer);
|
||||||
|
// we use audio.getSavedMapping(), because mapping may be removed directly after recording
|
||||||
|
const mapping = getNestedProperty(audio.getSavedMapping(), [layer.id()].concat(path), true);
|
||||||
|
const newLetterDelay = (() => {
|
||||||
|
if (typeof mapping['letterDelay'] === 'undefined') {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
return mapping['letterDelay'];
|
||||||
|
})();
|
||||||
|
if (newLetterDelay !== oldLetterDelay &&
|
||||||
|
!isLetterDelaySequenced &&
|
||||||
|
newLetterDelay !== false) {
|
||||||
|
const prop = getNestedProperty(layer.theatreObject.props.letterDelays, path);
|
||||||
|
tp.studio.transaction(({
|
||||||
|
set
|
||||||
|
}) => {
|
||||||
|
set(prop, newLetterDelay);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
const startRecording = () => {
|
const startRecording = () => {
|
||||||
isRecording = STARTING_RECORDING;
|
isRecording = STARTING_RECORDING;
|
||||||
console.log('Record::startRecording');
|
console.log('Record::startRecording');
|
||||||
|
@ -499,10 +532,10 @@ const Record = function(tp) {
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
//setTimeout(() => {
|
//setTimeout(() => {
|
||||||
const kf = clone(keyframes);
|
|
||||||
promises.push(() => {
|
promises.push(() => {
|
||||||
return new Promise((subResolve) => {
|
return new Promise((subResolve) => {
|
||||||
tp.addKeyframes(layer, keyframes).then(() => {
|
tp.addKeyframes(layer, keyframes).then(() => {
|
||||||
|
syncLetterDelays(layer, keyframes.map(k => k.path));
|
||||||
layer.updateValuesViaTheatre(true);
|
layer.updateValuesViaTheatre(true);
|
||||||
subResolve();
|
subResolve();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue