Skip to content

Commit

Permalink
DTMF解码限制频率需高于功能键频率,更新文档
Browse files Browse the repository at this point in the history
  • Loading branch information
xiangyuecn committed Mar 9, 2022
1 parent 388735b commit 5aefeef
Show file tree
Hide file tree
Showing 3 changed files with 56 additions and 17 deletions.
30 changes: 20 additions & 10 deletions assets/工具-GitHub页面历史版本访问.html
Original file line number Diff line number Diff line change
Expand Up @@ -11,17 +11,24 @@

<body>
<div style="font-size:16px;line-height:1.4">
<div style="padding:10px;background:#fff;border-bottom:4px solid #f60;border-radius: 8px;position:relative;">
<div title="是有多无聊才会写出这个页面,想学吗?Ctrl+U查看源码!"
style="cursor:zoom-in;position:absolute;left:12px;bottom:0px;font-size:12px;color:#f60">
<script>
/*是有多无聊才会写出这个页面,真查看源码,是想学吗?*/
var s=unescape('%uD83D%uDC97');document.write(s+s+"后会有期 at 2022-03-06"+s+s);
</script>
<div style="padding:10px;padding-bottom:5px;background:#fff;border-bottom:4px solid #f60;border-radius: 8px;position:relative;">
<div style="display:inline-block;vertical-align:middle;margin-right:50px;line-height:1">
<div style="font-size:24px;color:#f60">GitHub页面历史版本访问-简易版工具</div>

<div style="font-size:12px;margin-top:5px">
<span title="是有多无聊才会写出这个页面,想学吗?Ctrl+U查看源码!"
style="cursor:zoom-in;color:#f60;margin-right:115px">
<script>
/*是有多无聊才会写出这个页面,真查看源码,是想学吗?*/
var s=unescape('%uD83D%uDC97');document.write(s+s+"后会有期 at 2022-03-06"+s+s);
</script>
</span>

<a href="https://github.com/xiangyuecn/Recorder" target="_blank">GitHub</a>
| <a href="https://gitee.com/xiangyuecn/Recorder" target="_blank">Gitee</a>
</div>
</div>

<span style="font-size:24px;margin-right:50px;color:#f60">GitHub页面历史版本访问-简易版工具</span>

<span style="margin-right:20px;display:inline-block">
仓库路径:
<input class="OldVer_Url" placeholder="格式:`user:repo@*,path` @可选:@提交hash @分支名" style="height:24px;width:340px;width:min(340px, 70vw)">
Expand Down Expand Up @@ -92,7 +99,7 @@
var rootUrl="";

console.log("urlInfo",urlInfo);
reclog('<span style="font-weight:bold">本工具支持简单处理 GitHub 页面的历史版本页面的访问展示</span>'
reclog('<span style="font-weight:bold">本工具支持简单处理 GitHub Pages 的历史版本页面的访问展示</span>'
+';<span style="color:#f60">如果JsDelivr CDN无法访问,本工具将无法运行</span>'
+';【用法】:仓库路径中填写 <span style="color:#cb05ff">GitHub 用户名 + : + 仓库名 + 可选@(@Release版本号、@提交Hash、@分支名称) + , + /文件路径</span> (仓库路径中填写的@值比选择的版本号优先级高),版本可以先不选,然后点击加载。首次加载好后,可以切换版本号(或明确在仓库路径中指定分支、某次提交)来查看不同历史的页面效果。');
reclog("当前处理的地址为:"+ToA(urlInfo.url)+" 指定的版本号:"+(args_ver||"未指定"));
Expand All @@ -114,6 +121,9 @@
a[1]=replaceSrc("xhr."+m,u);
return oldOpen.apply(this,a);
};
XMLHttpRequest.prototype.setRequestHeader=function(k,v){
console.warn("xhr阻止添加请求头:"+k+"="+v);//沙雕jQuery会添加X-Requested-With
};
function replaceSrc(tag,src){
if(!urlInfo._dir){
urlInfo._dir=urlInfo.path.replace(/\/[^\/]+$/g,"/");
Expand Down
41 changes: 35 additions & 6 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@
<button onclick="resetSonicCtrl()">重置变速变调</button>
实时变速变调控制选项,可以边录边修改,同一时间应该只控制一个,否则叠加作用;请填写0.1-2.0的数字,1.0为不调整,当然超过2.0也是可以的(需手动输入)
</div>
<div class="sonicCtrlBox" style="margin:5px 0 0">
<div class="sonicCtrlBox" style="margin:5px 0 0;position: relative;">
<style>
.sonicCtrlBox span{display:inline-block;width:80px;text-align:right;}
.sonicCtrlBox input{text-align:right;}
Expand All @@ -377,6 +377,11 @@
<div><span>播放反馈:</span><input class="sonicCtrlInput sonicCtrlPlay" style="width:60px"> 不播放 <input type="range" class="sonicCtrlRange" min="0" max="1" step="1" value="1">实时播放反馈</div>

<div style="margin-top:10px"><button onclick="sonicRecTransform()">重新转换当前录音</button></div>

<div class="sonicCtrlBoxMask" style="position:absolute;top:0;left:0;width:100%;height:100%;background: rgba(0,0,0,.2);text-align: center;">
<div style="padding-top:50px;font-size: 30px;color: #fff;">挡住!防止滑块被误触</div>
<div><button onclick="sonicCtrlBoxMaskClose()">打开编辑</button></div>
</div>
</div>
</div>

Expand Down Expand Up @@ -588,7 +593,7 @@
};
};
//变速变调
var beginAsync=sonicProcess(buffers,sampleRate,newBufferIdx,asyncEnd);
var beginAsync=sonicProcess(rec,buffers,sampleRate,newBufferIdx,asyncEnd);

