diff --git a/bin/em/variabletime/web/js/audio.js b/bin/em/variabletime/web/js/audio.js index 9f07259..b527dcc 100644 --- a/bin/em/variabletime/web/js/audio.js +++ b/bin/em/variabletime/web/js/audio.js @@ -5,6 +5,7 @@ import { toCssClass, flattenObject, deFlattenObject, + getNestedProperty, clone, rgbaToHexa, hexaToRgba, @@ -81,14 +82,6 @@ const Audio = function(tp, record) { return false; } if (!mapping[layer.id()].hasOwnProperty(propTitle)) { - if (propTitle === 'color' && - config.audio.colorSeparateRGBA && - mapping[layer.id()].hasOwnProperty('color.r') && - mapping[layer.id()].hasOwnProperty('color.g') && - mapping[layer.id()].hasOwnProperty('color.b') && - mapping[layer.id()].hasOwnProperty('color.a')) { - return true; - } return false; } return true; @@ -136,7 +129,7 @@ const Audio = function(tp, record) { const channels = Object.keys(color); channels.forEach((channel) => { if (typeof color[channel] !== 'number') { - console.log('Audio::fixColor', `fixing color.${channel} => 1`); + console.log('Audio::fixColor', `fixing the color.${channel} => 1`); color[channel] = 1; } }); @@ -196,6 +189,11 @@ const Audio = function(tp, record) { return true; } else { // already there + if (propTitle === 'color') { + fixColor(mapping[layer.id()][propTitle].min_out); + fixColor(mapping[layer.id()][propTitle].max_out); + fixColor(mapping[layer.id()][propTitle].value); + } return false; } }; @@ -216,15 +214,6 @@ const Audio = function(tp, record) { } if (!mapping[layer.id()].hasOwnProperty(propTitle)) { // no propTitle - // perhaps color? - //if (config.audio.colorSeparateRGBA && propTitle === 'color') { - //let isGood = true; - //isGood = removeAudioMapping(layer, 'color.r'); - //isGood = removeAudioMapping(layer, 'color.g'); - //isGood = removeAudioMapping(layer, 'color.b'); - //isGood = removeAudioMapping(layer, 'color.a'); - //return isGood; - //} return false; } delete mapping[layer.id()][propTitle]; @@ -239,8 +228,12 @@ const Audio = function(tp, record) { let hasLetterDelay = config .layer.letterDelayProps - .indexOf(propTitle.split('.')[0]) >= 0 && propTitle.indexOf('color') < 0 && - !tp.isSequenced(propTitle); + .indexOf(propTitle.split('.')[0]) >= 0 + && mapping[layer.id()][`letterDelays.${propTitle}`] === 'undefined' // if the letterDelay is mapped itself, we don't do it + //&& propTitle.indexOf('color') < 0 + //&& !tp.isSequenced(propTitle) + ; + let isSequenced = tp.isSequenced(propTitle, layer); const panel = tp.getPanel(); if (!areMutationsObserved) { mutationObserver.observe(panel, { childList: true, subtree: true }); @@ -275,6 +268,12 @@ const Audio = function(tp, record) { if (hasLetterDelay) { const ld = panel.querySelector(toCssClass(`audio_letterDelay${propTitle}`,'#')); mappingOptions.letterDelay = typeof ld.value === 'number' ? ld.value : parseInt(ld.value); + if (isSequenced) { + const prop = getNestedProperty(layer.theatreObject.props.letterDelays, propTitle.split('.')); + tp.studio.transaction(({set}) => { + set(prop, mappingOptions.letterDelay); + }); + } } mappingOptions.source = panel.querySelector(toCssClass(`audio_source${propTitle}`,'#')).value; mappingOptions.muted = panel.querySelector(toCssClass(`audio_mute${propTitle}`,'#')).checked; @@ -702,15 +701,7 @@ const Audio = function(tp, record) { } const container = panelPropTitle.parentNode.parentNode; - if (propTitle === 'color' && config.audio.colorSeparateRGBA) { - // NOTE: attach reversed, because container.after(audioOptions) - createAudioOptions(layer, `${propTitle}.a`, container).classList.add(toCssClass(`audioOptions${propTitle}`)); - createAudioOptions(layer, `${propTitle}.b`, container).classList.add(toCssClass(`audioOptions${propTitle}`)); - createAudioOptions(layer, `${propTitle}.g`, container).classList.add(toCssClass(`audioOptions${propTitle}`)); - createAudioOptions(layer, `${propTitle}.r`, container).classList.add(toCssClass(`audioOptions${propTitle}`)); - } else { - createAudioOptions(layer, propTitle, container); - } + createAudioOptions(layer, propTitle, container); const audioButton = container.querySelector('.audioButton'); audioButton.classList.add('active'); @@ -734,14 +725,7 @@ const Audio = function(tp, record) { button.classList.remove('active'); }); } else { - if (config.audio.colorSeparateRGBA && propTitle === 'color') { - delete canvasCombos['color.r']; - delete canvasCombos['color.g']; - delete canvasCombos['color.b']; - delete canvasCombos['color.a']; - } else { - delete canvasCombos[propTitle]; - } + delete canvasCombos[propTitle]; // only selected layers have options // otherwise the ui is not there if (layer.isSelected()) { diff --git a/bin/em/variabletime/web/js/config.js b/bin/em/variabletime/web/js/config.js index 143b720..44ed4ca 100644 --- a/bin/em/variabletime/web/js/config.js +++ b/bin/em/variabletime/web/js/config.js @@ -109,7 +109,6 @@ const config = { fftBandsAnalysed: 256 * 8, fftBandsUsed: 256 / 2, fftHeight: 256 / 4, - colorSeparateRGBA: false, ignoreOutboundFrequencies: true, pitchCombineFrequencies: false, rolloverResetLoop: true, diff --git a/bin/em/variabletime/web/js/utils.js b/bin/em/variabletime/web/js/utils.js index e26f0e1..023ffc4 100644 --- a/bin/em/variabletime/web/js/utils.js +++ b/bin/em/variabletime/web/js/utils.js @@ -498,8 +498,8 @@ const getNestedProperty = (o, a, verify = false) => { } let b = clone(a); if (b.length > 1) { - o = o[b.shift()]; - return getNestedProperty(o, b, verify); + let c = o[b.shift()]; + return getNestedProperty(c, b, verify); } return o[b[0]]; };