Index: /trunk/CASCADE-MAKE.sh
===================================================================
--- /trunk/CASCADE-MAKE.sh	(revision 16659)
+++ /trunk/CASCADE-MAKE.sh	(revision 16659)
@@ -0,0 +1,18 @@
+#!/bin/bash
+
+source bin/script/test-setup.bash
+source lib/cascade-lib.bash
+
+
+for d in packages ; do
+  echo "Running $d/CASCADE-MAKE.sh $*"
+
+  (cd $d ; ./CASCADE-MAKE.sh $*)
+
+  if [ $? != 0 ] ; then
+    echo "Error encountered running $d/CASCADE-COMPILE.sh"
+    exit 1
+  fi
+done
+
+
Index: /trunk/bin/script/test-setup.bash
===================================================================
--- /trunk/bin/script/test-setup.bash	(revision 16659)
+++ /trunk/bin/script/test-setup.bash	(revision 16659)
@@ -0,0 +1,8 @@
+
+
+if [ "x$GEXTAUDIO" = "x" ] ; then
+  echo "Audio extension environment variable GEXTAUDIO not set."
+  echo "Have you sourced the extension's setup file, e.g. setup.bash?"
+  exit -1
+fi
+
Index: /trunk/lib/cascade-lib.bash
===================================================================
--- /trunk/lib/cascade-lib.bash	(revision 16659)
+++ /trunk/lib/cascade-lib.bash	(revision 16659)
@@ -0,0 +1,181 @@
+
+run_untar()
+{
+  local package=$1
+  local version=$2
+  local ext=$3
+
+  tar_args="";
+
+  if [ $ext = ".tar.gz" ] ; then
+    tar_args="xvzf"
+  elif [ $ext = ".tgzz" ] ; then
+    tar_args="xvjf"
+  elif [ $ext = ".tar.bz2" ] ; then
+    tar_args="xvjf"
+  elif [ $ext = ".tar.bz" ] ; then
+    tar_args="xvjf"
+  elif [ $ext = ".tar" ] ; then
+    tar_args="xvf"
+  else 
+    echo "Warning: Unrecognized extension: $ext"
+    echo "Assuming tarred, gzipped file"
+    tar_args="xvjf"
+  fi
+
+
+  echo tar $tar_args $package$version$ext 
+  tar $tar_args $package$version$ext
+
+  if [ $? != 0 ] ; then
+    echo "      Error encountered running *untar* stage of $progname"
+    exit 1
+  fi
+}
+
+opt_run_tarclean()
+{
+  local type=$1
+  local package=$2
+  local version=$3
+
+  if [ $type = "1" ] ; then
+
+    local dir=$package$version
+    if [ -d $dir ] ; then
+      echo /bin/rm -rf $dir
+      /bin/rm -rf $dir
+
+      if [ $? != 0 ] ; then
+        echo "      Error encountered running *tarclean* stage of $progname"
+        exit 1
+      fi
+    else 
+      echo "Unable to find directory $dir"
+    fi
+  fi
+}
+
+opt_run_untar()
+{
+  local force_untar=$1
+  local auto_untar=$2
+  local package=$3
+  local version=$4
+
+  local ext="";
+
+  if [ ! -z "$5" ] ; then
+    ext=$5
+  else 
+    ext=".tar.gz"
+  fi
+
+  if [ $force_untar = "1" ] ; then
+    run_untar $package $version $ext
+  elif [ $auto_config = "1" ] ; then
+    if [ -d $package$version ] ; then
+      echo "Found untarred version of $package$version$ext => no need to untar"
+    else
+      run_untar $package $version $ext
+    fi
+  fi
+}
+
+
+opt_run_configure()
+{
+  local force_config=$1
+  local auto_config=$2
+  local package=$3
+  local version=$4
+  local prefix=$5
+  local opt_args="";
+
+  if [ ! -z "$6" ] ; then
+    opt_args=$6
+  fi
+
+  if [ $force_config = "1" ] ; then
+    ( echo "[pushd $package$version]"
+      cd $package$version ; \
+      echo ./configure --prefix="$prefix" $opt_args ; \
+      ./configure --prefix="$prefix" $opt_args )
+      echo "[popd]"
+    if [ $? != 0 ] ; then
+        echo "      Error encountered running *configure* stage of $progname"
+        exit 1
+    fi
+  else
+    if [ $auto_config = "1" ] ; then
+      echo "Found top-level for ${progname%.*} => no need to run ./configure"
+    fi
+  fi
+}
+
+
+opt_run_make()
+{
+  local type=$1
+  local package=$2
+  local version=$3
+  local opt_target=""
+
+  if [ ! -z "$4" ] ; then
+    opt_target=$4
+  fi
+
+  if [ $type = "1" ] ; then
+    ( cd $package$version ; \
+      make $opt_target)
+
+    if [ $? != 0 ] ; then
+        echo "      Error encountered running *make $target* stage of $progname"
+        exit 1
+    fi
+  fi
+}
+
+
+
+force_untar=0
+auto_untar=0
+
+force_config=0
+auto_config=0
+
+compile=0
+install=0
+clean=0
+distclean=0
+tarclean=0
+
+if [ $# -gt 0 ] ; then
+  for cmd in $* ; do
+    echo $cmd
+    if   [ $cmd = "untar" ] ;     then force_untar=1
+    elif [ $cmd = "configure" ] ; then force_config=1
+    elif [ $cmd = "compile" ]   ; then compile=1
+    elif [ $cmd = "install" ]   ; then install=1  
+    elif [ $cmd = "clean" ]     ; then clean=1  
+    elif [ $cmd = "distclean" ] ; then distclean=1
+    elif [ $cmd = "tarclean" ] ;  then tarclean=1
+    fi
+  done
+else
+  # defaults
+  auto_untar=1
+  auto_config=1
+  compile=1
+  install=1
+  clean=0
+  distclean=0
+  tarclean=0
+fi
+
+if [ $auto_config = "1" ] ; then
+  if [ ! -e $package$version/Makefile ] ; then
+    force_config=1
+  fi
+fi
+
Index: /trunk/packages/CASCADE-MAKE.sh
===================================================================
--- /trunk/packages/CASCADE-MAKE.sh	(revision 16659)
+++ /trunk/packages/CASCADE-MAKE.sh	(revision 16659)
@@ -0,0 +1,13 @@
+#!/bin/bash
+
+
+for d in LAME LIBMAD SOX ALSA MARSYAS ; do
+  echo "    Running CASCADE-MAKE/$d.sh $*"
+
+  ./CASCADE-MAKE/$d.sh $*
+
+  if [ $? != 0 ] ; then
+    echo "  Error encountered running CASCADE-COMPILE/$d.sh"
+    exit 1
+  fi
+done
Index: /trunk/packages/CASCADE-MAKE/ALSA.sh
===================================================================
--- /trunk/packages/CASCADE-MAKE/ALSA.sh	(revision 16659)
+++ /trunk/packages/CASCADE-MAKE/ALSA.sh	(revision 16659)
@@ -0,0 +1,23 @@
+#!/bin/bash
+
+package=alsa-lib
+version=-1.0.17
+
+progname=$0
+
+source ../bin/script/test-setup.bash
+source ../lib/cascade-lib.bash
+
+prefix=$GEXTAUDIO_INSTALLED
+
+opt_run_untar $force_untar $auto_untar $package $version ".tar.bz2"
+opt_run_configure $force_config $auto_config $package $version "$prefix"
+
+opt_run_make $compile   $package $version
+opt_run_make $install   $package $version "install"
+opt_run_make $clean     $package $version "clean"
+opt_run_make $distclean $package $version "distclean"
+
+opt_run_tarclean $tarclean $package $version
+
+
Index: /trunk/packages/CASCADE-MAKE/LAME.sh
===================================================================
--- /trunk/packages/CASCADE-MAKE/LAME.sh	(revision 16659)
+++ /trunk/packages/CASCADE-MAKE/LAME.sh	(revision 16659)
@@ -0,0 +1,22 @@
+#!/bin/bash
+
+package=lame
+version=-3.97
+
+progname=$0
+
+source ../bin/script/test-setup.bash
+source ../lib/cascade-lib.bash
+
+prefix=$GEXTAUDIO_INSTALLED
+
+opt_run_untar $force_untar $auto_untar $package $version
+opt_run_configure $force_config $auto_config $package $version "$prefix"
+
+opt_run_make $compile   $package $version
+opt_run_make $install   $package $version "install"
+opt_run_make $clean     $package $version "clean"
+opt_run_make $distclean $package $version "distclean"
+
+opt_run_tarclean $tarclean $package $version
+
Index: /trunk/packages/CASCADE-MAKE/LIBMAD.sh
===================================================================
--- /trunk/packages/CASCADE-MAKE/LIBMAD.sh	(revision 16659)
+++ /trunk/packages/CASCADE-MAKE/LIBMAD.sh	(revision 16659)
@@ -0,0 +1,24 @@
+#!/bin/bash
+
+package=libmad
+version=-0.15.1b
+
+progname=$0
+
+source ../bin/script/test-setup.bash
+source ../lib/cascade-lib.bash
+
+prefix=$GEXTAUDIO_INSTALLED
+
+opt_run_untar $force_untar $auto_untar $package $version
+opt_run_configure $force_config $auto_config $package $version "$prefix"
+
+opt_run_make $compile   $package $version
+opt_run_make $install   $package $version "install"
+opt_run_make $clean     $package $version "clean"
+opt_run_make $distclean $package $version "distclean"
+
+opt_run_tarclean $tarclean $package $version
+
+
+
Index: /trunk/packages/CASCADE-MAKE/MARSYAS.sh
===================================================================
--- /trunk/packages/CASCADE-MAKE/MARSYAS.sh	(revision 16659)
+++ /trunk/packages/CASCADE-MAKE/MARSYAS.sh	(revision 16659)
@@ -0,0 +1,35 @@
+#!/bin/bash
+
+package=marsyas
+version=-0.2.16
+
+progname=$0
+
+source ../bin/script/test-setup.bash
+source ../lib/cascade-lib.bash
+
+prefix=$GEXTAUDIO_INSTALLED
+
+
+opt_run_untar $force_untar $auto_untar $package $version
+
+export CFLAGS="-I$prefix/include"
+
+opt_run_configure $force_config $auto_config $package $version "$prefix" \
+       "--enable-debug \
+        --with-lame --with-mad \
+        CFLAGS=-I$prefix/include \
+        CXXFLAGS=-I$prefix/include \
+        CPPFLAGS=-I$prefix/include \
+        LDFLAGS=-L$prefix/lib"
+
+opt_run_make $compile   $package $version
+opt_run_make $install   $package $version "install"
+opt_run_make $clean     $package $version "clean"
+opt_run_make $distclean $package $version "distclean"
+
+opt_run_tarclean $tarclean $package $version
+
+
+
+
Index: /trunk/packages/CASCADE-MAKE/SOX.sh
===================================================================
--- /trunk/packages/CASCADE-MAKE/SOX.sh	(revision 16659)
+++ /trunk/packages/CASCADE-MAKE/SOX.sh	(revision 16659)
@@ -0,0 +1,25 @@
+#!/bin/bash
+
+package=sox
+version=-14.0.1
+
+progname=$0
+
+source ../bin/script/test-setup.bash
+source ../lib/cascade-lib.bash
+
+prefix=$GEXTAUDIO_INSTALLED
+
+opt_run_untar $force_untar $auto_untar $package $version
+
+opt_run_configure $force_config $auto_config $package $version "$prefix" \
+        "--with-lame --with-mad \
+        CFLAGS=-I$prefix/include \
+        LDFLAGS=-L$prefix/lib"
+
+opt_run_make $compile   $package $version
+opt_run_make $install   $package $version "install"
+opt_run_make $clean     $package $version "clean"
+opt_run_make $distclean $package $version "distclean"
+
+opt_run_tarclean $tarclean $package $version
Index: /trunk/perllib/plugins/AudioConverter.pm
===================================================================
--- /trunk/perllib/plugins/AudioConverter.pm	(revision 16659)
+++ /trunk/perllib/plugins/AudioConverter.pm	(revision 16659)
@@ -0,0 +1,275 @@
+###########################################################################
+#
+# AudioConverter - helper plugin that does audio conversion using sox
+#
+# A component of the Greenstone digital library software
+# from the New Zealand Digital Library Project at the 
+# University of Waikato, New Zealand.
+#
+# Copyright (C) 2008 New Zealand Digital Library Project
+#
+# This program 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 program 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, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+###########################################################################
+package AudioConverter;
+
+use MediaConverter;
+
+
+use strict;
+no strict 'refs'; # allow filehandles to be variables and viceversa
+
+use gsprintf 'gsprintf';
+
+BEGIN {
+    @AudioConverter::ISA = ('MediaConverter');
+}
+
+my $arguments = [
+      { 'name' => "cache_generated_audio",
+	'desc' => "{AudioConverter.cache_generated_audio}",
+	'type' => "flag",
+	'reqd' => "no",
+	'hiddengli' => "yes" # option to delete cache from GLI not yet implemented
+	}
+		 ];
+
+my $options = { 'name' => "AudioConverter",
+		'desc' => "{AudioConverter.desc}",
+		'abstract' => "yes",
+		'inherits' => "yes",
+		'args' => $arguments };
+
+sub new {
+    my ($class) = shift (@_);
+    my ($pluginlist,$inputargs,$hashArgOptLists) = @_;
+    push(@$pluginlist, $class);
+
+    push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});
+    push(@{$hashArgOptLists->{"OptList"}},$options);
+
+    my $self = new MediaConverter($pluginlist, $inputargs, $hashArgOptLists, 1);
+
+
+    return bless $self, $class;
+
+}
+
+# needs to be called after BasePlugin init, so that outhandle is set up.
+sub init {
+    my $self = shift(@_);
+
+    $self->{'tmp_file_paths'} = ();
+
+    # Check that sox is installed and available on the path 
+    my $audio_conversion_available = 1;
+    my $no_audio_conversion_reason = "";
+
+    # Conversion does not work very well on Windows 95/98...
+    # (because of distinction needed between stdout and stderr???)
+
+    if ($ENV{'GSDLOS'} eq "windows" && !Win32::IsWinNT()) {
+	$audio_conversion_available = 0;
+	$no_audio_conversion_reason = "win95notsupported";
+    } else {
+	my $result = `sox -h 2>&1`;
+	if ($? == -1 || $? == 256) {  # Linux and Windows return different values for "program not found"
+	    $audio_conversion_available = 0;
+	    $no_audio_conversion_reason = "soxnotinstalled";
+	}
+    }
+    $self->{'audio_conversion_available'} = $audio_conversion_available;
+    $self->{'no_audio_conversion_reason'} = $no_audio_conversion_reason;
+
+    if ($self->{'audio_conversion_available'} == 0) {
+	my $outhandle = $self->{'outhandle'};
+	&gsprintf($outhandle, "AudioConverter: {AudioConverter.noconversionavailable} ({AudioConverter.".$self->{'no_audio_conversion_reason'}."})\n");
+    }
+}
+	
+
+# convert audio to new type if converttotype is set
+# discover audio metadata
+sub generate_audio {
+    my $self = shift(@_);
+
+    my ($filename_full_path, $filename_no_path, $doc_obj, $section) = @_;
+
+    # check sox status
+    return 0 if $self->{'audio_conversion_available'} == 0;
+    # check the filenames
+    return 0 if ($filename_no_path eq "" || !-f $filename_full_path);
+
+    if ($self->{'cache_generated_audio'}) {
+	$self->init_cache_for_file($filename_full_path);
+    }
+
+    my $verbosity = $self->{'verbosity'};
+    my $outhandle = $self->{'outhandle'};
+
+    
+    my $filehead = $filename_no_path;
+    $filehead =~ s/\.([^\.]*)$//; # filename with no extension
+    my $assocfilemeta = "[assocfilepath]";
+    if ($section ne $doc_obj->get_top_section()) {
+	$assocfilemeta = "[parent(Top):assocfilepath]";
+    }
+
+    # Convert the audio to a new type (if required).
+    my $converttotype = $self->{'converttotype'};
+    my $type = "unknown";
+
+    if ($converttotype ne "" && $filename_full_path !~ m/$converttotype$/) {
+	
+	my ($result,$filename_full_path) 
+	    = $self->convert($filename_full_path, $converttotype, "", "CONVERTTYPE");
+
+	$type = $converttotype;
+	$filename_no_path = "$filehead.$type";
+    }
+
+    # add Audio metadata 
+    $doc_obj->add_metadata($section, "Audio", $filename_no_path);
+
+    # Source and SourceUTF8 - should this be converted filename or original?
+    # here we overwrite the originals with converted ones
+    $self->set_Source_metadata($doc_obj, $filename_no_path);
+
+    # use identify to get info about the (possibly converted) audio
+
+    my ($audio_type, $audio_srate, $audio_quant, $audio_chans, $audio_dur, $audio_samples) 
+	= &identify($filename_full_path, $outhandle, $verbosity);
+
+    if ($audio_type ne " ") {
+	$type = $audio_type;
+    }
+
+    my $file_size = -s $filename_full_path;
+    #overwrite the ones added in BasePlugin
+    $doc_obj->set_metadata_element ($section, "FileFormat", $type);
+    $doc_obj->set_metadata_element ($section, "FileSize",   $file_size);
+
+    $doc_obj->add_metadata ($section, "AudioType",         $audio_type);
+    $doc_obj->add_metadata ($section, "AudioSampleRate",   $audio_srate);
+    $doc_obj->add_metadata ($section, "AudioQuantization", $audio_quant);
+    $doc_obj->add_metadata ($section, "AudioNumChannels",  $audio_chans);
+    $doc_obj->add_metadata ($section, "AudioDuration",     $audio_dur);
+    $doc_obj->add_metadata ($section, "AudioNumSamples",   $audio_samples);
+
+    $doc_obj->add_metadata ($section, "srclink", "<a href=\"_httpprefix_/collect/[collection]/index/assoc/$assocfilemeta/[Audio]\">");
+    $doc_obj->add_metadata ($section, "/srclink", "</a>");
+    $doc_obj->add_metadata ($section, "srcicon", "<img src=\"_httpprefix_/collect/[collection]/index/assoc/$assocfilemeta/_icon${type}_\" width=\"100\">");
+
+    # Add the audio as an associated file
+    $doc_obj->associate_file($filename_full_path, $filename_no_path, "audio/$type", $section);
+
+}
+
+
+
+sub convert {
+    my $self = shift(@_);
+    my $source_file_path = shift(@_);
+    my $target_file_type = shift(@_);
+    my $convert_options  = shift(@_) || "";
+    my $convert_id       = shift(@_) || "";
+
+    my $outhandle = $self->{'outhandle'};
+    my $verbosity = $self->{'verbosity'};
+
+    my $source_file_no_path = &File::Basename::basename($source_file_path);
+
+    # Determine the full name and path of the output file
+    my $target_file_path;
+    if ($self->{'cache_generated_audio'}) {
+	my $cached_audio_dir = $self->{'cached_dir'};
+	my $audio_root = $self->{'cached_file_root'};
+	$audio_root .= "_$convert_id" if ($convert_id ne "");
+	my $audio_file = "$audio_root.$target_file_type";
+	$target_file_path = &util::filename_cat($cached_audio_dir,$audio_file);
+    }
+    else {
+	$target_file_path = &util::get_tmp_filename($target_file_type);
+	push(@{$self->{'tmp_file_paths'}}, $target_file_path);
+    }
+
+    # Generate and run the convert command
+    my $vl = int($verbosity/2);
+
+    my $convert_command = "sox -V$vl --show-progress $convert_options \"$source_file_path\" \"$target_file_path\"";
+
+    my $print_info = { 'message_prefix' => $convert_id,
+		       'message' => "Converting audio $source_file_no_path to: $convert_id $target_file_type" };
+ 
+    my ($regenerated,$result,$had_error) 
+	= $self->autorun_general_cmd($convert_command,$target_file_path,$print_info);
+
+    return ($result,$target_file_path);
+}
+
+
+# Discover the characteristics of an audio file with sox
+# Name 'indentify' relates to original operation written for images using
+# ImageMagick's 'indentify' 
+sub identify { 
+    my ($audio, $outhandle, $verbosity) = @_;
+
+    # Use the 'sox -V3' command to get the file specs
+    my $command = "sox -V3 \"$audio\" 2>&1";
+    print $outhandle "$command\n" if ($verbosity > 2);
+    my $result = '';
+    $result = `$command`;
+    print $outhandle "$result\n" if ($verbosity > 3);
+
+    # Extract useful metadata about audio files
+    ## my $type  = 'unknown';  # ... set this to something related to mime type?
+    ## allow plugin to specify mime-type info?
+
+    my $encod = 'unknown';
+    my $srate = 'unknown';
+    my $qsize = 'unknown';
+    my $chans = 'unknown';
+    my $durat = 'unknown';
+    my $sampl = 'unknown';
+
+    ($encod) = ($result =~ m/Sample Encoding\s*:\s+(.*)$/m);
+    ($srate) = ($result =~ m/Sample Rate\s*:\s+(.*)$/m);
+    ($qsize) = ($result =~ m/Sample Size\s*:\s+(\d+)$/m);
+    ($chans) = ($result =~ m/Channels\s*:\s+(.*)$/m);
+
+    my ($durat_full) = ($result =~ m/Duration\s*:\s+(.*)$/m);
+    ($durat,$sampl) = ($durat_full =~ m/^(.*?)\s+=\s+(\d+)/m);
+
+    print $outhandle "file: $audio:\t $encod, $srate, $qsize, $chans, $durat\n" 
+	if ($verbosity > 2);
+
+    # Return the specs
+    return ($encod, $srate, $qsize, $chans, $durat, $sampl);
+}
+
+### Can this be moved into MediaConverter ???
+
+sub clean_up_temporary_files {
+    my $self = shift(@_);
+
+    foreach my $tmp_file_path (@{$self->{'tmp_file_paths'}}) {
+	if (-e $tmp_file_path) {
+	    &util::rm($tmp_file_path);
+	}
+    }
+   
+}
+
+1;	
Index: /trunk/perllib/plugins/AudioPlugin.pm
===================================================================
--- /trunk/perllib/plugins/AudioPlugin.pm	(revision 16659)
+++ /trunk/perllib/plugins/AudioPlugin.pm	(revision 16659)
@@ -0,0 +1,162 @@
+###########################################################################
+#
+# AudioPlugin.pm -- Plugin for MP3 files (MPEG audio layer 3).
+#
+# A component of the Greenstone digital library software from the New
+# Zealand Digital Library Project at the University of Waikato, New
+# Zealand.
+#
+# Copyright (C) 2001 New Zealand Digital Library Project
+#
+# This program 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 program 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, write to the Free Software
+# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+#
+###########################################################################
+
+
+package AudioPlugin;
+
+use BasePlugin;
+use AudioConverter;
+
+use strict;
+no strict 'refs'; # allow filehandles to be variables and viceversa
+###no strict 'subs';
+
+sub BEGIN {
+    @AudioPlugin::ISA = ('BasePlugin', 'AudioConverter');
+}
+
+my $arguments =
+    [ { 'name' => "process_exp",
+	'desc' => "{BasePlugin.process_exp}",
+	'type' => "regexp",
+	'deft' => &get_default_process_exp(),
+	'reqd' => "no" } ];
+
+my $options = { 'name'     => "AudioPlugin",
+		'desc'     => "{AudioPlugin.desc}",
+		'abstract' => "no",
+		'inherits' => "yes",
+		'args'     => $arguments };
+
+sub new {
+    my ($class) = shift (@_);
+    my ($pluginlist,$inputargs,$hashArgOptLists) = @_;
+    push(@$pluginlist, $class);
+
+    push(@{$hashArgOptLists->{"ArgList"}},@{$arguments});
+    push(@{$hashArgOptLists->{"OptList"}},$options);
+
+    new AudioConverter($pluginlist, $inputargs, $hashArgOptLists);
+    my $self = new BasePlugin($pluginlist, $inputargs, $hashArgOptLists);
+
+    return bless $self, $class;
+}
+
+sub init {
+    my $self = shift (@_);
+    my ($verbosity, $outhandle, $failhandle) = @_;
+
+    $self->SUPER::init(@_);
+    $self->AudioConverter::init();
+}
+
+sub get_default_process_exp 
+{
+    my $self = shift (@_);
+    if (!defined $self->{'stored_process_re'}) {
+
+	my $static_fallback_re = q^(?i)\.(aif?|au|mp3|ogg|snd|wav)$^;
+	
+	if ($self->{'audio_conversion_available'}) {
+	    # Haven't run sox before to see what formats it supports
+	    # => do so now
+	    
+	    my $sox_output = `sox -h`;
+	    my ($output_list) = ($sox_output =~ m/SUPPORTED FILE FORMATS:\s*(.*)$/m);
+	    if (defined $output_list && ($output_list ne "")) {
+		$output_list =~ s/\s+/,/g;
+
+		$self->{'stored_process_re'} = $output_list;
+	    }
+	    else {
+		$self->{'stored_process_re'} = $static_fallback_re;
+	    }
+	}
+	else {
+	    # Audio format conversion isn't supported, but (as for images)
+	    # source format might very well be OK for inclusion in web
+	    # page produced for document 
+	    
+	    $self->{'stored_process_re'} = $static_fallback_re;
+	}
+    }
+
+    print STDERR "*** returning: $self->{'stored_process_re'}\n";
+
+    return $self->{'stored_process_re'};
+	
+}
+
+
+
+# do plugin specific processing of doc_obj
+sub process {
+    my $self = shift (@_);
+    # options??
+    my ($pluginfo, $base_dir, $file, $metadata, $doc_obj, $gli) = @_;
+
+
+    my $outhandle = $self->{'outhandle'};
+    my ($filename_full_path, $filename_no_path) = &util::get_full_filenames($base_dir, $file);
+
+    my $top_section = $doc_obj->get_top_section();
+
+    if ($self->{'audio_conversion_available'} == 1) {
+	$self->generate_audio($filename_full_path, $filename_no_path, $doc_obj, $top_section); # should we check the return value?
+    } else {
+	# do some basic stuff
+	# associate the audio, fileformat, mimetype, srclink, srcicon
+	# do this if sox not installed. but also if generate hasn't worked??
+    }
+    #we have no text - adds dummy text and NoText metadata
+    $self->add_dummy_text($doc_obj, $top_section);
+
+
+    # *****
+    # Does the code currently associate the original file with document?
+    # How about it's MIME type.  This might be a bit tricky to work out
+    # for a dynamically generated list
+
+    return 1;
+
+}
+
+
+
+
+
+1;
+
+
+
+
+
+
+
+
+
+
+
Index: /trunk/perllib/strings.property
===================================================================
--- /trunk/perllib/strings.property	(revision 16659)
+++ /trunk/perllib/strings.property	(revision 16659)
@@ -0,0 +1,14 @@
+
+AudioConverter.cache_generated_audio:Cache converted audio so it doesn't need to be repeatedly generated.
+
+AudioConverter.converttotype:Convert main audio to format 's'.
+
+AudioConverter.desc:Helper plugin for audio conversion using SOund eXchanger (SOX)
+
+AudioConverter.soxnotinstalled: SOund eXchanger (SOX) not installed
+
+AudioConverter.noconversionavailable:Audi conversion not available
+
+AudioConverter.win95notsupported: SOund eXchanger (SOX) not supported on Win95/98
+
+AudioPlugin.desc:This plugin processes audio, adding basic metadata
Index: /trunk/setup.bash
===================================================================
--- /trunk/setup.bash	(revision 16659)
+++ /trunk/setup.bash	(revision 16659)
@@ -0,0 +1,27 @@
+
+
+if [ "x$GEXTAUDIO" = "x" ] ; then
+  export GEXTAUDIO=`pwd`
+  export GEXTAUDIO_INSTALLED=$GEXTAUDIO/installed
+
+  export PATH=$GEXTAUDIO_INSTALLED/bin:$PATH
+
+  if [ "x$LD_LIBRARY_PATH" = "x" ] ; then
+    export LD_LIBRARY_PATH=$GEXTAUDIO_INSTALLED/lib
+  else
+    export LD_LIBRARY_PATH=$GEXTAUDIO_INSTALLED/lib:$LD_LIBRARY_PATH
+  fi
+
+  if [ "x$GSDLEXTS" = "x" ] ; then
+    export GSDLEXTS=audio
+  else 
+    export GSDLEXTS=$GSDLEXTS:audio
+  fi
+
+
+  echo "+Your environment is now setup for the Audio Extension to Greenstone"
+else
+  echo "+Your environment is already setup for the Audio Extension to Greenstone"
+fi
+
+
