[xiph-commits] r9578 - in trunk/ghost: . m-files

jm at svn.xiph.org jm at svn.xiph.org
Sun Jul 17 16:35:26 PDT 2005


Author: jm
Date: 2005-07-17 16:35:23 -0700 (Sun, 17 Jul 2005)
New Revision: 9578

Added:
   trunk/ghost/Makefile.am
   trunk/ghost/autogen.sh
   trunk/ghost/configure.ac
   trunk/ghost/m-files/
   trunk/ghost/m-files/ESPRIT.m
   trunk/ghost/m-files/MUSIC.m
   trunk/ghost/m-files/analyse.m
   trunk/ghost/m-files/track_sin.m
   trunk/ghost/m-files/track_sin2.m
   trunk/ghost/m-files/track_sin3.m
   trunk/ghost/m-files/track_sin3b.m
Log:
automake/autoconf stuff, plus some m files


Added: trunk/ghost/Makefile.am
===================================================================
--- trunk/ghost/Makefile.am	2005-07-17 23:20:05 UTC (rev 9577)
+++ trunk/ghost/Makefile.am	2005-07-17 23:35:23 UTC (rev 9578)
@@ -0,0 +1,11 @@
+## Process this file with automake to produce Makefile.in. -*-Makefile-*-
+
+# To disable automatic dependency tracking if using other tools than
+# gcc and gmake, add the option 'no-dependencies'
+AUTOMAKE_OPTIONS = 1.8
+
+#Fools KDevelop into including all files
+SUBDIRS = libghost
+
+rpm: dist
+	rpmbuild -ta ${PACKAGE}-${VERSION}.tar.gz

Added: trunk/ghost/autogen.sh
===================================================================
--- trunk/ghost/autogen.sh	2005-07-17 23:20:05 UTC (rev 9577)
+++ trunk/ghost/autogen.sh	2005-07-17 23:35:23 UTC (rev 9578)
@@ -0,0 +1,116 @@
+#!/bin/sh
+# Run this to set up the build system: configure, makefiles, etc.
+# (based on the version in enlightenment's cvs)
+
+package="ghost"
+
+olddir=`pwd`
+srcdir=`dirname $0`
+test -z "$srcdir" && srcdir=.
+
+cd "$srcdir"
+DIE=0
+
+echo "checking for autoconf... "
+(autoconf --version) < /dev/null > /dev/null 2>&1 || {
+        echo
+        echo "You must have autoconf installed to compile $package."
+        echo "Download the appropriate package for your distribution,"
+        echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
+        DIE=1
+}
+
+VERSIONGREP="sed -e s/.*[^0-9\.]\([0-9]\.[0-9]\).*/\1/"
+VERSIONMKINT="sed -e s/[^0-9]//"
+                                                                                
+# do we need automake?
+if test -r Makefile.am; then
+  AM_NEEDED=`fgrep AUTOMAKE_OPTIONS Makefile.am | $VERSIONGREP`
+  if test -z $AM_NEEDED; then
+    echo -n "checking for automake... "
+    AUTOMAKE=automake
+    ACLOCAL=aclocal
+    if ($AUTOMAKE --version < /dev/null > /dev/null 2>&1); then
+      echo "no"
+      AUTOMAKE=
+    else
+      echo "yes"
+    fi
+  else
+    echo -n "checking for automake $AM_NEEDED or later... "
+    for am in automake-$AM_NEEDED automake$AM_NEEDED automake; do
+      ($am --version < /dev/null > /dev/null 2>&1) || continue
+      ver=`$am --version < /dev/null | head -n 1 | $VERSIONGREP | $VERSIONMKINT`
+      verneeded=`echo $AM_NEEDED | $VERSIONMKINT`
+      if test $ver -ge $verneeded; then
+        AUTOMAKE=$am
+        echo $AUTOMAKE
+        break
+      fi
+    done
+    test -z $AUTOMAKE &&  echo "no"
+    echo -n "checking for aclocal $AM_NEEDED or later... "
+    for ac in aclocal-$AM_NEEDED aclocal$AM_NEEDED aclocal; do
+      ($ac --version < /dev/null > /dev/null 2>&1) || continue
+      ver=`$ac --version < /dev/null | head -n 1 | $VERSIONGREP | $VERSIONMKINT`
+      verneeded=`echo $AM_NEEDED | $VERSIONMKINT`
+      if test $ver -ge $verneeded; then
+        ACLOCAL=$ac
+        echo $ACLOCAL
+        break
+      fi
+    done
+    test -z $ACLOCAL && echo "no"
+  fi
+  test -z $AUTOMAKE || test -z $ACLOCAL && {
+        echo
+        echo "You must have automake installed to compile $package."
+        echo "Download the appropriate package for your distribution,"
+        echo "or get the source tarball at ftp://ftp.gnu.org/pub/gnu/"
+        exit 1
+  }
+fi
+
+echo -n "checking for libtool... "
+for LIBTOOLIZE in libtoolize glibtoolize nope; do
+  ($LIBTOOLIZE --version) < /dev/null > /dev/null 2>&1 && break
+done
+if test x$LIBTOOLIZE = xnope; then
+  echo "nope."
+  LIBTOOLIZE=libtoolize
+else
+  echo $LIBTOOLIZE
+fi
+($LIBTOOLIZE --version) < /dev/null > /dev/null 2>&1 || {
+	echo
+	echo "You must have libtool installed to compile $package."
+	echo "Download the appropriate package for your system,"
+	echo "or get the source from one of the GNU ftp sites"
+	echo "listed in http://www.gnu.org/order/ftp.html"
+	DIE=1
+}
+
+if test "$DIE" -eq 1; then
+        exit 1
+fi
+
+if test -z "$*"; then
+        echo "I am going to run ./configure with no arguments - if you wish "
+        echo "to pass any to it, please specify them on the $0 command line."
+fi
+
+echo "Generating configuration files for $package, please wait...."
+
+echo "  $ACLOCAL $ACLOCAL_FLAGS"
+$ACLOCAL $ACLOCAL_FLAGS || exit 1
+echo "  autoheader"
+autoheader || exit 1
+echo "  $LIBTOOLIZE --automake"
+$LIBTOOLIZE --automake || exit 1
+echo "  $AUTOMAKE --add-missing $AUTOMAKE_FLAGS"
+$AUTOMAKE --add-missing $AUTOMAKE_FLAGS || exit 1
+echo "  autoconf"
+autoconf || exit 1
+
+cd $olddir
+$srcdir/configure "$@" && echo


Property changes on: trunk/ghost/autogen.sh
___________________________________________________________________
Name: svn:executable
   + *

Added: trunk/ghost/configure.ac
===================================================================
--- trunk/ghost/configure.ac	2005-07-17 23:20:05 UTC (rev 9577)
+++ trunk/ghost/configure.ac	2005-07-17 23:35:23 UTC (rev 9578)
@@ -0,0 +1,132 @@
+dnl Process this file with autoconf to produce a configure script. -*-m4-*-
+
+AC_INIT(libghost/ghost.c)
+
+AM_CONFIG_HEADER([config.h])
+
+GHOST_MAJOR_VERSION=0
+GHOST_MINOR_VERSION=0
+GHOST_MICRO_VERSION=0
+GHOST_EXTRA_VERSION=
+GHOST_VERSION=$GHOST_MAJOR_VERSION.$GHOST_MINOR_VERSION.$GHOST_MICRO_VERSION$GHOST_EXTRA_VERSION
+
+GHOST_LT_CURRENT=0
+GHOST_LT_REVISION=0
+GHOST_LT_AGE=0
+
+AC_SUBST(GHOST_LT_CURRENT)
+AC_SUBST(GHOST_LT_REVISION)
+AC_SUBST(GHOST_LT_AGE)
+
+# For automake.
+VERSION=$GHOST_VERSION
+PACKAGE=ghost
+
+AC_SUBST(GHOST_VERSION)
+
+AM_INIT_AUTOMAKE($PACKAGE, $VERSION, no-define)
+AM_MAINTAINER_MODE
+
+AC_CANONICAL_HOST
+AM_PROG_LIBTOOL
+
+AC_C_BIGENDIAN
+AC_C_CONST
+AC_C_INLINE
+AC_C_RESTRICT
+
+
+AC_MSG_CHECKING(for C99 variable-size arrays)
+AC_TRY_COMPILE( , [
+int foo=10;
+int array[foo];
+],
+[has_var_arrays=yes;AC_DEFINE([VAR_ARRAYS], [], [Use C99 variable-size arrays])
+],
+has_var_arrays=no
+)
+AC_MSG_RESULT($has_var_arrays)
+
+AC_MSG_CHECKING(for alloca)
+AC_TRY_COMPILE( [#include <alloca.h>], [
+int foo=10;
+int *array = alloca(foo);
+],
+[
+has_alloca=yes;
+if test x$has_var_arrays = "xno" ; then
+AC_DEFINE([USE_ALLOCA], [], [Make use of alloca])
+fi
+],
+has_alloca=no
+)
+AC_MSG_RESULT($has_alloca)
+
+
+AC_CHECK_HEADERS(sys/soundcard.h sys/audioio.h)
+
+XIPH_PATH_OGG([src="src"], [src=""])
+AC_SUBST(src)
+
+AC_CHECK_LIB(m, sin)
+
+# Check for getopt_long; if not found, use included source.
+AC_CHECK_FUNCS([getopt_long],,
+[# FreeBSD has a gnugetopt library.
+  AC_CHECK_LIB([gnugetopt],[getopt_long],
+[AC_DEFINE([HAVE_GETOPT_LONG])],
+[# Use the GNU replacement.
+AC_LIBOBJ(getopt)
+AC_LIBOBJ(getopt1)])])
+
+AC_CHECK_LIB(winmm, main)
+
+AC_DEFINE_UNQUOTED(GHOST_VERSION, "${GHOST_VERSION}", [Complete version string])
+AC_DEFINE_UNQUOTED(GHOST_MAJOR_VERSION, ${GHOST_MAJOR_VERSION}, [Version major])
+AC_DEFINE_UNQUOTED(GHOST_MINOR_VERSION, ${GHOST_MINOR_VERSION}, [Version minor])
+AC_DEFINE_UNQUOTED(GHOST_MICRO_VERSION, ${GHOST_MICRO_VERSION}, [Version micro])
+AC_DEFINE_UNQUOTED(GHOST_EXTRA_VERSION, "${GHOST_EXTRA_VERSION}", [Version extra])
+
+AC_CHECK_SIZEOF(short)
+AC_CHECK_SIZEOF(int)
+AC_CHECK_SIZEOF(long)
+AC_CHECK_SIZEOF(long long)
+
+if test x$has_char16 = "xyes" ; then
+        case 1 in
+                $ac_cv_sizeof_short) SIZE16="short";;
+                $ac_cv_sizeof_int) SIZE16="int";;
+        esac
+else
+        case 2 in
+                $ac_cv_sizeof_short) SIZE16="short";;
+                $ac_cv_sizeof_int) SIZE16="int";;
+        esac
+fi
+
+if test x$has_char16 = "xyes" ; then
+        case 2 in
+                $ac_cv_sizeof_int) SIZE32="int";;
+                $ac_cv_sizeof_long) SIZE32="long";;
+                $ac_cv_sizeof_short) SIZE32="short";;
+        esac
+else
+        case 4 in
+                $ac_cv_sizeof_int) SIZE32="int";;
+                $ac_cv_sizeof_long) SIZE32="long";;
+                $ac_cv_sizeof_short) SIZE32="short";;
+        esac
+fi
+
+AC_SUBST(SIZE16)
+AC_SUBST(SIZE32)
+
+AC_OUTPUT([Makefile libghost/Makefile])
+
+if test "x$src" = "x"; then 
+echo "**IMPORTANT**"
+echo "You don't seem to have the development package for libogg (libogg-devel) installed. Only the library will be built (no encoder/decoder executable)"
+echo "You can download libogg from http://www.vorbis.com/download.psp"
+fi
+
+echo "Type \"make; make install\" to compile and install";

