Debian packaging, thanks Stuart
authordrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Sun, 30 Aug 2015 20:33:55 +0000 (20:33 +0000)
committerdrowe67 <drowe67@01035d8c-6547-0410-b346-abe4f91aad63>
Sun, 30 Aug 2015 20:33:55 +0000 (20:33 +0000)
git-svn-id: https://svn.code.sf.net/p/freetel/code@2292 01035d8c-6547-0410-b346-abe4f91aad63

17 files changed:
codec2-dev/debian/changelog [new file with mode: 0644]
codec2-dev/debian/codec2.doc-base.EX [new file with mode: 0644]
codec2-dev/debian/codec2.install [new file with mode: 0644]
codec2-dev/debian/codec21.dirs [new file with mode: 0644]
codec2-dev/debian/codec21.install [new file with mode: 0644]
codec2-dev/debian/compat [new file with mode: 0644]
codec2-dev/debian/control [new file with mode: 0644]
codec2-dev/debian/copyright [new file with mode: 0644]
codec2-dev/debian/docs [new file with mode: 0644]
codec2-dev/debian/libcodec2-dev.dirs [new file with mode: 0644]
codec2-dev/debian/libcodec2-dev.install [new file with mode: 0644]
codec2-dev/debian/libcodec2.install [new file with mode: 0644]
codec2-dev/debian/rules [new file with mode: 0644]
codec2-dev/debian/source/format [new file with mode: 0644]
codec2-dev/octave/newamp.m
codec2-dev/octave/newamp_batch.m
codec2-dev/octave/newamp_fbf.m

