Signals Computing Assignment 2 Deepan Final
Signals Computing Assignment 2 Deepan Final
Question 1 and 2
To synthesize a sinusoid of a given frequency and experiment with adding harmonics, we can break the
task into two parts:
x(t) = A · sin(2πf t + ϕ)
Where:
• A is the amplitude of the sinusoid (A1 = 1)
• f is the frequency in hertz (F0 = 200 Hz)
• t is time
• ϕ is the phase (Inital phase = 0)
This waveform can be created in Python by leveraging the NumPy library.
1
3. Main Features of the Code
• Sinusoid generation: The initial sinusoidal waveform is derived from numpy.sin().
• Harmonics: New harmonics with different parameters are incorporated.
• Graphing and Audio Playback: Using Matplotlib, waveforms are plotted, and audio is gen-
erated to assess changes in timbre
• Fourier Transform: The fft function from scipy.fftpack is used to compute the magnitude
spectrum.
2
Figure 2: Two harmonics
4. Observations
• Waveform: The inclusion of harmonics makes it more complex and enhances its timbre
• Magnitude Spectrum: The fundamental frequency F0 remains the same, with peaks appearing
at harmonics (e.g., 2F0 , 3F0 , . . .).
Question 3
To generate a song from given notes and durations, the process can be broken down as follows:
Steps
1. Note Generation: For each note, generate a sinusoidal waveform of the specified frequency and
duration.
2. Concatenation: Combine all the notes to form the complete song.
3
Figure 4: Second Song - My Heart Will Go On
• Concatenation: The waveforms of each note are joined together to form a continuous piece of
music.
• Normalization: The resulting waveform is normalized to avoid clipping.
• Saving as .wav: The final waveform is saved in a 16-bit PCM .wav file format.
How It Works
• A sine wave is generated for each note based on its frequency and duration.
• The sine waves are combined in sequence to create the complete song.
• The final output is exported as a .wav file, making it playable on any media player.