forked from Mashiro_Sorata/ADV-Plugin
mashiros
2 years ago
30 changed files with 1693 additions and 1560 deletions
Binary file not shown.
Binary file not shown.
Binary file not shown.
@ -1,6 +1,5 @@ |
|||||||
<?xml version="1.0" encoding="UTF-8"?> |
<?xml version="1.0" encoding="UTF-8"?> |
||||||
<map> |
<map> |
||||||
<value name="styles">{"index":3}</value> |
<value name="current_style">"nvg://advp.widget.mashiros.top/advp-style-preset/circle"</value> |
||||||
<value name="current_style">"nvg://advp.widget.mashiros.top/advp-style-preset/circle#Style.qml"</value> |
<value name="nvg://advp.widget.mashiros.top/advp-style-preset/circle">{"Main Color":"#ff4500","Line Position":0,"Line Width":1,"Max Range":50,"Data Length":0,"Channel":2,"Reverse":false,"Rotate":false,"Ratate Speed":10,"Angle":0,"Data Settings":{"Auto Normalizing":true,"Amplitude":10,"Unit Style":0}}</value> |
||||||
<value name="nvg://advp.widget.mashiros.top/advp-style-preset/circle#Style.qml">{"__version":"1.0.0","__cfg_height":740,"Main Color":"#ff4500","Line Position":0,"Line Width":1,"Max Range":50,"Data Length":0,"Channel":2,"Reverse":false,"Rotate":false,"Ratate Speed":10,"Angle":0,"Data Settings":{"Auto Normalizing":true,"Amplitude":10,"Unit Style":0}}</value> |
|
||||||
</map> |
</map> |
@ -1,6 +1,5 @@ |
|||||||
<?xml version="1.0" encoding="UTF-8"?> |
<?xml version="1.0" encoding="UTF-8"?> |
||||||
<map> |
<map> |
||||||
<value name="styles">{"index":1}</value> |
<value name="current_style">"nvg://advp.widget.mashiros.top/advp-style-preset/gradient_line"</value> |
||||||
<value name="current_style">"nvg://advp.widget.mashiros.top/advp-style-preset/gradient_line#Style.qml"</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#Style.qml">{"__version":"1.0.0","__cfg_height":660,"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> |
|
||||||
</map> |
</map> |
@ -1,6 +1,5 @@ |
|||||||
<?xml version="1.0" encoding="UTF-8"?> |
<?xml version="1.0" encoding="UTF-8"?> |
||||||
<map> |
<map> |
||||||
<value name="nvg://advp.widget.mashiros.top/advp-style-preset/line#Style.qml">{"__version":"1.0.0","__cfg_height":580,"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,"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="styles">{"index":0}</value> |
<value name="current_style">"nvg://advp.widget.mashiros.top/advp-style-preset/line"</value> |
||||||
<value name="current_style">"nvg://advp.widget.mashiros.top/advp-style-preset/line#Style.qml"</value> |
|
||||||
</map> |
</map> |
@ -1,6 +1,5 @@ |
|||||||
<?xml version="1.0" encoding="UTF-8"?> |
<?xml version="1.0" encoding="UTF-8"?> |
||||||
<map> |
<map> |
||||||
<value name="styles">{"index":5}</value> |
<value name="current_style">"nvg://advp.widget.mashiros.top/advp-style-preset/ordinal_scale_ui_bottom"</value> |
||||||
<value name="current_style">"nvg://advp.widget.mashiros.top/advp-style-preset/ordinal_scale_ui_bottom#Style.qml"</value> |
<value name="nvg://advp.widget.mashiros.top/advp-style-preset/ordinal_scale_ui_bottom">{"Bass Color":"#dc143c","Alto Color":"#f8f8ff","Treble Color":"#4169e1","Bass AM":100,"Alto AM":150,"Treble AM":200,"Static AM":25,"Speed":20,"Data Settings":{"Auto Normalizing":true,"Amplitude":10}}</value> |
||||||
<value name="nvg://advp.widget.mashiros.top/advp-style-preset/ordinal_scale_ui_bottom#Style.qml">{"__version":"1.0.0","__cfg_height":710,"Bass Color":"#dc143c","Alto Color":"#f8f8ff","Treble Color":"#4169e1","Bass AM":100,"Alto AM":150,"Treble AM":200,"Static AM":25,"Speed":20,"Data Settings":{"Auto Normalizing":true,"Amplitude":10}}</value> |
|
||||||
</map> |
</map> |
@ -1,6 +1,5 @@ |
|||||||
<?xml version="1.0" encoding="UTF-8"?> |
<?xml version="1.0" encoding="UTF-8"?> |
||||||
<map> |
<map> |
||||||
<value name="styles">{"index":4}</value> |
<value name="current_style">"nvg://advp.widget.mashiros.top/advp-style-preset/solidcircle"</value> |
||||||
<value name="current_style">"nvg://advp.widget.mashiros.top/advp-style-preset/solidcircle#Style.qml"</value> |
<value name="nvg://advp.widget.mashiros.top/advp-style-preset/solidcircle">{"Main Color":"#ff4500","Line Position":0,"Line Width":1,"Max Range":50,"Data Length":0,"Channel":2,"Reverse":false,"Rotate":false,"Ratate Speed":10,"Angle":0,"Data Settings":{"Auto Normalizing":true,"Amplitude":10,"Unit Style":0}}</value> |
||||||
<value name="nvg://advp.widget.mashiros.top/advp-style-preset/solidcircle#Style.qml">{"__version":"1.0.0","__cfg_height":740,"Main Color":"#ff4500","Line Position":0,"Line Width":1,"Max Range":50,"Data Length":0,"Channel":2,"Reverse":false,"Rotate":false,"Ratate Speed":10,"Angle":0,"Data Settings":{"Auto Normalizing":true,"Amplitude":10,"Unit Style":0}}</value> |
|
||||||
</map> |
</map> |
@ -1,6 +1,5 @@ |
|||||||
<?xml version="1.0" encoding="UTF-8"?> |
<?xml version="1.0" encoding="UTF-8"?> |
||||||
<map> |
<map> |
||||||
<value name="styles">{"index":2}</value> |
<value name="current_style">"nvg://advp.widget.mashiros.top/advp-style-preset/waves"</value> |
||||||
<value name="current_style">"nvg://advp.widget.mashiros.top/advp-style-preset/waves#Style.qml"</value> |
<value name="nvg://advp.widget.mashiros.top/advp-style-preset/waves">{"Line Width":1,"Line Color":"#ff4500","Data Length":0,"Data Settings":{"Auto Normalizing":true,"Amplitude":10,"Unit Style":0}}</value> |
||||||
<value name="nvg://advp.widget.mashiros.top/advp-style-preset/waves#Style.qml">{"__version":"1.0.0","__cfg_height":580,"Line Width":1,"Line Color":"#ff4500","Data Settings":{"Auto Normalizing":true,"Amplitude":10}}</value> |
|
||||||
</map> |
</map> |
@ -0,0 +1,9 @@ |
|||||||
|
import QtQuick 2.12 |
||||||
|
|
||||||
|
QtObject { |
||||||
|
property Component style |
||||||
|
|
||||||
|
property var defaultValues |
||||||
|
|
||||||
|
property Component preference |
||||||
|
} |
@ -1,111 +0,0 @@ |
|||||||
import QtQuick 2.12 |
|
||||||
import NERvGear.Preferences 1.0 as P |
|
||||||
|
|
||||||
import "../../qml/api" //导入CfgAPI.qml |
|
||||||
|
|
||||||
CfgAPI { |
|
||||||
version: "1.0.0" |
|
||||||
cfg_height: 710 |
|
||||||
|
|
||||||
P.ColorPreference { |
|
||||||
name: "Bass Color" |
|
||||||
label: qsTr("Bass Line Color") |
|
||||||
defaultValue: "#DC143C" |
|
||||||
} |
|
||||||
|
|
||||||
P.ColorPreference { |
|
||||||
name: "Alto Color" |
|
||||||
label: qsTr("Alto Line Color") |
|
||||||
defaultValue: "#F8F8FF" |
|
||||||
} |
|
||||||
|
|
||||||
P.ColorPreference { |
|
||||||
name: "Treble Color" |
|
||||||
label: qsTr("Treble Line Color") |
|
||||||
defaultValue: "#4169E1" |
|
||||||
} |
|
||||||
|
|
||||||
P.Separator {} |
|
||||||
|
|
||||||
P.SliderPreference { |
|
||||||
name: "Bass AM" |
|
||||||
label: qsTr("Bass Amplitude") |
|
||||||
from: 10 |
|
||||||
to: 300 |
|
||||||
stepSize: 5 |
|
||||||
defaultValue: 100 |
|
||||||
displayValue: value + "%" |
|
||||||
} |
|
||||||
|
|
||||||
P.SliderPreference { |
|
||||||
name: "Alto AM" |
|
||||||
label: qsTr("Alto Amplitude") |
|
||||||
from: 10 |
|
||||||
to: 300 |
|
||||||
stepSize: 5 |
|
||||||
defaultValue: 150 |
|
||||||
displayValue: value + "%" |
|
||||||
} |
|
||||||
|
|
||||||
P.SliderPreference { |
|
||||||
name: "Treble AM" |
|
||||||
label: qsTr("Treble Amplitude") |
|
||||||
from: 10 |
|
||||||
to: 300 |
|
||||||
stepSize: 5 |
|
||||||
defaultValue: 200 |
|
||||||
displayValue: value + "%" |
|
||||||
} |
|
||||||
|
|
||||||
P.Separator {} |
|
||||||
|
|
||||||
P.SliderPreference { |
|
||||||
name: "Static AM" |
|
||||||
label: qsTr("Static Amplitude") |
|
||||||
from: 5 |
|
||||||
to: 100 |
|
||||||
stepSize: 1 |
|
||||||
defaultValue: 15 |
|
||||||
displayValue: value + "%" |
|
||||||
} |
|
||||||
|
|
||||||
P.Separator {} |
|
||||||
|
|
||||||
P.SliderPreference { |
|
||||||
name: "Speed" |
|
||||||
label: qsTr("Wave Speed") |
|
||||||
from: 1 |
|
||||||
to: 100 |
|
||||||
stepSize: 1 |
|
||||||
defaultValue: 20 |
|
||||||
displayValue: value + "%" |
|
||||||
} |
|
||||||
|
|
||||||
P.Separator {} |
|
||||||
|
|
||||||
P.DialogPreference { |
|
||||||
name: "Data Settings" |
|
||||||
label: qsTr("Data Settings") |
|
||||||
live: true |
|
||||||
icon.name: "regular:\uf1de" |
|
||||||
|
|
||||||
P.SwitchPreference { |
|
||||||
id: _cfg_preset_osui_dataSettings_autoNormalizing |
|
||||||
name: "Auto Normalizing" |
|
||||||
label: qsTr("Auto Normalizing") |
|
||||||
defaultValue: true |
|
||||||
} |
|
||||||
|
|
||||||
P.SpinPreference { |
|
||||||
name: "Amplitude" |
|
||||||
label: qsTr("Amplitude Ratio") |
|
||||||
enabled: !_cfg_preset_osui_dataSettings_autoNormalizing.value |
|
||||||
message: "1 to 100" |
|
||||||
display: P.TextFieldPreference.ExpandLabel |
|
||||||
editable: true |
|
||||||
from: 1 |
|
||||||
to: 100 |
|
||||||
defaultValue: 10 |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
File diff suppressed because one or more lines are too long
@ -1,139 +0,0 @@ |
|||||||
import QtQuick 2.12 |
|
||||||
import NERvGear.Preferences 1.0 as P |
|
||||||
|
|
||||||
import "../../qml/api" //导入CfgAPI.qml |
|
||||||
|
|
||||||
CfgAPI { |
|
||||||
version: "1.0.0" |
|
||||||
cfg_height: 740 |
|
||||||
|
|
||||||
P.ColorPreference { |
|
||||||
name: "Main Color" |
|
||||||
label: qsTr("Spectrum Line Color") |
|
||||||
defaultValue: "#FF4500" |
|
||||||
} |
|
||||||
|
|
||||||
P.SelectPreference { |
|
||||||
name: "Line Position" |
|
||||||
label: qsTr("Spectrum Line Position") |
|
||||||
defaultValue: 0 |
|
||||||
model: [qsTr("Both"), qsTr("Outside"), qsTr("Inside")] |
|
||||||
} |
|
||||||
|
|
||||||
P.SliderPreference { |
|
||||||
name: "Line Width" |
|
||||||
label: qsTr("Spectrum Line Width") |
|
||||||
from: 0.1 |
|
||||||
to: 10 |
|
||||||
stepSize: 0.1 |
|
||||||
defaultValue: 1 |
|
||||||
displayValue: value.toFixed(1) + "px" |
|
||||||
} |
|
||||||
|
|
||||||
P.SliderPreference { |
|
||||||
name: "Max Range" |
|
||||||
label: qsTr("Max Amplitude") |
|
||||||
from: 0 |
|
||||||
to: 100 |
|
||||||
stepSize: 1 |
|
||||||
defaultValue: 50 |
|
||||||
displayValue: value + "%" |
|
||||||
} |
|
||||||
|
|
||||||
P.SelectPreference { |
|
||||||
name: "Data Length" |
|
||||||
label: qsTr("Spectrum Length") |
|
||||||
defaultValue: 0 |
|
||||||
model: [64, 32, 16, 8] |
|
||||||
} |
|
||||||
|
|
||||||
P.Separator {} |
|
||||||
|
|
||||||
P.SpinPreference { |
|
||||||
name: "Channel" |
|
||||||
label: qsTr("Channel") |
|
||||||
message: "1 to 2" |
|
||||||
display: P.TextFieldPreference.ExpandLabel |
|
||||||
editable: false |
|
||||||
from: 1 |
|
||||||
to: 2 |
|
||||||
defaultValue: 2 |
|
||||||
} |
|
||||||
|
|
||||||
P.Separator {} |
|
||||||
|
|
||||||
P.SwitchPreference { |
|
||||||
name: "Reverse" |
|
||||||
label: qsTr("Reverse Spectrum") |
|
||||||
defaultValue: false |
|
||||||
} |
|
||||||
|
|
||||||
P.Separator {} |
|
||||||
|
|
||||||
P.SwitchPreference { |
|
||||||
id: _cfg_preset_line_rotate |
|
||||||
name: "Rotate" |
|
||||||
label: qsTr("Auto Rotate") |
|
||||||
defaultValue: false |
|
||||||
} |
|
||||||
|
|
||||||
P.SliderPreference { |
|
||||||
name: "Ratate Speed" |
|
||||||
label: qsTr("Ratate Speed") |
|
||||||
enabled: _cfg_preset_line_rotate.value |
|
||||||
from: 1 |
|
||||||
to: 100 |
|
||||||
stepSize: 1 |
|
||||||
defaultValue: 10 |
|
||||||
displayValue: value + "%" |
|
||||||
} |
|
||||||
|
|
||||||
P.SpinPreference { |
|
||||||
name: "Angle" |
|
||||||
label: qsTr("Initial Angle") |
|
||||||
message: "0 to 359" |
|
||||||
enabled: !_cfg_preset_line_rotate.value |
|
||||||
display: P.TextFieldPreference.ExpandLabel |
|
||||||
editable: true |
|
||||||
from: 0 |
|
||||||
to: 359 |
|
||||||
defaultValue: 0 |
|
||||||
} |
|
||||||
|
|
||||||
P.Separator {} |
|
||||||
|
|
||||||
P.DialogPreference { |
|
||||||
name: "Data Settings" |
|
||||||
label: qsTr("Data Settings") |
|
||||||
live: true |
|
||||||
icon.name: "regular:\uf1de" |
|
||||||
|
|
||||||
P.SwitchPreference { |
|
||||||
id: _cfg_preset_circle_dataSettings_autoNormalizing |
|
||||||
name: "Auto Normalizing" |
|
||||||
label: qsTr("Auto Normalizing") |
|
||||||
defaultValue: true |
|
||||||
} |
|
||||||
|
|
||||||
P.SpinPreference { |
|
||||||
name: "Amplitude" |
|
||||||
label: qsTr("Amplitude Ratio") |
|
||||||
enabled: !_cfg_preset_circle_dataSettings_autoNormalizing.value |
|
||||||
message: "1 to 100" |
|
||||||
display: P.TextFieldPreference.ExpandLabel |
|
||||||
editable: true |
|
||||||
from: 1 |
|
||||||
to: 100 |
|
||||||
defaultValue: 10 |
|
||||||
} |
|
||||||
|
|
||||||
P.Separator {} |
|
||||||
|
|
||||||
P.SelectPreference { |
|
||||||
name: "Unit Style" |
|
||||||
label: qsTr("Display Style") |
|
||||||
defaultValue: 0 |
|
||||||
model: [qsTr("Linear"), qsTr("Decibel")] |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,132 +1,286 @@ |
|||||||
import QtQuick 2.12 |
import QtQuick 2.12 |
||||||
import QtQuick.Controls 2.12 |
import NERvGear.Preferences 1.0 as P |
||||||
|
|
||||||
import "../../qml/api" |
import "../../qml/api" |
||||||
|
|
||||||
StyleAPI { |
AdvpStyleTemplate { |
||||||
readonly property var audioData: new Array(128) |
style: AdvpCanvasTemplate { |
||||||
|
readonly property var audioData: new Array(128) |
||||||
//configs |
|
||||||
readonly property string color: configs["Main Color"] |
|
||||||
readonly property int linePosition: configs["Line Position"] |
|
||||||
readonly property real lineWidth: configs["Line Width"] |
|
||||||
readonly property real maxRange: configs["Max Range"] / 100 |
|
||||||
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 rotateFlag: configs["Rotate"] |
|
||||||
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 int unitStyle: configs["Data Settings"]["Unit Style"] |
|
||||||
|
|
||||||
readonly property int total: channel*dataLength |
|
||||||
|
|
||||||
readonly property real dotGap: 360/total |
|
||||||
property real offsetAngle: 0 |
|
||||||
property var outerPos: [] |
|
||||||
property var innerPos: [] |
|
||||||
readonly property real degUnit: Math.PI/180 |
|
||||||
|
|
||||||
readonly property real subRatio: 0.2*maxRange |
|
||||||
readonly property real mainRatio: 1-subRatio*2.5 |
|
||||||
|
|
||||||
readonly property real minLength: Math.min(width, height) |
|
||||||
readonly property real ratio:minLength*subRatio |
|
||||||
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: { |
|
||||||
context.lineWidth = lineWidth; |
|
||||||
context.strokeStyle = color; |
|
||||||
} |
|
||||||
|
|
||||||
function getPos(r, deg) { |
//configs |
||||||
return [halfWidth+Math.cos(deg)*r,halfHeight+Math.sin(deg)*r]; |
readonly property int linePosition: configs["Line Position"] |
||||||
} |
readonly property real maxRange: configs["Max Range"] / 100 |
||||||
|
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 rotateFlag: configs["Rotate"] |
||||||
|
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 int unitStyle: configs["Data Settings"]["Unit Style"] |
||||||
|
|
||||||
function createPoint() { |
readonly property int total: channel*dataLength |
||||||
outerPos = []; |
|
||||||
innerPos = []; |
readonly property real dotGap: 360/total |
||||||
let deg, deltaR, r1, r2, _rhmLen; |
property real offsetAngle: 0 |
||||||
_rhmLen = mainRatio*halfMinLength; |
property var outerPos: [] |
||||||
|
property var innerPos: [] |
||||||
for (let j=0; j < channel; j++) { |
readonly property real degUnit: Math.PI/180 |
||||||
for (let i=0; i < dataLength; i++) { |
|
||||||
deg = degUnit*((i+j*dataLength)*dotGap + offsetAngle); |
readonly property real subRatio: 0.2*maxRange |
||||||
deltaR = audioData[reverse*(dataLength-i-1)+(!reverse)*(i+j*dataLength)] * ratio; |
readonly property real mainRatio: 1-subRatio*2.5 |
||||||
r1 = _rhmLen+1+deltaR*(linePosition!==2); |
|
||||||
r2 = _rhmLen-1-deltaR*(linePosition!==1); |
readonly property real minLength: Math.min(width, height) |
||||||
outerPos.push(getPos(r1, deg)); |
readonly property real ratio:minLength*subRatio |
||||||
innerPos.push(getPos(r2, deg)); |
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: { |
||||||
|
context.lineWidth = configs["Line Width"]; |
||||||
|
context.strokeStyle = configs["Main Color"]; |
||||||
} |
} |
||||||
offsetAngle = rotateFlag ? ((offsetAngle + rSpeed) % 360) : angle; |
|
||||||
} |
|
||||||
|
|
||||||
onAudioDataUpdeted: { |
function getPos(r, deg) { |
||||||
if(autoNormalizing) { |
return [halfWidth+Math.cos(deg)*r,halfHeight+Math.sin(deg)*r]; |
||||||
if (unitStyle) { |
} |
||||||
//对数化显示 |
|
||||||
let logPeak = Math.log10(data[128]); |
function createPoint() { |
||||||
for(let i=0; i<total; i++) { |
outerPos = []; |
||||||
audioData[i] = 0; |
innerPos = []; |
||||||
for(let j=0; j<uDataLen; j++) { |
let deg, deltaR, r1, r2, _rhmLen; |
||||||
audioData[i] += Math.max(0, 0.4 * (Math.log10(data[i*uDataLen+j])-logPeak) + 1.0); |
_rhmLen = mainRatio*halfMinLength; |
||||||
} |
|
||||||
audioData[i] /= uDataLen; |
for (let j=0; j < channel; j++) { |
||||||
} |
for (let i=0; i < dataLength; i++) { |
||||||
} else { |
deg = degUnit*((i+j*dataLength)*dotGap + offsetAngle); |
||||||
//线性化显示 |
deltaR = audioData[reverse*(dataLength-i-1)+(!reverse)*(i+j*dataLength)] * ratio; |
||||||
for(let i=0; i<total; i++) { |
r1 = _rhmLen+1+deltaR*(linePosition!==2); |
||||||
audioData[i] = 0; |
r2 = _rhmLen-1-deltaR*(linePosition!==1); |
||||||
for(let j=0; j<uDataLen; j++) { |
outerPos.push(getPos(r1, deg)); |
||||||
audioData[i] += data[i*uDataLen+j] / data[128]; |
innerPos.push(getPos(r2, deg)); |
||||||
} |
|
||||||
audioData[i] /= uDataLen; |
|
||||||
} |
} |
||||||
} |
} |
||||||
} else { |
offsetAngle = rotateFlag ? ((offsetAngle + rSpeed) % 360) : angle; |
||||||
if (unitStyle) { |
} |
||||||
//对数化显示 |
|
||||||
for(let i=0; i<total; i++) { |
onAudioDataUpdeted: { |
||||||
audioData[i] = 0; |
if(autoNormalizing) { |
||||||
for(let j=0; j<uDataLen; j++) { |
if (unitStyle) { |
||||||
audioData[i] += Math.max(0, 0.35 * (Math.log10(data[i*uDataLen+j])+logAmplitude) + 1.0); |
//对数化显示 |
||||||
|
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; |
||||||
} |
} |
||||||
audioData[i] /= uDataLen; |
|
||||||
} |
} |
||||||
} else { |
} else { |
||||||
//线性化显示 |
if (unitStyle) { |
||||||
for(let i=0; i<total; i++) { |
//对数化显示 |
||||||
audioData[i] = 0; |
for(let i=0; i<total; i++) { |
||||||
for(let j=0; j<uDataLen; j++) { |
audioData[i] = 0; |
||||||
audioData[i] += data[i*uDataLen+j] * amplitude; |
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; |
||||||
} |
} |
||||||
audioData[i] /= uDataLen; |
|
||||||
} |
} |
||||||
} |
} |
||||||
|
context.clearRect(0, 0, width+32, height+32); |
||||||
|
createPoint(); |
||||||
|
|
||||||
|
context.beginPath(); |
||||||
|
for(let i=0; i<total; i++) { |
||||||
|
context.moveTo(outerPos[i][0], outerPos[i][1]); |
||||||
|
context.lineTo(innerPos[i][0], innerPos[i][1]); |
||||||
|
} |
||||||
|
context.stroke(); |
||||||
|
requestPaint(); |
||||||
} |
} |
||||||
context.clearRect(0, 0, width+32, height+32); |
|
||||||
createPoint(); |
|
||||||
|
|
||||||
context.beginPath(); |
Component.onCompleted: { |
||||||
for(let i=0; i<total; i++) { |
for (let i = 0; i < 128; i++) { |
||||||
context.moveTo(outerPos[i][0], outerPos[i][1]); |
audioData[i] = 0; |
||||||
context.lineTo(innerPos[i][0], innerPos[i][1]); |
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
defaultValues: { |
||||||
|
"Version": "1.0.0", |
||||||
|
"Main Color": "#ff4500", |
||||||
|
"Line Position": 0, |
||||||
|
"Line Width": 1, |
||||||
|
"Max Range": 50, |
||||||
|
"Data Length": 0, |
||||||
|
"Channel": 2, |
||||||
|
"Reverse": false, |
||||||
|
"Rotate": false, |
||||||
|
"Ratate Speed": 10, |
||||||
|
"Angle": 0, |
||||||
|
"Data Settings": { |
||||||
|
"Auto Normalizing": true, |
||||||
|
"Amplitude": 10, |
||||||
|
"Unit Style": 0 |
||||||
} |
} |
||||||
context.stroke(); |
|
||||||
requestPaint(); |
|
||||||
} |
} |
||||||
|
|
||||||
Component.onCompleted: { |
preference: AdvpPreference { |
||||||
for (let i = 0; i < 128; i++) { |
version: defaultValues["Version"] |
||||||
audioData[i] = 0; |
cfg_height: 740 |
||||||
|
|
||||||
|
P.ColorPreference { |
||||||
|
name: "Main Color" |
||||||
|
label: qsTr("Spectrum Line Color") |
||||||
|
defaultValue: defaultValues["Main Color"] |
||||||
|
} |
||||||
|
|
||||||
|
P.SelectPreference { |
||||||
|
name: "Line Position" |
||||||
|
label: qsTr("Spectrum Line Position") |
||||||
|
defaultValue: defaultValues["Line Position"] |
||||||
|
model: [qsTr("Both"), qsTr("Outside"), qsTr("Inside")] |
||||||
|
} |
||||||
|
|
||||||
|
P.SliderPreference { |
||||||
|
name: "Line Width" |
||||||
|
label: qsTr("Spectrum Line Width") |
||||||
|
from: 0.1 |
||||||
|
to: 10 |
||||||
|
stepSize: 0.1 |
||||||
|
defaultValue: defaultValues["Line Width"] |
||||||
|
displayValue: value.toFixed(1) + "px" |
||||||
|
} |
||||||
|
|
||||||
|
P.SliderPreference { |
||||||
|
name: "Max Range" |
||||||
|
label: qsTr("Max Amplitude") |
||||||
|
from: 0 |
||||||
|
to: 100 |
||||||
|
stepSize: 1 |
||||||
|
defaultValue: defaultValues["Max Range"] |
||||||
|
displayValue: value + "%" |
||||||
|
} |
||||||
|
|
||||||
|
P.SelectPreference { |
||||||
|
name: "Data Length" |
||||||
|
label: qsTr("Spectrum Length") |
||||||
|
defaultValue: defaultValues["Data Length"] |
||||||
|
model: [64, 32, 16, 8] |
||||||
|
} |
||||||
|
|
||||||
|
P.Separator {} |
||||||
|
|
||||||
|
P.SpinPreference { |
||||||
|
name: "Channel" |
||||||
|
label: qsTr("Channel") |
||||||
|
message: "1 to 2" |
||||||
|
display: P.TextFieldPreference.ExpandLabel |
||||||
|
editable: false |
||||||
|
from: 1 |
||||||
|
to: 2 |
||||||
|
defaultValue: defaultValues["Channel"] |
||||||
|
} |
||||||
|
|
||||||
|
P.Separator {} |
||||||
|
|
||||||
|
P.SwitchPreference { |
||||||
|
name: "Reverse" |
||||||
|
label: qsTr("Reverse Spectrum") |
||||||
|
defaultValue: defaultValues["Reverse"] |
||||||
|
} |
||||||
|
|
||||||
|
P.Separator {} |
||||||
|
|
||||||
|
P.SwitchPreference { |
||||||
|
id: _cfg_preset_line_rotate |
||||||
|
name: "Rotate" |
||||||
|
label: qsTr("Auto Rotate") |
||||||
|
defaultValue: defaultValues["Rotate"] |
||||||
|
} |
||||||
|
|
||||||
|
P.SliderPreference { |
||||||
|
name: "Ratate Speed" |
||||||
|
label: qsTr("Ratate Speed") |
||||||
|
enabled: _cfg_preset_line_rotate.value |
||||||
|
from: 1 |
||||||
|
to: 100 |
||||||
|
stepSize: 1 |
||||||
|
defaultValue: defaultValues["Ratate Speed"] |
||||||
|
displayValue: value + "%" |
||||||
|
} |
||||||
|
|
||||||
|
P.SpinPreference { |
||||||
|
name: "Angle" |
||||||
|
label: qsTr("Initial Angle") |
||||||
|
message: "0 to 359" |
||||||
|
enabled: !_cfg_preset_line_rotate.value |
||||||
|
display: P.TextFieldPreference.ExpandLabel |
||||||
|
editable: true |
||||||
|
from: 0 |
||||||
|
to: 359 |
||||||
|
defaultValue: defaultValues["Angle"] |
||||||
|
} |
||||||
|
|
||||||
|
P.Separator {} |
||||||
|
|
||||||
|
P.DialogPreference { |
||||||
|
name: "Data Settings" |
||||||
|
label: qsTr("Data Settings") |
||||||
|
live: true |
||||||
|
icon.name: "regular:\uf1de" |
||||||
|
|
||||||
|
P.SwitchPreference { |
||||||
|
id: _cfg_preset_circle_dataSettings_autoNormalizing |
||||||
|
name: "Auto Normalizing" |
||||||
|
label: qsTr("Auto Normalizing") |
||||||
|
defaultValue: defaultValues["Data Settings"]["Auto Normalizing"] |
||||||
|
} |
||||||
|
|
||||||
|
P.SpinPreference { |
||||||
|
name: "Amplitude" |
||||||
|
label: qsTr("Amplitude Ratio") |
||||||
|
enabled: !_cfg_preset_circle_dataSettings_autoNormalizing.value |
||||||
|
message: "1 to 100" |
||||||
|
display: P.TextFieldPreference.ExpandLabel |
||||||
|
editable: true |
||||||
|
from: 1 |
||||||
|
to: 100 |
||||||
|
defaultValue: defaultValues["Data Settings"]["Amplitude"] |
||||||
|
} |
||||||
|
|
||||||
|
P.Separator {} |
||||||
|
|
||||||
|
P.SelectPreference { |
||||||
|
name: "Unit Style" |
||||||
|
label: qsTr("Display Style") |
||||||
|
defaultValue: defaultValues["Data Settings"]["Unit Style"] |
||||||
|
model: [qsTr("Linear"), qsTr("Decibel")] |
||||||
|
} |
||||||
} |
} |
||||||
} |
} |
||||||
} |
} |
||||||
|
@ -1,161 +0,0 @@ |
|||||||
import QtQuick 2.12 |
|
||||||
import NERvGear.Preferences 1.0 as P |
|
||||||
|
|
||||||
import "../../qml/api" //导入CfgAPI.qml |
|
||||||
|
|
||||||
CfgAPI { |
|
||||||
version: "1.0.0" |
|
||||||
cfg_height: 660 |
|
||||||
|
|
||||||
P.SelectPreference { |
|
||||||
name: "Gradient Direction" |
|
||||||
label: qsTr("Gradient Direction") |
|
||||||
defaultValue: 0 |
|
||||||
model: [qsTr("Horizontal"), qsTr("Vertical"), qsTr("Oblique Upward"), qsTr("Oblique downward")] |
|
||||||
} |
|
||||||
|
|
||||||
P.ColorPreference { |
|
||||||
name: "Start Position Color" |
|
||||||
label: qsTr("Start Position Color") |
|
||||||
defaultValue: "#f44336" |
|
||||||
} |
|
||||||
|
|
||||||
P.ColorPreference { |
|
||||||
name: "Middle Position Color" |
|
||||||
label: qsTr("Middle Position Color") |
|
||||||
defaultValue: "#4caf50" |
|
||||||
} |
|
||||||
|
|
||||||
P.ColorPreference { |
|
||||||
name: "End Position Color" |
|
||||||
label: qsTr("End Position Color") |
|
||||||
defaultValue: "#03a9f4" |
|
||||||
} |
|
||||||
|
|
||||||
P.Separator {} |
|
||||||
|
|
||||||
P.SwitchPreference { |
|
||||||
name: "Center Line" |
|
||||||
label: qsTr("Show Center Line") |
|
||||||
defaultValue: true |
|
||||||
} |
|
||||||
|
|
||||||
P.SelectPreference { |
|
||||||
name: "Line Position" |
|
||||||
label: qsTr("Spectrum Line Position") |
|
||||||
defaultValue: 0 |
|
||||||
model: [qsTr("Both"), qsTr("Up"), qsTr("Down")] |
|
||||||
} |
|
||||||
|
|
||||||
P.SelectPreference { |
|
||||||
name: "Data Length" |
|
||||||
label: qsTr("Spectrum Length") |
|
||||||
defaultValue: 0 |
|
||||||
model: [64, 32, 16, 8] |
|
||||||
} |
|
||||||
|
|
||||||
P.Separator {} |
|
||||||
|
|
||||||
P.SpinPreference { |
|
||||||
id: _cfg_preset_line_Channel |
|
||||||
name: "Channel" |
|
||||||
label: qsTr("Channel") |
|
||||||
message: "1 to 2" |
|
||||||
display: P.TextFieldPreference.ExpandLabel |
|
||||||
editable: false |
|
||||||
from: 1 |
|
||||||
to: 2 |
|
||||||
defaultValue: 2 |
|
||||||
} |
|
||||||
|
|
||||||
P.SwitchPreference { |
|
||||||
name: "Reverse" |
|
||||||
label: qsTr("Reverse Spectrum") |
|
||||||
enabled: _cfg_preset_line_Channel.value === 1 |
|
||||||
defaultValue: false |
|
||||||
} |
|
||||||
|
|
||||||
P.Separator {} |
|
||||||
|
|
||||||
P.DialogPreference { |
|
||||||
name: "Rotate Settings" |
|
||||||
label: qsTr("Rotate Settings") |
|
||||||
live: true |
|
||||||
icon.name: "regular:\uf1de" |
|
||||||
|
|
||||||
P.SwitchPreference { |
|
||||||
id: _cfg_preset_line_Rotate_Center_Enable |
|
||||||
name: "Center Enable" |
|
||||||
label: qsTr("Rotate Center Line") |
|
||||||
defaultValue: false |
|
||||||
} |
|
||||||
|
|
||||||
P.SliderPreference { |
|
||||||
name: "Center Angle" |
|
||||||
label: qsTr("Angle of Center Line") |
|
||||||
enabled: _cfg_preset_line_Rotate_Center_Enable.value |
|
||||||
from: -45 |
|
||||||
to: 45 |
|
||||||
stepSize: 1 |
|
||||||
defaultValue: 10 |
|
||||||
displayValue: value + "°" |
|
||||||
} |
|
||||||
|
|
||||||
P.Separator {} |
|
||||||
|
|
||||||
P.SwitchPreference { |
|
||||||
id: _cfg_preset_line_Rotate_Line_Enable |
|
||||||
name: "Line Enable" |
|
||||||
label: qsTr("Rotate Spectrum Line") |
|
||||||
defaultValue: false |
|
||||||
} |
|
||||||
|
|
||||||
P.SliderPreference { |
|
||||||
name: "Line Angle" |
|
||||||
label: qsTr("Angle of Spectrum Line") |
|
||||||
enabled: _cfg_preset_line_Rotate_Line_Enable.value |
|
||||||
from: -75 |
|
||||||
to: 75 |
|
||||||
stepSize: 1 |
|
||||||
defaultValue: 10 |
|
||||||
displayValue: value + "°" |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
P.Separator {} |
|
||||||
|
|
||||||
P.DialogPreference { |
|
||||||
name: "Data Settings" |
|
||||||
label: qsTr("Data Settings") |
|
||||||
live: true |
|
||||||
icon.name: "regular:\uf1de" |
|
||||||
|
|
||||||
P.SwitchPreference { |
|
||||||
id: _cfg_preset_line_dataSettings_autoNormalizing |
|
||||||
name: "Auto Normalizing" |
|
||||||
label: qsTr("Auto Normalizing") |
|
||||||
defaultValue: true |
|
||||||
} |
|
||||||
|
|
||||||
P.SpinPreference { |
|
||||||
name: "Amplitude" |
|
||||||
label: qsTr("Amplitude Ratio") |
|
||||||
enabled: !_cfg_preset_line_dataSettings_autoNormalizing.value |
|
||||||
message: "1 to 100" |
|
||||||
display: P.TextFieldPreference.ExpandLabel |
|
||||||
editable: true |
|
||||||
from: 1 |
|
||||||
to: 100 |
|
||||||
defaultValue: 10 |
|
||||||
} |
|
||||||
|
|
||||||
P.Separator {} |
|
||||||
|
|
||||||
P.SelectPreference { |
|
||||||
name: "Unit Style" |
|
||||||
label: qsTr("Display Style") |
|
||||||
defaultValue: 0 |
|
||||||
model: [qsTr("Linear"), qsTr("Decibel")] |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,187 +1,367 @@ |
|||||||
import QtQuick 2.12 |
import QtQuick 2.12 |
||||||
import QtQuick.Controls 2.12 |
|
||||||
|
|
||||||
import QtGraphicalEffects 1.12 |
import QtGraphicalEffects 1.12 |
||||||
|
import NERvGear.Preferences 1.0 as P |
||||||
|
|
||||||
import "../../qml/api" //导入CfgAPI.qml |
import "../../qml/api" |
||||||
|
|
||||||
Rectangle { |
AdvpStyleTemplate { |
||||||
width: widget.width; |
style: Rectangle { |
||||||
height: widget.height; |
width: widget.width; |
||||||
|
height: widget.height; |
||||||
|
|
||||||
LinearGradient { |
LinearGradient { |
||||||
id: gradient_mask |
id: gradient_mask |
||||||
anchors.fill: parent |
anchors.fill: parent |
||||||
gradient: Gradient { |
gradient: Gradient { |
||||||
GradientStop { id: p_start; position: 0.0 } |
GradientStop { id: p_start; position: 0.0 } |
||||||
GradientStop { id: p_middle; position: 0.5 } |
GradientStop { id: p_middle; position: 0.5 } |
||||||
GradientStop { id: p_end; position: 1.0 } |
GradientStop { id: p_end; position: 1.0 } |
||||||
|
} |
||||||
} |
} |
||||||
} |
|
||||||
|
|
||||||
layer.enabled: true |
layer.enabled: true |
||||||
layer.effect: OpacityMask{ |
layer.effect: OpacityMask{ |
||||||
maskSource: StyleAPI { |
maskSource: AdvpCanvasTemplate { |
||||||
readonly property var audioData: new Array(128) |
readonly property var audioData: new Array(128) |
||||||
|
|
||||||
readonly property bool centerLineFlag: configs["Center Line"] |
|
||||||
readonly property int linePosition: configs["Line Position"] |
|
||||||
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 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 |
|
||||||
|
|
||||||
onConfigsUpdated: { |
|
||||||
context.fillStyle = "black"; |
|
||||||
gradient_mask.start = Qt.point(0, height*(configs["Gradient Direction"]===2)) |
|
||||||
gradient_mask.end = Qt.point(width*(configs["Gradient Direction"]!==1), height*(configs["Gradient Direction"]%2)) |
|
||||||
p_start.color = configs["Start Position Color"]; |
|
||||||
p_middle.color = configs["Middle Position Color"]; |
|
||||||
p_end.color = configs["End Position Color"]; |
|
||||||
} |
|
||||||
|
|
||||||
onAudioDataUpdeted: { |
readonly property bool centerLineFlag: configs["Center Line"] |
||||||
if(autoNormalizing) { |
readonly property int linePosition: configs["Line Position"] |
||||||
if (unitStyle) { |
readonly property int uDataLen: Math.pow(2, configs["Data Length"]); |
||||||
//对数化显示 |
readonly property int dataLength: 64/uDataLen |
||||||
for(let i=0; i<dataLength; i++) { |
readonly property int channel: configs["Channel"] |
||||||
audioData[i] = 0; |
readonly property bool reverse: configs["Reverse"] |
||||||
for(let j=0; j<uDataLen; j++) { |
readonly property bool centerRotateFlag: configs["Rotate Settings"]["Center Enable"] |
||||||
audioData[i] += Math.max(0, 0.4 * (Math.log10(data[64-i*uDataLen-j-1]/data[128])) + 1.0); |
readonly property real centerRotateAngle: configs["Rotate Settings"]["Center Angle"] |
||||||
} |
readonly property bool lineRotateFlag: configs["Rotate Settings"]["Line Enable"] |
||||||
audioData[i] /= uDataLen; |
readonly property real lineRotateAngle: configs["Rotate Settings"]["Line Angle"] |
||||||
} |
readonly property bool autoNormalizing: configs["Data Settings"]["Auto Normalizing"] |
||||||
if (channel === 2) { |
readonly property real amplitude: configs["Data Settings"]["Amplitude"] / 400.0 |
||||||
for(let i=dataLength; i<total; i++) { |
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 |
||||||
|
|
||||||
|
onConfigsUpdated: { |
||||||
|
context.fillStyle = "black"; |
||||||
|
gradient_mask.start = Qt.point(0, height*(configs["Gradient Direction"]===2)) |
||||||
|
gradient_mask.end = Qt.point(width*(configs["Gradient Direction"]!==1), height*(configs["Gradient Direction"]%2)) |
||||||
|
p_start.color = configs["Start Position Color"]; |
||||||
|
p_middle.color = configs["Middle Position Color"]; |
||||||
|
p_end.color = configs["End Position Color"]; |
||||||
|
} |
||||||
|
|
||||||
|
onAudioDataUpdeted: { |
||||||
|
if(autoNormalizing) { |
||||||
|
if (unitStyle) { |
||||||
|
//对数化显示 |
||||||
|
for(let i=0; i<dataLength; i++) { |
||||||
audioData[i] = 0; |
audioData[i] = 0; |
||||||
for(let j=0; j<uDataLen; j++) { |
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] += Math.max(0, 0.4 * (Math.log10(data[64-i*uDataLen-j-1]/data[128])) + 1.0); |
||||||
} |
} |
||||||
audioData[i] /= uDataLen; |
audioData[i] /= uDataLen; |
||||||
} |
} |
||||||
} |
if (channel === 2) { |
||||||
} else { |
for(let i=dataLength; i<total; i++) { |
||||||
//线性化显示 |
audioData[i] = 0; |
||||||
for(let i=0; i<dataLength; i++) { |
for(let j=0; j<uDataLen; j++) { |
||||||
audioData[i] = 0; |
audioData[i] += Math.max(0, 0.4 * (Math.log10(data[64+(i-dataLength)*uDataLen+j]/data[128])) + 1.0); |
||||||
for(let j=0; j<uDataLen; j++) { |
} |
||||||
audioData[i] += data[64-i*uDataLen-j-1]; |
audioData[i] /= uDataLen; |
||||||
|
} |
||||||
} |
} |
||||||
audioData[i] /= (uDataLen * data[128]); |
} else { |
||||||
} |
//线性化显示 |
||||||
if (channel === 2) { |
for(let i=0; i<dataLength; i++) { |
||||||
for(let i=dataLength; i<total; i++) { |
|
||||||
audioData[i] = 0; |
audioData[i] = 0; |
||||||
for(let j=0; j<uDataLen; j++) { |
for(let j=0; j<uDataLen; j++) { |
||||||
audioData[i] += data[64+(i-dataLength)*uDataLen+j]; |
audioData[i] += data[64-i*uDataLen-j-1]; |
||||||
} |
} |
||||||
audioData[i] /= (uDataLen * data[128]); |
audioData[i] /= (uDataLen * data[128]); |
||||||
} |
} |
||||||
} |
if (channel === 2) { |
||||||
} |
for(let i=dataLength; i<total; i++) { |
||||||
} else { |
audioData[i] = 0; |
||||||
if (unitStyle) { |
for(let j=0; j<uDataLen; j++) { |
||||||
//对数化显示 |
audioData[i] += data[64+(i-dataLength)*uDataLen+j]; |
||||||
for(let i=0; i<dataLength; i++) { |
} |
||||||
audioData[i] = 0; |
audioData[i] /= (uDataLen * data[128]); |
||||||
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; |
|
||||||
} |
} |
||||||
if (channel === 2) { |
} else { |
||||||
for(let i=dataLength; i<total; i++) { |
if (unitStyle) { |
||||||
|
//对数化显示 |
||||||
|
for(let i=0; i<dataLength; i++) { |
||||||
audioData[i] = 0; |
audioData[i] = 0; |
||||||
for(let j=0; j<uDataLen; j++) { |
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] += Math.max(0, 0.35 * (Math.log10(data[64-i*uDataLen-j-1])+logAmplitude) + 1.0); |
||||||
} |
} |
||||||
audioData[i] /= uDataLen; |
audioData[i] /= uDataLen; |
||||||
} |
} |
||||||
} |
if (channel === 2) { |
||||||
} else { |
for(let i=dataLength; i<total; i++) { |
||||||
//线性化显示 |
audioData[i] = 0; |
||||||
for(let i=0; i<dataLength; i++) { |
for(let j=0; j<uDataLen; j++) { |
||||||
audioData[i] = 0; |
audioData[i] += Math.max(0, 0.35 * (Math.log10(data[64+(i-dataLength)*uDataLen+j])+logAmplitude) + 1.0); |
||||||
for(let j=0; j<uDataLen; j++) { |
} |
||||||
audioData[i] += data[64-i*uDataLen-j-1]; |
audioData[i] /= uDataLen; |
||||||
|
} |
||||||
} |
} |
||||||
audioData[i] /= (uDataLen/amplitude); |
} else { |
||||||
} |
//线性化显示 |
||||||
if (channel === 2) { |
for(let i=0; i<dataLength; i++) { |
||||||
for(let i=dataLength; i<total; i++) { |
|
||||||
audioData[i] = 0; |
audioData[i] = 0; |
||||||
for(let j=0; j<uDataLen; j++) { |
for(let j=0; j<uDataLen; j++) { |
||||||
audioData[i] += data[64+(i-dataLength)*uDataLen+j]; |
audioData[i] += data[64-i*uDataLen-j-1]; |
||||||
} |
} |
||||||
audioData[i] /= (uDataLen/amplitude); |
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); |
||||||
|
} |
||||||
|
} |
||||||
} |
} |
||||||
} |
} |
||||||
} |
let _dy; |
||||||
let _dy; |
let _y_dy = centerRotateFlag*Math.tan(centerRotateAngle*degUnit)*halfWidth; |
||||||
let _y_dy = centerRotateFlag*Math.tan(centerRotateAngle*degUnit)*halfWidth; |
let _ux = width/total; |
||||||
let _ux = width/total; |
let _dx = Math.round(_ux/2); |
||||||
let _dx = Math.round(_ux/2); |
let _y = halfHeight-_y_dy |
||||||
let _y = halfHeight-_y_dy |
|
||||||
|
|
||||||
context.clearRect(0, 0, width+32, height+32); |
|
||||||
|
|
||||||
if(lineRotateFlag || centerRotateFlag) { |
context.clearRect(0, 0, width+32, height+32); |
||||||
context.transform(1, centerRotateFlag*centerRotateAngle * degUnit, -lineRotateFlag*lineRotateAngle * degUnit, 1, lineRotateFlag*Math.sin(1.05*lineRotateAngle*degUnit)*_y, 0); |
|
||||||
} |
|
||||||
|
|
||||||
if (centerLineFlag) { |
if(lineRotateFlag || centerRotateFlag) { |
||||||
context.fillRect(0, _y, width, 2); |
context.transform(1, centerRotateFlag*centerRotateAngle * degUnit, -lineRotateFlag*lineRotateAngle * degUnit, 1, lineRotateFlag*Math.sin(1.05*lineRotateAngle*degUnit)*_y, 0); |
||||||
} |
} |
||||||
|
|
||||||
//绘制频谱 |
if (centerLineFlag) { |
||||||
if (channel === 1 && reverse) { |
context.fillRect(0, _y, width, 2); |
||||||
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++) { |
//绘制频谱 |
||||||
|
if (channel === 1 && reverse) { |
||||||
for (let i = 0; i < dataLength; i++) { |
for (let i = 0; i < dataLength; i++) { |
||||||
let index = j ? ((total - dataLength) + i) : i; |
let index = dataLength - i - 1; |
||||||
_y = halfHeight*(1-(linePosition!==2)*audioData[index])-_y_dy; |
_y = halfHeight*(1-(linePosition!==2)*audioData[index])-_y_dy; |
||||||
_dy = (halfHeight + (!linePosition)*halfHeight)*audioData[index]; |
_dy = (halfHeight + (!linePosition)*halfHeight)*audioData[index]; |
||||||
context.fillRect(_ux * (i + j * dataLength), _y, _dx, _dy); |
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); |
||||||
|
} |
||||||
} |
} |
||||||
} |
} |
||||||
} |
|
||||||
|
|
||||||
if (centerRotateFlag || lineRotateFlag) |
if (centerRotateFlag || lineRotateFlag) |
||||||
context.resetTransform(); |
context.resetTransform(); |
||||||
|
|
||||||
context.fill(); |
context.fill(); |
||||||
|
|
||||||
requestPaint(); |
requestPaint(); |
||||||
} |
} |
||||||
|
|
||||||
Component.onCompleted: { |
Component.onCompleted: { |
||||||
for (let i = 0; i < 128; i++) { |
for (let i = 0; i < 128; i++) { |
||||||
audioData[i] = 0; |
audioData[i] = 0; |
||||||
|
} |
||||||
} |
} |
||||||
} |
} |
||||||
} |
} |
||||||
} |
} |
||||||
} |
|
||||||
|
|
||||||
|
defaultValues: { |
||||||
|
"Version": "1.0.0", |
||||||
|
"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 |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
preference: AdvpPreference { |
||||||
|
version: defaultValues["Version"] |
||||||
|
cfg_height: 670 |
||||||
|
|
||||||
|
P.SelectPreference { |
||||||
|
name: "Gradient Direction" |
||||||
|
label: qsTr("Gradient Direction") |
||||||
|
defaultValue: defaultValues["Gradient Direction"] |
||||||
|
model: [qsTr("Horizontal"), qsTr("Vertical"), qsTr("Oblique Upward"), qsTr("Oblique downward")] |
||||||
|
} |
||||||
|
|
||||||
|
P.ColorPreference { |
||||||
|
name: "Start Position Color" |
||||||
|
label: qsTr("Start Position Color") |
||||||
|
defaultValue: defaultValues["Start Position Color"] |
||||||
|
} |
||||||
|
|
||||||
|
P.ColorPreference { |
||||||
|
name: "Middle Position Color" |
||||||
|
label: qsTr("Middle Position Color") |
||||||
|
defaultValue: defaultValues["Middle Position Color"] |
||||||
|
} |
||||||
|
|
||||||
|
P.ColorPreference { |
||||||
|
name: "End Position Color" |
||||||
|
label: qsTr("End Position Color") |
||||||
|
defaultValue: defaultValues["End Position Color"] |
||||||
|
} |
||||||
|
|
||||||
|
P.Separator {} |
||||||
|
|
||||||
|
P.SwitchPreference { |
||||||
|
name: "Center Line" |
||||||
|
label: qsTr("Show Center Line") |
||||||
|
defaultValue: defaultValues["Center Line"] |
||||||
|
} |
||||||
|
|
||||||
|
P.SelectPreference { |
||||||
|
name: "Line Position" |
||||||
|
label: qsTr("Spectrum Line Position") |
||||||
|
defaultValue: defaultValues["Line Position"] |
||||||
|
model: [qsTr("Both"), qsTr("Up"), qsTr("Down")] |
||||||
|
} |
||||||
|
|
||||||
|
P.SelectPreference { |
||||||
|
name: "Data Length" |
||||||
|
label: qsTr("Spectrum Length") |
||||||
|
defaultValue: defaultValues["Data Length"] |
||||||
|
model: [64, 32, 16, 8] |
||||||
|
} |
||||||
|
|
||||||
|
P.Separator {} |
||||||
|
|
||||||
|
P.SpinPreference { |
||||||
|
id: _cfg_preset_line_Channel |
||||||
|
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"] |
||||||
|
} |
||||||
|
|
||||||
|
P.Separator {} |
||||||
|
|
||||||
|
P.DialogPreference { |
||||||
|
name: "Rotate Settings" |
||||||
|
label: qsTr("Rotate Settings") |
||||||
|
live: true |
||||||
|
icon.name: "regular:\uf1de" |
||||||
|
|
||||||
|
P.SwitchPreference { |
||||||
|
id: _cfg_preset_line_Rotate_Center_Enable |
||||||
|
name: "Center Enable" |
||||||
|
label: qsTr("Rotate Center Line") |
||||||
|
defaultValue: defaultValues["Rotate Settings"]["Center Enable"] |
||||||
|
} |
||||||
|
|
||||||
|
P.SliderPreference { |
||||||
|
name: "Center Angle" |
||||||
|
label: qsTr("Angle of Center Line") |
||||||
|
enabled: _cfg_preset_line_Rotate_Center_Enable.value |
||||||
|
from: -45 |
||||||
|
to: 45 |
||||||
|
stepSize: 1 |
||||||
|
defaultValue: defaultValues["Rotate Settings"]["Center Angle"] |
||||||
|
displayValue: value + "°" |
||||||
|
} |
||||||
|
|
||||||
|
P.Separator {} |
||||||
|
|
||||||
|
P.SwitchPreference { |
||||||
|
id: _cfg_preset_line_Rotate_Line_Enable |
||||||
|
name: "Line Enable" |
||||||
|
label: qsTr("Rotate Spectrum Line") |
||||||
|
defaultValue: defaultValues["Rotate Settings"]["Line Enable"] |
||||||
|
} |
||||||
|
|
||||||
|
P.SliderPreference { |
||||||
|
name: "Line Angle" |
||||||
|
label: qsTr("Angle of Spectrum Line") |
||||||
|
enabled: _cfg_preset_line_Rotate_Line_Enable.value |
||||||
|
from: -75 |
||||||
|
to: 75 |
||||||
|
stepSize: 1 |
||||||
|
defaultValue: defaultValues["Rotate Settings"]["Line Angle"] |
||||||
|
displayValue: value + "°" |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
P.Separator {} |
||||||
|
|
||||||
|
P.DialogPreference { |
||||||
|
name: "Data Settings" |
||||||
|
label: qsTr("Data Settings") |
||||||
|
live: true |
||||||
|
icon.name: "regular:\uf1de" |
||||||
|
|
||||||
|
P.SwitchPreference { |
||||||
|
id: _cfg_preset_line_dataSettings_autoNormalizing |
||||||
|
name: "Auto Normalizing" |
||||||
|
label: qsTr("Auto Normalizing") |
||||||
|
defaultValue: defaultValues["Data Settings"]["Auto Normalizing"] |
||||||
|
} |
||||||
|
|
||||||
|
P.SpinPreference { |
||||||
|
name: "Amplitude" |
||||||
|
label: qsTr("Amplitude Ratio") |
||||||
|
enabled: !_cfg_preset_line_dataSettings_autoNormalizing.value |
||||||
|
message: "1 to 100" |
||||||
|
display: P.TextFieldPreference.ExpandLabel |
||||||
|
editable: true |
||||||
|
from: 1 |
||||||
|
to: 100 |
||||||
|
defaultValue: defaultValues["Data Settings"]["Amplitude"] |
||||||
|
} |
||||||
|
|
||||||
|
P.Separator {} |
||||||
|
|
||||||
|
P.SelectPreference { |
||||||
|
name: "Unit Style" |
||||||
|
label: qsTr("Display Style") |
||||||
|
defaultValue: defaultValues["Data Settings"]["Unit Style"] |
||||||
|
model: [qsTr("Linear"), qsTr("Decibel")] |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
@ -1,150 +0,0 @@ |
|||||||
import QtQuick 2.12 |
|
||||||
import NERvGear.Preferences 1.0 as P |
|
||||||
|
|
||||||
import "../../qml/api" //导入CfgAPI.qml |
|
||||||
|
|
||||||
CfgAPI { |
|
||||||
version: "1.0.0" |
|
||||||
cfg_height: 580 |
|
||||||
|
|
||||||
P.SwitchPreference { |
|
||||||
id: _cfg_preset_line_Center_Line |
|
||||||
name: "Center Line" |
|
||||||
label: qsTr("Show Center Line") |
|
||||||
defaultValue: true |
|
||||||
} |
|
||||||
|
|
||||||
P.ColorPreference { |
|
||||||
name: "Center Color" |
|
||||||
label: qsTr("Center Line Color") |
|
||||||
enabled: _cfg_preset_line_Center_Line.value |
|
||||||
defaultValue: "#FF4500" |
|
||||||
} |
|
||||||
|
|
||||||
P.Separator {} |
|
||||||
|
|
||||||
P.ColorPreference { |
|
||||||
name: "Line Color" |
|
||||||
label: qsTr("Spectrum Line Color") |
|
||||||
defaultValue: "#FF4500" |
|
||||||
} |
|
||||||
|
|
||||||
P.SelectPreference { |
|
||||||
name: "Line Position" |
|
||||||
label: qsTr("Spectrum Line Position") |
|
||||||
defaultValue: 0 |
|
||||||
model: [qsTr("Both"), qsTr("Up"), qsTr("Down")] |
|
||||||
} |
|
||||||
|
|
||||||
P.SelectPreference { |
|
||||||
name: "Data Length" |
|
||||||
label: qsTr("Spectrum Length") |
|
||||||
defaultValue: 0 |
|
||||||
model: [64, 32, 16, 8] |
|
||||||
} |
|
||||||
|
|
||||||
P.Separator {} |
|
||||||
|
|
||||||
P.SpinPreference { |
|
||||||
id: _cfg_preset_line_Channel |
|
||||||
name: "Channel" |
|
||||||
label: qsTr("Channel") |
|
||||||
message: "1 to 2" |
|
||||||
display: P.TextFieldPreference.ExpandLabel |
|
||||||
editable: false |
|
||||||
from: 1 |
|
||||||
to: 2 |
|
||||||
defaultValue: 2 |
|
||||||
} |
|
||||||
|
|
||||||
P.SwitchPreference { |
|
||||||
name: "Reverse" |
|
||||||
label: qsTr("Reverse Spectrum") |
|
||||||
enabled: _cfg_preset_line_Channel.value === 1 |
|
||||||
defaultValue: false |
|
||||||
} |
|
||||||
|
|
||||||
P.Separator {} |
|
||||||
|
|
||||||
P.DialogPreference { |
|
||||||
name: "Rotate Settings" |
|
||||||
label: qsTr("Rotate Settings") |
|
||||||
live: true |
|
||||||
icon.name: "regular:\uf1de" |
|
||||||
|
|
||||||
P.SwitchPreference { |
|
||||||
id: _cfg_preset_line_Rotate_Center_Enable |
|
||||||
name: "Center Enable" |
|
||||||
label: qsTr("Rotate Center Line") |
|
||||||
defaultValue: false |
|
||||||
} |
|
||||||
|
|
||||||
P.SliderPreference { |
|
||||||
name: "Center Angle" |
|
||||||
label: qsTr("Angle of Center Line") |
|
||||||
enabled: _cfg_preset_line_Rotate_Center_Enable.value |
|
||||||
from: -45 |
|
||||||
to: 45 |
|
||||||
stepSize: 1 |
|
||||||
defaultValue: 10 |
|
||||||
displayValue: value + "°" |
|
||||||
} |
|
||||||
|
|
||||||
P.Separator {} |
|
||||||
|
|
||||||
P.SwitchPreference { |
|
||||||
id: _cfg_preset_line_Rotate_Line_Enable |
|
||||||
name: "Line Enable" |
|
||||||
label: qsTr("Rotate Spectrum Line") |
|
||||||
defaultValue: false |
|
||||||
} |
|
||||||
|
|
||||||
P.SliderPreference { |
|
||||||
name: "Line Angle" |
|
||||||
label: qsTr("Angle of Spectrum Line") |
|
||||||
enabled: _cfg_preset_line_Rotate_Line_Enable.value |
|
||||||
from: -75 |
|
||||||
to: 75 |
|
||||||
stepSize: 1 |
|
||||||
defaultValue: 10 |
|
||||||
displayValue: value + "°" |
|
||||||
} |
|
||||||
} |
|
||||||
|
|
||||||
P.Separator {} |
|
||||||
|
|
||||||
P.DialogPreference { |
|
||||||
name: "Data Settings" |
|
||||||
label: qsTr("Data Settings") |
|
||||||
live: true |
|
||||||
icon.name: "regular:\uf1de" |
|
||||||
|
|
||||||
P.SwitchPreference { |
|
||||||
id: _cfg_preset_line_dataSettings_autoNormalizing |
|
||||||
name: "Auto Normalizing" |
|
||||||
label: qsTr("Auto Normalizing") |
|
||||||
defaultValue: true |
|
||||||
} |
|
||||||
|
|
||||||
P.SpinPreference { |
|
||||||
name: "Amplitude" |
|
||||||
label: qsTr("Amplitude Ratio") |
|
||||||
enabled: !_cfg_preset_line_dataSettings_autoNormalizing.value |
|
||||||
message: "1 to 100" |
|
||||||
display: P.TextFieldPreference.ExpandLabel |
|
||||||
editable: true |
|
||||||
from: 1 |
|
||||||
to: 100 |
|
||||||
defaultValue: 10 |
|
||||||
} |
|
||||||
|
|
||||||
P.Separator {} |
|
||||||
|
|
||||||
P.SelectPreference { |
|
||||||
name: "Unit Style" |
|
||||||
label: qsTr("Display Style") |
|
||||||
defaultValue: 0 |
|
||||||
model: [qsTr("Linear"), qsTr("Decibel")] |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,163 +1,333 @@ |
|||||||
import QtQuick 2.12 |
import QtQuick 2.12 |
||||||
import QtQuick.Controls 2.12 |
import NERvGear.Preferences 1.0 as P |
||||||
|
|
||||||
import "../../qml/api" |
import "../../qml/api" |
||||||
|
|
||||||
StyleAPI { |
AdvpStyleTemplate { |
||||||
readonly property var audioData: new Array(128) |
style: AdvpCanvasTemplate { |
||||||
|
readonly property var audioData: new Array(128) |
||||||
readonly property bool centerLineFlag: configs["Center Line"] |
|
||||||
readonly property string center_color: configs["Center Color"] |
readonly property bool centerLineFlag: configs["Center Line"] |
||||||
readonly property string line_color: configs["Line Color"] |
readonly property string center_color: configs["Center Color"] |
||||||
readonly property int linePosition: configs["Line Position"] |
readonly property string line_color: configs["Line Color"] |
||||||
readonly property int uDataLen: Math.pow(2, configs["Data Length"]); |
readonly property int linePosition: configs["Line Position"] |
||||||
readonly property int dataLength: 64/uDataLen |
readonly property int uDataLen: Math.pow(2, configs["Data Length"]); |
||||||
readonly property int channel: configs["Channel"] |
readonly property int dataLength: 64/uDataLen |
||||||
readonly property bool reverse: configs["Reverse"] |
readonly property int channel: configs["Channel"] |
||||||
readonly property bool centerRotateFlag: configs["Rotate Settings"]["Center Enable"] |
readonly property bool reverse: configs["Reverse"] |
||||||
readonly property real centerRotateAngle: configs["Rotate Settings"]["Center Angle"] |
readonly property bool centerRotateFlag: configs["Rotate Settings"]["Center Enable"] |
||||||
readonly property bool lineRotateFlag: configs["Rotate Settings"]["Line Enable"] |
readonly property real centerRotateAngle: configs["Rotate Settings"]["Center Angle"] |
||||||
readonly property real lineRotateAngle: configs["Rotate Settings"]["Line Angle"] |
readonly property bool lineRotateFlag: configs["Rotate Settings"]["Line Enable"] |
||||||
readonly property bool autoNormalizing: configs["Data Settings"]["Auto Normalizing"] |
readonly property real lineRotateAngle: configs["Rotate Settings"]["Line Angle"] |
||||||
readonly property real amplitude: configs["Data Settings"]["Amplitude"] / 400.0 |
readonly property bool autoNormalizing: configs["Data Settings"]["Auto Normalizing"] |
||||||
readonly property int unitStyle: configs["Data Settings"]["Unit Style"] |
readonly property real amplitude: configs["Data Settings"]["Amplitude"] / 400.0 |
||||||
|
readonly property int unitStyle: configs["Data Settings"]["Unit Style"] |
||||||
property int total: channel * dataLength |
|
||||||
property real logAmplitude: Math.log10(amplitude) |
property int total: channel * dataLength |
||||||
property real degUnit: Math.PI / 180 |
property real logAmplitude: Math.log10(amplitude) |
||||||
|
property real degUnit: Math.PI / 180 |
||||||
property real halfWidth: width/2 |
|
||||||
property real halfHeight: height/2 |
property real halfWidth: width/2 |
||||||
|
property real halfHeight: height/2 |
||||||
onAudioDataUpdeted: { |
|
||||||
if(autoNormalizing) { |
onAudioDataUpdeted: { |
||||||
if (unitStyle) { |
if(autoNormalizing) { |
||||||
//对数化显示 |
if (unitStyle) { |
||||||
for(let i=0; i<dataLength; i++) { |
//对数化显示 |
||||||
audioData[i] = 0; |
for(let i=0; i<dataLength; i++) { |
||||||
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; |
|
||||||
} |
|
||||||
if (channel === 2) { |
|
||||||
for(let i=dataLength; i<total; i++) { |
|
||||||
audioData[i] = 0; |
audioData[i] = 0; |
||||||
for(let j=0; j<uDataLen; j++) { |
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] += Math.max(0, 0.4 * (Math.log10(data[64-i*uDataLen-j-1]/data[128])) + 1.0); |
||||||
} |
} |
||||||
audioData[i] /= uDataLen; |
audioData[i] /= uDataLen; |
||||||
} |
} |
||||||
} |
if (channel === 2) { |
||||||
} else { |
for(let i=dataLength; i<total; i++) { |
||||||
//线性化显示 |
audioData[i] = 0; |
||||||
for(let i=0; i<dataLength; i++) { |
for(let j=0; j<uDataLen; j++) { |
||||||
audioData[i] = 0; |
audioData[i] += Math.max(0, 0.4 * (Math.log10(data[64+(i-dataLength)*uDataLen+j]/data[128])) + 1.0); |
||||||
for(let j=0; j<uDataLen; j++) { |
} |
||||||
audioData[i] += data[64-i*uDataLen-j-1]; |
audioData[i] /= uDataLen; |
||||||
|
} |
||||||
} |
} |
||||||
audioData[i] /= (uDataLen * data[128]); |
} else { |
||||||
} |
//线性化显示 |
||||||
if (channel === 2) { |
for(let i=0; i<dataLength; i++) { |
||||||
for(let i=dataLength; i<total; i++) { |
|
||||||
audioData[i] = 0; |
audioData[i] = 0; |
||||||
for(let j=0; j<uDataLen; j++) { |
for(let j=0; j<uDataLen; j++) { |
||||||
audioData[i] += data[64+(i-dataLength)*uDataLen+j]; |
audioData[i] += data[64-i*uDataLen-j-1]; |
||||||
} |
} |
||||||
audioData[i] /= (uDataLen * data[128]); |
audioData[i] /= (uDataLen * data[128]); |
||||||
} |
} |
||||||
} |
if (channel === 2) { |
||||||
} |
for(let i=dataLength; i<total; i++) { |
||||||
} else { |
audioData[i] = 0; |
||||||
if (unitStyle) { |
for(let j=0; j<uDataLen; j++) { |
||||||
//对数化显示 |
audioData[i] += data[64+(i-dataLength)*uDataLen+j]; |
||||||
for(let i=0; i<dataLength; i++) { |
} |
||||||
audioData[i] = 0; |
audioData[i] /= (uDataLen * data[128]); |
||||||
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; |
|
||||||
} |
} |
||||||
if (channel === 2) { |
} else { |
||||||
for(let i=dataLength; i<total; i++) { |
if (unitStyle) { |
||||||
|
//对数化显示 |
||||||
|
for(let i=0; i<dataLength; i++) { |
||||||
audioData[i] = 0; |
audioData[i] = 0; |
||||||
for(let j=0; j<uDataLen; j++) { |
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] += Math.max(0, 0.35 * (Math.log10(data[64-i*uDataLen-j-1])+logAmplitude) + 1.0); |
||||||
} |
} |
||||||
audioData[i] /= uDataLen; |
audioData[i] /= uDataLen; |
||||||
} |
} |
||||||
} |
if (channel === 2) { |
||||||
} else { |
for(let i=dataLength; i<total; i++) { |
||||||
//线性化显示 |
audioData[i] = 0; |
||||||
for(let i=0; i<dataLength; i++) { |
for(let j=0; j<uDataLen; j++) { |
||||||
audioData[i] = 0; |
audioData[i] += Math.max(0, 0.35 * (Math.log10(data[64+(i-dataLength)*uDataLen+j])+logAmplitude) + 1.0); |
||||||
for(let j=0; j<uDataLen; j++) { |
} |
||||||
audioData[i] += data[64-i*uDataLen-j-1]; |
audioData[i] /= uDataLen; |
||||||
|
} |
||||||
} |
} |
||||||
audioData[i] /= (uDataLen/amplitude); |
} else { |
||||||
} |
//线性化显示 |
||||||
if (channel === 2) { |
for(let i=0; i<dataLength; i++) { |
||||||
for(let i=dataLength; i<total; i++) { |
|
||||||
audioData[i] = 0; |
audioData[i] = 0; |
||||||
for(let j=0; j<uDataLen; j++) { |
for(let j=0; j<uDataLen; j++) { |
||||||
audioData[i] += data[64+(i-dataLength)*uDataLen+j]; |
audioData[i] += data[64-i*uDataLen-j-1]; |
||||||
} |
} |
||||||
audioData[i] /= (uDataLen/amplitude); |
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); |
||||||
|
} |
||||||
|
} |
||||||
} |
} |
||||||
} |
} |
||||||
} |
let _dy; |
||||||
let _dy; |
let _y_dy = centerRotateFlag*Math.tan(centerRotateAngle*degUnit)*halfWidth; |
||||||
let _y_dy = centerRotateFlag*Math.tan(centerRotateAngle*degUnit)*halfWidth; |
let _ux = width/total; |
||||||
let _ux = width/total; |
let _dx = Math.round(_ux/2); |
||||||
let _dx = Math.round(_ux/2); |
let _y = halfHeight-_y_dy |
||||||
let _y = halfHeight-_y_dy |
|
||||||
|
|
||||||
context.clearRect(0, 0, width+32, height+32); |
context.clearRect(0, 0, width+32, height+32); |
||||||
|
|
||||||
if(lineRotateFlag || centerRotateFlag) { |
if(lineRotateFlag || centerRotateFlag) { |
||||||
context.transform(1, centerRotateFlag*centerRotateAngle * degUnit, -lineRotateFlag*lineRotateAngle * degUnit, 1, lineRotateFlag*Math.sin(1.05*lineRotateAngle*degUnit)*_y, 0); |
context.transform(1, centerRotateFlag*centerRotateAngle * degUnit, -lineRotateFlag*lineRotateAngle * degUnit, 1, lineRotateFlag*Math.sin(1.05*lineRotateAngle*degUnit)*_y, 0); |
||||||
} |
} |
||||||
|
|
||||||
if (centerLineFlag) { |
if (centerLineFlag) { |
||||||
context.fillStyle = center_color; |
context.fillStyle = center_color; |
||||||
context.fillRect(0, _y, width, 2); |
context.fillRect(0, _y, width, 2); |
||||||
} |
} |
||||||
|
|
||||||
|
|
||||||
|
|
||||||
context.fillStyle = line_color; |
context.fillStyle = line_color; |
||||||
|
|
||||||
//绘制频谱 |
//绘制频谱 |
||||||
if (channel === 1 && reverse) { |
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++) { |
for (let i = 0; i < dataLength; i++) { |
||||||
let index = j ? ((total - dataLength) + i) : i; |
let index = dataLength - i - 1; |
||||||
_y = halfHeight*(1-(linePosition!==2)*audioData[index])-_y_dy; |
_y = halfHeight*(1-(linePosition!==2)*audioData[index])-_y_dy; |
||||||
_dy = (halfHeight + (!linePosition)*halfHeight)*audioData[index]; |
_dy = (halfHeight + (!linePosition)*halfHeight)*audioData[index]; |
||||||
context.fillRect(_ux * (i + j * dataLength), _y, _dx, _dy); |
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); |
||||||
|
} |
||||||
} |
} |
||||||
} |
} |
||||||
} |
|
||||||
|
|
||||||
if (centerRotateFlag || lineRotateFlag) |
if (centerRotateFlag || lineRotateFlag) |
||||||
context.resetTransform(); |
context.resetTransform(); |
||||||
|
|
||||||
context.fill(); |
context.fill(); |
||||||
|
|
||||||
requestPaint(); |
requestPaint(); |
||||||
|
} |
||||||
|
|
||||||
|
Component.onCompleted: { |
||||||
|
for (let i = 0; i < 128; i++) { |
||||||
|
audioData[i] = 0; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
defaultValues: { |
||||||
|
"Version": "1.0.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, |
||||||
|
"Line Enable": false, |
||||||
|
"Line Angle": 10 |
||||||
|
}, |
||||||
|
"Data Settings": { |
||||||
|
"Auto Normalizing": true, |
||||||
|
"Amplitude": 10, |
||||||
|
"Unit Style": 0 |
||||||
|
} |
||||||
} |
} |
||||||
|
|
||||||
Component.onCompleted: { |
preference: AdvpPreference { |
||||||
for (let i = 0; i < 128; i++) { |
version: defaultValues["Version"] |
||||||
audioData[i] = 0; |
cfg_height: 580 |
||||||
|
|
||||||
|
P.SwitchPreference { |
||||||
|
id: _cfg_preset_line_Center_Line |
||||||
|
name: "Center Line" |
||||||
|
label: qsTr("Show Center Line") |
||||||
|
defaultValue: defaultValues["Center Line"] |
||||||
|
} |
||||||
|
|
||||||
|
P.ColorPreference { |
||||||
|
name: "Center Color" |
||||||
|
label: qsTr("Center Line Color") |
||||||
|
enabled: _cfg_preset_line_Center_Line.value |
||||||
|
defaultValue: defaultValues["Center Color"] |
||||||
|
} |
||||||
|
|
||||||
|
P.Separator {} |
||||||
|
|
||||||
|
P.ColorPreference { |
||||||
|
name: "Line Color" |
||||||
|
label: qsTr("Spectrum Line Color") |
||||||
|
defaultValue: defaultValues["Line Color"] |
||||||
|
} |
||||||
|
|
||||||
|
P.SelectPreference { |
||||||
|
name: "Line Position" |
||||||
|
label: qsTr("Spectrum Line Position") |
||||||
|
defaultValue: defaultValues["Line Position"] |
||||||
|
model: [qsTr("Both"), qsTr("Up"), qsTr("Down")] |
||||||
|
} |
||||||
|
|
||||||
|
P.SelectPreference { |
||||||
|
name: "Data Length" |
||||||
|
label: qsTr("Spectrum Length") |
||||||
|
defaultValue: defaultValues["Data Length"] |
||||||
|
model: [64, 32, 16, 8] |
||||||
|
} |
||||||
|
|
||||||
|
P.Separator {} |
||||||
|
|
||||||
|
P.SpinPreference { |
||||||
|
id: _cfg_preset_line_Channel |
||||||
|
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"] |
||||||
|
} |
||||||
|
|
||||||
|
P.Separator {} |
||||||
|
|
||||||
|
P.DialogPreference { |
||||||
|
name: "Rotate Settings" |
||||||
|
label: qsTr("Rotate Settings") |
||||||
|
live: true |
||||||
|
icon.name: "regular:\uf1de" |
||||||
|
|
||||||
|
P.SwitchPreference { |
||||||
|
id: _cfg_preset_line_Rotate_Center_Enable |
||||||
|
name: "Center Enable" |
||||||
|
label: qsTr("Rotate Center Line") |
||||||
|
defaultValue: defaultValues["Rotate Settings"]["Center Enable"] |
||||||
|
} |
||||||
|
|
||||||
|
P.SliderPreference { |
||||||
|
name: "Center Angle" |
||||||
|
label: qsTr("Angle of Center Line") |
||||||
|
enabled: _cfg_preset_line_Rotate_Center_Enable.value |
||||||
|
from: -45 |
||||||
|
to: 45 |
||||||
|
stepSize: 1 |
||||||
|
defaultValue: defaultValues["Rotate Settings"]["Center Angle"] |
||||||
|
displayValue: value + "°" |
||||||
|
} |
||||||
|
|
||||||
|
P.Separator {} |
||||||
|
|
||||||
|
P.SwitchPreference { |
||||||
|
id: _cfg_preset_line_Rotate_Line_Enable |
||||||
|
name: "Line Enable" |
||||||
|
label: qsTr("Rotate Spectrum Line") |
||||||
|
defaultValue: defaultValues["Rotate Settings"]["Line Enable"] |
||||||
|
} |
||||||
|
|
||||||
|
P.SliderPreference { |
||||||
|
name: "Line Angle" |
||||||
|
label: qsTr("Angle of Spectrum Line") |
||||||
|
enabled: _cfg_preset_line_Rotate_Line_Enable.value |
||||||
|
from: -75 |
||||||
|
to: 75 |
||||||
|
stepSize: 1 |
||||||
|
defaultValue: defaultValues["Rotate Settings"]["Line Angle"] |
||||||
|
displayValue: value + "°" |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
P.Separator {} |
||||||
|
|
||||||
|
P.DialogPreference { |
||||||
|
name: "Data Settings" |
||||||
|
label: qsTr("Data Settings") |
||||||
|
live: true |
||||||
|
icon.name: "regular:\uf1de" |
||||||
|
|
||||||
|
P.SwitchPreference { |
||||||
|
id: _cfg_preset_line_dataSettings_autoNormalizing |
||||||
|
name: "Auto Normalizing" |
||||||
|
label: qsTr("Auto Normalizing") |
||||||
|
defaultValue: defaultValues["Data Settings"]["Auto Normalizing"] |
||||||
|
} |
||||||
|
|
||||||
|
P.SpinPreference { |
||||||
|
name: "Amplitude" |
||||||
|
label: qsTr("Amplitude Ratio") |
||||||
|
enabled: !_cfg_preset_line_dataSettings_autoNormalizing.value |
||||||
|
message: "1 to 100" |
||||||
|
display: P.TextFieldPreference.ExpandLabel |
||||||
|
editable: true |
||||||
|
from: 1 |
||||||
|
to: 100 |
||||||
|
defaultValue: defaultValues["Data Settings"]["Amplitude"] |
||||||
|
} |
||||||
|
|
||||||
|
P.Separator {} |
||||||
|
|
||||||
|
P.SelectPreference { |
||||||
|
name: "Unit Style" |
||||||
|
label: qsTr("Display Style") |
||||||
|
defaultValue: defaultValues["Data Settings"]["Unit Style"] |
||||||
|
model: [qsTr("Linear"), qsTr("Decibel")] |
||||||
|
} |
||||||
} |
} |
||||||
} |
} |
||||||
} |
} |
||||||
|
@ -1,139 +0,0 @@ |
|||||||
import QtQuick 2.12 |
|
||||||
import NERvGear.Preferences 1.0 as P |
|
||||||
|
|
||||||
import "../../qml/api" //导入CfgAPI.qml |
|
||||||
|
|
||||||
CfgAPI { |
|
||||||
version: "1.0.0" |
|
||||||
cfg_height: 740 |
|
||||||
|
|
||||||
P.ColorPreference { |
|
||||||
name: "Main Color" |
|
||||||
label: qsTr("Spectrum Line Color") |
|
||||||
defaultValue: "#FF4500" |
|
||||||
} |
|
||||||
|
|
||||||
P.SelectPreference { |
|
||||||
name: "Line Position" |
|
||||||
label: qsTr("Spectrum Line Position") |
|
||||||
defaultValue: 0 |
|
||||||
model: [qsTr("Both"), qsTr("Outside"), qsTr("Inside")] |
|
||||||
} |
|
||||||
|
|
||||||
P.SliderPreference { |
|
||||||
name: "Line Width" |
|
||||||
label: qsTr("Spectrum Line Width") |
|
||||||
from: 0.1 |
|
||||||
to: 4 |
|
||||||
stepSize: 0.1 |
|
||||||
defaultValue: 1 |
|
||||||
displayValue: value.toFixed(1) + "px" |
|
||||||
} |
|
||||||
|
|
||||||
P.SliderPreference { |
|
||||||
name: "Max Range" |
|
||||||
label: qsTr("Max Amplitude") |
|
||||||
from: 0 |
|
||||||
to: 100 |
|
||||||
stepSize: 1 |
|
||||||
defaultValue: 50 |
|
||||||
displayValue: value + "%" |
|
||||||
} |
|
||||||
|
|
||||||
P.SelectPreference { |
|
||||||
name: "Data Length" |
|
||||||
label: qsTr("Spectrum Length") |
|
||||||
defaultValue: 0 |
|
||||||
model: [64, 32, 16, 8] |
|
||||||
} |
|
||||||
|
|
||||||
P.Separator {} |
|
||||||
|
|
||||||
P.SpinPreference { |
|
||||||
name: "Channel" |
|
||||||
label: qsTr("Channel") |
|
||||||
message: "1 to 2" |
|
||||||
display: P.TextFieldPreference.ExpandLabel |
|
||||||
editable: false |
|
||||||
from: 1 |
|
||||||
to: 2 |
|
||||||
defaultValue: 2 |
|
||||||
} |
|
||||||
|
|
||||||
P.Separator {} |
|
||||||
|
|
||||||
P.SwitchPreference { |
|
||||||
name: "Reverse" |
|
||||||
label: qsTr("Reverse Spectrum") |
|
||||||
defaultValue: false |
|
||||||
} |
|
||||||
|
|
||||||
P.Separator {} |
|
||||||
|
|
||||||
P.SwitchPreference { |
|
||||||
id: _cfg_preset_line_rotate |
|
||||||
name: "Rotate" |
|
||||||
label: qsTr("Auto Rotate") |
|
||||||
defaultValue: false |
|
||||||
} |
|
||||||
|
|
||||||
P.SliderPreference { |
|
||||||
name: "Ratate Speed" |
|
||||||
label: qsTr("Ratate Speed") |
|
||||||
enabled: _cfg_preset_line_rotate.value |
|
||||||
from: 1 |
|
||||||
to: 100 |
|
||||||
stepSize: 1 |
|
||||||
defaultValue: 10 |
|
||||||
displayValue: value + "%" |
|
||||||
} |
|
||||||
|
|
||||||
P.SpinPreference { |
|
||||||
name: "Angle" |
|
||||||
label: qsTr("Initial Angle") |
|
||||||
message: "0 to 359" |
|
||||||
enabled: !_cfg_preset_line_rotate.value |
|
||||||
display: P.TextFieldPreference.ExpandLabel |
|
||||||
editable: true |
|
||||||
from: 0 |
|
||||||
to: 359 |
|
||||||
defaultValue: 0 |
|
||||||
} |
|
||||||
|
|
||||||
P.Separator {} |
|
||||||
|
|
||||||
P.DialogPreference { |
|
||||||
name: "Data Settings" |
|
||||||
label: qsTr("Data Settings") |
|
||||||
live: true |
|
||||||
icon.name: "regular:\uf1de" |
|
||||||
|
|
||||||
P.SwitchPreference { |
|
||||||
id: _cfg_preset_solidcircle_dataSettings_autoNormalizing |
|
||||||
name: "Auto Normalizing" |
|
||||||
label: qsTr("Auto Normalizing") |
|
||||||
defaultValue: true |
|
||||||
} |
|
||||||
|
|
||||||
P.SpinPreference { |
|
||||||
name: "Amplitude" |
|
||||||
label: qsTr("Amplitude Ratio") |
|
||||||
enabled: !_cfg_preset_solidcircle_dataSettings_autoNormalizing.value |
|
||||||
message: "1 to 100" |
|
||||||
display: P.TextFieldPreference.ExpandLabel |
|
||||||
editable: true |
|
||||||
from: 1 |
|
||||||
to: 100 |
|
||||||
defaultValue: 10 |
|
||||||
} |
|
||||||
|
|
||||||
P.Separator {} |
|
||||||
|
|
||||||
P.SelectPreference { |
|
||||||
name: "Unit Style" |
|
||||||
label: qsTr("Display Style") |
|
||||||
defaultValue: 0 |
|
||||||
model: [qsTr("Linear"), qsTr("Decibel")] |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,149 +1,303 @@ |
|||||||
import QtQuick 2.12 |
import QtQuick 2.12 |
||||||
import QtQuick.Controls 2.12 |
import NERvGear.Preferences 1.0 as P |
||||||
|
|
||||||
import "../../qml/api" |
import "../../qml/api" |
||||||
|
|
||||||
StyleAPI { |
AdvpStyleTemplate { |
||||||
readonly property var audioData: new Array(128) |
style: AdvpCanvasTemplate { |
||||||
|
readonly property var audioData: new Array(128) |
||||||
//configs |
|
||||||
readonly property string color: configs["Main Color"] |
|
||||||
readonly property int linePosition: configs["Line Position"] |
|
||||||
readonly property real lineWidth: configs["Line Width"] |
|
||||||
readonly property real maxRange: configs["Max Range"] / 100 |
|
||||||
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 rotateFlag: configs["Rotate"] |
|
||||||
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 int unitStyle: configs["Data Settings"]["Unit Style"] |
|
||||||
|
|
||||||
readonly property int total: channel*dataLength |
|
||||||
|
|
||||||
readonly property real dotGap: 360/total |
|
||||||
property real offsetAngle: 0 |
|
||||||
property var outerPos: [] |
|
||||||
property var innerPos: [] |
|
||||||
readonly property real degUnit: Math.PI/180 |
|
||||||
|
|
||||||
readonly property real subRatio: 0.2*maxRange |
|
||||||
readonly property real mainRatio: 1-subRatio*2.5 |
|
||||||
|
|
||||||
readonly property real minLength: Math.min(width, height) |
|
||||||
readonly property real ratio:minLength*subRatio |
|
||||||
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: { |
|
||||||
context.lineWidth = lineWidth; |
|
||||||
context.strokeStyle = color; |
|
||||||
} |
|
||||||
|
|
||||||
function getPos(r, deg) { |
//configs |
||||||
return [halfWidth+Math.cos(deg)*r,halfHeight+Math.sin(deg)*r]; |
readonly property int linePosition: configs["Line Position"] |
||||||
} |
readonly property real maxRange: configs["Max Range"] / 100 |
||||||
|
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 rotateFlag: configs["Rotate"] |
||||||
|
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 int unitStyle: configs["Data Settings"]["Unit Style"] |
||||||
|
|
||||||
function createPoint() { |
readonly property int total: channel*dataLength |
||||||
outerPos = []; |
|
||||||
innerPos = []; |
readonly property real dotGap: 360/total |
||||||
let deg, deltaR, r1, r2, _rhmLen; |
property real offsetAngle: 0 |
||||||
_rhmLen = mainRatio*halfMinLength; |
property var outerPos: [] |
||||||
|
property var innerPos: [] |
||||||
for (let j=0; j < channel; j++) { |
readonly property real degUnit: Math.PI/180 |
||||||
for (let i=0; i < dataLength; i++) { |
|
||||||
deg = degUnit*((i+j*dataLength)*dotGap + offsetAngle); |
readonly property real subRatio: 0.2*maxRange |
||||||
deltaR = audioData[reverse*(dataLength-i-1)+(!reverse)*(i+j*dataLength)] * ratio; |
readonly property real mainRatio: 1-subRatio*2.5 |
||||||
r1 = _rhmLen+1+deltaR*(linePosition!==2); |
|
||||||
r2 = _rhmLen-1-deltaR*(linePosition!==1); |
readonly property real minLength: Math.min(width, height) |
||||||
outerPos.push(getPos(r1, deg)); |
readonly property real ratio:minLength*subRatio |
||||||
innerPos.push(getPos(r2, deg)); |
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: { |
||||||
|
context.lineWidth = configs["Line Width"]; |
||||||
|
context.strokeStyle = configs["Main Color"]; |
||||||
} |
} |
||||||
offsetAngle = rotateFlag ? ((offsetAngle + rSpeed) % 360) : angle; |
|
||||||
} |
|
||||||
|
|
||||||
onAudioDataUpdeted: { |
function getPos(r, deg) { |
||||||
if(autoNormalizing) { |
return [halfWidth+Math.cos(deg)*r,halfHeight+Math.sin(deg)*r]; |
||||||
if (unitStyle) { |
} |
||||||
//对数化显示 |
|
||||||
let logPeak = Math.log10(data[128]); |
function createPoint() { |
||||||
for(let i=0; i<total; i++) { |
outerPos = []; |
||||||
audioData[i] = 0; |
innerPos = []; |
||||||
for(let j=0; j<uDataLen; j++) { |
let deg, deltaR, r1, r2, _rhmLen; |
||||||
audioData[i] += Math.max(0, 0.4 * (Math.log10(data[i*uDataLen+j])-logPeak) + 1.0); |
_rhmLen = mainRatio*halfMinLength; |
||||||
} |
|
||||||
audioData[i] /= uDataLen; |
for (let j=0; j < channel; j++) { |
||||||
} |
for (let i=0; i < dataLength; i++) { |
||||||
} else { |
deg = degUnit*((i+j*dataLength)*dotGap + offsetAngle); |
||||||
//线性化显示 |
deltaR = audioData[reverse*(dataLength-i-1)+(!reverse)*(i+j*dataLength)] * ratio; |
||||||
for(let i=0; i<total; i++) { |
r1 = _rhmLen+1+deltaR*(linePosition!==2); |
||||||
audioData[i] = 0; |
r2 = _rhmLen-1-deltaR*(linePosition!==1); |
||||||
for(let j=0; j<uDataLen; j++) { |
outerPos.push(getPos(r1, deg)); |
||||||
audioData[i] += data[i*uDataLen+j] / data[128]; |
innerPos.push(getPos(r2, deg)); |
||||||
} |
|
||||||
audioData[i] /= uDataLen; |
|
||||||
} |
} |
||||||
} |
} |
||||||
} else { |
offsetAngle = rotateFlag ? ((offsetAngle + rSpeed) % 360) : angle; |
||||||
if (unitStyle) { |
} |
||||||
//对数化显示 |
|
||||||
for(let i=0; i<total; i++) { |
onAudioDataUpdeted: { |
||||||
audioData[i] = 0; |
if(autoNormalizing) { |
||||||
for(let j=0; j<uDataLen; j++) { |
if (unitStyle) { |
||||||
audioData[i] += Math.max(0, 0.35 * (Math.log10(data[i*uDataLen+j])+logAmplitude) + 1.0); |
//对数化显示 |
||||||
|
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; |
||||||
} |
} |
||||||
audioData[i] /= uDataLen; |
|
||||||
} |
} |
||||||
} else { |
} else { |
||||||
//线性化显示 |
if (unitStyle) { |
||||||
for(let i=0; i<total; i++) { |
//对数化显示 |
||||||
audioData[i] = 0; |
for(let i=0; i<total; i++) { |
||||||
for(let j=0; j<uDataLen; j++) { |
audioData[i] = 0; |
||||||
audioData[i] += data[i*uDataLen+j] * amplitude; |
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; |
||||||
} |
} |
||||||
audioData[i] /= uDataLen; |
|
||||||
} |
} |
||||||
} |
} |
||||||
} |
|
||||||
|
|
||||||
context.clearRect(0, 0, width+32, height+32); |
context.clearRect(0, 0, width+32, height+32); |
||||||
createPoint(); |
createPoint(); |
||||||
|
|
||||||
|
context.beginPath(); |
||||||
|
context.moveTo(outerPos[0][0], outerPos[0][1]); |
||||||
|
for(let i=0; i<total; i++) { |
||||||
|
context.lineTo(outerPos[i][0], outerPos[i][1]); |
||||||
|
} |
||||||
|
context.closePath(); |
||||||
|
context.stroke(); |
||||||
|
|
||||||
context.beginPath(); |
context.beginPath(); |
||||||
context.moveTo(outerPos[0][0], outerPos[0][1]); |
context.moveTo(innerPos[0][0], innerPos[0][1]); |
||||||
for(let i=0; i<total; i++) { |
for(let i=0; i<total; i++) { |
||||||
context.lineTo(outerPos[i][0], outerPos[i][1]); |
context.lineTo(innerPos[i][0], innerPos[i][1]); |
||||||
|
} |
||||||
|
context.closePath(); |
||||||
|
context.stroke(); |
||||||
|
|
||||||
|
context.beginPath(); |
||||||
|
for(let i=0; i<total; i++) { |
||||||
|
context.moveTo(outerPos[i][0], outerPos[i][1]); |
||||||
|
context.lineTo(innerPos[i][0], innerPos[i][1]); |
||||||
|
} |
||||||
|
context.stroke(); |
||||||
|
requestPaint(); |
||||||
} |
} |
||||||
context.closePath(); |
|
||||||
context.stroke(); |
|
||||||
|
|
||||||
context.beginPath(); |
Component.onCompleted: { |
||||||
context.moveTo(innerPos[0][0], innerPos[0][1]); |
for (let i = 0; i < 128; i++) { |
||||||
for(let i=0; i<total; i++) { |
audioData[i] = 0; |
||||||
context.lineTo(innerPos[i][0], innerPos[i][1]); |
} |
||||||
} |
} |
||||||
context.closePath(); |
} |
||||||
context.stroke(); |
|
||||||
|
|
||||||
context.beginPath(); |
defaultValues: { |
||||||
for(let i=0; i<total; i++) { |
"Version": "1.0.0", |
||||||
context.moveTo(outerPos[i][0], outerPos[i][1]); |
"Main Color": "#ff4500", |
||||||
context.lineTo(innerPos[i][0], innerPos[i][1]); |
"Line Position": 0, |
||||||
|
"Line Width": 1, |
||||||
|
"Max Range": 50, |
||||||
|
"Data Length": 0, |
||||||
|
"Channel": 2, |
||||||
|
"Reverse": false, |
||||||
|
"Rotate": false, |
||||||
|
"Ratate Speed": 10, |
||||||
|
"Angle": 0, |
||||||
|
"Data Settings": { |
||||||
|
"Auto Normalizing": true, |
||||||
|
"Amplitude": 10, |
||||||
|
"Unit Style": 0 |
||||||
} |
} |
||||||
context.stroke(); |
|
||||||
requestPaint(); |
|
||||||
} |
} |
||||||
|
|
||||||
Component.onCompleted: { |
preference: AdvpPreference { |
||||||
for (let i = 0; i < 128; i++) { |
version: defaultValues["Version"] |
||||||
audioData[i] = 0; |
cfg_height: 740 |
||||||
|
|
||||||
|
P.ColorPreference { |
||||||
|
name: "Main Color" |
||||||
|
label: qsTr("Spectrum Line Color") |
||||||
|
defaultValue: defaultValues["Main Color"] |
||||||
|
} |
||||||
|
|
||||||
|
P.SelectPreference { |
||||||
|
name: "Line Position" |
||||||
|
label: qsTr("Spectrum Line Position") |
||||||
|
defaultValue: defaultValues["Line Position"] |
||||||
|
model: [qsTr("Both"), qsTr("Outside"), qsTr("Inside")] |
||||||
|
} |
||||||
|
|
||||||
|
P.SliderPreference { |
||||||
|
name: "Line Width" |
||||||
|
label: qsTr("Spectrum Line Width") |
||||||
|
from: 0.1 |
||||||
|
to: 10 |
||||||
|
stepSize: 0.1 |
||||||
|
defaultValue: defaultValues["Line Width"] |
||||||
|
displayValue: value.toFixed(1) + "px" |
||||||
|
} |
||||||
|
|
||||||
|
P.SliderPreference { |
||||||
|
name: "Max Range" |
||||||
|
label: qsTr("Max Amplitude") |
||||||
|
from: 0 |
||||||
|
to: 100 |
||||||
|
stepSize: 1 |
||||||
|
defaultValue: defaultValues["Max Range"] |
||||||
|
displayValue: value + "%" |
||||||
|
} |
||||||
|
|
||||||
|
P.SelectPreference { |
||||||
|
name: "Data Length" |
||||||
|
label: qsTr("Spectrum Length") |
||||||
|
defaultValue: defaultValues["Data Length"] |
||||||
|
model: [64, 32, 16, 8] |
||||||
|
} |
||||||
|
|
||||||
|
P.Separator {} |
||||||
|
|
||||||
|
P.SpinPreference { |
||||||
|
name: "Channel" |
||||||
|
label: qsTr("Channel") |
||||||
|
message: "1 to 2" |
||||||
|
display: P.TextFieldPreference.ExpandLabel |
||||||
|
editable: false |
||||||
|
from: 1 |
||||||
|
to: 2 |
||||||
|
defaultValue: defaultValues["Channel"] |
||||||
|
} |
||||||
|
|
||||||
|
P.Separator {} |
||||||
|
|
||||||
|
P.SwitchPreference { |
||||||
|
name: "Reverse" |
||||||
|
label: qsTr("Reverse Spectrum") |
||||||
|
defaultValue: defaultValues["Reverse"] |
||||||
|
} |
||||||
|
|
||||||
|
P.Separator {} |
||||||
|
|
||||||
|
P.SwitchPreference { |
||||||
|
id: _cfg_preset_line_rotate |
||||||
|
name: "Rotate" |
||||||
|
label: qsTr("Auto Rotate") |
||||||
|
defaultValue: defaultValues["Rotate"] |
||||||
|
} |
||||||
|
|
||||||
|
P.SliderPreference { |
||||||
|
name: "Ratate Speed" |
||||||
|
label: qsTr("Ratate Speed") |
||||||
|
enabled: _cfg_preset_line_rotate.value |
||||||
|
from: 1 |
||||||
|
to: 100 |
||||||
|
stepSize: 1 |
||||||
|
defaultValue: defaultValues["Ratate Speed"] |
||||||
|
displayValue: value + "%" |
||||||
|
} |
||||||
|
|
||||||
|
P.SpinPreference { |
||||||
|
name: "Angle" |
||||||
|
label: qsTr("Initial Angle") |
||||||
|
message: "0 to 359" |
||||||
|
enabled: !_cfg_preset_line_rotate.value |
||||||
|
display: P.TextFieldPreference.ExpandLabel |
||||||
|
editable: true |
||||||
|
from: 0 |
||||||
|
to: 359 |
||||||
|
defaultValue: defaultValues["Angle"] |
||||||
|
} |
||||||
|
|
||||||
|
P.Separator {} |
||||||
|
|
||||||
|
P.DialogPreference { |
||||||
|
name: "Data Settings" |
||||||
|
label: qsTr("Data Settings") |
||||||
|
live: true |
||||||
|
icon.name: "regular:\uf1de" |
||||||
|
|
||||||
|
P.SwitchPreference { |
||||||
|
id: _cfg_preset_circle_dataSettings_autoNormalizing |
||||||
|
name: "Auto Normalizing" |
||||||
|
label: qsTr("Auto Normalizing") |
||||||
|
defaultValue: defaultValues["Data Settings"]["Auto Normalizing"] |
||||||
|
} |
||||||
|
|
||||||
|
P.SpinPreference { |
||||||
|
name: "Amplitude" |
||||||
|
label: qsTr("Amplitude Ratio") |
||||||
|
enabled: !_cfg_preset_circle_dataSettings_autoNormalizing.value |
||||||
|
message: "1 to 100" |
||||||
|
display: P.TextFieldPreference.ExpandLabel |
||||||
|
editable: true |
||||||
|
from: 1 |
||||||
|
to: 100 |
||||||
|
defaultValue: defaultValues["Data Settings"]["Amplitude"] |
||||||
|
} |
||||||
|
|
||||||
|
P.Separator {} |
||||||
|
|
||||||
|
P.SelectPreference { |
||||||
|
name: "Unit Style" |
||||||
|
label: qsTr("Display Style") |
||||||
|
defaultValue: defaultValues["Data Settings"]["Unit Style"] |
||||||
|
model: [qsTr("Linear"), qsTr("Decibel")] |
||||||
|
} |
||||||
} |
} |
||||||
} |
} |
||||||
} |
} |
||||||
|
@ -1,53 +0,0 @@ |
|||||||
import QtQuick 2.12 |
|
||||||
import NERvGear.Preferences 1.0 as P |
|
||||||
|
|
||||||
import "../../qml/api" //导入CfgAPI.qml |
|
||||||
|
|
||||||
CfgAPI { |
|
||||||
version: "1.0.0" |
|
||||||
cfg_height: 580 |
|
||||||
|
|
||||||
P.SliderPreference { |
|
||||||
name: "Line Width" |
|
||||||
label: qsTr("Spectrum Line Width") |
|
||||||
from: 0.1 |
|
||||||
to: 4 |
|
||||||
stepSize: 0.1 |
|
||||||
defaultValue: 1 |
|
||||||
displayValue: value.toFixed(1) + "px" |
|
||||||
} |
|
||||||
|
|
||||||
P.ColorPreference { |
|
||||||
name: "Line Color" |
|
||||||
label: qsTr("Spectrum Line Color") |
|
||||||
defaultValue: "#FF4500" |
|
||||||
} |
|
||||||
|
|
||||||
P.Separator {} |
|
||||||
|
|
||||||
P.DialogPreference { |
|
||||||
name: "Data Settings" |
|
||||||
label: qsTr("Data Settings") |
|
||||||
live: true |
|
||||||
icon.name: "regular:\uf1de" |
|
||||||
|
|
||||||
P.SwitchPreference { |
|
||||||
id: _cfg_preset_line_dataSettings_autoNormalizing |
|
||||||
name: "Auto Normalizing" |
|
||||||
label: qsTr("Auto Normalizing") |
|
||||||
defaultValue: true |
|
||||||
} |
|
||||||
|
|
||||||
P.SpinPreference { |
|
||||||
name: "Amplitude" |
|
||||||
label: qsTr("Amplitude Ratio") |
|
||||||
enabled: !_cfg_preset_line_dataSettings_autoNormalizing.value |
|
||||||
message: "1 to 100" |
|
||||||
display: P.TextFieldPreference.ExpandLabel |
|
||||||
editable: true |
|
||||||
from: 1 |
|
||||||
to: 100 |
|
||||||
defaultValue: 10 |
|
||||||
} |
|
||||||
} |
|
||||||
} |
|
@ -1,62 +1,199 @@ |
|||||||
import QtQuick 2.12 |
import QtQuick 2.12 |
||||||
import QtQuick.Controls 2.12 |
import NERvGear.Preferences 1.0 as P |
||||||
|
|
||||||
import "../../qml/api" |
import "../../qml/api" |
||||||
|
|
||||||
StyleAPI { |
AdvpStyleTemplate { |
||||||
readonly property var audioData: new Array(128) |
style: AdvpCanvasTemplate { |
||||||
|
readonly property var audioData: new Array(128) |
||||||
|
|
||||||
readonly property real lineWidth: configs["Line Width"] |
readonly property bool autoNormalizing: configs["Data Settings"]["Auto Normalizing"] |
||||||
readonly property string line_color: configs["Line Color"] |
readonly property real amplitude: configs["Data Settings"]["Amplitude"] / 400.0 |
||||||
readonly property bool autoNormalizing: configs["Data Settings"]["Auto Normalizing"] |
|
||||||
readonly property real amplitude: configs["Data Settings"]["Amplitude"] / 400.0 |
|
||||||
|
|
||||||
readonly property real ux: width/129 |
readonly property int uDataLen: Math.pow(2, configs["Data Length"]); |
||||||
readonly property real halfHeight: height/2 |
readonly property int dataLength: 64/uDataLen |
||||||
|
readonly property int unitStyle: configs["Data Settings"]["Unit Style"] |
||||||
|
|
||||||
onConfigsUpdated: { |
readonly property int total: dataLength*2 |
||||||
context.lineWidth = lineWidth; |
|
||||||
context.strokeStyle = line_color; |
|
||||||
} |
|
||||||
|
|
||||||
onAudioDataUpdeted: { |
readonly property real ux: width/(total+1) |
||||||
data[128] *= 2; |
readonly property real halfHeight: height/2 |
||||||
if(autoNormalizing) { |
|
||||||
//线性化显示 |
onConfigsUpdated: { |
||||||
for(let i=0; i<64; i++) { |
//尽量不要使用绑定configs的属性以免造成竞争,若一定要使用推荐使用Qt.callLater(()=>{}) |
||||||
audioData[i] = data[64-i-1] / data[128]; |
context.lineWidth = configs["Line Width"]; |
||||||
} |
context.strokeStyle = configs["Line Color"]; |
||||||
for(let i=64; i<128; i++) { |
} |
||||||
audioData[i] = data[i] / data[128]; |
|
||||||
|
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; |
||||||
|
} |
||||||
|
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]); |
||||||
|
} |
||||||
|
} |
||||||
|
} 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=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); |
||||||
|
} |
||||||
|
} |
||||||
} |
} |
||||||
} else { |
|
||||||
//线性化显示 |
context.clearRect(0, 0, width+32, height+32); |
||||||
for(let i=0; i<64; i++) { |
|
||||||
audioData[i] = data[64-i-1] * amplitude; |
context.beginPath(); |
||||||
|
context.moveTo(0, halfHeight); |
||||||
|
|
||||||
|
for (let i=0; i<dataLength*2; i+=2) { |
||||||
|
context.lineTo(ux*i, halfHeight*(1+audioData[i])); |
||||||
|
context.lineTo(ux*(i+1), halfHeight*(1-audioData[i+1])); |
||||||
} |
} |
||||||
for(let i=64; i<128; i++) { |
|
||||||
audioData[i] = data[i] * amplitude; |
context.lineTo(width, halfHeight); |
||||||
|
context.stroke(); |
||||||
|
|
||||||
|
requestPaint(); |
||||||
|
} |
||||||
|
|
||||||
|
Component.onCompleted: { |
||||||
|
for (let i = 0; i < 128; i++) { |
||||||
|
audioData[i] = 0; |
||||||
} |
} |
||||||
} |
} |
||||||
|
} |
||||||
|
|
||||||
|
defaultValues: { |
||||||
|
"Version": "1.1.0", |
||||||
|
"Line Width": 1, |
||||||
|
"Line Color": "#ff4500", |
||||||
|
"Data Length": 0, |
||||||
|
"Data Settings": { |
||||||
|
"Auto Normalizing": true, |
||||||
|
"Amplitude": 10, |
||||||
|
"Unit Style": 0 |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
context.clearRect(0, 0, width+32, height+32); |
preference: AdvpPreference { |
||||||
|
version: defaultValues["Version"] |
||||||
|
cfg_height: 400 |
||||||
|
|
||||||
context.beginPath(); |
P.SliderPreference { |
||||||
context.moveTo(0, halfHeight); |
name: "Line Width" |
||||||
for(let i=0; i<128; i+=2) { |
label: qsTr("Spectrum Line Width") |
||||||
context.lineTo(ux*i, halfHeight*(1+audioData[i])); |
from: 0.1 |
||||||
context.lineTo(ux*(i+1), halfHeight*(1-audioData[i+1])); |
to: 4 |
||||||
|
stepSize: 0.1 |
||||||
|
defaultValue: defaultValues["Line Width"] |
||||||
|
displayValue: value.toFixed(1) + "px" |
||||||
} |
} |
||||||
context.lineTo(width, halfHeight); |
|
||||||
// context.closePath(); |
|
||||||
context.stroke(); |
|
||||||
|
|
||||||
requestPaint(); |
P.ColorPreference { |
||||||
} |
name: "Line Color" |
||||||
|
label: qsTr("Spectrum Line Color") |
||||||
|
defaultValue: defaultValues["Line Color"] |
||||||
|
} |
||||||
|
|
||||||
|
P.Separator {} |
||||||
|
|
||||||
|
P.SelectPreference { |
||||||
|
name: "Data Length" |
||||||
|
label: qsTr("Spectrum Length") |
||||||
|
defaultValue: defaultValues["Data Length"] |
||||||
|
model: [64, 32, 16, 8] |
||||||
|
} |
||||||
|
|
||||||
Component.onCompleted: { |
P.DialogPreference { |
||||||
for (let i = 0; i < 128; i++) { |
name: "Data Settings" |
||||||
audioData[i] = 0; |
label: qsTr("Data Settings") |
||||||
|
live: true |
||||||
|
icon.name: "regular:\uf1de" |
||||||
|
|
||||||
|
P.SwitchPreference { |
||||||
|
id: _cfg_preset_line_dataSettings_autoNormalizing |
||||||
|
name: "Auto Normalizing" |
||||||
|
label: qsTr("Auto Normalizing") |
||||||
|
defaultValue: defaultValues["Data Settings"]["Auto Normalizing"] |
||||||
|
} |
||||||
|
|
||||||
|
P.SpinPreference { |
||||||
|
name: "Amplitude" |
||||||
|
label: qsTr("Amplitude Ratio") |
||||||
|
enabled: !_cfg_preset_line_dataSettings_autoNormalizing.value |
||||||
|
message: "1 to 100" |
||||||
|
display: P.TextFieldPreference.ExpandLabel |
||||||
|
editable: true |
||||||
|
from: 1 |
||||||
|
to: 100 |
||||||
|
defaultValue: defaultValues["Data Settings"]["Amplitude"] |
||||||
|
} |
||||||
|
|
||||||
|
P.Separator {} |
||||||
|
|
||||||
|
P.SelectPreference { |
||||||
|
name: "Unit Style" |
||||||
|
label: qsTr("Display Style") |
||||||
|
defaultValue: defaultValues["Data Settings"]["Unit Style"] |
||||||
|
model: [qsTr("Linear"), qsTr("Decibel")] |
||||||
|
} |
||||||
} |
} |
||||||
} |
} |
||||||
} |
} |
||||||
|
Loading…
Reference in new issue