Audio Signal Generation. Young Won Lim 2/2/18

Similar documents
Audio Signal Generation. Young Won Lim 2/2/18

Audio Signal Generation. Young Won Lim 1/29/18

Digital Signal Octave Codes (0A)

Digital Signal Octave Codes (0A)

Digital Signal Octave Codes (0A)

Digital Signal Octave Codes (0A)

Digital Signal Octave Codes (0A)

DFT Frequency (9A) Each Row of the DFT Matrix. Young Won Lim 7/31/10

FFT Octave Codes (1B) Young Won Lim 7/6/17

General CORDIC Description (1A)

Digital Signal Octave Codes (0A)

Higher Order ODE's (3A) Young Won Lim 12/27/15

DFT Octave Codes (0B) Young Won Lim 4/15/17

Expected Value (10D) Young Won Lim 6/12/17

Higher Order ODE's (3A) Young Won Lim 7/7/14

Fourier Analysis Overview (0A)

Fourier Analysis Overview (0A)

Capacitor Young Won Lim 06/22/2017

Capacitor in an AC circuit

Relations (3A) Young Won Lim 3/27/18

Root Locus (2A) Young Won Lim 10/15/14

Matrix Transformation (2A) Young Won Lim 11/10/12

Background Trigonmetry (2A) Young Won Lim 5/5/15

Propagating Wave (1B)

Capacitor in an AC circuit

Capacitor in an AC circuit

Fourier Analysis Overview (0B)

Phasor Young Won Lim 05/19/2015

The Growth of Functions (2A) Young Won Lim 4/6/18

CT Rectangular Function Pairs (5B)

Capacitor in an AC circuit

Up-Sampling (5B) Young Won Lim 11/15/12

Group & Phase Velocities (2A)

Capacitor in an AC circuit

Capacitor in an AC circuit

ODE Background: Differential (1A) Young Won Lim 12/29/15

Capacitor in an AC circuit

Higher Order ODE's (3A) Young Won Lim 7/8/14

Line Integrals (4A) Line Integral Path Independence. Young Won Lim 10/22/12

Introduction to ODE's (0A) Young Won Lim 3/9/15

Signal Processing. Young Won Lim 2/20/18

General Vector Space (2A) Young Won Lim 11/4/12

Capacitors in an AC circuit

Down-Sampling (4B) Young Won Lim 11/15/12

Detect Sensor (6B) Eddy Current Sensor. Young Won Lim 11/19/09

Signal Functions (0B)

Signal Processing. Young Won Lim 2/22/18

Capacitor and Inductor

Capacitor and Inductor

Down-Sampling (4B) Young Won Lim 10/25/12

Matrix Transformation (2A) Young Won Lim 11/9/12

Group Velocity and Phase Velocity (1A) Young Won Lim 5/26/12

Utility Functions Octave Codes (0A) Young Won Lim 1/24/18

Definitions of the Laplace Transform (1A) Young Won Lim 1/31/15

Separable Equations (1A) Young Won Lim 3/24/15

Complex Trigonometric and Hyperbolic Functions (7A)

Discrete Time Rect Function(4B)

Higher Order ODE's, (3A)

Signals and Spectra (1A) Young Won Lim 11/26/12

Complex Series (3A) Young Won Lim 8/17/13

Background ODEs (2A) Young Won Lim 3/7/15

Discrete Time Rect Function(4B)

Line Integrals (4A) Line Integral Path Independence. Young Won Lim 11/2/12

Dispersion (3A) 1-D Dispersion. Young W. Lim 10/15/13

Group Delay and Phase Delay (1A) Young Won Lim 7/19/12

Bayes Theorem (10B) Young Won Lim 6/3/17

Signal Processing. Young Won Lim 3/3/18

Magnetic Sensor (3B) Magnetism Hall Effect AMR Effect GMR Effect. Young Won Lim 9/23/09

Bandpass Sampling (2B) Young Won Lim 3/27/12

Differentiation Rules (2A) Young Won Lim 1/30/16

Signal Processing. Young Won Lim 2/24/18

Propositional Logic Resolution (6A) Young W. Lim 12/12/16

Complex Functions (1A) Young Won Lim 2/22/14

CLTI Differential Equations (3A) Young Won Lim 6/4/15

Sequential Circuit Timing. Young Won Lim 11/6/15

Linear Equations with Constant Coefficients (2A) Young Won Lim 4/13/15

Propositional Logic Resolution (6A) Young W. Lim 12/31/16

