Skip to content
Snippets Groups Projects
Commit b61b9eb6 authored by RANWEZ Pierre's avatar RANWEZ Pierre :anchor:
Browse files

:bug: bug: range parse int

parent fb7a258c
Branches
Tags
1 merge request!1✨ feat: CSSLSD V2
...@@ -156,7 +156,7 @@ function midiEvent(type, data) { ...@@ -156,7 +156,7 @@ function midiEvent(type, data) {
midiValue = data.value; midiValue = data.value;
templates = templateToDict(event['value']); templates = templateToDict(event['value']);
templates.forEach(template => { templates.forEach(template => {
midiValue = midiValue * template['max']; midiValue =(template['min'] + ((template['max']-template['min'])*midiValue));
if (type == 'noteon' && template['eventType'] == 'noteon' && template['eventName'] == data.note.name) { if (type == 'noteon' && template['eventType'] == 'noteon' && template['eventName'] == data.note.name) {
value = event['value'].replace('[' + template['templateFull'] + ']', midiValue); value = event['value'].replace('[' + template['templateFull'] + ']', midiValue);
let els = document.querySelectorAll(event['selector']); let els = document.querySelectorAll(event['selector']);
...@@ -430,21 +430,17 @@ function audioEvent() { ...@@ -430,21 +430,17 @@ function audioEvent() {
if (min == 0) { if (min == 0) {
min = 1; min = 1;
} }
if (template['eventType'] == 'energy' && template['eventName'] == 'bass') { Object.keys(presets).forEach(preset => {
if (template['eventType'] == 'energy' && template['eventName'] == preset) {
eventIn = true; eventIn = true;
value = value.replace('[' + template['templateFull'] + ']', (energies['bass'] * min + (template['max'] - template['min']))); value = value.replace('[' + template['templateFull'] + ']', parseInt(template['min'])+Math.round((template['max']-template['min'])*energies[preset]));
}
if (template['eventType'] == 'energy' && template['eventName'] == 'mid') {
eventIn = true;
value = value.replace('[' + template['templateFull'] + ']', (energies['mid'] * min + (template['max'] - template['min'])));
}
if (template['eventType'] == 'energy' && template['eventName'] == 'treble') {
eventIn = true;
value = value.replace('[' + template['templateFull'] + ']', (energies['treble'] * min + (template['max'] - template['min'])));
} }
});
if (template['eventType'] == 'meter' && template['eventName'] == 'volume') { if (template['eventType'] == 'meter' && template['eventName'] == 'volume') {
eventIn = true; eventIn = true;
value = value.replace('[' + template['templateFull'] + ']', (meter.volume * template['max'])); volume = meter.volume * 1.4;
// value = value.replace('[' + template['templateFull'] + ']', (template['max'] * meter.volume));
value = value.replace('[' + template['templateFull'] + ']', (meter.volume * 1.4<1?parseInt(template['min'])+Math.round((template['max']-template['min'])*volume):0));
} }
if (event['value'].includes('[audio.noteon.' + noteStrings[note % 12] + ']')) { if (event['value'].includes('[audio.noteon.' + noteStrings[note % 12] + ']')) {
eventIn = true; eventIn = true;
...@@ -457,7 +453,6 @@ function audioEvent() { ...@@ -457,7 +453,6 @@ function audioEvent() {
}); });
if (eventIn) { if (eventIn) {
let els = document.querySelectorAll(event['selector']); let els = document.querySelectorAll(event['selector']);
console.log(value);
els.forEach(e => { els.forEach(e => {
e.style[event['property']] = value; e.style[event['property']] = value;
}); });
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment