Compare commits

...

3 commits

Author SHA1 Message Date
themancalledjakob
f829eea911 remember play state 2024-03-07 11:14:24 +01:00
themancalledjakob
be11f015b9 sync letter delays after recording 2024-03-07 11:13:31 +01:00
themancalledjakob
05c6f3f5f9 remove unnecessary logs 2024-03-07 11:11:37 +01:00
3 changed files with 46 additions and 21 deletions

View file

@ -376,13 +376,11 @@ const Layer = function(tp, layerID, fontsAndAxes, autoInit = true) {
}; };
this.init = (initialValues = false) => { this.init = (initialValues = false) => {
return new Promise((resolve) => { return new Promise((resolve) => {
console.log('this is happening','layer init');
const promises = []; const promises = [];
promises.push(this.findInjectHierarchyPanelPromise()); promises.push(this.findInjectHierarchyPanelPromise());
const doUpdateTheatre = false; const doUpdateTheatre = false;
this.updateFonts(doUpdateTheatre) this.updateFonts(doUpdateTheatre)
.then(() => { .then(() => {
console.log('this is happening','layer init update fonts');
this.theatreObject = tp.addObject(this.id(), this.props, this.onValuesChange); this.theatreObject = tp.addObject(this.id(), this.props, this.onValuesChange);
if (typeof initialValues === 'object') { if (typeof initialValues === 'object') {
this.theatreObject.initialValue = initialValues; this.theatreObject.initialValue = initialValues;
@ -390,19 +388,14 @@ const Layer = function(tp, layerID, fontsAndAxes, autoInit = true) {
window.layerOrder.add(this.id()); window.layerOrder.add(this.id());
setTimeout(() => { setTimeout(() => {
const values = JSON.parse(JSON.stringify(this.theatreObject.value)); const values = JSON.parse(JSON.stringify(this.theatreObject.value));
console.log('this is happening','doing the transaction');
tp.studio.transaction(({ tp.studio.transaction(({
set set
}) => { }) => {
set(this.theatreObject.props, values); set(this.theatreObject.props, values);
}); });
console.log('this is happening','has have been doing the transaction');
setTimeout(() => { setTimeout(() => {
console.log('this is happening');
promises.push(this.findInjectPanelPromise()); promises.push(this.findInjectPanelPromise());
console.log(promises);
Promise.allSettled(promises).then(() => { Promise.allSettled(promises).then(() => {
console.log('this is happening');
resolve(); resolve();
if (config.autoSave && window.isInitialized) { if (config.autoSave && window.isInitialized) {
tp.saveProject(); tp.saveProject();
@ -468,7 +461,6 @@ const Layer = function(tp, layerID, fontsAndAxes, autoInit = true) {
} }
if (doItAgain) { if (doItAgain) {
hierarchyPanelFinderTimeout = setTimeout(() => { hierarchyPanelFinderTimeout = setTimeout(() => {
console.log('hierachrypanelfinder');
this.findInjectHierarchyPanel(resolve); this.findInjectHierarchyPanel(resolve);
}, 30); }, 30);
window.hierarchyPanelFinderTimeout = hierarchyPanelFinderTimeout; window.hierarchyPanelFinderTimeout = hierarchyPanelFinderTimeout;
@ -520,19 +512,14 @@ const Layer = function(tp, layerID, fontsAndAxes, autoInit = true) {
let panelFinderTimeout = false; let panelFinderTimeout = false;
this.findInjectPanelPromise = () => { this.findInjectPanelPromise = () => {
return new Promise((resolve) => { return new Promise((resolve) => {
console.log('this is happening', 'finInjectPanelPRomisE');
this.findInjectPanel(resolve); this.findInjectPanel(resolve);
}); });
}; };
this.findInjectPanel = (resolve = false) => { this.findInjectPanel = (resolve = false) => {
if (tp.studio.selection.length === 0 || (tp.studio.selection.length > 0 && tp.studio.selection[0].address.objectKey !== this.id())) { if (tp.studio.selection.length === 0 || (tp.studio.selection.length > 0 && tp.studio.selection[0].address.objectKey !== this.id())) {
console.log('this is happening', 'finInjectPanel DOES NOT RESOLVE HAHAHAHA');
if (typeof resolve === 'function') { if (typeof resolve === 'function') {
console.log('this is happening', 'resolver');
resolve(); resolve();
} }
console.log('this is happening', 'was resolved?');
return; return;
} else { } else {
const panel = tp.getPanel(); const panel = tp.getPanel();

View file

@ -323,20 +323,16 @@ const resize = () => {
}; };
const postModuleInitialized = () => { const postModuleInitialized = () => {
console.log('this is happening');
window.setLoadingTask('setting up animation', 80); window.setLoadingTask('setting up animation', 80);
moduleFS.init() moduleFS.init()
.then(() => { .then(() => {
console.log('this is happening');
artboard = new Artboard(tp, content); artboard = new Artboard(tp, content);
initPanels(); initPanels();
// NOTE: we know that our TheatrePlay is initialized // NOTE: we know that our TheatrePlay is initialized
tp.connectModuleCallbacks(); tp.connectModuleCallbacks();
exporter.init(); exporter.init();
getFontsAndAxes(); getFontsAndAxes();
console.log('this is happening');
tp.loadProject().then(() => { tp.loadProject().then(() => {
console.log('this is happening');
interactor.init(); interactor.init();
resize(); resize();
adjustPanel(); adjustPanel();
@ -348,7 +344,6 @@ const postModuleInitialized = () => {
tp.saveProject(); tp.saveProject();
} }
}, 1000); }, 1000);
console.log('this is happening');
}); });
//midiController.init(); //midiController.init();
}); });
@ -461,9 +456,7 @@ const addExistingLayer = (layerID, values) => {
layer.valuesCorrector(values); layer.valuesCorrector(values);
const cppProps = layer.values2cppProps(values); const cppProps = layer.values2cppProps(values);
const checkID = Module.addExistingLayer(cppProps, layerID); const checkID = Module.addExistingLayer(cppProps, layerID);
console.log('this is happening');
layer.init().then(() => { layer.init().then(() => {
console.log('this is happening');
layers.push(layer); layers.push(layer);
layersById[layerID] = layer; layersById[layerID] = layer;
resolve(layer); resolve(layer);

View file

@ -4,6 +4,7 @@ import {
toCssClass, toCssClass,
flattenObject, flattenObject,
deFlattenObject, deFlattenObject,
getNestedProperty,
} from './utils.js'; } from './utils.js';
const LiveBuffer = function() { const LiveBuffer = function() {
@ -159,10 +160,15 @@ const Record = function(tp) {
const liveUpdater = new LiveUpdater(tp, buffy); const liveUpdater = new LiveUpdater(tp, buffy);
let isInitialized = false; let isInitialized = false;
let remember = {};
const init = () => { const init = () => {
if (!isInitialized) { if (!isInitialized) {
tp.core.onChange(tp.sheet.sequence.pointer.playing, (playing) => { tp.core.onChange(tp.sheet.sequence.pointer.playing, (playing) => {
if (isRecording === RECORDING && !playing) { if (isRecording === RECORDING && !playing) {
// when you hit space to stop recording,
// we want to keep it paused
remember.isPlaying = false;
stopRecording(); stopRecording();
} }
}); });
@ -394,6 +400,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');
@ -407,6 +445,7 @@ const Record = function(tp) {
init(); init();
} }
lastPositions = {}; lastPositions = {};
remember.isPlaying = tp.core.val(tp.sheet.sequence.pointer.playing);
tp.sheet.sequence.pause(); tp.sheet.sequence.pause();
const layerKeys = Object.keys(hot); const layerKeys = Object.keys(hot);
layerKeys.forEach((layerID) => { layerKeys.forEach((layerID) => {
@ -499,10 +538,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();
}); });
@ -521,6 +560,12 @@ const Record = function(tp) {
.classList.remove('visible'); .classList.remove('visible');
console.log('Record::stopRecording', 'stopped recording'); console.log('Record::stopRecording', 'stopped recording');
isRecording = NOT_RECORDING; isRecording = NOT_RECORDING;
if (remember.isPlaying) {
tp.sheet.sequence.play();
} else {
tp.sheet.sequence.pause();
}
resolve(); resolve();
}); });
}); });