Audio dynamic filter loading wip
This commit is contained in:
parent
820ee95496
commit
70c8078dd7
4 changed files with 145 additions and 63 deletions
|
@ -6,7 +6,6 @@ var CiderAudio = {
|
||||||
spatialNode : null,
|
spatialNode : null,
|
||||||
spatialInput: null,
|
spatialInput: null,
|
||||||
audioBands : null,
|
audioBands : null,
|
||||||
preampNode : null,
|
|
||||||
vibrantbassNode: null,
|
vibrantbassNode: null,
|
||||||
llpw: null,
|
llpw: null,
|
||||||
llpwEnabled: null
|
llpwEnabled: null
|
||||||
|
@ -30,7 +29,6 @@ var CiderAudio = {
|
||||||
CiderAudio.audioNodes.gainNode.disconnect(); } catch(e){}
|
CiderAudio.audioNodes.gainNode.disconnect(); } catch(e){}
|
||||||
try{ CiderAudio.audioNodes.spatialNode.disconnect();} catch(e){}
|
try{ CiderAudio.audioNodes.spatialNode.disconnect();} catch(e){}
|
||||||
try{
|
try{
|
||||||
// CiderAudio.audioNodes.preampNode.disconnect();
|
|
||||||
for (var i of CiderAudio.audioNodes.llpw){
|
for (var i of CiderAudio.audioNodes.llpw){
|
||||||
i.disconnect();
|
i.disconnect();
|
||||||
}
|
}
|
||||||
|
@ -47,8 +45,9 @@ var CiderAudio = {
|
||||||
spatialNode : null,
|
spatialNode : null,
|
||||||
spatialInput: null,
|
spatialInput: null,
|
||||||
audioBands : null,
|
audioBands : null,
|
||||||
preampNode : null,
|
|
||||||
vibrantbassNode: null,
|
vibrantbassNode: null,
|
||||||
|
llpw: null,
|
||||||
|
llpwEnabled: null
|
||||||
}
|
}
|
||||||
} catch (e) {}
|
} catch (e) {}
|
||||||
CiderAudio.source.connect(CiderAudio.context.destination);} catch(e){}
|
CiderAudio.source.connect(CiderAudio.context.destination);} catch(e){}
|
||||||
|
@ -119,17 +118,146 @@ var CiderAudio = {
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
equalizer: function (){
|
llpw_h2_2: function (status, hierarchy){
|
||||||
let BANDS = app.cfg.audio.equalizer.frequencies;
|
if (status == true) {
|
||||||
let GAIN = app.cfg.audio.equalizer.gain;
|
|
||||||
let Q = app.cfg.audio.equalizer.Q;
|
|
||||||
let VIBRANTBASSBANDS = app.cfg.audio.vibrantBass.frequencies;
|
|
||||||
let VIBRANTBASSGAIN = app.cfg.audio.vibrantBass.gain;
|
|
||||||
let VIBRANTBASSQ = app.cfg.audio.vibrantBass.Q;
|
|
||||||
let LLPW_Q = [5, 1, 3.536, 1.25, 8.409, 1.25, 14.14, 7.071, 5, 0.625, 16.82, 20, 20, 20, 28.28, 28.28, 28.28, 20, 33.64, 33.64, 10, 28.28, 7.071, 3.856];
|
let LLPW_Q = [5, 1, 3.536, 1.25, 8.409, 1.25, 14.14, 7.071, 5, 0.625, 16.82, 20, 20, 20, 28.28, 28.28, 28.28, 20, 33.64, 33.64, 10, 28.28, 7.071, 3.856];
|
||||||
let LLPW_GAIN = [0.38, -1.81, -0.23, -0.51, 0.4, 0.84, 0.36, -0.34, 0.27, -1.2, -0.42, -0.67, 0.81, 1.31, -0.71, 0.68, -1.04, 0.79, -0.73, -1.33, 1.17, 0.57, 0.35, 6.33];
|
let LLPW_GAIN = [0.38, -1.81, -0.23, -0.51, 0.4, 0.84, 0.36, -0.34, 0.27, -1.2, -0.42, -0.67, 0.81, 1.31, -0.71, 0.68, -1.04, 0.79, -0.73, -1.33, 1.17, 0.57, 0.35, 6.33];
|
||||||
let LLPW_FREQUENCIES = [16.452, 24.636, 37.134, 74.483, 159.54, 308.18, 670.21, 915.81, 1200.7, 2766.4, 2930.6, 4050.6, 4409.1, 5395.2, 5901.6, 6455.5, 7164.1, 7724.1, 8449, 10573, 12368, 14198, 17910, 18916];
|
let LLPW_FREQUENCIES = [16.452, 24.636, 37.134, 74.483, 159.54, 308.18, 670.21, 915.81, 1200.7, 2766.4, 2930.6, 4050.6, 4409.1, 5395.2, 5901.6, 6455.5, 7164.1, 7724.1, 8449, 10573, 12368, 14198, 17910, 18916];
|
||||||
CiderAudio.audioNodes.audioBands = []; CiderAudio.audioNodes.vibrantbassNode = []; CiderAudio.audioNodes.llpw = [];
|
CiderAudio.audioNodes.llpw = [];
|
||||||
|
for (i = 0; i < LLPW_FREQUENCIES.length; i++) {
|
||||||
|
CiderAudio.audioNodes.llpw[i] = CiderAudio.context.createBiquadFilter();
|
||||||
|
CiderAudio.audioNodes.llpw[i].type = 'peaking'; // 'peaking';
|
||||||
|
CiderAudio.audioNodes.llpw[i].frequency.value = LLPW_FREQUENCIES[i];
|
||||||
|
CiderAudio.audioNodes.llpw[i].Q.value = LLPW_Q[i];
|
||||||
|
CiderAudio.audioNodes.llpw[i].gain.value = LLPW_GAIN[i] * app.cfg.audio.ciderPPE_value * CiderAudio.audioNodes.llpwEnabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 1; i < LLPW_FREQUENCIES.length; i ++) {
|
||||||
|
CiderAudio.audioNodes.llpw[i-1].connect(CiderAudio.audioNodes.llpw[i]);
|
||||||
|
}
|
||||||
|
if (hierarchy === 2) {
|
||||||
|
try{
|
||||||
|
CiderAudio.audioNodes.llpw[LLPW_FREQUENCIES.length-1].disconnect();
|
||||||
|
CiderAudio.audioNodes.llpw[LLPW_FREQUENCIES.length-1].connect(CiderAudio.audioNodes.vibrantbassNode[0]);} catch(e){}}
|
||||||
|
|
||||||
|
else if (hierarchy === 1) {
|
||||||
|
try{
|
||||||
|
CiderAudio.audioNodes.llpw[LLPW_FREQUENCIES.length-1].disconnect();
|
||||||
|
CiderAudio.audioNodes.llpw[LLPW_FREQUENCIES.length-1].connect(CiderAudio.audioNodes.audioBands[0]);} catch(e){}}
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
try{
|
||||||
|
for (var i of CiderAudio.audioNodes.llpw){
|
||||||
|
i.disconnect();
|
||||||
|
}
|
||||||
|
CiderAudio.audioNodes.llpw = [];} catch(e){}
|
||||||
|
}
|
||||||
|
|
||||||
|
},
|
||||||
|
vibrantbass_h2_1: function (status){
|
||||||
|
if (status == true) {
|
||||||
|
let VIBRANTBASSBANDS = app.cfg.audio.vibrantBass.frequencies;
|
||||||
|
let VIBRANTBASSGAIN = app.cfg.audio.vibrantBass.gain;
|
||||||
|
let VIBRANTBASSQ = app.cfg.audio.vibrantBass.Q;
|
||||||
|
CiderAudio.audioNodes.vibrantbassNode = [];
|
||||||
|
|
||||||
|
for (i = 0; i < VIBRANTBASSBANDS.length; i++) {
|
||||||
|
CiderAudio.audioNodes.vibrantbassNode[i] = CiderAudio.context.createBiquadFilter();
|
||||||
|
CiderAudio.audioNodes.vibrantbassNode[i].type = 'peaking'; // 'peaking';
|
||||||
|
CiderAudio.audioNodes.vibrantbassNode[i].frequency.value = VIBRANTBASSBANDS[i];
|
||||||
|
CiderAudio.audioNodes.vibrantbassNode[i].Q.value = VIBRANTBASSQ[i];
|
||||||
|
CiderAudio.audioNodes.vibrantbassNode[i].gain.value = VIBRANTBASSGAIN[i] * app.cfg.audio.vibrantBass.multiplier;
|
||||||
|
}
|
||||||
|
|
||||||
|
for (i = 1; i < VIBRANTBASSBANDS.length; i ++) {
|
||||||
|
CiderAudio.audioNodes.vibrantbassNode[i-1].connect(CiderAudio.audioNodes.vibrantbassNode[i]);
|
||||||
|
}
|
||||||
|
|
||||||
|
CiderAudio.audioNodes.vibrantbassNode[VIBRANTBASSBANDS.length-1].connect(CiderAudio.audioNodes.audioBands[0]);
|
||||||
|
}
|
||||||
|
|
||||||
|
else {
|
||||||
|
try {
|
||||||
|
for (var i of CiderAudio.audioNodes.vibrantbassNode){
|
||||||
|
i.disconnect();
|
||||||
|
}
|
||||||
|
CiderAudio.audioNodes.vibrantbassNode = [];} catch(e){}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
hierarchical_loading: function (){
|
||||||
|
if (app.cfg.audio.vibrantBass.multiplier != 0) { // If vibrant bass is enabled
|
||||||
|
if (CiderAudio.audioNodes.llpwEnabled == 1) { // If CAP & vibrant bass is enabled
|
||||||
|
CiderAudio.vibrantbass_h2_1(true)
|
||||||
|
CiderAudio.llpw_h2_2(true, 2)
|
||||||
|
}
|
||||||
|
else { // If only vibrant bass is enabled
|
||||||
|
CiderAudio.vibrantbass_h2_1(true)
|
||||||
|
CiderAudio.llpw_h2_2(false, 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else { // If vibrant bass is disabled
|
||||||
|
if (CiderAudio.audioNodes.llpwEnabled == 1) { // If CAP is enabled & vibrant bass is disabled
|
||||||
|
CiderAudio.vibrantbass_h2_1(false)
|
||||||
|
CiderAudio.llpw_h2_2(true, 1)
|
||||||
|
}
|
||||||
|
else { // If CAP & vibrant bass is disabled
|
||||||
|
CiderAudio.vibrantbass_h2_1(false)
|
||||||
|
CiderAudio.llpw_h2_2(false, 0)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (app.cfg.audio.spatial) {
|
||||||
|
try{
|
||||||
|
CiderAudio.audioNodes.spatialNode.output.disconnect(CiderAudio.context.destination);
|
||||||
|
if (app.cfg.audio.vibrantBass.multiplier != 0) { // If vibrant bass is enabled
|
||||||
|
if (CiderAudio.audioNodes.llpwEnabled == 1) { // If CAP & vibrant bass is enabled
|
||||||
|
CiderAudio.audioNodes.spatialNode.output.connect(CiderAudio.audioNodes.llpw[0]);
|
||||||
|
}
|
||||||
|
else { // If only vibrant bass is enabled
|
||||||
|
CiderAudio.audioNodes.spatialNode.output.connect(CiderAudio.audioNodes.vibrantbassNode[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else { // If vibrant bass is disabled
|
||||||
|
if (CiderAudio.audioNodes.llpwEnabled == 1) { // If CAP is enabled & vibrant bass is disabled
|
||||||
|
CiderAudio.audioNodes.spatialNode.output.connect(CiderAudio.audioNodes.llpw[0]);
|
||||||
|
}
|
||||||
|
else { // If CAP & vibrant bass is disabled
|
||||||
|
CiderAudio.audioNodes.spatialNode.output.connect(CiderAudio.audioNodes.audioBands[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch(e){}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
try{
|
||||||
|
CiderAudio.audioNodes.gainNode.disconnect(CiderAudio.context.destination);
|
||||||
|
if (app.cfg.audio.vibrantBass.multiplier != 0) { // If vibrant bass is enabled
|
||||||
|
if (CiderAudio.audioNodes.llpwEnabled == 1) { // If CAP & vibrant bass is enabled
|
||||||
|
CiderAudio.audioNodes.gainNode.connect(CiderAudio.audioNodes.llpw[0]);
|
||||||
|
}
|
||||||
|
else { // If only vibrant bass is enabled
|
||||||
|
CiderAudio.audioNodes.gainNode.connect(CiderAudio.audioNodes.vibrantbassNode[0]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else { // If vibrant bass is disabled
|
||||||
|
if (CiderAudio.audioNodes.llpwEnabled == 1) { // If CAP is enabled & vibrant bass is disabled
|
||||||
|
CCiderAudio.audioNodes.gainNode.connect(CiderAudio.audioNodes.llpw[0]);
|
||||||
|
}
|
||||||
|
else { // If CAP & vibrant bass is disabled
|
||||||
|
CCiderAudio.audioNodes.gainNode.connect(CiderAudio.audioNodes.audioBands[0]);
|
||||||
|
}
|
||||||
|
}} catch(e){}
|
||||||
|
|
||||||
|
}
|
||||||
|
console.log("[Cider][Audio] Finished hierarchical loading");
|
||||||
|
|
||||||
|
},
|
||||||
|
|
||||||
|
equalizer: function (){ // h1_1
|
||||||
|
let BANDS = app.cfg.audio.equalizer.frequencies;
|
||||||
|
let GAIN = app.cfg.audio.equalizer.gain;
|
||||||
|
let Q = app.cfg.audio.equalizer.Q;
|
||||||
|
|
||||||
|
CiderAudio.audioNodes.audioBands = [];
|
||||||
|
|
||||||
for (i = 0; i < BANDS.length; i++) {
|
for (i = 0; i < BANDS.length; i++) {
|
||||||
CiderAudio.audioNodes.audioBands[i] = CiderAudio.context.createBiquadFilter();
|
CiderAudio.audioNodes.audioBands[i] = CiderAudio.context.createBiquadFilter();
|
||||||
|
@ -139,50 +267,8 @@ var CiderAudio = {
|
||||||
CiderAudio.audioNodes.audioBands[i].gain.value = GAIN[i] * app.cfg.audio.equalizer.mix;
|
CiderAudio.audioNodes.audioBands[i].gain.value = GAIN[i] * app.cfg.audio.equalizer.mix;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (i = 0; i < LLPW_FREQUENCIES.length; i++) {
|
// Dynamic-ish loading
|
||||||
CiderAudio.audioNodes.llpw[i] = CiderAudio.context.createBiquadFilter();
|
CiderAudio.hierarchical_loading();
|
||||||
CiderAudio.audioNodes.llpw[i].type = 'peaking'; // 'peaking';
|
|
||||||
CiderAudio.audioNodes.llpw[i].frequency.value = LLPW_FREQUENCIES[i];
|
|
||||||
CiderAudio.audioNodes.llpw[i].Q.value = LLPW_Q[i];
|
|
||||||
CiderAudio.audioNodes.llpw[i].gain.value = LLPW_GAIN[i] * app.cfg.audio.ciderPPE_value * CiderAudio.audioNodes.llpwEnabled;
|
|
||||||
}
|
|
||||||
/**
|
|
||||||
CiderAudio.audioNodes.preampNode = CiderAudio.context.createBiquadFilter();
|
|
||||||
CiderAudio.audioNodes.preampNode.type = 'highshelf';
|
|
||||||
CiderAudio.audioNodes.preampNode.frequency.value = 0; // Passthrough
|
|
||||||
CiderAudio.audioNodes.preampNode.gain.value = 0;
|
|
||||||
/** if (CiderAudio.audioNodes.llpwEnabled === 1) {CiderAudio.audioNodes.preampNode.gain.value = (-Math.max(...app.cfg.audio.equalizer.gain.concat(CiderAudio.audioNodes.llpw[23].gain.value)));}
|
|
||||||
else {CiderAudio.audioNodes.preampNode.gain.value = (-Math.max(...app.cfg.audio.equalizer.gain));}*/
|
|
||||||
|
|
||||||
for (i = 0; i < VIBRANTBASSBANDS.length; i++) {
|
|
||||||
CiderAudio.audioNodes.vibrantbassNode[i] = CiderAudio.context.createBiquadFilter();
|
|
||||||
CiderAudio.audioNodes.vibrantbassNode[i].type = 'peaking'; // 'peaking';
|
|
||||||
CiderAudio.audioNodes.vibrantbassNode[i].frequency.value = VIBRANTBASSBANDS[i];
|
|
||||||
CiderAudio.audioNodes.vibrantbassNode[i].Q.value = VIBRANTBASSQ[i];
|
|
||||||
CiderAudio.audioNodes.vibrantbassNode[i].gain.value = VIBRANTBASSGAIN[i] * app.cfg.audio.vibrantBass.multiplier;}
|
|
||||||
|
|
||||||
|
|
||||||
if (app.cfg.audio.spatial) {
|
|
||||||
try{
|
|
||||||
CiderAudio.audioNodes.spatialNode.output.disconnect(CiderAudio.context.destination); } catch(e){}
|
|
||||||
CiderAudio.audioNodes.spatialNode.output.connect(CiderAudio.audioNodes.llpw[0]);
|
|
||||||
} else {
|
|
||||||
try{
|
|
||||||
CiderAudio.audioNodes.gainNode.disconnect(CiderAudio.context.destination);} catch(e){}
|
|
||||||
CiderAudio.audioNodes.gainNode.connect(CiderAudio.audioNodes.llpw[0]);
|
|
||||||
}
|
|
||||||
|
|
||||||
// CiderAudio.audioNodes.preampNode.connect(CiderAudio.audioNodes.llpw[0]);
|
|
||||||
|
|
||||||
for (i = 1; i < LLPW_FREQUENCIES.length; i ++) {
|
|
||||||
CiderAudio.audioNodes.llpw[i-1].connect(CiderAudio.audioNodes.llpw[i]);
|
|
||||||
}
|
|
||||||
CiderAudio.audioNodes.llpw[LLPW_FREQUENCIES.length-1].connect(CiderAudio.audioNodes.vibrantbassNode[0]);
|
|
||||||
for (i = 1; i < VIBRANTBASSBANDS.length; i ++) {
|
|
||||||
CiderAudio.audioNodes.vibrantbassNode[i-1].connect(CiderAudio.audioNodes.vibrantbassNode[i]);
|
|
||||||
}
|
|
||||||
CiderAudio.audioNodes.vibrantbassNode[VIBRANTBASSBANDS.length-1].connect(CiderAudio.audioNodes.audioBands[0]);
|
|
||||||
|
|
||||||
|
|
||||||
for (i = 1; i < BANDS.length; i ++) {
|
for (i = 1; i < BANDS.length; i ++) {
|
||||||
CiderAudio.audioNodes.audioBands[i-1].connect(CiderAudio.audioNodes.audioBands[i]);
|
CiderAudio.audioNodes.audioBands[i-1].connect(CiderAudio.audioNodes.audioBands[i]);
|
||||||
|
|
|
@ -2354,7 +2354,7 @@ const app = new Vue({
|
||||||
if (extendedAssets.attributes.audioTraits.includes('lossless')) {*/
|
if (extendedAssets.attributes.audioTraits.includes('lossless')) {*/
|
||||||
app.mk.nowPlayingItem['attributes']['lossless'] = true
|
app.mk.nowPlayingItem['attributes']['lossless'] = true
|
||||||
CiderAudio.audioNodes.llpwEnabled = 1
|
CiderAudio.audioNodes.llpwEnabled = 1
|
||||||
console.log("[Cider][Enhanced] Audio being processed by PPE")
|
console.log("[Cider][Audio] PPE Kicking in...");
|
||||||
/**}
|
/**}
|
||||||
else {
|
else {
|
||||||
CiderAudio.audioNodes.llpwEnabled = 0
|
CiderAudio.audioNodes.llpwEnabled = 0
|
||||||
|
|
|
@ -316,20 +316,16 @@
|
||||||
app.cfg.audio.vibrantBass.multiplier = app.cfg.audio.equalizer.vibrantBass / 10
|
app.cfg.audio.vibrantBass.multiplier = app.cfg.audio.equalizer.vibrantBass / 10
|
||||||
for (var i = 0; i < 21; i++) {
|
for (var i = 0; i < 21; i++) {
|
||||||
CiderAudio.audioNodes.vibrantbassNode[i].gain.value = app.cfg.audio.vibrantBass.gain[i] * (app.cfg.audio.equalizer.vibrantBass / 10);
|
CiderAudio.audioNodes.vibrantbassNode[i].gain.value = app.cfg.audio.vibrantBass.gain[i] * (app.cfg.audio.equalizer.vibrantBass / 10);
|
||||||
}
|
}
|
||||||
|
CiderAudio.hierarchical_loading();
|
||||||
},
|
},
|
||||||
changeMix() {
|
changeMix() {
|
||||||
for (var i = 0; i < 10; i++) {
|
for (var i = 0; i < 10; i++) {
|
||||||
CiderAudio.audioNodes.audioBands[i].gain.value = app.cfg.audio.equalizer.gain[i] * app.cfg.audio.equalizer.mix
|
CiderAudio.audioNodes.audioBands[i].gain.value = app.cfg.audio.equalizer.gain[i] * app.cfg.audio.equalizer.mix
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
changePreamp() {
|
|
||||||
/** if (CiderAudio.audioNodes.llpwEnabled === 1) {CiderAudio.audioNodes.preampNode.gain.value = (-Math.max(...app.cfg.audio.equalizer.gain.concat(CiderAudio.audioNodes.llpw[23].gain.value)));}
|
|
||||||
else {CiderAudio.audioNodes.preampNode.gain.value = (-Math.max(...app.cfg.audio.equalizer.gain));} */
|
|
||||||
},
|
|
||||||
changeGain(i) {
|
changeGain(i) {
|
||||||
CiderAudio.audioNodes.audioBands[i].gain.value = app.cfg.audio.equalizer.gain[i] * app.cfg.audio.equalizer.mix
|
CiderAudio.audioNodes.audioBands[i].gain.value = app.cfg.audio.equalizer.gain[i] * app.cfg.audio.equalizer.mix
|
||||||
this.changePreamp()
|
|
||||||
},
|
},
|
||||||
changeFreq(i) {
|
changeFreq(i) {
|
||||||
CiderAudio.audioNodes.audioBands[i].frequency.value = app.cfg.audio.equalizer.frequencies[i]
|
CiderAudio.audioNodes.audioBands[i].frequency.value = app.cfg.audio.equalizer.frequencies[i]
|
||||||
|
@ -345,7 +341,6 @@
|
||||||
'mix': 1,
|
'mix': 1,
|
||||||
'vibrantBass': 0,
|
'vibrantBass': 0,
|
||||||
})
|
})
|
||||||
CiderAudio.audioNodes.preampNode.gain.value = 0;
|
|
||||||
if (app.cfg.audio.equalizer.userGenerated) {
|
if (app.cfg.audio.equalizer.userGenerated) {
|
||||||
this.saveSelectedPreset()
|
this.saveSelectedPreset()
|
||||||
}
|
}
|
||||||
|
|
|
@ -846,6 +846,7 @@
|
||||||
notyf.error(app.getLz('settings.warn.audio.enableAdvancedFunctionality.ciderPPE.compatibility'))
|
notyf.error(app.getLz('settings.warn.audio.enableAdvancedFunctionality.ciderPPE.compatibility'))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
CiderAudio.hierarchical_loading();
|
||||||
},
|
},
|
||||||
toggleSpatial: function () {
|
toggleSpatial: function () {
|
||||||
if (app.cfg.audio.spatial) {
|
if (app.cfg.audio.spatial) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue