Construction of a Musical Synthesizer on a DSP

 


Final Project Proposal

Abstract

            For our final project, we plan on making a musical synthesizer.  The main sound source for the synthesizer will be simple sine waves.  We will use the TMS320C542 DSP chip to implement a difference equation to produce sine waves at the desired frequencies, which will be strung together to form a musical melody.  The main goals are to have the chip produce a simple melody, which uses 8 to 10 distinct tones (8 to 10 different frequencies), and to perhaps experiment with harmony and other musical effects.  Harmony can be achieved through the use of amplitude modulation (AM) since a sine wave modulated by a sine wave will produce two harmonics if DSBSC AM is used.  Once the sine wave melody is composed on MATLAB, it will only be a matter of translating the desired pattern of sine waves and rests (pauses) into assembly.  After the melody is up and running, we will experiment with different waveforms to add to the overall arrangement (e.g. finding a percussive-sounding waveform to keep the rhythm).

 

Implementation

 

            Since the goal is to create a musical synthesizer—as opposed to an audio processor—there will be no external input to the system.  The melody will be hard-coded onto the chip, and will repeat indefinitely until the user stops the program.  The “input” will come from the chip’s program memory—the program will generate the samples corresponding to a sine wave and output an audio signal at each interrupt.  The output must be passed through the onboard AIC chip, which has built-in analog filters, so care must be taken to initialize the AIC to pass the desired frequency range without attenuation.  The cutoff frequency of the AIC is a function of the values of the registers within the chip (as is the sampling frequency):

                                                                                           

The low pass filter should be set to have a cutoff frequency beyond the highest frequency used in the melody.  The high pass filter can be left on for this application to block any unwanted DC component in the signal.  The sampling frequency should be set to be greater than two times the highest frequency in the melody in order to satisfy the Nyquist theorem.  The output will then be run through an external amplifier and speaker.

            The difference equation used to generate the sine wave is the same difference equation that was used to create the carrier signal for AM in experiment 3.  The equation is outlined on pg. 85 of the course reader:

        Fig. 2.  Samples produced by difference equation.

 

A musical harmony can be obtained by modulating a sine wave with another sine wave to create a spectrum that contains two harmonics.  If the carrier is a sine wave with frequency fc and this carrier is modulated with another sine wave of frequency fm, then the resulting spectrum (considering only positive frequencies) will have harmonics at and fc - fm and fc + fm.  No harmonic will appear at f unless a DC offset is applied (DSBSC AM) as is depicted in Fig. 3:

        Fig. 3.  Spectrum of sine wave modulated by a sine wave.

Luckily, the human ear is not very good at detecting phase shifts, so a sine wave will sound like a cosine wave and the inversion will not be detected.  Careful consideration must be given to the choice of fm and fc because some combinations of frequencies will sound musical (440Hz and 659Hz, for example, denote a musical A and E, respectively, which together form a 5th harmony) and other combinations will sound awful (e.g. 988Hz—which is a B—and 1047Hz—which is a C).

            If this modulation technique proves too inefficient, another way to achieve the same effect is to simply add a sine wave with frequency  to another sine wave of frequency fc - fm to another sine wave of frequency fc + fm .  Both methods will be employed in the MATLAB code.

            Implementing such a simple sine wave pattern generator on MATLAB is easy—simply compose the melody, choose a sampling frequency that satisfies the Nyquist theorem, use the sin function to generate a bunch of vectors, and use the sound and pause functions to play the sin waves and create rests, respectively.  This can all be stored in an m file and played through the computer’s sound card easily.  The challenges we face involve translating this into assembly.  We already know how to create a sine wave using a difference equation and how to set up an AM scheme from experiment 3, which we performed last Tuesday in preparation for this project.  What we have to figure out next is how to repeat a sine wave for a specific number of interrupts to give each note its desired play time, how to change the frequency at the right moment to implement the desired melodic pattern, and how to implement the pauses between notes to establish the rhythm of the melody.  The idea thus far is to store a count that decrements after an interrupt is serviced.  By nesting loops using different counts, we should be able to generate any arbitrary time length.  Another challenge will be to perform all the necessary math to sort out which coefficients will be needed for our melody, what sampling frequency to use, and what the cutoff frequency of the low pass filter on the AIC should be.

            Some research (or experimentation) must be done in order to discover what sorts of waveforms sound interesting and/or musical (if sine waves get too boring).

 

Timeline

 

            From now until the end of the quarter, a stringent timeline must be followed in order to accomplish the above tasks (and still have enough time to write the report and plan the presentation).  The plan is as follows:

 

Week 7 (Tuesday, May 15):  Have completed proposal and preliminary website up and running.  Have melody composed and demonstrated in MATLAB.  Start research on different musical/percussive waveform generation.

 

Week 8 (Tuesday, May 22):  Have assembly code written.  Must have solid plan on how to implement pauses by this week.

 

Week 9 (Tuesday, May 29):  Debug program.  Have basic functionality working perfectly.  Start experimenting with alternate waveforms.  Start report/presentation and discuss what has been accomplished thus far.

 

Week 10 (Tuesday, June 5):  Time to present!  Focus all energy on presentation and report this week.  Discuss what was learned, what was disappointing, any ethics issues (i.e. being honest about missed deadlines, etc.), and what conclusions were drawn now that the project is complete.

 

Sign in  |  Recent Site Activity  |  Terms  |  Report Abuse  |  Print page  |  Powered by Google Sites