ignore outboundfrequencies and pitchcombine
This commit is contained in:
parent
870a99d725
commit
04041870da
2 changed files with 54 additions and 22 deletions
|
@ -406,12 +406,12 @@ const Audio = function(tp, record) {
|
|||
// otherwise the ui is not there
|
||||
if (layer.isSelected()) {
|
||||
if (config.audio.colorSeparateRGBA && propTitle === 'color') {
|
||||
delete canvasCombos[layer.id()]['color.r'];
|
||||
delete canvasCombos[layer.id()]['color.g'];
|
||||
delete canvasCombos[layer.id()]['color.b'];
|
||||
delete canvasCombos[layer.id()]['color.a'];
|
||||
delete canvasCombos['color.r'];
|
||||
delete canvasCombos['color.g'];
|
||||
delete canvasCombos['color.b'];
|
||||
delete canvasCombos['color.a'];
|
||||
} else {
|
||||
delete canvasCombos[layer.id()][propTitle];
|
||||
delete canvasCombos[propTitle];
|
||||
}
|
||||
const audioOptions = panel.querySelectorAll(toCssClass(`audioOptions${propTitle}`,'.'));
|
||||
if (audioOptions.length > 0) {
|
||||
|
@ -731,21 +731,41 @@ const Audio = function(tp, record) {
|
|||
let x = 0;
|
||||
|
||||
let max_i = 0;
|
||||
let max_ri = 0;
|
||||
let total_v = 0;
|
||||
let max_v = 0;
|
||||
let min_v = 9999999;
|
||||
for (let k = 0; k < canvasKeys.length; k++) {
|
||||
const layerID = canvasCombos[canvasKeys[k]][2];
|
||||
const m = mapping[layerID][canvasKeys[k]];
|
||||
m.max_v = max_v;
|
||||
m.max_i = max_i;
|
||||
m.max_ri = max_ri;
|
||||
m.total_v = total_v;
|
||||
}
|
||||
for (let i = 0; i < w; i++) {
|
||||
barHeight = dataArrayAlt[i];
|
||||
total_v += barHeight;
|
||||
max_ri = barHeight * i;
|
||||
|
||||
if (barHeight > max_v) {
|
||||
max_v = barHeight;
|
||||
max_i = i;
|
||||
}
|
||||
if (barHeight < min_v) {
|
||||
min_v = barHeight;
|
||||
for (let k = 0; k < canvasKeys.length; k++) {
|
||||
const layerID = canvasCombos[canvasKeys[k]][2];
|
||||
const m = mapping[layerID][canvasKeys[k]];
|
||||
let fillStyle = "rgb(200,200,200)"; // AUDIO COLOR
|
||||
if (m.min_freq <= i && m.max_freq >= i) {
|
||||
m.total_v += barHeight;
|
||||
if (barHeight > m.max_v) {
|
||||
m.max_v = barHeight;
|
||||
m.max_i = i;
|
||||
m.max_ri = barHeight * i;
|
||||
}
|
||||
for (let i = 0; i < canvasKeys.length; i++) {
|
||||
canvasCombos[canvasKeys[i]][1].fillStyle = "rgb(200,200,200)"; // AUDIO COLOR
|
||||
canvasCombos[canvasKeys[i]][1].fillRect(
|
||||
fillStyle = "rgb(255,255,255)"; // AUDIO COLOR
|
||||
}
|
||||
canvasCombos[canvasKeys[k]][1].fillStyle = fillStyle;
|
||||
canvasCombos[canvasKeys[k]][1].fillRect(
|
||||
x,
|
||||
h - (barHeight * verticalFactor),
|
||||
barWidth,
|
||||
|
@ -755,24 +775,28 @@ const Audio = function(tp, record) {
|
|||
|
||||
x += barWidth;
|
||||
}
|
||||
for (let i = 0; i < canvasKeys.length; i++) {
|
||||
const layerID = canvasCombos[canvasKeys[i]][2];
|
||||
const m = mapping[layerID][canvasKeys[i]];
|
||||
max_ri /= total_v;
|
||||
for (let k = 0; k < canvasKeys.length; k++) {
|
||||
const layerID = canvasCombos[canvasKeys[k]][2];
|
||||
const m = mapping[layerID][canvasKeys[k]];
|
||||
m.max_ri /= m.total_v;
|
||||
if (m.sync === 'volume') {
|
||||
const sx = m.min_freq;
|
||||
const sw = m.max_freq - m.min_freq;
|
||||
const sy = h - (m.max_in * verticalFactor);
|
||||
const sh = (m.max_in - m.min_in) * verticalFactor;
|
||||
canvasCombos[canvasKeys[i]][1].strokeStyle = "rgb(255, 255, 255)"; // AUDIO COLOR
|
||||
canvasCombos[canvasKeys[i]][1].strokeRect(sx, sy, sw, sh);
|
||||
canvasCombos[canvasKeys[k]][1].lineWidth = 1; // AUDIO COLOR
|
||||
canvasCombos[canvasKeys[k]][1].strokeStyle = "rgb(255,255,255)"; // AUDIO COLOR
|
||||
canvasCombos[canvasKeys[k]][1].strokeRect(sx, sy, sw, sh);
|
||||
} else if (m.sync === 'pitch') {
|
||||
const m = mapping[layerID][canvasKeys[i]];
|
||||
const m = mapping[layerID][canvasKeys[k]];
|
||||
const sx = m.min_freq;
|
||||
const sw = m.max_freq - m.min_freq;
|
||||
const sy = 0;
|
||||
const sh = h;
|
||||
canvasCombos[canvasKeys[i]][1].strokeStyle = "rgb(255, 255, 255)"; // AUDIO COLOR
|
||||
canvasCombos[canvasKeys[i]][1].strokeRect(sx, sy, sw, sh);
|
||||
canvasCombos[canvasKeys[k]][1].lineWidth = 1; // AUDIO COLOR
|
||||
canvasCombos[canvasKeys[k]][1].strokeStyle = "rgb(255,255,255)"; // AUDIO COLOR
|
||||
canvasCombos[canvasKeys[k]][1].strokeRect(sx, sy, sw, sh);
|
||||
}
|
||||
}
|
||||
const propsToSet = [];
|
||||
|
@ -782,7 +806,7 @@ const Audio = function(tp, record) {
|
|||
const m = mapping[layer.id()][propTitle];
|
||||
switch (m.sync) {
|
||||
case 'volume': {
|
||||
let a = mapValue(max_v, m.min_in, m.max_in, m.min_out, m.max_out, true);
|
||||
let a = mapValue(m.max_v, m.min_in, m.max_in, m.min_out, m.max_out, true);
|
||||
m.value = m.value * m.smoothing + (1.0 - m.smoothing) * a;
|
||||
propsToSet.push({
|
||||
layer,
|
||||
|
@ -794,7 +818,10 @@ const Audio = function(tp, record) {
|
|||
break;
|
||||
}
|
||||
case 'pitch': {
|
||||
let a = mapValue(max_i, m.min_freq, m.max_freq, m.min_out, m.max_out, true);
|
||||
const mi = config.audio.ignoreOutboundFrequencies ? m.max_i : max_i;
|
||||
const ri = config.audio.ignoreOutboundFrequencies ? m.max_ri : max_ri;
|
||||
const fi = config.audio.pitchCombineFrequencies ? ri : mi;
|
||||
let a = mapValue(fi, m.min_freq, m.max_freq, m.min_out, m.max_out, true);
|
||||
m.value = m.value * m.smoothing + (1.0 - m.smoothing) * a;
|
||||
propsToSet.push({
|
||||
layer,
|
||||
|
@ -994,6 +1021,9 @@ const Audio = function(tp, record) {
|
|||
this.addAudioOptions = addAudioOptions;
|
||||
this.removeAudioOptions = removeAudioOptions;
|
||||
this.AudioMappingOptions = AudioMappingOptions;
|
||||
|
||||
// debug
|
||||
this.canvasCombos = canvasCombos;
|
||||
};
|
||||
|
||||
export {
|
||||
|
|
|
@ -89,6 +89,8 @@ const config = {
|
|||
fftBandsUsed: 256 / 2,
|
||||
fftHeight: 256 / 4,
|
||||
colorSeparateRGBA: true,
|
||||
ignoreOutboundFrequencies: true,
|
||||
pitchCombineFrequencies: false,
|
||||
},
|
||||
record: {
|
||||
ignoreProps: ['transformOrigin', 'fontFamily', 'text', 'mirror_x', 'mirror_y', 'mirror_xy'],
|
||||
|
|
Loading…
Reference in a new issue