Ae S3 Instructions

Download as pdf or txt
Download as pdf or txt
You are on page 1of 6

Acoustic Engineering seminar project

Bart Bijnens - bart.bijnens@upf.edu


Adriana Modrego - adriana.modrego@upf.edu
Genı́s Plaja - genis.plaja@upf.edu

October 27, 2023

1 Introduction
In this third seminar, we will focus on understanding the importance of sam-
pling frequency and we will take a look at audio compression techniques.

Using the appropriate sampling frequency in audio signals is crucial. As


you already know from theory and also the lab sessions, it determines how
many samples per second we use to represent a digital signal. Therefore,
when trying to capture the details of a fast-changing waveform, if you do
not sample frequently enough, you might miss important details, leading to
a loss of information and a degradation of audio quality.

In technical terms, the sampling frequency is tied to the Nyquist theorem,


which states that to accurately represent a signal, the sampling frequency
must be at least twice the highest frequency present in that signal. So, if you
want to capture frequencies up to 20 kHz (which is roughly the upper limit
of human hearing), you would need a sampling frequency of at least 40 kHz.

Choosing the right sampling frequency is a bit of a balancing act. Higher


sampling frequencies allow for a more accurate representation of the original
signal but also require more data storage and processing power. So, it is im-
portant to carefully evaluate the trade-off between sampling frequency and
resources used to capture the details without keeping unnecessary informa-
tion that might burden your system.

1
Audio compression is a process that reduces the file size of audio files
while trying to maintain most of the original audio quality. This is super
useful for storage and transmission, especially in the world of music stream-
ing and digital media. There are many types of audio compression since
different scenarios might require different types of compression.

2 Topics for Seminar 3


The goal of this seminar is to clearly understand the importance of the sam-
pling frequency and, how audio compression methods work. Therefore to-
day’s seminar consists of:

• Experimenting with the sampling frequency: Let’s try to play around


with the sampling frequency to see what can happen if we do not take
enough care of it.

– Take one or two audio signals, from the ones you have selected in
previous seminars, and load them into a jupyter notebook using
SoundFile. Make sure you print out and verify that you are clear
about the sampling frequency at which this audio file has been
originally sampled. Now do two experiments:
∗ Directly save or reproduce the audio signal, using SoundFile
at a different sampling frequency. Try one higher and one
lower. Standard values for sampling frequencies are {8000,
16000, 22050, 24000, 44100, 48000}Hz. Listen to the result
and explain what happened and why.
∗ Undersample your signal, i.e. remove samples from your au-
dio array to mimic how the audio array would look like if we
had initially sampled it at a lower sampling frequency. Note
that, if your audio is sampled at 44100Hz, and you want to
undersample it to 8000Hz, then the new length of the under-
8000
sampled audio must be X, being X the original length
44100
in samples. Also, you need to remove the samples equiva-
lently. That can be done using an audio processing library or
by NumPy array manipulation. Listen to the result and explain

2
what happened and why. Do you hear any noticeable dif-
ference? Why?

• Audio compression: There are many methods for audio compression.


The most simple one is to reduce the sampling frequency, namely, to re-
duce the amount of information, as we explored in the previous section.
However, is how we operate in real-world applications?

– A codec can be understood as a particular format to store an audio


signal. Probably you are familiar with codecs such as .wav, .mp3,
or .ogg. In this experiment, we will proceed as follows:
∗ Take a .wav file from your sounds (if you did not take any
.wav file for your previous experiments, do so now).
∗ Convert this audio to .mp3 (preferably use Python for that,
see Section 3 for some libraries to use).
∗ Following what you did in the previous exercise, try to un-
dersample a .wav file by array manipulation until you get the
same file size that you achieved by the .wav to .mp3 conver-
sion. How do the two files compare? Investigate a bit
how .mp3 does to compress the audio.
– Additional experiment 1 (not required): The size of an au-
dio file can also be reduced by shortening the bit rate. Briefly
investigate what that is and apply a bit rate reduction to study
the quality loss.
– Additional experiment 2 (not required): The size of an audio
file can also be reduced by removing some frequencies that might
be non-essential. You can achieve that by implementing the filters
you explored in seminar 2. How much you can reduce the file size
without audio degradation using this method?

NOTE: Use the sounds chosen for the previous seminar sessions for the
experiments today.

3 Relevant resources for Seminar 3


You can use many different Python libraries for audio and signal processing
as well as for changing audio format and audio compression. For instance:

3
• SciPy’s: It has several functions for 1D signal processing, including
audio. Have a look at online resources to find out more.

• NumPy’s: It is a powerful Python library for numerical computing


that provides support for large, multi-dimensional arrays and matrices,
along with mathematical functions to operate on these data structures.

• Librosa: Useful Python library for for music and audio analysis. Find
out more about this library through the online documentation.

• SoundFile: Interesting Python library to read and write sound files.

• Pydub: It is a high-level audio processing library that allows you to


work easily with audio files. It supports a variety of audio formats and
provides a simple interface for common operations. In addition, you
can use it for basic audio compression and format conversion.

• Other options: Find more information about other Python modules


that could be useful for your work.

• Neural codecs (Meta’s encodec): Deep Learning can be also used to


compress and uncompress audio. Take a look at these examples by
Meta’s Encodec and their comparison to other compression techniques.

4 Instructions for the final report


The final report should have a maximum length of 8 pages (around 2
pages per session) and you can follow the proposed structure. Anyway, you
can add other sections for your consideration.

• Introduction:

– Define the purpose of the report


– Introduce the family of sounds selected and the specific elements
chosen.
– Provide a brief description of each element and pair your descrip-
tions with relevant images or diagrams.
– Explain how each sound is generated and propagated, emphasizing
the differences in procedures within the selected family instances.

4
• Methodology: Present briefly the steps you have followed to obtain
your results. You should include:

– Which software and tools you have used for the spectral analysis.
– Description of the audio filters used and software used for their
implementation. Remember to include the type of filter, the cut-
off frequency, and all the relevant parameters of the filters used.
– Present briefly the different experiments you have performed re-
garding the sampling frequency.
– Techniques used for sound compression.

• Results:

– Spectral analysis:
∗ Present the results obtained from your experiments and anal-
ysis using the provided resources or others of your choice.
∗ Use graphs or charts to illustrate the results.
∗ Explain the significance of the results and any patterns or
trends you observe.
– Audio filtering:
∗ Present the results obtained from your experiments.
∗ Use graphs or charts to illustrate the results.
∗ Explain the significance of the results and what you observe
after applying the different audio filters.
– Sampling frequency and audio compression:
∗ Present the results obtained from your experiments.
∗ Use graphs or charts to illustrate the results.
∗ Explain the significance of the results. What do you ob-
serve when reducing the sampling frequency? What happens
when you save the signal using the wrong sampling frequency?
Which is the best audio compression technique? etc.

• Analysis of the results:

– Situate the analysis within a theoretical framework.

5
– Delve into a detailed discussion of the differences among the out-
comes of the selected items.
– Relate these differences to the processes of sound generation and
propagation.
– Consider the implications of these variations regarding the overall
characteristics and quality of the sounds.
– What is the contribution of audio filters? How you could take
advantage of them and in which situations?
– What is the importance of sampling frequency?
– Identify why some audio compression methods are better than
others. Present the main differences.

• Conclusions:

– Summarize the key findings from your results and their analysis.
– Highlight the importance of the conducted research.

• References: List all the sources you used throughout your report.

You might also like