San Jose State University

Spring 2002

 

 

 

 

 

 

 

 

EE198B Senior Project

DSP-Based Music Synthesizer with Morphable Filters

 

 

 

 

 

 

 

 

 

 

 

Presented by

Anthony Lombardi

Senior Project Advisor:  Professor Singh

May 10, 2002


Table of Contents

I.  INTRODUCTION

A.  Objective

B.  MIDI

C.  TMS320C5402 DSP Starter Kit

D.  MATLAB

II.      DESCRIPTION OF DESIGN

A.  General Theory of Operation

B.  Design Goals

C.  Simulation in MATLAB

D.  Software

i.   Note Generation

ii.  Filters

iii. MIDI Control

E.  Hardware

III.         DESIGN RESULTS

IX.        APPENDIX A – MATLAB CODE

X.        APPENDIX B – TI ASSEMBLY CODE

XI.        APPENDIX C – Synth User Manual


I.  INTRODUCTION

 

A.  Objective

            The objective of this project was to design a MIDI-controllable musical synthesizer that allows the user a unique type of real-time control over the sound output.  This unique control was to be the ability of the user to smoothly change the coefficients of the digital filter from one set of user specified coefficients to another set of user specified coefficients.  In addition, the synthesizer was to have other controls such as volume and waveform type, which are common to all music synthesizers.

 

B.  MIDI

            MIDI, which stands for Musical Instrument Digital Interface and is pronounced “mid´ē”, is a communication standard that is commonly used to communicate with musical synthesizers.  It is an asynchronous serial interface that runs at 31.25 Kbaud, +-1%.  There is 1 start bit, 8 data bits, and 1 stop bit for a total of 10 bits per serial byte.  The type of signal is current loop, 5 mA, with logic 0 assigned to current ON.

There are two types of setups with which it is used: a sequencer connected to a synthesizer, and two or more synthesizers connected together.

A software sequencer is a program where a musician writes music to be played on a synthesizer connected to the computer via MIDI ports.  The MIDI OUT port of the computer connects to the MIDI IN port of the synthesizer and vice versa.  When “play” is pressed on a sequencer, the music, or the sequence, is sent out via the MIDI OUT port on the computer.  The MIDI messages are sent out as they are encountered in the music.  For example, the first note’s “Note On” message is sent out when the song position pointer gets to it in the music and never before or after.  In other words there is no buffering of the MIDI messages.  The messages are then received by the synthesizer via the MIDI IN port on the synthesizer and immediately processed.

In the second setup, two or more synthesizers are connected together via their MIDI ports.  Typically one of the synths is used as a main controller, controlling one or more other synths.  These other synths may not even have keys.  These types of synths are called “rackmount” and only have the sound generation hardware and MIDI IN and OUT ports.  These are specifically made for musicians who already have a keyboard that they prefer to play on and just want to add more sounds to their rig.  Rackmount synths are far more compact and can be neatly stacked on top of each other in a rack.   The lack of keyboard also makes them cheaper.  Other than the lack of a keyboard, these synths typically contain exactly the same functionality as their keyboard versions.  Typically a keyboard version of a synth is released first, and after a few months the rackmount version is released.  My project would fall into the category of “rackmount” since it must be played from an external keyboard or sequencer.

      

 

 

C.  TMS320C5402 DSP Starter Kit

            The TMS320C5402 DSP Starter Kit is a development system for the Texas Instruments TMS320C5402 DSP.  It consists of hardware and software that enables the user to program the hardware.  The hardware consists of the following:

 

·           100 MHz TMS320VC5402 DSP

 

·           128 Kbytes of one wait-state SRAM and 256K words of FLASH

 

·           Embedded JTAG Emulation via TBC and IEEE-1284 parallel port  &  External XDS510 Support

 

·           Four LED Indicators (3 user-controllable + power)

 

·           Expansion memory and DSP peripheral connectors for daughterboard

 

·           Telephone network interface via DAA and AD50 AIC.

 

·           Microphone and speaker I/O via standard audio jacks and AD50 AIC.

 

·           RS-232 UART interface

 

·           Internal generation of 1.8, 3.3 and 5V analog capacity

Provided by linear regulators from external +5V supply connected by a 2.5mm barrel-type jack.

 

            All the hardware is contained on a single board that connects to the host computer via the parallel port.

            The software included in the kit is called Code Composer Studio.  The version used in this project was version 1.21.  A typical screenshot of the software is shown on the following page.  The software consists of windows that enable the user to monitor the registers of the DSP and the memory.  Debugging tools such as breakpoints and probes are also provided.

 

D.  MATLAB

            MATLAB, which stands for Matrix Laboratory, is a very powerful numerical analysis and simulation tool.  It is used widely in the field of DSP in order to model and design systems.  Dozens of add-in toolboxes, from neural networks to signal processing to multi-variable optimization, are available for the main program.  A signal processing toolbox add-in that includes convenient functions that help in filter design is available for the main program.  In this project the student version was used with the Signal Processing Toolbox.

 


II.          DESCRIPTION OF DESIGN

 

A.  General Theory of Operation


            Figure 1 shows the general operation of the project.

 

 

            The project consists of everything contained in the grey rectangle:  MIDI Decoder, Sound Generator, Digital Filter, and DAC. 

            The MIDI Decoder decodes MIDI messages coming into the device from either a sequencer or another synthesizer.  All control of the synthesizer comes through this interface.  Some of the decoded messages control the Sound Generation section and the rest control the Digital Filter section.

            The are only a few controls for the Sound Generation section.  They are waveform type and the notes that are to be played.  There are four types of waveforms: sine, square, triangle and noise.  Only one type of waveform can be played on the synth at any given time.  The note range of the synth is from the C three octaves below middle C, up to middle C (middle C is the C just below the staff on a treble clef). 

            For the Digital Filter section there are a total of twenty controls.  There are a total of sixteen controls directly linked to coefficients of the filter.  These coefficients are shown in the following equation for the digital filter:

 

y(n)+a1y(n-1)+a2y(n-2)+... +a5y(n-5)=b1x(n)+b2x(n-1)+...+b11x(n-10)

 

Here the a’s and b’s are the coefficients, n is the sample number, x is the input, and y is the output.  The other four controls are interpolation, filter type, filter number and morph. 

The interpolation control inserts multiple coefficients between the directly controlled coefficients.  This control was implemented because FIR filters usually need a rather large number of coefficients to implement certain filter response shapes.  The number of coefficients inserted can be modified with this control.  The values of the inserted coefficients are found through linear interpolation of the directly controlled coefficients. 

The filter type control is a two-way switch that enables the user to choose between FIR and IIR.  When FIR is chosen, the feedback coefficients, i.e. those that multiply with previous outputs, are ignored.  When IIR is chosen, the interpolation control has no function. 

The filter number control is a three-way switch that chooses between filter 1, filter 2 and the morph filter.  When filter number is either filter 1 or filter 2, MIDI messages that change the directly controlled coefficients change the corresponding set of filter 1 and filter 2 coefficients in the DSP memory. This allows the user to chose between two completely separate sets of coefficients.  The coefficients stored for filter 1 and filter 2 are the set of coefficients generated after interpolation.  The amount of interpolation for the two sets can be different.  When filter number is set to morph, the morph control becomes operative.  At all other times it is ignored.

The morph control allows the user to morph between the sets of coefficients stored in filter 1 and filter 2.  When morph = 0, the filter applied is the same as filter 1.  When morph = 127, the filter applied is the same as filter 2.  When morph is somewhere in between, the values of the coefficients are linearly interpolated based on the morph value and the filter 1 and filter 2 values.

 

B.  Design Goals

            The design goals first appeared in the final report for the design portion (198A) of the senior project.  In that report they appear under the heading “Specification”.  They are repeated below for convenience.

The music synthesizer to be built will have at least the following characteristics.

 

1.                  Digital filter with 11 MIDI controllable FIR coefficients and 5 MIDI controllable IIR coefficients.  Other FIR coefficients will be linearly interpolated from the controlled coefficients.  The number of interpolated coefficients will also be MIDI controlled.

2.                  MIDI filter morph control.

3.                  10-voice polyphony.  Polyphony is the number of notes that can sound simultaneously.

4.                  MIDI selection of 4 types of sound sources: sine, triangle, square and white noise.

5.                  MIDI selection of FIR or IIR filter type and filter 1, 2 or morph

6.                  MIDI adjustment of signal gain.

C.  Simulation in MATLAB

            The MATLAB simulation consisted of simulating the filter coefficient generation and plotting the frequency response associated with it.  It was not created to mimic the full functionality of the project, but rather just to see what sorts of frequency responses could be expected.  For this purpose a MATLAB

GUI was developed.  The GUI contains several of the filter coefficient controls that the project was designed to have.  It consists of 11 FIR coefficients, 5 IIR coefficients, an interpolation control, and a filter type control that allows the user to choose between FIR and IIR.  The GUI also contains a frequency response plot.  When the user modifies the values of any of the controls, a MATLAB .m file linked to the GUI runs and updates the frequency response plot on the GUI.  A screenshot of the GUI is shown in Figure 2.

 

Figure 2.Figure 1

 

 

D.  Software

            All of the code for the synthesizer was written using the TMS320C5402 assembly language instructions.  The main reason this method was chosen was because the author already had some experience with this method.  Another method is to code in C and use software tools to automatically convert the C code to assembly.  This method may be easier in some cases but in general it produces less efficient assembly code than directly coded assembly.

            Most of the code can be split up into one of the three different categories discussed in General Theory of Operation: Sound Generation, Filter Generation, and MIDI Decoding.  The order shown is the same order in which they were coded.

 

i.   Note Generation

            Since this synthesizer was to be polyphonic, i.e. able to play more than one note at a time, some way had to be thought of to generate simultaneous notes.  This was done by using a multiply and accumulate between two arrays.  One array holds the output of every note of the synth.  The other array holds ones and zeros that correspond to the notes that are on and off.  When these arrays are multiplied and accumulated, the result is the sum of all the notes that are on.  This is shown in Figure 3.


 

Figure 3.

 

As previously mentioned, there are four different waveforms to chose: sine, square, triangle, and noise.  Each of these waveforms has a different algorithm that generates the next sample for all the notes.


For the sine wave, the Goertzel algorithm was used.  This algorithm is governed by the following equation.

 

Here q is the digital frequency and i is the sample number.  The equation basically says that the next sine sample is a function of the previous two sine samples and the digital frequency.  The assembly language program that implements this algorithm accesses an area of memory where the latest two samples are stored, and an area that contains the cosine of the digital frequency of all the notes.

            The square wave algorithm is much simpler.  A square wave has two different levels that only differ by sign.  This was taken advantage of in the algorithm, which simply counts down to zero and then multiplies the previous output by negative one when zero is reached.  Each note has its own value that it begins counting down from.  When zero is reached, this value is reloaded.  The following equation was used to get the starting value for each note.

Here Nn is the starting count value for note n, Fs is the sampling rate, and fn is the frequency of note n.

The triangle wave algorithm is a bit more complicated.  It uses the same starting count values used in the square wave algorithm, but in addition to these values there is another set of values, two for each note, which are named “note delta” and “note slope”.  The note delta is the distance between successive samples of the note, and the note slope is the sign of the slope of the part of the wave currently being generated.  The relationship between the note delta, note slope, count value, and the output for the note is shown below.

 

Here On(i) is the ith sample of note n, mn(i) is the slope for sample i of note n, Cn(i) is the current count value of the down counter for note n, and Dn is the note delta for note n.  The slope function switches between one and negative one whenever Cn(i) reaches zero.

The noise algorithm is relatively simple.  It is based on the linear congruential method, which is a method introduced by D. Lehmer in 1951.  The form of the algorithm used in the synth was taken from the TI application brief SPRA239.  It is shown below.

 

Rndnum(n) = (Rndnum(n-l) * MULT) + INC (mod M)

 

Here Rndnum(n) is the nth random number generated, M is the word width of the processor, MULT and INC are special constants that result in a uniformly random distribution.  The first random number is an arbitrary number called the SEED.

This algorithm was simulated in MATLAB and found to be relatively uniform.

            Originally the note range of the synthesizer was the 61 notes from C3 to C7, C4 being middle C.  However there were intonation problem for notes above C4 for the square and triangle waves.  Notes below C4 are reasonably in tune, so C4 is the highest note of the synth and C1 is the lowest.  Because of this range, the synth can be regarded as a three octave base synth.  This is not an unusual usage of a synthesizer.  Many popular songs of the 80’s had synth baselines.  Incidentally, the Design Goals section says nothing regarding the range of notes to be implemented, so the restricted range is not a problem.

 

ii.  Filters

            As mentioned in Design Goals, the user has a few options when controlling the filter section of the synth.  One of the options is filter type, which can be either FIR or IIR, and the other is filter number, which can be filter 1, filter 2, or the morph filter.  These two options are used simultaneously, so there are a total of six different combinations.

