summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/tex
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2023-11-09 22:01:47 +0000
committerKarl Berry <karl@freefriends.org>2023-11-09 22:01:47 +0000
commitd8e71bb2ac22baee0954c07417d4ab1bde33d19b (patch)
tree701530cb28cc49aee26a017e1e56f540adf45dd1 /Master/texmf-dist/tex
parentadc76608e83b72f81e102f5c56cbb8bc1617ef07 (diff)
dsptricks (9nov23)
git-svn-id: svn://tug.org/texlive/trunk@68753 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r--Master/texmf-dist/tex/latex/dsptricks/dspblocks.sty13
-rw-r--r--Master/texmf-dist/tex/latex/dsptricks/dspfunctions.sty99
-rw-r--r--Master/texmf-dist/tex/latex/dsptricks/dsptricks.sty6
3 files changed, 96 insertions, 22 deletions
diff --git a/Master/texmf-dist/tex/latex/dsptricks/dspblocks.sty b/Master/texmf-dist/tex/latex/dsptricks/dspblocks.sty
index b7aba995a9e..7cf2b136e35 100644
--- a/Master/texmf-dist/tex/latex/dsptricks/dspblocks.sty
+++ b/Master/texmf-dist/tex/latex/dsptricks/dspblocks.sty
@@ -11,7 +11,7 @@
%% set of macros to draw the types of block diagrams commonly
%% used in DSP theory
%%
-%% v1.0, July 2014
+%% v1.1, November 2023
%%
% required packages:
@@ -21,7 +21,7 @@
\RequirePackage{fmtcount}
\RequirePackage{ifthen}
%
-\ProvidesPackage{dspblocks}[2014/07/24 package for signal processing graphics]
+\ProvidesPackage{dspblocks}[2023/11/08 package for signal processing graphics]
% turn off FP messages
@@ -103,6 +103,15 @@
\psline{->}(0,-1.8)(0,2)%
\psplot[linewidth=1pt, plotpoints=500,linejoin=1]{-2.5}{2.5}{x \dspSinc{0}{0.5} 1.5 mul .5 sub}%
\endpspicture}}}
+\newcommand{\BDclip}[1][1em]{
+ \newskip\tmpLen \tmpLen=#1%
+ \raisebox{-1.5\tmpLen}{%
+ \psframebox[linewidth=1.2pt]{%
+ \psset{unit=#1,linearc=0,linewidth=2pt}%
+ \pspicture(-3,-2)(3,2)%
+ \psline[linecolor=gray](-2,-0)(2,-0)%
+ \psline(-1.5,-1.7)(0,-1.7)(0,1.7)(1.5,1.7)%
+ \endpspicture}}}
\newenvironment{dspBlocks}[2]{%
\begin{psmatrix}[colsep=#1,rowsep=#2,emnode=R] }{%
diff --git a/Master/texmf-dist/tex/latex/dsptricks/dspfunctions.sty b/Master/texmf-dist/tex/latex/dsptricks/dspfunctions.sty
index ae63eccaa0d..45b8fc4b612 100644
--- a/Master/texmf-dist/tex/latex/dsptricks/dspfunctions.sty
+++ b/Master/texmf-dist/tex/latex/dsptricks/dspfunctions.sty
@@ -11,10 +11,10 @@
%% set of postscript macros to compute the value of various DSP
%% common functions
%%
-%% v1.0, July 2014
+%% v1.1, November 2023
%%
-\ProvidesPackage{dspfunctions}[2014/07/24 package for signal processing graphics]
+\ProvidesPackage{dspfunctions}[2023/11/08 package for signal processing graphics]
\def\dspToDeg{180 mul }
@@ -108,6 +108,27 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
+% \dspAudio{a}{b} zero-DC baseband shape (e.g. an audio signal)
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\def\dspAudio#1#2{%
+ #1 sub #2 div
+ abs
+ dup 1 gt
+ {pop 0}%
+ {dup 0.01 le
+ {pop 0}
+ {dup 0.2 lt
+ {-30 mul}
+ {1 exch sub -8 mul}
+ ifelse
+ 2.7 exch exp 1 add 1 exch div 0.5 sub 2 mul
+ }
+ ifelse}
+ ifelse}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
% Fourier transform of a symmetric 2N+1 tap rect
% \dspSincS{a}{N} sin((x-a)(2N+1)/2)/sin((x-a)/2)
%
@@ -200,12 +221,12 @@
%
% Magnitude response of a generic digital filter defined by the
% constant-coefficient difference equation:
-% y[n] = a_0 x[n] + a_1 x[n-1] + ... + a_{N-1} x[n-N+1]
-% - b_1 y[n-1] - ... - b_{M-1} y[n-M+1]
+% y[n] = b_0 x[n] + b_1 x[n-1] + ... + b_{N-1} x[n-N+1]
+% - a_1 y[n-1] - ... - a_{M-1} y[n-M+1]
%
% The response is computed at the given normalized frequency value
%
-% \dspTFM{a_0 a_1 ... a_{N-1}}{b_1 b_2 ... b_{M-1}}
+% \dspTFM{b_0 b_1 b_2 ... b_{M-1}}{a_0 a_1 ... a_{N-1}}
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\def\dspTFM#1#2{%
@@ -214,17 +235,17 @@
0 % index n
0 % accumulator Re
0 % accumulator Im
- [#1] % coefficients a_n
+ [#1] % coefficients b_n
{ % STACK (neglecting saved input at bottom):
- % x n re im a_n
- dup % x n re im a_n a_n
- 5 index % x n re im a_n a_n x
- 5 index % x n re im a_n a_n x n
- mul dup % x n re im a_n a_n nx nx
- sin exch cos % x n re im a_n a_n sin(nx) cos(nx)
- 4 1 roll mul % x n re im cos(nx) a_n (a_n)sin(nx)
- 3 1 roll mul % x n re im (a_n)sin(nx) (a_n)cos(nx)
- 4 1 roll add % x n (a_n)cos(nx) re im'
+ % x n re im b_n
+ dup % x n re im b_n b_n
+ 5 index % x n re im b_n b_n x
+ 5 index % x n re im b_n b_n x n
+ mul dup % x n re im b_n b_n nx nx
+ sin exch cos % x n re im b_n b_n sin(nx) cos(nx)
+ 4 1 roll mul % x n re im cos(nx) b_n (b_n)sin(nx)
+ 3 1 roll mul % x n re im (b_n)sin(nx) (b_n)cos(nx)
+ 4 1 roll add % x n (b_n)cos(nx) re im'
3 1 roll add exch % x n re' im'
3 2 roll 1 add % x re' im' n'
3 1 roll % x n re im
@@ -233,10 +254,10 @@
dup mul exch dup mul add % (re^2 + im^2)
sqrt % mag of the numerator of transfer function
exch % bring up saved input copy
- 0 % same loop for the b_n coefficients
+ 0 % same loop for the a_n coefficients
0
0
- [#2]
+ [1 #2]
{
dup
5 index
@@ -256,3 +277,47 @@
div %0 eq {pop pop 0} {div} ifelse
}
+
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+%
+% Filter the data with a system implementing the transfer function
+% y[n] = b_0 x[n] + b_1 x[n-1] + ... + b_{N-1} x[n-N+1]
+% - a_1 y[n-1] - ... - a_{M-1} y[n-M+1]
+%
+% Use the setFilter macro in the setup part of the drawing command
+% and then \dspFilter{b_0 b_1 b_2 ... b_{M-1}}{a_1 ... a_{N-1}}
+%
+% \dspSignalOpt{\dspSetFilter{b_0 b_1 b_2 ... b_{M-1}}{a_1 ... a_{N-1}}}{x ... \dspFilter}
+%
+% NB: skip a_0 (assumed = 1) from the feedback part!
+%
+%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+\def\dspSetFilter#1#2{%
+ /b [#1] def
+ /xlen b length def
+ /xbuf [xlen {0} repeat] def
+ /a [#2] def
+ /ylen a length def
+ /ybuf [ylen {0} repeat] def
+}
+\def\dspFilter{
+ xbuf aload pop pop xbuf astore /xbuf exch def
+ 0
+ 0 1 xlen 1 sub {
+ dup
+ xbuf exch get
+ exch
+ b exch get
+ mul add
+ } for
+ 0 1 ylen 1 sub {
+ dup
+ ybuf exch get
+ exch
+ a exch get
+ mul sub
+ } for
+ dup
+ ybuf aload pop pop ybuf astore /ybuf exch def
+}
+
diff --git a/Master/texmf-dist/tex/latex/dsptricks/dsptricks.sty b/Master/texmf-dist/tex/latex/dsptricks/dsptricks.sty
index 5b075c043c1..43870b3d9cc 100644
--- a/Master/texmf-dist/tex/latex/dsptricks/dsptricks.sty
+++ b/Master/texmf-dist/tex/latex/dsptricks/dsptricks.sty
@@ -12,7 +12,7 @@
%% while writing the textbook "Signal Processing for Communication" by P. Prandoni
%% and M. Vetterli, freely available at www.sp4comm.org
%%
-%% v1.0, July 2014
+%% v1.1, November 2023
%%
\RequirePackage{pstricks}
\RequirePackage{pstricks-add}
@@ -21,7 +21,7 @@
\RequirePackage{fp}
\RequirePackage{ifthen}
%
-\ProvidesPackage{dsptricks}[2014/07/24 package for signal processing graphics]
+\ProvidesPackage{dsptricks}[2023/11/08 package for signal processing graphics]
% turn off FP messages
\FPmessagesfalse
@@ -207,7 +207,7 @@
\def\dspMkTk##1##2{{\dspTickLabelYR{##1}{##2}}}%
\fi
\def\dspMakeTicks##1 ##2 ##3\relax{%
- \ifx&##3&
+ \ifx\relax##3\relax
\dspMkTk{##1}{##2} %
\else
\dspMkTk{##1}{##2} \relax %