Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

DSP Lab #5: Signal Synthesis - Noise Generation & Wavetable Synthesis - Prof. Clifford T. , Lab Reports of Digital Signal Processing

The implementation of signal synthesis algorithms in dsp applications, focusing on the generation of pseudo-random noise and the use of wavetable synthesizers for periodic signals. Students are required to develop a band-pass filter for noise and a chirp signal, as well as a wave-table generator for a sine wave and a more complex harmonic waveform.

Typology: Lab Reports

Pre 2010

Uploaded on 02/13/2009

koofers-user-fw7
koofers-user-fw7 🇺🇸

10 documents

1 / 7

Toggle sidebar

Related documents


Partial preview of the text

Download DSP Lab #5: Signal Synthesis - Noise Generation & Wavetable Synthesis - Prof. Clifford T. and more Lab Reports Digital Signal Processing in PDF only on Docsity! ECEN4532/5532 Digital Signal Processing Laboratory Spring 2008 Laboratory Exercise #5 Signal Generation and Music Score Players In previous exercises we have developed and implemented signal processing algorithms. These started with an analog input signal that was sampled before some digital process was performed on it. Finally, an analog output signal was produced. In these applications, the process did something to an independent input. A separate category of DSP application involves signal synthesis algorithms: the DSP 56k computes the output signal from scratch - perhaps with some low bandwidth control signals, but independent of the ADC inputs. Signal synthesis is useful in many DSP applications. Examples include communications systems (e.g. modulation applied to bit streams), test and simulation equipment, music and entertainment. Part 1 In the first week three examples of synthesis routines will be developed. The first type involves generating the output signal directly from an algorithm. The specific application of this type is to synthesize a pseudo- random noise signal, using a simple random number generator, and filter it to get noise in a specified frequency band. A second type of synthesis is to compute a standard test signal – in this exercise it will be a “chirp”. This project and the third one both involve the use of a stored waveform (in a look-up, or wave- table) that is interpolated. In the third project the goal is to produce a periodic signal with a desired period and waveform. These applications can use the table driver subroutines that were developed in Lab #2. 1.a - Pseudo-random noise generation using an algorithm Noise is typically the enemy in signal processing and communication problems. Surprisingly, there are situations where noise is helpful. More honestly, it is often the case that the signal should look like noise to the outside world, but is determinable within its application. Some techniques for data encryption are like that. The question we shall address is how to generate a signal that is deterministic but noise-like. A classic example is a pseudo-random sequence, which is a binary sequence produced by a finite state machine (FSM). Since the state machine is finite, its output is actually periodic. However, the period can be so large that it is not detectable. By using a long shift register (with n bits) and carefully selecting a feedback function, it is possible to generate a sequence that goes through every possible combination of n bits except the case of all n zeros. There are 2n-1 such binary words – so this number would be the period of the generated sequence. These are called a "maximum length" pseudo-random or PN sequences. Such a sequence would look statistically like a Bernoulli random binary sequence, since the mean and autocorrelation statistics (achieved by averaging over time) will be almost perfect. A computationally cheap method for generating a pseudo-random sequence of uniformly distributed numbers (real numbers as opposed to binary values) in the DSP 56K is the linear congruential method. The computation is expressed as y[n]=(d·y[n-1] + c) modulo M , where a is a constant multiplier, c is a constant offset, and M is the modulus. The initial value to start the sequence, y[0], is called the seed of the random generator. The choice of a, c, and M must be made with care to ensure that a maximal length output sequence is obtained for any choice of the seed, y[0]. Note that if c is chosen to be zero, then the seed must not also be zero. It is common to choose M to be equal to the word length of the processor (e.g., 24 bits for the 56K) so that the “modulo” operation is achieved simply by taking the lower portion of the accumulator. ECEN 4532/5532 DSP Lab #5 2 It is important to keep in mind that a linear congruence generator is deterministic, and consequently the sequence of output values is completely known when the seed and the constants are known. And it is often true that the bit patterns are correlated from one output to the next, especially the least-significant bits. This means that if you try to simulate the outcome of a coin flip by testing the LSB of the random word, the result may have a periodic pattern of some kind rather than a more random distribution. The moral of this story is to be skeptical of simple algorithmic random number generators! Starting with a nonzero seed number in the accumulator A, do an integer multiply by a constant d. You will need to do a right shift after the multiply to convert from fractional to integer form. Then throw away the most significant part of the result by moving A0 into A. Note that we are taking c to be zero, but you can also try this with a non-zero c value. If the constant d is 'good' then the iteration of this scheme will produce a reasonable approximation to a random sequence, which is uniform on the interval –1 < y < 1. What is the theoretical mean and variance of this sequence? You will have to experiment with the choice of the constant d. For some values, the result will be noticeably nonwhite (pitched or repetitive) to the ear. For your report, include an example of a ‘bad’ value of d in combination with a seed that results in a short repetitive sequence, and a ‘good’ value of d and a seed that gives a white-sounding sequence. (It is sometimes possible to detect periodicity from a long scope trace). Graduate Students: Write a MATLAB simulation of the algorithm. For your ‘good’ value of d, generate a long sequence and include in your report a histogram and empirical autocorrelation statistics. All Students: Construct a band-pass filter table via: >> soaptable('invchebychev(11,.05)',[1 2]/24,'filtername') Using the SOAP code from lab #4, drive the band-pass filter with the output of your noise generator. Put the wide-band noise filter input on one DSP board output and the narrow-band filter output on the other. Make sure you use the band-pass output and not the band-stop output. Boost the amplitude of the filter output by 16 by using four asl a’s. Listen to the two signals, and capture scope traces. Describe what you hear and what you see. If you can, include a digital photo of the scope traces in your report. 1.b – Chirps An interesting test signal is the “chirp”, so named because of its resemblance to a bird’s chirp. But it has a formula, involving three parameters: T – the duration of the chirp f1 - the starting frequency f2 - the final frequency The idea is to generate a sinusoid whose frequency varies from f1 to f2 over the time interval 0 < t < T. The frequency can change linearly or exponentially. The former is easier but the latter sounds better. Produce a chirp generator whose output is y(t) = 0.99*cos(2π g(t)), where dg(t)/dt = f1 + at, where f1 + aT = f2 Write a MATLAB table generator whose inputs are the three parameters. The output is an assembly language text file containing (1) any parameter-related constants that are used in your table pointer computation, and (2) a table of 1024 sinusoidal samples. You can use the ‘numtable.m’ tool from lab #2, with input string f = ‘0.99*cos(2*pi*x)’. ECEN 4532/5532 DSP Lab #5 5 Besides frequency control, we will also want amplitude control of the synthesized waveform. This means that the sample values obtained or interpolated from the wave-table will be multiplied by an amplitude scaling-factor. If the amplitude scaling is time varying, then the control is known as an amplitude envelope. The envelope gives the output signal a more natural and gradual change in loudness rather than an abrupt ‘on/off’ transition that would produce annoying “clicks” in the audio output. The amplitude envelope can be created by using linear segments or some other functional representation, or by using another look-up table. Construct a wave-table generator Write a wave-table signal generator module that can produce an accurate sine wave in the frequency range from near zero to at least 9 kHz. The technique must use linear interpolation between the samples loaded into the sine wave data buffer, and run at an output sampling frequency of 48 kHz. You will probably want to create the sine wave table using the MATLAB tool numtable.m. Choose an appropriate size for your table in order to get good interpolation quality with tolerable high-frequency artifacts due to the linear interpolation. The table should contain only one period of the sinusoid. In your report, include a discussion of your thinking. Your LUA and SI values should have 24-bits in the fractional part and up to 24 bits in the integer part - hopefully you can use your lab #2 table drivers without modification. Use an easy to remember location in X memory (labelled X:freq) to store the frequency code. In other words, if you are asked to produce a 1 kHz sine wave, you will enter 1000 decimal in this location and then start your program. You might need to do some computation on the contents of X:freq in the initialization part of your code in order to get the proper integer part and fractional part of the sample increment (SI) for your circular buffer manager routines. After the sine wave generator is working, make a different wave table signal that contains a more complicated—but still harmonic—waveform. You can use MATLAB to sum up a Fourier series of harmonic components, then normalize the result to fit within the +/-1 range of the DSP. How does it sound? Part 2 Music Score players this part will be revised by spring break Program a monophonic (one note at a time) wavetable synthesizer that can read the contents of an encoded musical 'score' and generate a musical 'tune'. Apologies in advance to all serious musicians. Your program should “play” the score and then stop automatically. The score is a simple “pitch, duration” encoding like the following: ; format of score is [note# ,duration], ...,[note#,duration],[-1] ; ; fs equ 48000 eighth equ fs/6 quarter equ 2*eighth half equ 2*quarter whole equ 2*half c_ equ 0 c#_ equ 1 d_ equ 2 d#_ equ 3 …etc… ; your definition of musical pitches (SI values) goes here!! SI_int dc …etc… ECEN 4532/5532 DSP Lab #5 6 SI_fract dc …etc… ; scoretab dc 12+c_,half,b_,eighth,a_,eighth,g_,eighth,f_,eighth dc e_,quarter,d_,quarter,c_,whole,-1 Your musical pitch definitions must use the 1939 international standard frequency values in Hz for notes in the middle octave of the piano as given in the following table. (see Science and Music, by Sir James Jeans, Dover reprint, pp. 22-25) C C# D D# E F F# G G# A A# B 261.6 277.2 293.6 311.1 329.6 349.2 370.0 392.0 415.3 440.0 466.2 493.9 Study the way that the tones are encoded carefully so that you can determine the integer (SI_int) and fractional (SI_fract) parts of the wavetable step size for your synthesizer. If possible, have the pre- processor do the calculation at assemble time. Note that the SI values will depend on the sample rate, table length, and the desired output frequency. When your program is “playing” the score, it should read the musical pitch index and look up the proper SI value from your SI_int and SI_fract tables, then read the note duration and set up a counter to produce the desired number of output samples for that note. This process should continue until the end of the score is reached. Find a short musical piece or compose one of your own, then encode the notes into the scoretab format shown above. You must be able to demonstrate that your song player can read your given score and play the music. Optional: How would you also handle musical “rests”: silences between notes? Part 2: Now modify your wavetable program to include a simple linear amplitude envelope. At first, just have the envelope start at its maximum value and then decay linearly to zero over the specified duration of the note. Optional: If you have time, modify the envelope to have a linear attack segment going from zero to maximum in 100ms, then a linear decay to zero over the remainder of the note. Additional exercise for Graduate Students: Alter your wavetable music player to allow duets: at least two wavetable notes playing and mixed (added) together at the same time. You can make two different scoretab tables, one for each of the two musical voices. Find or compose a simple tune to demonstrate your duet player. Optional: If you are very ambitious, perhaps even consider a trio (three-part) system, such as a “Row, Row, Row Your Boat” round player with looping? ECEN 4532/5532 DSP Lab #5 7 Report and Grading Checklist A: Random number generator Code listing for Linear Congruential routine, with comments. Examples of “good” and “bad” values for a and the seed. Histogram results from “good” output and comments on the empirical statistics. Comments on results of filtered noise, if any. Grad student exercise, if applicable B: Wavetable signal generator Code listing with comments for wavetable sine wave synthesizer with linear interpolation. Results (discussion) of signal generator with more complicated harmonic waveform. C: Wavetable music player Part 1: Code listing with comments for wavetable music player. Fully explain your design and any choices you needed to make. Part 2: Code listing with comments for wavetable synthesizer with simple amplitude envelope. Grad student exercise, if applicable. Grading Guidelines (for each grade, you must also satisfy the requirements of all lower grades): F Anything less than what is necessary for a D. D Exercise A code listing with example a values you determined. D+ Exercise A empirical results. C Exercise B with clear and concise comments. B- Exercise C music player, functional but no envelope. B Exercise C music player with envelope. A Demo of wavetable music player for Prof. Maher or lab TA. Grad student grades also require the additional exercises (parts A and C).
Docsity logo



Copyright © 2024 Ladybird Srl - Via Leonardo da Vinci 16, 10126, Torino, Italy - VAT 10816460017 - All rights reserved