The FIR filter implementation was one of the most complicated parts of the project.  For the FIR type filter, a routine had to be designed to interpolate coefficients based on the directly controlled coefficients.  The routine first calculates the difference between two consecutive coefficients, and then divides this by the interp variable.  The resulting number is the difference between the coefficients to be inserted.  This number is used in a loop that adds it to the previous coefficient in the loop until the loop is done generating the correct number of coefficients to be inserted. 

The IIR filter implementation was easier than the FIR implementation because there was no interpolation.  The programming was standard programming of the IIR algorithm.

Filter 1 and filter 2 programming were exactly the same.  The programming basically handles storing and loading from the filter 1 and filter 2 coefficient banks in memory.  A more detailed analysis and flow chart is shown in MIDI Control.

When filter number is the morph filter, the morph variable is used to interpolate between the coefficients stored in the filter 1 and filter 2 banks.

The next section gives more detail into what exactly happens when the filter controls are used.

 

iii. MIDI Control

            For reference, Table 1 is a list of all 24 MIDI-controlled variables with their assigned controller number.   The numbers shown were chosen because they are undefined controllers in the MIDI specification.  This means that musicians can assign them to control whatever they wish to.  Some controllers are by default set up to control certain variables regardless of what synthesizer is being used.  For example, controller 7 by default controls the overall volume of the synthesizer.  Similarly, controller 10 by default controls the panning of the sound in the stereo field.  However these assignments can be changed in most high-end synthesizers.  On the left of most keyboards is a control called the mod wheel, which is a small wheel that musicians can turn with their left hand while they play with their right.  By default on all synthesizers it is connected to controller 1.  I’ve assigned controller 1 to the morph variable.  This means that when a typical synth is connected through MIDI to the synth, the mod wheel on it will control the morph variable.

            Before the MIDI messages are used in the synth, they must be received.  As mentioned in the introduction, MIDI is an asynchronous serial interface that runs at 31.25 Kbaud, ±1%.  The TMS320C5402 DSK has a Universal Asynchronous Receiver Transceiver, or UART, but 31.25 Kbaud is not one of the


 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


Table 1.

 

programmable baud rates.  The closest rate was much more than ±1% from the desired rate.  Therefore, a different method of implementing a UART was used.  

            This method, which is described in TI application report SPRA555, uses one of the timers of the DSP and a general purpose I/O pin tied to the interrupt 0 pin.  The method in the application report includes receiving and transmitting, and since in this case only receiving is needed, the code for the project is a modified version of the code in the report.  A flowchart for the code appears in Figure 4.

            The MIDI messages need to be interpreted after they are received.  Table 2 shows how MIDI messages are represented in bytes.  Messages in bold are those that are implemented in the synth.

The MIDI Control routine handles the processing of the bytes.  In some cases, processing the message received involves simply changing the value of a single control in one location.  This is what happens when a note on or note off message occurs.  The corresponding note flag is either set or reset.  In other cases, processing the message involves much more.  For example when a filter coefficient is changed, the interpolation routine must be executed again.  Flowcharts for this process are shown in Figure 5 and 6.

 

Table 2.




           

 


           

E.  Hardware

            Most of the hardware for this project was provided on the TMS320C5402 DSK board.  For example, the AD50 on the board is a DAC that was used for the digital to analog conversion.  The sampling rate used was the highest that it would run on the DSK, which is 16 kHz.  Since MIDI is a current loop signal and there is no interface for current loop signals on the DSK board, an interface circuit had to be made.  This circuit is shown in Figure 7.


Figure 7.

 

            The IC in the circuit is an optocoupler.  There are several that work with the circuit but the one used was the SHARP PC900 because of its very short rise time.

 

III.        DESIGN RESULTS

            Two different methods were used to test the sequencer: a sequencer as the MIDI source and a keyboard as the MIDI source.

 

A.  Testing Using a Sequencer

The sequencer used to test the synth was a Windows program called Cakewalk Pro Audio 9.0.  This was used primarily because of its ease of use, though any sequencer would do.  Like most sequencers there is a lot of customization possible in Cakewalk.  For example, you can make virtual interfaces for any MIDI device connected to your computer.  In Cakewalk these interfaces are called Studioware.  This tool is exactly what was needed for the test.  A Studioware panel was made for the synth, and it is shown in Figure 8.  As is seen in the figure, each of the controllable variables mentioned above has its own movable fader similar to the ones found on a typical mixer.  A mouse was used to move them up and down.  The number at the top of the controller represents the current value of the fader. 

