multi-e ect processor for acoustic...

191
Aalborg University, Department of Electronic Systems, Section Acoustics Multi-Effect Processor for Acoustic Guitar Design and Implementation in Matlab Group: 790 Names: Eduardo Fonseca Montero Javier Gald´ on Romero Ignacio P´ erez Pablos Estrella Merino Siles Lutz Ehrig Supervisor: Christian Sejer Pedersen Date: December 16, 2007

Upload: ngobao

Post on 20-Apr-2018

219 views

Category:

Documents


4 download

TRANSCRIPT

Page 1: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

Aalborg University, Department of Electronic Systems, Section Acoustics

Multi-Effect Processorfor

Acoustic Guitar

Design and Implementation in Matlab

Group: 790

Names: Eduardo Fonseca MonteroJavier Galdon RomeroIgnacio Perez PablosEstrella Merino SilesLutz Ehrig

Supervisor: Christian Sejer Pedersen

Date: December 16, 2007

Page 2: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics
Page 3: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

Institute for Elektronic Systems

Elektronics & Electrotechnics

Fredriks Bajersvej 7

Telefon 96 35 86 50

Fax 98 15 15 83

http://kom.aau.dk/

Title:

Multi-Effect Processor for AcousticGuitar - Design and Implementation inMatlab

Theme:

Digital Signal Processing

Project period:

winter semester 2007/2008

Project group:

07gr790

Participants:

Eduardo Fonseca MonteroJavier Galdon RomeroIgnacio Perez PablosEstrella Merino SilesLutz Ehrig

Supervisor:

Christian Sejer Pedersen

Copies: 8

Page numbers: 191

Appendices: 6

Enclosures: CD-ROM

Date of completion December 16, 2007

Synopsis:

A multi-effect processor for anacoustic guitar was designed andimplemented in Matlab. Someof the most common used ef-fects and audio signal enhance-ment units were included: com-pressor, noise gate, equalizer, re-verberation and eight delay andmodulation effects as well. Theprocessor was designed to treattwo input signals independentlyand to allow different signal rout-ings for guitar and vocals. SinceMatlab is not optimized forsample-by-sample operations, itis not possible to provide pro-cessed data in real time. Arbi-trarily waveform audio files areused for input and output.

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

Page 4: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

IV

Page 5: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

Preface

This final report was written by students of the 7th semester in the AcousticsSection, Department of Electronic Systems, Aalborg University. It marks the endof a semester project that lasts from September 3rd to December 17th, 2007.

The project contains the design of a multi-effect processor for acoustic guitarand its implementation in Matlab. According to the content of the semester,that focuses on stochastic signal processing, the focal point in this report lies inthe processing of an audio signal by the different implemented effects and signalenhancement algorithms as well.

The proposal of this project was given by Miguel Angel Aranda de Toro andsupervised by Christian Sejer Pedersen. We would like to thank Christian forhis support, his critical feedback and for the fruitful discussions. In addition wewould also like to thank Miguel for making an acoustic guitar available for us.

Aalborg, December 16, 2007.

Eduardo Fonseca Montero Javier Galdon Romero

Ignacio Perez Pablos Estrella Merino Siles

Lutz Ehrig

V

Page 6: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

VI

Page 7: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

Report Overview

The introduction presented in chapter 1 will introduce difficulties a guitar playermight be confronted with and therefore the motivation for this project will begiven there.

The specifications and a general discussion of aspects concerning the effects pro-cessor can be found in chapter 2.

This first overview of the whole unit will be followed by the main part of thisreport, a very detailed description of the implemented effects in chapter 3. Eacheffect will be presented in a separate section, where the theoretical background,the design and the implementation in Matlab will be elaborated.

Once the particular effects are introduced, in chapter 4 the merge of them,resulting in one final module, will be described. Different options how this canbe done will be presented and how the musician may take advantage of them.

In chapter 5 the evaluation procedure will be described. In addition to countlessindividual assessments, the set up of an informal listening test will be presentedshortly as well as the obtained results.

A step towards a practical application will be shown in chapter 6, where anapproach for a real time implementation is presented. Due to the fact that thispart is additional, only some effects were rewritten as a working example.

Finally chapter 7 will conclude this report and the project and summarizing theobtained results.

VII

Page 8: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

VIII

Page 9: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

Nomenclature

This section gives a short overview of used conventions for numbering figures,equations and tables and the used abbreviations.

� figures and tables are numbered consecutively by the number of chapter andfollowed by the number of the section; for instance figure 3.2.1 refers to thefirst figure in the second section within the third chapter

� equations are only numbered in the way mentioned above, when the textcontains a reference to a formula

� the name of the section and the associated number can be seen on the rightof the header of each page except the first page of a chapter

Abbreviation Description

AES Audio Engineering SocietyDSP Digital Signal Processor

DTFT Discrete-Time Fourier TransformFDN Feedback Delay NetworkFIR Finite Impulse Response

FOPHC First-Order Peak Hold CircuitIIR Infinite Impulse ResponseLFO Low Frequency OscillatorMIDI Musical Instrument Digital InterfaceVST Steinberg’s Virtual Studio Technology

IX

Page 10: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

X

Page 11: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

Contents

1 Introduction 11.1 Guitar and Effects Development . . . . . . . . . . . . . . . . . . . 11.2 Acoustic Guitar . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21.3 Sound Processing . . . . . . . . . . . . . . . . . . . . . . . . . . . 3

2 The Effect Processor 52.1 Problem Formulation . . . . . . . . . . . . . . . . . . . . . . . . . 62.2 The Effects Processor in the Sound Path . . . . . . . . . . . . . . 62.3 Specifications . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 8

3 The Effects 113.1 Dynamic Processors . . . . . . . . . . . . . . . . . . . . . . . . . . 12

3.1.1 Compressor . . . . . . . . . . . . . . . . . . . . . . . . . . 123.1.2 Noise Gate . . . . . . . . . . . . . . . . . . . . . . . . . . . 19

3.2 Equalizer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223.2.1 Equalizer Design . . . . . . . . . . . . . . . . . . . . . . . 223.2.2 Implementation . . . . . . . . . . . . . . . . . . . . . . . . 253.2.3 Results and Conclusion . . . . . . . . . . . . . . . . . . . . 26

3.3 Delay . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 283.3.1 Echo Unit and Feedback Delay . . . . . . . . . . . . . . . 283.3.2 Dynamic Delay . . . . . . . . . . . . . . . . . . . . . . . . 363.3.3 Ping Pong Delay . . . . . . . . . . . . . . . . . . . . . . . 393.3.4 Analog Delay . . . . . . . . . . . . . . . . . . . . . . . . . 42

3.4 Reverberation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433.4.1 Theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433.4.2 Design . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 463.4.3 Implementation . . . . . . . . . . . . . . . . . . . . . . . . 513.4.4 Results and Conclusion . . . . . . . . . . . . . . . . . . . . 54

3.5 Modulation Effects . . . . . . . . . . . . . . . . . . . . . . . . . . 573.5.1 Flanger and Chorus . . . . . . . . . . . . . . . . . . . . . . 573.5.2 Vibrato . . . . . . . . . . . . . . . . . . . . . . . . . . . . 633.5.3 Tremolo . . . . . . . . . . . . . . . . . . . . . . . . . . . . 653.5.4 High-cut filter . . . . . . . . . . . . . . . . . . . . . . . . . 68

XI

Page 12: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

CONTENTS

4 Combination of Effects 694.1 Routings . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 704.2 Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71

4.2.1 Decision Vector . . . . . . . . . . . . . . . . . . . . . . . . 724.2.2 Definition Part . . . . . . . . . . . . . . . . . . . . . . . . 744.2.3 Loading Signals . . . . . . . . . . . . . . . . . . . . . . . . 744.2.4 Preliminary Calculations . . . . . . . . . . . . . . . . . . . 744.2.5 Core or Engine of the Processor . . . . . . . . . . . . . . . 74

5 The Effects Evaluation 775.1 Listening Test . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 78

5.1.1 Preliminary Analysis . . . . . . . . . . . . . . . . . . . . . 785.1.2 Listening Room . . . . . . . . . . . . . . . . . . . . . . . . 815.1.3 The Test Basis . . . . . . . . . . . . . . . . . . . . . . . . 82

5.2 Interpretation of the Results . . . . . . . . . . . . . . . . . . . . . 86

6 Real Time Implementation 896.1 SynthMaker . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 896.2 Real Time Effects Processor . . . . . . . . . . . . . . . . . . . . . 91

6.2.1 Compressor . . . . . . . . . . . . . . . . . . . . . . . . . . 926.2.2 Equalizer . . . . . . . . . . . . . . . . . . . . . . . . . . . 926.2.3 Tremolo . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94

7 Conclusions 97

A Dynamic Processors 99A.1 Compressor: Further Information . . . . . . . . . . . . . . . . . . 99A.2 Compressor: Parameters Description . . . . . . . . . . . . . . . . 100A.3 Compressor: Considered Designs . . . . . . . . . . . . . . . . . . 100A.4 Noise Gate: Parameters Description . . . . . . . . . . . . . . . . . 102

B Filter Design 103B.1 FIR Filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103B.2 IIR-Filter . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 104

C Tail Calculation 109

D Reverberation Algorithms 113

E Listening Test 117E.1 Listening Test Form . . . . . . . . . . . . . . . . . . . . . . . . . 117E.2 Results of the Listening Test . . . . . . . . . . . . . . . . . . . . . 121

E.2.1 Task 1: Equalizer . . . . . . . . . . . . . . . . . . . . . . . 121

XII

Page 13: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

CONTENTS

E.2.2 Task 2: Compressor . . . . . . . . . . . . . . . . . . . . . . 122E.2.3 Task 3: Noise Gate . . . . . . . . . . . . . . . . . . . . . . 122E.2.4 Task 4: Delay . . . . . . . . . . . . . . . . . . . . . . . . . 122E.2.5 Task 5: Modulation Effects . . . . . . . . . . . . . . . . . 123E.2.6 Task 6: Reverb I . . . . . . . . . . . . . . . . . . . . . . . 123E.2.7 Task 7: Reverb II . . . . . . . . . . . . . . . . . . . . . . . 123

F Matlab-Code 125F.1 Processor Main Function . . . . . . . . . . . . . . . . . . . . . . . 125F.2 Noise Gate . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 143F.3 Compressor . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145F.4 Equalizer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 146

F.4.1 Signal Equalizing . . . . . . . . . . . . . . . . . . . . . . . 146F.4.2 Calculating Filter Coefficients - Peak Filter . . . . . . . . . 149F.4.3 Calculating Filter Coefficients - Shelving Filter (low) . . . 150F.4.4 Calculating Filter Coefficients - Shelving Filter (high) . . . 151

F.5 Delay . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152F.5.1 Echo Delay . . . . . . . . . . . . . . . . . . . . . . . . . . 152F.5.2 Feedback Delay . . . . . . . . . . . . . . . . . . . . . . . . 153F.5.3 Dynamic Delay . . . . . . . . . . . . . . . . . . . . . . . . 154F.5.4 Ping Pong Delay . . . . . . . . . . . . . . . . . . . . . . . 156

F.6 Reverberation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157F.7 Modulation Effects . . . . . . . . . . . . . . . . . . . . . . . . . . 164

F.7.1 Flanger . . . . . . . . . . . . . . . . . . . . . . . . . . . . 164F.7.2 Chorus . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165F.7.3 Vibrato . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166F.7.4 Tremolo . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167

XIII

Page 14: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

XIV

Page 15: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

Chapter 1

Introduction

The variety of sounds a professional musician is able to obtain by playing aninstrument in different ways is enormous. Beyond, it has always been a desire bymusicians and composers as well, to enrich this variety and to amaze the audienceanew. For this reason instruments were and are in constant development. Theart of playing has changed over the time and additional effects have been added.

One of the most common used effect, related to classic instruments is damping.Different realizations of dampers can be found for all string instruments, likeviolin and cello, for most of the wind instruments, as trumpet and tromboneand for percussion instruments but, particularly, for the pianoforte and the grandpiano.

In fact, for the piano the damper is an inherent part of the instrument. Butalready in the early days of piano development the counterpart of the damper,the sustain pedal, was introduced. It raises the dampers from all strings, allowingthem to vibrate freely [Rip07]. This effect can be heard for instance in the firstmovement of Beethoven’s Piano Sonata No. 14, also known as the MoonlightSonata. It would be unimaginable to play this piece of music without using thesustain pedal.

1.1 Guitar and Effects Development

The desire for higher volume of the sound produced by a guitar in the early yearsof the 20th century, when smaller groups of musicians formed bands, acceleratedthe development of this instrument to a great extent. By the end of the 1920s,steel-strung, flat-top guitars, altered structures to bear the higher tension of the

1

Page 16: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

1. Introduction

steel strings were manufactured. Instead of one single circular soundhole, two f-shaped holes for a greater sound projection were used [Bac07]. The first of theseguitars, the Gibson L5 was produced in 1922.

Followed by electric-acoustic guitars equipped with simple magnetic pickups, thefirst solid-bodied electrical guitar was introduced by Fender in 1948 and markedalso the begin of electronic sound effects development. Often guitar amplifiersincorporated such sound-modifying devices but it was also common to connectthem in form of pedals between instrument and amplifier [Bac07]. In the 1950samplifiers provided in addition to simple tone control for treble and bass, springreverberation or electronic tremolo units. In the 1960s guitarists began experi-menting with feedback and distortion by feeding the output of one amplifier intoanother [Pic07].

With the upcoming digital technology in the second half of the 20th century andthe ever-increasing speed of digital devices, it is nowadays without any difficultiespossible to include many sound processing effects and signal enhancing units inonly one DSP. Hence it is not necessary anymore to use for each effect a dedicatedanalog device. Although this is still preferred by most of professional guitarists,more and more digital multi-effect units are available.

1.2 Acoustic Guitar

The impact of the electric guitar was so huge, that many new music genres de-veloped shortly. But still, for many of them acoustic guitars are indispensablebecause of the different timbre. As mentioned in the section above, the acousticguitar consists, in contrast to common used electric guitars, of a hollow body.Thus the frequency spectrum expands to lower frequencies and results in a dif-ferent sound. In addition, the dynamic range of an acoustic guitar is wider thanin the electric guitar.

When it is necessary to record or to amplify an acoustic guitar, several methodscan be used:

� a microphone can be placed in front of the soundhole,

� a microphone can be placed inside the guitar body,

� a pickup can be utilized.

The first method might be the best for obtaining the most natural sound. But itconstrains the free movement of the artist and the microphone might catch other

2

Page 17: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

1.3 Sound Processing

Figure 1.3.1: Spectrum view of a pickup (left) and a microphone signal(right). The microphone was placed in front of the soundhole.The amplitude of the high frequencies is for the pickup signalhigher than for the output of the microphone.

instruments playing on stage. By placing the microphone inside the body thisproblem can be solved partially. But it is still very susceptible for unintentionalfeedback. Therefore the soundhole can be covered.

Instead of using a microphone, the vibration of the strings or the guitar body,can be transformed directly to an electric signal by using a pickup. This can bea piezo-ceramic, that is placed between bridge and body or an electromagneticpickup, similar to the pickups used for electric guitars, placed under the strings,for instance in the soundhole. For the latter solution steel strings are necessary.

1.3 Sound Processing

In order to combine the benefits of using a microphone and a pickup, both trans-ducers can be used together. This means that two signals are obtained and haveto be mixed. Due to the different characteristics of these signals, they may haveto be treated differently before they were mixed together, see figure 1.3.1.

Furthermore, the artist might want to use effects to achieve a special artisticexpression by using a certain sound. This can simply be a boost of the gainduring certain passages or a change of the timbre of the instrument. It is obviousthat this task can not be done by a sound engineer. Hence, a special effectprocessing unit is necessary, that can easily be controlled by the musician whileplaying the guitar.

3

Page 18: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

1. Introduction

As mentioned before, this unit has to be adapted especially for an acoustic guitar,because of the following features of this instrument:

� wide dynamic range

� wide frequency spectrum

� two guitar output signals

An effect processor that does not reflect those special requirements is not rec-ommended for an acoustic guitar. This is probably the case for all processorsdesigned for electric guitars.

Hence, the purpose of this project is to implement a virtual effect processor inMatlab, that takes the above mentioned features of an acoustic guitar intoconsideration. The most important effects, suitable for acoustic guitar, should beimplemented.

4

Page 19: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

Chapter 2

The Effect Processor

In the previous chapter, a historical introduction of guitar and audio effects isincluded, an overview about concrete features of an acoustic guitar is describedand the motivation for the project is presented. In the current chapter the projectproblem formulation is stated and general aspects and specifications of the im-plemented effect processor are described.

Nowadays, there is a clear trend towards completely digital audio systems. De-spite audio has remained mostly analog in the last stage of the sound chain,the increase in digital infrastructures, along with new digital sound sources hasconverted working with audio in digital domain into common practice [All01].One of the advantages of dealing with audio in the digital domain is to be ableto use digital signal processing techniques in order to achieve a huge number offunctions and treatments that would entail certain difficulties in analog domain.A multi-effect processor, able to perform several operations such as equalization,compression and other sound effects is an example of the power of digital signalprocessing.

Perhaps the most important requirement a multi-effect processor should provide isto produce good sound quality, while offering configurable algorithms [All01] andan user-friendly interface. Thus, the user would be able to handle the processorand change its parameters in an optimal way ensuring a powerful performance.

It is possible to find these systems in many different versions. Traditionally theywere mostly built in hardware, meaning DSP based devices that would acquire andgive analog signals with the advantage of being portable and relatively affordable.However, lately there has been an increasing trend to implement these devicesinto software by means of using the resources of a CPU. These virtual effectsprocessors would provide the same processing capability as their predecessors,

5

Page 20: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

2. The Effect Processor

but with the advantage of being included in the computer applications, avoidingthe need of acquiring any other hardware. Thus, this type of virtual or PC-basedprocessors have become very popular, reaching not only professional audio usersbut a wide spectrum of amateur population.

Although the effects processor to be created in this project is PC-based, the ideais to accomplish it while orientating its development as if it was a hardware baseddevice.

2.1 Problem Formulation

As mentioned in the introduction of this report, the aim of this project is todesign and implement a multi-effect processor for an acoustic guitar in Matlab.Therefore, the scope of this project consists of studying, designing and imple-menting a number of effects in Matlab, and combining them together in orderto obtain an offline application to be used as an effect processor. Although itwould have been optimal to develop such a processor in real time using a DSP, itwas not possible due to time limitations.

To test the system, several waveform audio files were recorded using as source anacoustic guitar. They are meant to be the input of the system and the way totest the results of the application.

Also, it was decided that an additional part would be added. Instead of developingan entire graphical user interface for the processor in Matlab, it was thoughtit would be of more interest to spend that effort in achieving a sample of realtime implementation. In this way, some of the effects were also implemented inSynthMaker audio programming tool, as presented in chapter 6.

2.2 The Effects Processor in the Sound Path

An effect processor thought to be employed with an acoustic guitar has one mainobjective: modify the initial dry sound to a certain extent or provide it withcertain shades so as to obtain a more powerful and satisfactory sound while pre-serving its natural character. Despite it is a common goal for all effect processors,when employed to process signals coming from an acoustic guitar, there may beseveral slightly distinct configurations.

The standard setup for an effects processor designed for an acoustic guitar wouldbe as depicted in the figure 2.2.1. That figure shows how the pickup of the guitar

6

Page 21: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

2.2 The Effects Processor in the Sound Path

Figure 2.2.1: Typical setup for an effect processor based on guitar andpickup [GNa07].

is connected to the processor. There, the analog singnal would be digitalized andprocessed. Finally, the processed signal would be converted into analog domainleading either a mono or stereo outcoming output to a mixer.

Although this is the basic setup, it is common for professional performers to em-ploy another more complex setup based on the use of both pickup and microphoneas figure 2.2.2 shows. According to this figure, there are now two signals coming

Figure 2.2.2: Typical setup for an effect processor based on guitar andpickup and microphone [GNa07].

7

Page 22: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

2. The Effect Processor

from the guitar, feeding the effect processor. Their treatment would be similar tothe previous case. Firstly, they would be digitalized and processed. Then, havingapplied the desired effects, those processed signals would be converted into analogdomain and led to the next device of the sound path (e.g. a mixer). Although infigures 2.2.1 and 2.2.2 the last element of the sound chain is a mixer, that is justan example. A dedicated amplifier, for instance, could take place instead.

It is widely accepted that this latter setup is the appropriate way of capturingthe sound of an acoustic guitar, that is, by means of a combination of eitherdynamic or condenser microphone and a pickup [Har07]. Consequently, in anattempt to create an effect processor specially tuned for an acoustic guitar, thatconfiguration was chosen for this project (see figure 2.2.2). In that way, thepossibility of two signals feeding the processor is considered. Furthermore, inorder to provide the processor with more versatility, it was developed in such away that the signal coming from the microphone could be not only a guitar signalbut also a vocal signal. That involves giving the chance to process it in a differentmanner, according to its concrete needs, as it will be discussed later on in chapter4.

2.3 Specifications

Since the implemented multi-effect processor is an offline application and it is notimplemented in hardware, it cannot be treated as a device as such. Therefore,most analytic specifications that would appear in a hardware-based effect pro-cessor like frequency response or signal-to-noise ratio are not appropriate here.Those parameters are related basically to the analog-to-digital conversion and thecharacteristics due to the hardware elements constituting the device. Hence, sincethe implemented processor is a purely digital PC-based system, those parametersare not applicable. However, a discussion of some aspects that are still applicableis presented in the following paragraphs.

System Overview

The implemented system corresponds to the figure 2.3.1. It has two differentinputs:

� L Pickup input

� R Mic input

8

Page 23: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

2.3 Specifications

Figure 2.3.1: Serial block diagram of the implemented effect processor,based on [GNa07].

and one output. Whereas the inputs are independent mono signals coming fromeither the pickup or the microphone, the output is stereo. Concerning the output,there are two possible cases:

� If the effects applied are mono1, channels left and right are equal.

� If a stereo effect is applied, the output is a true stereo signal being left andright channel different.

With respect to signal routings, the processor allows the user to choose amongtwo distinct signal flows: serial and parallel. They are explained in detail inchapter 4.

The sampling frequency fs of the processor is set to 44,100 Hz.

Input and Output Signals

As commented previously, since the application is non real time based, a seriesof waveform audio files were recorded to gather some excitation signals to testthe system. Thus, during the recording process it was taken care that the signallevel was appropriate, avoiding clippings but taking advantage of the availabledynamic range. Those audio files are loaded in Matlab in such a way that fromthen on the amplitude ranges from -1 to 1. Once the processing is accomplished,the outcoming output is saved in another waveform file in order to be comparedwith the input.

1As mono effects it is understood those ones which output is a mono signal. In practice,all of them are mono except the reverberation and the so-called ping pong delay, as it will beexplained in chapter 3.

9

Page 24: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

2. The Effect Processor

An issue of concern was the phase difference between both signals along theprocessor. This phenomenon may be caused by two reasons. Firstly, dependingon the guitar-microphone distance, there will be a certain phase difference inthe microphone signal with respect to the pickup signal. Secondly, due to theunlike inner processing for both signals, it is likely that a phase difference will beinduced as well. Due to time limitations, this matter was left unsolved. Thus,such a phase adjustment becomes a future possible improvement of the designedsystem.

In the same way, it was not taken into account whether the guitar pickup is activeor passive since it was understood it was not within the scope of the project.

Implementation Philosophy

It was concluded that even though the environment was offline, the Matlabimplementation of the effects should be an intermediate step towards a real timeimplementation.

Consequently, all the effects and implementations of the processor are based ona sample-by-sample philosophy, in an attempt to make a treatment as close aspossible to a future real time implementation. In other words, the treatment isdone in such a way that there is a sample entering the system and, once it isappropriately processed, it is lead to the output and so on.

To achieve this goal the need of using buffers arose since, in many cases, thealgorithm of an effect is based on the difference equations of filters involving pastsamples of either inputs or outputs. Hence, a series of buffers were created forevery effect.

As a result, despite the system is still offline it counts with the advantage that thefollowed sample-by-sample philosophy is real time based. Thus, the only mainissue left to achieve a real time application would be to translate the code to asuitable programming language (e.g. C/C++) and implement it on a DSP.

10

Page 25: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

Chapter 3

The Effects

This chapter introduces each effect and audio signal enhancement algorithm, thatwill be implemented in the multi-effect processor. The most common and usefuleffects related to acoustic guitar sound processing are included:

� Compressor: Treats the dynamic range of an audio signal to adapt it fora channel with less dynamic in order to avoid distortion.

� Noise gate: Attenuates or mutes a signal that is under a certain thresholdvalue.

� Equalizer: Emphasizes or attenuates one or more parts of the sound spec-trum, the timbre of the instrument can be changed and the sound can beadapted to certain room conditions.

� Delay: Creates one or more delayed versions of the input signal, meantto be added to such input, in order to produce several effects: echo delay,feedback delay, dynamic delay and ping pong delay.

� Reverberation: Creates a reverberation tail based on the incoming signal.It will consist of a set of echoes that decay and increase their density overtime.

� Modulation: These effects modulate the signal. They may modulate thepitch and or time to produce a different sound. Chorus, flange, tremolo andvibrato will be explained with more detail in the following sections.

Each algorithm is treated independently in terms of theory, design, implementa-tion and results in the following sections. The obtained functions can be combinedin any desired way, allowing different routings of the audio signal. Chapter 4 willrefer to this issue in detail.

11

Page 26: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

3. The Effects

3.1 Dynamic Processors

In order to avoid possible distortions of the signal and also get a clearer soundwithout noise, the implementation of dynamic processing devices is needed. Thesedevices process the dynamic range of the signals.

First of all, it is convenient to provide the meaning of dynamic range. Signaldynamic range can be defined as the difference between the maximum level ofthe input signal (with a prefixed distortion rate) and its background noise level[Tab05b]. Hence, it is directly related with its amplitude.

On the one hand, this devices are used to reduce the dynamic range of a signalin order to introduce it inside a channel with limited dynamic1.

On the other hand, dynamic processors are applied in order to obtain specialsound effects in certain instruments.

Dynamic devices group compressors, limiters, expanders and noise gates. Theimplementation of a compressor/limiter2 and a noise gate has been carried out inthis project. The compressor will reduce possible distortions in acoustics guitarchannels and the noise gate will avoid the existing background noise.

3.1.1 Compressor

Theory

This effect is the most important device used to control the dynamic range of asignal. It arises to decrease the higher levels of a signal signals. Thus the higherthe amplitude of the signal, the more attenuation applied. This means that eachinput level is transformed into another specific output level via a transfer functionwhich defines the gain to be applied.

In addition, the amplitude of audio signals is varying all the time, so if the level ischanging, the gain must follow those variations. The velocity of the gain responseto variations of the input signal is named attack when increasing, and release whendecreasing. Further details about compression theory can be seen in appendixA.1.

1This objective is both avoiding saturation of the channel and not missing the lower back-ground noise levels.

2Limiters are special cases of compressors.

12

Page 27: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

3.1 Dynamic Processors

The motivation to include this effect in the project, among other things com-mented before, is that an acoustic guitar player should have an effect processorto play with the dynamic of the signal. Besides, the user is able to control thecompression of the different input signals. It means that probably the parame-ters that are going to be applied for the microphone input signal will differ fromthe ones applied for the pickup input signal. In this way, they can be adjustedseparately.

Design

During design process some different approaches have been considered, they areexplained in appendix A.3.

A brief description of the adjustable parameters used in this design is given below:

� Threshold is the limit for the compressor to be activated. An input levelabove the threshold point is attenuated according to the settings of theparameters such as ratio, attack and release time (from 0 to 1).

� Ratio determines how hard the signal is compressed (from 0 to 1).

� Attack time is the time for the compressor responds to changes in the inputlevel when the threshold is exceeded (from 0.3 ms to 140 ms recommended).

� Release time adjusts how quickly the compressor returns to no-gain-reduction once the input level falls below the threshold, is known as release(from 50 ms to 2000 ms recommended).

� Output gain increases the output level of the compressed signal (from 1to 6).

Further details concerning the operation of these parameters can be found inappendix A.2. They are explained through the typical transfer function for com-pression.

The flow diagram for the compressor can be seen in figure 3.1.1.

Dynamics processing is performed by an amplifier where its gain is automaticallycontrolled by the level of the input signal. The flow diagram consists of a directpath for the input signal and a side chain path in which the gain is calculated.The equation can be easily inferred from the figure 3.1.1 where x(n) is the original

13

Page 28: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

3. The Effects

Figure 3.1.1: Signal processing in the compressor.

signal, y(n) is the output signal and g(n) is the gain that is going to be appliedfor the compression by means of the side chain path.

y(n) = g(n)x(n) (3.1.1)

This gain is obtained through four stages that are explained next.

� Level Detector

This stage compute the absolute value of each sample.

� Release Stage

The envelope of the signal is needed in order to compare each sample witha specific threshold. Once obtained the absolute value of every sample theshape of the signal is obtained taking into consideration the effect caused bythe release time. This time is related with the envelope [Sti86], so it can becoupled directly to the output of the level detector. This is the reason whythis specific design has been chosen. See appendix A.3 to compare otherconsiderations.

Then, to generate the release time, a circuit as is shown in figure 3.1.2 isused .

Figure 3.1.2: Release stage circuit.

14

Page 29: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

3.1 Dynamic Processors

In this diagram each present sample (in absolute value) is compared withthe sample before multiplied by a release constant [Sti86]:

r = e�Ts/Tr (3.1.2)

where r is the release constant, Ts is the sampling time and Tr is the releasetime defined by the user. The switch controls the comparison between thesesamples in such a way that the largest value is put into the delay elementin the output.

� Compression Characteristic

Once the envelope has been achieved, every sample will be compared withthe threshold for applying the corresponding compression.

The goal is to obtain almost instantaneously the gain control factor, thatwill be multiplied with the original input sample later.

If the gain value is equal to one, no compression is necessary. This occurswhen the amplitude of the envelope is less than the threshold.

However, when the input sample is above the threshold, the compression isactivated. This stage can be chosen arbitrarily.

In the beginning it was discussed that a solution could be obtained by usingan input range relationship of the compressor where it takes into accountthe corresponding compression ratio [Sti86].

Nevertheless, compression is dealing only with each sample of the envelopeand the threshold. For achieve the desired effect, the equation 3.1.3 isperformed where T is the threshold between zero and one, E is the envelopesample of the input signal, and R is the compression ratio.

g(n) =T

E

1�R(3.1.3)

When the ratio is just one, there is not compression, and the output isequal to the input. If the user decides to apply a ratio equal to zero, thenthe compressor is going to work as a limiter. The limiter is the maximumcompression possible. All values above the threshold will be adjust as closeas possible to the value of this limit. Therefore, this device can work as acompressor/limiter through this equation.

� Attack Stage

Once obtained the gain value for all samples, next step is creating the effectcaused by the attack time.

15

Page 30: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

3. The Effects

The attack constant is calculated using the release equation shown in 3.1.2,but working with the attack time selected by the user instead of the releasetime.