Added: trunk/ghost/m-files/ESPRIT.m
===================================================================
--- trunk/ghost/m-files/ESPRIT.m	2005-07-17 23:20:05 UTC (rev 9577)
+++ trunk/ghost/m-files/ESPRIT.m	2005-07-17 23:35:23 UTC (rev 9578)
@@ -0,0 +1,19 @@
+function R = ESPRIT(a, N, M);
+M = 2*M;
+%Compute cross-correlation for signal (well, it's almost an auto-correlation)
+for j=1:N
+   for k=1:N
+      A(j,k)=sum(a(j:end-N+j).*a(k:end-N+k));
+   end
+end
+%Eigendecomposition
+[V,D]=eig(A);
+%Signal subspace
+Eu = V(2:end,N-M+1:end);
+Ed = V(1:end-1,N-M+1:end);
+
+PHI = inv(Eu'*Eu)*Eu'*Ed;
+
+%Get the frequencies
+[V2,D2]=eig(PHI);
+R=D2;

Added: trunk/ghost/m-files/MUSIC.m
===================================================================
--- trunk/ghost/m-files/MUSIC.m	2005-07-17 23:20:05 UTC (rev 9577)
+++ trunk/ghost/m-files/MUSIC.m	2005-07-17 23:35:23 UTC (rev 9578)
@@ -0,0 +1,17 @@
+function [R,d] = MUSIC(a, N, M);
+M = 2*M;
+for j=1:N
+   for k=1:N
+      A(j,k)=sum(a(j:end-N+j).*a(k:end-N+k));
+   end
+end
+[V,D]=eig(A);
+G=V(:,1:N-M)*V(:,1:N-M)';
+r=zeros(2*N-1,1);
+for j=1:N
+   for k=1:N
+      r(j-k+N) = r(j-k+N)+G(j,k);
+   end
+end
+R = roots(r);
+d = diag(D);

Added: trunk/ghost/m-files/analyse.m
===================================================================
--- trunk/ghost/m-files/analyse.m	2005-07-17 23:20:05 UTC (rev 9577)
+++ trunk/ghost/m-files/analyse.m	2005-07-17 23:35:23 UTC (rev 9578)
@@ -0,0 +1,12 @@
+A=B;w=ww;phi=p;
+[A,w,phi,a,b,syn1] = track_sin3b(t(1:256)',A,w,phi);
+%[A,w,phi,a,b,syn2] = track_sin3(t(257:512)',A,w,phi);
+%[A,w,phi,a,b,syn3] = track_sin3(t(513:768)',A,w,phi);
+%[A,w,phi,a,b,syn4] = track_sin3(t(769:1024)',A,w,phi);
+%syn=[syn1,syn2,syn3,syn4];
+
+syn=syn1;
+for k=1:10
+   [A,w,phi,a,b,synn] = track_sin3b(t(1+k*256:256*k+256)',A,w,phi);
+   syn=[syn,synn];
+end

Added: trunk/ghost/m-files/track_sin.m
===================================================================
--- trunk/ghost/m-files/track_sin.m	2005-07-17 23:20:05 UTC (rev 9577)
+++ trunk/ghost/m-files/track_sin.m	2005-07-17 23:35:23 UTC (rev 9578)
@@ -0,0 +1,33 @@
+function [A,w,phi,a,b,syn] = track_sin (x,A,w,phi,noise);
+
+N=length(x);
+n=0:N-1;
+xp = A*cos(w.*n+phi);
+r = x-xp;
+plot (r-noise);
+G(1,:) = xp.*n;
+G(2,:) = n.*n.*sin(w.*n+phi);
+G(3,:) = cos(w.*n+phi);
+%G(4,:) = sin(w.*n+phi);
+
+%na = sqrt(G(1,:)*G(1,:)');
+%nb = sqrt(G(2,:)*G(2,:)');
+%G(1,:) = G(1,:)/sqrt(G(1,:)*G(1,:)');
+%G(2,:) = G(2,:)/sqrt(G(2,:)*G(2,:)');
+
+p = G'\r';
+a=p(1);
+b=p(2);
+AA=p(3);
+%a = a + AA/(1.5*N);
+b=max(-2e-6,min(2e-6,b));
+a=max(-3e-3*A,min(3e-3*A,a));
+syn = (A+a*n).*cos(w.*n-b*n.^2+phi);
+A=A*(1+a*(N-1));
+phi = mod(phi+N*w-b*N.^2,2*pi);
+w=w-2*b*N;
+%syn = xp + a*G(1,:) + b*G(2,:);
+%syn = xp + (G'*(G'\r'))';
+
+
+

Added: trunk/ghost/m-files/track_sin2.m
===================================================================
--- trunk/ghost/m-files/track_sin2.m	2005-07-17 23:20:05 UTC (rev 9577)
+++ trunk/ghost/m-files/track_sin2.m	2005-07-17 23:35:23 UTC (rev 9578)
@@ -0,0 +1,31 @@
+function [A,w,phi,a,b,syn] = track_sin2 (x,A,w,phi);
+
+N=length(x);
+n=0:N-1;
+xp = cos(w.*n+phi);
+xd = sin(w.*n+phi);
+r = x-A*xp;
+G(1,:) = xp;
+G(2,:) = xd;
+
+%na = (G(1,:)*G(1,:)');
+%nb = (G(2,:)*G(2,:)');
+
+p = G'\r';
+%p= G*r';
+%p(1)=p(1)/na;
+%p(2)=p(2)/nb;
+
+a=1.5*p(1)/N;
+b = (p(2)/(1+p(1)))*3/(2*N*N);
+a = max(-1e-3*A,min(1e-3*A,a));
+b = max(-1e-5,min(1e-5,b));
+
+syn = (A+a*n).*cos(w.*n-b*n.^2+phi);
+A=A+a*N;
+phi = mod(phi+N*w-b*N.^2,2*pi);
+w=w-2*b*N;
+
+
+
+

Added: trunk/ghost/m-files/track_sin3.m
===================================================================
--- trunk/ghost/m-files/track_sin3.m	2005-07-17 23:20:05 UTC (rev 9577)
+++ trunk/ghost/m-files/track_sin3.m	2005-07-17 23:35:23 UTC (rev 9578)
@@ -0,0 +1,61 @@
+function [A,w,phi,a,b,syn] = track_sin3 (x,A,w,phi);
+
+
+N=length(x);
+M=length(w);
+n=0:N-1;
+r=x;
+for k=1:M
+   G(k,:)   = cos(w(k)*n+phi(k));
+   G(k+M,:) = sin(w(k)*n+phi(k));
+   r = r - A(k)*G(k,:);
+end
+
+%xp = cos(w.*n+phi);
+%xd = sin(w.*n+phi);
+%r = x-A*xp;
+%G(1,:) = xp;
+%G(2,:) = xd;
+
+%na = (G(1,:)*G(1,:)');
+%nb = (G(2,:)*G(2,:)');
+
+p = G'\r';
+%p= G*r';
+%p(1)=p(1)/na;
+%p(2)=p(2)/nb;
+p1 = p(1:M)';
+p2 = p(M+1:end)';
+
+%p1=max(-.3*A,min(p1,.3*A));
+a=1.5*p1/N;
+%b = (p2./(.1+A+p1))*4/(2*N*N);
+b = atan2(p2, A+p1)*4/(2*N*N);
+%a = max(-1e-4*A,min(1e-4*A,a));
+b = max(-1e-6,min(1e-6,b));
+
+%a=a*0;
+%b=b*0;
+%[atan2(p2,A+p1);A+p1]
+
+%phi = phi - atan2(p2,A+p1);
+delta_phi = -atan2(p2,A+p1);
+
+A = sqrt((A+p1).^2 + p2.^2);
+%a = 1.5*(sqrt((A+p1).^2 + p2.^2)-A)/N;
+b=b*0;
+a=a*0;
+
+syn=0;
+for k=1:M
+   syn = syn + (A(k)+a(k)*n).*cos(w(k)*n-b(k)*n.^2+phi(k) + delta_phi(k));%*min(8*n/256,1));
+end
+
+%syn = (G'*p+G(1:M,:)'*A')';
+%syn = (G'*p)';
+
+A=A+a*N;
+phi = mod(phi+N*w-b*N.^2+delta_phi(k),2*pi);
+w = w + .3*delta_phi(k)/N;
+%w=w-.2*b*N;
+

Added: trunk/ghost/m-files/track_sin3b.m
===================================================================
--- trunk/ghost/m-files/track_sin3b.m	2005-07-17 23:20:05 UTC (rev 9577)
+++ trunk/ghost/m-files/track_sin3b.m	2005-07-17 23:35:23 UTC (rev 9578)
@@ -0,0 +1,64 @@
+function [A,w,phi,a,b,syn] = track_sin3b (x,A,w,phi);
+
+
+N=length(x);
+M=length(w);
+n=0:N-1;
+r=x;
+for k=1:M
+   G(k,:)   = cos(w(k)*n+phi(k));
+   G(k+M,:) = sin(w(k)*n+phi(k));
+   r = r - A(k)*G(k,:);
+end
+
+%xp = cos(w.*n+phi);
+%xd = sin(w.*n+phi);
+%r = x-A*xp;
+%G(1,:) = xp;
+%G(2,:) = xd;
+
+%na = (G(1,:)*G(1,:)');
+%nb = (G(2,:)*G(2,:)');
+
+p = G'\r';
+%p= G*r';
+%p(1)=p(1)/na;
+%p(2)=p(2)/nb;
+p1 = p(1:M)';
+p2 = p(M+1:end)';
+
+%p1=max(-.3*A,min(p1,.3*A));
+a=1.5*p1/N;
+%b = (p2./(.1+A+p1))*4/(2*N*N);
+b = atan2(p2, A+p1)*4/(2*N*N);
+%a = max(-1e-4*A,min(1e-4*A,a));
+b = max(-1e-6,min(1e-6,b));
+
+%a=a*0;
+%b=b*0;
+%[atan2(p2,A+p1);A+p1]
+
+%phi = phi - atan2(p2,A+p1);
+delta_phi = -atan2(p2,A+p1);
+
+A = sqrt((A+p1).^2 + p2.^2);
+%a = 1.5*(sqrt((A+p1).^2 + p2.^2)-A)/N;
+b=b*0;
+a=a*0;
+
+syn=0;
+for k=1:M
+   syn = syn + (A(k)+a(k)*n).*cos(w(k)*n-b(k)*n.^2+phi(k) + delta_phi(k));
+end
+
+%syn = (G'*p+G(1:M,:)'*A')';
+%syn = (G'*p)';
+
+A=A+a*N;
+phi = mod(phi+N*w-b*N.^2+delta_phi(k),2*pi);
+%w = w + delta_phi(k)/N;
+%w=w-.2*b*N;
+
+
+
+



More information about the commits mailing list