Tesi di Diploma Accademico di 1° livello in TECNICO DI SALA DI REGISTRAZIONE Digital modeling of a bucket-brigade device chorus: the chorus ensemble section of the Vermona Piano Strings Diplomando: Moro Giulio Matricola: 00137 Relatore: M° Bernardini Nicola This work is made available under the terms of the Creative Commons Attribution-ShareAlike 3.0 license. http://creativecommons.org/licenses/by-sa/3.0/ Table of Contents Acknowledgments............................................................................................................7 1- Introduction.........................................................................................................................8 1.1 Abstract........................................................................................................................8 1.2 Objectives of the present work....................................................................................8 1.3 Modeling of analog musical instruments....................................................................9 1.3.1 Approaches.........................................................................................................11 1.3.1.1 Sampling....................................................................................................11 1.3.1.2 Structured sampling...................................................................................13 1.3.1.3 Spectral models..........................................................................................14 1.3.1.4 Virtual analog.............................................................................................14 1.3.2 Virtual analog signal processing........................................................................16 1.3.2.1 Fields of application...................................................................................17 1.3.2.2 Techniques used.........................................................................................18 1.4 Modeling of bucket-brigade devices.........................................................................20 1.4.1 The BBD model.................................................................................................20 1.4.1.1 Anti-aliasing and reconstruction filters......................................................21 1.4.1.2 The delay line.............................................................................................21 1.4.1.3 Frequency-dependent insertion gain..........................................................22 1.4.1.4 Noise..........................................................................................................22 1.4.1.5 Harmonic distortion...................................................................................23 1.4.2 Implementations................................................................................................23 1.4.3 Open points........................................................................................................24 1.5 Principle of operation................................................................................................25 1.6 BBD circuit topology................................................................................................27 2- Overview of the Vermona Piano Strings...........................................................................28 2.1 Block Diagram...........................................................................................................29 2.2 Tone generator...........................................................................................................30 2.3 Keying circuit............................................................................................................32 3 2.4 Piano section..............................................................................................................33 2.4.1 Envelope............................................................................................................33 2.4.2 Three band equalizer..........................................................................................34 2.4.3 Presets................................................................................................................35 2.5 Strings section...........................................................................................................35 2.5.1 Envelope............................................................................................................35 2.5.2 Three band equalizer..........................................................................................36 2.5.3 Presets................................................................................................................36 2.6 The chorus section.....................................................................................................37 2.6.1 The ST1 board...................................................................................................37 2.6.1.1 The BBD....................................................................................................37 2.6.1.2 The clock circuit.........................................................................................38 2.6.1.3 The anti-aliasing filter................................................................................39 2.6.1.4 The reconstruction filter.............................................................................40 2.6.2 Modulation.........................................................................................................42 3- Data acquisition and analysis............................................................................................44 3.1 The Fast Fourier Transform.......................................................................................44 3.1.1 Windowing.........................................................................................................45 3.1.2 FFT size.............................................................................................................46 3.1.3 Overlapping.......................................................................................................46 3.1.4 Spectrum scattering...........................................................................................46 3.2 Computations on the spectrum..................................................................................47 3.2.1 Estimate power and amplitude of a peak...........................................................47 3.2.2 Signal to Noise Ratio (SNR)..............................................................................48 3.2.3 Power Spectral Density (PSD)...........................................................................49 3.2.4 Total Harmonic Distortion (THD) ....................................................................50 3.3 Measurement setup....................................................................................................51 3.3.1 Modifications to the ST1 board.........................................................................51 3.3.2 Equipment and connections...............................................................................53 3.3.3 Calibration.........................................................................................................55 4 3.4 Measurements............................................................................................................56 3.4.1 Background noise..............................................................................................56 3.4.2 Frequency response...........................................................................................58 3.4.3 Harmonic distortion...........................................................................................62 3.4.4 Frequency response of the reconstruction filter.................................................64 3.4.5 Control voltages and LFO.................................................................................65 3.4.5.1 CV-frequency relation................................................................................66 3.4.5.2 LFO waveforms.........................................................................................66 4- The digital model..............................................................................................................68 4.1 Overview...................................................................................................................68 4.2 Bandlimited interpolation..........................................................................................68 4.2.1 The implementation of the “digital DAC/ADC”...............................................73 4.3 The resample software...............................................................................................75 4.3.1 The time register................................................................................................76 4.3.1.1 Bitwise operators........................................................................................77 4.3.1.2 Use of bitwise operators in resample.........................................................78 4.3.2 The filter table....................................................................................................80 4.4 The BBDresample software.......................................................................................82 4.4.1 The BBD buffer.................................................................................................83 4.4.2 Using circular buffers........................................................................................85 4.4.3 The signal flow..................................................................................................86 4.4.4 Aliasing .............................................................................................................87 4.4.4.1 Non-bandlimited input signal.....................................................................88 4.4.4.2 Spectral periodicization at the BBD output...............................................88 4.4.4.3 Harmonic distortion inside the BBD..........................................................88 4.4.4.4 Aliasing in the model.................................................................................89 4.4.5 The delay line.....................................................................................................89 4.4.6 Choosing proper bandlimited interpolation filter..............................................96 4.4.7 The filters...........................................................................................................97 4.4.8 The waveshaper.................................................................................................99 5 4.4.9 Noise................................................................................................................101 4.4.10 The onboard LFO...........................................................................................102 4.5 Modeling the characteristics of the Vermona Piano String chorus in BBDresample ........................................................................................................................................104 4.5.1 General parameters..........................................................................................104 4.5.2 Parameters of the filters of the ST1 board......................................................104 4.5.2.1 The anti-aliasing filter..............................................................................105 4.5.2.2 The reconstruction filter...........................................................................107 4.5.3 Parameters of the TDA1022............................................................................109 4.5.3.1 Noise .......................................................................................................109 4.5.3.2 Frequency-dependent insertion gain........................................................109 4.5.3.3 Harmonic distortion.................................................................................110 4.5.3.4 Presets......................................................................................................112 4.6 Comparing the modeled and physical devices........................................................113 4.6.1 Harmonic-distortion.........................................................................................114 4.6.2 Aliasing............................................................................................................114 4.6.3 Modulation.......................................................................................................115 5Conclusions.......................................................................................................................116 5.1 Future work..............................................................................................................118 Appendix A – Octave code..................................................................................................120 thd.m.............................................................................................................................120 retrieving_filter_coeff.m...............................................................................................124 cawa.m .........................................................................................................................125 Appendix B – C code..........................................................................................................127 Appendix C – Tables...........................................................................................................130 Appendix D - Illustrations...................................................................................................132 Figure index........................................................................................................................151 Illustration index.................................................................................................................152 Bibliography........................................................................................................................154 6 Acknowledgments A work like the one described in this thesis is authored by one person (me) but it makes considerable use of many contributions. Among these, I would like to thank Prof. Julius Orion Smith III and Colin Raffel for their paper on bucket-brigade devices [1], quoted countless times throughout this thesis, and in particular Prof. Smith for kindly replying to several emails of mine asking details and in-depth explanations. The tutoring of Prof. Matteo Costa in these last years has been very precious for the analog analysis part of this paper, while I'd like to thank my supervisor Prof.Nicola Bernardini for bearing with me during all this enduring time. 7 1- 1.1 INTRODUCTION Abstract This work analyzes the characteristics of an analog chorus device based on the TDA1022 bucket-brigade device and suggests a digital model of it. The chorus device examined is the one that can be found in the Vermona Piano Strings which uses three identical boards equipped with one TDA1022 integrated circuit. The outputs of the boards can be mixed in different ways according to eight fixed presets. The clock of each board is modulated by a low frequency oscillator. Analysis of these presets are performed and modeled as well. 1.2 Objectives of the present work The aim of the present work is that of producing a software implementation of the model proposed by Raffel and Smith in the paper “Practical modeling of bucket-brigade circuits”([1]) applied to the modeling of BBD-based chorus circuits as those found in the Vermona Piano Strings. The implementation must be both flexible and efficient, so 8 that it can easily be adapted to other similar devices and it must be able to perform realtime computations. A different implementation of the delay line than those currently available must be developed. This new implementation must allow any ratio between the system sampling rate and the clock of the BBD, must provide LFO modulation capability and must use an higher quality interpolation method. Measurements must be taken of the performances of the physical device and their results must be used to refine the model. Analysis of the measurements and retrieving of the parameters of the TDA1022 are performed via GNU Octave scripts which are made available to the reader in order to let him analyze similar devices and simulate them in the provided software . 1.3 Modeling of analog musical instruments The process of digitization of electronic instruments is rapidly developing in many forms and for many different purposes. As reported by Välimäki et al in [22], this need arises primarily from the inevitable aging of analog components and circuits, which sooner or later come to a day when they are no longer serviceable and must be replaced by their virtual counterpart. “This development follows, after a long delay, the development of digital audio recording equipment and digital storage systems […], the new fully digital studios and the use of PCs in music production aroused the dream of replacing musical instruments and all other musical devices with software. In addition to 9 achieving a fully digital system, it was desired to reduce the number of connections, error sources, and physical devices, which can be large, expensive, and laborious to maintain. Typical examples of today's virtual music technology are guitar amplifier models, virtual analog synthesizers and filters, and virtual musical instruments, such as digital pianos.” [22] An entirely different reason from which arises the need for digitization and modeling of electrophones (as named by C. Sachs in [2]), or rather – to be more specific – electronic, electroacustic and electromechanical musical instruments, is that of “active preservation” of the equipment used in electroacustic music production. In spite of his relatively short story, electroacustic instruments have a number of characteristics that make their preservation difficult. Electronic and computerized means of music production allowed musical composers of the second half of the XX century to compose by sounds and not only notes. The fast evolution in analogue and digital electronic equipment, caused by rapid advances in electronics and by the large demand of the consumer market, led the electrophones to a fast obsolescence. Furthermore, many custom-made – or custom-modified – devices have been used in the compositions and performances of both electroacustic and popular music. Actually, it was not unusual for a composer – especially for the pioneers of electroacustic music – to work side-by-side with a technician who would help him in interfacing with these new means of expression and would build new equipment – when needed – or modify the existing devices in order to suit specific needs, as for the work of Henri Pousser with Antonio Lietti at Studio di Fonologia in Milan [3]. While passive preservation consists in devices from external agents without 10 preserving the physical altering the electronic components, active preservation is defined by Avanzini and Canazza in [3] as the set of actions aimed at keeping alive a musical composition, by transferring the recordings and the instruments into the digital domain, thus allowing performance and functionality both for musicological research and for philological analysis. Of course, digital modeling of the analog devices is expected to play a major role in this field, and some case studies are reported in [3]. 1.3.1 Approaches In the process of digitization of an electronic musical instrument or of an audio effect processor, one of these approaches is usually taken, as outlined by Smith in [4]: • sampling • structured sampling • spectral models • virtual analog 1.3.1.1 Sampling The simplest way of reproducing the sound of an instrument is recording it and then reproducing it. This approach has been taken since the end of the 1960's with the first magnetic-tape samplers, the most notable of which was the Mellotron, and later on, since the mid 70's, by digital samplers. During the 1980s hybrid synthesizers began to use short samples (such as the attack phase of an instrument) along with digital synthesis to create more realistic imitations of instruments than 11 had previously been possible. Limiting factors at the time were the cost of physical memory (RAM) and the limitations of external data storage devices, and this approach made best use of the tiny amount of memory available to the design engineers. Akai pioneered many processing techniques, such as crossfade, looping and "time stretch" to shorten or lengthen samples without affecting pitch and vice versa. The sounds played by the first samplers could not even aim at being defined “realistic”: the quality of the audio converters and the small memory simply did not allow for it. Nowadays sampling is extensively used in audio production, often combined with sequencing and various audio transforming processes, and it is not uncommon to use sampled sounds of acoustic and electronic instruments even in high-end audio productions. The recording effort needed in the creation of a high-quality fullysampled instrument is enormous: “for each possible input condition (such as a key-press on a keyboard, pedal press, etc.) the sound produced has to be recorded in the desired acoustic space (which itself can be a recording parameter). […] dimensions of expressive performance are invariably limited.” - states Smith in [4], and explains that while impressive highly-accurate results can be obtained for keyboard instruments, provided an enormous amount of samples is recorded, instruments which make use of continuous interaction between the player and the instrument, such as bowed and pluckedstrings, winds and brass cannot be accurately emulated by the exclusive use of sampling, as this would prevent the player from using the multiple continuous dimensions of control which are part of the sound of the instrument (such as vibrato and glissato on a violin) . 12 While sample-based sound synthesis can be frustrating for the performing musician, its best feature is the high quality of the ultimate sound to the listener: the sound quality is limited only by the quality of the original recordings and subsequent signal processing. 1.3.1.2 Structured sampling Structured sampling involves the sampling of some fundamental characteristics of the sound source, such as its impulse response, instead of the generated acoustic pressure wave. A proper choice of the characteristics sampled can offer the desired balance between audio quality and flexibility, and between the memory usage and the computation power needed for synthesis.([4]) For instance, sampling the total impulse response of a bank of n filters placed in series would provide low memory usage (just one impulse-response is sampled) and low computational cost (just one impulse-response has to be applied to the signal), while sampling the impulse-response of each of the filters would require n times memory space and n times computational cost (n impulse-responses are to be applied to the signal), while giving the added flexibility of disabling or altering individual filters. 1.3.1.3 Spectral models Spectral models are inspired by the mechanics of hearing. Typically they are based on the Fourier Transform, but there are also signal models, such as Linear Predictive Coding (LPC) whose success derives from how well they match spectral characteristics of hearing (Smith in [6]). Additionally, Frequency-Modulation (FM) synthesis is typically developed by tweaking FM parameters to match short-term audio 13 spectra. Other well known signal models rooted in the spectral point of view include the phase vocoder, additive synthesis, and so-called spectral modeling synthesis. 1.3.1.4 Virtual analog Physical modeling of an acoustic musical instrument is a process of digital emulation that is based on the recreation of a model of the physical components of the instrument and his parts, such as the vibrating strings of a violin, the wood body of a guitar, the membranes of drums. Virtual analog modeling can be seen as a parallel approach to physical modeling, where what is emulated is not what the listener ear perceives, as in sampling or spectral-model synthesis, but the underlying electronic circuit that generates it. Non-linear and time-varying systems are often involved in both virtual analog and acoustic models. Instruments and equipment subject that have been often modeled include tube amplifiers, loudspeaker cabinets, synthesizers and effect processors. “It is possible” - states Välimäki in [22] - “to imagine a virtual guitar amplifier in which the user could change the device's component values or circuit connections and hear in real time the resulting change in the amplifier's tone.” The Virtual Analog (VA) approach shows some major advantages over the above mentioned methods: • flexibility: once the model of a system is computed, the effect of variations that may occur on its parameters – component values, user adjustable parameters – are easy to compute 14 • scalability: after modeling a block of a circuit, this can be reused in other models that include the same block • interaction: physical models are desirable when many dimensions of expressive control are needed. This is generally best appreciated by performing musicians, as audience members only hear the final music played, and cannot judge the quality of the interaction between the player and the instrument • the internal state is automatically maintained: sample-based models should in principle index each acoustic recording by not only the input state, but also by the internal state of the instrument (which is prohibitive and rarely done). Physical models, in contrast, propagate some kind of simulation of the internal state, so that realistic interactions between the external inputs and the internal state are provided “for free” ([4]) • prediction: a properly-computed model could be used to predict the state of the system outside the ranges it has been designed for. Of course there are also some drawbacks, such as: • they are more computationally expensive than a sample-based system. For this reason simplifications in the model often occur in order to retain real-time performances. • the model must really sound like the instrument or effect it is imitating. In some cases this can be difficult to achieve. Thus it can be difficult to generate exactly the right timbre throughout the control space. For this reason, many expressive sound synthesizers 15 employ both modeling structure and measured data as in structured sampling ( 1.3.1.2) 1.3.2 Virtual analog signal processing Taken from [4]: “The term "Virtual Analog" (VA) is commonly used for describing digital implementations of analog circuitry employed for generation, enhancement or processing of musical sounds. The typical approach to the development of virtual analog algorithms consists of starting with the reference analog circuit and, from there, developing a digital implementation that will mimic the behavior of the analog reference while providing improved flexibility and, perhaps, incorporating additional features; extending its range of applicability; or enhancing its performance.” Despite being a recently-born field of study, VA benefits extensively from the physical modeling and electronic circuit analysis and simulation literature. As computer performances increased, the techniques and algorithms initially intended for simulation purposes could lately be applied to real time sound processing. 1.3.2.1 Fields of application Virtual analog audio signal processing is applied to the emulation of several different musical instruments and sound processing equipment, including, most notably, instrument tube amplifiers and loudspeaker cabinets, analog synthesizers down to their individual components such as filters and oscillators, effect boxes such as overdrive, distortion, chorus, flanger, delay, filter, effect processors such as compressors and 16 spring and plate reverberators, more complex systems such as electromechanical organs and electric pianos and even the challenging percussion, string, wind and brass instruments, which high degree of expressiveness is difficult to replace with a computer simulation. 1.3.2.2 Techniques used Many techniques have been proposed over the years in order to implement virtual analog modeling, most of which are taken from the physical modeling theory. Here are some: • Wave Digital Filter: in [7] nonlinear wave digital network approaches are applied to analog modeling for the purposes of sound synthesis and effects modeling. A Wave Digital Filter (WDF) is a particular kind of digital filter based on physical modeling principles. Unlike most digital filter types, every delay element in a WDF can be interpreted physically as holding the current state of a mass or spring (or capacitor or inductor) [8]. Pakarinen and Karjalainen describe in their paper a wave digital triode model for realtime tube amplifier emulation. • Nonlinear discrete-time state-space model: in [9] a nonlinear discrete-time state-space description is presented which allows real-time modeling of nonlinear analog circuits. A similar effort can be found in [10]. • Volterra series: truncated versions of Volterra series are usually involved in the simulation of weakly nonlinear systems. In [11], Hèlie uses and optimizes them in order to derive a digital simulation of the well-known Moog ladder filter, which has been an essential part of several analog synthesizers . 17 • Nonlinear analog circuits as filter networks : the analysis of a similar device – the VCS-3 ladder filter – is performed with a different approach in [12] by Civolani and Fontana, where a method for digitizing nonlinear analog circuits as filter networks in a manner that preserves the original circuit structure is shown. • Bandlimited synthesis: in [13] Välimäki, Smith and et al. introduce alternative algorithms for generating approximately bandlimited discrete-time versions of classical waveforms, such as the sawtooth waveform. The resulting signals can be used as oscillators in digital subtractive synthesis of musical tones. • Direct physical modeling of electromechanical or acoustic instruments and devices have been undertaken, by addressing spring reverberation in [14], acoustic piano in [15], brass and trombone in [16], bow control in the violin in [17], circular thin shells of spherical geometry in [18], tubular bells in [19], circular membrane percussions in [20] 1.4 Modeling of bucket-brigade devices As for the digital modeling of bucket-brigade devices, the specific topic of this work, few documents are available from literature. A brief review is given in [21]: “Bucket brigade delay lines have been widely used in chorus and delay processors since the 1970s. A sample and hold was used with a network of switched capacitors to delay an input signal according to an externally applied clock. However, as the charge representing the input signal is transferred from one capacitor to the 18 next, a small amount bleeds to adjacent capacitors, and the output acquires a mild lowpass characteristic. In addition, while the charge is propagating through the delay line, it decays to the substrate. In this way, louder signals are distorted.”. This generic definition is not entirely compatible with what proposed by Raffel and Smith in [1], where the “mild lowpass characteristic” is regarded to as caused by the BBD itself only in those applications in which half the clock frequency(the Nyquist limit) is close to or into the audio range (e.g.: echoes and delays), and it is nevertheless often masked by the effect of the drastic anti-aliasing and reconstruction filters accompanying the device. 1.4.1 The BBD model In [1], Colin Raffel and Julius Smith provide a full physical model of Bucket Brigade Devices, with practical guidelines to its implementation. Accessory circuits such as companders and anti-aliasing and reconstruction filters are taken into consideration, as well as the inherent noise, frequency response and harmonic distortion caused by the device itself. A brief review of the topics discussed is reported below, with the exception of companders which generally are not used in chorus devices. 1.4.1.1 Anti-aliasing and reconstruction filters BBD filters often consist of Sallen-Key type circuits in series. Typically a third order filter for anti-aliasing and a third order followed by a second order filter for reconstruction. The transfer functions of the filters are reported and the developer is suggested to compute the transfer 19 function of the series which corresponds to the product of the single transfer functions, and then use a numerical method to retrieve the coefficients of an IIR filter, such as the equation-error method implemented in the function invfreqz in Octave Forge and Matlab. A matlab script for calculating filter coefficients based on filter component values is provided. 1.4.1.2 The delay line Concerning the delay line model, Raffel and Smith write: “The most accurate implementation would involve a software delay line of fixed length matching the number of delay stages in the BBD circuit being modeled. This delay line would take in a new input sample and output a delayed sample at a rate determined by an artificial clock frequency.” As the artificial clock frequency of the BBD, which is time-variable, and the input/output sampling frequency of the system are not necessarily related, some kind of interpolation is needed to ensure that the correct values are read from and written to the delay line. The aliasing effect caused by the discrete time behaviour of the BBD is thus reproduced, as well as the pitch-change effect caused by variations in the clock frequency. 1.4.1.3 Frequency-dependent insertion gain One relatively minimal effect of the constant transfer of charge between thousands of capacitors results in unintentional imperfections. One is a frequency-dependent insertion gain. This gain effectively acts as a low-pass filter with a cutoff frequency determined by the clock rate of the BBD. This effect can be thought of as a result of the BBD’s 20 capacitors not being able to react to changes in the input signal which occur at a frequency close to the Nyquist limit. As a result, the extremity of this filtering varies with the number of clock stages. In general, the insertion gain tends to be between 0 and 2 dB at low frequencies, but falls off slowly to between -4 and -6 dB at the Nyquist limit for any given clock rate. 1.4.1.4 Noise Although one of the purposes of a digital model might be to create a noise-free system, a truly accurate model would involve the insertion of low-amplitude noise immediately before or after the delay line. Furthermore, in devices with a feedback loop, noise can make the device to self oscillate, and thus should be implemented. The appropriate noise level for a specific BBD can be measured or found in the device’s datasheet. 1.4.1.5 Harmonic distortion The unavoidable total harmonic distortion is reported to be about 1% for every 1024 stages of BBD. This distortion is reported to be almost amplitude-independent. Therefore its digital implementation by means of a polynomial waveshaper should require multiple sets of polynomial functions. 1.4.2 Implementations Two implementations of the above described model are currently available. 21 The first is provided by one of the authors of the paper, Colin Raffel, and can be found in [23]. The code provided uses the Synthesis Tool Kit ([24]) library and is a straightforward implementation of the model that uses some simplifications of the model proposed: the delay line uses linear interpolation between samples instead of a more sophisticate resampling interpolator; the waveshaper coefficients are static and not dynamic as proposed in 1.4.1.5. The only effect available from this implementation is the feedback delay. Another implementation is that made by Tristan Bayfield, a student of Simon Fraser University, California, as a final project for a Computational Modelling For Sound Synthesis Course [24]. His job takes the form of an AU plugin and includes two distinct effects: feedback delay and flanging. This implementation is even simpler than that of Raffel as it does not make use of any waveshaping function, while using linear interpolation as well. The source code reported in [24] does not show the LFO modulator reported in Bayfield's accompanying description. 1.4.3 Open points Both implementations proposed in 1.4.2 are limited by the fact that the clock of the BBD must be lower than the sampling rate of the system, and the use of linear interpolation. As a direct consequence of the fact that the implemented delay line must have a lower sampling rate than the system and that the output is not resampled back to system sample rate, the very same sample may be output multiple times in a row. Moreover neither of the two provides a mean of modulating the clock frequency of the BBD. 22 The first issue is not necessarily to be concerned about when working with delay and echo devices, as the clock frequency of BBD-based delays is often lower than the sampling rates typically used in digital audio processing. On the other hand, flanger and chorus devices, as the ones addressed in the present document, often use higher clocks – up to 100KHz, and therefore this implementation cannot be fitted to these devices. A more satisfactory model of the delay line must be found which is free by these constraints. On the other hand, linear interpolation is depicted by Crochiere and Rabiner in ([26], 4.3.11) as “non useful in the interpolation of signals which are not highly bandlimited, because of the high side-lobes of the linear interpolator function”, but its use is nevertheless widespread because of its simplicity, low computational cost and the small number of samples involved in the interpolation (just two). Hence, addressing a Figure 1 A antiphase-clock Bucket-Brigade circuit (TDA1022) 23 new implementation of the model, a higher-quality interpolator should be used in order to achieve better sonic results. Moreover, both of the implementations are devoted to the modeling of delay devices, while choruses and flangers have different characteristics, such as higher clock rates, lower harmonic distortion, different filters and clock modulation. A basic implementation of such a device would fill this lack allowing for further expansions of the model proposed by Raffel and Smith in [1]. 1.5 Principle of operation The bucket-brigade device is an analog IC that realizes a time delay, it was invented in 1968 by Sangster at Philips. By that time digital delay devices performing the same tasks had already been conceived, but BBD's remained a cheaper and widely used alternative until the 1980's. Their name derives by the fact that they contain many charge-holding elements which receive their charge by the previous and pass it on to the following similarly to people passing buckets of water when fighting a fire. The principle of operation is well described in [1]: “The input signal is sampled in time and passed into a series of typically thousands of capacitors and MOS transistor switches. The charge in each capacitor stage is passed into the subsequent stage at a rate determined by an external clock signal. […] schemes using two out-of-phase clock signals developed by Sangster and Reticon Corporation allowed the device to be used practically in audio systems.” This topology is shown in Figure 1. Thanks to these improvements, the BBD effectively functions as a time24 delay system that falls into the uncommon category of discrete-time, but non-digital circuitry. The clock signal that controls the charge transfer between capacitors sets the sampling frequency of the system and the delay time of the device. The total delay time is thus: t= 1.6 number of stages 2f (1) BBD circuit topology Illustration XVIII reports the topology of a typical chorus/flanger BBDbased device. As aliasing is a characteristic that the BBD shares with purely digital devices, the input stage is preceded by an anti-aliasing filter, and the output is followed by a reconstruction filter. The clock frequency is modulated by a low frequency oscillator. If the clock frequency at acquisition time differs from that at output time, an effect of pitch-shifting is obtained, which is the principle at the base of the chorus and flanger effects. If the difference in the clock frequencies is so small that no audible pitch-shifting effect is perceived, a phaser effect is obtained instead. 25 2 - OVERVIEW OF THE VERMONA PIANO STRINGS The Vermona Piano Strings is an analogue keyboard instrument produced by DDR company Vermona during the late seventies. It is a 61keys (F to F) polyphonic synthesizer aimed at reproducing piano and strings sounds. The sound produced is very far from being a faithful reproduction of the acoustic instruments, but it rather focuses on a couple of the most significant features of the real sound and mimics them by means of electronics. In this instrument the piano sound is characterized by a percussive note with a short decay time which stops playing as the key is released. It is possible to let the note sustain after the key is released by pressing the sustain pedal while the key is held down. On the other hand the strings sound does not stop immediately as the key is released but it rather sustains and fades out gently. The sounds are processed through a chorus section. There are eight presets available, four are for “piano” sounds and four for “strings” sounds. Only one of the presets can be activated at a time. The four presets of each section correspond to different settings of the chorus section. A three band equalizer is provided for each section, as well as a global output volume. A slider labeled “sustain” acts as decay control for pianos and as release control for strings. By connecting a sustain pedal (a normally closed monostable switch) to the proper 26 connector, the sound of the piano notes slowly decays after the key has been released, thus adding “release” to the envelope of the notes. A “sustain long” switch on the front panel of the machine accomplishes the same result. All of the circuit schemes of this chapter have been taken from the Vermona Piano Strings schematic diagrams[27] except for Figure 2 and Figure 11. 2.1 Block Diagram Figure 2: Block diagram of the Vermona Piano Strings 27 Like most other strings machines of the time (such as Eminent-Arp Solina, Eko Stradivarius, Crumar Performer, Roland RS-202, Logan String Ensemble and many others), the basic block structure is derived from the “classic” electronic organ block structure (consisting of a master oscillator, a top-octave generator and dividers), whereas the added keying circuitry provides attack/sustain facilities and three identical BBDbased boards along with an LFO modulator form the chorus ensemble section. 2.2 Tone generator Figure 3 The master clock and top octave generator circuit The master oscillator (consisting of L1, T1,T2 and associated components) outputs a “smoothed” pulse wave at a clock rate of about 700KHz. 28 Figure 4 The top-octave generator output waveform. Figure 5 The master oscillator output waveform. The top-octave generator (IS1 MM5555 and IS2 MM5556) takes the output of the master oscillator and outputs twelve square waves – one for each note of the tempered chromatic scale – whose frequencies are then divided several times (7 times for the F's and 6 times for the other tones) by IS3...11 U112D (7-stage binary frequency divider) . The output waveform of the dividers is a square wave. 29 2.3 Keying circuit The square wave tones generated by the frequency dividers are then routed to the keying circuits. The keying circuit of each key is fed with the fundamental note and one or two upper harmonics, passively mixed in 1:1:1 proportion (mixing resistors are R1-R45). The notes of the highest octave have only one upper harmonic, while the others have two. Waveforms resulting from these sums are reported in Figure 7 and Figure 8. A BJT NPN transistor in a common-base configuration amplifies the blend of waveforms according to the voltage across a capacitor(C1-C16), Figure 6: Keying circuit, oscillator mixer and envelope generators 30 and feds its output to a common bus through a resistor(R46-R61) which value depends on the octave of the key. From lower to higher octave, resistor values are: 560k, 390k, 270k, 180k, 120k. The gain of the subsequent octave with respect to the first can be calculated as 20*log(Ri/560k), and is respectively: 0dB, 3.6dB, 6.8dB, 10.3dB, 13.8dB. Figure 8: The waveform resulting Figure 7 The waveform resulting from the sum of the fundamental square from the sum of the fundamental square wave and his second harmonic. wave and two of its harmonics. 2.4 Piano section 2.4.1 Envelope A sustain pedal can be connected to the Piano Strings. It must contain a monostable normally closed SPST switch. It is wired in series with the “sustain long” switch, and thus can be used to switch to “sustain long” mode while playing, acting in a way similar to that of a traditional piano sustain pedal. 31 2.4.2 The piano Three band equalizer section features three controls labeled “spinet”, “clavichord”, “piano”. In spite of the labels, these are not register controls, but are rather the level control of three different filters. The “spinet” is a passive 6dB/oct high pass filter, the “clavichord” is just an attenuator, and the “piano” is an active resonant filter. Figure 9 Three band equalizer for the piano section 32 2.4.3 Presets "direct": no chorus is applied to the signal. "slow": only the slow sinewave is used as CV for the chorus. Only the output of the first stage is used and mixed at a 1:1 rate with the "direct" signal. "chor1": only the slow sinewave is used as CV for the chorus, though this time all of the three stages are used, and their outputs are mixed together a a 1:1:1 rate. "chor2": the CV waveform is the sum of the slow and fast sinewaves, all three stages are used and their outputs are mixed together at a 1:1:1 rate. 2.5 2.5.1 Strings section Envelope The envelope of the strings sound consists of on Attack-Release envelope which has a slow attack time and a long release time. The “sustain long” switch has no effect on this envelope. 33 2.5.2 Three band equalizer The strings section features three controls labeled “cello”, “viola”, “violine”, which are the controls for a three-band 6dB/octave passive equalizer. The “cello” is a low pass, while the “viola” and “violine” are high pass. Figure 10 Three-band equalizer for the strings section 2.5.3 Presets "direct": no chorus is applied to the signal. "fast": the CV waveform is built up of the fast sinewave and a DC bias. Only the output of the first stage is used and mixed at a 1:1 rate with the "direct" signal(the schematics read "vibrato" for this preset, though it is in fact a chorus). "chor1": only the slow sinewave is used as CV for the chorus, though this time all of the three stages are used, and their outputs are mixed together a a 1:1:1 rate. 34 "chor2": the CV waveform is the sum of the slow and fast sinewaves, all three stages are used and their outputs are mixed together at a 1:1:1 rate. 2.6 The chorus section The chorus section consists of three ST1 boards and a modulation section. The ST1 board contains the TDA1022 BBD, anti-aliasing and reconstruction filters and a clock generator circuit; it has an input for the audio signal, an input for the modulation signal and an audio output. The modulator consists of two LFO's running at different frequencies. Both of them are three-phases sinusoidal oscillators and therefore have three outputs each, providing access to different phases of the same wave. The routing of the modulation signals to the ST1 boards and the mixing of the outputs of the latter is controlled by the presets buttons, as explained in the presets sections above. 2.6.1 2.6.1.1 The ST1 board The BBD Whereas the schematics call for a TCA350Y as the BBD device for the chorus section, the actual specimen in exam have a TDA1022 that replaces it. Other specimens are known to use the same IC. The two were probably similar IC's which could be easily swapped at the factory seconding availability. While the TCA350Y is a 8-pin DIL IC, the TDA1022 has 16 pins, 8 of which are not connected. The TDA1022 is therefore 35 mounted on a small adapter board which provides pinout matching and two additional resistors. The circuit on the board has been reverseengineered and its circuit diagram is shown in Figure 11. Figure 11 schematics of the adapter board that matches the TDA1022 to the pinout of the TCA350Y 2.6.1.2 The clock circuit The clock circuit is an astable multivibrator built around transistors T2 and T3 and capacitors C4 and C5. Control of clock frequency via CV is provided by T1, and R5 is an onboard trimmer that controls the maximum amount of modulation that can come from T1. Oscillation frequency of this circuit – without any external CV applied – is about 100KHz. 36 Figure 12 Schematics of the ST1 board 2.6.1.3 The anti-aliasing filter The anti-aliasing filter simply consists of a first order passive RC high pass filter consisting of R2 and C7. The cutoff frequency is ([28], VII-95) f cAA= 1 = 2 RC 2 1 =10.261KHz R2 C t (2) and the filter has a slope of 6dB/Octave In this board the clock frequency of the BBD is approximately f =65000Hz , thus the Nyquist frequency of is f N =f /2=32250Hz . If the signal present at the input of the BBD should have some spectral components in the range 45000Hz - 85000Hz , these would be aliased in 37 in the audio band for the Shannon-Nyquist theorem. The attenuation of this filter at 45KHz – which is about 2 octaves above f cAA – is 12dB. 2.6.1.4 The reconstruction filter The reconstruction filter consists of two low pass second-order SallenKey active filters in series. They are followed by a passive high-pass filter (C13 and R23) which has a nominal cutoff of F cH = 1 =33.9 Hz 2 R 23 C 13 (3) Figure 13 Typical second-order Sallen-Key filter The circuit diagram of a generic Sallen-Key low pass filter is shown in Figure 13. The transfer function is ([28] VII-162): Vo s 1 = 2 2 Vi s s R C 1 C 2 2 RC 2 1 (4) The transfer function of the two filters in series is given by the product of the individual transfer functions. Being C1 and C2 the 38 capacitors in the first filter and C3 and C4 the respective capacitors in the second filter, the transfer function of the series of the two is: 4 4 3 3 s R C 1 C 2 C 3 C 4 2 s R C2 C 4 C1 C3 1 s R 2 C 1 C 2 4 C 2 C 4 C3 C 4 2 2 s R C2 C4 1 (5) The transfer function of each of the filters and of the series has been computed on the basis of the values of the capacitors and resistance of the ST-1 board and they are all plotted in Illustration I. The first has nominal cutoff Fc1 and quality factor Q1 ([28] VII-162) F c1= 1 2 1 =8598.2 Hz R14 R 15 C 8 C9 1 C9 =3.4 Q 1= 2 C8 (6) , while the second has a nominal cutoff Fc2 and a quality factor Q2 of Fc2= 1 2 1 =4733.2 Hz R18 R19 C 10 C 11 1 C10 =1.3 Q 2= 2 C 11 (7) The transfer function of the series has a wide resonant band comprised between 1KHz and 9KHz, and a -3dB cutoff at about 10KHz. The theoretical slope of each of the filters is 12dB/oct, while that of the series is 24dB/oct. These values are not immediately visible off the graph, as they are reached only higher in the frequency range. The 39 highpass is a first order passive, and with its 38Hz cutoff and a slope of 6dB/oct does not influence much the total transfer function . Figure 14 Schematics of the two modulation sources 2.6.2 Modulation The piano strings features two Low Frequency Oscillator (LFO) which generate sinewave Control Voltages(CV's) that are used to drive the chorus stages (Figure 14). The faster has a nominal frequency of about 6Hz, while the slower has a nominal frequency of about 0.6Hz. The LFO's are built as three phase oscillators, providing three outputs each with a 40 different phase of the same waveform: 0°, 120°, 240°. The topology is the same in the two oscillators and they differ almost only for the values of the timing capacitors and for the output resistors. The waveforms as reported in the original schematics diagram are shown here in Figure 15 . Figure 15 waveforms of the slow(left) and fast(right) LFO 41 3DATA ANALYSIS 3.1 ACQUISITION AND The Fast Fourier Transform The Fast Fourier Transform (FFT) is an algorithm to compute the Discrete Fourier Transform(DFT) and its inverse. The DFT is a function that transforms a digital signal from the time domain to the frequency domain. The result of an FFT is an ordered set of complex values which are the respective coefficients of a set of sinusoids ranging from 0 to Fs f spaced in frequency by f =F s / N where N is the number of points of the time-domain signal on which the transform is computed. This representation is often referred to as the spectrum of the signal. Given a complex number k =a bi where a is the real part, i is the imaginary unit i= 1 and b is the imaginary part, the magnitude of k is defined as magnitude k = a2 b 2 and the phase of k is =arctan b / a . Similarly, the magnitude spectrum and the phase spectrum can be obtained by computing the magnitude and phase of the values of the complex spectrum. Most of the analysis performed here involve the use of Fast Fourier Transform including noise, frequency response, harmonic distortion. Proper windowing, slicing and overlapping have to be used for each analysis type. Here's a brief explanation of each of these techniques, which is a review of the detailed descriptions found in [29]. 42 3.1.1 Windowing Windowing techniques help to reduce spectral leakage in FFT analysis. Spectral leakage is the result of an assumption in the FFT algorithm that the time record is exactly repeated throughout all time and that signals contained in a time record are thus periodic at intervals that correspond to the length of the time record. If the time record has a nonintegral number of cycles, this assumption is violated and spectral leakage occurs. A window is a properly designed function which is usually normalized to an amplitude of 1 and has an x-axis scaled in such a way that its values at x=0 and x=FFTsize are 0. For an example see the plot of a Hann function in Illustration II. The function is multiplied by the analyzed samples before computing the FFT. Each window has its own characteristics and effects and very often one that is well suited for a task would not perform well in a different task, and vice versa. The windowing of the input data is equivalent to convolving the spectrum of the original signal with the spectrum of the window. Windowing functions by can thus be schematically characterized some characteristics of their own spectrum. Hann function is often referred to as the “universal window” for it has a rather narrow main lobe, and a rather low maximum side lobe level, along with a high side-lobe roll-off. This translates into good frequency resolution and low spectral leakage. Flat top window is less good at frequency resolutions, as the main lobe is quite large but features a very good amplitude accuracy, which could be useful in precision-critical amplitude measurements. Uniform or rectangular windows may be useful for broadband random signals, as in noise analysis. 43 3.1.2 FFT size FFT size is the number of samples used for computing an FFT. It influences the frequency resolution, as the size of each frequency bin of an FFT of length N is : f bin=F s / N where Fs is the sampling rate. Choosing larger N allows for better frequency resolution but needs more samples, thus limiting time resolutions. The analyses performed in the present work do not need narrow time resolutions, as no transients are present among test tones, so FFT size can be as large as needed for frequency resolution. 3.1.3 Overlapping Overlapping is a technique that performs multiple FFT analyses where each sample is used in general by more than one analysis. The signal is sliced into sets of contiguous samples that partially overlap. This allows , for a given FFT size, to get more FFT's out of a given number of samples, making available more spectra for averaging, thus reducing the noise variance as described above. By averaging the overlapped spectra, the amplitude of the averaged spectrum must be rescaled of a proper factor in order to maintain unitary gain. 3.1.4 Spectrum scattering One problem of looking at noise with an FFT is that the obtained spectrum is inherently noisy. In fact,due to Parseval's theorem, the variance 2 n of the spectrum is simply the variance of the noise, or, in 44 2 other words n = x n2 . In a scattered plot the outer edges extend to approximately to 3 n which means that the upper visual edge of a noise spectrum is always at xn 3 2 n = 4xn 2 (8) which is 6dB above the expected value in the power spectrum. By averaging multiple spectra it is possible to reduce the variance , in particular by averaging na spectra, n reduces to n / na . The averaging of multiple smaller-sized FFT is thus preferable over a single longer one, especially for noise or noisy measurements. [36] 3.2 3.2.1 Computations on the spectrum Estimate power and amplitude of a peak Because of the window spreading effect and/or the fact that the analyzed frequency may not be centered in the analysis bin, the total power at a given frequency is spread in the spectrum over more than one bin. The amount of this spreading is proportional to the main lobe width of the window. To get an estimate of the power at a certain frequency, the powers of the surrounding bins must be summed and divided by the noise power bandwidth of the window. For a given bin j where a peak in the spectrum is detected, the estimated power and amplitude of the peak are: 45 j 3 Power i Estimated power= j 3 (9) noise power bandwidth of the window j 3 Amplitude i Estimated amplitude= The span j 3 (10) noise power bandwidth of the window ±3 is reasonable because is greater than the main lobe width of most windows, but can be adjusted for less or more depending on the noise of the spectrum and the separation between adjacent peaks. For frequencies centered in a bin, the span could be lower. This method performs correctly only for spectra made up of discrete frequencies components, it is not valid for a continuous spectrum, a noise spectrum or a spectrum where the peaks are closer to each other less than 2 times the span, as they would influence each others' power. 3.2.2 Signal to Noise Ratio (SNR) When plotting the spectrum of a signal some peaks will emerge which are generated by the signal itself and there will be a noise floor at lower amplitude. This noise floor will often be many dB's below the rated signal to noise ratio (SNR) of the system. This is because the SNR is an indication of the total noise power, which is spread all over the spectrum. Furthermore, the represented amplitude will vary depending on the number of points of the FFT. This happens because what is represented in the noise floor of a power spectrum is the narrowband noise level in each FFT bin. Therefore the noise floor of a N-length FFT 46 f =F s /N . In other words, the noise level power spectrum depends on at each frequency line reads as if it were measured through a f Hz filter centered at that frequency line. Consequently, for a given sampling rate, doubling the number of points acquired reduces the noise power that appears in each bin by 3 dB. Discrete frequency components theoretically have zero bandwidth and therefore do not scale with the number of points or frequency range of the FFT. To compute the signal to noise ratio of a spectrum, a sum must be performed of all the power spectrum bins excluding DC and any peaks, and this will result in a number close to the system's rating. What is important here is that peaks can be measured well below the SNR level. For a noise spectrum without peaks, SNR (in dB) can be computed as N /2 1 SNR=10 log10 (11) 1/ Power i i=1 3.2.3 Because Power Spectral Density (PSD) of noise-level scaling with f , spectra for noise measurement are often displayed in a normalized format called power or amplitude spectral density. This normalizes the power or amplitude spectrum to the spectrum that would be measured by a 1 Hz-wide square filter, a convention for noise-level measurements. The level at each frequency line then reads as if it were measured through a 1 Hz filter centered at that frequency line. Power spectral density is computed as PSD= Power spectrum f ×Noise Power Bandwidthof the window 47 (12) The spectral density format is appropriate for random, chirp or noise signals but inappropriate for discrete frequency components because the latter theoretically have zero bandwidth and do not rescale well this way. 3.2.4 Total Harmonic Distortion (THD) A non-linear system fed with a sinusoidal signal shows at the output a distorted signal that is not purely sinusoidal: it contains harmonics that were not present in the input signal. This is called non-linearity distortion or harmonic distortion. Two conflicting definition of total harmonic distortion exist. One, which is power-based, says that THD is the ratio between the sum of the harmonics powers(excluding the fundamental) and the power of the fundamental; the other is instead amplitude-based, and says that the THD is the ratio between the sum of the rms amplitude values of the harmonics(excluding the fundamental) and the rms value of the fundamental. The latter definition is the more often used in audio and electronics measurements, and best fits the measurement reported in the TDA1022 datasheet, where the formula used for the measurement of THD is not specified. So this definition is the one that will be adopted in the rest of this work. The percentage THD relative to the first n harmonics is thus ([28], XVII.10.22): i=n V 2i thd % =100 i=2 V1 48 (13) 3.3 3.3.1 Measurement setup Modifications to the ST1 board For the tests, the BBD board was pulled off the Vermona and put in a custom made aluminium case. Inputs and outputs were provided by panel-mount 1/4” jack sockets, some of which provided with an internal switch used to open the circuit at chosen test points and normalize some inputs to ground. A panel-mount potentiometer provided fine tuning of the BBD clock. A through-hole pin was mounted on the case to give the oscilloscope probe access to the clock oscillator. The panel controls and connections include: • DC power in – coaxial socket 5.5x2.1mm • AC-coupled input to BBD, normalized to ground – jack socket • BBD output – jack socket • DC-coupled input to BBD – jack socket – this acts also as a direct output • reconstruction filter input, normalized to BBD output – jack socket • clock potentiometer • CV in, normalized to ground – jack socket • reconstruction filter in – jack socket • reconstruction filter out – jack socket • clock out – metal pin 49 On the board itself a bunch of modifications were made: • an external stabilized linear power supply of 14.2V DC was used to power on the device • C101, a 100uF electrolytic capacitor, was placed across power supply rails and, along with C3 helps to stabilize the power supply • to provide correct biasing of 5.6V to the BBD input, a passive voltage divider network made of a 22k and a 33k resistor was added • C102, a coupling 47uF solid tantalum electrolytic capacitor was placed in series with the BBD input • R2 and C7 which constituted the anti-aliasing filter were removed • the anti-aliasing filter was replaced by C103, a 820pF ceramic disc capacitor, was placed from the BBD input to ground, thus forming with the divider network resistors a passive low pass filter with cutoff aliasing f c= 1 =14704Hz which acts as a smooth anti2 C R101 R102 filter for the BBD, which F =100KHz and a Nyquist frequency has a clock frequency F n=F / 2=50KHz of 50KHz. The decision to use a first order low pass with a rather high cutoff is that the signal is already bandlimited by the soundcard and that F is far above the audio range. This is mostly for filtering out RF interferences, which would be possibly aliased into audio band. • VR1, a 10k linear potentiometer was connected across Gnd and Vcc. Its wiper was wired to the CV input of the clock oscillator. This is used for regulating the clock frequency F by the insertion of a jack into the CVin input 50 , and is deactivated In the first place the sleeve connections of the output jacks were automatically switched so that only one of the sleeves of the inputs/outputs jacks at a time was connected to ground. This was intended to avoid ground loops and get a cleaner recording. After connections were made, it was discovered that providing grounding to all of the cable shields gave less noise and better overall results, so the original device was updated this way. Laboratory ground loops were also avoided, so that the only the oscilloscope was connected to electric earth. 3.3.2 Equipment and connections Hardware used for the measurements included a Beckman Industrial 9012 – 20MHz dual analog oscilloscope, a total of two Yamaha i88x firewire soundcards and two computers. The oscilloscope was used to check and tune clock frequency. The clock runs in the range of 100KHz, and consists of square waves, so no soundcard could have been used in place of this. Each of the Yamaha's features on channel one a high impedance input. These are the only inputs used; one is used for recording the reference signal, and one for the processed signal. From now onwards they will be referred to respectively as input1 or reference input and input 2 or processed input. Only one output of one of the soundcards is used to output test signals. The two i88x's use Yamaha proprietary bus mLan which transfers audio over a firewire connection. A firewire cable connects the two i88x's together while another firewire cable goes to a computer. Due to the fact that nowadays firewire interfaces are almost 51 impossible to be found on a PC, an Apple MacBook running Mac OS X Snow Leopard has been used, where the mLANGraphicPatchbay software is used to make available the input and output channels as necessary to Reaper. Reaper is a multi-platform DAW which supports scripting to automatize procedures. A python script has been written which automatizes the playback and recording of various test tones at different amplitudes, assigning properly formatted filenames and using dialogs and audio alerts to request the user for altering physical connections when required, for instance when background noise is to be measured and input to the device has to be disconnected[ link to the scripts ]. A different computer was used for data analysis, a desktop PC running Ubuntu Linux 10.04 Lucid Lynx . The software used for analysis was GNU Octave 3.6.3 with Gnuplot 4.6 patchlevel 2 as graphic backend. Synchronization of files between the two PC's was taken care of by a shell script which used rsync to transfer the files over the LAN. The Yamaha i88x analog outputs are capable, when used as unbalanced, of providing an output voltage of up to 12V peak-to-peak . Since the level of the signal fed to the BBD in practical applications is much lower and in the Vermona itself it rarely rises above 2V peak-topeak, and the full output level would clip the Hi-z inputs even when their gain is set to minimum, it was chosen to set the maximum output level to -12dBFS. From now onward, 0dBFS will be considered this level, which is the maximum output level used. This 0dBFS corresponds to an output of 2.8 V peak-to-peak (1.697 Vrms) . Setup for noise, frequency response and thd analysis: test signal is fed into the BBD input, reference signal is recorded at “BBD DC input”, processed signal is recorded at BBD output. A dummy jack plug is 52 plugged into the LPF in , thus disconnecting it from the output of the BBD. Setup for frequency response of the reconstruction filter: test signal is fed into reconstruction filter in, reference signal is recorded with a mono y-cable in parallel with the input to reconstruction filter, processed signal is recorded at reconstruction filter out. Setup for CV-frequency relation: the negative probe of a digital voltmeter (DVM) is connected to ground while the positive one is placed at the CV input of the clock generator. The ground of the oscilloscope is connected to the ground of the TS-1 while the probe is connected to the “Clock out” metal pin. 3.3.3 Calibration Setting the time scale of the oscilloscope to 10uS/div, and the voltage scale to 2V/div, clock is set to 100KHz by adjusting the panel potentiometer. Calibration for noise, frequency response and thd analysis: A 129Hz sinewave is output by the computer at 0dBFS, gains are individually set so that the level of each channel on the Reaper monitoring meter are at -2.0dB. The clip led on the input will stay on at higher levels, but this is of no concern, as it is built to light up 3dB before clipping. Input 2 gain is set higher than input 1, because the BBD chip attenuates signal. As the i88x doesn't provide on the gain pot itself the gain values, the difference in gain between the two channels has been measured this way: a mono y-cable has been connected from the soundcard output to both inputs, and a test signal at -6dBFS has been output. The input meters now show 53 a relative difference of 5.2dB, with input 2 been the highest. Connections are then restored back for recording as they were during calibration. Calibration for frequency response of the reconstruction filter: gain of channel 1 and 2 are set at minimum. 3.4 Measurements Each measurement reports an introductory table where are defined the test tones used, the levels (in dBFS) at which the output has been set for each tone, and the duration of the recording time for each level and each tone. As a general rule, when the spectrum of only one of the channels is plotted at a time, no correction occurs on the gain. When on the same plot appear the spectra of both channels, a gain correction is applied so to compensate for the different gain settings described in 3.3.3. 3.4.1 Background noise Test tones No test tone was used for this measurement. The output of the BBD has been recorded with no output from the soundcard. Levels n/a Duration 100s Multiple 8192-points FFT's with overlap of 0.5 have been performed and the sum of their results have been averaged, thus reducing the 54 variance and the scattering of the noise spectrum. A rectangular window has been used. The total number of FFT performed on a 100s time sample is about n= Fst 44100×100×2 = =1076 N overlap 8192 Because of the wide variance of the noise spectrum, it has been decided to use the mean of the spectra of the four 100-seconds measurements taken as a basis for further considerations. The Power Spectral Density has been computed as described in 3.2.3 and is plotted in Illustration III. On this spectrum, SNR has been measured as in (11), and results in SNR= 67.782dB, whereas the TDA1022 datasheet provides 74dB as a typical value [29]. By analyzing in details the spectrum of the noise can be noticed that at 50, 100 and 200 Hz are present some peaks, though at low level (Illustration IV). These are most likely caused by AC ripple in the power supply or AC hum induced by the 50Hz power line into the device or the connecting cables. Other smaller peaks are found in the 3500-4500 Hz range (Illustration V) Apart from these spurious frequencies – which anyhow lie more than 100dB below full scale – the noise floor can be seen constant at about -108dB in the 20 – 2000Hz range and then it rises almost linearly from -108dB to about -101dB in the 2 – 20 KHz range (7dB/decade). 55 3.4.2 Frequency response Test tones Linear chirp tone from 0 to 22050Hz Levels [0 -2 -4 -6 -8 -10 -12 -14 -16] Duration 100s The chirp tone is a time-swept cosine wave. Analyzing a chirp tone with a single rectangular window generates a heavy ripple at the lower and upper limits of the spectrum, due to the fact that there exist a discontinuity at the extremes of the chirp tone. This happens even if the chirp is forced to start and end at – or around – 0. By analyzing a chirp tone with a single Hann window, of course the frequencies that are not centered in the time domain will result attenuated in the spectrum. Using multiple overlapped FFT's windowed with Hann produce a ripple due to the non perfectly unitary summation of the overlapping windows, as this would cause some time fragments to be weighted less than others, which results in some frequencies been weighted less than others. The ripple issue does not show up in the transfer function, as the ripples in the spectrum of input and output signal cancel each other. Having considered all of the above, two different analysis methods have been used for the chirp tones: to print the frequency response of the system along with the frequency response of the reference signal, multiple FFT's of size N = 65536, overlapped by 0.5 and with Hann windowing have been performed on both signals. As for the transfer function, a single FFT have been performed on the full length of each signal. 56 Using slicing and Hann windowing in a chirp tone FFT analysis always cause to lose amplitude in the response in the lower and upper bands of the spectrum because applying the windowing to the first half of the first and the second part of the last slices of signal , these will result attenuated by the multiplication for the window functions, and this attenuation is not compensated by overlapping – as happens in the rest of the signal. Being that in a chirp tone each frequency is present only at a given instant, attenuating the time samples will reduce the amplitude of the frequencies present in those samples. The frequency f t at time t is for a linear chirp that starts at t=0 with a frequency f 0 and ends at T 1 with a frequency f 1 f1 f0 t T1 f t=f 0 (14) In this case is f 0=0, f 1 =22050, T1=100s . The first time instant where the amplitude of the window is t 1=N / 2/ F s=32768/ 44100Hz=0.743s from which derives last t2=T1 time instant where the amplitude 32768 N =100 =99.257s from which derives 2F s 44100 unitary is f t1=163.84Hz . The is unitary is f t2=21886Hz , so the pass band of this analysis is from 163Hz to 21886 Hz. Being 20Hz – 20000Hz the passband of interest for us, only the range of frequencies 163Hz – 20000Hz will be considered ,which approximately correspond to the FFT bins bin l=110 at frequency f l=163.47Hz and bin h=13458 at frequency f h=20000Hz . Because of the spreading effect of windowing, though, reduction in amplitude will be effective also on the surrounding bins. Furthermore, as the processed channel is delayed by the BBD of 57 about 130 samples with respect to the reference channel, there will be small differences between the two, but barely noticeable. The frequency response obtained with an output level of -10dB is shown in Illustration VI. As can be seen, the reference itself is not linear because its signal is taken after the anti-aliasing filter consisting of C103 (see 3.3.1). The processed signal is about 4.8dB below the reference. This is coherent with the values provided by the datasheet, which gives for “Attenuation from input to output at 1KHz”: a typical value of 4dB, and a maximum value of 7dB. The transfer function of the BBD is computed by dividing the complex values of the processed spectrum by the reference (Illustration VII). The response is almost flat ( ±0.1dB ) up to 5KHz and then slowly decreases by 2dB in the range 5KHz – 20KHz. This response is not drastically different from that reported on the datasheet, shown in Illustration XXIX, which states a flat response up to 15KHz and -0.5dB at 20KHz for a clock of 100KHz. The phase response looks a bit weird in the graph. This is caused by the delay generated by the BBD, which is, for a clock of 100KHz as used in these tests, on the basis of (1): t= 512 =0.025s 2 105 Hz (15) Which corresponds – at the sampling-rate Fs=44100 – to a delay of nd =t F s=112.9 (16) samples. By compensating the above mentioned delay by discarding the first 113 samples of the processed signal before computing the FFT, the resulting phase plot shown in Illustration VIII is much more conventional. 58 A cumulative phase-compensed plot of multiple transfer functions at different input levels shows that the amplitude and phase behaviour is pretty much consistent across levels, with the higher levels showing a response which is a little weaker than the others, especially at lower frequencies (Illustration XXX). This denotes a little compression at higher levels, which causes the harmonic distortion which will be analyzed in 3.4.3 . Anyway, we are talking of some ±0.1dB between the 0dB and the -16dB curve, so it is not much relevant. By watching at Illustration XXIX is furthermore possible to guess what happened in the lower band of our analysis, where we could not investigate because of the limits in the passband of the acquisition soundcard: the response is expected to be flat down to 0Hz. Two spectrograms are shown in Illustration IX and Illustration X of the processed signal with a test signal of, respectively, 0dB and at -10dB. They show an evident harmonic distortion – which will be analyzed in greater detail in 3.4.3 – and aliasing, too. Notice that the frequencies plotted here go up to 22050Hz, that is above the passband of the soundcard. The aliasing in the 20000-22050Hz range, which is evident in the lower-order harmonics folding their higher part into the audio band, is caused by the soundcard ADC, whose anti-aliasing filter is set for minimizing attenuation in the passband, by letting some aliasing fold below Nyquist but above the nominal passband. Another cause of aliasing, which generates inside the TDA1022, are the upper harmonics getting above the Nyquist frequency of the BBD which are then aliased in the audio band. In Illustration IX up to 6 harmonics can be recognized at lower frequencies, before they rise above 22050Hz. The 6th harmonic of a 22050Hz sinusoid is at a 59 frequency of 132.3Hz. The BBD is driven by a clock of 100KHz, thus the Nyquist frequency of the BBD is 50KHz. For a frequency to be aliased in the visible band (<22.05KHz), it has to be between 77.5KHz and 122.5KHz. A set of systems of linear inequalities has been solved for knowing exactly which harmonics are supposed to be aliased and at which frequency. The results are: 2nd : no aliasing 3rd : no aliasing 4th : f 0 19375 5th: f 0 15500 6th: 12917 f 0 20417 (17) which correspond to what can be seen in the spectrogram plot. 3.4.3 Harmonic distortion Test tones Sinewaves at 123.82Hz, 500.65Hz, 1001.29Hz Levels [0 -1 -2 -3 -4 -5 -6 -7 -8 -9 -10 -11 -12 -13 -14 -15 -16 -17 -18 -19 -20 -21 -22 -23 -24 -25 -26 -27 -28 -29 -30] Duration 8s The test tones used here have uncommon frequencies. These frequencies have been properly chosen to be close to the common choices of 1000Hz, 500Hz and 100Hz, but taking care that they are centered in a frequency bin of the FFT that was going to be performed on them. This ensures reduction of the spectral leakage and more precise measurements for the computation of harmonics strength and total harmonic distortion. The lower value has been chosen to be far from 100Hz as this frequency already showed up in the background 60 noise measurements as being occupied by the harmonics of the 50Hz power AC line hum. As for this analysis, multiple FFT's with N=8192 have been performed on the signal, using Hann window and a 0.5 overlap. A plot of the spectrum of the processed signal using a 1001.29KHz sinusoid at 0dBFS shows that the amplitude of the first 8 harmonics is well above the noise floor. It can be safely assumed for the following measures that any peak above -90dB in the range 2000Hz-20000Hz is above the noise floor and thus can be originated only by harmonics generated by the non linearities of the BBD. Using the thd.m script (Appendix A), the magnitude of the first 8 harmonics is calculated for each of the signals recorded, with the threshold set to -90dB and THD is computed as in (13). The harmonic analysis of amplitudes from 0 to -30 and harmonics up to Nyquist frequency of a 1001Hz sinusoid is reported in Table 3. Smith and Raffel in [22, page 5] report that the unavoidable total harmonic distortion of an N -stage BBD is thd % =100 1.01N / 1024 1 (18) In this case N=512, so thd as given by this formula should be of 0.5%. The datasheet of the TDA1022 reports that thd is dependent on the RMS value of Vs, showing a thd of about 0.3% for Vs below 2Vrms, and then a steep increase to over 5% at 3Vrms (Illustration XXVI). The measured trend of the total harmonic distortion vs the RMS input voltage is shown in Illustration XIV. The measured values show THD steadily rising from 0.068% at 0.07 Vrms to 1.5% at 1Vrms (maximum output voltage used for testing). 61 Raffel and Smith ( [1] page 6) continue reporting that measurements made on a BBD with thousands of stage show the 2nd and 3rd harmonic decrease linearly in magnitude with the 4th and higher harmonics at almost imperceptibly low magnitude. Analysis of harmonic content of a sinusoid at 1001Hz at various levels of Vs is shown in figure Illustration XI. As shown in Illustration XII, levels from -5dB to -20dB all behave similarly between them, with a noticeably loud 2nd – placed more than 40dB below the fundamental - and 3rd – placed a few dB below the previous – while higher harmonics are almost imperceptible. This results are quite different from those reported by Raffel and Smith, which were in turn referred to a different BBD with more than 4 times the stages of the TDA1022. The distortion detected here could thus have a different cause than that showed by Raffel and Smith. It could be caused not by the delay line charge transfer but by distortion of the MOS transistors. 3.4.4 Frequency response of the reconstruction filter Test tones Linear chirp tone from 0 to 22050Hz Levels [-4 -8 -12] Duration 100s The transfer function has been calculated with a single FFT on the entire file length, with a rectangular window. The measured transfer function for the reconstruction filter is shown in Illustration XIII. It stands out that this is quite different from the total transfer function computed in 2.6.1.4 and plotted in Illustration I. A sideby-side comparison of the two is plotted in Illustration XXVII. Apart from 62 the influences of the high pass filter, differences between the theoretical and measured values could be due mainly to: • drift in the component values: the Sallen-Key filters are quite sensitive to component values, especially for high quality factors (Q). The quality factor here is not very high, but the components have more than 35 years, and their values could have drifted from the nominal value more than the nominal tolerance. • non-ideal input and output impedances: because of the real input and output impedances, the coupling of the two filters may yield different results than if the impedances were ideal, that is if the input impedance were infinite and the output were 0. This has already been pointed out by Gleason in [10]. The above points could be investigated further by measuring the individual response of each filter and measuring effective component values, but this would be beyond the scope of the present document. The digital model in 4.5.2 will try to mimic the measured behaviour of the filter by implementing an IIR filter. The filter coefficients can be nevertheless easily edited by the user in order to meet a different frequency response. 3.4.5 Control voltages and LFO These measurements were taken without scientific intent as the equipment available could not provide enough accuracy. In fact they rely on the use of a DVM and an analog oscilloscope which have no means of being connected to the PC to perform analytical analyses. Most PC audio 63 interfaces like most audio equipment have a DC-blocking capacitor at their input that do not allow measurements of DC voltages nor of slowly varying waveforms – such as those of the LFO's . These measurements have therefore been taken just in order to get an idea of what are the clock frequencies, how they are related with the control voltage and if the LFO waveforms are corresponding to the ones shown in the schematics 3.4.5.1 CV-frequency relation The oscilloscope is used to measure the period length of the clock frequency. The clock period is measured at different CV tension levels obtained by rotating VR1, The results are tabulated in Table 2 and graphed in Illustration XVI. The relation is almost linear with F decreasing as CVin increases. GNU Octave function polyfit has been used in order to retrieve the coefficients of a first order interpolating polynomial, which can be used to retrieve the value of F for each value of CVin. Such interpolating function is: F phi = 4235.96 CVin 102045.54 3.4.5.2 (19) LFO waveforms By watching the LFO waveforms as represented on the oscilloscope display, the following stands out: • The slow waveform is not at all similar to the left waveform in Figure 15. It can be roughly described as a periodic signal of frequency 0.6Hz which has brief positive and negative spikes of 64 about +-6V. This cannot be considered a complete description, but what can be derived from this is that the actual waveform is very different from that in Figure 15, probably due to something that has gone wrong in the electronic circuit. The DC voltage is about 8V, and the spikes are in the range 1.5V-14.5V. These values, substituted in (19) give that the stationary clock frequency is F [F S0 =68157Hz , and the frequency is modulated in the range Sl =40624Hz , F Sh =95691 Hz] . This results in a modulation width of wS= • F S0 F F Sl F = F Sh F S0 Sh =0.40 (20) Sh The fast waveform instead seems very close to the image in Figure 15. When the “fast” preset is active, the DC voltage is 9V and a peak amplitude of about 2V. The (19) gives that the stationary clock frequency is F in the range [F Sl F0 =63921Hz , and the frequency is modulated =55450Hz , F Sh =72394 Hz] . This results in a modulation width of of wS= F F0 F F Fl = F F0 F Fh F Fh =0.13 (21) Fh When the active preset is “Chorus 2” the fast sinewave sums to the above described slow one without the 9V DC offset, as discussed in 2.5.3. 65 4- 4.1 THE DIGITAL MODEL Overview An existing software library, called resample which allows samplingrate conversion of audio files has been modified to implement the model of BBD devices applied to the chorus section of the Vermona Piano Strings. This eventually lead to the creation of new software called BBDresample which is a command-line audio processing tool that allow the user to choose between the different modulation presets of the Vermona Piano Strings or even use custom parameters and modulation waveforms provided by the user. Before discussing the BBDresample software, the interpolation technique used as well as some characteristics of the original resample software are reviewed. Images used in this section to illustrate the behaviour of resample are taken from the original description of the software made by the author J. O. Smith himself in [30]. 4.2 Bandlimited interpolation Smith introduces bandlimited interpolation of discrete-time signals as as: “... a basic tool having extensive application in digital signal processing. In general, the problem is to correctly compute signal values at arbitrary continuous times from a set of discrete-time samples of the 66 signal amplitude. In other words, we must be able to interpolate the signal between samples. Since the original signal is always assumed to be bandlimited to half the sampling rate, (otherwise aliasing distortion would occur upon sampling), Shannon's sampling theorem tells us the signal can be exactly and uniquely reconstructed for all time from its samples by bandlimited interpolation. [ … ] Since Shannon's sampling theorem says it is possible to restore an audio signal exactly from its samples, it makes sense that the best digital audio interpolators are based on that theory. Such "ideal" interpolation is called bandlimited interpolation.” A conceptually simple analog-based method for resampling is proposed in ([26] page 22) as can be seen in Figure 16. Figure 16 Analog-based resampling method A time-discrete x0(n) signal is converted by a DAC into the timecontinuous signal xa(t). The continuous signal is then sampled by a sampling-function H into the signal x1(m) which is at a different sampling-rate than x0(n). Of course using a pair of DAC and ADC would be pretty expensive and their imperfections would introduce errors. A fully-digital interpretation of this method would involve the use of the ideal D/A formula in place of the “physical” D/A ([30], page 5) : y t = x nT s h s t nT s x t n= where Ts =1/Fs is the time duration of a sample and 67 (22) h s t =sinc F s t = sin Fs t Fst (23) is a filter function that performs anti-aliasing filtering. Although the sinc function has a discontinuity in the origin, its limit in the origin is 1, and thus it is assumed to have unitary value at zero. In Illustration XV can be noticed that at any non-zero integer its value is zero. When resampling from a sample rate Fs to a new sample rate F's , the sinc function must be properly chosen as: h s t =min {1, F 's }sinc min{F s , F ' s }t Fs (24) where the scale factor in front of the sinc functions maintains unity gain in the passband, and the Fs chosen for the sinc function assures aliasing-free resampling. Equation (22) can be written as a convolution: y t = x h s t . This new form shows that to compute the signal y(t), the filter function hs is applied to the signal x(n). The interpretation of (22) which will be used from now on is that to obtain the interpolation at time t, the signal samples must be shifted under one sinc function so that time t in the signal is translated under the peak of the sinc function, then the output is computed as a linear combination of signal samples where the coefficient of each sample is given by the value of the sinc function at that location. Two points must be noted here: first, when t=nTs ,that is when an output sample is required on a sample instant, the only contribution to the output will be that of the sample n itself, as the other samples are multiplied each for one of the zeros of the sinc function; second, this 68 principle can be extended to the fact that when upsampling to Fs'= kFs where k is a positive integer, every kjth output sample will be exactly equal to the jth input sample. (22) cannot be implemented in the real world as the ideal lowpass filter impulse response hs extends from to , and an equally infinite number of samples should be used and summed, it is necessary to limit the impulse response to a finite number Nzc of zero crossings, and being m the index of x so that mTs<t and (m+1)Ts>t , the (22) becomes m N zc y t = (25) x nT s h s t nT s n=m N zc The ideal lowpass filter has the frequency response shown in Figure 17 Figure 17 Ideal low pass filter response 69 Figure 18 Response of a truncated ideal low pass filter As shown in [30, page 6], limiting the length of the filter impulse by simply truncating it, or rather windowing it with a rectangular window centered over the origin, is not a good idea, as shown by the resulting frequency response in Figure 18 , where can be seen that the stop band is only 20dB below the passband. Figure 19 Response of a Kaiser windowed ideal low pass filter 70 By using a different window, a way better response can be obtained, as in Figure 19 , where a Kaiser window has been used, and this results in the stopband being more than 80dB below the passband. 4.2.1 The implementation of the “digital DAC/ADC” As explained in 4.3.2, only half of the filter response is stored in the table. That is the reason why (25) has to be implemented in resample in three subsequent steps, consisting of : h end x n i [h l iL v= h l iL ] (26) i=0 (27) P=1 P h end v =v x n 1 i [h l iL h l iL ] (28) i=0 (29) y=v Where v is a temporary variable, P is the concatenation of the rightmost two fields of the time register, as described above, and h is the table of the differences of hs and L is the number of samples per zero crossing in the filter table. The term [h l iL h l iL ] is the linear interpolation of the value of the filter at the point given by P. As can be seen, the filter table is traversed twice, in (26) to apply the left wing of the filter and in (28) to apply the right wing. In between the two, the time register is updated in (27). The sum at (26) and (28) is performed by the FilterUD function in the filterkit.c file, which prototype is : 71 in filterkit.c 409. WORD FilterUD( HWORD Imp[], HWORD ImpD[], 410. UHWORD Nwing, BOOL Interp, 411. HWORD *Xp, HWORD Ph, HWORD Inc, UHWORD dhb) where Imp is a pointer to the filter table, ImpD is a pointer to the table of differences, and Nwing is the length of these tables. Interp is a boolean value which means “interpolate between filter table values” . If it is 0, no interpolation is performed and a value of the table is used instead. *Xp is the pointer to the current input sample, Ph is the phase into the filter table, Inc must be -1 when applying the left wing of the filter, and +1 when applying the right wing. It corresponds to the coefficient of 1 in the argument of x() in (26) and (28). dhb is the step through the filter table. The FilterUD function is called twice by the SrcUD function in resamplesubs.c, first as: SrcUD() in resamplesubs.c 165. v = FilterUD(Imp, ImpD, Nwing, Interp, Xp, (HWORD)(*Time&Pmask),-1, dhb); 166. 167. v += FilterUD(Imp, ImpD, Nwing, Interp, Xp+1, (HWORD)((((*Time)^Pmask)+1)&Pmask),1, dhb); Where *Time&Pmask at row 165 is the P part of the time register, as defined in (34). Lines 165 and 167 differ only for arguments 4, 5 and 6 (*Xp, Ph and Inc in the prototype). Line 165 corresponds to equation (26), the difference in argument 5 (Ph) corresponds to the update in the P part of the time register as in (27) and line 167's Xp+1 corresponds to the increment of n in (28). 72 This implementation of the bandlimited interpolation does not allow the step in the filter response to be greater than 2 zero crossings, i.e. the filter cutoff frequency cannot be greater than the greater of the two frequencies involved in the resampling. 4.3 The resample software The methods and strategies outlined in the previous section have been implemented by Julius Smith from the Stanford University in a software called simply resample, which is written in C , is currently at release 1.8.1 and licensed under the LGPL license. This software is a command-line resampling tool that relies on the soundlib library for input and output of soundfiles in many different formats. The many-times cited [30] contains a detailed description of the implementation and an analysis of approximation errors due to the use of finite-length impulse responses and fixed-point computations, and the reader is referred to it for further details not reported here. Three aspects will be reviewed here: • the time-register • the filter table • the implementation of (25), the “digital DAC ADC” resample processes input data in batches of 4096 samples, which are passed to the functions SrcUp and SrcUD. The first is used when upsampling, while the other could be used both while upsampling and downsampling. Being SrcUp slightly faster, resample uses it for 73 upsampling and SrcUD for downsampling. In the prospective of making a time varying sampling-rate conversion tool, we will use and refer to only the SrcUD function in the following paragraphs, as it gives more flexibility. Resample uses fixed-point values throughout his computation process. Practically, this means that (almost) all of the values and the numbers inside the program are treated as integers, and floating-point values are converted to integer as soon as possible. This allows for faster computation, but has two major drawbacks. The first is that the precision is finite and less than would have been made available by using floating-point values. Nevertheless, with proper choices of the length of the filter and the interpolation index the resulting error is of the same order as the quantization error of a 16bit fixed-point audio file(a detailed analysis of the approximations error can be found in section 3.6 of ). The second drawback is that there are a series of conventions and tricks in the coding that must be outlined in order to let the first-time reader understand what's going on. 4.3.1 The time register The time register is a variable in resample called Time that is a 32bit unsigned int which identifies the relative position of the present t instant in the input signal. For the above mentioned efficiency's sake, this variable contains not one but three values at once as can be seen in Figure 20. 74 Figure 20 the Time variable n is the index into the input signal buffer, l is the initial value in the filter table, and is the interpolation factor between two values in the filter table. These fields have each respectively nn nl n bits. The sum nn + nl + n is 32 by definition, and nl have been chosen to be 8 and n 7, in this implementation. The concatenation of l and is considered as a value comprised between 0 and 1, and is interpreted as the relative position of the time instant t between the sample n and n+1. In resample the value nl is named Nhc, and n is named Na, and the sum of the two is Np. 4.3.1.1 Bitwise operators To access the values stored in this variable individually, a set of operators is used which relies on operators that act at the level of the binary representation of the value, which are reported below. To understand them, it is necessary to convert the decimal number to its binary representation (denoted by the leading 0x), apply the operator and then convert back to decimal. 75 Name Symbol Meaning Bitwise AND a&b Performs a bit-by-bit 4 & 7 comparison of two 0x100 & 0x111 = integers, and 0x100 4 applies the logical AND to each bit-pair Bitwise a^b Performs a bit-by-bit 4^7 0x100 & 0x111 = 0x011 3 comparison of two integers, and applies the logical XOR to each bit-pair a << b Shifts the bit representation of a to the left of b bytes, discards bytes as needed X-OR Left bit-shift Right bit-shift a >> b 4.3.1.2 Example Shifts the bit representation of a to the right of b bytes, discards bytes as needed 3<<5 0x00000011 << 5 = 0x01100000 96 25>>2 0x11001 >> 2 = 0x00110 6 Use of bitwise operators in resample In particular binary shifts are used in resample to extract the value of n by Time the following is used: n=Time (30) Np , while to increment the value of n by the integer k : Time =Np To retrieve the values of l and k (31) , the so called “masks” are used in conjunction with the bitwise and. Pmask and Amask are defined as 76 follows. Note the use of parenthesis around the bitshift operators, needed as they have lower precedence than the sum and minus operators. Pmask= 1 Np Amask= 1 1=32767=0x111111111111111 (32) Na (33) 1=127=0x1111111 To retrieve the concatenation of l and from the Time variable, the following is used: la=Time & Pmask While to retrieve (34) from the above calculated concatenation : =la & Amask (35) resample uses a normalized sample rate, this means that the sampling rate of the system is considered to be Fs=1 , while the output sampling rate Fs' is defined as the ratio between the output and the input sampling rate, which ratio is stored in the variable factor main() in resample.c 187. double factor = newsrate / (double)insrate; For instance, the time increment to step between the t time instants at which a value of (25) is required is dtb: SrcUD() in resamplesubs.c 193. dt = 1.0/factor; period */ 194. dtb = dt*(1<<Np) + 0.5; representation */ And the increment is performed as 77 /* Output sampling /* Fixed-point SrcUD() in resamplesubs.c 213. *Time += dtb; 4.3.2 The filter table For the implementation of (25), resample uses a pre-computed table of values of a symmetric finite-impulse-response(FIR) filter hs, between which values linearly interpolates to compute the required value hs(tnTs). In fact, being the impulse response symmetrical, only half of the values are stored, for better memory efficiency. For better computational efficiency in calculating the linear interpolation, also a table of the differences between the elements of hs is stored. Npc=2 n =256 l (36) is defined as the number of look-up values available for the lowpass filter between the beginning of its impulse response and the "cutoff time" of the filter. The cutoff time is defined as the reciprocal of the lowpass filter cut off frequency in Hz. For example, if the lowpass filter were a sinc function, Npc would be the index of the impulse-response lookup-table corresponding to the first zero-crossing of the sinc function. The filter table is fixed, but we have seen in (24) that the proper filter function must be chosen as – in the case of an ideal sinc function – sinc(min{Fs,Fs'}). To simulate this with a fixed filter-table, what is changed for a given conversion factor is the sampling-period of the filter. This is achieved by defining the step in the filter table at each iteration of the sum in (25) , dh, and its fixed-point equivalent dhb, as: 78 SrcUD() in resamplesubs.c: 196. dh = MIN(Npc, factor*Npc); period */ 197. dhb = dh*(1<<Na) + 0.5; representation */ /* Filter sampling /* Fixed-point Code 1 choice of the step in the filter-table To better understand what's going on, the values discussed above are illustrated in Figure 21 4.4 The BBDresample software The resample software has been heavily modified in order to implement a model of a BBD based signal processor and this turned it into a new software, called BBDresample. Modifications to the source files of the original resample software include: – minor modifications to the main function in resample.c and to the resample and resampleWithFilter functions in resamplesubs.c provide an interface for the use of presets and modulation options – the audio samples are now internally stored and processed as floating-point instead of integer. Conversion to fixed-point occurs when writing the output file – the SrcUD function has been entirely rewritten and offers now multiple interpolating delay lines – functions lfoGen, reinitLfoGen, waveshaper, filtiir added resamplesubs.c provide LFO, waveshaping, IIR filter capabilities 79 in – minor modifications to the FilterUD function in filterkit.c allow for the use of circular buffers – minor, undocumented modifications to other source files The most relevant introductions are reviewed in this chapter which explains the DSP algorithms used, while the following focuses on the selection of the parameters used in the software in order to emulate the behaviour of the chorus section of the Vermona Piano Strings. 4.4.1 The BBD buffer The BBD device is represented as an array where the samples are stored and read. As given by (1), the number Ns of samples stored in a BBD is half the number of stages in the device. Representing this in the digital domain would require a buffer where samples are stored. Being the number of samples limited, the buffer could consist of an array of fixed size where a read pointer and a write pointer move in order to get input and output samples. While the BBD operation relies on shifting the elements from the input towards the output, this would be computationally expensive because at each read/write cycle all but one of the elements of the array should be moved in memory. Therefore this array must be used as a circular buffer, that is a fixed-size buffer that is used as if it were connected end-to-end. When no interpolation is performed only one buffer sample – the target sample – is needed per output sample. When any kind of interpolation is performed, there arises the need to get access to more than just the target sample per each output sample. Using linear interpolation only one previous sample would be sufficient. When using 80 different interpolation techniques such as bandlimited interpolation, many samples may be needed before and after the target sample. As a consequence of this, a buffer consisting of an array containing Ns values would not be suited for the task to be accomplished here. The length of the buffer should be greater than Ns in order to provide the necessary padding samples around the target sample to be used in interpolation. Each target sample should then be read Ns samples earlier 81 than the last written sample. The minimum number of padding values needed is determined by the number of samples needed by the interpolation method used. In this implementation an arbitrarily high number of 100 samples on each side of the target sample has been chosen. As the software developed will be able to simulate the behaviour of multiple BBD-based device working in parallel on the same input signal, the circular buffers, one for each BBD, will be stored in a multidimensional array. #define BBDBUCKS 512 /* Number of stages in the BBD */ #define BBDDEL (BBDBUCKS/2) /* Number of stored samples in the BBD */ #define BBDOFF 100 /*padding in the BBD array */ #define BBDSIZE (BBDDEL+2*BBDOFF) /* Total size of the BBD array*/ #define NUMBER_OF_BBDS 3 FLOAT bbd[NUMBER_OF_BBDS][BBDSIZE]={0}; The bbd array itself as well as other array variables which are related to it, will be indexed throughout the program with the subscript index [ch] where ch is the channel considered. These variables are declared and used in the SrcUD function and are: static static static static static UWORD T2[NUMBER_OF_BBDS]; UWORD oldBBDevent[NUMBER_OF_BBDS]; UWORD nextBBDevent[NUMBER_OF_BBDS]; UWORD nextTevent[NUMBER_OF_BBDS]; int BBDindex[NUMBER_OF_BBDS]={0}; 82 4.4.2 Using circular buffers To access elements in an array the index of the element must be provided. Common operations on indexes are those of sum and difference. To maintain the index between the lower and upper limits of the array after these operations, the modulus operator is used. Being j an index into an array of size S, when j is incremented by a positive quantity k, the resulting index will be: j ( j + k )%S (37) where "%" denotes the modulus operator. When j is decremented by a positive quantity k<=S, the resulting index will be: j ( j k + S )%S (38) In order to read and write into a circular buffer two pointers are generally used, as the distance between the two is variable. The BBDresample software always reads from the buffer BBDDEL values before the write index. For this reason only the write index is stored in the BBDindex[ch] variable, and the read pointer is calculated when needed as BBDindex[ch]-BBDDEL, applying the formula above. This method of accessing array elements had to be implemented in two core functions of resample , i.e. SrcUD and FilterUD. Most notably, the FilterUD prototype was modified from WORD FilterUD( HWORD Imp[], HWORD ImpD[], UHWORD Nwing, BOOL Interp, HWORD *Xp, HWORD Ph, HWORD Inc, UHWORD dhb) to 83 FLOAT FilterUD(HWORD Imp[], /*pointer to a table of filter values*/ HWORD ImpD[], /*pointer to a table of differences of filter values*/ UHWORD Nwing,/*length of the tables*/ BOOL Interp,/*use linear interpolation between filter values*/ HWORD Xp, /*index in the input signal*/ HWORD Ph, /*location between samples in the input signal*/ HWORD Inc, /*-1 performs left wing, +1 performs right wing*/ UHWORD dhb,/*step in the filter impulse response*/ FLOAT X[],/*array containing the input signal*/ HWORD length);/*length of the input array to be used as circular buffer. If this is 0, doesn't use circular buffer*/ 4.4.3 The signal flow The block diagram of a typical BBD based chorus device constituted of three BBD IC's and accessory circuits is shown in Illustration XVII, where the clock generator is omitted for clarity. The three delay lines are placed in parallel, each with it's own anti-aliasing filter and reconstruction filter. A representation of a single delay line and associated circuits is shown instead in Illustration XVIII. Here the BBD box is expanded in order to show the signal processing that happen in there after what stated by Raffel and Smith in [1] and reviewed here in 1.4.1. The order in which these processings are to be applied to the signal is not specified. Noise, harmonic distortion and the low pass filter resulting from frequency-dependent insertion gain are all added to the signal right inside the delay line. A very accurate model 84 would consider the charge loss and its consequences for each element of the delay line at each clock cycle, but this would require an exaggerate number of computations, that an implementation aimed at real-time signal processing could not bear. A real time model would add these effects immediately before or after the delay line. The signal flow that has been implemented in BBDresample is shown in Illustration XIX. Harmonic distortion is generated by means of a waveshaper, which is placed after the interpolator. Noise is added to the signal after the waveshaper and before the delay line. It has been decided not to implement neither filtering of the noise nor the low pass filter resulting from the frequency-dependent insertion gain. In fact, their contribution is not relevant, as both of them would affect only the higher frequencies of the spectrum, well above the cutoff frequency of the reconstruction filter. On top of that, in the assumption that the anti-aliasing and reconstruction filters are linear for the low amplitudes of the output signal of the BBD, as stated in ([1] , 4.4) and in order to save computation resources, these filters can be applied just once each, the anti-aliasing filter before splitting the signal to three BBD's and the reconstruction filter after the sum of the outputs of the BBD's but before the point where an amount of the dry input signal is summed to the processed signal. The resulting block diagram is shown in Illustration XX. 4.4.4 Aliasing In a physical (analog) circuit involving a BBD IC, frequency aliasing originates mainly from three sources: 85 • non-bandlimited signal at BBD input • spectral periodicization at the BBD output • harmonic distortion inside the BBD 4.4.4.1 Non-bandlimited input signal The anti-aliasing filter should provide a bandlimited signal to the input of the BBD. Bandlimited means in this case that the time-continuous signal which is sampled respects the Nyquist criterion, that is it does not contain any frequency above half of the sampling frequency. This kind of aliasing could occur in case of inadequately designed anti-aliasing-filters, or in case the input signal has an harmonic content different than the one the filter was designed for. 4.4.4.2 Spectral periodicization at the BBD output When a discrete-tome signal is converted back to continuous time, the spectral periodicization that characterizes the discrete-time signal persists in the continuous-time signal. Reconstruction filters placed after the BBD output are designed to remove the unwanted harmonic content by cutting off frequencies above half of the sampling rate. 4.4.4.3 Harmonic distortion inside the BBD Even if anti-aliasing filter is properly designed resulting in a properly bandlimited input signal at the input of the BBD, whatever harmonic content should be added inside the BBD, that is in the discrete-time domain, could cause frequency aliasing in the very same manner as usually happens in digital signal processing. If harmonic distortion occurs 86 inside the BBD, for instance, the generated harmonics could be aliased if they should rise above the Nyquist frequency of the system, that is half the BBD clock rate. This effect was plainly visible in the results of the measurements taken in 3.4.2. 4.4.4.4 Aliasing in the model A digital model of the BBD should allow the above mentioned aliasing manifestations to occur. For this to happen, the interpolating filter must be set to cutoff at the system sampling rate both at the input and at the output of the BBD. If the clock of the digital-BBD is lower than the system sampling rate, the full spectrum of the input signal, already processed by the antialiasing filter, can reach the input of the digital-BBD and possibly alias. Similarly, the output of the digital-BBD is allowed to output its full spectrum, which will be then filtered by reconstruction filters. If the clock of the BBD is higher than the system sampling rate, these effects will not be noticeable. This is - otherwise – the same behaviour that would show the analog circuit, as long as the input signal is limited to the audio range. 4.4.5 The delay line According to [1], a proper model of the delay line would consist of a fixed-length delay line which artificial sampling-rate is uncorrelated with the working input/output sampling-rate of the software itself. The artificial sampling-rate must be time-varying and must be modulated by an external source. The analog equivalents are obvious: for the fixed87 length delay line the charge-holding elements of the BBD and for the artificial sampling-rate the clock signal that drives the BBD, and the modulation source is the LFO. As the two sampling-frequencies are asynchronous, there will be the need for some kind of interpolation in order to make a sample available at each of them at the exactly time instant when it is required. The delay line is implemented in the SrcUD() function, which is the core of BBDresample . It reads and writes to the delay line – the bbd[] arrays – using bandlimited interpolation by means of the FilterUD function. It allows multiple delay line to run in parallel, process the same batch of samples, and sum their outputs – properly scaled – to the output buffer. The number of delay lines available is defined at compile time by the NUMBER_OF_BBDS flag. The number of delay lines used is decided at runtime on the basis of the preset chosen. The clock of the delay line is modulated by an internal LFO – computed by the lfoGen function – or by an external LFO, passed by the user as the right channel of the input file. Although this implementation has been prototyped in Octave, C-style pseudo-code is the best fit illustrating the algorithm, as Octave uses different rules for indexing arrays which result in overly-complicated code. BBDDEL /* Number of stored samples in the BBD*/ BBDSIZE /* Total size of the BBD array*/ X[] input buffer Y[] output buffer bbd[BBDSIZE] BBD buffer T2 sampling increment of the BBD clock Nx number of samples to process Time elapsed time in samples 88 Time=0 nextBBDevent=0 /*when it's time to write a sample in the BBD*/ oldBBDevent=0-T2 /*previous value*/ nextTevent=0 /*when it's time to read from the BBD and write to output*/ 1. while ( Time<Nx ){ 2. if (Time==nextBBDevent){ 3. BBDindex=circularAdd(BBDindex,1) //increment in the circular buffer 4. Xp=floor(T)/*integer part of T, index in the input array*/ 5. w=fract(T)/*fractional part of T*/ 6. bbd[ch][BBDindex]=interp( X, T, w ) /*an arbitrary interpolating function*/ 7. oldBBDevent=nextBBDevent /*save old*/ 8. nextBBDevent=Time+T2 /*schedule next*/ 9. } 10. if (*Time==nextTevent){ 11. rread=circularSubtract(BBDindex, BBDDEL)/*read index in the BBD: subtraction in the circular buffer */ 12. w=(Time-oldBBDevent)/T2 /*relative position of T between bbd[rread] and bbd[rread-1] */ 13. Yp=floor(Y) /*index in the output array*/ 14. Y[Yp]=interp(BBD,rread,w) 15. nextTevent=Time+1 /*schedule next*/ 16. } 17. Time=MIN(nextTevent,nextBBDevent[ch]) 18. } Code 2 pseudo-code of the delay line implementation NextBBDevent is the next time at which an input must be fed to the BBD, while nextTevent is the next time an output sample is needed. At each iteration of the while loop the current Time is compared with the time of the scheduled events. If one matches, the associated actions are performed and the event is rescheduled. At the end of each iteration, the 89 new Time is set as the lesser of the scheduled events. This is a fullyasynchronous implementation. In this way, at each iteration at least one event takes place and is rescheduled. Two events at the same Time can happen as well, as is the case of the first iteration. Moreover, events of a given type – be it BBDevent or Tevent – can take place whatever number of times between two consecutive events of the other type. In fact, this is limited only by the size of the BBD array, as discussed in 4.4.1. Note that Tevents take place only at integer values of Time as they are the times when an output sample is required. Interp() is a generic interpolating function which takes as parameters the array, the index in the array to be interpolated and the fractional index between the indexed element and the next. These three parameters are enough both for a simple linear interpolation and a more elaborate bandlimited interpolation. Retrieving the indexing parameters when reading from the input buffer is pretty straightforward, being them respectively the integer and the fractional part of the current Time. Otherwise, when reading from the BBD array things are slightly more complicated. While the index in the array is easily computed with a subtraction in the circular buffer (line 11), the fractional part needs to be calculated as the ratio between the time elapsed since oldBBDevent and the sampling increment T2 of the bucket-brigade clock (line 12). The result is always in [0,1), as it would be 1 only if nextBBDevent ==Time, but it is not possible because even if nextBBDevent were equal to Time at the beginning of the iteration, it would have been updated at line 8 with a new value greater than Time. Figure 22 illustrates the method used and the variables involved. T1 is the sampling increment of the system frequency. The interpolating function will need to access some elements before and after the one indexed by rread. Therefore, 90 appropriate padding must be reserved in the BBD array, as discussed in 4.4.1 The clock frequency of the BBD and its sampling increment T2 do not need to be time-invariant and thus they can be modulated by an LFO. In the implementation above, no effect is applied to the signal other than the resampling itself. The extended implementation in Code 3 shows the multiple-channel processing, the LFO modulator and the points where distortion, noise and filtering are applied to the signal. Only lines that have been introduced here for the first time have comments. BBDDEL Number of samples stored in the BBD 91 BBDSIZE Total size of the BBD array Y[]={0} /*output buffer must now be initialized to 0*/ channels /*number of BBD devices used in parallel*/ bbd[channels][BBDSIZE]={0} /*this is now a multidimensional array*/ BBDindex[channels]={0}/*these variables are now arrays*/ oldBBDevent[channels]={Time-T2}/*these variables are now arrays*/ nextBBDevent[channels]={Time}/*these variables are now arrays*/ T2fixed /*sampling period of the BBD clock when no LFO is applied*/ width /*modulation width, expressed as percentage of the BBD clock*/ cleanWidth /*amplitude of the clean signal summed with the dry signal*/ 1. X=filter(X) /*anti-aliasing filter applied to the whole buffer*/for (ch=0;ch<channels;ch++){ 2. Time=startTime; 3. nextTevent=Time; 4. Yp=0; 5. 6. while ( Time<Nx ){ 7. if (Time==nextBBDevent){ 8. lfo=lfoGen(ch,Time) /*an lfo generator*/ 9. T2=T2fixed/(width*lfo+1)/*lfo modulates clock frequency, that is 1/T2 */ 10. BBDindex[ch]=circularAdd(BBDindex[ch],1) 11. Xp=floor(T) 12. w=fract(T) 13. v=interp( X, T, w ) 14. v=waveshaper(v) /*applying waveshaper*/ 15. v+=noiseAmplitude*noise()/*adding noise*/ 16. bbd[ch][BBDindex[ch]]=v 17. oldBBDevent[ch]=nextBBDevent[ch] 18. nextBBDevent[ch]=Time+T2 19. } 92 20. if (*Time==nextTevent){ 21. rread=circularSubtract(BBDindex[ch], BBDDEL) 22. w=(Time-oldBBDevent[ch])/T2 23. Yp=floor(Y) 24. Y[Yp]+=interp(bbd[ch],rread,w)/channels 25. nextTevent=Time+1 26. } 27. Time=MIN(nextTevent,nextBBDevent[ch]) 28. } 29. } 30. Y2=filterIIR(Y) /* reconstruction iir filter applied to the whole buffer*/ 31. Y2+=cleanWidth*X /* clean signal mixed with the output signal */ Code 3 Full pseudo-code of the delay line, including LFO modulation and insertion points for noise, waveshaping and filtering The most efficient multi-channel implementation is the one outlined here, where the for loop iterating through the channels is outside the while loop which iterates through time. Although this calls for reinitializing Time, nextTevent and Yp variables at each for iteration, it is much faster than nesting the for loop inside the while. The waveshaping function is applied after the interpolation and before writing the sample to the bbd buffer. In this way the harmonic distortion that the waveshaper generates may rise above the Nyquist frequency of the BBD and then possibly foldback in the audio range, which is intended as explained in 4.4.4.3. If needed, a fraction of the input signal can be summed to the output (line 31). This pseudo code implementation is split in BBDresample between the SrcUD and the resampleWithFilter functions. The for and while loop 93 reside in the SrcUD function while the filter processing and the mix with the dry signal take place in resampleWithFilter. The SrcUD function has been entirely rewritten but it still uses the same fixed-point time-register method as used in resample. With the aid of the explanations in 4.3.1 and of the pseudo-code above, the reader should easily understand its code, which can be found in Appendix B. 4.4.6 Choosing proper bandlimited interpolation filter Bandlimited interpolation is performed by the FilterUD function, which is basically the same as it was in resample apart from the modifications outlined in 4.4.2. Filtering, waveshaping and LFO are provided by some new functions which are reviewed below. The steps into the interpolating filters are chosen so that the cutoff frequency is fixed to system Fs. As stated by (24), a properly chosen sinc function for sampling-rate conversion should have a frequency that is the lower of the two sampling rates involved. This would set the interpolating filter cutoff frequency at the Nyquist frequency of the lower of the sampling rates, thus ensuring aliasing-free resampling. In this application, though, as discussed in 4.4.4.4, a certain kind of aliasing is desirable and the cutoff frequency of both resampling filters must be fixed at system sampling rate. In order to fulfill this constrain, the filter steps to pass to the FilterUD() function must be properly chosen. Being Fs the system sampling-rate and F the BBD sampling rate, when converting from system to BBD sampling rate, the converting factor is 94 factor ' = F Fs (39) To place the filter cutoff at system frequency, the filter step must be unitary, as if factor' was 1. In resample this translates, as seen in Code 1, to a filter step of Npc. When converting back from BBD to system sampling rate, the converting factor is factor ' '= Fs F (40) To place the filter cutoff at system frequency, the filter step must be factor''. In resample this translates to a filter step of factor times Npc. Unfortunately, the implementation used does not allow a filter step greater or equal to 2*Npc. This value must thus be limited and defined as dh=MIN(2*Npc-1,Npc*T2lfo); This means that – in the current implementation – the interpolating filter will have effects in the audio band whenever the clock frequency is below half the upper frequency limit of the audio range, that is when F 10Khz . 4.4.7 The filters In this implementation, filtering can be performed through both Finite Impulse Response and Infinite Impulse Response filters. The filtiir() function provides these capabilities, as shown in Code 4. 95 The function requires as parameters a pointer to an array x[] containing samples of the input signal, its length lengthx, and an array where the output samples are to be written, y[]. The pointers passed must be properly placed in the input and output array. The filtiir function requires that x[] is Blgt positions into the x array, and y[] is Algt positions into the output array. Applying IIR filters in place is not possible, as the output is a function of both input and output values and input values cannot be overwritten. y[] is the first element of the array that is written by the function. Applying filters to batches of samples – as is usually done – needs to remember a number of previous input and output samples between batches. The code of filtiir is a straightforward implementation of the IIR filter algorithm ([31]): N y n= i =0 M bi x n i ai y n i (41) i=1 Where bi and ai are the filter coefficients and x and y are respectively the input and output signal. The output signal is a function of both the input elements – in the first summation – and of the previously output elements in the second summation. This second summation is known as the recursive part of the filter. 1. 2. 3. 4. #define Blgt 5 #define Algt 5 FLOAT filtiir(FLOAT x[],int lengthx, FLOAT y[]){ static double A[Algt]={1.000000,2.099811,2.439923,-1.502647,0.483548}; 5. static double B[Blgt]={0.010773,0.043093,0.064640,0.043093,0.01077 3}; 6. int n,i,iend; 96 7. 8. 9. 10. 11. 12. 13. 14. 15. 16. 17. 18. double out=0; for (n=0;n<lengthx;n++){ out=0; for(i=0;i<Blgt;i++){ out+=B[i]*x[n-i]; } for (i=1;i<Algt;i++){ out-=A[i]*y[n-i]; } y[n]=out; } } 19. Code 4 The filtiir() function 4.4.8 The waveshaper Waveshaping is a type of distortion synthesis which consists in applying to the signal a non-linear function. The distortion generated by a waveshaper is harmonic, which means that the spectral components added in the output signal are multiples of the harmonics that were present in the input signal. The choice of a polynomial function as waveshaping function allows to limit the band of the resulting signal. In fact, a polynomial function of degree N will add to the input signal up to N harmonics ([32]). On this basis it can be easily predicted whether passing a given digital signal through a waveshaper will generate aliasing in the signal. Computing polynomial functions of a high degree can be very CPUintensive. An alternative to computing polynomial functions on-the-fly is to read pre-computed values from a table. While on-the-fly computing method gives a continuous response, and allows for inputs >1 or <-1, on 97 the other hand the table-lookup method gives a quantized response, thus the table should be very large or else interpolation between its samples would be needed. Furthermore the input values must be clipped in the range [1,1). It has been found that with a non-interpolated table of 65536 samples and polynomials up to the third degree the two methods are equally faster, while for higher degrees the table-lookup method is much more efficient and has no limitations in the degree of the polynomial, and can also use tables that origin from other kinds of functions. As the purpose of this software is to be flexible and scalable, a function for each method has been written, while only the table-lookup one is actually called by the program. #include "wash1.h" double washtable(double a){/*WAVESHAPER look up table of length WAVESHAPER_N must be declared in included files.*/ if (a>MAX_SIGNAL) return WAVESHAPER[WAVESHAPER_N-1];/*a must be limited between MAX_SIGNAL and MIN_SIGNAL, otherwise it is clipped*/ if (a<MIN_SIGNAL) return WAVESHAPER[0]; return WAVESHAPER[(int)((a+1)/2.0*WAVESHAPER_N+.5)]; } #define WASHCOEFF_N 7 double washcoeff[WASHCOEFF_N]={1.004788129644182,0.4950691592538 86,-0.313495276667667,0.133623824894141,0.042531730800134,1.024943394186864,0.005144271811968}; //~ double washcoeff[WASHCOEFF_N]={6,5,4,3,2,1,0}; double washcompute(double a){ int i; double out=washcoeff[WASHCOEFF_N-1]; 98 for(i=1;i<WASHCOEFF_N;i++){ out+=pow(a,i)*washcoeff[WASHCOEFF_N-i-1]; } return out; } Code 5 Waveshaping functions The table-lookup implementation needs that the waveshaper values are in a properly-formatted external header file “wash1.h”. An Octave script is provided in [37] which, given the coefficients of a polynomial function, computes the values and writes the wash1.h file. 4.4.9 Noise For the noise generator an algorithm developed in 1997 by Makoto Matsumoto and Takuji Nishimura which is known as “Mersenne twister” is used [33]. This pseudo-casual random generator has a period of 219937 1 iterations, which is greater than 4.3 106001 . The generated numbers are equidistributed and this runs faster than other generators of the same class. The function used is based on the program coded by Matsumoto and Nishimura in 1997 and successive modifications, which is distributed under BSD license, and can thus be incorporated in this project as long as the license and disclaimer are included along with the source code. The modifications that have been done to the original code make the noise() function output 32bit floating-point values in the range [-1,1). The algorithm is initialized at each program run by calling the initNoise function and seeding it with the return value of the C time(). 99 As mentioned in 4.4.3 the noise has not been filtered. The value returned by noise() is simply multiplied by the desired noise amplitude. Given a SNR ratio in dB, the amplitude of the noise can be expressed as noiseAmp=10 SNR 20 (42) 4.4.10 The onboard LFO The “onboard” LFO capability is provided by the lfoGen function which prototype is double lfoGen(int preset, int channel, UWORD uTime, double sysFs) The uTime variable is the time in fixed-point format, as used in the rest of the program and as explained in great detail in 4.3.1. Internally, the lfoGen function converts it to floating-point time expressed in seconds in the variable Time. The function switches the given preset and channel and returns a floating-point value. An example of a return from the function is shown here for the preset 2: switch (channel){ case 0 : return .5*sin(pi2*Time*fslow+phs) + famp/2*sin(pi2*Time*ffast+phf); case 1 : return .5*sin(pi2*Time*fslow+phs+ph1) + . 5*famp*sin(pi2*Time*ffast+phf+ph1); case 2 : return .5*sin(pi2*Time*fslow+phs+ph2) + famp/2*sin(pi2*Time*ffast+phf+ph2); } 100 Where pi2=2 and ffast and fslow are the frequencies of – respectively – the fast and slow sinewaves. The phase argument of the sin() function deserves a particular attention. ph1 and ph2 are the relative phases of the second and third output – respectively – of the three-phases oscillators and are constants defined as static double ph1=2*M_PI/3;/*phase of second modulator*/ static double ph2=2*M_PI*2/3;/*phase of third modulator*/ Global variables phs and phf, on the other hand, are initialized to 0 and then updated by function reinitLfoGen at the end of SrcUD(). void reinitLfoGen(UWORD Time, double sysFs){ double t=(Time/32768.0 - Xoff)/sys; phs+= t*fslow*2*M_PI; phs=fmod(phs,2*M_PI); phf+= (t*ffast)*2*M_PI; phf=fmod(phf,2*M_PI); } This function takes as argument the fixed-point time at the moment when SrcUD() is returning to the caller, which corresponds to the elapsed samples, subtracts Xoff (padding offset in the input buffer) samples and calculates the phase of each LFO at that time and stores these value in the phs and phf variables, so that when, at the next call of the function, the *Time variable in SrcUD resets, the phase of the LFO's is preserved. The LFO modulates the clock frequency of the BBD, so that, being F s2 = 1 the clock frequency when the amplitude of the LFO is zero and T s2 w the modulation width in the range [0,1), the frequency at time t is given by 101 F s2 t = F s2 F s2 w lfo t = F s2 1 w lfo t (43) And the sampling period Ts2 becomes T s2 t = 1 F s2 t = F s2 T s2 1 = 1 w lfo t 1 w lfo t (44) 4.5 Modeling the characteristics of the Vermona Piano String chorus in BBDresample 4.5.1 General parameters As seen in 2.6, the chorus section of the Vermona Piano Strings consists of three ST1 boards, each including a TDA1022 IC, a clock oscillator, anti-aliasing and reconstruction filters. The modulation is provided by two three-phases LFO's. The number of stages in a TDA1022 is 512 and the number of delay lines available is 3, so in BBDresample the following constants must be defined: #define BBDBUCKS 512 #define NUMBER_OF_BBDS 3 4.5.2 Parameters of the filters of the ST1 board Two methods are outlined here for retrieving the coefficients of an IIR filter for a given frequency response. The analog-based method used for the anti-aliasing filter retrieves the filter coefficients analytically by 102 starting from the Laplace transform of a given analog system. On the other hand, the method used for the reconstruction filters takes as parameter the measured frequency response of a system and fits to it an arbitrary-length IIR filter. 4.5.2.1 The anti-aliasing filter The frequency response of the anti-aliasing filter has not been measured. Nonetheless. its behaviour is supposed to be adhering to the theoretical one, as the output impedance of the operational amplifier that drives its input is low and the input impedance of the TDA1022 which follows it is that of a MOS, so quite high. It has been implemented in the form of a IIR filter. The coefficients of the filter can be computed on the basis of the transfer function of the analog filter in the Laplace domain by transforming it in the Z-transform domain by means of the bilinear transform. This method allows to retrieve the coefficients of a time-discrete IIR filter which frequency response is equal to that of the analog filter considered starting by the Laplace transform of the analog filter. The Laplace transform of a first order passive analog low pass filter is given by [31]: G s = c s (45) c Where c =2 fc (46) is the cutoff frequency of the filter. The bilinear transform equation is : 103 s= 2 z 1 Ts z 1 (47) Where Ts is the sampling period of the digital system. Substituting the (47) in the (45), the Z-transform of the system is: G z = Y z c = X z 2 z 1 Ts z 1 1 z = c 2 cT s 1 1 1 (48) 2 cT s The coefficients of the numerator and denominator polynomials are the coefficients of the IIR filter. Equation (2) gives a cutoff frequency for the anti-aliasing filter FcAA=10261Hz. By substituting this into (46) and considering a sampling frequency Fs=44100 and Ts=1/Fs : cAA T s=2 f cAA 1 1 =2 10261 =1.4619 Fs 44100 (49) At last the (48) can be written for the anti-aliasing filter of the TS1 board as: 1 z G z= 1 2 1.4619 1 1 2 z 1.4619 = 1 1 z 1 2.368 0.368z 1 (50) The filter coefficients for the anti-aliasing filter are then: B={1,1} A={2.368 , 0.368} (51) The computed transfer function of an IIR filter with these coefficients is shown in Illustration XXI. Octave function first_order_low_pass_coeff() , which source code can be found in [37], can be used to compute the 104 coefficients of a first order passive lowpass filter, given the resistance and capacitance values of the analog components. In BBDresample the anti-aliasing filter is defined by the following parameters: int AAfilter_Blgt=2; int AAfilter_Algt=2; double AAfilter_B[AAfilter_Blgt]={1,1}; double Aafilter_A[AAfilter_Algt]={2.367982,-0.367982}; 4.5.2.2 The reconstruction filter The measurements made on the device in 3.4.4 revealed that the actual behaviour of the reconstruction filters on the ST1 board is quite different from that calculated in 2.6.1.4. Nevertheless, the measured behaviour is the one that has been emulated in BBDresample. In order to compute the filter coefficients for a given frequencyresponse, any of a number of digital filter design techniques can be used. An highly-accurate low-order IIR filter can be obtained by using the invfreqz Octave function. This function implements an FFT-based equation-error method which minimizes the error in the frequency domain [34]. By means of the the retrieving_filter_coeff.m Octave script, which can be found in Appendix A, one of the files recorded in 3.4.4 is read, the transfer function of the second channel against the first channel is computed and it is passed to the invfreqz function which returns the filter coefficients. The filter is then applied to the reference signal and the transfer function of the filter is computed and plot along with the measured one. The plot for a filter length of 5 is shown in Illustration 105 XXII. As can be seen, the frequency response and the phase response match almost exactly above 100Hz. The high pass filtering in the measured frequency response is caused by the coupling high-pass filter placed at the output of the reconstruction as already discussed in 2.6.1.4. The filter coefficients retrieved with this method do not show the effect of this filter as the invfreqz function weighs uniformly the values of the desired frequency response, and this the range 20Hz-100Hz is small compared to the 22050Hz of the audio band. By weighing differently the frequency response by passing an additional parameter to invfreqz, or by increasing the order of the filter, the frequency response of the filter can be made more similar to the measured one. It has been decided, nonetheless, that this high-pass filtering is non-necessary in this digital implementation, as it is mainly a consequence of an electronic constrain rather than a precise choice of the designer of the circuit, and furthermore its audible effect in the audio band is limited. The parameters retrieved for the reconstruction filter with the method above are defined in BBDresample as follows: int RECfilter_Blgt=5; int RECfilter_Algt=5; double RECfilter_B[RECfilter_Blgt]={-0.000970280898205, 0.025084538676200, 0.098919471890114, 0.055388793738097, -0.000448162789216}; double RECfilter_A[RECfilter_Algt]={1.000000000000000, -1.908763376321394, 1.945435616960158, -1.088255269315177, 0.330561974978888}; 106 4.5.3 Parameters of the TDA1022 4.5.3.1 Noise As previously discussed, noise filtering has not been modeled in this implementation. The three main reasons that have lead to this decision are: • filtering noise would have minimal effect on the overall result, because the spectrum of the noise is almost flat in the passband of the reconstruction filters and shows a maximum gain of about +6dB at higher frequencies which would be attenuated by the filters • filtering noise would be computationally expensive, as an additional FIR or IIR filter should be employed here • noise is generally an unwanted feature in an audio effect and the user would most likely want to turn it off From the measurements made in 3.4.1 results that SNR= 67.782dB, so the noise amplitude must as given by (42) is: noiseAmp=10 SNR 20 =10 67.782 /20 =0.00040823 (52) In BBDresample the following constant must be defined: double NOISEAMP=0.00040823 4.5.3.2 Frequency-dependent insertion gain As seen from the measurements made on the TDA1022 in 3.4.2, frequency-dependent insertion gain is mostly non-relevant for the high 107 clock frequencies used in chorus devices. The effect of the -2dB gain that has been measured at 20KHz would be almost canceled by the reconstruction filter which have a gain of -40dB at 20KHz. Generally speaking, as stated in [1], the global transfer function of the filters is usually such that frequencies near the Nyquist frequency are already so much attenuated that the effect of frequency-dependent insertion gain can be ignored. 4.5.3.3 Harmonic distortion Raffel and Smith in ([1], page 6) suggest the use of a waveshaper in order to model the harmonic distortion of the BBD. Only the first three harmonics are considered of relevance, as the higher ones have a negligible amplitude. It also reports that the characteristics of the measured harmonic distortions are similar for a wide range of amplitudes and the relative amplitude of the harmonic peaks is almost amplitude-independent, thus making it difficult to approximate the harmonic distortion with just one waveshaper. The harmonic distortion generated by a waveshaper is in fact by definition amplitude-dependent. Otherwise, as reported in 3.4.3, the measurements made on the TDA1022 reveal a different kind of distortion. It was then attempted to fit a single waveshaping function to a wide range of amplitudes and measure the difference between the computed and the measured values. The harmonic distortion measured on the 1001.29Hz sinusoids in the range of amplitude from 0dB to -20dB is shown in Illustration XI . Of the amplitudes shown, only those in the range [0 -13] show the presence of both the 2nd and 3rd harmonic. Only the sinusoids inside this range 108 were taken into account for the following analysis, which are devoted to find a waveshaping polynomial function of third degree, being relevant only the first three harmonics. For each of these input levels the amplitude of the first three harmonics of the output signal was computed using the thd.m script (Appendix A). The reference signal showed a little amount of harmonic distortion ( less than -75dB for the second harmonic and -100dB for the third). The amplitudes of the harmonics measured in the input signal were subtracted from the respective amplitudes in the inputs signal, weighted by the ratio between the amplitude of the output and input fundamentals. A waveshaping polynomial function of order three has been fitted to these values, using a custom script that writes a linear system with appropriate coefficients by means of a Pascal triangle and cosine multiplication formulas and solves it. See cawa.m in Appendix A. After all of the waveshaping functions had been computed, each of them has been evaluated between the +and- amplitude of the reference file with a step of 0.001, and the points obtained have been used to compute a polynomial fit of 3rd degree using Octave's polyfit function. The computed waveshaping functions have then been applied to each input signal in the range [-6 -18], and the magnitude of the obtained signals was compared with that of the measured output. The difference between the measured and computed magnitudes have been plotted and the mean squared error (MSE) of the estimator has been computed for each harmonic and as a global for each reference level. MSE values are reported in Table 1. Surprisingly, the polyfit function returned the worst results by far ( Illustration XXIII), reporting differences of more than 20dB on the third 109 harmonics. Of the other waveshaping functions, the minimum MSE was obtained from the one based on the -7dB signal Illustration XXIV. For each harmonic the difference between the measured and the computed amplitude of the first and second harmonic is comprised across all the measured range between -1.2dB and +0.6 dB. The resulting polynomial function is: y=0.075x 3 0.01768x 2 0.91289x 0.0058932 (53) The graph of the function in the [-1 ,1] range is plotted in Illustration XXV. The coefficients retrieved with this method have been used for the waveshaping function in the BBDresample software: int WASHCOEFF_N=4; double WASHCOEFF[WASHCOEFF_N]={0.074999901728955, 0.017679532761088, 0.912890447963023, -0.005893177587029}; 4.5.3.4 Presets At each program run the user can choose a preset via the -p command-line switch. Each preset sets the BBDclock, the presence of the direct channel in the output mix, the number of delay lines to process, the rescale divisor and the modulation width of the lfo. The values for the Vermona Piano Strings are shown below, and have been retrieved in 2.4.3, 2.5.3, 2.6.2, 3.4.5.2. switch (preset){ case 0 :/*slow*/ channels=1; direct=1; 110 rescale=2; BBDclock=63821; modwidth=40; break; case 3 :/*fast*/ channels=1; direct=1; rescale=2; modwidth=13; BBDclock=68175; break; case 1:/*chor1*/ case 2:/*chor2*/ channels=3; direct=0; rescale=3; modwidth=40; BBDclock=63821; break; 4.6 Comparing the modeled and physical devices In this section some of the tests performed in Part 3 on the physical device are performed on the digital model and the results are compared. Unfortunately by the time of this final tests one of the ST1 boards had ceased working and thus tests on presets that involved more than one board could not be performed. Furthermore, as discussed in 3.4.5, the slow LFO was not working properly so the only test involving modulation was performed on the fast LFO. 111 4.6.1 Harmonic-distortion By typing the following code on the command line BBDresample -p 4 -w 0 -b -g 0.5 sin1001.wav BBDhd.wav; The test tone sin1001 is processed by BBDresample in dry-only mode and without modulation, bypassing the filters. The result of the comparison is shown in Illustration XXVIII. The harmonic contents of the two signals nearly match for the first three harmonics, while higher harmonics are not showing in the modeled signal as the order of the polynomial waveshaping function has been limited to 3, as discussed in 4.5.3.3. 4.6.2 Aliasing BBDresample -e -p 4 -w 0 -b cref.wav out.wav; The chirp test tone is processed by BBDresample in dry-only mode and without modulation, bypassing the filters. In this test the clock of the BDB is set to 100KHz. The results are shown in Illustration XXXI. In order to allow the upper harmonics to alias and foldback, a polynomial waveshaper of the 7th degree has been used. This test shows that the delay line implementation gives the expected results with respect to spectral aliasing. The upper harmonics generated inside the BBD by harmonic distortion fold back around the Nyquist frequency of the BBD and eventually fold back in the audio band. 112 4.6.3 Modulation BBDresample -p 5 -w 20 -b -g 0.5 sin500.wav BBDmodulate.wav A sinewave at 500Hz is processed by BBDresample with the fast LFO and a 20% modulation width. The filters are bypassed. The clock of the BBD is set to 68175Hz. The same processing has been recorded from the TS1 board. The spectrogram of the obtained signals is shown in Illustration XXXII. The two spectrograms are very similar between each other. While the modulation width and the modulation frequency match, a zoomed-in view (Illustration XXXIII) shows that the modulating waveforms appear to be slightly different. Probably the analog fast LFO has a waveform that is not a pure sinusoid but has also some higher harmonics which influence the modulated response. Nevertheless, the results obtained by the model in this respect show a significant adherence to the behaviour of the modeled device. 113 5 CONCLUSIONS The physical model of a Bucket Brigade Device circuit as proposed by Raffel and Smith has been implemented in a new software called BBDresample, based on the existing software resample written by Smith himself. BBDresample provides multiple resampled modulated delay lines that emulate the behaviour of BBD's, along with anti-aliasing and reconstruction IIR filters, waveshaping harmonic distortion, noise and an on-board multiple LFO generator. BBDresample is distributed under LGPL license. The core of the software is the delay line, which overcomes the intrinsic limitations of the previously available implementations reviewed in 1.4.2, by allowing for any ratio between the BBD clock and the system sampling rate and using bandlimited interpolation for resampling purposes. By properly setting the BBD frequency and modulation width, a wide range of flanging and chorus effects can be obtained. This solid delay line core can be reused in other applications involving emulations of BBD's such as reverberators, phasers and delays. The software currently emulates the filters, non-linearities and presets of the TS1 chorus boards of the Vermona Piano Strings, a strings machine from the late seventies made in DDR by Vermona. GNU Octave scripts that have been used for the analysis and definition of the parameters are provided to the reader and could easily be re-used in order to perform an analogue analysis of a similar device, and possibly use it to expand the effect library of BBDresample. 114 Bucket-brigade devices are one of the few circuitry that belong to the uncommon category of discrete-time, but non-digital circuitry. In spite of their non-digital nature, being them discrete-time they suffer of spectral aliasing. Proper anti-aliasing filtering always show up in BBD based circuits but some aliasing is nevertheless generated by the harmonic distortion that takes place inside the device itself. Furthermore, many delay and flanger units have a clock whose Nyquist frequency falls inside the audio range. The aliasing generated by the BBD is a characteristic of the analog device that has been taken into account and recreated in this implementation. The interpolating filters have a cutoff frequency fixed to the system Nyquist frequency and the waveshaper which causes harmonic distortion is placed right after the first interpolator which marks the beginning of the discrete-time domain of the BBD. In this way, the harmonic distortion takes place “inside” the BBD, which output is then resampled back to system sampling rate. The comparison between the model and the modeled device has been performed by processing the same test tones in the digital model and in the physical device, and the results are promising. The delay line behaves as expected, correctly aliasing the frequencies above the Nyquist frequency of the BBD. The modulation effects could not be compared extensively with the physical device as the electronic slow LFO showed a different waveform than the sinewave graphed in the schematics, but there was no mean of analyzing it, as none of the soundcards available was able to acquire a waveform with such a low frequency (0.6Hz). The comparison with the modulation of the faster LFO proved to be successful as the resulting effects are very closelysounding, even though a zoom in the spectrogram of both the digital- 115 processed and the analog-processed signals reveals that the latter seems to be modulated by a non-perfect sinewave. 5.1 Future work Though the software presently has a command-line-only interface, a plugin version is currently under development in order to make the underlying algorithm available for realtime signal processing in a DAW or other realtime audio processing environments such as PureData, SuperCollider etc. The current implementation with multiple delay lines resampled using bandlimited interpolation is rather computationally expensive. While BBDresample is able to perform command-line processing much faster than realtime, using the same algorithm in a realtime environment along with possibly a huge amount of other plugins running may require some simplifications in the algorithm, i.e. reducing the length of the interpolation convolution, replacing the interpolation algorithm with a faster one, enlarging the look-up table of the filter used for bandlimited interpolation and thus avoid the linear interpolation presently used while reading from the lookup table. Furthermore, the resampling bandlimited interpolator used, which is almost entirely based on that of resample, has some constraints that limit the frequency of the interpolating filter to a maximum value of twice the clock of the BBD. This means that for very low (<10Khz) clocks the aliased frequencies cannot be entirely reconstructed. This is mostly of no concern as the reconstruction filters would usually cutoff them nonetheless. 116 As for the modeling of the Vermona Piano Strings, a proper digitization of the LFO waveforms is missing and should be performed in order to recreate a more realistic LFO model, as the implementation uses simple sinewaves. 117 presently APPENDIX A – OCTAVE CODE thd.m # [harmonics pthd]=thd(outsml,F,[, threshold=-Inf verbose=1 "lin" "db" "f0" "l10" "pNaN"]) # Performs a thd analysis of the spectrum oustml. Default values are shown above. # # harmonics is a matrix containing # in the first col the magnitude, # in the second the bin frequency, # in the third the bin number, # in the fourth the power. # in the fifth the order of the harmonic # if two values are requested, pthd is the percentage of thd # outsml must be a real FFT , could be dB's(should be normalized to 0) or linear (should be normalized to 1) # assumes that outsml has been retrieved using a Hann function. # Otherwise, column 4 must be multiplied by 1.5 and then divided by the noise-power bandwidth of the window (1 for rectangular). # Other columns are unaffected. # F is the frequency vector of the FFT # threshold is the threshold below which the harmonic is not detected # If verbose is a "no" , no output will be displayed on the terminal, otherwise a pretty-formatted table containing the results is printed # f0 0 is the frequency assumed to be fundamental, if not provided tries autodetect # l10 10 is the maximum number of harmonics returned. 0 means no limit (limited by f0 and Fs/2)function [harmonics, thdp]=thd(outsml,F,varargin # if harmonics in the explicit limit range are below the explicit threshold and a "pad" or "p[value]" argumentis passed (such as pNaN, # they will be shown as [value] if specified or as "-Inf" or "0" depending on the lin/dB method used function [harmonics, thdp]=thd(outsml,F,varargin) if !isnumeric(F) || length(F)!=length(outsml) 118 usage("second argument must be an array of frequencies of the same length as outsml") endif if columns(outsml)>1 outsml=outsml'; endif verbose=1; pad=0; threshold=-Inf; limit=0; #tries to guess if data is dB or linear, and defaults to dB if min(outsml)<0 && max(outsml)<=0 lin=0; elseif min(outsml)>=0 lin=1; else lin=0; endif if numel(varargin)>0 for i=1:length(varargin) check=varargin{i}; if ischar(check) if strcmpi(check,"no") verbose=0; elseif strcmpi(check,"yes") verbose=1; elseif strcmpi(check,"lin") lin=1; elseif strcmpi(check,"db") lin=0; elseif strcmpi(check,"pad") pad=1; elseif strcmpi(check(1),"p") pad=1; padd=str2num(check(2:end)); elseif check(1)=="f" f0=str2num(check(2:end)); elseif check(1)=="l" limit=str2num(check(2:end)); endif else threshold=check; endif endfor endif if lin==0 linv="dB"; 119 form=" %8.2f "; else linv="linear"; form=" %8.6f "; endif hfs=length(outsml); if exist("f0","var") [n fundbin]=min(abs(F-f0)); else %tries to autodetect [fundval fundbin]=max([-Inf; -Inf; -Inf; outsml(4:end)]); %ignores first two bins endif i=fundbin; harmonics=[]; harmanalysisstring=[]; c=1; while i<=hfs-3 && i>0 if outsml(i)>=threshold harmonics(end+1,1)=outsml(i);%magnitude harmonics(end,2)=F(i);%frequency harmonics(end,3)=i;%bin linval= outsml(i-3:i+3); if !lin linval=10.^(linval/20); endif harmonics(end,4)=sum(linval.^2); harmonics(end,5)=c;%order harmanalysisstring=[harmanalysisstring; sprintf([" %3d | %5d | %9.3f |" form "| %.9f"], harmonics(end,5), harmonics(end,3), harmonics(end,2), harmonics(end,1), harmonics(end,4))]; endif i+=fundbin-1; range=clip([i-2 : i+2],[1 hfs]); [harmval harmbin]=max(outsml(range)); harmbin+=i-3; i=harmbin; if c==limit break; endif c++; endwhile if length(harmonics)==0 if verbose disp("No bin was above the set threshold"); endif thdp=NaN; return endif 120 # thdp=100*sum(harmonics(2:end,4))/harmonics(1,4); # power definition thdp=100*sqrt(sum(harmonics(2:end,4))/harmonics(1,4)); # amplitude definition if pad && limit && rows(harmonics)<limit if !exist("padd","var") if lin==1 padd=0; else padd=-Inf; endif endif harmonics=[harmonics; zeros(limit-rows(harmonics),5)]; for c=1:limit if harmonics(c,5)!=c harmonics(c:end+1,:)=[padd 0 0 0 c; harmonics(c:end,:)]; endif endfor harmonics=harmonics(1:limit,:); endif if verbose sumup=[ "data has been treated as " linv "."]; sumup=[sumup; sprintf("\nStrongest harmonic found at bin %d, bin frequency %f;\nExtimated frequency (mean of diffs) is %f; ", harmonics(1,3), harmonics(1,2), mean(diff(harmonics(:,2))) ) ]; sumup=[sumup; sprintf("Threshold as been set to %.1f\n\n thd is %f%%",threshold,thdp)]; disp([ "\n---------------------" "\nHarmonic analysis:" sumup "\norder| bin | frequency | magnitude | power" harmanalysisstring]); endif 121 retrieving_filter_coeff.m #given an input file containing reference and processed signals, computes the transfer function and retrieves the #coefficients of a stable IIR filter of given length which #approximates the given transfer function. nA=4; #order of the denominator polynomial nB=4; #order of the numerator polynomial x=wavread("chirp1001Hz_100s_-2dB.wav"); #file must be deal(x,y) X=fft(x)(1:end/2); Y=fft(y)(1:end/2); Z=Y./X; stereo binsize=fs/(length(Z)*2); F=[0:binsize:fs/2-binsize]'; [B,A]=invfreqz(Z,pi*F/(fs/2),nA,nB); if max(abs(roots(A)))>1 #if there are poles outside the unitary circle warning("filter instable, trying to polystab it") A=polystab(A); #may induce phase distorsions endif y2=filter(B,A,x); Y2=fft(y2)(1:end/2); Z2=dec(Y2./X,decim); B*=1/(max(abs(Z2))); #normalization 122 cawa.m # function as=cawa(harm,amplitude=1,lin) # CAlculates WAveshaper coefficients # given an array harm of harmonic strength and the amplitude=max(abs(input)) of the input signal computes the waveshaper coefficients # harm must contain the amplitudes of the first harmonics, ordered as follows: # [ dc fund 2nd 3rd . . . . ] # Tries to automatically detect if the input is given as dB or linear, or this could be specified with the # third parameter "lin" or "dB" function as=cawa(harm,a=1,lin) Nmax=10; #maximum number of harmonics computable, additional values are ignored if !exist("lin","var") if max(harm)<=0 lin="dB"; elseif max(harm)<=1 && min(harm)>=0 lin="lin"; else error("Couldn't guess if lin or dB, please specify with the second parameter \"lin\" or \"dB\"."); endif endif if strcmpi(lin,"db") harm=10.^(harm/20); endif if rows(harm)<columns(harm) #rotates if harm is row harm=harm'; endif for N=length(harm):-1:1 #removes 0 paddings from the end of harm if harm(N)!=0 && harm(N)!=NaN break endif endfor pascal=trpascal(N); #retrieves a N-by-N lower triangular matrix filled with the coefficients of the pascal triangle M=zeros(N); M(1,end)=1; #sets up a linear system of equations for k=1:N-1 #row length m=(k/2); 123 per=1/2^(k-1); for j=1:k h=( abs(round(m-j) ) -1 )*2+1+1-mod(k,2); val=a^k*pascal( k,j)/(2^(k-1)); M(h+1,N-k)+=val; endfor endfor harm=harm(1:N); as=M\harm; #solves the linear system 124 APPENDIX B – C CODE int SrcUD( FLOAT X[],/*pointer to the first element to be processed in the input buffer*/ FLOAT Y[],/*pointer to the first element to be written in the input buffer*/ UWORD *Time,/*the time accumulator*/ UHWORD Nx,/*number of samples to process*/ UHWORD Nwing,/*number of samples in the filter table*/ UHWORD LpScl,/*unitary gain rescale factor of the filter table*/ HWORD Imp[],/*pointer to a table of filter values*/ HWORD ImpD[],/*pointer to a table of differences filter values*/ BOOL Interp, /*use filter interpolation?*/ FLOAT X2[], /*pointer to the first element of the external lfo buffer*/ int channels, /*number of channels to process*/ double rescale,/*rescale coefficient for output samples*/ int onboard,/*use onboard lfo?*/ double sysFs)/*system sampling rate*/ { extern double bbd[]; extern double gain; extern double BBDclock;/*BBD clock frequency*/ extern double modwidth;/*BBD modulation width*/ static BOOL init =0; static double T2f;/*step through bbd samples, floating point*/ static UWORD T2i;/*step through bbd samples, fixed point*/ static UWORD T2[NUMBER_OF_BBDS];/*intialized below*/ static double T2lfo; static int BBDindex[NUMBER_OF_BBDS]={0}; static double amp1; static double amp2; static double lfo=0; double z0,z1,w; /*interpolator parameters*/ UWORD wi; int Xp; int ch; int rread; double width=modwidth/100; double v; static UWORD t; /*time variables*/ static UWORD oldBBDevent[NUMBER_OF_BBDS];/*initialized below*/ 125 static UWORD nextBBDevent[NUMBER_OF_BBDS];/*initialized below*/ static UWORD nextTevent; double dhw; UWORD dhbw; if (!init){/*first time initialization*/ for (ch=0;ch<channels;ch++){ oldBBDevent[ch]+=*Time-T2[0]; nextBBDevent[ch]+=*Time; T2[ch]=T2i; amp1=gain*.9; amp2=(2-gain)*.4; } initNoise(time(NULL));/*seed noise generator*/ T2f=sysFs/BBDclock; T2i=(UWORD)(T2f*(1<<Np)+.5); init=1; } else{ /*reinizialization*/ for (ch=0;ch<channels;ch++){ oldBBDevent[ch]+=*Time-nextTevent; nextBBDevent[ch]+=*Time-nextTevent; } } UWORD startTime=*Time; UWORD endTime=0; FLOAT *Ystart = Y; for (ch=0;ch<channels;ch++){ *Time=startTime; nextTevent=*Time; Y=Ystart; while ( *Time-startTime >>Np < Nx ){ Xp = *Time>>Np; /* index of X[] to current input sample */ if (*Time==nextBBDevent[ch]){ if (onboard==1) lfo=lfoGen(ch,*Time,sysFs); else lfo=X2[Xp]; /*external lfo, no interpolation performed*/ T2lfo= T2f/(width*lfo+1); dhw = Npc; /* Filter sampling period min(Fs,Fs')*/ dhbw = dhw*(1<<Na) + 0.5; /* Fixed-point representation*/ T2[ch]=(UWORD)( (T2lfo)*(1<<Np) +.5); BBDindex[ch]=(BBDindex[ch]+1)%BBDSIZE; /*increment in the circular buffer*/ w=(*Time&Pmask)/32768.0; /*relative position between X[Xp] and X[Xp+1] of the current time instant */ v = FilterUD(Imp, ImpD, Nwing, Interp, Xp, (HWORD) (*Time&Pmask),-1, dhbw, X,0); /* Perform left-wing inner product */ v += FilterUD(Imp, ImpD, Nwing, Interp, Xp+1,(HWORD) ((((*Time)^Pmask)+1)&Pmask),1, dhbw, X,0); /* Perform right-wing inner product */ 126 bbd[ch][BBDindex[ch]]= washcompute(v*amp1) + noise()*NOISEAMP; oldBBDevent[ch]=*Time; nextBBDevent[ch]=*Time + T2[ch]; } if (*Time==nextTevent){ dhw = MIN(2*Npc-1,Npc*T2lfo); /* Filter sampling period */ dhbw = dhw*(1<<Na) + 0.5; /* Fixed-point representation*/ rread=(BBDindex[ch]-BBDDEL+BBDSIZE-1)%BBDSIZE; z0=bbd[ch][ rread ]; z1=bbd[ch][ (rread+1)%BBDSIZE]; w=(*Time-oldBBDevent[ch])/(double)(T2[ch]); wi=(UWORD)(w*32767+.5); v = FilterUD(Imp, ImpD, Nwing, Interp, rread, (HWORD) (wi&Pmask),-1, dhbw, bbd[ch],BBDSIZE); /* Perform left-wing inner product */ v += FilterUD(Imp, ImpD, Nwing, Interp, (rread+1)%BBDSIZE, (HWORD)((((wi)^Pmask)+1)&Pmask),1, dhbw, bbd[ch],BBDSIZE); /* Perform right-wing inner product */ *Y++=*Y+ T2lfo*amp2*v/rescale; nextTevent=*Time+(1<<Np); } *Time=MIN(nextTevent,nextBBDevent[ch]); } endTime=MAX(endTime,*Time); } reinitLfoGen(*Time,sysFs); t=endTime; return (Y - Ystart); /* Return the number of output samples */ } 127 APPENDIX C – TABLES Reference 1st harmonic 2nd harmonic 3rd harmonic level MSE MSE MSE POLYFIT 0.01 15.43 99.67 0 0.3 0.49 0.11 -1 0.02 1.03 0.21 -2 0.01 0.74 0.11 -3 0.01 0.57 0.11 -4 0.01 0.44 0.12 -5 0 0.34 0.12 -6 0 0.28 0.12 -7 0 0.26 0.12 -8 0 0.26 0.12 -9 0 0.28 0.14 -10 0 0.31 0.15 -11 0.01 0.34 0.17 -12 0.01 0.38 0.18 -13 0.01 0.42 0.2 Total MSE 20.85 0.32 0.45 0.31 0.24 0.2 0.16 0.14 0.13 0.13 0.14 0.16 0.17 0.19 0.21 Table 1 Errors in the harmonic amplitudes for different 3rd degree polynomial waveshaping functions CV Voltage Time/Div (s) (V) 1.5 5.00E-006 2.5 5.00E-006 3.5 5.00E-006 4.5 5.00E-006 5.5 5.00E-006 6.5 5.00E-006 7.5 5.00E-006 8.5 5.00E-006 9.5 5.00E-006 10.5 5.00E-006 11.5 5.00E-006 12.5 5.00E-006 13.5 5.00E-006 Divs Periods 8.4 8.6 9.2 9.6 7.6 8.2 8.6 9.2 9.6 7 7.4 8.2 8.8 4 4 4 4 3 3 3 3 3 2 2 2 2 Table 2 measures of the clock frequency F voltages 128 Frequency (Hz) 95238.10 93023.26 86956.52 83333.33 78947.37 73170.73 69767.44 65217.39 62500.00 57142.86 54054.05 48780.49 45454.55 of the TDA1022 at different CV Input Input level level T.H.D Amplitudes(dB) h2 h3 h4 h5 h6 (dBFS) (Vrms) (%) h1 0 0.99 1.3 -1.97 -40.62 -47.52 -56.13 -64.14 -72.45 -1 0.88 1.08 -2.96 -42.95 -51.18 -61.36 -70.2 -80.35 -2 0.79 0.92 -3.94 -45.13 -54.49 -66.34 -75.85 -87.3 -3 0.7 0.8 -4.93 -47.27 -57.6 -71.09 -81.36 NaN -4 0.62 0.7 -5.92 -49.4 -60.61 -75.63 -86.71 NaN -5 0.56 0.61 -6.91 -51.53 -63.62 -79.96 NaN NaN -6 0.5 0.53 -7.9 -53.66 -66.62 -84.34 NaN NaN -7 0.44 0.46 -8.89 -55.78 -69.63 -88.4 NaN NaN -8 0.39 0.4 -9.89 -57.89 -72.64 NaN NaN NaN -9 0.35 0.36 -10.88 -59.98 -75.67 NaN NaN NaN -10 0.31 0.31 -11.88 -62.05 -78.69 NaN NaN NaN -11 0.28 0.28 -12.88 -64.11 -81.73 NaN NaN NaN -12 0.25 0.24 -13.87 -66.17 -84.73 NaN NaN NaN -13 0.22 0.22 -14.87 -68.22 -87.7 NaN NaN NaN -14 0.2 0.19 -15.87 -70.26 NaN NaN NaN NaN -15 0.18 0.17 -16.87 -72.28 NaN NaN NaN NaN -16 0.16 0.15 -17.87 -74.28 NaN NaN NaN NaN -17 0.14 0.13 -18.87 -76.31 NaN NaN NaN NaN -18 0.12 0.12 -19.87 -78.31 NaN NaN NaN NaN -19 0.11 0.11 -20.87 -80.35 NaN NaN NaN NaN -20 0.1 0.09 -21.87 -82.36 NaN NaN NaN NaN -21 0.09 0.08 -22.87 -84.33 NaN NaN NaN NaN -22 0.08 0.08 -23.87 -86.3 NaN NaN NaN NaN -23 0.07 0.07 -24.87 -88.24 NaN NaN NaN NaN -24 0.06 0 -25.87 NaN NaN NaN NaN NaN -25 0.06 0 -26.87 NaN NaN NaN NaN NaN -26 0.05 0 -27.87 NaN NaN NaN NaN NaN -27 0.04 0 -28.86 NaN NaN NaN NaN NaN -28 0.04 0 -29.86 NaN NaN NaN NaN NaN -29 0.04 0 -30.86 NaN NaN NaN NaN NaN -30 0.03 0 -31.86 NaN NaN NaN NaN NaN Table 3 Harmonic distortion of the TDA1022 at different input levels. Threshold was set to -90dB 129 h7 -78.82 -88.11 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN h8 -84.58 NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN NaN APPENDIX D - ILLUSTRATIONS Illustration I frequency response of the Sallen-Key filters Illustration II The Hann function 130 Illustration III background noise PSD Illustration IV background noise PSD (detail) 131 Illustration V background noise PSD(detail) Illustration VI Frequency response of the TDA1022 132 Illustration VII transfer function of the TDA1022 Illustration VIII transfer function of the TDA1022 after phase correction 133 Illustration IX Spectrogram of the TDA1022 response to a linear chirp with a test amplitude of 0dB Illustration X Spectrogram of the TDA1022 response to a linear chirp with a test amplitude of -10dB 134 Illustration XI measured harmonic amplitudes with a sine wave input at different levels Illustration XII measured harmonic amplitudes with a sine wave input at different levels (detail) 135 Illustration XIII measured transfer function of the reconstruction filter Illustration XIV measured total harmonic distortion of the TDA1022 Vs input level 136 Illustration XV the sinc function sinc t =sin t t Illustration XVI CV-frequency relation of the BBD clock oscillator 137 138 139 140 Illustration XXI transfer function of the low pass anti-aliasing filter Illustration XXII measured and computed transfer functions for the reconstruction filter 141 Illustration XXIII difference between the real harmonic amplitude and the one computed using a waveshaping function with the coefficients returned by polyfit() Illustration XXIV difference between the real harmonic amplitude and the one computed using a waveshaping function with the coefficients based on the harmonic distortion at -7dB 142 Illustration XXV the waveshaping function implemented in BBDresample Illustration XXVI THD of the TDA1022(from original datasheet [29]) 143 Illustration XXVII comparative plot of the measured and computed transfer functions of the reconstruction filter Illustration XXVIII: comparative plot of the real and modeled harmonic content 144 Illustration XXIX frequency-dependent insertion gain (from the TDA1022 datasheet) Illustration XXX transfer function of the TDA1022 after phase correction at multiple test levels 145 146 Illustration XXXII spectrograms of a 500Hz sine tone processed by the physical device(top) and by BBRresample(bottom) 147 Illustration XXXIII spectrograms of a 500Hz sine tone as processed by the physical device(top) and by BBRresample(bottom) 148 FIGURE INDEX Figure 1 A antiphase-clock Bucket-Brigade circuit (TDA1022)........................................................22 Figure 2: Block diagram of the Vermona Piano Strings.....................................................................26 Figure 3 The master clock and top octave generator circuit...............................................................27 Figure 4 The top-octave generator output waveform.........................................................................28 Figure 5 The master oscillator output waveform................................................................................28 Figure 6: Keying circuit, oscillator mixer and envelope generators...................................................29 Figure 7 The waveform resulting from the sum of the fundamental square wave and two of its harmonics............................................................................................................................................30 Figure 8: The waveform resulting from the sum of the fundamental square wave and his second harmonic.............................................................................................................................................30 Figure 9 Three band equalizer for the piano section...........................................................................31 Figure 10 Three-band equalizer for the strings section......................................................................33 Figure 11 schematics of the adapter board that matches the TDA1022 to the pinout of the TCA350Y............................................................................................................................................35 Figure 12 Schematics of the ST1 board..............................................................................................36 Figure 13 Typical second-order Sallen-Key filter...............................................................................37 Figure 14 Schematics of the two modulation sources........................................................................39 Figure 15 waveforms of the slow(left) and fast(right) LFO...............................................................40 Figure 16 Analog-based resampling method......................................................................................66 Figure 17 Ideal low pass filter response.............................................................................................68 Figure 18 Response of a truncated ideal low pass filter.....................................................................69 Figure 19 Response of a Kaiser windowed ideal low pass filter........................................................69 Figure 20 the Time variable...............................................................................................................74 Figure 21 Illustration of waveforms and parameters of the interpolating function............................81 Figure 22 graphical representation of the parameters used by a generic interpolating function........90 149 ILLUSTRATION INDEX Illustration I frequency response of the Sallen-Key filters...............................................................130 Illustration II The Hann function......................................................................................................130 Illustration III background noise PSD..............................................................................................131 Illustration IV background noise PSD (detail)..................................................................................131 Illustration V background noise PSD(detail)....................................................................................132 Illustration VI Frequency response of the TDA1022........................................................................132 Illustration VII transfer function of the TDA1022............................................................................133 Illustration VIII transfer function of the TDA1022 after phase correction.......................................133 Illustration IX Spectrogram of the TDA1022 response to a linear chirp with a test amplitude of 0dB ...........................................................................................................................................................134 Illustration X Spectrogram of the TDA1022 response to a linear chirp with a test amplitude of -10dB.................................................................................................................................................134 Illustration XI measured harmonic amplitudes with a sine wave input at different levels ..............135 Illustration XII measured harmonic amplitudes with a sine wave input at different levels (detail). 135 Illustration XIII measured transfer function of the reconstruction filter..........................................136 Illustration XIV measured total harmonic distortion of the TDA1022 Vs input level.....................136 Illustration XV the sinc function ......................................................................................................137 Illustration XVI CV-frequency relation of the BBD clock oscillator..............................................137 Illustration XVII block diagram of a typical chorus device with multiple BBD's...........................138 Illustration XVIII block diagram of a single delay line....................................................................138 Illustration XIX the signal flow of the BBD model as implemented in BBDresample ...................139 Illustration XX block diagram implemented in BBDresample........................................................140 Illustration XXI transfer function of the low pass anti-aliasing filter...............................................141 Illustration XXII measured and computed transfer functions for the reconstruction filter..............141 Illustration XXIII difference between the real harmonic amplitude and the one computed using a waveshaping function with the coefficients returned by polyfit()....................................................142 Illustration XXIV difference between the real harmonic amplitude and the one computed using a waveshaping function with the coefficients based on the harmonic distortion at -7dB...................142 Illustration XXV the waveshaping function implemented in BBDresample....................................143 Illustration XXVI THD of the TDA1022(from original datasheet [29])..........................................143 Illustration XXVII comparative plot of the measured and computed transfer functions of the reconstruction filter...........................................................................................................................144 Illustration XXVIII: comparative plot of the real and modeled harmonic content...........................144 Illustration XXIX frequency-dependent insertion gain (from the TDA1022 datasheet)..................145 Illustration XXX transfer function of the TDA1022 after phase correction at multiple test levels..145 150 Illustration XXXI spectrograms of a linear chirp tone as processed by the physical device(top) and by BBRresample(bottom).................................................................................................................146 Illustration XXXII spectrograms of a 500Hz sine tone processed by the physical device(top) and by BBRresample(bottom)......................................................................................................................147 Illustration XXXIII spectrograms of a 500Hz sine tone as processed by the physical device(top) and by BBRresample(bottom).................................................................................................................148 151 BIBLIOGRAPHY [1] Raffel C. and Smith J.O. "Practical modeling of bucket-brigade device circuits", Proc. of the 13th Int. Conference on Digital Audio Effects (DAFx-10), Graz, Austria , September 6-10, 2010 [2] Sachs C. “The history of musical instruments”, 1940 [3] Canazza S. and Avanzini F. “Virtual analogue instruments:an approach to active preservationof the Studio di Fonologia Musicale”, in The Studio di Fonologia - A Musical Journey, 2012, edited by Maddalena Novati and John Dack, published by Ricordi [4] Smith, J.O. "Physical Audio Signal Processing", http://ccrma.stanford.edu/~jos/pasp/, online book, accessed 15/4/2013 [5]"Sampler(musical instrument)", http://en.wikipedia.org/wiki/Sampler_(musical_instrument) , accessed 16/4/2013 [6] Smith, J.O. "Spectral audio signal processing", https://ccrma.stanford.edu/~jos/sasp/, online book, accessed 15/4/2013 [7] De Sanctis and G. Sarti A., "Virtual Analog Modeling in the Wave-Digital Domain" in IEEE transactions on audio, speech, and language processing, vol. 18, no. 4, May 2010 [8] Fettweis A. "Wave digital filters theory and practice" in Proceedings of the IEEE, vol. 74, no. 2, february 1986 [9] Yeh D.T., Abel J.S., Smith J.O. "Automated Physical Modeling of Nonlinear AudioCircuits For Real-Time Audio Effects--Part I:Theoretical Development", in IEEE transactions on audio, speech, and language processing, vol. 18, no. 4, May 2010 [10] Gleason B., "Real-time digital modeling of analog circuitry for audio applications", Worcester Polytechnic Institute, 2010, http://www.wpi.edu/Pubs/E-project/Available/E-project-042910160139/unrestricted/Bryan_Gleason_MQP.pdf [11] Hélie T. "Volterra Series and State Transformation for real-time simulations of audio circuits including saturations: application to the Moog ladder filter", in IEEE transactions on audio, speech, and language processing, vol. 18, no. 4, May 2010 [12] Civolani M. and Fontana F. "Modeling of the EMS VCS3 Voltage-Controlled Filter as a nonlinear filter network", in IEEE transactions on audio, speech, and language processing, vol. 18, no. 4, May 2010 [13] Abel J., Nam J., Smith J.O. and Välimäki V. "Efficient Antialiasing Oscillator Algorithms Using Low-Order Fractional Delay Filters", in IEEE transactions on audio, speech, and language processing, vol. 18, no. 4, May 2010 [14] Bilbao S. and Parker J. "A Virtual Model of Spring Reverberation", in in IEEE transactions on audio, speech, and language processing, vol. 18, no. 4, May 2010 [15] Bank B., Fontana F. and Zambon S. "A Modal-Based Real-Time Piano Synthesizer", in IEEE transactions on audio, speech, and language processing, vol. 18, no. 4, May 2010 [16] Matignon D., Mignot R., Hélie T. "Digital waveguide modeling for wind instruments: building a state-space representation based on the webster-lokshin model", in IEEE transactions on audio, speech, and language processing, vol. 18, no. 4, May 2010 [17] Blaauw M., Bonada J., Guaus E., Maestre E., Perez, A. "Statistical Modeling of Bowing Control Applied to Violin Sound Synthesis", in IEEE transactions on audio, speech, and language processing, vol. 18, no. 4, May 2010 [18] Bilbao S. "Percussion Synthesis Based on Models of Nonlinear Shell Vibration", in IEEE 152 transactions on audio, speech, and language processing, vol. 18, no. 4, May 2010 [19] Koch T., Popp C. and Rabenstein, R. "Tubular Bells: A Physical and Algorithmic Model", in IEEE transactions on audio, speech, and language processing, vol. 18, no. 4, May 2010 [20] Avanzini F., Marogna R. "A Modular Physically Based Approach to the Sound Synthesis of Membrane Percussion Instruments", in IEEE transactions on audio, speech, and language processing, vol. 18, no. 4, May 2010 [21] Abel J.S., Fontana F., Lazzarini V., Pakarinen J., Valimaki V., "Recent Advances in Real-Time Musical Effects,Synthesis, and Virtual Analog Models", Manuscript for Eurasip Jasp, special issue on musical applications of real-time signal processing, Dec. 2011 [22] Fontana F., Smith J.O., Välimäki V., Zolzer U. "Introduction to the Special Issue on Virtual AnalogAudio Effects and Musical Instruments", in IEEE transactions on audio, speech, and language processing, vol. 18, no. 4, May 2010 [23] Raffel C., "Model of a Bucket Bridage Device delay using STK" , http://colinraffel.com/software/bbdmodeling/echo.cpp, computer software, accessed 16/4/2013 [24] Cook P.R. and Scavone G. P., "STK, The Synthesis ToolKit", computer software, https://ccrma.stanford.edu/software/stk/, accessed 16/4/2013 [25] Bayfield T. "Digital Modeling of Analog Delay Effects Employing the Bucket Brigade Device", final project for the Computational Modelling for Sound Synthesis course 2012, http://www.cs.sfu.ca/~tamaras/cmpt889projects/tristan/index.html, accessed 13/8/2012 [26] Crochiere R. E. and Rabiner L. R "Multirate digital signal processing", 1983, ISBN 0-13605162-6, Prentice-Hall, Inc. [27] Vermona Piano Strings Schematics, Vermona [28] Biondo G. and Sacchi E. "Manuale di elettronica e telecomunicazioni", 1996, Hoepli [29] Harvey A.F. and Cerna M. "The Fundamentals of FFT-Based Signal Analysis and Measurement", Application Note 04, National Instruments, 2000 [29] TDA1022 datasheet, http://www.datasheetcatalog.com/datasheets_pdf/T/D/A/1/TDA1022.shtml [30] Smith J.O. "Digital Audio Resampling Home Page", online book, https:/ccrma.stanford.edu/~jos/resample/, accessed 18/8/2012 [31] Panella E. and Spalierno G., "Sistemi a dati campionati, trasformata Z, filtri digitali" in Corso di Elettronica 3, Edizioni Cupido [32] Puckette M., "Waveshaping" in Theory and Techniques of Electronic Music” , online book, http://crca.ucsd.edu/~msp/techniques/v0.08/book-html/node74.html, accessed 20/9/2012 [33] Matsumoto M. and Nishimura T. "Mersenne Twister noise generation algorithm", computer software, http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/emt19937ar.html, accessed 15/4/2013 [34] Smith J. O. "An FFT-based equation-error method", in Introduction to digital filters with audio applications, online book, https://ccrma.stanford.edu/~jos/filters/FFT_Based_Equation_Error_Method.html, accessed 10/4/2013 [35] Beckmann P. E. and Russell A. "Efficient Arbitrary Sampling Rate Conversion With Recursive Calculation of Coefficients" in IEEE transactions on signal processing, vol. 50, no. 4, april 2002 [36] Schmid H., “How to use the FFT and Matlab’s pwelch function for signal and noise simulations and measurements” Institute of Microelectronics, University of Applied Sciences NW Switzerland, 2012 [37] Home page of the BBDresample project https://github.com/giuliomoro/BBDresample 153