To test operation of the FIR and IIR filters, the MATLAB GUI was first used to get the response for an arbitrarily chosen set of test coefficients.  This response was then imported into Excel.  To get the response of the filters in the synth using the same coefficients, the Cakewalk Studioware panel was used to set them, and the sine waveform was chosen as the note type.  Since sine waves have no harmonic content, the level of the output for a sine wave input can be used to measure the response at the frequency of the sine wave.  The output of the synth for several different notes, i.e. frequencies, was recorded into Cakewalk using the audio recording capability of the program.  The resulting wave files for the notes were then exported from the sequencer and measured in an audio program called Sound Forge.  The results for the test FIR and test IIR filters are shown in Figure 9 and 10 respectively.

 


Figure 8.

           

Besides testing the FIR and IIR filters using the Studioware panel, real-time operation was also tested, and the square wave was used so that changes in harmonic content of the sound could be observed.  To do this, the loop operation of the sequencer was used to loop one note so that it played repeatedly until the stop button was pressed.  While the note played, various controls were changed and the output was monitored through headphones.  After correcting some errors in the MIDI receive program, which caused missed messages, the synth now seems to detect all messages correctly.  It can occasionally miss a message when multiple coefficients are modified at exactly the same time.  However this is not really a problem because using the synth in this way defeats the purpose of having the morph control, which can change any number of coefficients from one set to another using just one controller.

 

Figure 9.

 

Figure 10.

 

 

 

The morph variable was checked and works as expected.  It provides quite a smooth transition from one filter to another.

As a final sequencer test, a test sequence (a.k.a the theme to Star Wars) was written to demonstrate the functionality of the instrument and sent to the synth to play.  It works as expected. 

One thing that occurred occasionally was that when the sequencer was stopped in the middle of a note and before the note off was sent out, the note would continue to play.  Sequencers have an “all notes off” button on them to kill all notes that continue to play in these cases.  Even though this is not in the Design Goals, I decided to add decoding of this to the synth for convenience.  Upon receiving this message, the synth basically clears the note flags array.

            Another addition beyond the Design Goals is a reset controller.  When this controller message is received, the DSP resets and reloads from FLASH.  Effectively it’s a software method of power-cycling the synth

 

B.  Testing using a Keyboard

            The keyboard used to test the live operation of the synth was the Kurzweil 2000.  This is a fairly high-end synth that first came out roughly eight years ago.  All of the user controls on it are assignable to any MIDI controller number.  To

test the various controls, I used a fader on the surface of the synthesizer that is similar to the software ones made in the Cakewalk Studioware panel.  One by one I went through all the controls without a problem, while playing notes with my other hand.  No matter how fast I play or how many notes I play, the synth follows all note on and note off messages fine.

 

IV.       DISCUSSION

A.  Clarification of Results

            Except for occasional missed messages when multiple coefficients are being modified simultaneously, which is actually an incorrect usage of the synth, everything works in real-time as expected. 

            One of the interesting things observed when playing with the synth was that IIR filters can produce very strange results.  Since IIR filters have poles, that means the output can go to infinity when the input has a partial at the location of the pole.  This was observed this a few times when the IIR coefficients were set to certain values that made the output saturate or ring at a high frequency.  Since this is a musical instrument, and the term “musical” is different for different musicians, such ringing or clipping of the signal may be exactly what the user wants.

 

B.  Design Goals Compliance

            In this project, all the design goals were met.  In addition, there were a couple of additions made to the project beyond those mentioned in the Design Goals section.  Specifically these are the all notes off controller and the reset controller.   

 

 

V.        MATERIALS/COST

Table 3 shows the materials and cost of the items that were used in this project.

Table 3.

 

 

 

 

 

 

 

 

 

 

 

VI.       PROJECT SCHEDULE

            Table 4 shows the project schedule.

 

Table 4.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 


VII.      CONCLUSION

            This project was a success.  The synth created is a usable and unique electronic instrument capable of a unique form of sound shaping.  It can be used as a live instrument or with a sequencer.  It shows that filter morphing is a viable form of sound synthesis that should be included in the high-end synthesizers of today. 

