finished exercise except for some parts of number 1
This commit is contained in:
1
.direnv/flake-profile
Symbolic link
1
.direnv/flake-profile
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
flake-profile-1-link
|
||||||
1
.direnv/flake-profile-1-link
Symbolic link
1
.direnv/flake-profile-1-link
Symbolic link
@@ -0,0 +1 @@
|
|||||||
|
/nix/store/zcsc63f1ncp6p1nf533q6m35imm42z78-latex-env
|
||||||
BIN
Assignment1_211.pdf
Normal file
BIN
Assignment1_211.pdf
Normal file
Binary file not shown.
@@ -105,7 +105,7 @@
|
|||||||
\begin{minipage}[b][4cm]{1.0\textwidth}
|
\begin{minipage}[b][4cm]{1.0\textwidth}
|
||||||
\begin{center}
|
\begin{center}
|
||||||
\begin{bf}
|
\begin{bf}
|
||||||
\begin{large} Digitale Signalverarbeitung WS 2025/26 -- 1.~Aufgabe\end{large} \\
|
\begin{large} Digitale Signalverarbeitung SS 2025/26 -- 2.~Aufgabe\end{large} \\
|
||||||
\vspace{0.3cm}
|
\vspace{0.3cm}
|
||||||
\begin{Large} Analog Signals and Systems \end{Large} \\
|
\begin{Large} Analog Signals and Systems \end{Large} \\
|
||||||
\vspace{0.3cm}
|
\vspace{0.3cm}
|
||||||
@@ -121,231 +121,115 @@ Quirin Ecker, k12310122 \\
|
|||||||
\noindent \rule[0.8em]{\textwidth}{0.12mm}\\[-0.5em]
|
\noindent \rule[0.8em]{\textwidth}{0.12mm}\\[-0.5em]
|
||||||
%=======================================================================================
|
%=======================================================================================
|
||||||
|
|
||||||
|
\begin{aufgabe}
|
||||||
|
|
||||||
\begin{aufgabe}{}
|
|
||||||
|
|
||||||
\begin{align*}
|
|
||||||
c_1 &= -5 + 3j
|
|
||||||
= \sqrt{(-5)^2 + 3^2}\, e^{j \arctan\left(\frac{3}{-5}\right)}
|
|
||||||
= \sqrt{34}\, e^{-j\,0.54} \\
|
|
||||||
\end{align*}
|
|
||||||
|
|
||||||
\begin{align*}
|
|
||||||
c_2 &= \frac{\sqrt{2}}{2} e^{-j \frac{3\pi}{4}}
|
|
||||||
= \frac{\sqrt{2}}{2} \cos\left(-\frac{3\pi}{4}\right)
|
|
||||||
+ j \frac{\sqrt{2}}{2} \sin\left(-\frac{3\pi}{4}\right)
|
|
||||||
= -\frac{1}{2} - \frac{1}{2}j \\
|
|
||||||
\end{align*}
|
|
||||||
|
|
||||||
\begin{align*}
|
|
||||||
c_3 &= \frac{1}{\sqrt{2}} + \frac{1}{\sqrt{2}}j
|
|
||||||
= \sqrt{\left(\frac{1}{\sqrt{2}}\right)^2 + \left(\frac{1}{\sqrt{2}}\right)^2}
|
|
||||||
\, e^{j \arctan\left(\frac{\frac{1}{\sqrt{2}}}{\frac{1}{\sqrt{2}}}\right)}
|
|
||||||
= e^{j \frac{\pi}{4}} \\
|
|
||||||
\end{align*}
|
|
||||||
|
|
||||||
\begin{align*}
|
|
||||||
c_4 &= c_1 + c_2
|
|
||||||
= (-5 + 3j) + \left(-\frac{1}{2} - \frac{1}{2}j\right)
|
|
||||||
= -\frac{11}{2} + \frac{5}{2}j \\
|
|
||||||
\end{align*}
|
|
||||||
|
|
||||||
\begin{align*}
|
|
||||||
c_5 &= c_1 \cdot c_2
|
|
||||||
= \left(\sqrt{34}\, e^{-j\,0.54}\right)\left(\frac{\sqrt{2}}{2} e^{-j \frac{3 \pi}{4}}\right)
|
|
||||||
\approx \sqrt{17} e^{-j\,2.8961} \\
|
|
||||||
\end{align*}
|
|
||||||
|
|
||||||
\begin{align*}
|
|
||||||
c_6 &= |c_3|^2
|
|
||||||
= \left(\sqrt{\left(\frac{1}{\sqrt{2}}\right)^2 + \left(\frac{1}{\sqrt{2}}\right)^2}\right)^2
|
|
||||||
= 1 \\
|
|
||||||
\end{align*}
|
|
||||||
|
|
||||||
\begin{align*}
|
|
||||||
c_7 &= \arg(c_3) = \frac{\pi}{4} \\
|
|
||||||
\end{align*}
|
|
||||||
|
|
||||||
\begin{align*}
|
|
||||||
c_8 &= \frac{c_1}{c_2}
|
|
||||||
= \frac{-5 + 3j}{-\frac{1}{2} - \frac{1}{2}j}
|
|
||||||
\cdot \frac{-\frac{1}{2} + \frac{1}{2}j}{-\frac{1}{2} + \frac{1}{2}j} \\
|
|
||||||
&= \frac{(-5)(-\frac{1}{2}) + 3(-\frac{1}{2}) + j\left(3(-\frac{1}{2}) - (-5)(-\frac{1}{2})\right)}{\left(-\frac{1}{2}\right)^2 + \left(-\frac{1}{2}\right)^2} \\
|
|
||||||
&= 2 - 8j \\
|
|
||||||
\end{align*}
|
|
||||||
|
|
||||||
\begin{align*}
|
|
||||||
c_9 &= c_1 \cdot c_1^*
|
|
||||||
= \sqrt{34}\, e^{-j\,0.54} \cdot \sqrt{34}\, e^{j\,0.54}
|
|
||||||
= 34
|
|
||||||
\end{align*}
|
|
||||||
\end{aufgabe}
|
|
||||||
|
|
||||||
\begin{aufgabe}{}
|
|
||||||
|
|
||||||
|
|
||||||
\[
|
|
||||||
x(t) = \hat{X} \cos(2\pi f_0 t) \xleftrightarrow{} \iff X(f) = \frac{\hat{X}}{2} \delta(f - f_0) + \frac{\hat{X}}{2} \delta(f + f_0) \\
|
|
||||||
\]
|
|
||||||
|
|
||||||
\[
|
|
||||||
x(t) = \hat{X}( \frac{1}{2} \cdot e^{j2\pi f_0 t} + \frac{1}{2} \cdot e^{-j2\pi f_0 t} )
|
|
||||||
\]
|
|
||||||
|
|
||||||
\[
|
|
||||||
X(f) = \hat{X}( \frac{1}{2} \cdot \delta (f-f_0) + \frac{1}{2} \cdot \delta (f+f_0) )
|
|
||||||
\]
|
|
||||||
|
|
||||||
\[
|
|
||||||
X(f) = \frac{\hat{X}}{2} \cdot \delta (f-f_0) + \frac{\hat{X}}{2} \cdot \delta (f+f_0)
|
|
||||||
\]
|
|
||||||
|
|
||||||
\begin{center}
|
|
||||||
\includegraphics[width=0.95\textwidth]{fig/aufgabe2.png}
|
|
||||||
\end{center}
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
\end{aufgabe}
|
|
||||||
|
|
||||||
\begin{aufgabe}{}
|
|
||||||
|
|
||||||
\begin{enumerate}
|
\begin{enumerate}
|
||||||
\item
|
\item add back in
|
||||||
\[
|
\item add back in
|
||||||
\sin\left(2\pi f_i (t - 0.1)\right) = \sin\left(2\pi f_i t + \phi_i\right)
|
\item add back in
|
||||||
\]
|
\item add back in
|
||||||
|
\item (see assignment2\_1.m)
|
||||||
\[
|
\item table:
|
||||||
2\pi f_i (t - 0.1) = 2\pi f_i t + \phi_i
|
\begin{table}[h]
|
||||||
\]
|
\centering
|
||||||
|
\begin{tabular}{|c|c|c|}
|
||||||
\[
|
\hline
|
||||||
2\pi f_i (t - 0.1) - 2\pi f_i t = \phi_i
|
Signal & Energy & Power \\
|
||||||
\]
|
\hline
|
||||||
|
$x_1[n]$ & 37 & -- \\
|
||||||
\[
|
$x_2[n]$ & 48.0394 & -- \\
|
||||||
2\pi f_i \big((t - 0.1) - t\big) = \phi_i
|
$x_3[n]$ & 1152 & 4.4825 \\
|
||||||
\]
|
$x_4[n]$ & 128.9565 & -- \\
|
||||||
|
\hline
|
||||||
\[
|
\end{tabular}
|
||||||
\phi_i = 2\pi f_i (-0.1) = -0.1 \cdot 2\pi f_i
|
\caption{Energy and Power Values}
|
||||||
\]
|
\label{tab:energy_power}
|
||||||
|
\end{table}
|
||||||
The fourier transform shift theorem states $x(t - T) \;\longleftrightarrow\; X(f)\, e^{-j 2\pi f T}$, where the angle is $2\pi fT$ and $T = 0.1$ in this case. Combining everything, we get $-0.1 \cdot 2\pi f_i$ which is equivalent to the result we got.
|
|
||||||
|
|
||||||
\item Figures:
|
|
||||||
\begin{center}
|
|
||||||
\includegraphics[width=0.95\textwidth]{fig/aufgabe3_1.png}
|
|
||||||
\includegraphics[width=0.95\textwidth]{fig/aufgabe3_2.png}
|
|
||||||
\end{center}
|
|
||||||
\end{enumerate}
|
\end{enumerate}
|
||||||
|
|
||||||
\end{aufgabe}
|
\end{aufgabe}
|
||||||
|
|
||||||
|
|
||||||
\begin{aufgabe}{}
|
|
||||||
|
|
||||||
\begin{itemize}
|
|
||||||
\item $y(t) = (x(t))^2$
|
|
||||||
|
|
||||||
\[
|
|
||||||
y(t) = (x(t))^2
|
|
||||||
\]
|
|
||||||
|
|
||||||
\[
|
|
||||||
y_1(t) = (\alpha x_1(t))^2 + (\beta x_2(t))^2
|
|
||||||
\]
|
|
||||||
|
|
||||||
\[
|
|
||||||
= \alpha^2 (x_1(t))^2 + \beta^2 (x_2(t))^2
|
|
||||||
\]
|
|
||||||
|
|
||||||
\[
|
|
||||||
y_2(t) = \alpha (x_1(t))^2 + \beta (x_2(t))^2
|
|
||||||
\]
|
|
||||||
|
|
||||||
\[
|
|
||||||
y_1(t) \ne y_2(t)
|
|
||||||
\]
|
|
||||||
|
|
||||||
\[
|
|
||||||
\implies \text{Not linear}
|
|
||||||
\]
|
|
||||||
|
|
||||||
|
|
||||||
\[
|
|
||||||
y_1(t) &= \left(x(t - \Delta)\right)^2 \\
|
|
||||||
\]
|
|
||||||
|
|
||||||
\[
|
|
||||||
y_2(t) &= y_1(t - \Delta) = \left(x(t - \Delta)\right)^2 \\
|
|
||||||
\]
|
|
||||||
|
|
||||||
\[
|
|
||||||
y_1 &= y_2 \\
|
|
||||||
\]
|
|
||||||
|
|
||||||
\[
|
|
||||||
\implies \text{Time invariant}
|
|
||||||
\]
|
|
||||||
\item $y(t) = x(t) sin(\Omega_0 t)$
|
|
||||||
|
|
||||||
\[
|
|
||||||
y(t) &= x(t) \sin(\Omega_0 t) \\
|
|
||||||
\]
|
|
||||||
|
|
||||||
\[
|
|
||||||
y_1(t) &= \left( \alpha \, x(t) \sin(\Omega_0 t) \right) + \left( \beta \, x(t) \sin(\Omega_0 t) \right) \\
|
|
||||||
\]
|
|
||||||
|
|
||||||
\[
|
|
||||||
y_t(t) &= \alpha \left( x(t) \sin(\Omega_0 t) \right) + \beta \left( x(t) \sin(\Omega_0 t) \right) \\
|
|
||||||
\]
|
|
||||||
|
|
||||||
\[
|
|
||||||
y_1 &= y_2
|
|
||||||
\]
|
|
||||||
|
|
||||||
\[
|
|
||||||
\implies \text{linear}
|
|
||||||
\]
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
\[
|
|
||||||
y_1(t) = &\coloneqq x(t - \Delta) \sin(\Omega_0 t - \Delta) \\
|
|
||||||
\]
|
|
||||||
|
|
||||||
\[
|
|
||||||
y_2(t) &= y_1(t - \Delta) = x(t - \Delta) \sin(\Omega_0 t - \Delta) \\
|
|
||||||
\]
|
|
||||||
|
|
||||||
\[
|
|
||||||
y_1 &= y_2 \\
|
|
||||||
\]
|
|
||||||
|
|
||||||
\[
|
|
||||||
\implies \text{Time invariant}
|
|
||||||
\]
|
|
||||||
\end{itemize}
|
|
||||||
|
|
||||||
\end{aufgabe}
|
|
||||||
|
|
||||||
\begin{aufgabe}
|
\begin{aufgabe}
|
||||||
|
|
||||||
\begin{enumerate}
|
\begin{enumerate}
|
||||||
\item System A is linear because there is no difference between the plot $T [x_1(t) + x_2(t)]$ and $T [x_1(t)] + T [x_2(t)]$.
|
\item $|x[n]| + |h[n]| - 1 = 5 + 4 - 1 = 8$
|
||||||
You can also see in the error plot that the error is small.
|
\item
|
||||||
It is not exactyly zero becuase rounding errors.
|
\begin{gather*}
|
||||||
\item Input and output are not proportional in a non linear system and
|
|
||||||
therefore the error change is greater than the one of the linear system
|
A=
|
||||||
\item The output sound of System B does differ when comparing $T [x_1(t) + x_2(t)]$ and $T [x_1(t)] + T [x_2(t)]$.
|
\begin{bmatrix}
|
||||||
But is the same when using System A. This matches the differences in the graphs.
|
3 & 0 & 0 & 0\\
|
||||||
|
-1 & 3 & 0 & 0\\
|
||||||
|
2 & -1 & 3 & 0\\
|
||||||
|
0 & 2 & -1 & 3\\
|
||||||
|
1 & 0 & 2 & -1\\
|
||||||
|
0 & 1 & 0 & 2\\
|
||||||
|
0 & 0 & 1 & 0\\
|
||||||
|
0 & 0 & 0 & 1
|
||||||
|
\end{bmatrix},
|
||||||
|
\qquad
|
||||||
|
x=
|
||||||
|
\begin{bmatrix}
|
||||||
|
2\\
|
||||||
|
3\\
|
||||||
|
4\\
|
||||||
|
1
|
||||||
|
\end{bmatrix}
|
||||||
|
|
||||||
|
Ax=
|
||||||
|
\begin{bmatrix}
|
||||||
|
6\\
|
||||||
|
7\\
|
||||||
|
13\\
|
||||||
|
5\\
|
||||||
|
9\\
|
||||||
|
5\\
|
||||||
|
4\\
|
||||||
|
1
|
||||||
|
\end{bmatrix}
|
||||||
|
\end{gather*}
|
||||||
\end{enumerate}
|
\end{enumerate}
|
||||||
|
|
||||||
|
\end{aufgabe}
|
||||||
|
|
||||||
|
\begin{aufgabe}
|
||||||
|
|
||||||
|
\begin{enumerate}
|
||||||
|
\item $L_y = |x[n]| + |h[n]| - 1 = 50 + 3 - 1 = 52$
|
||||||
|
\item (see assignment2\_3.m)
|
||||||
|
\item see d)
|
||||||
|
\item figure: \\
|
||||||
|
\includegraphics[width=0.95\textwidth]{fig/aufgabe3_cd.png}
|
||||||
|
\end{enumerate}
|
||||||
|
|
||||||
|
\end{aufgabe}
|
||||||
|
|
||||||
|
\begin{aufgabe}
|
||||||
|
|
||||||
|
\begin{enumerate}
|
||||||
|
\item (see assignment2\_4.m)
|
||||||
|
\item Phase Response is very small in the realm of $10^{-15}$. The signal contians multiple bigger spikes. \\
|
||||||
|
\includegraphics[width=0.95\textwidth]{fig/aufgabe4_b.png}
|
||||||
|
\item The magnitued seems to be repeating and the phase response seems to be mirrored accross the x and y axis.
|
||||||
|
\end{enumerate}
|
||||||
|
|
||||||
|
\end{aufgabe}
|
||||||
|
|
||||||
|
|
||||||
|
\begin{aufgabe}
|
||||||
|
|
||||||
|
\begin{enumerate}
|
||||||
|
\item (siehe assignment2\_5.m)
|
||||||
|
\item (siehe assignment2\_5.m)
|
||||||
|
\item figure: \\
|
||||||
|
\includegraphics[width=0.95\textwidth]{fig/aufgabe5_c.png}
|
||||||
|
\item original energy: 41343 \\ reverb energy: 2069.0506 \\ rir energy: $9.9997 \cdot 10^{3}$ \\
|
||||||
|
explanation: The rir energy is less than one which would explain why the outcoming signal is smaller than the original, because convulution scales proportionally.
|
||||||
|
\end{enumerate}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
\end{aufgabe}
|
\end{aufgabe}
|
||||||
|
|
||||||
\end{document}
|
\end{document}
|
||||||
|
|||||||
62
Assignment2_211/assignment2_1.m
Normal file
62
Assignment2_211/assignment2_1.m
Normal file
@@ -0,0 +1,62 @@
|
|||||||
|
clear
|
||||||
|
close all
|
||||||
|
clc
|
||||||
|
|
||||||
|
% x1[n], -5 <= n <= 10
|
||||||
|
n1 = -5:10;
|
||||||
|
x1 = -4*(n1 == -3) + 4*(n1 == 0) - (n1 == 3) + 2*(n1 == 7);
|
||||||
|
|
||||||
|
% x2[n], -5 <= n <= 10
|
||||||
|
n2 = -5:10;
|
||||||
|
x2 = exp(-0.31*n2);
|
||||||
|
|
||||||
|
% x3[n], 0 <= n <= 256
|
||||||
|
n3 = 0:256;
|
||||||
|
x3 = 3*sin(2*pi*(3.5/64)*n3);
|
||||||
|
|
||||||
|
% x4[n], 0 <= n <= 256
|
||||||
|
n4 = 0:256;
|
||||||
|
x4 = -cos((9/64)*n4);
|
||||||
|
|
||||||
|
|
||||||
|
% Visualization
|
||||||
|
figure;
|
||||||
|
subplot(121); hold on; grid on;
|
||||||
|
stem(n1, x1);
|
||||||
|
stem(n2, x2);
|
||||||
|
xlabel('n');
|
||||||
|
ylabel('x[n]');
|
||||||
|
legend('x_1[n]', 'x_2[n]');
|
||||||
|
|
||||||
|
subplot(122); hold on; grid on;
|
||||||
|
plot(n3, x3);
|
||||||
|
plot(n4, x4);
|
||||||
|
xlabel('n');
|
||||||
|
ylabel('x[n]');
|
||||||
|
legend('x_3[n]', 'x_4[n]');
|
||||||
|
|
||||||
|
% Custom power function
|
||||||
|
function [ P ] = custom_power( x )
|
||||||
|
P = (1/length(x)) * sum(abs(x).^2);
|
||||||
|
end
|
||||||
|
|
||||||
|
% Calculate and display the power
|
||||||
|
P3 = custom_power(x3);
|
||||||
|
% Display the calculated powers
|
||||||
|
disp(['Power of x_3[n]: ', num2str(P3)]);
|
||||||
|
|
||||||
|
% Energy function
|
||||||
|
function [ W ] = energy( x )
|
||||||
|
W = sum(abs(x).^2);
|
||||||
|
end
|
||||||
|
|
||||||
|
% Calculate and display the energy of each signal
|
||||||
|
P1 = energy(x1);
|
||||||
|
P2 = energy(x2);
|
||||||
|
P3 = energy(x3);
|
||||||
|
P4 = energy(x4);
|
||||||
|
% Display the calculated powers
|
||||||
|
disp(['Energy of x_1[n]: ', num2str(P1)]);
|
||||||
|
disp(['Energy of x_2[n]: ', num2str(P2)]);
|
||||||
|
disp(['Energy of x_3[n]: ', num2str(P3)]);
|
||||||
|
disp(['Energy of x_4[n]: ', num2str(P4)]);
|
||||||
39
Assignment2_211/assignment2_3.m
Normal file
39
Assignment2_211/assignment2_3.m
Normal file
@@ -0,0 +1,39 @@
|
|||||||
|
clear
|
||||||
|
close all
|
||||||
|
clc
|
||||||
|
|
||||||
|
|
||||||
|
% Convolution function
|
||||||
|
function [ Y ] = convolution( h, x )
|
||||||
|
Ny = length(x)+length(h)-1
|
||||||
|
Y = zeros(1, Ny);
|
||||||
|
for n = 1:Ny
|
||||||
|
for i = 1:length(h)
|
||||||
|
if (n-i+1 >= 1) && (n-i+1 <= length(x))
|
||||||
|
Y(n) = Y(n) + h(i) * x(n-i+1)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
n = 0:49
|
||||||
|
hn = [0.25, 0.5, 0.25]
|
||||||
|
xn = cos(((2*pi)/20)*n)
|
||||||
|
|
||||||
|
% Perform convolution of xn and hn
|
||||||
|
Y = convolution(hn, xn);
|
||||||
|
Y2 = conv(xn, hn)
|
||||||
|
|
||||||
|
% Plot the results
|
||||||
|
plot(Y);
|
||||||
|
xlabel('Sample Index');
|
||||||
|
ylabel('Amplitude');
|
||||||
|
title('Convolution Result');
|
||||||
|
grid on;
|
||||||
|
|
||||||
|
% Plot Y2 on same graph
|
||||||
|
hold on;
|
||||||
|
plot(Y2, '--');
|
||||||
|
legend('Custom Convolution', 'MATLAB conv Function');
|
||||||
|
hold off;
|
||||||
|
|
||||||
29
Assignment2_211/assignment2_4.m
Normal file
29
Assignment2_211/assignment2_4.m
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
function X = dtft ( x , n , w )
|
||||||
|
% DTFT Computes Discrete-time Fourier transform
|
||||||
|
% @param x : finite duration sequence (vector) over n
|
||||||
|
% @param n : sample indices vector
|
||||||
|
% @param w : frequency vector
|
||||||
|
% @return X : DTFT of x[n] at frequencies w
|
||||||
|
% this function does not use for loops
|
||||||
|
X = sum(x(:) .* exp(-1j * n(:) * w), 1);
|
||||||
|
end
|
||||||
|
|
||||||
|
n = -10:10;
|
||||||
|
x = (0.8) .^ abs(n) .* ((n >= -10) & (n < 11));
|
||||||
|
w = linspace(-pi, pi, 1000);
|
||||||
|
|
||||||
|
X = dtft(x, n, w);
|
||||||
|
|
||||||
|
magnitude = abs(X);
|
||||||
|
phase = angle(X);
|
||||||
|
figure;
|
||||||
|
subplot(2, 1, 1);
|
||||||
|
plot(w, magnitude);
|
||||||
|
title('Magnitude Response');
|
||||||
|
xlabel('Frequency (rad/sample)');
|
||||||
|
ylabel('|X(w)|');
|
||||||
|
subplot(2, 1, 2);
|
||||||
|
plot(w, phase);
|
||||||
|
title('Phase Response');
|
||||||
|
xlabel('Frequency (rad/sample)');
|
||||||
|
ylabel('Phase(rad)');
|
||||||
42
Assignment2_211/assignment2_5.m
Normal file
42
Assignment2_211/assignment2_5.m
Normal file
@@ -0,0 +1,42 @@
|
|||||||
|
% Read and play original audio
|
||||||
|
[audio, fs] = audioread('./audio.wav');
|
||||||
|
%sound(audio, fs);
|
||||||
|
|
||||||
|
% Read and play room impulse response (RIR)
|
||||||
|
[rir, fs_rir] = audioread('./rir.wav');
|
||||||
|
%sound(rir, fs_rir);
|
||||||
|
|
||||||
|
% Apply convolution (reverb effect)
|
||||||
|
audio_reverb = conv(audio, rir);
|
||||||
|
|
||||||
|
%sound(audio_reverb, fs);
|
||||||
|
|
||||||
|
% Plot the waveforms
|
||||||
|
figure;
|
||||||
|
|
||||||
|
% Original audio
|
||||||
|
subplot(2,1,1);
|
||||||
|
plot(audio);
|
||||||
|
title('Original Audio');
|
||||||
|
xlabel('Sample Number');
|
||||||
|
ylabel('Amplitude');
|
||||||
|
|
||||||
|
% Reverberated audio
|
||||||
|
subplot(2,1,2);
|
||||||
|
plot(audio_reverb);
|
||||||
|
title('Audio with Reverb');
|
||||||
|
xlabel('Sample Number');
|
||||||
|
ylabel('Amplitude');
|
||||||
|
|
||||||
|
% Calculate signal energy
|
||||||
|
function [ W ] = energy( x )
|
||||||
|
W = sum(abs(x).^2);
|
||||||
|
end
|
||||||
|
|
||||||
|
energy_rir = energy(rir)
|
||||||
|
energy_original = energy(audio)
|
||||||
|
energy_reverb = energy(audio_reverb)
|
||||||
|
|
||||||
|
% Display energy values
|
||||||
|
fprintf('Original Audio Energy: %.4f\n', energy_original);
|
||||||
|
fprintf('Reverberated Audio Energy: %.4f\n', energy_reverb);
|
||||||
BIN
Assignment2_211/audio.wav
Normal file
BIN
Assignment2_211/audio.wav
Normal file
Binary file not shown.
BIN
Assignment2_211/rir.wav
Normal file
BIN
Assignment2_211/rir.wav
Normal file
Binary file not shown.
BIN
fig/aufgabe3_cd.png
Normal file
BIN
fig/aufgabe3_cd.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 43 KiB |
BIN
fig/aufgabe4_b.png
Normal file
BIN
fig/aufgabe4_b.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 32 KiB |
BIN
fig/aufgabe5_c.png
Normal file
BIN
fig/aufgabe5_c.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 28 KiB |
26
flake.lock
generated
Normal file
26
flake.lock
generated
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
{
|
||||||
|
"nodes": {
|
||||||
|
"nixpkgs": {
|
||||||
|
"locked": {
|
||||||
|
"lastModified": 1778325437,
|
||||||
|
"narHash": "sha256-k2mUy6bm3dUviWmMCqkixBBSwfL9piisGqU41dq61Ns=",
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"rev": "f4f40ee764efd448458bea3ee8b3de51dd2859aa",
|
||||||
|
"type": "github"
|
||||||
|
},
|
||||||
|
"original": {
|
||||||
|
"owner": "NixOS",
|
||||||
|
"repo": "nixpkgs",
|
||||||
|
"type": "github"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": {
|
||||||
|
"inputs": {
|
||||||
|
"nixpkgs": "nixpkgs"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
|
"root": "root",
|
||||||
|
"version": 7
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user