From a5f2d450c73002ea16fc99ad561f0ef42d7febb7 Mon Sep 17 00:00:00 2001 From: drowe67 Date: Sun, 30 Aug 2015 20:33:55 +0000 Subject: [PATCH] Debian packaging, thanks Stuart git-svn-id: https://svn.code.sf.net/p/freetel/code@2292 01035d8c-6547-0410-b346-abe4f91aad63 --- codec2-dev/debian/changelog | 5 + codec2-dev/debian/codec2.doc-base.EX | 20 ++++ codec2-dev/debian/codec2.install | 1 + codec2-dev/debian/codec21.dirs | 1 + codec2-dev/debian/codec21.install | 1 + codec2-dev/debian/compat | 1 + codec2-dev/debian/control | 36 ++++++ codec2-dev/debian/copyright | 38 +++++++ codec2-dev/debian/docs | 6 + codec2-dev/debian/libcodec2-dev.dirs | 2 + codec2-dev/debian/libcodec2-dev.install | 1 + codec2-dev/debian/libcodec2.install | 1 + codec2-dev/debian/rules | 24 ++++ codec2-dev/debian/source/format | 1 + codec2-dev/octave/newamp.m | 140 +++++++++++++++++++----- codec2-dev/octave/newamp_batch.m | 10 +- codec2-dev/octave/newamp_fbf.m | 11 +- 17 files changed, 270 insertions(+), 29 deletions(-) create mode 100644 codec2-dev/debian/changelog create mode 100644 codec2-dev/debian/codec2.doc-base.EX create mode 100644 codec2-dev/debian/codec2.install create mode 100644 codec2-dev/debian/codec21.dirs create mode 100644 codec2-dev/debian/codec21.install create mode 100644 codec2-dev/debian/compat create mode 100644 codec2-dev/debian/control create mode 100644 codec2-dev/debian/copyright create mode 100644 codec2-dev/debian/docs create mode 100644 codec2-dev/debian/libcodec2-dev.dirs create mode 100644 codec2-dev/debian/libcodec2-dev.install create mode 100644 codec2-dev/debian/libcodec2.install create mode 100644 codec2-dev/debian/rules create mode 100644 codec2-dev/debian/source/format diff --git a/codec2-dev/debian/changelog b/codec2-dev/debian/changelog new file mode 100644 index 00000000..214efcf9 --- /dev/null +++ b/codec2-dev/debian/changelog @@ -0,0 +1,5 @@ +codec2 (0.4-150830) unstable; urgency=low + + * Subversion snapshot of tag 0.4. + + -- Stuart Longland 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 index 00000000..58360877 --- /dev/null +++ b/codec2-dev/debian/codec2.doc-base.EX @@ -0,0 +1,20 @@ +Document: codec2 +Title: Debian codec2 Manual +Author: +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 index 00000000..1df36c61 --- /dev/null +++ b/codec2-dev/debian/codec2.install @@ -0,0 +1 @@ +usr/bin/* diff --git a/codec2-dev/debian/codec21.dirs b/codec2-dev/debian/codec21.dirs new file mode 100644 index 00000000..68457717 --- /dev/null +++ b/codec2-dev/debian/codec21.dirs @@ -0,0 +1 @@ +usr/lib diff --git a/codec2-dev/debian/codec21.install b/codec2-dev/debian/codec21.install new file mode 100644 index 00000000..d0dbfd18 --- /dev/null +++ b/codec2-dev/debian/codec21.install @@ -0,0 +1 @@ +usr/lib/lib*.so.* diff --git a/codec2-dev/debian/compat b/codec2-dev/debian/compat new file mode 100644 index 00000000..ec635144 --- /dev/null +++ b/codec2-dev/debian/compat @@ -0,0 +1 @@ +9 diff --git a/codec2-dev/debian/control b/codec2-dev/debian/control new file mode 100644 index 00000000..de9aa3bf --- /dev/null +++ b/codec2-dev/debian/control @@ -0,0 +1,36 @@ +Source: codec2 +Priority: optional +Maintainer: Stuart Longland +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 index 00000000..598dd85a --- /dev/null +++ b/codec2-dev/debian/copyright @@ -0,0 +1,38 @@ +Format: http://www.debian.org/doc/packaging-manuals/copyright-format/1.0/ +Upstream-Name: codec2 +Source: + +Files: * +Copyright: + +License: + + + . + + +# 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 +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 + . + 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 index 00000000..8e229a37 --- /dev/null +++ b/codec2-dev/debian/docs @@ -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 index 00000000..44188162 --- /dev/null +++ b/codec2-dev/debian/libcodec2-dev.dirs @@ -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 index 00000000..41a14144 --- /dev/null +++ b/codec2-dev/debian/libcodec2-dev.install @@ -0,0 +1 @@ +usr/include/* diff --git a/codec2-dev/debian/libcodec2.install b/codec2-dev/debian/libcodec2.install new file mode 100644 index 00000000..f1d0181f --- /dev/null +++ b/codec2-dev/debian/libcodec2.install @@ -0,0 +1 @@ +usr/lib/* diff --git a/codec2-dev/debian/rules b/codec2-dev/debian/rules new file mode 100644 index 00000000..c6cdbe71 --- /dev/null +++ b/codec2-dev/debian/rules @@ -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 index 00000000..163aaf8d --- /dev/null +++ b/codec2-dev/debian/source/format @@ -0,0 +1 @@ +3.0 (quilt) diff --git a/codec2-dev/octave/newamp.m b/codec2-dev/octave/newamp.m index aedd37fe..f10a985c 100644 --- a/codec2-dev/octave/newamp.m +++ b/codec2-dev/octave/newamp.m @@ -38,6 +38,19 @@ % [ ] 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 diff --git a/codec2-dev/octave/newamp_batch.m b/codec2-dev/octave/newamp_batch.m index db432e71..8119a117 100644 --- a/codec2-dev/octave/newamp_batch.m +++ b/codec2-dev/octave/newamp_batch.m @@ -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 diff --git a/codec2-dev/octave/newamp_fbf.m b/codec2-dev/octave/newamp_fbf.m index 39e0cbde..04050323 100644 --- a/codec2-dev/octave/newamp_fbf.m +++ b/codec2-dev/octave/newamp_fbf.m @@ -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); -- 2.25.1