Skip to content

KimonArisV/MusicalInstrumentDeviceMATLAB

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 

Repository files navigation

MusicalInstrumentDeviceMATLAB

Authors: Kimon-Aristotelis Vogt, Drew P.

Year: 2019

This is a project that uses Signal and Systems priciples to create a instrumental device that can mimic any musical instrument and play any song.


Goal

In this project, the goal is to tie together the mathematical procedures learned in the classroom to a real world application involving signals and sound processing. More specifically, through the use of addition, multiplication, and other mathematical operations on sinusoids, sounds can be produced. This project overall allows students an opportunity at obtaining a thorough understanding of the frequency domain and time domain. For instance, seeing what effects changing the time domain components will have on the frequency domain. By using MatLab, familiarity with signals domain can be gained by representing a continuous time signal as a discrete sampled version solidifying our work in the classroom. Matlab gives us this understanding and awareness that certain conditions have to be met so that all of the information can be reproduced. We will also get more familiar with the reasons of having sampling frequency and what its effects are when we tune this value. For the last song we chose to use “Claire de la luna” to code and play. Using and modifying signals in such a way that produces desired results regarding project objectives. Some of these desired results included dialing a telephone, playing musical scales, playing notes that produced songs, and manipulating signals to gain certain tonal aspects as to mimic acoustic instruments. A large portion of the success of this project comes from the ability to distinguish if the given sounds are correct. Using your sense of hearing to determine that the melody was accurately implemented is a form of feedback to correcting the code

Getting started with the Project

  • Install MATLAB and the Signal Processing Toolbox dependency
  • You can turn the boolean of any of the provided songs and examples in the MATLAB file to true and run the file.
  • You can also look up a song include the musical notes in the script and adjust the frequency to match any instrument. I have the frequency adjusted to flute.
  • Ability to retrieve plots with the harmonies are also included.

Technology/Methods

The main implementation of the project involved programming and matlab. In the case of the telephone, using the given table 1 DTMF (Appendix A), there was an application of the table into Matlab. Setting a sampling frequency, delay and duration there was a generation of tones from a unique combination of a row and a column of frequencies. By taking these unique combinations we could add together the sinusoids to produce these tones which is what produces the keypad on phones. Then, by putting in a brief delay, you can hear the pause in between the tones which allows us to distinguish between the different sounds or tones. In the case of playing the musical scales, using Table 2 (Appendix A), starting with the lowest note and smallest frequency. Then, going through the table, multiplying by the offset of the 12th root of 2 to achieve the output of sound. In the case of playing notes of Re Mi Do Do So, referencing Table 2 (Appendix A) which contained the frequencies of the notes needed. The notes were generated by a sinusoid of that given frequency. For the next portion, with the same approach as the Re Mi Do Do So, the Table: 2 scale frequencies was once again used and tones were produced based on the required output. In the case of removing every other sample, we reduced the sample rate of our initial sequence of notes by a factor of two. Using the decimate function in Matlab which reduces the sample rate and input signal of the sinusoid. In the case of the time reverse, the processing of the time reverse portion used an implementation of the fliplr function of matlab. Which reverses the sequences of the samples that we created the notes with instead of purely the notes. The function returns the original array with its columns flipped in the left-right direction. Then, applying the classic ADSR envelope, the goal was trying to mimic the sound of a flute. We started out by creating amplitudes and durations for the attack, decay, sustain, and release intervals, and building up the mathematical representation that produces the envelope. After, we multiplied the ADSR envelope by the frequencies of the notes that produced the desired output. Through the use of arrays and looping the focus was on moving through an array that contained the frequencies that could produce the desired output. In all of the cases listed below there was an implementation of a duration of .6 for quarter notes which allowed for a small gap and adjusted that to other note durations. When playing a song such as “Twinkle Twinkle Little Star”, the frequencies of the notes were entered into an array. Taking into consideration different delays and durations which are dependent on how many notes are in a measure. For instance, if the song has a 2/4 time signature, there is two quarter notes per measure. In the case of a half note per measure, we used one delay of doubled duration. Then, using this idea, we also adjusted the durations and delays for each case to achieve the desired notes. (Appendix E.1). In another attempt to play a song, the piece “Au Clair De La Lune” was chosen. For the last song, moduli were used in order to simplify the method to produce the notes that have different durations and delays as there are varied note lengths used in the song. A modulus of 11 was employed for indexes of the frequencies of the array to give them specific durations, being that of a quarter note, half note, and whole note. After assigning the frequencies, durations, and delays the desired output was able to be generated. (Appendix E.4) The final implementation was for the ADSR for “Au Clair De La Lune”, which was done by taking the previous modulation method specified above and combining that with the ADSR method that was used in the “Twinkle Twinkle Little Star” signal. This produced a flute like sound which generates the tune of “Au Clair De La Lune”. A large part of our methods and implementation was being able to take our classroom knowledge of the theory on signals and domains in conjunction with programming in Matlab to produce an output. Matlab provides the outlet to be sure that our techniques were accurate regarding the parameters of the assignment.


About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages