Sound synthesis with Pure Data

Similar documents
CS 591 S1 Midterm Exam

Fourier Series and Gibbs Phenomenon

ECEGR Lab #8: Introduction to Simulink

EEL 4350 Principles of Communication Project 2 Due Tuesday, February 10 at the Beginning of Class

Memorial University of Newfoundland Faculty of Engineering and Applied Science. Lab Manual

Linear Frequency Modulation (FM) Chirp Signal. Chirp Signal cont. CMPT 468: Lecture 7 Frequency Modulation (FM) Synthesis

Additive Synthesis OBJECTIVES BACKGROUND

ELT COMMUNICATION THEORY

EXPERIMENT 4 INTRODUCTION TO AMPLITUDE MODULATION SUBMITTED BY

FFT analysis in practice

Frequency Division Multiplexing Spring 2011 Lecture #14. Sinusoids and LTI Systems. Periodic Sequences. x[n] = x[n + N]

Type pwd on Unix did on Windows (followed by Return) at the Octave prompt to see the full path of Octave's working directory.

Experiment # 4. Frequency Modulation

L A B 3 : G E N E R A T I N G S I N U S O I D S

UNIVERSITY OF WARWICK

CMPT 468: Frequency Modulation (FM) Synthesis

Problem Set 1 (Solutions are due Mon )

Lab 4 Fourier Series and the Gibbs Phenomenon

8A. ANALYSIS OF COMPLEX SOUNDS. Amplitude, loudness, and decibels

VIBRATO DETECTING ALGORITHM IN REAL TIME. Minhao Zhang, Xinzhao Liu. University of Rochester Department of Electrical and Computer Engineering

CME 312-Lab Communication Systems Laboratory

LABORATORY - FREQUENCY ANALYSIS OF DISCRETE-TIME SIGNALS

SMS045 - DSP Systems in Practice. Lab 1 - Filter Design and Evaluation in MATLAB Due date: Thursday Nov 13, 2003

Spectrum. Additive Synthesis. Additive Synthesis Caveat. Music 270a: Modulation

Music 270a: Modulation

C.11 Sampling and Aliasing Solution

Advanced Audiovisual Processing Expected Background

Discrete Fourier Transform (DFT)

THE HONG KONG POLYTECHNIC UNIVERSITY Department of Electronic and Information Engineering. EIE2106 Signal and System Analysis Lab 2 Fourier series

Signal Processing. Introduction

G(f ) = g(t) dt. e i2πft. = cos(2πf t) + i sin(2πf t)

Lecture 3 Complex Exponential Signals

m208w2014 Six Basic Properties of Sound

Experiment One: Generating Frequency Modulation (FM) Using Voltage Controlled Oscillator (VCO)

Physics. AC Circuits ID: 9525

EGR 111 Audio Processing

ME 365 EXPERIMENT 8 FREQUENCY ANALYSIS

ECE 2713 Homework 7 DUE: 05/1/2018, 11:59 PM

Physics 115 Lecture 13. Fourier Analysis February 22, 2018

PHYC 500: Introduction to LabView. Exercise 9 (v 1.1) Spectral content of waveforms. M.P. Hasselbeck, University of New Mexico

Digital Signal Processing ETI

Laboratory Assignment 4. Fourier Sound Synthesis

Music 171: Amplitude Modulation

Scanning Digital Radar Receiver Project Proposal. Ryan Hamor. Project Advisor: Dr. Brian Huggins

ENSC327 Communication Systems Fall 2011 Assignment #1 Due Wednesday, Sept. 28, 4:00 pm

Experiment 1 Introduction to MATLAB and Simulink

A-110 VCO. 1. Introduction. doepfer System A VCO A-110. Module A-110 (VCO) is a voltage-controlled oscillator.

Signal Processing. Naureen Ghani. December 9, 2017

Week 2: Plotting in Matlab APPM 2460

SigCal32 User s Guide Version 3.0

Lab 1B LabVIEW Filter Signal

The Formula for Sinusoidal Signals

Electrical & Computer Engineering Technology

Massachusetts Institute of Technology Dept. of Electrical Engineering and Computer Science Fall Semester, Introduction to EECS 2

PART I: The questions in Part I refer to the aliasing portion of the procedure as outlined in the lab manual.

UNIVERSITY OF WARWICK

Biomedical Signals. Signals and Images in Medicine Dr Nabeel Anwar

Lab #2 First Order RC Circuits Week of 27 January 2015

14 fasttest. Multitone Audio Analyzer. Multitone and Synchronous FFT Concepts

Lab 8. ANALYSIS OF COMPLEX SOUNDS AND SPEECH ANALYSIS Amplitude, loudness, and decibels

Digital Signal Processing ETI

Lab 12 Laboratory 12 Data Acquisition Required Special Equipment: 12.1 Objectives 12.2 Introduction 12.3 A/D basics

Multirate Signal Processing Lecture 7, Sampling Gerald Schuller, TU Ilmenau

CMPT 368: Lecture 4 Amplitude Modulation (AM) Synthesis

Pitch Detection Algorithms

Alternative View of Frequency Modulation

ESE 150 Lab 04: The Discrete Fourier Transform (DFT)

MUSC 316 Sound & Digital Audio Basics Worksheet

EECS 216 Winter 2008 Lab 2: FM Detector Part II: In-Lab & Post-Lab Assignment

FM AND BESSEL ZEROS TUTORIAL QUESTIONS using the WAVE ANALYSER without a WAVE ANALYSER...137

EECS 307: Lab Handout 2 (FALL 2012)

1B Paper 6: Communications Handout 2: Analogue Modulation

BASIC SYNTHESIS/AUDIO TERMS

Sound Synthesis Methods

ME scope Application Note 01 The FFT, Leakage, and Windowing

E40M Sound and Music. M. Horowitz, J. Plummer, R. Howe 1

Lab 4: Using the CODEC

Section 10: Radio Frequency Communication

II. LAB. * Open the LabVIEW program (Start > All Programs > National Instruments > LabVIEW 2012 > LabVIEW 2012)

Introduction to Simulink

Reading: Johnson Ch , Ch.5.5 (today); Liljencrants & Lindblom; Stevens (Tues) reminder: no class on Thursday.

Experiment 1 Introduction to Simulink

THE CITADEL THE MILITARY COLLEGE OF SOUTH CAROLINA. Department of Electrical and Computer Engineering. ELEC 423 Digital Signal Processing

ME scope Application Note 02 Waveform Integration & Differentiation

DFT: Discrete Fourier Transform & Linear Signal Processing

Synthesis Techniques. Juan P Bello

The University of Queensland School of Information Technology and Electrical Engineering. ELEC3004/7312: Signals, Systems and Controls

Massachusetts Institute of Technology Dept. of Electrical Engineering and Computer Science Spring Semester, Introduction to EECS 2

Many powerful new options were added to the MetaSynth instrument architecture in version 5.0.

Waveshaping Synthesis. Indexing. Waveshaper. CMPT 468: Waveshaping Synthesis

University of Pennsylvania Department of Electrical and Systems Engineering Digital Audio Basics

6.02 Practice Problems: Modulation & Demodulation

Lab 1: Analog Modulations

Sound Synthesis. A review of some techniques. Synthesis

Laboratory Assignment 2 Signal Sampling, Manipulation, and Playback

Lab 4 Digital Scope and Spectrum Analyzer

SuperCollider Tutorial

Laboratory Experiment #1 Introduction to Spectral Analysis

FIR/Convolution. Visulalizing the convolution sum. Convolution

The Fast Fourier Transform

Transcription:

Sound synthesis with Pure Data 1. Start Pure Data from the programs menu in classroom TC307. You should get the following window: The DSP check box switches sound output on and off. Getting sound out First, we ll set up a simple oscillator to test the sound. Open a new workspace by going to File>New. A blank window should pop up. To create an object in PD, go to Put>Object, or press ctrl+1.

A small box will appear. Click to place it on the workspace. WE WILL NOW DEFINE WHAT TYPE OF OBECT THIS SHOULD BE. Type osc~ into the box, then click outside of the box. You will see that the box is now and OSC or oscillator object. Create another object, except this time, set it as a dac~ in the same way as you set the OSC. This block is the digital to analogue convertor, and defines what is sent to your computer soundcard.