It would be interesting to see how this form of synthesis can be extended.  For example, instead of just morphing from one set of coefficients to another, it should be possible to oscillate between them.  Essentially you would have a form of amplitude modulation, where the amplitudes of different harmonics are oscillating by different amounts.

            I’d like to thank my father, Bob Lombardi, for helping me put the synth in the project box.

VIII.     REFERENCES

 

Strum, Robert D. and Donald E. Kirk.  First Principles of Discrete Systems and Digital Signal Processing.  Reading, Massachusetts: Addison-Wesley Publishing Company, 1988.

 

Jaffe, Adrienne Prahler. Implementation of a Software UART on

TMS320C54x Using General-Purpose I/O Pins.  SPRA555.  Texas Instruments, 1999.

 

Wilber, Eric.  Random Number Generation on a TMS320C5X.  SPRA239.  Texas Instruments, 1994.

 

Smile, Eli.  TI 5402 DSK: The Things I Learned the Hard Way. http://elismile.hypermart.net/dsk5402.html.  Last modified 5/7/02   

 

Texas Instruments, Inc.  TMS320C54X Assembly Language Tool’s User Guide.  SPRU102E.  Texas Instruments, June 2001.

 

Texas Instruments, Inc.  TMS320C54X DSKplus User’s Guide.  SPRU191.  Texas Instruments, October 1996.

 

Texas Instruments, Inc.  TMS320C54X DSP Reference Set Volume 1: CPU and Peripherals.  SPRU131G.  Texas Instruments, March 2001.

 

Texas Instruments, Inc.  TMS320C54X DSP Reference Set Volume 2: Mnemonic Instruction Set.  SPRU172C.  Texas Instruments, March 2001.

 

Texas Instruments, Inc.  TMS320C54X DSP Reference Set Volume 5: Enhanced Peripherals.    SPRU302.  Texas Instruments, June 1999

 

.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

IX.       APPENDIX A – MATLAB CODE

 

%This code is referenced by the GUI that was designed to get

% a good idea of filter responses for the 198B synth Spring 2002

%Author: Anthony Lombardi

if a0==a1,

   s0=ones(1,interp_c);

   s0=a0*s0;

else

   s0=a0:(a1-a0)/interp_c:a1-((a1-a0)/interp_c);

end

 

if a1==a2,

   s1=ones(1,interp_c);

   s1=a1*s1;

else

  s1=a1:(a2-a1)/interp_c:a2-((a2-a1)/interp_c);

end

 

if a2==a3,

   s2=ones(1,interp_c);

   s2=a2*s2;

else

   s2=a2:(a3-a2)/interp_c:a3-((a3-a2)/interp_c);

end

 

if a3==a4,

   s3=ones(1,interp_c);

   s3=a3*s3;

else

   s3=a3:(a4-a3)/interp_c:a4-((a4-a3)/interp_c);

end

 

if a4==a5,

   s4=ones(1,interp_c);

   s4=a4*s4;

else

   s4=a4:(a5-a4)/interp_c:a5-((a5-a4)/interp_c);

end

 

if a5==a6,

   s5=ones(1,interp_c);

   s5=a5*s5;

else

   s5=a5:(a6-a5)/interp_c:a6-((a6-a5)/interp_c);

end

 

if a6==a7,

   s6=ones(1,interp_c);

   s6=a6*s6;

else

   s6=a6:(a7-a6)/interp_c:a7-((a7-a6)/interp_c);

end

 

if a7==a8,

   s7=ones(1,interp_c);

   s7=a7*s7;

else

   s7=a7:(a8-a7)/interp_c:a8-((a8-a7)/interp_c);

end

 

if a8==a9,

   s8=ones(1,interp_c);

   s8=a8*s8;

else

   s8=a8:(a9-a8)/interp_c:a9-((a9-a8)/interp_c);

end

  

if a9==a10,

   s9=ones(1,interp_c);

   s9=a9*s9;

else

   s9=a9:(a10-a9)/interp_c:a10-((a10-a9)/interp_c);

  

end

%--------------------------------------------End of FIR coefficients

if b0==b1,

   r0=ones(1,interp_c);

   r0=b0*r0;

else

   r0=b0:(b1-b0)/interp_c:b1-((b1-b0)/interp_c); 

end

 

if b1==b2,

   r1=ones(1,interp_c);

   r1=b1*r1;

