题目:
    对所给音频信号,进行时域压缩和扩展,画出时域波形与幅度谱,使其满足以下要求。
    1、将music1.wav的音调变低a倍(0.82、将music2.wav的音调变化到与儿童和男声相似的声音,分析变换前后的10%带宽的变化情况(变宽或变窄多少)。(变化情况手写)

    (1) 原音频、音调降低、音调升高的时域波形分别如图3.1、图3.2、图3.3所示,频域波形分别如图3.4、 图3.5、图3.6所示,分析前后的10%带宽(最大值10%处的带宽)的变化情况如图3_1所示。

    1. [Origin_Wav, fs] = audioread('C:\Users\yang\Desktop\matlab\music1.wav'); %读取音频文件信息
    2. % sound(Origin_Wav);
    3. N = 62500;
    4. f=(-N/2:N/2-1)/N*fs; %自变量,fs采样频率
    5. Origin_Dt = 1/length(Origin_Wav);
    6. Origin_t = (0:Origin_Dt:1-Origin_Dt);
    7. figure;
    8. plot(Origin_t,Origin_Wav);
    9. title('源音频时域图');%绘制时域图
    10. Origin_X = fftshift(fft(Origin_Wav,N)); %傅里叶变换
    11. Origin_AMP = abs(Origin_X); %得频域点
    12. figure;
    13. plot(f,Origin_AMP);title('源音频频谱图'); %绘制幅频图
    14. Max_Origin_AMP = max(Origin_AMP); %求频谱最大值
    15. TenPer_Max_Origin_AMP = 0.1 * Max_Origin_AMP;
    16. hold on;
    17. plot([f(1) f(length(f))],[TenPer_Max_Origin_AMP TenPer_Max_Origin_AMP],'r-');
    18. Low_Wav = resample(Origin_Wav,10,9); %时域扩展
    19. Low_Dt = 1/length(Low_Wav);
    20. Low_t = (0:Low_Dt:1-Low_Dt);
    21. figure;
    22. plot(Low_t,Low_Wav);title('时域扩展图');%绘制时域图
    23. Low_X = fftshift(fft(Low_Wav,N)); %傅里叶变换
    24. Low_AMP = abs(Low_X); %得频域点
    25. figure;
    26. plot(f,Low_AMP);title('时域扩展幅频图');%绘制幅频图
    27. Max_Low_AMP = max(Low_AMP); %求频谱最大值
    28. TenPer_Max_Low_AMP = 0.1 * Max_Low_AMP;
    29. hold on;
    30. plot([f(1) f(length(f))],[TenPer_Max_Low_AMP TenPer_Max_Low_AMP],'r-');
    31. High_Wav = resample(Origin_Wav,10,12); %时域压缩
    32. High_Dt = 1/length(High_Wav);
    33. High_t = (0:High_Dt:1-High_Dt);
    34. figure;
    35. plot(High_t,High_Wav);title('时域压缩图');%绘制时域图
    36. High_X = fftshift(fft(High_Wav,N)); %傅里叶变换
    37. High_AMP = abs(High_X); %得频域点
    38. figure;
    39. plot(f,High_AMP);title('时域压缩幅频图');%绘制幅频图
    40. Max_High_AMP = max(High_AMP); %求频谱最大值
    41. TenPer_Max_High_AMP = 0.1 * Max_High_AMP;
    42. hold on;
    43. plot([f(1) f(length(f))],[TenPer_Max_High_AMP TenPer_Max_High_AMP],'r-');

    image.pngimage.pngimage.png
    图3.1 原音频时域图 图3.2 音调降低后时域图 图3.3 音调升高后时域图
    image.pngimage.pngimage.png 图3.4 原音频频谱图图 3.5 音调降低后频谱图 图3.6 音调升高后频谱图


    image.png
    图3_1 变换前后10%带宽分析
    2、根据时域频域关系的知识,时域扩展1.2倍,频域压缩,原音频变为男声,时域压缩1.4倍时,频域扩 展,原音频变为童声。原音频、变化到男声、变化到童声的时域波形分别如图3.7、图3.8、图3.9所 示,频域波形分别如图3.10、图3.11、图3.12所示, 变换前后的10%带宽(最大值10%处的带宽)的变 化情况如图3_2所示。

    [Origin_Wav, fs] = audioread('C:\Users\yang\Desktop\matlab\music2.wav');  %读取音频文件信息
    sound(Origin_Wav);
    N = 62500;%length(Low_Wav);             %点的数量
    f=(-N/2:N/2-1)/N*fs;                    %自变量,fs采样频率
    Origin_Dt = 1/length(Origin_Wav);
    Origin_t = (0:Origin_Dt:1-Origin_Dt);
    figure;
    plot(Origin_t,Origin_Wav);title('源音频时域图');%绘制时域图
    
    Origin_X = fftshift(fft(Origin_Wav,N));       %傅里叶变换
    Origin_AMP = abs(Origin_X);                   %得频域点
    figure;
    plot(f,Origin_AMP);title('源音频频谱图');     %绘制幅频图
    Max_Origin_AMP = max(Origin_AMP);             %求频谱最大值
    TenPer_Max_Origin_AMP = 0.1 * Max_Origin_AMP; 
    hold on;
    plot([f(1) f(length(f))],[TenPer_Max_Origin_AMP TenPer_Max_Origin_AMP],'r-');
    
    Low_Wav = resample(Origin_Wav,12,10);   %时域扩展
    %sound (Low_Wav,fs);     %播放
    Low_Dt = 1/length(Low_Wav);
    Low_t = (0:Low_Dt:1-Low_Dt);
    figure;
    plot(Low_t,Low_Wav);title('时域扩展图');%绘制时域图
    
    Low_X = fftshift(fft(Low_Wav,N));       %傅里叶变换
    Low_AMP = abs(Low_X);                   %得频域点
    figure;
    plot(f,Low_AMP);title('时域扩展幅频图');%绘制幅频图
    Max_Low_AMP = max(Low_AMP);             %求频谱最大值
    TenPer_Max_Low_AMP = 0.1 * Max_Low_AMP; 
    hold on;
    plot([f(1) f(length(f))],[TenPer_Max_Low_AMP TenPer_Max_Low_AMP],'r-');
    
    High_Wav = resample(Origin_Wav,10,14);  %时域压缩
    %sound(High_Wav,fs);     %播放
    High_Dt = 1/length(High_Wav);
    High_t = (0:High_Dt:1-High_Dt);
    figure;
    plot(High_t,High_Wav);title('时域压缩图');%绘制时域图
    
    High_X = fftshift(fft(High_Wav,N));     %傅里叶变换
    High_AMP = abs(High_X);                 %得频域点
    figure;
    plot(f,High_AMP);title('时域压缩幅频图');%绘制幅频图
    Max_High_AMP = max(High_AMP);           %求频谱最大值
    TenPer_Max_High_AMP = 0.1 * Max_High_AMP;
    hold on;
    plot([f(1) f(length(f))],[TenPer_Max_High_AMP TenPer_Max_High_AMP],'r-');
    
                    ![image.png](https://cdn.nlark.com/yuque/0/2021/png/812258/1617984890852-03d27a08-3560-4864-b2e2-62d7e1d50e42.png#height=107&id=QaIFf&margin=%5Bobject%20Object%5D&name=image.png&originHeight=214&originWidth=329&originalType=binary&size=11610&status=done&style=none&width=164.5)![image.png](https://cdn.nlark.com/yuque/0/2021/png/812258/1617984894295-bd1fb85c-0829-44c5-8f1d-2de48d72966f.png#height=107&id=aHl1E&margin=%5Bobject%20Object%5D&name=image.png&originHeight=214&originWidth=346&originalType=binary&size=12062&status=done&style=none&width=173)![image.png](https://cdn.nlark.com/yuque/0/2021/png/812258/1617984897019-72344423-ff84-43d5-9f14-e960211dd13e.png#height=117&id=l8Nr1&margin=%5Bobject%20Object%5D&name=image.png&originHeight=233&originWidth=331&originalType=binary&size=11286&status=done&style=none&width=165.5)<br />   图3.7 原音频时域图                图3.8 变化到男声时域图图            3.9 变化到童声时域图<br />                    ![image.png](https://cdn.nlark.com/yuque/0/2021/png/812258/1617984901434-c521faed-8c75-4c54-955e-1bf5f5bfd536.png#height=115&id=yz2gJ&margin=%5Bobject%20Object%5D&name=image.png&originHeight=230&originWidth=346&originalType=binary&size=10003&status=done&style=none&width=173)![image.png](https://cdn.nlark.com/yuque/0/2021/png/812258/1617984906517-26663ead-79c7-40bd-982d-80b062f471f5.png#height=113&id=xDqSj&margin=%5Bobject%20Object%5D&name=image.png&originHeight=226&originWidth=336&originalType=binary&size=8625&status=done&style=none&width=168)![image.png](https://cdn.nlark.com/yuque/0/2021/png/812258/1617984910601-2198ae2a-60eb-4a34-82c3-5decd8878d8e.png#height=112&id=ohHbS&margin=%5Bobject%20Object%5D&name=image.png&originHeight=223&originWidth=346&originalType=binary&size=11123&status=done&style=none&width=173)<br />图3.10 原音频频谱图           图3.11 变化到男声频谱图        图3.12 变化到童声频谱图<br />                                        ![image.png](https://cdn.nlark.com/yuque/0/2021/png/812258/1617985149410-b3d7ba89-5c65-4513-aeca-e12cc6e1d543.png#height=225&id=pCgOH&margin=%5Bobject%20Object%5D&name=image.png&originHeight=225&originWidth=473&originalType=binary&size=192877&status=done&style=none&width=473)<br />图3_2 变换前后10%带宽分析<br />