Index: /gs2-extensions/music-ir-src/trunk/CASCADE-MAKE.bat
===================================================================
--- /gs2-extensions/music-ir-src/trunk/CASCADE-MAKE.bat	(revision 22580)
+++ /gs2-extensions/music-ir-src/trunk/CASCADE-MAKE.bat	(revision 22580)
@@ -0,0 +1,66 @@
+@echo off
+
+pushd "%CD%"
+CD /D "%~dp0"
+
+call cascade-make/lib/cascade-lib.bat
+
+:: Guaranteed that GSDLOS has now been set
+
+
+:: Make sure can find javac
+
+:: Remove any quotes from around JAVA_HOME
+if defined JAVA_HOME set JAVA_HOME=%JAVA_HOME:"=%
+
+
+if "%JAVA_HOME%" == "" (
+  echo Testing for Java compiler ...
+
+  javac -version 2>nul
+  if ERRORLEVEL 1 (
+    echo ... failed to find 'javac'
+    cmd /c exit -4
+    goto:EOF
+  ) else (
+    echo ... found it
+  )
+) else (
+
+  :: Good chance it's in the path already => don't want to see any output
+  javac -version 2>nul
+  if ERRORLEVEL 1 (
+    echo Setting path to include "%JAVA_HOME%\bin"
+    set "PATH=%JAVA_HOME%\bin;%PATH%"
+  )
+)
+
+
+for /D %%d IN ("%GSDLOS%" "lib\java") do (
+  if not exist "%GEXT_MUSICIR_INSTALLED%\%%d" (
+    echo Creating %GEXT_MUSICIR_INSTALLED%\%%d
+    mkdir "%GEXT_MUSICIR_INSTALLED%\%%d"
+  )
+)
+
+set dirlist=build-srcpack
+
+for /D %%d IN (%dirlist%) do (
+  echo Running %%d\CASCADE-MAKE.bat %*
+
+  (cd %%d && call CASCADE-MAKE.bat %* && cd ..)
+  
+  if ERRORLEVEL 1 (
+    echo Error encountered running %%d\CASCADE-MAKE.bat
+    cmd /c exit 1
+    goto:EOF
+  )
+)
+
+
+if  %install% == 1 (
+  type README.txt
+)
+
+
+
Index: /gs2-extensions/music-ir-src/trunk/CASCADE-MAKE.sh
===================================================================
--- /gs2-extensions/music-ir-src/trunk/CASCADE-MAKE.sh	(revision 22580)
+++ /gs2-extensions/music-ir-src/trunk/CASCADE-MAKE.sh	(revision 22580)
@@ -0,0 +1,41 @@
+#!/bin/bash
+
+source cascade-make/lib/cascade-lib.bash GEXT_MUSICIR . $*
+
+if [ -z "$JAVA_HOME" ] ; then
+  echo "Testing for Java compiler ..."
+  javac -version
+  if [ $? != "0" ] ; then
+    echo "Failed to find 'javac'"
+    exit -1
+  fi
+fi
+
+if [ ! -e $GEXT_MUSICIR_INSTALLED ] ; then
+  echo "Creating $GEXT_MUSICIR_INSTALLED for installed files"
+  mkdir $GEXT_MUSICIR_INSTALLED
+fi
+
+if [ ! -e "$GEXT_MUSICIR_LIBJAVA" ] ; then
+  echo "Creating $GEXT_MUSICIR_LIBJAVA for Java lib and jar files"
+  mkdir -p "$GEXT_MUSICIR_LIBJAVA" 
+fi
+
+
+dirlist="build-srcpack"
+
+for d in $dirlist ; do
+  echo "Running $d/CASCADE-MAKE.sh $*"
+
+  (cd $d ; ./CASCADE-MAKE.sh $*)
+
+  if [ $? != 0 ] ; then
+    echo "Error encountered running $d/CASCADE-MAKE.sh"
+    exit 1
+  fi
+done
+
+
+if [ $install = "1" ] ; then
+  cat README.txt
+fi
Index: /gs2-extensions/music-ir-src/trunk/README.txt
===================================================================
--- /gs2-extensions/music-ir-src/trunk/README.txt	(revision 22580)
+++ /gs2-extensions/music-ir-src/trunk/README.txt	(revision 22580)
@@ -0,0 +1,3 @@
+
+Music-IR extension to Greenstone, based on jAudio from McGill University
+
Index: /gs2-extensions/music-ir-src/trunk/bin/script/jaudio
===================================================================
--- /gs2-extensions/music-ir-src/trunk/bin/script/jaudio	(revision 22580)
+++ /gs2-extensions/music-ir-src/trunk/bin/script/jaudio	(revision 22580)
@@ -0,0 +1,11 @@
+#!/bin/bash
+
+if [ -z "$GEXT_MUSICIR" ] ; then
+  echo "Environment variable GEXT_MUSICIR is not set."
+  echo "Have you sourced setup.bash?"
+  exit -1
+fi
+
+( cd "$GEXT_MUSICIR/lib/java" && \
+  java -jar jaudio.jar  $* )
+
Index: /gs2-extensions/music-ir-src/trunk/bin/script/jaudio.bat
===================================================================
--- /gs2-extensions/music-ir-src/trunk/bin/script/jaudio.bat	(revision 22580)
+++ /gs2-extensions/music-ir-src/trunk/bin/script/jaudio.bat	(revision 22580)
@@ -0,0 +1,16 @@
+@echo off 
+
+if "%GEXT_MUSICIR%" == "" goto notSetup
+
+pushd  %GEXT_MUSICIR%\lib\java && java -jar jaudio.jar %* && popd
+
+goto done
+
+
+:notSetup
+
+  echo Environment variable GEXT_MUSICIR is not set.
+  echo Have you sourced setup.bash?
+  ERRORLEVEL=-1
+
+:done
Index: /gs2-extensions/music-ir-src/trunk/build-srcpack/CASCADE-MAKE.bat
===================================================================
--- /gs2-extensions/music-ir-src/trunk/build-srcpack/CASCADE-MAKE.bat	(revision 22580)
+++ /gs2-extensions/music-ir-src/trunk/build-srcpack/CASCADE-MAKE.bat	(revision 22580)
@@ -0,0 +1,14 @@
+@echo off
+
+for /D %%d IN (packages) do (
+  echo   Running %%d\CASCADE-MAKE.bat %*
+
+  (cd %%d && call CASCADE-MAKE.bat %* && cd ..)
+
+  if ERRORLEVEL 1 (
+    echo   Error encountered running %%d\CASCADE-MAKE.bat
+    cmd /c exit 1
+    goto:EOF
+  )
+)
+
Index: /gs2-extensions/music-ir-src/trunk/build-srcpack/CASCADE-MAKE.sh
===================================================================
--- /gs2-extensions/music-ir-src/trunk/build-srcpack/CASCADE-MAKE.sh	(revision 22580)
+++ /gs2-extensions/music-ir-src/trunk/build-srcpack/CASCADE-MAKE.sh	(revision 22580)
@@ -0,0 +1,14 @@
+#!/bin/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-MAKE.sh"
+    exit 1
+  fi
+done
+
Index: /gs2-extensions/music-ir-src/trunk/build-srcpack/packages/CASCADE-MAKE.bat
===================================================================
--- /gs2-extensions/music-ir-src/trunk/build-srcpack/packages/CASCADE-MAKE.bat	(revision 22580)
+++ /gs2-extensions/music-ir-src/trunk/build-srcpack/packages/CASCADE-MAKE.bat	(revision 22580)
@@ -0,0 +1,15 @@
+@echo off
+
+for /D %%d IN (JAUDIO) do (
+  echo     Running CASCADE-MAKE\%%d.bat %*
+
+  call CASCADE-MAKE\%%d.bat %*
+
+  if ERRORLEVEL 1 (
+    echo     Error encountered running CASCADE-MAKE\%%d.bat
+    cmd /c exit 1
+    goto:EOF
+  )
+)
+
+
Index: /gs2-extensions/music-ir-src/trunk/build-srcpack/packages/CASCADE-MAKE.sh
===================================================================
--- /gs2-extensions/music-ir-src/trunk/build-srcpack/packages/CASCADE-MAKE.sh	(revision 22580)
+++ /gs2-extensions/music-ir-src/trunk/build-srcpack/packages/CASCADE-MAKE.sh	(revision 22580)
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+
+for d in JAUDIO ; do
+  echo "    Running CASCADE-MAKE/$d.sh $*"
+
+  ./CASCADE-MAKE/$d.sh $*
+
+  if [ $? != 0 ] ; then
+    echo "  Error encountered running CASCADE-MAKE/$d.sh"
+    exit 1
+  fi
+done
+
+
Index: /gs2-extensions/music-ir-src/trunk/build-srcpack/packages/CASCADE-MAKE/JAUDIO.bat
===================================================================
--- /gs2-extensions/music-ir-src/trunk/build-srcpack/packages/CASCADE-MAKE/JAUDIO.bat	(revision 22580)
+++ /gs2-extensions/music-ir-src/trunk/build-srcpack/packages/CASCADE-MAKE/JAUDIO.bat	(revision 22580)
@@ -0,0 +1,36 @@
+@echo off
+
+set package=jAudio0.4
+set version=-cvs-06052010
+
+set progname=%0
+
+call ..\..\cascade-make\lib\cascade-lib.bat
+
+
+set prefix=%GEXTVIDEO_INSTALLED%\%GSDLOS%
+
+REM opt_run_untar $force_untar $auto_untar $package $version
+
+if %compile% == 1 (
+  cd %package%%version% 
+  set "classpath=.;jAudioFeatureExtractor;tritonus_remaining-0.3.6.jar;tritonus_share-0.3.6.jar;xerces.jar;jhall.jar;mp3plugin.jar" 
+
+  set auxfiles=jAudioFeatureExtractor\AudioFeatures\*.java
+
+  echo       Compiling Java source files
+  javac -classpath %classpath% %auxfiles%
+  javac -classpath %classpath% jAudioFE.java
+
+  cd ..
+  
+)
+
+
+
+REM opt_run_make $compile   $package "$version"
+REM opt_run_make $install   $package "$version" "install"
+REM opt_run_make $clean     $package "$version" "clean"
+
+REM opt_run_tarclean $tarclean $package $version
+
Index: /gs2-extensions/music-ir-src/trunk/build-srcpack/packages/CASCADE-MAKE/JAUDIO.sh
===================================================================
--- /gs2-extensions/music-ir-src/trunk/build-srcpack/packages/CASCADE-MAKE/JAUDIO.sh	(revision 22580)
+++ /gs2-extensions/music-ir-src/trunk/build-srcpack/packages/CASCADE-MAKE/JAUDIO.sh	(revision 22580)
@@ -0,0 +1,91 @@
+#!/bin/bash
+
+package=jAudio0.4
+version=-cvs-06052010
+
+progname=$0
+
+source ../../cascade-make/lib/cascade-lib.bash GEXT_MUSICIR ../.. $*
+
+prefix=$GEXT_MUSICIR_INSTALLED
+
+
+opt_run_untar $force_untar $auto_untar $package $version
+if [ -d "$package" ] ; then
+  mv "$package" "$package$version"
+fi
+
+if [ $compile = "1" ] ; then
+  cd $package$version 
+  classpath=".:jAudioFeatureExtractor:tritonus_remaining-0.3.6.jar:tritonus_share-0.3.6.jar:xerces.jar:jhall.jar:mp3plugin.jar" 
+
+  auxfiles="jAudioFeatureExtractor/AudioFeatures/*.java"
+
+  which cygpath 2>&1 > /dev/null
+  if [ $? = "0" ] ; then
+    classpath=`cygpath -pw "$classpath"`
+    auxfiles=`cygpath -w "$auxfiles"`
+  fi
+
+  echo "      Compiling Java source files"
+  javac -classpath "$classpath" $auxfiles
+  javac -classpath "$classpath" jAudioFE.java
+
+  cd ..
+  
+fi
+
+if [ $install = "1" ] ; then
+  cd $package$version 
+
+  /bin/rm -f jaudio.jar
+
+  jarcp=`ls *.jar | tr '\n' ' '`
+
+  echo "Manifest-Version: 1.0" > Manifest.txt && \
+  echo "Main-Class: jAudioFE" >> Manifest.txt && \
+  echo "Class-Path: $jarcp plugin" >> Manifest.txt
+
+  class_files=`find . -name "*.class" -print`
+
+  which cygpath 2>&1 >/dev/null
+  if [ $? = "0" ] ; then
+    class_files=`cygpath -w $class_files`
+  fi
+
+  echo "      Bundling Java classes (and related files) into jaudio.jar"
+
+  jar cfm jaudio.jar Manifest.txt $class_files \
+     jAudioFeatureExtractor org \
+     features \
+     help JavaHelpSearch \
+     Map.jhm Sample.hs SampleIndex.xml SampleTOC.xml \
+  && \
+  /bin/cp *.jar $GEXT_MUSICIR/lib/java/. \
+
+  echo "Configuring features.xml"
+
+  plugin_home="$GEXT_MUSICIR/lib/java"
+  which cygpath 2>&1 >/dev/null
+  if [ $? = "0" ] ; then
+    plugin_home=`cygpath -w "$plugin_home"`
+    plugin_home=`echo "$plugin_home" | sed 's@\\\\@\\\\\\\\@g'`
+  fi
+
+
+  cat ../etc/features.xml.in \
+    | sed -e "s@\*\*pluginhome\*\*@$plugin_home@g" \
+    > $GEXT_MUSICIR/lib/java/features.xml
+
+  if [ ! -d "$GEXT_MUSICIR/lib/java/plugin" ] ; then
+    echo "Creating $GEXT_MUSICIR/lib/java/plugin"
+    mkdir "$GEXT_MUSICIR/lib/java/plugin"
+  fi
+
+  cd ..
+fi
+
+#opt_run_make $clean     $package $version "clean"
+#opt_run_make $distclean $package $version "distclean"
+
+opt_run_tarclean $tarclean $package $version
Index: /gs2-extensions/music-ir-src/trunk/build-srcpack/packages/etc/features.xml.in
===================================================================
--- /gs2-extensions/music-ir-src/trunk/build-srcpack/packages/etc/features.xml.in	(revision 22580)
+++ /gs2-extensions/music-ir-src/trunk/build-srcpack/packages/etc/features.xml.in	(revision 22580)
@@ -0,0 +1,116 @@
+<?xml version="1.0"?>
+<!DOCTYPE featureList [
+	<!ELEMENT featureList (pluginFolder?,feature+,aggregator*)>
+	<!ELEMENT pluginFolder (#PCDATA)>
+	<!ELEMENT feature (class , on?)>
+	<!ELEMENT class (#PCDATA) >
+	<!ELEMENT on EMPTY>
+	<!ELEMENT aggregator (#PCDATA)>
+]>
+
+<featureList>
+        <pluginFolder>file://**pluginhome**</pluginFolder>
+	<feature>
+		<class>jAudioFeatureExtractor.AudioFeatures.MagnitudeSpectrum</class>
+	</feature>
+	<feature>
+		<class>jAudioFeatureExtractor.AudioFeatures.PowerSpectrum</class>
+	</feature>
+	<feature>
+		<class>jAudioFeatureExtractor.AudioFeatures.FFTBinFrequencies</class>
+	</feature>
+	<feature>
+		<class>jAudioFeatureExtractor.AudioFeatures.SpectralCentroid</class>
+		<on/>
+	</feature>
+	<feature>
+		<class>jAudioFeatureExtractor.AudioFeatures.SpectralRolloffPoint</class>
+		<on/>
+	</feature>
+	<feature>
+		<class>jAudioFeatureExtractor.AudioFeatures.SpectralFlux</class>
+		<on/>
+	</feature>
+	<feature>
+		<class>jAudioFeatureExtractor.AudioFeatures.Compactness</class>
+		<on/>
+	</feature>
+	<feature>
+		<class>jAudioFeatureExtractor.AudioFeatures.SpectralVariability</class>
+		<on/>
+	</feature>
+	<feature>
+		<class>jAudioFeatureExtractor.AudioFeatures.RMS</class>
+		<on/>
+	</feature>
+	<feature>
+		<class>jAudioFeatureExtractor.AudioFeatures.FractionOfLowEnergyWindows</class>
+		<on/>
+	</feature>
+	<feature>
+		<class>jAudioFeatureExtractor.AudioFeatures.ZeroCrossings</class>
+		<on/>
+	</feature>
+	<feature>
+		<class>jAudioFeatureExtractor.AudioFeatures.BeatHistogram</class>
+	</feature>
+	<feature>
+		<class>jAudioFeatureExtractor.AudioFeatures.BeatHistogramLabels</class>
+	</feature>
+	<feature>
+		<class>jAudioFeatureExtractor.AudioFeatures.StrongestBeat</class>
+		<on/>
+	</feature>
+	<feature>
+		<class>jAudioFeatureExtractor.AudioFeatures.BeatSum</class>
+		<on/>
+	</feature>
+	<feature>
+		<class>jAudioFeatureExtractor.AudioFeatures.StrengthOfStrongestBeat</class>
+		<on/>
+	</feature>
+	<feature>
+		<class>jAudioFeatureExtractor.AudioFeatures.StrongestFrequencyViaZeroCrossings</class>
+	</feature>
+	<feature>
+		<class>jAudioFeatureExtractor.AudioFeatures.StrongestFrequencyViaSpectralCentroid</class>
+	</feature>
+	<feature>
+		<class>jAudioFeatureExtractor.AudioFeatures.StrongestFrequencyViaFFTMax</class>
+	</feature>
+	<feature>
+		<class>jAudioFeatureExtractor.AudioFeatures.MFCC</class>
+		<on/>
+	</feature>
+	<feature>
+		<class>jAudioFeatureExtractor.AudioFeatures.LPC</class>
+		<on/>
+	</feature>
+	<feature>
+		<class>jAudioFeatureExtractor.AudioFeatures.Moments</class>
+		<on/>
+	</feature>
+	<feature>
+		<class>jAudioFeatureExtractor.AudioFeatures.PeakFinder</class>
+	</feature>
+	<feature>
+		<class>jAudioFeatureExtractor.AudioFeatures.HarmonicSpectralCentroid</class>
+	</feature>
+	<feature>
+		<class>jAudioFeatureExtractor.AudioFeatures.HarmonicSpectralFlux</class>
+	</feature>
+	<feature>
+		<class>jAudioFeatureExtractor.AudioFeatures.HarmonicSpectralSmoothness</class>
+	</feature>
+	<feature>
+		<class>jAudioFeatureExtractor.AudioFeatures.RelativeDifferenceFunction</class>
+	</feature>
+	<feature>
+	  <class>jAudioFeatureExtractor.AudioFeatures.AreaMoments</class>
+	</feature>
+	<aggregator>jAudioFeatureExtractor.Aggregators.Mean</aggregator>
+	<aggregator>jAudioFeatureExtractor.Aggregators.StandardDeviation</aggregator>
+	<aggregator>jAudioFeatureExtractor.Aggregators.AreaMoments</aggregator>
+	<aggregator>jAudioFeatureExtractor.Aggregators.MFCC</aggregator>
+	<aggregator>jAudioFeatureExtractor.Aggregators.MultipleFeatureHistogram</aggregator>
+</featureList>
Index: /gs2-extensions/music-ir-src/trunk/perllib/plugins/MusicIRPlugin.pm
===================================================================
--- /gs2-extensions/music-ir-src/trunk/perllib/plugins/MusicIRPlugin.pm	(revision 22580)
+++ /gs2-extensions/music-ir-src/trunk/perllib/plugins/MusicIRPlugin.pm	(revision 22580)
@@ -0,0 +1,176 @@
+###########################################################################
+#
+# MusicIRPlugin.pm -- for augmenting audio/midi files with Music IR 
+#                     features and tags
+# A component of the Greenstone digital library software
+# from the New Zealand Digital Library Project at the 
+# University of Waikato, New Zealand.
+#
+# Copyright (C) 1999 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 MusicIRPlugin;
+
+use BasePlugin;
+use jAudioExtractor;
+use jSongMinerExtractor;
+
+use strict;
+no strict 'refs'; # allow filehandles to be variables and viceversa
+no strict 'subs';
+
+use gsprintf 'gsprintf';
+
+sub BEGIN {
+    @MusicIRPlugin::ISA = ('BasePlugin', 'jAudioExtractor', 'jSongMinerExtractor');
+}
+
+my $arguments =
+    [ 
+      { 'name' => "compute_mir_features",
+	'desc' => "{BasePlugin.compute_mir_features}",
+	'type' => "enum",
+	'list' => [{'name' => "true",  'desc' => "{common.true}"},
+		   {'name' => "false", 'desc' => "{common.false}"}],
+	'deft' => "false",
+	'reqd' => "no" },
+      { 'name' => "retrieve_mir_metadata",
+	'desc' => "{BasePlugin.retrieve_mir_metadata}",
+	'type' => "enum",
+	'list' => [{'name' => "true",  'desc' => "{common.true}"},
+		   {'name' => "false", 'desc' => "{common.false}"}],
+	'deft' => "false",
+	'reqd' => "no" },
+      { 'name' => "process_exp",
+	'desc' => "{BasePlugin.process_exp}",
+	'type' => "regexp",
+	'deft' => &get_default_process_exp(),
+	'reqd' => "no" }
+      ];
+
+my $options = { 'name'     => "MusicIRPlugin",
+		'desc'     => "{MusicIRPlugin.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);
+
+    
+    my $jae_self = new jAudioExtractor($pluginlist, $inputargs, $hashArgOptLists,1);
+    my $jsme_self = new jSongMinerExtractor($pluginlist, $inputargs, $hashArgOptLists,1);
+    my $base_self = new BasePlugin($pluginlist, $inputargs, $hashArgOptLists);
+
+    my $self = BasePlugin::merge_inheritance($jae_self,$jsme_self,$base_self);
+
+    return bless $self, $class;
+}
+
+sub get_default_process_exp {
+    my $self = shift (@_);
+    
+    return q^(?i)(\.mp3|\.wave?|\.aif[fc]?|\.au|\.snd|\.og[ga])$^; 
+}
+
+sub begin {
+    my $self = shift (@_);
+    my ($pluginfo, $base_dir, $processor, $maxdocs) = @_;
+
+    $self->SUPER::begin(@_);
+    $self->jAudioExtractor::begin(@_);
+    $self->jSongMinerExtractor::begin(@_);
+}
+
+
+
+# do plugin specific processing of doc_obj
+sub process {
+    my $self = shift (@_);
+    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);
+
+    if ($self->{'compute_mir_features'} eq "true")
+    {
+	my $utf8_filename_no_path = $self->filepath_to_utf8($filename_no_path);
+	my $url_encoded_filename = &util::rename_file($utf8_filename_no_path, $self->{'file_rename_method'});
+	
+	my $features_filename = $self->compute_features($filename_full_path);
+	my ($features_ext) = ($features_filename =~ m/\.([^.]+)$/);
+
+	my $top_section = $doc_obj->get_top_section();
+	
+	my $mime_type = ($features_ext eq "arff") ? "text/plain" : "text/xml";
+	$doc_obj->associate_file($features_filename, "jaudio.$features_ext", 
+				 $mime_type, $top_section);
+
+    }
+
+    
+    #we have no text - adds dummy text and NoText metadata
+    $self->add_dummy_text($doc_obj, $doc_obj->get_top_section());
+
+    return 1;
+
+}
+
+sub post_process_doc_obj {
+    my $self = shift (@_);  
+    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);
+
+    if ($self->{'retrieve_mir_metadata'} eq "true") {
+	my $top_section = $doc_obj->get_top_section();
+	my $id3_titles = $doc_obj->get_metadata($top_section,"ID3.Title");
+
+	my $id3_title = shift @$id3_titles || "Unknown";
+
+	my $id3_artists = $doc_obj->get_metadata($top_section,"ID3.Artist");
+	my $id3_artist = shift @$id3_artists || "Unkown";
+
+	my ($metadata_acexml_filename,$metadata_txt_filename) 
+	    = $self->retrieve_metadata($filename_full_path,$id3_title,$id3_artist);
+	
+	if (-e $metadata_txt_filename) {
+	    $self->parse_txt_metadata($doc_obj,$metadata_txt_filename);
+	}
+
+
+    }
+
+
+    return 1;
+}
+
+
+1;
+
+
+
Index: /gs2-extensions/music-ir-src/trunk/perllib/plugins/jAudioExtractor.pm
===================================================================
--- /gs2-extensions/music-ir-src/trunk/perllib/plugins/jAudioExtractor.pm	(revision 22580)
+++ /gs2-extensions/music-ir-src/trunk/perllib/plugins/jAudioExtractor.pm	(revision 22580)
@@ -0,0 +1,257 @@
+###########################################################################
+#
+# jAudioExtractor - helper plugin that computers audio features for 
+#                        music information retrieval use, using jAudio
+#
+# A component of the Greenstone digital library software
+# from the New Zealand Digital Library Project at the 
+# University of Waikato, New Zealand.
+#
+# Copyright (C) 2010 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 jAudioExtractor;
+
+use BaseMediaConverter;
+
+use Cwd;
+
+use strict;
+no strict 'refs'; # allow filehandles to be variables and viceversa
+
+
+BEGIN {
+    @jAudioExtractor::ISA = ('BaseMediaConverter');
+}
+
+
+my $arguments = [
+    { 'name' => "window_size",
+      'desc' => "{jAudioExtractor.window_size}",
+      'type' => "int",
+      'range' => "128,",
+      'deft' => '512',
+      'reqd' => "no" },
+    { 'name' => "window_overlap",
+      'desc' => "{jAudioExtractor.window_overlap}",
+      'type' => "string",
+      'range' => "0.0",
+      'deft' => '0.0',
+      'reqd' => "no" },
+    { 'name' => "sample_rate",
+      'desc' => "{jAudioExtractor.sample_rate}",
+      'type' => "enum",
+      'list' => [{'name' => "8 kHz",      'desc' => "{jAudioExtractor.8000Hz}"},
+		 {'name' => "11.025 kHz", 'desc' => "{jAudioExtractor.11025Hz}"},
+		 {'name' => "16 kHz",     'desc' => "{jAudioExtractor.16000Hz}"},
+		 {'name' => "22.05 kHz",  'desc' => "{jAudioExtractor.22050Hz}"},
+		 {'name' => "44.1 kHz",   'desc' => "{jAudioExtractor.44100Hz}"} ],
+      'deft' => '16 kHz',
+      'reqd' => "no" },
+    { 'name' => "extracted_data",
+      'desc' => "{jAudioExtractor.extracted_data}",
+      'type' => "enum",
+      'list' => [{'name' => "Overall and Windowed", 'desc' => "{jAudioExtractor.overall_and_windowed}"},
+		 {'name' => "Windowed only", 'desc' => "{jAudioExtractor.windowed_only}"},
+		 {'name' => "Overall only", 'desc' => "{jAudioExtractor.overall_only}"}],
+      'deft' => 'Overall and Windowed',
+      'reqd' => "no" },
+    { 'name' => "output_type",
+      'desc' => "{jAudioExtractor.output_type}",
+      'type' => "enum",
+      'list' => [{'name' => "ACE XML", 'desc' => "{jAudioExtractor.ace_xml}"},
+		 {'name' => "Weka ARFF", 'desc' => "{jAudioExtractor.weka_arff}"}],
+      'deft' => 'ACE XML',
+      'reqd' => "no" }
+    ];
+
+
+
+my $options = { 'name' => "jAudioExtractor",
+		'desc' => "{jAudioExtractor.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 BaseMediaConverter($pluginlist, $inputargs, $hashArgOptLists, 1);
+
+    # Set controlling variables
+    my $gsdl_home = $ENV{'GSDLHOME'};
+    my $music_ir_home = $ENV{'GEXT_MUSICIR'};
+
+    $self->{'ace_xml_output_directory'} = &util::filename_cat($gsdl_home,"tmp"); # Set the directory to save the the ACE XML output files in
+    $self->{'jmir_directory'} = &util::filename_cat($music_ir_home,"lib","java"); # Set the directory holding the jMIR .jar files
+
+
+    return bless $self, $class;
+}
+
+
+# Create and save a temporary jAudio batch file referring to a file to extract
+# features from
+sub prepareTempJAudioBatchFile 
+{
+    # ARG Ob1: $new_batch_file_path refers to the path of the temporary batch file to create
+    # ARG Ob2: $model_batch_file_path refers to the path of the model batch file to base the temporary one on
+    # ARG Ob3: $input_music_file_path refers to the file to extract features with
+    # ARG Ob4: $feature_values_file_path refers to the path of the ACE XML Feature Values file that the jMIR component will output to
+    # ARG Ob5: $feature_values_file_path refers to the path of the ACE XML Feature Descriptions file that the jMIR component will output to
+    my ( $self, $new_batch_file_path, $model_batch_file_path, $input_music_file_path, $feature_values_file_path, $feature_descriptions_file_path ) = @_;
+
+    # Retrieve settings for jAudioPlugin and use in batch file that is generated
+    my $sample_rate = $self->{'sample_rate'}; # sample of how to get parameter from Greenstone/GLI
+
+
+    # Read the contents of the model batch file
+    my $batch_file_contents;
+    local $/=undef;
+    open (INPUT, "$model_batch_file_path") or die "Could not read the model jAudio batch file $model_batch_file_path";
+    binmode INPUT;
+    $batch_file_contents = <INPUT>;
+    close INPUT;
+
+    # Set the batch ID tag in the temporary file
+    $batch_file_contents =~ s/<batch ID="SampleJAudioBatch">/<batch ID="$input_music_file_path">/;
+
+    # Set the input file name in the file tag in the temporary file
+    $batch_file_contents =~ s/<file><\/file>/<file>$input_music_file_path<\/file>/;
+
+    # Set the feature vales save path in the temporary file
+    $batch_file_contents =~ s/<destination><\/destination>/<destination>$feature_descriptions_file_path<\/destination>/;
+
+    # Set the feature vales save path in the temporary file
+    $batch_file_contents =~ s/<destination><\/destination>/<destination>$feature_values_file_path<\/destination>/;
+
+    # Save the temporary batch file
+    open (OUTPUT, ">$new_batch_file_path") or die "Could not create the temporary jAudio batch file $new_batch_file_path";
+    print OUTPUT "$batch_file_contents";
+    close OUTPUT;
+    
+    # Done
+    return 0;
+}
+
+
+sub compute_features
+{
+    my $self = shift(@_);
+    my $source_file_path = shift(@_);
+    my $convert_options  = shift(@_) || "";
+
+    my $outhandle = $self->{'outhandle'};
+    my $verbosity = $self->{'verbosity'};
+
+    my $source_file_no_path = &File::Basename::basename($source_file_path);
+
+    $self->init_cache_for_file($source_file_path);
+
+    # Determine the full name and path of the output file
+    my $target_file_path;
+    my $feature_values_file_path;
+    my $feature_descriptions_file_path;
+
+    my $target_file_type;
+    if ($self->{'output_type'} eq "ACE XML") {
+	$target_file_type="xml";
+    }
+    else {
+	# ARFF
+	$target_file_type="arff";
+    }
+
+    if ($self->{'enable_cache'}) {
+	my $cached_dir = $self->{'cached_dir'};
+	my $file_root = $self->{'cached_file_root'};
+
+	my $target_file = "$file_root.$target_file_type";
+
+	$target_file_path = &util::filename_cat($cached_dir,$target_file);
+    }
+    else {
+	$target_file_path = &util::get_tmp_filename($target_file_type);
+    }
+
+    if ($self->{'output_type'} eq "ACE XML") {
+	$feature_values_file_path = $target_file_path;
+	$feature_values_file_path =~ s/\.xml$/_FV.xml/;
+
+	$feature_descriptions_file_path = $target_file_path;
+	$feature_descriptions_file_path =~ s/\.xml$/_FD.xml/;
+
+	# Make target_file_path be the principle file generated by jAudio when using ACE XML
+	$target_file_path = $feature_values_file_path;
+    }
+
+    my $ace_xml_output_directory = $self->{'ace_xml_output_directory'};
+    my $jmir_directory = $self->{'jmir_directory'};
+
+
+    my $store_cwd = cwd();
+
+    if (!-d $jmir_directory) {
+	print STDERR "Error: Unable able to find directory '$jmir_directory'\n";
+	print STDERR "       Cannot run jAudio\n";
+    }
+    elsif (chdir($jmir_directory)) {
+
+	# Run the feature extraction.
+
+	# Specify the name for a temporary jAudio batch file
+	my $template_batch_file_path = &util::filename_cat($jmir_directory,"SampleJAudioBatchFile.xml.in");
+	my $batch_file_path = &util::filename_cat($ace_xml_output_directory,"tempjaudiobatchfile.xml");
+	
+	# Create the batch file
+	$self->prepareTempJAudioBatchFile( $batch_file_path, $template_batch_file_path, 
+					   $source_file_path, $feature_values_file_path, $feature_descriptions_file_path );
+	
+	# Input and Output files to use are stored in the batch_file
+	my $jaudio_cmd = "java -Xmx1024M -jar jAudio.jar $convert_options -b \"$batch_file_path\"";
+		
+	# Test the execution path
+	# print("EXECUTION CMD: $jaudio_cmd\n");
+    
+	my $print_info = { 'message_prefix' => "jAudio",
+			   'message' => "Extracting audio features from $source_file_no_path" };
+	
+	my ($regenerated,$result,$had_error) 
+	    = $self->autorun_general_cmd($jaudio_cmd,$source_file_path,$target_file_path,$print_info);
+	
+	# Delete the jAudio batch file
+	unlink($batch_file_path);
+    }
+    else {
+	print STDERR "Error: failed to change directory to '$jmir_directory'\n";
+	print STDERR "       Cannot run jAudio\n";
+    }
+
+    chdir($store_cwd);
+
+    return ($target_file_path);
+}
+    
+
+
+
+1;	
Index: /gs2-extensions/music-ir-src/trunk/perllib/plugins/jSongMinerExtractor.pm
===================================================================
--- /gs2-extensions/music-ir-src/trunk/perllib/plugins/jSongMinerExtractor.pm	(revision 22580)
+++ /gs2-extensions/music-ir-src/trunk/perllib/plugins/jSongMinerExtractor.pm	(revision 22580)
@@ -0,0 +1,212 @@
+###########################################################################
+#
+# jSongMinerExtractor - helper plugin that identifies audio through
+#                       external web services based on either an audio
+#                       computed fingerprint or ID3 title and album
+#
+# A component of the Greenstone digital library software
+# from the New Zealand Digital Library Project at the 
+# University of Waikato, New Zealand.
+#
+# Copyright (C) 2010 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 jSongMinerExtractor;
+
+use BaseMediaConverter;
+
+use Cwd;
+use URI::Escape;
+
+use strict;
+no strict 'refs'; # allow filehandles to be variables and viceversa
+
+
+BEGIN {
+    @jSongMinerExtractor::ISA = ('BaseMediaConverter');
+}
+
+
+my $arguments = [
+    { 'name' => "track_identification",
+      'desc' => "{jSongMinerExtractor.track_identification}",
+      'type' => "enum",
+      'list' => [{'name' => "Fingerprint then ID3 tags", 'desc' => "{jSongMinerExtractor.fingerprint_first}"},
+		 {'name' => "ID3 tags only", 'desc' => "{jSongMinerExtractor.only_ids}"},
+		 {'name' => "Disabled",     'desc' => "{jSongMinerExtractor.off}"} ],
+      'deft' => 'Fingerprint then ID3 tags',
+      'reqd' => "no" }
+    ];
+
+my $options = { 'name' => "jSongMinerExtractor",
+		'desc' => "{jSongMinerExtractor.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 BaseMediaConverter($pluginlist, $inputargs, $hashArgOptLists, 1);
+
+    # Set controlling variables
+    my $gsdl_home = $ENV{'GSDLHOME'};
+    my $music_ir_home = $ENV{'GEXT_MUSICIR'};
+
+    $self->{'jmir_directory'} = &util::filename_cat($music_ir_home,"lib","java"); # Set the directory holding the jMIR .jar files
+
+    return bless $self, $class;
+}
+
+sub urlEncode{
+	# ARG 1: $to_encode is the string to URL encode
+	my ($to_encode) = @_;
+	return uri_escape($to_encode);
+}
+
+# URL Decode the given string
+sub urlDecode{
+	# ARG 1: $to_decode is the string to URL decode
+	my ($to_decode) = @_;
+	return uri_unescape($to_decode);
+}
+
+sub parse_txt_metadata
+{
+    my $self = shift @_;
+    my ($doc_obj,$target_txt_file_path) = @_;
+
+    if (open(MIN,"<$target_txt_file_path")) {
+
+	my ($md_name, $md_value);
+
+	while (defined($md_name=<MIN>) && defined($md_value=<MIN>)) {
+
+	    chomp $md_name;
+	    chomp $md_value;
+
+	    my $top_section=$doc_obj->get_top_section();
+
+	    $md_name =~ s/\+//g;
+	    $md_value =~ s/\+//g;
+	    
+	    $md_name = urlDecode($md_name);
+	    $md_value = urlDecode($md_value);
+
+	    # $md_name =~ s/\s+//g;
+	    $md_name =~ s/\(.*?\)$//;
+	    $md_name =~ s/Last\.FM/LastFM/g;
+	    $md_name =~ s/:/^/g;
+	    $md_name =~ s/(API)?\^/./;
+
+	    $doc_obj->add_metadata($top_section,$md_name,$md_value);
+	}
+
+	close(MIN);
+    }
+    else {
+	print STDERR "Error: Failed to open $target_txt_file_path\n";
+	print STDERR "       !$\n";
+    }
+}
+
+
+sub retrieve_metadata
+{
+    my $self = shift(@_);
+    my ($source_file_path,$id3_title,$id3_artist,$convert_options) = @_;
+
+    $convert_options = "" if (!defined $convert_options);
+
+    my $outhandle = $self->{'outhandle'};
+    my $verbosity = $self->{'verbosity'};
+
+    my $source_file_no_path = &File::Basename::basename($source_file_path);
+
+    $self->init_cache_for_file($source_file_path);
+
+    my $target_txt_file_path;
+    my $target_acexml_file_path;
+
+    if ($self->{'enable_cache'}) {
+	my $cached_dir = $self->{'cached_dir'};
+	my $file_root = $self->{'cached_file_root'};
+
+	my $target_txt_file = "${file_root}_metadata.txt";
+	my $target_acexml_file = "${file_root}.xml";
+
+	$target_txt_file_path = &util::filename_cat($cached_dir,$target_txt_file);
+	$target_acexml_file_path = &util::filename_cat($cached_dir,$target_acexml_file);
+    }
+    else {
+	$target_txt_file_path = &util::get_tmp_filename("_metadata.txt");
+	$target_acexml_file_path = &util::get_tmp_filename(".xml");
+    }
+
+    my $jmir_directory = $self->{'jmir_directory'};
+
+
+    my $store_cwd = cwd();
+
+    if (!-d $jmir_directory) {
+	print STDERR "Error: Unable able to find directory '$jmir_directory'\n";
+	print STDERR "       Cannot run jAudio\n";
+    }
+    elsif (chdir($jmir_directory)) {
+
+
+	my $jsongminer_cmd = "java -Xmx1024M -jar jSongMiner.jar $convert_options";
+	$jsongminer_cmd .= " -title \"$id3_title\"";
+	$jsongminer_cmd .= " -artist \"$id3_artist\"";
+	$jsongminer_cmd .= " -audio \"$source_file_path\"";
+	$jsongminer_cmd .= " -savefile \"$target_txt_file_path\"";
+##	$jsongminer_cmd .= " -saveacefile \"$target_acexml_file_path\"";
+	
+	if ($verbosity>2) {
+	    print $outhandle "jSongMinerExtractor: Running ...\n";
+	    print $outhandle "jSongMinerExtractor:   $jsongminer_cmd\n";
+	}
+	
+	my $print_info = { 'message_prefix' => "jSongMiner",
+			   'message' => "jSongMinerExtractor: Retrieving audio metadata for $source_file_no_path" };
+	
+	my ($regenerated,$result,$had_error) 
+	    = $self->autorun_general_cmd($jsongminer_cmd,$source_file_path,$target_txt_file_path,$print_info);
+	
+	if ($verbosity>2) {
+	    print $outhandle "jSongMinerExtractor: ...done\n";
+	}
+    }
+    else {
+	print STDERR "Error: failed to change directory to '$jmir_directory'\n";
+	print STDERR "       Cannot run jAudio\n";
+    }
+
+    chdir($store_cwd);
+
+    return ($target_acexml_file_path,$target_txt_file_path);
+}
+    
+
+
+
+1;	
Index: /gs2-extensions/music-ir-src/trunk/perllib/plugins/jSongMinerMetadata.pm
===================================================================
--- /gs2-extensions/music-ir-src/trunk/perllib/plugins/jSongMinerMetadata.pm	(revision 22580)
+++ /gs2-extensions/music-ir-src/trunk/perllib/plugins/jSongMinerMetadata.pm	(revision 22580)
@@ -0,0 +1,257 @@
+###########################################################################
+#
+# jAudioExtractor - helper plugin that does office document conversion 
+#                       using jodconverter combined with MIR
+#
+# A component of the Greenstone digital library software
+# from the New Zealand Digital Library Project at the 
+# University of Waikato, New Zealand.
+#
+# Copyright (C) 2010 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 jAudioExtractor;
+
+use BaseMediaConverter;
+
+use Cwd;
+
+use strict;
+no strict 'refs'; # allow filehandles to be variables and viceversa
+
+
+BEGIN {
+    @jAudioExtractor::ISA = ('BaseMediaConverter');
+}
+
+
+my $arguments = [
+    { 'name' => "window_size",
+      'desc' => "{jAudioExtractor.window_size}",
+      'type' => "int",
+      'range' => "128,",
+      'deft' => '512',
+      'reqd' => "no" },
+    { 'name' => "window_overlap",
+      'desc' => "{jAudioExtractor.window_overlap}",
+      'type' => "string",
+      'range' => "0.0",
+      'deft' => '0.0',
+      'reqd' => "no" },
+    { 'name' => "sample_rate",
+      'desc' => "{jAudioExtractor.sample_rate}",
+      'type' => "enum",
+      'list' => [{'name' => "8 kHz",      'desc' => "{jAudioExtractor.8000Hz}"},
+		 {'name' => "11.025 kHz", 'desc' => "{jAudioExtractor.11025Hz}"},
+		 {'name' => "16 kHz",     'desc' => "{jAudioExtractor.16000Hz}"},
+		 {'name' => "22.05 kHz",  'desc' => "{jAudioExtractor.22050Hz}"},
+		 {'name' => "44.1 kHz",   'desc' => "{jAudioExtractor.44100Hz}"} ],
+      'deft' => '16 kHz',
+      'reqd' => "no" },
+    { 'name' => "extracted_data",
+      'desc' => "{jAudioExtractor.extracted_data}",
+      'type' => "enum",
+      'list' => [{'name' => "Overall and Windowed", 'desc' => "{jAudioExtractor.overall_and_windowed}"},
+		 {'name' => "Windowed only", 'desc' => "{jAudioExtractor.windowed_only}"},
+		 {'name' => "Overall only", 'desc' => "{jAudioExtractor.overall_only}"}],
+      'deft' => 'Overall and Windowed',
+      'reqd' => "no" },
+    { 'name' => "output_type",
+      'desc' => "{jAudioExtractor.output_type}",
+      'type' => "enum",
+      'list' => [{'name' => "ACE XML", 'desc' => "{jAudioExtractor.ace_xml}"},
+		 {'name' => "Weka ARFF", 'desc' => "{jAudioExtractor.weka_arff}"}],
+      'deft' => 'ACE XML',
+      'reqd' => "no" }
+    ];
+
+
+
+my $options = { 'name' => "jAudioExtractor",
+		'desc' => "{jAudioExtractor.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 BaseMediaConverter($pluginlist, $inputargs, $hashArgOptLists, 1);
+
+    # Set controlling variables
+    my $gsdl_home = $ENV{'GSDLHOME'};
+    my $music_ir_home = $ENV{'GEXT_MUSICIR'};
+
+    $self->{'ace_xml_output_directory'} = &util::filename_cat($gsdl_home,"tmp"); # Set the directory to save the the ACE XML output files in
+    $self->{'jmir_directory'} = &util::filename_cat($music_ir_home,"lib","java"); # Set the directory holding the jMIR .jar files
+
+
+    return bless $self, $class;
+}
+
+
+# Create and save a temporary jAudio batch file referring to a file to extract
+# features from
+sub prepareTempJAudioBatchFile 
+{
+    # ARG Ob1: $new_batch_file_path refers to the path of the temporary batch file to create
+    # ARG Ob2: $model_batch_file_path refers to the path of the model batch file to base the temporary one on
+    # ARG Ob3: $input_music_file_path refers to the file to extract features with
+    # ARG Ob4: $feature_values_file_path refers to the path of the ACE XML Feature Values file that the jMIR component will output to
+    # ARG Ob5: $feature_values_file_path refers to the path of the ACE XML Feature Descriptions file that the jMIR component will output to
+    my ( $self, $new_batch_file_path, $model_batch_file_path, $input_music_file_path, $feature_values_file_path, $feature_descriptions_file_path ) = @_;
+
+    # Retrieve settings for jAudioPlugin and use in batch file that is generated
+    my $sample_rate = $self->{'sample_rate'}; # sample of how to get parameter from Greenstone/GLI
+
+
+    # Read the contents of the model batch file
+    my $batch_file_contents;
+    local $/=undef;
+    open (INPUT, "$model_batch_file_path") or die "Could not read the model jAudio batch file $model_batch_file_path";
+    binmode INPUT;
+    $batch_file_contents = <INPUT>;
+    close INPUT;
+
+    # Set the batch ID tag in the temporary file
+    $batch_file_contents =~ s/<batch ID="SampleJAudioBatch">/<batch ID="$input_music_file_path">/;
+
+    # Set the input file name in the file tag in the temporary file
+    $batch_file_contents =~ s/<file><\/file>/<file>$input_music_file_path<\/file>/;
+
+    # Set the feature vales save path in the temporary file
+    $batch_file_contents =~ s/<destination><\/destination>/<destination>$feature_descriptions_file_path<\/destination>/;
+
+    # Set the feature vales save path in the temporary file
+    $batch_file_contents =~ s/<destination><\/destination>/<destination>$feature_values_file_path<\/destination>/;
+
+    # Save the temporary batch file
+    open (OUTPUT, ">$new_batch_file_path") or die "Could not create the temporary jAudio batch file $new_batch_file_path";
+    print OUTPUT "$batch_file_contents";
+    close OUTPUT;
+    
+    # Done
+    return 0;
+}
+
+
+sub compute_features
+{
+    my $self = shift(@_);
+    my $source_file_path = shift(@_);
+    my $convert_options  = shift(@_) || "";
+
+    my $outhandle = $self->{'outhandle'};
+    my $verbosity = $self->{'verbosity'};
+
+    my $source_file_no_path = &File::Basename::basename($source_file_path);
+
+    $self->init_cache_for_file($source_file_path);
+
+    # Determine the full name and path of the output file
+    my $target_file_path;
+    my $feature_values_file_path;
+    my $feature_descriptions_file_path;
+
+    my $target_file_type;
+    if ($self->{'output_type'} eq "ACE XML") {
+	$target_file_type="xml";
+    }
+    else {
+	# ARFF
+	$target_file_type="arff";
+    }
+
+    if ($self->{'enable_cache'}) {
+	my $cached_dir = $self->{'cached_dir'};
+	my $file_root = $self->{'cached_file_root'};
+
+	my $target_file = "$file_root.$target_file_type";
+
+	$target_file_path = &util::filename_cat($cached_dir,$target_file);
+    }
+    else {
+	$target_file_path = &util::get_tmp_filename($target_file_type);
+    }
+
+    if ($self->{'output_type'} eq "ACE XML") {
+	$feature_values_file_path = $target_file_path;
+	$feature_values_file_path =~ s/\.xml$/_FV.xml/;
+
+	$feature_descriptions_file_path = $target_file_path;
+	$feature_descriptions_file_path =~ s/\.xml$/_FD.xml/;
+
+	# Make target_file_path be the principle file generated by jAudio when using ACE XML
+	$target_file_path = $feature_values_file_path;
+    }
+
+    my $ace_xml_output_directory = $self->{'ace_xml_output_directory'};
+    my $jmir_directory = $self->{'jmir_directory'};
+
+
+    my $store_cwd = cwd();
+
+    if (!-d $jmir_directory) {
+	print STDERR "Error: Unable able to find directory '$jmir_directory'\n";
+	print STDERR "       Cannot run jAudio\n";
+    }
+    elsif (chdir($jmir_directory)) {
+
+	# Run the feature extraction.
+
+	# Specify the name for a temporary jAudio batch file
+	my $template_batch_file_path = &util::filename_cat($jmir_directory,"SampleJAudioBatchFile.xml.in");
+	my $batch_file_path = &util::filename_cat($ace_xml_output_directory,"tempjaudiobatchfile.xml");
+	
+	# Create the batch file
+	$self->prepareTempJAudioBatchFile( $batch_file_path, $template_batch_file_path, 
+					   $source_file_path, $feature_values_file_path, $feature_descriptions_file_path );
+	
+	# Input and Output files to use are stored in the batch_file
+	my $jaudio_cmd = "java -Xmx1024M -jar jAudio.jar $convert_options -b \"$batch_file_path\"";
+		
+	# Test the execution path
+	# print("EXECUTION CMD: $jaudio_cmd\n");
+    
+	my $print_info = { 'message_prefix' => "jAudio",
+			   'message' => "Extracting audio features from $source_file_no_path" };
+	
+	my ($regenerated,$result,$had_error) 
+	    = $self->autorun_general_cmd($jaudio_cmd,$source_file_path,$target_file_path,$print_info);
+	
+	# Delete the jAudio batch file
+	unlink($batch_file_path);
+    }
+    else {
+	print STDERR "Error: failed to change directory to '$jmir_directory'\n";
+	print STDERR "       Cannot run jAudio\n";
+    }
+
+    chdir($store_cwd);
+
+    return ($target_file_path);
+}
+    
+
+
+
+1;	
Index: /gs2-extensions/music-ir-src/trunk/setup.bash
===================================================================
--- /gs2-extensions/music-ir-src/trunk/setup.bash	(revision 22580)
+++ /gs2-extensions/music-ir-src/trunk/setup.bash	(revision 22580)
@@ -0,0 +1,40 @@
+
+extdesc="the Digital Music Information Retrieval Extension"
+
+full_setup=`pwd`/${BASH_SOURCE}
+fulldir=${full_setup%/*}
+fulldir=${fulldir%/.}
+
+source cascade-make/lib/cascade-lib.bash
+
+if [ "x$GEXT_MUSICIR" = "x" ] ; then
+  export GEXT_MUSICIR=$fulldir
+  export GEXT_MUSICIR_INSTALLED=$GEXT_MUSICIR/$GSDLOS
+  export GEXT_MUSICIR_LIBJAVA=$GEXT_MUSICIR/lib/java
+
+
+  export PATH=$GEXT_MUSICIR_INSTALLED/bin:$GEXT_MUSICIR/bin/script:$PATH
+
+  if [ "x$LD_LIBRARY_PATH" = "x" ] ; then
+    export LD_LIBRARY_PATH=$GEXT_MUSICIR_INSTALLED/lib
+  else
+    export LD_LIBRARY_PATH=$GEXT_MUSICIR_INSTALLED/lib:$LD_LIBRARY_PATH
+  fi
+  if [ "x$DYLD_LIBRARY_PATH" = "x" ] ; then
+    export DYLD_LIBRARY_PATH=$GEXT_MUSICIR_INSTALLED/lib
+  else
+    export DYLD_LIBRARY_PATH=$GEXT_MUSICIR_INSTALLED/lib:$DYLD_LIBRARY_PATH
+  fi
+
+  extdir=${GEXT_MUSICIR##*/}
+
+  if [ "x$GSDLEXTS" = "x" ] ; then
+    export GSDLEXTS=$extdir
+  else 
+    export GSDLEXTS=$GSDLEXTS:$extdir
+  fi
+
+  echo "+Your environment is now setup for $extdesc"
+else
+  echo "+Your environment is already setup for $extdesc"
+fi
Index: /gs2-extensions/music-ir-src/trunk/setup.bat
===================================================================
--- /gs2-extensions/music-ir-src/trunk/setup.bat	(revision 22580)
+++ /gs2-extensions/music-ir-src/trunk/setup.bat	(revision 22580)
@@ -0,0 +1,57 @@
+@echo off
+pushd "%CD%"
+CD /D "%~dp0"
+
+set extdesc=the Music IR Extension
+
+if "%OS%" == "Windows_NT" goto WinNT
+if "%OS%" == "" goto Win95
+if "%GSDLLANG%" == "en" echo Setup failed - your PATH has not been set
+if "%GSDLLANG%" == "es" echo No se pudo realizar la configuraci¢n - no se ha establecido la RUTA.
+if "%GSDLLANG%" == "fr" echo Echc de l'installation - votre variable PATH n'a pas t ajuste
+if "%GSDLLANG%" == "ru" echo áâ ­®¢ª  ­¥ ã€ « áì -  ­¥ ¡ë« ãáâ ­®¢«¥­
+goto End
+
+:WinNT
+set GEXT_MUSICIR=%CD%
+set GEXT_MUSICIR_INSTALLED=%GEXT_MUSICIR%\windows
+
+set PATH=%GEXT_MUSICIR_INSTALLED%\bin;%GEXT_MUSICIR%\bin\script;%PATH%
+
+set GS_CP_SET=yes
+goto Success
+
+:Win95
+if "%1" == "SetEnv" goto Win95Env
+REM We'll invoke a second copy of the command processor to make
+REM sure there's enough environment space
+COMMAND /E:2048 /K %0 SetEnv
+goto End
+
+:Win95Env
+set GEXT_MUSICIR=%CD%
+set PATH=%GEXT_MUSICIR_INSTALLED%\bin;%GEXT_MUSICIR%\bin\script;%PATH%
+set GS_CP_SET=yes
+goto Success
+
+:Success
+
+set fulldir=%~dp0
+
+:: strip off everything up to (and including) ext dir
+set extdir=%fulldir:*ext\=%
+
+:: remove trailing slash
+set extdir=%extdir:\=%
+
+if "x%GSDLEXTS%" == "x" (
+  set GSDLEXTS=%extdir%
+) else (
+  set GSDLEXTS=%GSDLEXTS%:%extdir%
+)
+
+echo +Your environment is now setup for %extdesc%
+
+:End
+
+popd