� Output Gain

The input sample is multiplied by the compression gain value. The outputvalue is obtained by multiplying the compressed sample by the output gain.

Implementation

This effect is implemented in Matlab in the function compressor.m, which maybe seen in appendix F.3.

Next, a fragment of Matlab code, concerning the level detector and release stageis displayed as follows.

global buffer1aglobal buffer1b

%% Level Detectionlevel = abs(x);

% Release Stageif level > (buffer1a(1)*release)

buffer1a(2) = level;else

buffer1a(2) = (buffer1a(1)*release);end

shape = buffer1a(2);buffer1a(1) = [];

Once the absolute value is calculated in the level detector, each present samplewill be compared with the sample before multiplied by a release constant. Thisconstant is obtained by means of the equation explained in the design concerningthis part.

The compression block is implemented at it was explained in the design. Theequation 3.1.3 is used:

% Is Compression necessary ?if shape >= T

16

Page 31: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

3.1 Dynamic Processors

g_pre = (T/shape)^(1-R); % Compress it!else

g_pre = 1; % no compression necessaryend

Regarding the attack time implementation, its calculation follows the same methodused for the release stage. For each sample, it will be compared the present gainvalue with the before gain value multiplied by the attack constant. The function-ality of the rest of the circuit is the same that was explained in figure 3.1.2. Theonly difference is that, instead of the sample obtained in the output of the leveldetector block, the gain will be used to compare the sample before multiplied bythe attack constant. Next, this fragment of Matlab code can be seen.

% consider attack timeif g_pre > (buffer1b(1)*attack)

buffer1b(2) = g_pre;else

buffer1b(2) = (buffer1b(1)*attack);endg = buffer1b(2);buffer1b(1) = [];

Finally, the input sample will be multiplied by the compressed gain. The outputLevel will depend on the amplification of the compressed signal that the user canchoose through the output gain parameter.

Results and Conclusion

Once the signal has passed through the level detector and release stages, theenvelope obtained in Matlab using the circuit of the figure 3.1.2 is shown infigure 3.1.3.

Not performing the effect of the attack time in implementation, when a loudmusic passage follows a quiet one, the gain would increase rapidly. This leads toa hard change in the compression quite perceptible.

For this reason, the attack time has been implemented in such a way that the dy-namic range compressor increases its gain smoothly as can be seen in figure 3.1.4.In acoustic guitar setups, typical values for the ratio are 5:1 - 10:1(input:output).

17

Page 32: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

3. The Effects

Figure 3.1.3: Envelope after release stage.

For the limiters between 10:1 - 20:1 [Tab05b]. Concerning to the attack time, itsvalue usually varies between 0.3 ms to 140 ms. Release times are larger, between50 ms to 2 s [GNa07].

Figure 3.1.4: Gain response with and without attack time.

18

Page 33: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

3.1 Dynamic Processors

3.1.2 Noise Gate

Theory

This effect is applicable when the background noise is required to be eliminatedin audio signals. It is very intuitive: attenuating the lower signal levels (noise)below a specific value and not altering the higher signal levels (signal itself) abovethis value.

This device is indispensable testing the sound for a concert. The objective is toavoid that the sound of others instruments or some voices can be infiltrated in theinstrument channel with whom it is working. It is also used for sound recordingsince the signal from a microphone picks up some noises generated in a recordingsession. For this reason, this device placed first in the effects processor routing[Tab05b].

All systems that are dealing with audio signals must include a noise gate inorder to eliminate the background noise. For an acoustic guitar effect processorwill be twice useful, using different configurations for the pickup signal and themicrophone one.

Design

As well as the rest of the effects, the noise gate has been designed following asample-by-sample structure. In order to design this device, an expander whoseconfiguration based on a compressor could be a solution, since a noise gate shouldbe understood as an expansion ratio from 1 : 1 [Tab05b].

In fact, the block diagram employed in the developed compressor has been usedfor the noise gate. Essentially it is the same, but it is necessary to modify someblocks to avoid the noise below the threshold.

Figure 3.1.5: Signal processing in the noise gate.

A brief description of the adjustable parameters used in this design is given below:

19

Page 34: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

3. The Effects

� Threshold is the limit for the attenuation to be activated. An input levelbelow the threshold point is attenuated according to the settings of theparameters such as ratio, attack and release time (from 0 to 1).

� Damp determines how hard the signal should be attenuated when belowthe set threshold (from 0 to 1).

� Attack time determines how fast the noise gate should attenuate the signalwhen below the threshold.

� Release time adjusts how fast the signal is released when the input signalrises above the threshold point.

Further details concerning the operation of these parameters can be found inappendix A.4. They are explained through the typical transfer function of anoise gate.

Implementation

This effect was implemented in Matlab in the function noisegate.m, which maybe seen in appendix F. Concerning the Matlab implementation, firstly, theenvelope of the signal will be calculated following the same procedure as thecompressor through the level detector and release stage.

In order to compare each sample with the threshold, the implemented equationbelow follows the same idea in compression. In contrast to the compressor, theattenuation is activated when the envelope is below threshold in such a way thatthe background noise is eliminated. Next, a fragment of Matlab code concerningto this part is displayed.

% Comparison shape with thresholdif shape <= T

g_pre = (shape/T)^(1-R); % attenuated it!else

g_pre = 1; % no attenuationend

The attack and release time are implemented following the same structure thatin the compressor effect.

20

Page 35: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

3.1 Dynamic Processors

Results and Conclusion

Most efficient way to check the results of the noise gate is listening an originalsound sample and comparing it with the processed. For this reason, some soundshave been recorded and included in the enclosed CD.

As can be seen in figure 3.1.6, the lowest background noises are eliminated belowthe threshold.

Figure 3.1.6: Input signal applying or not noise gate.

21

Page 36: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

3. The Effects

3.2 Equalizer

Frequency equalization is a common requirement for processing audio signals.Related to communication technology, it is actually used to make all frequencycomponents equal with respect to the amplitude, i.e. to achieve a flat frequencyresponse. For recording, mixing and play-back audio systems it is in additionused to emphasize or attenuate particular parts of the spectrum. Used in an effectprocessor for an acoustic guitar, it can be used for changing the timbre of theinstrument and for adapting the sound to room conditions for a live performancefor instance.

Due to the importance of filter usage, the following sections will introduce com-mon filter theories and the particular equalizer design used in this project. Theimplementation in Matlab and the obtained results are presented.

3.2.1 Equalizer Design

Equalizers are networks of filters. Due to the parameters the user is able to modify,they are divided into graphical and parametric equalizers. In a graphical equalizerthe spectrum is divided in terms of independent bands, normally one octave, 2/3,1/2 or 1/3 of an octave in width. Each band can be individually controlledin loudness by means of parallel slide controls. Their position represents thefrequency response of an equalizer in a graphical way. The bandwidth for eachfilter is usually proportional to the filters center frequency [Har93].

Parametric equalizers are more variable but not as intuitive to use than graphicequalizers. Besides the gain, it is possible to adjust the center frequency, thebandwidth and the Q-value respectively, for each filter. With a certain number ofthose parametric filters mostly every desired frequency response can be obtainedthat is suitable for audio applications [Orf96].

Depending on the particular specifications and requirements, literature providesa wide number of different approaches for filter design and realization. Filter canbe classified by means of the impulse response properties into

� finite impulse response (FIR) filter and

� infinite impulse response (IIR) filter.

By using an IIR filter, narrow peaks and notches in the frequency response can beobtained, although using a low order. A FIR filter would need a higher order to

22

Page 37: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

3.2 Equalizer

Figure 3.2.1: Amplitude response of a low frequency shelving filter (left)and a high frequency shelving filter (right). For both filtersdifferent values of V0 are applied.

obtain the same characteristic and thus more computational time. Since second-order IIR filters are used in commercial products [Aud04] and are suitable foraudio signal processing [Zol05] the filters presented in [Zol99] are used.

Based on a simple approach for a first-order shelving filter, the transfer functionfor a second-order shelving filter is derived [Zol99]:

Hlow, boost(s) =s2 +

p2V0s+ V0

s2 +p

2s+ 1, V0 > 1.

Inversion leads to the transfer function for the cut case. By applying highpasstransformation the corresponding high frequency shelving filters can be obtained.Figure 3.2.1 shows frequency responses for both types with different values of V0.

For emphasizing or attenuating a narrow frequency band, peak and notch filtersare used. The corresponding transfer function can be obtained by combining abandpass filter with an allpass filter [Zol99]:

Hpeak(s) = 1 +HBP(s) =s2 + V0

Qs+ 1

s2 + 1Qs+ 1

.

Inversion leads to the transfer function for the notch filter. Figure 3.2.2 shows thefrequency response for different values of V0 for the peak filter and the frequencyresponse for different values of Q for the notch filter as well. A more detailedderivation of the above presented transfer functions can be found in appendix B.

23

Page 38: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

3. The Effects

Figure 3.2.2: Amplitude response of a peak and a notch filter. For thepeak filter different values of V0 are applied; for the notchfilter different values of Q.

To obtain the desired digital filter in the z-domain, a suitable bilinear transfor-mation must be applied to the analog filter transfer functions. With

s =2

T

z − 1

z + 1

the second-order transfer function

H(z) =a0 + a1z

−1 + a2z−2

1 + b1z−1 + b2z−2

is obtained [Zol99], which contains the coefficients given by the tables B.1 andB.2 in appendix B.

Although second-order IIR filters are used in commercial products, they do nothave a constant group delay, which might be a disadvantage in audio processingapplications. Due to the fact that the other effects implemented in the effectsprocessor for this project may also introduce variable group delay over frequency,it was decided to disregard this issue firstly, but it might be considered for futureimprovements.

According to [Zol05] the obtained filters are arranged in series like shown in figure3.2.3. Therefor the output of each filter is connected with the input of the nextfilter.

To offer a parametric equalizer that provides the possibility to adjust the fre-quency response in mostly any desired way, the equalizer consists finally of thefollowing second-order IIR filters:

24

Page 39: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

3.2 Equalizer

Figure 3.2.3: Series connection of shelving and peak/notch filters.

� one low frequency shelving filter, with adjustable cut-off frequency fc andgain G,

� five peak filters, with adjustable center frequency fc, gain G and Q-factorQ,

� one high frequency shelving filter, with adjustable cut-off frequency fc andgain G.

The range of the parameters can be chosen arbitrarily in a wide range, but dueto feasible ranges for this particular application they are limited to

� center frequency fc = 40 . . . 20, 000 Hz

� gain G = −24 . . . + 24 dB

� Q-factor Q = 0.1 . . . 5

According to [Orf96] the difference equation of a second-order IIR filter is givenby

y(n) = b0x(n) + b1x(n− 1) + b2x(n− 2)− a1y(n− 1)− a2y(n− 2) ,

where x(n) and y(n) are the current input and output samples and a and b thefilter coefficients. The block diagram of this filter can be seen in figure 3.2.4.The output of the first filter is connected with the input of the second filter, i.e.y1(n) = x2(n), and so on.

3.2.2 Implementation

Using Matlab/Simulink an equalizer can be implemented within minutes. Byusing the Data Acquisition Toolbox and the Signal Processing Blockset, even areal time processing solution can be built, like shown in figure 3.2.5. In order to

25

Page 40: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

3. The Effects

Figure 3.2.4: Block diagram of a second-order IIR filter

Figure 3.2.5: Matlab/Simulink modell of a 2-band parametric equalizer.

simulate the behavior of a DSP and to understand sample-by-sample processing,it is however recommendable to break down the problem into signal processingoperations.

The implementation is straightforward: Each difference equation features onefilter. The result of the first equation is the input for the next equation and soon. For providing past samples a small buffer is used for each filter. If the userparameters change during processing the coefficients for the particular filter willbe recalculated. The function code can be seen in appendix F.4.1.

3.2.3 Results and Conclusion

A five-band parametric equalizer was implemented in Matlab by using second-order IIR filters. For gaining or attenuating low or high frequencies two shelvingfilters can be used. Figure 3.2.6 shows the frequency response for each filter for aspecific set of parameters. The frequency response of the whole equalizer can beseen as well.

26

Page 41: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

3.2 Equalizer

Figure 3.2.6: Frequency responses for the particular filters and the equal-izer itself, by using the following parameters: fc,low = 150 Hz,Glow = 1.5 dB; fc1 = 150 Hz, Q1 = 3, G1 = −1 dB;fc2 = 700 Hz, Q2 = 3, G2 = 4 dB; fc3 = 2000 Hz,Q3 = 4, G3 = 3 dB; fc4 = 4000 Hz, Q4 = 5, G4 = 2 dB;fc4 = 6000 Hz, Q4 = 5, G4 = 0 dB; fc,high = 8000 Hz,Ghigh = 3 dB.

The implementation takes into account that parameters may be change duringprocessing. If necessary, the coefficients of the particular filter were recalculated.For an implementation with real time requirements it must be guaranteed thatthese calculations are fast enough.

A filter design that provides linear phase response and thus a constant groupdelay would be regarded as desirable for future improvements.

27

Page 42: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

3. The Effects

3.3 Delay

The delay effect constitutes one of the most classic and common effects in manyaudio applications, being present in both music production and performance.They are used in all kinds of music from electronic to electroacoustic music, as wellas in sound reinforcement systems. They provide a huge variety of applicationsranging from purely artistic purposes to other sound enhancement techniqueswidely used in P.A. systems. Besides, although delay could be one of the simplestexisting effects, it becomes extremely important not only as a truly versatile effectitself but also as a potential building block [Orf96][Zol05] for other certain effectssuch as reverberation, chorus and flanger, as it will be shown in this chapter later.

In this project, a number of delay effects related to the usage of an acousticguitar are presented and implemented. An overview of each one of those typesof delay effects is described in this section. For every effect, the same outline ofpresentation is followed. First of all, the procedure elected to develop each type isexposed. Then, aspects concerning implementation are discussed. Finally, someresults are presented. The implemented delay types are: basic delay (also calledecho unit), feedback delay, dynamic delay and ping pong delay.

3.3.1 Echo Unit and Feedback Delay

Sound waves in a listening space arrive at our ears in such a way that first, thedirect sound from the direct source is perceived and, then, reflections from thewalls and other possible elements arrive later on. These reflections come withvarious amounts of time delays and attenuations. Thus, delays can be noticedin acoustical spaces. Depending on how large the delay is, the human ear willcompute a different perception of it, ranging from a pure echo to a modificationof the sound colour.

In this section, the so-called echo unit or basic delay is discussed. It simulates adirect sound plus a single reflection, attenuated and delayed a certain amount oftime. However, in many audio applications, or for determined artistic purposes, itseems that a single reflection is rather limiting. Sometimes it is preferable to havea certain amount of replicas of the input signal. For that reason, the so-calledfeedback delay is also included as an extension of the echo unit.

28

Page 43: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

3.3 Delay

Theory

As introduced in previous paragraphs, the echo unit block takes an audio signaland plays it back after certain amount of time called delay time together with theinput dry signal. According to the consulted bibliography, it appears that themost common way to design this effect is using a FIR comb filter [Orf96][Zol05].The block diagram representing this filter is shown in the figure 3.3.1:

Figure 3.3.1: Block diagram of a FIR comb filter [Har07].

The next difference equation expresses its performance.

y(n) = x(n) +mix � x(n�M) (3.3.1)

whereM = τfs (3.3.2)

being fs the sampling ratio and τ the time delay value in seconds. It is seenhow the output is based on the input and one past sample of the input. Thus,it constitutes a feedforward loop. To be precise, the output is the input plus asingle delayed copy of itself, attenuated by the factor mix.

The transfer function of such filter is given by:

H(z) = 1 + gz�M (3.3.3)

and its graph may be seen in the figure 3.3.2. It is shown in that figure how thisfilter amplifies the frequencies multiple of the fundamental frequency fs/M andattenuates those other frequencies lying in between. Hence, its transfer functionlooks like a comb, giving that name to the filter.

Concerning the feedback delay there may be several approaches. In [Orf96][Zol05]the solution suggested is based on an IIR comb filter. The block diagram of the

29

Page 44: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

3. The Effects

Figure 3.3.2: FIR comb filter transfer function for a delay of 8 samples andmix equal to 0.7.

Figure 3.3.3: Block diagram of the IIR comb filter proposed in [Zol05].

system is depicted in figure 3.3.3. This filter provides an endless series of responsesy to a certain input x. There is a feedback loop in which the signal is fed backinto the input over and over again. Every time the signal passes by that loop, itbecomes attenuated by the feedback gain g. Hence, factor g affects the numberof replicas to be heard in the output. The larger this value, the more replicaswill be present. It is important to take into account that g should not be greaterthan one, for the system to remain stable. Otherwise the signal would grow inevery loop. This filter may also be used as the elementary building block of areverberator. The expression of its difference equation is shown next:

y(n) = x(n) + gy(n�M) (3.3.4)

where M is defined in equation 3.3.2. It is seen how the output is based on

30

Page 45: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

3.3 Delay

the input and also on past samples of the output, meaning a feedback loop. Itprovides infinite time response, with replicas equally spaced every M samples.

Although it seems this filter is widely employed for this purpose, a slightly differ-ent approach was used instead. In SynthMaker software [Syn07], another IIRcomb filter is proposed. It is presented in figure 3.3.4 and characterized by the

Figure 3.3.4: Block diagram of the IIR comb filter proposed by [Syn07].

difference equation

y(n) = x(n�M) + gy(n�M), (3.3.5)

where M is defined in equation 3.3.2. It keeps the same behaviour regardinginfinite time response but it has some variations with respect to the previoussystem. Regarding filter phase, in this last case it is almost linear whereas inthe first case it is not whatsoever. Besides, in this last IIR comb filter proposed,it is possible to see, according to its difference equation 3.3.5, that the outputonly contains delayed versions of both input and output. In other words, the drysignal or reference signal as such is not included in the output, as shown in blockdiagram 3.3.4.

Thus, it seemed it could be feasible to use such system to obtain only the desiredreplicas of the input. Then, once scaled, they would be added to the input drysignal. The result achieved [Har07] is represented in the block diagram 3.3.5.

It is noticeable, if compared to figure 3.3.1, that this system is exactly the echounit with a feedback loop. Hence, when the feedback gain turns to be zero, theresultant block is an echo unit whereas in the method suggested in [Orf96][Zol05],for the same setup, the obtained output would be only the dry signal. Thepossibility of gathering the two types of delays in a single block by means ofvarying only one parameter (i.e. feedback gain g) appeared to be practical. Forthis reason, this was the solution chosen, which will be described next.

31

Page 46: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

3. The Effects

Figure 3.3.5: Block diagram of the IIR comb filter to be implemented forthe effects processor.

Design

The implemented system to accomplish the delay with feedback and echo unit,corresponding to the block diagram 3.3.5, follows the next difference equation:

y(n) = x(n) +mix(x(n�M) + gz(n�M)) (3.3.6)

where M is defined in equation 3.3.2. The expression 3.3.6 consists of a sum oftwo terms. The first one is just the input dry signal with no delay. The last onerepresents the IIR comb filter proposed by [Syn07] according to equation 3.3.5and scaled by the factor mix. This term would contain only the desired replicasof the input signal and its transfer function is as follows:

H(z) =z�M

1� gz�M(3.3.7)

Which frequency response is depicted in figure 3.3.6. It presents a similar be-haviour as in the FIR comb filter case. Also here, there are certain frequenciesto be amplified and attenuated as seen in the figure. Thus, the transfer functionpresents the appearance of a comb too. The difference consists mainly of theshapes of the peaks. In this case, the figure 3.3.6 shows how they become nar-rower as g approximates the unity [Orf96]. Note that the transfer function maybe scaled with a factor less than the unity in certain cases if the system providestoo high amplification due to its feedback structure.

There are three parameters to tune this effect: the delay time M, the relationbetween the amplitude of the delayed signal and the input signal given by mix,and the feedback gain g.

32

Page 47: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

3.3 Delay

Figure 3.3.6: Transfer function for the IIR comb filter proposed in [Syn07]for a delay of 8 samples and g equal to 0.7.

� The delay time M is the time between replicas. Concerning the echo unit,it means the delay between the dry signal and the only delayed copy. Thisvalue may range from a few miliseconds to various seconds. In the firstcase, the result would be a quick repetition of the input called slapback ordoubling which produces a coloration of the sound. On the other hand, whenthe delay time exceeds certain amount of time (50 ms) [Zol05] a single echois perceived separated from the input signal. With respect to the feedbackdelay, M is the temporal separation between all existent replicas and drysignal as well.

� The factor mix means the mix between original or dry signal and processedor wet signal. The value of mix ranges from 0 (i.e. only dry signal) to 1(i.e. same amplitude for both dry and wet signals).

� The feedback gain g is the factor by which each replica is attenuated everytime it goes through the feedback loop. The larger this value, the morereplicas will be present in the output signal. This value must not exceedthe unity. Otherwise the signal would grow endlessly and the system wouldbecome unstable. Hence, it ranges from 0 to 1.

Implementation

As commented previously, the echo unit is a special case of the feedback delayand therefore it can be achieved by means of the last one. However, with inspi-ration in [GNa07], two distinct implementations were performed generating two

33

Page 48: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

3. The Effects

separated effects which result more intuitive for the user. Their code may be seenin functions echodel.m and feedbackdel.m respectively, included in appendix F.5.1and F.5.2.

Concerning the echo unit, its code is based on the FIR filter difference equation3.3.1. It uses a global variable to compute a linear buffer in order to simulate therequired input past sample. This buffer is a simple FIFO structure fed from thetop and updated with the new input sample in every iteration.

The delay time is used to initialize the buffer size in the main script. It fixes itssize so that when implementing the difference equation 3.3.1, the only addressedsample is always the last one in the buffer. As parameters, the function makesuse of a unique input sample and the parameter mix.

With respect to the feedback delay, its code is based on the IIR comb filterdifference equation 3.3.5. It makes use of two global variables to compute the twolinear buffers required to simulate the past samples from both output and input.Those buffers are of the same character as in the echo unit.

Once the delayed signal is calculated, it is scaled according to the mix parameterand added to the dry signal, following the equation 3.3.6 and obtaining the outputsample.

The delay time determines the buffer size in the same way as in the echo unit.Also in this case, the only addressed sample is always the last one in the buffer. Asparameters, the function makes use of a unique input sample, the mix parameterand the feedback gain g.

Due to the character of these effects, the output signal will be longer than theinput signal in a certain amount of samples. That amount of samples will benamed the tail of the output and its value is M times the number of existingreplicas. A calculation of such tail was performed. This procedure is describedin detail in appendix C.

It was previoulsy mentioned how the feedback loop of this structure may causea too high amplification. This phenomenon would likely happen as the feedbackgain g comes close to 1. Consequently, in order to ensure that no overload wouldtake place, a normalization coefficient [Zol05] is applied to the equation 3.3.6. Itscales the samples coming from the input and its expression is:

norm = 1� g. (3.3.8)

This coefficient is also passed to the function as a parameter.

34

Page 49: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

3.3 Delay

Results and Conclusion

As a result of the performance of these effects, next figures show the output ofthe feedback delay system when it is fed with a unique impulse, so-called Diracdelta function. Hence, the impulse response is obtained. Results from the echounit implementation are not included since they are redundant.

The results of the first case, where the feedback delay is working as an echo unit,are presented in the figure 3.3.7. For this case the parameters are set as follows:

Figure 3.3.7: Feedback Delay output performing as an Echo Unit whenexciting with a Dirac delta function. Delay applied 200 ms,mix equal to 0.5 and g equal to 0.

� delay time: 200 ms

� mix: 0.5

� Feedback gain: 0

The figure 3.3.7 shows the performance of the feedback delay as an echo unit.When the feedback gain g is set to zero, there is only a delayed copy of the inputsignal in the output. Its amplitude is given by the mix value as seen in the figure.

The second case deals with the following parameters:

� delay time: 200 ms

35

Page 50: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

3. The Effects

� mix: 1

� Feedback gain: 0.6

Figure 3.3.8: Feedback Delay output when exciting with a Dirac delta func-tion. Delay applied 200 ms, mix equal to 1 and g equal to0.6.

In this case, the feedback loop is active as seen in the figure 3.3.8. Now, theamplitude of the replicas depends on the mix value and also, indirectly, on thefeedback gain g through the normalization coefficient of equation 3.3.8. Moreover,it is possible to appreciate how the delayed replicas decay with a smooth shapeeven at the end of the process, meaning the calculated output tail is valid.

3.3.2 Dynamic Delay

There may be cases when the musician would like to use a delay effect but,depending on the chosen set of parameters, sometimes this effect may result inmessy sounds. To avoid that situation, it would be of interest to keep a clearsound while performing, and to increase the amount of delay when the artistpauses, that is, when the last chord begins to decay.

In an attempt to accomplish this feature for the effect processor, the so-calleddynamic delay is included.

36

Page 51: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

3.3 Delay

Theory

It is not easy to find scientific bibliography about this type of delay as such. Itcould be treated as a variation of the feedback delay since its approach is basicallythe same (see section 3.3.1). There is only one differentiation consisting of thefact that there must be a detection of the signal level. The aim is to apply onedelay or another depending on that level in such a way that during musicianperformance the amount of delay decreases and vice versa when the musicianstops playing. In other words, it means allowing the dynamics of the signal todecide how much delay is applied to the output [GNa07].

The chosen method to detect the signal level is exposed in [Sti86]. That paperpresents a dynamic range compressor for audio and, among other topics, a so-called first-order peak hold circuit is described.

Design

The implemented system to perform the dynamic delay is shown in the blockdiagram 3.3.9. It follows the same difference equation as in the feedback delay

Figure 3.3.9: Block diagram of the Dynamic Delay to be implemented inthe effects processor.

(expression 3.3.6) which is rewritten next:

y(n) = x(n) +mix(x(n�M) + gz(n�M)) (3.3.9)

As explained in section 3.3.1 the expression consists of a sum of two terms. Thelast one represents the IIR comb filter proposed, scaled by the factor mix. Thisterm would contain only the desired replicas of the input signal and, because ofthat, it will be the one to be focused on. The procedure chosen is based on scaling

37

Page 52: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

3. The Effects

such term with a variable value depending on whether the signal shape exceeds adetermined threshold or not. Both the attenuating factor, named damp, and thethreshold would be set by the user.

In order to detect the signal level, the so-called first-order peak hold circuit(FOPHC) is used. It was already applied in this project concerning the achieve-ment of the compressor effect in section 3.1. Should the reader need a morethorough explanation of this system, it is included in that section. For this pur-pose, it is applied over the input signal, as figure 3.3.9 shows and basically, it ismeant to achieve two goals. First of all, it is suitable for calculating the shape ofthe signal. Secondly, when obtaining such shape, this circuit allows generating arelease time. It is useful in order to ensure that the short-term dynamics of thesignal do not suddenly affect the global value of its shape. Furthermore, thinkingabout real environment, in a situation when there may be a quiet music passagefollowing a loud one, it would provide a more natural sound since the incrementof delay would occur gradually rather than impulsively.

Therefore, there are several parameters to be considered for this effect. In thesame way as in the feedback delay case, there are three basic parameters: delaytime M, the mix factor and the feedback gain g. These ones were already explainedin section 3.3.1. Moreover, there are other particular parameters for this effectsuch as damp, threshold and release time:

� damp: it is the factor that will attenuate the term representing the delayedreplicas. Its values may range from 0 (maximum attenuation) to 1 (noattenuation).

� threshold: it is the amplitude level with whom to compare the signal shape.Its values may range from 0 to 1.

� release time: this parameter is equal to the one seen in section 3.1 con-cerning the compressor effect. It is a temporal value which will define howsmooth the calculated shape is, i.e. how sensitive the signal is to short-term dynamics. The larger it is, the longer it takes to notice the variationof delay.

Implementation

This effect was implemented in Matlab in the function dynamicdel.m, whichmay be seen in appendix F.5.3.

The code is very similar to the one described for the feedback delay in section3.3.1. The calculation of the tail remains the same. See appendix C for further

38

Page 53: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

3.3 Delay

information. The treatment of the normalization coefficient is the same too. Thetwo global variables working as linear buffers are also of the same type. However,in order to store the past sample of the gained signal shape, a one-sample bufferis required, meaning a third global variable.

The procedure to implement this effect is as follows. First of all, in every iteration,the shape value (considering the release time) for the input sample is obtained.Secondly, after comparing such shape with the threshold level, the mix factor iscalculated. Its value would remain constant if the shape is less than the threshold.On the contrary, its value would be attenuated by the parameter damp. Finally,a regular feedback delay is applied.

Results and Conclusion

Concerning the results gathered by this effect, it turns out it is difficult to perceivethem either graphically or by words. Therefore, it was thought a good choiceto test this effect would be to listen to a sample with certain set of parameters.Consequently, the reader is encouraged to listen to the sample audio files recordedin the enclosed CD.

3.3.3 Ping Pong Delay

In this section a very common effect will be presented: the ping pong delay. Itsperformance is based on the feedback delay of section 3.3.1, obtaining a series ofdelayed replicas in the output. The only difference is that this effect creates astereo output signal sending replicas alternatively to left and right channel.

Theory

It is not easy to find scientific bibliography about this type of delay as such. Itcould be treated as a variation of the feedback delay since its implementationis basically the same (i.e. IIR comb filter based). There are a few differencesconcerning how to design this system and they will be described next.

Design

The design of this effect is based on the block diagram of figure 3.3.10:

39

Page 54: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

3. The Effects

Figure 3.3.10: Block diagram of the Ping Pong Delay to be implementedin the effects processor.

It must be considered that 2 outputs are needed here, corresponding with leftand right channel. Therefore, there will be two IIR filters, meaning two delaylines instead of one. The main condition to achieve this effect is that the outputof one filter feeds the input of the other one and vice versa. Aside from that, theapproach is equal to the feedback delay, as seen in block diagram 3.3.10.

Its difference equations are presented next:

yL(n) = x(n) +mix(x(n�M) + gzR(n�M)) (3.3.10)

yR(n) = x(n) +mix(gzL(n�M)) (3.3.11)

where M is defined in equation 3.3.2. The system is fed with a mono input inthe left channel. Once delayed, that signal is fed back not into its input but intothe input of the other delay line i.e. the right one. This procedure is repeatedendlessly, from the left channel to the right one and vice versa. It is possibleto see in the diagram 3.3.10 how the dry signal is added to both left and rightoutput channels. As well, the replicas are bouncing between them, taking placethe odd replicas in the left channel and the even replicas in the right one.

This configuration is a basic version of a more complex one [Har07] based on twoinput signals. In this project, however, it was decided to implement the basic

40

Page 55: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

3.3 Delay

case where there is only one input and parameters remain equal for both delaylines.

With respect to the parameters, they are exactly the same as in section 3.3.1:delay time M, mixture between dry and wet signal given by mix and the feedbackgain g.

Implementation

This effect was implemented in Matlab in the function ppongdel.m, which maybe seen in appendix F.5.4.

The code is very similar to the one described for the feedback delay in section 3.3.1.The calculation of the tail is the same. See appendix C for further information.The parameters required by the function and the treatment of the normalizationcoefficient are the same too.

The main difference lies in the fact that since there are two distinct delay lines (oneper output channel) the code is repeated twice. Instead of two global variablesto simulate the linear buffers, there are three variables3 needed now. The codefor each one of the channels is close to a feedback delay, but with the conditionof feeding the input of a filter with the output from the other one, according tothe equations 3.3.10 and 3.3.11.

Results and Conclusion

As a result of the performance of this effect, figure 3.3.11 shows the output ofthe system when it is fed with a unique impulse, so-called Dirac delta function.Hence, the impulse response is obtained.

The parameters are set as follows:

� delay time: 200 ms

� mix: 1

� Feedback gain: 0.6

3two for the left channel and one for the right channel since this one does not consider anyinput.

41

Page 56: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

3. The Effects

Figure 3.3.11 represents both left and right output channels. It is easy to appre-ciate how the replicas are split alternatively among them. Aside from that issue,the behaviour of the system is the same as in the feedback delay case.

Figure 3.3.11: Ping Pong Delay output when exciting with a Dirac deltafunction. Delay applied 200 ms, mix equal to 1 and g equalto 0.6.

3.3.4 Analog Delay

Sometimes it could be desired to obtain a warm sound, trying to emulate atraditional analog delay. This effect is widely extended in commercial devicessuch as [GNa07].

To accomplish that objective, it was decided to make use of a first-order lowpassfilter that attenuates high frequencies. It was introduced in the output of alleffects explained in this section. The block diagram of such system is shown inthe figure 3.4.6 of the reverberation effect section 3.4.2.

Its difference equation is:

y(n) = (1� g)x(n) + gy(n� 1) (3.3.12)

It makes use of the parameter cutf in the following way,

g = 1� cutf (3.3.13)

which is related to the filter cutting frequency and ranges from 0 to 1.

42

Page 57: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

3.4 Reverberation

3.4 Reverberation

Reverberation phenomenon is one of the biggest issues concerning modern acous-tics theory. Its study has caused some of the most important theories in thearchitectural acoustics field. In addition, it has become an essential ingredientin worldwide recording techniques. These days instruments are recorded in dryconditions, meaning that their sound is obtained in conditions of direct field, withno reflections or less as possible. Due to this fact, artificial reverberation is usedas a post-processing technique in order to achieve a feeling of spaciousness, aswell as to place the recorded sound in a certain position of our sound landscape.

This chapter will focus on the study of the artificial reverberation, more preciselyin the reverberation effect inside an effects processor. The following sectionswill include some explanations of its physical aspects, different approaches toits design, a description of its implementation in Matlab and some conclusionsobtained from tests.

3.4.1 Theory

Reverberation is based on the reflection of sound. One approach to understandthe behavior of the sound within a room is taken in geometrical acoustics. In thisway, reverberation is properly described as the sound caused by all the reflectionsthat occur in a room. In a listening situation, see figure 3.4.1, the listener willfirst hear the direct sound, followed by reflections of the sound off the surfaces allover the room.

Figure 3.4.1: Schematic of a listening example [Har07].

This waves will arrive at the listener delayed in time. They also will be weakerthan the direct sound as they loose energy following a longer path and reflectingoff surfaces. Consequently, this reflections will lead to an echogram as shown infigure 3.4.2.

43

Page 58: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

3. The Effects

Figure 3.4.2: Echogram of a room [Har07].

Three different parts can be described on this response. First one is called pre-delay, it will be the time taken from the arrival of the direct sound and the firstreflection, the longer this time, the greater the room the listener will feel. There isa second part including some of the first reflections, so called early echoes. Theycan be distinguished in time and level and are considered to provide the listenerwith information regarding the geometry of the physical space. These echoescontinuously increase with time, then the density of reflected waves becomes toohigh for discrete recognition and will lead to a random signal with exponentialdecay called diffuse reverberation [Zol99].

Artificial Reverberation

Lots of methods creating artificial reverberation responses have been achievedover the years. Mostly used solutions are based on IIR comb and allpass filters.Moreover, some algorithms can include FIR filtering in order to simulate earlyreflections, while others use convolution of the source signal with the impulseresponse of a room.

In order to properly understand the course of reverberation algorithms over his-tory, the reader is encouraged to read appendix D, which includes detailed infor-mation concerning greatest breakthroughs in artificial reverberation over the lastsix decades.

The basis of creating artificial reverberation is found on the use of comb andallpass filters. Recently, comb filters are not longer used since it is possible toachieve great results by more efficient allpass recirculating networks.

A comb filter is a simple delay with feedback as shown in figure 3.4.3. Its difference

44

Page 59: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

3.4 Reverberation

equation is:

y(n) = x(n�m) + gy(n�m) (3.4.1)

Its impulse response represents an impulse bouncing between two parallel wallswith energy exponentially decaying in time. Its frequency response introducescoloration4.

Figure 3.4.3: Comb filter flow diagram and impulse response [Gar92].

Figure 3.4.4 shows an allpass filter which is based on a comb filter with a feed-forward path around the delay. Its difference equation is:

y(n) = �gx(n) + x(n�m) + gy(n�m) (3.4.2)

Figure 3.4.4: Allpass filter flow diagram and impulse response [Gar92].

This filter is suitable to obtain a dense impulse response offering a flat frequencyresponse5. Its pole-zero diagram has the same pole configuration as the comb

4Some advantage can be taken of it as its peaks will correspond to the normal modes of thevirtualized room.

5It is assumed that this filter does not introduce coloration in the input sound. However,this is not always true. From a perceptual viewpoint it is proved that only if the delay line ismuch shorter than the integration time of the ear, about 50 ms, this assumption will be valid[ZF90]. On the contrary, the timbre of the incoming signal is significantly affected.

45

Page 60: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

3. The Effects

filter, but now for every pole, there is a zero at its conjugate reciprocal location,canceling the influence of the poles on the magnitude of the frequency response[Gar92].

Chosen solution consist of an algorithm combining allpass filters, delay lines andlowpass filters. It was designed by Dattorro and described in AES Journal in1997 [Dat97].

He explains one particular topology for a plate reverberation. It has two differentsections divided in input diffusers and the so-called tank. Their structure will bediscussed in next design subsection. The reason of why this topology is chosenlies to the fact that the developed effect processor is aimed at musicians. For thisparticular target, an easy to use and versatile reverberator is needed. In addition,some of these users require instantaneous high density responses, which describesmore a plate reverberator than an accurate emulator of a physical space.

Furthermore, Dattorro [Dat97] gives some attractive answers to the question:Why this particular network?

� Simple parameters: It has simple knobs, which easily control particularaspects of the reverberated sound, such as input and decay diffusion (decor-relation), decay rate, high-frequency damping, and input signal bandwidth.

� Computational efficiency: The style of the topology is more computa-tionally efficient than most others known.

� Versatility: It has demonstrated applicability to a broad range of signalsources.

� Simpleness: It is the smallest (in memory and complexity) good soundingreverberation network found.

3.4.2 Design

General Overview

The topology for Dattorro’s reverberator is depicted in figure 3.4.5. The firstconclusion obtained when scanning the algorithm is that it is based on allpassfilters. They are going to decorrelate the incoming signal and create the diffuseresponse itself, hence, they will be called diffusers.

The structure is split into two sections differing in functionality, the input sectionand the tank. The first one is aimed to quickly decorrelate the input in order

46

Page 61: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

3.4 Reverberation

Figure 3.4.5: Dattorro’s reverberator flow diagram, based on [Bel04].

to provide the tank with a semi-diffuse signal. It also includes a predelay anda lowpass filter which can control whether to process the whole signal or only acertain low frequency band. The objective of the tank is to trap the incomingsignal by making it recirculate again and again, in such a way that generates adecaying signal according to the parameters. The output of this reverberator isobtained from a weighted combination of different taps from some delay units ofthe system. This will be explained further on.

Parameters

A brief description of the adjustable parameters is given below:

� Predelay adjusts the predelay of the diffuse reverberation tail in samplesfrom zero to the desired value.

� Bandwidth adjusts the bandwidth (high frequency attenuation) of thesignal that is going to be processed with values from 0 to 1 representing thefeedback gain of the lowpass filter.

47

Page 62: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

3. The Effects

� Input Diffusion 1 and 2 determine the quantity of decorrelation appliedto the incoming signal with values from 0 to 1.

� Decay Diffusion 1 and 2 determine the quantity of decorrelation appliedto the tank signals with values from 0 to 1.

� Damping adjusts the high frequency damping in the tank signals withvalues from 0 to 1 representing the feedback gain of the lowpass filters.

� Decay adjusts the rate of decay for the diffuse reverberation tail with valuesfrom 0 to 1.

These parameters are easy to use, but enough sophisticated to provide a suitablecontrol of the reverberation unit. Other parameter called mix will be needed inorder to integrate the generated reverberation with the dry signal, this will betreated in the implementation subsection.

Input Section

A delay is firstly applied to the input signal in order to place the reverberationtail in time. It will consist of a simple delay line with adjustable length.

Then the signal is filtered by a first-order lowpass filter. The realization of thissimple filter is shown in figure 3.4.6,

Figure 3.4.6: First-order lowpass filter flow diagram [Bel04].

Its difference equation is

y(n) = (1� g)x(n) + gy(n� 1). (3.4.3)

Bandwidth parameter is obtained by substituting:

g = 1� bandwidth (3.4.4)

48

Page 63: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

3.4 Reverberation

Once filtered and delayed, four allpass diffusers (Allpass 1, 2, 3 and 4) in seriesare placed to decorrelate the signal. This will generate a diffuse signal ready tobe applied in the next section6. The realization of these allpass filters is the sameas shown in the previous section and the length of the delays involved is given7.Parameters Input diffusion 1 and 2 will be the gain g of the feedback loop of thefilters.

Tank

In this section, the signal will recirculate through the four allpass diffusers (Allpass5, 5’, 6 and 6’ in figure 3.4.5). It will become more diffuse and dense in eachcycle, and will decay exponentially depending on the decay parameters. Thetwo recirculating paths include four diffusers, two first-order lowpass filters, fourdelays units and four decay gains.

The parameter Decay diffusion 1 corresponds to the allpass filters 5 and 5’. Theyhave a different realization from the allpass filters seen until this point, see figure3.4.7. Firstly, the sign of their feedback gains is inverted; making their coefficientsboth negative, the character of the impulse response will change but the allpasstransfer will not be destroyed. In fact, it will increase the dichotomy betweenthe two pairs of tank diffusers [Dat97]. Secondly, they implement a peculiaritywhich consists of a time-variable delay length8. This is achieved by applying alow frequency oscillator to the value of this length.

Lowpass filters used in the tank have the same realization as shown in the inputsection, see figure 3.4.6 and equation 3.4.3. To obtain the parameter damping inthis case, substitution is as follows:

g = damping (3.4.5)

Parameter Decay diffusion 2 is related to the allpass 6 and 6’. They have exactlythe same typology as the diffusers used in the input section.

6Tank recirculation can sometimes become perceptible as strong cyclic events if the inputsignal is not preconditioned in this manner. In fact, this function becomes especially importantfor the successful reverberation of percussive sounds [Dat97].

7The length of the inner delay of each filter is given in samples for a sample rate of 44100Hz [Dat97]. All of these length values are shown in figure 3.4.5.

8This slight modulation will introduce undulating pitch change into the tank. For signalswith much high-frequency content, such as drum sets, these built-in modulators serve to breakup some pretty audible modes. The amount of the tank diffusion is effectively increased [Dat97].

49

Page 64: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

3. The Effects

Figure 3.4.7: Flow diagram of allpass filters 5 and 5’. Based on [Gar92].

Decay gains will determine the rate of decay for the reverberation tail. Delayunits will be useful to achieve overlapping9 between the two parts of the tank byusing different lengths on each one.

The Output Taps

The output signal for this reverberator will be obtained by combining signals fromdifferent taps around the structure. It is possible to extract the signal from insidea delay line, choosing a desired point of its length. The following pseudocodeshows how to combine these signals and what are the certain points within thedelay lines to obtain them:

%**** Left output, all wet ****YL = 0.6 x tap1[266]YL = YL + 0.6 x tap1[2974]YL = YL - 0.6 x tap2[1913]YL = YL + 0.6 x tap3[1996]YL = YL - 0.6 x tap4[1990]YL = YL - 0.6 x tap5[187]YL = YL - 0.6 x tap6[1066]

%**** Right output, all wet ****YR = 0.6 x tap4[353]YR = YR + 0.6 x tap4[3627]YR = YR - 0.6 x tap5[1228]

9This overlapping will eliminate any aural pattern in the signal recirculation.

50

Page 65: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

3.4 Reverberation

YR = YR + 0.6 x tap6[2673]YR = YR - 0.6 x tap1[2111]YR = YR - 0.6 x tap2[335]YR = YR - 0.6 x tap3[121]

3.4.3 Implementation

This effect was implemented in Matlab in the function reverb.m, which may beseen in appendix F.6.

The user parameters for this function are: mix, predelay, bandwidth, damping,decay, in diff1, in diff2, dec diff1 and dec diff2.

The code is based on Dattorro’s algorithm (figure 3.4.5) explained in the sectionbefore and it is divided in the following parts:

� Input section: It includes predelay, lowpass filter 1 (bandwidth) and all-pass 1, 2, 3 and 4 (input diffusion 1 and 2).

� The tank part 1: It includes allpass 5 (decay diffusion 1), one delay line,lowpass 2 (damping), decay gain, allpass 6 (decay diffusion 2), another delayline and decay gain.

� The tank part 2: It includes allpass 5’ (decay diffusion 1), one delay line,lowpass 2’ (damping), decay gain, allpass 6’ (decay diffusion 2), anotherdelay line and decay gain.

� Output section: It includes the expressions to extract the signal fromdifferent taps around the tank and compute the mix between reverberationand dry signal.

Each filter is implemented by computing its difference equation. In order to com-pute those equations that involve past samples, using memory becomes necessary.Hence, each filter or delay line uses global variables as linear buffers which areFIFO structures fed from the top. They allow access to any sample within a delayline and are essential in a sample-by-sample implementation.

Next, the implementation for each block of figure 3.4.5 is explained.

51

Page 66: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

3. The Effects

Delay units

Delay units include predelay as well as the four delay lines appearing in the tank.They consist of simple delay lines implemented by linear buffers in which the lastvalue is the output. The buffer is updated after the input is inserted in beginningof the vector. See code in appendix F.6.

Lowpass filter 1

Its difference equation

y(n) = bandwidth � x(n) + (1� bandwidth) � y(n� 1), (3.4.6)

is computed from the bandwidth, the input sample x(n), and the output valuefrom previous iteration y(n-1). See code in appendix F.6.

Lowpass filter 2 and 2’

Its difference equation

y(n) = (1� damping) � x(n) + damping � y(n� 1), (3.4.7)

is computed from the damping, the input sample x(n), and the output value fromprevious iteration y(n-1). See code in appendix F.6.

Allpass 1, 2, 3, 4, 6 and 6’

They are implemented from their difference equation

y(n) = diffusion � y(n) + x(n�m)� diffusion � y(n�m), (3.4.8)

where diffusion would be in diff1, in diff2 or dec diff2 and m the delay lengthfor each filter.

Past samples are obtained from two buffers, one containing input values andthe other output values. Both are updated right after computing the differenceequation. See code in appendix F.6.

52

Page 67: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

3.4 Reverberation

Allpass 5 and 5’

As explained in design section 3.4.2, this filters have some peculiarities. Theirdifference equation differs from the other allpass since they have their sign invertedin their feedback gains. Moreover their delay lengths are variable in time, then aLFO is needed. Dattorro suggests an excursion of 24 samples, for a sample rateof 44,100 Hz, and frequency of 1 Hz. The code of this filters is listed below as anexample, even tough it is included in appendix F.6.

%%%%% Allpass filter 5 with excursion%%%%%

% Calculate excursionr = round(excursion * sin((2*pi/round(fs/flfo))*n)); % LFO

% Apply filtery7 = - dec_diff1*(ya+yc) + all_in5_b(all_d(5) + r)

+ dec_diff1*all_out5_b(all_d(5) + r);

% Load buffersall_in5_b = [(ya+yc);all_in5_b(1:end-1)];all_out5_b = [y7;all_out5_b(1:end-1)];

Decays

Decays are simply multipliers following:

y = decay � x (3.4.9)

Once each block is designed, they are joined together according to Dattorro’s flowdiagram.

Output Section

Dattorro gives the expressions for extracting the reverb tail. They are listed inthe design section. In order to obtain the reverberation signals (yL and yR),those expressions have been followed. In order to mix those reverberation tailswith the input signal, this mixer has been implemented:

53

Page 68: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

3. The Effects

%%%%% MIX %%%%%

yL = (1-mix)*xL + mix*yL;yR = (1-mix)*xR + mix*yR;

In addition, as considered in previous section 3.3.1, the output signal will belonger than the input signal depending on decay and predelay parameters. Thatwill make the output longer in a certain amount of samples. In order to write theoutput signal into a vector in Matlab, and avoid cutting the reverberation tail,it was agreed to calculate this length. Thus, it will be stored in a variable calledreverb tail. Its calculation process is explained in appendix C.

3.4.4 Results and Conclusion

A test period has been carried out after implementation. It helped to properlyunderstand the effect caused by each parameter and set their limits. After sometime testing the effect, good results are obtained, not showing any strange ar-tifact. Apart from that, and due to the subjective nature of the reverberationevaluation, a listening test has been carried out showing good response from thesubjects. These test methods and their results will be extended in chapter 5.One objective measure of reverberation is its impulse response, showing reflec-tions density and decay shape. Next, some impulse responses are shown. Eachhas different parameters settings.

Decay Influence

Figure 3.4.8 shows the influence of the decay parameter over the impulse response.It is easily inferred the relationship between reverberation time and decay values.

Input Diffusion Influence

The influence of the input diffusion parameter over the impulse response is shownin figure 3.4.9, the reflections density is directly related with this parameter. Theinput section does not provide the tank with enough copies of the signal if thisparameter is set to a low value, then the overall density of reflections is affected.

54

Page 69: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

3.4 Reverberation

Figure 3.4.8: Impulse responses for decay = 0.5, decay = 0.05 and decay =0.001.

Decay Diffusion Influence

The influence of the decay diffusion parameter over the impulse response is shownin figure 3.4.10. It is inferred that it affects in the reverberation time as thisparameter adjusts the loop gains of the allpass filters of the tank recirculation.It is also recommended to set this parameter around its central value (0.5) toprevent aural patterns in the response. The figure 3.4.10 shows those undesirablepatterns.

55

Page 70: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

3. The Effects

Figure 3.4.9: Impulse responses for input diffusion 1 and 2 = 0.1 andinput diffusion 1 and 2 = 0.95.

Figure 3.4.10: Impulse responses for decay diffusion1 and 2 = 0.1 anddecay diffusion 1 and 2= 0.95.

56

Page 71: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

3.5 Modulation Effects

3.5 Modulation Effects

A very clear and brief definition of modulation, presented in [Zol05], is going tobe used to introduce this section.

‘Modulation is the process by which parameters of a sinusoidal signal (amplitude,frequency and phase) are modified or varied by an audio signal [...] Wah-wah,phaser and tremolo are typical examples of amplitude modulation and vibrato,flanger and chorus are examples for phase modulations of the audio signal.’

This sinusoidal signal mentioned above is generated by a Low Frequency Oscillator(LFO). The diverse effects will be accomplished by different ways to be appliedto the input signal and its parameters configurations.

In the following sections an explanation about theory, design, implementation andresults and conclusions of the implemented modulation effects (chorus, flanging,vibrato and tremolo) is realized.

3.5.1 Flanger and Chorus

Theory

Flanging effect was produced in the 1960’s by recording two tape decks simulta-neously and mixing the result. As they were recorded, an audio engineer wouldlightly touch the flange of one the tape reels slowing it down, creating a swhoosh-ing effect when played back [Tab05a].

Thus, flanging is the effect in which the original signal is mixed with a delayedversion of itself, when the delay value varies along time.

It is important to understand the filtering effect a delay produces in the outputsignal to understand the flanging. When applying a constant delay to a signal, theoutput is filtered by a series of notches in its frequency response. Those notchesare frequencies in which the response is zero, hence the signal is eliminated. Thisfrequency response corresponds to a comb filter. The notches are created by de-structive interference between the original signal and the delayed one. Dependingon the delay applied, the frequencies in which both signals are perfectly out ofphase will be eliminated (destructive interference), while the others are passedthrough.

When these notches sweep up and down the frequency axis over time, the flangingeffect appears. This sweep is due to the changes in the delay amount, determined

57

Page 72: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

3. The Effects

by a LFO [Har07]. Flanger is often used sparingly to add a swooshing effect fora brief time. It is also used during single note solos.

The aim of the chorus effect is making an instrument sound like the same instru-ment played simultaneously. It is important to note that, when that happens, thepiece is not played in precise synchronization (what will result in small delays,above all at the beginning of the composition). Besides, they are not perfectly intune and the sound would never reach the audience (or the microphone) at thevery same time [Tab05a].

Its principle is very similar to the flanging, splitting the input and slightly delayingone of the parts, to mix them all at the output of the effect. Together with thepossibility of having more than one voice, the maximum delay time applied toflanger and chorus effect is different, being higher in the chorus.

Chorus is usually used with clean tones, but can be added to distortion for athicker distortion with a unique tone or muted arpeggios.

Design

The flanger algorithm [Orf96] can be achieved by varying the delay d(n) period-ically between 0 and D, with a low frequency Fd. As can be seen in figure 3.5.1,the variable delayed and attenuated version of the input and the input itself aresummed to obtain the output signal. The difference equation 3.5.1 can be easilyinfered from figure 3.5.1 as well, where x(n) is the original signal, y(n) is theoutput signal and a is the gain of the feedback loop.

Figure 3.5.1: Block diagram of a flanger [McG07].

y(n) = x(n) + ax(n� d(n)) (3.5.1)

58

Page 73: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

3.5 Modulation Effects

Lets suppose that a sinusoidal variation of d(n) is required. Then d(n) would bedefined as follows,

d(n) =D

2(1� cos(2πFdn)) (3.5.2)

Figure 3.5.2: Frequency response of a flanger effect.

In figure 3.5.2, the frequency response of the system is shown. The notches occurat odd multiples of π divided by the variable delay d (odd multiples of fs/2d, fsthe sampling frequency), while a determines the depth of the notches. That isthe typical response of a time-varying comb filter, which produces the flangingeffect.

As the effect is dealing with samples, it is important to notice that d can take non-integer values within its range. Therefore the implementation of 3.5.1 requiresthe calculation of the delay line output at such non-integer values. This can beeasily achieved by rounding, truncation or linear interpolation [Orf96].

Flanger effect is controlled [Har07] according to the values of its depth, delay,rate, and LFO waveform.

� Depth determines how pronounced the notches in the response are. It canvaries from 0 to 1 (0% to 100% [GNa07]).

59

Page 74: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

3. The Effects

� Delay determines the maximum delay to be applied. This value must beless than 15 ms [Zol05].

� Rate is basically the frequency of the LFO (how many times per second thenotches sweep up and down). It can varies from 0.05 Hz to 20 Hz [GNa07].

� LFO waveform determines the way in which the delay varies in time.

To get into the algorithm of the chorus, it seems logical that a summation ofdelayed pitch modulated signals must take place [Tab05a]. This block diagramis shown in figure 3.5.3, where a dual-voice chorus is displayed. In a similar waythan flanger, the difference equation 3.5.3 of a dual-voice chorus can be infer fromthat figure.

Figure 3.5.3: Block diagram of a dual-voice chorus [McG07].

y(n) = x(n) + a1x(n� d1(n)) + a2x(n� d2(n)) (3.5.3)

where d1(n) and d2(n) are defined in 3.5.2. By making use of the gains a1 and a2

the unprocessed signal can be placed in a rear level, reaching a wider sonority.The pitch modulation introduced by the variable delay is aimed to simulate thetune variation of the different voices. Besides, this variable delay can be obtainedby means of the LFO signal or a low-frequency filtered white noise [Tab05a].

Chorus is controlled with the same parameters as the flanger, the difference issituated in the values they take. For example, delay in a chorus must be higherthat in a flange, varying among 10 ms and 25 ms [Zol05].

60

Page 75: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

3.5 Modulation Effects

Implementation

These effects were implemented in Matlab in the functions flanger.m and cho-rus.m, which may be seen in appendix F.7.1 and F.7.2, respectively.

Concerning flanger and chorus implementation, there are several ways to reachit. The first solution to be taken into account would be obtaining the impulseresponse of a Comb Filter, so that the result would be the convolution of theinput signal and that impulse response. But, since the amount of delay appliedis continuously changing over time, the coefficients of the filter will vary as well,so a variable in time filtering would be necessary. For that reason, this solutionhas not been used in none of the modulating effects. However, a most intuitivesolution using vectors and matrices has been chosen as the implementation forthose effects in the sample-by-sample procedure.

As mentioned above, a variable delay is needed in order to accomplish flangingeffect. Thus, a buffer must be created to store the quantity of past samples of theinput signal, which size will be determined by the maximum delay D. This buffercan be consider as a FIFO (First In First Out) fed from the end. First of all, themaximum delay time (milliseconds) has to be converted into number of samples(md fla or md cho), which will determine the size of the buffer. Once the buffer iscreated, it has to be updated with an incoming input sample signal every iteration.Then, the corresponding sample of the low frequency signal generated by the LFO(with omega Wd) is obtain iteration by iteration too. That will determine whichpast sample of the input signal buffer will be taken to be attenuated a factor a flaand summed together with the original signal. Next, a fragment of Matlabcode, concerning the explained part above is displayed as follows.

% Update the bufferbuffer_fla(1) = [];buffer_fla(end+1) = b; % b is the current input sample

% variation of the delay d(n) at a certain nd = round((md_fla/2)*(1-cos(Wd_fla*n)));

% y (n) = x(n) + a*x(n - d(n))y_fla = buffer_fla(end) + a_fla * buffer_fla(end-d);

It was mentioned before, that d(n) can take non integers values within the rangefrom 0 to D, so that a rounding method of those values has been carried out.

As an extension of flanger, the chorus implementation uses some basic ideasand code lines in a similar way, but the particular case that the chorus to be

61

Page 76: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

3. The Effects

implemented holds two voices of delayed versions of the input signal. In orderto accomplish a dual-voice chorus, the user introduces the parameters (maximumdelay, attenuation and rate) for the first voice, while the parameters of the secondvoice are internally calculated by the effect. This internal calculation is justmultiplying all those parameters by a random factor which varies from one tozero. This decision has been motivated together with the idea of creating a user-friendly multi-effects processor; therefore the user does not have to spend a longwhile choosing the parameters for each voice. Once all the voices are calculated,the summation of all values is realized to obtain the output of the effect. Themost relevant part of the code is shown as follows.

% Update the bufferbuffer_cho(1)= [];buffer_cho(end+1) = b;

% Calculating voice 1: User defined voice%----------------------------------------%number of maximun samples delayedmd_voice1 = round(v_cho*fs/1000);

% variation of the delay d_1(n)d = round((md_voice1/2)*(1-cos(Wd_cho*n)));

% Output of the voice number 1voices(1) = a_cho*buffer_cho(end-d);

% Calculating voice 2: Randomly variation%----------------------------------------%number of maximun samples delayedmd_voice2 = round(v_cho*rand_factor*fs/1000);

% variation of the delay d_2(n)d_2 = round((md_voice2/2)*(1-cos(Wd_cho_v2*n)));

% Output of the voice number 2voices(1) = a_cho*rand_factor*buffer_cho(end-d_2);

Results and Conclusion

Finally, if the delay varies in a periodic way around some value less than 15 ms,with a low frequency oscillation, around 1 Hz, the resulting signal will be theoutput of a flanger effect. Nevertheless, if the delay time fluctuates between

62

Page 77: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

3.5 Modulation Effects

10 ms and 25 ms, and they are affected by slow random oscillations, the choruseffect is present in the outcoming signal [Zol05] [McG07].

Sound samples of flanger and chorus processed signals are included in the CD, sothat the reader can have a complete idea of how the resulting signals sound like,and how the different parameters influence it.

3.5.2 Vibrato

Theory

Vibrato is the simplest pitch modulation effect. In this case, the frequency of theinput signal is cyclically varied by the LFO signal but, in contrast to a flangingor a chorus effect, no dry input signal is used to obtain the output [Tab05a].

A guitarist creates a vibrato by moving the finger back and forth on the fin-gerboard. The variable string length causes a constant frequency modulation.Vibrato is used in order to give more depth and sustain to the sound.

Design

As shown in figure 3.5.4, the variation on the input pitch is accomplished byapplying a variable time delay line to the unprocessed signal. Thus, the differenceequation is represented in 3.5.4

Figure 3.5.4: Block diagram of a vibrato [McG07]

y(n) = x(n� d(n)) (3.5.4)

where d(n) is defined as 3.5.2

63

Page 78: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

3. The Effects

Vibrato effect is controlled [Har07] according to the values of its delay, rate, andLFO waveform.

� Delay determines the maximum delay to be applied. This value can varybetween 5 ms and 10 ms [Zol05].

� Rate is basically the frequency of the LFO (how many times per secondthe notches sweep up and down). It can varies from 5 Hz to 14 Hz [GNa07].

� LFO waveform determines the way in which the delay varies in time.

Implementation

This effect was implemented in Matlab in the function vibrato.m, which may beseen in appendix F.7.3.

Once 3.5.4 is known, the implementation of this effect is just a simplification offlanging. A buffer of size of the maximum number of samples delayed is neededto store the input as well, so that it can be used to process the output everyiteration. A relevant part of the vibrato code is included next.

% variation of the delay d(n)d = round((md_vib/2)*(1-cos(Wd_vib*n)));

% output sample of the vibratoy_vib = buffer_vib(end-d);

Results and Conclusion

In order to understand the effect, an example is presented. The input signal is a10 Hz sinusoidal signal , the sampling frequency is 44,100 Hz and the number ofsamples shown in the figure 3.5.5 is 50,000. Vibrato is set with next parametersvalues:

� Rate (frequency of the LFO) = 1 Hz.

� Maximum delay time = 10 ms.

64

Page 79: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

3.5 Modulation Effects

Figure 3.5.5: Vibrato applied to a sinusoidal signal.

According to the figure 3.5.5, the frequency modulation realized is shown. Notethat this is only an example to clarity this effect, since the input of the signal isnever going to be a tone, but a more complex signal.

When the average delay time varies between 5 ms and 10 ms, with a rate between5 Hz or 15 Hz in the low frequency oscillator, then a typical vibrato is processed[Zol05] [McG07]. Some sound samples of vibrato processed signals are includedin the CD, so that the reader can have an idea of how the processed signals soundlike.

3.5.3 Tremolo

Theory

A tremolo is basically a fluctuation of the signal amplitude periodically overtime. Due to those variations, it can be considered as an amplitude modulation,produced by applying a low frequency oscillating mask to the input signal. Thus,the amplitude of the original signal varies according to the amplitude of the lowfrequency signal. The tremolo effect appears when the LFO is below 20 Hz [Zol05].

In this modulation process, the input signal is the carrier and the low frequencysignal generated by the LFO is the modulator. In order to achieve different tinges

65

Page 80: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

3. The Effects

of the same tremolo, diverse LFO signal can be used. The most common LFOsignals used are triangle-wave and sine-wave.

A guitarist can use a tremolo effect in many artistic ways, for instance, for slownotes runs, or together with distortion for chords [Bet07].

Design

This amplitude modulation mentioned above can be designed as a multiplicationof the input signal and a weighted version of the LFO signal. As can be inferredfrom figure 3.5.6, tremolo effect follows the equation 3.5.5 [Zol05], where y(n) isthe output, x(n) is the audio input signal, m(n) is the modulator and α is thecoefficient that determines how deep the modulation is going to be. If it is equalto one, the modulating effect will reach its maximum value; otherwise, if it is zero,no modulation will take place. Assuming that m(n) peak amplitude is 1 and thephase must remain unchanged, an offset must be added to the modulator signal,so that all the values of the LFO signal are positive.

Figure 3.5.6: Block diagram of a tremolo [Zol05].

y(n) = (1 + αm(x))x(n) (3.5.5)

Tremolo is controlled by the parameters rate, depth and LFO waveform.

� Rate sets the speed of the effect, the frequency of the LFO. It takes valuesfrom 0.05 Hz to 20 Hz. [GNa07]

� Depth shows how much attenuation the effect has. It can varies from 0 to1 (0% to 100% [GNa07]).

� LFO waveform determines the signal type.

66

Page 81: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

3.5 Modulation Effects

Implementation

This effect was implemented in Matlab in the function tremolo.m, which maybe seen in appendix F.7.4.

Concerning Matlab implementation, this effect is just a multiplication of both,original and weighted LFO signals sample-by-sample. Thus, the aim has beento create an LFO signal in which the user can choose the rate and the depth.Nevertheless, the user will not be able to choose among different waveforms inthe LFO, only the sine wave form has been consider as relevant. One of the mainaims of the multi-effect processor developed is the user-friendly characteristic,thus the type of LFO has decided not to be implemented. A relevant part of thevibrato code is included in the next lines.

% trem = (1 + alfa * m(n))trem =1 +(a_trem*sin(2*pi*n*(f_trem/fs)));

% output sample of the tremolo% b is the curreny input signaly_trem = b*trem;

Results and Conclusion

To clarify tremolo effect, an example is presented. A 10 Hz sinusoidal signal isplaced as the input of the system, the sampling frequency is 44,100 Hz and thenumber of samples shown in the figure 3.5.7 is 100,000. Tremolo is set with nextparameters values:

� Rate (frequency of the LFO) = 1 Hz

� Depth = 0.9

In figure 3.5.7, the amplitude modulation realized by the tremolo effect is shown.Note that this is only an example to clarify this effect, since the input of thesignal is never going to be a tone, but a more complex signal. Real examples oftremolo are included in the CD, so that the reader can have an idea of how theprocessed signals sound like, after all the main aim of the effects.

67

Page 82: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

3. The Effects

Figure 3.5.7: Tremolo applied to a sinusoidal signal.

3.5.4 High-cut filter

Sometimes, reducing the high frequencies in those modulation effects could bedesirable. Specially, when the presence of the effect is too dominant, but the userwants to preserve the depth of the effect [GNa07].

To accomplish that objective, a first-order lowpass filter that attenuates highfrequencies was designed. It was introduced in the output of all effects explainedin this section. The block diagram of such system is shown in the figure 3.4.6 ofthe reverberation effect section 3.4.2.

Its difference equation is:

y(n) = (1� g)x(n) + gy(n� 1) (3.5.6)

It makes use of the parameter cutf in the following way,

g = 1� cutf (3.5.7)

which is related to the filter cutting frequency and ranges from 0 to 1.

68

Page 83: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

Chapter 4

Combination of Effects

In this chapter the virtual multi-effect processor implemented is presented asa unique module formed by the effects explained in the previous chapter. Thedeveloped processor consists of twelve effects, divided in six different blocks: noisegate, equalizer, compressor, modulation, delay and reverberation. Furthermore,it can be used with two different signal routings: serial and parallel. As it isspecially designed for acoustics guitar, it can deal with two different signals. Onecoming from the pickup of the guitar and the other coming from a microphone.A description of its main features, as well as the structure of the processor willbe explained in more detail in the following sections.

Once the implemented effects are working individually, a combination of all ofthem is necessary to develop the multi-effect processor. For that purpose thereare some important issues to consider.

Firstly, the possibility of working with two different input signals (one comingfrom the pickup of the guitar and the other one coming from a microphone) mustbe considered. Regarding that, each signal should have its own noise gate, equal-izer and compressor. This feature becomes really important when, for example,recording the signal with a microphone in a noisy ambient, such as a live per-formance, where using different settings of such effects is highly recommended.Nevertheless, it is not that significant having an independent processing of thesignal with delay, modulation and reverberation effects, since they have a moreartistic purpose.

Secondly, a bypass system for every effect has been considered essential. So that,the user not only has the possibility to setup every effect, but also to choose whenusing them. Furthermore, the multi-effect processor offers two different routingfor the signal in order to provide a more versatile usage.

69

Page 84: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

4. Combination of Effects

As it was mentioned in chapter 2, both inputs (pickup and microphone) are monowhile the output signal of the whole processor is stereo.

4.1 Routings

The implemented multi-effect processor provides two different routings: serial andparallel. Both routings have independent noise gate, compressor and equalizerlines for the pickup and the microphone input sections.

The serial routing, figure 4.1.1, connects all effect in line. This means that theoutput of an effect is the input of the next one.

Figure 4.1.1: Block diagram of the serial routing, based on [GNa07].

As it can be seen in figure 4.1.1, there is a so-called Mic Pre-routing block [GNa07],where the user can choose whether using a Vocal or a Guitar configuration. WhenVocal mode is chosen in a serial routing, the microphone signal will not be affectedby delay and modulation sections, but by reverberation. This configuration (vocalplus serial routing) could be selected by a user interested in using the microphone,not to pick up the guitar signal, but a voice. In that case, most probably justa reverb is going to be need for such signal, skipping then the modulation anddelay part. Such reverb is applied to the summation of the processed pickup andthe microphone signal.

Note that, in order not to enlarge the figure 4.1.1, a combination of all the mod-ulation effects, as well as the delay ones has be done. In figures 4.1.2 and 4.1.3this combination can be seen.

In the parallel routing, figure 4.1.4, the same signal is fed to the input of themodulation, delay and reverb blocks, and therefore these effects will not affecteach other.

Similarly to the serial routing, in figure 4.1.4 a Mic Pre-routing can be selectedby the user as well. By choosing Vocal with a parallel routing, none of the

70

Page 85: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

4.2 Implementation

Figure 4.1.2: Block diagram of the serial modulation block.

Figure 4.1.3: Block diagram of the serial delay block.

Figure 4.1.4: Block diagram of the parallel routing, based on [GNa07].

modulation, delay or reveberb effects would be available for the microphone signal.If the Guitar configuration is selected, the summation of both signal would bethe input of the parallel (modulation, delay and reverb) blocks.

Note that, in order not to enlarge the figure 4.1.4, a combination of all the mod-ulation effects, as well as the delay ones has be done. In figures 4.1.5 and 4.1.6this combination can be seen.

4.2 Implementation

As mentioned in chapter 2, the working philosophy is sample-by-sample based,where the core of the script is a for loop in which for every iteration an input

71

Page 86: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

4. Combination of Effects

Figure 4.1.5: Block diagram of the parallel modulation block.

Figure 4.1.6: Block diagram of the parallel delay block.

sample is processed through the selected effects in the chosen routing way. As aresult, an output sample is stored in an output vector. Since most of the effectsneed access to a certain number of past samples the usage of buffers is required.

In an attempt to make the code as easy to understand as possible, the main scriptis structured in the following five principal parts: decision vector, defining part,load signal, preliminary calculations and core of the processor.

4.2.1 Decision Vector

It is important to mention that this solution to bypass the effects was supposedto be a mere link between the main function (Matlab) and a graphical userinterface. However, this GUI has not been realized in an attempt to develop areal time implementation of some of the effects.

Each element of that decision vector implies whether a determined effect is going

72

Page 87: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

4.2 Implementation

to be used or not (bypassed). Each element represents a determined effect, inaddition there are two reserved elements to choose between vocal and guitarrouting. If its value is zero it means that this specific effect or routing is notgoing to be used, otherwise if it takes the number of the effect, it is activated.The easiest way of understanding this procedure is by means of an example.

Let us suppose that the user wants to use a noise gate for the microphone input,equalizer for both inputs, compressor for the pickup, vibrato and pingpong delay.Besides, a guitar routing is preferred. The decision vector w, would result asfollows:

w = [0 2 3 4 5 0 0 8 0 0 0 0 0 0 15 16 0];

% case 0 % Bypass,% case 1 % Noise Gate% case 2 % Noise Gate Mic% case 3 % Equalizer% case 4 % Equalizer Mic% case 5 % Compressor% case 6 % Compressor Mic% case 7 % GUITAR ROUTING% case 8 % Vibrato% case 9 % Tremolo% case 10 % Flanger% case 11 % Chorus% case 12 % Echo% case 13 % Feedback Delay% case 14 % Dynamic Delay% case 15 % Ping-Pong Delay% case 16 % VOCAL ROUTING% case 17 % Reverb

The decision vector contains not only decision about bypassing effects but alsoinformation concerning the signal routing, vocal routing and guitar routing, thatindicates where to sum the signals, within the chain of effects. Thus, the signalis processed and a stereo output vector is created, iteration by iteration.

Seeing figures 4.1.1 and 4.1.4, it is understood that a change in the order of thelast two elements of the decision vector is required, in order to use the same vectorfor both vocal and guitar routings. This change is nothing but switch the positionof the two last elements, corresponding to the reverberation block and the guitarrouting. If such elements would remain unchanged, the parallel routing wouldnot be correct. This change is realized the parallel routing part.

73

Page 88: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

4. Combination of Effects

4.2.2 Definition Part

In that part all global variables and buffers are defined, as well as the user pa-rameters for all the effects. Next, an example of the definition of a buffer and avariable for vibrato effect.

% __________ Modulation _____________% Vibratoglobal buffer_vibglobal ycut_vib

4.2.3 Loading Signals

As the processor is designed to be used with an acoustic guitar signal, two inputscan be processed. Both signals are stored in two different vector using wavreadMatlab function. Input vector stores the signal coming from the pickup, whileinput mic stores the signal from the microphone. Since the value of the samplingratio is going to be needed for most of the operation, it is also stored in thevariable fs.

[input,fs] = wavread(’example_signal_pickup’);[input_mic,fs] = wavread(’example_signal_mic’);

4.2.4 Preliminary Calculations

Many of the effects require a few parameters and calculations to be obtained inadvance. As they are fixed values for the entire process, they are calculated pre-viously, and not inside of each function. That would mean that the same valueis calculated iteration by iteration, what would involve an increasing time forthe whole processing progress. These previous calculations are mainly: initializebuffers and variables, and calculating the tail of the outcoming signal (see chapter3 for further explanations).

4.2.5 Core or Engine of the Processor

Firstly the routing decision is evaluated by a switch, deciding whether to forwardthe signal in a serial or a parallel way. Once this decision is made, the so-called

74

Page 89: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

4.2 Implementation

’sample-by-sample for loop’ starts. This for loop covers the whole length of theinput signal. Therefore, every iteration a single input sample feeds a secondfor loop, so-called ’decision for loop’ that covers the decision vector. From thatmoment on (for every iteration of this ’decision for loop’ ), a sample is processed bya single determined effect evaluated in a switch loop with the cases of every effectand guitar/vocal routing, every iteration. When ’decision for loop’ is finished,the processing part over that single sample is done. Should the reader need amore thorough understanding about this approach, it is included in next lines,which represents an schematic pseudo-code version of the core of the processor.

switch routing % Chosing the serial or parallel routing

case ’serial’% SERIAL ROUTING implementation for the Virtual Effect Processor% ---------------------------------------------------------------for n = 1:input_length

% Store one pickup input sample in a variable% Store one microphone input sample in a variable

for s = 1:decision vector length

switch w(s)

% All the cases of the effects and vocal/parallel routing% In the serial routing the output of an effect is the% input of the next one

end % SERIAL ROUTING effects switchend % SERIAL ROUTING decision for loop

% Store the output samples in the output vector

end % SERIAL ROUTING sample-by-sample for loop

%------------------------------------------------------------------case ’parallel’

% PARALLEL ROUTING implementation for the VirtualEffect Processor% ---------------------------------------------------------------

% changes to use the SAME decision vector in both routings

% Find out how many effects are ON

75

Page 90: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

4. Combination of Effects

% The modulation, delay and reverb blocks are in parallel, so% these effects do not affect each other. They have the same% input but independent output, to be summed at the end.

for n = 1:input_length

% Store one pickup input sample in a variable% Store one microphone input sample in a variable

for s = 1:decision vector length

switch w(s)

% All the cases of the effects and vocal/parallel routing% In the parallel routing the output of an effect is the% input of the next one ONLY in the noise gate, EQ and% compressor blocks.

end % PARALLEL ROUTING effects switchend % PARALLEL ROUTING decision for loop

% Store the output samples in the output vector

end % PARALLEL ROUTING sample-by-sample for loop

%--------------------------------------------------------------------end % routing (serial/parallel) switch

76

Page 91: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

Chapter 5

The Effects Evaluation

The main objective of this project is designing a virtual effect processor tuned foracoustic guitar, where the musician can set the parameters of the effects, gettinga variety of sounds without losing the natural character of his instrument.

Once the implementation of each effect has been made and the whole structurehas been designed and implemented, an evaluation of the system is required.

Firstly, each effect was designed separately trying to find the optimal code wherethe input signal is modified according to the parameters. Therefore, the hardesttask is preserving a natural sound on the processed signal altering features in theoriginal at the same time.

Once the implementation is managed, the problem is getting some objective feed-backs to know if the generated sound by every effect could be compared qualita-tively with a commercial one.

In the beginning, the possibility of doing an evaluation between the developedeffects with the commercial’s was discussed. G-Natural user’s manual has beenused to get some concepts concerning the operation of an effects processors. A firstsolution is comparing the G-Natural sound with the effects processor developedone. But due to time limitations, this analysis was rejected.

Other solution was thought in order to achieve an objective evaluation. It consistsin getting some people together to participate in an informal listening test inorder to get some results and useful feedbacks for the effects. Each effect shouldbe tested separately creating sound samples with different parameters as well asthe original one. Also, a comparison with a commercial PC-based processor couldbe carried out.

77

Page 92: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

5. The Effects Evaluation

Through a listening test with a specific audience, and trusting the criterion of thedevelopers, some presets for each effect could be managed.

5.1 Listening Test

Mainly, the test procedure consists of preparing sound samples for each effect inorder to show the subjects the sounds generated derivate from the combinationsof the different parameters used to implement the effects and to obtain someconclusions of their feedbacks.

First of all, developers have analyzed each effect separately looking for what arethe desired outcomes for each effect. As well as their own criterion explained inthe preliminary analysis, the listening test could help to ensure the success of thesounds generated.

5.1.1 Preliminary Analysis

Equalizer Test

This part of the listening test refers to an older implementation of the equalizer. Inthis implementation it was necessary to calculate frequency and impulse responsesfor filters. For the used algorithm a certain number of points n for the Fouriertransform had been chosen.

This number of points was representing the resolution of the frequency response.When the number of points was too high, then computational time was high.Contrary, if that amount was too low, the resolution was low as well and theobtained frequency response was differing too much from the desired one as itcan bee seen in figure 5.1.1. This would have been perceptible.

Hence, thinking about the upcoming listening test, equalizer questions should befocused on the comparison between samples with a certain number of points andthe reference one in order to decide the optimum number of points. This amountmust be set so that the difference between the desired frequency response and thegenerated frequency response would not be noticeable.

A sound signal was processed with the described equalizer implementation above,having two narrow peaks in the frequency response. This procedure was done withdifferent number of points: 128, 512, 1024 and 16384. The last one represents the

78

Page 93: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

5.1 Listening Test

Figure 5.1.1: Frequency response for different numbers of sample points byusing the Matlab function freqz.

reference sample. Also, a control sound sample was included in order to detectthe listening level of the audience. This was the same as the reference sample.

The subjects were asked about the similarity grade between different samples,the optimum resolution of the frequency response will be discovered.

Reverberation Test

Due to the fact that reverberation is a qualitative effect and must be evaluatedwith regard to the sound impression, this process will be mainly done based onthe criterion of the developers.

Once the implementation has been managed, the first objective is checking thatthe obtained sound sample is similar to the known characteristic sound of rever-beration. After that, in order to approach to realistic sounds, user parametersmust be set looking for typical values in each case.

The first reverberation implemented was based on Moorer’s algorithm, but aftertesting its sound quality did not meet the requirements.

Then, Datorro’s algorithm was considered, all the code was implemented again fol-lowing a sample-by-sample solution. Thus, qualitative measurements were madein order to delimit the range of the different parameters. In addition, this algo-rithm was exported to a real time architecture [Syn07], and it helped greatly to

79

Page 94: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

5. The Effects Evaluation

understand the influence of each parameter on the response of the reverberator.This method made conclusions come faster.

In the listening test, the subjects are asked about the differences between thesound reached and a sound sample processed by a commercial reverberator. Toobtain a commercial sound of a typical reverberation, the audio software Audi-tion [Aud04] was used.

Taking into account the reasonable values of each parameter provided thanksto the audio software, some presets with typical sound configurations such ashall, room or shower were designed. The listening test will provide a feedbackconcerning the similarity between commercial and developed presets.

Compressor and Noise Gate Test

The compressor is probably the least intuitive effect with regard to a possiblesound impression. The subjects are not able to appreciate easily if the amplitudeof the signal is being modified or not. Basically, the effect only will be notablewhen the subject hears the original sample and compares with the compressedversion.

In order to create some presets which can be compared between themselves andwith the original sample, a good idea could be fixing some parameters and tomodifying the rest of them to evaluate the changes in the dynamic of the signal.To achieve this, typical parameters used for acoustic guitar took into account.

The main objective in the listening test for the compressor effect is to check ifthe sound is natural or artificial. In fact, the presets must be obtained thanks tothe answers for this question.

First, the dry signal will be played followed by the processed samples. Finally inthis section, five processed samples were used to test the audience that is goingto attendance in the listening room . Thus, one of them will be equal to otherwith the intention to find out the listening reliable of the subjects.

Concerning to the noise gate effect, the same method will be followed only thatin this case the reference has to be a noisy sound sample. The desired outcomeshould be obtaining a good suppression of the background noise without theprocessed sample differing from the original qualitatively. The subjects will beasked about that they are able to appreciate this suppression and to check thesound quality.

80

Page 95: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

5.1 Listening Test

Modulation and Delay Test

Basically, the modulation and delay effects need to be tested to avoid that thegenerated signal sound looks like a comparison of the dry signal and the processedsamples can be done in order to obtain some useful presets for acoustic guitarplayers.

The procedure for the evaluation is similar to the other effects. To be sure thatthe generated sound in each case could be compared with the sound from acommercial effect, the audio software Audition was used. In addition, due tothe fact that in these effects a lowpass filter has been implemented, it could beconvenient to ask the audience, somehow, if they are able to perceive in whichsamples the low frequencies are more present with the intention of the generatedsound is warmer. The processed samples are similar, but the frequency of thisfilter will be modified in each case.

This in conjunction with the own criterion of the developers will let clarify theconsistent presets.

5.1.2 Listening Room

In order to carry out the listening test, the listening room of the Acoustics Lab-oratory in Aalborg university was used.

This room has been conformed to the IEC 60268-13 standard, which describes anaverage living room acoustically. The Listening room is used for both listeningtests and measurements.

Normally, during these tests, the subjects are asked to estimate the quality ofwhat they hear. Besides, this room offers the possibility that the equipment ishid behind curtains so that the subjects are not influenced by visual impressions.In addition, all equipment can be handled from the control room which is besidethe listening room [Aau07].

Therefore, the room must be prepared for the listening test. The position of thechairs will also be taken into account to favor the listening as much as possible.This room is prepared to accommodate from two to nine people approximately.The room structure can be seen in figure 5.1.2.

In order to explain the audience the steps to follow during the test, one of thedevelopers will explain the audience the steps to follow during the test, givingsome directions while other will play the samples generated.

81

Page 96: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

5. The Effects Evaluation

Figure 5.1.2: Listening room of the Acoustics Laboratory.

5.1.3 The Test Basis

To prepare the test, the developers recorded some samples with a Washburnacoustic guitar in the audiometry room of the Acoustics Department in AalborgUniversity. Next, a list of equipment used during the recording session can beseen.

� Mixer Behringer Eurorack MX802A

� Condenser microphone Rode NT3

� Audio interface Edirol UA-5

� Laptop with Adobe Audition 1.5

� Acoustic guitar Washburn

Several types of signal were need in order to accentuate some specific character-istics of the effects. Next, the effects and the type of signals required are shown.

� Compressor: attack high chords followed by quite parts.

� Noise gate: signal with some noise.

� Equalizer: full bandwidth solo.

� Reverberation and delay: low and high frequency easy and slow scales.Some percussion with the body of the guitar.

� Modulation: chord progression.

82

Page 97: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

5.1 Listening Test

Test Equipment

To apply the desired evaluation, it will be necessary to provide the room with aspecific equipment. The different samples will be played from a laptop with anaudio interface.

� Audio interface Edirol UA-5

� Loudpeakers Genelec (auto-amplified)

� Laptop with Adobe Audition 1.5

Tasks

The listening test is divided in seven different tasks (see form in appendix E.1).The parameters of the effects used to record the signal of each task are shown.

� Task 1: Equalizer Effect

In this task five different samples were presented to the subjects. The firsttwo samples are reference samples. Test sample number 3 is used as acontrol sample.

sample n

reference (good) 16384

reference (bad) 4

sound sample 1 1024

sound sample 2 128

sound sample 3 16384

sound sample 4 512

Table 5.1: List of signals used for task 1 and the number of samplepoints used to process them.

� Task 2: Compressor Effect

This task needs six different sound samples. The first one is dry, the restare processed with the parameters shown in table 5.2.

Basically, the threshold and the attack time were the only modified param-eters. This effect needs a hard ratio in order to get an noticeable com-pression, what would mean that the compressor is working as a limiter.

83

Page 98: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

5. The Effects Evaluation

Sample 1 2 3 4 5

Threshold 0.3 0.3 0.1 0.1 0.3

Ratio 0.1 0.1 0.1 0.1 0.1

Attack time [ms] 5 75 5 75 75

Release time [ms] 50 50 50 50 50

Output gain 1 1 1 1 1

Table 5.2: List of signals used for task 2 and the parameters used toprocess them.

Therefore, this parameter must not be modified. Regarding the releasetime, its changes are not very appreciable by the listeners.

As it can be seen in table 5.2, the samples 2 and 5 are equal since thedevelopers wanted to appreciate the sound quality of the audience.

� Task 3: Noise Gate Effect

This task requires five different samples, first sample is dry, and the rest ofthe samples are processed with the parameters shown in table 5.3.

Sample 1 2 3 4

Threshold 0.03 0.03 0.03 0.03

Damp 0.2 0.01 0.01 0.2

Attack time [ms] 10 1 1 10

Release time [ms] 5 5 5 20

Table 5.3: Parameter values of the noise gate effect samples.

� Task 4: Delay Effects

The five sound samples used in this task are processed with the effectsconfigured with the parameters shown in table 5.4.

Sample 1 2 3 4 5

Delay time [ms] 180 180 180 180 180

Mix 0.6 0.6 0.6 0.6 0.6

Feedback Gain 0.4 0.4 0.4 0.4 0.4

Cutf 0.5 0.3 0.1 0.4 0.2

Table 5.4: Parameter values for the delay effects samples.

84

Page 99: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

5.1 Listening Test

� Task 5: Modulation Effects

The 10 sound samples used in this task are processed with the effects con-figured with the parameters shown in table 5.5.

Flanger Tremolo Vibrato Chorus

Sample 1 2 3 4 5 6 8 9 10 11

Max Delay [ms] 10 10 10 15 5 10 8 8 10 10

LFO freq [Hz] 0.2 0.2 0.05 0.05 0.5 0.8 2 0.5 0.2 0.2

LPF Gain 0.4 0.2 0.2 0.9 0.2 0.2 0.2 0.9 0.4 0.2

Gain 0.7 0.7 0.7 0.7 0.7 0.7

Table 5.5: Parameter values of the modulation effects samples.

� Task 6: Reverberation Presets

Sound signals used in this task consist of three samples for each question,first sample is dry, second sample is processed by a commercial reverber-ation, and third sample by the reverberation developed. Each questionevaluates the resemblance between presets, corresponding to parametersshown in table 5.11. Table 5.7 shows the list of samples used in the test,where P symbolize a percussive sound and C symbolize a sample based onchords.

Preset Dry signal Comercial Developed

Question 1 Shower P P P

Question 2 Large Hall P P P

Question 3 Warm Room P P P

Question 4 Large Hall C C C

Table 5.6: Signals used for task 6.

� Task 7: Reverberation Presets

In this task two sound samples for each question are shown. They consistof the same sound processed by the commercial and the developed rever-beretions respectively, obtaining two samples to compare the presets. Thesame dry signal were used for all questions and it was a percussive sound.Table shows the playlist of the used samples. the C symbolizes the soundprocessed by the commercial reverberator, and the T by the developed one.

The listening test took around 25 minutes. The test was realized on seven subjectsat the same time.

85

Page 100: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

5. The Effects Evaluation

Percussive sound

Question 5 Shower P T

Question 6 Large Hall T P

Question 7 Warm Room P T

Table 5.7: List of signals used for task 7.

Compression Noise Gate

Threshold = 0.3 Threshold = 0.03

Ratio = 0.1 Damp = 0.01

Attack time = 75 ms Attack time = 1 ms

Release time = 50 ms Release time = 5 ms

Output gain = 1

Table 5.8: Compressor and noise gate presets.

5.2 Interpretation of the Results

After the preliminary analysis and the listening test, some conclusions were takenout.

The old version of the equalizer should have been implemented with a resolutionof 512 points, since the subjects considered, that the generated sound using thisresolution was the closest to the good reference sample with the least possiblecomputational cost.

About the dynamic processor effects, the feedbacks of the audience proved thatsome of the developed samples could process perfectly the audio signal withoutlosing sound quality. On the one hand, the obtained preset for the compressorshows a hard compression with attack and release time as it can be seen in table5.8. These values are within the typical ranges used in commercial processors.On the other hand, the preset that have been obtained concerning the noise gateeffect (see table 5.8 as well) could be used perfectly to eliminate the backgroundnoise of the signal in the channel for acoustic guitar player.

With regard to modulation effects, the best presets founded to simulate a realisticand a natural sound of these effects are shown in table 5.9.

For delay effect, the presets acquired from the listening test and the analysis withthe commercial audio software can be extracted in table 5.10.

Concerning the reverberation effect, the evaluation showed that the developed

86

Page 101: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

5.2 Interpretation of the Results

Flanger Chorus Vibrato Tremolo

Max Delay 12 ms 18 ms 8 ms 0.5 ms

LFO freq (rate) 0.05 Hz 0.2 Hz 0.5 Hz 5 Hz

LPF Gain 0.9 0.3 0.2 0.2

Gain 0.7 0.7

Table 5.9: Modulation presets.

Echo Feedback Dynamic Ping Pong Analog

delay 70 ms 180 ms 180 ms 180 ms 180 ms

mix 0.4 0.4 0.9 0.6 0.6

g 0.4 0.65 0.4 0.4

threshold = 0.3 Cutf = 0.2

damp = 0.5

release time = 200 ms

Table 5.10: Presets for the different delay effects.

samples were comparable with the samples generated by audio software. Theobtained presets provide the typical configuration to simulate some specific en-vironments, such as shower, room or hall. these parameters can be seen in table5.11.

All files can be founded in attached CD, which contains a folder called ’ListeningTest’ with all waveforms audio files. Also, there is another folder called ’Presets’where the dry signal and the preset used with the parameters of the table abovecan be found within their corresponding effect folder.

Large Hall Warm Room Shower

Mix 0.3 0.18 0.5

Predelay 3000 500 1300

Bandwidth 2000 Hz 600 Hz 20000 Hz

Damp 400 Hz 600 Hz 20000 Hz

Decay 0.3 0.01 0.03

Input Diffusion 1 0.8 0.9 0.5

Input Diffusion 2 0.7 0.8 0.4

Decay Diffusion 1 0.7 0.7 0.7

Decay Diffusion 2 0.65 0.8 0.65

Table 5.11: Reverberation presets.

87

Page 102: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

88

Page 103: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

Chapter 6

Real Time Implementation

The nature of an effects processor has led to consider a real time implementation.Despite not being the aim of this project, developing a real time processor basedon the effects achieved, arose as an ambitious idea. Thus, some of the effectsimplemented in Matlab have also been implemented as PC-based VST effectswith its own graphical user interface.

Even though Matlab is a powerful application, it has not been specially de-veloped to work as an audio processing environment out from the educationalfield, due to the fact that its processing time is too long for working in real time.Therefore, other tools have been considered. C programming language is the mostwidely used environment in audio programming. It is portable to many DSP ar-chitectures and achieves very good performance in terms of latency. However,its complexity would require a great effort to achieve the implementation, andit is out of the scope of this project. Hence, the real time multi-effect processorhas been developed under the audio programing tool SynthMaker. This toolbecomes a powerful and more user-friendly solution.

6.1 SynthMaker

Developed by Outsim, SynthMaker is an audio programming tool that allowscreating PC-based instruments and effects with graphical user interface. Theseinstruments and effects can then be used for playing via MIDI or as VST plugins tobe used in any recording software supporting VST, see figure 6.1.1. Its programingenvironment is based in the interconnection of different modules. Each modulehas its own function within the schematic, besides they can be edited in order toachieve the desired function. Starting from the modules included in the library

89

Page 104: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

6. Real Time Implementation

and creating new ones it is possible to perform any calculation and create anyeffect or instrument. Moreover it includes a module in which it is possible towrite DSP code and achieves calculations that otherwise would be complicatedto implement by means of interconections. To study its operation deeply, thereader is encouraged to visit its website www.synthmaker.com and consulting itsmanual [SyU06] or its component reference [SyC06].

Figure 6.1.1: Screenshot of the real time effect processor working over arecording software.

The real time developed effects processor is included in the enclosed CD withsome brief instructions attached. It is built as an executable file and a dynamiclink library, being the standalone application and the VST plug-in respectively.Further explanations about the implementation of each effect are far from the

90

Page 105: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

6.2 Real Time Effects Processor

scope of the project, as well as documentation concerning the graphical userinterface. For this reason only some screenshots and details will be given.

