音频录入后以不同采样率输出

  • 自行录制一段语音,并存储为wav文件

  • 存储为wav文件时,分别以采样频率、2倍采样频率和1/2采样频率存为三个wav文件,

  • 并将plot函数结合subplot函数在一幅图上显示3个波形

  • 横轴和纵轴带有标注。横轴的单位为秒(s),纵轴显示的为归一化后的数值

1.matlab代码
clear all
clc
%初始化
fs=8000;
duration=2;
n=duration*fs;
t=(0:n-1)/fs;

%录音
music=audiorecorder(fs,16,2);
recordblocking(music,2);
MyRecording=getaudiodata(music);

%归一化处理
ymax=max(abs(MyRecording));
y=MyRecording/ymax;
%不同频率存储
audiowrite('01.wav',MyRecording,fs);
audiowrite('02.wav',MyRecording,fs/2);
audiowrite('03.wav',MyRecording,2*fs);
%各个读取,算时间
[y2,fs2]=audioread('02.wav');
[y3,fs3]=audioread('03.wav');
t2=(1:length(y2))/fs2;
t3=(1:length(y3))/fs3;
%绘图
figure
subplot(311);
axis([0 3 -1 1]);M,H
plot(t,MyRecording);
xlabel('时间/s');
ylabel('幅值');
title('初始采样率');

subplot(312);
axis([0 3 -1 1]);
plot(t2,y2);
xlabel('时间/s');
ylabel('幅值');
title('1/2采样率');

subplot(313);
axis([0 3 -1 1]);
plot(t3,y3);
xlabel('时间/s');
ylabel('幅值');
title('2倍采样率');
2.结果显示

在这里插入图片描述

  • 3
    点赞
  • 25
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 6
    评论
评论 6
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

唐维康

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值