digital audio - github pages · 2018-12-30 · digital audio graduate school of culture technology,...

22
2018 Fall CTP431: Music and Audio Computing Digital Audio Graduate School of Culture Technology, KAIST Juhan Nam

Upload: others

Post on 15-Apr-2020

1 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Digital Audio - GitHub Pages · 2018-12-30 · Digital Audio Graduate School of Culture Technology, KAIST Juhan Nam. Outlines

2018 FallCTP431: Music and Audio Computing

Digital Audio

Graduate School of Culture Technology, KAISTJuhan Nam

Page 2: Digital Audio - GitHub Pages · 2018-12-30 · Digital Audio Graduate School of Culture Technology, KAIST Juhan Nam. Outlines

Outlines

• Introduction

• Sampling

• Quantization

• Digital audio standards

• Playback Rate Conversion / Resampling

Page 3: Digital Audio - GitHub Pages · 2018-12-30 · Digital Audio Graduate School of Culture Technology, KAIST Juhan Nam. Outlines

Introduction

Sound

Image

Text

… 0 1 1 0 1 1 0 …

… 1 0 0 1 1 0 1 …

… 0 0 1 1 0 1 1 …

Page 4: Digital Audio - GitHub Pages · 2018-12-30 · Digital Audio Graduate School of Culture Technology, KAIST Juhan Nam. Outlines

Digital Representations

• Sampling and Quantization- Sound (samples) - Image (pixels)

• Trade-off - Between quality and data size

Page 5: Digital Audio - GitHub Pages · 2018-12-30 · Digital Audio Graduate School of Culture Technology, KAIST Juhan Nam. Outlines

Digital Audio Chain

Page 6: Digital Audio - GitHub Pages · 2018-12-30 · Digital Audio Graduate School of Culture Technology, KAIST Juhan Nam. Outlines

Microphone and Speakers

• Microphones- Sound to electrical signal- Dynamic mic: Fleming’s right-hand rule - Condenser mic: Q = CV, C = A/d- Pre-amp

• Loudspeakers- Electrical signal to sound- Similar to dynamic mic in principle- Fleming’s left-hand rule

- Crossover networks: woofer / tweeter- Power amp

Condenser mic

Source: http://www.shure.com/americas/support/find-an-answer/difference-between-a-dynamic-and-condenser-microphoneSource: http://hyperphysics.phy-astr.gsu.edu/hbase/Audio/cross.html

Dynamic mic(A= area, D= distance)

Page 7: Digital Audio - GitHub Pages · 2018-12-30 · Digital Audio Graduate School of Culture Technology, KAIST Juhan Nam. Outlines

Sampling

• Convert continuous-time signals to discrete-time signals by periodically picking up the instantaneous values- Represented as a sequence of numbers: pulse code modulation (PCM)- Sampling period (Ts): the amount of time between samples- Sampling rate ( fs =1/Ts )

Ts

x(t)→ x(nTs )Signal notation

Page 8: Digital Audio - GitHub Pages · 2018-12-30 · Digital Audio Graduate School of Culture Technology, KAIST Juhan Nam. Outlines

Sampling Theorem

• What is an appropriate sampling rate?- Too high: increase data rate- Too low: become hard to reconstruct the original signal

• Sampling Theorem- In order for a band-limited signal to be reconstructed fully, the sampling

rate must be greater than twice the maximum frequency in the signal

- Half the sampling rate is called Nyquist frequency (𝑓"/2)

𝑓" > 2 & 𝑓'𝑓": sampling rate

𝑓': maximum frequency

Page 9: Digital Audio - GitHub Pages · 2018-12-30 · Digital Audio Graduate School of Culture Technology, KAIST Juhan Nam. Outlines

Aliasing

• If the sampling rate is less than twice the maximum frequency, the high-frequency content is folded over to lower frequency range

0 0.2 0.4 0.6 0.8 1 1.2 1.4 1.6 1.8 2x 104

−0.8

−0.6

−0.4

−0.2

0

0.2

0.4

0.6

0.8

1

Page 10: Digital Audio - GitHub Pages · 2018-12-30 · Digital Audio Graduate School of Culture Technology, KAIST Juhan Nam. Outlines

Aliasing in Frequency Domain

• For general signals, high-frequency content is folded over to lower frequency range

fm-fm fs+fmfs-fm fs-fs

Audible range

Page 11: Digital Audio - GitHub Pages · 2018-12-30 · Digital Audio Graduate School of Culture Technology, KAIST Juhan Nam. Outlines

To avoid Aliasing

• Increase sampling rate

• Or use lowpass filters before sampling

fs > 2 ⋅ fm

fs/2 fs-fs -fs/2

fm-fm fs+fmfs-fm fs-fs

Lowpass Filter

Page 12: Digital Audio - GitHub Pages · 2018-12-30 · Digital Audio Graduate School of Culture Technology, KAIST Juhan Nam. Outlines

Example of Aliasing

12Frequency sweep of the trivial sawtooth wave

Time (s)

Freq

uenc

y (H

z)

1 1.5 2 2.5 3 3.5 4 4.50

0.5

1

1.5

2

x 104

Bandlimited sawtooth wave spectrum

5 10 15 20−60

−40

−20

0

Frequency (kHz)

Mag

nitu

de (d

B)

5 10 15 20−60

−40

−20

0

Frequency (kHz)

Mag

nitu

de (d

B)

Trivial sawtooth wave spectrum

Page 13: Digital Audio - GitHub Pages · 2018-12-30 · Digital Audio Graduate School of Culture Technology, KAIST Juhan Nam. Outlines

Example of Aliasing in Video

https://www.youtube.com/watch?v=jHS9JGkEOmA

Page 14: Digital Audio - GitHub Pages · 2018-12-30 · Digital Audio Graduate School of Culture Technology, KAIST Juhan Nam. Outlines

Quantization

• Discretizing the amplitude of real-valued signals- Round the amplitude to the nearest discrete steps- The discrete steps are determined by the number of bit bits - N bits can range from -2N-1 to 2N-1-1

Quantization step

2N-1-1

-2N-1

Page 15: Digital Audio - GitHub Pages · 2018-12-30 · Digital Audio Graduate School of Culture Technology, KAIST Juhan Nam. Outlines

Quantization Error

• Quantization causes noise- Average power of quantization noise: obtained from the probability density

function (PDF) of the error

• Signal to Noise Ratio (SNR)- Based on average power

1/2-1/2

P(e)

1

x2p(e)dx−1/2

1/2∫ = 1

12

Root mean square (RMS) of noise

20 log10SrmsNrms

= 20 log102B−1 / 2112

= 6.02B+1.76 dB

RMS of full-scale sine wave

Page 16: Digital Audio - GitHub Pages · 2018-12-30 · Digital Audio Graduate School of Culture Technology, KAIST Juhan Nam. Outlines

Digital Audio Standards

• Determined by the limit in human hearing- Maximum audible frequency (bandwidth): 20kHz - Dynamic range: depends on frequency (the maximum is about 120dB)

Soun

d Le

vel (

dB)

Human hearing range

Page 17: Digital Audio - GitHub Pages · 2018-12-30 · Digital Audio Graduate School of Culture Technology, KAIST Juhan Nam. Outlines

Digital Audio Standards

• Compact disc- Sampling rate: 44.1 kHz: > 2 x 20 kHz- Bit depth: 16 bits: SNR = 98.08dB

• Blu-ray disc / professional audio - Sampling rate: 48 / 96 /192kHz: > 2 x 20 kHz- Bit depth: 16 / 20 / 24 bits

• Telephone - Sampling rate: 8 / 16 kHz- Bit depth: 8 bits (with companding)

Page 18: Digital Audio - GitHub Pages · 2018-12-30 · Digital Audio Graduate School of Culture Technology, KAIST Juhan Nam. Outlines

Playback Rate Conversion

• Playback rate does not have to be the same as the recording rate

• Adjusting the playback rate given the recorded audio creates different tones- Sliding tapes on the magnetic header in a variable speed- Speeding down: “monster-like”- Speeding up: “chipmunk-like”- It can be even negative rate: reverse playback

Page 19: Digital Audio - GitHub Pages · 2018-12-30 · Digital Audio Graduate School of Culture Technology, KAIST Juhan Nam. Outlines

Demo: Playback Rate Conversion

• https://musiclab.chromeexperiments.com/Voice-Spinner

Page 20: Digital Audio - GitHub Pages · 2018-12-30 · Digital Audio Graduate School of Culture Technology, KAIST Juhan Nam. Outlines

• Reconstruct the original signal and sample it with a new sampling rate

• For a digital system with a constant playback rate- Up-sampling makes the original have slower speed and lower pitch - Down-sampling makes the original have faster speed and higher pitch

Resampling

Page 21: Digital Audio - GitHub Pages · 2018-12-30 · Digital Audio Graduate School of Culture Technology, KAIST Juhan Nam. Outlines

Resampling

• Resampling changes pitch, length and timbre at the same time!

[The DaFX book]

Original

Speed Down(Up-sampling)

Speed Up(Down-sampling)

Page 22: Digital Audio - GitHub Pages · 2018-12-30 · Digital Audio Graduate School of Culture Technology, KAIST Juhan Nam. Outlines

Practice: Audacity

• Recording

• Editing

• Digital Audio Effects