打印
[经验分享]

PWM 正弦波调制音频 - 算法分析

[复制链接]
27|0
手机看帖
扫描二维码
随时随地手机跟帖
跳转到指定楼层
楼主
设计概览
电话语音信号频率范围是:300Hz ~ 3400Hz。

基本思路
基频:18 KHz
18KHz 导致个别人群耳鸣,放弃

试音范围: 165 - 2637 Hz(调制 三角波 11等分)

基频:20 KHz
试音范围:131 - 1976 Hz(调制 正弦波 11等分)

定时器重载值:2399

分频系数:0

实际基频:48MHz / 2400 / 1 = 20 KHz

正弦表 [0,741,1410,1940,2281,2399,2281,1940,1410,741,0]

曲线生成



#-- coding: utf-8 --
import matplotlib.pyplot as plt
import math
import numpy as np

def sineMode(A,T,index):
    result = A * math.sin((math.pi / T) * index)
    print(result)
    return int(result)

max = 250
lenth = 10
y0 = []

open("sine.txt","w").write("")
with open('sine.txt', 'a') as f:
    i = 0
    while i <= lenth:
        f.write(str(sineMode(max, lenth, i))+',')
        # if i % 10 == 0:
        #     f.write('\n')
        # if i % 100 == 0:
        #     f.write('\n')               
        i += 1

x = np.linspace(0, lenth,num=lenth+1)
for i in x:
    print(i)
    y0.append(sineMode(max, lenth, i))

plt.figure(1)
plt.title('Sine pic')
plt.plot(x, y0,'*')
plt.legend()
plt.show()





测试中间数据
频率        (20KHz)计数长度
重音部       
131        152
147        136
165        121
175        114
196        102
220        90
247        80
中音部       
262        76
294        68
330        60
349        57
392        51
440        45
494        40
高音部       
523        38
587        34
659        30
698        28
784        25
880        22
988        20
二高音       
1047        19
1175        17
1319        15
1397        14
1568        12
1760        11
1976        10
计算过程



调试过程





————————————————

                            版权声明:本文为博主原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。

原文链接:https://blog.csdn.net/chendu103/article/details/106711399

使用特权

评论回复
发新帖 我要提问
您需要登录后才可以回帖 登录 | 注册

本版积分规则

32

主题

112

帖子

0

粉丝