Add a script to update qm-dsp library
[ardour.git] / tools / update_qm-dsp.sh
1 #!/bin/sh
2
3 if ! test -f wscript || ! test -d gtk2_ardour || ! test -d libs/qm-dsp/;then
4         echo "This script needs to run from ardour's top-level src tree"
5         exit 1
6 fi
7
8 if test -z "`which rsync`" -o -z "`which git`"; then
9         echo "this script needs rsync and git"
10         exit 1
11 fi
12
13 ASRC=`pwd`
14 set -e
15
16 cd libs/qm-dsp
17 QMFILES=`find . -type f | grep -v MSVCqm-dsp | grep -v wscript`
18
19 TMP=`mktemp -d`
20 test -d "$TMP"
21 echo $TMP
22 trap "rm -rf $TMP" EXIT
23
24 cd $TMP
25 git clone git://github.com/c4dm/qm-dsp.git qm-dsp
26 cd qm-dsp
27 git describe --tags > "$ASRC/libs/qm-dsp/gitrev.txt"
28 QMDSP="$TMP/qm-dsp"
29
30 cd "$ASRC/libs/qm-dsp"
31 find base dsp ext maths -type f -exec rsync -c --progress "$QMDSP/{}" "{}" \;
32
33
34 ## this applies to qm-vamp-plugins-v1.7.1-20-g4d15479
35 ## (see also Ardour 5.8-250-gc0c24aff7)
36 patch -p3 << EOF
37 diff --git a/libs/qm-dsp/dsp/signalconditioning/FiltFilt.cpp b/libs/qm-dsp/dsp/signalconditioning/FiltFilt.cpp
38 index 714d5755d..c88641de7 100644
39 --- a/libs/qm-dsp/dsp/signalconditioning/FiltFilt.cpp
40 +++ b/libs/qm-dsp/dsp/signalconditioning/FiltFilt.cpp
41 @@ -35,6 +35,13 @@ void FiltFilt::process(double *src, double *dst, unsigned int length)
42  
43      if (length == 0) return;
44  
45 +    if (length < 2) {
46 +       for( i = 0; i < length; i++ ) {
47 +           dst[i] = src [i];
48 +       }
49 +       return;
50 +    }
51 +
52      unsigned int nFilt = m_ord + 1;
53      unsigned int nFact = 3 * ( nFilt - 1);
54      unsigned int nExt  = length + 2 * nFact;
55 @@ -58,11 +65,16 @@ void FiltFilt::process(double *src, double *dst, unsigned int length)
56         filtScratchIn[ index++ ] = sample0 - src[ i ];
57      }
58      index = 0;
59 -    for( i = 0; i < nFact; i++ )
60 +    for( i = 0; i < nFact && i + 2 < length; i++ )
61      {
62         filtScratchIn[ (nExt - nFact) + index++ ] = sampleN - src[ (length - 2) - i ];
63      }
64  
65 +    for(; i < nFact; i++ )
66 +    {
67 +       filtScratchIn[ (nExt - nFact) + index++ ] = 0;
68 +    }
69 +
70      index = 0;
71      for( i = 0; i < length; i++ )
72      {
73 EOF
74
75 git add gitrev.txt base dsp ext maths