diff --git a/Locales/ja_JP.qm b/Locales/ja_JP.qm
index eb79157..204b7ce 100644
Binary files a/Locales/ja_JP.qm and b/Locales/ja_JP.qm differ
diff --git a/Locales/zh.qm b/Locales/zh.qm
index 520e1e4..70de469 100644
Binary files a/Locales/zh.qm and b/Locales/zh.qm differ
diff --git a/Locales/zh_CN.qm b/Locales/zh_CN.qm
index d3bd6a0..ef3937b 100644
Binary files a/Locales/zh_CN.qm and b/Locales/zh_CN.qm differ
diff --git a/Presets/Circle/settings.xml b/Presets/Circle/settings.xml
index 0b4c8c8..69253ab 100644
--- a/Presets/Circle/settings.xml
+++ b/Presets/Circle/settings.xml
@@ -1,6 +1,5 @@
\ No newline at end of file
diff --git a/Presets/Gradient_Line/settings.xml b/Presets/Gradient_Line/settings.xml
index f1d0abf..f60ec93 100644
--- a/Presets/Gradient_Line/settings.xml
+++ b/Presets/Gradient_Line/settings.xml
@@ -1,6 +1,5 @@
\ No newline at end of file
diff --git a/Presets/Line/settings.xml b/Presets/Line/settings.xml
index 5c834dc..1a4a28b 100644
--- a/Presets/Line/settings.xml
+++ b/Presets/Line/settings.xml
@@ -1,6 +1,5 @@
\ No newline at end of file
diff --git a/Presets/Ordinal_Scale_UI_bottom/settings.xml b/Presets/Ordinal_Scale_UI_bottom/settings.xml
index 16b6829..d30c10c 100644
--- a/Presets/Ordinal_Scale_UI_bottom/settings.xml
+++ b/Presets/Ordinal_Scale_UI_bottom/settings.xml
@@ -1,6 +1,5 @@
\ No newline at end of file
diff --git a/Presets/Solidcircle/settings.xml b/Presets/Solidcircle/settings.xml
index 3e29fc3..eb8e7b6 100644
--- a/Presets/Solidcircle/settings.xml
+++ b/Presets/Solidcircle/settings.xml
@@ -1,6 +1,5 @@
\ No newline at end of file
diff --git a/Presets/Waves/settings.xml b/Presets/Waves/settings.xml
index bd4c1fa..c2bc705 100644
--- a/Presets/Waves/settings.xml
+++ b/Presets/Waves/settings.xml
@@ -1,6 +1,5 @@
\ No newline at end of file
diff --git a/package.json b/package.json
index 7266ef3..d2f13f9 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
{
"name": "top.mashiros.widget.advp",
- "version": "1.1.0",
+ "version": "1.2.0",
"title": {
"en": "ADV Plugin",
@@ -59,7 +59,7 @@
"zh_TW": "預置 線",
"ja": "プリセット 線"
},
- "entry": "./styles/Preset_line"
+ "entry": "./styles/Preset_line/Style.qml"
},
{
"location": "/advp-style-preset/gradient_line",
@@ -70,7 +70,7 @@
"zh_TW": "預置 漸變線",
"ja": "プリセット グラデーションライン"
},
- "entry": "./styles/Preset_gradient_line"
+ "entry": "./styles/Preset_gradient_line/Style.qml"
},
{
"location": "/advp-style-preset/waves",
@@ -81,7 +81,7 @@
"zh_TW": "預置 波浪",
"ja": "プリセット 波浪"
},
- "entry": "./styles/Preset_waves"
+ "entry": "./styles/Preset_waves/Style.qml"
},
{
"location": "/advp-style-preset/circle",
@@ -92,7 +92,7 @@
"zh_TW": "預置 圓",
"ja": "プリセット 円"
},
- "entry": "./styles/Preset_circle"
+ "entry": "./styles/Preset_circle/Style.qml"
},
{
"location": "/advp-style-preset/solidcircle",
@@ -103,7 +103,7 @@
"zh_TW": "預置 實心圓",
"ja": "プリセット 固形円"
},
- "entry": "./styles/Preset_solidcircle"
+ "entry": "./styles/Preset_solidcircle/Style.qml"
},
{
"location": "/advp-style-preset/ordinal_scale_ui_bottom",
@@ -114,10 +114,10 @@
"zh_TW": "預置 序列之爭底部UI",
"ja": "プリセット オーディナル・スケール- UI 下部"
},
- "entry": "./styles/Preset_Ordinal_Scale_UI_bottom"
+ "entry": "./styles/Preset_Ordinal_Scale_UI_bottom/Style.qml"
},
{
- "location": "/preset/advp-style-preset_line",
+ "location": "/preset/advp-style-preset/line",
"catalog": "preset/widget",
"title": {
"en": "ADV Preset Line",
@@ -129,7 +129,7 @@
"entry": "Presets/Line/preset.json"
},
{
- "location": "/preset/advp-style-preset_gradient_line",
+ "location": "/preset/advp-style-preset/gradient_line",
"catalog": "preset/widget",
"title": {
"en": "ADV Preset Gradient Line",
@@ -141,7 +141,7 @@
"entry": "Presets/Gradient_Line/preset.json"
},
{
- "location": "/preset/advp-style-preset_waves",
+ "location": "/preset/advp-style-preset/waves",
"catalog": "preset/widget",
"title": {
"en": "ADV Preset Waves",
@@ -153,7 +153,7 @@
"entry": "Presets/Waves/preset.json"
},
{
- "location": "/preset/advp-style-preset_circle",
+ "location": "/preset/advp-style-preset/circle",
"catalog": "preset/widget",
"title": {
"en": "ADV Preset Circle",
@@ -165,7 +165,7 @@
"entry": "Presets/Circle/preset.json"
},
{
- "location": "/preset/advp-style-preset_solidcircle",
+ "location": "/preset/advp-style-preset/solidcircle",
"catalog": "preset/widget",
"title": {
"en": "ADV Preset Solid-circle",
@@ -177,7 +177,7 @@
"entry": "Presets/Solidcircle/preset.json"
},
{
- "location": "/preset/advp-style-preset_ordinal_scale_ui_bottom",
+ "location": "/preset/advp-style-preset/ordinal_scale_ui_bottom",
"catalog": "preset/widget",
"title": {
"en": "ADV Preset Ordinal Scale UI bottom",
diff --git a/qml/Common.qml b/qml/Common.qml
index ca18ea4..9d581a0 100644
--- a/qml/Common.qml
+++ b/qml/Common.qml
@@ -9,7 +9,6 @@ import NERvGear 1.0 as NVG
Item {
readonly property var styles: []
readonly property var stylesURL: []
- readonly property var stylesCFG: []
property int widgetsNum: 0
@@ -103,20 +102,9 @@ Item {
return 0;
});
resource_list.forEach(function (resource) {
- let name = resource.title;
- let styleURL = "";
- let styleCFG = "";
- resource.files().forEach(function (file) {
- if (file.entry === "Style.qml") {
- styleURL = String(file.url);
- } else if (file.entry === "Config.qml") {
- styleCFG = String(file.url);
- }
- });
- if (styleURL && stylesURL.indexOf(styleURL) === -1) {
- styles.push(name);
- stylesURL.push(styleURL);
- stylesCFG.push(styleCFG);
+ if (resource.url && stylesURL.indexOf(resource.url.toString()) === -1) {
+ styles.push(resource.title);
+ stylesURL.push(resource.url.toString());
}
});
}
@@ -124,7 +112,6 @@ Item {
function updateStyleList() {
styles.length = 0;
stylesURL.length = 0;
- stylesCFG.length = 0;
const preset_list = NVG.Resources.filter(/advp.widget.mashiros.top/, /top.mashiros.advp-style/);
parse_resource(preset_list, true);
const third_list = NVG.Resources.filter(/.*/, /top.mashiros.advp-style/);
diff --git a/qml/Main.qml b/qml/Main.qml
index f757f6c..f774523 100644
--- a/qml/Main.qml
+++ b/qml/Main.qml
@@ -15,27 +15,34 @@ T.Widget {
editing: styleDialog.active
- property bool initial: true
-
- function setStyleURL(url) {
- styleLoader.source = url;
- }
+ property Component style
+ property Component preference
+ property var defaultValues
Loader {
id: styleDialog
active: false
- visible: false
sourceComponent: StylePreferences {
transientParent: widget.NVG.View.window
}
+ }
+
+ Loader {
+ id: styleObjectLoader
+ active: widget.NVG.View.exposed
+ enabled: true
+ source: Qt.resolvedUrl(widget.settings.current_style)
onLoaded: {
- if(initial) {
- styleDialog.active = false;
- styleDialog.visible = true;
- initial = false;
- } else {
- item.visible = true;
+ preference = item.preference;
+ defaultValues = item.defaultValues;
+ style = item.style;
+ if (!widget.settings[widget.settings.current_style]) {
+ widget.settings[widget.settings.current_style] = defaultValues;
+ }else if(widget.settings[widget.settings.current_style]["Version"] !== defaultValues["Version"]) {
+ delete widget.settings[widget.settings.current_style]["__cfg_height"];
+ delete widget.settings[widget.settings.current_style]["Version"];
+ widget.settings[widget.settings.current_style] = Object.assign(defaultValues, widget.settings[widget.settings.current_style]);
}
}
}
@@ -44,7 +51,7 @@ T.Widget {
id: styleLoader
active: widget.NVG.View.exposed
enabled: true
- source: ""
+ sourceComponent: style
}
menu: Menu {
@@ -53,14 +60,16 @@ T.Widget {
enabled: !styleDialog.active
onTriggered: {
Common.updateStyleList();
- styleDialog.active = true
+ styleDialog.active = true;
}
}
}
Component.onCompleted: {
- styleDialog.active = true;
Common.widgetsNum++;
+ if ((!widget.settings.current_style) || (Common.stylesURL.indexOf(widget.settings.current_style) === -1)) {
+ widget.settings.current_style = Common.stylesURL[0];
+ }
}
Component.onDestruction: {
diff --git a/qml/StylePreferences.qml b/qml/StylePreferences.qml
index 411cdb2..38a8484 100644
--- a/qml/StylePreferences.qml
+++ b/qml/StylePreferences.qml
@@ -12,7 +12,7 @@ import "."
NVG.Window {
id: window
title: qsTr("ADV-Plugin: Settings")
- visible: false
+ visible: true
minimumWidth: 480
minimumHeight: 580
width: minimumWidth
@@ -25,8 +25,8 @@ NVG.Window {
}
}
- property var configuration
property var old_style_cfg
+ property int last_style_index
Page {
id: cfg_page
@@ -38,22 +38,15 @@ NVG.Window {
standardButtons: Dialog.Save | Dialog.Reset
onAccepted: {
- configuration = rootPreference.save();
- let index = configuration["index"];
- widget.settings[Common.stylesURL[index]] = configuration[Common.stylesURL[index]];
- delete configuration[Common.stylesURL[index]];
- widget.settings.styles = configuration;
- widget.settings.current_style = Common.stylesURL[index];
+ let cfg = rootPreference.save();
+ widget.settings[widget.settings.current_style] = cfg[widget.settings.current_style];
styleDialog.active = false;
}
onReset: {
- styleLoader.load();
+ stylePreferenceLoader.load();
let cfg = rootPreference.save();
- let index = cfg["index"];
- widget.settings[Common.stylesURL[index]] = cfg[Common.stylesURL[index]];
- widget.setStyleURL("");
- widget.setStyleURL(Qt.resolvedUrl(Common.stylesURL[widget.settings.styles["index"]]));
+ widget.settings[widget.settings.current_style] = cfg[widget.settings.current_style];
}
}
@@ -82,18 +75,13 @@ NVG.Window {
label: qsTr("Configuration")
onPreferenceEdited: {
- let cfg = rootPreference.save();
- let index = cfg["index"];
- if (widget.settings.styles["index"] !== index) {
- widget.setStyleURL("");
- widget.settings[Common.stylesURL[widget.settings.styles["index"]]] = old_style_cfg;
- old_style_cfg = widget.settings[Common.stylesURL[index]];
+ if (widget.settings.current_style !== Common.stylesURL[styleList.value]) {
+ widget.settings[widget.settings.current_style] = old_style_cfg;
+ old_style_cfg = widget.settings[Common.stylesURL[styleList.value]];
+ widget.settings.current_style = Common.stylesURL[styleList.value];
}
-
- widget.settings[Common.stylesURL[index]] = cfg[Common.stylesURL[index]];
- delete cfg[Common.stylesURL[index]];
- widget.settings.styles = cfg;
- widget.setStyleURL(Qt.resolvedUrl(Common.stylesURL[index]));
+ let cfg = rootPreference.save();
+ widget.settings[widget.settings.current_style] = cfg[widget.settings.current_style];
}
P.SelectPreference {
@@ -108,24 +96,21 @@ NVG.Window {
P.Separator {}
P.PreferenceLoader {
- id: styleLoader
- name: Common.stylesURL[styleList.value]
- source: Qt.resolvedUrl(Common.stylesCFG[styleList.value])
+ id: stylePreferenceLoader
+ name: widget.settings.current_style
+ sourceComponent: preference
onLoaded: {
let cfg = save();
- if (!widget.settings[Common.stylesURL[styleList.value]]) {
- widget.settings[Common.stylesURL[styleList.value]] = cfg;
- } else if(widget.settings[Common.stylesURL[styleList.value]]["__version"] === cfg["__version"]) {
- load(widget.settings[Common.stylesURL[styleList.value]]);
- } else {
- widget.settings[Common.stylesURL[styleList.value]] = cfg;
- }
+ load(widget.settings[widget.settings.current_style]);
window.minimumHeight = cfg["__cfg_height"];
}
onContentItemChanged: {
if(contentItem) {
- contentItem.label = Common.styles[styleList.value];
+ let index = Common.stylesURL.indexOf(widget.settings.current_style);
+ if (index === -1)
+ index = 0;
+ contentItem.label = Common.styles[index];
}
}
}
@@ -133,30 +118,14 @@ NVG.Window {
P.Separator {}
Component.onCompleted: {
- if(!widget.settings.styles) {
- configuration = rootPreference.save();
- let index = configuration["index"];
- widget.settings[Common.stylesURL[index]] = configuration[Common.stylesURL[index]];
- old_style_cfg = configuration[Common.stylesURL[index]];
- delete configuration[Common.stylesURL[index]];
- widget.settings.current_style = Common.stylesURL[index];
- widget.settings.styles = configuration;
+ last_style_index = Common.stylesURL.indexOf(widget.settings.current_style);
+ if (last_style_index === -1) {
+ last_style_index = 0;
+ widget.settings.current_style = Common.stylesURL[0];
}
-
- let index = Common.stylesURL.indexOf(widget.settings.current_style);
- if (index === -1) {
- index = 0;
- widget.settings.current_style = Common.stylesURL[index];
- }
-
- widget.settings.styles["index"] = index;
- widget.setStyleURL(Qt.resolvedUrl(Common.stylesURL[widget.settings.styles["index"]]));
-
- rootPreference.load(widget.settings.styles);
- configuration = widget.settings.styles;
- old_style_cfg = widget.settings[Common.stylesURL[index]];
-
- styleLoader.load(widget.settings[Common.stylesURL[index]]);
+ rootPreference.load({"index": last_style_index});
+ old_style_cfg = widget.settings[widget.settings.current_style];
+ stylePreferenceLoader.load(widget.settings[widget.settings.current_style]);
}
}
}
@@ -165,10 +134,8 @@ NVG.Window {
}
onClosing: {
- widget.setStyleURL("");
- widget.settings[Common.stylesURL[widget.settings.styles["index"]]] = old_style_cfg;
- widget.settings.styles = configuration;
- widget.setStyleURL(Qt.resolvedUrl(Common.stylesURL[widget.settings.styles["index"]]));
+ widget.settings[widget.settings.current_style] = old_style_cfg;
+ widget.settings.current_style = Common.stylesURL[last_style_index]
styleDialog.active = false;
}
}
diff --git a/qml/api/StyleAPI.qml b/qml/api/AdvpCanvasTemplate.qml
similarity index 86%
rename from qml/api/StyleAPI.qml
rename to qml/api/AdvpCanvasTemplate.qml
index 1d8adbb..fc70e12 100644
--- a/qml/api/StyleAPI.qml
+++ b/qml/api/AdvpCanvasTemplate.qml
@@ -11,7 +11,7 @@ Canvas {
signal audioDataUpdeted(var data)
signal configsUpdated()
- property var configs: widget.settings[Common.stylesURL[widget.settings.styles["index"]]]
+ readonly property var configs: widget.settings[widget.settings.current_style] ?? defaultValues
onConfigsChanged: {
if (context) {
diff --git a/qml/api/CfgAPI.qml b/qml/api/AdvpPreference.qml
similarity index 93%
rename from qml/api/CfgAPI.qml
rename to qml/api/AdvpPreference.qml
index afdc0a0..0888f60 100644
--- a/qml/api/CfgAPI.qml
+++ b/qml/api/AdvpPreference.qml
@@ -9,7 +9,7 @@ P.DialogPreference {
property int cfg_height: 580
P.TextFieldPreference {
- name: "__version"
+ name: "Version"
visible: false
enabled: false
defaultValue: version
@@ -39,5 +39,5 @@ P.DialogPreference {
}
}
- P.Separator {}
+ P.Separator {visible: version}
}
diff --git a/qml/api/AdvpStyleTemplate.qml b/qml/api/AdvpStyleTemplate.qml
new file mode 100644
index 0000000..400df15
--- /dev/null
+++ b/qml/api/AdvpStyleTemplate.qml
@@ -0,0 +1,9 @@
+import QtQuick 2.12
+
+QtObject {
+ property Component style
+
+ property var defaultValues
+
+ property Component preference
+}
diff --git a/styles/Preset_Ordinal_Scale_UI_bottom/Config.qml b/styles/Preset_Ordinal_Scale_UI_bottom/Config.qml
deleted file mode 100644
index 358f2d2..0000000
--- a/styles/Preset_Ordinal_Scale_UI_bottom/Config.qml
+++ /dev/null
@@ -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
- }
- }
-}
diff --git a/styles/Preset_Ordinal_Scale_UI_bottom/Style.qml b/styles/Preset_Ordinal_Scale_UI_bottom/Style.qml
index 957e662..5ebb6b8 100644
--- a/styles/Preset_Ordinal_Scale_UI_bottom/Style.qml
+++ b/styles/Preset_Ordinal_Scale_UI_bottom/Style.qml
@@ -1,123 +1,248 @@
import QtQuick 2.12
-import QtQuick.Controls 2.12
+import NERvGear.Preferences 1.0 as P
import "../../qml/api"
-StyleAPI {
- readonly property var audioData: new Array(128)
+AdvpStyleTemplate {
+ style: AdvpCanvasTemplate {
+ readonly property var audioData: new Array(128)
+
+ //configs
+ readonly property real bassAmRatio: configs["Bass AM"]/100
+ readonly property real altoAmRatio: configs["Alto AM"]/100
+ readonly property real trebleAmRatio: configs["Treble AM"]/100
+ readonly property string bassColor: configs["Bass Color"]
+ readonly property string altoColor: configs["Alto Color"]
+ readonly property string trebleColor: configs["Treble Color"]
+ readonly property bool autoNormalizing: configs["Data Settings"]["Auto Normalizing"]
+ readonly property real amplitude: configs["Data Settings"]["Amplitude"] / 400
+
+ readonly property real halfWidth: width/2
+ readonly property real rHeight: 0.6*height
+
+ readonly property real this_speed: configs["Speed"]/100
+ readonly property real this_MAX: (height/2)-4
+ readonly property real this_noise: configs["Static AM"]/100*this_MAX
+ readonly property real this_delta: this_MAX-this_noise
+ property real this_phase: 0
+
+ readonly property var _globalAttenuationArray: [0.0017856573042805614, 0.002090029027424354, 0.0024428709787506155, 0.0028511620549328143, 0.003322734461672416, 0.0038663486688144872, 0.004491769417010894, 0.0052098416088514335, 0.0060325646905618185, 0.006973163895798498, 0.008046156486762173, 0.009267410897150058, 0.010654196465028541, 0.012225221251394174, 0.014000655282882916, 0.016002136446407085, 0.018252756211446522, 0.0207770223741957, 0.023600796118042038, 0.026751200876932862, 0.03025650078017051, 0.034145946854542274, 0.038449589664666724, 0.04319805768336597, 0.048422301394722714, 0.054153303932507744, 0.06042175993022312, 0.06725772518564865, 0.07469024069755677, 0.08274693558633812, 0.09145361433175414, 0.10083383461611592, 0.11090848281544048, 0.12169535480100475, 0.13320875016810133, 0.14545908827055729, 0.15845255448710202, 0.1721907849641367, 0.18667059766189825, 0.20188377687903944, 0.21781691755482288, 0.23445133456773634, 0.2517630409920839, 0.26972279787490494, 0.28829623659542597, 0.3074440533134911, 0.32712227344992756, 0.3472825826188692, 0.36787271899666724, 0.38883692080749416, 0.4101164214705023, 0.43164998401902316, 0.4533744656929005, 0.4752254031360044, 0.4971376084092084, 0.5190457660525851, 0.5408850216893105, 0.562591553140178, 0.5841031156880014, 0.6053595539666616, 0.6263032739177719, 0.6468796693242911, 0.6670374985596821, 0.6867292083486696, 0.7059112024886071, 0.7245440545987721, 0.7425926650223671, 0.760026362980347, 0.7768189559498792, 0.7929487290003452, 0.8083983974579334, 0.8231550167821777, 0.8372098539242965, 0.8505582247014246, 0.8631993018695427, 0.875135898619801, 0.8863742321691508, 0.8969236719785354, 0.9067964769231723, 0.9160075254728139, 0.9245740426279158, 0.9325153270127456, 0.9398524811601155, 0.9466081476449091, 0.9528062533442774, 0.9584717637292349, 0.9636304487320935, 0.9683086613922199, 0.9725331301632185, 0.9763307654708479, 0.9797284808449854, 0.9827530287117202, 0.9854308507237252, 0.9877879423279077, 0.9898497311182406, 0.9916409683972773, 0.9931856332704053, 0.9945068485207086, 0.9956268074571305, 0.9965667108926166, 0.9973467133897048, 0.997985877906754, 0.9985021379865716, 0.9989122666488067, 0.9992318511763106, 0.9994752730222837, 0.9996556921079202, 0.9997850348281199, 0.9998739851348633, 0.999931978122665, 0.9999671955978632, 0.999986563172305, 0.9999957484820413, 0.9999991601923922, 0.9999999475120023, 1.0, 0.9999999475120023, 0.9999991601923922, 0.9999957484820413, 0.999986563172305, 0.9999671955978632, 0.999931978122665, 0.9998739851348633, 0.9997850348281199, 0.9996556921079202, 0.9994752730222837, 0.9992318511763106, 0.9989122666488067, 0.9985021379865716, 0.997985877906754, 0.9973467133897048, 0.9965667108926166, 0.9956268074571305, 0.9945068485207086, 0.9931856332704053, 0.9916409683972773, 0.9898497311182406, 0.9877879423279077, 0.9854308507237252, 0.9827530287117202, 0.9797284808449854, 0.9763307654708498, 0.9725331301632185, 0.9683086613922199, 0.9636304487320935, 0.9584717637292349, 0.9528062533442774, 0.9466081476449091, 0.9398524811601155, 0.9325153270127456, 0.9245740426279158, 0.9160075254728139, 0.9067964769231723, 0.8969236719785354, 0.8863742321691508, 0.875135898619801, 0.8631993018695436, 0.8505582247014246, 0.8372098539242965, 0.8231550167821794, 0.8083983974579334, 0.7929487290003452, 0.7768189559498792, 0.760026362980347, 0.7425926650223671, 0.7245440545987721, 0.7059112024886071, 0.6867292083486696, 0.6670374985596821, 0.6468796693242911, 0.6263032739177719, 0.6053595539666616, 0.5841031156880014, 0.562591553140178, 0.5408850216893111, 0.5190457660525862, 0.49713760840920945, 0.4752254031360049, 0.4533744656929005, 0.43164998401902366, 0.4101164214705023, 0.3888369208074946, 0.36787271899666724, 0.34728258261887, 0.3271222734499283, 0.30744405331349145, 0.28829623659542597, 0.26972279787490555, 0.2517630409920839, 0.2344513345677366, 0.21781691755482313, 0.2018837768790397, 0.18667059766189847, 0.17219078496413692, 0.15845255448710202, 0.14545908827055729, 0.13320875016810133, 0.12169535480100475, 0.11090848281544048, 0.10083383461611592, 0.09145361433175414, 0.08274693558633812, 0.07469024069755677, 0.06725772518564865, 0.060421759930223286, 0.054153303932507744, 0.048422301394722776, 0.0431980576833661, 0.038449589664666724, 0.034145946854542274, 0.0302565007801706, 0.026751200876932904, 0.023600796118042038, 0.020777022374195733, 0.018252756211446522, 0.016002136446407085, 0.014000655282882938, 0.012225221251394195, 0.010654196465028541, 0.009267410897150073, 0.008046156486762187, 0.00697316389579851, 0.006032564690561829, 0.0052098416088514335, 0.004491769417010894, 0.0038663486688144872, 0.003322734461672416, 0.0028511620549328143, 0.0024428709787506155, 0.002090029027424354, 0.0017856573042805614, 0.0015235572708080104, 0.001298240554271166, 0.001104862087804041, 0.0009391569963475799, 0.000797381501252183, 0.0006762579957286263, 0.0005729243418569506, 0.00048488735639869217, 0.0004099803857607644, 0.00034632481850304286, 0.00029229534504994666, 0.0002464887470267302, 0.00020769598120373757, 0.00017487731379413836, 0.0001471402583278278, 0.0001237200731699464, 0.00010396258176888504, 8.730908885950263e-05, 7.328317821506653e-05];
+
+ function drawLine(ns, color, lwidth, _phase, main) {
+ context.strokeStyle = color;
+ context.lineWidth = lwidth || 1;
+
+ let x, y;
+ if (main) {
+ context.beginPath();
+ context.moveTo(0, height*0.6);
+ for (let i=0; i<=0.54; i+=0.06) {
+ x = halfWidth*i;
+ y = rHeight;
+ context.transform(1, (i-2)*0.0454, 0, 1, 0, 0);
+ context.lineTo(x, y);
+ context.resetTransform();
+ }
+ context.stroke();
+ }
- //configs
- readonly property real bassAmRatio: configs["Bass AM"]/100
- readonly property real altoAmRatio: configs["Alto AM"]/100
- readonly property real trebleAmRatio: configs["Treble AM"]/100
- readonly property string bassColor: configs["Bass Color"]
- readonly property string altoColor: configs["Alto Color"]
- readonly property string trebleColor: configs["Treble Color"]
- readonly property bool autoNormalizing: configs["Data Settings"]["Auto Normalizing"]
- readonly property real amplitude: configs["Data Settings"]["Amplitude"] / 400
+ context.beginPath();
+ context.transform(1, -0.066284, 0, 1, 0, 0);
+ context.moveTo(width*0.27, rHeight);
+ context.resetTransform();
+ for (let i=0; i<=249; i+=1) {
+ x = halfWidth*(0.54+i/250);
+ // y = rHeight + (this.noise + ns) * _globalAttenuationArray[i] * Math.sin((-24.84+i*4.5*12/n)-phase);
+ y = rHeight + (this_noise + ns) * _globalAttenuationArray[i] * Math.sin((-24.84+i*0.216)-_phase);
+ // ctx.transform(1, -0.066284+i*0.0454/n, 0, 1, 0, 0);
+ context.transform(1, -0.066284+i*0.0001816, 0, 1, 0, 0);
+ context.lineTo(x, y);
+ context.resetTransform();
+ }
- readonly property real halfWidth: width/2
- readonly property real rHeight: 0.6*height
+ if (main) {
+ for (let i=1.46; i<=2.06; i+=0.06) {
+ x = halfWidth*i;
+ y = rHeight;
+ context.transform(1, (i-2)*0.0454, 0, 1, 0, 0);
+ context.lineTo(x, y);
+ context.resetTransform();
+ }
+ }
+ context.stroke();
+ }
- readonly property real this_speed: configs["Speed"]/100
- readonly property real this_MAX: (height/2)-4
- readonly property real this_noise: configs["Static AM"]/100*this_MAX
- readonly property real this_delta: this_MAX-this_noise
- property real this_phase: 0
+ function draw() {
+ let trebleAm = 0;
+ let altoAm = 0;
+ let bassAm = 0;
- readonly property var _globalAttenuationArray: [0.0017856573042805614, 0.002090029027424354, 0.0024428709787506155, 0.0028511620549328143, 0.003322734461672416, 0.0038663486688144872, 0.004491769417010894, 0.0052098416088514335, 0.0060325646905618185, 0.006973163895798498, 0.008046156486762173, 0.009267410897150058, 0.010654196465028541, 0.012225221251394174, 0.014000655282882916, 0.016002136446407085, 0.018252756211446522, 0.0207770223741957, 0.023600796118042038, 0.026751200876932862, 0.03025650078017051, 0.034145946854542274, 0.038449589664666724, 0.04319805768336597, 0.048422301394722714, 0.054153303932507744, 0.06042175993022312, 0.06725772518564865, 0.07469024069755677, 0.08274693558633812, 0.09145361433175414, 0.10083383461611592, 0.11090848281544048, 0.12169535480100475, 0.13320875016810133, 0.14545908827055729, 0.15845255448710202, 0.1721907849641367, 0.18667059766189825, 0.20188377687903944, 0.21781691755482288, 0.23445133456773634, 0.2517630409920839, 0.26972279787490494, 0.28829623659542597, 0.3074440533134911, 0.32712227344992756, 0.3472825826188692, 0.36787271899666724, 0.38883692080749416, 0.4101164214705023, 0.43164998401902316, 0.4533744656929005, 0.4752254031360044, 0.4971376084092084, 0.5190457660525851, 0.5408850216893105, 0.562591553140178, 0.5841031156880014, 0.6053595539666616, 0.6263032739177719, 0.6468796693242911, 0.6670374985596821, 0.6867292083486696, 0.7059112024886071, 0.7245440545987721, 0.7425926650223671, 0.760026362980347, 0.7768189559498792, 0.7929487290003452, 0.8083983974579334, 0.8231550167821777, 0.8372098539242965, 0.8505582247014246, 0.8631993018695427, 0.875135898619801, 0.8863742321691508, 0.8969236719785354, 0.9067964769231723, 0.9160075254728139, 0.9245740426279158, 0.9325153270127456, 0.9398524811601155, 0.9466081476449091, 0.9528062533442774, 0.9584717637292349, 0.9636304487320935, 0.9683086613922199, 0.9725331301632185, 0.9763307654708479, 0.9797284808449854, 0.9827530287117202, 0.9854308507237252, 0.9877879423279077, 0.9898497311182406, 0.9916409683972773, 0.9931856332704053, 0.9945068485207086, 0.9956268074571305, 0.9965667108926166, 0.9973467133897048, 0.997985877906754, 0.9985021379865716, 0.9989122666488067, 0.9992318511763106, 0.9994752730222837, 0.9996556921079202, 0.9997850348281199, 0.9998739851348633, 0.999931978122665, 0.9999671955978632, 0.999986563172305, 0.9999957484820413, 0.9999991601923922, 0.9999999475120023, 1.0, 0.9999999475120023, 0.9999991601923922, 0.9999957484820413, 0.999986563172305, 0.9999671955978632, 0.999931978122665, 0.9998739851348633, 0.9997850348281199, 0.9996556921079202, 0.9994752730222837, 0.9992318511763106, 0.9989122666488067, 0.9985021379865716, 0.997985877906754, 0.9973467133897048, 0.9965667108926166, 0.9956268074571305, 0.9945068485207086, 0.9931856332704053, 0.9916409683972773, 0.9898497311182406, 0.9877879423279077, 0.9854308507237252, 0.9827530287117202, 0.9797284808449854, 0.9763307654708498, 0.9725331301632185, 0.9683086613922199, 0.9636304487320935, 0.9584717637292349, 0.9528062533442774, 0.9466081476449091, 0.9398524811601155, 0.9325153270127456, 0.9245740426279158, 0.9160075254728139, 0.9067964769231723, 0.8969236719785354, 0.8863742321691508, 0.875135898619801, 0.8631993018695436, 0.8505582247014246, 0.8372098539242965, 0.8231550167821794, 0.8083983974579334, 0.7929487290003452, 0.7768189559498792, 0.760026362980347, 0.7425926650223671, 0.7245440545987721, 0.7059112024886071, 0.6867292083486696, 0.6670374985596821, 0.6468796693242911, 0.6263032739177719, 0.6053595539666616, 0.5841031156880014, 0.562591553140178, 0.5408850216893111, 0.5190457660525862, 0.49713760840920945, 0.4752254031360049, 0.4533744656929005, 0.43164998401902366, 0.4101164214705023, 0.3888369208074946, 0.36787271899666724, 0.34728258261887, 0.3271222734499283, 0.30744405331349145, 0.28829623659542597, 0.26972279787490555, 0.2517630409920839, 0.2344513345677366, 0.21781691755482313, 0.2018837768790397, 0.18667059766189847, 0.17219078496413692, 0.15845255448710202, 0.14545908827055729, 0.13320875016810133, 0.12169535480100475, 0.11090848281544048, 0.10083383461611592, 0.09145361433175414, 0.08274693558633812, 0.07469024069755677, 0.06725772518564865, 0.060421759930223286, 0.054153303932507744, 0.048422301394722776, 0.0431980576833661, 0.038449589664666724, 0.034145946854542274, 0.0302565007801706, 0.026751200876932904, 0.023600796118042038, 0.020777022374195733, 0.018252756211446522, 0.016002136446407085, 0.014000655282882938, 0.012225221251394195, 0.010654196465028541, 0.009267410897150073, 0.008046156486762187, 0.00697316389579851, 0.006032564690561829, 0.0052098416088514335, 0.004491769417010894, 0.0038663486688144872, 0.003322734461672416, 0.0028511620549328143, 0.0024428709787506155, 0.002090029027424354, 0.0017856573042805614, 0.0015235572708080104, 0.001298240554271166, 0.001104862087804041, 0.0009391569963475799, 0.000797381501252183, 0.0006762579957286263, 0.0005729243418569506, 0.00048488735639869217, 0.0004099803857607644, 0.00034632481850304286, 0.00029229534504994666, 0.0002464887470267302, 0.00020769598120373757, 0.00017487731379413836, 0.0001471402583278278, 0.0001237200731699464, 0.00010396258176888504, 8.730908885950263e-05, 7.328317821506653e-05];
+ for(let i=0; i<6.4; i++) {
+ bassAm += audioData[i];
+ }
+ for(let i=7; i<19.2; i++) {
+ altoAm += audioData[i];
+ }
+ for(let i=20; i<64; i++) {
+ trebleAm += audioData[i];
+ }
- function drawLine(ns, color, lwidth, _phase, main) {
- context.strokeStyle = color;
- context.lineWidth = lwidth || 1;
+ trebleAm = trebleAm / 38.4;
+ altoAm = altoAm / 19.2;
+ bassAm = bassAm / 6.4;
- let x, y;
- if (main) {
+ this_phase = (this_phase+this_speed)%(Math.PI*64);
+
+ context.clearRect(0, 0, width+32, height+32);
+
+ drawLine(this_delta*trebleAmRatio*trebleAm, trebleColor, 1.5, this_phase, false);
+ drawLine(this_delta*bassAmRatio*bassAm, bassColor, 1.5, this_phase+0.8, false);
+ drawLine(this_delta*altoAmRatio*altoAm, altoColor, 2, this_phase+0.4, true);
context.beginPath();
- context.moveTo(0, height*0.6);
- for (let i=0; i<=0.54; i+=0.06) {
- x = halfWidth*i;
- y = rHeight;
- context.transform(1, (i-2)*0.0454, 0, 1, 0, 0);
- context.lineTo(x, y);
- context.resetTransform();
- }
context.stroke();
}
- context.beginPath();
- context.transform(1, -0.066284, 0, 1, 0, 0);
- context.moveTo(width*0.27, rHeight);
- context.resetTransform();
- for (let i=0; i<=249; i+=1) {
- x = halfWidth*(0.54+i/250);
- // y = rHeight + (this.noise + ns) * _globalAttenuationArray[i] * Math.sin((-24.84+i*4.5*12/n)-phase);
- y = rHeight + (this_noise + ns) * _globalAttenuationArray[i] * Math.sin((-24.84+i*0.216)-_phase);
- // ctx.transform(1, -0.066284+i*0.0454/n, 0, 1, 0, 0);
- context.transform(1, -0.066284+i*0.0001816, 0, 1, 0, 0);
- context.lineTo(x, y);
- context.resetTransform();
+ onAudioDataUpdeted: {
+ if(autoNormalizing) {
+ for (let i = 0; i < 128; i++) {
+ audioData[i] = data[i] / data[128];
+ }
+ } else {
+ for (let i = 0; i < 128; i++) {
+ audioData[i] = data[i] * amplitude;
+ }
+ }
+ draw();
+ requestPaint();
}
- if (main) {
- for (let i=1.46; i<=2.06; i+=0.06) {
- x = halfWidth*i;
- y = rHeight;
- context.transform(1, (i-2)*0.0454, 0, 1, 0, 0);
- context.lineTo(x, y);
- context.resetTransform();
+ Component.onCompleted: {
+ for (let i = 0; i < 128; i++) {
+ audioData[i] = 0;
}
}
- context.stroke();
}
- function draw() {
- let trebleAm = 0;
- let altoAm = 0;
- let bassAm = 0;
+ defaultValues: {
+ "Version": "1.0.0",
+ "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
+ }
+ }
+
+ preference: AdvpPreference {
+ version: defaultValues["Version"]
+ cfg_height: 680
- for(let i=0; i<6.4; i++) {
- bassAm += audioData[i];
+ P.ColorPreference {
+ name: "Bass Color"
+ label: qsTr("Bass Line Color")
+ defaultValue: defaultValues["Bass Color"]
}
- for(let i=7; i<19.2; i++) {
- altoAm += audioData[i];
+
+ P.ColorPreference {
+ name: "Alto Color"
+ label: qsTr("Alto Line Color")
+ defaultValue: defaultValues["Alto Color"]
}
- for(let i=20; i<64; i++) {
- trebleAm += audioData[i];
+
+ P.ColorPreference {
+ name: "Treble Color"
+ label: qsTr("Treble Line Color")
+ defaultValue: defaultValues["Treble Color"]
}
- trebleAm = trebleAm / 38.4;
- altoAm = altoAm / 19.2;
- bassAm = bassAm / 6.4;
+ P.Separator {}
- this_phase = (this_phase+this_speed)%(Math.PI*64);
+ P.SliderPreference {
+ name: "Bass AM"
+ label: qsTr("Bass Amplitude")
+ from: 10
+ to: 300
+ stepSize: 5
+ defaultValue: defaultValues["Bass AM"]
+ displayValue: value + "%"
+ }
- context.clearRect(0, 0, width+32, height+32);
+ P.SliderPreference {
+ name: "Alto AM"
+ label: qsTr("Alto Amplitude")
+ from: 10
+ to: 300
+ stepSize: 5
+ defaultValue: defaultValues["Alto AM"]
+ displayValue: value + "%"
+ }
- drawLine(this_delta*trebleAmRatio*trebleAm, trebleColor, 1.5, this_phase, false);
- drawLine(this_delta*bassAmRatio*bassAm, bassColor, 1.5, this_phase+0.8, false);
- drawLine(this_delta*altoAmRatio*altoAm, altoColor, 2, this_phase+0.4, true);
- context.beginPath();
- context.stroke();
- }
+ P.SliderPreference {
+ name: "Treble AM"
+ label: qsTr("Treble Amplitude")
+ from: 10
+ to: 300
+ stepSize: 5
+ defaultValue: defaultValues["Treble AM"]
+ displayValue: value + "%"
+ }
- onAudioDataUpdeted: {
- if(autoNormalizing) {
- for (let i = 0; i < 128; i++) {
- audioData[i] = data[i] / data[128];
- }
- } else {
- for (let i = 0; i < 128; i++) {
- audioData[i] = data[i] * amplitude;
- }
+ P.Separator {}
+
+ P.SliderPreference {
+ name: "Static AM"
+ label: qsTr("Static Amplitude")
+ from: 5
+ to: 100
+ stepSize: 1
+ defaultValue: defaultValues["Static AM"]
+ displayValue: value + "%"
+ }
+
+ P.Separator {}
+
+ P.SliderPreference {
+ name: "Speed"
+ label: qsTr("Wave Speed")
+ from: 1
+ to: 100
+ stepSize: 1
+ defaultValue: defaultValues["Speed"]
+ displayValue: value + "%"
}
- draw();
- requestPaint();
- }
- Component.onCompleted: {
- for (let i = 0; i < 128; i++) {
- audioData[i] = 0;
+ 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: defaultValues["Data Settings"]["Auto Normalizing"]
+ }
+
+ 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: defaultValues["Data Settings"]["Amplitude"]
+ }
}
}
}
diff --git a/styles/Preset_circle/Config.qml b/styles/Preset_circle/Config.qml
deleted file mode 100644
index 11c0586..0000000
--- a/styles/Preset_circle/Config.qml
+++ /dev/null
@@ -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")]
- }
- }
-}
diff --git a/styles/Preset_circle/Style.qml b/styles/Preset_circle/Style.qml
index bc574b1..45a3fa2 100644
--- a/styles/Preset_circle/Style.qml
+++ b/styles/Preset_circle/Style.qml
@@ -1,132 +1,286 @@
import QtQuick 2.12
-import QtQuick.Controls 2.12
+import NERvGear.Preferences 1.0 as P
import "../../qml/api"
-StyleAPI {
- 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;
- }
+AdvpStyleTemplate {
+ style: AdvpCanvasTemplate {
+ readonly property var audioData: new Array(128)
- function getPos(r, deg) {
- return [halfWidth+Math.cos(deg)*r,halfHeight+Math.sin(deg)*r];
- }
+ //configs
+ 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() {
- outerPos = [];
- innerPos = [];
- let deg, deltaR, r1, r2, _rhmLen;
- _rhmLen = mainRatio*halfMinLength;
-
- for (let j=0; j < channel; j++) {
- for (let i=0; i < dataLength; i++) {
- deg = degUnit*((i+j*dataLength)*dotGap + offsetAngle);
- deltaR = audioData[reverse*(dataLength-i-1)+(!reverse)*(i+j*dataLength)] * ratio;
- r1 = _rhmLen+1+deltaR*(linePosition!==2);
- r2 = _rhmLen-1-deltaR*(linePosition!==1);
- outerPos.push(getPos(r1, deg));
- innerPos.push(getPos(r2, deg));
- }
+ 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 = configs["Line Width"];
+ context.strokeStyle = configs["Main Color"];
}
- offsetAngle = rotateFlag ? ((offsetAngle + rSpeed) % 360) : angle;
- }
- onAudioDataUpdeted: {
- if(autoNormalizing) {
- if (unitStyle) {
- //对数化显示
- let logPeak = Math.log10(data[128]);
- for(let i=0; i{})
+ context.lineWidth = configs["Line Width"];
+ context.strokeStyle = configs["Line Color"];
+ }
+
+ onAudioDataUpdeted: {
+ data[128] *= 2;
+ if(autoNormalizing) {
+ if (unitStyle) {
+ //对数化显示
+ for(let i=0; i