You are on page 1of 219

Guitar Effects Unit

- based on analog and digital signal processing -

Department of Electronic Systems


6th semester
Aalborg university 2007
Project group 07gr642
Department of Electronic Systems
Fredriks Bajers Vej 7
http://es.aau.dk

Title:
Guitar Effects Unit Abstract:
Theme:
Signal Processing Algorithms and This project describes and documents the
Systems design and implementation of a guitar
effects unit that consists of both analog
and digital effects.
Project period:
On basis on descriptions of the most
E6, spring semester 2007 common guitar effects, the group have
chosen to implement wah wah, tremolo,
reverberator, echo, delay and equalizer
Project group: effects. The wah wah and tremolo effects
07gr642 are implemented as analog effects and
the remaining effects are implemented
as digital effects. To be able to execute
Participants: the digital effects, a DSP system has
been constructed. Since the constructed
Morten Christophersen DSP system has little memory and speed,
Jesper Rindom Jensen all effects have been implemented in
Mark Aarup Mikaelsen assembler code to ensure a low execution
Jesper Kjær Nielsen time.
Thomas Deleuran Rasmussen
Tests of the analog effects verify that
the effects have the desired functionalities
Supervisor: though not all the requirements are ful-
Per Rubak filled. Both effects, however, produce the
characteristic sound of the effect. The digi-
tal effects have been implemented and they
Copies: 7 are fully functional. However, it is not pos-
sible to use all digital effects at once since
Page numbers: 205 the execution time between each interrupt
will be to long.
Enclosures: CD-ROM

Date of completion: 30. May 2007


The content of this report is freely available, but publication (with reference source) may only be pursued
due to agreement with the respective authors.
Preface

This report is written by project group 07gr642 at the department of Electronic Systems
on Aalborg University during the 6th semester in the period spanning from February
1st, 2007 to May 30th, 2007. The project concerns the design of a guitar effects unit
and is subject to the theme of the semester ”Signal processing algorithms and systems”.
According to the curriculum the purpose of the 6th semester signal processing is to enable
the student to [Aalborg Universitet, 2005]:

• Perform a synthesis on a real time analog/digital signal processing system on the


basis of specifications to a given application.
• Make use of methods and theories related to design, realization and test of digital
signal processing algorithms and software implementation of those algorithms at
programmable digital signal processors.

The report is aimed at people with knowledge equivalent to the teaching on the 6th
semester signal processing. The project ”Guitar Effects Unit” is proposed by Sofus
Birkedal Nielsen.

The reader should pay attention to the following on perusal of this report:
• The report is divided into two major parts:
- The main report which is divided into numbered chapters.
- The appendices which are arranged alphabetically.
• Figures, tables and equations are numerated consecutively according to the chapter
number. Hence, the first figure in chapter one is named figure 1.1, the second figure
figure 1.2 and so on.
• The use of symbols is given in the nomenclature after the preface.
• The Harvard method is used for citation. The bibliography can be found after the
main report.
• The CD-ROM contains data sheets, internet sources, MATLAB scripts and assem-
bler code used in this project.
• The guitar effects unit is divided into a number of blocks whose components are
named after the block number. Det complete circuit diagram is shown in appendix
N.

II
Aalborg University May 30th, 2007

Jesper Rindom Jensen Morten Christophersen


<jesperrj@es.aau.dk> <mortench@es.aau.dk>

Mark Aarup Mikaelsen Jesper Kjær Nielsen


<markaa@es.aau.dk> <jkjaer@es.aau.dk>

Thomas Deleuran Rasmussen


<jazzy@es.aau.dk>

III
Report Overview

The main report contains the following chapters:

Introduction
In the first chapter of the report an introduction to signal processing in music in
general is given. Following this is a description of electrical guitars including a
description of two different types of pickups. Based upon this there is stated an
initiating problem formulation which ends the chapter.

Electric Guitar Effects


In this chapter typical guitar effects are categorized and described which are an-
swering some of the questions stated in the initiating problem formulation.

Requirements Specification
In this chapter the guitar effects unit is divided into Use Cases. The Use Cases are
defined so that the effects unit has the desired functionalities and a description of
the Use Cases is given. Following this the actual system requirements are specified
and organized under the relevant Use Cases. Based on the requirements the final
problem formulation is stated.

System Overview
In this chapter a technical overview of the effects unit is given. It is specified how it
should be possible to change the order of the individual effects and it is described
how the interface between the user and the system is.

Tremolo
In this chapter the tremolo effect is designed. First the different circuits required
for the tremolo are analyzed and one of the headlines here is how a sine wave is
generated from a triangular wave. Next the component values are dimensioned, the
effect is simulated and measured.

Wah Wah
In this chapter the wah wah effect is designed. First a block diagram which has
the functionalities required for the wah wah effect, is given. Afterwards the block
diagram is realized through analog circuits with the same properties. These circuits
are then dimensioned and finally the effect is simulated and measured.

DSP Hardware Design


In this chapter the DSP system is described. The chapter begins with the block

IV
diagram of the DSP system and the DSP, and its properties are described. Following
this the design of the A/D and D/A converter circuit for the system is made.
Afterwards calculations on the memory timing are made and the chapter is ended
with a description of the user interface with regard to the hardware.

Software Design
In this chapter it is described how the software for the guitar effects unit is designed.
The chapter begins with an overview of the software design which is done with a
data flow diagram. Next, the program flow is described in more detail and here
calculations on how much time there is available between each sample for signal
processing is made. Finally, the chapter concludes with an overview of how the
effects are organized in the memory.

Reverberation
In this chapter the reverberation effect is designed. Before the actual design is made,
it is specified what reverberation really is. Based on this two different algorithms for
making reverberation are described and analyzed, and one of them is dimensioned
and implemented. After this it is described how the effect is implemented including
calculations of scaling and signal-to-noise ratio (SNR).

Echo, Delay, Flanger and Chorus


The echo, delay, flanger and chorus effects are described in one chapter because of
their similarities with regard to their design. Each effect is analyzed, dimensioned
and simulated and the chapter concludes with a description of the implementation.

Equalizer
In this chapter the equalizer effect is designed. The design is based on a descrip-
tion of two typical equalizer types. Next the effect is analyzed, dimensioned and
simulated. The chapter ends with a description of the implementation and mea-
surements of the effect.

System Test
In this chapter the results of the system measurements are given and interpreted.
This means conclusions on the signal-to-noise ratio, utilization, listening and rout-
ing tests.

Conclusion
In this chapter the final conclusion on the guitar effects unit is made. Conclusions
are made on the individual effect.

V
Nomenclature

This chapter gives the basic terminology that is used to describe relationships between
different physical and mathematical symbols and units in this report. The core of the
terminology is taken from ISO 31 [ISO 31, 1993]. The IEC 60027 and different textbooks
are used as reference for those areas that are not covered by ISO 31.

Symbols and Units


Symbols and Units According to ISO 31
Symbols are written with a single letter from the Latin or Greek alphabet and can be
augmented with subscripts. All symbols are written in italics while subscripts can be
written in either roman or italics. A subscript must be written in italics if it represents
a symbol of a mathematical or physical quantity such as mass, current or symbols for
numbers. In descriptive cases the subscript is written in roman. Symbols for vectors and
matrices are written in both italics and bold.

The used units are all SI-units. Units are written in roman and never have subscripts.
Prefixes and numbers are written in roman as well. Some examples of different symbols
and units are shown in table 1.

Symbol Description
A Scalar quantity in italics.
Ar Symbol in italics with roman subscript.
Am Symbol in italics with subscript in italics.
A Vectors and matrices in bold and italics.
mA Unit and prefix in roman.
123.4 Numbers in roman.

Table 1: Some examples of notation recommended by ISO 31.

Electric Signals in Time and Frequency Domain


Electric signals can be characterized with its AC component, DC component, RMS value
and peak value. In this report the symbols shown in table 2 and figure 1 are used to
distinguish between the different expressions. Thus, an arbitrary signal vA (t) can be

VI
divided into its DC component and AC-component denoted by v̄A + va (t). Sometimes
(t) is omitted for convenience (vA (t) is written as vA ).

Type Signal RMS Peak vba va (t)


Total vA (t) VA -
DC v̄A v̄A v̄A
AC va (t) Va vba v̄A
vA (t)
Table 2: Expressions for AC component, DC
component, RMS value and peak value.

Figure 1: AC and DC component of a signal.

Signals in the frequency domain are written in uppercase italics. Hence, the Laplace
transformed of the time domain signal va (t) is denoted by Va (s). Transfer functions and
impedances are written in a similar way.

Discrete Signals
Neither ISO nor IEC 60027 states specific symbols to be used within the scope of discrete
mathematics. For this reason the nomenclature from Discrete-time signal processing by
Alan V. Oppenheim and Ronald Schafer is used.

A function x which is dependent on a discrete variable n is denoted by x[n]. To distinquish


between analog and digital angular frequency, analog angular frequency is written with
capital omega, Ω, while digital angular frequency is written with lower-case omega, ω.
The relationship between analog and digital angular frequency is [Oppenheim and Schafer,
1999]

ω= , (1)
fs
where fs is the sampling frequency. Note, that the analog angular frequency in other
relations than discrete mathematics is denoted by lower-case omega, ω.

Digital Electronics
If a pin is active low, the asterisk-character * is used. When signals are manipulated by
means of DeMorgans rules, an overline is used [Wakerly, 2001]. The radix of a number
is written with the base in subscript such as 10012 , 1A16 . If the radix is 10, the base is
omitted.

Table of Used Symbols and Units


The used physical and mathematical symbols and units are shown in table 3.

VII
Quantity Symbol Unit Reference
Physical quantities
Frequency f Hz, s−1 ISO 31
Impedance Z(s) Ω ISO 31
Capacitance C F ISO 31
Resistance R Ω ISO 31
RMS voltage V V IEC 60027
RMS current I A IEC 60027
Peak voltage vb V IEC 60027
Peak current bi A IEC 60027
Angular frequency ω rad/s ISO 31
Instantaneous voltage v V ISO 31
Instantaneous current i A ISO 31
Mathematical quantities
Analog angular frequency (discrete mathe- Ω rad/s Oppenheim
matics)
Argument, angle ∠ϕ N/A IEC 60027
Angular frequency (discrete mathematics) ω rad ISO 31
Discrete function x[n] N/A ISO 31
Convolution ∗ N/A ISO 31
Imaginary unit j N/A ISO 31
Complex number z N/A ISO 31
Mean value x̄ N/A ISO 31
Signal in frequency domain V (s) N/A ISO 31

Table 3: Used physical and mathematical quantities, symbols and units.

VIII
Table of Contents

1 Introduction 1
1.1 The Electric Guitar . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1
1.2 Initiating Problem Formulation . . . . . . . . . . . . . . . . . . . . . . . . 4

2 Electric Guitar Effects 6


2.1 Amplitude Tweaking Effects . . . . . . . . . . . . . . . . . . . . . . . . . . 6
2.2 Frequency Tweaking Effects . . . . . . . . . . . . . . . . . . . . . . . . . . 8
2.3 Time Tweaking Effects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
2.4 Pre-limitations and Sequential Order of Effects . . . . . . . . . . . . . . . 10

3 Requirement Specification 12
3.1 General Description by Use of Use Cases . . . . . . . . . . . . . . . . . . . 12
3.2 References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.3 Specific Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 14
3.4 External Interface Requirements . . . . . . . . . . . . . . . . . . . . . . . 17
3.5 Additional Requirements . . . . . . . . . . . . . . . . . . . . . . . . . . . . 18
3.6 Acceptance Test Specification . . . . . . . . . . . . . . . . . . . . . . . . . 19
3.7 Limitations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
3.8 Problem Formulation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21

4 System Overview 22
4.1 System Parts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 22
4.2 Choice of Effects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

5 Tremolo 25
5.1 Design of Tremolo Effect . . . . . . . . . . . . . . . . . . . . . . . . . . . . 25
5.2 Implementation of Tremolo . . . . . . . . . . . . . . . . . . . . . . . . . . 39
5.3 Simulation of Tremolo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 40
5.4 Measurements of Tremolo . . . . . . . . . . . . . . . . . . . . . . . . . . . 42
5.5 Conclusion on Tremolo Effect . . . . . . . . . . . . . . . . . . . . . . . . . 43

6 Wah Wah 44
6.1 Implementation of Wah Wah . . . . . . . . . . . . . . . . . . . . . . . . . 45
6.2 Input and Output Impedance . . . . . . . . . . . . . . . . . . . . . . . . . 46
6.3 Simulation of Wah Wah . . . . . . . . . . . . . . . . . . . . . . . . . . . . 46
6.4 Measurements of Wah Wah . . . . . . . . . . . . . . . . . . . . . . . . . . 47

X
TABLE OF CONTENTS

6.5 Conclusion on Wah Wah Effect . . . . . . . . . . . . . . . . . . . . . . . . 48

7 DSP Hardware Design 49


7.1 Overview of Digital Hardware Platform . . . . . . . . . . . . . . . . . . . 49
7.2 A/D and D/A Conversion . . . . . . . . . . . . . . . . . . . . . . . . . . . 52
7.3 Memory Timing and Address Decoding . . . . . . . . . . . . . . . . . . . . 55
7.4 User Interface . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 60

8 Software Design 62
8.1 Data Flow Analysis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62
8.2 Program Flow . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 64
8.3 Memory Management . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 65

9 Reverberation 66
9.1 Real and Simulated Reverberation . . . . . . . . . . . . . . . . . . . . . . 66
9.2 Reverberation Algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . 67
9.3 Design of Reverberator . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 77
9.4 Implementation of Reverberator . . . . . . . . . . . . . . . . . . . . . . . . 78
9.5 Reverberation Memory Requirements . . . . . . . . . . . . . . . . . . . . . 84
9.6 Conclusion on Reverberator . . . . . . . . . . . . . . . . . . . . . . . . . . 85

10 Echo, Delay, Flanger and Chorus 87


10.1 Echo Effect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 87
10.2 Delay Effect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 88
10.3 Flanger Effect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 89
10.4 Chorus Effect . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90
10.5 Memory Requirements for Echo, Delay, Chorus and Flanger Effects . . . . 91
10.6 Implementation of Echo and Delay on DSP . . . . . . . . . . . . . . . . . 92
10.7 Conclusion on Echo, Delay, Chorus and Flanger Effects . . . . . . . . . . . 92

11 Equalizer 93
11.1 Parametric and Graphical Equalizers . . . . . . . . . . . . . . . . . . . . . 93
11.2 Design of Equalizer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93
11.3 Simulation of Equalizer . . . . . . . . . . . . . . . . . . . . . . . . . . . . 97
11.4 Implementation of Equalizer Filters . . . . . . . . . . . . . . . . . . . . . . 99
11.5 Measurements of Equalizer . . . . . . . . . . . . . . . . . . . . . . . . . . . 100
11.6 Conclusion on Equalizer . . . . . . . . . . . . . . . . . . . . . . . . . . . . 100

12 System Test 101


12.1 SNR Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101
12.2 Utilization Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
12.3 Listening Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
12.4 Routing Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104

13 Summary and Conclusion 105

XI
Table of Contents

Bibliography 109

Appendices 111

A Electric Model of Guitar 111

B Tremolo Elaborations and Calculations 113

C Wah Wah Transfer Function and Component Values 121

D The Bilinear Transformation 125

E Noise on Lowpass Comb Filter for Reverberator 128

F Measurement Report: Output Impedance of Electric Guitar 130

G Measurement Report: Frequency Analysis of Electric Guitar 133

H Measurement Report: Guitar Output Voltage 135

I Measurement Report: Wah Wah Frequency Response 137

J Measurement Report: Tremolo Amplitude Response 139

K Measurement Report: Equalizer Amplitude Response 143

L Measurement Report: Signal Noise Ratio Test 146

M Measurement Report: Utilization Test 148

N Guitar Effect Unit Schematics 150

O Source Code 154

Enclosure: CD-ROM 205

XII
Chapter 1
Introduction

Signal processing in music has a wide range of applications. Coding, compression, equal-
ization, compensation and sound effects are some of the areas of music that benefit from
signal processing. This report concerns the development of a guitar effects unit which
is an excellent example of the power and applicability of music signal processing. The
source signal from the electric guitar is fed to the effects unit which manipulates the
signal by use of different effects. This enables the guitar to be used in a variety of music
genres which have different sound requirements.

1.1 The Electric Guitar


In the 1930s musicians often found that the acoustic guitar could not be heard over
the sound of other instruments. As a result, experiments were carried out in order to
amplify the sound of the acoustic guitar, but it was never a complete success since the
amplification often suffered from feedback problems caused by the hollow body of the
acoustic guitar [Brain, 2004]. In the 1940s a solution to the feedback problem was found
by the invention of the solid body guitar also known as the electric guitar.

The Electric Guitar as a Signal Source


Since the electric guitar has a solid body, it is an acoustic dead instrument and is therefore
often dependent on external signal processing and amplification. The signal processing
manipulates the output signal of the guitar before it is fed to a power amplifier that
drives a loudspeaker. The manipulation gives the guitar its sound and compensates for
the lack of acoustics of the solid body. This makes the signal processing an essential part
of the electric guitar.

The output signal from the electric guitar is generated by a pickup which acts as a trans-
ducer that converts mechanical vibration into an electric signal [Wikipedia, 2007]. The
mechanical vibration is created by the guitarist when he or she is plucking one or more
strings.

Two basic types of pickups exist which are magnetic and piezoelectric pickups [Lemme,
2003]. Magnetic pickups consist of magnets and coils beneath each string and therefore
require steel strings to work. When a string is moved a voltage is induced in the coil
directly beneath it. The induced voltage is proportional to the velocity of the string and
fluctuating with the same frequency as the string [Lemme, 2003]. The output voltage of

1
1 Introduction

the guitar is the sum of the induced voltages from each coil.

Piezoelectric pickups generates a voltage in response to mechanical stress and are there-
fore not limited to steel strings [Wikipedia, 2007]. In addition piezoelectric pickups are
immune to electromagnetic disturbances in contrast to magnetic pickups.

In this project an electric guitar with magnetic pickups is used for which reason only
magnetic pickups will be investigated further.

Equivalent Circuit of Magnetic Pickups

Since the magnetic pickup consists of a coil, the impedance of the pickup is equal to the
impedance of the coil. In figure 1.1(a) the coil is modeled with an inductance, a resistance
and a capacitance [Lemme, 2003]. The resistance models the ohmic loss in the wire of
the coil and the capacitance models the capacitive load between the wounded wires. The
resistance and capacitance have typically negligible effects on the frequency response of
the pickup and can therefore be neglected [Lemme, 2003].

L R
L R

vG(t) C

C
(a) The impedance of the magnetic pickup. (b) The magnetic pickup as a signal source.

Figure 1.1: Electric models of the magnetic pickup.

When a string is plucked, a voltage is induced and the electric guitar works as a signal
source. The signal source can be included in the equivalent circuit of the magnetic pickup
as shown in figure 1.1(b) [Lemme, 2003].

Active and Passive Pickups

Some guitars contain battery powered pickups which contain electronic circuitry that
modifies the signal. These pickups are called active pickups and are typically used to
flatten out the frequency response of the pickup [Wikipedia, 2007]. The frequency re-
sponse is flattened since the amplification makes it possible to construct the coil of the
pickup with fewer windings for which reason the inductance is decreased.

2
1.1. The Electric Guitar

Volume and Tone Control


Since the guitarist often needs to adjust the volume and frequency response, it is con-
venient to place volume and tone control on the guitar. The volume control typically
consists of a potentiometer and the tone control typically consists of a capacitor and a
potentiometer. An example of the implementation of volume and tone control is described
in appendix A page 111.

The Output Voltage, Frequency Content and Output Impedance of the Guitar

vG(t)

Figure 1.2: Model of the electric guitar as a signal source.

The total model of the used electric guitar is described in appendix A. The important
part of the guitar model viewed from the input stage of effects unit is shown in figure 1.2.
The impedance Z models the output impedance and consists of the impedance of the
tone control, volume control and active/passive pickup. The induced voltage is modelled
by the voltage source vG (t) whose amplitude and frequency content is of interest.

Three different measurements have been carried out in order to determine the output
impedance Z and the maximum amplitude and frequency content of the voltage source
vG (t). In appendix F page 130, G page 133 and H page 135 the details of the measure-
ments are given. Figure 1.3 page 5 shows the result of the measurements.

The output impedance of the guitar with the active pickup is shown in figure 1.3(a). The
output impedance has a magnitude of 17 kΩ at DC and decreases to a value of 6 kΩ. The
20 dB/dec-slope in the frequency interval ranging from DC to around 60 Hz is caused by
the tone control which has a pole at DC and a zero that causes a break in the frequency
response at 60 Hz at least.

The output impedance of the guitar with the passive pickup is shown in figure 1.3(b).
The impedance plot has a peak at a frequency of 5 kHz where the impedance is measured
to have a magnitude of about 90 kΩ. The peak is caused by the inductance of the pickup
and the capacitance of the capacitor in the tone control. If the guitar effects units must
be able to function with a guitar with passive pickup, it must have an input impedance
that is much greater than 90 kΩ.

The frequency content of the output voltage when the high E is played, is shown in figure
1.3(c). The fundamental frequency is about 1.2 kHz and the first six harmonics are shown.
The difference between the fundamental frequency and the first and second harmonic is

3
1 Introduction

15 dB, and the difference is about 40 dB to the third, fourth and fifth harmonics. The
sixth harmonic has an amplitude that is about 50 dB lower than the amplitude of the
fundamental frequency.

The total amplitude of the output signal has a maximum of 2.28 V. In total this concludes
the important properties of an electric guitar as a signal source which are summarized in
table 1.1.

Maximum magnitude of output impedance1 90 kΩ


Maximum frequency component of significance 7.2 kHz
Maximum amplitude of output voltage 2.28 V

Table 1.1: Important properties of the electric guitar as a signal source.

1.2 Initiating Problem Formulation


The signal processing is an essential part of the electric guitar because of the sound
manipulation. The manipulation of the output signal of the guitar can consist of several
effects that in some way change the sound of the electric guitar into something useful. This
raises a couple of questions to the requirements and performance of the signal processing:

• Which electric guitar effects are commonly used,

• how do they work,

• how are they designed,

• how are they implemented?

The answers to these questions will be the main topic of this report. In particular the
last two questions will be treated with greatest detail.

1
With the volume and tone control settings as described in appendix F, G and H.

4
1.2. Initiating Problem Formulation

4 4
x 10 x 10
1.8 9

8
1.6

7
1.4
6
Impedance [Ω]

Impedance [Ω]
1.2 5

1 4

3
0.8
2

0.6
1

0.4 0
0 1 2 3 4 5 1 2 3 4 5
10 10 10 10 10 10 10 10 10 10 10
Frequency [Hz] Frequency [Hz]

(a) Output impedance of guitar with active pick- (b) Output impedance of guitar with passive pick-
ups. ups.

−10

−20
Amplitude [dB]

−30

−40

−50

−60
0 1000 2000 3000 4000 5000 6000 7000 8000 9000
Frequency [Hz]

(c) Frequency content of output voltage generated by the high E.

Figure 1.3: Measurements of guitar characteristics.

5
Chapter 2
Electric Guitar Effects

The following sections introduce some of the basic guitar effects that are possible to
implement. These effects used to tweak the sound of the guitar can be categorized into
three sub categories.

• Amplitude tweaking effects: Effects that modify the amplitude of a signal, only
dependent on the signal amplitude.

• Frequency tweaking effects: Effects that modify the amplitude of a signal at


certain frequencies.

• Time tweaking effects: Effects that modify a signal by adding one or more
delayed and tweaked copies of the signal itself.

In the following sections some of the most basic guitar effects are described.

2.1 Amplitude Tweaking Effects


2.1.1 Overdrive
The overdrive effect was originally made by overdriving a tube amplifier. In this way the
signal was clipped so that the music was distorted. But due to the tube characteristic
the signal was softclipped as illustrated in figure 2.1.
Amplitude

Time

Figure 2.1: Input (the dotted lines) and output (the solid lines) of the asymmetric overdrive effect.

6
2.1. Amplitude Tweaking Effects

The sound caused by the overdrive can be tweaked by adjusting the gain of the amplifier
making the sine wave look more like a square. The important thing to notice is the
round edges of the square-like function as seen on figure 2.1. It is also noticed that the
overdriven wave is asymmetric.

2.1.2 Tremolo

The tremolo effect gives the sound of the guitar a pulsating effect. This is done by ad-
justing the amplitude of the signal up and down periodically. This can be implemented
by multiplying the signal with a low frequency wave. Since the signal phase is not to be
changed the wave must be offset so that it is always positive as illustrated on figure 2.2.

Input signal Low frequency sine wave w. offset


1 1

0.5 0.8
Amplitude

Amplitude

0 0.6

−0.5 0.4

−1 0.2
0 0.5 1 1.5 2 0 0.5 1 1.5 2
Time Time

Output signal
1

0.5
Amplitude

−0.5

−1
0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2
Time

Figure 2.2: Input and output of the tremolo effect.

If the low frequency wave is made adjustable the user can tweak the sound to his prefer-
ence.

7
2 Electric Guitar Effects

2.2 Frequency Tweaking Effects

2.2.1 Wah Wah

The wah wah effect passes the music through a narrow bandpass filter. The guitarist is
able to control the filter’s center frequency in real time typically with a foot pedal. The
gain is set as fixed specifications and the range of the center frequency and bandwidth
must be determined. The amplitude response of the filter is shown on figure 2.3.

Frequency range

Band-
Amplitude

width
Gain

fc
Frequency

Figure 2.3: The amplitude response of the filter for the wah wah effect.

2.2.2 Graphical Equalizer

The graphical equalizer is made by splitting the frequency spectrum up into a number of
bands. The center frequency of each band is typically set so that it is an octave higher
than the center frequency of the previous band. The volume of each individual band can
be adjusted in a given preset range. This gives the musician the possibility to amplify
or attenuate some frequency parts of the music. An alternative equalizer type is the
parametric equalizer where the user furthermore is able to adjust the band frequencies.

2.2.3 Pitch Shift

A pitch shifting effect alters the frequency response of the signal, usually by doubling
or halving the frequency contents. The effect can be realized by making an Fourier
transformation of the input signal and altering the frequency composition shifting the
frequency contents either up or down.

8
2.3. Time Tweaking Effects

2.3 Time Tweaking Effects


2.3.1 Delay
The most basic type of a time based effect is a delay. A copy of the input signal is delayed
and often attenuated and then added to the original signal as shown on figure 2.4.
Input Output
Ȉ

Delay G

Figure 2.4: Block diagram of the delay effect.

Applying this effect to a guitar will make it seem as if the same note was played twice.

2.3.2 Flanging
Another type of time based effects is the flanger which works much like the delay, but
with varying delay length. This is done by sine modulating the delay length, typically
with a 0.1 Hz to 1 Hz sine [Zölzer, 2005]. The length of the delays are usually varied
between 0 ms to 15 ms. The principle of the effect is shown in figure 2.5.
Input Output
Ȉ

Delay G

Figure 2.5: Block diagram of the flanger effect.

2.3.3 Chorus
Like the flanger, the chorus uses a modulated delay length, but instead of a sine mod-
ulation a random modulation is used [Zölzer, 2005]. In chorus the feedforward gain is
also modulated with a variable gain factor. These modulations simulates the small dif-
ferences of two guitarists playing the same music at the same time. By adding additional
feedforward loops with different parameters, the effect will sound like more guitarists are
added. Figure 2.6 shows the principle.

2.3.4 Echo
The echo effect will feedback a dampened and delayed copy of the output signal and add
it to the input as shown on figure 2.7 thereby creating an echo. The delay must be above
50 ms to ensure that the effect is perceived as an echo [Zölzer, 2005]. As a result of the
feedback loop the output will consist of several dampened copies of the original signal in
addition to the input signal.

9
2 Electric Guitar Effects

Input Output
Ȉ

Delay1 G1

Delay2 G2

Figure 2.6: Block diagram of the chorus effect. More feedforward loops can be added.

Input Output
Ȉ

Delay G

Figure 2.7: Block diagram of the echo effect.

2.3.5 Reverberation
Reverberation simulates room acoustics by adding the acoustics of a desired room to the
music as if it was played in this room. In short, when music is played in a room, there
will be reflections of the sound when it hits the surrounding walls and objects inside
the room. At some point these reflections will reach the listener and add to the sound
perceived by the listener. Different rooms will give different reflections and thereby alter
the listening experience uniquely. The reflections in a room over time can be shown as on
figure 2.8 where the impulse response of a room is shown. Especially the early reflections
characterize the sound experience.
Early Late
reflections reflections
Amplitude

Time

Figure 2.8: An example of a room impulse response.

2.4 Pre-limitations and Sequential Order of Effects


It is chosen to design all of the above described effects except from the overdrive and the
pitch shifter. It is difficult to predict the sound of the overdrive because of the operation

10
2.4. Pre-limitations and Sequential Order of Effects

range of the transistors. Therefore a great deal of trial and error design is required. Thus,
due to the time limitation it is chosen not to focus on this effect. It is also chosen not to
implement a pitch shifter due to time limitations.

Since not all effects are linear, it matters in which order the different effects are processed.
Hence, it must be possible to change the order of the effects. Some effects are implemented
as analog effects and some as digital. To simplify the system, the user cannot insert an
analog effect between two digital effects.

11
Chapter 3
Requirement Specification

In this chapter, the requirements and acceptance tests for the guitar effects unit are
specified. The guitar effects unit is described by use of Use Cases which is a part of UML
[Bennet, Skelton, and Lunn, 2001]. The requirements are then specified and arranged
under each of the Use Cases. Afterwards, acceptance tests to each of the requirements
are stated to verify that the requirements are fulfilled. The chapter ends with specifying
the limitations of the project and the problem formulation.

3.1 General Description by Use of Use Cases

Guitar effects unit

Show status

"User"
Configure effects

«includes»

Tweak signal

"Guitar" "Amplifier"

Figure 3.1: Use Case diagram of the guitar effects unit.

Figure 3.1 shows the Use Case diagram of the guitar effects unit. The interface to the
system as a whole is on the figure represented by a rectangle, the actors are represented
by matchstick men and the Use Cases are represented by ovals. In the following the
interface, the actors and the Use Cases are described respectively.

3.1.1 Actors of the Guitar Effects Unit


There is a total of three actors interacting with the guitar effects unit. These are ”User”
which is the person who attend the effects unit, ”Guitar” which is the electrical guitar
that is connected to the effects unit and ”Amplifier” which is the unit that amplifies the
tweaked sound signal to a desired level.

12
3.1. General Description by Use of Use Cases

3.1.2 Interfaces of the Guitar Effects Unit


The guitar effects unit interfaces, as mentioned, with three actors. The interface between
the ”User” and the guitar effects unit consists of a display and a keyboard, by which the
”User” should be able to read the current status of the guitar effects unit and configure the
effects respectively. Besides this the guitar effects unit has an interface to the ”Guitar”.
This consists of an input channel that receives the sound signal from the ”Guitar”. Finally
the guitar effects unit interfaces with ”Amplifier” and here the interface constitutes of an
output channel on the guitar effects unit from which the tweaked sound signal is sent.

3.1.3 Use Cases of the Guitar Effects Unit


In the following text the Use Cases of the guitar effects unit are described.

Show Status
- Goal description
Shows current effect configurations to the user. This is done by use of a display.

- Normal scenario

1. The guitar effects unit retrieves the chosen configuration parameters.


2. The guitar effects unit shows the chosen configuration parameters on a display.

- Exceptions
None.

Configure Effects
- Goal description
According to the user inputs from the keyboard it changes the effect configurations.

- Normal scenario

1. The guitar effects unit retrieves an input from the user.


2. The guitar effects unit changes the effect parameters if this is indicated by the
user input.

- Exceptions
None.

Tweak Signal
- Goal description
Tweaks the input signal from the guitar and sends the tweaked signal to an amplifier.
How the signal is tweaked, depends on the user configuration.

13
3 Requirement Specification

- Normal scenario

1. The guitar effects unit retrieves an input signal from the guitar.
2. The guitar effects unit tweaks the retrieved signal pursuant to the user con-
figuration.
3. The guitar effects unit sends the tweaked signal to the output channel con-
nected to an amplifier.

- Exceptions
If the user wants the guitar signal to be sent unchanged through the guitar effects
unit, it should be possible to bypass both the analog and digital effects.

3.2 References
The requirements are mainly specified on the basis of a user’s manual to the G•Major
guitar effects processor from t.c. electronic. Besides this the DIN 45 500 standard is
used.

3.3 Specific Requirements


Show status
Specification 1. Status types
Source and description
In order to see how the current configuration of the effects is, it should be possible
for the user to view the different effect parameter values on a display. The effect
parameters that can be shown, are specified and described later in section 3.3.

Acceptance tests
Acceptance test specification for status types is found in acceptance test 1 page 19.

Configure Effects
Specification 2. Parameter configuration
Source and description
It should be possible for the user to scroll through the different effects and change
the parameters for each effect by use of the keyboard. The effect parameters that
can be changed are specified and described later in section 3.3.

Acceptance test
Acceptance test specification for parameter configuration is found in acceptance
test 2 page 19.
Specification 3. Routing

14
3.3. Specific Requirements

Source and description


It should be possible for the user to change the order of the digital and analog
effects. However it should not be possible to insert an analog effect between two
digital effects. Therefore it should only be possible to place analog effects either
before or after all digital effects.

Acceptance test
Acceptance test specification for routing is found in acceptance test 3 page 19.

Tweak Signal
Specification 4. Tremolo

Source and description


The tremolo effect is controlled with the parameters: Rate, depth and type. Rate
specifies the frequency at which the tremolo changes the amplitude of the signal,
and depth is the amount of attenuation. The type parameter specifies whether
modulation is a sine, triangle or square, which alters the steepness of the tremolo.
With inspiration from the G•Major manual [t.c. electronic, 2001], this leads to the
following specifications:

– Rate ranges from 0.1 Hz to 10 Hz.


– Depth ranges from 0 dB to -60 dB.
– Type can be either sine, triangle or square function.

Acceptance test
Acceptance test specification for tremolo is found in acceptance test 4 page 20.

Specification 5. Wah Wah

Source and description


The wah wah effect must have a variable center frequency and adjustable band-
width. The demands for the wah wah is set based on what the group has found
reasonable.

– Center frequency ωc adjustable from 150 Hz to 2000 Hz.


– Q-factor adjustable from 1 to 10.
– Gain factor 0 dB.

Acceptance test
Acceptance test specification for wah wah is found in acceptance test 5 page 20.

Specification 6. Equalizer

15
3 Requirement Specification

Source and description


The equalizer effect must be a three band graphical equalizer. Therefore the cutoff
frequencies must be predetermined. The equalizer is controlled by adjusting the
amplitude of each frequency band. With inspiration from the G•Major manual
[t.c. electronic, 2001], this leads to the following specifications:

– Frequency bands can be adjusted from -24 dB to 0 dB in steps of 1 dB.


– There must be three logarithmic equally sized bands in the frequency range
from 80 Hz to 7800 Hz.

Acceptance test
Acceptance test specification for equalizer is found in acceptance test 6 page 20.

Specification 7. Delay/Echo

Source and description


The delay effect uses the parameters, delay time and gain. Delay time specifies
the duration before the signal is repeated and gain specifies the gain of the delayed
signal. When echo is selected, higher gain affects the number of hearable repetitions.
With inspiration from the G•Major manual [t.c. electronic, 2001] and [Zölzer, 2005],
this leads to the following specifications:

– Delay time ranges from 50 ms to 600 ms in steps of 50 ms.


– Gain ranges from 0% to 80% in steps of 10%.

Acceptance test
Acceptance test specification for delay/echo is found in acceptance test 7 page 20.

Specification 8. Reverberation

Source and description


The reverberation effect uses the parameters, reverberation time, pre-delay and
reverberation level. Reverberation time specifies the length of the reverberation
tail (both early and late reflections) until it has decayed 60 dB. Pre-delay specifies
the time before the early reflections start. Reverberation level specifies the level of
the reflections. With inspiration from the G•Major manual [t.c. electronic, 2001],
this leads to the following specifications:

– Reverberation time ranges from 0.1 s to 4 s in steps of 0.1 s from 0.1 s to 1 s


and 0.5 s from 1 s to 4 s.
– Pre-delay ranges from 0 ms to 100 ms in steps of 10 ms.
– Reverberation level ranges from 10 % to 100 % in steps of 10 %.

Acceptance test
Acceptance test specification for reverberation is found in acceptance test 8 page
21.

16
3.4. External Interface Requirements

Specification 9. Chorus/Flanger

Source and description


Both effects are tweaked using the parameters, rate and depth. Rate specifies the
frequency at which the delay time is modulated. Depth specifies how much the
signal is modulated, i.e., the amount of delay [t.c. electronic, 2001].

Furthermore, the chorus effect will consist of one or more voices. The user should
be able to specify how many voices, the signal should be modulated with. With
inspiration from the G•Major manual [t.c. electronic, 2001] and [Zölzer, 2005], this
leads to the following specifications:

Chorus:

– Delay ranges from 10 ms - 25 ms in steps of 1 ms.


– Delay gain factor ranges from 10 % to 100 % in steps of 10 %
– Rate ranges from 0.05 Hz to 20 Hz and varies randomly.
– Depth ranges from 10 % to 100 % of delay range in steps of 10 %.
– Voices ranges from one voice to four voices in total.

Flanger:

– Delay ranges from 0 ms - 15 ms in steps of 1 ms.


– Delay gain factor ranges from 10 % to 100 % in steps of 10 %
– Rate ranges from 0.05 Hz to 20 Hz.
– Depth ranges from 10 % to 100 % of delay range in steps of 10 %.

Acceptance test
Acceptance test specification for chorus/flanger is found in acceptance test 9 page
21.

3.4 External Interface Requirements


Communication Interface
Specification 10. Connectors

Source and description


To make it possible to connect the guitar effects unit to a guitar and an amplifier,
there should be jack-connectors as input and output.

Acceptance tests
This requirement will not be tested.

17
3 Requirement Specification

User Interface
Specification 11. Operation

Source and description


The guitar effects unit should have a keyboard so that the user can change the
effect parameters. It should also be possible to turn off all the effects if the user
wish to send the guitar signal unaltered through the guitar effects unit.

Acceptance tests
This requirement will not be tested.

3.5 Additional Requirements


Input and Output Specifications
The G•Major unit is not meant for a guitar as input, but being inserted after a pream-
plifier. Instead the inspiration is from t.c.electronic’s G•System that has an instrument
input specification.

Between each block it is adequate to have a factor 100 between input and output
impedance, which is also similar to the DIN 45 500 hifi standard [DIN, 1974]. Hence
the impedance specifications for the system is:

• Instrument input impedance > 1 MΩ [t.c. electronic, 2005]

• Block input impedance > 10 kΩ

• Block output impedance < 100 Ω

Frequency Response
Based on the highest and lowest tone a electric guitar is able to play, the frequency range,
in which the system should be able to reproduce the guitar signal, is set to be 83 Hz to
7.2 kHz.

SNR Requirements
With inspiration from the DIN 45 500 standard [DIN, 1974], the SNR of the different
effects in the system must be greater than 50 dB. The implemented effects will have their
SNR measured.

Real-time Specification
All effects must perform in real-time which means that no unwanted noticeable delay
must be perceived by the listener.

18
3.6. Acceptance Test Specification

3.6 Acceptance Test Specification


In this section the acceptance test specifications to the requirements are stated.

Show Status
Test 1. Status types

Requirement
Acceptance test for requirement 1 page 14.

Procedure

1. Use the keyboard to scroll through the effects on the display.


2. Verify that the effect parameters from section 3.3 can be shown on the display.

Configure Effects
Test 2. Parameter configuration

Requirement
Acceptance test for requirement 2 page 14.

Procedure

1. Use the keyboard to scroll through the effects on the display.


2. Verify that the different parameters from section 3.3 for each effect can be
changed to the specified values.

Test 3. Routing

Requirement
Acceptance test for requirement 3 page 14.

Procedure

1. Scroll to the routing menu on the display.


2. Verify by use of the keyboard that it is possible to change the order of the
digital effects.
3. Verify that it is possible to change the order of the analog effects by changing
the position in the rack.

19
3 Requirement Specification

Tweak Signal
Test 4. Tremolo

Requirement
Acceptance test for requirement 4 page 15.

Procedure

1. Set tremolo as only active effect.


2. Measure the amplitude response for the tremolo effect, with different settings
as specified in measurement report J page 139.
3. Verify that the measurements fulfill the specified demands.

Test 5. Wah wah

Requirement
Acceptance test for requirement 5 page 15.

Procedure

1. Set wah wah as only active effect.


2. Measure the frequency response at the four boundaries: Qmax , Qmin , fmax and
fmin .
3. Calculate Q-factor
4. Verify that the measurements fulfill the specified demands.

Test 6. Equalizer

Requirement
Acceptance test for requirement 6 page 15.

Procedure

1. Set equalizer as only active effect.


2. Measure amplitude response for equalizer with three different setups. In the
first test there is no regulation of the different bands. In the second test, bass
and treble are at -24 dB while middle band is at 0 dB. In the third test the
middle band is at -24 dB while bass and treble are at 0 dB.
3. Verify that the measurements fulfill the specified demands.

Test 7. Delay/Echo

Requirement
Acceptance test for requirement 7 page 16.

Procedure

20
3.7. Limitations

1. Set delay/echo as only active effect.


2. Measure the impulse response.
3. Compare to the simulated impulse response.
Test 8. Reverberation
Requirement
Acceptance test for requirement 8 page 16.
Procedure
1. Set reverberation as only active effect.
2. Measure the impulse response.
3. Compare to the simulated impulse response.
Test 9. Chorus/Flanger
Requirement
Acceptance test for requirement 9 page 17.
Procedure
1. Set chorus/flanger as only active effect.
2. Measure the impulse response.
3. Compare to the simulated impulse response.

3.7 Limitations
On basis of the semester description, the main topics of the report are set to be the
design of an analog/digital signal processing system and design, implementation and test
of digital algorithms. Therefore it is mainly these parts of the electric guitar guitar
effects unit that are described in detail in the report, while elements as user interface are
described with less degree of detail.

3.8 Problem Formulation


Based on the obtained knowledge from chapter 2 and specified requirements from this
chapter, the development procedure of the guitar effects unit can be carried out through
answering the following questions:
• How are the analog and digital effects designed?
• How are they implemented?
To deal with these questions, the first subject is to specify a block diagram for the guitar
effects unit that has the desired functionalities. This will be carried out in the following
chapter.

21
Chapter 4
System Overview

It has now been chosen which effects to implement and demands for each of them have
been specified. In this chapter, an overview of the system is given starting with a block
diagram showing the signal path. The signal path and the boundaries between the dif-
ferent parts of the system will be described.

4.1 System Parts

Guitar Guitar Effects Unit


Zo Pre-amp Amplifier

Speaker
Analog
Effect
DSP-System
A/D
Converter

Display
Digital
Effect 1
Control
Digital
Effect 5
Keyboard

D/A
Converter

Analog
Effect

Figure 4.1: Overview of the system with guitar and amplifier model.

The signal path through the guitar effects unit is shown on figure 4.1 where the input is
the connected guitar having an output impedance ZO , and the output is connected to an
amplifier and a loudspeaker. The guitar effects unit itself consists of:

22
4.1. System Parts

• Buffer
The guitar effects unit first of all consists of a buffer with the purpose of ensuring
that the impedance requirement for the input signal is met. Once the signal has
passed through this part it will either skip the effects and send the signal directly
to the output that is the externally connected amplifier, or it will pass through the
effects dependent on the users choice.

• Analog effects
When the signal has passed through the buffer it will pass to the first enabled effect.
It can be either an analog effect or a digital effect dependent on the chosen routing.
In figure 4.1 an analog effect has been chosen as the first effect. The effect needs
an analog input and will provide an analog output again. Once the signal has been
tweaked by this effect it will be sent to the next active effect.

• DSP system
When a digital effect is chosen, the DSP system is activated. However, if the signal
comes from either the buffer or an analog effect the signal will be in analog form
and will require an A/D conversion. This is done by an A/D converter and will
enable digital signal processing. The digital effects will tweak the signal and give a
digital signal as output. To enable the tweaked signal to enter either a new analog
effect or be sent to the output of the guitar effects unit and the amplifier, it has to
be converted back from digital to analog through a D/A converter.

Furthermore, through digital processing of the signal, a user interface is available to


the user in form of a keyboard and a display. Whenever a digital effect is chosen, the
keyboard can be used to alter the settings of the effect thereby altering the way the
effect tweaks the signal. These changes will be shown on a connected display to en-
able the user to see which effect is active and what the effect parameter settings are.

The DSP system can also be skipped by the flip of a switch circumventing the DSP
system. This will leave the signal untweaked. Once the signal has passed through
the system either tweaked or untweaked it is sent to an amplifier connected to a
loudspeaker.

The flow through the guitar effects unit has now been described and the different parts
of the system now have to designed and implemented. The analog tremolo effect will be
described in chapter 5 and the wah wah effect will be described in chapter 6. After this
the design of the DSP system will be described in chapter 7. Thereafter the design of
the individual digital effects chosen to be implemented are designed and implemented in
chapter 9 to 11.

23
4 System Overview

4.2 Choice of Effects


A requirement for the project is to implement both analog and digital effects in the sys-
tem. Therefore it is chosen to implement the tremolo effect as an analog effect. It is
chosen also to implement the wah wah as an analog effect as it must be connected to an
analog pedal and is therefore easiest implemented as an analog effect.

As some effects also needs to be realized digitally the echo, delay, flanger and chorus
effects are implemented as digital effects.

24
Chapter 5
Tremolo

As described in section 2.1.2 page 7, the tremolo effect regulates the amplitude of an
audio signal using a low frequent oscillator (LFO). As specified in specification 4 page 15,
it should be possible to control the rate and depth of the tremolo effect. Furthermore, the
user should be able to choose the type of amplitude regulation, which can be a square,
triangular or sinusoidal wave.

5.1 Design of Tremolo Effect


Basically, the tremolo modulates an audio signal with a low frequent signal. The low
frequent signal can be a sine, a triangle or a square wave. The simple block diagram in
figure 5.1 shows the building blocks of the tremolo effect.

LFO

Switch

Depth control

Input signal Output signal


Multiplier

Figure 5.1: Block diagram for the tremolo effect.

The following sections describe the design and realisation of the tremolo’s building blocks.

5.1.1 Low Frequency Oscillator


The LFO consists of three different types of signals. A square wave, a triangular wave and
a sinusoidal wave. The sine wave oscillator can be designed with a Wien-bridge oscillator,
but the very low frequencies yield a very distorted signal that is very slow at reaching
its steady-state oscillation [Sedra and Smith, 2004]. Therefore, it is preferable to start
designing the square wave, and use this wave to create the others. The triangle wave can
be created by integrating the square wave, and the sine wave can then be created with
a sine shaper design that takes a triangular shaped signal as input. The circuits that
generates these signals, are described in the following sections.

25
5 Tremolo

Square Wave Generation


One way to generate the square wave is through the use of a comparator. The comparator
evaluates an input voltage relative to a reference voltage. The input voltage being higher
or lower than the reference will correspond to two states of the output voltage defined
by the supply voltage. Since a signal may contain noise, the output of the comparator
may jump several times between its saturation levels. This can be solved by adding hys-
teresis to the comparator characteristics so it acts like a schmitt trigger. The comparator
exhibits two reference values that are symmetrically placed around the initial reference
value. The basic schematic for the comparator with added hysteresis is seen on figure
5.2.

vin R1 R2
v+

+
vout
-

Figure 5.2: Schematic of the comparator with added hysteresis.

When the input level exceeds the threshold value of upper reference value, the output
voltage goes high, and the threshold value is changed to the lower reference value.

The upper and lower threshold value can be determined by superposition by express-
ing v+ in terms of vin and vout ,
R2 R1
v+ = vin + vout , (5.1)
R1 + R 2 R1 + R2
where vin is the input voltage and vout is the output voltage.

From equation 5.1 it is seen that if the output voltage is in its positive state, the compara-
tor is not subject to change before vin reaches a value below the lower threshold value.
Hence v+ will become 0 V at the crossing and therefore change the output voltage to its
minimum value. When output voltage is at minimum, an input voltage of greater value
than the upper threshold is needed to change output state again and so forth. Figure 5.3
shows the characteristics of the comparator with added hysteresis.

26
5.1. Design of Tremolo Effect

vout

L+

VTL 0 VTH vin

L-

Figure 5.3: Transfer characteristics of comparator with hysteresis.

From the figure it is seen that L+ and L− indicate the maximum and minimum val-
ues of the output voltage, and VTH and VTL indicate the upper and lower thresholds. It
is now possible to express VTH and VTL in terms of L+ and L− .

When vin becomes VTL and vout is L+ , then v+ is 0 V. When substituted into equa-
tion 5.1, VTL can be found to
R2 R1
0 = VTL + L+
R1 + R2 R1 + R2
R2 R1
VTL = −L+
R1 + R2 R1 + R 2
R1
VTL = −L+ . (5.2)
R2
Likewise the expression for VTH can be found the same way with
R1
VTH = L+ . (5.3)
R2
With this design a square wave LFO is generated, and through additional designs it is
possible to achieve both triangular and sinusoidal waves.

Triangle Wave Generation


When a square wave is integrated, a triangular wave is generated. The basic schematic
for the inverting integrator is a resistor connected to an opamp’s negative input terminal,
and a capacitor placed in the feedback loop. The schematic is shown in figure 5.4.

The integrator operates by charging the capacitor with the current, vRin , flowing through
the resistor. As the current flows through the capacitor, a charge is accumulated. If
charging starts at time t = 0 then at any time later, the charge accumulated is equal to
Z t
Q(t) = iin (τ )dτ. (5.4)
0

27
5 Tremolo

R
vin -
V- vout
+
iin(t)

Figure 5.4: The integrator circuit.

This yields the corresponding change in the capacitor voltage as


Z
1 t
vout (t) = − iin (τ )dτ. (5.5)
C 0
If the initial voltage on the capacitor is denoted VC and R1 is moved outside the integral,
this yields
Z t
1
vout (t) = − vin (τ )dτ − VC . (5.6)
RC 0
Equation 5.6 shows that the output voltage is proportional with the input time integral,
where RC is the integrator time constant. The negative sign is due to the inverting
opamp.

In the frequency domain, the transfer function can be found by expressing V− in terms
of Vin (s) and Vout (s) with
1
sC R
V− = Vin (s) 1 + Vout (s) 1 . (5.7)
sC +R sC +R
Since V− is a virtual ground, the equation can be reduced by setting V− = 0 and therefore
1
sC R
0 = Vin (s) 1 + Vout (s) 1
sC +R sC +R
1
R sC
−Vout (s) 1 = Vin (s) 1
sC +R sC + R
1
sC
Vout (s) 1
sC
+R
=− R
Vin (s) 1
sC
+R
Vout (s) 1
=− . (5.8)
Vin (s) sCR
Substituting s with jω, an expression for the frequency response is
Vout (jω) 1
=− , (5.9)
Vin (jω) jωCR

28
5.1. Design of Tremolo Effect

and the magnitude of equation 5.10 is


Vout (jω) 1
(5.10)
Vin (jω) = ωCR ,

and the phase shift is φ = 90◦ .

The frequency response of the integrator transfer function corresponds to a single-time


constant (STC) low-pass network, where the integrator behaves as a low-pass filter with
corner frequency at DC. This means that at ω = 0, the magnitude is infinite, which also
can be seen in the ciruit, since the capacitor works as an open circuit. Hence the opamp
is operating with an open loop. The open loop performance may cause an offset problem,
which is further elaborated in appendix B page 113.

Square and Triangle Wave Generation Combined

Letting the integrator become the input of the comparator as seen in figure 5.5, the input
signal of the comparator will be a triangular wave. Hence both triangular and square
wave generation is implemented in the same circuit. Figure 5.5 shows such circuit.

R202
vtriangle
C201
R204
R201
- R203
+ vout +
vsquare
U201B -
U201A

Figure 5.5: Schematic of comparator with integrator as input.

The reason R202 is in the circuit, is due to the compensation of DC offset voltages and
bias currents. This subject is further elaborated in appendix B page 113.

To determine the frequency at which the triangular and square wave is generated, equa-
tion 5.6 is used. Due to the hysteresis of the comparator, the input voltage of the inte-
grator can only assume voltages of ±L+ , since L− is assumed −L+ . When vout reaches
±VTH , since VTL is assumed −VTH , the output voltage of the comparator switches po-
larity. So the frequency of one period is equal to two integrations from VTH to VTL and
again from VTL to VTH . Each of these integrations equal 2VTH , which together yields

29
5 Tremolo

4VTH . This forms the expression,


Z T
1 L+
4VTH = L+ dt = T
R201 C201 0 R201 C201
1 L+
=f = . (5.11)
T 4VTH R201 C201
R203
As seen in equation 5.3, VTH can be substituted with L+ R 204
. This simplifies equation
5.11.
R204
f= . (5.12)
4R203 R201 C201
This shows that the frequency is not only dependent on the traditional RC circuit, but also
the reference voltages specified by R203 and R204 . With an adjustable R201 is it possible
to change the frequency of the comparator hysteresis, thus the rate of the tremolo.

Sine Shaper
To obtain a sinusoidal wave from the triangular wave, different methods exist using non-
linear waveform-shaping circuits. These take advantage in the nonlinear characteristics of
diodes and transistors and perform quite well regarding the size of THD [Sedra and Smith,
2004]. Two of these methods are the breakpoint method and the nonlinear-amplification
method. The first method employ diodes combined with resistors to obtain the nonlinear
transfer characteristics and the second method uses a differential pair of transistors with
a resistor connected between the two emitters. Figure 5.6 shows how these methods affect
a triangular wave to produce a sinusoidal wave.

As a waveform-shaping circuit for the LFO, the breakpoint method is chosen. The circuit
of a three segment sine-wave shaper is shown on figure 5.7

The circuit consists of four diodes that together with the resistors form different break-
points at which the diodes individually become active. The resistors, R1 , R2 and R3 , are
placed symmetrically around the ground across the supply voltage Vcc and −Vcc . The
resistors form a voltage divider that determine the breakpoints of the diodes, i.e. voltage
references of the diodes. The symmetry around ground is due to the fact that the trian-
gular wave also is symmetrical around zero.

The sine shaper will then create three segments per each quarter cycle that are de-
termined by either the positive or negative voltage reference pair respectively. Figure 5.8
shows the relation between the input triangular wave and the approximately generated
sine wave.

To develop the different diode breakpoints determined by the voltage references in the
voltage divider, a possible solution is to look at the first quadrant in the unit circle. To

30
5.1. Design of Tremolo Effect

vout

0 0 t
vin T T
2

T 0
2
T
t

Figure 5.6: Transfer characteristic of the sine shaper.

Vcc

R1

Vref,2
D1
R2
R5
Vref,1
D2
R3
R4
vtriangle

R3
D3 R5
-Vref,1

R2
D4
vsinusoid -Vref,2

R1

-Vcc

Figure 5.7: Schematic of sine shaper.

31
5 Tremolo

Vref,2
Vref,1

t
0 T T 3T T
4 2 2
-Vref,2
-Vref,1

Figure 5.8: Approximated sine wave with diode breakpoints with triangular wave as input.

find the voltage breakpoints, the quarter-circle is divided into N breakpoints. The three
segment wave-shaper is used as an example in figure 5.9.

A2

A1

Figure 5.9: Using the unit circle to determine voltage references.

As seen on figure 5.9 when applying the sine function to each point, the y-coordinates are
found. These coordinates correspond to the factorical values, A1 and A2 , that the peak
voltage of the sinusoid should be multiplied with. As seen on figure 5.9, A2 corresponds
to the peak voltage, since this is the last breakpoint where the sine wave becomes flat.
From this solution regarding the voltage references in the voltage divider, the expression
is
 πn 
Vref,n = vbs sin , n = 1, 2, ..., N. (5.13)
2N
To determine the peak voltage of the sinusoid, the sine signal is considered as

vs = vbs sin (2πf t) . (5.14)

32
5.1. Design of Tremolo Effect

From equation 5.14 it is seen that the maximum slope is at 2πf vbs , which is the same as
the triangular signal, i.e at this time none of the diodes are open. To determine the slope
of the triangular signal, the period from zero to 14 T is considered, since the triangular
signal has reached the peak voltage by then. This peak voltage can also the be expressed
with use of the sine wave’s maximum slope
1
vbt = 2πf vbs T. (5.15)
4
Since T = f1 , the expression can be further reduced with
π
vbt = vbs , (5.16)
2
and the peak voltage of the sinusoid can then be found by isolating vbs so
2
vs = vbt . (5.17)
π
Because of the symmetry in the sine shaper, the design of the negative part of the voltage
divider is a mirror of the positive part. To keep the DC reference voltages stable, the
current through the voltage divider must be much larger than the current led through
the diodes.

To determine how much current each diode respectively on the positive or negative side
is allowed to let through, the slope of the sinusoid at each breakpoint is taken into con-
sideration. The resistors in series with the diodes determine the size of these slopes.

When input voltage is between zero and Vref,1 , the sine wave has the same slope as
the triangular wave. For each breakpoint passed, the slope of the sinusoid will differ from
the triangular slope with a greater and greater factor until the final breakpoint sets the
slope to zero. As a way of expressing these deviations from the maximum slope, it is
possible to look at the angles at each breakpoint as seen on figure 5.10.

In figure 5.10 a triangle reference line is illustrated that corresponds to the maximum
slope of the triangular wave. To form an expression that calculates the angle deviations,
the right-angled triangle is taken into consideration. The triangle is 180◦ in total, and
the triangle reference line corresponds to the 90◦ of the triangle. As the breakpoint angle
becomes greater, the difference between the angles becomes greater and thus a smaller
slope. At the last breakpoint, the angle is 90◦ and therefore parallel with the triangle
reference line, which yields a slope equal to zero. Equation 5.13 shows the relation
180 − 90 − θn
Slope deviation = , n = 1, 2, ..., N, (5.18)
90
where
 
90n
θn = arcsin . (5.19)
N

33
5 Tremolo

Triangle
reference line

șn

ș(90 -n)
o

șn

Figure 5.10: Illustrating the angle difference between a breakpoint and the triangle reference slope.

The calculation of these values will be carried out in appendix B page 113.

The final schematic can be seen in figure 5.11, which concludes the design of the LFO.
The circuit implements ten diodes instead of the initial four in figure 5.7, which is sug-
gested from the literature [Sedra and Smith, 2004] and will approximate the sinusoidal
wave with six segments on both the positive and negative side. Notice that a buffer is
implemented at the output of the sine wave shaper, since the output impedance is very
high, when none of the diodes are active.

R214 R215 R216 R217 R218 R221 R222 R223 R224 R225
Vcc -Vcc
R219 R220
R206 R207 R208 R209 R210 R211 R212 R213

D201 D202 D203 D204 D205 D206 D207 D208 D209 D210
-
+ Sine
R205 U201C
R202
Triangle

R204
C201
R201
- R203
+ +
Square
U201B -
U201A

Figure 5.11: Final schematic of LFO circuit.

This leads to the design of the LFO amplitude and offset adjustment.

34
5.1. Design of Tremolo Effect

5.1.2 Amplitude and Offset Adjustment


Three different signal types have now been generated, the square wave, triangular wave
and the sine wave. The signals serve as the LFO that through the multiplier will modulate
the amplitude of the incoming signal. The signals must all have the same peak voltage,
so the modulated audio signal also will have the same peak voltage. Furthermore, it is
necessary to bias the output signal of the LFO, so it does not reach voltage values below
zero, which will cause a 180◦ phase turn. The following subsections describe a way to
solve these issues.

Amplitude Regulation
As seen throughout the design of the LFO, the signal amplitude decreases for each new
wave type generated. The square signal has the largest peak amplitude approximately
equal to the supply voltage. The triangular signal has a peak amplitude equal to VTH
and the sine signal has a peak amplitude at π2 vbt . To achieve the same peak voltage from
each signal type, they each have to be amplified or attenuated with respect to the other
types.

To avoid using three opamps to amplify each individual signal, a possible solution is to
implement the amplification circuit around the switch as seen on figure 5.12:
R229
R226
vsquare Switch
R227
vtriangle -
R228 + vLFO
vsine
U202A

Figure 5.12: The switch circuit implementing an inverting opamp.

The circuit implements an inverting amplifier. This way only one opamp is needed,
and each signal will be amplified according to their respective input resistances.

The peak voltages of the LFO signals must be 5 V, since the multiplier divides the
product between the guitar signal and the LFO-signal with 10 to maintain the same peak
voltage of the guitar signal and offset is added before the multiplier.

The amplification of the circuit in figure 5.12 is expressed by

R229
vLFO = −vswitch , (5.20)
Rswitch

where Rswitch is the input resistor from either the square, triangular or sinusoidal wave.
Hence, the individual amplifications at peak voltages can be determined. Table 5.1 shows

35
5 Tremolo

these relations.

Square wave: Triangle wave: Sine wave:

2
Input [V] L+ VTH π VTH

R204
Gain [·] − 31 − 3R 203
− πR
6R203 Vsp
204

Table 5.1: The gain factors for each wave type according to input amplitude.

With the signals now being equal in amplitude, they need to be summed with a DC
voltage to keep their voltages above zero.

Summer
To achieve voltage levels above zero, an inverting summer is used as seen on figure 5.13.

-Vcc
R1 Rf
RDC

-
R2
RLFO vout
+
vLFO

Figure 5.13: The inverting summer.

The figure shows two inputs with the first being the LFO signal and the second a DC
value. Note that the DC voltage is negative, since it is an inverting summer. The relation
between the output and the input signal is
 
Rf Rf
vout = − vLFO + VDC . (5.21)
RLFO RDC

To determine the size of the DC value, the LFO signal must be considered when at its
peak voltage. Therefore the DC input must be equal to v̂LFO .

This will cause a problem though. Since the depth of the tremolo should be adjustable
according to requirement 4 page 15, the peak voltage will change and the DC voltage
must change too to maintain the maximum amplitude of the modulated signal. The
problem is illustrated on figure 5.14.

36
5.1. Design of Tremolo Effect

v v

vLFO vLFO

VDC2

VDC1

0 t 0 t

Figure 5.14: When adjusting depth of the tremolo, the DC offset voltage has to be adjusted corre-
spondingly.

Using the circuit design on figure 5.13, a way of adjusting the offset is achieved in figure
5.15.

-Vcc
R230 R235
R233
v1
-
R231
R234 vout
R232 +
v2 U202B
vLFO

Figure 5.15: An inverting summer where DC voltages are adjusted according to the LFO peak voltage.

This circuit has a fixed DC voltage at the first input v1 , but the second input, v2 , is a
sum of current from the DC and LFO, which is determined by a potentiometer. Selecting
a high resistor value for the potentiometer lets very little current flow through from
opposite the short-circuited side, thus affecting the input very little. Letting K describe
the potentiometer position between one and zero and knowing VDC = v1 , an expression
for the voltage at v2 can be derived as

v2 = (1 − K)vLFO + KVDC , (5.22)

if it is assumed that a larger current runs through the potentiometer than into the sum-
ming inputs.

37
5 Tremolo

Then equation 5.21 can be rewritten to


 
1 1
vout = −R235 ((1 − K)vLFO + KVDC ) + VDC . (5.23)
R234 R233

It is seen from the equation that when K is zero, only the LFO signal is the input at v2 .
For K equal to one, only the DC voltage is present at v2 , and an expression for R235 can
be found to be
 
R234 R233 vout
R235 = − . (5.24)
R234 + R233 VDC

Seen throughout the design, the inverting summer is subject to changing the depth of the
tremolo, and the LFO signal is now ready to be multiplied with the audio signal, which
will lead to the tremolo effect.

5.1.3 Multiplier
The multiplier is basically a voltage controlled amplifier (VCA) where the LFO signal is
the controlling voltage. For the tremolo effect it is chosen to use an IC that does the
multiplication. Since the audio signal contains both positive and negative voltages, it
must be at least a two-quadrant multiplier. The AD633 analog multiplier [Devices, 1999]
will be used. Since the input and output of the audio only runs through the multiplier,
the impedance specification 3.5 page 18 for the block is maintained. Figure 5.16 shows
the connection diagram of the AD633.

X1 1 8 +VS
1

X2 2 A 7 W
1
10V
Y1 3 6 Z

1
Y2 4 5 –VS
AD633JN

Figure 5.16: The four quadrant AD633 analog multiplier.

The input pin one to four are differential connections respectively for the x and y input.
Inside the multiplier, the signal inputs will be scaled down by a factor of ten when
multiplied. Finally the signal passes an optional summer that also takes pin 6 at input.
The outcoming signal is led through a buffer with output at pin 7.
This leads to the input-output relation [Devices, 1999]

(X1 − X2 )(Y1 − Y2 )
W = + Z. (5.25)
10

38
5.2. Implementation of Tremolo

Since input signals are not differential and there is no use of the summer, equation 5.25
with x being the LFO input and y being the audio input may be rewritten to
vLFO vguitar
W = . (5.26)
10
Implementing the input-output relation of equation 5.26 in the connection diagram on
figure 5.16 leads to the final design of the multiplier.

Vcc
U203
C202
vLFO 1 x1 +Vs 8

2 x2 W 7 vtremolo

vguitar 3 y1 Z 6

C203
4 y2 -Vs 5

AD633 -Vcc

Figure 5.17: Final design of the multiplier ciruit.

Notice on figure 5.17 that two 0.1 µF capacitors are connected to ground at voltage sup-
plies, which is suggested by the data sheet.

This concludes the design of the tremolo effect, which implements three different mod-
ulation types and the ability to adjust rate and depth of the tremolo. To realize this
design and implement it as an analog effect in the guitar effects rack, all calculations will
be carried out in appendix B 113.

5.2 Implementation of Tremolo


Through use of requirements, equations from design section and available components,
the component values required are calculated in appendix B page 113.

Figure 5.18 shows the final circuit and table 5.2 lists all the required component val-
ues. Since many of the calculated resistor values can not be realized by one component,
their closest value in the E24 series is chosen.

39
5 Tremolo

R214 R215 R216 R217 R218 R221 R222 R223 R224 R225
Vcc -Vcc
R219 R220
R206 R207 R208 R209 R210 R211 R212 R213

D201 D202 D203 D204 D205 D206 D207 D208 D209 D210
-
+
R205 U201C

R202

R204
C201
- R203
R201b + +
R201a
U201B -
U201A

R229
Switch Vcc
R228 - U203
C202
R227 +
U202A 1 x1 +Vs 8
R226

2 x2 W 7 vtremolo
-Vcc

R230 R235
R233
vguitar 3 y1 Z 6
v1
-
R231 R234 C203
R232 +
v2 U202B 4 y2 -Vs 5

AD633 -Vcc

Figure 5.18: Final circuit of the tremolo.

The tremolo is tested through use of simulations and measurement of the realized circuit
in laboratory.

5.3 Simulation of Tremolo


The simulation was carried out in LTspice 2.20d. Only until the offset adjusted LFO is
simulated, since the multiplier does not exist in LTspice. The simulation will show the
signal at lowest and highest frequency with 0% and 100% depth. Only the square wave
is simulated, since the other signals have the same amplitude.

Figure 5.19 shows a ten second simulation at a frequency of 0.1 Hz and 100% depth.
Maximum amplitude is 9.98 V and minimum amplitude is -62 mV. Figure 5.20 shows a
one second simulation at a frequency of 10 Hz and 100% depth. Maximum amplitude is
9.99 V and minimum amplitude is -64 mV. The negative minimum amplitudes will cause

40
5.3. Simulation of Tremolo

Component: Value: Component: Value:


R201a 24.9 kΩ R219 = R220 137 Ω
R201b (pot) 2.2 MΩ R226 12.7 kΩ
R202 10 MΩ R227 20 kΩ
R203 2 kΩ R228 30.1 kΩ
R204 3.01 kΩ R229 10 kΩ
R205 61.9 kΩ R230 2 kΩ
R206 = R213 40.2 kΩ R231 1 kΩ
R207 = R212 121 kΩ R232 (pot) 100 kΩ
R208 = R211 243 kΩ R233 1 MΩ
R209 = R210 402 kΩ R234 1 MΩ
R214 = R225 931 Ω R235 1 MΩ
R215 = R224 30.9 Ω C201 1.5 µF
R216 = R223 90.9 Ω C202 0.1 µF
R217 = R222 140 Ω C203 0.1 µF
R218 = R221 178 Ω

Table 5.2: Required component values for the tremolo.

the unwanted phaseshift as discussed in section 5.1.2 page 35. Therefore the realisation
of the circuit must be adjusted so the minimum amplitude is closer to zero. This problem
can be solved by fine tuning the DC voltage with a potentiometer in the realized design.

Square wave, 0.1 Hz 100% depth Square wave, 10 Hz 100% depth

10 10

8 8
Amplitude [V]
Amplitude [V]

6 6

4 4

2 2

0 0

0 1 2 3 4 5 6 7 8 9 10 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1


Time [s] Time [s]

Figure 5.19: Square wave at 0.1 Hz and 100 % Figure 5.20: Square wave at 10 Hz and 100 %
depth. depth.

Figure 5.21 shows a ten second simulation at a frequency of 0.1 Hz and 0 % depth. Max-
imum amplitude is 9.99 V and minimum amplitude is 9.85 V. Figure 5.22 shows a one
second simulation at a frequency of 10 Hz and 0 % depth. Max amplitude is 9.99 V and
minimum amplitude is 9.85 V. The depth is not fully 0 % because of the assumption that
the potentiometer adjusting the depth is not loaded.

41
5 Tremolo

Square wave, 0.1 Hz 0% depth Square wave, 10 Hz 0% depth

10 10

8 8
Amplitude [V]

Amplitude [V]
6 6

4 4

2 2

0 0

0 1 2 3 4 5 6 7 8 9 10 0 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 1


Time [s] Time [s]

Figure 5.21: Square wave at 0.1 Hz and 0 % Figure 5.22: Square wave at 10 Hz and 0 %
depth. depth.

At 0.1 Hz the THD of the generated sine wave was calculated to 5.07 % and at 10 Hz it
was 4.29 %. These values would not be acceptable if the wave was to be played, but as
a modulating signal in a tremolo it is acceptable.

5.4 Measurements of Tremolo


Laboratory testing of the tremolo is carried out in measurement report J page 139. Since
many different combinations regarding frequencies, offset adjustments, modulation types
and input signal, only some of them are being tested according to acceptance test 4 page
20.

Modulation Types
From procedure one the results show that the tremolo effect is able to amplitude modulate
a 100 Hz sine wave with a square wave, a triangular wave and a sinusoidal wave. Therefore
the third demand from specification 4 page 15 is considered fulfilled. The measurements
are performed at lowest frequency to show the characteristics of each modulation type.
These figures may be studied in the measurement report appendix J page 139.

Offset Adjustment
Results from procedure two show the maximum and minimum amplitudes of each mod-
ulation type at maximum frequency and maximum depth as seen on table 5.3.
Since the demand is that the tremolo effect must dampen the signal with 60 dB at
maximum depth, the desired minimum amplitudes can be calculated with
vmax
vmin = 60 . (5.27)
10 20

42
5.5. Conclusion on Tremolo Effect

Modulation type: Maximum amplitude [V] Minimum amplitude: [mV]


Square 9.56 870
Triangle 10.37 240
Sine 10.37 50

Table 5.3: Measured amplitudes of the three different modulation types.

Modulation type: Results from equation 5.27: [mV]


Square 9.56
Triangle 10.37
Sine 10.37

Table 5.4: Desired minimum amplitude voltages corresponding to the maximum amplitudes.

As seen on table 5.4 the results does not fulfill the demands. Though through listening
test, the tremolo perform as wished, and the results are therefore considered acceptable
values. The current maximum depth gives an attenuation of 20.82 dB for the square
wave, 32.71 dB for the triangular wave and 41.23 dB for the sinusoidal wave.

At minimum depth each modulation type had a maximum amplitude of 10.62 V and
minimum amplitude of 10.24 V. This yields an attenuation of 0.32 dB which is consid-
ered acceptable.

Frequency Adjustment
The minimum frequency was measured to 182.5 mHz and the maximum frequency was
10.9 Hz, which are acceptable results corresponding to specification 4 page 15.

5.5 Conclusion on Tremolo Effect


Throughout this chapter the tremolo effect has been designed, simulated, realized and
tested. Tests show that the realized tremolo is capable of pursuing the desired effect
defined as tremolo effect in section 2.1.2 page 7. Though the offset adjustment does not
fulfill the specified demands, the effect is still perceived as acceptable through listen-
ing test. To fulfill the demands of the depth parameter, the offset adjustment may be
perfected with the use of potentiometers.

43
Chapter 6
Wah Wah

As described in chapter 2, the wah wah effect consists of a narrow bandpass filter. The
filter must be implemented so that it is possible to control the center frequency ωc and
the Q-factor while the gain factor G is held constant. Since the filter is everything the
effect consist of, the filter must fulfill the requirements for output and input impedance
described in the specifications section 3.5, page 18. This chapter is based on the book
Analog Filters [Su, 2002].

Using the transfer function of a bandpass filter a realization where ωc , Q and G are
independent is found. The wah wah effect is based on the standard second order biquad
bandpass filter transfer function
Ks
H(s) = 2 . (6.1)
s + b1 s + b0
This can be rewritten to
 
ωc
Vout G Q s
H(s) = =   , (6.2)
Vin s2 + ωc s + ω 2
Q c

where: √
ωc b0
Q = BW = BW equals the bandwidth see figure 2.3 page 8
√ b1
ω c = bo .
This transfer function is then manipulated into an equation that can easily be expressed
by a block diagram.
 
ωc
Vout G Q s
=   ⇒
Vin s2 + ωQc s + ωc2
   
2 ωc 2 ωc
Vout s + s + ωc = Vin s ⇒
Q Q
   
ωc ωc2 ωc
Vout 1 + + 2 = Vin ⇒
Qs s Qs
ωc ωc ω2
Vout = Vin − Vout − Vout 2c ⇒
Qs Qs s
 
1 ωc ωc
Vout = (Vin − Vout ) − Vout ⇒
Q s s
 
1 −ωc −ωc
Vout = − (Vin − Vout ) + Vout (6.3)
Q s s

44
6.1. Implementation of Wah Wah

The block diagram for equation 6.3 is shown on figure 6.1:

Ȉ Ȉ
Vin 1 -c Vout
Q s

-c
s

Figure 6.1: Block diagram for the wah wah effect.

6.1 Implementation of Wah Wah


The block diagram on figure 6.1 consists of three different building blocks: A subtracter,
an inverting summer and two integrators. The properties of these building blocks are
sketched in table 6.1.
Block: Schematic: Transfer function:
R0

Vin1 R1
- Vout
Vin2
R3 (R0 +R1 )
Subtracter R2
+
Vout = − R
R1 Vin1 +
0
R1 (R2 +R3 ) Vin2
R3

R0

Vin1 R1  
- Vout R0 R0
Inverting summer Vin2 Vout = − R1 Vin1 + R2 Vin2
+
R2

Vin R
- 1
Integrator Vout Vout = − RCs Vin
+

Table 6.1: Wah wah building blocks.

From the block diagram and the building blocks the complete schematic can be made,
see figure 6.2.

45
6 Wah Wah

R300 R304 C301


R301 U301A
- R305 U301B
- R307 U301C
Vin + V1 -
R302 + V2 Vout
+
R303
C300

R306
U301D R308
-

V3 +

Figure 6.2: Schematic for the wah wah effect.

In appendix C page 121 the transfer function is derived. After the transfer function
is found, expressions for ωc , Q and G are derived and finally component values are
calculated. Ultimately this leads to the transfer function

10·109
(1000+∆R305 )(787+∆R307 ) s
H(s) = 10·109 100·1012
. (6.4)
s2 + (1000+∆R305 )(787+∆R307 ) s + (787+∆R307 )(787+∆R308 )

6.2 Input and Output Impedance


The input impedance can be calculated to R302 + R303 = 20 kΩ. Actually R303 should
be a parallel coupling between R303 and the impedance from the operational amplifier,
but since the input impedance from the opamp is much larger than R303 the dependence
of the opamp can be omitted.

As seen on figure 6.2 the output is directly from the opamp. So the output impedance
from the effect will be the same as the closed loop output impedance from the opamp.
The open loop output impedance is 80 Ω at DC [Instruments, 2000], and it will be reduced
by a factor of approximately the loop gain when feedback is applied. Thus, the input
and output impedance requirements are fulfilled.

6.3 Simulation of Wah Wah


The wah wah effect is simulated so that it is possible to compare the measurements
with a simulation. The transfer function 6.4 is simulated in MATLAB the four different
boundaries. The plot is sketched on figure 6.3.

46
6.4. Measurements of Wah Wah

−2

−4

−6
Amplitude [dB]

−8

−10

−12

−14

−16 DR305=DR307=DR308=0
DR305=10k DR307=DR308=0
−18 DR305=0 DR307=DR308=10k
DR305=DR307=DR308=10k
−20
2 3
10 10
Frequency [Hz]

Figure 6.3: Simulation of the transfer function for the wah wah. The legends show the position of the
two potentiometers for the different plots.

From the plot, the effect of the adjustable Q-factor is easily seen, both at the low fre-
quencies and at the highest frequencies. It is also seen that the effect covers the required
frequency range.

6.4 Measurements of Wah Wah


The four simulations are verified in the measurement report I page 137. From the plot
ωc
Qmin and Qmax can be calculated since Q = BW . Table 6.2 shows the readings from the
plot in figure I.2 page 138.
From table 6.2 that Qmin is a bit higher than the requirements. Since the difference is

Bandwidth [Hz] fc [Hz] Q [·]


Qmin 142 165 1.16
Qmax 15 157 10.47

Table 6.2: Readings from the plotted measurements.

only 0.16 and is caused by component tolerances, no effort will be done to lower Qmin .

47
6 Wah Wah

6.5 Conclusion on Wah Wah Effect


The analog wah wah effect has been realized and tested. The effect is fully functional and
it has the desired impact on the sound signal, making the sound that are characteristic
for the wah wah effect.

Except from the lower Q-factor, the wah wah effect fulfills the specifications. However, it
removes a lot of energy from the signal, making it sound attenuated. A solution to this
will be to make the gain of the wah wah effect higher, but this will be problematic when
interfacing to the A/D converter. Another solution could be to add an attenuated version
of the input to the output, and thereby setting a lower boundary for the filter attenuation.

As the effect currently is constructed the stereo potentiometer is put in a foot pedal,
which is connected through a long wire (2 metres). This cable makes the filter vulnerable
to noise coming from the surroundings. This might be prevented by implementing the
effect solely in the pedal. In this way the signal would be more resistant to noise from
the surroundings.

48
Chapter 7
DSP Hardware Design

As described in chapter 4 the digital effects need to be implemented in a DSP system


as the effects will be realized as software. Figure 4.1 page 22 shows the different blocks
which the DSP system must consist of. These different parts of the system are designed
in this chapter. First, the DSP itself and the needed hardware to make the DSP system
work will be introduced. After this, the A/D and D/A conversion hardware needed will
be designed. Then the memory of the DSP system will be chosen and analyzed. The
chapter will end with a description of the user interface part of the system, consisting of
the keyboard and the display.

7.1 Overview of Digital Hardware Platform


The DSP-system consists of the different blocks shown on figure 7.1. That is, the DSP
itself is connected to the external components through an address bus and a data bus.
The DSP is connected to a clock to enable the DSP to run at the desired speed. The
input from the analog part of the circuit comes from an A/D-converter and after the
digital modifications it is converted into analog form again through a D/A-converter.
An EPROM is connected to the buses to allow a debugger monitor (D/M) to be used
during the development process. This D/M features an interface to a computer through
a RS232 connection. External RAM is also added to allow some user program and data
to be stored. A display and a keyboard is also connected to allow user interaction with
the system. To make sure there is no bus conflicts, an address decoder is connected to
the different external components to provide chip-selects to the blocks that are allowed
to use the buses at a certain time.

7.1.1 The TMS320C26 DSP


The DSP that will be used for the system is a TMS320C26 from Texas Instruments, and
it is based on the Harvard-structure meaning that it internally has separate 16 bit data
memory bus and 16 bit program memory bus. Furthermore, it has a 16 bit I/O bus to
allow communication with external components. The DSP has the pins shown on figure
7.2 grouped by functionality.

• The address bus is a 16 bit parallel bus consisting of the A0 - A15 pins and is used
to address external data, program and I/O.

• The data bus is a 16 bit parallel bus consisting of the D0 - D15 pins. The data
bus handles all data transfer between the DSP and external data, program and I/O
components.

49
7 DSP Hardware Design

Address Display Keyboard


Decoder

Data Bus

Adress Bus

16 bit 16 bit

D/M-interface EPROM RAM


- DSP - -
IDM3202 circuit - external external
TMS320C26

A/D converter Clock


- In/Output
D/A converter 16 bit
serial

Figure 7.1: Overview of the DSP-system.

• The strobe group handles the control of what kind of data is transmitted between
the DSP and external components and whether the data is to be read or written.
DS*, PS* and IS*, respectively data strobe, program strobe and I/O strobe, are
used with the address bus to select the respective spaces: Data, memory and I/O.
The STRB* is used in combination with the R/W* to indicate to the memory
whether the DSP is trying to read or write. READY is used during wait states to
provide slow external components an extra instruction cycle to get ready to deliver
data.

• CLKR and CLKX are receive and transmit clock signals to use during serial data
transmissions on respectively the DR and DX pins where FSR and FSX are frame
synchronization signals for the data packages.

• BIO* is a software controlled external device monitoring pin and not used in the
configuration. IACK*, INT0*-INT2* are interrupt pins enabling the use of hard-
ware interrupts. The MP/MC* pin is used to map the internal ROM into the lower
program memory map. MSC* indicates that a memory operation has just been
handled, and can combined with READY be used to generate a wait state for slow
external memory. RS* is a reset pin to reset the system when asserted low. XF is
used as an output flag for multiprocessor systems.

• The CLKOUT1 is the master clock output pin, CLKOUT2 is a secondary clock
output with a quarter of a cycle offset compared to CLKOUT1. X1 and X2 must

50
7.1. Overview of Digital Hardware Platform

[
[
A0 BIO*
Address A1 IACK*
bus ... INT0*
A14 INT1*
A15 Interrupt
INT2* and misc
MP/MC*
MSC*

[
D0 RS*
D1 XF
Data
bus ...
D14
D15
TMS320C26 CLKOUT1
CLKOUT2
X1 [ Clock

[
DS*
PS* X2
Strobe IS*
STRB*
R/W*
READY
BR*
HLDA*
[ Multi-
processor

[
CLKR HOLD*
CLKX functions
Serial input/ SYNC*
DR
output pins DX
FSR
FSX

Figure 7.2: Pin-descriptions for the TMS320C26 DSP.

be connected to a crystal with the desired frequency. The frequency present at the
CLKOUT1 and CLKOUT2 pins is 1/4th the clock frequency.
• The pins concerning multiprocessor usage are not used, as only one DSP is used.
The pins are used for bus sharing control and synchronization.

7.1.2 External Hardware


The external components to be connected to the DSP are listed below. The components
are chosen from the selection available at http://komponenten.es.aau.dk.
• The clock that will be used is a crystal with a frequency of 40 MHz.
• The A/D- and D/A-converters are together found in a 16 bit stereo audio codec
CS4218.
• The external EPROM module for the D/M application is chosen to be a 16 bit 64k
words EPROM of the type M27C1024-10.
• The D/M application is provided by Sofus Birkedal Nielsen and requires an in-
terface from the system to a pc by the use of a IDM3202X-V circuit which is a

51
7 DSP Hardware Design

preprogrammed PEEL 22CV10, and an RS232-connection to enable connection to


a pc.

• As extra data and program memory space two CY7C199-20 RAM blocks are chosen.
These blocks are each 8 bit 32k words and coupled in parallel they will act as one
16 bit 32k words RAM block.

• The keyboard is made using five separate buttons and a jog wheel.

• The used display is a L2014 LCD display featuring 4 lines with 20 characters pr.
line. The display comes with a KS0066 driver circuit enabling interface to the DSP.

• The address decoding circuit to form chip-selects for the different external blocks
thereby giving the different blocks the rights to use the buses at the right times is
realized with a PEEL 22CV10 circuit.

7.2 A/D and D/A Conversion


To tweak the analog signal from the electrical guitar with digital effects, it is required to
have analog to digital and digital to analog conversion. In this case it is chosen to use
a CS4218 stereo audio codec, which contains two delta-sigma A/D-converters and two
delta-sigma D/A-converters. The codec has a 16 bit resolution and it features internal
input and output digital anti-aliasing filters. The anti-aliasing filters has a transition
band as shown on figure 7.3.

Amplitude

0 dB

-74 dB

Frequency
0.4·fs 0.6·fs

Figure 7.3: Sketch of the transition band for the internal anti-aliasing filters in the CS4218 codec.

This means that the maximum frequency in the passband at which signals can pass
through the codec is given as

fmax = 0.4 · fs , (7.1)


where fs is the sampling frequency. As seen in appendix G figure G.2 the highest tone
that will be played on the guitar gives harmonics up to 8400 Hz. It has been verified that
the upper harmonic shown on the figure can not be heard. Hence, there is no noticeable

52
7.2. A/D and D/A Conversion

difference between the sound with or without the harmonic located at 8400 Hz for which
reason the highest frequency that should be reproduced will lie at 7200 Hz. This gives

fmax 7200 Hz
fs ≥ = = 18000 Hz . (7.2)
0.4 0.4
By use of the codec’s data sheet and dividing of the DSP clock, the sampling frequency
is finally set to be 19.531 kHz.

7.2.1 Input and Output Filters


As mentioned the codec features internal digital filters which means that only simple
external analog anti-aliasing filters are needed. These should prevent that noise from
the codecs real sample frequency is mirrored down in the desired frequency area. Since
the codec oversamples with 64·fs , a requirement to the analog filters is that their cutoff
frequency lies sufficiently below 64 · 19.531 kHz = 1.25 MHz. By recommendations from
the data sheet the filters seen on figure 7.4 is used to this purpose.

U101A R105
vii + R101 v1,i C102
voi C104
- Zo v1,o v2,o R104
U101B
R102 C101 vio -
Zi voo
C103 R103 +

(a) Schematic for the input filter to the CS4218 (b) Schematic for the output filter to the CS4218
codec. codec.

Figure 7.4: Schematics for the external analog anti-aliasing filters to the CS4218 codec.

Afterwards the two filters are designed starting with the input filter. It should be noted
that in the following derivation, it is assumed that the combined filters do not affect the
performance of each other. The transfer function from vii to v1,i in the input filter shown
on figure 7.4(a) is given as

R101 +R102
V1,i (s) R102 || sC1101 R102 R101 R102 C101
Hlp,i (s) = = = · , (7.3)
Vii (s) R101 + R102 || sC1101 R101 + R102 s + RR101R+RC102
101 102 101

which compared to the standard form has a gain Klp,i = R101R+R 102
102
and a cutoff frequency
R101 +R102
ωlp,i = R101 R102 C101 . Equally the transfer function from v1,i to voi is found to be

Voi (s) s 1
Hhp,i (s) = = 1 , Khp,i = 1, ωhp,i = . (7.4)
V1,i (s) s + C102 Zi
C102 Zi

53
7 DSP Hardware Design

The input signal to the codec should not exceed a RMS voltage of 1 V. According to
1 V
appendix H this means that Klp,i should be equal to 2.28
√ V
= 0.62. By setting R101 = 4.75
2
kΩ this gives

R102
Klp,i = = 0.62 ⇔ R102 = 1.63 · R101 = 1.63 · 4.75 kΩ ≈ 7.68 kΩ . (7.5)
R101 + R102
Next, the cutoff frequencies are chosen to be flp,i = 72 kHz and fhp,i = 8.3 Hz which is
respectively one decade below and one decade above the effective frequency range for a
guitar. This leads to the following values for C101 and C102

4.75 kΩ + 7.68 kΩ
C101 = ≈ 680 pF (7.6)
4.75 kΩ · 7.68 kΩ · 2π · 72 kHz
1
C102 = ≈ 1 µF , (7.7)
20 kΩ · 2π · 8.3 Hz
when Zi = 20 kΩ according to the data sheet. Due to rounding on the capacitor values
the realized cutoff frequencies are flp,ir = 79.7 kHz and fhp,ir = 8.0 Hz.

The output filter shown on figure 7.4(b) is designed in the same way. The transfer
functions from vio to v1,o , v1,o to v2,0 and v2,0 to voo are respectively given as

1
V1,o (s) 1
Hlp,o (s) = = Zo C103 , Klp,o = 1, ωlp,o = (7.8)
Vio (s) s + Zo C1103 Zo C103
V2,o (s) s 1
Hhp,o (s) = = 1 , Khp,o = 1, ωhp,o = R103 R104
(7.9)
V1,o (s) s+ R103 R104 R103 +R104 C104
C
R103 +R104 104

Voo (s) R105


Ha,o (s) = =− . (7.10)
V2,o (s) R104
The total gain in the output filter should be equal to the reciprocal of the gain in the
input filter. With R105 = 30.1 kΩ this statement gives

R105 R105
Ha,o (s) = − = −1.61 ⇔ R104 = ≈ 18.2 kΩ . (7.11)
R104 1.61
The rounding of the resistor value means that the realized gain is now Ha,o (s) = −1.65,
which is 2 % too high. Due to uncertainties in the other blocks of the effects unit, this
relatively small error is ignored. Afterwards the capacitor values are calculated. Using
the same values for the cutoff frequencies as in the input filter, the values of C103 and
C104 is

1
C103 = ≈ 2.20 nF (7.12)
800 Ω · 2π · 72 kHz
1
C104 = 20 kΩ·18.2 kΩ ≈ 2.20 µF , (7.13)
20 kΩ+18.2 kΩ · 2π · 8.3 Hz

54
7.3. Memory Timing and Address Decoding

when Zo = 800 Ω according to the data sheet. Due to rounding of the capacitor values
the realized cutoff frequencies are flp,or = 90.4 kHz and fhp,or = 7.6 Hz.

7.3 Memory Timing and Address Decoding


In this section the different memory blocks in the DSP-system will be described, and
the timing of the external memory blocks will be examined. The internal memory space
consists of a ROM of 256 words and four blocks of RAM with a total memory of 1568
words which can be independently used for data or program memory space. The DSP
can handle up to 64k words of external program memory space and 64k words of data
memory space.
The external RAM and ROM for the system was chosen given the timing for read/write
cycles of the DSP, to ensure that the memory chosen would be fast enough. However the
choice of components was limited to what was available. This section is written by use of
the data sheets for the DSP (TMS320C26) [Instruments, 1989], the ROM (M27C1024)
[STMicroelectronics, 1998] and the RAM (CY7C199) [Cypress, 2003].

7.3.1 RAM Write Cycle


First the timing conditions from the DSP to the RAM during a write cycle is analyzed.
A timing diagram for the DSP write cycle is shown on figure 7.5 and a write cycle for
the RAM is shown on figure 7.6. The first demand for the RAM is the maximum data

CLKOUT1

CLKOUT2

STRB*
th(A)
A15-A0,
BR*, PS*, VALID
DS* OR IS*

R/W*

READY
tsu(D)W th(D)W
D15-D0 DATAOUT

Figure 7.5: Timing for DSP write cycle.

setup time which must be less than tsu (D)W shown on figure 7.5. For the chosen RAM
this time is called tSD and is given to be 10 ns. The time tsu (D)W is calculated by adding
the propagation delay from the address decoder tPD = 10 ns to tsu (D)W = 2Q − 20 ns

55
7 DSP Hardware Design

ADDRESS
CE*
tPWE
WE*
OE*
tSD tHD
DATA DATAIN VALID
I/O

Figure 7.6: Timing for RAM write cycle.

where Q is a quarter of the time of one instruction cycle. With a 40 MHz clock the time
of an instruction cycle is 100 ns and therefore Q = 25 ns. The total data setup time must
then be less than

tsu (D)W + tPD = 2Q − 20 ns + 10 ns = 2 · 25 ns − 20 ns + 10 ns = 40 ns . (7.14)

From this inspection it is clear that tSD < tsu (D)W + tPD and therefore fulfills the data
setup time requirement.

The next requirement is the time the write enable WE* is low, tPWE > 15 ns according to
the data sheet for the RAM, and since WE* is combined with the STRB* it is lasting 2Q
- 5 ns = 45 ns and thereby fulfilling the demand of at least 15 ns. Furthermore the RAM
has a demand for the data hold time after WE* goes high tHD > 0 ns. This requirement
is by inspection fulfilled as this is given in the DSP as th (D)W = Q − 10 ns = 15 ns.

7.3.2 RAM and ROM Read Cycles


A similar analysis is performed for a read cycle for both the RAM and the ROM com-
pared to the DSP read cycle, which can be seen on figure 7.7.

First of all the RAM must have a data access time lower than ta (A) = 3 · 25 ns − 35 ns =
40 ns. The chosen RAM for which the read cycle is shown on figure 7.8, has access time
tACE = 20 ns given in the data sheet. This must be added with a propagation delay
tPD = 10 ns from the address decoder circuit. Thereby a total access time for the RAM
will be 30 ns and is lower than the required 40 ns from the DSP. Therefore the RAM
fulfills the demand for data access time in a read cycle.

Secondly, the RAM must release the data bus when the data has been sent before a new
instruction cycle begins. A new instruction cycle begins when STRB* goes low again
which happens after tw (SH) = 2 · 25 ns = 50 ns. As figure 7.8 shows, the time tHZOE is
the time for the RAM to get a high impedance output after OE* goes high. This is in
the data sheet given to be 11 ns and again has to be added with the propagation delay
from the decoder circuit. That is tHZ = 11 ns + 10 ns = 21 ns < tw (SH) = 50 ns clearly

56
7.3. Memory Timing and Address Decoding

td(C1-S)
CLKOUT1
td(C1-S)
CLKOUT2

STRB*
tsu(A) th(A)
A15 - A0,
BR*, PS*, VALID
DS* or IS* ta(A)
R/W*

READY

D15 - D0 DATAIN

Figure 7.7: Timing for DSP read cycle.

tRC

CE*
tACE
OE*
tHZOE
tDOE
tHZCE
DATA HIGH Z HIGH Z
OUT DATA VALID

Figure 7.8: Timing for RAM read cycle.

showing that the RAM also fulfill this requirement.

The demands for the ROM are a bit different as the chosen ROM is significantly slower.
The timing of a ROM read cycle is shown on figure 7.9. Specified in the data sheet the
data access time is 100 ns which exceeds the calculated ta (A) = 40 ns and it is therefore
necessary to introduce a wait-state for each ROM read cycle giving the ROM an addi-
tional 100 ns, so that the required maximum data access time is now 140 ns, which the
ROM fulfills.

Additionally the requirement for data hold time before the output gets high impedant
takes advantage from the wait state. The ROM has a tEHQZ < 30 ns and is thereby lower
than tw (SH) = 50 ns and therefore fulfilled.

57
7 DSP Hardware Design

A0 - A15 VALID VALID


tAVQV
CE*
tEHQZ
OE*
tELQV tGHQZ
D0 - D15 HIGH Z

Figure 7.9: Timing for ROM read cycle.

From these inspections it follows that the RAM and ROM blocks chosen are fast enough
and will therefore be implemented into the DSP-system.

7.3.3 Memory Map


The internal memory of the DSP consists of 256 words ROM and 1568 words RAM. The
1568 words of RAM are split up in four blocks of memory (B0 - B3). B2 is always data
memory and use 32 words of the 1568 words. B0, B1 and B3 each use 512 words and can,
through four configuration modes be set as either, all data memory blocks (CONF0), B0
as program memory and others as data (CONF1), B0 and B1 as program memory and
B3 as data (CONF2), or all blocks as program memory (CONF3). The configuration
chosen for the DSP-system is CONF0.

A memory map can now be made based on the choices of external and internal memory
usage. The memory is mapped correspondingly to the three parts, program memory,
data memory and I/O memory. With 32k words of external RAM used as data memory
space, 64k words of external EPROM to use for program memory, 1568 words of internal
data memory space in B0, B1, B2 and B3, and 16 words of I/O memory space.

The resulting memory map is shown on figure 7.10.

7.3.4 Address Decoder


From the memory map an address decoder can be constructed by the use of a PEEL
22CV10 circuit. This is done by assigning the different parts the memory space shown
in figure 7.10 combined with the control signals to the different blocks. The assignment
of the different blocks have, for the data and program parts been assigned according to
the DSP data sheet, whereas the I/O blocks have been assigned using partial address
decoding.

58
7.3. Memory Timing and Address Decoding

PROGRAM DATA I/O

0000h 0000h
Interrupts On-chip
and reserved 00h Display
MMRs
001Fh -(external)- 0005h
0020h 0006h
Reserved
005Fh
0060h
On-chip
D/M Block B2
- EPROM 007Fh
0080h 04h Keyboard
Reserved
01FFh
0200h
On-chip
Block B0
0FFFh 03FFh
0400h
On-chip
External Block B1
05FFh
unused 0600h
On-chip
Block B3
FFFFh 07FFh
0800h 0Fh D/M
External
8FFFh

Figure 7.10: Memory map for program, data and I/O memory space.

Function A2 A3 A12 A13 A14 A15 DS* PS* IS*


Display 0 0 X X X X 1 1 0
Keyboard 1 0 X X X X 1 1 0
ROM X X 0 0 0 0 1 0 1
RAM X X 1 X X X X X 1
X X X 1 X X X X 1
X X X X 1 X X X 1
X X X X X 1 X X 1

Table 7.1: Address decoder table.

In table 7.1 these mappings can be seen expressed by the address bus pins that construct
the desired address and control signals. Additionally, a wait state signal is needed for the
ROM and an indication of whether data is to be written to or read from the RAM must
be created.

The signal for the ROM to indicate when a wait state is needed (READY*) must be
constructed from: READY* = MSC* · CS_ROM. This signal is sent to the DSP in-
dicating that it must wait an instruction cycle, thereby allowing the ROM to ready its
data for reading.

The read and write signals can be made from the R/W* pin from the DSP combined
with the STRB* pin. Thus a write enable signal (WE*) can be constructed from: WE*
= R/W* · STRB* and an output enable signal (OE*) can be constructed from: OE* =

59
7 DSP Hardware Design

R/W* · STRB*.

Now the different chip select signals can be constructed.

• CS_DISP = A2 · A3 · DS* · PS* · IS*

• CS_KEYS* = A2 · A3 · DS* · PS* · IS*

• CS_ROM* = A12 · A13 · A14 · A15 · DS · PS* · IS*

• CS_RAM* = (A12 + A13 + A14 + A15) · IS*

7.4 User Interface


For the user and the guitar effects unit to be able to communicate with each other a user
interface must be designed. The guitar effects unit uses a LCD-display for showing effects
routing and effects parameters and the user uses five buttons with debouncing circuits
attached and a 24 step jog wheel.

The menu system will be in two levels. Menu level one is the main menu or routing menu
as seen on figure 7.11. Here the user selects which effects to become active by pressing left
and right buttons, and the order of the current effects are determined by the up and down
buttons. When pressing the ok button at any given effect, this takes the user to menu
level two as seen on figure 7.12. Menu level two allows the user to change the settings

Routing Menu Settings Menu


> Effect A < > Param A 0 ms <
Effect B Param B 0.1 Hz
Effect C Param C -10 dB
Ĺ Ĺ
ĸ OK ĺ ĸ OK ĺ
Ļ Ļ

Figure 7.11: User interface at menu level one Figure 7.12: User interface at menu level two
where up to three different effects can be chosen. with different values and units as examples.

of each parameter of the current effect. Up and down buttons select which parameter to
configure and the direction of the jog wheel changes the value of the chosen parameter.
Pressing ok button again takes the user to the routing menu.

7.4.1 Jog Wheel (Incremental Encoder)


The benefit of using an incremental encoder is that it is not dependent on the position of
the wheel. Its only function is to indicate whether it is turned clockwise (CW) or counter
clockwise (CCW). This is done through the use of two data pins, A and B. Figure 7.13

60
7.4. User Interface

shows the quadrature output table for a clockwise turn on the jog wheel, and figure 7.14
shows the quadrature output table for a counter-clockwise turn on the jog wheel.

Pin A 1 0 0 1 1 Pin A 1 1 0 0 1
Pin B 1 1 0 0 1 Pin B 1 0 0 1 1

Figure 7.13: Quadrature of a clockwise turn Figure 7.14: Quadrature of a counter-


on the jog wheel. clockwise turn on the jog wheel.

Some sort of logic is needed to determine the direction of the jog wheel when turned.
It is chosen to implement this logic as software where one evaluates which pin goes low
first, and performs respective subroutine as both pins turn low.

Before the pins are connected to the data bus, both pins are fed through a bus driver
which ensures a high impedance output when the jog wheel is not chip selected.

61
Chapter 8
Software Design

This chapter gives an overview of the overall DSP software design. The software design
is based on an analysis of the data flow in the DSP-system. The content of this chapter
also comprises an analysis of memory consumption and memory management.

8.1 Data Flow Analysis

Keyboard
Keyboard
driver
Display
Display
Menu driver
handler

Jog wheel
Jog wheel
driver Effect settings

Delay Echo Chorus Flanger Reverb Equalizer

A/D D/A
converter converter

Effect
handler

Figure 8.1: Data flow diagram of overall DSP software.

In order to analyze the overall DSP software system an analysis of the data flow has
been performed. Figure 8.1 shows a data flow diagram which consists of four symbolic
objects: A square indicates where data emerges and terminates, a circle indicates a data
transformation, two parallel lines indicate a data storage and the arrows indicate the di-
rection of the data flow between the individual objects. One major advantage of the data
flow design approach to software design is that it enables a high degree of modularity. A
program which is easy to test, expand, recycle and maintain is thereby achieved. Once
the individual objects are identified, the interface between them can be specified. In that
way each data transformation and data storage is a module that can be developed, tested
and maintained separately.

62
8.1. Data Flow Analysis

The individual parts of the data flow diagram are described below:
• Data emerge
- Keyboard
The keyboard consists of five buttons whose functionality is described in sec-
tion 7.4 on page 60. Data emerge each time the user presses a button.
- Jog wheel
The jog wheel is like the buttons a part of the user interface. The functionality
of the jog wheel is described in section 7.4 on page 60. Data emerge each time
the user turn the jog wheel.
- A/D converter
The input signal is the data from the A/D converter which samples the guitar
signal. Data emerge with the sampling frequency.
• Data transformations
- Keyboard driver
The keyboard driver scans and decodes the keyboard.
- Jog wheel driver
The jog wheel driver scans and decodes the jog wheel.
- Menu handler
The menu handler reads the output data from the keyboard driver and the
jog wheel driver and changes the menu state accordingly. If some of the ef-
fect settings are altered, the menu handler writes those changes to the menu
settings data storage. Finally, the menu handler updates the display through
the display driver.
- Display driver
The display driver writes strings to the display.
- Effect handler
The effect handler reads an input sample from the A/D converter, determines
which effects are enabled and the order of them based on a lookup in the effect
settings data storage. When all the enabled effects have been performed, the
output sample is passed to the D/A-converter.
- The effects
The different effects take a sample passed from the effect handler as input
and calculate an output sample. The calculations are based on look-up in the
effect settings data storage. Each effect has its own data storage which is not
shown in the figure.
• Data termination
- Display
The display shows the different settings of the effects. The menu structure is
described in section 7.4 on page 60.

63
8 Software Design

- D/A converter
The D/A converter converts the output sample into an analog output signal.

The interface between each object will not be described here even though it is vital. It
is, however, very cumbersome to give an easy and short description of each module for
which reason it is omitted in this chapter.

8.2 Program Flow


The program flow is subject to hard real-time requirements. This means that if an op-
eration completes after its deadline, the output is considered useless. The important
deadline in the guitar effects unit that the program must not exceed, is the sampling fre-
quency. Each time the D/A converter must convert, a new sample must be ready for it. If
the new sample is not ready before the D/A converter must convert, the sample is useless.

Ts=51.2 µs
512 instructions/sample

ISR MP ISR MP

Interrupt Interrupt Interrupt

A/D and A/D and A/D and


D/A D/A D/A
conversion conversion conversion

Figure 8.2: Program flow overall DSP software.

Figure 8.2 shows the program flow of the software in the guitar effects unit. An inter-
rupt occurs with the sampling frequency of 19531 Hz. This initiates the interrupt service
routine (ISR) whose task is to add the desired effects to the input sample from the A/D
converter and send the output sample to the D/A converter before the next interrupt
occurs. Referring to the data flow diagram in figure 8.1 the interrupt service routine
consists of the effect handler and the different effects.

The DSP runs with a speed of 10 million instructions per second (Mips) which gives
b10 Mips/19531 Hzc = 512 instructions per sample. Hence, the interrupt service routine
must not exceed 512 instructions. When the interrupt service routine has completed, it
leaves the DSP to the main program (MP) until the next interrupt occurs. The main
program consists of the non time-critical part of the program which is the keyboard and
jog wheel driver, the menu handler and the display driver in the data flow diagram in
figure 8.1.

64
8.3. Memory Management

8.3 Memory Management


The memory management concerns partitioning of the memory into different parts that
the different data transformation routines in figure 8.1 can use. Every effect require mem-
ory in order to operate where coefficients and delayed samples can be stored. If multiple
effects are enabled these memory spaces must not overlap. Additionally the effect and
menu settings must be stored and the effect settings must be accessible by the individual
effects.

Internal registers
and RAM Data memory External RAM
0000h DRR (0000h) 0000h
DXR (0001h) Internal registers 1000h D/M RAM
Memory mapped TIM (0002h) and RAM (80 words) 104Fh
registers PRD (0003h) (2048 words) 1050h Interrupt vectors
IMR (0004h) 07FFh (14 words) 105Dh
0005h 0800h Mirror of external 105Eh D/M RAM
GREG (0005h)
0006h Reserved ROM 0FFFh (18 words) 106Fh
005Fh 1070h Unused (144 words)
1000h 10FFh
0060h Temporary data
On-chip Block B2 1100h User program
(32 words) 007Fh (7936 words) 2FFFh
0080h Reserved 01FFh 3000h Chorus/Flanger
0200h Data stack External RAM
(32768 words) (3200 words) 3C7Fh
On-chip Block B0 (128 words) 027Fh 3C80h Equalizer
0280h Menu table (1024 words) 407Fh
0380h 037Fh
4080h
Effect settings 8FFFh Reverberation
On-chip Block B1 (512 words) 9000h (8319 words)
05FFh
60FFh
0600h Mirror of external 6100h Echo Delay
On-chip Block B3 Menu handler
RAM (12032 (12032
(512 words) 07FFh words) words) 8FFFh
FFFFh

Figure 8.3: Data memory organization.

Figure 8.3 shows the data memory organization. The data memory is on overall basis
partitioned into two memory spaces. The first space consists of the internal registers and
internal RAM of the DSP. The second space is the external RAM. The memory allocation
to each effect is based on calculations that will be done in the different effect chapters.
The delay and echo effects consume a lot of memory and can therefore not be enabled at
the same time. Hence, they share the same part of the memory.

This concludes the design of the hardware and software platform on which the digital
effects should run. In the next three chapters the different digital effects will be designed
and implemented.

65
Chapter 9
Reverberation

In this chapter the reverberation effect is designed. The chapter begins with a description
of what reverberation is and what it is typically used for. Afterwards, some simple
reverberation algorithms are examined. This comprises the simple plain reverberator and
the simple allpass reverberator which are building blocks in more advanced reverberators
as Scroeder’s and Moorer’s reverberator. These reverberators will also be examined in
some detail. The final reverberator is a mix between Scroeder’s and Moorer’s reverberator
and the rest of this chapter will focus on the implementation of it on the DSP-system.
The implementation comprises scaling and SNR calculations.

9.1 Real and Simulated Reverberation


Reverberation is the acoustic effect of a room on an acoustic signal. Figure 9.1 shows
an example of reverberation. A loudspeaker generates acoustic waves which travel inside
a room. The direct sound is the part of the sound that travels directly from the loud-
speaker to the listener and is indicated by a solid line in figure 9.1. The early reflections
correspond to the first couple of reflections off the walls and are indicated by long dotted
lines in the figure. The acoustic waves perceived by the listener increase in density as the
acoustic wave reflects more and more times off the walls. This is known as the late or
subsequent reflections and is indicated by short dotted lines in the figure.

|h(t)|
Direct
sound

t
Early Late
reflections reflections

Figure 9.1: The influence of the room on the Figure 9.2: Partitioning of reverberation in di-
sound. The direct sound, early and late reflec- rect sound, early and late reflections.
tions are shown.

The influence of the room on the acoustic signal perceived by the listener can be char-
acterized by the impulse response of the room. An example of the impulse response of
a room is shown in figure 9.2. The impulse response is dependent upon the placement

66
9.2. Reverberation Algorithms

of loudspeaker and the listener. Especially the early reflections vary with placement of
the loudspeaker and the listener while the late reflections are relatively independent of
the location in the room [Kahrs, 1998]. The amplitude level is approximately decaying
exponentially and the density of the acoustic signal perceived by the listener increases
quadratic with time. The time it takes for the sound pressure to decrease by 60 dB is
defined as the reverberation time [Zölzer, 1997].

Artificial reverberation is mainly used for post-processing [Zölzer, 1997]. Music is of-
ten recorded in a studio with a microphone in the vicinity of a voice or an instrument
for which reason mainly the direct signal is recorded. To make the music sound more
natural, artificial reverberation is often applied to the direct signal which maps it to an
acoustical room. In fact, almost all the audio from the radio, movies and recordings have
had artificial reverberation added [Kahrs, 1998]. In that way classical music can sound
like it is played in a concert hall even though it is recorded in a studio.

There exist several ways to implement reverberation in a digital computer. One way is to
measure an actual typical impulse response of a room and implement it as a FIR-filter.
This approach works only for impulse responses with a very short reverberation time
since the FIR-filter length otherwise will be very long and leads to long computation
time. The method can be speeded up by FFT-block convolution, but this approach suf-
fers from processing delay whose length is often unacceptable in real time reverberation
[Zölzer, 2005]. There exist algorithms that speed up the FFT-block convolution consid-
erably, but those methods are advanced and will not be investigated further in this text
[Zölzer, 2005]. Instead several artificial reverberation algorithms without significant pro-
cessing delay or computation time, have been developed to simulate real reverberation.
This approach has in addition the advance of adjustability. Hence, it is possible to adjust
several parameters of the algorithm which allows the same algorithm to simulate various
types of reverberation. The parameters could for instance be the reflection coefficients of
the walls, reverberation time and the initial delay between the direct sound and the first
reflection.

A lot of reverberation algorithms have been developed spanning from extremely simple
ones to advanced ones. The rest of the content of this chapter will focus on a few simple
reverberation algorithms which form the basis of more advanced ones. It is, however,
beyond the scope of this project to cover more advanced reverberation algorithms.

9.2 Reverberation Algorithms


The first digital artificial reverberator was invented by Scroeder in 1961 and is known as
Schroeder’s reverberator [Zölzer, 1997]. It consists of two basic building blocks; the plain
reverberator and the allpass reverberator which will be examined in the beginning of this
section. After that, Schroeder’s reverberator will be examined. Schroeder’s reverberator
has some disadvantages that will be discussed in the conclusion of this section in the

67
9 Reverberation

context of Moorer who proposed some improvements of Schroeder’s reverberator.

9.2.1 Plain Reverberator


The plain reverberator is the simplest reverberation tool. It simulates the exponential
decay of the reverberation and it is shown in figure 9.3. It consists of a delay unit z −m ,
a gain g in the feedback path and a summer which add the input signal to the feedback
signal. The Z-transform can be derived from the figure by

X(z) + gY (z)z −m = Y (z) (9.1)

which can be rearranged to yield the transfer function

Y (z) 1
H(z) = = . (9.2)
X(z) 1 − gz −m

h(n)
1
x[n] y[n]
+
Ȉ
g
+
z-m g2
g g3
g4
g5
0 m 2m 3m 4m 5m n

Figure 9.3: Plain reverberator.


Figure 9.4: Impulse response of plain reverberator.

From the transfer function given in equation 9.2 several important properties of the plain
reverberator can be found. One important property can be derived from the impulse
response. The difference equation can be found to

y[n] = x[n] + gy[n − m] (9.3)

which can be used to plot the impulse response of the plain reverberator recursively. If
the input signal, x[n], is Dirac’s delta function, δ[n], the output signal, y[n], will be the
impulse response, h[n]. Figure 9.4 shows the first six samples of the impulse response of
the plain reverberator. The figure shows that the spacing between two successive nonzero
samples is the delay m and that the amplitude of the nonzero samples decreases expo-
nentially.

Another property that can be derived from the transfer function in equation 9.2, is the
frequency response. By setting z = ejω the frequency response can be found from the
transfer function to
1
H(ejω ) = , (9.4)
1 − ge−jωm

68
9.2. Reverberation Algorithms

whose amplitude response is given by


1 1
|H(ejω )| = =p
|1 − g[cos(ωm) − j sin(ωm)]| (1 − g cos(ωm))2 + (g sin(ωm))2
1
=p . (9.5)
2
1 + g − 2g cos(ωm)

The maximum and minimum values of the amplitude response can be found to be
1 1 2π
|H(ejω )|MAX = p = for ω = p , p = 0, 1, 2, · · · , m − 1 (9.6)
2
1 + g − 2g 1 − g m

and
1 1 π
|H(ejω )|MIN = p = for ω = (2p + 1) , p = 0, 1, 2, · · · , m − 1 .
2
1 + g + 2g 1 + g m
(9.7)

Figure 9.5 shows an example of the amplitude response of the plain reverberator in the
frequency interval spanning from 0 to 2π. In the example the delay, m, is set to 8 and
the feedback gain, g, is set to 0.5. The amplitude has m = 8 uniformly spaced peaks
with a value of |H(ejω )|MAX = 2 as suggested by equation 9.6. The minimum value is
|H(ejω )|MIN = 2/3 as suggested by equation 9.7. Due to the shape of the amplitude
response it is often referred to as a comb filter.

2
Im(z)
1.8

1.6

1.4
|H(ejω)| [×]

1.2

1
Re(z)
0.8
1
0.6

0.4

0.2

0
0 pi/2 pi 3pi/2 2pi
ω [rad]

Figure 9.6: Poles of the comb filter


Figure 9.5: Frequency response of comb filter with m = 8
transfer function.
and g = 0.5.

The poles of the transfer function are closely related to the frequency response. The roots
of the denominator of the transfer function in equation 9.2 can be found to

0 = 1 − gz −m ⇔ z m = g . (9.8)

69
9 Reverberation

If z is written in polar form, the poles can be found to

rm ejωm = g , (9.9)

which yields a pole radius of

r = g 1/m (9.10)

and a pole angle of


ω=p , p = 0, 1, 2, · · · , m − 1 . (9.11)
m
The poles are plotted in figure 9.6 with m = 8 and g = 0.5.

The reverberation time of the plain reverberator can be found from the impulse response
shown in figure 9.4. The amplitude of the kth nonzero sample is g k . The amplitude has
therefore decreased 60 dB at
 kr   
g kr
− 60 dB = 20 log10 = 20 log 10 g (9.12)
g0
where kr is the nonzero sample number corresponding to the reverberation time tr . Since
n = k · m and n = tfs , kr can be replaced with trmfs which yields a reverberation time of
 tr fs 
−60 dB = 20 log10 g m (9.13)
m
−3m
tr = . (9.14)
log10 (g)fs
Thus, given the sampling frequency, the reverberation time can be determined by the
delay length, m, and the feedback gain, g, of the plain reverberator.

The shape of the amplitude response is often undesirable since the frequencies between
the peaks of the spectrum will be attenuated. The density of the peaks in the frequency
can be increased by increasing the delay m, but this leads to a decreasing echo density
in the time domain. One way to obtain high frequency density and high echo density is
to use several comb filters with different delays and gains in parallel. This design is used
in Schoeder’s reverberator.

9.2.2 Allpass Reverberator


Since the peaks in the frequency response of the comb filter are undesirable, Schroeder
modified the comb filter so that the amplitude response was flat [Kahrs, 1998]. The re-
sulting filter is called an allpass filter and its block diagram is shown in figure 9.7.

70
9.2. Reverberation Algorithms

-g h(n)
x[n] + y[n]
+
Ȉ Ȉ 1-g2
g(1-g2) 2
+ + g (1-g2)
z-m g3(1-g2)g4(1-g2)
0
m 2m 3m 4m 5m n

g
-g

Figure 9.7: Allpass reverberator.


Figure 9.8: Impulse response of allpass reverberator.

From the block diagram the transfer function can be found to

Y (z) z −m − g
H(z) = = , (9.15)
X(z) 1 − gz −m

from which the difference equation is

y[n] = x[n − m] − gx[n] + gy[n − m] . (9.16)

The impulse response can now be plotted recursively by setting x[n] = δ[n], and the first
few samples of the impulse response are shown in figure 9.8. Like the impulse response
of the plain reverberator, the amplitude of the impulse response of the allpass filter de-
creases exponentially.

The amplitude response of the allpass filter is constant since

|e−jωm − g|
|H(ejω | = (9.17)
|1 − ge−jωm |
|1 − gejωm |
= |e−jωm | (9.18)
|1 − ge−jωm |
p
1 + g 2 − 2g cos(ωm)
= 1p =1. (9.19)
1 + g 2 − 2g cos(ωm)

Even though the amplitude response of the allpass reverberator is flat, it sounds quite
like the plain reverberator [Kahrs, 1998]. This is due to the physics of the human ear
which performs a short-time frequency analysis in contrast to the Fourier transform that
is defined for infinity time integration [Kahrs, 1998]. Figure 9.9 illustrates the spectrum
of the allpass reverberator and has been computed using an FFT and window length of
50 ms which corresponds to the integration time of the human ear [Zwicker and Fastl,
1999]. The window is a Hanning window which has been shifted 1 ms for each FFT
computation. The spectrum has the form of a comb filter for a fixed time which explains,
that it sounds like the plain reverberator.

71
9 Reverberation

|H(t,ω)| [W]
2

0 0
5
1 10
2 15
20
325
ω [rad] t [ms]

Figure 9.9: Spectrum of the allpass reverberator with m = 8 and g = 0.5.

The denominator of the transfer function of the allpass filter in equation 9.15 is equal to
the denominator of the transfer function of the comb filter in equation 9.2. Hence, they
have the same poles. The zeros of the allpass filter transfer function are

0 = z −m − g ⇔ z −m = g . (9.20)

If z is written in polar form, the zeros can be found to

r−m e−jωm = g , (9.21)

which yields a zero radius of

r = g −1/m (9.22)

and a zero angle of


ω = −p , p = 0, 1, 2, · · · , m − 1 . (9.23)
m
An example of the pole-zero plot of the allpass reverberator is shown in figure 9.10 with
m = 8 and g = 0.5.

Like the plain reverberator, the allpass reverberator is not suitable to act as a standalone
reverberator since it sounds quite like the plain reverberator. It is, however, very useful
as a building block in a reverberator and is widely used to increase echo density without
affecting the frequency response of the reverberator [Zölzer, 1997].

72
9.2. Reverberation Algorithms

Im(z)

Re(z)
1

Figure 9.10: Pole-zero plot of allpass filter.

9.2.3 Schroeder’s Reverberator


As discussed previously, neither the plain reverberator nor the allpas reverberator can
be used as a standalone reverberator, because neither of them can simulate the required
frequency and echo density at the same time. Schroeder found that the frequency density
should be at least 0.15 Hz−1 and the echo density should be at least 1000 s−1 in order
to make the reverberator sound realistic [Zölzer, 1997]. This means that the distance
between two successive peaks in the amplitude response of the reverberator should be
less than 6.67 Hz and the number of echoes per second that a listener perceives should
be greater than 1000.

One way to achieve the desired frequency and echo density is to use several comb filters
in parallel. If the delays of the different comb filters are chosen in such a way that
they are prime relatively to each other, the frequency and echo density can be increased.
Schroeder showed that at least 12 comb filters in parallel was required in order to meet the
required density specifications [Kahrs, 1998]. He also showed that if two allpass filters in
series were combined with the comb filters in parallel only four comb filters were required
[Kahrs, 1998]. Figure 9.11 shows this basic reverberator which is known as Schroeder’s
reverberator. The input signal is fed into the four comb filters whose outputs are summed.
The summed signal is then fed into two allpass filters in series. The four comb filters
increase the frequency density while the allpass filters increase the echo density.

It is half an art half a science to find the optimal gain and delay factors involved in the
reverberator. Schroeder suggested that the delays in the comb filters should be in the
interval of 30 ms to 45 ms [Kahrs, 1998]. The gains of the comb filters are determined
by the desired reverberation time which from equation 9.14 is given by
−3mi
gi = 10 tr fs . (9.24)

73
9 Reverberation

CF w1[n]
m1, g1

CF w2[n] +
x[n] m2, g2 + w5[n] w6[n] y[n]
Ȉ
APF APF
+ m5, g5 m6, g6
CF
m3, g3 w3[n] +

CF
m4, g4 w4[n]

Figure 9.11: The basic Scroeder reverberator.

The delays of the allpass filter are chosen to be small with respect to the delays of the
comb filters. This ensures that the allpass filters increase the echo density significantly.
Additionally, the overall reverberation time only depends on the reverberation time set
by the comb filters. The gains of the allpass filter are typically set to around 0.7 [Kahrs,
1998].

0.5
h(t)

−0.5

−1
0 0.2 0.4 0.6 0.8 1
t [s]

Figure 9.12: Impulse response of Scroeder’s reverberator with reverberation time set to 1 s.

τ1 τ2 τ3 τ4 τ5 τ6
Delays [ms]
31 37 41 43 5 1.7
g1 g2 g3 g4 g5 g6
Gains [·]
0.81 0.77 0.75 0.74 0.70 0.70

Table 9.1: Selected delays and gains in Schroeder’s reverberator.

Figure 9.12 shows the impulse response of Schroeder’s reverberator with the values of the
various gains and delays as given in table 9.1. The gains of the comb filters are calculated
from equation 9.24 with a reverberation time of 1 s and mi = τi fs . The envelope of
the impulse response is clearly decreasing exponentially. Figure 9.13 shows the spectrum

74
9.2. Reverberation Algorithms

of Schroeder’s reverberator. The spectrum has been created using a short-time Fourier
transform again with an FFT and window length of 50 ms. The window is a Hanning
window which has been shifted 25 ms for each FFT computation. The spectrum indicates
that every frequency component has almost the same reverberation time.
|H(t,ω)|2 [W]

0 0

1
0.5
2

3 1 t [s]
ω [rad]

Figure 9.13: Spectrum of Scroeder’s reverberator with reverberation time set to 1 s.

A sound test has been performed with Schroeder’s reverberator. In the test a source
signal is convolved with the impulse response of Schroeder’s reverberator to create a
reverberated signal. Different impulse responses with various reverberation times have
been generated and used, and it is easy to distinguish between the different reverber-
ation times when the reverberated signals have been played. The reverberated signals
suffer, however, from one major disadvantage which make the reverberated signals sound
unnatural. They sound metallic, especially for longer reverberation times. This obser-
vation was also done by Moorer for which reason, he made some small modification on
Schroeder’s revereberator [Kahrs, 1998]. These modifications will be described next.

9.2.4 Moorer’s Reverberator


In 1979 Moorer proposed two improvements of Schroeder’s original reverberator [Kahrs,
1998]. The first improvement was to increase the number of comb filters from four to six
which increased both the frequency and echo density. The second improvement was to
add a one-pole lowpass filter in the feedback path of the comb filters. This was based on

75
9 Reverberation

the physical properties of sound wave propagation inside a room where higher frequency
components tend to get attenuated more than lower frequency components.

x[n] y[n]
+
Ȉ
+ G(z) z-m
+ +
Ȉ Ȉ
b + +
z-1
a1

Figure 9.14: The plain reverberator with a one-pole lowpass filter in the feedback path.

Figure 9.14 shows the plain reverberator with a one-pole lowpass filter in the feedback
path. The transfer function of the lowpass filter, G(z), is

1 + z −1
G(z) = b . (9.25)
1 − a1 z −1

The coefficients b and a1 are found from filter design based on the bilinear transformation
method described in appendix D. The steps shown in figure D.1 on page 125 gives the
following procedure for the design:

1. Digital filter specifications


The digital filter must be a first order Butterworth lowpass filter with a cutoff
frequency of ωc .

2. Analog filter specifications


The analog specifications are the same as the digital except for the pre-warping
of the cutoff frequency. The pre-warped analog cutoff frequency is according to
equation D.9 page 127
2
Ωc = tan(ωc /2) (9.26)
Ts
where Ts is the sampling time.

3. Analog filter design


The Butterworth filter design leads to a first order lowpass filter with the transfer
function
Ωc
Ga (s) = c (9.27)
s + Ωc
where c is the DC gain.

76
9.3. Design of Reverberator

4. Digital filter design


The digital filter is obtained from the analog filter through the bilinear transforma-
tion. Specifically equation D.4 page 126 is applied which gives the transfer function
of the digital first order lowpass filter to

Ωc 1 + z −1

Gd (z) = Ga (s) =c
2 1−z−1 2/Ts + Ωc 2/Ts − Ωc −1
s= T 1− z
s 1+z −1
2/Ts + Ωc
tan(ωc /2) 1 + z −1
=c . (9.28)
1 + tan(ωc /2) 1 − tan(ωc /2) −1
1− z
1 + tan(ωc /2)

Comparing equation 9.28 with equation 9.25 gives expressions for the coefficients b and
a1 to

tan(ωc /2)
b=c (9.29)
1 + tan(ωc /2)

and

1 − tan(ωc /2)
a1 = . (9.30)
1 + tan(ωc /2)

The DC gain of the digital lowpass filter must equal the gain, g, from the original plain
reverberator to ensure the same reverberation time in the passband. This means that

2b g(1 − a1 )
g = G(z = 1) = ⇔b= (9.31)
1 − a1 2
which can used to compute the b coefficient.

Figure 9.15 shows the spectrum of the lowpass filter version of Schroeder’s reverberator
(see figure 9.11) with the delays and gains as in table 9.1 and the corner frequency set
to 0.25π. From the figure it is seen that the reverberation time is frequency dependent.
The reverberation time decreases with increasing frequency. A sound test has revealed
that the metallic sound has been reduced significantly with the addition of the lowpass
filter into the feedback path of the plain reverberator.

9.3 Design of Reverberator


Specification 8 in the requirement specification specifies that

• the reverberation time should be adjustable in the range from 0.1 s to 4 s.

• the reverberation level should be adjustable in the range from 10 % to 100 %.

77
9 Reverberation

|H(t,ω)|2 [W]

0 0

1
0.5
2
3 1 t [s]
ω [rad]

Figure 9.15: Spectrum of the lowpass filters version of Scroeder’s reverberator with reverberation time
set to 1 s.

• the pre-delay should be adjustable in the range from 0 ms to 100 ms.


A reverberator that enables adjustability of these factors is shown in figure 9.16. The
pre-delay is a simple delay block with adjustable delay length d. The reverberation level
gr is controlled with a simple gain block. The reverberation time is controlled with the
b coefficients that can be calculated from equation 9.31 and 9.24. The coefficient a1 is
calculated from equation 9.30 to -0.0189 which corresponds to a corner frequency of 5
kHz, and the rest of the coefficients are set according to table 9.1.

9.4 Implementation of Reverberator


Before the reverberator is implemented it must be chosen whether the filters must be im-
plemented as direct form type I or direct form type II. As shown later in this section, type
I has the best SNR for this application, but requires more memory. Type II has a worse
SNR but has the advantage of a lesser buffer size. Type I is chosen due to the better SNR.

First, the scale factor and the SNR of the reverberator are calculated.

9.4.1 Scaling and Signal to Noise Ratio


The DSP system is a fixed point arithmetic system, meaning that values like 2.3 and 23
are represented alike. So it is the user that must take care of handling where the point

78
9.4. Implementation of Reverberator

x[n]
Reverberator
Pre-delay LPCF w1[n]
m1, b1, a1
z-d
LPCF w2[n] + +
gr m2, b2, a1 w5[n] w6[n] y[n]
+ w7[n] +
Ȉ Ȉ
APF APF
+ m5, g5 m6, g6
LPCF
Reverberation m3, b3, a1 w3[n] +
level
LPCF
m4, b4, a1 w4[n]

Figure 9.16: Scroeder’s reverberator with lowpass filter version of comb filters, pre-delay and reverber-
ation level.

is to be. If numbers are specified to be in the Q15 format, 15 bit are used to represent
the numbers before the point, meaning that the values between -1 and 1-LSB can be
represented with a resolution of 15 bits. This can be problematic if the implemented
filters increases the values of the input sample, causing overflow and thereby corrupting
the output sample. To prevent this from happening the filter coefficients or the input
sample must be scaled. To determine whether scaling is necessary, the filters must be
analyzed.

Filter Analysis to Determine the Scale Factor


Filters consist of multiply and addition operands. As all filter coefficients for the rever-
berator are between -1 and 1-LSB and Q15 is used, a multiplication can never lead to
overflow. Hence, the analysis must be focused on the summing point at the output of
the respective filters. If some points result in overflow, the input signal must be scaled
accordingly.

The analysis for the allpass filter can be done finding the filter impulse response. When
this is found a variance scaling can be performed. Using equation [Oppenheim and Schafer,
1999, page 401]

1
s ≤ qP (9.32)
∞ 2
n=−∞ |h[n]|

the scaling factor s is then the factor that the input must be scaled with. If the scale
factor is multiplied with the input before it is fed to the filter, the output will be scaled
so that it in most cases will not overflow. If overflow should be totally avoided, variance
scaling is not the approach to take. This is because variance scaling, scale on basis of the
energy in the signal and not the signal itself [Oppenheim and Schafer, 1999, page 401].

79
9 Reverberation

The impulse response for one of the allpass filters is calculated here. For analysis of the
lowpass filters, see appendix E page 128.

To find the impulse response for the allpass filter, the transfer function 9.15 is rewritten
into the form
B
H(z) = A + , (9.33)
1 − gz −m
(1−g )2
where A = −1g and B = g . The last term of equation 9.33 is a geometric series, and
equation 9.33 is equal to [Orfanidis, 1996, page 369]

X
H(z) = (A + B) + B g k z −n·m . (9.34)
k=1

The inverse Z-transform of equation 9.34 is

h[n] = (A + B)δ[n] + B(gδ[n − m] + g 2m δ[n − 2m] + g 3m δ[n − 3m] + g 4m δ[n − 4m] + ...) ,
(9.35)

−1 (1−0.72 )
where g = 0.7, A = 0.7 = −1.43 and B = 0.7 = 0.729. Using equation 9.35,
P∞ 2
n=−∞ |h[n]| can be calculated to

X ∞
X
|h[n]|2 = (A + B)δ[n] + B(gδ[n − m] + g 2m δ[n − 2m] + g 3m δ[n − 3m] + ...) 2
n=−∞ n=−∞
= −0.7 + 0.729(0.72 + 0.492 + 0.3432 + 0.2402 + ...)
2

= 1. (9.36)

Using this result with equation 9.32, the scale factor can be found
1 1
s ≤ qP = √ =1. (9.37)
∞ 2 1
n=−∞ |h[n]|

The scale factors for the lowpass comb filters are calculated in appendix E page 128, and
the results are repeated in table 9.2.
Since LPCF1 to LPCF4 are coupled in parallel the filters must be scaled equally. Choos-
ing the lowest scale factor ensures the best protection against overflow. Furthermore since
all parallel filters are summed after filtering, each scale factor must be divided by four,
so the result of the summation is not greater than one.

From figure 9.16 it is seen that the last thing the reverberator does is adding the output
of the filters with the input sample, meaning that the input must be scaled by 21 . To avoid
the scaling from interfering with the sound of the reverberator, all scaling must be done
prior to filtering. All in all the input must be scaled with a factor s = 21 · 14 ·0.5602 = 0.0699
.

80
9.4. Implementation of Reverberator

Filter: Scale factor:


LPCF1 0.5590
LPCF2 0.5832
LPCF3 0.5976
LPCF4 0.6042
APF5 1
APF6 1

Table 9.2: Simulated scale factors using the derivations of appendix E.

Allpass Filters Analysis to Determine SNR


Scaling the input signal to the filters have the advantage of making the system output
more resistant to overflow. But it also has the disadvantage of decreasing the SNR. This
can be seen from the equation [Oppenheim and Schafer, 1999, page 403]
σy2
SNR = s2 (9.38)
σf2
which defines SNR. σy2 is the variance of the output signal and σf2 is the noise variance. It
can be seen from the equation 9.38, that the SNR is dependent on the scale factor squared.

To calculate SNR on the reverberator effect, first the noise variance σf2 of the individual
filters must be found. Since this is quite extensive only the principle is demonstrated for
the allpass filter and the principles for the lowpass comb filters can be found in appendix
E, page 128. Figure 9.17 show the linear noise model for one of the reverberators allpass
filters [Hayes, 1999, page 350].

e[n]

x[n] + y[n]
+
Σ Σ
-g
+ +
z-m z-m

Figure 9.17: The principle of calculating noise variance on a direct form I allpass filter.

1 −2B
The variance of the noise e[n] is σe2 = 12 2 [Hayes, 1999, page 349]. This represent
the quantization noise where B = 15 is the numbers of bit representing the signal values.
This amount of quantization noise is added for every truncation in the filter. The DSP
has a 32 bit accumulator, which has the advantage that the quantization noise only hap-
pens during truncation when data is stored as a 16 bit word.

81
9 Reverberation

The variance of the output noise defined as [Hayes, 1999, page 349, 350]

X
σf2 = σe2 · |hef [n]|2 (9.39)
n=−∞

Before this can be calculated the impulse response has to be found. From figure 9.17 it
is seen that the quantization noise only passes through the pole of the filter. The effect
of this is that only the impulse response from where e[n] is added to y[n] must be found.
This is done using the same method as for the scale factor, as the transfer function
is equivalent to equation 9.33, where A = 0 and B = 1. Using the same procedure
P ∞ 2
n=−∞ |hef [n]| is found to 1.961. The output noise variance can then be calculated
using equation 9.39 to

1 −2·15
σf2 = 2 · 1.961 = 152.18 · 10−12 . (9.40)
12
The signal variance can be calculated setting the input to white noise with variance
2
σinput = 31 [Oppenheim and Schafer, 1999, page 402] and the SNR for the allpass filter
can be found using equation 9.38 and setting the scale factor s = 1

σy2 1
SNR = s2 = 12 3
= 2.19 · 109 . (9.41)
σf2 152.18 · 10−12

In decibel this gives 10 · log(2.19 · 109 ) = 93.41 dB.

A similar analysis have been made for the lowpass comb filters. This can be found in
appendix E on page 128.

SNR for Reverberator Effect


In this section the SNR for the entire reverberator will be elaborated. Figure 9.18 shows
the different variance amplification factors that are needed for the SNR calculations.

It can be seen from the figure that for the reverberator a type I filter structure will have
a superior SNR over a type II filter. This is due to the noise
 variance for a type I filters
P∞ P∞
is σf = σe · n=−∞ |hef [n]| and for a type II σf = σe 1 + n=−∞ |hxy [n]|2 . From
2 2 2 2 2
P P∞
the values on the figure it is seen that 1 + ∞ 2
n=−∞ |hxy [n]| >
2
n=−∞ |hef [n]| . Hence,
type I has the better SNR.

During calculations one must notice that the noise for one filter is both dependent on
the noise from the filter itself and the noise on the input that was made in the previous
filter. This implies that the noise is accumulated through the filters of the reverberator.
So the output noise of the reverberator can be found by identifying each noise source,
calculating the noise on the reverberator output from each of them and finally adding

82
9.4. Implementation of Reverberator

es[n]
Scale factor
s=0.07

x[n]
Ȉ
e1[n] 3.140
3.201
e6[n] +
Pre-delay e5[n]
e2[n] 2.887 + + y[n]
Ȉ
1.961
2.940 + 1.961 1
Ȉ +
Ȉ 1
e3[n] 2.752
2.780 +

e0[n] e4[n] 2.693


2.739

Figure 9.18: The variance amplification factors for calculating the SNR on the reverberator effect for
reverberation time of 4 seconds.

them all together.

When measuring SNR, the noise variance on the system is found when the input is set
x[n] = 0, and when the input is set to white noise.

First the noise variance is derived using figure 9.18. The figure shows the variance am-
plification from signal input to output and noise input to output of each filter block
respectively. As a block in the reverberator has the previous block as input, the noise
variance can be derived to

σf2 = (σe2s + σe20 )(σ1xy


2 2
+ σ2xy 2
+ σ3xy 2
+ σ4xy )
  2
+σe21 (σ1ef
2 2
+ σ2ef 2
+ σ3ef 2
+ σ4ef 2
) · σ5xy + σe25 σ5ef
2
· σ6xy + σe26 · σ6ef
2
+ σe2s ,
(9.42)
1 −2·15
where each of the quantization noises σe2x = 12 2 . If equation 9.42 is read backwards it
is like looking on figure 9.18, from y[n] towards x[n]. It is seen that each filter takes all the
noise from the previous filters as input. The noise variance for a 4 second reverberation
time can be calculated to

2 1 1
σf = ( 2−2·15 + 2−2·15 )(3.201 + 2.940 + 2.780 + 2.739)
12 12
 
1 −2·15 1 −2·15 1
+ 2 (3.140 + 2.887 + 2.752 + 2.693) · 1 + 2 · 1.961 · 1 + 2−2·15 · 1.961
12 12 12
=3.008 · 10−9 . (9.43)

Next the variance for the signal must be found. This can be done using the already
2 . See figure 9.18 for values.
calculated impulse responses for filters input to output σxy

83
9 Reverberation

The signal variance can be calculated setting the input to white noise with variance
2
σinput = 31 [Oppenheim and Schafer, 1999, page 402]. Then the signal variance is

2 2
σsignal =σinput · s2 (σ1xy
2 2
+ σ2xy 2
+ σ3xy 2
+ σ4xy 2
) · σ5xy 2
· σ6xy + s2 · σinput
2

1 1
= · (69.87 · 10−3 )2 (3.201 + 2.940 + 2.780 + 2.739) · 1 · 1 + (69.87 · 10−3 )2 ·
3 3
=20.633 · 10−3 . (9.44)

Now the scaling factor and quantization noise is known the SNR can be calculated
2
σsignal 20.633 · 10−3
SNR = = = 6.860 · 106 (9.45)
σf2 3.008 · 10−9

In decibel this gives 10 · log(6.860 · 106 ) = 68.36 dB. Figure 9.19 show the SNR depending
on the reverberation time.

68.4

68.35

68.3
SNR [dB]

68.25

68.2

68.15
0 0.5 1 1.5 2 2.5 3 3.5 4
Reverberation time [s]

Figure 9.19: SNR of the reverberation effect based on derivation and calculations in MATLAB.

It is seen on the figure that the noise in the filters is almost unaffected over time. Since
both the signal variance and the noise variance raises over time, making the SNR almost
unaffected. This results in a difference of 1.2 dB from the shortest reverberation time to
the longest.

9.5 Reverberation Memory Requirements


The reverberation effect are dependent on several ring buffers due to the different filters.
To give an overview of the memory requirements this section describes the structure of
the memory. The different ring buffers are listed in table 9.3

84
9.6. Conclusion on Reverberator

Ring buffer: Maximal length: [ms] Maximal length: [words]


Pre-delay 100 1953
LPCF1 31 606
LPCF2 37 723
LPCF3 41 801
LPCF4 43 840
APF5 5 98
APF6 1.7 33

Table 9.3: Ring buffers for the reverberation effect.

From the table the memory requirements can be calculated. As described in the chapter,
the filters are implemented as type I filters. Each type I filter has an input buffer and an
output buffer. This means that the total memory requirements are the double of what
table 9.3 lists, since every sample must be stored in both an input and an output buffer.
For two successive filters, the output buffer of the first filter will be identical to the input
buffer of the second filter. Using this fact the pre-delay buffer can be used as input buffer
for the four lowpass comb filters and the output buffer of the first allpass filter can be
used as input buffer for the second allpass filter. For the software implementation the
total memory requirement can now be calulated. In total, eight ring buffers are needed:

1. Pre-delay buffer (also used for input buffer for all LPCF filters) length of 1953
words.

2. LPCF1 output buffer length of 606 words.

3. LPCF2 output buffer length of 723 words.

4. LPCF3 output buffer length of 801 words.

5. LPCF4 output buffer length of 840 words.

6. APF5 input buffer length 98 words.

7. APF5 output buffer (also used for input buffer for APF6 filter) length 98 words.

8. APF6 output buffer length 33 words.

This requires a total memory size of 1953 + 606 + 723 + 801 + 840 + 98 + 33 = 5054 words
in the use for ring buffers, which is about 61 of the total system memory.

9.6 Conclusion on Reverberator


This chapter was begun with review of different reverberation algorithm. A mix between
the Shroeder’s and Moorer’s reverberator was chosen for implementation since it per-
formed quite well in MATLAB simulation and listening tests. The best implementation

85
9 Reverberation

structure was found to be a direct form I structure since the noise caused by rounding
is lower and the memory consumption can be reduced by recycling the buffers. Due to
time limitations, the acceptance test specified has not been carried out.

86
Chapter 10
Echo, Delay, Flanger and Chorus

The echo, delay, flanger and chorus are all time dependent effects. Since all effects are
alike, the descriptions will be short. First, all effects will be described from their block
diagram and difference equation. Afterwards the effects are simulated in MATLAB and
the implementation on the DSP is described.

10.1 Echo Effect


The echo effect is made using a feedback loop. This gives an IIR filter structure, where
the gain factor ge determines how much the delayed output is attenuated before it is fed
back to the input. Figure 10.1 shows the block diagram for the echo.

x[n] y[n]
+ Ȉ
+ ge
z-m

Figure 10.1: Block diagram of echo effect.

The diagram shows that the output is a function of a previous output, which can be seen
from the difference equation

y[n] = x[n] + ge · y[n − m] . (10.1)

The gain factor must be set to the desired gain between 0 and 0.8. The larger the value
the more echoes will be heard. The frequency response of the echo effect will be a comb
filter as described in section 9.2.1 page 68.

10.1.1 Simulation of Echo


An impulse response for the echo effect is found using MATLAB. A simulation is shown
on figure 10.2.

The simulation is made by inputting a Dirac delta function so the impulse response is
obtained. For the echo effect it is seen that each echo has half the amplitude of the
previous echo since the gain factor is set at 50 %.

87
10 Echo, Delay, Flanger and Chorus

0.9

0.8

0.7

0.6

Amplitude [.]
0.5

0.4

0.3

0.2

0.1

0
−2 0 2 4 6 8 10 12 14
Time [s]

Figure 10.2: Simulation of the echo effect with ge equal to 50 % and a delay of 600 ms.

10.2 Delay Effect


The delay effect is made using a feedforward loop. In this way the output will not be
repeated again and again and only one echo is heard. This single echo is known as delay.
The gain factor gd determines the level of delay. Figure 10.3 shows the block diagram for
the delay.

x[n] y[n]
+ Ȉ
gd +
z-m

Figure 10.3: Block diagram of delay effect.

This shows that the output is a function of a delayed input, which can be seen from the
difference equation

y[n] = x[n] + gd · x[n − m]. (10.2)

This corresponds to a FIR filter as the filter only contains a feedforward path. Like the
echo effect the gain factor must be between 0 and 0.8.

10.2.1 Simulation of Delay


An impulse response for the delay effect is found using MATLAB. A simulation is shown
on figure 10.4.

The simulations are made by inputting a Dirac delta function, so the impulse response
is obtained. For the delay effect it is seen that the delay has an amplitude equal to gd of
50 %.

88
10.3. Flanger Effect

0.9

0.8

0.7

0.6

Amplitude [.]
0.5

0.4

0.3

0.2

0.1

0
−2 0 2 4 6 8 10 12 14
Time [s]

Figure 10.4: Simulation of the delay effect with gd equal to 50% and a delay of 600 ms.

10.3 Flanger Effect


The flanger builds on the same fundamentals as the delay, but it has an additional fea-
ture. The delay is modulated so that the delay length varies periodically [Orfanidis, 1996].

The block diagram can be seen on figure 10.5.

x[n] y[n]
+
Ȉ
g
+
z-m

Figure 10.5: Block diagram of the flanger effect.

The difference equation for the flanger is made from the difference equation for the delay
effect, simply by adding a modulation factor on the delay. The modulation varies the
delay length with a low frequency sine wave.

The depth of the modulation can be adjusted and this involve that the sine wave must
have an adjustable offset. This can also be seen from the difference equation
 
y[n] = x[n] + g · x n − m[n] , (10.3)
where m[n] is the integer value of
 sweepdepth  sweepdepth n
m[n] = delaytotal · 1 − + · sin(2 · π · modHz ) . (10.4)
2 2 fs
The equation states that if modulation rate is set at 2 Hz and depth is set to 40 % the
delay will vary between 100% and 60% of the delay length at a frequency of 2 Hz. This
is seen as the dotted line on figure 10.6. The full line show a depth of 100%.

89
10 Echo, Delay, Flanger and Chorus

100

90

80

Delay [% of delay length]


70

60

50

40

30

20

10

0
0 0.5 1 1.5 2 2.5 3 3.5
Time [s] 4
x 10

Figure 10.6: Two different modulation depths at same modulation frequency, 2 Hz. An offset ensures
that maximal delay is always used.

10.3.1 Simulation of Flanger

0.9

0.8

0.7

0.6
Amplitude [.]

0.5

0.4

0.3

0.2

0.1

0
−0.5 0 0.5 1 1.5 2
Time [s]

Figure 10.7: Simulation of the flanger effect with g equal to 50% and a delay of 100 ms, modHz = 1
Hz and a sweepdepth = 100%.

Figure 10.7 shows a simulation where an impulse has been inserted after 0 ms, 500 ms
and 750 ms. It is seen that the delayed samples arrives at different times as the delay
length has been modulated with a low frequency sine. This is also why the first impulse
appears not to produce a delayed sample.

10.4 Chorus Effect


The chorus works like the flanger just with additional feedforward loops and different
delay lengths. The multiple feedforward loops simulate a number of sound sources making
the same sound, but with small deviations. Figure 10.8 shows the principle.
It is seen that each feedforward loop have separate gain factors, delays and modulation
factors. Unlike the flanger, the delay is modulated with lowpass noise instead of a sine

90
10.5. Memory Requirements for Echo, Delay, Chorus and Flanger Effects

x[n] y[n]
+ Ȉ
g1
+ +
z-m1

g2
z-m2

Figure 10.8: Block diagram of the chorus effect with three voices.

wave. The difference equation for the chorus effect is


   
y[n] = x[n] + g1 · x n − m1 [n] + g2 · x n − m2 [n] . (10.5)

10.4.1 Simulation of Chorus

0.9

0.8

0.7

0.6
Amplitude [.]

0.5

0.4

0.3

0.2

0.1

0
−0.05 0 0.05 0.1
Time [s]

Figure 10.9: Zoom of the simulation of the chorus effect with five voices.

Figure 10.9 shows a chorus simulation with a Dirac delta function as input. The figure
shows a zoom of the first impulse where the additional sound sources can be seen.

10.5 Memory Requirements for Echo, Delay, Chorus and


Flanger Effects
Each time an input sample arrives it must be stored accordingly to the delay length.
This implies that the memory requirements are determined by the delay length and the
sample frequency. The two implemented effects (delay and echo) are set to share the
same memory, so only one effect can be enabled at a time. This is necessary since there
is not enough memory to enable both effects at the same time.

91
10 Echo, Delay, Flanger and Chorus

The requirement for the maximum delay length is 600 ms, and the sample rate is 19531
Hz. This gives the memory requirement
W
τmax = ⇒ W = τmax · fs = 600 ms · 19531 Hz ≈ 11719 words (10.6)
fs
which is around one third of the total available memory.

10.6 Implementation of Echo and Delay on DSP


The echo and delay effects are very similar and also implemented in almost the same
way. It is therefore chosen to let the two effects share the same variables as well as buffer
space wherever possible. This has the benefit of lowering the memory requirements as
there is only need for one buffer instead of two. However this disables the possibility of
using echo and delay at the same time. The delay and echo routines are implemented as
shown on figure 10.10 and figure 10.10 respectively.

Start Start

Multiply delayed Scale Add attenuated


Scale sample to
input sample sample with gain input sample
input sample

Add attenuated Store resulting


Update buffer Update buffer
sample to sample at buffer
input pointer input pointer
input sample input pointer position

Store scaled Send resulting Calculate which Send resulting


input sample output sample delayed sample output sample
to handler software to use to handler software

Calculate which Multiply delayed


delayed sample End sample with gain End
to use

Figure 10.10: Flowchart of the delay effect im- Figure 10.11: Flowchart of the echo effect im-
plementation. plementation.

10.7 Conclusion on Echo, Delay, Chorus and Flanger Effects


The digital effects delay and echo have now been designed, simulated and implemented
into the DSP system. Due to time limitations, the acceptance test specified has not been
carried out.

The chorus and flanger effects have been designed and simulated but not implemented
into the DSP system due to time limitations.

92
Chapter 11
Equalizer

In the following chapter the equalizer of the guitar effects unit is designed. The equalizer
ensures that specific frequency bands of the guitar signal can be enhanced or toned down
by use of a series of filters. Before the actual design of the equalizer, two different types
of equalizers are described. Based upon this a selection of equalizer type is made, and
afterwards the filters of the equalizer are designed. Following this, a description of how
the filters are realized on the DSP is given. Finally the chapter contains simulation and
measurement results.

11.1 Parametric and Graphical Equalizers


Basically two types of equalizers exist; the parametric and graphical equalizers. The most
common type is the graphical equalizer. In such equalizers the audio range is divided
into a fixed number of frequency bands. The gain in each band is then controlled by
a bandpass filter. The center frequencies of the bands and the 3-dB bandwidth of the
filters are fixed, so the only parameter that can be varied is the gain in each band.

To get a more flexible equalizer a parametric equalizer could be used. In these it is pos-
sible to change both gain, bandwidth and center frequency. By cascade coupling more of
these filters it is possible to obtain almost any desired equalization effect.

It is chosen that it should only be possible to change the level of the guitar signal in three
bands - the bass, middle and treble frequency ranges. Therefore the center frequency
of the filters will be fixed in this case. To simplify the equalizer it is chosen that the
bandwidth of the filters will be fixed as well which means that the equalizer can be
designed as a graphical equalizer.

11.2 Design of Equalizer


As mentioned the equalizer will consist of three parallel filters which adjust the signal
level in three different frequency bands respectively. This is illustrated on figure 11.1 and
the limits between the frequency bands are found by dividing the whole frequency range
of the guitar into three logarithmic equally sized bands. The frequency range for a guitar
is set to be from 80 Hz, which approximately is the lowest tone a guitar can play, to 7200
Hz, which is the highest harmonic that will be experienced when playing the highest tone
on the guitar.

93
11 Equalizer

Amplitude
[dB]
Guitar frequency range

Bass Middle Treble


0 dB

Frequency
[Hz]
80 Hz 359 Hz 1607 Hz 7200 Hz

Figure 11.1: Illustration of the bass, middle and treble frequency ranges.

To simplify the design of the equalizer, it is implemented with a first order lowpass and
highpass filter and a second order bandpass filter. Furthermore, it will not be possible to
amplify the signal but only to attenuate the signal in one or more of the three decided
frequency bands.

In the following the filters for the three bands are described and designed individually.

11.2.1 Bass Band


First the design of the lowpass part of the equalizer will be described. A simple first-order
lowpass filter has the following standard form [Orfanidis, 1996]

b0 + b1 z −1
Hlp (z) = klp · , (11.1)
1 + a1 z −1
where klp is the gain which can be adjusted in the range from 1 to -∞. It is wished to
determine the filter coefficents b0 , b1 and a1 such that the filter has the desired frequency
characteristics. To do this the digital cutoff frequency is first defined and found to
[Orfanidis, 1996]

2πfc,lp 2π · 359 Hz rad


ωc,lp = = = 0.1155 , (11.2)
fs 19531 Hz s
where fc,lp is the analog cutoff frequency and fs is the sampling frequency. Next, the
digital cutoff frequency is prewarped to obtain the equivalent analog cutoff frequency
[Orfanidis, 1996]
ωc,lp 0.1155
Ωc,lp = tan = tan = 57.81 · 10−3 . (11.3)
2 2
It is now possible to design the digital filter by first designing the equivalent analog filter.
The analog filter has the following standard form [Orfanidis, 1996]
α
Ha,lp (s) = klp · , (11.4)
s+α

94
11.2. Design of Equalizer

where α = Ωc,lp when the cutoff frequency is defined to be the frequency at which the
magnitude response squared drops by 3 dB, i.e. the 3 dB cutoff frequency. To obtain an
expression that gives the a and b coefficients as function of α, the bilinear transformation
is used. The bilinear transformation method is described in more detail in appendix D
page 125. After using the bilinear transformation method the transfer function is found
to


α α α(1 + z −1 )
Hlp (z) = Ha,lp (s) = klp · = klp · = klp · ,
s + α s= 1−z−1 1−z −1
+α 1− z −1
+ α(1 + z −1 )
1+z −1 1+z −1
(11.5)
which can be reduced to

1 + z −1 1−α α
Hlp (z) = klp b · −1
, a= , b= . (11.6)
1 − az 1+α 1+α
The coefficients are afterwards calculated to be

1 − 57.81 · 10−3
a1 = −a = = −0.8917 (11.7)
1 + 57.81 · 10−3
57.81 · 10−3
b0 = b1 = klp b = klp · = klp · 0.0547 . (11.8)
1 + 57.81 · 10−3
The final expression for the lowpass filter is then

0.0547 + 0.0547z −1
Hlp (z) = klp · . (11.9)
1 − 0.8917z −1

11.2.2 Middle Band


The bandpass and highpass filters for the middle and treble range respectively, are de-
signed in a similar manner and therefore described in less detail. The standard form for
a second order bandpass filter is given as [Orfanidis, 1996]

1 − z −2
Hbp (z) = kbp (1 − b) , (11.10)
1 − 2b cos ωbp z −1 + (2b − 1)z −2
1
where b = 1+β and ωbp is the digital center frequency of the bandpass filter and kbp is
the gain which can be adjusted in the range from 1 to -∞. The factor β can be found as
[Orfanidis, 1996]

∆ω
,
β = tan (11.11)
2
and here ∆ω is the digital bandwidth of the bandpass filter. The center frequency is
placed in the geometric center between the bass and treble band. The analog center
frequency and bandwidth is determined to be

95
11 Equalizer

fbp 1 √
log = (log 1607 + log 359) ⇒ fbp = 2π · 1607 Hz · 359 Hz = 760 Hz (11.12)
2π 2
∆f = 1607 Hz − 359 Hz = 1248 Hz . (11.13)

The equivalent digital center frequency and bandwidth is then ωbp = 0.2445 and ∆ω =
0.4015. When these are known β and b are calculated to

0.4015
β = tan = 0.2035 (11.14)
2
1
b= = 0.8309 , (11.15)
1 + 0.2035
and finally the transfer function is found to be

1 − z −2
H(z) = kbp · 0.1691 · . (11.16)
1 − 1.6124z −1 + 0.6618z −2
The coefficients are afterwards calculated to be

b0 = b2 = kbp · 0.1691 (11.17)


b1 = 0 (11.18)
a1 = −1.1624 (11.19)
a2 = 0.6618 . (11.20)

11.2.3 Treble Band


The last filter is the highpass filter which should make it possible to adjust the gain in
the treble band. The standard form for a first-order highpass analog and digital filter
respectively can be found to [Orfanidis, 1996]

s
Ha,hp (s) = (11.21)
s+α
1 − z −1
Hhp (z) = khp · b · , (11.22)
1 − az −1
where α is equal to the prewarped analog frequency Ωhp for the 3 dB case. The digital
cutoff frequency and the prewarped analog frequency are found to

2π · 1607 Hz
ωhp = = 0.5170 (11.23)
19531 Hz
Ωhp = tan 0.51702 = 0.2644 . (11.24)

96
11.3. Simulation of Equalizer

The coefficients a and b are then through bilinear transformation found to be

1−α 1 − 0.2644
a= = = 0.5818 (11.25)
1+α 1 + 0.2644
1 1
b= = = 0.7909 , (11.26)
1+α 1 + 0.2644

which gives the transfer function

0.7909 − 0.7909z −1
Hhp (z) = khp · , (11.27)
1 − 0.5818z −1
and the final filter coefficients for the treble band highpass filter are then given as

b0 = 0.7909 · khp (11.28)


b1 = −0.7909 · khp (11.29)
a1 = −0.5818 . (11.30)

11.3 Simulation of Equalizer


Simulations are made to verify that the designed filters for the equalizer has the desired
characteristics. First, the amplitude response of the individual filters is calculated and
plotted in MATLAB. This is shown on figure 11.2.

1
Bass
0 Treble
Middle
−1

−2

−3
Amplitude [dB]

−4

−5

−6

−7

−8

−9

−10
2 3
10 10
Frequency [Hz]

Figure 11.2: Amplitude response of the individual filter for the bass, middle and treble ranges.

97
11 Equalizer

It is seen that the three filters have the desired 3 dB cutoff frequencies which is marked
on the figure. In the simulation these lie at approximately 359 Hz and 1612 Hz which is
close to the desired values on 359 Hz and 1607 Hz.

Afterwards, the filters are coupled in parallel by use of MATLAB. The amplitude re-
sponse of the equalizer as a whole is then plotted where the gain in each band is set to
be 0 dB. This gives the result seen on figure 11.3(a). Unfortunately, this gives a gain
different from 0 dB at most frequencies which is due to the overlap between the filters.
To compensate for this non-ideal equalizer characteristic, the maximum amplitude in dB
of the total amplitude response is found. The output from the bandpass filter is then
divided by this factor, to obtain a amplitude response for the bandpass filter which lies
between -1 and 1 dB. The corresponding factor to multiply with is shown on figure 11.5 de-
noted as gbp . After the scaling, the amplitude response seen on figure 11.3(b) is obtained.

3 3

2.5 2.5

2 2

1.5 1.5
Amplitude [dB]

Amplitude [dB]

1 1

0.5 0.5

0 0

−0.5 −0.5

−1 −1

−1.5 −1.5

−2 −2
2 3 4 2 3 4
10 10 10 10 10 10
Frequency [Hz] Frequency [Hz]

(a) Amplitude response of equalizer with 0 dB (b) Amplitude response of scaled equalizer with 0
gain in each band and non-scaled bandpass filter. dB gain in each band and scaled bandpass filter.

Figure 11.3: Amplitude responses of non-scaled and scaled equalizer.

Next, the equalizer is simulated with the gain different from 0 dB in some of the frequency
bands. On figure 11.4(a) the amplitude response is plotted where the gain in the bass
and treble bands are set to -24 dB and the gain in the middle band is set to 0 dB.
Because low order filters are used, the -24 dB gain is only obtained at frequencies below
the frequency range of the guitar which starts from about 80 Hz, and at frequencies close
to the sampling frequency. Correspondingly, the overall gain does not reach -24 dB when
the gain in the bass and treble bands are set to 0 dB and the gain in the middle band
is set to -24 dB. The minimum gain obtained is -8 dB at the center frequency of the
bandpass filter. Again, this is due to the low order filters. It is chosen to accept this
because of time limitations.

98
11.4. Implementation of Equalizer Filters

0 0

−5 −5
Amplitude [dB]

Amplitude [dB]
−10 −10

−15 −15

−20 −20

−25 −25
2 3 4 2 3 4
10 10 10 10 10 10
Frequency [Hz] Frequency [Hz]

(a) Amplitude response of scaled equalizer with (b) Amplitude response of scaled equalizer with
-24 dB gain in bass and treble band. -24 dB gain in middle band.

Figure 11.4: Amplitude responses of scaled equalizer with different settings.

11.4 Implementation of Equalizer Filters


The final implementation form of the equalizer is illustrated on figure 11.5. The factors
klp , kbp and khp are the same as the ones used in equation 11.9, 11.16 and 11.27. The
last two factors s and gbp are the scaling factors for the filters which ensures better SNR
and the scaling of the bandpass filter which gives a better amplitude response for the
equalizer. gbp is mentioned in the previous section and is therefore not elaborated here.

It is seen by calculations in MATLAB that the filters of the equalizer would not lead
to overflow. This is not surprising because each of the filters only attenuates the signal.
This property gives the opportunity to increase the gain and thereby obtain a better
SNR. This is done by use of variance scaling. To get the most ideal amplitude response
of the equalizer, the same scaling factors are used for each filter. The lowest scaling factor
found was for the highpass filter, and this was found to s = 1.1245.

Equalizer
klp
LP

+
s kbp gbp
x[n] + y[n]
BP Ȉ
+
khp
HP

Figure 11.5: Block diagram of the implemented equalizer.

99
11 Equalizer

11.5 Measurements of Equalizer


Two things were measured on the equalizer. The amplitude response to compare with
the simulation and the SNR. The SNR measurement is not described here but in chapter
12. On figure K.2 and K.3 the measurements of the amplitude response are shown. In
the first measurement only the gain in the bass and treble bands were adjusted from
-24 dB to 0 dB while the gain in the middle band were fixed to 0 dB. This is shown on
figure K.2. Compared with the simulation on figure 11.4(a) it is seen that the expected
amplitude response is obtained during implementation.

Next, a measurement where the gain in the bass and treble bands are fixed to 0 dB and
the gain in the middle band is adjusted from -24 dB to 0 dB is made. This is shown on
figure K.3. Compared with the simulation on figure 11.4(b) it is seen that the amplitude
response is as expected. The minimum gain of the equalizer when the middle band gain
is set to -24 dB is read to approximately -8 dB as expected.

11.6 Conclusion on Equalizer


It was chosen to make the equalizer simple because of time limitations. Therefore the
equalizer was made as a three band graphical equalizer by use of three low order filters.
The filters was made so that they divided the effective frequency range in three logarith-
mic equally sized bands.

The simulations showed that the calculations were right and afterwards the calculated
equalizer was implemented on the DSP system. Like all the other digital effects the
equalizer was coded in the assembler language.

Additionally, measurements of the amplitude response verified that the equalizer worked
as intended after it was implemented on the DSP system.

100
Chapter 12
System Test

The different parts of the system must be tested to see if they meet the demands. First,
the SNR test for the different effects is carried out. Next, a processor utilization test is
carried out to see how well the DSP system performs and how much of the processing
time the different effects require. Also, all effects must undergo a listening test to see
how well the system performs with all parts together. Furthermore, it is tested whether
it is possible to interchange the order of the effects.

12.1 SNR Test


This test has the purpose of determining the SNR for the all the implemented effects.
The SNR is measured by turning all effects off except for the one to test and load it
with the settings that maximize the output amplitude of the effect. Using a distortion
analyzer and sending a 1 kHz sine through the system, the SNR for the given effect can
be measured. The more specific procedure of measuring the SNR is described in the
measurement report in appendix L page 146.

Effect: SNR:
Tremolo 82.1 dB
Wah wah 80.9 dB
Delay 67.9 dB
Echo 63.9 dB
Equalizer 67.8 dB
Reverberator 65.4 dB
DSP system 67.7 dB

Table 12.1: Measured SNR.

The results of this test are shown in table 12.1. The SNR for each of the implemented
effects has been measured, as well as the SNR of the DSP system with no effects enabled.

The analog tremolo effect had a measured SNR of 82.1 dB when the settings were set to
maximum output level. As the requirement is that the effects must have an SNR > 50
dB, the tremolo effect fulfills the demand.

The wah wah effect was measured to have a SNR of 80.9 dB at maximum output settings
which also fulfills the SNR requirement.

101
12 System Test

The DSP system was measured with and without effects enabled. Without any effects
enabled the SNR was measured to 67.7 dB. The big difference between this result and
the SNR of the analog effects is caused by the A/D and D/A conversions of the signal
as they pass through the DSP system. As the SNR is still above the required 50 dB the
DSP system itself fulfills the SNR requirements.

The effective number of bits for a B + 1-bit A/D converter can be found from the expres-
sion for the noise variance [Oppenheim and Schafer, 1999]

2−2B
σe2 = , (12.1)
12
if and only if the noise signal is uniform and has the full scale value of 1. This is combined
with the expression for the signal-to-noise ratio
 2
σs
SNR = 10 · log10 , (12.2)
σe2

where σs2 is the signal variance and σe2 is the noise variance.

It is assumed that only the A/D converter has quantization noise and with a measured
SNR of 67.7 dB the expression for σe2 can be rewritten into

2−2B σs2
σe2 = = 6.77 ⇔
12 10
 6.77 
10
B = 1/2 · log2 . (12.3)
12 · σs2

With σs2 = 1/3 the effective number of bits is B = 10.2 + sign bit.

The delay effect has a measured SNR of 67.9 dB which is actually higher than that of
the DSP system without any effects enabled. This is assumed to be due to uncertainty
of measurement with the used equipment.

The echo effect had a slightly lower SNR than that of the delay. Although these two
effects are almost similarly implemented, the small differences in the tweaking methods
are believed to cause the lower SNR. Although the SNR of the echo effect has the lowest
measured SNR it still fulfills the requirement for the SNR.

The equalizer effect had a measured SNR of 67.8 dB which is also higher than the DSP
system with no effects enabled. This difference is also believed to be due to uncertainty
of measurement with the used equipment.

The reverberator is the last effect and had a measured SNR of 65.4 dB. It is believed
that the tweaking of the signal happening in this effect causes the lowered SNR.

102
12.2. Utilization Test

12.2 Utilization Test


This test has the purpose of determining how much processor time is used for the different
digital effects and for the DSP system with no effects enabled. The test is performed by
using a pin on the DSP called XF and two software commands SXF and RXF. The
XF-pin will attain logic 1 when the command SXF is called in the software routine and
will attain logic 0 when the RXF command is used. The way to measure the processor
utilization will then be to activate the SXF command just before the desired effect is
called and then call the RXF command at the end of the effect. In this way the processor
utilization is measured by finding the duty cycle of the signal on the XF pin. The results
of the utilization test are shown in table 12.2.

Effect: Utilization [%]


Reverberator 67.8 %
Equalizer 19.6 %
Echo 11.1 %
Delay 10.6 %
No effects 13.1 %

Table 12.2: Measured utilization.

The test of the reverberator shows that it utilizes 67.8 % of the total available processor
power. As shown in table 12.2 the processor uses without any effects enabled is 13.1 %
which is basically used to store settings before interrupt routines, and to restore them
after. Combined with the reverberator this gives a total usage of 80.9 %. This shows that
the reverberator can only be used in combination with the least demanding effects which
are the echo effect and the delay effect that only utilize 11.1 % and 10.6 % respectively.
If the utilization percentage becomes greater than 100 % it means that the processor
has too much work to do per sample and thereby will lose samples and not allow user
interaction. The combination possibilities are further described later in the routing test
section.

12.3 Listening Test


Listening tests were performed the different effects are all tested to see if they co work
with the other parts of the system. Sound is sent through the system and one by one
the effects are enabled and it is tested whether they function correctly by adjusting the
different parameters for the effect.

The wah wah effect was tested and an attenuation of the signal was noticed. The effect
has the characteristic wah wah sound and therefore works as intended.

103
12 System Test

The tremolo effect was also tested using different settings with different modulation types,
rates and depths. Through different settings the differences could easily be heard and
worked as intended. It was, however difficult to distinguish between the two modulation
types sine and triangle.

With the delay effect enabled a delayed sample could easily be heard. With different
settings the changes in the sound were as expected.

The echo effect produced echoes delayed by the specified delay length and sounds as
expected.

The equalizer effect was tested and when modifying the gains in the different bands,
attenuation of the respective bands could be heard.

The reverberator was tested as the last effect and though the reverberation effect was
present, a metallic effect was also heard.

12.4 Routing Test


The ability to interchange the order of the different analog effects will be tested by simply
switching their positions in the rack, and for the digital effects internally, the routing is
built into the software and will be tested separately.

The routing of the analog effects and the DSP system were tested and when the two
analog effects and the DSP system had their rack positions switched. However the front
of the tremolo effect board did not fit into the other slots in the rack and could therefore
not be switched. The hardware routing of the effects therefore does not work as intended.
However the wah wah effect and the DSP system could be switched as intended.

For the digital effects, a software routing possibility was desired as not all of the effects
are linear, and will therefore affect the sound differently dependent on their order. The
menu system has been designed to enable three effects simultaneously. However, as also
concluded during the utilization test, the utilization percentage of the effects has an in-
fluence on the possible combinations. As the system will only work as long as the total
utilization is less than 100 % certain combinations can not be made. As shown in the
utilization test a combination like reverberator and equalizer enabled will utilize the pro-
cessor with 13.1 % + 19.6 % + 67.8 % = 100.5 %. Hence it will require more processor
power than what is available. The system will therefore miss instructions, block user
interaction and at a point crash. Combinations like reverberator and delay or echo, will
utilize less than 100 % and thereby work.

104
Chapter 13
Summary and Conclusion

The design of the guitar effects unit was initiated with a short review of some typical
guitar effects. The reviewed guitar effects were divided into three groups; amplitude
tweaking, frequency tweaking and time tweaking effects, and some of the effects from
each group was chosen to be designed and implemented. The chosen effects comprised
tremolo as an amplitude tweaking effect, wah wah and equalizer as frequency tweaking
effects and delay, echo, chorus, flanger and reverberation as time tweaking effects.

With inspiration from a commercial guitar effects unit [t.c. electronic, 2001], the require-
ments to each of the effects and to the entire guitar effects unit were specified. This
procedure led to realistic, but challenging requirements that were hard to fulfill and in
some cases infeasible because of memory and speed limitations. Since memory and speed
limitation often is an issue in real time signal processing systems, the implementation
problems have been very relevant.

Based on the requirements, the system design was developed. The guitar effects unit
was separated into two overall parts; an analog part on which the analog effects should
run and a digital part on which the digital effects should run. It was chosen to imple-
ment wah wah and tremolo as analog effects and equalizer, delay, echo, chorus, flanger
and reverberation as digital effects. The motivation between this separation was imple-
mentation complexity and requirements from the curriculum. The only effect that was
subject to the second constraint was tremolo. It was estimated that tremolo was easier
to implement as a digital effect than as an analog effect, but due to the curriculum it was
implemented as an analog effect. This led to a higher implementation complexity.

As discussed, tremolo was implemented as an analog effect which required the use of
several analog techniques. A lot of effort was put into the design of the low frequency
oscillator (LFO) which comprised a square wave, triangular wave and sine wave generator
whose frequency should be globally adjustable in the range from 0.1 Hz to 10 Hz. It was
chosen to generate the square and triangular waves from an astable multivibrator consist-
ing of a non-inverting schmitt trigger and an inverting integrator, and the sine wave was
generated from the triangular wave by use of a sine shaper. This design approach to the
LFO has shown to be expedient. Especially the generation of the square and triangular
waves have been easy while the sine wave generation has been more complex. The quality
of the resulting sine wave was satisfactory even though its total harmonic distortion was
around 4.5 %.

The modulation of the guitar signal was done using a multiplication circuit. The over-

105
13 Summary and Conclusion

all tremolo effect worked acceptably according to measurements and a sound test even
though the depth adjustment did not fulfill the specification. It is not at maximum
depth able to attenuate the original signal with more than 60 dB as required, but only
20.8 dB for the square wave, 32.7 dB for the triangular wave and 41.2 dB for the sine wave.

The second analog effect was wah wah. It was obvious to implement it as an analog effect
since it involves continuous change of the bandwidth and center frequency of a second
order bandpass filter. The design of the bandpass filter was conducted using a block
diagram approach, where the Q-factor and center frequency adjustments were isolated
to one and two blocks respectively. In that way, the center frequency could be adjusted
continuously with a stereo potentiometer without affecting the Q-factor and the Q-factor
could be changed continuously with a mono potentiometer without affecting the center
frequency.

The resulting wah wah effect fulfilled the requirements except from the lower bound of
the Q-factor adjustment. The deviation from the requirement was caused by component
tolerances and considered so small that no effort was put into reducing it. One problem
with the wah wah effect is that the bandpass filter removes a lot of energy from the
original signal. This is especially an issue for high Q-factor settings. One way to avoid
this problem is to make the gain of the wah wah effect dependent on the Q-factor setting.
This, however, leads to a scaling problem if the output signal of the wah wah effect must
be fed into the digital part of the guitar effects unit. Another possible solution is adding
an attenuated copy of the original signal to the output signal of the wah wah effect. In
this way, some of the energy from the original signal is still retained.

To execute the digital effects, a hardware and software platform were required. The hard-
ware platform featured the TMS320C26 DSP which has a speed of 10 million instructions
per second. The choice of DSP was motivated by the teaching of the semester and the
development tools as e.g. the debugger monitor. A 16-bit A/D and D/A converter was
chosen to convert the signals between analog and digital form with a sampling frequency
of 19531 Hz. Measurements on the A/D and D/A converter performance revealed an
effective resolution of approximately 10.2 bit plus sign-bit which is acceptable considered
the hardware construction. The sampling frequency dictated the program flow on the
software platform which was subject to hard real time constraint. All the enabled digital
effects had to be completed between two successive samples which yielded a calculation
time of 51.2 µs or 512 instructions.

The digital effect that was handled with the greatest level of detail, was the reverbera-
tion effect. After a review of the plain, the allpass, Schroeder’s and Moorer’s reverberator
algorithms, the final reverberator was chosen to be a mix of Schroeder’s and Moorer’s
reverberator. This choice was motivated by sound test which revealed that the metallic
sound associated with Schroeder’s reverberator could be significantly reduced by use of
the lowpass filter modification of Moorer’s reverberator.

106
Before implementation of the reverberator on the hardware and software platform, the
reverberator was analyzed with regard to noise associated with implementation form and
scaling. Calculation on noise caused by rounding showed that the direct from I struc-
ture performed better than the direct from II structure. This was especially the case for
the lowpass comb filters. By utilizing the inherent cascading of the different filters, the
storage elements could be recycled from one filter to another thus reducing the overall
memory consumption of the implementation. Sound test on the implemented reverber-
ation effect revealed that the effect performed quite well, but the DSP utilization was
high. It has been measured to 67.8 % which means that only the delay or echo effect can
be enabled at the same time as the reverberation effect without violation of the real time
requirements.

The echo, delay, chorus and flanger are quite alike for which reason they were described,
designed and simulated in the same chapter. Since these effects, especially the delay
and echo effects, had a greater memory usage due to the predominant large delays, these
requirements were considered before the implementation on the DSP. Due to the time
limitations of this project, the flanger and chorus effects were not implemented and tested.

After a short introduction of the graphical and parametric equalizer, the graphical type
was chosen to be constructed. The equalizer was designed with three bands, respectively
a first order lowpass filter, a second order bandpass filter and a first order highpass filter.
As the equalizer type was graphical, only the gains of each band could be adjusted. It
was chosen only to be able to attenuate the bands from 0 dB to -24 dB, whereas this
would avoid the scaling problem. Through bilinear transformation, the digital filters were
determined and implemented in a direct form I structure.

After implementation of the equalizer, measurements were made to verify the calculations
and simulations. The measurements showed the expected results, as they looked similar
to the simulations. Although this verifies both calculations and simulations, it means as
was seen from the results, that the overall gain of the equalizer only reaches -8 dB when
the middle band is set to a gain of -24 dB. Furthermore, the overall gain of the equalizer
does not reach -24 dB inside the frequency range of the guitar, when the gain in the bass
and treble bands are set to -24 dB. The reason for these observations are that the filters
are of low order. Typical equalizers are therefore implemented with higher order filters
that also gives the possibility to amplify signals in the desired frequency bands. The
amplify feature is not present in the implemented equalizer.

The overall system does not fulfill the requirement specification since some of the effects
do not fulfill their specifications. Most of the violations are insignificant to the user, but
one violation is significant. It is that the total DSP utilization of the digital effects is
greater than the total processing time which make the real time requirements infeasible
when all digital effects are enabled. Particularly, the reverberation algorithm is very

107
13 Summary and Conclusion

time consuming and should be the algorithm to optimize or reduce in complexity if the
requirement should be fulfilled.

108
Bibliography

Aalborg Universitet. Studieordning for Bacheloruddannelsen i Elektronik og Elektroteknik


samt Datateknik 3.-6. semester, curriculum is downloaded on 2007-11-03 edition, 2005.

Simon Bennet, John Skelton, and Ken Lunn. Schaum’s Outline of UML. McGRAW-
HILL, 2. edition, 2001. ISBN 0077107411.

Marshall Brain. Electric Guitar History, 2004. URL http://entertainment.


howstuffworks.com/electric-guitar3.htm. Home page downloaded on 2007-02-25.

Cypress. CYC199 manual, 2003. Data sheet enclosured on CD-ROM.

Analog Devices. AD633 multiplier. Analog Devices, 1. edition, 1999.

DIN. DIN 45 500. Deutsches Institut fur Normung, 1. edition, 1974.

Monson Hayes. Theory and problems of digital signal processing. McGraw Hill, 1. edition,
1999. ISBN 0-07-027389-8.

Texas Instruments. TMS320C26 Digital Signal Processor, 1989. Data sheet enclosured
on CD-ROM.

Texas Instruments. TLE2074 quad opamp. Texas Instruments, 1. edition, 2000.

ISO 31. Quantities and Units. Genve, 3. edition, 1993. ISBN 92-67-10185-4.

Mark Kahrs. Applications of digital signal processing to audio and acoustics. Kluwer, 1.
edition, 1998. ISBN 0792381300.

Helmuth E. W. Lemme. The Secrets of Electric Guitar Pickups, 2003. URL http://www.
buildyourguitar.com/resources/lemme/. Home page downloaded on 2007-02-25.

Alan Oppenheim and Ronald Schafer. Discrete-time signal processing. Prentice-Hall,


Inc., 2. edition, 1999. ISBN 0-13-083443-2.

Sophocles Orfanidis. Introduction to signal processing. Prentice Hall, 1. edition, 1996.


ISBN 0-13-240334-X.

Adel Sedra and Kenneth Smith. Microelectronic Circuits. Oxford University, 5th edition,
2004. ISBN 0-19-514252-7.

STMicroelectronics. M27C1024 manual, 1998. Data sheet enclosured on CD-ROM.

109
Bibliography

Kendall Su. Analog filters. Kluwer academic publishers, 2. edition, 2002. ISBN 0-4020-
7033-0.

t.c. electronic. G-Major manual, 2001. URL http://www.tcelectronic.com/media/G_


Major_US_rev71.pdf. Manual downloaded on 2007-03-05.

t.c. electronic. G-Systems manual, 2005. URL http://www.tcelectronic.com/media/


G_System_204_US.pdf. Manual downloaded on 2007-04-06.

John Wakerly. Digital design. Prentice-Hall, Inc., 3. edition, 2001. ISBN 0-13-090772-3.

Wikipedia. Pickup (music), 2007. URL http://en.wikipedia.org/wiki/Pickup_


%28music%29. Home page downloaded on 2007-02-25.

Udo Zölzer. Digital audio signal processing. John Wiley and sons, 1. edition, 1997. ISBN
0-471-97226-6.

Udo Zölzer. DAFX - Digital audio effects. John Wiley and sons, 1. edition, 2005. ISBN
0-471-49078-4.

Eberhard Zwicker and Hugo Fastl. Psychoacoustics - Facts and Models. Springer, 2.
edition, 1999. ISBN 978-3540650638.

110
Appendix A
Electric Model of Guitar

An electric guitar consists from an electrical point of view of a pickup which can be either
active or passive, a volume control and a tone control. In this appendix a description of
the used electric model of the electric guitar will be given for a guitar with active pickup
and for a guitar with passive pickup. The models are based on an electric guitar named
Grassroots with active pickups and an electric guitar named Axtech Vintage with passive
pickups. The models will be used to determine the maximum output impedance of an
electric guitar. This is important because the pre-amplifier which interfaces the guitar,
must have a sufficient large input impedance in order to take advance of the output
voltage of the guitar in the best possible way. These results are described in chapter 1.

Model of the Electric Guitar with Active Pickups

9V

R3
R1 EMG EMG
R2 25 kȹ
25 kȹ 81 81
3-position 25 kȹ
Output Tone switch
Jack control C 100 nF Neck
Bridge
volume
volume
Neck Bridge
pickup pickup

Figure A.1: Model of the Grassroots electric guitar with active pickups.

The model of the Grassroots electric guitar with active pickups is shown in figure A.1.
The model consists of two EMG 81 active pickups which are denoted bridge and neck
pickup, respectively. Each pickup has a separate volume control which is implemented
with the potentiometers R2 and R3 . The output signals from the two volume control
potentiometers are fed into a 3-position switch that can be used to select the signal from
one of the volume controls or the signal from both of them. The tone control consists
of a potentiometer and a capacitor in series. This gives a pole at s = 0 and a zero at
s = −1/R1 C. With R1 ≤ 25kΩ and C = 100 nF the zero gives a break frequency that is
greater or equal to 64 Hz.

111
A Electric Model of Guitar

Model of the Electric Guitar with Passive Pickups

500 kȹ

R1 500 kȹ 500 kȹ
5-position
Stratocastor R2 R3
Output Volume switch Middle Neck
Jack control tone tone
C 33 nF

Neck Middle Bridge


pickup pickup pickup

Figure A.2: Model of the Axtech Vintage electric guitar with passive pickups.

The model of the Axtech Vintage electric guitar with passive pickups is shown in figure
A.2. The model consists of three passive pickups of the type Axtech Vintage Plus, and
they are denoted bridge, middle and neck pickup, respectively. The tone control can
alter the frequency response of the neck and middle pickup by adjusting the two poten-
tiometers R2 and R3 . The output signal of the bridge pickup is only affected by the tone
control when the switch connects it with the output signal of the middle pickup.

The switch has five positions and can select the signal from one of the pickups or a
combination of signals from the bridge and middle pickup or middle and neck pickup.
The output signal from the switch are fed into a potentiometer, R1 , which acts as a
volume control.

112
Appendix B
Tremolo Elaborations and
Calculations

The following subsections elaborate some of the contents discussed in chapter 5 page 25.

Integrator Offset Problem


This open loop performance of the integrator can yield serious problems, since even a
small DC component in theory would give an infinite amplification or cause the practical
opamp to saturate. To illustrate this effect of an input DC voltage and give basis for
design of counter-measures, the integrator circuit is shown in figure B.1 with the signal
source short circuited.

VOS/R C

R
-
VOS/R + Vout

VOS

Figure B.1: Integrator with signal source short-circuited showing the currents running due to an offset
voltage.

Using equation 5.5 page 28 and assuming the voltage across the capacitor at t = 0 is
zero, the output voltage caused by the DC offset voltage can be found to
Z
1 t VOS
vout (t) = VOS + dτ
C 0 R
Voffset
= Voffset + t. (B.1)
RC
Equation B.1 shows that the output voltage will increase linearly until the opamp satu-
rates. If the comparator duty cycle is not precise 50%, this will cause a slight offset in
the DC input voltage.

Furthermore the bias current running in a non-ideal opamp will cause a similar effect.
To compensate for this current flowing through the capacitor, a resistor may be added
to the positive input terminal of the opamp as seen on figure B.2.

113
B Tremolo Elaborations and Calculations

IOS
IB2 R
-
IB1 + Vout

R IB2

Figure B.2: Integrator with signal source short-circuited showing the offset current running due to the
bias currents running into the input terminals of the opamp.

Still this will not prevent the input offset current, IOS = IB1 − IB2 , from flowing through
the capacitor and at the end cause the opamp to saturate.

A way to counteract such behavior, can be solved by connecting a large resistor in parallel
with the capacitor as seen in figure B.3.

RF

R
-
Vin
+ Vout

Figure B.3: Integrator with resistor parallel with capacitor in feedback loop.

This will provide a path for the DC currents, VROS


and IOS , to flow, so it will keep the
output voltage constant instead of rising linearly. The DC components of the output
voltage can then be expressed by
 
RF
VDC-out = VOS 1 + + IOS RF . (B.2)
R
The new transfer function for the integrator circuit will then be
RF
Vout (s) R
=− . (B.3)
Vin (s) 1 + sCRF
The newly introduced resistor, RF , will cause the frequency of the integrator pole to move
from the ideal location at ω = 0 to a higher corner frequency. Hereby the integrator also
becomes less ideal. The corner frequency is specified by RF1 C , and it is seen that the
lower RF the higher corner frequency. At the same time this will also cause the DC
performance to improve, since a lower resistor value gives a smaller DC offset as derived
from equation B.2 or it can be seen by the DC gain, RRF , in equation B.3.

114
Tremolo Calculations
Through use of requirements, equations from design section 5.1 page 25 and available
components, the following subsections will calculate the component values required to
build the different blocks.

LFO
The first generated signal is the square wave, which is generated by the comparator.
The output voltage is determined by the available supply voltage. The guitar effects rack
already has a built in voltage supply at 15 V. Hence, the square wave peak voltage is 15 V.

The threshold values required for the comparator to switch state corresponds to the
output voltage of the integrator, thus the peak voltage of the triangular wave. From
equation 5.3 an expression for the threshold values is found since VT L = −VT H . The
output voltage of the integrator is chosen to be 10 V and letting R203 = 2 kΩ makes it
possible to calculate R204 with

R203
VTH = 15 ⇔
R204
R203 2 · 103
R204 = 15 = 15 = 3 kΩ .
VTH 10

Knowing the threshold values of the comparator and input voltage of the integrator,
equation 5.11 shows the frequency relation. From requirement 4 page 15, the frequency
should be adjustable between 0.1 Hz and 10 Hz. A capacitor of 1.5 µF is chosen. Then
the resistance for minimum and maximum frequency can be calculated by

L+
R201 = ,
4VTH C201 f

15
R201,fmin = = 2.42 MΩ,
4 · 10 · 1.5 · 10−6 · 0.1

15
R201,fmax = = 24.19 kΩ.
4 · 10 · 1.5 · 10−6 · 10

As a solution a 2.2 MΩ potentiometer in series with a 24 kΩ resistor is chosen to substi-


tute R201 . This will set the frequency area from 0.11 Hz to 10.08 Hz, which is acceptable.
To prevent any DC offset or unwanted flowing currents to cause the integrator to saturate
in time, R202 is set to 10 MΩ.

With equation 5.17 the peak voltage of the sinusoidal wave can be calculated knowing

115
B Tremolo Elaborations and Calculations

that vbt is 10 V by
2
vbs = vbt
π
2
vbs = 10 = 6.37 V.
π
To determine the reference values of the voltage divider, equation 5.13 is used. To com-
pensate for the diode voltage drops, equation B.4 is subtracted 0.6 V and the reference
voltages are calculated by
 πn 
Vref,n = vbs sin − 0.6, n = 1, 2, ..., 5. (B.4)
2·5

n: Vref,n [V]:
1 1.37
2 3.14
3 4.55
4 5.45
5 5.77
6 15

Table B.1: Calculated voltage references using equation B.4.

As noted in the design of the sine shaper on page 30, the current running through the
voltage divider must be much larger than the currents added by the diodes. At least a
factor 100 between the total diode currents, itdiodes , and the voltage divider current, IDC ,
on one side is considered high enough to fulfill this demand. Choosing IDC to 10 mA
implies that itdiodes must be much smaller than 0.1 mA. Note that table B.1 has been
expanded with n = 6 to be able to calculate the size of R214 . Now each resistor value can
be calculated according to the difference between the voltage values. Again calculated
on the positive side of the voltage divider this forms

Vn+1 − Vn
Rref,n = , n = 1, 2, ..., 6. (B.5)
IDC

Equation 5.18 page 33 calculates the slopes deviations of the triangular wave at each
voltage reference with

180 − 90 − θn
Slope deviation = , n = 1, 2, ..., 5. (B.6)
90

It is now possible to calculate the values of the resistors in series with the diodes.
Since ideally the sine wave is made of six straight line segments, it is necessary to consider

116
Rref,n : Value [Ω]:
R219 136.73
R218 177.47
R217 140.84
R216 90.43
R215 31.16
R214 923.38

Table B.2: Calculated resistances in voltage divider using equation B.5.

θn : Deviation: [·]
18 0.8
36 0.6
54 0.4
72 0.2
90 0.0

Table B.3: Calculated slopes at breakpoints using equation B.6.

the voltage between the breakpoints. The slope is determined by the voltage division be-
tween R205 and the resistors in series with the diodes open at the given amplitude.

To determine R205 it is chosen that the current through the resistor is 0.1 mA at peak
voltage of the triangular wave. Thus, the value of R205 is
10 V
R205 = = 100 kΩ.
0.1 mA
With the slopes and R205 known, the resistor values in series with the diodes can be
calculated. Voltages between zero and Vref,1 + 0.6 are taken into consideration, since the
voltage division will be between R205 and the buffer at the output of the sine wave. Thus,
the slope of the sinusoid is almost identical to the slope of the triangular wave.

1.37 V ≤ vs < 3.14 V:


8 R209
=
10 R205 + R209
8 · (R205 + R209 ) = 10 · R209
8 · R205 = 2 · R209 .

Knowing R205 = 100 kΩ:

R209 = 400 kΩ.

3.14 V ≤ vs < 4.55 V:

117
B Tremolo Elaborations and Calculations

6 R209 ||R208
=
10 R205 + R209 ||R208
6 · (R205 + R209 ||R208 ) = 10 · R209 ||R208
6 · R205 = 4 · R209 ||R208 .
Knowing R205 = 100 kΩ and R209 =400 kΩ:
6 · 100 · 103 400 · 103 · R208
=
4 400 · 103 + R208
600 · 10 (400 · 10 + R208 ) = 1600 · 103 · R208
3 3

240 · 109 = 1000 · 103 · R208


R208 = 240 kΩ.
4.55 V ≤ vs < 5.45 V:
For the sake of simplicity R209 ||R208 will be denoted R209||208 = 150 kΩ.
4 R209||208 ||R207
=
10 R205 + R209||208 ||R207
4 · (R205 + R209||208 ||R207 ) = 10 · R209||208 ||R207
4 · R205 = 6 · R209||208 ||R207 .
Knowing R205 = 100 kΩ and R209||208 =150 kΩ:
4 · 100 · 103 150 · 103 · R207
=
6 150 · 103 + R207
400 · 10 (150 · 10 + R207 ) = 900 · 103 · R207
3 3

60 · 109 = 500 · 103 · R207


R207 = 120 kΩ.
5.45 V ≤ vs < 5.77 V:
For the sake of simplicity R209 ||R208 ||R207 will be denoted R209||208||207 = 66.67 kΩ.
2 R209||208||207 ||R206
=
10 R205 + R209||208||207 ||R206
2 · (R205 + R209||208||207 ||R206 ) = 10 · R209||208||207 ||R206
2 · R205 = 8 · R209||208||207 ||R206 .
Knowing R205 =100 kΩ and R209||208||207 = 66.67 kΩ:
2 · 100 · 103 66.67 · 103 · R206
=
8 66.67 · 103 + R206
200 · 103 (66.67 · 103 + R206 ) = 533.33 · 103 · R206
13.33 · 109 = 333.33 · 103 · R206
R206 = 40 kΩ.

118
5.77 V ≤ vs < 10 V:
Since the final slope is zero, there is no resistor connected with the diode.

This concludes the calculations of the component values in the LFO, which are listed
in table B.4. The diodes implemented in the sine shaper are of type 1N4148. Further-
more, three opamps are required in the LFO, which are implemented with the TL2074
[Instruments, 2000].

Component: Value:
R201a 25 kΩ
R201b (pot) 2.2 MΩ
R202 10 MΩ
R203 2 kΩ
R204 3 kΩ
R205 100 kΩ
R206 = R213 40 kΩ
R207 = R212 120 kΩ
R208 = R211 240 kΩ
R209 = R210 400 kΩ
R214 = R225 923.38 Ω
R215 = R224 31.16 Ω
R216 = R223 90.43 Ω
R217 = R222 140.84 Ω
R218 = R221 177.47 Ω
R219 = R220 136.73 Ω
C201 1.5 µF

Table B.4: Calculated component values in the LFO.

Amplitude and Offset Adjustment


Based on table 5.1 page 36, the resistor values concerning amplitude adjustment can now
be calculated to

R226 = 3R229 = 3 · 10 · 103 = 30 kΩ.

3R203 3 · 2 · 103
R227 = R229 = · 10 · 103 = 20 kΩ.
R204 3 · 103

6R203 6 · 2 · 103
R228 = R229 = · 10 · 103 = 12.73 kΩ.
πR204 π · 3 · 103

119
B Tremolo Elaborations and Calculations

All three of the waveforms now have an amplitude of 5 V, which is what the DC voltage
in the summer must be. This voltage is created by a voltage division of the negative
supply, since it is an inverting summer. With R231 chosen to be 1 kΩ to ensure a large
current is running, R230 can be calculated to be
R231
VDC = −Vcc
R230 + R231
−Vcc −15
R230 = R231 − R231 = · 1 · 103 − 10 · 103 = 2 kΩ.
VDC −5
The summer must have the same resistor value on each summing input, R233 and R234 ,
which is chosen to 1 MΩ. Since the values must be higher than the value of the poten-
tiometer, R232 is chosen to be 100 kΩ.
Using equation 5.24, R235 is calculated to be
   
R234 R33 vout 1 · 106 10
R235 = − =− = 1 MΩ.
R234 + R233 VDC 2 −5

Multiplier
With the offset adjusted LFO, its peak amplitude is 10 V. Since the chosen multiplier
divides the signal by a factor of ten, the maximum outgoing voltage corresponds to
the incoming voltage of the audio signal. As mentioned in section 5.1.3 page 38, the
two capacitors, C202 and C203 , are chosen to be 0.1 µF as suggested by the data sheet
[Devices, 1999] of the multiplier.

120
Appendix C
Wah Wah Transfer Function and
Component Values

This appendix contains the calculations for the transfer function and component values
for the wah wah effect.

Using the three reference points V1 , V2 and V3 on figure 6.2 and table 6.1, page 45 the
transfer function for the wah wah effect is derived.

R300 R303 (R300 + R301 )


V1 = − Vout + Vin
R301 R301 (R302 + R303 )
 
R304 R304
V2 = − V1 + V3 (C.1)
R305 R306
Vout
V3 = −
R308 C302 s
V2
Vout = − ⇒ V2 = −R307 C301 sVout
R307 C301 s

This can be rewritten into one equation by inserting into equation C.1
     
R304 R300 R303 (R300 + R301 ) R304 Vout
−R307 C301 sVout = − − Vout + Vin + −
R305 R301 R301 (R302 + R303 ) R306 R308 C302 s
R304 R300 R304 R303 (R300 + R301 ) R304
−R307 C301 sVout = Vout − Vin + Vout
R305 R301 R305 R301 (R302 + R303 ) R306 R308 C302 s
Vout −R 304 R303 (R300 +R301 )
R305 R301 (R302 +R303 )
= 
Vin −R307 C301 s − R R304 R300
− R304
305 R301 R306 R308 C302 s
(R300 +R301 )R303 R304
Vout (R302 +R303 )R301 R305 R307 C301
= R300 R304 R304
(C.2)
Vin s2 + R301 R305 R307 C301 s + R306 R307 R308 C301 C302

It can be seen that equation C.2 is on the same form as the standard transfer function
of a biquad bandpass filter. This makes it possible to determine ωc , G and Q.
First ωc is determined
r
2 R304 R304
ωc = ⇒ ωc = . (C.3)
R306 R307 R308 C301 C302 R306 R307 R308 C301 C302

121
C Wah Wah Transfer Function and Component Values

Next, the Q is calculated


q
R304
ωc R300 R304 R301 R305 R307 C1 R306 R307 R308 C301 C302
= ⇒Q= . (C.4)
Q R301 R305 R307 C301 R300 R304

And finally G:

ωc (R300 + R301 )R303 R304 (R300 + R301 )R303


G = ⇒G= . (C.5)
Q (R302 + R303 )R301 R305 R307 C301 (R302 + R303 )R300

From equation C.3, it is seen that ωc can be adjusted independently with R307 and R308 ,
if they at all times are equal.

The Q factor can be independently adjusted, as this is the only factor that is dependent
on R305 .

The requirements specifies that G is 1 at all times. This is obtained by setting R300 =
R301 = R302 = R303 .

To simplify calculations it is determined that C300 = C301 and R304 = R306 . The new
simplified expressions for ωc , Q and G are

1
ωc = (C.6)
R307 C301
R305
Q= (C.7)
R304
G=1. (C.8)

Component Values
Since ωc must be adjustable from 150 to 2000 Hz, it follows that 300π ≤ ωc ≤ 4000π
rad. This implies that the resistor R307 must be a resistor in series with a potentiometer.
First the resister value is found, this can be done by setting C301 = 100 nF and then
determine R307 from the upper limit of ωc .
1 1 1
ωc = = = 4000π ⇒ R307 = ≈ 787 Ω
R307 C301 R307 · 100 nF 100 nF · 4000π
Next the potentiometer ∆R307 can be determined:
1 1
ωc = = = 300π ⇒ (C.9)
(R307 + ∆R307max )C301 (R307 + ∆R307max )100 nF
1
∆R307max = − R307 ≈ 10 kΩ
100 nF · 300π

122
The range for Q is 1 to 10. To be able to vary this R305 must be a resistor in series with
a potentiometer ∆R305 . If R304 is set to 1 kΩ, R305 is determined using the lower limit
for Q
R305
Q= ⇒ R305 = QR304 = 1 kΩ
R304
(C.10)

∆R305 is found using the upper limit for Q:


R305 + ∆R305
Q= ⇒ ∆R305max = QR304 − R305 ≈ 10 kΩ
R304
(C.11)

This gives the Q - factor a range from 1 to 11, but since this fulfills the requirements this
is found acceptable.

The value for R300 = R301 = R302 = R303 is set to 10 kΩ. Table C.1 shows all component
values and figure C.1.

Component: Value:
C300 = C301 100 nF
R300 = R301 = R302 = R303 10 kΩ
R304 = R306 1 kΩ
R305 1 kΩ
∆R305max 10 kΩ
R307 = R308 787 Ω
∆R307max = ∆R308max 10 kΩ

Table C.1: Component values for the wah wah effect.

In the end the transfer function is found to

10·109
(1000+∆R305 )(787+∆R307 ) s
H(s) = 10·109 100·1012
(C.12)
s2 + (1000+∆R305 )(787+∆R307 ) s + (787+∆R307 )(787+∆R308 )

123
C Wah Wah Transfer Function and Component Values

R300 R304 C301


R301
U301A R305 ǻR305
- U301B ǻR307
- R307
U301C
Vin + -
R302 + Vout
+
R303
C300

R306
ǻR308 R308
U301D -
+

Figure C.1: Final schematic for the wah wah effect.

124
Appendix D
The Bilinear Transformation

This appendix gives a short review of the bilinear transformation. The bilinear transfor-
mation is a filter design technique and is used to design a digital filter from an analog
filter. This technique is very useful since the filter design can be carried out in the analog
domain utilizing powerful filter design methods such as Butterworth and Chebyshev filter
designs [Orfanidis, 1996].

The Bilinear Design Method

Bilinear
Digital filter Pre-warping Analog filter Analog design transformation
Analog filter Digital filter
specifications specifications

Figure D.1: Overview of the bilinear filter design method.

The bilinear design method consists of four basic steps which are shown in figure D.1.
The design procedure begins typically with specifications to a digital filter. To utilize the
analog design tools, the digital filter specifications are converted into analog filter spec-
ifications using pre-warping. Pre-warping prevents distortion of frequency components
that are critical to the design like the cutoff frequency. This is explained further later on
in this appendix.

Utilizing one of the powerful analog filter design methods, the transfer function of the
analog filter is found from the analog specifications. The last step is to transform the
transfer function of the analog filter into a transfer function of the digital filter. This is
carried out with bilinear transformation.

The Transformation Between s- and z-domain


One of the major advantages of the bilinear transformation is that it avoids aliasing in
the frequency response [Oppenheim and Schafer, 1999]. This is obtained by transforming
the entire frequency axis in the s-domain into one revolution on the unit circle in the
z-domain. Hence, the analog frequency −∞ < Ω < ∞ maps onto the digital frequency
−π < ω < π. To find a function s = f (z) that carries out the desired mapping between
the frequency axis of the s- and z-domain, note that on the unit circle in the z-domain
z = ejω . The mapping from analog to digital frequency is ω = ΩTs where Ts is the
sampling time, and s = jΩ on the analog frequency axis. These equations combined

125
D The Bilinear Transformation

yield
z = ejω = ejΩTs = esTs . (D.1)
Solving for s gives
1
s= ln z . (D.2)
Ts
The bilinear transformation is defined as the first order approximation of equation D.2.
1 − z −1
The ln z factor is approximated by the first term of its series expansion which is 2 .
1 + z −1
This yields the bilinear transformation [Orfanidis, 1996]

2 1 − z −1
s= . (D.3)
Ts 1 + z −1

Hence, once an analog filter Ha (s) has been designed, the digital filter is found from the
bilinear transformation by



Hd (z) = Ha (s) . (D.4)
2 1−z−1
s= T
s 1+z −1

Since the bilinear transformation is nonlinear, frequency distortion or warping occurs


[Oppenheim and Schafer, 1999]. If this is ignored, it can lead to a digital filter design,
that does not fulfill its specifications even though the analog filter does. This is the major
disadvantage of the bilinear method and the price to pay in order to avoid aliasing in the
frequency response.

Solving equation D.3 for z yields

1 + sTs /2
z = rejω = (D.5)
1 − sTs /2
1 + σTs /2 + jΩTs /2
=
1 − σTs /2 − jΩTs /2

whose magnitude is
p
(1 + σTs /2)2 + (ΩTs /2)2
r=p (D.6)
(1 − σTs /2)2 + (ΩTs /2)2

and argument is
   
ΩTs /2 −ΩTs /2
ω = arctan − arctan . (D.7)
1 + σTs /2 1 − σTs /2

Several important properties of the mapping can be derived from these equations:

126
1. s = 0 ⇒ z = 1.
If s = 0 in equation D.5, then z = 1. This means that origo of the s-domain is
mapped to (1, 0) in the z-domain.
2. σ = 0 ⇒ |z| = 1.
If σ = 0 in equation D.6, then |z| = 1. This means that the frequency axis in the
s-domain is mapped onto the unit circle in the z-domain. Since Ω → ∞ ⇒ ω → π
and Ω → −∞ ⇒ ω → −π which can be seen from equation D.7, the mapping
corresponds to one revolution of the unit circle.
3. σ < 0 ⇒ |z| < 1
If σ < 0 in equation D.6, then |z| < 1. This means, that the entire left half plane
of the s-domain is mapped onto the interior of the unit circle in the z-domain. A
stable filter in the s-domain is therefore also stable and causal in the z-domain.
These properties are shown on figure D.2.

Ω Im(z)

σ Re(z)

s-domain z-domain

Figure D.2: Mapping from s- to z-domain with the bilinear transformation.

Pre-warping
From equation D.7 the relationship between the analog and digital frequency can be
found by setting σ = 0 which gives

ω = 2 arctan(ΩTs /2) . (D.8)

Solving this for the analog frequency Ω yields


2
Ω= tan(ω/2) (D.9)
Ts
which is used for pre-warping. Pre-warping alter the specification to the analog filter in
such way that the digital filter meets its specification after the warping of the bilinear
method. Thus, all the critical frequencies must be pre-warped before the analog filter is
designed.

127
Appendix E
Noise on Lowpass Comb Filter for
Reverberator

In this appendix the quantization noise in the first lowpass filter is found. In the calcula-
tions for the allpass filter the impulse response is used. For the lowpass comb filters the
same recursive approach is used, as for the allpass filters.

Scale Factor for Lowpass Comb Filters


The analysis for the first lowpass comb filter can be done finding the filter impulse re-
sponse. When this is found a variance scaling can be applied. Using equation
1
s≤ q P∞  (E.1)
2
maxk n=−∞ |hk [n] |

the scaling factor s is then the factor that the input must be scaled with [Oppenheim and Schafer,
1999, page 401]. The impulse response for one of the lowpass comb filters is calculated
here. To find the impulse response for the filter, the difference equation

y[n] = x[n] − a1 x[n − 1] + a1 y[n − 1] + b1 y[n − m] + b1 y[n − m − 1] (E.2)

is used. The length of the input is set to the time of the longest reverberation time, as
the reverberation time is defined as Pthe time when the input is attenuated 60 dB. The
output of the script results the gain ∞ 2
n=−∞ |h1 [n]| = 3.201. From this the scale factor
can be calculated using equation E.1 which gives a scale factor s = 0.5590. Scale factors
for the other lowpass comb filters are found in table 9.2 page 81.

Quantization Noise in Lowpass Comb Filters


The lowpass comb filters are realized from the difference equation, which gives a type I
filter structure shown on figure E.1.

The scale factor is calculated using the impulse response from input to output, but the
quantization noise must only be calculated from where the noise e[n] is added. So the
impulse response hef [n] must be determined. This is done directly from figure E.1, where
it is seen that only the poles have influence on hef [n]. The impulse response hef [n] can
be calculated recursively from the difference equation

yef = x[n] + a1 y[n − 1] + b1 y[n − m] + b1 [n − m − 1] (E.3)

128
e[n]

x[n] + + y[n]
Σ Σ
+ +
z-1 z-1
+
Σ
-a1 a1
+ z-m+1
+
Σ
b
+ z-1

Figure E.1: The principle of calculating noise variance on a direct form I lowpass comb filter.

by setting the input equal to the Dirac’s


P delta function. The variance amplification is
2 P∞
obtained from the impulse response ∞ |h
n=−∞ ef [n]| . 2
n=−∞ |h1ef [n]| is calculated to
3.140.

The quantization noise only happens one time in the filter due to the 32 bit accumulator
and therefore the noise can be calculated to

X 2−2·15
σf2 = σe2 · |h1ef [n]|2 = · 3.140 = 243.68 · 10−12 . (E.4)
n=−∞
12

This gives the following SNR


1 2 P∞ 2 1
3 σy · n=−∞ |h[n]|
SNR = = 3
= 1.368 · 109 . (E.5)
σf2 243.68 · 10−12

1
In decibel this gives 10 · log( 1.368·10 9 ) = 91.36 dB. Table E.1 show the results for the four
filters.
2 =
P∞ 2 2 =
P∞ 2
Filter: σef n=−∞ |hef [n]| σxy n=−∞ |h[n]| Noise: [·] Noise: [dB]
LPCF1 3.140 3.201 243.68 · 10−12 91.36
LPCF2 2.888 2.940 224.10 · 10−12 91.72
LPCF3 2.752 2.800 213.58 · 10−12 91.93
LPCF4 2.693 2.739 209.01 · 10−12 92.03

Table E.1: Calculated noise from the lowpass comb filters using MATLAB and equation E.4 for a
reverberation time of 4 seconds.

129
Appendix F
Measurement Report: Output
Impedance of Electric Guitar

The purpose is to measure the output impedance of the guitar. This can be used to set
requirement for the guitar effects unit input impedance.

Measurement Theory
The impedance can be calculated from the following equation:
V2
Zout = R · q  (F.1)
π
V12 + V22 − 2 · V1 · V2 · cos ω · 180

Measurement Setup

z
Z

Figure F.1: Measurement setup.

Equipment

Description: Type: AAU number:


Oscilloscope Agilent 54621A 33852
Oscillator B & O TG7 07993
Resistor 10 kOhm 1%
GrassRoots Guitar w.
active pickup
Axtech Vintage Guitar w.
passive pickup

Table F.1: Used equipment.

130
Measurement Procedure
1. Make the setup of figure F.1 and set the oscillator to the first frequency in table
F.2.

2. Set the volume control to max., the tone control to min. dampening of the high
frequencies and select only one pickup.

3. Note the voltages and the phase on the Oscilloscope.

4. Continue this procedure for all frequencies in table F.2.

5. Repeat for guitar with active and passive pickup.

Results
Guitar with Active Pickup

Frequency Input peak Guitar input peak Phase [◦ ]:


[Hz]: voltage [b
va ]: voltage [b
va ]:
0 1.40 0.88 0
20 1.40 0.66 14
40 1.40 0.58 12.5
80 1.40 0.53 7
160 1.40 0.52 6
320 1.40 0.51 2.3
640 1.40 0.51 1.2
1280 1.40 0.51 1
2560 1.40 0.51 0.5
5120 1.39 0.51 1.4
10240 1.39 0.51 3
20480 1.39 0.53 6

Table F.2: Measured results for guitar with active pickup.

131
F Measurement Report: Output Impedance of Electric Guitar

Guitar with Passive Pickup

Frequency Input peak Guitar input peak Phase [◦ ]


[Hz] voltage [b
va ] voltage [b
va ]
20 1.41 0.57 -1
40 1.41 0.57 -3
80 1.41 0.57 -6
160 1.41 0.61 -11
320 1.41 0.69 -20
640 1.41 0.88 -23
1280 1.41 1.13 -17
2560 1.41 1.25 -7
5120 1.41 1.28 3
10240 1.41 1.27 12
20480 1.41 1.15 28

Table F.3: Measured results for guitar with passive pickup.

132
Appendix G
Measurement Report: Frequency
Analysis of Electric Guitar

The purpose is to measure the frequency content of the guitar output.

Measurement Setup

laptop

Figure G.1: Measurement setup.

Equipment

Description: Type: AAU number:


Laptop w. sound card Znote 4200 extreme N/A
GrassRoots Guitar N/A

Table G.1: Used equipment.

Measurement Procedure
1. Make the setup of figure G.1.

2. Set the laptop to record at 44100 kHz, 16 bit.

3. Play the 6th string on fret 24 (high E).

4. Make an FFT of the recorded signal and find the frequency of the highest noticeable
harmonic.

133
G Measurement Report: Frequency Analysis of Electric Guitar

Results
Figure G.2 shows the amplitude response of a high E.

−10

−20
Amplitude [dB]

−30

−40

−50

−60
0 1000 2000 3000 4000 5000 6000 7000 8000 9000
Frequency [Hz]

Figure G.2: Measured results.

134
Appendix H
Measurement Report: Guitar
Output Voltage

The purpose is to measure the maximum guitar output voltage.

Measurement Setup

Figure H.1: Measurement setup.

Equipment

Description: Type: AAU number:


Oscilloscope Agilent 54621A 33866
Grass Roots Guitar w.
active pickup
Axtech Vintage Guitar w.
passive pickup

Table H.1: Used equipment.

Measurement Procedure
1. Make the setup of figure H.1.

2. Setup oscilloscope to measure maximum voltage.

3. Play the guitar roughly.

4. Note the maximum peak voltage

135
H Measurement Report: Guitar Output Voltage

Results

Guitar Output peak voltage [b


va ]
Grass Roots 2.28
Axtech Vintage 1.44

Table H.2: Measured results.

136
Appendix I
Measurement Report: Wah Wah
Frequency Response

The purpose is to measure the frequency response for the wah wah effect.

Measurement Setup

Measuring
Wah wah
Sine generator amplifier &
effect
x-y recorder

Figure I.1: Setup for measuring frequency response.

Equipment

Description: Type: AAU number:


B& K X-Y recorder 2308 08450
B& K Measuring amplifier 2636 08451
B& K Sine generator 1051 08449

Table I.1: Used equipment.

Measurement Procedure
1. Make the setup of figure I.1.

2. Set Qmin and the frequency response as low as possible.

3. Adjust the sine generator to sweep from 20 hz to 20 kHz.

4. Plot the sweep using the X-Y recorder.

5. Repeat for:

137
I Measurement Report: Wah Wah Frequency Response

• QMax and the frequency response as low as possible.


• QMin and the frequency response as high as possible.
• QMax and the frequency response as high as possible.

Results

dB

-10

-20

-30

-40

-50
20 Hz 50 100 200 500 1kHz 2 5 10 20kHz

Figure I.2: Results for frequency response measurements.

138
Appendix J
Measurement Report: Tremolo
Amplitude Response

The purpose is to measure the amplitude response of the tremolo effect.

Measurement Setup

Tremolo
Sine generator Oscilloscope
effect

Figure J.1: Setup for measuring amplitude response.

Equipment

Description: Type: AAU number:


Agilent Oscilloscope 54621A 33857
B& O sine generator TG7 07996

Table J.1: Used equipment.

Measurement Procedure
Procedure 1
1. Use the setup of figure J.1.

2. Set sine generator to 100 Hz with an RMS value of 1 V.

3. Set rate at minimum frequency and depth at maximum modulation.

4. Set modulation type to square, triangle and sine.

5. Save respective data from oscilloscope.

139
J Measurement Report: Tremolo Amplitude Response

Procedure 2

1. Connect oscilloscope to output of inverting summer in the LFO.

2. Set rate at maximum frequency and depth at maximum modulation.

3. Set modulation type to square, triangle and sine.

4. Measure maximum and minimum amplitude on oscilloscope.

Procedure 3

1. Connect oscilloscope to output of inverting summer in the LFO.

2. Set depth at maximum modulation.

3. Set modulation type to sine wave.

4. Set rate at minimum frequency and afterwards at maximum frequency

5. Measure maximum and minimum frequency on oscilloscope.

Results
Procedure 1

Figure J.2, J.3 and J.4 show the results of modulating a 100 Hz sine wave with each
different modulation type at lowest rate.

Figure J.2: Modulating a 100 Hz sine wave with a square wave at lowest rate.

140
Figure J.3: Modulating a 100 Hz sine wave with a triangular wave at lowest rate.

Figure J.4: Modulating a 100 Hz sine wave with a sinusoidal wave at lowest rate.

Modulation type: Maximum amplitude: [V] Minimum amplitude: [mV]


Square 9.56 870
Triangle 10.37 240
Sine 10.37 50

Table J.2: Measured amplitudes of the three different modulation types.

Procedure 2

Table J.2 shows the results of measuring the maximum and minimum amplitudes at each
different modulation type at maximum depth.

At minimum depth each modulation type had a maximum amplitude of 10.62 V and
minimum amplitude of 10.24.

141
J Measurement Report: Tremolo Amplitude Response

Procedure 3
Figure J.5 shows the LFO at minimum rate, which is measured to a frequency at 182.5
mHz. Figure J.6 shows the LFO at maximum rate, which is measured to a frequency at
10.9 Hz. Measurements were performed with a sinusoidal wave as modulation type.
LFO min frequency LFO max frequency

6 6

4 4

2 2
Amplitude [V]

Amplitude [V]
0 0

−2 −2

−4 −4

−6 −6

−5 −4 −3 −2 −1 0 1 2 3 4 5 6 0 0.1 0.2 0.3 0.4 0.5 0.6


Time [s] Time [s]

Figure J.5: Minimum frequency of LFO. Figure J.6: Maximum frequency of LFO.

142
Appendix K
Measurement Report: Equalizer
Amplitude Response

The purpose is to measure the amplitude response for the equalizer effect.

Measurement Setup

Measuring
Equalizer
Sine generator amplifier &
effect
x-y recorder

Figure K.1: Setup for measuring amplitude response.

Equipment

Description: Type: AAU number:


B& K X-Y recorder 2308 08450
B& K Measuring amplifier 2636 08451
B& K Sine generator 1051 08449

Table K.1: Used equipment.

Measurement Procedure
1. Make the setup of figure K.1.

2. Set the gain in the middle band to 0 dB and set the gain in the bass and treble
bands to -24 dB.

3. Adjust the sine generator to sweep from 20 hz to 20 kHz.

4. Plot the sweep using the X-Y recorder.

143
K Measurement Report: Equalizer Amplitude Response

5. Repeat step 1 to 4 where the gain in the bass and treble bands are increased with
4 dB until the gains reach 0 dB.

6. Set the gain in the bass and treble bands to 0 dB and set the gain in the middle
band to -24 dB.

7. Plot the sweep using the X-Y recorder.

8. Repeat step 6 to 7 where the gain in the middle band is increased with 4 dB until
the gain reach 0 dB.

Results
The results from the amplitude measurement are shown on figure K.2 and figure K.3 re-
spectively. Figure K.2 shows the results from the measurement where only the gain in the
bass and treble bands are varied and figure K.3 shows the results from the measurement
where only the gain in the middle band is varied.

dB

-10

-20

-30

-40
20 Hz 50 100 200 500 1kHz 2 5 10 20kHz

Figure K.2: Results of amplitude response measurement where the gain in the bass and treble bands
are varied from -24 to 0 dB in steps of 4 dB and middle band is fixed to 0 dB.

144
0

dB

-10

-20

-30

-40
20 Hz 50 100 200 500 1kHz 2 5 10 20kHz

Figure K.3: Results of amplitude response measurement where the gain in the bass and treble bands
are fixed to 0 dB and the gain in the middle band is varied from -24 dB to 0 dB in steps of 4 dB.

145
Appendix L
Measurement Report: Signal Noise
Ratio Test

The purpose is to measure the SNR of all the implemented effects.

Measurement Setup

Distortion Output Input


analyzer
Guitar
G effects
f DA
unit

Figure L.1: Measurement setup.

Equipment

Description: Type: AAU number:


Distortion analyzer Tektronik AA501A 08650
Tone generator Tektronik SG505 08650

Table L.1: Used equipment.

Measurement Procedure
1. Make the setup of figure L.1.

2. During the test, all other effects than the one being measured must be turned off.

3. Ground the input to the guitar effects unit.

4. Zero the distortion analyzer to make a reference point.

146
5. The sine generator must now emit a 1 kHz sine.

6. Read out the SNR from the distortion analyzer.

7. Now repeat the above listed steps for the digital effects.

Results

Effect: SNR:
Tremolo 82.1 dB
Wah wah 80.9 dB
Delay 67.9 dB
Echo 63.9 dB
Equalizer 67.8 dB
Reverberator 65.4 dB
DSP system 67.7 dB

Table L.2: Measured SNR.

147
Appendix M
Measurement Report: Utilization
Test

The purpose is to measure the processor utilization of the digital effects.

Measurement Setup

Guitar
effects
unit

Figure M.1: Measurement setup.

Equipment

Description: Type: AAU number:


Oscilloscope 54621A 33869

Table M.1: Used equipment.

Measurement Procedure
1. Make the setup of figure M.1.

2. During the test, all other effects than the one being measured must be deactivated.

3. The XF-pin is measured over a period of fs .

4. The duty cycle of the measured signal will represent the processor utilization per-
centage.

5. Now repeat the above listed steps for the rest of the digital effect.

148
Results

Effect: Utilization [%]


Reverberator 67.8 %
Equalizer 19.6 %
Echo 11.1 %
Delay 10.6 %
No effects 13.1 %

Table M.2: Utilization times.

149
Appendix N
Guitar Effect Unit Schematics

VCC

U401A
4

TLE2074
Guitar in 3 +
1 Guitar effects unit in
2 -
11

-VCC

-VCC

U401C

11
-VCC TLE2074
- 9
8
U401B
11

+ 10 Guitar effects unit out


TLE2074
- 6 R401
4

AMP out 7 10k


+ 5

VCC
4

VCC

Title
Input, output buffer and volumen control - Group 642

Size Document Number Rev


A 5 1

Date: Saturday, May 26, 2007 Sheet 1 of 1

Figure N.1: Schematic for input output buffer with volume control.

150
L101
VDD
LM78L05ACZ/TO92 U109 VCC VDD

D0
D1
D2
D3
D4
D5
D6
D7
D8
D9
D10
D11
D12
D13
D14
D15
3 VOUT 1

GND
C137 VIN C124 C123 C125 U106

19
18
17
16
15
14
13
12
10
9
8
7
6
5
4
3
C113 + C112 10n M27C1024
100n 1u C136 100n 220u 100n

O0
O1
O2
O3
O4
O5
O6
O7
O8
O9
O10
O11
O12
O13
O14
O15
2
VCC C134 BEAD FERRITE 330n 40 30
Vin + C110 C111 U2 VCC GND

23
35
61
62
GND 11
1u 100n

PGM

VPP
A10
A11
A12
A13
A14
A15
100n

OE

CE
18 26

A0
A1
A2
A3
A4
A5
A6
A7
A8
A9
VCC
VCC
VCC
VCC
U101A VDD R106 D0 A0
17 D1 A1 28

8
R101 16 29

21
22
23
24
25
26
27
28
29
31
32
33
34
35
36
37

20
39
2

1
D2 A2 VDD
3 + 15 D3 A3 30
U102

A0
A1
A2
A3
A4
A5
A6
A7
A8
A9
A10
A11
A12
A13
A14
A15
24
1 4.7k 14 D4 A4 31

4
2 - 13 D5 A5 32
4.75k 43 12 33

VA
VD
SDOUT R105 D6 A6
11 34
4

30.1k D7 A7
C102 33 DI1 DO1 37 C104 R104 9 D8 A8 36
C135 8 37
18.2k D9 A9

+
27 LIN1 LOUT 16 6 -
Vout 7 D10 A10 38
28 LIN2 ROUT 15 7 6 D11 A11 39
100n -VCC 25 R103 5 + 5 40
VDD R102 1u RIN1 2.2u
C103 20k U101B D12 A12
26 RIN2 MF5/DO2/INT 38 4 D13 A13 41
7.68k C101 C105 2.2n OPAMP DUAL SUPPLY 3 42
680p C106 D14 A14
0.1u 6 FILT MF1/F1/CDOUT 40 2 D15 A15 43

D0
D1
D2
D3
D4
D5
D6
D7
20 REFBUF MF2/F2/CDIN 39
R110 44 58 64
10k SCLK CLKOUT1 CLKR U104

11
12
13
15
16
17
18
19
0.47u SSYNC 1 57 CLKOUT2 CLKX 63 C114
R118 CY7C199/SO
500 53 51

D0
D1
D2
D3
D4
D5
D6
D7
VDD FSX X1
13 PDN 25 FSR X2/CLKIN 52
2 VDD 14
+ C109 J101 RST 10p GND
35 50

VCC
MF3/DI3/F3/CCLK BR

A10
A11
A12
A13
A14

WE
Y101

OE

CE
47u 36 21 20 45

A0
A1
A2
A3
A4
A5
A6
A7
A8
A9
MF4/MA/CCS REFBYP INT0 DS
1 2 34 MF6/DI2/F1 21 INT1 DX 54 40M
3 4 31 C107 + C108 22 55 C126
C115

21
23
24
25
26
1
2
3
4
5
6
7
8
9
10

22
27
20

28
MF7/SFS1/F2 INT2 HLDA
5 6 30 MF8/SFS2/F3 REFGND 22 0.1u 10u IACK 60
100n

A0
A1
A2
A3
A4
A5
A6
A7
A8
A9
A10
A11
A12
A13
A14
29 SMODE1 68 BIO IS 46
32 24 59 VDD
SMODE2 DR MSC
41 SMODE3 67 HOLD PS 47 10p
1 MP/MC R/W 48
CLKIN 3 66 READY STRB 49

DGND
AGND
65 56

GND
GND
GND
R107 RS XF
SDIN 42 19 SYNC
10k

D8
D9
D10
D11
D12
D13
D14
D15
23

10
27
44
R108 TMS320C26/LCC
10k U105

11
12
13
15
16
17
18
19
CY7C199/SO
R109

D0
D1
D2
D3
D4
D5
D6
D7
10k VDD C131
GND 14

VCC
A10
A11
A12
A13
A14

WE
100n C127

OE

CE
A0
A1
A2
A3
A4
A5
A6
A7
A8
A9
U107

24
100n

21
23
24
25
26
1
2
3
4
5
6
7
8
9
10

22
27
20

28
A2 2 14 VDD

VCC
A3 I I/O

A0
A1
A2
A3
A4
A5
A6
A7
A8
A9
A10
A11
A12
A13
A14
3 I I/O 15
A15 4 16
DS* I I/O CS_DISP
5 I I/O 17
PS* 6 18 CS_KEYS*
IS* I I/O CS_ROM*
7 I I/O 19
Title MSC* 8 20 CS_RAM*
DSP Basis system - Group 642 I I/O OE*
9 I I/O 21
R/W* 10 22 WE*
Size Document Number Rev STRB*11 I I/O READY*
I I/O 23
A3 1 1 13 I

GND
C130
Date: Monday, May 28, 2007 Sheet 1 of 1 1 I/CLK VDD
C128

12
22CV10A 100n U114
100n

1
U108 U113

10
3 2

VCC
A A

2
KS0066F 74HCT573 5 4
D0 12 B B
VDD C132 7 9 D0 7 6

VCC

GND
DB0 D1 13 8Q 8D C C
DB1 8 7Q 7D 8 D1 9 D D 10
9 D2 14 7 D2 11 12
DB2 6Q 6D E E
VDD 100n
DB3 10 D3 15 5Q 5D 6 D3 14 F F 15
U110 11 D4 16 5 D4
24
DB4 4Q 4D
12 D5 17 4 D5 13

GND
D15 DB5 3Q 3D NC1
13 16 13 D6 18 3 D6 16
+5v

RXD D15 D14 DB6 2Q 2D NC2


R115 D101
D14 23 DB7 14 D7 19 1Q 1D 2 D7
10k ? 17 21 D13 11

VCC

8
TXD D13 D11 C MC14584
R116 D11 20 OC 1
R114 1 19 D12 6
- D12 E
18 9 4

20
C133 - D12x A3 RS
A3 5 R/W* 5 U112
1u 100 10p 10k C116 R113 A2

12
10 RSI A2 4
U111 100k A1 22CV10A
16

GND
C118 C117 10n A1 A0 CS_DISP
2 3 1

GND
R112 A0 Vcontrast I/CLK
12 13 RESET 15
VCC

R1OUT R1IN 10n RSO


9 8 14 13

1
R2OUT R2IN TRPO I
23 I/O I 11
14 11 C119 100k 11 22 10
T1OUT T1IN TRPI I/O I
7 T2OUT T2IN 10 R/W* 8 R/W* R111 21 I/O I 9
1u TRAP
STRB* 7 STRB* R119 20 I/O I 8
1 22 6 IS* 4.7k 33.2k 19 7
GND

C1+ DMON* IS* CS_KEYS* VDD I/O I


C1- 3 18 I/O I 6
4 C120 17 5
C2+ 1u R117 D0 I/O I
5 16 4
12

C2- 470 IDM3202X-V D1 I/O I


2 15 3
GND

VCC
V+ VDD D2 I/O I A0
V- 6 14 I/O I 2
C121 D3 KEYBOARD
1u 1u D4
15

24
MAX232 D5
151

D6 C138
C122 D102 C129
D7 100n
LED
VDD VDD
100n

Figure N.2: Schematic for DSP system.


N Guitar Effect Unit Schematics

D0-D7
VDD

VDD
R120 VDD 100n
E

20
S1 U116
10k 100n

24
1

VCC
U115 OE1
19 OE2
R121 Switch1a 2 14 2 18

VCC
Switch1b I I/O A0 Y0
3 I I/O 15 3 A1 Y1 17
Switch2a 4 16 4 16
10k Switch2b I I/O A2 Y2
5 I I/O 17 5 A3 Y3 15
Switch3a 6 18 6 14
R122 Switch3b I I/O A4 Y4
7 I I/O 19 7 A5 Y5 13
Switch4a 8 20 8 12

GND
Switch4b I I/O A6 Y6
S2 9 I I/O 21 9 A7 Y7 11
10k Switch5a 10 22
Switch5b I I/O 74HC541
11 23

10
I I/O
13 I
R123

GND
1 I/CLK
10k 22CV10A

12
R124

S3
10k

R125

10k

R126

S4
10k

R127

10k

R128

S5
10k

R129

10k

R130 R131
10k 10k
SW1

Title
Keyboard - Group 642

SW Momentary SPST Size Document Number Rev


A4 2 1

Date: Wednesday, May 23, 2007 Sheet 1 of 1

Figure N.3: Schematic for keyboard system.

152
VCC R211 R215 R216 R217 R218 R219 R220 R221 R222 R223 R224 R225 -VCC

931 30.9 90.9 140 177 137 137 177 140 90.9 30.9 931

R206 R207 R208 R209 R210 R211 R212 R213


R202 40.2 121 243 402 40.2 121 243 402

D201 D202 D203 D204 D205 D206 D207 D208 D209 D210
10M
100n
C201

11
1.5u D1N4148 D1N4148 D1N4148 D1N4148 D1N4148 D1N4148 D1N4148 D1N4148 D1N4148 D1N4148
-VCC 9 - LM324
8
100n R205 10 +
U201C
11

61.9

4
6 - LM324
7
5 + R201a 100n
R201b U201B VCC
2.2M
24.9k
4

VCC

100n 100n
VCC

4
R203
3 + LM324
2k 1
2 -
R229 U201A

11
VCC
10k
R228 100n 100n
-VCC
S1
4

R227
30k
2 - TLE2072
R226 1
20k
3 + U203
SC 1X3 U202A R235
12.73k
1 7 Tremolo out
8

VCC X1 W
1M 2 X2
-VCC Tremolo in 3 Y1
100n 100n 4 Y2
-VCC 6 Z
4

R230 VCC
2k 6 - TLE2072 8
R233 100n +VCC
7 5 -VCC
5 +
U202B AD633
1M
R231
8

1k R32
100k R234 100n -VCC
100n
-VCC
1k
Title
Tremolo - Group 642

Size Document Number Rev


A 3 1

Date: Saturday, May 26, 2007 Sheet 1 of 1

Figure N.4: Schematic for tremolo effect.

R300
R304
10k
1k C301
R301 VCC
10k VCC 100n
VCC
11

TLE2074A
4

2 - R305
4

R302 1 5 + U301B R307


Input 3 + 7 10 + U301C
1k
R305_delta 6 - 8
10k 10k 787 Output
TLE2074A R307_delta 9 -
4

U301A 10k TLE2074A


11

R303
11

10k
-VCC
-VCC
-VCC
R306 C300
1k
100n
-VCC

TLE2074A
11

R308
- 13
14 787
+ 12 R308_delta
U301D 10k
4

Title
VCC Wah Wah - Group 642

Size Document Number Rev


A 4 1

Date: Saturday, May 26, 2007 Sheet 1 of 1

Figure N.5: Schematic for wah wah effect.

153
Appendix O
Source Code

Source Code for Main

1 ********************************************
2 * filename : main . asm
3 * creator : jkjaer
4 * generated : May 1 st 2007
5 *
6 * This is the main program which includes
7 * all other files .
8 *
154

9 * references :
10 * [ aug ] TMS320C1X / C2X / C2XX / C5X Assembly language tools Texas Instruments
11 * [ ug ] TMS320C2X user ’ s guide Texas Instruments
12 * [D/M] Debugger / monitor Sofus Birkedal Nielsen
13 ********************************************
14
15 ********************************************
16 * Constants
17 ********************************************
18 . text ; . t e x t = 1100 h i n t h e l i n k e r command f i l e
19 IMASK . equ 011 h ; interruptmask
20
21 ********************************************
22 * Initialization
23 ********************************************
24 . mmregs ; c h o o s e r e s e r v e d names f o r i n t e r n a l r e g i s t e r . See [ aug ] p . 4.58+4.59
25 INIT :
26 *
27 * Generel setup .
28 *
29 ; DINT ; d i s a b l e i n t e r r u p t t o p r e v e n t e r r o r s i f t h e program i s s t a r t e d w i t h e n t e r
ins t ea d of space
30 SSXM ; Enable s i g n e x t e n s i o n
31 CONF 0 ; A l l i n t e r n a l r e g i s t e r s are data r e g i s t e r s ’
32 RXF ; r e s e t e x t e r n a l f l a g p i n − i s used t o show i n t e r r u p t l e n g t h
33 ; d a t a s t a c k p o i n t e r . A s o f t w a r e s t a c k t o s t o r e d a t a ( n o t t h e PC t h a t w i l l be s t o r e d on t h e hardware s t a c k ) − page 4
(128 words b e g i n n i n g from a d d r e s s 0200 h ) i s used
34 LRLK AR6 ,027 Fh ; i n t e r r u p t s t a c k p o i n t e r (AR6) on bottom o f page 4 ! ! Grows w i t h d e c r e a s i n g
address .
35 LRLK AR7 ,0200 h ; d a t a s t a c k p o i n t e r (AR7) on page 4 ! ! Grows w i t h i n c r e a s i n g a d d r e s s .
36 LARP AR7 ; The a d d r e s s r e g i s t e r p o i n t e r p o i n t s a t t h e d a t a s t a c k p o i n t e r − ALWAYS RESTORE
IF CHANGED
37 ; s e t u p o f page and d i f f e r e n t
38 LDPK 0 ; Page 0 s e l e c t e d − ALWAYS RESTORE IF CHANGED
39 LALK 01 h ; load accumulator with 1
40 SACL PRD ; copy t h e v a l u e o f t h e a c c u m u l a t o r t o t h e p e r i o d r e g i s t e r (PRD) i n t h e t i m e r
41 *
42 * Interrupt init ( inspired by [ D / M ] p . 91) .
43 *
44 ; push opcode f o r branch t o d a t a s t a c k
45 LALK 0 FF80h ; FF80 = opcode f o r branch
46 SACL *+ ; push b r a c h i n s t r u c t i o n onto d a t a s t a c k
47 ; TOdS−1 −> 0FF80h ( opcode f o r branch )
48 ; push a d d r e s s o f i n t e r r u p t r u t i n e s t a r t t o d a t a s t a c k
49 LALK RINTR ;RINTR i s t h e a d d r e s s ( name ) o f t h e u s e r s i n t e r u p t r u t i n e
50 SACL * ; push a d d r e s s o f RINTR onto d a t a s t a c k
51 ; TOdS −> a d d r e s s o f RINTR
52 ; s e t u p i n t e r r u p t v e c t o r f o r s e r i a l p o r t r e c e i v e r i n t e r r u p t on a d d r e s s 01058 h and 01059 h
53 LALK 1059 h ; a d d r e s s+1 f o r RINT i n t e r r u p t v e c t o r
54 TBLW *- ; pop t o p o f d a t a s t a c k (= a d d r e s s o f RINTR) t o a d d r e s s 1059 h
55 ; TOdS −> 0FF80h ( opcode f o r branch )
56 SUBK 1 ; a c c u m u l a t o r = 1058
57 TBLW * ; pop t o p o f d a t a s t a c k (=opcode o f branch ) t o a d d r e s s 1058 h
58 ; s e t u p i n t e r r u p t mask
59 LALK IMASK ; mask f o r TRAP and RINT
60 SACL IMR ; w r i t e IMASK t o a d d r e s s o f IMR ( i n t e r r u p t mask r e g i s t e r )
61 *
62 * Serial port init ( see [ ug ] p . 3.64) .
63 *
64 FORT 0 ; S e t s t h e s e r i a l p o r t t o 16 b i t mode
65 RTXM ; R e s e t s t h e TXM ( t r a n s m i t mode ) b i t −> t h e FSX p i n becomes an i n p u t p i n −
requires external syncronization
66 SFSM ; S e t s FSM ( frame s y n c r o n i z a t i o n mode ) b i t . E x t e r n e l frame sync p u l s e s a r e
required .
67 *
155

68 * Display init .
69 *
156

O Source Code
70 ; initialize display
71 *
72 CALL DISP_INIT
73 * Init of keyboard and jog wheel .
74 *
75 CALL KEYB_INIT
76
77 * Init of menu handler .
78 *
79 CALL MENU_INIT
80 *
81 * Init of effects .
82 *
83 CALL E_INIT ; i n i t o f d e l a y / echo
84 CALL REVERB_INIT ; i n i t o f REVERB
85 CALL Q_INIT ; INIT EQUALIZER
86 *
87 * End of initialization . Interrupt is enabled .
88 *
89 EINT ; enable interrupt
90 ********************************************
91 * Main program
92 ********************************************
93 MAIN :
94 ; CALL RINTR ; u s e t h i s i f you want t o u s e s i n g l e s t e p
95 CALL MENU_HANDLER
96 NOP
97 B MAIN ; end o f main . Branch t o b e g i n n i n g o f main
98
99 ********************************************
100 * Receive interrupt rutine
101 ********************************************
102 RINTR :
103 *
104 * Save contents of important registers to data stack ( inspir ed by [ ug ] p . 5.30) .
105 *
106 SXF ; set external flag
107 ; set stack pointer
108 LARP 6 ; s e l e c t i n t e r r u p t s t a c k p o i n t e r . The p r e v i o u s v a l u e o f ARP i s s a v e d i n ARB and
w i l l be r e s t o r e d a t t h e end o f t h e i n t e r r u p t r u t i n e
109 ; save s t a t u s r e g i s t e r s
110 SST1 *- ; push s t a t u s r e g i s t e r ST1 t o d a t a s t a c k
111 ; TOiS−1 −> ST1
112 SST0 *- ; push s t a t u s r e g i s t e r ST0 t o d a t a s t a c k
113 ; TOiS−1 −> ST0
114 ; save accumulator
115 SACH *- ; push upper a c c u m u l a t o r t o d a t a s t a c k
116 ; TOiS−1 −> ACCH
117 SACL *- ; push l o w e r a c c u m u l a t o r t o d a t a s t a c k
118 ; TOiS−1 −> ACCL
119 ; s a v e P−r e g i s t e r
120 ; SPM 0 ; s e t s h i f t of product r e g i s t e r output to 0
121 ; SPH ∗− ; push upper P−r e g i s t e r t o d a t a s t a c k
122 ; TOiS−1 −> upper P−r e g
123 ; SPL ∗− ; push l o w e r P−r e g i s t e r t o d a t a s t a c k
124 ; TOiS−1 −> l o w e r P−r e g
125 ; s a v e T−r e g i s t e r
126 ; MPYK 1 ; copy T−r e g i s t e r t o P−r e g i s t e r
127 ; SPL ∗− ; push t h e c o p i e d T−r e g i s t e r t o d a t a s t a c k
128 ; TOiS−1 −> T−r e g
129 ; s a v e hardware s t a c k
130 RPTK 4 ; r e p e a t POPD 5 t i m e s
131 POPD *- ; push hardware s t a c k t o d a t a s t a c k
132 ; TOiS−1 −> BOhS
133 ; save a u x i l i a r y r e g i s t e r s
134 ; SAR AR0,∗− ; push AR0 t o d a t a s t a c k
135 ; TOdS−1 −> AR0
136 ; SAR AR1,∗− ; push AR1 t o d a t a s t a c k
137 ; TOiS−1 −> AR1
138 ; SAR AR2,∗− ; push AR2 t o d a t a s t a c k
139 ; TOiS−1 −> AR2
140 ; SAR AR3,∗− ; push AR3 t o d a t a s t a c k
141 ; TOiS−1 −> AR3
142 ; SAR AR4,∗− ; push AR4 t o d a t a s t a c k
143 ; TOiS−1 −> AR4
144 ; SAR AR5,∗− ; push AR5to d a t a s t a c k
145 ; TOiS−1 −> AR5
146 ; s w i t c h t o AR7 as s t a c k p o i n t e r
147 MAR *+ ,7 ; use t h i s i f c o n t e x t s w i t c h i n g i s optimized
148 ; LARP 7 ; s e l e c t data stack pointer .
149 ADRK 10 ; add 10 t o d a t a s t a c k p o i n t e r . N e c e s s a r y s i n c e t h e s t a c k p o i n t e r might p o i n t t o
s o m e t h i n g d i f f e r e n t than TOdS .
150 *
151 * Beginning of interrupt rutine .
152 *
153 CALL EFF_HAND ; branch t o e f f e c t h a n d l e r
157

154 *
155 * Restore contents of important registers ( inspired by [ ug ] p . 5.31) .
158

O Source Code
156 * Assumes ARP -> AR7
157 *
158 RESTORE :
159 ;
160 SBRK 10 ; s u b t r a c t 10 from d a t a s t a c k p o i n t e r
161 LARP 6 ; select interrupt stack pointer .
162 ; restore auxiliary registers
163 ; TOiS −> AR5
164 ; LAR AR5,∗+ ; pop AR5 from d a t a s t a c k
165 ; TOiS −> AR4
166 ; LAR AR4,∗+ ; pop AR4 from d a t a s t a c k
167 ; TOiS −> AR3
168 ; LAR AR3,∗+ ; pop AR3 from d a t a s t a c k
169 ; TOiS −> AR2
170 ; LAR AR2,∗+ ; pop AR2 from d a t a s t a c k
171 ; TOiS −> AR1
172 ; LAR AR1,∗+ ; pop AR1 from d a t a s t a c k
173 ; TOiS −> AR0
174 ; LAR AR0,∗+ ; pop AR0 from d a t a s t a c k
175 ; TOiS −> BOhS
176 ; r e s t o r e hardware s t a c k
177 RPTK 4 ; r e p e a t PSHD 5 t i m e s
178 PSHD *+ ; r e s t o r e hardware s t a c k
179 ; TOiS −> T−r e g
180 ; r e s t o r e l o w e r P−r e g i s t e r
181 ; MAR ∗+ ; T−r e g i s t e r i s s k i p p e d
182 ; TOiS −> l o w e r P−r e g
183 ; LT ∗− ; The T−r e g i s t e r i l o a d e d w i t h t h e l o w e r P−r e g i s t e r
184 ; TOiS −> T−r e g
185 ; MPYK 1 ; The l o w e r P−r e g i s t e r i s r e s t o r e d
186 ; r e s t o r e T−r e g i s t e r
187 ; LT ∗+ ; pop T−r e g i s t e r from d a t a s t a c k
188 ; TOiS −> l o w e r P−r e g
189 ; r e s t o r e upper P−r e g i s t e r
190 ; MAR ∗+ ; P−r e g i s t e r i s s k i p p e d
191 ; TOiS −> upper P−r e g
192 ; LPH ∗+ ; pop upper P−r e g i s t e r from d a t a s t a c k
193 ; TOiS −> ACCL
194 ; r e s t o r e lower accumulator
195 ZALS *+ ; pop l o w e r a c c u m u l a t o r from s t a c k . S i g n e x t e n s i o n s u r p r e s s e d .
196 ; TOiS −> ACCH
197 ; r e s t o r e upper a c c u m u l a t o r
198 ADDH *+ ; pop upper a c c u m u l a t o r from s t a c k .
199 ; TOiS −> ST0
200 ; restore status registers
201 LST *+ ; pop s t a t u s r e g i s t e r ST0 from d a t a s t a c k
202 ; TOiS −> ST1
203 LST1 * ; pop s t a t u s r e g i s t e r ST1 from d a t a s t a c k . ARP r e s t o r e d .
204 *
205 * Return to main .
206 *
207 RXF ; set external flag
208 EINT ; e n a b l e i n t e r r u p t − t h e TMS320C2x d i s a b l e s i n t e r r u p t when an i n t e r r u p t r u t i n e i s
called
209 RET ; r e t u r n from i n t e r r u p t
210 **************************************************
211 * Include program modules
212 **************************************************
213
214 . copy " display . asm "
215 . copy " keyboard . asm "
216 . copy " menu_handler . asm "
217 . copy " effect_handler . asm "
218 . copy " echo_delay2 . asm "
219 . copy " equalizer . asm "
220 ; . copy " f l a n g e r _ c h o r u s . asm"
221 . copy " reverb2 . asm "
222 . end
159
160

O Source Code
Source Code for Display

1 ********************************************
2 * filename : display . asm
3 * creator : jkjaer
4 * generated : May 8 th 2007
5 *
6 * This is the display driver
7 *
8 * references :
9 * [ aug ] TMS320C1X / C2X / C2XX / C5X Assembly language tools Texas Instruments
10 * [ ug ] TMS320C2X user ’ s guide Texas Instruments
11 * [D/M] Debugger / monitor Sofus Birkedal Nielsen
12 * [ L1620 ] L1620 alphanumeric display datasheet Seiko
13 ********************************************
14 ********************************************
15 * Constants
16 ********************************************
17 IR_DISP . equ 00 h ; address of instruction r e g i s t e r of display
18 DR_DISP . equ 01 h ; address of data r e g i s t e r of d i s p l a y
19 ********************************************
20 * Initialization of display
21 * Inspired by [ L1620 ]
22 * Requires no input arguments
23 * Returns no output argument
24 ********************************************
25 DISP_INIT :
26 ; The d i s p l a y cannot n o t be i n i t i a l i z e d u n t i l 15 ms a f t e r power−up . S i n c e t h i s program i s s t a r t e d from t h e D/M, t h i s
requirement i s f u l f i l l e d .
27 ; Function s e t . I n i t i a l i z e s t h e d i s p l a y t o 8 b i t d a t a l e n g t h , 2 l i n e s and 5∗7 d o t m a t r i x f o r m a t . The i n s t r u c t i o n i s
w r i t t e n f o u r t i m e s as s u g g e s t e d by [ L1620 ]
28 LALK 038 h ; l o a d t h e f u n c t i o n code t o t h e l o w e r a c c u m u l a t o r
29 SACL * ; push 38 h t o t h e s t a c k − t h e s t a c k p o i n t e r i s n o t i n c r e m e n t e d i n o r d e r t o s a v e
one i n s t r u c t i o n (MAR ∗−)
30 ; TOdS −> f u n c t i o n code (38 h )
31 ; f i r s t w r i t e o f f u n c t i o n code t o d i s p l a y
32 OUT * , IR_DISP ; w r i t e f u n c t i o n code (38 h ) t o t h e i n s t r u c t i o n r e g i s t e r o f d i s p l a y
33 ; d e l a y b e t w e e n f i r s t and second f u n c t i o n code w r i t e must be a t l e a s t 4 . 1 ms
34 LACK 0 A028h ; Load 41000 (=A028h ) t o a c c u m u l a t o r which c o r r e s p o n d s t o 4 . 1 ms d e l a y (100 ns
∗41000 = 4 . 1 ms) .
35 SACL TIM ; l o a d t h e t i m e r r e g i s t e r w i t h 4 1 0 0 0 . Assumes page 0 i s s e l e c t e d .
36 DELAY1 : ZALS TIM ; Copies t h e c u r r e n t v a l u e o f TIM t o a c c u m u l a t o r . Assumes page 0 i s s e l e c t e d .
37 SUBK 05 h ; s u b t r a c t 5 from a c c u m u l a t o r . S i n c e TIM i s n o t r e a d e v e r y time i s d e c r e a s e s , i t
i s n e c e s s a r y t o i n t r o d u c e some margin
38 BGZ DELAY1 ; branch t o DELAY1 as l o n g as a c c u m u l a t o r v a l u e i s g r e a t e r tha n z e r o => TIM
g r e a t e r than 9 .
39 ; second w r i t e
40 OUT * , IR_DISP ; w r i t e f u n c t i o n code (38 h ) t o t h e i n s t r u c t i o n r e g i s t e r o f d i s p l a y
41 ; d e l a y b e t w e e n second and f i r s t f u n c t i o n code w r i t e must be a t l e a s t 100 us
42 LALK 05 E8h ; Load 1000 (=3E8h ) t o a c c u m u l a t o r which c o r r e s p o n d s t o 100 us d e l a y (100 ns ∗1000
= 100 us )
43 SACL TIM ; l o a d t h e t i m e r r e g i s t e r w i t h 1 0 0 0 . Assumes page 0 i s s e l e c t e d .
44 DELAY2 : ZALS TIM ; Copies t h e c u r r e n t v a l u e o f TIM t o a c c u m u l a t o r . Assumes page 0 i s s e l e c t e d .
45 SUBK 05 h ; s u b t r a c t 9 from a c c u m u l a t o r . S i n c e TIM i s n o t r e a d e v e r y time i s d e c r e a s e s , i t
i s n e c e s s a r y t o i n t r o d u c e some margin
46 BGZ DELAY2 ; branch t o DELAY2 as l o n g as a c c u m u l a t o r v a l u e i s g r e a t e r tha n z e r o => TIM
g r e a t e r than 9 .
47 ; third write
48 OUT * , IR_DISP ; w r i t e f u n c t i o n code (38 h ) t o t h e i n s t r u c t i o n r e g i s t e r o f d i s p l a y
49 ; d e l a y b e t w e e n second and t h i r d f u n c t i o n code w r i t e must be a t l e a s t 40 us
50 LALK 0500 h ; Load 400 (=190h ) t o a c c u m u l a t o r which c o r r e s p o n d s t o 40 us d e l a y (100 ns ∗400 =
40 us )
51 SACL TIM ; l o a d t h e t i m e r r e g i s t e r w i t h 4 0 0 . Assumes page 0 i s s e l e c t e d .
52 DELAY3 : ZALS TIM ; Copies t h e c u r r e n t v a l u e o f TIM t o a c c u m u l a t o r . Assumes page 0 i s s e l e c t e d .
53 SUBK 05 h ; s u b t r a c t 9 from a c c u m u l a t o r . S i n c e TIM i s n o t r e a d e v e r y time i s d e c r e a s e s , i t
i s n e c e s s a r y t o i n t r o d u c e some margin
54 BGZ DELAY3 ; branch t o DELAY3 as l o n g as a c c u m u l a t o r v a l u e i s g r e a t e r tha n z e r o => TIM
g r e a t e r than 9 .
55 ; fourth write
56 OUT * , IR_DISP ; w r i t e f u n c t i o n code (38 h ) t o t h e i n s t r u c t i o n r e g i s t e r o f d i s p l a y
57 ; d e l a y b e t w e e n t h i r d and f o u r t h f u n c t i o n code w r i t e must be a t l e a s t 40 us
58 LALK 0500 h ; Load 400 (=190h ) t o a c c u m u l a t o r which c o r r e s p o n d s t o 40 us d e l a y (100 ns ∗400 =
40 us )
59 SACL TIM ; l o a d t h e t i m e r r e g i s t e r w i t h 4 0 0 . Assumes page 0 i s s e l e c t e d .
60 DELAY4 : ZALS TIM ; Copies t h e c u r r e n t v a l u e o f TIM t o a c c u m u l a t o r . Assumes page 0 i s s e l e c t e d .
61 SUBK 05 h ; s u b t r a c t 9 from a c c u m u l a t o r . S i n c e TIM i s n o t r e a d e v e r y time i s d e c r e a s e s , i t
i s n e c e s s a r y t o i n t r o d u c e some margin
62 BGZ DELAY4 ; branch t o DELAY4 as l o n g as a c c u m u l a t o r v a l u e i s g r e a t e r tha n z e r o => TIM
g r e a t e r than 9 .
63 ; Entry mode s e t . Increment t h e a d d r e s s c o u n t e r a u t o m a t i c and d i s a b l e s h i f t o f d i s p l a y .
64 LALK 06 h ; l o a d t h e e n t r y mode t o t h e l o w e r a c c u m u l a t o r
65 SACL * ; push 6h t o t h e s t a c k − t h e s t a c k p o i n t e r i s n o t i n c r e m e n t e d i n o r d e r t o s a v e
one i n s t r u c t i o n (MAR ∗−)
66 ; TOdS −> f u n c t i o n code (6 h )
161

67 OUT * , IR_DISP ; w r i t e e n t r y mode (6 h ) t o t h e i n s t r u c t i o n r e g i s t e r o f d i s p l a y


68 ; d e l a y a f t e r w r i t e o f e n t r y mode
162

O Source Code
69 LALK 0500 h ; Load 400 (=190h ) t o a c c u m u l a t o r which c o r r e s p o n d s t o 40 us d e l a y (100 ns ∗400 =
40 us )
70 SACL TIM ; l o a d t h e t i m e r r e g i s t e r w i t h 4 0 0 . Assumes page 0 i s s e l e c t e d .
71 DELAY5 : ZALS TIM ; Copies t h e c u r r e n t v a l u e o f TIM t o a c c u m u l a t o r . Assumes page 0 i s s e l e c t e d .
72 SUBK 05 h ; s u b t r a c t 9 from a c c u m u l a t o r . S i n c e TIM i s n o t r e a d e v e r y time i s d e c r e a s e s , i t
i s n e c e s s a r y t o i n t r o d u c e some margin
73 BGZ DELAY5 ; branch t o DELAY5 as l o n g as a c c u m u l a t o r v a l u e i s g r e a t e r tha n z e r o => TIM
g r e a t e r than 9 .
74 ; D i s p l a y ON/OFF. Turns t h e d i s p l a y , c u r s o r and b l i n k on .
75 LALK 0 Ch ; l o a d t h e d i s p l a y ON/OFF t o t h e l o w e r a c c u m u l a t o r
76 SACL * ; push Fh t o t h e s t a c k − t h e s t a c k p o i n t e r i s n o t i n c r e m e n t e d i n o r d e r t o s a v e
one i n s t r u c t i o n (MAR ∗−)
77 ; TOdS −> f u n c t i o n code ( Fh )
78 OUT * , IR_DISP ; w r i t e e n t r y mode ( Fh ) t o t h e i n s t r u c t i o n r e g i s t e r o f d i s p l a y
79 ; d e l a y a f t e r w r i t e o f d i s p l a y ON/OFF
80 LALK 0500 h ; Load 400 (=190h ) t o a c c u m u l a t o r which c o r r e s p o n d s t o 40 us d e l a y (100 ns ∗400 =
40 us )
81 SACL TIM ; l o a d t h e t i m e r r e g i s t e r w i t h 4 0 0 . Assumes page 0 i s s e l e c t e d .
82 DELAY6 : ZALS TIM ; Copies t h e c u r r e n t v a l u e o f TIM t o a c c u m u l a t o r . Assumes page 0 i s s e l e c t e d .
83 SUBK 05 h ; s u b t r a c t 9 from a c c u m u l a t o r . S i n c e TIM i s n o t r e a d e v e r y time i s d e c r e a s e s , i t
i s n e c e s s a r y t o i n t r o d u c e some margin
84 BGZ DELAY6 ; branch t o DELAY6 as l o n g as a c c u m u l a t o r v a l u e i s g r e a t e r tha n z e r o => TIM
g r e a t e r than 9 .
85 ; Clear d i s p l a y .
86 LALK 01 h ; load the c l e a r d i s p l a y to the lower accumulator
87 SACL * ; push 1h t o t h e s t a c k − t h e s t a c k p o i n t e r i s n o t i n c r e m e n t e d i n o r d e r t o s a v e
one i n s t r u c t i o n (MAR ∗−)
88 ; TOdS −> f u n c t i o n code (1 h )
89 OUT * , IR_DISP ; w r i t e e n t r y mode ( Fh ) t o t h e i n s t r u c t i o n r e g i s t e r o f d i s p l a y
90 ; delay after write of clear display
91 LALK 05010 h ; Load 16400(=4010 h ) t o a c c u m u l a t o r which c o r r e s p o n d s t o 1 . 6 4 ms d e l a y (100 ns
∗16400 = 1 . 6 4 ms)
92 SACL TIM ; l o a d t h e t i m e r r e g i s t e r w i t h 1 6 4 0 0 . Assumes page 0 i s s e l e c t e d .
93 DELAY7 : ZALS TIM ; Copies t h e c u r r e n t v a l u e o f TIM t o a c c u m u l a t o r . Assumes page 0 i s s e l e c t e d .
94 SUBK 05 h ; s u b t r a c t 9 from a c c u m u l a t o r . S i n c e TIM i s n o t r e a d e v e r y time i s d e c r e a s e s , i t
i s n e c e s s a r y t o i n t r o d u c e some margin
95 BGZ DELAY7 ; branch t o DELAY7 as l o n g as a c c u m u l a t o r v a l u e i s g r e a t e r tha n z e r o => TIM
g r e a t e r than 9 .
96 ; Reset address counter .
97 LALK 080 h ; load the r e s e t address counter to the lower accumulator
98 SACL * ; push 80 h t o t h e s t a c k − t h e s t a c k p o i n t e r i s n o t i n c r e m e n t e d i n o r d e r t o s a v e
one i n s t r u c t i o n (MAR ∗−)
99 ; TOdS −> f u n c t i o n code (80 h )
100 OUT * , IR_DISP ; w r i t e e n t r y mode (80 h ) t o t h e i n s t r u c t i o n r e g i s t e r o f d i s p l a y
101 ; delay a f t e r write of r e s e t address counter
102 LALK 0500 h ; Load 400 (=190h ) t o a c c u m u l a t o r which c o r r e s p o n d s t o 40 us d e l a y (100 ns ∗400 =
40 us )
103 SACL TIM ; l o a d t h e t i m e r r e g i s t e r w i t h 4 0 0 . Assumes page 0 i s s e l e c t e d .
104 DELAY8 : ZALS TIM ; Copies t h e c u r r e n t v a l u e o f TIM t o a c c u m u l a t o r . Assumes page 0 i s s e l e c t e d .
105 SUBK 05 h ; s u b t r a c t 9 from a c c u m u l a t o r . S i n c e TIM i s n o t r e a d e v e r y time i s d e c r e a s e s , i t
i s n e c e s s a r y t o i n t r o d u c e some margin
106 BGZ DELAY8 ; branch t o DELAY8 as l o n g as a c c u m u l a t o r v a l u e i s g r e a t e r tha n z e r o => TIM
g r e a t e r than 9 .
107 ; end o f i n i t i a l i z a t i o n
108 RET ; r e t u r n s from d i s p l a y i n i t .
109
110 ********************************************
111 * Display driver
112 * Writes a string to the display
113 * Use of function :
114 * 1) push address of string to stack ( lenght between 1 and 20 ASCII characters delimited with ’\n ’. The first
character has lowest address )
115 * 2) push line indent length to stack (0 to 19)
116 * 3) push line number to stack (1 to 4)
117 * Remember that the sum of the string length and line indent length should not exceed 20.
118 * The display driver does not return anything but changes the stack pointer to point at address of string
119 ********************************************
120 DISP_DRV :
121 ; r e t r i e v e l i n e number
122 MAR *- ; d a t a s t a c k p o i n t e r decremented i n o r d e r t o p o i n t a t t o p e l e m e n t
123 ; TOdS −> l i n e number
124 LAC *- ; pop l i n e number from s t a c k and copy i t t o t h e a c c u m u l a t o r
125 ; TOdS −> l i n e i n d e n t
126 ; d e t e r m i n e l i n e number s t a r t a d d r e s s
127 DISP_LINE1 :
128 SUBK 01 h ; s u b t r a c t one from l i n e number
129 BGZ DISP_LINE2 ; branch i f a c c u m u l a t o r i s g r e a t e r than z e r o
130 LACK 0h ; s e t a c c u m u l a t o r t o 0h ( a d d r e s s o f f i r s t c h a r a c t e r i n l i n e 1)
131 B DISP_INDENT ; branch t o i n d e n t i o n
132 DISP_LINE2 :
133 SUBK 01 h ; s u b t r a c t one from l i n e number
134 BGZ DISP_LINE3 ; branch i f a c c u m u l a t o r i s g r e a t e r than z e r o
135 LACK 040 h ; s e t a c c u m u l a t o r t o 40 h ( a d d r e s s o f f i r s t c h a r a c t e r i n l i n e 2 )
136 B DISP_INDENT ; branch t o i n d e n t i o n
137 DISP_LINE3 :
138 SUBK 01 h ; s u b t r a c t one from l i n e number
163

139 BGZ DISP_LINE4 ; branch i f a c c u m u l a t o r i s g r e a t e r than z e r o


140 LACK 014 h ; s e t a c c u m u l a t o r t o 10 h ( a d d r e s s o f f i r s t c h a r a c t e r i n l i n e 3 )
164

O Source Code
141 B DISP_INDENT ; branch t o i n d e n t i o n
142 DISP_LINE4 :
143 LACK 054 h ; s e t a c c u m u l a t o r t o 50 h ( a d d r e s s o f f i r s t c h a r a c t e r i n l i n e 4 )
144 ; d e t e r m i n e l i n e i n d e n t i o n
145 DISP_INDENT :
146 ADD * ; pop d i s p l a y l i n e i n d e n t from s t a c k and add i t t o a d d r e s s o f t h e s e l e c t e d l i n e
number . The a d d r e s s i s a l r e a d y i n t h e a c c u m u l a t o r .
147 ; TOdS −> l i n e i n d e n t
148 ADDK 080 h ; b i t 7 must be s e t t o one i n o r d e r t o s e t t h e a d d r e s s c o u n t e r
149 ; s e t a d d r e s s c o u n t e r o f d i s p l a y
150 SACL * ; push v a l u e o f a d d r e s s c o u n t e r t o s t a c k . The l i n e i n d e n t v a l u e i s o v e r w r i t t e n .
151 ; TOdS −> a d d r e s s c o u n t e r
152 OUT * , IR_DISP ; s e t address counter of d i s p l a y
153 ; TOdS −> a d d r e s s c o u n t e r
154 ; delay a f t e r write of address to display
155 LALK 0200 h ; Load 400 (=190h ) t o a c c u m u l a t o r which c o r r e s p o n d s t o 40 us d e l a y (100 ns ∗400 =
40 us )
156 SACL TIM ; l o a d t h e t i m e r r e g i s t e r w i t h 4 0 0 . Assumes page 0 i s s e l e c t e d .
157 DELAY9 : ZALS TIM ; Copies t h e c u r r e n t v a l u e o f TIM t o a c c u m u l a t o r . Assumes page 0 i s s e l e c t e d .
158 SUBK 05 h ; s u b t r a c t 5 from a c c u m u l a t o r . S i n c e TIM i s n o t r e a d e v e r y time i s d e c r e a s e s , i t
i s n e c e s s a r y t o i n t r o d u c e some margin
159 BGZ DELAY9 ; branch t o DELAY9 as l o n g as a c c u m u l a t o r v a l u e i s g r e a t e r tha n z e r o => TIM
g r e a t e r than 9 .
160 ; w r i t e s t r i n g t o d i s p l a y
161 SAR AR5 ,* - ; push c o n t e n t s o f AR5 t o s t a c k . P r e v e n t s d e s t r u c t i o n o f p o s s i b l e d a t a i n
r e g i s t e r t h a t w i l l be used by t h e d i s p l a y d r i v e r
162 ; TOdS −> a d d r e s s o f s t r i n g
163 LAR AR5 ,*+ ,5 ; pop t h e a d d r e s s o f s t r i n g t o AR5 and i n c r e m e n t s t a c k p o i n t e r . The l a s t argument
l o a d s 6 i n t o ARP ( aux r e g i s t e r p o i n t e r ) .
164 ; TOdS −> o l d AR5
165 ; AR5 −> f i r s t c h a r o f s t r i n g
166 DISP_WRITE :
167 LAC * ; l o a d a c h a r a c t e r from s t r i n g i n t o a c c u m u l a t o r
168 BZ DISP_END ; t h e w h o l e s t r i n g has been w r i t t e n i f t h e n u l l c h a r a c t e r i s meet . Goto end o f
display driver
169 OUT *+ , DR_DISP ; w r i t e char to d i s p l a y
170 ; AR5 −> n e x t c h a r o f s t r i n g
171 ; d e l a y a f t e r w r i t e o f char to d i s p l a y
172 LALK 0200 h ; Load 400 (=190h ) t o a c c u m u l a t o r which c o r r e s p o n d s t o 40 us d e l a y (100 ns ∗400 =
40 us )
173 SACL TIM ; l o a d t h e t i m e r r e g i s t e r w i t h 4 0 0 . Assumes page 0 i s s e l e c t e d .
174 DELAYA : ZALS TIM ; Copies t h e c u r r e n t v a l u e o f TIM t o a c c u m u l a t o r . Assumes page 0 i s s e l e c t e d .
175 SUBK 05 h ; s u b t r a c t 5 from a c c u m u l a t o r . S i n c e TIM i s n o t r e a d e v e r y time i s d e c r e a s e s , i t
i s n e c e s s a r y t o i n t r o d u c e some margin
176 BGZ DELAYA ; branch t o DELAYA as l o n g as a c c u m u l a t o r v a l u e i s g r e a t e r tha n z e r o => TIM
g r e a t e r than 9 .
177 B DISP_WRITE ; branch t o DISP_STRING t o w r i t e t h e n e x t c h a r
178 ; r e s t o r e o f s t a c k p o i n t e r and AR5
179 DISP_END :
180 LARP AR7 ; s e t t h e ARP ( aux r e g i s t e r p o i n t e r ) t o 7
181 LAR AR5 ,* - ; pop o l d AR5 from s t a c k . This r e s t o r e s AR5 .
182 ; TOdS −> a d d r e s s o f s t r i n g
183 ; end o f d i s p l a y d r i v e r
184 RET ; r e t u r n from d i s p l a y d r i v e r
185 ********************************************
186 * Display test
187 * Writes :
188 * line 1: Hello World !
189 * line 2: Hello World !
190 * line 3: Hello World !
191 * line 4: Hello World !
192 * to the display .
193 * Requires no input arguments
194 * Returns no output argument
195 * Uses 60 h to 6 Ch to store the string ’ Hello world !\ n ’ and AR5 as pointer .
196 * Data in those places will be destroyed
197 ********************************************
198 DISP_TEST :
199 ; s e t u p AR5 as p o i n t e r t o t h e s t r i n g . S t o r e t h e f i r s t a d d r e s s on t h e s t a c k as r e q u i r e d by t h e d i s p l a y d r i v e r .
200 LALK 60 h ; load the accumulator with the address of the f i r s t characte r in the s t r i n g
201 SACL * ; push 60 h onto s t a c k
202 ; TOdS −> 60 h ( a d d r e s s o f b e g i n n i n g o f s t r i n g )
203 LAR AR5 ,*+ ,5 ; copy 60 h i n t o AR5 and s e t ARP => AR5
204 ; store string
205 LALK ’H ’
206 SACL *+ ; s t o r e ’H’ on 60 h
207 LALK ’e ’
208 SACL *+ ; s t o r e ’ e ’ on 61 h
209 LALK ’l ’
210 SACL *+ ; s t o r e ’ ’ on 62 h
211 LALK ’l ’
212 SACL *+ ; s t o r e ’ l ’ on 63 h
213 LALK ’o ’
214 SACL *+ ; s t o r e ’ o ’ on 64 h
215 LALK ’ ’
216 SACL *+ ; s t o r e ’ ’ on 65 h
165

217 LALK ’W ’
218 SACL *+ ; s t o r e ’W’ on 66 h
166

O Source Code
219 LALK ’o ’
220 SACL *+ ; s t o r e ’ o ’ on 67 h
221 LALK ’r ’
222 SACL *+ ; s t o r e ’ r ’ on 68 h
223 LALK ’l ’
224 SACL *+ ; s t o r e ’ l ’ on 69 h
225 LALK ’d ’
226 SACL *+ ; s t o r e ’ d ’ on 6Ah
227 LALK ’! ’
228 SACL *+ ; store ’ ! ’ on 6Bh
229 LALK ’’
230 SACL * ,0 ,7 ; store ’ ’ ( end o f s t r i n g \0) on 6Ch . S h i f t = 0 . S e t ARP −> AR7 ( s t a c k p o i n t e r )
231 ; write line 1
232 LALK 0 ; load l i n e indent = 0 to accumulator
233 SACL *+ ; push l i n e i n d e n t onto s t a c k
234 ; TOdS−1 −> l i n e i n d e n t
235 LALK 1 ; l o a d w i t h l i n e number
236 SACL *+ ; push l i n e number onto s t a c k
237 ; TOdS−1 −>l i n e number
238 CALL DISP_DRV ; write line 1
239 ; TOdS −> a d d r e s s o f s t r i n g
240 ; write line 2
241 MAR *+ ; add one t o s t a c k p o i n t e r
242 ; TOdS−1 −> a d d r e s s o f s t r i n g
243 LALK 1 ; load l i n e indent = 1 to accumulator
244 SACL *+ ; push l i n e i n d e n t onto s t a c k
245 ; TOdS−1 −> l i n e i n d e n t
246 LALK 2 ; l o a d w i t h l i n e number
247 SACL *+ ; push l i n e number onto s t a c k
248 ; TOdS−1 −>l i n e number
249 CALL DISP_DRV ; write line 2
250 ; TOdS −> a d d r e s s o f s t r i n g
251 ; write line 3
252 MAR *+ ; add one t o s t a c k p o i n t e r
253 ; TOdS−1 −> a d d r e s s o f s t r i n g
254 LALK 2 ; load l i n e indent = 1 to accumulator
255 SACL *+ ; push l i n e i n d e n t onto s t a c k
256 ; TOdS−1 −> l i n e i n d e n t
257 LALK 3 ; l o a d w i t h l i n e number
258 SACL *+ ; push l i n e number onto s t a c k
259 ; TOdS−1 −>l i n e number
260 CALL DISP_DRV ; write line 2
261 ; TOdS −> a d d r e s s o f s t r i n g
262 ; write line 4
263 MAR *+ ; add one t o s t a c k p o i n t e r
264 ; TOdS−1 −> a d d r e s s o f s t r i n g
265 LALK 3 ; load l i n e indent = 1 to accumulator
266 SACL *+ ; push l i n e i n d e n t onto s t a c k
267 ; TOdS−1 −> l i n e i n d e n t
268 LALK 4 ; l o a d w i t h l i n e number
269 SACL *+ ; push l i n e number onto s t a c k
270 ; TOdS−1 −>l i n e number
271 CALL DISP_DRV ; write line 2
272 ; TOdS −> a d d r e s s o f s t r i n g
273 ; end o f d i s p l a y t e s t s u b r o u t i o n e . Return
274 RET ; r e t u r n from d i s p l a y t e s t
167
168

O Source Code
Source Code for Echo and Delay
1 ********************************************
2 * filename : echo_delay . asm
3 * creator : jkjaer
4 * generated : May 8 th 2007
5 *
6 * This file contains the delay and echo effects
7 *
8 * references :
9 * [ aug ] TMS320C1X / C2X / C2XX / C5X Assembly language tools Texas Instruments
10 * [ ug ] TMS320C2X user ’ s guide Texas Instruments
11 * [D/M] Debugger / monitor Sofus Birkedal Nielsen
12 ********************************************
13
14 ; Effect settings
15 E_GAIN . equ 6120 h ; Address o f g a i n f a c t o r ( from 0 t o 1)
16 E_DELAY . equ 6110 h ; Delay l e n g t h ( from 0 t o 600 ms)
17 ; Constants f o r c i r c u l a r buffer
18 EIN_ADD . equ 6100 h ; P o i n t e r t o c i r c u l a r b u f f e r i n p u t . Must a l w a y s be s e t s t a r t o f memory a r e a 4
F30h d u r i n g i n i t .
19 EOUT_ADD . equ 6101 h ; Pointer to c i r c u l a r b u f f e r output .
20 ESOD_ADD . equ 6102 h ; S t a r t o f B u f f e r Address
21 EEOD_ADD . equ 6103 h ; End o f B u f f e r Address
22 ESCALE . equ 6104 h ; Scale factor
23 DSCALE . equ 6105 h ; Scale factor
24 ESOD . equ 6238 h ; Start of Buffer
25 EEOD . equ 8 FFFh ; End o f B u f f e r
26
27 ; B u f f e r runs from 6238 −−> 8FFF
28
29 E_INIT :
30 ; Delay Length T a b l e
31 E_DELAY_TABLE :
32 ; s e t u p AR5 as p o i n t e r t o t h e s t r i n g . S t o r e t h e f i r s t a d d r e s s on t h e s t a c k as r e q u i r e d by t h e d i s p l a y d r i v e r .
33 LALK E_DELAY ; load the accumulator with the address of the f i r s t characte r in the s t r i n g
34 SACL * ; push 6110 h onto s t a c k
35 ; TOdS −> 60 h ( a d d r e s s o f b e g i n n i n g o f s t r i n g )
36 LAR AR5 ,*+ ,5 ; copy 6110 h i n t o AR5 and s e t ARP => AR5
37 ; store string
38 LALK 29 F6h
39 SACL *+ ; s t o r e 50 ms = 29F6h on 6110 h
40 LALK 2625 h
41 SACL *+ ; s t o r e 100 ms = 2625 h on 6111 h
42 LALK 2255 h
43 SACL *+ ; s t o r e 150 ms = 2255 h on 6112 h
44 LALK 1 E84h
45 SACL *+ ; s t o r e 200 ms = 1E84h on 6113 h
46 LALK 1 AB4h
47 SACL *+ ; s t o r e 250 ms = 1AB4h on 6114 h
48 LALK 16 E3h
49 SACL *+ ; s t o r e 300 ms = 16E3h on 6115 h
50 LALK 1313 h
51 SACL *+ ; s t o r e 350 ms = 1313 h on 6116 h
52 LALK 0 F42h
53 SACL *+ ; s t o r e 400 ms = 0F42h on 6117 h
54 LALK 0 B71h
55 SACL *+ ; s t o r e 450 ms = 0B71h on 6118 h
56 LALK 07 A1h
57 SACL *+ ; s t o r e 500 ms = 07A1h on 6119 h
58 LALK 03 D0h
59 SACL *+ ; s t o r e 550 ms = 03D0h on 611Ah
60 LALK 0004 h
61 SACL * ,0 ,7 ; s t o r e 600 ms = 0004 h on 611Bh . S h i f t = 0 . S e t ARP −> AR7 ( s t a c k p o i n t e r )
62
63 E_GAIN_TABLE :
64 ; s e t u p AR5 as p o i n t e r t o t h e s t r i n g . S t o r e t h e f i r s t a d d r e s s on t h e s t a c k as r e q u i r e d by t h e d i s p l a y d r i v e r .
65 LALK E_GAIN ; load the accumulator with the address of the f i r s t characte r in the s t r i n g
66 SACL * ; push 6210 h onto s t a c k
67 ; TOdS −> 60 h ( a d d r e s s o f b e g i n n i n g o f s t r i n g )
68 LAR AR5 ,*+ ,5 ; copy 6210 h i n t o AR5 and s e t ARP => AR5
69 ; s t o r e s t r i n g
70 LALK 0000 h
71 SACL *+ ; s t o r e 0 ,0 x = 0000 h on 6210 h
72 LALK 0 CCCh
73 SACL *+ ; s t o r e 0 ,1 x = 0CCCh on 6211 h
74 LALK 1999 h
75 SACL *+ ; s t o r e 0 ,2 x = 1999 h on 6212 h
76 LALK 2666 h
77 SACL *+ ; s t o r e 0 ,3 x = 2666 h on 6213 h
78 LALK 3333 h
79 SACL *+ ; s t o r e 0 ,4 x = 3333 h on 6214 h
80 LALK 4000 h
81 SACL *+ ; s t o r e 0 ,5 x = 4000 h on 6215 h
82 LALK 4 CCCh
169

83 SACL *+ ; s t o r e 0 ,6 x = 4CCCh on 6216 h


84 LALK 5999 h
170

O Source Code
85 SACL *+ ; s t o r e 0 ,7 x = 5999 h on 6217 h
86 LALK 6666 h
87 SACL *+ ; s t o r e 0 ,8 x = 6666 h on 6218 h
88 LALK 7333 h
89 SACL * ,0 ,7 ; s t o r e 0 ,9 x = 7333 h on 6219 h . S h i f t = 0 . S e t ARP −> AR7 ( s t a c k p o i n t e r )
90
91 ; I n i t i a l i z a t i o n of Scale factor
92 LARP 5 ; Load AR5
93 LALK 4 CCDh ; m u l t i p l y i n p u t sample w i t h s c a l e f a c t o r 0 ,6 = 4CCDh.
94 LRLK AR5 ,6104 h ; Load AR5
95 SACL * ; S t o r e 4CCDh i n ESCALE
96 LALK 63 D7h ; m u l t i p l y i n p u t sample w i t h s c a l e f a c t o r 0 ,78 = 63D7h .
97 LRLK AR5 ,6105 h ; Load AR5
98 SACL * ,0 ,7 ; S t o r e 63D7h i n DSCALE
99 ; The d i f f e r e n t P o i n t e r s must c o n t a i n t h e a d d r e s s o f t h e p l a c e i n t h e b u f f e r t o which t h e y a r e p o i n t i n g .
100 ; I n i t i a l i z a t i o n o f t h e b u f f e r . Here t h e b u f f e r i s f i l l e d w i t h z e r o e s .
101 LRLK AR0 , EEOD ; AR0 i s l o a d e d w i t h t h e a d d r e s s o f t h e b u f f e r end .
102 LRLK AR4 , ESOD ; AR4 i s l o a d e d w i t h t h e a d d r e s s o f t h e b u f f e r b e g i n n i n g .
103 LARP AR4 ; The ARP i s now p o i n t i n g a t AR4 .
104 ZAC ; The Accumulator i s now l o a d e d w i t h z e r o .
105 E_CLR_BUFF : SACL *+ ; The z e r o i n t h e a c c u m u l a t o r i s s t o r e d i n t h e a d d r e s s ARP p o i n t s t o ( Address
i n AR4) .
106 CMPR 0 ; I f t h e a d d r e s s i n AR4 = AR0 ( opcode 0) t h e c o n t r o l b i t TC = 1 , e l s e TC = 0 .
107 BBZ E_CLR_BUFF ; I f TC = 0 c l e a r t h e n e x t a d d r e s s . The r o u t i n e w i l l s t o p once a l l a d d r e s s e s
in the b u f f e r contains zeros .
108 SACL * ; clear the l a s t address
109 ; i n i t i a l i z e pointers
110 LDPK 194 ; s e t page p o i n t e r t o 194
111 LALK ESOD ; s t o r e s t a r t address of b u f f e r to accmulator
112 SACL ESOD_ADD ; save address to pointer address
113 SACL EOUT_ADD ; save address to output pointer
114 LALK EEOD ; s t o r e end a d d r e s s o f b u f f e r t o a c c m u l a t o r
115 SACL EEOD_ADD ; save address to pointer address
116 SACL EIN_ADD ; save address to input pointer
117 ; end o f i n i t i a l i z a t i o n
118 ; LDPK 8 ; s e t page p o i n t e r t o 8
119 ; LALK 3000 h ; l o a d 6000 h t o acc
120 ; SACL E_GAIN ; s e t gain to 0.8
121 ; LALK 0004 h ; l o a d 0FFF t o acc
122 ; SACL E_DELAY ; s e t d e l a y t o 400 ms
123 LARP 7 ;ARP −> AR7
124 LDPK 0 ; s e t page p o i n t e r t o 0
125 RET ; r e t u r n from i n i t
126
127 ********************************************
128 * Delay Effect
129 *
130 * Use of function :
131 * 1) push Input sample to stack
132 * Returns : Overwrites input sample with Output sample . Stack pointer points at output element
133 ********************************************
134 DELAY :
135 LDPK 194 ; change t o page 194
136 ; Load p o i n t e r s t o c i r c u l a r b u f f e r i n t o AR2 and AR3
137 LAC EIN_ADD ; copy a d d r e s s o f i n p u t p o i n t e r t o c i r c u l a r b u f f e r t o a c c u m u l a t o r
138 SACL * ; push t o s t a c k
139 LAR AR2 ,* ; s t o r e a d d r e s s o f i n p u t p o i n t e r t o c i r c u l a r b u f f e r t o AR2
140 LAC EOUT_ADD ; copy a d d r e s s o f o u t p u t p o i n t e r t o c i r c u l a r b u f f e r t o a c c u m u l a t o r
141 SACL * ; push t o s t a c k
142 LAR AR3 ,* - ; s t o r e a d d r e s s o f o u t p u t p o i n t e r t o c i r c u l a r b u f f e r t o AR3
143 ; dSP −> i n p u t sample
144 ; s c a l e and s a v e i n p u t sample t o c i r c u l a r b u f f e r
145 LT * ,5 ; l o a d T−r e g i s t e r w i t h i n p u t sample which i s popped from s t a c k
146 MPY DSCALE ; m u l t i p l y i n p u t sample w i t h s c a l e f a c t o r . r e s u l t i s s t o r e d i n P
147 PAC ; Copy c o n t e n t s o f P−r e g i s t e r t o a c c u m u l a t o r
148 SFL ; l e f t s h i f t a c c u m u l a t o r one b i t
149 LARP 7 ; s e t ARP −> AR7
150 SACH * ; Push s c a l e d i n p u t sample t o s t a c k
151 LAC *+ ,0 ,2 ; copy i n p u t sample t o a c c u m u l a t o r
152 ; dSP−1 −> i n p u t sample
153 ; AR2 −> i n p u t a d d r e s s o f c i r c u l a r b u f f e r
154 SACL * ,0 ,4 ; s a v e i n p u t sample t o b u f f e r .
155 ;ARP −> AR7
156 ; Fetch t h e d e l a y e d sample from t h e s t a c k and m u l t i p l y w i t h Gain f a c t o r
157 LDPK 101 ; change t o page 101
158 LAR AR4 , M_ECPA ; load delay l e n g t h to accumulator
159 LAC * ,0 ,7
160 SACL *+ ,0 ,4 ; push d e l a y l e n g t h t o d a t a s t a c k
161 ; dSP−1 −> d e l a y l e n g t h a d d r e s s
162 LDPK 102
163 LAR AR4 , M_ECPB ; load gain to accumulator
164 LAC * ,0 ,7 ; push g a i n t o s t a c k
165 SACL*
166 ; dSP − > g a i n f a c t o r
167 LT * - ,3 ; l o a d T−r e g i s t e r w i t h g a i n f a c t o r which i s popped from s t a c k
168 ; dSP −> d e l a y l e n g t h
171

169 ; AR3 −> a d d r e s s o f o u t p u t o f c i r c u l a r b u f f e r


172

O Source Code
170 MPY * - ,7 ; m u l t i p l y d e l a y e d i n p u t sample w i t h g a i n f a c t o r . Decrement o u t p u t p o i n t e r i n
buffer .
171 ;ARP −> AR7
172 ; Add i n p u t sample w i t h d e l a y e d and s c a l e d sample
173 MAR *- ; decrement s t a c k p o i n t e r t o p o i n t a t i n p u t sample
174 ; dSP −> i n p u t sample
175 LAC * ,15 ; l o a d a c c u m u l a t o r w i t h i n p u t sample .
176 APAC ; add i n p u t sample w i t h c o n t e n t s o f P−r e g i s t e r
177 SFL ; l e f t s h i f t a c c u m u l a t o r one b i t
178 ; s t o r e o u t p u t sample
179 SACH *+ ; push o u t p u t sample t o s t a c k
180 ; dSP −> d e l a y l e n g t h
181 ; update b u f f e r
182 LDPK 194 ; change t o page 194
183 SAR AR3 , EOUT_ADD ; s t o r e new o u t p u t p o i n t e r a d d r e s s t o c i r c u l a r b u f f e r
184 LAR AR0 , ESOD_ADD ; s t o r e a d d r e s s o f s t a r t p o i n t e r t o c i r c u l a r b u f f e r t o AR0
185 LARP 3 ;ARP −> AR3
186 CMPR 1 ; i s c o n t e n t s o f AR0 g r e a t e r than AR3? I f yes , t h e n TC=1
187 BBZ E_UPIN ; i f TC=1, r e s e t o u t p u t p o i n t e r
188 LALK EEOD ; l o a d a c c u m u l a t o r w i t h bottom o f b u f f e r w i t h s i g n e x t e n s i o n s u p p r e s s e d
189 SACL EOUT_ADD ; s e t o u t p u t t o bottom o f b u f f e r
190 E_UPIN : LARP 7 ; set a u x i l l e r y r e g i s t e r pointer to 7
191 LAC * ; load accumulator with delay l e n g t h
192 SAR AR3 ,* ; push a d d r e s s o f o u t p u t p o i n t e r t o c i r c u l a r b u f f e r onto s t a c k
193 ADDS *- ; add a d d r e s s o f o u t p u t p o i n t e r t o c i r c u l a r b u f f e r t o d e l a y l e n g t h
194 ; dSP −> o u t p u t sample
195 SACL EIN_ADD ; copy new a d d r e s s o f i n p u t p o i n t e r t o c i r c u l a r b u f f e r t o EIN_ADD
196 SUBS EEOD_ADD ; s u b t r a c t a d d r e s s o f bottom o f b u f f e r
197 BLZ E_END ; branch t o end o f d e l a y ;
198 ADDS ESOD_ADD ; add s t a r t o f a d d r e s s o f b u f f e r t o new i n p u t p o i n t e r
199 SACL EIN_ADD ; copy new a d d r e s s o f i n p u t p o i n t e r t o c i r c u l a r b u f f e r t o EIN_ADD
200 ; end o f echo r o u t i n e
201 E_END : LDPK 0 ; s e t d a t a page p o i n t e r t o 0
202 RET ; r e t u r n from s u b r o u t i n e
203
204
205
206 ********************************************
207 * Echo Effect
208 *
209 * Use of function :
210 * 1) push Input sample to stack
211 * Returns : Overwrites input sample with Output sample . Stack pointer points at output element
212 ********************************************
213 ECHO :
214 LDPK 194 ; change t o page 194
215 ; Load p o i n t e r s t o c i r c u l a r b u f f e r i n t o AR2 and AR3
216 LAC EIN_ADD ; copy a d d r e s s o f i n p u t p o i n t e r t o c i r c u l a r b u f f e r t o a c c u m u l a t o r
217 SACL * ; push t o s t a c k
218 LAR AR2 ,* ; s t o r e a d d r e s s o f i n p u t p o i n t e r t o c i r c u l a r b u f f e r t o AR2
219 LAC EOUT_ADD ; copy a d d r e s s o f o u t p u t p o i n t e r t o c i r c u l a r b u f f e r t o a c c u m u l a t o r
220 SACL * ; push t o s t a c k
221 LAR AR3 ,* - ; s t o r e a d d r e s s o f o u t p u t p o i n t e r t o c i r c u l a r b u f f e r t o AR3
222 ; dSP −> i n p u t sample
223 ; s a v e i n p u t sample t o c i r c u l a r b u f f e r
224 LT * ,5 ; l o a d T−r e g i s t e r w i t h i n p u t sample which i s popped from s t a c k
225 MPY ESCALE ; m u l t i p l y i n p u t sample w i t h s c a l e f a c t o r . r e s u l t i s s t o r e d i n P
226 PAC ; Copy c o n t e n t s o f P−r e g i s t e r t o a c c u m u l a t o r
227 SFL ; l e f t s h i f t a c c u m u l a t o r one b i t
228 LARP 7 ; s e t ARP −> AR7
229 SACH * ; Push s c a l e d i n p u t sample t o s t a c k
230 MAR *+ ,4 ; copy i n p u t sample t o a c c u m u l a t o r
231 ; dSP−1 −> i n p u t sample
232 ;ARP −> AR7
233 ; Fetch t h e d e l a y e d sample from t h e s t a c k and m u l t i p l y w i t h Gain f a c t o r
234 LDPK 101 ; change t o page 8
235 LAR AR4 , M_ECPA
236 LAC * ,0 ,7 ; load delay l e n g t h to accumulator
237 SACL *+ ,0 ,4 ; push d e l a y l e n g t h t o d a t a s t a c k
238 ; dSP−1 −> d e l a y l e n g t h a d d r e s s
239 LDPK 102
240 LAR AR4 , M_ECPB ; load gain to accumulator
241 LAC * ,0 ,7
242 SACL * ; push g a i n t o s t a c k
243 ; dSP − > g a i n f a c t o r
244 LT * - ,3 ; l o a d T−r e g i s t e r w i t h g a i n f a c t o r which i s popped from s t a c k
245 ; dSP −> d e l a y l e n g t h
246 ; AR3 −> a d d r e s s o f o u t p u t o f c i r c u l a r b u f f e r
247 MPY * - ,7 ; m u l t i p l y d e l a y e d i n p u t sample w i t h g a i n f a c t o r . Decrement o u t p u t p o i n t e r i n
buffer .
248 ;ARP −> AR7
249 ; Add i n p u t sample w i t h d e l a y e d and s c a l e d sample
250 MAR *- ; decrement s t a c k p o i n t e r t o p o i n t a t i n p u t sample
251 ; dSP −> i n p u t sample
252 LAC * ,15 ; l o a d a c c u m u l a t o r w i t h i n p u t sample .
253 APAC ; add i n p u t sample w i t h c o n t e n t s o f P−r e g i s t e r
173

254 SFL ; l e f t s h i f t a c c u m u l a t o r one b i t


255 ; s t o r e o u t p u t sample
174

O Source Code
256 LARP 2
257 MAR *+ ; copy i n p u t sample t o a c c u m u l a t o r
258 ; dSP−1 −> i n p u t sample
259 ; AR2 −> i n p u t a d d r e s s o f c i r c u l a r b u f f e r
260 SACH * ,0 ,7 ; s a v e o u t p u t sample t o b u f f e r .
261 SACH *+ ; push o u t p u t sample t o s t a c k
262 ; dSP −> d e l a y l e n g t h
263 ; update b u f f e r
264 LDPK 194 ; change t o page 194
265 SAR AR3 , EOUT_ADD ; s t o r e new o u t p u t p o i n t e r a d d r e s s t o c i r c u l a r b u f f e r
266 LAR AR0 , ESOD_ADD ; s t o r e a d d r e s s o f s t a r t p o i n t e r t o c i r c u l a r b u f f e r t o AR0
267 LARP 3 ;ARP −> AR3
268 CMPR 1 ; i s c o n t e n t s o f AR0 g r e a t e r than AR3? I f yes , t h e n TC=1
269 BBZ E_EUPIN ; i f TC=1, r e s e t o u t p u t p o i n t e r
270 LALK EEOD ; l o a d a c c u m u l a t o r w i t h bottom o f b u f f e r w i t h s i g n e x t e n s i o n s u p p r e s s e d
271 SACL EOUT_ADD ; s e t o u t p u t t o bottom o f b u f f e r
272 E_EUPIN : LARP 7 ; set a u x i l l e r y r e g i s t e r pointer to 7
273 LAC * ; load accumulator with delay l e n g t h
274 SAR AR3 ,* ; push a d d r e s s o f o u t p u t p o i n t e r t o c i r c u l a r b u f f e r onto s t a c k
275 ADDS *- ; add a d d r e s s o f o u t p u t p o i n t e r t o c i r c u l a r b u f f e r t o d e l a y l e n g t h
276 ; dSP −> o u t p u t sample
277 SACL EIN_ADD ; copy new a d d r e s s o f i n p u t p o i n t e r t o c i r c u l a r b u f f e r t o EIN_ADD
278 SUBS EEOD_ADD ; s u b t r a c t a d d r e s s o f bottom o f b u f f e r
279 BLZ E_EEND ; branch t o end o f d e l a y ;
280 ADDS ESOD_ADD ; add s t a r t o f a d d r e s s o f b u f f e r t o new i n p u t p o i n t e r
281 SACL EIN_ADD ; copy new a d d r e s s o f i n p u t p o i n t e r t o c i r c u l a r b u f f e r t o EIN_ADD
282 ; end o f echo r o u t i n e
283 E_EEND : LDPK 0 ; s e t d a t a page p o i n t e r t o 0
284 RET ; r e t u r n from s u b r o u t i n e
Source Code for effect Handler
1 *******************************************
2 * filename : effect_handler . asm
3 * creator : jkjaer
4 * generated : May 8 th 2007
5 *
6 * This is the effect handler which load the different effects in the correct order
7 *
8 * references :
9 * [ aug ] TMS320C1X / C2X / C2XX / C5X Assembly language tools Texas Instruments
10 * [ ug ] TMS320C2X user ’ s guide Texas Instruments
11 * [D/M] Debugger / monitor Sofus Birkedal Nielsen
12 ********************************************
13 ********************************************
14 * Effect handler
15 * Requires no input arguments
16 * Returns no output argument
17 ********************************************
18 EFF_HAND :
19 *
20 * Load received serial data
21 *
22 LDPK 0 ; c h o o s e page 0 from which DRR i s r e a d
23 LAC DRR ; copy c o n t e n t s o f d a t a r e c e i v e r e g i s t e r t o l o w e r a c c u m u l a t o r − assumes page 0 i s
selected
24 SACL *+ ; push c o n t e n t s o f c o p i e d d a t a r e c e i v e r e g i s t e r t o s t a c k
25
26 ; TOdS−1 −> copy o f DRR c o n t e n t s
27 *
28 * Call the correct effects in the right order
29 *
30 ;CALL EQUALIZER
31 LDPK 14
32 LAC M_ESA
33 CALA
34
35 MAR *+
36 LDPK 14
37 LAC M_ESB
38 CALA
175

39
40 MAR *+
176

O Source Code
41 LDPK 14
42 LAC M_ESC
43 CALA
44
45 LDPK 0
46 ; dSP −> o u t p u t sample
47 *
48 * Send tweaked signal
49 *
50 LAC * ; pop t w e a k e d s i g n a l from s t a c k and move i t t o a c c u m u l a t o r
51 SACL DXR ; move t w e a k e d s i g n a l t o d a t a t r a n s m i t r e g i s t e r − assumes page 0 i s s e l e c t e d
52 *
53 * Return
54 *
55 RET
56 NOEFFECT :
57 MAR *-
58 RET ; r e t u r n from s u b r o u t i n e
Source Code for Equalizer
1 ********************************************
2 * filename : equalizer . asm
3 * creator : jesperrj
4 * generated : May 15 th 2007
5 *
6 * This file contains the equalizer effect
7 *
8 * references :
9 * [ aug ] TMS320C1X / C2X / C2XX / C5X Assembly language tools Texas Instruments
10 * [ ug ] TMS320C2X user ’ s guide Texas Instruments
11 * [D/M] Debugger / monitor Sofus Birkedal Nielsen
12 ********************************************
13
14 Q_LPBS . equ 4031 h ; Start a d r e s s o f b−c o e f f i c i e n t s f o r LP f i l t e r
15 Q_BPBS . equ 404 Ah ; Start a d r e s s o f b−c o e f f i c i e n t s f o r BP f i l t e r
16 Q_HPBS . equ 4063 h ; Start a d r e s s o f b−c o e f f i c i e n t s f o r HP f i l t e r
17 Q_AS . equ 407 Ch ; Start a d d r e s s o f a−c o e f f i c i e n t s
18
19 Q_XDONE . equ 3 C80h ; address of x [ n−1]
20 Q_XDTWO . equ 3 C81h ; address of x [ n−2]
21 Q_YLPDONE . equ 3 C82h ; address of y [ n−1] f o r LP f i l t e r
22 Q_YBPDONE . equ 3 C83h ; address of y [ n−1] f o r BP f i l t e r
23 Q_YBPDTWO . equ 3 C84h ; address of y [ n−2] f o r BP f i l t e r
24 Q_YHPDONE . equ 3 C85h ; address of y [ n−1] f o r HP f i l t e r
25 Q_LPNEWY . equ 3 C86h ; address of y [ n ] f o r LP f i l t e r
26 Q_BPNEWY . equ 3 C87h ; address of y [ n ] f o r BP f i l t e r
27 Q_HPNEWY . equ 3 C88h ; address of y [ n ] f o r HP f i l t e r
28 Q_ZERO . equ 3 C89h ; address of a zero value
29 ;Q_XDTWOBP . equ 3C8Ah
30
31 ;M_EQPA . equ 0280 h ; a d d r e s s o f p o i n t e r t o LP b−c o e f f i c i e n t s
32 ;M_EQPB . equ 0300 h ; a d d r e s s o f p o i n t e r t o BP b−c o e f f i c i e n t s
33 ;M_EQPC . equ 0380 h ; a d d r e s s o f p o i n t e r t o HP b−c o e f f i c i e n t s
34
35 Q_INIT :
36 ; I n i t i a l i z e s o l d i n p u t and o u t p u t s a m p l e s t o 0
37
38 LDPK 121 ; Changes page t o page 121
39 ZAC ; Resets accumulator to 0
177

40 LRLK AR0 , Q_XDONE ; Loads AR0 w i t h a d d r e s s o f x [ n−1]


41 LARP AR0 ; S e t s ARP −> AR0
178

O Source Code
42 SACL *+ ; x [ n−1] = 0
43 SACL *+ ; x [ n−2] = 0
44 SACL *+ ; y [ n−1] _lp = 0
45 SACL *+ ; y [ n−1]_bp = 0
46 SACL *+ ; y [ n−2]_bp = 0
47 SACL * ; y [ n−1]_hp = 0
48 LRLK AR0 , Q_ZERO ; Loads AR0 w i t h a d d r e s s o f z e r o v a l u e
49 SACL * ; and s e t s t h e z e r o t o 0
50
51 ; I n i t i a l i z a t i o n o f c o e f f i c e n t t a b l e . A l l c o e f f i c i e n t s t o t h e e q u a l i z e r f i l t e r s a r e l o a d e d i n t o
52 ; t h e memory , s t a r t i n g from a d d r e s s 5366 h
53
54 ; LP− f i l t e r b−c o e f f i c i e n t s . According t o v a r i a n c e s c a l i n g t h e s e c o e f f i c i e n t s a r e s c a l e d w i t h a f a c t o r s =
1 . 1 2 4 4 5 7 0 9 2 7 4 4 0 4 . Q15 f o r m a t
55 LDPK 128 ; S e t page p o i n t e r t o 128
56 LRLK AR0 , Q_LPBS ; A0 i s l o a d e d w i t h t h e a d d r e s s o f t h e c o e f f i c i e n t t a b l e
57 LALK 07 DEh ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e 0 dB b−c o e f f i c e n t o f t h e LP− f i l t e r
58 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
59 LALK 0703 h ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −1 dB b−c o e f f i c e n t o f t h e LP− f i l t e r
60 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
61 LALK 0640 h ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −2 dB b−c o e f f i c e n t o f t h e LP− f i l t e r
62 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
63 LALK 0592 h ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −3 dB b−c o e f f i c e n t o f t h e LP− f i l t e r
64 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
65 LALK 04 F7h ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −4 dB b−c o e f f i c e n t o f t h e LP− f i l t e r
66 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
67 LALK 046 Ch ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −5 dB b−c o e f f i c e n t o f t h e LP− f i l t e r
68 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
69 LALK 03 F1h ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −6 dB b−c o e f f i c e n t o f t h e LP− f i l t e r
70 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
71 LALK 0383 h ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −7 dB b−c o e f f i c e n t o f t h e LP− f i l t e r
72 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
73 LALK 0322 h ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −8 dB b−c o e f f i c e n t o f t h e LP− f i l t e r
74 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
75 LALK 02 CAh ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −9 dB b−c o e f f i c e n t o f t h e LP− f i l t e r
76 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
77 LALK 027 Dh ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −10 dB b−c o e f f i c e n t o f t h e LP− f i l t e r
78 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
79 LALK 0238 h ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −11 dB b−c o e f f i c e n t o f t h e LP− f i l t e r
80 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
81 LALK 01 FAh ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −12 dB b−c o e f f i c e n t o f t h e LP− f i l t e r
82 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
83 LALK 01 C3h ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −13 dB b−c o e f f i c e n t o f t h e LP− f i l t e r
84 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
85 LALK 0192 h ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −14 dB b−c o e f f i c e n t o f t h e LP− f i l t e r
86 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
87 LALK 0166 h ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −15 dB b−c o e f f i c e n t o f t h e LP− f i l t e r
88 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
89 LALK 013 Fh ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −16 dB b−c o e f f i c e n t o f t h e LP− f i l t e r
90 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
91 LALK 011 Ch ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −17 dB b−c o e f f i c e n t o f t h e LP− f i l t e r
92 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
93 LALK 00 FEh ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −18 dB b−c o e f f i c e n t o f t h e LP− f i l t e r
94 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
95 LALK 00 E2h ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −19 dB b−c o e f f i c e n t o f t h e LP− f i l t e r
96 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
97 LALK 00 C9h ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −20 dB b−c o e f f i c e n t o f t h e LP− f i l t e r
98 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
99 LALK 00 B3h ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −21 dB b−c o e f f i c e n t o f t h e LP− f i l t e r
100 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
101 LALK 00 A0h ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −22 dB b−c o e f f i c e n t o f t h e LP− f i l t e r
102 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
103 LALK 008 Fh ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −23 dB b−c o e f f i c e n t o f t h e LP− f i l t e r
179

104 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s


incremented .
180

O Source Code
105 LALK 007 Fh ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −24 dB b−c o e f f i c e n t o f t h e LP− f i l t e r
106 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
107
108 ;BP − f i l t e r b−c o e f f i c i e n t s . According t o v a r i a n c e s c a l i n g t h e s e c o e f f i c i e n t s a r e s c a l e d w i t h a f a c t o r s =
1 . 1 2 4 4 5 7 0 9 2 7 4 4 0 4 . Q14 f o r m a t
109 LALK 08 F4h ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e 0 dB b−c o e f f i c e n t o f t h e BP− f i l t e r
110 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
111 LALK 07 FBh ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −1 dB b−c o e f f i c e n t o f t h e BP− f i l t e r
112 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
113 LALK 071 Dh ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −2 dB b−c o e f f i c e n t o f t h e BP− f i l t e r
114 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
115 LALK 0657 h ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −3 dB b−c o e f f i c e n t o f t h e BP− f i l t e r
116 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
117 LALK 05 A6h ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −4 dB b−c o e f f i c e n t o f t h e BP− f i l t e r
118 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
119 LALK 0509 h ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −5 dB b−c o e f f i c e n t o f t h e BP− f i l t e r
120 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
121 LALK 047 Dh ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −6 dB b−c o e f f i c e n t o f t h e BP− f i l t e r
122 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
123 LALK 0400 h ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −7 dB b−c o e f f i c e n t o f t h e BP− f i l t e r
124 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
125 LALK 0391 h ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −8 dB b−c o e f f i c e n t o f t h e BP− f i l t e r
126 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
127 LALK 032 Dh ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −9 dB b−c o e f f i c e n t o f t h e BP− f i l t e r
128 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
129 LALK 02 D5h ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −10 dB b−c o e f f i c e n t o f t h e BP− f i l t e r
130 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
131 LALK 0286 h ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −11 dB b−c o e f f i c e n t o f t h e BP− f i l t e r
132 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
133 LALK 0240 h ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −12 dB b−c o e f f i c e n t o f t h e BP− f i l t e r
134 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
135 LALK 0201 h ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −13 dB b−c o e f f i c e n t o f t h e BP− f i l t e r
136 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
137 LALK 01 C9h ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −14 dB b−c o e f f i c e n t o f t h e BP− f i l t e r
138 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
139 LALK 0198 h ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −15 dB b−c o e f f i c e n t o f t h e BP− f i l t e r
140 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
141 LALK 016 Bh ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −16 dB b−c o e f f i c e n t o f t h e BP− f i l t e r
142 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
143 LALK 0144 h ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −17 dB b−c o e f f i c e n t o f t h e BP− f i l t e r
144 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
145 LALK 0121 h ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −18 dB b−c o e f f i c e n t o f t h e BP− f i l t e r
146 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
147 LALK 0101 h ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −19 dB b−c o e f f i c e n t o f t h e BP− f i l t e r
148 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
149 LALK 00 E5h ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −20 dB b−c o e f f i c e n t o f t h e BP− f i l t e r
150 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
151 LALK 00 CCh ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −21 dB b−c o e f f i c e n t o f t h e BP− f i l t e r
152 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
153 LALK 00 B6h ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −22 dB b−c o e f f i c e n t o f t h e BP− f i l t e r
154 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
155 LALK 00 A2h ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −23 dB b−c o e f f i c e n t o f t h e BP− f i l t e r
156 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
157 LALK 0091 h ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −24 dB b−c o e f f i c e n t o f t h e BP− f i l t e r
158 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
159
160 ;HP− f i l t e r b−c o e f f i c i e n t s . According t o v a r i a n c e s c a l i n g t h e s e c o e f f i c i e n t s a r e s c a l e d w i t h a f a c t o r s =
1 . 1 2 4 4 5 7 0 9 2 7 4 4 0 4 . Q15 f o r m a t
161 LALK 71 D5h ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e 0 dB b−c o e f f i c e n t o f t h e HP− f i l t e r
181

162 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s


incremented .
182

O Source Code
163 LALK 6574 h ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −1 dB b−c o e f f i c e n t o f t h e HP− f i l t e r
164 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
165 LALK 5 A6Ch ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −2 dB b−c o e f f i c e n t o f t h e HP− f i l t e r
166 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
167 LALK 5096 h ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −3 dB b−c o e f f i c e n t o f t h e HP− f i l t e r
168 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
169 LALK 47 D3h ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −4 dB b−c o e f f i c e n t o f t h e HP− f i l t e r
170 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
171 LALK 4003 h ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −5 dB b−c o e f f i c e n t o f t h e HP− f i l t e r
172 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
173 LALK 390 Dh ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −6 dB b−c o e f f i c e n t o f t h e HP− f i l t e r
174 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
175 LALK 32 D9h ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −7 dB b−c o e f f i c e n t o f t h e HP− f i l t e r
176 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
177 LALK 2 D51h ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −8 dB b−c o e f f i c e n t o f t h e HP− f i l t e r
178 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
179 LALK 2864 h ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −9 dB b−c o e f f i c e n t o f t h e HP− f i l t e r
180 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
181 LALK 23 FFh ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −10 dB b−c o e f f i c e n t o f t h e HP− f i l t e r
182 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
183 LALK 2015 h ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −11 dB b−c o e f f i c e n t o f t h e HP− f i l t e r
184 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
185 LALK 1 C98h ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −12 dB b−c o e f f i c e n t o f t h e HP− f i l t e r
186 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
187 LALK 197 Ch ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −13 dB b−c o e f f i c e n t o f t h e HP− f i l t e r
188 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
189 LALK 16 B6h ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −14 dB b−c o e f f i c e n t o f t h e HP− f i l t e r
190 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
191 LALK 143 Eh ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −15 dB b−c o e f f i c e n t o f t h e HP− f i l t e r
192 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
193 LALK 120 Bh ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −16 dB b−c o e f f i c e n t o f t h e HP− f i l t e r
194 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
195 LALK 1014 h ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −17 dB b−c o e f f i c e n t o f t h e HP− f i l t e r
196 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
197 LALK 0 E55h ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −18 dB b−c o e f f i c e n t o f t h e HP− f i l t e r
198 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
199 LALK 0 CC6h ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −19 dB b−c o e f f i c e n t o f t h e HP− f i l t e r
200 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
201 LALK 0 B62h ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −20 dB b−c o e f f i c e n t o f t h e HP− f i l t e r
202 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
203 LALK 0 A25h ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −21 dB b−c o e f f i c e n t o f t h e HP− f i l t e r
204 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
205 LALK 090 Bh ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −22 dB b−c o e f f i c e n t o f t h e HP− f i l t e r
206 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
207 LALK 080 Fh ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −23 dB b−c o e f f i c e n t o f t h e HP− f i l t e r
208 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
209 LALK 072 Fh ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e −24 dB b−c o e f f i c e n t o f t h e HP− f i l t e r
210 SACL * ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g
211
212
213 ; a−c o e f f i c i e n t s
214 LRLK AR0 , Q_AS ; A0 i s l o a d e d w i t h t h e s t a r t a d d r e s s o f t h e a−c o e f f i c i e n t s
215 LALK 7202 h ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e a1−c o e f f i c e n t o f t h e LP− f i l t e r
216 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
217 LALK 6733 h ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e a1−c o e f f i c e n t o f t h e BP− f i l t e r
218 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
219 LALK 2 A5Ch ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e a2−c o e f f i c e n t o f t h e BP− f i l t e r
220 SACL *+ ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g , and AR0 i s
incremented .
221 LALK 4 A78h ; The a c c u m u l a t o r i s now l o a d e d w i t h t h e a1−c o e f f i c e n t o f t h e HP− f i l t e r
183

222 SACL * ; The v a l u e from t h e a c c u m u l a t o r i s s t o r e d where AR0 i s p o i n t i n g


223
184

O Source Code
224 ; Test p a r a m e t e r s
225 ; LDPK 5 ; Changes t h e page t o page 11
226 ; LRLK AR0,M_EQPA ; Load a d d r e s s o f LP b−c o e f f i c i e n t p o i n t e r i n t o AR0
227 ; LALK 4031 h ; Load a c c u m u l a t o r w i t h a d d r e s s o f LP 0 dB c o e f f i c i e n t
228 ; SACL ∗ ; S e t b−c o e f f i c i e n t p o i n t e r t o LP 0 dB c o e f f i c i e n t
229 ; LDPK 6
230 ; LRLK AR0,M_EQPB ; Load a d d r e s s o f BP b−c o e f f i c i e n t p o i n t e r i n t o AR0
231 ; LALK 4062 h ; Load a c c u m u l a t o r w i t h a d d r e s s o f BP 0 dB c o e f f i c i e n t
232 ; SACL ∗ ; S e t b−c o e f f i c i e n t p o i n t e r t o BP 0 dB c o e f f i c i e n t
233 ; LDPK 7
234 ; LRLK AR0,M_EQPC ; Load a d d r e s s o f HP b−c o e f f i c i e n t p o i n t e r i n t o AR0
235 ; LALK 4063 h ; Load a c c u m u l a t o r w i t h a d d r e s s o f HP 0 dB c o e f f i c i e n t
236 ; SACL ∗ ; S e t b−c o e f f i c i e n t p o i n t e r t o HP 0 dB c o e f f i c i e n t
237
238 ; End o f i n i t i a l i z a t i o n
239 LARP 7 ;ARP −> AR7
240 LDPK 0 ; s e t page p o i n t e r t o 0
241 RET ; r e t u r n from i n i t
242
243 ********************************************
244 * Equalizer
245 *
246 * Use of function :
247 * 1) push Input sample to stack
248 * Returns : Overwrites input sample with Output sample .
249 ********************************************
250
251 EQUALIZER :
252 ; Load LP b−c o e f f i c i e n t p o i n t e r s i n t o AR2 and a−c o e f f i c i e n t p o i n t e r i n t o AR3
253 LDPK 5 ; Change page t o page 11 ; 5
254 LAR AR2 , M_EQPA ; AR2 i s l o a d e d w i t h LP b−c o e f f i c i e n t s p o i n t e r
255 LARK AR3 , Q_AS ; AR3 i s l o a d e d w i t h a−c o e f f i c i e n t s p o i n t e r
256 ; LARP 3 ;ARP −> AR3
257 ; LALK 407Ch ; AR3 i s l o a d e d w i t h 407Ch ( a d d r e s s o f a−c o e f f i c i e n t s )
258 ; Pop i n p u t sample from s t a c k
259 LDPK 121 ; Change page t o page 121
260 LARP 7 ;ARP −> AR7
261 MAR *- ; dSP −> i n p u t sample
262 ZAC ; Sets accumulator to 0
263 LT * ,2 ; Loads i n p u t sample i n t o T−r e g i s t e r and ARP −> AR2
264 MPY * ; M u l t i p l i e s i n p u t sample w i t h b0−c o e f f i c i e n t and AR2 −> b1
265 LT Q_XDONE ; Loads x [ n−1] i n t o T−r e g i s t e r
266 MPYA * ,3 ; M u l t i p l i e s x [ n−1] w i t h b1 and a c c u m u l a t e s p r e v i o u s p r o d u c t and AR2 −> b0 BP
filter
267 LT Q_YLPDONE ; Loads y [ n−1] i n t o T−r e g i s t e r
268 MPYA *+ ,7 ; M u l t i p l i e s y [ n−1] w i t h a1 and a c c u m u l a t e s p r e v i o u s p r o d u c t . AR3 −> a1 BP
f i l t e r and ARP −> AR7
269 APAC ; Adds l a s t p r o d u c t t o a c c u m u l a t o r
270 SFL
271 SACH Q_LPNEWY ; Stores newest output .
272 SACH Q_YLPDONE ; S t o r e s o u t p u t i n y [ n−1]
273
274 LDPK 6 ; Changes page t o page 11 ; 6
275 LAR AR2 , M_EQPB ; AR2 i s l o a d e d w i t h BP b−c o e f f i c i e n t s p o i n t e r
276 LDPK 121 ; Changes page t o page 121
277 LAC *+ ; Loads x [ n ] , Q15 i n t o a c c u m u l a t o r . dSP+1 −> x [ n ]
278 SFR ; Changes x [ n ] t o Q14 f o r m a t
279 SACL * ; S t o r e s x [ n ] , Q14 on s t a c k
280 ZAC ; Sets accumulator to 0
281 LT * - ,2 ; Loads x [ n ] , Q14 i n t o T−r e g i s t e r and s e t s ARP −> AR2 . dSP −> x [ n ] , Q15
282 MPY * ; M u l t i p l i e s x [ n ] w i t h b0
283 LT Q_XDTWO ; Loads x [ n−2] i n t o T−r e g i s t e r
284 MPYA * ,3 ; M u l t i p l i e s x [ n−2] w i t h b2 and a c c u m u l a t e s p r e v i o u s p r o d u c t and s e t s ARP −>
AR3
285 LT Q_YBPDONE ; Loads y [ n−1] i n t o T−r e g i s t e r
286 MPYS *+ ; M u l t i p l i e s y [ n−1] w i t h a1 , s e t s AR3 −> a2 and s u b t r a c t s p r e v i o u s p r o d u c t
from a c c u m u l a t o r
287 LT Q_YBPDTWO ; Loads y [ n−2] i n t o T−r e g i s t e r
288 MPYA *+ ,7 ; M u l t i p l i e s y [ n−2] w i t h a2 , s e t s AR3 −> a1 HP c o e f f , s e t s ARP −> AR7 and
accumulates previous output
289 SPAC ; S u b t r a c t s l a s t p r o d u c t from a c c u m u l a t o r
290 SFL
291 SFL
292 SACH Q_BPNEWY ; S t o r e s n e w e s t ouput y [ n ]
293 LAC Q_YBPDONE ; Loads a c c u m u l a t o r w i t h y [ n−1]
294 SACL Q_YBPDTWO ; S t o r e s y [ n−1] i n y [ n−2]
295 LAC Q_BPNEWY ; Loads a c c u m u l a t o r w i t h y [ n ]
296 SACL Q_YBPDONE ; S t o r e s y [ n ] i n y [ n−1]
297 SFL ; Changes o u t p u t y [ n ] t o Q15
298 SACL Q_BPNEWY ; S t o r e s y [ n ] i n Q15 f o r m a t .
299
300 LDPK 7 ; Changes page t o page 11 ; 7
301 LAR AR2 , M_EQPC ; AR2 i s l o a d e d w i t h HP b−c o e f f i c i e n t s p o i n t e r
302 LDPK 121 ; Changes page t o page 121
303 ZAC ; Sets accumulator to 0
304 LT * ,2 ; Loads T−r e g i s t e r w i t h x [ n ] and s e t s ARP −> AR2
185

305 MPY * ; M u l t i p l i e s x [ n ] w i t h b0
306 LT Q_XDONE ; Loads T−r e g i s t e r w i t h x [ n−1]
186

O Source Code
307 MPYA * ,3 ; M u l t i p l i e s x [ n−1] w i t h b1 and s e t s ARP −> AR3
308 LT Q_YHPDONE ; Loads T−r e g i s t e r w i t h y [ n−1]
309 MPYS * ; M u l t i p l i e s y [ n−1] w i t h a1 and s u b t r a c t s p r e v i o u s p r o d u c t from a c c u m u l a t o r
310 APAC ; Accumulates l a s t p r o d u c t
311 SFL
312 SACH Q_HPNEWY ; S t o r e s t newest output
313 SACH Q_YHPDONE ; S t o r e s y [ n ] i n t o y [ n−1]
314
315 LAC Q_XDONE
316 SFR
317 SACL Q_XDTWO
318 ;LAR 4 ,Q_XDONE ; Loads AR4 w i t h x [ n−1]
319 ;SAR 4 ,Q_XDTWO ; O v e r w r i t e s x [ n−2] w i t h x [ n−1]
320 LARP 7 ;ARP −> AR7
321
322 LAC * ; Load a c c u m u l a t o r w i t h x [ n ] .
323 SACL Q_XDONE ; O v e r w r i t e s x [ n−1] w i t h x [ n ]
324 LAC Q_LPNEWY ; Load a c c u m u l a t o r w i t h y [ n ] _lp
325 ADD Q_BPNEWY ; Add a c c u m u l a t o r w i t h y [ n ] _bp
326 ADD Q_HPNEWY ; Add a c c u m u l a t o r w i t h y [ n ] _hp
327
328 SACL * ; Overwrite x [ n ]
329 LDPK 0 ; s e t page p o i n t e r t o 0
330 RET ; Returns from s u b r o u t i n e
Source Code for Flanger and Chorus
1 ********************************************
2 * filename : flanger_chorus . asm
3 * creator : jkjaer
4 * generated : May 8 th 2007
5 *
6 * This file contains the chorus and flanger effects
7 *
8 * references :
9 * [ aug ] TMS320C1X / C2X / C2XX / C5X Assembly language tools Texas Instruments
10 * [ ug ] TMS320C2X user ’ s guide Texas Instruments
11 * [D/M] Debugger / monitor Sofus Birkedal Nielsen
12 ********************************************
187
188

O Source Code
Source Code for Keyboard
1 ********************************************
2 * filename : keyboard . asm
3 * creator : jkjaer
4 * generated : May 8 th 2007
5 *
6 * This is the keyboard and jog wheel driver
7 *
8 * references :
9 * [ aug ] TMS320C1X / C2X / C2XX / C5X Assembly language tools Texas Instruments
10 * [ ug ] TMS320C2X user ’ s guide Texas Instruments
11 * [D/M] Debugger / monitor Sofus Birkedal Nielsen
12 ********************************************
13 *
14 ********************************************
15 * Defines :
16 ********************************************
17 . text
18 K_INPUT . equ 07 h ; Address o f t h e k e y b o a r d i n p u t
19 K_TESTUP . equ 0 Fh ; Test i f b i t 0 i s one .
20 K_TESTDOWN . equ 0 Eh ; Test i f b i t 1 i s one .
21 K_TESTLEFT . equ 0 Dh ; Test i f b i t 2 i s one .
22 K_TESTRIGHT . equ 0 Ch ; Test i f b i t 3 i s one .
23 K_TESTOK . equ 0 Bh ; Test i f b i t 4 i s one .
24 K_TSTJRIGHT . equ 0 Ah ; Test i f b i t 5 i s one .
25 K_TSTJLEFT . equ 09 h ; Test i f b i t 6 i s one .
26 *
27 K_UP . equ 01 h ; I n d i c a t e s b u t t o n UP i s pushed .
28 K_DOWN . equ 02 h ; I n d i c a t e s b u t t o n DOWN i s pushed .
29 K_LEFT . equ 04 h ; I n d i c a t e s b u t t o n LEFT i s pushed .
30 K_RIGHT . equ 08 h ; I n d i c a t e s b u t t o n RIGHT i s pushed .
31 K_OK . equ 10 h ; I n d i c a t e s b u t t o n OK i s pushed .
32 K_JLEFT . equ 20 h ; I n d i c a t e s j o g w h e e l t u r n e d l e f t .
33 K_JRIGHT . equ 40 h ; I n d i c a t e s j o g w h e e l t u r n e d l e f t .
34 *
35 ; PAGE 15
36 K_KFLAG . equ 0780 h ; Address o f t h e Key f l a g .
37 K_JFLAG . equ 0781 h ; Address o f t h e Jog f l a g .
38 K_JDIRECT . equ 0782 h ; Address f o r s a v e d i r e c t i o n o f jog wheel .
39 ;KEYS . equ 0783 h
40 ********************************************
41 ********************************************
42 KEYB_INIT :
43 LDPK 15 ; Load page 1 5 .
44 ZAC ; Zero a c c u m u l a t o r .
45 SACL K_KFLAG ; Zero k e y b o a r d f l a g .
46 SACL K_JFLAG ; Zero j o g w h e e l f l a g .
47 SACL K_JDIRECT ; Zero j o g w h e e l d i r e c t i o n .
48 LDPK 0 ; Load page 0 .
49 RET ; Return t o i n i t i a l i z a t i o n p r o c e s s .
50 ********************************************
51 ********************************************
52
53 KEYBOARD :
54 ********************************************
55 IN * , K_INPUT ; S t o r e s k e y b o a r d i n p u t on s t a c k . (1110 0000)
56 LAC * ; Loads a c c u m u l a t o r w i t h i n p u t
57 XORK 0060 h ; Invert jog pins . (1110 0000)XOR(0110 0000)
58 ANDK 007 Fh ; Z e r o e s upper word . (1000 0000)AND(0111 1111)
59 SACL * ; S t o r e s a c c u m u l a t o r on s t a c k a g a i n (0000 0000)
60 BNZ KTSTKFLAG ; Branches i f any k e y s have been p r e s s e d .
61 ZAC ; Zero a c c u m u l a t o r .
62 LDPK 15
63 SACL K_KFLAG ; S e t KFLAG z e r o .
64 SACL K_JFLAG ; S e t JFLAG z e r o .
65 SACL K_JDIRECT ; Zero Jog d i r e c t i o n .
66 SACL * ; Put z e r o on s t a c k
67 LDPK 0
68 RET ; Return t o menu h a n d l e r .
69
70 KTSTKFLAG :
71 ********************************************
72 LAC K_KFLAG ; Load K_KFLAG s t a t u s
73 BZ KTSTKEY ; Branch i f K_KFLAG i s z e r o .
74 B MAIN ; Return t o MAIN.
75 KTSTKEY BIT * , K_TESTUP ; Test f o r b u t t o n UP.
76 BBNZ KKEYU ; Branch t o b u t t o n UP i f n o t z e r o .
77 BIT * , K_TESTDOWN ; Test f o r b u t t o n DOWN.
78 BBNZ KKEYD ; Branch t o b u t t o n DOWN i f n o t z e r o .
79 BIT * , K_TESTLEFT ; Test f o r b u t t o n LEFT.
80 BBNZ KKEYL ; Branch t o b u t t o n LEFT i f n o t z e r o .
81 BIT * , K_TESTRIGHT ; Test f o r b u t t o n RIGHT.
82 BBNZ KKEYR ; Branch t o b u t t o n RIGHT i f n o t z e r o .
83 BIT * , K_TESTOK ; Test f o r b u t t o n OK.
189

84 BBNZ KKEYOK ; Branch t o b u t t o n OK i f n o t z e r o .


85 B KTSTJFLAG ; Branch t o t e s t i n g K_JFLAG when no b u t t o n s p r e s s e d .
190

O Source Code
86 KKEYU LALK 1 ; Load one on a c c u m u l a t o r .
87 SACL K_KFLAG ; S e t KFLAG one .
88 LALK K_UP ; Load b u t t o n UP.
89 SACL * ; Save on s t a c k .
90 RET ; Return t o menu h a n d l e r .
91 KKEYD LALK 1 ; Load one on a c c u m u l a t o r .
92 SACL K_KFLAG ; S e t KFLAG one .
93 LALK K_DOWN ; Load b u t t o n DOWN.
94 SACL * ; Save on s t a c k .
95 RET ; Return t o menu h a n d l e r .
96 KKEYL LALK 1 ; Load one on a c c u m u l a t o r .
97 SACL K_KFLAG ; S e t KFLAG one .
98 LALK K_LEFT ; Load b u t t o n LEFT.
99 SACL * ; Save on s t a c k .
100 RET ; Return t o menu h a n d l e r .
101 KKEYR LALK 1 ; Load one on a c c u m u l a t o r .
102 SACL K_KFLAG ; S e t KFLAG one .
103 LALK K_RIGHT ; Load b u t t o n RIGHT.
104 SACL * ; Save on s t a c k .
105 RET ; Return t o menu h a n d l e r .
106 KKEYOK LALK 1 ; Load one on a c c u m u l a t o r .
107 SACL K_KFLAG ; S e t KFLAG one .
108 LALK K_OK ; Load b u t t o n OK.
109 SACL * ; Save on s t a c k .
110 RET ; Return t o menu h a n d l e r .
111
112 KTSTJFLAG :
113 ********************************************
114 LAC K_JFLAG ; Load K_JFLAG s t a t u s .
115 BZ KTSTJO ; Branch i f J_KFLAG i s z e r o .
116 ZAC ; Else zero accumulator .
117 SACL * ; And s t o r e on s t a c k .
118 RET ; And r e t u r n t o menu h a n d l e r .
119
120 KTSTJO : ; Test i f Jog w h e e l p i n s a r e ones .
121 BIT * , K_TSTJLEFT ; I s b i t no . 6 one ?
122 BBZ KSAVJR ; I f zero then save d i r e c t i o n r i g h t .
123 BIT * , K_TSTJRIGHT ; I s b i t no . 7 one ?
124 BBZ KSAVJL ; I f zero then save d i r e c t i o n l e f t .
125 LALK 1 ; E l s e l o a d one on a c c u m u l a t o r .
126 SACL K_JFLAG ; And t h e n s e t JFLAG h i g h .
127 LAC K_JDIRECT ; Load c u r r e n t j o g d i r e c t i o n i n d i c a t o r .
128 SACL * ; S t o r e on s t a c k .
129 ZAC ; Zero a c c u m u l a t o r .
130 SACL K_JDIRECT ; Zero d i r e c t i o n i n d i c a t o r .
131 RET ; Return t o menu h a n d l e r .
132
133 KSAVJR LALK K_JRIGHT ; Load d i r e c t i o n l e f t .
134 SACL K_JDIRECT ; Save i n d i r e c t i o n i n d i c a t o r
135 ZAC ; Zero a c c u m u l a t o r .
136 SACL * ; S t o r e on s t a c k t o i n d i c a t e no a c t i v i t y a t c u r r e n t time .
137 RET ; Return t o menu h a n d l e r .
138
139 KSAVJL LALK K_JLEFT ; Load d i r e c t i o n r i g h t .
140 SACL K_JDIRECT ; Save i n d i r e c t i o n i n d i c a t o r
141 ZAC ; Zero a c c u m u l a t o r .
142 SACL * ; S t o r e on s t a c k t o i n d i c a t e no a c t i v i t y a t c u r r e n t time .
143 RET ; Return t o menu h a n d l e r .
191
192

O Source Code
Source Code for Reverberator
1 ********************************************
2 * filename : reverb . asm
3 * creator : jkjaer
4 * generated : May 8 th 2007
5 *
6 * This file contains the reverb effect
7 *
8 * references :
9 * [ aug ] TMS320C1X / C2X / C2XX / C5X Assembly language tools Texas Instruments
10 * [ ug ] TMS320C2X user ’ s guide Texas Instruments
11 * [D/M] Debugger / monitor Sofus Birkedal Nielsen
12 ********************************************
13 ********************************************
14 * Constants
15 ********************************************
16 ; addresses of reverb s e t t i n g s
17 REV_LEVEL . equ 540 h ; a d d r e s s o f r e v e r b l e v e l . Number from 0 t o 1 .
18 REV_DELAY . equ 541 h ; a d d r e s s o f r e v e r b pre−d e l a y . Number from 0 t o 100 ms
19 REV_TIME . equ 542 h ; a d d r e s s o f a d d r e s s t o b−c o e f f i c i e n t s t h a t d e t e r m i n e s r e v e r b time . Number
from 0 t o 4 s
20 ; filter coefficients
21 R_AP_GAIN . equ 599 Ah ; s e t a l l p a s s gain to 0.7
22 R_A1 . equ 0 C6B2h ; s e t LP− f i l t e r c o e f f i c i e n t t o −0.0189 0FD96h
23 ; s t o r a g e f o r temporary o u t p u t
24 R_LPCF1_OUT . equ 2500 h ; s t o r a g e f o r o u t p u t from LPCF1
25 R_LPCF2_OUT . equ 2501 h ; s t o r a g e f o r o u t p u t from LPCF2
26 R_LPCF3_OUT . equ 2502 h ; s t o r a g e f o r o u t p u t from LPCF3
27 ; pre−d e l a y b u f f e r p o i n t e r and a d d r e s s e s
28 R_PRE_D_IN_ADD . equ 2509 h ; a d d r e s s o f a d d r e s s t o i n p o i n t e r o f pre−d e l a y b u f f e r
29 R_PRE_D_TOP . equ 2600 h ; a d d r e s s o f t o p p o i n t e r t o pre−d e l a y b u f f e r
30 R_PRE_D_BOT . equ 2 B16h ; a d d r e s s o f bottom p o i n t e r t o pre−d e l a y b u f f e r 2DA2
31 ; s t o r a g e f o r l o w p a s s comb f i l t e r 1 c i r c u l a r b u f f e r p o i n t e r s and a d d r e s s e s
32 LPCF1_BUF_TOP_ADD . equ 2510 h ; address of address of top pointer of c i r c u l a r b u f f e r
33 LPCF1_BUF_IN_ADD . equ 2511 h ; address of address of in pointer of c i r c u l a r b u f f e r
34 LPCF1_BUF_BOT_ADD . equ 2512 h ; a d d r e s s o f a d d r e s s o f bottom p o i n t e r o f c i r c u l a r b u f f e r
35 LPCF1_BUF_TOP . equ 2 DB0h ; address of top pointer of c i r c u l a r b u f f e r
36 LPCF1_BUF_BOT . equ 2 F43h ; a d d r e s s o f bottom p o i n t e r o f c i r c u l a r b u f f e r 300Dh
37 ; s t o r a g e f o r l o w p a s s comb f i l t e r 2 c i r c u l a r b u f f e r p o i n t e r s and a d d r e s s e s
38 LPCF2_BUF_TOP_ADD . equ 2514 h ; address of address of top pointer of c i r c u l a r b u f f e r
39 LPCF2_BUF_IN_ADD . equ 2515 h ; address of address of in pointer of c i r c u l a r b u f f e r
40 LPCF2_BUF_BOT_ADD . equ 2516 h ; a d d r e s s o f a d d r e s s o f bottom p o i n t e r o f c i r c u l a r b u f f e r
41 LPCF2_BUF_TOP . equ 3010 h ; address of top pointer of c i r c u l a r b u f f e r
42 LPCF2_BUF_BOT . equ 31 F132E2h ; a d d r e s s o f bottom p o i n t e r o f c i r c u l a r b u f f e r 32E2h
43 ; s t o r a g e f o r l o w p a s s comb f i l t e r 3 c i r c u l a r b u f f e r p o i n t e r s and a d d r e s s e s
44 LPCF3_BUF_TOP_ADD . equ 2518 h ; address of address of top pointer of c i r c u l a r b u f f e r
45 LPCF3_BUF_IN_ADD . equ 2519 h ; address of address of in pointer of c i r c u l a r b u f f e r
46 LPCF3_BUF_BOT_ADD . equ 251 Ah ; a d d r e s s o f a d d r e s s o f bottom p o i n t e r o f c i r c u l a r b u f f e r
47 LPCF3_BUF_TOP . equ 32 F0h ; address of top pointer of c i r c u l a r b u f f e r
48 LPCF3_BUF_BOT . equ 3506 h ; a d d r e s s o f bottom p o i n t e r o f c i r c u l a r b u f f e r 3610 h
49 ; s t o r a g e f o r l o w p a s s comb f i l t e r 4 c i r c u l a r b u f f e r p o i n t e r s and a d d r e s s e s
50 LPCF4_BUF_TOP_ADD . equ 251 Ch ; address of address of top pointer of c i r c u l a r b u f f e r
51 LPCF4_BUF_IN_ADD . equ 251 Dh ; address of address of in pointer of c i r c u l a r b u f f e r
52 LPCF4_BUF_BOT_ADD . equ 251 Eh ; a d d r e s s o f a d d r e s s o f bottom p o i n t e r o f c i r c u l a r b u f f e r
53 LPCF4_BUF_TOP . equ 3612 h ; address of top pointer of c i r c u l a r b u f f e r
54 LPCF4_BUF_BOT . equ 3842 h ; a d d r e s s o f bottom p o i n t e r o f c i r c u l a r b u f f e r 3959 h
55 ; s t o r a g e f o r a l l p a s s f i l t e r 1 c i r c u l a r b u f f e r p o i n t e r s and a d d r e s s e s
56 RAPF1_BUF_TOP_ADD . equ 2520 h ; address of address of top pointer of c i r c u l a r b u f f e r
57 RAPF1_BUF_IN_ADD . equ 2521 h ; address of address of in pointer of c i r c u l a r b u f f e r
58 RAPF1_BUF_BOT_ADD . equ 2522 h ; a d d r e s s o f a d d r e s s o f bottom p o i n t e r o f c i r c u l a r b u f f e r
59 RAPF1_BUF_TOP . equ 39 D0h ; address of top pointer of c i r c u l a r b u f f e r
60 RAPF1_BUF_BOT . equ 3 A11h ; a d d r e s s o f bottom p o i n t e r o f c i r c u l a r b u f f e r 3A31h
61 ; s t o r a g e f o r a l l p a s s f i l t e r 2 c i r c u l a r b u f f e r p o i n t e r s and a d d r e s s e s
62 RAPF2_BUF_TOP_ADD . equ 2524 h ; address of address of top pointer of c i r c u l a r b u f f e r
63 RAPF2_BUF_IN_ADD . equ 2525 h ; address of address of in pointer of c i r c u l a r b u f f e r
64 RAPF2_BUF_BOT_ADD . equ 2526 h ; a d d r e s s o f a d d r e s s o f bottom p o i n t e r o f c i r c u l a r b u f f e r
65 RAPF2_BUF_TOP . equ 3 A40h ; address of top pointer of c i r c u l a r b u f f e r
66 RAPF2_BUF_BOT . equ 3 A56h ; a d d r e s s o f bottom p o i n t e r o f c i r c u l a r b u f f e r 3A61h
67 ; s t o r a g e f o r p o i n t e r s t o b u f f e r t h a t h o l d s sum o f o u t p u t s from LPCFs
68 R_LPCF_SUM_IN_ADD . equ 2508 h ; a d d r e s s o f a d d r e s s t o i n p o i n t e r o f pre−d e l a y b u f f e r
69 R_LPCF_SUM_TOP . equ 3960 h ; a d d r e s s o f t o p p o i n t e r t o pre−d e l a y b u f f e r
70 R_LPCF_SUM_BOT . equ 39 A1h ; a d d r e s s o f bottom p o i n t e r t o pre−d e l a y b u f f e r 39C1h
71 ********************************************
72 * Reverberation initialization
73 * Initializes Moorer ’ s reverberator
74 * The function takes no input arguments
75 * The function returns no output arguments
76 * The function does not alter the stack pointer
77 ********************************************
78 REVERB_INIT :
79 ; The d i f f e r e n t P o i n t e r s must c o n t a i n t h e a d d r e s s o f t h e p l a c e i n t h e b u f f e r t o which t h e y a r e p o i n t i n g .
80 ; I n i t i a l i z a t i o n o f t h e b u f f e r s . Here t h e b u f f e r s i s f i l l e d w i t h z e r o e s .
81 LRLK AR0 , RAPF2_BUF_BOT ; AR0 i s l o a d e d w i t h t h e a d d r e s s o f t h e b u f f e r end .
82 LRLK AR4 , R_PRE_D_TOP ; AR4 i s l o a d e d w i t h t h e a d d r e s s o f t h e b u f f e r b e g i n n i n g .
193

83 LARP AR4 ; The ARP i s now p o i n t i n g a t AR4 .


84 ZAC ; The Accumulator i s now l o a d e d w i t h z e r o .
194

O Source Code
85 R_CLR_BUFF : SACL *+ ; The z e r o i n t h e a c c u m u l a t o r i s s t o r e d i n t h e a d d r e s s ARP p o i n t s t o ( Address
i n AR4) .
86 CMPR 0 ; I f t h e a d d r e s s i n AR4 = AR0 ( opcode 0) t h e c o n t r o l b i t TC = 1 , e l s e TC = 0 .
87 BBZ R_CLR_BUFF ; I f TC = 0 c l e a r t h e n e x t a d d r e s s . The r o u t i n e w i l l s t o p once a l l a d d r e s s e s
in the b u f f e r contains zeros .
88 SACL * ; clear the l a s t address
89 *
90 * initialize input pointers to the different buffers
91 *
92 LDPK 74 ; s e t page p o i n t e r t o 194
93 ; i n i t o f pre−d e l a y p o i n t e r
94 LALK R_PRE_D_TOP ; s t o r e s t a r t address of pre_delay b u f f e r to accumulator
95 SACL R_PRE_D_IN_ADD ; save address to in pointer address
96 ; i n i t o f LPCF1 p o i n t e r s
97 LALK LPCF1_BUF_TOP ; s t o r e s t a r t a d d r e s s o f LPCF1 b u f f e r t o a c c u m u l a t o r
98 SACL LPCF1_BUF_TOP_ADD ; save address to top pointer address
99 SACL LPCF1_BUF_IN_ADD ; save address to in pointer address
100 LALK LPCF1_BUF_BOT ; s t o r e bottom a d d r e s s o f LPCF1 b u f f e r t o a c c u m u l a t o r
101 SACL LPCF1_BUF_BOT_ADD ; save address to in pointer address
102 ; i n i t o f LPCF2 p o i n t e r s
103 LALK LPCF2_BUF_TOP ; s t o r e s t a r t a d d r e s s o f LPCF2 b u f f e r t o a c c u m u l a t o r
104 SACL LPCF2_BUF_TOP_ADD ; save address to top pointer address
105 SACL LPCF2_BUF_IN_ADD ; save address to in pointer address
106 LALK LPCF2_BUF_BOT ; s t o r e bottom a d d r e s s o f LPCF2 b u f f e r t o a c c u m u l a t o r
107 SACL LPCF2_BUF_BOT_ADD ; save address to in pointer address
108 ; i n i t o f LPCF3 p o i n t e r s
109 LALK LPCF3_BUF_TOP ; s t o r e s t a r t a d d r e s s o f LPCF3 b u f f e r t o a c c u m u l a t o r
110 SACL LPCF3_BUF_TOP_ADD ; save address to top pointer address
111 SACL LPCF3_BUF_IN_ADD ; save address to in pointer address
112 LALK LPCF3_BUF_BOT ; s t o r e bottom a d d r e s s o f LPCF3 b u f f e r t o a c c u m u l a t o r
113 SACL LPCF3_BUF_BOT_ADD ; save address to in pointer address
114 ; i n i t o f LPCF4 p o i n t e r s
115 LALK LPCF4_BUF_TOP ; s t o r e s t a r t a d d r e s s o f LPCF4 b u f f e r t o a c c u m u l a t o r
116 SACL LPCF4_BUF_TOP_ADD ; save address to top pointer address
117 SACL LPCF4_BUF_IN_ADD ; save address to in pointer address
118 LALK LPCF4_BUF_BOT ; s t o r e bottom a d d r e s s o f LPCF4 b u f f e r t o a c c u m u l a t o r
119 SACL LPCF4_BUF_BOT_ADD ; save address to in pointer address
120 ; i n i t o f LPCF sum p o i n t e r
121 LALK R_LPCF_SUM_TOP ; s t o r e s t a r t address of pre_delay b u f f e r to accumulator
122 SACL R_LPCF_SUM_IN_ADD ; save address to in pointer address
123 ; i n i t o f APF1 p o i n t e r s
124 LALK RAPF1_BUF_TOP ; s t o r e s t a r t a d d r e s s o f APF1 b u f f e r t o a c c u m u l a t o r
125 SACL RAPF1_BUF_TOP_ADD ; save address to top pointer address
126 SACL RAPF1_BUF_IN_ADD ; save address to in pointer address
127 LALK RAPF1_BUF_BOT ; s t o r e bottom a d d r e s s o f APF1 b u f f e r t o a c c u m u l a t o r
128 SACL RAPF1_BUF_BOT_ADD ; save address to in pointer address
129 ; i n i t o f APF2 p o i n t e r s
130 LALK RAPF2_BUF_TOP ; s t o r e s t a r t a d d r e s s o f APF2 b u f f e r t o a c c u m u l a t o r
131 SACL RAPF2_BUF_TOP_ADD ; save address to top pointer address
132 SACL RAPF2_BUF_IN_ADD ; save address to in pointer address
133 LALK RAPF2_BUF_BOT ; s t o r e bottom a d d r e s s o f APF2 b u f f e r t o a c c u m u l a t o r
134 SACL RAPF2_BUF_BOT_ADD ; save address to in pointer address
135 *
136 * initialize reverb settings
137 *
138 LDPK 10 ; s e t page p o i n t e r t o 10
139 ; reverb l e v e l
140 LALK 7 FFFh ; l o a d 7FFFh t o ACC
141 SACL REV_LEVEL ; s e t r e v e r b l e v e l t o 1−(en LSB)
142 ; pre−d e l a y
143 LALK 0h ; l o a d 0h t o ACC 514
144 SACL REV_DELAY ; s e t p r e _ d e l a y l e n g t h t o 0 ms
145 ; r e v e r b time
146 LRLK AR4 ,2540 h ; a d d r e s s o f t e s t c o e f f i c i e n t s which c o r r e s p o n d t o 1 s r e v e r b time
147 SAR AR4 , REV_TIME ; move a d d r e s s t o REV_TIME a d d r e s s
148 ; initialize coefficients
149 LALK 57 D3h ; s e t u p 0 . 8 1 i n ACC 34A3h 4ACB
150 SACL *+ ; s a v e 0 . 8 1 on a d d r e s s 2540 h
151 LALK 56 EBh ; s e t u p 0 . 7 7 i n ACC 3280 h 47C2
152 SACL *+ ; s a v e 0 . 7 7 on a d d r e s s 2541 h
153 LALK 5652 h ; s e t u p 0 . 7 5 i n ACC 3120 h 45CD
154 SACL *+ ; s a v e 0 . 7 5 on a d d r e s s 2542 h
155 LALK 5606 h ; s e t u p 0 . 7 4 i n ACC 3073 h 44D8
156 SACL * ; s a v e 0 . 7 4 on a d d r e s s 2543 h
157 ; r e s t o r e and r e t u r n from r e v e r b i n i t
158 LARP 7 ; S e t ARP −> AR7
159 LDPK 0 ; l o a d d a t a page 0
160 RET ; r e t u r n from r e v e r b i n i t
161
162 ********************************************
163 * Reverberation algorithm
164 * Implements Moorer ’ s reverberator
165 * Use of function :
166 * 1) push input sample to stack
167 * The reveration function overwrites the input sample with the output sample .
168 * The stack pointer points to the output sample
195

169 ********************************************
170 REVERB :
196

O Source Code
171 ; scale
172 MAR *- ; decrement s t a c k p o i n t e r
173 LT * ; move i n p u t sample t o t−r e g i s t e r
174 MPYK 0 CCCh ; d i v i d e i n p u t s i g n a l w i t h 10
175 PAC ; save to accumulator
176 SFL ; s h i f t accumulator l e f t
177 SACH * ; s t o r e new i n p u t sample
178 *
179 * reverberation level
180 *
181 ; MAR ∗− ; decrement s t a c k p o i n t e r
182 ; dSP −> i n p u t sample
183 LDPK 10 ; s e t page p o i n t e r t o 1 0 . Reverb s e t t i n g s t a b l e
184 LTA REV_LEVEL ; l o a d r e v e r b e r a t i o n l e v e l T−r e g
185 MPY *+ ,1 ; m u l t i p l y r e v e r b l e v e l w i t h i n p u t sample . S e t ARP −> AR1
186 ; dSP−1 −> i n p u t sample
187 PAC ; copy P−r e g t o ACC
188 ; s h i f t data in accumulator
189 SFL ; s h i f t accumulator l e f t
190 *
191 * pre - delay
192 *
193 ; s a v e l e v e l e d i n p u t sample t o pre−d e l a y buffer
194 LDPK 74 ; s e t page p o i n t e r t o 7 4 .
195 LAR AR1 , R_PRE_D_IN_ADD ; l o a d i n p o i n t e r o f pre−d e l a y b u f f e r i n t o AR1
196 SACH *- ; s t o r e l e v e l e d i n p u t sample i n t o pre−d e l a y b u f f e r and decrement
197 SAR AR1 , R_PRE_D_IN_ADD ; s a v e u p d a t e d i n p o i n t e r o f pre−d e l a y b u f f e r .
198 LARP 7 ; s e t ARP −> AR7
199 ; wrap i n p o i n t e r o f pre−d e l a y b u f f e r i f necessary
200 LAC R_PRE_D_IN_ADD ; l o a d u p d a t e d i n p o i n t e r o f pre−d e l a y b u f f e r i n t o a c c u m u l a t o r
201 SBLK R_PRE_D_TOP ; s u b t r a c t a d d r e s s o f t o p o f pre−d e l a y b u f f e r
202 BGEZ R_FIND_OUT_PTR ; branch i f a c c u m u l a t o r i s g r e a t e r or e q u a l t o z e r o − no wrapping n e c e s s a r y
203 ; wrapping
204 LALK R_PRE_D_BOT ; copy a d d r e s s o f bottom o f pre−d e l a y b u f f e r t o ACC
205 SACL R_PRE_D_IN_ADD ; s e t i n p o i n t e r a d d r e s s e q u a l t o bottom a d d r e s s o f pre−d e l a y b u f f e r
206 ; f i n d a d d r e s s o f o u t p u t sample
207 R_FIND_OUT_PTR :
208 LDPK 10 ; s e t page p o i n t e r t o 1 0 . Reverb s e t t i n g s t a b l e
209 LAC REV_DELAY ; l o a d pre−d e l a y t o a c c u m u l a t o r
210 ADDK 1 ; compensate f o r i n c r e m e n t o f i n p o i n t e r ( t h a t has a l l r e a d y been performed )
211 LDPK 74 ; s e t page p o i n t e r t o 7 4 .
212 ADD R_PRE_D_IN_ADD ; add i n p o i n t e r t o pre−d e l a y l e n g t h t o f i n d o u t p u t a d d r e s s
213 SACL * ; push o u t a d d r e s s t o s t a c k
214 ; wrap o u t p o i n t e r o f pre−d e l a y b u f f e r i f necessary
215 SBLK R_PRE_D_BOT ; s u b t r a c t a d d r e s s o f bottom o f pre−d e l a y b u f f e r
216 BLEZ R_LOAD_OUT_SAMP1 ; branch i f a c c u m u l a t o r i s l e s s than z e r o − no wrapping n e c e s s a r y
217 ; wrapping
218 ADLK R_PRE_D_TOP ; add a d d r e s s o f t o p o f pre−d e l a y b u f f e r
219 SUBK 1 ; s u b t r a c t one from a c c u m u l a t o r
220 SACL * ; push o u t a d d r e s s t o s t a c k − o v e r w r i t e wrong a d d r e s s
221 ; l o a d two d e l a y e d s a m p l e s from pre−d e l a y b u f f e r ( x [ n−d ] and x [ n−d −1]) and push them onto s t a c k
222 R_LOAD_OUT_SAMP1 :
223 LAR AR1 ,* ,1 ; l o a d AR1 w i t h o u t p u t p o i n t e r . S e t ARP −> AR1
224 LAC *+ ,0 ,7 ; l o a d a c c u m u l a t o r w i t h f i r s t o u t p u t sample ( x [ n−d ] ) .
225 SACL *+ ,0 ,1 ; push f i r s t o u t p u t sample t o s t a c k
226 ; dSP−1 −> x [ n−d ]
227 ; wrap o u t p o i n t e r +1 o f pre−d e l a y b u f f e r i f n e c e s s a r y
228 LRLK AR0 , R_PRE_D_BOT ; l o a d a d d r e s s o f bottom o f pre−d e l a y b u f f e r t o AR0
229 CMPR 2 ; i f AR1 > AR0, t h e n TC = 1
230 BBZ R_LOAD_OUT_SAMP2 ; branc i f TC=0
231 ; wrapping
232 LRLK AR1 , R_PRE_D_TOP ; l o a d a d d r e s s o f t o p o f pre−d e l a y b u f f e r t o AR1
233 R_LOAD_OUT_SAMP2 :
234 LAC * ,0 ,7 ; l o a d a c c u m u l a t o r w i t h x [ n−d −1]
235 SACL *+ ,0 ,4 ; push x [ n−d −1] t o s t a c k
236 ; dSP−1 −> x [ n−d −1]
237 *
238 * lowpass comb filter 1
239 *
240 ; l o a d b−c o e f f i c i e n t t o s t a c k
241 LDPK 10 ; s e t page p o i n t e r t o 1 0 . Reverb s e t t i n g s t a b l e
242 LAR AR4 , REV_TIME ; l o a d a d d r e s s o f b c o e f f i c i e n t s t o AR4
243 LDPK 74 ; s e t page p o i n t e r t o 7 4 .
244 LAC *+ ,0 ,7 ; l o a d f i r s t b−c o e f f i c i e n t t o a c c u m u l a t o r
245 SACL *+ ; push b−c o e f f i c i e n t t o s t a c k
246 ; push f i l t e r number t o s t a c k
247 LACK 0 ; l o a d a c c u m u l a t o r w i t h f i l t e r number 0
248 SACL * ; push f i l t e r number 0 t o s t a c k .
249 CALL LPCF ; c a l l comb f i l t e r s u b r o u t i n e
250 ; dSP −> o u t p u t sample
251 LAC * ; move o u t p u t sample t o a c c u m u l a t o r
252 ; s a v e o u t p u t sample
253 SACL R_LPCF1_OUT ; s t o r e o u t p u t from LPCF1
254 *
255 * lowpass comb filter 2
256 *
197

257 ; l o a d b−c o e f f i c i e n t t o s t a c k
258 LARP 4 ; s e t ARP −> AR4
198

O Source Code
259 LAC *+ ,0 ,7 ; l o a d second b−c o e f f i c i e n t t o a c c u m u l a t o r
260 SACL *+ ; push b−c o e f f i c i e n t t o s t a c k
261 ; push f i l t e r number t o s t a c k
262 LACK 1 ; l o a d a c c u m u l a t o r w i t h f i l t e r number 1
263 SACL * ; push f i l t e r number 1 t o s t a c k
264 CALL LPCF ; c a l l comb f i l t e r s u b r o u t i n e
265 ; dSP −> o u t p u t sample
266 LAC * ; move o u t p u t sample t o a c c u m u l a t o r
267 ; s a v e o u t p u t sample
268 SACL R_LPCF2_OUT ; s t o r e o u t p u t from LPCF2
269 *
270 * lowpass comb filter 3
271 *
272 ; l o a d b−c o e f f i c i e n t t o s t a c k
273 LARP 4 ; s e t ARP −> AR4
274 LAC *+ ,0 ,7 ; l o a d second b−c o e f f i c i e n t t o a c c u m u l a t o r
275 SACL *+ ; push b−c o e f f i c i e n t t o s t a c k
276 ; push f i l t e r number t o s t a c k
277 LACK 2 ; l o a d a c c u m u l a t o r w i t h f i l t e r number 2
278 SACL * ; push f i l t e r number 2 t o s t a c k
279 CALL LPCF ; c a l l comb f i l t e r s u b r o u t i n e
280 ; dSP −> o u t p u t sample
281 LAC * ; move o u t p u t sample t o a c c u m u l a t o r
282 ; s a v e o u t p u t sample
283 SACL R_LPCF3_OUT ; s t o r e o u t p u t from LPCF3
284 *
285 * lowpass comb filter 4
286 *
287 ; l o a d b−c o e f f i c i e n t t o s t a c k
288 LARP 4 ; s e t ARP −> AR4
289 LAC * ,0 ,7 ; l o a d second b−c o e f f i c i e n t t o a c c u m u l a t o r
290 SACL *+ ; push b−c o e f f i c i e n t t o s t a c k
291 ; push f i l t e r number t o s t a c k
292 LACK 3 ; l o a d a c c u m u l a t o r w i t h f i l t e r number 3
293 SACL * ; push f i l t e r number 3 t o s t a c k
294 CALL LPCF ; c a l l comb f i l t e r s u b r o u t i n e
295 ; dSP −> o u t p u t sample
296 LAC * ; move o u t p u t sample t o a c c u m u l a t o r
297 *
298 * sum of comb filter outputs
299 *
300 ; compute sum
301 ADD R_LPCF1_OUT ; add f i r s t o u t p u t from LPCF t o ACC
302 ADD R_LPCF2_OUT ; add second o u t p u t from LPCF t o ACC
303 ADD R_LPCF3_OUT ; add t h i r d o u t p u t from LPCF t o ACC
304 ; change s t a c k p o i n t e r ( p r e p a r e t o l o a d s a m p l e s t o s t a c k from LPCF sum b u f f e r )
305 SBRK 2 ; decrement s t a c k p o i n t e r t w i c e
306 ; dSP −> x [ n−d ]
307 ; u p d a t e LPCF sum b u f f e r
308 SACL *+ ,0 ,4 ; push new sum sample t o s t a c k
309 ; dSP−1 −> y [ n ] ( new sum sample )
310 LAR AR4 , R _ L P C F _ S U M _ I N _ A D D ; l o a d a d d r e s s o f i n p u t p o i n t e r t o AR4
311 LAC * ,0 ,7 ; copy y [ n−m] t o ACC
312 SACL *- ; push y [ n−m] t o s t a c k
313 ; dSP −> y [ n ] ( new sum sample )
314 LAC *+ ,0 ,4 ; copy y [ n ] t o a c c u m u l a t o r .
315 ; dSP −> y [ n−m] ( new sum sample )
316 SACL *- ; u p d a t e sum b u f f e r
317 SAR AR4 , R _ L P C F _ S U M _ I N _ A D D ; update in p o i n t e r address
318 ; wrap AR4 i f n e c e s s a r y
319 LRLK AR0 , R_LPCF_SUM_TOP ; l o a d t o p o f sum b u f f e r t o
320 CMPR 1 ; i f AR4 < AR0, t h e n TC=1
321 BBZ R_APF_CALL1 ; branch i f TC = 0 − no wrapping n e c e s s a r y
322 ; wrapping
323 LALK R_LPCF_SUM_BOT ; l o a d a c c u m u l a t o r w i t h bottom a d d r e s s o f sum b u f f e r
324 SACL R_LPCF_SUM_IN_ADD ; u p d a t e i n p o i n t e r w i t h bottom a d d r e s s
325 *
326 * allpass filter 1
327 *
328 R_APF_CALL1 :
329 ; p r e p a r e s t a c k f o r APF f u n c t i o n s
330 LARP 7 ; s e t ARP −> AR7
331 MAR *+ ; increment s t a c k p o i n t e r
332 ; dSP−1 −> y [ n−m]
333 ; move f i l t e r number t o s t a c k
334 LACK 0 ; s e t u p f i l t e r number i n s t a c k
335 SACL * ; copy f i l t e r number t o s t a c k
336 ; dSP −> f i l t e r number
337 CALL R_APF ; c a l l allpass f i l t e r function
338 ; dSP −> f i l t e r number
339 *
340 * allpass filter 2
341 *
342 ; move f i l t e r number t o s t a c k
343 LACK 1 ; s e t u p f i l t e r number i n s t a c k
344 SACL * ; copy f i l t e r number t o s t a c k
199

345 ; dSP −> f i l t e r number


346 CALL R_APF ; c a l l allpass f i l t e r function
200

O Source Code
347 ; dSP −> f i l t e r number
348 *
349 * compute output sample
350 *
351 SBRK 2 ; decrement s t a c k p o i n t e r t w i c e
352 ; dSP −> y [ n ]
353 LAC *- ; copy o u t p u t sample from r e v e r b e r a t o r t o ACC
354 ADD * ; add o r i g i n a l i n p u t sample t o r e v e r b e r a t e d sample
355 SACL * ; move o u t p u t sample t o s t a c k
356 ; restore settings
357 LDPK 0 ; s e t page p o i n t e r t o 0
358 RET ; r e t u r n from r e v e r b a l g o r i t h m
359
360 ********************************************
361 * Lowpass Comb filter function
362 * Implements a lowpass comb filter
363 * Use of function :
364 * 1) push address of x [n - d ] to stack from pre - delay buffer
365 * 2) push address of x [n -d -1] to stack from pre - delay buffer
366 * 3) push b coefficient to stack
367 * 4) push filter number to stack . Number 0 to 3.
368 * Overwrites b coefficient with output sample
369 * The stack pointer points to the output sample
370 ********************************************
371 LPCF :
372 *
373 * load buffer pointers into AR1 to AR3
374 *
375 ; find s t a r t address of b u f f e r pointers
376 LT *+ ; copy f i l t e r number from s t a c k t o T−r e g
377 ; dSP−1 −> f i l t e r number
378 MPYK 4 ; m u l t i p l y f i l t e r number w i t h a d d r e s s o f f s e t b e t w e e n d i f f e r e n t s u c c e s s i v e
f i l t e r pointers
379 PAC ; copy P−r e g i s t e r t o a c c u m u l a t o r
380 ADLK LPCF1_BUF_TOP_ADD ; add s t a r t a d d r e s s o f b u f f e r p o i n t e r a r r a y t o a d d r e s s o f f s e t
381 ; s a v e s t a r t a d d r e s s t o AR0
382 SACL * ; push s t a r t a d d r e s s o f b u f f e r p o i n t e r s t o s t a c k
383 ; dSP −> s t a r t a d d r e s s
384 LAR AR5 ,* - ,5 ; s a v e s t a r t a d d r e s s o f b u f f e r p o i n t e r s t o AR5 . S e t ARP−AR5
385 ; dSP −> f i l t e r number
386 ; l o a d AR1 t o AR3 w i t h b u f f e r p o i n t e r s
387 LAR AR1 ,*+ ; l o a d AR1 w i t h t o p o f b u f f e r a d d r e s s
388 LAR AR2 ,*+ ; l o a d AR2 w i t h i n p u t b u f f e r a d d r e s s
389 LAR AR3 ,* - ,7 ; l o a d AR3 w i t h bottom b u f f e r a d d r e s s
390 *
391 * push old output samples to stack ( y [n -1] , y [n - m ] and y [n -m -1])
392 *
393 ; move b−c o e f f i c i e n t from s t a c k t o T−r e g
394 MAR *- ; decrement s t a c k p o i n t e r
395 ; dSP −> b−c o e f f i c i e n t
396 LT * ; copy b−c o e f f i c i e n t t o T−r e g .
397 ; move a1 t o s t a c k
398 LALK R_A1 ; s e t u p a1 i n ACC
399 SACL *+ ,0 ,2 ; move a1 t o s t a c k . S e t ARP −> AR2
400 ; dSP−1 −> a1−c o e f f i c i e n t
401 ; AR2 −> i n p o i n t e r −> y [ n−1]
402 ; g e t y [ n−1] and push t o s t a c k
403 LAC * - ,0 ,7 ; copy y [ n−1] t o a c c u m u l a t o r
404 ; AR2 −> i n p o i n t e r −> y [ n−m−1]
405 SACL *+ ; push y [ n−1] t o s t a c k
406 ; dSP−1 −> y [ n−1]
407 ; wrap AR2 i f n e c e s s a r y
408 SAR AR1 ,* ; push AR1 t o s t a c k
409 LAR AR0 ,* ,2 ; copy t o p p o i n t e r (AR1) t o AR0
410 CMPR 1 ; i f AR2 < AR0, t h e TC = 1
411 LARP 7 ; s e t ARP−>AR7
412 BBZ R_GET_YNM1 ; branch i f TC = 0 − wrapping n o t n e c e s s a r y
413 ; wrapping
414 SAR AR3 ,* ; push AR3 t o s t a c k
415 LAR AR2 ,* ; s e t AR2 = AR3 ( i n p o i n t e r = bottom p o i n t e r )
416 R_GET_YNM1 :
417 ; g e t y [ n−m−1] and push t o s t a c k
418 SAR AR2 ,* ; push AR2 t o s t a c k
419 LAR AR1 ,* ,2 ; copy AR2 t o AR1 => AR1 c o n t a i n s i n p o i n t e r t o y [ n ]
420 LAC * - ,0 ,7 ; copy y [ n−m−1] t o a c c u m u l a t o r
421 ; AR2 −> i n p o i n t e r −> y [ n−m]
422 SACL *+ ,0 ,2 ; push y [ n−m−1] t o s t a c k
423 ; dSP−1 −> y [ n−m−1]
424 ; wrap AR2 i f n e c e s s a r y
425 CMPR 1 ; i f AR2 < AR0, t h e n TC = 1
426 BBZ R_GET_YNM2 ; branch i f TC = 0 − wrapping n o t n e c e s s a r y
427 ; wrapping
428 LARP 7 ; s e t ARP−>AR3
429 SAR AR3 ,* ; push AR3 t o s t a c k
430 LAR AR2 ,* ,2 ; s e t AR2 = AR3 ( i n p o i n t e r = bottom p o i n t e r )
431 R_GET_YNM2 :
201

432 ; g e t y [ n−m] and push t o s t a c k


433 LAC * ,0 ,7 ; copy y [ n−m] t o a c c u m u l a t o r
202

O Source Code
434 ; AR2 −> i n p o i n t e r −> y [ n−m]
435 SACL * ,0 ,5 ; push y [ n−m] t o s t a c k
436 ; dSP −> y [ n−m]
437 ; s e t AR2 t o o v e r w r i t e y [ n−m−1] w i t h y [ n ] when i t i s c a l c u l a t e d
438 SAR AR1 ,* ,7 ; update in p o i n t e r b u f f e r
439 *
440 * compute the difference equation given by
441 * y [ n ] = w [ n ] - a1 * w [n -1]+ a1 * y [n -1]+ b * y [n - m ]+ b * y [n -m -1] where w [ n ]= x [n - d ]
442 *
443 ZAC ; zero accumulator
444 ; m u l t i p l y T−r e g w i t h y [ n−m] . Accumulate .
445 MPY *- ; m u l t i p l y b and y [ n−m]
446 ; dSP −> y [ n−m−1]
447 ; m u l t i p l y T−r e g w i t h y [ n−m− 1 ] . Accumulate .
448 MPYA *- ; m u l t i p l y b and y [ n−m− 1 ] . P r e v i o u s P−r e g i s a c c u m u l a t e d
449 ; dSP −> y [ n−1]
450 ; l o a d T−r e g w i t h a1 and m u l t i p l y w i t h y [ n − 1 ] . Accumulate .
451 LTA *- ; copy y [ n−1] from s t a c k t o T−r e g
452 ; dSP −> a1−c o e f f i c i e n t
453 MPY * ; c a l c u l a t e a1 ∗ y [ n−1]
454 ; dSP −> a1−c o e f f i c i e n t
455 ; m u l t i p l y T−r e g w i t h −w [ n − 1 ] . Accumulate
456 LTA *- ; copy a1 from s t a c k t o T−r e g
457 ; dSP −> w [ n−1]
458 MPY *- ; c a l c u l a t e a1 ∗w [ n−1]
459 ; dSP −> w [ n ]
460 SPAC ; s u b t r a c t p r e v i o u s p r o d u c t from a c c u m u l a t o r
461 ; load x [ n ] i n t o accumulator
462 ADD *+ ,15 ; add w [ n ] t o a c c u m u l a t o r
463 ; dSP −> w [ n−1]
464 MAR *+ ; increment s t a c k p o i n t e r
465 ; dSP −> a1−c o e f f i c i e n t
466 *
467 * Store output sample and update buffer
468 *
469 ; s h i f t data in accumulator
470 SFL ; s h i f t accumulator l e f t
471 ; s t o r e o u t p u t sample on s t a c k
472 SACH * ,0 ,1 ; push o u t p u t sample t o s t a c k . S e t ARP −> AR1
473 ; update b u f f e r
474 SACH * ,0 ,7 ; push o u t p u t sample t o b u f f e r ( l o c a t i o n d e t e r m i n e d by AR1) . S e t ARP −> AR7
475 ; dSP −> y [ n ]
476 RET ; r e t u r n from l o w p a s s comb f i l t e r f u n c t i o n
477 ********************************************
478 * Allpass filter function
479 * Implements a allpass filter
480 * Use of function :
481 * 1) push address of y [ n ] to stack from sum buffer
482 * 2) push address of y [n - m ] to stack from sum buffer
483 * 3) push filter number to stack . Number 0 to 1.
484 * Overwrites y [ n ] and y [n - m ] with new output samples
485 * The stack pointer points to filter number
486 ********************************************
487 R_APF :
488 *
489 * load buffer pointers into AR1 to AR3
490 *
491 ; find s t a r t address of b u f f e r pointers
492 LT *+ ; copy f i l t e r number from s t a c k t o T−r e g
493 ; dSP−1 −> f i l t e r number
494 MPYK 4 ; m u l t i p l y f i l t e r number w i t h a d d r e s s o f f s e t b e t w e e n d i f f e r e n t s u c c e s s i v e
f i l t e r pointers
495 PAC ; copy P−r e g i s t e r t o a c c u m u l a t o r
496 ADLK RAPF1_BUF_TOP_ADD ; add s t a r t a d d r e s s o f b u f f e r p o i n t e r a r r a y t o a d d r e s s o f f s e t
497 ; s a v e s t a r t a d d r e s s t o AR5
498 SACL * ; push s t a r t a d d r e s s o f b u f f e r p o i n t e r s t o s t a c k
499 ; dSP −> s t a r t a d d r e s s
500 LAR AR5 ,* - ,5 ; s a v e s t a r t a d d r e s s o f b u f f e r p o i n t e r s t o AR5 . S e t ARP−AR5
501 ; dSP −> f i l t e r number
502 ; l o a d AR1 t o AR3 w i t h b u f f e r p o i n t e r s
503 LAR AR1 ,*+ ; l o a d AR1 w i t h t o p o f b u f f e r a d d r e s s
504 LAR AR2 ,*+ ; l o a d AR2 w i t h i n p u t b u f f e r a d d r e s s
505 LAR AR3 ,* - ,2 ; l o a d AR3 w i t h bottom b u f f e r a d d r e s s
506 *
507 * push old output sample to stack ( y [n - d ])
508 *
509 MAR * - ,7 ; p o i n t t o y [ n−d ]
510 ; wrap AR2 i f n e c e s s a r y
511 SAR AR1 ,* ; push AR1 t o s t a c k
512 LAR AR0 ,* ,2 ; copy t o p p o i n t e r (AR1) t o AR0
513 CMPR 1 ; i f AR2 < AR0, t h e n TC = 1
514 BBZ R_COM_APF ; branch i f TC = 0 − wrapping n o t n e c e s s a r y
515 ; wrapping
516 LARP 7 ; s e t ARP−>AR3
517 SAR AR3 ,* ; push AR3 t o s t a c k
518 LAR AR2 ,* ; s e t AR2 = AR3 ( i n p o i n t e r = bottom p o i n t e r )
203

519 R_COM_APF :
520 LARP 5 ; s e t ARP −> AR5
204

O Source Code
521 SAR AR2 ,* ,2 ; update in p o i n t e r
522 LAC * ,0 ,7 ; copy y [ n−d ] t o ACC
523 SACL *+ ; push o l d o u t p u t sample t o s t a c k
524 ; dSP−1 −> y [ n−d ]
525 *
526 * compute the difference equation given by
527 * y [ n ] = w [n - d ] -0.7* w [ n ]+0.7* y [n - d ] , where w [ n ] = y [ n ] from input arguments
528 *
529 ; s t o r e g =0.7 t o s t a c k
530 LALK R_AP_GAIN ; s e t u p 0 . 7 i n ACC
531 SACL * ; push 0 . 7 t o s t a c k
532 ; compute
533 ZAC ; zero accumulator
534 LT *- ; s e t T−r e g = 0 . 7
535 ; dSP −> y [ n−d ]
536 ; m u l t i p l y T−r e g w i t h y [ n−m] . Accumulate .
537 MPY *- ; m u l t i p l y 0 . 7 and y [ n−d ]
538 ; dSP −> w [ n−d ]
539 ; add ACC w i t h w [ n−d ]
540 ADD * - ,15 ; add w [ n−d ] t o a c c u m u l a t o r
541 ; dSP −> w [ n ]
542 ; m u l t i p l y T−r e g w i t h y [ n−m− 1 ] . Accumulate .
543 MPYA * ; m u l t i p l y b and y [ n−m− 1 ] . P r e v i o u s P−r e g i s a c c u m u l a t e d
544 ; dSP −> y [ n−1]
545 SPAC ; s u b t r a c t 0 . 7 ∗w [ n ] from ACC
546 *
547 * Store output sample and update buffer
548 *
549 ; s h i f t data in accumulator
550 SFL ; s h i f t accumulator l e f t
551 ; s t o r e o u t p u t sample on s t a c k
552 SACH *+ ,0 ,2 ; push o u t p u t sample t o s t a c k . S e t ARP −> AR2
553 ; dSP −> w [ n−d ]
554 ; update b u f f e r
555 SACH * ,0 ,7 ; push o u t p u t sample t o b u f f e r ( l o c a t i o n d e t e r m i n e d by AR2) . S e t ARP −> AR7
556 ; move d e l a y e d o u t p u t ( y [ n−d ] ) sample one down i n s t a c k
557 MAR *+ ; increment s t a c k p o i n t e r
558 ; dSP −> y [ n−d ]
559 LAC *- ; copy d e l a y e d o u t p u t ( y [ n−d ] ) sample t o ACC
560 ; dSP −> w [ n−d ]
561 SACL *+ ; push d e l a y e d o u t p u t ( y [ n−d ] ) sample t o s t a c k
562 ; dSP−1 −> y [ n−d ]
563 ; move
564 RET ; r e t u r n from a l l p a s s f i l t e r f u n c t i o n
Enclosure: CD-ROM

As enclosure a CD-ROM is attached. This CD-ROM contains information to be studied


if the reader desires additional insight into the different topics of the report.

Contents of the CD-ROM:

• Project proposal.

• Report (PDF-format).

• Pictures of the guitar effects unit.

• Datasheets.

• Circuits.

• Source code.

• Test scripts.

• Internet bibliography.

• Abel code.

205

You might also like