- 优化样式代码
This commit is contained in:
parent
613857c67f
commit
e7e3946492
BIN
Locales/ja_JP.qm
BIN
Locales/ja_JP.qm
Binary file not shown.
BIN
Locales/zh.qm
BIN
Locales/zh.qm
Binary file not shown.
BIN
Locales/zh_CN.qm
BIN
Locales/zh_CN.qm
Binary file not shown.
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<map>
|
||||
<value name="current_style">"nvg://advp.widget.mashiros.top/advp-style-preset/gradient_line"</value>
|
||||
<value name="nvg://advp.widget.mashiros.top/advp-style-preset/gradient_line">{"Gradient Direction":0,"Start Position Color":"#f44336","Middle Position Color":"#4caf50","End Position Color":"#03a9f4","Center Line":true,"Line Position":0,"Data Length":0,"Channel":2,"Reverse":false,"Rotate Settings":{"Center Enable":false,"Center Angle":10,"Line Enable":false,"Line Angle":10},"Data Settings":{"Auto Normalizing":true,"Amplitude":10,"Unit Style":0}}</value>
|
||||
<value name="nvg://advp.widget.mashiros.top/advp-style-preset/gradient_line">{"Gradient Direction":0,"Start Position Color":"#f44336","Middle Position Color":"#4caf50","End Position Color":"#03a9f4","Center Line":true,"Line Position":0,"Data Length":0,"Channel":2,"Rotate Settings":{"Center Enable":false,"Center Angle":10,"Line Enable":false,"Line Angle":10},"Data Settings":{"Auto Normalizing":true,"Amplitude":10,"Unit Style":0}}</value>
|
||||
</map>
|
||||
@ -1,5 +1,5 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<map>
|
||||
<value name="nvg://advp.widget.mashiros.top/advp-style-preset/line">{"Center Line":true,"Center Color":"#ff4500","Line Color":"#ff4500","Line Position":0,"Data Length":0,"Channel":2,"Reverse":false,"Rotate Settings":{"Center Enable":false,"Center Angle":10,"Line Enable":false,"Line Angle":10},"Data Settings":{"Auto Normalizing":true,"Amplitude":10,"Unit Style":0}}</value>
|
||||
<value name="nvg://advp.widget.mashiros.top/advp-style-preset/line">{"Center Line":true,"Center Color":"#ff4500","Line Color":"#ff4500","Line Position":0,"Data Length":0,"Channel":2,"Rotate Settings":{"Center Enable":false,"Center Angle":10,"Line Enable":false,"Line Angle":10},"Data Settings":{"Auto Normalizing":true,"Amplitude":10,"Unit Style":0}}</value>
|
||||
<value name="current_style">"nvg://advp.widget.mashiros.top/advp-style-preset/line"</value>
|
||||
</map>
|
||||
@ -77,8 +77,8 @@ NVG.Window {
|
||||
onPreferenceEdited: {
|
||||
if (widget.settings.current_style !== Common.stylesURL[styleList.value]) {
|
||||
widget.settings[widget.settings.current_style] = old_style_cfg;
|
||||
old_style_cfg = widget.settings[Common.stylesURL[styleList.value]];
|
||||
widget.settings.current_style = Common.stylesURL[styleList.value];
|
||||
old_style_cfg = widget.settings[widget.settings.current_style];
|
||||
}
|
||||
let cfg = rootPreference.save();
|
||||
widget.settings[widget.settings.current_style] = cfg[widget.settings.current_style];
|
||||
|
||||
File diff suppressed because one or more lines are too long
@ -18,7 +18,7 @@ AdvpStyleTemplate {
|
||||
readonly property real rSpeed: configs["Ratate Speed"] / 100
|
||||
readonly property real angle: configs["Angle"]
|
||||
readonly property bool autoNormalizing: configs["Data Settings"]["Auto Normalizing"]
|
||||
readonly property real amplitude: configs["Data Settings"]["Amplitude"] / 400
|
||||
readonly property real amplitude: 400/configs["Data Settings"]["Amplitude"]
|
||||
readonly property int unitStyle: configs["Data Settings"]["Unit Style"]
|
||||
|
||||
readonly property int total: channel*dataLength
|
||||
@ -37,7 +37,6 @@ AdvpStyleTemplate {
|
||||
readonly property real halfWidth: width/2
|
||||
readonly property real halfHeight: height/2
|
||||
readonly property real halfMinLength: minLength/2
|
||||
readonly property real logAmplitude: Math.log10(amplitude)
|
||||
|
||||
|
||||
onConfigsUpdated: {
|
||||
@ -45,13 +44,9 @@ AdvpStyleTemplate {
|
||||
context.strokeStyle = configs["Main Color"];
|
||||
}
|
||||
|
||||
function getPos(r, deg) {
|
||||
return [halfWidth+Math.cos(deg)*r,halfHeight+Math.sin(deg)*r];
|
||||
}
|
||||
|
||||
function createPoint() {
|
||||
outerPos = [];
|
||||
innerPos = [];
|
||||
outerPos.length = 0;
|
||||
innerPos.length = 0;
|
||||
let deg, deltaR, r1, r2, _rhmLen;
|
||||
_rhmLen = mainRatio*halfMinLength;
|
||||
|
||||
@ -61,56 +56,35 @@ AdvpStyleTemplate {
|
||||
deltaR = audioData[reverse*(dataLength-i-1)+(!reverse)*(i+j*dataLength)] * ratio;
|
||||
r1 = _rhmLen+1+deltaR*(linePosition!==2);
|
||||
r2 = _rhmLen-1-deltaR*(linePosition!==1);
|
||||
outerPos.push(getPos(r1, deg));
|
||||
innerPos.push(getPos(r2, deg));
|
||||
outerPos.push([halfWidth+Math.cos(deg)*r1,halfHeight+Math.sin(deg)*r1]);
|
||||
innerPos.push([halfWidth+Math.cos(deg)*r2,halfHeight+Math.sin(deg)*r2]);
|
||||
}
|
||||
}
|
||||
offsetAngle = rotateFlag ? ((offsetAngle + rSpeed) % 360) : angle;
|
||||
}
|
||||
|
||||
onAudioDataUpdeted: {
|
||||
if(autoNormalizing) {
|
||||
if (unitStyle) {
|
||||
//对数化显示
|
||||
let logPeak = Math.log10(data[128]);
|
||||
for(let i=0; i<total; i++) {
|
||||
audioData[i] = 0;
|
||||
for(let j=0; j<uDataLen; j++) {
|
||||
audioData[i] += Math.max(0, 0.4 * (Math.log10(data[i*uDataLen+j])-logPeak) + 1.0);
|
||||
}
|
||||
audioData[i] /= uDataLen;
|
||||
}
|
||||
} else {
|
||||
//线性化显示
|
||||
for(let i=0; i<total; i++) {
|
||||
audioData[i] = 0;
|
||||
for(let j=0; j<uDataLen; j++) {
|
||||
audioData[i] += data[i*uDataLen+j] / data[128];
|
||||
}
|
||||
audioData[i] /= uDataLen;
|
||||
let normalizing_ratio = autoNormalizing ? data[128] : amplitude;
|
||||
if (unitStyle) {
|
||||
//对数化显示
|
||||
for(let i=0; i<total; i++) {
|
||||
audioData[i] = 0;
|
||||
for(let j=0; j<uDataLen; j++) {
|
||||
audioData[i] += Math.max(0, 0.4 * (Math.log10(data[i*uDataLen+j]/normalizing_ratio)) + 1.0);
|
||||
}
|
||||
audioData[i] /= uDataLen;
|
||||
}
|
||||
} else {
|
||||
if (unitStyle) {
|
||||
//对数化显示
|
||||
for(let i=0; i<total; i++) {
|
||||
audioData[i] = 0;
|
||||
for(let j=0; j<uDataLen; j++) {
|
||||
audioData[i] += Math.max(0, 0.35 * (Math.log10(data[i*uDataLen+j])+logAmplitude) + 1.0);
|
||||
}
|
||||
audioData[i] /= uDataLen;
|
||||
}
|
||||
} else {
|
||||
//线性化显示
|
||||
for(let i=0; i<total; i++) {
|
||||
audioData[i] = 0;
|
||||
for(let j=0; j<uDataLen; j++) {
|
||||
audioData[i] += data[i*uDataLen+j] * amplitude;
|
||||
}
|
||||
audioData[i] /= uDataLen;
|
||||
//线性化显示
|
||||
for(let i=0; i<total; i++) {
|
||||
audioData[i] = 0;
|
||||
for(let j=0; j<uDataLen; j++) {
|
||||
audioData[i] += data[i*uDataLen+j];
|
||||
}
|
||||
audioData[i] /= (uDataLen * normalizing_ratio);
|
||||
}
|
||||
}
|
||||
|
||||
context.clearRect(0, 0, width+32, height+32);
|
||||
createPoint();
|
||||
|
||||
@ -131,7 +105,7 @@ AdvpStyleTemplate {
|
||||
}
|
||||
|
||||
defaultValues: {
|
||||
"Version": "1.0.0",
|
||||
"Version": "1.1.0",
|
||||
"Main Color": "#ff4500",
|
||||
"Line Position": 0,
|
||||
"Line Width": 1,
|
||||
|
||||
@ -29,22 +29,27 @@ AdvpStyleTemplate {
|
||||
readonly property int uDataLen: Math.pow(2, configs["Data Length"]);
|
||||
readonly property int dataLength: 64/uDataLen
|
||||
readonly property int channel: configs["Channel"]
|
||||
readonly property bool reverse: configs["Reverse"]
|
||||
readonly property bool centerRotateFlag: configs["Rotate Settings"]["Center Enable"]
|
||||
readonly property real centerRotateAngle: configs["Rotate Settings"]["Center Angle"]
|
||||
readonly property bool lineRotateFlag: configs["Rotate Settings"]["Line Enable"]
|
||||
readonly property real lineRotateAngle: configs["Rotate Settings"]["Line Angle"]
|
||||
readonly property bool autoNormalizing: configs["Data Settings"]["Auto Normalizing"]
|
||||
readonly property real amplitude: configs["Data Settings"]["Amplitude"] / 400.0
|
||||
readonly property real amplitude: 400.0/configs["Data Settings"]["Amplitude"]
|
||||
readonly property int unitStyle: configs["Data Settings"]["Unit Style"]
|
||||
|
||||
property int total: channel * dataLength
|
||||
property real logAmplitude: Math.log10(amplitude)
|
||||
property real degUnit: Math.PI / 180
|
||||
|
||||
property real halfWidth: width/2
|
||||
property real halfHeight: height/2
|
||||
|
||||
readonly property int l_start: (channel===1)*dataLength
|
||||
readonly property int r_stop: dataLength+dataLength*(channel!==0)
|
||||
|
||||
readonly property int total: r_stop-l_start
|
||||
readonly property real _y_dy: centerRotateFlag*Math.tan(centerRotateAngle*degUnit)*halfWidth
|
||||
readonly property real _ux: width/(r_stop-l_start)
|
||||
readonly property real _dx: Math.round(_ux/2)
|
||||
|
||||
onConfigsUpdated: {
|
||||
context.fillStyle = "black";
|
||||
gradient_mask.start = Qt.point(0, height*(configs["Gradient Direction"]===2))
|
||||
@ -55,91 +60,44 @@ AdvpStyleTemplate {
|
||||
}
|
||||
|
||||
onAudioDataUpdeted: {
|
||||
if(autoNormalizing) {
|
||||
if (unitStyle) {
|
||||
//对数化显示
|
||||
for(let i=0; i<dataLength; i++) {
|
||||
audioData[i] = 0;
|
||||
for(let j=0; j<uDataLen; j++) {
|
||||
audioData[i] += Math.max(0, 0.4 * (Math.log10(data[64-i*uDataLen-j-1]/data[128])) + 1.0);
|
||||
}
|
||||
audioData[i] /= uDataLen;
|
||||
let normalizing_ratio = autoNormalizing ? data[128] : amplitude;
|
||||
if (unitStyle) {
|
||||
//对数化显示
|
||||
for(let i=l_start; i<dataLength; i++) {
|
||||
audioData[i] = 0;
|
||||
for(let j=0; j<uDataLen; j++) {
|
||||
audioData[i] += Math.max(0, 0.4 * (Math.log10(data[63-i*uDataLen-j]/normalizing_ratio)) + 1.0);
|
||||
}
|
||||
if (channel === 2) {
|
||||
for(let i=dataLength; i<total; i++) {
|
||||
audioData[i] = 0;
|
||||
for(let j=0; j<uDataLen; j++) {
|
||||
audioData[i] += Math.max(0, 0.4 * (Math.log10(data[64+(i-dataLength)*uDataLen+j]/data[128])) + 1.0);
|
||||
}
|
||||
audioData[i] /= uDataLen;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//线性化显示
|
||||
for(let i=0; i<dataLength; i++) {
|
||||
audioData[i] = 0;
|
||||
for(let j=0; j<uDataLen; j++) {
|
||||
audioData[i] += data[64-i*uDataLen-j-1];
|
||||
}
|
||||
audioData[i] /= (uDataLen * data[128]);
|
||||
}
|
||||
if (channel === 2) {
|
||||
for(let i=dataLength; i<total; i++) {
|
||||
audioData[i] = 0;
|
||||
for(let j=0; j<uDataLen; j++) {
|
||||
audioData[i] += data[64+(i-dataLength)*uDataLen+j];
|
||||
}
|
||||
audioData[i] /= (uDataLen * data[128]);
|
||||
}
|
||||
audioData[i] /= uDataLen;
|
||||
}
|
||||
for(let i=dataLength; i<r_stop; i++) {
|
||||
audioData[i] = 0;
|
||||
for(let j=0; j<uDataLen; j++) {
|
||||
audioData[i] += Math.max(0, 0.4 * (Math.log10(data[i*uDataLen+j]/normalizing_ratio)) + 1.0);
|
||||
}
|
||||
audioData[i] /= uDataLen;
|
||||
}
|
||||
} else {
|
||||
if (unitStyle) {
|
||||
//对数化显示
|
||||
for(let i=0; i<dataLength; i++) {
|
||||
audioData[i] = 0;
|
||||
for(let j=0; j<uDataLen; j++) {
|
||||
audioData[i] += Math.max(0, 0.35 * (Math.log10(data[64-i*uDataLen-j-1])+logAmplitude) + 1.0);
|
||||
}
|
||||
audioData[i] /= uDataLen;
|
||||
//线性化显示
|
||||
for(let i=l_start; i<dataLength; i++) {
|
||||
audioData[i] = 0;
|
||||
for(let j=0; j<uDataLen; j++) {
|
||||
audioData[i] += data[63-i*uDataLen-j];
|
||||
}
|
||||
if (channel === 2) {
|
||||
for(let i=dataLength; i<total; i++) {
|
||||
audioData[i] = 0;
|
||||
for(let j=0; j<uDataLen; j++) {
|
||||
audioData[i] += Math.max(0, 0.35 * (Math.log10(data[64+(i-dataLength)*uDataLen+j])+logAmplitude) + 1.0);
|
||||
}
|
||||
audioData[i] /= uDataLen;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//线性化显示
|
||||
for(let i=0; i<dataLength; i++) {
|
||||
audioData[i] = 0;
|
||||
for(let j=0; j<uDataLen; j++) {
|
||||
audioData[i] += data[64-i*uDataLen-j-1];
|
||||
}
|
||||
audioData[i] /= (uDataLen/amplitude);
|
||||
}
|
||||
if (channel === 2) {
|
||||
for(let i=dataLength; i<total; i++) {
|
||||
audioData[i] = 0;
|
||||
for(let j=0; j<uDataLen; j++) {
|
||||
audioData[i] += data[64+(i-dataLength)*uDataLen+j];
|
||||
}
|
||||
audioData[i] /= (uDataLen/amplitude);
|
||||
}
|
||||
audioData[i] /= (uDataLen * normalizing_ratio);
|
||||
}
|
||||
for(let i=dataLength; i<r_stop; i++) {
|
||||
audioData[i] = 0;
|
||||
for(let j=0; j<uDataLen; j++) {
|
||||
audioData[i] += data[i*uDataLen+j];
|
||||
}
|
||||
audioData[i] /= (uDataLen * normalizing_ratio);
|
||||
}
|
||||
}
|
||||
let _dy;
|
||||
let _y_dy = centerRotateFlag*Math.tan(centerRotateAngle*degUnit)*halfWidth;
|
||||
let _ux = width/total;
|
||||
let _dx = Math.round(_ux/2);
|
||||
let _y = halfHeight-_y_dy
|
||||
|
||||
context.clearRect(0, 0, width+32, height+32);
|
||||
|
||||
let _y = halfHeight-_y_dy;
|
||||
if(lineRotateFlag || centerRotateFlag) {
|
||||
context.transform(1, centerRotateFlag*centerRotateAngle * degUnit, -lineRotateFlag*lineRotateAngle * degUnit, 1, lineRotateFlag*Math.sin(1.05*lineRotateAngle*degUnit)*_y, 0);
|
||||
}
|
||||
@ -149,29 +107,18 @@ AdvpStyleTemplate {
|
||||
}
|
||||
|
||||
//绘制频谱
|
||||
if (channel === 1 && reverse) {
|
||||
for (let i = 0; i < dataLength; i++) {
|
||||
let index = dataLength - i - 1;
|
||||
_y = halfHeight*(1-(linePosition!==2)*audioData[index])-_y_dy;
|
||||
_dy = (halfHeight + (!linePosition)*halfHeight)*audioData[index];
|
||||
context.fillRect(_ux * i, _y, _dx, _dy);
|
||||
}
|
||||
} else {
|
||||
for (let j = 0; j < channel; j++) {
|
||||
for (let i = 0; i < dataLength; i++) {
|
||||
let index = j ? ((total - dataLength) + i) : i;
|
||||
_y = halfHeight*(1-(linePosition!==2)*audioData[index])-_y_dy;
|
||||
_dy = (halfHeight + (!linePosition)*halfHeight)*audioData[index];
|
||||
context.fillRect(_ux * (i + j * dataLength), _y, _dx, _dy);
|
||||
}
|
||||
}
|
||||
let _dy;
|
||||
for (let i=l_start; i<r_stop; i++) {
|
||||
_y = halfHeight*(1-(linePosition!==2)*audioData[i])-_y_dy;
|
||||
_dy = (halfHeight + (!linePosition)*halfHeight)*audioData[i];
|
||||
context.fillRect(_ux * (i-l_start), _y, _dx, _dy);
|
||||
}
|
||||
|
||||
|
||||
if (centerRotateFlag || lineRotateFlag)
|
||||
context.resetTransform();
|
||||
|
||||
context.fill();
|
||||
|
||||
requestPaint();
|
||||
}
|
||||
|
||||
@ -185,7 +132,7 @@ AdvpStyleTemplate {
|
||||
}
|
||||
|
||||
defaultValues: {
|
||||
"Version": "1.0.0",
|
||||
"Version": "1.1.0",
|
||||
"Gradient Direction": 0,
|
||||
"Start Position Color": "#f44336",
|
||||
"Middle Position Color": "#4caf50",
|
||||
@ -194,7 +141,6 @@ AdvpStyleTemplate {
|
||||
"Line Position": 0,
|
||||
"Data Length": 0,
|
||||
"Channel": 2,
|
||||
"Reverse": false,
|
||||
"Rotate Settings": {
|
||||
"Center Enable": false,
|
||||
"Center Angle": 10,
|
||||
@ -259,25 +205,11 @@ AdvpStyleTemplate {
|
||||
model: [64, 32, 16, 8]
|
||||
}
|
||||
|
||||
P.Separator {}
|
||||
|
||||
P.SpinPreference {
|
||||
id: _cfg_preset_line_Channel
|
||||
P.SelectPreference {
|
||||
name: "Channel"
|
||||
label: qsTr("Channel")
|
||||
message: "1 to 2"
|
||||
display: P.TextFieldPreference.ExpandLabel
|
||||
editable: false
|
||||
from: 1
|
||||
to: 2
|
||||
defaultValue: defaultValues["Channel"]
|
||||
}
|
||||
|
||||
P.SwitchPreference {
|
||||
name: "Reverse"
|
||||
label: qsTr("Reverse Spectrum")
|
||||
enabled: _cfg_preset_line_Channel.value === 1
|
||||
defaultValue: defaultValues["Reverse"]
|
||||
model: [qsTr("Left Channel"), qsTr("Right Channel"), qsTr("Stereo")]
|
||||
}
|
||||
|
||||
P.Separator {}
|
||||
|
||||
@ -14,108 +14,65 @@ AdvpStyleTemplate {
|
||||
readonly property int uDataLen: Math.pow(2, configs["Data Length"]);
|
||||
readonly property int dataLength: 64/uDataLen
|
||||
readonly property int channel: configs["Channel"]
|
||||
readonly property bool reverse: configs["Reverse"]
|
||||
readonly property bool centerRotateFlag: configs["Rotate Settings"]["Center Enable"]
|
||||
readonly property real centerRotateAngle: configs["Rotate Settings"]["Center Angle"]
|
||||
readonly property bool lineRotateFlag: configs["Rotate Settings"]["Line Enable"]
|
||||
readonly property real lineRotateAngle: configs["Rotate Settings"]["Line Angle"]
|
||||
readonly property bool autoNormalizing: configs["Data Settings"]["Auto Normalizing"]
|
||||
readonly property real amplitude: configs["Data Settings"]["Amplitude"] / 400.0
|
||||
readonly property real amplitude: 400.0/configs["Data Settings"]["Amplitude"]
|
||||
readonly property int unitStyle: configs["Data Settings"]["Unit Style"]
|
||||
|
||||
property int total: channel * dataLength
|
||||
property real logAmplitude: Math.log10(amplitude)
|
||||
property real degUnit: Math.PI / 180
|
||||
|
||||
property real halfWidth: width/2
|
||||
property real halfHeight: height/2
|
||||
|
||||
readonly property int l_start: (channel===1)*dataLength
|
||||
readonly property int r_stop: dataLength+dataLength*(channel!==0)
|
||||
readonly property int total: r_stop-l_start
|
||||
readonly property real _y_dy: centerRotateFlag*Math.tan(centerRotateAngle*degUnit)*halfWidth
|
||||
readonly property real _ux: width/(r_stop-l_start)
|
||||
readonly property real _dx: Math.round(_ux/2)
|
||||
|
||||
onAudioDataUpdeted: {
|
||||
if(autoNormalizing) {
|
||||
if (unitStyle) {
|
||||
//对数化显示
|
||||
for(let i=0; i<dataLength; i++) {
|
||||
audioData[i] = 0;
|
||||
for(let j=0; j<uDataLen; j++) {
|
||||
audioData[i] += Math.max(0, 0.4 * (Math.log10(data[64-i*uDataLen-j-1]/data[128])) + 1.0);
|
||||
}
|
||||
audioData[i] /= uDataLen;
|
||||
let normalizing_ratio = autoNormalizing ? data[128] : amplitude;
|
||||
if (unitStyle) {
|
||||
//对数化显示
|
||||
for(let i=l_start; i<dataLength; i++) {
|
||||
audioData[i] = 0;
|
||||
for(let j=0; j<uDataLen; j++) {
|
||||
audioData[i] += Math.max(0, 0.4 * (Math.log10(data[63-i*uDataLen-j]/normalizing_ratio)) + 1.0);
|
||||
}
|
||||
if (channel === 2) {
|
||||
for(let i=dataLength; i<total; i++) {
|
||||
audioData[i] = 0;
|
||||
for(let j=0; j<uDataLen; j++) {
|
||||
audioData[i] += Math.max(0, 0.4 * (Math.log10(data[64+(i-dataLength)*uDataLen+j]/data[128])) + 1.0);
|
||||
}
|
||||
audioData[i] /= uDataLen;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//线性化显示
|
||||
for(let i=0; i<dataLength; i++) {
|
||||
audioData[i] = 0;
|
||||
for(let j=0; j<uDataLen; j++) {
|
||||
audioData[i] += data[64-i*uDataLen-j-1];
|
||||
}
|
||||
audioData[i] /= (uDataLen * data[128]);
|
||||
}
|
||||
if (channel === 2) {
|
||||
for(let i=dataLength; i<total; i++) {
|
||||
audioData[i] = 0;
|
||||
for(let j=0; j<uDataLen; j++) {
|
||||
audioData[i] += data[64+(i-dataLength)*uDataLen+j];
|
||||
}
|
||||
audioData[i] /= (uDataLen * data[128]);
|
||||
}
|
||||
audioData[i] /= uDataLen;
|
||||
}
|
||||
for(let i=dataLength; i<r_stop; i++) {
|
||||
audioData[i] = 0;
|
||||
for(let j=0; j<uDataLen; j++) {
|
||||
audioData[i] += Math.max(0, 0.4 * (Math.log10(data[i*uDataLen+j]/normalizing_ratio)) + 1.0);
|
||||
}
|
||||
audioData[i] /= uDataLen;
|
||||
}
|
||||
} else {
|
||||
if (unitStyle) {
|
||||
//对数化显示
|
||||
for(let i=0; i<dataLength; i++) {
|
||||
audioData[i] = 0;
|
||||
for(let j=0; j<uDataLen; j++) {
|
||||
audioData[i] += Math.max(0, 0.35 * (Math.log10(data[64-i*uDataLen-j-1])+logAmplitude) + 1.0);
|
||||
}
|
||||
audioData[i] /= uDataLen;
|
||||
//线性化显示
|
||||
for(let i=l_start; i<dataLength; i++) {
|
||||
audioData[i] = 0;
|
||||
for(let j=0; j<uDataLen; j++) {
|
||||
audioData[i] += data[63-i*uDataLen-j];
|
||||
}
|
||||
if (channel === 2) {
|
||||
for(let i=dataLength; i<total; i++) {
|
||||
audioData[i] = 0;
|
||||
for(let j=0; j<uDataLen; j++) {
|
||||
audioData[i] += Math.max(0, 0.35 * (Math.log10(data[64+(i-dataLength)*uDataLen+j])+logAmplitude) + 1.0);
|
||||
}
|
||||
audioData[i] /= uDataLen;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
//线性化显示
|
||||
for(let i=0; i<dataLength; i++) {
|
||||
audioData[i] = 0;
|
||||
for(let j=0; j<uDataLen; j++) {
|
||||
audioData[i] += data[64-i*uDataLen-j-1];
|
||||
}
|
||||
audioData[i] /= (uDataLen/amplitude);
|
||||
}
|
||||
if (channel === 2) {
|
||||
for(let i=dataLength; i<total; i++) {
|
||||
audioData[i] = 0;
|
||||
for(let j=0; j<uDataLen; j++) {
|
||||
audioData[i] += data[64+(i-dataLength)*uDataLen+j];
|
||||
}
|
||||
audioData[i] /= (uDataLen/amplitude);
|
||||
}
|
||||
audioData[i] /= (uDataLen * normalizing_ratio);
|
||||
}
|
||||
for(let i=dataLength; i<r_stop; i++) {
|
||||
audioData[i] = 0;
|
||||
for(let j=0; j<uDataLen; j++) {
|
||||
audioData[i] += data[i*uDataLen+j];
|
||||
}
|
||||
audioData[i] /= (uDataLen * normalizing_ratio);
|
||||
}
|
||||
}
|
||||
let _dy;
|
||||
let _y_dy = centerRotateFlag*Math.tan(centerRotateAngle*degUnit)*halfWidth;
|
||||
let _ux = width/total;
|
||||
let _dx = Math.round(_ux/2);
|
||||
let _y = halfHeight-_y_dy
|
||||
|
||||
context.clearRect(0, 0, width+32, height+32);
|
||||
|
||||
let _y = halfHeight-_y_dy;
|
||||
if(lineRotateFlag || centerRotateFlag) {
|
||||
context.transform(1, centerRotateFlag*centerRotateAngle * degUnit, -lineRotateFlag*lineRotateAngle * degUnit, 1, lineRotateFlag*Math.sin(1.05*lineRotateAngle*degUnit)*_y, 0);
|
||||
}
|
||||
@ -125,34 +82,19 @@ AdvpStyleTemplate {
|
||||
context.fillRect(0, _y, width, 2);
|
||||
}
|
||||
|
||||
|
||||
|
||||
context.fillStyle = line_color;
|
||||
|
||||
//绘制频谱
|
||||
if (channel === 1 && reverse) {
|
||||
for (let i = 0; i < dataLength; i++) {
|
||||
let index = dataLength - i - 1;
|
||||
_y = halfHeight*(1-(linePosition!==2)*audioData[index])-_y_dy;
|
||||
_dy = (halfHeight + (!linePosition)*halfHeight)*audioData[index];
|
||||
context.fillRect(_ux * i, _y, _dx, _dy);
|
||||
}
|
||||
} else {
|
||||
for (let j = 0; j < channel; j++) {
|
||||
for (let i = 0; i < dataLength; i++) {
|
||||
let index = j ? ((total - dataLength) + i) : i;
|
||||
_y = halfHeight*(1-(linePosition!==2)*audioData[index])-_y_dy;
|
||||
_dy = (halfHeight + (!linePosition)*halfHeight)*audioData[index];
|
||||
context.fillRect(_ux * (i + j * dataLength), _y, _dx, _dy);
|
||||
}
|
||||
}
|
||||
let _dy;
|
||||
for (let i=l_start; i<r_stop; i++) {
|
||||
_y = halfHeight*(1-(linePosition!==2)*audioData[i])-_y_dy;
|
||||
_dy = (halfHeight + (!linePosition)*halfHeight)*audioData[i];
|
||||
context.fillRect(_ux * (i-l_start), _y, _dx, _dy);
|
||||
}
|
||||
|
||||
if (centerRotateFlag || lineRotateFlag)
|
||||
context.resetTransform();
|
||||
|
||||
context.fill();
|
||||
|
||||
requestPaint();
|
||||
}
|
||||
|
||||
@ -164,14 +106,13 @@ AdvpStyleTemplate {
|
||||
}
|
||||
|
||||
defaultValues: {
|
||||
"Version": "1.0.0",
|
||||
"Version": "1.1.0",
|
||||
"Center Line": true,
|
||||
"Center Color": "#ff4500",
|
||||
"Line Color": "#ff4500",
|
||||
"Line Position": 0,
|
||||
"Data Length": 0,
|
||||
"Channel": 2,
|
||||
"Reverse": false,
|
||||
"Rotate Settings": {
|
||||
"Center Enable": false,
|
||||
"Center Angle": 10,
|
||||
@ -225,25 +166,11 @@ AdvpStyleTemplate {
|
||||
model: [64, 32, 16, 8]
|
||||
}
|
||||
|
||||
P.Separator {}
|
||||
|
||||
P.SpinPreference {
|
||||
id: _cfg_preset_line_Channel
|
||||
P.SelectPreference {
|
||||
name: "Channel"
|
||||
label: qsTr("Channel")
|
||||
message: "1 to 2"
|
||||
display: P.TextFieldPreference.ExpandLabel
|
||||
editable: false
|
||||
from: 1
|
||||
to: 2
|
||||
defaultValue: defaultValues["Channel"]
|
||||
}
|
||||
|
||||
P.SwitchPreference {
|
||||
name: "Reverse"
|
||||
label: qsTr("Reverse Spectrum")
|
||||
enabled: _cfg_preset_line_Channel.value === 1
|
||||
defaultValue: defaultValues["Reverse"]
|
||||
model: [qsTr("Left Channel"), qsTr("Right Channel"), qsTr("Stereo")]
|
||||
}
|
||||
|
||||
P.Separator {}
|
||||
|
||||
@ -18,7 +18,7 @@ AdvpStyleTemplate {
|
||||
readonly property real rSpeed: configs["Ratate Speed"] / 100
|
||||
readonly property real angle: configs["Angle"]
|
||||
readonly property bool autoNormalizing: configs["Data Settings"]["Auto Normalizing"]
|
||||
readonly property real amplitude: configs["Data Settings"]["Amplitude"] / 400
|
||||
readonly property real amplitude: 400/configs["Data Settings"]["Amplitude"]
|
||||
readonly property int unitStyle: configs["Data Settings"]["Unit Style"]
|
||||
|
||||
readonly property int total: channel*dataLength
|
||||
@ -37,7 +37,6 @@ AdvpStyleTemplate {
|
||||
readonly property real halfWidth: width/2
|
||||
readonly property real halfHeight: height/2
|
||||
readonly property real halfMinLength: minLength/2
|
||||
readonly property real logAmplitude: Math.log10(amplitude)
|
||||
|
||||
|
||||
onConfigsUpdated: {
|
||||
@ -45,13 +44,9 @@ AdvpStyleTemplate {
|
||||
context.strokeStyle = configs["Main Color"];
|
||||
}
|
||||
|
||||
function getPos(r, deg) {
|
||||
return [halfWidth+Math.cos(deg)*r,halfHeight+Math.sin(deg)*r];
|
||||
}
|
||||
|
||||
function createPoint() {
|
||||
outerPos = [];
|
||||
innerPos = [];
|
||||
outerPos.length = 0;
|
||||
innerPos.length = 0;
|
||||
let deg, deltaR, r1, r2, _rhmLen;
|
||||
_rhmLen = mainRatio*halfMinLength;
|
||||
|
||||
@ -61,54 +56,32 @@ AdvpStyleTemplate {
|
||||
deltaR = audioData[reverse*(dataLength-i-1)+(!reverse)*(i+j*dataLength)] * ratio;
|
||||
r1 = _rhmLen+1+deltaR*(linePosition!==2);
|
||||
r2 = _rhmLen-1-deltaR*(linePosition!==1);
|
||||
outerPos.push(getPos(r1, deg));
|
||||
innerPos.push(getPos(r2, deg));
|
||||
outerPos.push([halfWidth+Math.cos(deg)*r1,halfHeight+Math.sin(deg)*r1]);
|
||||
innerPos.push([halfWidth+Math.cos(deg)*r2,halfHeight+Math.sin(deg)*r2]);
|
||||
}
|
||||
}
|
||||
offsetAngle = rotateFlag ? ((offsetAngle + rSpeed) % 360) : angle;
|
||||
}
|
||||
|
||||
onAudioDataUpdeted: {
|
||||
if(autoNormalizing) {
|
||||
if (unitStyle) {
|
||||
//对数化显示
|
||||
let logPeak = Math.log10(data[128]);
|
||||
for(let i=0; i<total; i++) {
|
||||
audioData[i] = 0;
|
||||
for(let j=0; j<uDataLen; j++) {
|
||||
audioData[i] += Math.max(0, 0.4 * (Math.log10(data[i*uDataLen+j])-logPeak) + 1.0);
|
||||
}
|
||||
audioData[i] /= uDataLen;
|
||||
}
|
||||
} else {
|
||||
//线性化显示
|
||||
for(let i=0; i<total; i++) {
|
||||
audioData[i] = 0;
|
||||
for(let j=0; j<uDataLen; j++) {
|
||||
audioData[i] += data[i*uDataLen+j] / data[128];
|
||||
}
|
||||
audioData[i] /= uDataLen;
|
||||
let normalizing_ratio = autoNormalizing ? data[128] : amplitude;
|
||||
if (unitStyle) {
|
||||
//对数化显示
|
||||
for(let i=0; i<total; i++) {
|
||||
audioData[i] = 0;
|
||||
for(let j=0; j<uDataLen; j++) {
|
||||
audioData[i] += Math.max(0, 0.4 * (Math.log10(data[i*uDataLen+j]/normalizing_ratio)) + 1.0);
|
||||
}
|
||||
audioData[i] /= uDataLen;
|
||||
}
|
||||
} else {
|
||||
if (unitStyle) {
|
||||
//对数化显示
|
||||
for(let i=0; i<total; i++) {
|
||||
audioData[i] = 0;
|
||||
for(let j=0; j<uDataLen; j++) {
|
||||
audioData[i] += Math.max(0, 0.35 * (Math.log10(data[i*uDataLen+j])+logAmplitude) + 1.0);
|
||||
}
|
||||
audioData[i] /= uDataLen;
|
||||
}
|
||||
} else {
|
||||
//线性化显示
|
||||
for(let i=0; i<total; i++) {
|
||||
audioData[i] = 0;
|
||||
for(let j=0; j<uDataLen; j++) {
|
||||
audioData[i] += data[i*uDataLen+j] * amplitude;
|
||||
}
|
||||
audioData[i] /= uDataLen;
|
||||
//线性化显示
|
||||
for(let i=0; i<total; i++) {
|
||||
audioData[i] = 0;
|
||||
for(let j=0; j<uDataLen; j++) {
|
||||
audioData[i] += data[i*uDataLen+j];
|
||||
}
|
||||
audioData[i] /= (uDataLen * normalizing_ratio);
|
||||
}
|
||||
}
|
||||
|
||||
@ -148,7 +121,7 @@ AdvpStyleTemplate {
|
||||
}
|
||||
|
||||
defaultValues: {
|
||||
"Version": "1.0.0",
|
||||
"Version": "1.1.0",
|
||||
"Main Color": "#ff4500",
|
||||
"Line Position": 0,
|
||||
"Line Width": 1,
|
||||
|
||||
@ -8,7 +8,7 @@ AdvpStyleTemplate {
|
||||
readonly property var audioData: new Array(128)
|
||||
|
||||
readonly property bool autoNormalizing: configs["Data Settings"]["Auto Normalizing"]
|
||||
readonly property real amplitude: configs["Data Settings"]["Amplitude"] / 400.0
|
||||
readonly property real amplitude: 400/configs["Data Settings"]["Amplitude"]
|
||||
|
||||
readonly property int uDataLen: Math.pow(2, configs["Data Length"]);
|
||||
readonly property int dataLength: 64/uDataLen
|
||||
@ -26,74 +26,38 @@ AdvpStyleTemplate {
|
||||
}
|
||||
|
||||
onAudioDataUpdeted: {
|
||||
data[128] *= 2;
|
||||
if(autoNormalizing) {
|
||||
if (unitStyle) {
|
||||
//对数化显示
|
||||
for(let i=0; i<dataLength; i++) {
|
||||
audioData[i] = 0;
|
||||
for(let j=0; j<uDataLen; j++) {
|
||||
audioData[i] += Math.max(0, 0.4 * (Math.log10(data[64-i*uDataLen-j-1]/data[128])) + 1.0);
|
||||
}
|
||||
audioData[i] /= uDataLen;
|
||||
let normalizing_ratio = autoNormalizing ? data[128]*2 : amplitude;
|
||||
if (unitStyle) {
|
||||
//对数化显示
|
||||
for(let i=0; i<dataLength; i++) {
|
||||
audioData[i] = 0;
|
||||
for(let j=0; j<uDataLen; j++) {
|
||||
audioData[i] += Math.max(0, 0.4 * (Math.log10(data[63-i*uDataLen-j]/normalizing_ratio)) + 1.0);
|
||||
}
|
||||
for(let i=dataLength; i<total; i++) {
|
||||
audioData[i] = 0;
|
||||
for(let j=0; j<uDataLen; j++) {
|
||||
audioData[i] += Math.max(0, 0.4 * (Math.log10(data[64+(i-dataLength)*uDataLen+j]/data[128])) + 1.0);
|
||||
}
|
||||
audioData[i] /= uDataLen;
|
||||
}
|
||||
} else {
|
||||
//线性化显示
|
||||
for(let i=0; i<dataLength; i++) {
|
||||
audioData[i] = 0;
|
||||
for(let j=0; j<uDataLen; j++) {
|
||||
audioData[i] += data[64-i*uDataLen-j-1];
|
||||
}
|
||||
audioData[i] /= (uDataLen * data[128]);
|
||||
}
|
||||
for(let i=dataLength; i<total; i++) {
|
||||
audioData[i] = 0;
|
||||
for(let j=0; j<uDataLen; j++) {
|
||||
audioData[i] += data[64+(i-dataLength)*uDataLen+j];
|
||||
}
|
||||
audioData[i] /= (uDataLen * data[128]);
|
||||
audioData[i] /= uDataLen;
|
||||
}
|
||||
for(let i=dataLength; i<total; i++) {
|
||||
audioData[i] = 0;
|
||||
for(let j=0; j<uDataLen; j++) {
|
||||
audioData[i] += Math.max(0, 0.4 * (Math.log10(data[i*uDataLen+j]/normalizing_ratio)) + 1.0);
|
||||
}
|
||||
audioData[i] /= uDataLen;
|
||||
}
|
||||
} else {
|
||||
if (unitStyle) {
|
||||
//对数化显示
|
||||
for(let i=0; i<dataLength; i++) {
|
||||
audioData[i] = 0;
|
||||
for(let j=0; j<uDataLen; j++) {
|
||||
audioData[i] += Math.max(0, 0.35 * (Math.log10(data[64-i*uDataLen-j-1])+logAmplitude) + 1.0);
|
||||
}
|
||||
audioData[i] /= uDataLen;
|
||||
//线性化显示
|
||||
for(let i=0; i<dataLength; i++) {
|
||||
audioData[i] = 0;
|
||||
for(let j=0; j<uDataLen; j++) {
|
||||
audioData[i] += data[63-i*uDataLen-j];
|
||||
}
|
||||
for(let i=dataLength; i<total; i++) {
|
||||
audioData[i] = 0;
|
||||
for(let j=0; j<uDataLen; j++) {
|
||||
audioData[i] += Math.max(0, 0.35 * (Math.log10(data[64+(i-dataLength)*uDataLen+j])+logAmplitude) + 1.0);
|
||||
}
|
||||
audioData[i] /= uDataLen;
|
||||
}
|
||||
} else {
|
||||
//线性化显示
|
||||
for(let i=0; i<dataLength; i++) {
|
||||
audioData[i] = 0;
|
||||
for(let j=0; j<uDataLen; j++) {
|
||||
audioData[i] += data[64-i*uDataLen-j-1];
|
||||
}
|
||||
audioData[i] /= (uDataLen/amplitude);
|
||||
}
|
||||
for(let i=dataLength; i<total; i++) {
|
||||
audioData[i] = 0;
|
||||
for(let j=0; j<uDataLen; j++) {
|
||||
audioData[i] += data[64+(i-dataLength)*uDataLen+j];
|
||||
}
|
||||
audioData[i] /= (uDataLen/amplitude);
|
||||
audioData[i] /= (uDataLen * normalizing_ratio);
|
||||
}
|
||||
for(let i=dataLength; i<total; i++) {
|
||||
audioData[i] = 0;
|
||||
for(let j=0; j<uDataLen; j++) {
|
||||
audioData[i] += data[i*uDataLen+j];
|
||||
}
|
||||
audioData[i] /= (uDataLen * normalizing_ratio);
|
||||
}
|
||||
}
|
||||
|
||||
@ -134,7 +98,7 @@ AdvpStyleTemplate {
|
||||
|
||||
preference: AdvpPreference {
|
||||
version: defaultValues["Version"]
|
||||
cfg_height: 400
|
||||
cfg_height: 500
|
||||
|
||||
P.SliderPreference {
|
||||
name: "Line Width"
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user