From 18525ede674c9d5a396bb4ffbdc398f56f8d979a Mon Sep 17 00:00:00 2001 From: drowe67 Date: Sat, 30 May 2015 03:26:56 +0000 Subject: [PATCH] processing single symbol thru speex git-svn-id: https://svn.code.sf.net/p/freetel/code@2167 01035d8c-6547-0410-b346-abe4f91aad63 --- codec2-dev/octave/cellmodem.m | 58 ++++++++++++++++++++++++++--------- 1 file changed, 43 insertions(+), 15 deletions(-) diff --git a/codec2-dev/octave/cellmodem.m b/codec2-dev/octave/cellmodem.m index 7477d06f..ac0e0c3b 100644 --- a/codec2-dev/octave/cellmodem.m +++ b/codec2-dev/octave/cellmodem.m @@ -22,37 +22,65 @@ graphics_toolkit ("gnuplot"); lsp; +codec_cmd = "speexenc --bitrate 4000 in.raw - | speexdec - out.raw" + lpc_order = 4; Fs = 8000; -fo = 100; % pitch frequency of voice +fo = 200; % pitch frequency of voice wo = 2*pi*fo/Fs; % pitch in rads N = Fs*0.04; % frame length +frames = Fs/N; % frames to play through codec +gain = 100; + +s = []; +w_log = []; +w__log = []; + +for f=1:frames -% construct LSP symbol + % construct LSP symbol -w = [0.1 0.4 0.5 0.8]*pi + w = [0.1 0.4 0.5 0.8]*pi; -% synthesise speech signal + % synthesise speech signal -a=lsptoa(w) -l=pi/wo; -ex = zeros(1,N); -for m=1:l + a=lsptoa(w); + w_log = [w_log; w]; + l=pi/wo; + ex = zeros(1,N); + for m=1:l ex += cos(wo*m*(1:N)); + end + s = [s filter(1, a, ex)]; end -s = filter(1, a, ex); -% insert codec here (e.g. write to file, run codec, read file) +% play through codec -% extract received symbol from channel +s *= gain; +f=fopen("in.raw","wb"); +fwrite(f,s,"short"); +fclose(f); +system(codec_cmd); +f=fopen("out.raw","rb"); +s_ = fread(f,Inf,"short"); +fclose(f); -a_ = lpcauto(s, lpc_order) -w_ = atolsp(a_) +% extract received symbols from channel and evaluate + +for f=1:frames + a_ = lpcauto(s_((f-1)*N+1:f*N), lpc_order); + w_ = atolsp(a_); + w__log = [w__log; w_]; +end figure(1); clf; subplot(211) plot(s) +axis([1 Fs/10 -4000 4000]); subplot(212) -plot(w,'g+',w_','r+'); -axis([0 lpc_order+1 0 pi]) +plot(s_); +axis([1 Fs/10 -4000 4000]); + +figure(2) +plot(w_log, 'g', w__log, 'r+') -- 2.25.1