Connect the output of the oscillator to the DAC. TO do this, click the box in the bottom left of OSC, when a small circle appears, and hold and drag the resulting line to one of the top boxes on the DAC. In general, connections on the bottom are outputs, and the top are inputs. Repeat the process to connect the OSC output to the other DAC input. You should now have something like this: Now we have an oscillator connected to the soundcard output. However, the oscillator has no control signals. Therefore, we need to define the frequency that the oscillator will work at. There are different types of objects in Pure Data. We need to drive the oscillator with a NUMBER input. Go to Put>Number or press Ctrl+3, and place a number object above the oscillator. A box with a 0 will appear. Connect this box to the LEFT input of the oscillator. In Pure Data, where objects have 2 inputs, one of the inputs is live. You can see on the osc~ object above, the left input is black. The object only updates when a signal is changed on the LEFT input.

You should now have the following. You are ready to make some noise! To edit the value in the number box, go to the Edit menu and take PD out of Edit Mode, or press Ctrl+E.

You can vary the value in the oscillator driving number box. Click the box and type a sensible value, e.g. 440. Press return. This is the frequency in Hz at which the oscillator will produce a sine wave. Now switch on Output from Pure Data. First, check that PC volume is set to a sensible level, then click the DSP check box. Clicking the box next to the IN OUT meters will allow monitoring of the output level. This is done in the MAIN PD window, now in the window where you are creating your objects. Great, so we have sound output. Now to make some more interesting sounds. Turn the DSP tick box off.

FM Synthesis in Pure Data As we know, FM synthesis creates spectrally complex sounds by modulating the frequency input of a simple oscillator with another oscillator. Draw a simple schematic for an FM synthesiser in the space below: (see lecture notes) What differences do you notice between the oscillator objects in Pure Data and those shown in the typical diagram above? In order to control the amplitude (volume) of our sounds, we need to multiply by some gain factor. Go back to our simple oscillator example. Go back INTO Edit Mode, and delete the connections between our oscillator and the output. Do this by clicking on each connection, and pressing delete.

Add a multiplier object between the oscillator and the DAC by creating an object (ctrl+1) and typing *~ to set it. We will use this multiplier to control the signal level going to the DAC. Also create a number object. Connect them as shown: You may notice that some of the connections are thick, and some thin. This is to do with the type of signal they are carrying. Thin connections are control signals, whilst thick connections carry audio signals.

Turn the DSP tick box on. In the configuration shown above, there should be no sound coming out. Why? Let s add a label to make things clear. Goto Put>Comment and insert a comment saying amplitude control next to our latest number box. Now, let s vary the gain of the multiplier. Exit Edit Mode. HOLD SHIFT and upwards drag on the amplitude control. Holding shift allows fine grain control of the numbers in number boxes. Keep an eye on the audio level meters in the main window. What happens if the amplitude control goes above 1 or below -1? What happens to the quality of the outputted sound when this happens?

We saw how we could multiply two objects in pure data with a *~ object. We can also sum using a +~operator. In FM Synthesis, we use 2 frequencies; the carrier and modulator. Currently, we re driving our output oscillator with a single carrier frequency. TO get FM synthesis, we need to vary (modulate) the frequency with which we re driving the oscillator with. Click and drag up and down on the carrier frequency control number as rapidly as you can, in order to change the pitch up and down. What do you hear? How would you describe the sound? We want to be able to vary the pitch more rapidly. Up to many hundreds of times per second. TO do this we should use an oscillator. Remember that the one way of writing the equation describing the output from an FM synthesiser is: x(n) = A(n)sin [2π(f c + I sin(2πf m n)) n]

Which terms refer to the carrier signal? Which refer to the modulator? We need to sum the carrier frequency with a modulating frequency. Set up the following: By entering the terms in the boxes shown. Modulator Frequency and Modulator gain boxes are numbers, whilst osc~and *~100 are objects. Experiment with the effect of varying different parameters. Sometimes, due to the order of control signals, varying one parameter will not have the expected effect until the live input on an object is varied. What is the effect of varying the modulator frequency whilst the modulator gain is set to 0?