It is important to point out that SynthMaker allows to get in and out theschematic of every module. Thus, screenshots have been taken moving betweendifferent levels. Besides, in order to better understand the schematics shown, itis essential to clarify the meaning of each connector shown. It can be infferedthat the signal flows from left to right, and it passes through modules that treatit in different ways. The signal enters the module by the left side and leavesit by the right side. The connectors are the circles that allow links betweenmodules. Different kinds of connectors exist for the different signals involved inone implementation, but only two types are shown in the selected schematics.Within the blue ones is flowing the audio signal itself, which has a monofonicnature as coming from a continous stream provided by the guitar. The greenones with an F in the middle, allow links between float values, which can beunderstood as simple variables. However, there is an exception in the DSP codemodule, which treats float variables as monofonic signals.

6.2 Real Time Effects Processor

The real time effects processor is a light version of the one implemented in Mat-lab. Including only the following effects as an example.

� Compressor

� Equalizer

� Tremolo

Each effect has been implemented following its code in Matlab thoroughly, inorder to achieve results obtained with previous simulations. Through the pro-cess, other SynthMaker realizations were considered, some of them even moreadvanced, but discarded since the aim of this implementation was to go to theend with all of the designs carried out during the project.

The effects are interconnected following the same order as in Matlab. Theyalso have the same parameters as the user parameters designed for each function,and they are represented as knobs in the graphical user interface. The selectedvalue for each parameter is shown below each knob, providing full control of theprocessor in one view.

91

Page 106: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

6. Real Time Implementation

Figure 6.2.1: Screenshot of the real time effects processor.

6.2.1 Compressor

The compressor front panel is shown in figure 6.2.1. Getting into its internalschematic, figure 6.2.2, it is inferred that it follows the same design as it does overMatlab, composed by level detector, release stage, compression gain calculationand attack stage.

6.2.2 Equalizer

The equalizer front panel is shown in figure 6.2.1. The first two couples of knobscorrespond to the shelving filters, the rest correspond to the peak filters.

The internal schematic of the equalizer is shown in figure 6.2.3. Each couple ofmodules correspond to one filter, the first one performs the calculation of thecoefficients of the filter, while the second module contains the filter itself. This

92

Page 107: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

6.2 Real Time Effects Processor

Figure 6.2.2: Screenshot of the compressor internal schematic.

Figure 6.2.3: Screenshot of the equalizer internal schematic.

93

Page 108: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

6. Real Time Implementation

Figure 6.2.4: Screenshot of the implemetation of a biquad IIR filter underSynthMaker.

filter is implemented using SynthMaker DSP code shown in figure 6.2.4, notethat it works with simple instructions and allows transfer Matlab code easily.Both modules follow exactly the same equations used to implement the equalizerin Matlab.

6.2.3 Tremolo

Figure 6.2.1 shows tremolo front panel. It includes two simple knobs controlingthe frequency and the amplitude of the effect.

Its internal schematic is shown in figure 6.2.5 and consists of an LFO multiplyingthe signal and a mixer which controls the amount of the effect.

94

Page 109: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

6.2 Real Time Effects Processor

Figure 6.2.5: Screenshot of the tremolo internal schematic.

95

Page 110: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

96

Page 111: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

Chapter 7

Conclusions

The objective of the project was creating a virtual multi-effect processor in Mat-lab specially intended for acoustic guitar. This goal has been achieved. Theimplemented processor not only houses the most common effects presented in acommercial multi-effect device, but also deals with the particular properties ofthe input signal.

During the first part of the developing progress, the priority was to obtain all theindividual effects functioning properly. A research stage took place at the begin-ning when knowledge about the operation and implementation of the differenteffects was acquired. The possible solutions were discussed and the most optimalregarding the usage of an acoustic guitar was elected for every case. Thus, effectssuch as equalizer, compressor, noise gate, reverberation, modulation effects anddelay were implemented.

Once this aim was achieved, the second part of the progress was focused on cre-ating the multi-effect processor itself, based on the combination of the individualeffects. The outcoming tool provides versatility and also becomes an user-friendlyenvironment.

It is important to point out the essential presence of digital filters along thisproject. It turned out that both FIR and IIR filters were used in most of theimplemented effects showing its relevance in audio signal processing and its utilityfor many different purposes such as generating a delay or emphasizing certainparts of the audio spectrum.

Concerning the effects implementation, all of them are developed by using thesame sample-by-sample based philosophy. It means that, even though the achievedapplication is offline, the treatment is done in such a way that once the input sam-

97

Page 112: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

7. Conclusions

ple is appropriately processed is lead to the output. This is an attempt to makea treatment as close as possible to a future real time implementation.

A further improvement of the multi-effect processor could be to implement othereffects like wah-wah, notch filters, boost or a multi-band compressor. Howeversome of these effects are not suitable for an offline application. In order to avoidclipping and distortions in the processor, input and output stages, to take care ofthe level adjustment, could be included. The phase difference among the signalswithin the processor could be taken into account as well.

Concerning the evaluation of the effects, finding an objective criterion is a thor-ough task. An informal listening test was arranged in order to obtain feedbackabout the particular effects. A comparison with a commercial device could havebeen done as well. However, the processor is software-based and does not containan interface, i.e. equal conditions for such a test can not be assume.

Since Matlab is optimized for vector and matrix calculations it has shown slowcalculation speed for the purpose of this project. For that reason it is not ap-propriate for real time processing. Nevertheless, Matlab can be considered asa suitable tool for the simulation process, where the properties of the designedfilters can be tested and calculations can be performed. It may be seen as an steptowards real time implementation.

Many other issues arise when thinking further on a real application of the imple-mented processor. Some examples of those issues that could be included are:

� an input and output stage, allowing control of the signal levels in order toachieve the processor integration within the sound chain

� an advanced code control over the parameters introduced by the user, set-ting limitations and avoiding possible instability of the system

� a feedback system, which would improve the control over the processor,such as graphical user interfaces in the case of PC-based applications, orlevel meters, knobs and LCD screens in hardware devices

Considering those points, real time application has been partly reached and itsviability has been proved by implementing some effects. Those issues have beenfaced on its design, building a graphical user interface and providing precise con-trol over the processor.

98

Page 113: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

Appendix A

Dynamic Processors

A.1 Compressor: Further Information

With regard to the reduction of the amplitude, it is convenient to hold the soundcharacteristics of the signal. Otherwise the original sound quality would be lost.During all this process is necessary that the sonority of the instruments is sus-tained as similar as possible than before.

Used as a limiter, it is able to avoid possible distortions that normally appear inlive concerts. As well, the signal can be adapted for the used channel.

Most types of effects such as reverberation, equalizer and delays are designed tomake a change in the sound. The compressor effect, based on dynamics manipula-tion, is less intuitive. When used properly, most listeners would not be aware thatsignal processing is being used. In some situations, the effect may only be notableby comparing the original signal dynamic range with the compressed version.

The compressor is also implemented in order to achieve sound effects like sustainof the signal just before or after applying compression. To do this, the user canmodify some parameters related to the signal evolution in time.

This effect is really useful when it is required to record vocal sounds. Normally,most of commercial effect processors for acoustic guitar use two different inputsignals [GNa07]: One for a microphone which could be also dedicated to vocals,and another one for the instrument pickup. In many cases, the vocals have someweak parts that could be confused with the background noise. Due to this, if ahard compression is used, it is possible to achieve a deeper sound.

99

Page 114: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

A. Dynamic Processors

A.2 Compressor: Parameters Description

The parameters of a compressor can be easily explained through figure A.2.1,which concerns its typical transfer function.

Figure A.2.1: Typical transfer function of a compressor.

Horizontal axis corresponds to the input signal level and vertical axis to the outputlevel. Both of them are expressed in Decibels. When no compression is required,so-called bypass, the input/output relationship is linear. Then, if the input signalis below the threshold, the output is equal to the input. When the input signalis above the threshold, the compression is activated. The greater the ratio, theharder the compression. As an example, with a 4:1 ratio, increasing 4 dB isneeded in order to rise 1 dB at the output. The compressor becomes a limiterfrom a 20:1 ratio in ahead, where the output is exactly the threshold [Tab05b].This is very useful in live performances in order to avoid some distortions.

The use of a compressor is to create several effects modifying the dynamics of thesignal. For this reason, all compressors contain parameters for attack and releasetimes. To understand their operation, figure A.2.2 shows both of them.

A.3 Compressor: Considered Designs

In the beginning, it was discussed that it could be interesting to design a com-pressor/limiter/expander together, because normally they are not marketed sep-arately and expanders are close associated with compressors. However, since the

100

Page 115: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

A.3 Compressor: Considered Designs

Figure A.2.2: Attack and release times.

main issue with respect to an acoustic guitar is the distortion created by satu-ration of the input signal, expanders do not find enough application. Therefore,only a compressor/limiter is implemented.

First approach for a design consisting of a dynamic range controller [Zol05] wasdiscussed. This solution implied calculating attack and release times by meansof a lowpass filter in only one block. Due to the fact that this process seemed tobe too complex, this solution was not carried out. On the contrary, the chosensolution deals with attack and release times separately in a more efficient manner.

The flow diagram in figure A.3.1 depicts the operation of the first approach con-sidered.

Figure A.3.1: Block diagram of a dynamic range controller.

As an overview of its general structure, the level measurement block obtainsthe absolute value of every sample. After that, those samples that must be

101

Page 116: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

A. Dynamic Processors

compressed are multiplied by a known compression ratio. The rest of them are notmodified. Finally, the gain factor obtained in the processing chain is multipliedby the delayed sample of the input signal. In this way, the desired output sampleis accomplished:

y(n) = g(n)x(n� D) (A.3.1)

In order to obtain the release and attack effect, a solution would be to createthem by means of lowpass filters. They would be placed in the end of the gainprocessing chain as shown in figure A.3.1. Further details can be found in [Zol05].

A.4 Noise Gate: Parameters Description

The most feasible way to explain the parameters from a noise gate is based on itstransfer function, as figure A.4.1 represents.

Figure A.4.1: Noise gate transfer function.

Input levels above the threshold are processed with unit gain. The rest of levelsare attenuated to the utmost. The threshold should be fixed a bit above thenoise level. This attenuation produces a dynamics increase feeling since the noiseis sent until no-audible levels.

102

Page 117: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

Appendix B

Filter Design

B.1 FIR Filter

One of the simplest method of designing a digital FIR filter is the window method[Opp99]. For simple frequency response shapes, like low and highpass, bandpassand bandstop filters it is well suited. An ideal desired frequency response that isgiven, say H(ω), can be transformed to the corresponding impulse response byusing inverse DTFT relationship:

h(k) =1

∫ π

�πH(ω)ejωkdω .

For simple frequency response shapes the integral in the equation above can besolved in a closed form. The obtained impulse response h(k) will be double-sided and infinite. Applying a window truncates h(k) to a finite length, that isN = 2M + 1. According to this, the final transfer function of a FIR filter is givenby

H(z) = z�MM∑

k=�M

h(k)z�k .

Besides the window method, that is, by using the Kaiser window for instance,quite simple and can be applied for many filter design problems, the frequencysample method should be mentioned as well as the Parks-McClellan method, fordesigning FIR filters. The latter one is based on optimal Chebyshev filter design[Vij99] and results usually in filters of lower order [Orf96] than the filters obtainedby the methods mentioned before.

103

Page 118: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

B. Filter Design

B.2 IIR-Filter

A simple techniques for digital IIR filter design is based on transformations ofcontinuous-time IIR systems into discrete IIR systems [Opp99]. By using thebilinear transformation, the digital filter specifications are mapped to equivalentanalog filter specifications. According to these specifications an analog filter canbe designed. The obtained filter is then mapped back to the desired digital filter.

Shelving Filter

Bilinear transformation is used in [Zol99] for designing digital shelving, peak andnotch filters respectively for a parametric equalizer. First the analog transferfunctions are derived: A first-order shelving filter is introduced by

H(s) = 1 +G0

s+ 1.

This function represents an allpass system in parallel with a first order lowpassfilter with an amplification of G0. It can be rewritten as

H(s) =s+ (1 +G0)

s+ 1=s+ V0

s+ 1, (B.2.1)

where V0 is the amplification at ω = 0. In order to obtain for boost (V0 > 1) andcut (V0 < 1) a symmetric frequency response according to the frequency axis, itis necessary to invert the transfer function B.2.1 for the case of V0 < 1:

Hcut(s) =s+ 1

s+ V0

, V0 < 1.

Using lowpass to highpass transformation, the corresponding shelving filters forhigh frequencies can be obtained:

Hhigh, boost(s) =sV0 + 1

s+ 1, V0 > 1

and

Hhigh, cut(s) =s+ 1

sV0 + 1, V0 < 1,

where V0 determines the value of the transfer function H(s) for ω =1.

Considering a general second-order transfer function

H(s) =a2s

2 + a1s+ a0

s2 +p

2s+ 1,

104

Page 119: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

B.2 IIR-Filter

Figure B.2.1: Pole-zero plot and qualitative magnitude response of asecond-order transfer function.

the slope of the filter frequency response can be increased. The two poles of thetransfer function are s1/2 =

p0.5(�1 � j). When complex zeros were added to

these poles and they can be moved on a line (see figure B.2.1) by changing V0,the second-order low frequency shelving filter is obtained for the boost case:

Hlow, boost(s) =s2 +

p2V0s+ V0

s2 +p

2s+ 1, V0 > 1, (B.2.2a)

and by inversion for the cut case

Hlow, cut(s) =s2 +

p2s+ 1

s2 +p

2V0s+ V0

, V0 < 1. (B.2.2b)

By applying lowpass to highpass transformation, the corresponding filter for highfrequencies can be obtained:

Hhigh, boost(s) =V0s

2 +p

2V0s+ 1

s2 +p

2s+ 1, V0 > 1 (B.2.3a)

and for the cut case

Hhigh, cut(s) =s2 +

p2s+ 1

V0s2 +p

2V0s+ 1, V0 < 1 . (B.2.3b)

The amplitude response of the presented shelving filters for low and high frequen-cies and different values of V0, are shown in figure 3.2.1 on page 23.

105

Page 120: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

B. Filter Design

peak (boost V0 = 10G/20)

a0 a1 a2 b1 b11+

V0QK+K2

1+ 1QK+K2

2(K2�1)

1+ 1QK+K2

1�V0QK+K2

1+ 1QK+K2

2(K2�1)

1+ 1QK+K2

1� 1QK+K2

1+ 1QK+K2

peak (cut V0 = 10�G/20)

a0 a1 a2 b1 b11+ 1

QK+K2

1+V0QK+K2

2(K2�1)

1+V0QK+K2

1� 1QK+K2

1+V0QK+K2

2(K2�1)

1+V0QK+K2

1�V0QK+K2

1+V0QK+K2

Table B.1: Filter coefficients for peak filter [Zol99].

Peak and Notch Filter

For emphasizing and attenuating a desired frequency or a narrow frequency band,peak and notch filters are used. By introducing a second-order bandpass transferfunction

HBP(s) =

G0

Q

s2 + 1Qs+ 1

,

and combining this function with an allpass filter:

H(s) = 1 +HBP(s) =s2 + 1+G0

Qs+ 1

s2 + 1Qs+ 1

.

a peak filter can be obtained. With V0 = 1 + G0 the amplitude of the frequencyresponse at the center frequency can be adjusted by changing V0, the relativebandwidth by changing the value for Q. Finally the transfer function

Hpeak(s) =s2 + V0

Qs+ 1

s2 + 1Qs+ 1

(B.2.4a)

is obtained for the peak filter and

Hnotch(s) =s2 + 1

Qs+ 1

s2 + V0

Qs+ 1

(B.2.4b)

for the notch filter. The amplitude response can be seen in figure 3.2.2 on page24.

Mapping to the z-Domain

The analog filters designed in the s-domain with the transfer function H(s) haveto be transformed to the z-domain in order to obtain the desired digital filter

106

Page 121: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

B.2 IIR-Filter

low-frequency shelving filter (boost V0 = 10G/20)

a0 a1 a2 b1 b11+p

2V0K+V0K2

1+p

2K+K2

2(V0K2�1)

1+p

2K+K2

1�p

2V0K+V0K2

1+p

2K+K2

2(K2�1)

1+p

2K+K2

1�p

2K+K2

1+p

2K+K2

low-frequency shelving filter (cut V0 = 10�G/20)

a0 a1 a2 b1 b1

1+p

2K+K2

1+p

2V0K+V0K2

2(K2�1)

1+p

2V0K+V0K21�p

2K+K2

1+p

2V0K+V0K2

2(V0K2�1)

1+p

2V0K+V0K2

1�p

2V0K+V0K2

1+p

2V0K+V0K2

high-frequency shelving filter (boost V0 = 10G/20)

a0 a1 a2 b1 b1V0+p

2V0K+K2

1+p

2K+K2

2(K2�V0)

1+p

2K+K2

V0�p

2V0K+K2

1+p

2K+K2

2(K2�1)

1+p

2K+K2

1�p

2K+K2

1+p

2K+K2

high-frequency shelving filter (cut V0 = 10�G/20)

a0 a1 a2 b1 b1

1+p

2K+K2

V0+p

2V0K+K2

2(K2�1)

V0+p

2V0K+K21�p

2K+K2

V0+p

2V0K+K2

2(K2

V0�1)

1+√

2V0K+K2

V0

1�√

2V0K+K2

V 0

1+√

2V0K+K2

V 0

Table B.2: Filter coefficients for shelving filter [Zol99].

with the transfer function H(z). With a suitable bilinear transformation givenby

s =2

T

z � 1

z + 1

the second-order transfer function

H(z) =a0 + a1z

�1 + a2z�2

1 + b1z�1 + b2z�2

is obtained [Zol99], which contains the coefficients given by the tables B.1 andB.2.

107

Page 122: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

108

Page 123: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

Appendix C

Tail Calculation

Due to the character of the delay and the reverberation, the output signal of theprocessor is longer than the input signal in a certain amount of samples. Thatamount of samples will be named the tail of the output. In this appendix, thecalculation of the tail for both delay and reverberation effects is presented. Inthe end, the larger tail is adopted for the outcoming signal of the processor.

Delay Tail

In this case, the tail of the output is M times the number of existing replicas,where M is the delay time in samples. There would be one replica for the echounit and more in the feedback delay case. A calculation of such tail is explainedas follows.

Since the implemented processor is not a real time application, it is a must toknow in advance the length of both inputs and outputs involved in the system,simply because Matlab requires it. In consequence, prior to any calculation inthe designed processor, these lengths have to be defined. Hence, the aim nowis how to calculate the number of replicas present in the output signal. It wasagreed not to do a thorough study of this matter giving the fact this is just anintermediate step before real time implementation where this sort of treatmentwould not be necessary.

The chosen algorithm is based on the assumption that the input signal is correctlyadjusted with respect to the available dynamic range. Thus, the elected maximumamplitude value is 0.8 (if dealing with absolute values ranging from 0 to 1). Thealgorithm consists of a while loop where, in every iteration, the amplitude of theincoming replica is multiplied by the feedback gain as long as its amplitude is

109

Page 124: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

C. Tail Calculation

greater than a certain threshold. This is an attempt of simulation of what ishappening in the block diagram of figure 3.3.5 and it is implemented as follows:

REP=max_signal;while (REP>treshold)

REP=REP*feed_gain;num_rep=num_rep+1;

end

where

max_signal=0.8;

In every iteration, a counter is incremented, meaning the searched number ofreplicas. Regarding the audible threshold, it was calculated according to theexpression:

threshold=max_signal/2000;

Where the constant 2000 was fixed by trial and error. After several tests it wasconcluded that this value ensured the tail would be long enough to allow a naturaldecay of the signal. Even when large feedback gains are used, it is possible toperceive how the delayed signals decay and finally die properly, without suddencuts. In this way, the number of replicas is calculated and, therefore, the tail theoutput must include.

Reverberation Tail

For reverberation case, some previous calcultions are needed. For an impulseresponse, its samples with values above an audible treshold are considered toconstitute the reverberation tail. Its lenght calculation is performded by calcu-lating some impulse responses with different decay values and storing the numberof samples of their tails. Those pairs of values (decay vs sampels) are stored invectors and used to obtain the coefficients of a polynomial regression by usingthe function polyfit in Matlab.

Once obtained the polynomial which represents the relationship between taillength and decay values, the inverse operation is performed. Decay value setby the user and the coefficients of the polinomial are introduced in the functionpolyval obtaining the length of the tail for that certain value of decay.

110

Page 125: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

Finally, the reverb tail variable in Matlab stores the lenght of the this reverber-ation tail and the predelay in samples.

The Matlab code for this calcultaion is listed below.

%Sampling some decay values

decay_sampling = [0.01 0.05 0.09 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 0.99];

tail_lengths = [24255 33075 37485 41895 48510 52900 61740 79380 101430

145500 207270 463050 2646000];

p_degree = 11;

%Obtain the coefficients of the polynomial expression

poly_coef = polyfit(decay_sampling, tail_lengths,p_degree);

%calculate tail in samples

reverb_tail = round(polyval(poly_coef,decay));

reverb_tail = reverb_tail + predelay;

111

Page 126: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

112

Page 127: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

Appendix D

Reverberation Algorithms

FIR Reverberation

One direct way to obtain the most realistic reverberation consists of a convolutionof the source signal with the impulse response of a room. This method startsby obtaining the impulse response feeding the room with an impulsive sound.Once obtained, direct convolution can be achieved by storing each sample of theimpulse response as a coefficient of a FIR filter. However, this method becomescomputationally expensive since the structure of the FIR filter would consist of adelay line with several hundreds of taps. Computed the Fourier transform of theimpulse response, and the Fourier transform of a block of the input signal, bothcan be multiplied point by point and the result transformed back to the timedomain [Zol05]. This kind of processing can be used in successive blocks andthe output signal can be obtained by overlapping and adding the partial results[Opp99]. In spite of the fact that this technique can be significantly faster, theinput-output latency in samples can be twice the size of a block [Zol05]. Hence,this method will not be suitable for real time applications. Furthermore, it is notparameterizable since each impulse response is specific to a room in particular.

IIR Reverberation

Other approaches to generate artificial reverberation are based on IIR filters.These other techniques are by far more efficient than based on FIR filtering ones.Manfred Schroeder can be considered the pioneer on the field of artificial rever-beration. His first works during early sixties reveal that it is feasible modelinginexpensive reverberation by using a simple combination of comb and allpassfilters. His initial reverberator was composed of these two types of IIR filters.

113

Page 128: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

D. Reverberation Algorithms

The first feasible reverberator designed by Schroeder consisted of four comb filtersin parallel feeding into two allpass filters in series. It is depicted in figure D.0.1.

Figure D.0.1: Schroeder’s reverberator flow diagram [Gar92].

The purpose of including comb filters arises from the need to obtain a certainamount of echoes, taking advantage of its frequency response whose peaks cansimulate the normal modes of the room. However, these four comb filters donot supply a sufficient buildup of echoes for realistic diffuse reverberation. Thesolution then becomes to feed some allpass filters in series. They will produce amultiplying effect on the number of echoes while preventing coloration.

Schroeder’s reverberator became a real breakthrough in its time, but it offers quitepoor characteristics comparing to today’s standards. It does not give enoughbuildup of echoes for diffuse reverberation and its response to impulsive soundsis very poor.

A couple of decades after, Andy Moorer extended Schroeder’s work.

Firstly, he found out that the early echoes had a great importance in the percep-tion of the acoustic space. In order to simulate them, he designed a FIR structurebased on a tapped delay line which can generate early echoes accurately.

Then, he added a first-order lowpass filter in the loop of each comb filter tosimulate frequency dependent air absorption. And finally, he decided to increasethe amount of reflections by using six comb filters instead of four. Moorer’sreview can be seen on figure D.0.2. Although it sounds much more realistic thanthe Schroeder reverberator, it still has a poor response to impulsive sounds.

Next approaches to design improved algorithms are found one decade after. Thework of J. Stautner and M. Puckette [Sta82], in 1982, introduced a new method

114

Page 129: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

Figure D.0.2: Moorer’s reverberator flow diagram [Zol05].

to obtain artificial reverberation based on delay lines, more recently called Feed-back Delay Networks (FDN). It consists of some delay lines interconnected ina feedback loop by means of a matrix. The Stautner and Puckette’s FDN wasobtained as a vector generalization of the recursive comb filter explained above.This structure were later improved by Jean-Marc Jot in 1992. Jot obtained areverberator based on an energy conserving system which will give an impulse re-sponse perceptually equivalent to stationary white noise [Jot92]. A flow diagramof this algorithm can be seen on figure D.0.3.

Last works on artificial reverberation have been carried out by William GrantGardner in 1992 [Gar92] and Jon Dattorro in 1997 [Dat97].

Gardner’s ideas are good solutions for real time performance. He suggests threedifferent algorithms to model three diffuse reverberators, that will cover small,medium, and large room sizes. He also introduces the use of nested allpass filtersthat achieve better impulse response with no coloration. The idea is to embedan allpass filter into the delay element of another allpass filter. Consecuently, the

115

Page 130: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

D. Reverberation Algorithms

Figure D.0.3: Jot’s reverberator flow diagram [Bel04].

buildup of output echoes increases with time, and each echo of the outer allpasswill consist of a set of echoes from the inner one, leading to a very smooth anddense diffuse tail.

116

Page 131: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

Appendix E

Listening Test

E.1 Listening Test Form

117

Page 132: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

E. Listening Test

118

Page 133: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

E.1 Listening Test Form

119

Page 134: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

E. Listening Test

120

Page 135: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

E.2 Results of the Listening Test

E.2 Results of the Listening Test

E.2.1 Task 1: Equalizer

1 2 3 4 5 6 7

test sample 1 2 2 1 2

test sample 2 1 1 3 1 1

test sample 3 1 3 2 1

test sample 4 3 3 1

Table E.1: Results of task 1. Scale: 1 - it is the good reference sample /2 - it is next to the good reference sample / 3 - similar to thegood reference sample / 4 - inbetween good and bad reference/ 5 - similiar to bad reference / 6 - next to bad reference / 7 -it is the bad reference.

121

Page 136: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

E. Listening Test

E.2.2 Task 2: Compressor

++ + +/- - –

test sample 1 2 2 3

test sample 2 4 1 2

test sample 3 2 2 1 2

test sample 4 3 1 3

test sample 5 1 2 3 1

Table E.2: Results of task 2. Scale from ++: sample sounds very naturalto –: sample sounds very artificial.

E.2.3 Task 3: Noise Gate

Question 1 Question 1

++ + +/- - – ++ + +/- - –

test sample 1 2 4 1 4 3

test sample 2 1 3 2 1 4 2 1

test sample 3 1 5 2 1 4 1 1 1

test sample 4 2 3 1 1 1 1 4 1

Table E.3: Results of task 3. Scale from ++: sample sounds very naturalto –: sample sounds very artificial.

E.2.4 Task 4: Delay

++ + +/- - –

test sample 1 1 2 2 2

test sample 2 3 2 2

test sample 3 3 4

test sample 4 1 2 2 1 1

test sample 5 2 3 2

Table E.4: Results of task 4. Scale from ++: sample sounds very naturalto –: sample sounds very artificial.

122

Page 137: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

E.2 Results of the Listening Test

E.2.5 Task 5: Modulation Effects

++ + +/- - –

test sample 1 3 3 1

test sample 2 1 3 2 1

Question 1 Sample 1: 3 Sample 2: 3

test sample 3 1 2 3 1

test sample 4 1 5 1

Question 2 Sample 3: 5 Sample 4: 2

test sample 5 2 3 2

test sample 6 1 4 2

test sample 8 1 3 3

test sample 9 1 6

test sample 10 3 4

test sample 11 3 3 1

Table E.5: Results of task 5. Scale from ++: sample sounds very naturalto –: sample sounds very artificial.

E.2.6 Task 6: Reverb I

1 2 3

question 1 3 4

question 2 6 1

question 3 1 6

question 4 3 4

Table E.6: Results of task 6.

E.2.7 Task 7: Reverb II

1 2 3 4

question 1 2 3 2

question 2 4 3

question 3 1 1 3 2

Table E.7: Results of task 7.

123

Page 138: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

124

Page 139: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

Appendix F

Matlab-Code

F.1 Processor Main Function

1 %---------------------------------------------------------------------------2 % Virtual Effect Processor for Acoustics Guitar3 % GROUP 7904 % Eduardo Fonseca, Lutz Ehrig, Javier Galdn, Ignacio Prez, Estrella Merino5 % Aalborg University6 % December 20077 %---------------------------------------------------------------------------8 % Last revision: 13 Dec 20079 %---------------------------------------------------------------------------

10

11 % DEFINITION OF THE DECISSION VECTOR12 % --------------------------------------------------------------------------13

14 % creating decision vector according to:15 % -effects the user want to apply and16 % -signal routing (G-natural t.c.electronics unit)17 %18 % This vector contains the effects to be used. If a value is 0, this19 % effect is not going to be used20

21 w = zeros(1,17);22

23 % note the 4th and the 16th element in the decision vector describe the24 % chosen configuration (vocal or guitar) Meaning the signals from mic and25 % pickup are summed either in one or another position in the sound chain.26 % They cannot be activated at the same time.27

28 w = [0 0 0 0 5 6 0 0 0 0 0 0 0 0 0 16 0];29 % 1 2 3 4 5 6 7 8 9 0 1 2 3 4 5 16 1730

125

Page 140: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

F. Matlab-Code

31 % case 0 % Bypass,32 % case 1 % Noise Gate33 % case 2 % Noise Gate Mic34 % case 3 % Equalizer35 % case 4 % Equalizer Mic36 % case 5 % Compressor37 % case 6 % Compressor Mic38 % case 7 % GUITAR ROUTING39 % case 8 % Vibrato40 % case 9 % Tremolo41 % case 10 % Flanger42 % case 11 % Chorus43 % case 12 % Echo44 % case 13 % Feedback Delay45 % case 14 % Dynamic Delay46 % case 15 % Ping-Pong Delay47 % case 16 % VOCAL ROUTING48 % case 17 % Reverb49

50

51 % if for some reason both routings are activated, ’guitar routing’ is used52 if w(7)==7&&w(16)==1653 display(’the routing has moved to GUITAR MODE’)54 w(16)=0;55 end56

57 p = length(w);58

59 % __________ Routing _____________60 % Choose between the Serial and Parallel proposed by the G-Natural61 routing = ’serial’;62 % ’parallel’63 % ’serial’64

65

66

67 % DEFINITION PART68 % -------------------------------------------------------------------------69

70 % BUFFERS71 % __________ Noise Gate _____________72 global buffer10_ng73 global buffer1a_ng74 global buffer1b_ng75

76 % __________ Noise Gate Mic _____________77 global buffer10_ng_mic78 global buffer1a_ng_mic79 global buffer1b_ng_mic80

81

126

Page 141: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

F.1 Processor Main Function

82 % __________ Equalizer _____________83 global old_param84 global coeff85 global buff_x1_eq86 global buff_x2_eq87 global buff_x3_eq88 global buff_x4_eq89 global buff_x5_eq90 global buff_x6_eq91 global buff_x7_eq92 global buff_x8_eq93

94

95 % __________ Equalizer Mic _____________96 global old_param_mic97 global coeff_mic98 global buff_x1_eq_mic99 global buff_x2_eq_mic

100 global buff_x3_eq_mic101 global buff_x4_eq_mic102 global buff_x5_eq_mic103 global buff_x6_eq_mic104 global buff_x7_eq_mic105 global buff_x8_eq_mic106

107 % __________ Compressor _____________108 global buffer1a109 global buffer1b110

111 % __________ Compressor Mic _____________112 global buffer1a_mic113 global buffer1b_mic114

115 % __________ Modulation _____________116 % Vibrato117 global buffer_vib118 global ycut_vib119 % Tremolo120 global ycut_trem121 %Flanger122 global buffer_fla123 global ycut_fla124 %Chorus125 global buffer_cho126 global ycut_cho127

128

129 % __________ Delay _____________130 % Echo Delay131 global echoBuff132 global y_cutE

127

Page 142: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

F. Matlab-Code

133 % Feedback Delay134 global buff_x135 global buff_y136 global y_cutF137 % Dynamic Delay138 global var %to store the shape139 global buff_x_dyn140 global buff_y_dyn141 global y_cutF_dyn142 % Ping Pong Delay143 global buff_x_L144 global buff_y_L145 global buff_y_R146 global y_cutL147 global y_cutR148

149

150

151 % __________ Reverberation _____________152

153 global pre_b154 global d1_b155 global d2_b156 global d3_b157 global d4_b158 global all_in1_b159 global all_out1_b160 global all_in2_b161 global all_out2_b162 global all_in3_b163 global all_out3_b164 global all_in4_b165 global all_out4_b166 global all_in5_b167 global all_out5_b168 global all_in6_b169 global inner6_b170 global all_out6_b171 global all_in7_b172 global all_out7_b173 global all_in8_b174 global inner8_b175 global all_out8_b176 global y2 %LPF minibuffer177 global y9 %LPF minibuffer178 global y16 %LPF minibuffer179 global ya %Outcome from the input diffusers180 global yb %Outcome from Tank Path 1181 global yc %Outcome from Tank Path 2182

183

128

Page 143: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

F.1 Processor Main Function

184

185 % USER PARAMETERS186 %187

188 % __________ Noise Gate Pick _____________189 T_ng = 0.6; % Threshold Level190 R_ng = 1; % Damp (0-full attenuation, 1 Bypass)191 tau_attack_ng = 5e-3; % Attack-Time192 tau_release_ng = 5e-3; % Release-Time193

194 % __________ Noise Gate Mic _____________195 T_ng_mic = 0.6; % Threshold Level196 R_ng_mic = 0; % Damp (0-full attenuation, 1 Bypass)197 tau_attack_ng_mic = 5e-3; % Attack-Time198 tau_release_ng_mic = 5e-3; % Release-Time199

200

201 % __________ Compressor _____________202 T = 0.05; % Threshold (0...1)203 R = 0.05; % Ratio (0-Limiter, 1-Bypass)204 tau_attack = 3e-3; % Attack-Time [s]205 tau_release = 100e-3; % Release-Time [s]206 output_gain = 2; % Output gain (1...2)207

208 % __________ Compressor Mic _____________209 T_mic = 0.05; % Threshold (0...1)210 R_mic = 0.05; % Ratio (0-Limiter, 1-Bypass)211 tau_attack_mic = 3e-3; % Attack-Time [s]212 tau_release_mic = 100e-3; % Release-Time [s]213 output_gain_mic = 2; % Output gain (1...2)214

215

216

217 % __________ Equalizer _____________218

219 fc_low = 100; % cut-freq low-shelving filter220 g_low = 0; % gain low-shelving filter221

222 fc1 = 220; % center freq filter 1223 Q1 = 3; % Q-factor filter 1224 g1 = 0; % gain filter 1225

226 fc2 = 440; % center freq filter 2227 Q2 = 3; % Q-factor filter 2228 g2 = 0; % gain filter 2229

230 fc3 = 880; % center freq filter 3231 Q3 = 3; % Q-factor filter 3232 g3 = 0; % gain filter 3233

234 fc4 = 1760; % center freq filter 4

129

Page 144: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

F. Matlab-Code

235 Q4 = 5; % Q-factor filter 4236 g4 = 0; % gain filter 4237

238 fc5 = 8020; % center freq filter 5239 Q5 = 2; % Q-factor filter 5240 g5 = 0; % gain filter 5241

242 fc_high = 1000; % cut-freq high-shelving filter243 g_high = 0; % gain high-shelving filter244

245 % __________ Equalizer Mic _____________246

247 fc_low_mic = 100; % cut-freq low-shelving filter248 g_low_mic = 15; % gain low-shelving filter249

250 fc1_mic = 220; % center freq filter 1251 Q1_mic = 3; % Q-factor filter 1252 g1_mic = 15; % gain filter 1253

254 fc2_mic = 440; % center freq filter 2255 Q2_mic = 3; % Q-factor filter 2256 g2_mic = 15; % gain filter 2257

258 fc3_mic = 880; % center freq filter 3259 Q3_mic = 3; % Q-factor filter 3260 g3_mic = 5; % gain filter 3261

262 fc4_mic = 1760; % center freq filter 4263 Q4_mic = 5; % Q-factor filter 4264 g4_mic = 4; % gain filter 4265

266 fc5_mic = 8020; % center freq filter 5267 Q5_mic = 2; % Q-factor filter 5268 g5_mic = 5; % gain filter 5269

270 fc_high_mic = 1000; % cut-freq high-shelving filter271 g_high_mic = 5; % gain high-shelving filter272

273

274 % __________ Modulation _____________275 % Vibrato276 v_vib = 5; % Maximun Delay Variation [ms]277 flfo_vib = 1; % Frequency of the LFO [Hz]278 g_vib = 0.2; % Gain of the Low Pass Filter (0-1)279

280

281 % Tremolo282 flfo_trem = 10; % Freqency in Hz of tremolo wave283 a_trem = 0.7; % Max amplitude factor of tremelo wave (0-1)284 g_trem = 0.05; % Gain of the Low Pass Filter285

130

Page 145: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

F.1 Processor Main Function

286

287 % Flanger288 v_fla = 12; % Maximun Delay Variation [ms]289 flfo_fla = 0.05; % Frequency of the LFO [Hz]290 a_fla = 0.7; % Gain of the loop (0-1)291 g_fla = 0.1; % Gain of the Low Pass Filter (0-1)292

293

294 % Chorus295 v_cho = 30; % Maximun Delay Variation [ms]296 flfo_cho = 0.5; % Frequency of the LFO [Hz]297 a_cho = 0.7; % Gain of the loop (0-1)298 g_cho = 1; % Gain of the Low Pass Filter (0-1)299

300

301 % __________ Delay _____________302 % % mix between delayed and dry signal303 del_mix=0.9;304 %delay in ms305 d=180;306 % feedback gain307 feed_gain=0.7;308

309 %feedback gain for the low pass filter (to filter the delayed repetitions)310 % it is related to its cutting frequency311 % 0 means fc tends to 0, therefore no pass312 % 1 means fc is th top so it is an ALL pass313 cutf=1;314

315 % % % % % % % % % % Dynamic Delay316 T_dyn= 0.3; % Threshold (0...1)317 tau_release_dyn = 50e-3; % Release-Time [s]318 damp_dyn=0.4; %attenuation of dry/wet mix (scale)319

320

321

322 % __________ Reverberation _____________323

324 % Every parameter ranges from 0 to 1325 mix = 0.5; %mix original + reverb: dry->0 wet->1326 predelay = 1300; %from 0 to 4000 (100ms)327 bandwidth = 20000; %From 0 to 20000 hz328 damping = 20000; %From 0 to 20000 hz329 decay = 0.03; %Rate of decay. From 0 to 1330 in_diff1 = 0.5; %Decorrelates incoming signal. From 0 to 1331 in_diff2 = 0.4;332 dec_diff1 = 0.70; %Controls density of reverb tail. From 0 to 1333 dec_diff2 = 0.65; %Decorrelates tank signals;334 %decay diffusion 2 = decay + 0.15, floor = 0.25,335 %ceiling = 0.50336

131

Page 146: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

F. Matlab-Code

337

338

339 % LOAD SIGNALS340 % -------------------------------------------------------------------------341

342 % Input signal from the Pick up of the acoustic guitar343 [input,fs] = wavread(’3_Mic’);344

345 % Input signal from the Microphone of the acoustic guitar346 [inputmic,fs] = wavread(’3_Mic’);347

348

349

350

351 % PRELIMINARY CALCULATION352 % -------------------------------------------------------------------------353

354 % INITIALIZE CONSTANTS, VARIABLES AND PREVIOUS CALCULATIONS355

356 % __________ Noise Gate _____________357 % Calculating Time Constants358 ts = 1/fs; % sample time359 release2_ng = exp(-(ts)/(tau_release_ng)); % calculating release-constant360 attack_ng = exp(-(ts/tau_attack_ng)); % calculating attack-constant361 % Release-Time for shape calculation (default: 100e-3)362 % tau_release = 100e-3;363 % release = exp(-(ts)/(tau_release));364 % time constant is only valid for fs=44100365 release_ng = 0.999773268337895;366

367 % __________ Noise Gate Mic _____________368 % Calculating Time Constants369 release2_ng_mic = exp(-(ts)/(tau_release_ng_mic)); % calculating rel.-cnst.370 attack_ng_mic = exp(-(ts/tau_attack_ng_mic)); % calculating att.-cnst.371

372

373 % __________ Compressor _____________374 % Calculating Time Constants375 release = exp(-(ts)/(tau_release)); % calculating release-constant376 attack = exp(-(ts/tau_attack)); % calculating attack-constant377

378 % __________ Compressor Mic _____________379 % Calculating Time Constants380 release_mic = exp(-(ts)/(tau_release_mic)); % calculating release-constant381 attack_mic = exp(-(ts/tau_attack_mic)); % calculating attack-constant382

383

384

385 % __________ Modulation _____________386 % Vibrato387 %number of maximun samples delayed md = D

132

Page 147: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

F.1 Processor Main Function

388 md_vib = round(v_vib*fs/1000);389 % omega of the vibrato LFO390 Wd_vib = 2*pi/round(fs/flfo_vib);391

392

393 %Flanger394 %number of maximun samples delayed395 md_fla = round(v_fla*fs/1000);396 % omega of the flanger LFO397 Wd_fla = 2*pi/round(fs/flfo_fla);398

399 %Chorus400 rand_factor = rand;401 %number of maximun samples delayed md402 md_cho = round(v_cho*fs/1000);403 % omegas of the chorus LFO404 Wd_cho = 2*pi/round(fs/flfo_cho);405 Wd_cho_v2 = 2*pi/round(fs/(flfo_cho*rand_factor));406

407 % __________ Delay _____________408 %delay in samples409 del_samp=round(d*fs/1000);410

411

412 % CALCULATING THE DELAY TAIL413

414 % Finding out the number of replicas415 % Zeropad the input at the end and decide the length of the output (tail)416 % in a dynamic way. Note that the size of the buffer do not care about this417 % since the difference equation only demand the actual sample and the one418 % which took place ’del_samp’ samples before419

420 num_rep=0;%variable where i store the number of replicas that will take421 % %place in the effect,422

423 if (find(w==12)==12)424 %echo delay is applied425 num_rep=1;426 elseif ((w(13)==13)||(w(14)==14)||(w(15)==15))427 %feedback or ppong delay or dynamic delay is applied428 %%%%%%%%%%%%%%%%%%%%%%%%%%%% using the entire signal (completely off-line)429 % max_signal=max(signal);430 % or431 %%%%%%%%%%%%%%%%%%%%%%%%%%%% assumption when normal case of dynamic range432 max_signal=0.8;433

434 treshold=max_signal/2000;%audible treshold435 % it should be 1000 to have 60 dB of atenuation436

437 REP=max_signal;438 while (REP>treshold)

133

Page 148: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

F. Matlab-Code

439 REP=REP*feed_gain;440 num_rep=num_rep+1;441 end442 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%443 else %no delay is applied444 num_rep=0;445 end446 delay_tail=del_samp*num_rep;447

448 % udo Zolzer’s DAFX page 70449 %normalizing coefficient, to be used in certain cases450 norm=1-feed_gain;451

452 % % % % % % % % Dynamic Delay453 release_dyn=exp(-(ts)/(tau_release_dyn)); % calculating release-constant454

455

456

457 % __________ Reverberation _____________458

459 % xL = input;460 yR = 0; %this variable is thought to be an input parameter in reverb function461 % its aim is to provide the ’right channel’ info. this would be:462 %463 % -0 if there is no ping pong so taht a unique mono signal reaches the reverb464 %465 % -other value if ppong takes place so that it converts its mono input466 % into stereo one467

468 %Delay times469 d1 = 6598;470 d2 = 5512;471 d3 = 6249;472 d4 = 4687;473 d = [d1 d2 d3 d4]; % They are joined in one vector474 %LFO excursion475 excursion = 12; % Excursion applied to the delay of allpass filter 5 & 7476 flfo = 1; % Frequency of the lfo(excursion) in hz477 %All-pass filters Orders478 all_d1 = 210;479 all_d2 = 158;480 all_d3 = 561;481 all_d4 = 410;482 all_d5 = 995;483 all_d6 = 2667;484 all_d7 = 1345;485 all_d8 = 3935;486 all_d = [all_d1 all_d2 all_d3 all_d4 all_d5 all_d6 all_d7 all_d8];487

488 %convert frenquency parameters into low pass filter gain parameters (0-1)489 bandwidth = 2-cos(2*pi*bandwidth/fs)-sqrt(((cos(2*pi*bandwidth/fs)-2)^2)-1);

134

Page 149: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

F.1 Processor Main Function

490 damping = 2-cos(2*pi*damping/fs)-sqrt(((cos(2*pi*damping/fs)-2)^2)-1);491

492

493 %%%%%%%%%%%%%%%%%%%%%%%%CALCULATING THE REVERB TAIL%%%%%%%%%%%%%%%%%%%%%%%%494 % Sampling of the tail length applying different decay times. A polynomial495 % regression is applied in order to achieve a relationship between input496 % decay times and tail length in samples.497

498 %Sampling some decay values499 decay_sampling = [0.01 0.05 0.09 0.1 0.2 0.3 0.4 0.5 0.6 0.7 0.8 0.9 0.99];500 tail_lengths = [24255 33075 37485 41895 48510 52900 61740 79380 101430 145500

207270 463050 2646000];501 p_degree = 11;502

503 %Obtain the coefficients of the polynomial expression504 poly_coef = polyfit(decay_sampling, tail_lengths,p_degree);505 %calculate tail in samples506 reverb_tail = round(polyval(poly_coef,decay));507 reverb_tail = reverb_tail + predelay;508

509

510

511

512 % INITIALIZE BUFFERS513

514 % __________ Noise Gate _____________515 buffer10_ng = 0;516 buffer1a_ng = 1;517 buffer1b_ng = 0;518

519 % __________ Noise Gate Mic_____________520 buffer10_ng_mic = 0;521 buffer1a_ng_mic = 1;522 buffer1b_ng_mic = 0;523

524

525 % __________ Equalizer _____________526 old_param = zeros(1,19);527 coeff = zeros(14,3);528 buff_x1_eq = [0 0 0];529 buff_x2_eq = [0 0 0];530 buff_x3_eq = [0 0 0];531 buff_x4_eq = [0 0 0];532 buff_x5_eq = [0 0 0];533 buff_x6_eq = [0 0 0];534 buff_x7_eq = [0 0 0];535 buff_x8_eq = [0 0 0];536

537 % __________ Equalizer Mic _____________538 old_param_mic = zeros(1,19);539 coeff_mic = zeros(14,3);

135

Page 150: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

F. Matlab-Code

540 buff_x1_eq_mic = [0 0 0];541 buff_x2_eq_mic = [0 0 0];542 buff_x3_eq_mic = [0 0 0];543 buff_x4_eq_mic = [0 0 0];544 buff_x5_eq_mic = [0 0 0];545 buff_x6_eq_mic = [0 0 0];546 buff_x7_eq_mic = [0 0 0];547 buff_x8_eq_mic = [0 0 0];548

549 % __________ Compressor _____________550 buffer1a = 0;551 buffer1b = 0;552

553 % __________ Compressor Mic _____________554 buffer1a_mic = 0;555 buffer1b_mic = 0;556

557

558

559 % __________ Modulation _____________560 % Vibrato561 buffer_vib = zeros(md_vib+1,1); %buffer of zeros md+1 long562 ycut_vib = 0; %stores the past sample for Low Pass filtering563

564 % Tremolo565 ycut_trem = 0; %stores the past sample for Low Pass filtering566

567 %Flanger568 buffer_fla = zeros(md_fla+1,1); %buffer of zeros md+1 long569 ycut_fla = 0; %stores the past sample for Low Pass filtering570

571 %Chorus572 buffer_cho = zeros(md_cho+1,1); %buffer of zeros md+1 long573 ycut_cho = 0; %stores the past sample for Low Pass filtering574

575 % __________ Delay _____________576

577 % Echo Delay578 % initialize this paramenter for the LP filter to work on the first579 % iteration, from them on it saves the last value to operate with it. this580 % is taken from matlab implementation of reverberation algorithms,581 % concretely from datorro’s network582 y_cutE=0;583 echoBuff=zeros(del_samp,1);584

585

586 % Feedback Delay587 % initialize this paramenter for the LP filter to work on the first588 % iteration, from them on it saves the last value to operate with it. this589 % is taken from matlab implementation of reverberation algorithms,590 % concretely from datorro’s network

136

Page 151: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

F.1 Processor Main Function

591 y_cutF=0;592 %to store past samples of the input593 buff_x=zeros(del_samp,1);594 %to store past samples not from the final output but from a point in the595 %middle of the block diagram596 buff_y=zeros(del_samp,1);597

598

599 % Dynamic Delay600 var=0;601 buff_x_dyn=zeros(del_samp,1);602 buff_y_dyn=zeros(del_samp,1);603 y_cutF_dyn=0;604

605

606 % Ping Pong Delay607 % to store past samples of the input_L608 buff_x_L=zeros(del_samp,1);609 %to store past samples not from the final output but from a point in the610 %middle of the block diagram, concerning L channel611 buff_y_L=zeros(del_samp,1);612 %to store past samples not from the final output but from a point in the613 %middle of the block diagram, concerning R channel614 buff_y_R=zeros(del_samp,1);615 % initialize these parameters for the LP filter to work on the first616 % iteration, from them on it saves the last value to operate with it. this617 % is taken from matlab implementation of reverberation algorithms,618 % concretely from datorro’s network619 y_cutL=0;620 y_cutR=0;621

622

623

624 % __________ Reverberation _____________625

626 %%%%% DELAY BUFFERS %%%%%627 pre_b = zeros(predelay,1);628 d1_b = zeros(d1,1);629 d2_b = zeros(d2,1);630 d3_b = zeros(d3,1);631 d4_b = zeros(d4,1);632

633 %%%%% 1 SAMPLE BUFFERS %%%%%634 %These are not buffers by definition but work as buffers, must be zero635 %initialized here636 y2 = 0;637 y9 = 0;638 y16= 0;639 ya = 0;640 yb = 0;641 yc = 0;

137

Page 152: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

F. Matlab-Code

642

643 %%%%% ALL PASS FILTER BUFFERS %%%%%644 all_in1_b = zeros(all_d1,1);645 all_out1_b = zeros(all_d1,1);646 all_in2_b = zeros(all_d2,1);647 all_out2_b = zeros(all_d2,1);648 all_in3_b = zeros(all_d3,1);649 all_out3_b = zeros(all_d3,1);650 all_in4_b = zeros(all_d4,1);651 all_out4_b = zeros(all_d4,1);652 all_in5_b = zeros(all_d5 + excursion,1);653 all_out5_b = zeros(all_d5 + excursion,1);654 all_in6_b = zeros(all_d6,1);655 inner6_b = zeros(all_d6,1);656 all_out6_b = zeros(all_d6,1);657 all_in7_b = zeros(all_d7 + excursion,1);658 all_out7_b = zeros(all_d7 + excursion,1);659 all_in8_b = zeros(all_d8,1);660 inner8_b = zeros(all_d8,1);661 all_out8_b = zeros(all_d8,1);662

663 %-------------------------------------------------------------------------664 % __________ Other Parameters _____________665

666 % if the input signal for the reverb will be mono or stereo667 pingpong = 0;668 reverbon = 0;669

670 for i = 1:p671 if (find(w==15)==15)672 pingpong = 1;673 elseif (find(w==17)==17)674 reverbon = 1;675 end676 end677

678

679 % CALCULATING THE FINAL TAIL680

681 if reverbon == 0 % no reverb is applied682 final_tail = delay_tail;683 else684 final_tail = max(delay_tail,reverb_tail);685 end686

687

688 % ZERO-PADDING THE SIGNAL689 % zero-pad end of the input, tail depending on the maximum value among690 % those required by delay and reverb691 input = [input;zeros(final_tail,1)];692

138

Page 153: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

F.1 Processor Main Function

693 % length of the input to be processed after zero-padding, so that the other694 % input (inputmic)and the output (output_st) are to be of the same length695 in_len=length(input);696 inputmic = [inputmic;zeros(in_len-length(inputmic),1)];697

698

699 % preallocating the size of output vectors700 outputL = zeros(in_len,1);701 outputR = zeros(in_len,1);702 output_st = zeros(in_len,2);703

704 % ------------------------------------------------------------------------705 % ------------------------------------------------------------------------706 % ------------------------------------------------------------------------707

708 % tic709 switch lower(routing)710

711 case ’serial’712

713 % SERIAL ROUTING implementation for the Virtual Effect Processor714 % ---------------------------------------------------------------715 % See blog diagram in Chapter 4 of the report716

717 for n = 1:in_len718

719 y = input(n); % Storing the sample to be processed720 % y now is considered to be the PICKUP Signal721 ymic = inputmic(n);722

723 for s = 1:p724

725 switch w(s)726 case 0 %bypass, it means there is an effect in by pass727 %----------------------------------------------------728 case 1 %Noise Gate729 y = noisegate(y,R_ng,T_ng,attack_ng,release2_ng,

release_ng);730 case 2 %Noise Gate Mic731 ymic = noisegate_mic(ymic,R_ng_mic,T_ng_mic,attack_ng_mic

,release2_ng_mic,release_ng);732 %----------------------------------------------------733 case 3 % Equalizer734 y=equalizer3(y,fc_low,g_low,fc1,Q1,g1,fc2,Q2,g2,fc3,Q3,g3

,fc4,Q4,g4,fc5,Q5,g5,fc_high,g_high,fs);735 case 4 % Equalizer Mic736 ymic=equalizer3_mic(ymic,fc_low_mic,g_low_mic,fc1_mic,

Q1_mic,g1_mic,fc2_mic,Q2_mic,g2_mic,fc3_mic,Q3_mic,g3_mic,fc4_mic,Q4_mic,g4_mic,fc5_mic,Q5_mic,g5_mic,fc_high_mic,g_high_mic,fs);

737 %----------------------------------------------------

139

Page 154: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

F. Matlab-Code

738 case 5 % Compressor739 y = compressor(y,R,T,attack,release,output_gain);740 case 6 % Compressor Mic741 ymic = compressor_mic(ymic,R_mic,T_mic,attack_mic,

release_mic,output_gain_mic);742 %----------------------------------------------------743 case 7 %GUITAR ROUTING744 y=(y+ymic)/2;745 %----------------------------------------------------746 case 8 % Vibrato747 y = vibrato(y,md_vib,Wd_vib,g_vib,n);748 case 9 % Tremolo749 y = tremolo(y,fs,a_trem,flfo_trem,g_trem,n);750 case 10 % Flanger751 y = flanger(y,a_fla,md_fla,Wd_fla,g_fla,n);752 case 11 % Chorus753 y = chorus(y,fs,a_cho,v_cho,Wd_cho,Wd_cho_v2,rand_factor,

g_cho,n);754 %----------------------------------------------------755 case 12 % Echo756 y = echo_del(y,del_mix,cutf);757 case 13 % Feedback Delay758 y = feedback_del(y,del_mix,feed_gain,cutf,norm);759 case 14 % Dynamic Delay760 y = dynamic_del(y,del_mix,feed_gain,cutf,T_dyn,

release_dyn,damp_dyn,norm);761 case 15 % Ping-Pong Delay762 %take care with the election of channel inputs inside the763 %function764 [y,yR] = ppong_del(y,del_mix,feed_gain,cutf,norm);765 %----------------------------------------------------766 case 16%VOCAL ROUTING767 y=(y+ymic)/2;768 yR=(yR+ymic)/2;769 %----------------------------------------------------770 case 17 % Reverb771 [y,yR] = reverb(y,yR,pingpong,fs,n,mix,predelay,bandwidth

,damping,decay,in_diff1,in_diff2,dec_diff1,dec_diff2,d,excursion,flfo,all_d);

772

773 %----------------------------------------------------774 otherwise error(’ERROR, switch out of regular cases’)775 end % SERIAL ROUTING switch776 end % SERIAL ROUTING decission vector for loop777

778 outputL(n) = y;779 if (pingpong==0) && (reverbon==0) % if this is mono780 outputR(n) = y;781 else782 outputR(n) = yR;783 end

140

Page 155: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

F.1 Processor Main Function

784

785 output_st(n,:) = [outputL(n), outputR(n)];786

787 end % SERIAL ROUTING sample for loop788 %--------------------------------------------------------------------------789 %--------------------------------------------------------------------------790 case ’parallel’791

792 % PARALLEL ROUTING implementation for the Virtual Effect Processor793 % -----------------------------------------------------------------794 % See blog diagram in Chapter 4795

796 % the input of the reverb is a mono signal, although the pingpong797 % is working798 pingpongon = 0;799

800 % changes to use the same decission vector in both routings801 aux_value = w(16);802 w(16) = w(17);803 w(17) = aux_value;804

805 % Find out how many effects are ON806 % number of effects OFF and the non-chosen routing807 n_zeros = find(w==0);808 n_effects_on = length(w)-length(n_zeros)-1; % -1 chosen routing809

810 % Initialize every parallel effect output811 y_vib = 0;812 y_trem = 0;813 y_fla = 0;814 y_cho = 0;815 y_echo =0;816 y_feed = 0;817 y_dyn_del=0;818 y_ping = 0;819 y_rev = 0;820 yR_ping = 0;821 yR_rev =0;822

823

824 for n = 1:in_len825

826 y = input(n); % Storing the sample to be processed827 % y now is considered to be the PICKUP Signal828 ymic = inputmic(n);829

830 for s = 1:p831

832 switch w(s)833 case 0 %bypass, it means there is an effect in by pass834 %----------------------------------------------------

141

Page 156: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

F. Matlab-Code

835 case 1 %Noise Gate836 y = noisegate(y,R_ng,T_ng,attack_ng,release2_ng,

release_ng);837 case 2 %Noise Gate Mic838 ymic = noisegate_mic(ymic,R_ng_mic,T_ng_mic,attack_ng_mic

,release2_ng_mic,release_ng);839 %----------------------------------------------------840 case 3 % Equalizer841 y=equalizer3(y,fc_low,g_low,fc1,Q1,g1,fc2,Q2,g2,fc3,Q3,g3

,fc4,Q4,g4,fc5,Q5,g5,fc_high,g_high,fs);842 case 4 % Equalizer Mic843 ymic=equalizer3_mic(ymic,fc_low_mic,g_low_mic,fc1_mic,

Q1_mic,g1_mic,fc2_mic,Q2_mic,g2_mic,fc3_mic,Q3_mic,g3_mic,fc4_mic,Q4_mic,g4_mic,fc5_mic,Q5_mic,g5_mic,fc_high_mic,g_high_mic,fs);

844 %----------------------------------------------------845 case 5 % Compressor846 y = compressor(y,R,T,attack,release,output_gain);847 case 6 % Compressor Mic848 ymic = compressor_mic(ymic,R_mic,T_mic,attack_mic,

release_mic,output_gain_mic);849 %----------------------------------------------------850 case 7 %GUITAR ROUTING851 y=(y+ymic)/2;852 %----------------------------------------------------853 case 8 % Vibrato854 y_vib = vibrato(y,md_vib,Wd_vib,g_vib,n);855 case 9 % Tremolo856 y_trem = tremolo(y,fs,a_trem,flfo_trem,g_trem,n);857 case 10 % Flanger858 y_fla = flanger(y,a_fla,md_fla,Wd_fla,g_fla,n);859 case 11 % Chorus860 y_cho = chorus(y,fs,a_cho,v_cho,Wd_cho,Wd_cho_v2,

rand_factor,g_cho,n);861 %----------------------------------------------------862 case 12 % Echo863 y_echo = echo_del(y,del_mix,cutf);864 case 13 % Feedback Delay865 y_feed = feedback_del(y,del_mix,feed_gain,cutf,norm);866 case 14 % Dynamic Delay867 y_dyn_del = dynamic_del(y,del_mix,feed_gain,cutf,T_dyn,

release_dyn,damp_dyn,norm);868 case 15 % Ping-Pong Delay869 [y_ping,yR_ping] = ppong_del(y,del_mix,feed_gain,cutf,

norm);870 %----------------------------------------------------871 case 16 %VOCAL ROUTING (this one is the LAST STEP because

the w vector has been changed)872 y =(y_vib+y_trem+y_fla+y_cho+y_echo+y_feed+y_dyn_del+

y_ping+y_rev+ymic)/(n_effects_on+1);873 yR =(y_vib+y_trem+y_fla+y_cho+y_echo+y_feed+y_dyn_del+

142

Page 157: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

F.2 Noise Gate

yR_ping+yR_rev+ymic)/(n_effects_on+1);874 %----------------------------------------------------875 case 17 % Reverb876 [y_rev,yR_rev] = reverb(y,yR,pingpong,fs,n,mix,predelay,

bandwidth,damping,decay,in_diff1,in_diff2,dec_diff1,dec_diff2,d,excursion,flfo,all_d);

877 %----------------------------------------------------878 otherwise error(’ERROR, switch out of regular cases’)879 end % PARALLEL ROUTING switch880 end % PARALLEL ROUTING decission vector for loop881

882 outputL(n) = y;883 outputR(n) = yR;884 output_st(n,:) = [outputL(n), outputR(n)];885

886 end % PARALLEL ROUTING sample for loop887

888 otherwise error(’ERROR, unknown routing’)889 end % routing (serial/parallel) switch890

891 % t = toc892

893 % display(’input’)894 % soundsc(input, fs);895 % pause;896 % display(’inputmic’)897 % soundsc(inputmic, fs);898 % pause899 mixture =(input+inputmic)/2;900 display(’both of them mixed’)901 soundsc(mixture, fs);902 pause903 display(’output_st’)904 soundsc(output_st,fs);

F.2 Noise Gate

1 %--------------------------------------------------------------------------2 % Virtual Effect Processor for Acoustics Guitar3 % GROUP 7904 % Eduardo Fonseca, Lutz Ehrig, Javier Galdn, Ignacio Prez, Estrella Merino5 % Aalborg University6 % December 20077 %--------------------------------------------------------------------------8 % Description:9 % -------