General Vector Space (3A) Young Won Lim 11/19/12

Undersampling (2B) Young Won Lim 4/4/12

FSM Examples. Young Won Lim 11/6/15

CLTI System Response (4A) Young Won Lim 4/11/15

Implication (6A) Young Won Lim 3/17/18

Bayes Theorem (4A) Young Won Lim 3/5/18

Introduction to ODE's (0P) Young Won Lim 12/27/14

Hamiltonian Cycle (3A) Young Won Lim 5/5/18

Differentiation Rules (2A) Young Won Lim 2/22/16

Surface Integrals (6A)

CT Correlation (2A) Young Won Lim 9/9/14

Resolution (7A) Young Won Lim 4/21/18

Background LTI Systems (4A) Young Won Lim 4/20/15

Probability (10A) Young Won Lim 6/12/17

Hilbert Inner Product Space (2B) Young Won Lim 2/7/12

Second Order ODE's (2A) Young Won Lim 5/5/15

Propositional Logic Logical Implication (4A) Young W. Lim 4/11/17

Implication (6A) Young Won Lim 3/12/18

CMOS Inverter. Young Won Lim 3/31/16

LAB # 5 HANDOUT. »»» The N-point DFT is converted into two DFTs each of N/2 points. N = -W N Then, the following formulas must be used. = k=0,...

Propositional Logic Logical Implication (4A) Young W. Lim 4/21/17

Hyperbolic Functions (1A)

Surface Integrals (6A)

Transcription:

Generation

Copyright (c) 2016-2018 Young W. Lim. Permission is granted to copy, distribute and/or modify this document under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts. A copy of the license is included in the section entitled "GNU Free Documentation License". Please send corrections (or suggestions) to youngwlim@hotmail.com. This document was produced by using OpenOffice.

Based on Signal Processing with Free Software : Practical Experiments F. Auger 3

SOX information http://sox.sourceforge.net/docs/documentation http://www.thegeekstuff.com/2009/05/sound-exchange-sox-15-examples-to-manipulate-audi o-files/ http://billposer.org/linguistics/computation/soxtutorial.html 4

Audacity information http://www.library.kent.edu/files/sms_audacity_basics.pdf http://manual.audacityteam.org/man/tutorials.html https://multimedia.journalism.berkeley.edu/tutorials/audacity/ http://ctlt.jhsph.edu/help/views/tutorials/audacity/guidetousingaudacity.pdf 5

Visual Analyser http://www.sillanumsoft.org/ 6

TimeFreqPlot # Prevent Octave from thinking that this # is a function file: 1; #-------------------------------------------# n : time index vector # x : time domain signal vector # k : frequency index vector # X : frequency domain signal vector #-------------------------------------------function TimeFreqPlot(n, x, k, X, mode) NF = length(n); if (strmatch(typeinfo(mode), "range")) trange = mode; frange = mode; else if (strmatch(mode, "half")) trange = 1:NF; frange = 1:NF/2; elseif (strmatch(mode, "full")) trange = 1:NF; frange = 1:NF; fs = k(2)+k(nf) X = fftshift(x); k = fftshift(k); k(1:nf/2) = k(1:nf/2) - fs; else trange = 1:NF; frange = 1:NF; endif endif subplot(3,1,1); p = stem(n(trange), x(trange), 'k'); grid on; xlabel('time, t (s)'); ylabel('x(t)'); subplot(3,1,2); p = stem(k(frange), abs(x(frange)), 'k'); set(p,'linewidth',2,'markersize',4); grid on; xlabel('harmonic number, k'); ylabel(' X(k) '); subplot(3,1,3); p = stem(k(frange), angle(x(frange)), 'k'); set(p,'linewidth',2,'markersize',4); grid on; xlabel('harmonic Number, k'); ylabel('ang{x[k]}'); endfunction 7

wavplot function wavplot(fname) [x, fs, nbits] = wavread(fname); nn = length(x); printf('fs = %f \n', fs); printf('nn = %d \n', nn); n = (0 : nn-1) / fs ; k = fs * (0 : nn-1) / nn ; X = fft( x ); source "../0.util.octave/util.m" #TimeFreqPlot(n, x, k, X, "half") #TimeFreqPlot(n, x, k, X, (1:1024)+1024*0.5) #TimeFreqPlot(n, x, k, X, (1*1024:2*1024)) #TimeFreqPlot(n, x, k, X, (35200-0.5*1024:35200+0.5*1024)) TimeFreqPlot(n, x, k, X, (2*1024:3*1024)) endfunction 8

