-
Notifications
You must be signed in to change notification settings - Fork 2
/
DolphinAttack
50 lines (34 loc) · 1.08 KB
/
DolphinAttack
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
%% Cleaning Part
clc;
clear all;
close all;
%% Loading Audio/Creating needed vector
[y, Fs] = audioread('napo48.wav');
[b,a]=butter(10, 3000/(Fs/2),'low');
y_filtered = filter(b,a,y);
L = max(size(y));
t = (1:L)'/Fs;
%% Parameter of the AM
% OK GOOOGLE WORKING WITH 20KHz ; 21KHz
f_0 = 21000; %% Frequency of the modulation
a = 1; %% Amplitude
x_m = a*sin(2*pi*f_0*t);
%% Processing the modulation
% x_hf_1 is a simple stereo AM signal (Not the one from the article), doesn't work in my tests
x_hf_1(:,1) =x_m.*y_filtered(:,1);
x_hf_1(:,2) =x_m.*y_filtered(:,2);
%soundsc(x_hf_1, Fs)
% x_hf_2 is the one from the article, works in my tests
x_hf_2(:,1) =(x_m).*y_filtered(:,1)+x_m;
x_hf_2(:,2) =(x_m).*y_filtered(:,2)+x_m;
%soundsc(x_hf_2, Fs)
%% Save the signal in a flat audioformat
hf_norm = x_hf_2/max(x_hf_2(:));
audiowrite('save.flac', hf_norm, Fs,'BitsPerSample',24);
%% Visualisation of spectrum
f_axis = [0:L-1]*Fs/L;
Y = abs(fft(y_filtered(:,1)))./L;
YHF = abs(fft(x_hf_1(:,1)))./L;
plot(f_axis(1:L/2), Y(1:L/2),'color','b')
hold on
plot(f_axis(1:L/2), YHF(1:L/2), 'color','r')