Computing the fundamental frequency

Assignment Help Other Engineering
Reference no: EM131371765

Introduction to Signal Analysis Project: Music Synthesis

Project Definition: The objective of this project is to synthesize musical signals. You will generate harmonic tones and use them to perform well-known melodies. Moreover, you will use the concept of FIR filtering to add reverb, a popular sound effect, to musical signals.

A. Computing the fundamental frequency

The relationship between a Piano key number and the fundamental frequency of the played note is given by:

f0 = 440·2(k-49)/12,

where f0 denotes the fundamental frequency and K the Piano key number.

Write a function named keynum2freq, which receives a Piano key number, K (a non-negative integer number), and returns the corresponding fundamental frequency, f0. Note that the Piano has 88 keys in total (key numbers range from 1 to 88); we will also include 0 in the range of K values to represent silence in a melody line.

B. Generating Harmonic Tones

A harmonic signal is basically the sum of a number of sinusoids, whose frequencies are multiples of a fundamental frequency, i.e.

X(t) = h=1HAhcos(2πfht),

where Ah is the amplitude, and fh = h·f0 the frequency of the hth harmonic.

Write a function named harmonic_signal, which receives the fundamental frequency, f0 (a real and positive number), the number of harmonics, Nh (a positive integer number), harmonic amplitudes, Ah (a vector of length Nh with elements greater than zero), the total duration of the harmonic signal, dur (a real and positive number), and the sampling rate, fs (a positive and integer number). The function should return a vector containing samples of the harmonic signal, X(t), over the specified duration. The output vector should be normalized so that its maximum value is equal to one.

C. Generating Time-Domain Envelopes

To improve the quality of the sound, we can multiply the harmonic signal by an envelope, E(t), so that it would fade in and out. A standard way to define the envelope function is to divide E(t) into four sections: attack (A), decay (D), sustain (S), and release (R), abbreviated as ADSR. The following figure shows a linear approximation to the ADSR envelope:

1187_Figure.png

Write a function named adsr, which receives the following input variables:

- Adur: ratio of attack time to the total envelope duration (real, between zero and one)

- Ddur: ratio of decay time to the total envelope duration (real, between zero and one)

- Sdur: ratio of sustain time to the total envelope duration (real, between zero and one)

- Rdur: ratio of release time to the total envelope duration (real, between zero and one)

-Damp: envelope amplitude at the end of decay time (real, between zero and one)

-Samp: envelope amplitude at the end of sustain time (real, between zero and one)

-dur: total duration of the envelope (real and positive)

-fs: sampling rate (integer and positive)

Note that the sum of Adur, Ddur, Sdur, and Rdur, should be equal to one. Also, note that we are generating a normalized envelope (the maximum value of the envelope is equal to one, i.e. Aamp = 1). The function should return a vector containing samples of the envelope, E(t), over the specified duration.

D. Generating Musical Notes

Write a function named note which receives the Piano key number, K (integer, between 0 and 88), the intensity of tone or sound volume, vol (real, positive), the duration of the note, dur (real and positive), and the sampling rate, fs (integer and positive) and returns a vector containing samples of the synthesized tone. Functions keynum2freq, harmonic_signal, and adsr should be called to calculate the fundamental frequency of the note, harmonics, and the time-domain envelope respectively. The musical tone can be computed from the following relationship:

X(t) = vol·E(t)h=1HAhcos(2πfht).

Note that if K = 0, the function should return a vector of zeros (silence) over the specified duration.

E. Synthesis of Melody Lines

Write a function named melody, which receives a vector of Piano key numbers, Keynums, a vector of note/silence durations, Durs, a vector of tone intensities (sound volumes), Vols, and the sampling rate, fs. The function should call the note function for each key number and corresponding tone properties and put the outputs back to back to generate a longer signal (Hint: you can use a for loop that calls the note function for one key number in each iteration). This longer signal is composed of a series of notes and silences, in other words it forms a melody.

F. Playing Tunes You Know Well!

Download the file Tune.mat from Blackboard and place it in the same folder as your functions. Open a new MFile. Load the content of the file to the workspace. You should be able to see six variables named, Gk, Gdur, Gvol, Fk, Fdur, and Fvol in the workspace. The first three are parameters of one melody line and the rest parameters of another. Call the function melody in each case and save the outputs in variables named G and F (set the sampling rate to at least 20000 Hz). Generate another variable named GF which is the sum of G and F. Call the MATLAB function sound with inputs GF and fs to play the music signal. Does it sound familiar? Feel free to test your code with your favorite melodies.

G. Adding Sound Effects to the Musical Signal

In this part we will add reverb to our musical signal, which is equivalent to FIR filtering of the signal. The reverb effect can be created by adding delayed versions of the sound signal to the original version. Each one of the delayed versions represents a reflection of the signal from some surface. Altogether, it gives a feeling of space, e.g. the contrast between being in a small room or in a concert hall.