Arg of cos(ωt) and sin(ωt) t = -1:0.01:1; wt = 20 * t; y1 y2 y3 y4 y5 y6 = = = = = = e.^(i*wt); e.^(-i*wt); y1+y2; y1-y2; y3/2; y4/(2*i); plot(t, arg(y1), t, arg(y2)); plot(t, arg(y3), t, arg(y4)); plot(t, arg(y5), t, arg(y6)); 9

Plots with a low resolution t = -10:0.1:10; graphical illusions 10

wavplot fs = 2^6-1; n = linspace(0, 1, fs+1); nn = length(n); k = fs *(0:nn-1)/nn; x = cos(2*pi*440*n); X = fft(x); Small magnitude overrides phase source "../0.util.octave/util.m" TimeFreqPlot(n, x, k, X, "full") 11

wavplot fs = 100-1; n = linspace(0, 1, fs+1); nn = length(n); k = fs *(0:nn-1)/nn; x = cos(2*pi*440*n); X = fft(x); Not exact integer multiple cycles source "../0.util.octave/util.m" TimeFreqPlot(n, x, k, X, "full") 12

wavplot fs = 48000; n = linspace(0, 1, fs+1); nn = length(n); k = fs *(0:nn-1)/nn; x = cos(2*pi*440*n); X = fft(x); TimeFreqPlot(n, x, k, X, "half") fs = 48000; n = linspace(0, 1, fs+1); nn = length(n); n = n(1:nn-1); nn = length(n); k = fs *(0:nn-1)/nn; x = cos(2*pi*440*n); X = fft(x); TimeFreqPlot(n, x, k, X, "half") 13

Generating signals using sox sox sox sox sox sox sox -n -n -n -n -n -n s1.wav s2.wav s3.wav s4.wav s5.wav s6.wav synth synth synth synth synth synth 3.5 90000s 1:20 1:20 6 5 sine sine triangle trapezium square noise time duration 440 660:1000 440 440 440 0 0 40 frequency -V0, -V1, -V2, -V3, -V4 : verbosity levels -n (null) : absence of an input signal 14

Generating signals using sox f s =1/ 48000=2.0833e-05 (sample /sec) T s = 0.0208 msec /sample s1.wav 3.5 sec T /T s = T f s = 3.5 48000 = 168000 samples s2.wav 90000 s 90000 samples s3.wav 80 sec T /T s = T f s = 80 48000 = 3840000 samples N = 3840000 pt FFT s4.wav 80 sec T /T s = T f s = 80 48000 = 3840000 samples N = 3840000 pt FFT s5.wav 6 sec T /T s = T f s = 6 48000 = 288000 samples N = 288000 pt FFT s6.wav 5 sec T /T s = T f s = 5 48000 = 240000 samples N = 240000 pt FFT 15 N = 168000 pt FFT N= 90000 pt FFT

Generating signals using sox f s =1/ 48000=2.0833e-05 (sample /sec) T s = 0.0208 msec /sample s1.wav k f s / N = k 48000/168000 440 168000/ 48000 s2.wav k f s / N = k 48000/90000 660 90000/ 48000 1000 90000 /48000 440 3.5 = 1540 660 1.875 = 1237.5 1000 1.875 = 1875 s3.wav k f s / N = k 48000/3840000 440 3840000 /48000 440 80 = 35200 s4.wav k f s / N = k 48000/3840000 440 3840000 /48000 440 80 = 35200 s5.wav k f s / N = k 48000/288000 440 288000 / 48000 440 6 = 2640 s6.wav k f s / N = k 48000/240000 440 240000 / 48000 440 5 = 2200 16

sox -n s1.wav synth 3.5 sine 440 N = 168000 pt FFT 440 3.5 = 1540 17

sox -n s2.wav synth 90000s sine 660:1000 660 1.875 = 1237.5 N= 1000 1.875 = 1875 18 90000 pt FFT

sox -n s3.wav synth 1:20 triangle 440 N = 3840000 pt FFT 440 80 = 35200 19

sox -n s4.wav synth 1:20 trapezium 440 N = 3840000 pt FFT 440 80 = 35200 20

sox -n s5.wav synth 6 square 440 0 0 40 N = 288000 pt FFT 440 6 = 2640 21

sox -n s6.wav synth 5 noise 440 5 = 2200 N = 240000 pt FFT 22

References [1] F. Auger, Signal Processing with Free Software : Practical Experiments