10 % NOISE GATE EFFECT MICROPHONE11 %12 % Outputs:

143

Page 158: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

F. Matlab-Code

13 % -------14 % y = output sample15 %16 % Inputs:17 % -------18 %19 % x = input sample20 % R = noise gate ratio between zero and one(0->max attenuation; 1->Bypass)21 % T = threshold between 0 and 122 % attack = attack constant (using attack time)23 % release2 = release constant (using release time)24 % release = time constant25 % n = number of sample to be processed (index of the for loop)26 %27 % Last revision: 3 Dec 200728 %-------------------------------------------------------------------------29 function y = noisegate_mic(x,R,T,attack,release2,release)30

31 global buffer10_ng_mic32 global buffer1a_ng_mic33 global buffer1b_ng_mic34

35

36 % level detection37 level = abs(x);38

39 % Calculating the "shape" of the signal40 % the shape of the signal considers the release time41 if level > (buffer10_ng_mic(1)*release)42 buffer10_ng_mic(2) = level;43 else44 buffer10_ng_mic(2) = (buffer10_ng_mic(1)*release);45 end46 shape = buffer10_ng_mic(2);47 buffer10_ng_mic(1) = [];48

49 buffer_comp = shape;50

51 % Calculates the "Release shape" based on52 % the shape calculated above53 if abs(buffer_comp) > (buffer1a_ng_mic(1)*1/release2)54 buffer1a_ng_mic(2) = 1/release2*buffer1a_ng_mic(1);55 elseif abs(buffer_comp) == 056 buffer1a_ng_mic(2) = 1/release2*buffer1a_ng_mic(1);57 else58 buffer1a_ng_mic(2) = abs(buffer_comp);59 end60 shape = buffer1a_ng_mic(2);61 buffer1a_ng_mic(1) = [];62

63 % test if attenuation is necessary

144

Page 159: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

F.3 Compressor

64 if shape <= T65 g_pre = (shape/T)^(1-R); % attenuation66 else67 g_pre = 1; % no attenuation68 end69

70 % consider attack time71 if g_pre > (buffer1b_ng_mic(1)*attack)72 buffer1b_ng_mic(2) = g_pre;73 else74 buffer1b_ng_mic(2) = (buffer1b_ng_mic(1)*attack);75 end76 g = buffer1b_ng_mic(2);77 buffer1b_ng_mic(1) = [];78

79

80 y = x * g;81

82 end

F.3 Compressor

1 %--------------------------------------------------------------------------2 % Virtual Effect Processor for Acoustics Guitar3 % GROUP 7904 % Eduardo Fonseca, Lutz Ehrig, Javier Galdn, Ignacio Prez, Estrella Merino5 % Aalborg University6 % December 20077 %--------------------------------------------------------------------------8 % Description:9 % ------------

10 % COMPRESSOR EFFECT MICROPHONE11 %12 % Outputs:13 % -------14 % y = output sample15 %16 % Inputs:17 % -------18 %19 % x = input sample20 % R = compression ratio between zero and one(0->Limiter;1->Bypass)21 % T = threshold between 0 and 122 % attack = attack constant (using attack time)23 % release = release constant (using release time)24 % n = number of sample to be processed (index of the for loop)25 %26 % Last revision: 13 Dec 200727 %--------------------------------------------------------------------------

145

Page 160: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

F. Matlab-Code

28

29 function y = compressor_mic(x,R,T,attack,release,output_gain)30 global buffer1a_mic31 global buffer1b_mic32

33 %% Level Detection34 level = abs(x);35

36 %% First Order Peak Hold Circuit37 % Calculating the "shape" of the signal38 % the shape of the signal considers the release time39 if level > (buffer1a_mic(1)*release)40 buffer1a_mic(2) = level;41 else42 buffer1a_mic(2) = (buffer1a_mic(1)*release);43 end44

45 shape = buffer1a_mic(2);46 buffer1a_mic(1) = [];47

48 % Is Compression necessary ?49 if shape >= T50 g_pre = (T/shape)^(1-R); % Compress it!51 else52 g_pre = 1; % no compression necessary53 end54

55 % consider attack time56 if g_pre > (buffer1b_mic(1)*attack)57 buffer1b_mic(2) = g_pre;58 else59 buffer1b_mic(2) = (buffer1b_mic(1)*attack);60 end61 g = buffer1b_mic(2);62 buffer1b_mic(1) = [];63

64 y = x * g;65

66 y = y * output_gain;67

68 end

F.4 Equalizer

F.4.1 Signal Equalizing

1 %--------------------------------------------------------------------------2 % Virtual Effect Processor for Acoustics Guitar

146

Page 161: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

F.4 Equalizer

3 % GROUP 7904 % Eduardo Fonseca, Lutz Ehrig, Javier Galdn, Ignacio Prez, Estrella Merino5 % Aalborg University6 % December 20077 %--------------------------------------------------------------------------8 % Description:9 % ------------

10 % 5-band parametric EQUALIZER11 % y = equalizer3(x,fc_low,g_low,fc1,Q1,G1,fc2,Q2,G2,fc3,Q3,G3,fc4,Q4,G4,...12 % ...fc5,Q5,G5,fc_high

,g_high,fs)13 %14 % Outputs:15 % --------16 % y = output sample17 %18 % Inputs:19 % -------20 % x = input sample21 % fc_low = cut-off frequency for low pass shelving filter [Hz]22 % g_low = gain for low pass shelving filter [dB]23 % fcx = center frequency for peak filter [Hz]; x = 1..524 % Qx = Q-factor for peak filter; x = 1..525 % Gx = gain for peak filter[dB]; x = 1..526 % fc_high = cut-off freq for high pass shelving filter [Hz]27 % g_high = gain for high pass shelving filter [dB]28 % fs = sample frequency [Hz]29

30 % Last revision: 10 Dec 200731 %--------------------------------------------------------------------------32 %33 function y = equalizer3(x,fc_low,g_low,fc1,Q1,G1,fc2,Q2,G2,fc3,Q3,G3,fc4,Q4,G4

,fc5,Q5,G5,fc_high,g_high,fs)34

35 global old_param36 global coeff37 global buff_x1_eq38 global buff_x2_eq39 global buff_x3_eq40 global buff_x4_eq41 global buff_x5_eq42 global buff_x6_eq43 global buff_x7_eq44 global buff_x8_eq45

46 n = 3; % length of the buffer47

48 % check if paramters have changed49 new_param = [fc_low,g_low,fc1,Q1,G1,fc2,Q2,G2,fc3,Q3,G3,fc4,Q4,G4,fc5,Q5,G5,

fc_high,g_high];50 if find(new_param ~= old_param)

147

Page 162: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

F. Matlab-Code

51 % recalculate changed parameters52 changed_param = find(new_param ~= old_param);53 for i=1:length(changed_param)54 switch changed_param(i)55 case {1,2}56 [coeff(1,:),coeff(2,:)] = get_coeff_shelv_low(fc_low,g_low,fs);57 case {3,4,5}58 [coeff(3,:),coeff(4,:)] = get_coeff_peak(fc1,G1,Q1,fs);59 case {6,7,8}60 [coeff(5,:),coeff(6,:)] = get_coeff_peak(fc2,G2,Q2,fs);61 case {9,10,11}62 [coeff(7,:),coeff(8,:)] = get_coeff_peak(fc3,G3,Q3,fs);63 case {12,13,14}64 [coeff(9,:),coeff(10,:)] = get_coeff_peak(fc4,G4,Q4,fs);65 case {15,16,17}66 [coeff(11,:),coeff(12,:)] = get_coeff_peak(fc5,G5,Q5,fs);67 case {18,19}68 [coeff(13,:),coeff(14,:)] = get_coeff_shelv_high(fc_high,g_high,

fs);69 end70 end71 end72 old_param = new_param; % save paramters73

74 buff_x1_eq(n) = x;75

76 % filter difference equations77 buff_x2_eq(n) = coeff(1,1)*buff_x1_eq(n)+coeff(1,2)*buff_x1_eq(n-1)+coeff(1,3)

*buff_x1_eq(n-2)-coeff(2,2)*buff_x2_eq(n-1)-coeff(2,3)*buff_x2_eq(n-2);78 buff_x3_eq(n) = coeff(3,1)*buff_x2_eq(n)+coeff(3,2)*buff_x2_eq(n-1)+coeff(3,3)

*buff_x2_eq(n-2)-coeff(4,2)*buff_x3_eq(n-1)-coeff(4,3)*buff_x3_eq(n-2);79 buff_x4_eq(n) = coeff(5,1)*buff_x3_eq(n)+coeff(5,2)*buff_x3_eq(n-1)+coeff(5,3)

*buff_x3_eq(n-2)-coeff(6,2)*buff_x4_eq(n-1)-coeff(6,3)*buff_x4_eq(n-2);80 buff_x5_eq(n) = coeff(7,1)*buff_x4_eq(n)+coeff(7,2)*buff_x4_eq(n-1)+coeff(7,3)

*buff_x4_eq(n-2)-coeff(8,2)*buff_x5_eq(n-1)-coeff(8,3)*buff_x5_eq(n-2);81 buff_x6_eq(n) = coeff(9,1)*buff_x5_eq(n)+coeff(9,2)*buff_x5_eq(n-1)+coeff(9,3)

*buff_x5_eq(n-2)-coeff(10,2)*buff_x6_eq(n-1)-coeff(10,3)*buff_x6_eq(n-2);82 buff_x7_eq(n) = coeff(11,1)*buff_x6_eq(n)+coeff(11,2)*buff_x6_eq(n-1)+coeff

(11,3)*buff_x6_eq(n-2)-coeff(12,2)*buff_x7_eq(n-1)-coeff(12,3)*buff_x7_eq(n-2);

83 buff_x8_eq(n) = coeff(13,1)*buff_x7_eq(n)+coeff(13,2)*buff_x7_eq(n-1)+coeff(13,3)*buff_x7_eq(n-2)-coeff(14,2)*buff_x8_eq(n-1)-coeff(14,3)*buff_x8_eq(n-2);

84

85 y = buff_x8_eq(n);86

87 buff_x1_eq(1) = [];88 buff_x2_eq(1) = [];89 buff_x3_eq(1) = [];90 buff_x4_eq(1) = [];91 buff_x5_eq(1) = [];

148

Page 163: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

F.4 Equalizer

92 buff_x6_eq(1) = [];93 buff_x7_eq(1) = [];94 buff_x8_eq(1) = [];

F.4.2 Calculating Filter Coefficients - Peak Filter

1 %--------------------------------------------------------------------------2 % Virtual Effect Processor for Acoustics Guitar3 % GROUP 7904 % Eduardo Fonseca, Lutz Ehrig, Javier Galdn, Ignacio Prez, Estrella Merino5 % Aalborg University6 % December 20077 %--------------------------------------------------------------------------8 % Description:9 % ------------

10 % returns coefficients for peak filter11 % [b,a] = get_coeff_peak(fc,g,Q,fs)12 %13 % Outputs:14 % --------15 % b = filter coefficients numerator16 % a = filter coefficients denominator17 %18 % Inputs:19 % -------20 % fc = center frequency [Hz]21 % g = gain [dB]22 % Q = Q-factor23 % fs = sample frequency [Hz]24

25 % Last revision: 15 Nov 200726 %--------------------------------------------------------------------------27 %28

29 function [b,a] = get_coeff_peak(fc,g,Q,fs)30

31 K = tan(pi*fc/fs);32 V0 = 10^(abs(g)/20);33

34 if g > 035 %%%%%%%%% boost %%%%%%%%%%%36 b(1) = (1+(V0/Q)*K+K^2)/(1+(1/Q)*K+K^2);37 b(2) = (2*(K^2-1))/(1+(1/Q)*K+K^2);38 b(3) = (1-(V0/Q)*K+K^2)/(1+(1/Q)*K+K^2);39

40 a(1) = 1;41 a(2) = (2*(K^2-1))/(1+(1/Q)*K+K^2);42 a(3) = (1-(1/Q)*K+K^2)/(1+(1/Q)*K+K^2);43

44 elseif g < 0

149

Page 164: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

F. Matlab-Code

45 %%%%%%%%% cut46 b(1) = (1+(1/Q)*K+K^2)/(1+(V0/Q)*K+K^2);47 b(2) = (2*(K^2-1))/(1+(V0/Q)*K+K^2);48 b(3) = (1-(1/Q)*K+K^2)/(1+(V0/Q)*K+K^2);49

50 a(1) = 1;51 a(2) = (2*(K^2-1))/(1+(V0/Q)*K+K^2);52 a(3) = (1-(V0/Q)*K+K^2)/(1+(V0/Q)*K+K^2);53

54 else55 b = 1;56 a = 1;57 end

F.4.3 Calculating Filter Coefficients - Shelving Filter (low)

1 %--------------------------------------------------------------------------2 % Virtual Effect Processor for Acoustics Guitar3 % GROUP 7904 % Eduardo Fonseca, Lutz Ehrig, Javier Galdn, Ignacio Prez, Estrella Merino5 % Aalborg University6 % December 20077 %--------------------------------------------------------------------------8 % Description:9 % ------------

10 % returns coefficients for low frequency shelving filter11 % [b_low,a_low] = get_coeff_shelv_low(fc_low,g_low,fs)12 %13 % Outputs:14 % --------15 % b_low = filter coefficients numerator16 % a_low = filter coefficients denominator17 %18 % Inputs:19 % -------20 % fc_low = center frequency [Hz]21 % g_low = gain [dB]22 % fs = sample frequency [Hz]23

24 % Last revision: 10 Dec 200725 %--------------------------------------------------------------------------26 %27 function [b_low,a_low] = get_coeff_shelv_low(fc_low,g_low,fs)28

29 %%%%%%%%%%%%%%%%%%%%%%%%%%%% low pass shelving filer %%%%%%%%%%%%%%%%%%%%30 K = tan(pi*fc_low/fs);31 V0 = 10^(abs(g_low)/20);32

33 if g_low > 034 %%%%%%%%%%%%%%%% boost %%%%%%%%%%%%%%%%%%%%%%

150

Page 165: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

F.4 Equalizer

35 b_low(1) = (1+sqrt(2*V0)*K+V0*K^2)/(1+sqrt(2)*K+K^2);36 b_low(2) = 2*(V0*K^2-1)/(1+sqrt(2)*K+K^2);37 b_low(3) = (1-sqrt(2*V0)*K+V0*K^2)/(1+sqrt(2)*K+K^2);38

39 a_low(1) = 1;40 a_low(2) = 2*(K^2-1)/(1+sqrt(2)*K+K^2);41 a_low(3) = (1-sqrt(2)*K+K^2)/(1+sqrt(2)*K+K^2);42

43 elseif g_low < 044 %%%%%%%%%%%%%%%%%%% cut %%%%%%%%%%%%%%%%%%%%%%45 b_low(1) = (1+sqrt(2)*K+K^2)/(1+sqrt(2*V0)*K+V0*K^2);46 b_low(2) = 2*(K^2-1)/(1+sqrt(2*V0)*K+V0*K^2);47 b_low(3) = (1-sqrt(2)*K+K^2)/(1+sqrt(2*V0)*K+V0*K^2);48

49 a_low(1) = 1;50 a_low(2) = 2*(V0*K^2-1)/(1+sqrt(2*V0)*K+V0*K^2);51 a_low(3) = (1-sqrt(2*V0)*K+V0*K^2)/(1+sqrt(2*V0)*K+V0*K^2);52

53 else % g_low == 054 %%%%%%%%%%%%%%%%%%%%%% bypass filter %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%55 b_low = [1 0 0];56 a_low = [1 0 0];57 end

F.4.4 Calculating Filter Coefficients - Shelving Filter (high)

1 %--------------------------------------------------------------------------2 % Virtual Effect Processor for Acoustics Guitar3 % GROUP 7904 % Eduardo Fonseca, Lutz Ehrig, Javier Galdn, Ignacio Prez, Estrella Merino5 % Aalborg University6 % December 20077 %--------------------------------------------------------------------------8 % Description:9 % ------------

10 % returns coefficients for high frequency shelving filter11 % [b_high,a_high] = get_coeff_shelv_high(fc_high,g_high,fs)12 %13 % Outputs:14 % --------15 % b_high = filter coefficients numerator16 % a_high = filter coefficients denominator17 %18 % Inputs:19 % -------20 % fc_high = center frequency [Hz]21 % g_high = gain [Hz]22 % fs = sample frequency [Hz]23

24 % Last revision: 10 Dec 2007

151

Page 166: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

F. Matlab-Code

25 %--------------------------------------------------------------------------26 %27 function [b_high,a_high] = get_coeff_shelv_high(fc_high,g_high,fs)28

29 %%%%%%%%%%%%%%%%%%%%%% high pass shelving filter %%%%%%%%%%%%%%%%%%%%%%%30 K = tan(pi*fc_high/fs);31 V0 = 10^(abs(g_high)/20);32

33 if g_high > 034 %%%%%%%%%%%%%%%%%%%%%%%% boost %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%35 b_high(1) = (V0+sqrt(2*V0)*K+K^2)/(1+sqrt(2)*K+K^2);36 b_high(2) = 2*(K^2-V0)/(1+sqrt(2)*K+K^2);37 b_high(3) = (V0-sqrt(2*V0)*K+K^2)/(1+sqrt(2)*K+K^2);38

39 a_high(1) = 1;40 a_high(2) = 2*(K^2-1)/(1+sqrt(2)*K+K^2);41 a_high(3) = (1-sqrt(2)*K+K^2)/(1+sqrt(2)*K+K^2);42

43 elseif g_high < 044 %%%%%%%%%%%%%%%%%%%%%%% cut %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%45 b_high(1) = (1+sqrt(2)*K+K^2)/(V0+sqrt(2*V0)*K+K^2);46 b_high(2) = 2*(K^2-1)/(V0+sqrt(2*V0)*K+K^2);47 b_high(3) = (1-sqrt(2)*K+K^2)/(V0+sqrt(2*V0)*K+K^2);48

49 a_high(1) = 1;50 a_high(2) = 2*((K^2/V0)-1)/(1+sqrt(2/V0)*K+(K^2/V0));51 a_high(3) = (1-sqrt(2/V0)*K+(K^2/V0))/(1+sqrt(2/V0)*K+(K^2/V0));52

53 else54 %%%%%%%%%%%%%%%%%%%%%% bypass filter %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%55 b_high = [1 0 0];56 a_high = [1 0 0];57 end

F.5 Delay

F.5.1 Echo Delay

1 %--------------------------------------------------------------------------2 % Virtual Effect Processor for Acoustics Guitar3 % GROUP 7904 % Eduardo Fonseca, Lutz Ehrig, Javier Galdn, Ignacio Prez, Estrella Merino5 % Aalborg University6 % December 20077 %--------------------------------------------------------------------------8 % Description:9 % ------------

10 % ECHO DELAY EFFECT

152

Page 167: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

F.5 Delay

11 %12 % Outputs:13 % -------14 % out = output sample15 %16 % Inputs:17 % -------18 %19 % signal = input sample20 % del_mix = amplitude mix between dry and wet signal21 % cutf = lowpass filter gain22 %23 % Last revision: 3 Dec 200724 %--------------------------------------------------------------------------25

26 function [out] = echo_del(signal,del_mix,cutf)27

28 % declare global variables29 global echoBuff30 global y_cutE31

32

33

34 % low pass filter, applied to replicas35 y_cutE=cutf*echoBuff(end)+(1-cutf)*y_cutE;36

37 % FIR comb filter38 out=signal+del_mix*y_cutE;39

40 % update buffers41 echoBuff=[signal;echoBuff(1:end-1)];

F.5.2 Feedback Delay

1 %--------------------------------------------------------------------------2 % Virtual Effect Processor for Acoustics Guitar3 % GROUP 7904 % Eduardo Fonseca, Lutz Ehrig, Javier Galdn, Ignacio Prez, Estrella Merino5 % Aalborg University6 % December 20077 %--------------------------------------------------------------------------8 % Description:9 % ------------

10 % FEEDBACK DELAY EFFECT11 %12 % Outputs:13 % -------14 % out = output sample15 %16 % Inputs:

153

Page 168: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

F. Matlab-Code

17 % -------18 %19 % signal = input sample20 % del_mix = amplitude mix between dry and wet signal21 % feed_gain = delay feedback gain22 % cutf = lowpass filter gain23 % norm = normalization coefficient24 %25 % Last revision: 3 Dec 200726 %--------------------------------------------------------------------------27

28 function [out] = feedback_del(signal,del_mix,feed_gain,cutf,norm)29

30 % declare global variables31 global buff_x32 global buff_y33 global y_cutF34

35

36

37 % IIR comb filter38 y= norm*buff_x(end)+feed_gain*buff_y(end);39

40 % low pass filter, applied to replicas41 y_cutF=cutf*y+(1-cutf)*y_cutF;42

43 % sum dry and wet signal44 out=signal+del_mix*y_cutF;45

46 % update buffers47 buff_x=[signal;buff_x(1:end-1)];48 buff_y=[y;buff_y(1:end-1)];

F.5.3 Dynamic Delay

1 %--------------------------------------------------------------------------2 % Virtual Effect Processor for Acoustics Guitar3 % GROUP 7904 % Eduardo Fonseca, Lutz Ehrig, Javier Galdn, Ignacio Prez, Estrella Merino5 % Aalborg University6 % December 20077 %--------------------------------------------------------------------------8 % Description:9 % ------------

10 % DYNAMIC DELAY EFFECT11 %12 % Outputs:13 % -------14 % out = output sample15 %

154

Page 169: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

F.5 Delay

16 % Inputs:17 % -------18 %19 % signal = input sample20 % del_mix = amplitude mix between dry and wet signal21 % feed_gain = delay feedback gain22 % cutf = lowpass filter gain23 % T = threshold between 0 and 124 % release = release constant (using release time)25 % damp_dyn = attenuation for the delayed replicas26 % norm = normalization coefficient27 %28 % Last revision: 3 Dec 200729 %--------------------------------------------------------------------------30

31 function [out] = dynamic_del(signal,del_mix,feed_gain,cutf,T,release,damp_dyn,norm)

32

33 global var %to store the shape34 global buff_x_dyn35 global buff_y_dyn36 global y_cutF_dyn37

38 %% Level Detection39 level = abs(signal);40

41 %% First Order Peak Hold Circuit42 % Calculating the "shape" of the signal43 % the shape of the signal considers the release time44 if level > (var*release)45 var = level;46 else47 var = var*release;48 end49

50 shape = var; %obtained shape for the actual imput51

52 if shape >= T %shape above treshold =>decrease delay53 del_mix=del_mix*damp_dyn;54 else55 del_mix=del_mix;56 end57

58 % regular feedback delay59 % IIR comb filter60 y= norm*buff_x_dyn(end)+feed_gain*buff_y_dyn(end);61

62 % low pass filter, applied to replicas63 y_cutF_dyn=cutf*y+(1-cutf)*y_cutF_dyn;64

65 % sum dry and wet signal

155

Page 170: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

F. Matlab-Code

66 out=signal+del_mix*y_cutF_dyn;67

68 % update buffers69 buff_x_dyn=[signal;buff_x_dyn(1:end-1)];70 buff_y_dyn=[y;buff_y_dyn(1:end-1)];

F.5.4 Ping Pong Delay

1 %--------------------------------------------------------------------------2 % Virtual Effect Processor for Acoustics Guitar3 % GROUP 7904 % Eduardo Fonseca, Lutz Ehrig, Javier Galdn, Ignacio Prez, Estrella Merino5 % Aalborg University6 % December 20077 %--------------------------------------------------------------------------8 % Description:9 % ------------

10 % PING PONG DELAY EFFECT11 %12 % Outputs:13 % -------14 % out_L = left channel output sample15 % out_R = right channel output sample16 %17 % Inputs:18 % -------19 %20 % signal_L = input sample21 % del_mix = amplitude mix between dry and wet signal22 % feed_gain = delay feedback gain23 % cutf = lowpass filter gain24 % norm = normalization coefficient25 %26 % Last revision: 3 Dec 200727 %--------------------------------------------------------------------------28

29 function [out_L,out_R] = ppong_del(signal_L,del_mix,feed_gain,cutf,norm)30

31 % declare global variables32 global buff_x_L33 global buff_y_L34 global buff_y_R35 global y_cutL36 global y_cutR37

38

39

40 % % % % % % LEFT CHANNEL41

42 % IIR comb filter

156

Page 171: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

F.6 Reverberation

43 y_L= norm*buff_x_L(end)+feed_gain*buff_y_R(end);44 % low pass filter, applied to replicas45 y_cutL=cutf*y_L+(1-cutf)*y_cutL;46 % sum dry and wet signal47 out_L=signal_L+del_mix*y_cutL;48

49 % update buffers for LEFT channel50 buff_x_L=[signal_L;buff_x_L(1:end-1)];51 buff_y_L=[y_L;buff_y_L(1:end-1)];52

53 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%54 % % % % % % RIGHT CHANNEL55

56 % IIR comb filter57 y_R= feed_gain*buff_y_L(end);58 % low pass filter, applied to replicas59 y_cutR=cutf*y_R+(1-cutf)*y_cutR;60 % sum dry and wet signal61 out_R=del_mix*y_cutR+signal_L;62

63 % update buffers for RIGHT channel64 buff_y_R=[y_R;buff_y_R(1:end-1)];

F.6 Reverberation

1 %--------------------------------------------------------------------------2 % Virtual Effect Processor3 % Group 7904 % Aalborg University5 %--------------------------------------------------------------------------6 % Description:7 % -------8 % REVERBERATION EFFECT9 % Based on Dattorro’s algorithm form paper "Design Part 1: Reverberation

10 % and Other Filters", AES Journal, Vol. 45, No 9, September 1997.11 %12 % Outputs:13 % -------14 % yL = output sample left channel15 % yR = output sample right channel16 %17 % Inputs:18 % -------19 % xL = input sample left channel20 % xR = input sample right channel21 % fs = sample rate [Hz]22 % n = iteration index value23 % mix = mixer parameter between dry and reverberation signals (0=dry; 1=wet)24 % predelay = delay before generating reverb tail (0 to inf samples)

157

Page 172: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

F. Matlab-Code

25 % bandwidth = frquency band which is processed (Hz)26 % damping = frequency cut in high-attenuation due to air absortion (Hz)27 % decay = reverberation tail decay rate (0 to 1)28 % in_diff1, in_diff2 = decorrelation of input signal (0 to 1)29 % dec_diff1, dec_diff2 = decorrelation of recirculate signal (0 to 1)30 % d = vector containing the length of delay lines (in samples)31 % all_d = vector containing the order of the allpass filters32 % excursion = amplitude of lfo applied to the delay in allpass 5 an 5’33 % flfo = frequency of the lfo applied to the delay in allpass 5 and 5’34

35 % Last revision: 11 Dec 200736 %--------------------------------------------------------------------------37

38 function [yL,yR] = reverb(xL,xR,pingpong,fs,n,mix,predelay,bandwidth,damping,decay,in_diff1,in_diff2,dec_diff1,dec_diff2,d,excursion,flfo,all_d)

39

40 global pre_b41 global d1_b42 global d2_b43 global d3_b44 global d4_b45 global all_in1_b46 global all_out1_b47 global all_in2_b48 global all_out2_b49 global all_in3_b50 global all_out3_b51 global all_in4_b52 global all_out4_b53 global all_in5_b54 global all_out5_b55 global all_in6_b56 global inner6_b57 global all_out6_b58 global all_in7_b59 global all_out7_b60 global all_in8_b61 global inner8_b62 global all_out8_b63 global y264 global y965 global y1666 global ya67 global yb68 global yc69

70 if pingpong == 0 % input signal is mono71 xR = xL;72 end73 x = 0.5*(xL + xR); %mix inputs L & R74

158

Page 173: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

F.6 Reverberation

75

76 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%77 %%%%%________________________________________________________________%%%%%%78 %%%%%_______________________INPUT SECTION____________________________%%%%%%79

80 %%%%%%%%%%%%%%%%%%%%%%%%%%%% PRE-DELAY %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%81 %One single delay in the input82 %User Parameter: predelay = (0->inf)83 %Buffers: pre_b84

85 %Apply delay86 if predelay == 087 y1 = x;88 else89 y1 = pre_b(predelay);90 end91 %Load buffer92 pre_b = [x;pre_b(1:end-1)];93

94

95 %%%%%%%%%%%%%%%%%%%%%%%% LOW PASS 1 (BANDWIDTH) %%%%%%%%%%%%%%%%%%%%%%%%%%%96 %First order low pass filter97 %User Parameter: bandwidth = (0->0.999999...)98

99 y2 = (1-bandwidth)*y1 + bandwidth*y2;100

101

102 %%%%%%%%%%%%%%%%%%%%%%%% INPUT DIFFUSERS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%103 %Four all pass filters in series104 %Differences ecuation: y(n) = ax(n)+x(n-k)-ay(n-k)105 %User Parameter: input diffusion 1 (in_diff1 = 0->0.9999...)106 %User Parameter: input diffusion 2 (in_diff2 = 0->0.9999...)107 %Buffers: all_in1_b ; all_out1_b ; all_in2_b ; all_out2_b ; all_in3_b ;108 % all_out3_b ; all_in4_b ; all_out4_b109

110

111 %%%%% All-pass filter 1 %%%%%112

113 %Apply filter114 y3 = in_diff1*y2 + all_in1_b(all_d(1)) - in_diff1*all_out1_b(all_d(1));115 %Load buffers116 all_in1_b = [y2;all_in1_b(1:end-1)];117 all_out1_b = [y3;all_out1_b(1:end-1)];118

119 %%%%% All-pass filter 2 %%%%%120

121 %Apply filter122 y4 = in_diff1*y3 + all_in2_b(all_d(2)) - in_diff1*all_out2_b(all_d(2));123 %Load buffers124 all_in2_b = [y3;all_in2_b(1:end-1)];125 all_out2_b = [y4;all_out2_b(1:end-1)];

159

Page 174: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

F. Matlab-Code

126

127 %%%%% All-pass filter 3 %%%%%128

129 %Apply filter130 y5 = in_diff2*y4 + all_in3_b(all_d(3)) - in_diff2*all_out3_b(all_d(3));131 %Load buffers132 all_in3_b = [y4;all_in3_b(1:end-1)];133 all_out3_b = [y5;all_out3_b(1:end-1)];134

135 %%%%% All-pass filter 4 %%%%%136

137 %Apply filter138 y6 = in_diff2*y5 + all_in4_b(all_d(4)) - in_diff2*all_out4_b(all_d(4));139 %Load buffers140 all_in4_b = [y5;all_in4_b(1:end-1)];141 all_out4_b = [y6;all_out4_b(1:end-1)];142

143 %%%%% WRITE OUTPUT OF 1st PART %%%%%144

145 ya = y6;146

147

148

149 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%150 %%%%%________________________________________________________________%%%%%%151 %%%%%__________________________THE TANK______________________________%%%%%%152

153

