function varargout = DSP_mark(varargin)
% DSP_MARK MATLAB code for DSP_mark.fig
% DSP_MARK, by itself, creates a new DSP_MARK or raises the existing
% singleton*.
%
% H = DSP_MARK returns the handle to a new DSP_MARK or the handle to
% the existing singleton*.
%
% DSP_MARK('CALLBACK',hObject,eventData,handles,...) calls the local
% function named CALLBACK in DSP_MARK.M with the given input arguments.
%
% DSP_MARK('Property','Value',...) creates a new DSP_MARK or raises the
% existing singleton*. Starting from the left, property value pairs are
% applied to the GUI before DSP_mark_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property application
% stop. All inputs are passed to DSP_mark_OpeningFcn via varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help DSP_mark
% Last Modified by GUIDE v2.5 20-Apr-2023 21:46:39
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @DSP_mark_OpeningFcn, ...
'gui_OutputFcn', @DSP_mark_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
% --- Executes just before DSP_mark is made visible.
function DSP_mark_OpeningFcn(hObject,handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to DSP_mark (see VARARGIN)
% Choose default command line output for DSP_mark
handles.output = hObject;
handles.axes1 = findobj(gcf, 'Tag', 'axes1');
handles.axes2 = findobj(gcf, 'Tag', 'axes2');
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes DSP_mark wait for user response (see UIRESUME)
% uiwait(handles.figure1);
% --- Outputs from this function are returned to the command line.
function varargout = DSP_mark_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDA)
%--------------------------读取原始音频-------------------------%
cla reset;
FILE1='Rihanna - Take A Bow.wav';
[y,Fs]=audioread(FILE1);%音频信号y,采样率fs,采样精度bits
y_fft=fft(y,Fs);
% y_fft_f=2*sqrt(y_fft.*conj(y_fft));
axes(handles.axes1);
plot(y);
grid on;axis tight;
title('原始音频信号的时域波形');
xlabel('time(s)');ylabel('幅度');
axes(handles.axes2);
plot(abs(y_fft));
grid on;axis tight;
title('原始音频信号的频域波形');
xlabel('f(Hz)');ylabel('幅度');
player = audioplayer(y, Fs);
play(player);%播放原始语音
% --- Executes on button press in pushbutton2.
function pushbutton2_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%--------------------------读取水印音频-------------------------%
cla reset;
FILE1='Rihanna - Take A Bow.wav';
[y,~]=audioread(FILE1);%音频信号y,采样率fs,采样精度bits
%用db4小波对原始音频信号进行3级小波分解
y = y(:); % 将矩阵转换为列向量
[c,l]=wavedec(y,3,'db4');%3级小波分解,低频部分为相似,高频部分为细节
%提取3级小波分解的低频系数和高频系数
ca3=appcoef(c,l,'db4',3);%提取三级小波分解的最低频分
%cd3=detcoef(c,l,3);%提取三级小波分解的次低频分
%cd2=detcoef(c,l,2);
%cd1=detcoef(c,l,1);
x=ca3;%提取三级小波分解的最低频部分
%找到插入位置,检测特征点
s=max(abs(x))*0.2;
i= abs(x)>s;
lx=length(x(i));
%读取水印音频
FILE2='test_new.wav';
[mark,Fs]=audioread(FILE2);
mark=mark(1:lx);
mark_fft=fft(mark);
% mark_fft_f=2*sqrt(mark_fft.*conj(mark_fft));
axes(handles.axes1);
plot(mark);
grid on;axis tight;
title('水印音频信号的时域波形');
xlabel('time(s)');ylabel('幅度');
axes(handles.axes2)
plot(abs(mark_fft));
grid on;axis tight;
title('水印音频信号的频域波形');
xlabel('f(Hz)');ylabel('幅度');
sound(mark,Fs);
% --- Executes on button press in pushbutton3.
function pushbutton3_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%--------------------------水印嵌入-------------------------%
cla reset;
FILE1='Rihanna - Take A Bow.wav';
[y,~]=audioread(FILE1);%音频信号y,采样率fs,采样精度bits
%用db4小波对原始音频信号进行3级小波分解
y = y(:); % 将矩阵转换为列向量
[c,l]=wavedec(y,3,'db4');%3级小波分解,低频部分为相似,高频部分为细节
%提取3级小波分解的低频系数和高频系数
ca3=appcoef(c,l,'db4',3);%提取三级小波分解的最低频分
cd3=detcoef(c,l,3);%提取三级小波分解的次低频分
cd2=detcoef(c,l,2);
cd1=detcoef(c,l,1);
x=ca3;%提取三级小波分解的最低频部分
%找到插入位置,检测特征点
s=max(abs(x))*0.2;
i=find(abs(x)>s);
lx=length(x(i));
%读取水印音频
FILE2='test_new.wav';
[mark,Fs]=audioread(FILE2);
mark=mark(1:lx);
%水印信号嵌入
ss=mark(1:lx);
rr=ss*0.02;
x(i)=x(i).*(1+rr');
%小波重构,生成加入了水印信号的音频信号
c1=[x',cd3',cd2',cd1'];
s1=waverec(c1,l,'db4');
%把加入了水印的原始音频信号作为final1.wav保存
FILE3='final1.wav';
% 归一化音频数据
s1 = s1 / max(abs(s1));
audiowrite(FILE3,s1,Fs,'BitsPerSample',16,...
'Comment','This is my new audio file.');
[y1,Fs]=audioread(FILE3);
y1_fft=fft(y1,Fs);
% y1_fft_f=2*sqrt(y1_fft.*conj(y1_fft));
axes(handles.axes1);
plot(y1);
grid on;axis tight;
title('嵌入水印后的原始音频信号的时域波形');
xlabel('time(s)');ylabel('幅度');
axes(handles.axes2);
plot(abs(y1_fft));
grid on;axis tight;
title('嵌入水印后的原始音频信号的频域波形');
xlabel('f(Hz)');ylabel('幅度');
ly1=length(y1);
y1=y1(1:0.5*ly1);
sound(y1,Fs);
% --- Executes on button press in pushbutton4.
matlab
function pushbutton4_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
%--------------------------水印提取-------------------------%
cla reset;
FILE1='Rihanna - Take A Bow.wav';
[y,~]=audioread(FILE1);%音频信号y,采样率fs,采样精度bits
%用db4小波对原始音频信号进行3级小波分解
y = y(:); % 将矩阵转换为列向量
[c,l]=wavedec(y,3,'db4');%3级小波分解,低频部分为相似,高频部分为细节
%提取3级小波分解的低频系数和高频系数
ca3=appcoef(c,l,'db4',3);%提取三级小波分解的最低频分
%cd3=detcoef(c,l,3);%提取三级小波分解的次低频分
%cd2=detcoef(c,l,2);
%cd1=detcoef(c,l,1);
x=ca3;%提取三级小波分解的最低频部分
%找到插入位置,检测特征点
s=max(abs(x))*0.2;
i=find(abs(x)>s);
%lx=length(i);
%读取含有水印的原始音频
FILE3='final1.wav';
[y1,Fs]=audioread(FILE3);
%用db4小波对含有水印的原始音频信号进行3级小波分解
[c1,l1]=wavedec(y1,3,'db4');
%提取3级小波分解的低频系数和高频系数
ca31=appcoef(c1,l1,'db4',3);
%cd31=detcoef(c1,l1,3);
%cd21=detcoef(c1,l1,2);
%cd11=detcoef(c1,l1,1);
x1=ca31;
%水印信号提取
z(i)=x1(i)-x(i);
s2=z(i)./x(i)';
s2=s2/0.02;
%把提取的水印信号作为final2.wav保存
FILE4='final2.wav';
% 归一化
![avatar](https://profile-avatar.csdnimg.cn/default.jpg!1)
普通网友
- 粉丝: 1124
- 资源: 5294
最新资源
- RHEL9环境下Python和PHP的安装及应用指南
- 基于OpenCV与Python的车道线智能检测系统:从图像预处理到UI界面的实现,基于OpenCV与Python的车道线智能检测系统(带UI界面):从图像预处理到霍夫直线检测与拟合的自动驾驶核心技术解
- FMETP STREAM EditionS
- 【大作业-36】基于yolov8和yolo11的绝缘子缺陷检测系统.zip
- 基于LSTM的时间序列预测模型:单输入单输出预测,数据存入Excel,性能评估指标包括决定系数R2、平均绝对误差MAE及平均相对误差MBE的详解代码,基于LSTM的时间序列预测模型:单输入单输出预测
- 清华大学第四弹-deepseek+Research让科研像聊天一样简单
- 使用Android手机的摄像头,通过闪光灯识别手指的血管,完成心率的检测,绘制出心率图
- 基于随机森林算法RF的数据分类预测详解:从代码注释到Excel数据存储的全面指南,基于随机森林算法RF的数据分类预测详解:从代码注释到Excel数据存储之道,基于随机森林算法RF的数据分类预测 代码含
- 呼气式酒精检测仪压力传感器US9411规格书V6.0:参数特性、应用领域及订购指南
- coreutils+wget.zip
- Nginx 服务器安装及配置文件详解.docx
- 资源-网络工程师知识点
- CCNA课件14节课程,pdf课件
- 《免费模电-Multisim电路仿真大合集(120例)-电子类专业实验/毕设实战资源库》
- stm32f103c8
- SDN 架构图.jpg
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback](https://img-home.csdnimg.cn/images/20220527035711.png)
![feedback-tip](https://img-home.csdnimg.cn/images/20220527035111.png)