else

   r1=b1:(b2-b1)/interp_c:b2-((b2-b1)/interp_c);

end

 

if b2==b3,

   r2=ones(1,interp_c);

   r2=b2*r2;

else

   r2=b2:(b3-b2)/interp_c:b3-((b3-b2)/interp_c);

end

 

if b3==b4,

   r3=ones(1,interp_c);

   r3=b3*r3;

else

   r3=b3:(b4-b3)/interp_c:b4-((b4-b3)/interp_c);

end

%-----------------------------------------End of IIR coefficients

switch Fs_control

case 1,

   Fs=44000;

case 2,

   Fs=22000;

case 3,

   Fs=16000;

case 4,

   Fs=8000;

end

 

if typ_control==1,      %type of filter

   b=1;

else

   b=[1 -r0 -r1 -r2 -r3 -b4];

end        

 

a=[s0 s1 s2 s3 s4 s5 s6 s7 s8 s9 a10];

 

 

[H,W]=freqz(a,b,1024,Fs);

Hm=20*log10(abs(H));  %absolute gain of filter

 

W=log2(W)-4.0314; %change x-scale to musical C octaves

 

 

xc4=[4 4];

yc4=[-200 200];

xc2=[1 1];

yc2=[-200 200];

plot(W,Hm, 'k',xc4,yc4,'k-.',xc2, yc2, 'k-.')

xlabel('Pitch, Octave','FontSize',12)

ylabel('Gain, dB','FontSize',12)

axis([0 8 -100 100]);

text(4, -85, '<-C4, Highest note') %label middle C

text(1, -85, '<-C1, Lowest note') %lowest note of synthesizer

 

 

[imp,t]=impz(a,b);

out=conv(imp,sum_notes);%FIR output for c_notes input

out=out/(10*interp_c);

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

X.        APPENDIX B – TI ASSEMBLY CODE

           

If you would like to see the source code of this project, please send me an email: tonyjlombardi at gmail dot com.

         

XI.       APPENDIX C – Synth User Manual

 

Settings of the synth at startup:

 

           

 

    

 

         

 

 

 

    

      

 

    

    

         

    

 

 

 

 

 

 

             

Table 5.

To change waveform type:

Send controller number 39 to synth with the value corresponding to the waveform:

0 – 31 = sine

32 – 63 = square

64 – 95 = triangle

96 – 127 = noise

 

To change filter number:

Send controller number 37 to synth with the value corresponding to the filter:

0 – 42 = morph

43 – 85 = filter 1

86 – 127 = filter 2

 

To change filter type:

Send controller number 36 to synth with the value corresponding to the filter type:

0 – 63 = FIR

64 – 127 = IIR

 

 

To change filter coefficients:

Send the controller number corresponding to the coefficient as shown in Table 5.

The MIDI range 0 to 127 will be scaled to the range –16256 to 16256 by the synth.

Note:

1.         Filter coefficients cannot be changed when the filter switch is the morph filter.

2.         IIR filter coefficients cannot be changed when filter type is FIR.

 

To change the interpolation value:

Send controller number 38 to synth with the value corresponding to values below.

0 – 10 = 1

11 – 21 = 2

22 – 31 = 3

32 – 42 = 4

43 – 52 = 5

53 – 63 = 6

64 – 74 = 7

75 – 84 = 8

85 – 95 = 9

96 – 105 = 10

106 – 116 = 11

117 – 127 = 12

 

Note:

1.         Interpolation value cannot be changed when filter switch is morph filter.

2.         Interpolation value is not used when filter type is IIR.

 

To change the morph value:

Send controller number 1 to the synth with the value corresponding to the values below:

0 = filter 1 .................interpolated between filter 1 and filter 2.............127 = filter 2

 

To morph between filter 1 and filter 2, with the filters having different interpolation values. 

1.         Set filter number to filter 2.

2.         Set coefficients for filter 2.

3.         Set interpolation value for filter 2.

3.         Set filter number to filter 1.

4.         Set coefficients for filter 1.

5.         Set interpolation value for filter 1.

6.         Set filter number to morph filter.

Note:  The filters must be set in this order.  Otherwise both will have the same interpolation values.

 

To reset the synth:

Send controller number 100 to the synth with any value.

 

To turn all notes off:

Send controller number 123 to the synth with any value.

Note:  All sequencers have a button that sends this message.  Simply click this button to send the message to the synth.