Digital Signal Processing - Part 1/6
Check it out here: Github
In this blog we will cover the following concepts:
To understand the difference between Analog and digital transmission, we understand how digital and analog signals are stored, while analog signals are continuous, digital signals can be represented discretely using integers. Analog signals are therefore bulkier, digitally speaking. A wav file for example can start from 100MB to up to 2GB of space. Usually, vinyl records are used to store them. But analog signals cannot be readily processed. To solve this problem, sampling theorem was used.
Sampling theorem allows us to convert continuous signals to discrete digital signals. This theorem states that under very mild conditions the relationship between a continuous time representation of a signal and its discrete time counterpart is given by the formula:
To sample a signal, we take samples or measure values at equidistant times to create a discrete time signal. Once the signal is converted into discrete time signals, we can easily represent it using integers. Since the representation of signals change to integers, we can change the way they are handled in essence, we make it easier for computers to process these signals therefore making it easier to apply operations on these signals therefore the term Digital signal processing. Though noise is still added on top of signals during
transmission we can have amplifiers that can work on the reduction of the noise. But we know that if the signal is greater than 0, we can use thresholder and we can reproduce the same signal.
Let’s imagine a situation where 5V is Digital signal HIGH and 0V is Digital signal LOW, then there can be either 2 parameters in essence, LOW or HIGH. If we send this signal through the transatlantic cable, at the end we might receive a distorted signal i.e.
LOW ∈ [-N, N]
Here N is the noise added to the signal
Procedure and Prerequisites
Equation of Attenuation
We consider the case of transmission over a long cable in which several repeaters are used to compensate for the attenuation. As seen earlier there can be either LOW or HIGH type of signals in digital signals. Therefore, the threshold signal after each repeater is considered and we virtually eliminate the noise at each stage.
A basic knowledge of python is required with basic knowledge of ipython notebooks, matplotlib and numpy as well as Scipy.
1. We start by importing the required libraries.
2. We visualise the audio file (Speech.wav) using matplotlib
3. Two versions of the signal were created, analog and digital
a. One would argue that a digital analog file is already in the digital format.
b. To solve this, we have approximated the value of the digital format to be 201 integers that is 8bits audio sample.
c. The signal is scaled between -100 and +100.
d. The output shown below:
e. Notice that the values at the y axis have changed from -100 to 100
f. We find the error in conversion; this is the price to pay for the digital conversion. We can plot the error by taking the difference in analog audio (Also Normalised to -100 and 100) and digital audio.
g. This value is less than [-0.5, 0.5]
4. Now we find out the SNR. To find the SNR, we supply to a function the noisy audio and the noise free audio or the original audio.
a. The error is calculated based on numpy operations, we normalise the difference between original and noisy signal.
b. The original signal is also converted to numpy.
c. The difference is put into the logarithmic formula
d. Finally, we print the result.
5. We find the SNR for the converted signal and the analog signal to be 17.124344dB
6. We can also hear that difference.
7. We now repeat this process n times to find the attenuation of the signal and the SNR after transmitting through the transatlantic network.
8. We design the function that adds noise and attenuation for the same.
9. This is then sent to a function that does the same for an analog and a digital function.
10. We then run the functions to find out the difference in audio degradation and the SNR.
11. We find the SNR for the analog transmission has changed to 8.754dB while the SNR for the digital transmission remains the same.
12. This result can also be heard in the output wav files.
13. However, if the Noise amplitude is extremely high the digital signal degrades even less gracefully than analog. We supply noise of 0.3 amplitude to the functions.
14. Here the degradation is worse for the digital signal than the analog signal.
We have therefore found out and learnt on python how the Signal transmission might help with a digital audio over analog values.