Effect of modulation frequency: Set the carrier to a nice round number, E.G. 200 Hz. Set modulator gain high E.g. 200, so the effects of the modulator are pronounced. Set the modulator frequency to an integer multiple of the carrier. E.G. 200, 400 or 600Hz if the carrier is 200Hz. How would you describe the sound? Now change the carrier frequency gradually so it is no longer an integer multiple. How does the sound change? Now set the modulator frequency low, E.G 1 to 3 Hz. How would you describe the sound? Do you perceive a complex timbre? Gradually increase the frequency, 1 or 2 Hz at a time. At some point, the quality of the sound should change. At what modulation frequency does this happen, and how would you describe the change?

Sound Synthesis with Matlab Now we ll try to model a desired instrument sound in Matlab using FM synthesis, filtering, and an ADSR type envelope. We will look at the frequencies present in the waveform and try to model these with FM, then apply a gain envelope to model the dynamics. Load the oboenote.wav file from the course webpage in Matlab. Samplerate is 16kHz. Use the wavread function to load the note and store into a variable, along with the samplerate of the audio. Listen to the note. soundsc(audiodata, fs); How does the QUALITY (timbre) of the sound change over time? Or does it remain fairly constant? Plot the note against time. If the audio file is 103201 samples long, how long is this in seconds? To plot against time, make a vector of the same length as the audio file (in samples), with equally spaced numbers. time=(1:length(audiodata))./fs; %Vector mapping sample number to time figure; plot(time, audiodata); xlabel Time, seconds ;

You should see something like the following plot: Draw a rough envelope of the AMPLITUDE of the waveform over time: Now let s look at the spectral content of the note, in order to inform parameters for our FM synthesis. If the samplerate of the audio is 16kHz, what is the Nyquist frequency? (the highest frequency which can be sampled)? Take the Fourier transform of the data. AUDIODATA=fft(audioData); When we take the FFT, of course we get complex valued data. We want to inspect the amplitude of the contribution at each frequency. figure; plot(abs(audiodata));

The figure produced has both the real frequencies and complex conjugates present. We want only the first half of the values produced. Create a new variable which has only the first N/2 samples present in AUDIODATA. In much the same way as we plotted our time-domain signal against a vector containing time values, we should plot our Fourier analysis against frequency, not sample number. frequencies=((1:length(audiodata))./length(audiodata))*(fs/2); figure; plot(frequencies, abs(audiodata)); You should get the following plot, showing the magnitude of various frequency components: Use the Datatip tool to inspect the following: What is the frequency of the fundamental? What is the frequency of the next biggest peak?

Fill in the following table, FOR THE 5 HIGHEST PEAKS (marked with dots): Component Fundamental (f1) Frequency Multiple of f1 1 Difference from 0 f1 Magnitude 1 compared to f1 Peak 2 Peak3 Peak 4 Peak5

Now we should synthesis the 5 biggest frequency components using FM synthesis. Load the script basicfm.m. % ---- Test PM synthesis in Matlab ----- fs = 16000; % sample rate (Hz) fcarr = 1; % carrier freq (Hz) fmod = 1; % modulation freq (Hz) A = 1; % amplitude I = 2; % modulation index: ratio of the peak deviation of modulation to the modulating freq n = 0:1/fs:1; % time vector in seconds % PM synthesize the sound y = A * sin( 2*pi*n.*fcarr + I*sin(2*pi*fmod*n)); % Check the spectrum Y = abs( fft(y))/length(y); plot( Y(1:round(length(Y)/2)), 'k'); title('magnitude spectrum'); xlabel('frequency'); soundsc(y, fs); % Play the sound Modify the values of fcarr (carrier frequency) and fmod (modulation frequency) so that they correspond to the values you entered in the table above. Run the script. Inspect the frequency response of the sound produced. Is it similar to the oboe sound we are trying to synthesise? Inspect the time-domain waveform. How does it vary from the time domain waveform of the oboe sound we are trying to synthesise? Create a gain envelope for the synthesized waveform using the linspace command, and concatenating various linear portions together; E.G. > env=[linspace(0, 1, 1000), linspace(1, 0, 2000)] Creates a vector of values which increase from 0 to 1 over 1000 samples, then fall from 1 to 0 over 2000 samples.

Make sure that your gain envelope is the same dimensions as the waveform to which it should be applied, and multiply the two together. How does the note sound? How does it compare to the target sound? How could it be improved?