$(".recpowerx").css("width",powerLevel+"%");
$(".recpowert").text(formatMs(duration,1)+" / "+powerLevel);
Expand Down Expand Up @@ -739,6 +744,7 @@

sonicAsync&&sonicAsync.flush();//丢弃不管,省的去同步麻烦
sonicAsync=null;
rec.sonicTips="";

takeoffChunks=[];

Expand Down Expand Up @@ -1192,6 +1198,12 @@
$(".sonicCtrlRange").val(1).change();
$(".sonicCtrlBufferRange").val(200).change();
};
var sonicCtrlBoxMaskClose=function(){
$(".sonicCtrlBoxMask").hide();
};
if(!/mobile/i.test(navigator.userAgent)){
sonicCtrlBoxMaskClose();
};
var sonicRecTransform=function(){
if(!rec||!rec.buffers){
reclog("请先录音",1);
Expand All @@ -1210,7 +1222,7 @@

var srcBuffers=rec.buffers;
var buffers=[];
var idx=-1;
var idx=-1,logScope={};
var run=function(){
idx++;
if(idx>=srcBuffers.length){
Expand All @@ -1223,7 +1235,7 @@
};

buffers.push(Recorder.SampleData([srcBuffers[idx]],rec.srcSampleRate,sampleRate).data);
var beginAsync=sonicProcess(buffers,sampleRate,idx,run);
var beginAsync=sonicProcess(logScope,buffers,sampleRate,idx,run);
if(!beginAsync){
reclog("不存在变速变调设置,或不能开启转换",1);
};
Expand All @@ -1232,11 +1244,15 @@
run();
};
var sonicInfo;
var sonicProcess=function(buffers,sampleRate,newBufferIdx,asyncEnd){
var sonicProcess=function(logScope,buffers,sampleRate,newBufferIdx,asyncEnd){
if(sonicCtrlSet.pitch==1
&&sonicCtrlSet.rate==1
&&sonicCtrlSet.speed==1
&&sonicCtrlSet.volume==1){//不存在变速变调设置
if(logScope.sonicTips){
logScope.sonicTips="";
reclog("已停用整变速变调","#aaa");
}
return;
};

Expand All @@ -1254,6 +1270,15 @@
};
};

var sonicTips="Pitch="+sonicCtrlSet.pitch
+", Speed="+sonicCtrlSet.speed
+", Rate="+sonicCtrlSet.rate
+", Volume="+sonicCtrlSet.volume;
if(logScope.sonicTips!=sonicTips){
reclog((logScope.sonicTips?"已修改":"已开启")+"变速变调:"+sonicTips,"#aaa");
logScope.sonicTips=sonicTips;
};

sonicAsync.setPitch(sonicCtrlSet.pitch);
sonicAsync.setRate(sonicCtrlSet.rate);
sonicAsync.setSpeed(sonicCtrlSet.speed);
Expand Down Expand Up @@ -1287,7 +1312,11 @@

//实时播放反馈
if(sonicCtrlSet.play&&window.DemoFragment&&DemoFragment.PlayBuffer){
DemoFragment.PlayBuffer(sonicInfo,pcm,sampleRate);
try{
DemoFragment.PlayBuffer(sonicInfo,pcm,sampleRate);
}catch(e){//在古董浏览器里面可能会开启播放失败
console.error("sonic -> DemoFragment.PlayBuffer错误,无法实时播放反馈",e);
}
};

asyncEnd();//完成处理必须进行回调
Expand Down
2 changes: 1 addition & 1 deletion src/extensions/dtmf.decode.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ Recorder.DTMF_Decode=function(pcmData,sampleRate,prevChunk){
};
};
var pv0 =-1, pv1=-1;
if(v0>600 && v1<1600 && Math.abs(p0-p1)<2.5){//高低频的幅度相差不能太大,此值是先给个大值再多次【测试】(下面一个log)得出来的
if(v0>600 && v1<1700 && Math.abs(p0-p1)<2.5){//高低频的幅度相差不能太大,此值是先给个大值再多次【测试】(下面一个log)得出来的
//波形匹配度:两个峰值之间应当是深V型曲线,如果出现大幅杂波,可以直接排除掉
var isV=1;
//先找出谷底
Expand Down

0 comments on commit 5aefeef

Please sign in to comment.