diff --git a/codec2-dev/debian/changelog b/codec2-dev/debian/changelog
new file mode 100644 (file)
index 0000000..214efcf
--- /dev/null
@@ -0,0 +1,5 @@
+codec2 (0.4-150830) unstable; urgency=low
+
+  * Subversion snapshot of tag 0.4.
+
+ -- Stuart Longland <stuartl@longlandclan.yi.org>  Sun, 30 Aug 2015 08:57:09 +1000
diff --git a/codec2-dev/debian/codec2.doc-base.EX b/codec2-dev/debian/codec2.doc-base.EX
new file mode 100644 (file)
index 0000000..5836087
--- /dev/null
@@ -0,0 +1,20 @@
+Document: codec2
+Title: Debian codec2 Manual
+Author: <insert document author here>
+Abstract: This manual describes what codec2 is
+ and how it can be used to
+ manage online manuals on Debian systems.
+Section: unknown
+
+Format: debiandoc-sgml
+Files: /usr/share/doc/codec2/codec2.sgml.gz
+
+Format: postscript
+Files: /usr/share/doc/codec2/codec2.ps.gz
+
+Format: text
+Files: /usr/share/doc/codec2/codec2.text.gz
+
+Format: HTML
+Index: /usr/share/doc/codec2/html/index.html
+Files: /usr/share/doc/codec2/html/*.html
diff --git a/codec2-dev/debian/codec2.install b/codec2-dev/debian/codec2.install
new file mode 100644 (file)
index 0000000..1df36c6
--- /dev/null
@@ -0,0 +1 @@
+usr/bin/*
diff --git a/codec2-dev/debian/codec21.dirs b/codec2-dev/debian/codec21.dirs
new file mode 100644 (file)
index 0000000..6845771
--- /dev/null
@@ -0,0 +1 @@
+usr/lib
diff --git a/codec2-dev/debian/codec21.install b/codec2-dev/debian/codec21.install
new file mode 100644 (file)
index 0000000..d0dbfd1
--- /dev/null
@@ -0,0 +1 @@
+usr/lib/lib*.so.*
diff --git a/codec2-dev/debian/compat b/codec2-dev/debian/compat
new file mode 100644 (file)
index 0000000..ec63514
--- /dev/null
@@ -0,0 +1 @@
+9
diff --git a/codec2-dev/debian/control b/codec2-dev/debian/control
new file mode 100644 (file)
index 0000000..de9aa3b
--- /dev/null
@@ -0,0 +1,36 @@
+Source: codec2
+Priority: optional
+Maintainer: Stuart Longland <stuartl@longlandclan.yi.org>
+Build-Depends: debhelper (>= 9), cmake, libspeexdsp-dev
+Standards-Version: 3.9.5
+Section: libs
+Homepage: http://www.freedv.org
+
+Package: libcodec2-dev
+Section: libdevel
+Architecture: any
+Depends: libcodec2 (= ${binary:Version}), ${misc:Depends}
+Description: Codec 2: ultra-low bitrate voice codec.  Headers.
+ Codec 2 is an ultra-low bitrate (sub 4kbps) voice codec
+ for use in radio frequency communications applications.
+ .
+ This package provides the headers.
+
+Package: libcodec2
+Architecture: any
+Depends: ${shlibs:Depends}, ${misc:Depends}, libspeexdsp1
+Description: Codec 2: ultra-low bitrate voice codec.  Library.
+ Codec 2 is an ultra-low bitrate (sub 4kbps) voice codec
+ for use in radio frequency communications applications.
+ .
+ This package provides the runtime library.
+
+Package: codec2
+Architecture: any
+Depends: libcodec2 (= ${binary:Version}), ${shlibs:Depends}, ${misc:Depends}
+Description: Codec 2: ultra-low bitrate voice codec.  Utilities.
+ Codec 2 is an ultra-low bitrate (sub 4kbps) voice codec
+ for use in radio frequency communications applications.
+ .
+ This package provides some command line utilities for encoding
+ and decoding codec2.
diff --git a/codec2-dev/debian/copyright b/codec2-dev/debian/copyright
new file mode 100644 (file)
index 0000000..598dd85
--- /dev/null
@@ -0,0 +1,38 @@
+Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/
+Upstream-Name: codec2
+Source: <url://example.com>
+
+Files: *
+Copyright: <years> <put author's name and email here>
+           <years> <likewise for another author>
+License: <special license>
+ <Put the license of the package here indented by 1 space>
+ <This follows the format of Description: lines in control file>
+ .
+ <Including paragraphs>
+
+# If you want to use GPL v2 or later for the /debian/* files use 
+# the following clauses, or change it to suit. Delete these two lines
+Files: debian/*
+Copyright: 2015 unknown <stuartl@unknown>
+License: GPL-2+
+ This package is free software; you can redistribute it and/or modify
+ it under the terms of the GNU General Public License as published by
+ the Free Software Foundation; either version 2 of the License, or
+ (at your option) any later version.
+ .
+ This package is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ GNU General Public License for more details.
+ .
+ You should have received a copy of the GNU General Public License
+ along with this program. If not, see <http://www.gnu.org/licenses/>
+ .
+ On Debian systems, the complete text of the GNU General
+ Public License version 2 can be found in "/usr/share/common-licenses/GPL-2".
+
+# Please also look if there are files or directories which have a
+# different copyright/license attached and list them here.
+# Please avoid to pick license terms that are more restrictive than the
+# packaged work, as it may make Debian's contributions unacceptable upstream.
diff --git a/codec2-dev/debian/docs b/codec2-dev/debian/docs
new file mode 100644 (file)
index 0000000..8e229a3
--- /dev/null
@@ -0,0 +1,6 @@
+NEWS
+README
+README_fdmdv.txt
+AUTHORS
+ChangeLog
+INSTALL
diff --git a/codec2-dev/debian/libcodec2-dev.dirs b/codec2-dev/debian/libcodec2-dev.dirs
new file mode 100644 (file)
index 0000000..4418816
--- /dev/null
@@ -0,0 +1,2 @@
+usr/lib
+usr/include
diff --git a/codec2-dev/debian/libcodec2-dev.install b/codec2-dev/debian/libcodec2-dev.install
new file mode 100644 (file)
index 0000000..41a1414
--- /dev/null
@@ -0,0 +1 @@
+usr/include/*
diff --git a/codec2-dev/debian/libcodec2.install b/codec2-dev/debian/libcodec2.install
new file mode 100644 (file)
index 0000000..f1d0181
--- /dev/null
@@ -0,0 +1 @@
+usr/lib/*
diff --git a/codec2-dev/debian/rules b/codec2-dev/debian/rules
new file mode 100644 (file)
index 0000000..c6cdbe7
--- /dev/null
@@ -0,0 +1,24 @@
+#!/usr/bin/make -f
+# See debhelper(7) (uncomment to enable)
+# output every command that modifies files on the build system.
+#DH_VERBOSE = 1
+
+# see EXAMPLES in dpkg-buildflags(1) and read /usr/share/dpkg/*
+DPKG_EXPORT_BUILDFLAGS = 1
+include /usr/share/dpkg/default.mk
+
+# see FEATURE AREAS in dpkg-buildflags(1)
+#export DEB_BUILD_MAINT_OPTIONS = hardening=+all
+
+# see ENVIRONMENT in dpkg-buildflags(1)
+# package maintainers to append CFLAGS
+#export DEB_CFLAGS_MAINT_APPEND  = -Wall -pedantic
+# package maintainers to append LDFLAGS
+#export DEB_LDFLAGS_MAINT_APPEND = -Wl,--as-needed
+
+
+# main packaging script based on dh7 syntax
+%:
+       dh $@ --buildsystem=cmake
+
+
diff --git a/codec2-dev/debian/source/format b/codec2-dev/debian/source/format
new file mode 100644 (file)
index 0000000..163aaf8
--- /dev/null
@@ -0,0 +1 @@
+3.0 (quilt)
index aedd37fed82249d38bda87ba464e835851b3f97c..f10a985c3f628cb41e2a47eadd959b0cea0ea7b5 100644 (file)
 %  [ ] return data for plotting, like slope m
 %  [ ] quantise m
 
+% dealing with UV, BG noise. Prob is flat spectra.  When we fit a low
+% freq masking model it's formant shaped rather than flat.  So we get
+% these gaps in spectra that come and go - waterfall noises.  In
+% particular at low frequencies.  Good news is they don't need to be
+% quantised too finely.  This model has the disadvantage of not having
+% variable bandwidths.
+% when do waterfall noises appear?
+% idea: we could add the ability to have wider bands
+%        Add some sort of slope or floor
+%        increase spacing of samples?  Like min spacing in bark dimension
+
+% can we fit a different shape?
+
 function [decmaskdB local_maxima_sort] = make_decmask(maskdB, AmdB, Wo, L, mask_sample_freqs_kHz)
 
     % band pass filter: limit search to 250 to 3800 Hz
@@ -122,29 +135,36 @@ endfunction
 % Ahh, takes me back to when I was a slip of a speech coder, playing
 % with my first CELP codec!
 
-function [decmaskdB dec_samples] = make_decmask_abys(maskdB, AmdB, Wo, L, mask_sample_freqs_kHz)
+function [decmaskdB dec_samples error_log candidate_log target_log] = make_decmask_abys(maskdB, AmdB, Wo, L, mask_sample_freqs_kHz)
 
     % band pass filter: limit search to 250 to 3800 Hz
 
-    m_st = max(1,floor((pi*250/4000)/Wo));
-    m_en = floor((pi*3800/4000)/Wo);
+    %m_st = max(1,floor((pi*250/4000)/Wo));
+    %m_en = floor((pi*3800/4000)/Wo);
+    m_st = 1;
+    m_en = L;
 
     target = maskdB;
     decmaskdB = zeros(1,L);
     dec_samples = [];
-
+    error_log = [];
+    candidate_log = [];
 
     for sample=1:4
 
+      target_log = target;
+
       % find best position for sample to minimise distance to target
 
       min_mse = 1E32;
       for m=m_st:m_en
         single_mask_m = schroeder(m*Wo*4/pi, mask_sample_freqs_kHz) + AmdB(m);
         candidate = max(decmaskdB, single_mask_m);
-        candidate = max(zeros(1,L), candidate);
+        candidate = max(min(maskdB), candidate);
         error = target - candidate;
-        mse = sum(error .^ 2);
+        error_log = [error_log; error];
+        candidate_log = [candidate_log; candidate];
+        mse = sum(abs(error)); % MSE in log domain
         %printf("m: %d f: %f error: %f\n", m, m*Wo*4/pi, mse);
         if (mse < min_mse)
           min_mse = mse;
@@ -155,8 +175,62 @@ function [decmaskdB dec_samples] = make_decmask_abys(maskdB, AmdB, Wo, L, mask_s
 
       decmaskdB = min_candidate;
       dec_samples = [dec_samples; AmdB(min_mse_m) min_mse_m];
+      %printf("sample: %d min_mse_m: %d\n", sample, min_mse_m);
+    end
+
+    % simulate quantisation of amplitudes by adding some noise
+
+    if 0
+      masker_amps_dB = dec_samples(:,1);
+      masker_amps_dB += 3*(1 - 2*rand(4,1));
+      masker_freqs_kHz = dec_samples(:,2)*Wo*4/pi;
+      decmaskdB = determine_mask(masker_amps_dB,  masker_freqs_kHz, mask_sample_freqs_kHz);
+    end
+    
+    % quantisation of amplitudes.  Determine and subtract mean.  Quantise difference
+    % from mean to 4 levels (2 bits), at 6dB/level:
+    %
+    %           Level
+    %    0       -9            
+    %    1       -3
+    %    2       +3
+    %    3       +9
+
+    if 0
+      masker_amps_dB = dec_samples(:,1);
+      masker_freqs_kHz = dec_samples(:,2)*Wo*4/pi;
+
+      energy_dB = mean(masker_amps_dB);
+      masker_amps_dB -= energy_dB;
+      for i=1:4
+        masker_amps_dB(i) = quantise([-9 -3 3 9], masker_amps_dB(i));
+      end
+      masker_amps_dB += energy_dB;
+      decmaskdB = determine_mask(masker_amps_dB,  masker_freqs_kHz, mask_sample_freqs_kHz);
     end
 
+    % fit straight line to amplitudes (sounds bad, still a bug somewhere)
+
+    if 0
+      [gradient intercept] = linreg(dec_samples(:,2), dec_samples(:,1), 4);
+      masker_amps_dB = dec_samples(:,2)*gradient + intercept;
+      masker_freqs_kHz = dec_samples(:,2)*Wo*4/pi;
+      decmaskdB = determine_mask(masker_amps_dB,  masker_freqs_kHz, mask_sample_freqs_kHz);
+    end
+endfunction
+
+
+% quantise input sample to nearest value in table 
+
+function quant_out = quantise(levels, quant_in)
+  best_se = 1E32;
+  for i=1:length(levels)
+    se = (levels(i) - quant_in)^2;
+    if se < best_se
+      quant_out = levels(i);
+      best_se = se;
+    end
+  end
 endfunction
 
 
@@ -202,14 +276,19 @@ function maskdB = schroeder(freq_tone_kHz, mask_sample_freqs_kHz, modified_bark_
     % beneath 1.5kHz wider to match the width of F1 and
     % "fill in" the spectra better for UV sounds.
 
-    if freq_tone_kHz <= 0.5
-      y = 0.5;
+    x1 = 0.5; x2 = 1.5;
+    y1 = 0.5; y2 = 1;
+    grad  = (y2 - y1)/(x2 - x1);
+    y_int = y1 - grad*x1;
+
+    if freq_tone_kHz <= x1
+      y = y1;
     end
     if (freq_tone_kHz > 0.5) && (freq_tone_kHz < 1.5)
-      y = 0.5*freq_tone_kHz + 0.25;
+      y = grad*freq_tone_kHz + y_int;
     end
-    if freq_tone_kHz >= 1.5
-      y = 1;
+    if freq_tone_kHz >= x2
+      y = y2;
     end
     dz = y*(bark(freq_tone_kHz*1000) - bark(f_Hz));
   else
@@ -228,6 +307,16 @@ function b=bark(f)
 endfunction
 
 
+% -12dB/octave mask to model speech articulation
+
+function maskdB = resonator(freq_tone_kHz, mask_sample_freqs_kHz)
+  maskdB = zeros(1, length(mask_sample_freqs_kHz));
+  for m=1:length(mask_sample_freqs_kHz)
+    maskdB(m) = -12*abs(log2(freq_tone_kHz/mask_sample_freqs_kHz(m)));
+    printf("m: %d ft: %f fm: %f ft/fm: %f maskdB: %f\n", m, freq_tone_kHz, mask_sample_freqs_kHz(m), freq_tone_kHz/mask_sample_freqs_kHz(m), maskdB(m));
+  end
+endfunction
+
 % plot some masking curves, used for working on masking filter changes
 
 function plot_masking
@@ -235,26 +324,27 @@ function plot_masking
 
   figure(1)
   mask_sample_freqs_kHz = 0.1:0.1:(Fs/1000)/2;
-  maskdB = schroeder(0.5, mask_sample_freqs_kHz, 0);
-  plot(mask_sample_freqs_kHz, maskdB);
+  maskdB_cb = schroeder(0.5, mask_sample_freqs_kHz, 1);
+  plot(mask_sample_freqs_kHz, maskdB_cb);
   hold on;
-  maskdB = schroeder(0.5, mask_sample_freqs_kHz, 1);
-  plot(mask_sample_freqs_kHz, maskdB,'g');
-
-  for f=1:0.5:3
-    maskdB = schroeder(f, mask_sample_freqs_kHz, 0);
-    plot(mask_sample_freqs_kHz, maskdB);
-    maskdB = schroeder(f, mask_sample_freqs_kHz, 1);
-    plot(mask_sample_freqs_kHz, maskdB,'g');
+  maskdB_res = resonator(0.5, mask_sample_freqs_kHz);
+  plot(mask_sample_freqs_kHz, maskdB_res,'g');
+
+  for f=0.5:0.5:3
+    maskdB_cb = schroeder(f, mask_sample_freqs_kHz, 1);
+    plot(mask_sample_freqs_kHz, maskdB_cb);
+    maskdB_res = resonator(f, mask_sample_freqs_kHz);
+    plot(mask_sample_freqs_kHz, maskdB_res,'g');
   end
   hold off;
   axis([0.1 4 -30 0])
+  grid
 
   figure(2)
-  plot(mask_sample_freqs_kHz, bark(mask_sample_freqs_kHz*1000))
-  hold on;
-  plot(mask_sample_freqs_kHz, modified_bark(mask_sample_freqs_kHz*1000),'g')
-  hold off;
+  clf;
+  w = pi/4; beta = 0.9;
+  X = freqz(1,[1 -2*beta*cos(w) beta*beta],4000);
+  plot(10*log10(abs(X)))
   grid
 endfunction
 
index db432e718b667badddd9c19154c079098bbc6a6e..8119a117103d8164ad1abc3022e4c85aaea9f1bd 100644 (file)
@@ -15,7 +15,7 @@
 
 % process a whole file and write results
 
-function newamp_batch(samname)
+function newamp_batch(samname, optional_Am_out_name)
   newamp;
   more off;
 
@@ -24,7 +24,13 @@ function newamp_batch(samname)
   [frames nc] = size(model);
   max_amp = 80;
 
-  Am_out_name = sprintf("%s_am.out", samname);
+  if nargin == 1
+    Am_out_name = sprintf("%s_am.out", samname);
+  end
+  if nargin == 2
+    Am_out_name = optional_Am_out_name;
+  end
+    
   fam = fopen(Am_out_name,"wb"); 
 
   for f=1:frames
index 39e0cbde95c6b394f6a5db3668b9b9d46976b4b0..040503238f3b6c67c23d0486546405e17edb3d2c 100644 (file)
@@ -73,7 +73,7 @@ function newamp_fbf(samname, f)
     % estimate low rate samples
 
     mask_sample_freqs_kHz = (1:L)*Wo*4/pi;
-    [decmaskdB local_maxima] = make_decmask_abys(maskdB, AmdB, Wo, L, mask_sample_freqs_kHz);
+    [decmaskdB local_maxima error_log candidate_log target_log] = make_decmask_abys(maskdB, AmdB, Wo, L, mask_sample_freqs_kHz);
     
     [nlm tmp] = size(local_maxima(:,2));
     nlm = min(nlm,4);
@@ -101,7 +101,14 @@ function newamp_fbf(samname, f)
     hold off;
 
     figure(3)
-    plot(decmaskdB)
+    plot(target_log,'g')
+    hold on;
+    plot(candidate_log(3,:),'b');
+    plot(candidate_log(5,:),'b');
+    plot(error_log(3,:),'r');
+    plot(error_log(5,:),'r');
+    hold off;
+
     % interactive menu
 
     printf("\rframe: %d  menu: n-next  b-back  p-png  q-quit m-all", f);