我决定将音调运动合并到我的项目中,而不是仅仅关注短单声道样本,因此除了频率和置信度读数之外,对于这部分代码,我还需要包括一些标准偏差计算。
考虑到西方音阶,将 Hertz 转换为每边 50cents(1/4 半音)的回火 12 音阶是明智的,我打算添加 microtonna 功能,但对于这项任务,设置半色调标清。因此,一旦信号偏离频率间隔比的值,我想将当前读数的平均值存储为 1 个单元格值,然后继续收集下一批读数,直到音高再次偏离(高于或低于)频率间隔比率。但是,是的,我坚持语法,想问是否有人可以提供一些帮助。
所以,我想存储平均值,从 stddev 处理程序的第一部分计算,并将其存储为一个读数,然后移动到下一个值,直到音高偏离极限,然后存储该平均值等等。通过引入置信度阈值,大多数音调异常和无用的谐波内容已被删除。所以我应该,最好的部分是能够依赖那里的信息。或者,如果我能成功获得单独的平均读数,那将有望实现。
我希望这能有所帮助,并提前感谢您的任何建议!
这就是我所拥有的,减去置信度值 shell 任务/AS 代码,并且没有 CSV,所以我只是添加了一些数字。
再次感谢
道格
use AppleScript version "2.4" -- Yosemite (10.10) or later
use framework "Foundation"
use framework "AVFAudio"
use scripting additions
property freqData : ""
-- reading the CSV
set my_data to read POSIX path of "Mojave:Users:dh:CSV:example.f0.csv" as «class furl»
set csvData to paragraphs 2 thru -2 of my_data as list -- theres a text row i want to be ignored
set freqData to {}
set oldDelims to AppleScript's text item delimiters
set AppleScript's text item delimiters to ","
repeat with a_reading in csvData
set x to text item 1 of a_reading -- timestamp from CSV
set y to text item 2 of a_reading -- frequency readings from CSV
set z to text item 3 of a_reading -- confidence readings from CSV
set end of freqData to y --frequency readings stored
end repeat
on stddev(readingHz) -- standard deviation handler
set n to count of readingHz
set sum to 0
repeat with val in readingHz -- calculating the mean
set sum to sum + val
end repeat
set mean to sum / n
set sum to 0
repeat with val in readingHz
set sum to sum + (val - mean) ^ 2
end repeat
return (sum / (n - 1)) ^ 0.5
end stddev
stddev({61.05, 67.23, 71.23, 70, 65.84, 60.49}) -- pretend this is the freqData data
--> 4.466536316506
set sD to the result