154 % It has a general input ya155 % the input splits in two different paths and recirculate adding again to156 % the other path157 % Output path1 = yb158 % Input path1 = ya + yc159 % Output path2 = yc160 % Input path2 = ya + yb161 % yb and yc are zero initialized outside the ’for’162

163 %%%%%%%%%%%%%%%%%%%%%%%%% TANK PT1 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%164 % All-pass filter with variable delay & fixed delay & LPF (damping) & Decay165 % & All-pass filter with inner buffer & delay & decay (combined in series)166 % in: ya + yc167 % out: yb168 % User parameter: decay diffusion 1 (dec_diff1 = 0->0.9999...)169 % User parameter: decay diffusion 2 (dec_diff2 = 0->0.9999...)170 % User parameter: decay = 0->0.9999...171 % User parameter: damping = 0->0.9999...172 % Buffers = all_in5_b ; all_out5_b ; all_in6_b ; all_out6_b ; inner6_b173 % d1_b ; d2_b174 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%175

176

160

Page 175: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

F.6 Reverberation

177 %%%%% All-pass filter 5 with excursion%%%%%178

179 %Calculate excurison180 r = round(excursion * sin((2*pi/round(fs/flfo))*n)); %LFO181 %Apply filter182 y7 = - dec_diff1*(ya+yc) + all_in5_b(all_d(5) + r) + dec_diff1*all_out5_b(

all_d(5) + r);183 %Load buffers184 all_in5_b = [(ya+yc);all_in5_b(1:end-1)];185 all_out5_b = [y7;all_out5_b(1:end-1)];186

187 %%%%% Delay 1 %%%%%188

189 y8 = d1_b(d(1));190 %Load buffer191 d1_b = [y7;d1_b(1:end-1)];192

193 %%%%% Low pass 2(damping) %%%%%194

195 y9 = (1-damping)*y8 + damping*y9;196

197 %%%%% Decay %%%%%198

199 y10 = decay*y9;200

201 %%%%% All-pass filter 6 with inner buffer %%%%%202

203 %Apply filter204 y11 = dec_diff2*y10 + all_in6_b(all_d(6)) - dec_diff2*all_out6_b(all_d(6));205 %it extracts values from inside the filter206 u6 = y10 - dec_diff2*inner6_b(all_d(6));207

208 %Load buffers209 %it stores values in the delay of the filter210 inner6_b = [u6;inner6_b(1:end-1)];211 all_in6_b = [y10;all_in6_b(1:end-1)];212 all_out6_b = [y11;all_out6_b(1:end-1)];213

214 %%%%% Delay 2 %%%%%215

216 y12 = d2_b(d(2));217 %Load buffer218 d2_b = [y11;d2_b(1:end-1)];219

220 %%%%% Decay %%%%%221

222 y13 = decay*y12;223

224 %%%%% WRITE OUTPUT OF TANK PT1 %%%%%225

226 yb = y13;

161

Page 176: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

F. Matlab-Code

227

228 %%%%%%%%%%%%%%%%%%%%%%%%% TANK PT2 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%229 % All-pass filter with variable delay & fixed delay & LPF (damping) &230 % Decay & All-pass filter with inner buffer & delay & decay (in series)231 % in: ya + yb232 % out: yc233 % User parameter: decay diffusion 1 (dec_diff1 = 0->0.9999...)234 % User parameter: decay diffusion 2 (dec_diff2 = 0->0.9999...)235 % User parameter: decay = 0->0.9999...236 % User parameter: damping = 0->0.9999...237 % Buffers = all_in7_b ; all_out7_b ; all_in8_b ; all_out8_b ; inner8_b238 % d3_b ; d4_b239 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%240

241

242 %%%%% All-pass filter 5’ with excursion %%%%%243

244 %Calculate excurison245 r = round(excursion * sin((2*pi/round(fs/flfo))*n)); %LFO246 %Apply filter247 y14 = - dec_diff1*(ya+yb) + all_in7_b(all_d(7) + r) + dec_diff1*all_out7_b(

all_d(7) + r);248 %Load buffers249 all_in7_b = [(ya+yb);all_in7_b(1:end-1)]; %write input250 all_out7_b = [y14;all_out7_b(1:end-1)]; %write output251

252 %%%%% Delay 3 %%%%%253 y15 = d3_b(d(3));254 %Load buffer255 d3_b = [y14;d3_b(1:end-1)];256

257 %%%%% Low pass 2’(damping) %%%%%258

259 y16 = (1-damping)*y15 + damping*y16;260

261 %%%%% Decay %%%%%262

263 y17 = decay*y16;264

265 %%%%% All-pass filter 6’ with inner buffer %%%%%266

267 %Apply filter268 y18 = dec_diff2*y17 + all_in8_b(all_d(8))-dec_diff2*all_out8_b(all_d(8));269 %it extracts values from inside the filter270 u8 = y17 - dec_diff2*inner8_b(all_d(8));271 %Load buffers272 %it stores values in the delay of the filter273 inner8_b = [u8;inner8_b(1:end-1)];274 all_in8_b = [y17;all_in8_b(1:end-1)];275 all_out8_b = [y18;all_out8_b(1:end-1)];276

162

Page 177: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

F.6 Reverberation

277 %%%%% Delay 4 %%%%%278

279 y19 = d4_b(d(4));280 %Load buffer281 d4_b = [y18;d4_b(1:end-1)];282

283 %%%%% Decay %%%%%284

285 y20 = decay*y19;286

287 %%%%% WRITE OUTPUT OF TANK PT2 %%%%%288

289 yc = y20;290

291

292 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%293 %%%%%________________________________________________________________%%%%%%294 %%%%%______________________OUTPUT SECTION____________________________%%%%%%295

296 %%%%%%%%%%%%%%%%%%%%%%%% WRITE OUTPUT (OUTPUT TAPS) %%%%%%%%%%%%%%%%%%%%%%%297 % Build the signal with the combination of different taps. These taps %298 % extract the signal from certain points in the buffers. %299 % Two signals, yL and yR, are obtained, both are mixed with the direct %300 % signal following ’mix’ parameter %301 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%302

303 %%%%% Left Output, all wet %%%%%304

305 yL = 0;306 yL = yL + 0.6 * d3_b(394); %394 from delay 3307 yL = yL + 0.6 * d3_b(4407); %4407 from delay 3308 yL = yL - 0.6 * inner8_b(2835); %2835 from allpass 8309 yL = yL + 0.6 * d4_b(2958); %2958 from delay 4310 yL = yL - 0.6 * d1_b(2949); %2949 from delay 1311 yL = yL - 0.6 * inner6_b(277); %277 from allpass 6312 yL = yL - 0.6 * d2_b(1580); %1580 from delay 2313

314 %%%%% Right Output, all wet %%%%%315

316 yR = 0;317 yR = yR + 0.6 * d1_b(523); %523 from delay 1318 yR = yR + 0.6 * d1_b(5374); %5374 from delay 1319 yR = yR - 0.6 * inner6_b(1820); %1820 from allpass 6320 yR = yR + 0.6 * d2_b(3961); %3961 from delay 2321 yR = yR - 0.6 * d3_b(3128); %3128 from delay 3322 yR = yR - 0.6 * inner8_b(496); %496 from allpass 8323 yR = yR - 0.6 * d4_b(179); %179 from delay 4324

325 %%%%% MIX %%%%%326

327 yL = (1-mix)*xL + mix*yL;

163

Page 178: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

F. Matlab-Code

328 yR = (1-mix)*xR + mix*yR;

F.7 Modulation Effects

F.7.1 Flanger

1 %--------------------------------------------------------------------------2 % Virtual Effect Processor for Acoustics Guitar3 % GROUP 7904 % Eduardo Fonseca, Lutz Ehrig, Javier Galdn, Ignacio Prez, Estrella Merino5 % Aalborg University6 % December 20077 %--------------------------------------------------------------------------8 % Description:9 % -------

10 % FLANGER EFFECT11 % y(n) = x(n) + a_fla*x(n - d(n))12 %13 % Outputs:14 % -------15 % y = output sample16 %17 % Inputs:18 % -------19 % b = input sample20 % a_fla = gain of the delay loop between 0 and 121 % md_fla = maximun Delay Variation [samples]22 % Wd_fla = omega of the LFO (2*pi*LFOfrequency)23 % cutf = feedback gain of the Low Pass Filter (0 to 1)24 % n = number of sample to be processed (index of the for loop)25 %26 % Last revision: 3 Dec 200727 %--------------------------------------------------------------------------28 function [y] = flanger(b,a_fla,md_fla,Wd_fla,cutf,n)29

30 global buffer_fla31 global ycut_fla32

33 % Update the buffer34 buffer_fla(1)= [];35 buffer_fla(end+1) = b;36

37 % variation of the delay d(n) at a certain n38 d = round((md_fla/2)*(1-cos(Wd_fla*n)));39 % y (n) = x(n) + a*x(n - d(n))40 y_fla = buffer_fla(end) + a_fla*buffer_fla(end-d);41

42 % Low Pass Filtering. 1st order IIR.

164

Page 179: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

F.7 Modulation Effects

43 ycut_fla = cutf*y_fla +(1-cutf)*ycut_fla;44

45 y = ycut_fla;

F.7.2 Chorus

1 %--------------------------------------------------------------------------2 % Virtual Effect Processor for Acoustics Guitar3 % GROUP 7904 % Eduardo Fonseca, Lutz Ehrig, Javier Galdn, Ignacio Prez, Estrella Merino5 % Aalborg University6 % December 20077 %--------------------------------------------------------------------------8 % Description:9 % -------

10 % CHORUS EFFECT with 2 voices11 % y(n) = x(n) + a_cho*x(n - d(n)) + a_cho*rand*x(n-d_2(n)12 %13 % Outputs:14 % -------15 % y = output sample16 %17 % Inputs:18 % -------19 % b = input sample20 % fs = sample rate [Hz]21 % a_cho = gain of the delay loop between 0 and 122 % v_cho = maximun Delay Variation [ms]23 % Wd_cho = omega of the LFO (2*pi*LFOfrequency)24 % Wd_cho_v2 = omega of the LFO (2*pi*LFOfrequency) for voice 225 % rand_factor = factor to get the slight different parameters for voice 226 % cutf = feedback gain of the Low Pass Filter (0 to 1)27 % n = number of sample to be processed (index of the for loop)28 %29 % Last revision: 3 Dic 200730 %--------------------------------------------------------------------------31

32 function [y] = chorus(b,fs,a_cho,v_cho,Wd_cho,Wd_cho_v2,rand_factor,cutf,n)33

34 global buffer_cho35 global ycut_cho36

37 % maximun matrix holding all voices (2 voices)38 voices = zeros(1,2);39

40 % Update the buffer41 buffer_cho(1)= [];42 buffer_cho(end+1) = b;43

44 % Calculating voice 1: User defined voice

165

Page 180: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

F. Matlab-Code

45 %----------------------------------------46 %number of maximun samples delayed47 md_voice1 = round(v_cho*fs/1000);48 % variation of the delay d(n)49 d = round((md_voice1/2)*(1-cos(Wd_cho*n)));50 % Output of the voice number 151 voices(1) = a_cho*buffer_cho(end-d);52

53 % Calculating voice 2: Randomly variation54 %----------------------------------------55 %number of maximun samples delayed56 md_voice2 = round(v_cho*rand_factor*fs/1000);57 % variation of the delay d(n)58 d_2 = round((md_voice2/2)*(1-cos(Wd_cho_v2*n)));59 % Output of the voice number 260 voices(1) = a_cho*rand_factor*buffer_cho(end-d_2);61

62

63 aux = sum(voices);64

65

66 y_cho = b + aux;67

68

69 % Low Pass Filtering. 1st order IIR.70 ycut_cho = cutf*y_cho +(1-cutf)*ycut_cho;71

72 y = ycut_cho;

F.7.3 Vibrato

1 %--------------------------------------------------------------------------2 % Virtual Effect Processor for Acoustics Guitar3 % GROUP 7904 % Eduardo Fonseca, Lutz Ehrig, Javier Galdn, Ignacio Prez, Estrella Merino5 % Aalborg University6 % December 20077 %--------------------------------------------------------------------------8 % Description:9 % -------

10 % VIBRATO EFFECT11 % y(n) = x(n - d(n))12 %13 % Outputs:14 % -------15 % y = output sample16 %17 % Inputs:18 % -------19 % b = input sample

166

Page 181: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

F.7 Modulation Effects

20 % md_vib = maximun Delay Variation [samples]21 % Wd_vib = omega of the LFO (2*pi*LFOfrequency)22 % cutf = feedback gain of the Low Pass Filter (0 to 1)23 % n = number of sample to be processed (index of the for loop)24 %25 % Last revision: 3 Dec 200726 %--------------------------------------------------------------------------27 function [y] = vibrato(b,md_vib,Wd_vib,cutf,n)28

29 global buffer_vib30 global ycut_vib31

32 % Update the buffer33 buffer_vib(1)= [];34 buffer_vib(end+1) = b;35

36 % variation of the delay d(n)37 d = round((md_vib/2)*(1-cos(Wd_vib*n)));38

39 y_vib = buffer_vib(end-d);40

41 % Low Pass Filtering. 1st order IIR.42 ycut_vib = cutf*y_vib +(1-cutf)*ycut_vib;43

44 y = ycut_vib;

F.7.4 Tremolo

1 %--------------------------------------------------------------------------2 % Virtual Effect Processor for Acoustics Guitar3 % GROUP 7904 % Eduardo Fonseca, Lutz Ehrig, Javier Galdn, Ignacio Prez, Estrella Merino5 % Aalborg University6 % December 20077 %--------------------------------------------------------------------------8 % Description:9 % -------

10 % TREMOLO EFFECT11 % y(n) = x(n) * (1 + alfa*m(n))12 %13 % Outputs:14 % -------15 % y = output sample16 %17 % Inputs:18 % -------19 % b = input sample20 % fs = sample rate [Hz]21 % a_trem = gain of the delay loop between 0 and 122 % f_trem = frequency of the LFO

167

Page 182: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

F. Matlab-Code

23 % cutf = feedback gain of the Low Pass Filter (0 to 1)24 % n = number of sample to be processed (index of the for loop)25 %26 % Last revision: 3 Dec 200727 %--------------------------------------------------------------------------28 function [y] = tremolo(b,fs,a_trem,f_trem,cutf,n)29

30 global ycut_trem31

32 % trem = 1 + alfa * m(n)33 % +1 in order not to change the phase34 trem =1 +(a_trem*sin(2*pi*n*(f_trem/fs)));35

36 y_trem = b*trem;37

38 % Low Pass Filtering. 1st order IIR.39 ycut_trem = cutf*y_trem +(1-cutf)*ycut_trem;40

41 y = ycut_trem;

168

Page 183: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

List of Figures

1.3.1 Spectrum view of a pickup (left) and a microphone signal (right).The microphone was placed in front of the soundhole. The am-plitude of the high frequencies is for the pickup signal higher thanfor the output of the microphone. . . . . . . . . . . . . . . . . . 3

2.2.1 Typical setup for an effect processor based on guitar and pickup[GNa07]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7

2.2.2 Typical setup for an effect processor based on guitar and pickupand microphone [GNa07]. . . . . . . . . . . . . . . . . . . . . . . 7

2.3.1 Serial block diagram of the implemented effect processor, basedon [GNa07]. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9

3.1.1 Signal processing in the compressor. . . . . . . . . . . . . . . . . 143.1.2 Release stage circuit. . . . . . . . . . . . . . . . . . . . . . . . . 143.1.3 Envelope after release stage. . . . . . . . . . . . . . . . . . . . . 183.1.4 Gain response with and without attack time. . . . . . . . . . . . 183.1.5 Signal processing in the noise gate. . . . . . . . . . . . . . . . . 193.1.6 Input signal applying or not noise gate. . . . . . . . . . . . . . . 213.2.1 Amplitude response of a low frequency shelving filter (left) and

a high frequency shelving filter (right). For both filters differentvalues of V0 are applied. . . . . . . . . . . . . . . . . . . . . . . 23

3.2.2 Amplitude response of a peak and a notch filter. For the peakfilter different values of V0 are applied; for the notch filter differentvalues of Q. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24

3.2.3 Series connection of shelving and peak/notch filters. . . . . . . . 253.2.4 Block diagram of a second-order IIR filter . . . . . . . . . . . . 263.2.5 Matlab/Simulink modell of a 2-band parametric equalizer. . . 263.2.6 Frequency responses for the particular filters and the equalizer

itself, by using the following parameters: fc,low = 150 Hz, Glow =1.5 dB; fc1 = 150 Hz, Q1 = 3, G1 = �1 dB; fc2 = 700 Hz,Q2 = 3, G2 = 4 dB; fc3 = 2000 Hz, Q3 = 4, G3 = 3 dB;fc4 = 4000 Hz, Q4 = 5, G4 = 2 dB; fc4 = 6000 Hz, Q4 = 5,G4 = 0 dB; fc,high = 8000 Hz, Ghigh = 3 dB. . . . . . . . . . . . . 27

3.3.1 Block diagram of a FIR comb filter [Har07]. . . . . . . . . . . . 29

169

Page 184: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

LIST OF FIGURES

3.3.2 FIR comb filter transfer function for a delay of 8 samples andmix equal to 0.7. . . . . . . . . . . . . . . . . . . . . . . . . . . 30

3.3.3 Block diagram of the IIR comb filter proposed in [Zol05]. . . . . 303.3.4 Block diagram of the IIR comb filter proposed by [Syn07]. . . . 313.3.5 Block diagram of the IIR comb filter to be implemented for the

effects processor. . . . . . . . . . . . . . . . . . . . . . . . . . . 323.3.6 Transfer function for the IIR comb filter proposed in [Syn07] for

a delay of 8 samples and g equal to 0.7. . . . . . . . . . . . . . . 333.3.7 Feedback Delay output performing as an Echo Unit when exciting

with a Dirac delta function. Delay applied 200 ms, mix equal to0.5 and g equal to 0. . . . . . . . . . . . . . . . . . . . . . . . . 35

3.3.8 Feedback Delay output when exciting with a Dirac delta function.Delay applied 200 ms, mix equal to 1 and g equal to 0.6. . . . . 36

3.3.9 Block diagram of the Dynamic Delay to be implemented in theeffects processor. . . . . . . . . . . . . . . . . . . . . . . . . . . 37

3.3.10 Block diagram of the Ping Pong Delay to be implemented in theeffects processor. . . . . . . . . . . . . . . . . . . . . . . . . . . 40

3.3.11 Ping Pong Delay output when exciting with a Dirac delta func-tion. Delay applied 200 ms, mix equal to 1 and g equal to 0.6. . 42

3.4.1 Schematic of a listening example [Har07]. . . . . . . . . . . . . . 433.4.2 Echogram of a room [Har07]. . . . . . . . . . . . . . . . . . . . . 443.4.3 Comb filter flow diagram and impulse response [Gar92]. . . . . . 453.4.4 Allpass filter flow diagram and impulse response [Gar92]. . . . . 453.4.5 Dattorro’s reverberator flow diagram, based on [Bel04]. . . . . . 473.4.6 First-order lowpass filter flow diagram [Bel04]. . . . . . . . . . . 483.4.7 Flow diagram of allpass filters 5 and 5’. Based on [Gar92]. . . . 503.4.8 Impulse responses for decay = 0.5, decay = 0.05 and decay = 0.001. 553.4.9 Impulse responses for input diffusion 1 and 2 = 0.1 and input diffusion

1 and 2 = 0.95. . . . . . . . . . . . . . . . . . . . . . . . . . . . 563.4.10 Impulse responses for decay diffusion1 and 2 = 0.1 and decay diffusion

1 and 2= 0.95. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 563.5.1 Block diagram of a flanger [McG07]. . . . . . . . . . . . . . . . . 583.5.2 Frequency response of a flanger effect. . . . . . . . . . . . . . . . 593.5.3 Block diagram of a dual-voice chorus [McG07]. . . . . . . . . . . 603.5.4 Block diagram of a vibrato [McG07] . . . . . . . . . . . . . . . . 633.5.5 Vibrato applied to a sinusoidal signal. . . . . . . . . . . . . . . . 653.5.6 Block diagram of a tremolo [Zol05]. . . . . . . . . . . . . . . . . 663.5.7 Tremolo applied to a sinusoidal signal. . . . . . . . . . . . . . . 68

4.1.1 Block diagram of the serial routing, based on [GNa07]. . . . . . 704.1.2 Block diagram of the serial modulation block. . . . . . . . . . . 714.1.3 Block diagram of the serial delay block. . . . . . . . . . . . . . . 71

170

Page 185: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

4.1.4 Block diagram of the parallel routing, based on [GNa07]. . . . . 714.1.5 Block diagram of the parallel modulation block. . . . . . . . . . 724.1.6 Block diagram of the parallel delay block. . . . . . . . . . . . . . 72

5.1.1 Frequency response for different numbers of sample points byusing the Matlab function freqz. . . . . . . . . . . . . . . . . 79

5.1.2 Listening room of the Acoustics Laboratory. . . . . . . . . . . . 82

6.1.1 Screenshot of the real time effect processor working over a record-ing software. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90

6.2.1 Screenshot of the real time effects processor. . . . . . . . . . . . 926.2.2 Screenshot of the compressor internal schematic. . . . . . . . . . 936.2.3 Screenshot of the equalizer internal schematic. . . . . . . . . . . 936.2.4 Screenshot of the implemetation of a biquad IIR filter under Syn-

thMaker. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 946.2.5 Screenshot of the tremolo internal schematic. . . . . . . . . . . . 95

A.2.1 Typical transfer function of a compressor. . . . . . . . . . . . . . 100A.2.2 Attack and release times. . . . . . . . . . . . . . . . . . . . . . . 101A.3.1 Block diagram of a dynamic range controller. . . . . . . . . . . . 101A.4.1 Noise gate transfer function. . . . . . . . . . . . . . . . . . . . . 102

B.2.1 Pole-zero plot and qualitative magnitude response of a second-order transfer function. . . . . . . . . . . . . . . . . . . . . . . . 105

D.0.1 Schroeder’s reverberator flow diagram [Gar92]. . . . . . . . . . . 114D.0.2 Moorer’s reverberator flow diagram [Zol05]. . . . . . . . . . . . . 115D.0.3 Jot’s reverberator flow diagram [Bel04]. . . . . . . . . . . . . . . 116

List of Tables

5.1 List of signals used for task 1 and the number of sample pointsused to process them. . . . . . . . . . . . . . . . . . . . . . . . . . 83

5.2 List of signals used for task 2 and the parameters used to processthem. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 84

5.3 Parameter values of the noise gate effect samples. . . . . . . . . . 845.4 Parameter values for the delay effects samples. . . . . . . . . . . . 845.5 Parameter values of the modulation effects samples. . . . . . . . . 85

171

Page 186: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

LIST OF TABLES

5.6 Signals used for task 6. . . . . . . . . . . . . . . . . . . . . . . . . 855.7 List of signals used for task 7. . . . . . . . . . . . . . . . . . . . . 865.8 Compressor and noise gate presets. . . . . . . . . . . . . . . . . . 865.9 Modulation presets. . . . . . . . . . . . . . . . . . . . . . . . . . . 875.10 Presets for the different delay effects. . . . . . . . . . . . . . . . . 875.11 Reverberation presets. . . . . . . . . . . . . . . . . . . . . . . . . 87

B.1 Filter coefficients for peak filter [Zol99]. . . . . . . . . . . . . . . . 106B.2 Filter coefficients for shelving filter [Zol99]. . . . . . . . . . . . . . 107

E.1 Results of task 1. Scale: 1 - it is the good reference sample / 2 -it is next to the good reference sample / 3 - similar to the goodreference sample / 4 - inbetween good and bad reference / 5 -similiar to bad reference / 6 - next to bad reference / 7 - it is thebad reference. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 121

E.2 Results of task 2. Scale from ++: sample sounds very natural to–: sample sounds very artificial. . . . . . . . . . . . . . . . . . . . 122

E.3 Results of task 3. Scale from ++: sample sounds very natural to–: sample sounds very artificial. . . . . . . . . . . . . . . . . . . . 122

E.4 Results of task 4. Scale from ++: sample sounds very natural to–: sample sounds very artificial. . . . . . . . . . . . . . . . . . . . 122

E.5 Results of task 5. Scale from ++: sample sounds very natural to–: sample sounds very artificial. . . . . . . . . . . . . . . . . . . . 123

E.6 Results of task 6. . . . . . . . . . . . . . . . . . . . . . . . . . . . 123E.7 Results of task 7. . . . . . . . . . . . . . . . . . . . . . . . . . . . 123

172

Page 187: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

Bibliography

[Aau07] Internet: Acoustics: Listening Room, http://es.aau.dk/sections/

acoustics/facilitiesequipment/listening_room/, Accessed December7, 2007.

[All01] R. Allred and M. Tsecouras: A Low-Cost, High-Performance, DigitalAudio Processor, Silicon for Audio, AES 16th UK Conference 2001.

[Aud04] Audition 1.5, Documentation, Adobe Systems, 2004.

[Bac07] T. Bacon: ’Guitar’, Grove Music Online ed. L. Macy (Accessed 11thDecember 2007), http://www.grovemusic.com

[Bel04] F. A. Beltran, J. R. Beltran, N. Holzem, A. Gogu: Matlab Implementationof Reverberation Algorithms, University of Zaragoza (Spain), Universite Librede Bruxelles (Belgium) and Technical University of Cluj-Napoca (Romania),2004.

[Bet07] Internet: Better Guitar - Guitar - Article that explains theTremolo guitar effect, how to use it, and gives buying sug-gestions: http://www.betterguitar.com/equipment/effects/effects_

explained/tremolo/effects_explained_tremolo.html, Accessed Octo-ber 30, 2007.

[Cha05] R. Chassaing: Digital Signal Processing and Applications with the C6713and C6416 DSK, John Wiley & Sons, 2005.

[Che02] W.-K. Chen: The Circuits and Filters Handbook, Second Edition, CRCPress LLC, Boca Raton, 2002.

[Dat97] J. Dattorro: Effect Design Part 1: Reverberator and Other Filters, Jour-nal of the Audio Engineering Society, 45(9):660-684, September 1997.

[Gar92] W. G. Gardner: The Virtual Acoustic Room, MSc thesis, MassachusettsInstitute of Technology, 1992.

173

Page 188: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

BIBLIOGRAPHY

[GNa07] TC Electronic: G-Natural - User’s Manual, TC Electronic, Sindalsvej34, DK-8240 Risskov, June 2007.

[Har07] Internet: Harmony Central - Effects: http://www.harmony-central.

com/Effects/, Accessed October 12, 2007.

[Har93] F. Harris, E. Brooking: A Versatile Parametric Filter Using an ImbeddedAll-Pass Sub-Filter to Independently Adjust Bandwidth, Center Frequency,and Boost or Cut, Presented at the 95th AES Convention, New York, Octo-ber 7-10, 1993.

[Hen90] J. A. Henriquez, T. E. Riemer and R. E. Trahan: A Phase-Linear Au-dio Equalizer: Design and Implementation, Journal of Audio EngineeringSociety, 38(9):653-666, September, 1990.

[Jot92] J. M. Jot: Etude et realisation dun spatialisateur de sons par modelesphysiques et perceptif Ph. D. thesis, Telecom, Paris, 1992.

[Kra90] P. H. Kraght: A Linear-Phase Digital Equalizer with Cubic-Spline Fre-quency Response, presented at the 89th AES Convention, New York, Septem-ber 21-25, 1990.

[Mat05] Matlab 7.1 (Release 14) Documentation, The MathWorks Inc., August2005.

[McG07] Experiment 1: Audio Effects in Matlab. Lecture Notes from Depart-ment of Electrical and Computer Engineering McGill University. Course2005-2006.

[Opp99] A. V. Oppenheim, R. W. Schafer: Discrete-Time Signal Processing,Prentice-Hall, New Jersey, 1999.

[Orf96] S. Orfanidis: Introduction To Signal Processing, Prentice Hall, 1. Edition,1996.

[Pic07] J. Picarella: ’Hendrix, Jimi’, Grove Music Online ed. L. Macy (Accessed11th December 2007), http://www.grovemusic.com

[Rei05] K. Reinschke: Lineare Regelungs- und Steuerungstheorie, Springer,Berlin, September 2005.

[Rip07] E. M. Ripin: ’Sustaining pedal’, Grove Music Online ed. L. Macy (Ac-cessed 11th December 2007), http://www.grovemusic.com

[Sta82] J. Stautner and M. Puckette: Designing Multichannel Reverberators,Computer Music Journal, 6(1):52-65, Spring 1982.

174

Page 189: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

BIBLIOGRAPHY

[Sti86] E. F. Stikvoort: Digital Dynamic Range Compressor for Audio, Journalof Audio Engineering Society, 34(1/2):3-9, January/February, 1986.

[SyC06] SynthMaker Component Reference Version 1, www.synthmaker.com,2006

[Syn07] SynthMaker 1.0.9 Audio Programing Tool, developed by Outsim, www.synthmaker.com, Last release on December 2007.

[SyU06] SynthMaker User Guide Version 1, www.synthmaker.com, 2006.

[Tab05a] F. Tabernero, A. Pedrero: Operaciones con Retardos, Lecture Notesfrom Sistemas de Audio I. Departamento de Ingenierıa Audiovisual y Comu-nicaciones, Universidad Politecnica de Madrid. Course 2005-2006.

[Tab05b] F. Tabernero: Procesadores de dinamica, Lecture Notes from Sistemasde Audio I. Departamento de Ingenierıa Audiovisual y Comunicaciones, Uni-versidad Politecnica de Madrid. Course 2005-2006.

[Vij99] E. Vijay, K. Madisetti, D. B. Williams: Digital Signal Processing Hand-book, CRC Press LLC, Boca Raton, 1999.

[ZF90] E. Zwicker and H. Fastl: Psychoacoustics: Facts and Models, Springer-Verlag, Berlin, Germany, 1990.

[Zol95] U. Zolzer, T. Boltze: Parametric Digital Filter Structures, Presented atthe 99th AES Convention, New York, October 6-9, 1995.

[Zol99] U. Zolzer: Digital Audio Signal Processing, England, December 1999.

[Zol05] U. Zolzer et al.: DAFX - Digital Audio Effects, John Wiley & Sons Ltd.,England, December 2005.

175

Page 190: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

176

Page 191: Multi-E ect Processor for Acoustic Guitaracoustics.aau.dk/~mbi/E2008_intro7/sites/dirs/Kurser/POPBL/P1... · Aalborg University, Department of Electronic Systems, Section Acoustics

CD Content

The enclosed CD-ROM contains the following files and folders:

� nListening Testn. . . : Listening test survey paper and sound samples.

� nMatlab Coden. . . : Matlab files of the function of all the effect and themain script of the processor.

� nPresetsn. . . : Sound samples processed with the presets values.

� nRecord Sessionn. . . : Sound samples recorded to test the multi-effect pro-cessor.

� nSynthMakern. . . : SynthMaker Standalone application and VST of thevirtual processor.

� this report as a pdf-file.

177