perf: 更新语音消息插件

This commit is contained in:
kuaifan 2024-05-09 16:09:14 +09:00
parent 0fce0c2386
commit bf46a00937
3 changed files with 127 additions and 97 deletions

View File

@ -24,7 +24,7 @@
display: flex; display: flex;
align-items: center; align-items: center;
>h1 { > h1 {
color: $primary-title-color; color: $primary-title-color;
font-size: 28px; font-size: 28px;
font-weight: 600; font-weight: 600;
@ -37,19 +37,19 @@
padding: 16px 30px; padding: 16px 30px;
overflow: auto; overflow: auto;
.apply-row-title{ .apply-row-title {
margin-bottom: 16px; margin-bottom: 16px;
} }
>div.apply-row-title:nth-last-child(2){ > div.apply-row-title:nth-last-child(2) {
margin-top: 22px !important; margin-top: 22px !important;
} }
.apply-col { .apply-col {
margin-bottom: 16px; margin-bottom: 16px;
>div { > div {
font-size: 14px; font-size: 14px;
font-weight: normal; font-weight: normal;
background: #FFFFFF; background: #FFFFFF;
@ -63,13 +63,13 @@
position: relative; position: relative;
border: 1px solid #f1f1f1; border: 1px solid #f1f1f1;
>.logo { > .logo {
width: 40px; width: 40px;
height: 40px; height: 40px;
display: inline-block; display: inline-block;
} }
>p{ > p {
overflow: hidden; overflow: hidden;
text-overflow: ellipsis; text-overflow: ellipsis;
display: -webkit-box; display: -webkit-box;
@ -90,13 +90,13 @@
@media (max-width: 510px) { @media (max-width: 510px) {
background-color: #FFFFFF; background-color: #FFFFFF;
.apply-row-title{ .apply-row-title {
margin-bottom: 8px !important; margin-bottom: 8px !important;
} }
.apply-content{ .apply-content {
.ivu-row{ .ivu-row {
margin-left: -12px !important; margin-left: -12px !important;
margin-right: -12px !important; margin-right: -12px !important;
} }
@ -104,10 +104,10 @@
.apply-col { .apply-col {
margin-bottom: 6px; margin-bottom: 6px;
>div { > div {
display: block; display: block;
text-align: center; text-align: center;
padding:12px 0; padding: 12px 0;
background: none; background: none;
border-color: #ffffff; border-color: #ffffff;
@ -116,7 +116,7 @@
position: relative; position: relative;
} }
>p{ > p {
-webkit-line-clamp: 1; -webkit-line-clamp: 1;
} }
@ -138,72 +138,95 @@
background-repeat: no-repeat; background-repeat: no-repeat;
background-size: contain; background-size: contain;
background-position: center center; background-position: center center;
&.approve { &.approve {
background-image: url("../images/application/approve.svg"); background-image: url("../images/application/approve.svg");
} }
&.add-project { &.add-project {
background-image: url("../images/application/add-project.svg"); background-image: url("../images/application/add-project.svg");
} }
&.add-task { &.add-task {
background-image: url("../images/application/add-task.svg"); background-image: url("../images/application/add-task.svg");
} }
&.all-user { &.all-user {
background-image: url("../images/application/all-user.svg"); background-image: url("../images/application/all-user.svg");
} }
&.complaint { &.complaint {
background-image: url("../images/application/complaint.svg"); background-image: url("../images/application/complaint.svg");
} }
&.app-push { &.app-push {
background-image: url("../images/application/app-push.svg"); background-image: url("../images/application/app-push.svg");
} }
&.approve { &.approve {
background-image: url("../images/application/approve.svg"); background-image: url("../images/application/approve.svg");
} }
&.calendar { &.calendar {
background-image: url("../images/application/calendar.svg"); background-image: url("../images/application/calendar.svg");
} }
&.file { &.file {
background-image: url("../images/application/file.svg"); background-image: url("../images/application/file.svg");
} }
&.ldap { &.ldap {
background-image: url("../images/application/ldap.svg"); background-image: url("../images/application/ldap.svg");
} }
&.mail { &.mail {
background-image: url("../images/application/mail.svg"); background-image: url("../images/application/mail.svg");
} }
&.meeting { &.meeting {
background-image: url("../images/application/meeting.svg"); background-image: url("../images/application/meeting.svg");
} }
&.meeting-create { &.meeting-create {
background-image: url("../images/application/meeting-create.svg"); background-image: url("../images/application/meeting-create.svg");
} }
&.meeting-join { &.meeting-join {
background-image: url("../images/application/meeting-join.svg"); background-image: url("../images/application/meeting-join.svg");
} }
&.okr { &.okr {
background-image: url("../images/application/okr.svg"); background-image: url("../images/application/okr.svg");
} }
&.okr-analyze { &.okr-analyze {
background-image: url("../images/application/okr-analyze.svg"); background-image: url("../images/application/okr-analyze.svg");
} }
&.report { &.report {
background-image: url("../images/application/report.svg"); background-image: url("../images/application/report.svg");
} }
&.robot { &.robot {
background-image: url("../images/application/robot.svg"); background-image: url("../images/application/robot.svg");
} }
&.scan { &.scan {
background-image: url("../images/application/scan.svg"); background-image: url("../images/application/scan.svg");
} }
&.setting { &.setting {
background-image: url("../images/application/setting.svg"); background-image: url("../images/application/setting.svg");
} }
&.signin { &.signin {
background-image: url("../images/application/signin.svg"); background-image: url("../images/application/signin.svg");
} }
&.vote { &.vote {
background-image: url("../images/application/vote.svg"); background-image: url("../images/application/vote.svg");
} }
&.word-chain { &.word-chain {
background-image: url("../images/application/word-chain.svg"); background-image: url("../images/application/word-chain.svg");
} }
@ -225,7 +248,7 @@
padding: 12px 30px; padding: 12px 30px;
color: #303133; color: #303133;
>p { > p {
float: right; float: right;
cursor: pointer; cursor: pointer;
color: #2b85e4; color: #2b85e4;
@ -254,32 +277,21 @@
display: flex; display: flex;
flex-direction: column; flex-direction: column;
>.ivu-form { .ivu-form {
padding: 8px 30px; padding: 8px 30px;
overflow: auto; overflow: auto;
flex: 1; flex: 1;
.ivu-form-item {
.ivu-form-item .ivu-form-item-content {
display: flex;
>.ivu-form {
margin-bottom: 8px;
}
}
}
} }
.setting-template { .setting-template {
margin-bottom: 12px; margin-bottom: 12px;
>div { > div {
padding-right: 12px; padding-right: 12px;
} }
} }
.export-data>p { .export-data > p {
cursor: pointer; cursor: pointer;
color: #2b85e4; color: #2b85e4;
} }
@ -292,7 +304,8 @@
display: flex; display: flex;
align-items: center; align-items: center;
gap: 8px; gap: 8px;
.ivu-btn{
.ivu-btn {
min-width: 120px; min-width: 120px;
height: 38px; height: 38px;
line-height: 36px; line-height: 36px;
@ -309,9 +322,11 @@
flex-direction: column; flex-direction: column;
height: 100%; height: 100%;
margin: 0 -30px; margin: 0 -30px;
.ivu-tabs-bar{
.ivu-tabs-bar {
padding: 0 10px; padding: 0 10px;
} }
.ivu-tabs-content { .ivu-tabs-content {
height: 100%; height: 100%;
flex: 1; flex: 1;
@ -372,7 +387,7 @@
} }
} }
.desc{ .desc {
cursor: pointer; cursor: pointer;
height: 84px; height: 84px;
@media (max-width: 510px) { @media (max-width: 510px) {
@ -409,9 +424,11 @@
.mobile-scan-login-box { .mobile-scan-login-box {
margin: 2px 0 12px; margin: 2px 0 12px;
.mobile-scan-login-title { .mobile-scan-login-title {
font-size: 20px; font-size: 20px;
} }
.mobile-scan-login-subtitle { .mobile-scan-login-subtitle {
padding-top: 8px; padding-top: 8px;
} }
@ -419,13 +436,15 @@
body.window-portrait { body.window-portrait {
.page-apply { .page-apply {
.apply-head{ .apply-head {
margin: 24px 24px 0 24px; margin: 24px 24px 0 24px;
} }
.apply-content{
.apply-content {
padding: 16px 20px; padding: 16px 20px;
.apply-col { .apply-col {
>div { > div {
font-size: 12px; font-size: 12px;
font-weight: 500; font-weight: 500;
} }

View File

@ -1,6 +1,6 @@
/* /*
录音 Recorder扩展频率直方图显示 录音 Recorder扩展频率直方图显示
使用本扩展需要引入src/extensions/lib.fft.js支持直方图特意优化主要显示0-5khz语音部分线性其他高频显示区域较小不适合用来展示音乐频谱自行修改源码恢复成完整的线性频谱修改成倍频程频谱伯德图对数频谱本可视化插件可以移植到其他语言环境如需定制可联系作者 使用本扩展需要引入src/extensions/lib.fft.js支持直方图特意优化主要显示0-5khz语音部分线性其他高频显示区域较小不适合用来展示音乐频谱通过配置fullFreq来恢复成完整的线性频谱自行修改源码修改成倍频程频谱伯德图对数频谱本可视化插件可以移植到其他语言环境如需定制可联系作者
https://github.com/xiangyuecn/Recorder https://github.com/xiangyuecn/Recorder
@ -65,6 +65,7 @@ H5环境以上配置二选一
,stripeShadowBlur:-1 //峰值小横条阴影基础大小设为0不显示阴影-1为柱子的大小如果柱子数量太多时请勿开启非常影响性能 ,stripeShadowBlur:-1 //峰值小横条阴影基础大小设为0不显示阴影-1为柱子的大小如果柱子数量太多时请勿开启非常影响性能
,stripeShadowColor:"" //峰值小横条阴影颜色,留空为柱子的阴影颜色 ,stripeShadowColor:"" //峰值小横条阴影颜色,留空为柱子的阴影颜色
,fullFreq:false //是否要绘制所有频率默认false主要绘制5khz以下的频率高频部分占比很少此时不同的采样率对频谱显示几乎没有影响设为true后不同采样率下显示的频谱是不一样的因为 最大频率=采样率/2 会有差异
//当发生绘制时会回调此方法参数为当前绘制的频率数据和采样率可实现多个直方图同时绘制只消耗一个input输入和计算时间 //当发生绘制时会回调此方法参数为当前绘制的频率数据和采样率可实现多个直方图同时绘制只消耗一个input输入和计算时间
,onDraw:function(frequencyData,sampleRate){} ,onDraw:function(frequencyData,sampleRate){}
}; };
@ -214,15 +215,17 @@ fn.prototype=FrequencyHistogramView.prototype={
var logY0 = Math.log(Y0)/Math.log(10); var logY0 = Math.log(Y0)/Math.log(10);
var dBmax=20*Math.log(0x7fff)/Math.log(10); var dBmax=20*Math.log(0x7fff)/Math.log(10);
var fftSize=bufferSize/2; var fftSize=bufferSize/2,fftSize5k=fftSize;
var fftSize5k=Math.min(fftSize,Math.floor(fftSize*5000/(sampleRate/2)));//5khz所在位置8000采样率及以下最高只有4khz if(!set.fullFreq){//非绘制所有频率时计算5khz所在位置8000采样率及以下最高只有4khz
var fftSize5kIsAll=fftSize5k==fftSize; fftSize5k=Math.min(fftSize,Math.floor(fftSize*5000/(sampleRate/2)));
var line80=fftSize5kIsAll?lineCount:Math.round(lineCount*0.8);//80%的柱子位置 }
var isFullFreq=fftSize5k==fftSize;
var line80=isFullFreq?lineCount:Math.round(lineCount*0.8);//80%的柱子位置
var fftSizeStep1=fftSize5k/line80; var fftSizeStep1=fftSize5k/line80;
var fftSizeStep2=fftSize5kIsAll?0:(fftSize-fftSize5k)/(lineCount-line80); var fftSizeStep2=isFullFreq?0:(fftSize-fftSize5k)/(lineCount-line80);
var fftIdx=0; var fftIdx=0;
for(var i=0;i<lineCount;i++){ for(var i=0;i<lineCount;i++){
//不采用jmp123的非线性划分频段录音语音并不适用于音乐的频率应当弱化高频部分 // !fullFreq 时不采用jmp123的非线性划分频段录音语音并不适用于音乐的频率应当弱化高频部分
//80%关注0-5khz主要人声部分 20%关注剩下的高频,这样不管什么采样率都能做到大部分频率显示一致。 //80%关注0-5khz主要人声部分 20%关注剩下的高频,这样不管什么采样率都能做到大部分频率显示一致。
var start=Math.ceil(fftIdx); var start=Math.ceil(fftIdx);
if(i<line80){ if(i<line80){
@ -232,7 +235,8 @@ fn.prototype=FrequencyHistogramView.prototype={
//5khz以上 //5khz以上
fftIdx+=fftSizeStep2; fftIdx+=fftSizeStep2;
}; };
var end=Math.min(Math.ceil(fftIdx),fftSize); var end=Math.ceil(fftIdx); if(end==start)end++;
end=Math.min(end,fftSize);
//参考AudioGUI.java .drawHistogram方法 //参考AudioGUI.java .drawHistogram方法
@ -276,8 +280,6 @@ fn.prototype=FrequencyHistogramView.prototype={
var stripeLinear2=set.stripeLinear&&This.genLinear(ctx,set.stripeLinear,originY,originY+heightY)||linear2;//上半部分的峰值小横条填充 var stripeLinear2=set.stripeLinear&&This.genLinear(ctx,set.stripeLinear,originY,originY+heightY)||linear2;//上半部分的峰值小横条填充
//计算柱子间距 //计算柱子间距
ctx.shadowBlur=set.shadowBlur*scale;
ctx.shadowColor=set.shadowColor;
var mirrorEnable=set.mirrorEnable; var mirrorEnable=set.mirrorEnable;
var mirrorCount=mirrorEnable?lineCount*2-1:lineCount;//镜像柱子数量翻一倍-1根 var mirrorCount=mirrorEnable?lineCount*2-1:lineCount;//镜像柱子数量翻一倍-1根
@ -287,72 +289,81 @@ fn.prototype=FrequencyHistogramView.prototype={
widthRatio=(width-spaceWidth*(mirrorCount+1))/width; widthRatio=(width-spaceWidth*(mirrorCount+1))/width;
}; };
var lineWidth=Math.max(1*scale,Math.floor((width*widthRatio)/mirrorCount));//柱子宽度至少1个单位 for(var i=0;i<2;i++){
var spaceFloat=(width-mirrorCount*lineWidth)/(mirrorCount+1);//均匀间隔,首尾都留空,可能为负数,柱子将发生重叠 var lineFloat=Math.max(1*scale,(width*widthRatio)/mirrorCount);//柱子宽度至少1个单位
var lineWN=Math.floor(lineFloat),lineWF=lineFloat-lineWN;//提取出小数部分
//绘制柱子 var spaceFloat=(width-mirrorCount*lineFloat)/(mirrorCount+1);//均匀间隔,首尾都留空,可能为负数,柱子将发生重叠
var minHeight=set.minHeight*scale; if(spaceFloat>0 && spaceFloat<1){
var mirrorSubX=spaceFloat+lineWidth/2; widthRatio=1; spaceFloat=0; //不够一个像素,丢弃不绘制间隔,重新计算
var XFloat=mirrorEnable?width/2-mirrorSubX:0;//镜像时,中间柱子位于正中心 }else break;
for(var i=0,xFloat=XFloat,x,y,h;i<lineCount;i++){
xFloat+=spaceFloat;
x=Math.floor(xFloat);
h=Math.max(lastH[i],minHeight);
//绘制上半部分
if(originY!=0){
y=originY-h;
ctx.fillStyle=linear1;
ctx.fillRect(x, y, lineWidth, h);
};
//绘制下半部分
if(originY!=height){
ctx.fillStyle=linear2;
ctx.fillRect(x, originY, lineWidth, h);
};
xFloat+=lineWidth;
}; };
//绘制柱子顶上峰值小横条 //绘制
if(set.stripeEnable){ var minHeight=set.minHeight*scale;
var stripeShadowBlur=set.stripeShadowBlur; var XFloat=mirrorEnable?(width-lineWN)/2-spaceFloat:0;//镜像时,中间柱子位于正中心
ctx.shadowBlur=(stripeShadowBlur==-1?set.shadowBlur:stripeShadowBlur)*scale; for(var iMirror=0;iMirror<2;iMirror++){
ctx.shadowColor=set.stripeShadowColor||set.shadowColor; if(iMirror){ ctx.save(); ctx.scale(-1,1); }
var stripeHeight=set.stripeHeight*scale; var xMirror=iMirror?width:0; //绘制镜像部分不用drawImage(canvas)进行镜像绘制提升兼容性iOS微信小程序bug https://developers.weixin.qq.com/community/develop/doc/000aaca2148dc8a235a0fb8c66b000
for(var i=0,xFloat=XFloat,x,y,h;i<lineCount;i++){
//绘制柱子
ctx.shadowBlur=set.shadowBlur*scale;
ctx.shadowColor=set.shadowColor;
for(var i=0,xFloat=XFloat,wFloat=0,x,y,w,h;i<lineCount;i++){
xFloat+=spaceFloat; xFloat+=spaceFloat;
x=Math.floor(xFloat); x=Math.floor(xFloat)-xMirror;
h=stripesH[i]; w=lineWN; wFloat+=lineWF; if(wFloat>=1){ w++; wFloat--; } //小数凑够1像素
h=Math.max(lastH[i],minHeight);
//绘制上半部分 //绘制上半部分
if(originY!=0){ if(originY!=0){
y=originY-h-stripeHeight; y=originY-h;
if(y<0){y=0;}; ctx.fillStyle=linear1;
ctx.fillStyle=stripeLinear1; ctx.fillRect(x, y, w, h);
ctx.fillRect(x, y, lineWidth, stripeHeight);
}; };
//绘制下半部分 //绘制下半部分
if(originY!=height){ if(originY!=height){
y=originY+h; ctx.fillStyle=linear2;
if(y+stripeHeight>height){ ctx.fillRect(x, originY, w, h);
y=height-stripeHeight;
};
ctx.fillStyle=stripeLinear2;
ctx.fillRect(x, y, lineWidth, stripeHeight);
}; };
xFloat+=lineWidth; xFloat+=w;
};
//绘制柱子顶上峰值小横条
if(set.stripeEnable){
var stripeShadowBlur=set.stripeShadowBlur;
ctx.shadowBlur=(stripeShadowBlur==-1?set.shadowBlur:stripeShadowBlur)*scale;
ctx.shadowColor=set.stripeShadowColor||set.shadowColor;
var stripeHeight=set.stripeHeight*scale;
for(var i=0,xFloat=XFloat,wFloat=0,x,y,w,h;i<lineCount;i++){
xFloat+=spaceFloat;
x=Math.floor(xFloat)-xMirror;
w=lineWN; wFloat+=lineWF; if(wFloat>=1){ w++; wFloat--; } //小数凑够1像素
h=stripesH[i];
//绘制上半部分
if(originY!=0){
y=originY-h-stripeHeight;
if(y<0){y=0;};
ctx.fillStyle=stripeLinear1;
ctx.fillRect(x, y, w, stripeHeight);
};
//绘制下半部分
if(originY!=height){
y=originY+h;
if(y+stripeHeight>height){
y=height-stripeHeight;
};
ctx.fillStyle=stripeLinear2;
ctx.fillRect(x, y, w, stripeHeight);
};
xFloat+=w;
};
}; };
};
//镜像,从中间直接镜像即可 if(iMirror){ ctx.restore(); }
if(mirrorEnable){ if(!mirrorEnable) break;
var srcW=Math.floor(width/2);
ctx.save();
ctx.scale(-1,1);
ctx.drawImage(This.canvas,Math.ceil(width/2),0,srcW,height,-srcW,0,srcW,height);
ctx.restore();
}; };
if(frequencyData){ if(frequencyData){

File diff suppressed because one or more lines are too long