Write a function named reverb, which receives the musical signal, X, the number of reverbs, Nr (integer and positive), a vector containing delay times for different reflections, Dr, a vector containing attenuation rate for different reflections, Ar, and the sampling rate, fs. Note that the input delays (elements of Dr) are measured in seconds, therefore the function should first convert them to number of delayed samples. The output is basically the sum of delayed versions of the input. This function is quite similar to the diff_eq function you worked with in Lab 8.

Call the reverb function in the script you created in the previous part for the GF sound signal. Again convert the signal to audio and listen to it. Do you notice any difference in the sound quality?

H. Parameter Setting

Here is a list of suggested parameter values for testing your code:

Harmonics: Nh = 5, Ah = [ 1  0.8  0.6  0.4  0.2 ]

Envelope: Adur = 0.05, Ddur = 0.1, Sdur = 0.6, Rdur = 0.25, Damp = 0.6, Samp = 0.4

Reverb: Nr = 3, Dr = [ 0.2  0.3   0.4 ], Ar = [ 0.4  0.1  0.05 ]

Feel free to tweak parameter values and synthesize a variety of sound colors.

Show the execution of your code to the instructor during the session designated for project submission. Prepare a report of your work and submit it on Blackboard. Your report should contain all the code you develop as well as a brief explanation of how it works (no more than one page). Also, include a conclusion section in your report explaining what you have learnt from this project (no more than one paragraph).

Reference no: EM131371765

Questions Cloud

Specify nature and types of products or services of apple : Specify the nature, structure, and types of products or services of Apple, and identify two key factors in the organization's external environment that can affect its success. Provide explanation to support the rationale.
Equilibrium position measured from the bridge : Part a) The new equilibrium position measured from the bridge where you will eventually end up. Part b) The period of oscillation. Part c) The lowest point you will reach below the bridge.
What are essentials in making a documentary effective : What are essentials in making a documentary effective for reaching people today? - What do people look for?
Describe the focus of nonprofit organizations : Describe the main components of contemporary business. Describe the focus of nonprofit organizations. Explain the five elements in the business environment.
Computing the fundamental frequency : ECE 201 - Introduction to Signal Analysis Fall 2016 Project: Music Synthesis. Project Definition: The objective of this project is to synthesize musical signals. You will generate harmonic tones and use them to perform well-known melodies. Moreover..
What economic trends are to be observed : What economic trends are to be observed? Who will make money from the technology? Who is funding the research and development? Who controls the purse strings, and why?
Calculate the work done by the force : A particle moves from the origin to the point x=3m y=6m along the curve y=ax^2-bx, where a =2m^-1 and b=4. It's subject to a force cxyi+dj, where c =10N/m^2 and d=15N. Calculate the work done by the force.
Write for me methodology of service quality gap model : Write for me Methodology of Service quality- Gap model.- International Journal of Quality & Reliability Management.
Distance traveled to reach the box car : (a) How long does it take him to catch up to the empty box car? (b) What is the distance traveled to reach the box car?

Reviews

Write a Review

Other Engineering Questions & Answers

  Burner sequence from start of cycle to end of cycle

What is the burner sequence from start of cycle to end of cycle and list all new requirements for BMS codes

  Questionnbsp - 1design problemnbspan ore body dips at 70deg

questionnbsp - 1design problemnbspan ore body dips at 70deg and has a vertical depth of 140m. the top of the ore body

  Magnitudes of the components of force

Determine the magnitudes of the components of force F = 400 N acting parallel and perpendicular to segment BC of the pipe assembly.

  Reading assignments - read and have a good understanding of

reading assignments - read and have a good understanding of mil-std-499 and mil-std-499a. be sure that you have

  Critical awareness of the concept of decision support

CISM02 Critical awareness of the concept of decision support and its effects on all parts of an organisation - critical understanding of modelling and simulation

  Calculate the allowable levelling misclosure

Calculate the allowable levelling misclosure and compare it with the actual misclosure. Briefly comment on the result. Carry out the error distribution and calculate the corrected levels of the sections indicated in the sketches

  State multiprogramming and multiprocessing for same problems

It is stated that multiprogramming and multiprocessing present the same problems, with respect to concurrency. This is true as far as it goes. However, cite two differences in terms of concurrency between multiprogramming and multiprocessing.

  Which is the preferred environmental condition

Which is the preferred environmental condition for handling electronic components that are ESD sensitive -  Higher relative humidity (RH) environment

  Describe the physical motion of the fluid

Describe the physical motion of the fluid and the main modes of heat transfer in each section (I through IV) of the following figure

  Why is testifying such as critical part of a computer job

Why is testifying and/or writing a report such as critical part of a computer forensics experts job? Give an example of terminology that could be confusing between a digital forensic expert, a lawyer, judge, and potential jurors.

  Correlation analyses

A small transits system has just become part of a transit authority which will provide significantly increased funding.

  Make a program that will determine the number of terms

write a program that will determine the number of terms in the series that are needed to approximate the function to a specified accuracy. Prompt the user to enter values for x and for an epsilon, where epsilon is the accuracy desired. Use a funct..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd