import QtQuick 2.12 import NERvGear.Preferences 1.0 as P import "../../qml/api" AdvpStyleTemplate { style: AdvpCanvasTemplate { readonly property var audioData: new Array(128) //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: 400/configs["Data Settings"]["Amplitude"] 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 onConfigsUpdated: { context.lineWidth = configs["Line Width"]; context.strokeStyle = configs["Main Color"]; } function createPoint() { outerPos.length = 0; innerPos.length = 0; 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([halfWidth+Math.cos(deg)*r1,halfHeight+Math.sin(deg)*r1]); innerPos.push([halfWidth+Math.cos(deg)*r2,halfHeight+Math.sin(deg)*r2]); } } offsetAngle = rotateFlag ? ((offsetAngle + rSpeed) % 360) : angle; } onAudioDataUpdeted: { let normalizing_ratio = autoNormalizing ? data[128] : amplitude; if (unitStyle) { //对数化显示 for(let i=0; i