[DEV] 2.4 tools

This commit is contained in:
2015-09-19 10:52:26 +02:00
commit b6ae08bd22
945 changed files with 186828 additions and 0 deletions

61
java/Makefile Normal file
View File

@@ -0,0 +1,61 @@
###########################################################################
## ##
## Centre for Speech Technology Research ##
## University of Edinburgh, UK ##
## Copyright (c) 1996 ##
## All Rights Reserved. ##
## ##
## Permission is hereby granted, free of charge, to use and distribute ##
## this software and its documentation without restriction, including ##
## without limitation the rights to use, copy, modify, merge, publish, ##
## distribute, sublicense, and/or sell copies of this work, and to ##
## permit persons to whom this work is furnished to do so, subject to ##
## the following conditions: ##
## 1. The code must retain the above copyright notice, this list of ##
## conditions and the following disclaimer. ##
## 2. Any modifications must be clearly marked as such. ##
## 3. Original authors' names are not deleted. ##
## 4. The authors' names are not used to endorse or promote products ##
## derived from this software without specific prior written ##
## permission. ##
## ##
## THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK ##
## DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ##
## ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT ##
## SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE ##
## FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ##
## WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN ##
## AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ##
## ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF ##
## THIS SOFTWARE. ##
## ##
###########################################################################
TOP=..
DIRNAME=java
VERSION_DIRS = basic_version
ALL_DIRS= common basic_version cpp_version media_version
DEPEND_DIRS = common
build_basic_version_from = common basic_version
build_cpp_version_from = common cpp_version
build_media_version_from = common media_version
FILES = Makefile java.mak java_cpp.mak java_media.mak ReadMe
LOCAL_CLEAN = $(VERSION_DIRS:%=%_build)
# We don't compile in here for Visual C++
VC_IGNORE=yes
# ALL = .sub_directories .javalib
ALL = check_and_make
include $(TOP)/config/common_make_rules
include $(EST)/config/rules/build_dir.mak
check_and_make: $(VERSION_DIRS:%=create_%_build) $(VERSION_DIRS:%=%_build)

5
java/ReadMe Normal file
View File

@@ -0,0 +1,5 @@
This directory tree contains a set of Java classes which give
access to the Edinburgh speech tools.
At the moment these are quite limited.

View File

@@ -0,0 +1,47 @@
###########################################################################
## ##
## Centre for Speech Technology Research ##
## University of Edinburgh, UK ##
## Copyright (c) 1996 ##
## All Rights Reserved. ##
## ##
## Permission is hereby granted, free of charge, to use and distribute ##
## this software and its documentation without restriction, including ##
## without limitation the rights to use, copy, modify, merge, publish, ##
## distribute, sublicense, and/or sell copies of this work, and to ##
## permit persons to whom this work is furnished to do so, subject to ##
## the following conditions: ##
## 1. The code must retain the above copyright notice, this list of ##
## conditions and the following disclaimer. ##
## 2. Any modifications must be clearly marked as such. ##
## 3. Original authors' names are not deleted. ##
## 4. The authors' names are not used to endorse or promote products ##
## derived from this software without specific prior written ##
## permission. ##
## ##
## THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK ##
## DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ##
## ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT ##
## SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE ##
## FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ##
## WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN ##
## AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ##
## ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF ##
## THIS SOFTWARE. ##
## ##
###########################################################################
TOP=../..
DIRNAME=java/basic_version
FILES = Makefile Makefile.version
BUILD_DIRS=cstr
NEED_JAVA=true
ALL = .sub_directories .javalib
include $(TOP)/config/common_make_rules
-include Makefile.version

View File

@@ -0,0 +1,42 @@
###########################################################################
## ##
## Centre for Speech Technology Research ##
## University of Edinburgh, UK ##
## Copyright (c) 1996 ##
## All Rights Reserved. ##
## ##
## Permission is hereby granted, free of charge, to use and distribute ##
## this software and its documentation without restriction, including ##
## without limitation the rights to use, copy, modify, merge, publish, ##
## distribute, sublicense, and/or sell copies of this work, and to ##
## permit persons to whom this work is furnished to do so, subject to ##
## the following conditions: ##
## 1. The code must retain the above copyright notice, this list of ##
## conditions and the following disclaimer. ##
## 2. Any modifications must be clearly marked as such. ##
## 3. Original authors' names are not deleted. ##
## 4. The authors' names are not used to endorse or promote products ##
## derived from this software without specific prior written ##
## permission. ##
## ##
## THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK ##
## DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ##
## ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT ##
## SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE ##
## FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ##
## WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN ##
## AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ##
## ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF ##
## THIS SOFTWARE. ##
## ##
###########################################################################
## Suplimental make information for this version
CODE_VERSION=basic
LOCAL_JAVA_CLASS_LIBRARY=$(TOP)/lib/est_$(CODE_VERSION).jar
LOCAL_JAVA_CLASSPATH=$(EST_HOME)/speech_tools/lib/est_$(CODE_VERSION).jar
JAVA_TOP_PACK=cstr
LOCAL_JAVA_ROOT=$(TOP)/java/$(CODE_VERSION)_version_build

View File

@@ -0,0 +1,50 @@
###########################################################################
## ##
## Centre for Speech Technology Research ##
## University of Edinburgh, UK ##
## Copyright (c) 1996 ##
## All Rights Reserved. ##
## ##
## Permission is hereby granted, free of charge, to use and distribute ##
## this software and its documentation without restriction, including ##
## without limitation the rights to use, copy, modify, merge, publish, ##
## distribute, sublicense, and/or sell copies of this work, and to ##
## permit persons to whom this work is furnished to do so, subject to ##
## the following conditions: ##
## 1. The code must retain the above copyright notice, this list of ##
## conditions and the following disclaimer. ##
## 2. Any modifications must be clearly marked as such. ##
## 3. Original authors' names are not deleted. ##
## 4. The authors' names are not used to endorse or promote products ##
## derived from this software without specific prior written ##
## permission. ##
## ##
## THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK ##
## DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ##
## ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT ##
## SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE ##
## FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ##
## WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN ##
## AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ##
## ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF ##
## THIS SOFTWARE. ##
## ##
###########################################################################
TOP=../../..
DIRNAME=java/basic_version/cstr
ALL_DIRS = est
BUILD_DIRS = awt est util testPrograms
NEED_JAVA = true
FILES = Makefile
ALL = .sub_directories
-include ../../../Makefile.version
include $(TOP)/config/common_make_rules

View File

@@ -0,0 +1,133 @@
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Centre for Speech Technology Research \\
// University of Edinburgh, UK \\
// Copyright (c) 1996,1997 \\
// All Rights Reserved. \\
// Permission is hereby granted, free of charge, to use and distribute \\
// this software and its documentation without restriction, including \\
// without limitation the rights to use, copy, modify, merge, publish, \\
// distribute, sublicense, and/or sell copies of this work, and to \\
// permit persons to whom this work is furnished to do so, subject to \\
// the following conditions: \\
// 1. The code must retain the above copyright notice, this list of \\
// conditions and the following disclaimer. \\
// 2. Any modifications must be clearly marked as such. \\
// 3. Original authors' names are not deleted. \\
// 4. The authors' names are not used to endorse or promote products \\
// derived from this software without specific prior written \\
// permission. \\
// THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK \\
// DISCLAIM ALL WARRANTIES With REGARD TO THIS SOFTWARE, INCLUDING \\
// ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT \\
// SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE \\
// FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES \\
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN \\
// AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, \\
// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF \\
// THIS SOFTWARE. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
// -------------------------------------------------------------------- \\
// Pretended EST_Features class. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
package cstr.est;
import java.lang.*;
import java.util.*;
import cstr.util.*;
public class Features
implements Featured
{
String [] cachedFeatureNames;
public Features()
{
this(0L, true);
}
public Features(long handle)
{
this(handle, false);
}
Features(long handle, boolean m)
{
}
protected void finalize() throws Throwable
{
super.finalize();
}
public String [] names()
{
if (cachedFeatureNames ==null)
cachedFeatureNames = new String [0];
return cachedFeatureNames;
}
public void getPaths(String prefix, Vector names, boolean paths, boolean leaves)
{
}
public boolean present(String n)
{
return false;
}
public String getS(String n)
{
return "";
}
public String getS(String n, String def)
{
return def;
}
public String getFeature(String n)
{
return "";
}
public float getF(String n)
{
return (float)0.0;
}
public float getF(String n, float def)
{
return def;
}
public Object get(String n)
{
return null;
}
public Object get(String n, Object def)
{
return def;
}
public void set(String n, float val)
{
}
public void set(String n, String val)
{
}
static {
}
}

View File

@@ -0,0 +1,164 @@
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Centre for Speech Technology Research \\
// University of Edinburgh, UK \\
// Copyright (c) 1996,1997 \\
// All Rights Reserved. \\
// Permission is hereby granted, free of charge, to use and distribute \\
// this software and its documentation without restriction, including \\
// without limitation the rights to use, copy, modify, merge, publish, \\
// distribute, sublicense, and/or sell copies of this work, and to \\
// permit persons to whom this work is furnished to do so, subject to \\
// the following conditions: \\
// 1. The code must retain the above copyright notice, this list of \\
// conditions and the following disclaimer. \\
// 2. Any modifications must be clearly marked as such. \\
// 3. Original authors' names are not deleted. \\
// 4. The authors' names are not used to endorse or promote products \\
// derived from this software without specific prior written \\
// permission. \\
// THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK \\
// DISCLAIM ALL WARRANTIES With REGARD TO THIS SOFTWARE, INCLUDING \\
// ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT \\
// SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE \\
// FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES \\
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN \\
// AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, \\
// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF \\
// THIS SOFTWARE. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
// Date: Tue Mar 31 1998 \\
// -------------------------------------------------------------------- \\
// Java wrapper around items. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
package cstr.est;
import java.lang.*;
import java.util.*;
import java.awt.*;
import cstr.util.*;
import java.io.*;
public class Item
implements Named, Keyed, Featured
{
public Item()
{
this(0L, true, null);
}
public Item(long handle)
{
this(handle, false, null);
}
public Item(long handle, Object utterance)
{
this(handle, false, utterance);
}
Item(long handle, boolean m, Object from_utterance)
{
}
protected void finalize() throws Throwable
{
super.finalize();
}
protected final Item getItem(long handle)
{
return null;
}
public String name()
{
return null;
}
public String getName()
{
return null;
}
public void setName(String name)
{
}
public final Item_Content getContent()
{
return null;
}
public final Object getKey()
{
return null;
}
public String getS(String n)
{
return null;
}
public String getS(String n, String def)
{
return def;
}
public String getFeature(String n)
{
return null;
}
public float getF(String n)
{
return (float)0.0;
}
public String type()
{
return null;
}
public float getStartTime()
{
return (float)0.0;
}
public float getMidTime()
{
return (float)0.0;
}
public float getEndTime()
{
return (float)0.0;
}
public Item next()
{
return null;
}
public Item prev()
{
return null;
}
public Item up()
{
return null;
}
public Item down()
{
return null;
}
}

View File

@@ -0,0 +1,132 @@
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Centre for Speech Technology Research \\
// University of Edinburgh, UK \\
// Copyright (c) 1996,1997 \\
// All Rights Reserved. \\
// Permission is hereby granted, free of charge, to use and distribute \\
// this software and its documentation without restriction, including \\
// without limitation the rights to use, copy, modify, merge, publish, \\
// distribute, sublicense, and/or sell copies of this work, and to \\
// permit persons to whom this work is furnished to do so, subject to \\
// the following conditions: \\
// 1. The code must retain the above copyright notice, this list of \\
// conditions and the following disclaimer. \\
// 2. Any modifications must be clearly marked as such. \\
// 3. Original authors' names are not deleted. \\
// 4. The authors' names are not used to endorse or promote products \\
// derived from this software without specific prior written \\
// permission. \\
// THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK \\
// DISCLAIM ALL WARRANTIES With REGARD TO THIS SOFTWARE, INCLUDING \\
// ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT \\
// SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE \\
// FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES \\
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN \\
// AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, \\
// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF \\
// THIS SOFTWARE. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
// Date: Wed Feb 25 1998 \\
// -------------------------------------------------------------------- \\
// Items in a stream. Wrapper around EST_StreamItem. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
package cstr.est ;
import java.lang.*;
import java.util.*;
import java.awt.*;
import cstr.util.*;
public class Item_Content
implements Featured
{
public Item_Content()
{
this(0L, true);
}
public Item_Content(long handle)
{
this(handle, false);
}
Item_Content(long handle, boolean m)
{
}
protected void finalize() throws Throwable
{
super.finalize();
}
public String name()
{
return "DUMMY";
}
public String getName()
{
return name();
}
public Features getFeatures()
{
return new Features();
}
public Item getItem()
{
return null;
}
public String [] featureNames()
{
return null;
}
public boolean featurePresent(String n)
{
return false;
}
public String getS(String n)
{
return null;
}
public String getFeature(String n)
{
return null;
}
public float getF(String n)
{
return (float)0.0;
}
public float getStartTime()
{
return (float)0.0;
}
public float getMidTime()
{
return (float)0.0;
}
public float getEndTime()
{
return (float)0.0;
}
}

View File

@@ -0,0 +1,58 @@
###########################################################################
## ##
## Centre for Speech Technology Research ##
## University of Edinburgh, UK ##
## Copyright (c) 1996 ##
## All Rights Reserved. ##
## ##
## Permission is hereby granted, free of charge, to use and distribute ##
## this software and its documentation without restriction, including ##
## without limitation the rights to use, copy, modify, merge, publish, ##
## distribute, sublicense, and/or sell copies of this work, and to ##
## permit persons to whom this work is furnished to do so, subject to ##
## the following conditions: ##
## 1. The code must retain the above copyright notice, this list of ##
## conditions and the following disclaimer. ##
## 2. Any modifications must be clearly marked as such. ##
## 3. Original authors' names are not deleted. ##
## 4. The authors' names are not used to endorse or promote products ##
## derived from this software without specific prior written ##
## permission. ##
## ##
## THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK ##
## DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ##
## ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT ##
## SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE ##
## FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ##
## WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN ##
## AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ##
## ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF ##
## THIS SOFTWARE. ##
## ##
###########################################################################
TOP=../../../..
DIRNAME = java/basic_version/cstr/est
JUST_BUILD_DIRS = awt
ALL_DIRS =
LOCAL_JAVA_NATIVE_CLASSES =
JAVA_NATIVE_CLASSES =$(LOCAL_JAVA_NATIVE_CLASSES)
LOCAL_JAVA_CLASSES = $(LOCAL_JAVA_NATIVE_CLASSES) Wave Item_Content Item Features
JAVA_CLASSES = $(LOCAL_JAVA_CLASSES) SocketsFile ServerConnection
CPPSRCS = $(JAVA_NATIVE_CLASSES:%=%.cc)
SRCS = $(CPPSRCS)
OBJS_estjava = $(SRCS:.cc=.o)
FILES = $(LOCAL_JAVA_CLASSES:%=%.java) $(LOCAL_JAVA_NATIVE_CLASSES:%=%.cc) Makefile
ALL = .java
-include ../../Makefile.version
include $(TOP)/config/common_make_rules

View File

@@ -0,0 +1,219 @@
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Centre for Speech Technology Research \\
// University of Edinburgh, UK \\
// Copyright (c) 1996,1997 \\
// All Rights Reserved. \\
// Permission is hereby granted, free of charge, to use and distribute \\
// this software and its documentation without restriction, including \\
// without limitation the rights to use, copy, modify, merge, publish, \\
// distribute, sublicense, and/or sell copies of this work, and to \\
// permit persons to whom this work is furnished to do so, subject to \\
// the following conditions: \\
// 1. The code must retain the above copyright notice, this list of \\
// conditions and the following disclaimer. \\
// 2. Any modifications must be clearly marked as such. \\
// 3. Original authors' names are not delete. \\
// 4. The authors' names are not used to endorse or promote products \\
// derived from this software without specific prior written \\
// permission. \\
// THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK \\
// DISCLAIM ALL WARRANTIES With REGARD TO THIS SOFTWARE, INCLUDING \\
// ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT \\
// SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE \\
// FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES \\
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN \\
// AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, \\
// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF \\
// THIS SOFTWARE. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
// -------------------------------------------------------------------- \\
// A simple java wave class. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
package cstr.est ;
import java.lang.*;
import java.util.*;
import java.net.*;
import java.io.*;
import sun.applet.*;
public class Wave
{
int rate;
int amplitude_cache=-1;
short [] data;
File fn;
public Wave()
{
data=null;
fn=null;
}
public Wave(byte [] bytes)
throws UnsupportedEncodingException
{
fn=null;
if (!parse(bytes))
{
throw new UnsupportedEncodingException("Can't create Wave from this bytestream");
}
}
public Wave(File file)
throws UnsupportedEncodingException, IOException
{
FileInputStream is = new FileInputStream(file);
int n=0;
byte [] buf = new byte[n];
while (true)
{
byte [] ibuf = new byte[10240];
int nr = is.read(ibuf, 0, 10240);
if (nr == -1)
break;
if (n==0)
{
buf = ibuf;
n = nr;
}
else
{
byte [] nbuf = new byte[n+nr];
for(int i=0; i<n; i++)
nbuf[i] = buf[i];
for(int i=0; i<nr; i++)
nbuf[i+n] = ibuf[i];
buf=nbuf;
n += nr;
}
}
if (!parse(buf))
{
throw new UnsupportedEncodingException("Can't create Wave from this bytestream");
}
}
public void finalize()
{
if (fn != null)
fn.delete();
}
public String name()
{
return toString();
}
public void resample(int rate)
{
}
public int amplitude(int c)
{
if (amplitude_cache<0)
for(int i=0; i<data.length; i++)
{
short d=data[i];
if (d>=0 && d > amplitude_cache)
amplitude_cache=d;
if (d<0 && -d > amplitude_cache)
amplitude_cache=-d;
}
return amplitude_cache;
}
public int num_samples()
{
return data.length;
}
public void cpp_getScanlines(int c,
byte[] line,
int lstart, int lnum,
int x, int chunk,
int width, int height,
int amplitude
)
{
}
private File mkFilename()
{
StringBuffer fn= new StringBuffer(50);
fn.append("/tmp/jsapi_");
fn.append(this.toString());
fn.append(".au");
return new File(fn.toString());
}
public boolean parse(byte[] bytes)
{
//clip = new AppletAudioClip(bytes);
fn=mkFilename();
try {
FileOutputStream os = new FileOutputStream(fn);
os.write(bytes);
os.close();
} catch (IOException ex) {
System.err.println("IO Exception: "+ex.getMessage());
return false;
}
int magic = (bytes[0] <<24) + (bytes[1] <<16) + (bytes[2] <<8) + bytes[3];
int smagic = (bytes[3] <<24) + (bytes[2] <<16) + (bytes[1] <<8) + bytes[0];
if (magic == 0x2e736e64)
{
return true;
}
return false;
}
public void play()
{
if (fn != null)
{
try {
String command = "na_play "+fn.toString();
// System.out.println("play command "+command);
Process p = Runtime.getRuntime().exec(command);
p.waitFor();
} catch (IOException ex) {
} catch (InterruptedException ex) {
}
}
}
public void stop()
{
}
public void load(String filename) throws FileNotFoundException
{
throw new FileNotFoundException("Load Not yet Implemented");
}
public void save(String filename, String format) throws IOException
{
throw new IOException("Save Not yet Implemented");
}
}

48
java/common/Makefile Normal file
View File

@@ -0,0 +1,48 @@
###########################################################################
## ##
## Centre for Speech Technology Research ##
## University of Edinburgh, UK ##
## Copyright (c) 1996 ##
## All Rights Reserved. ##
## ##
## Permission is hereby granted, free of charge, to use and distribute ##
## this software and its documentation without restriction, including ##
## without limitation the rights to use, copy, modify, merge, publish, ##
## distribute, sublicense, and/or sell copies of this work, and to ##
## permit persons to whom this work is furnished to do so, subject to ##
## the following conditions: ##
## 1. The code must retain the above copyright notice, this list of ##
## conditions and the following disclaimer. ##
## 2. Any modifications must be clearly marked as such. ##
## 3. Original authors' names are not deleted. ##
## 4. The authors' names are not used to endorse or promote products ##
## derived from this software without specific prior written ##
## permission. ##
## ##
## THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK ##
## DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ##
## ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT ##
## SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE ##
## FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ##
## WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN ##
## AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ##
## ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF ##
## THIS SOFTWARE. ##
## ##
###########################################################################
TOP=../..
DIRNAME=java/common
BUILD_DIRS = cstr
NEED_JAVA = true
FILES = Makefile
ALL = .sub_directories .javalib
-include Makefile.version
include $(TOP)/config/common_make_rules

48
java/common/cstr/Makefile Normal file
View File

@@ -0,0 +1,48 @@
###########################################################################
## ##
## Centre for Speech Technology Research ##
## University of Edinburgh, UK ##
## Copyright (c) 1996 ##
## All Rights Reserved. ##
## ##
## Permission is hereby granted, free of charge, to use and distribute ##
## this software and its documentation without restriction, including ##
## without limitation the rights to use, copy, modify, merge, publish, ##
## distribute, sublicense, and/or sell copies of this work, and to ##
## permit persons to whom this work is furnished to do so, subject to ##
## the following conditions: ##
## 1. The code must retain the above copyright notice, this list of ##
## conditions and the following disclaimer. ##
## 2. Any modifications must be clearly marked as such. ##
## 3. Original authors' names are not deleted. ##
## 4. The authors' names are not used to endorse or promote products ##
## derived from this software without specific prior written ##
## permission. ##
## ##
## THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK ##
## DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ##
## ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT ##
## SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE ##
## FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ##
## WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN ##
## AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ##
## ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF ##
## THIS SOFTWARE. ##
## ##
###########################################################################
TOP=../../..
DIRNAME=java/common/cstr
BUILD_DIRS = awt util est testPrograms
NEED_JAVA = true
FILES = Makefile
ALL = .sub_directories
-include ../Makefile.version
include $(TOP)/config/common_make_rules

View File

@@ -0,0 +1,86 @@
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Centre for Speech Technology Research \\
// University of Edinburgh, UK \\
// Copyright (c) 1996,1997 \\
// All Rights Reserved. \\
// Permission is hereby granted, free of charge, to use and distribute \\
// this software and its documentation without restriction, including \\
// without limitation the rights to use, copy, modify, merge, publish, \\
// distribute, sublicense, and/or sell copies of this work, and to \\
// permit persons to whom this work is furnished to do so, subject to \\
// the following conditions: \\
// 1. The code must retain the above copyright notice, this list of \\
// conditions and the following disclaimer. \\
// 2. Any modifications must be clearly marked as such. \\
// 3. Original authors' names are not deleted. \\
// 4. The authors' names are not used to endorse or promote products \\
// derived from this software without specific prior written \\
// permission. \\
// THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK \\
// DISCLAIM ALL WARRANTIES With REGARD TO THIS SOFTWARE, INCLUDING \\
// ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT \\
// SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE \\
// FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES \\
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN \\
// AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, \\
// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF \\
// THIS SOFTWARE. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
// -------------------------------------------------------------------- \\
// A selection of colors from which colors can be selected. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
package cstr.awt ;
import java.lang.*;
import java.util.*;
import java.awt.*;
public class ColorSelection
{
protected Color [] colors;
protected int pos;
public ColorSelection(Color [] cols)
{
colors = cols;
pos=0;
}
public ColorSelection(Color col)
{
colors = new Color [] {col};
pos=0;
}
public ColorSelection(String cols)
{
StringTokenizer tok = new StringTokenizer(cols, ",");
int n = tok.countTokens();
colors = new Color[n];
for(int i=0; i<n; i++)
colors[i] = new XColor(tok.nextToken());
pos=0;
}
public Color nextColor()
{
if (pos >= colors.length)
pos -= colors.length;
if (pos >= colors.length)
return Color.black;
return colors[pos++];
}
}

View File

@@ -0,0 +1,146 @@
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Centre for Speech Technology Research \\
// University of Edinburgh, UK \\
// Copyright (c) 1996,1997 \\
// All Rights Reserved. \\
// Permission is hereby granted, free of charge, to use and distribute \\
// this software and its documentation without restriction, including \\
// without limitation the rights to use, copy, modify, merge, publish, \\
// distribute, sublicense, and/or sell copies of this work, and to \\
// permit persons to whom this work is furnished to do so, subject to \\
// the following conditions: \\
// 1. The code must retain the above copyright notice, this list of \\
// conditions and the following disclaimer. \\
// 2. Any modifications must be clearly marked as such. \\
// 3. Original authors' names are not deleted. \\
// 4. The authors' names are not used to endorse or promote products \\
// derived from this software without specific prior written \\
// permission. \\
// THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK \\
// DISCLAIM ALL WARRANTIES With REGARD TO THIS SOFTWARE, INCLUDING \\
// ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT \\
// SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE \\
// FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES \\
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN \\
// AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, \\
// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF \\
// THIS SOFTWARE. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
// Date: Thu Apr 9 1998 \\
// -------------------------------------------------------------------- \\
package cstr.awt;
import java.util.*;
import java.lang.*;
import java.awt.*;
import java.awt.event.*;
import java.awt.image.*;
public class ImageCanvas extends Canvas
{
Image image;
int pwidth, pheight;
private void init(Image im, double xscale, double yscale)
{
pwidth = (int)(im.getWidth(this)*xscale);
pheight = (int)(im.getHeight(this)*yscale);
if (xscale != 1.0 || yscale != 1.0)
{
ImageFilter filter = new ReplicateScaleFilter(pwidth, pheight);
image = createImage(new FilteredImageSource(im.getSource(), filter));
}
else
image = im;
}
public ImageCanvas(Image touse, double xscale, double yscale)
{
super();
init(touse, xscale, yscale);
}
public ImageCanvas(ImageProducer prod, double xscale, double yscale)
{
super();
init(createImage(prod), xscale, yscale);
}
public ImageCanvas(Image touse, double scale)
{
super();
init(touse, scale, scale);
}
public ImageCanvas(ImageProducer prod, double scale)
{
super();
init(createImage(prod), scale, scale);
}
public ImageCanvas(Image touse)
{
super();
init(touse, 1.0, 1.0);
}
public ImageCanvas(ImageProducer prod)
{
super();
init(createImage(prod), 1.0, 1.0);
}
public boolean imageUpdate(Image img,
int flags,
int x,
int y,
int w,
int h)
{
int oh =pheight;
int ow = pwidth;
if ((flags & ImageObserver.WIDTH) != 0)
pwidth = w;
if ((flags & ImageObserver.HEIGHT) != 0 )
pheight = h;
if (pwidth!= ow || pheight != oh)
setSize(pwidth, pheight);
repaint();
return !((flags & ImageObserver.ALLBITS) != 0);
}
public Dimension getPreferredSize()
{
return new Dimension(pwidth, pheight);
}
public Dimension getMinimumSize()
{
return new Dimension(pwidth, pheight);
}
public void update(Graphics g)
{
paint(g);
}
public void paint(Graphics g)
{
g.drawImage(image, 0, 0, pwidth, pheight, this);
}
}

View File

@@ -0,0 +1,46 @@
###########################################################################
## ##
## Centre for Speech Technology Research ##
## University of Edinburgh, UK ##
## Copyright (c) 1996 ##
## All Rights Reserved. ##
## ##
## Permission is hereby granted, free of charge, to use and distribute ##
## this software and its documentation without restriction, including ##
## without limitation the rights to use, copy, modify, merge, publish, ##
## distribute, sublicense, and/or sell copies of this work, and to ##
## permit persons to whom this work is furnished to do so, subject to ##
## the following conditions: ##
## 1. The code must retain the above copyright notice, this list of ##
## conditions and the following disclaimer. ##
## 2. Any modifications must be clearly marked as such. ##
## 3. Original authors' names are not deleted. ##
## 4. The authors' names are not used to endorse or promote products ##
## derived from this software without specific prior written ##
## permission. ##
## ##
## THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK ##
## DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ##
## ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT ##
## SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE ##
## FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ##
## WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN ##
## AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ##
## ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF ##
## THIS SOFTWARE. ##
## ##
###########################################################################
TOP=../../../..
DIRNAME=java/common/cstr/awt
JAVA_CLASSES = ScrollWindow ImageCanvas XColor ColorSelection
NEED_JAVA = true
FILES = Makefile $(JAVA_CLASSES:=.java)
ALL = .java
-include ../../Makefile.version
include $(TOP)/config/common_make_rules

View File

@@ -0,0 +1,134 @@
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Centre for Speech Technology Research \\
// University of Edinburgh, UK \\
// Copyright (c) 1996,1997 \\
// All Rights Reserved. \\
// Permission is hereby granted, free of charge, to use and distribute \\
// this software and its documentation without restriction, including \\
// without limitation the rights to use, copy, modify, merge, publish, \\
// distribute, sublicense, and/or sell copies of this work, and to \\
// permit persons to whom this work is furnished to do so, subject to \\
// the following conditions: \\
// 1. The code must retain the above copyright notice, this list of \\
// conditions and the following disclaimer. \\
// 2. Any modifications must be clearly marked as such. \\
// 3. Original authors' names are not deleted. \\
// 4. The authors' names are not used to endorse or promote products \\
// derived from this software without specific prior written \\
// permission. \\
// THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK \\
// DISCLAIM ALL WARRANTIES With REGARD TO THIS SOFTWARE, INCLUDING \\
// ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT \\
// SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE \\
// FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES \\
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN \\
// AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, \\
// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF \\
// THIS SOFTWARE. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
// Date: Thu Apr 9 1998 \\
// -------------------------------------------------------------------- \\
package cstr.awt;
import java.util.*;
import java.lang.*;
import java.awt.*;
import java.awt.event.*;
import cstr.est.*;
public class ScrollWindow extends Frame
implements ActionListener, WindowListener
{
ScrollPane scroller;
Canvas canvas;
private void init(String title, Component contents, int width, int height)
{
setTitle(title);
setSize(width, height);
scroller = new ScrollPane(ScrollPane.SCROLLBARS_ALWAYS);
scroller.add(contents);
scroller.doLayout();
MenuBar mb = new MenuBar();
setMenuBar(mb);
Menu cMenu = new Menu("Control", true);
mb.add(cMenu);
MenuItem mItem = new MenuItem("Quit");
mItem.addActionListener(this);
cMenu.add(mItem);
addWindowListener(this);
setLayout(new BorderLayout());
add("Center", scroller);
pack();
}
public ScrollWindow(String name, Component contents)
{
super();
init(name, contents, 500, 500);
}
public ScrollWindow(String name, Component contents, int width, int height)
{
super();
init(name, contents, width, height);
}
public void quit()
{
dispose();
}
public void quit(String s)
{
dispose();
}
public void actionPerformed(ActionEvent event)
{
quit("action");
}
public void windowClosing(WindowEvent event)
{
quit("close");
}
public void windowOpened(WindowEvent event)
{
}
public void windowClosed(WindowEvent event)
{
}
public void windowIconified(WindowEvent event)
{
}
public void windowDeiconified(WindowEvent event)
{
}
public void windowActivated(WindowEvent event)
{
}
public void windowDeactivated(WindowEvent event)
{
}
}

View File

@@ -0,0 +1,202 @@
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Centre for Speech Technology Research \\
// University of Edinburgh, UK \\
// Copyright (c) 1996,1997 \\
// All Rights Reserved. \\
// Permission is hereby granted, free of charge, to use and distribute \\
// this software and its documentation without restriction, including \\
// without limitation the rights to use, copy, modify, merge, publish, \\
// distribute, sublicense, and/or sell copies of this work, and to \\
// permit persons to whom this work is furnished to do so, subject to \\
// the following conditions: \\
// 1. The code must retain the above copyright notice, this list of \\
// conditions and the following disclaimer. \\
// 2. Any modifications must be clearly marked as such. \\
// 3. Original authors' names are not deleted. \\
// 4. The authors' names are not used to endorse or promote products \\
// derived from this software without specific prior written \\
// permission. \\
// THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK \\
// DISCLAIM ALL WARRANTIES With REGARD TO THIS SOFTWARE, INCLUDING \\
// ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT \\
// SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE \\
// FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES \\
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN \\
// AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, \\
// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF \\
// THIS SOFTWARE. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
// Date: Thu Apr 9 1998 \\
// -------------------------------------------------------------------- \\
// Extend awt.Color to understand X11 color names. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
package cstr.awt ;
import java.lang.*;
import java.io.*;
import java.util.*;
import java.awt.*;
public class XColor extends Color
{
protected static String rgbFile;
protected static Hashtable colors = new Hashtable(100);
protected static Reader rgbStream;
protected static StreamTokenizer rgbTok;
protected String name;
static
{
rgbFile = System.getProperty("est.rgbFile");
}
public XColor(float r, float g, float b)
{
super(r,g,b);
name=null;
}
public XColor(int rgb)
{
super(rgb);
name=null;
}
public XColor(int r, int g, int b)
{
super(r,g,b);
name=null;
}
public XColor(String n)
{
super(x11ColorRGB(n));
name=n;
}
public XColor(String n, int i)
{
super(x11ColorRGBThrow(n));
name=n;
}
public static int x11ColorRGBThrow(String name)
throws IllegalArgumentException
{
int c = x11ColorRGB(name);
if (c<0)
throw new IllegalArgumentException("Can't find color '"+name+"'");
return c;
}
public static int x11ColorRGB(String name)
{
name = name.toLowerCase();
Integer rgbI = (Integer)colors.get(name);
if (rgbI != null)
return rgbI.intValue();
if (name.startsWith("#"))
try {
return Integer.parseInt(name.substring(1), 16);
} catch (NumberFormatException ex) {
System.err.println("Can't parse color '"+name+"'");
return 0;
};
if (rgbStream == null)
try {
rgbStream = new FileReader(rgbFile);
rgbTok = new StreamTokenizer(rgbStream);
rgbTok.parseNumbers();
rgbTok.ordinaryChar('\n');
} catch (FileNotFoundException ex) {
System.err.println("can't open '" + rgbFile + "' " + ex.getMessage());
}
int r=0;
int g=0;
int b=0;
String n="";
try {
while (1==1)
{
int t = rgbTok.nextToken();
if (t == rgbTok.TT_EOF)
break;
if (t == '\n')
continue;
if ( t == '!')
{
while (t != '\n' && t != rgbTok.TT_EOF)
t = rgbTok.nextToken();
continue;
}
if ( t == rgbTok.TT_NUMBER)
r = (int)rgbTok.nval;
t = rgbTok.nextToken();
if ( t == rgbTok.TT_NUMBER)
g = (int)rgbTok.nval;
t = rgbTok.nextToken();
if ( t == rgbTok.TT_NUMBER)
b = (int)rgbTok.nval;
n="";
while ((t = rgbTok.nextToken()) != '\n' && t != rgbTok.TT_EOF)
{
if (!n.equals(""))
n = n + " ";
n = n + rgbTok.sval;
}
int rgb = (r<<16)|(g<<8)|(b);
colors.put(n.toLowerCase(), new Integer(rgb));
if (name.equals(n.toLowerCase()))
return rgb;
}
} catch (IOException ex) {
System.err.println(ex.getMessage());
}
System.err.println("Can't find color '"+name+"'");
return -1;
}
public static String getName(Color c)
{
return "#"+Integer.toString(c.getRGB(), 16);
}
public String getName()
{
if (name != null)
return name;
return getName(this);
}
}

View File

@@ -0,0 +1,47 @@
###########################################################################
## ##
## Centre for Speech Technology Research ##
## University of Edinburgh, UK ##
## Copyright (c) 1996 ##
## All Rights Reserved. ##
## ##
## Permission is hereby granted, free of charge, to use and distribute ##
## this software and its documentation without restriction, including ##
## without limitation the rights to use, copy, modify, merge, publish, ##
## distribute, sublicense, and/or sell copies of this work, and to ##
## permit persons to whom this work is furnished to do so, subject to ##
## the following conditions: ##
## 1. The code must retain the above copyright notice, this list of ##
## conditions and the following disclaimer. ##
## 2. Any modifications must be clearly marked as such. ##
## 3. Original authors' names are not deleted. ##
## 4. The authors' names are not used to endorse or promote products ##
## derived from this software without specific prior written ##
## permission. ##
## ##
## THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK ##
## DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ##
## ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT ##
## SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE ##
## FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ##
## WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN ##
## AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ##
## ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF ##
## THIS SOFTWARE. ##
## ##
###########################################################################
TOP=../../../..
DIRNAME=java/common/cstr/est
BUILD_DIRS = awt
JAVA_CLASSES = SocketsFile ServerConnection
NEED_JAVA = true
FILES = Makefile $(JAVA_CLASSES:=.java)
ALL = .sub_directories
include $(TOP)/config/common_make_rules

View File

@@ -0,0 +1,129 @@
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Centre for Speech Technology Research \\
// University of Edinburgh, UK \\
// Copyright (c) 1996,1997 \\
// All Rights Reserved. \\
// Permission is hereby granted, free of charge, to use and distribute \\
// this software and its documentation without restriction, including \\
// without limitation the rights to use, copy, modify, merge, publish, \\
// distribute, sublicense, and/or sell copies of this work, and to \\
// permit persons to whom this work is furnished to do so, subject to \\
// the following conditions: \\
// 1. The code must retain the above copyright notice, this list of \\
// conditions and the following disclaimer. \\
// 2. Any modifications must be clearly marked as such. \\
// 3. Original authors' names are not deleted. \\
// 4. The authors' names are not used to endorse or promote products \\
// derived from this software without specific prior written \\
// permission. \\
// THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK \\
// DISCLAIM ALL WARRANTIES With REGARD TO THIS SOFTWARE, INCLUDING \\
// ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT \\
// SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE \\
// FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES \\
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN \\
// AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, \\
// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF \\
// THIS SOFTWARE. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
// -------------------------------------------------------------------- \\
// Wrapper around a socket which is connected to Fringe. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
package cstr.est;
import java.lang.*;
import java.util.*;
import java.io.*;
import java.net.*;
public class ServerConnection
{
private static String command_term = "//End//";
private static String result_term = "//End//";
private Socket s;
private BufferedReader reader;
private BufferedWriter writer;
public ServerConnection(Socket sk)
throws IOException
{
setSocket(sk);
}
public void setSocket(Socket sk)
throws IOException
{
s=sk;
try {
if (s == null)
throw new IOException("no socket");
Reader r = new InputStreamReader(s.getInputStream());
reader = new BufferedReader(r);
Writer w = new OutputStreamWriter(s.getOutputStream());
writer = new BufferedWriter(w);
} catch (IOException e) {
reader=null;
writer=null;
throw e;
}
}
protected String readResult()
throws IOException
{
while (true)
{
StringBuffer res = new StringBuffer(100);
String status = null;
while (true)
{
String line = reader.readLine();
if (line.startsWith(result_term))
{
status = line.substring(result_term.length());
break;
}
res.append(line);
}
if (status.equals("OK"))
return res.toString();
else if (status.equals("ERROR"))
return "!"+res.toString();
else if (status.equals("VAL"))
System.err.println("Warning, intermediate value '"+res.toString()+"'");
else
throw new IOException("Uknknown value type "+status);
}
}
public String sendCommand(String command)
throws IOException
{
writer.write(command, 0, command.length());
writer.newLine();
writer.write(command_term, 0, command_term.length());
writer.newLine();
writer.flush();
String result = readResult();
return result;
}
public String sendCommand(StringBuffer command)
throws IOException
{
return sendCommand(command.toString());
}
}

View File

@@ -0,0 +1,132 @@
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Centre for Speech Technology Research \\
// University of Edinburgh, UK \\
// Copyright (c) 1996,1997 \\
// All Rights Reserved. \\
// Permission is hereby granted, free of charge, to use and distribute \\
// this software and its documentation without restriction, including \\
// without limitation the rights to use, copy, modify, merge, publish, \\
// distribute, sublicense, and/or sell copies of this work, and to \\
// permit persons to whom this work is furnished to do so, subject to \\
// the following conditions: \\
// 1. The code must retain the above copyright notice, this list of \\
// conditions and the following disclaimer. \\
// 2. Any modifications must be clearly marked as such. \\
// 3. Original authors' names are not deleted. \\
// 4. The authors' names are not used to endorse or promote products \\
// derived from this software without specific prior written \\
// permission. \\
// THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK \\
// DISCLAIM ALL WARRANTIES With REGARD TO THIS SOFTWARE, INCLUDING \\
// ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT \\
// SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE \\
// FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES \\
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN \\
// AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, \\
// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF \\
// THIS SOFTWARE. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
// -------------------------------------------------------------------- \\
// Interface to the file in ~/.fringe/ which contains pointers to \\
// running fringe process \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
package cstr.est ;
import java.lang.*;
import java.util.*;
import java.awt.*;
import java.io.*;
import java.net.*;
public class SocketsFile
{
protected static Random random = new Random();
protected String filename;
public SocketsFile(String fn)
{
filename=fn;
}
public String setSocket(String type,
String name,
ServerSocket s)
throws IOException
{
int port = s.getLocalPort();
int cookie = random.nextInt();
InetAddress address = s.getInetAddress();
Properties props = new Properties();
try {
InputStream is = new FileInputStream(filename);
props.load(is);
} catch (IOException ex) {
}
props.put(name+".type", type);
props.put(name+".host", address.getHostName());
props.put(name+".address", address.getHostAddress());
props.put(name+".cookie", Integer.toString(cookie));
props.put(name+".port", Integer.toString(port));
OutputStream os = new FileOutputStream(filename);
props.save(os, "Fringe Sockets");
return Integer.toString(cookie);
}
protected static void sendCookie(Socket s, String cookie)
{
try {
Writer w = new OutputStreamWriter(s.getOutputStream());
w.write("//");
w.write(cookie);
w.write("\n");
w.flush();
} catch (IOException ex) {
}
}
public Socket getSocket(String myType, String name)
throws IOException
{
Socket s=null;
Properties props = new Properties();
InputStream is = new FileInputStream(filename);
props.load(is);
String type = props.getProperty(name+".type");
String hostname = props.getProperty(name+".host");
String address = props.getProperty(name+".address");
String portStr = props.getProperty(name+".port");
String cookieStr = props.getProperty(name+".cookie");
if (!myType.equals(type))
return null;
if (address != null && portStr != null)
{
int port = Integer.parseInt(portStr);
s = new Socket(address, port);
}
if (s != null && cookieStr !=null && !cookieStr.equals("none"))
sendCookie(s, cookieStr);
return s;
}
}

View File

@@ -0,0 +1,94 @@
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Centre for Speech Technology Research \\
// University of Edinburgh, UK \\
// Copyright (c) 1996,1997 \\
// All Rights Reserved. \\
// Permission is hereby granted, free of charge, to use and distribute \\
// this software and its documentation without restriction, including \\
// without limitation the rights to use, copy, modify, merge, publish, \\
// distribute, sublicense, and/or sell copies of this work, and to \\
// permit persons to whom this work is furnished to do so, subject to \\
// the following conditions: \\
// 1. The code must retain the above copyright notice, this list of \\
// conditions and the following disclaimer. \\
// 2. Any modifications must be clearly marked as such. \\
// 3. Original authors' names are not deleted. \\
// 4. The authors' names are not used to endorse or promote products \\
// derived from this software without specific prior written \\
// permission. \\
// THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK \\
// DISCLAIM ALL WARRANTIES With REGARD TO THIS SOFTWARE, INCLUDING \\
// ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT \\
// SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE \\
// FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES \\
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN \\
// AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, \\
// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF \\
// THIS SOFTWARE. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
// -------------------------------------------------------------------- \\
// Window which displays an Item_Content object. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
package cstr.est.awt ;
import java.lang.*;
import java.util.*;
import java.awt.*;
import cstr.est.*;
public class Item_Content_Window extends Container
{
protected Item_Content content;
protected Item item;
public Item_Content_Window(Item_Content cont)
{
super();
setLayout(new GridLayout(0,2));
content=cont;
item=cont.getItem();
update();
}
public void update()
{
removeAll();
if (content != null)
{
String [] names = getFeatureNames(content);
Label l;
for(int i=0; i<names.length; i++)
{
add(l=new Label(names[i], Label.RIGHT));
l.setBackground(Color.white);
add(l=new Label(item.getS(names[i],"NULL"), Label.LEFT));
l.setBackground(Color.white);
}
}
}
protected String [] getFeatureNames(Item_Content content)
{
Vector names = new Vector(100);
content.getFeatures().getPaths(null, names, false, true);
String [] s = new String[names.size()];
for (int i=0; i<s.length; i++)
s[i] = (String)names.elementAt(i);
return s;
}
}

View File

@@ -0,0 +1,49 @@
###########################################################################
## ##
## Centre for Speech Technology Research ##
## University of Edinburgh, UK ##
## Copyright (c) 1996 ##
## All Rights Reserved. ##
## ##
## Permission is hereby granted, free of charge, to use and distribute ##
## this software and its documentation without restriction, including ##
## without limitation the rights to use, copy, modify, merge, publish, ##
## distribute, sublicense, and/or sell copies of this work, and to ##
## permit persons to whom this work is furnished to do so, subject to ##
## the following conditions: ##
## 1. The code must retain the above copyright notice, this list of ##
## conditions and the following disclaimer. ##
## 2. Any modifications must be clearly marked as such. ##
## 3. Original authors' names are not deleted. ##
## 4. The authors' names are not used to endorse or promote products ##
## derived from this software without specific prior written ##
## permission. ##
## ##
## THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK ##
## DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ##
## ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT ##
## SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE ##
## FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ##
## WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN ##
## AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ##
## ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF ##
## THIS SOFTWARE. ##
## ##
###########################################################################
TOP=../../../../..
DIRNAME = java/common/cstr/est/awt
BUILD_DIRS =
JAVA_CLASSES = Item_Content_Window WaveImageSource
NEED_JAVA = true
FILES = $(JAVA_CLASSES:%=%.java) Makefile
ALL = .java .buildlib
-include ../../../Makefile.version
include $(TOP)/config/common_make_rules

View File

@@ -0,0 +1,218 @@
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Centre for Speech Technology Research \\
// University of Edinburgh, UK \\
// Copyright (c) 1996,1997 \\
// All Rights Reserved. \\
// Permission is hereby granted, free of charge, to use and distribute \\
// this software and its documentation without restriction, including \\
// without limitation the rights to use, copy, modify, merge, publish, \\
// distribute, sublicense, and/or sell copies of this work, and to \\
// permit persons to whom this work is furnished to do so, subject to \\
// the following conditions: \\
// 1. The code must retain the above copyright notice, this list of \\
// conditions and the following disclaimer. \\
// 2. Any modifications must be clearly marked as such. \\
// 3. Original authors' names are not deleted. \\
// 4. The authors' names are not used to endorse or promote products \\
// derived from this software without specific prior written \\
// permission. \\
// THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK \\
// DISCLAIM ALL WARRANTIES With REGARD TO THIS SOFTWARE, INCLUDING \\
// ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT \\
// SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE \\
// FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES \\
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN \\
// AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, \\
// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF \\
// THIS SOFTWARE. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
// Date: Mon Sep 22 1997 \\
// -------------------------------------------------------------------- \\
// A class which implements the image producer interface using a Wave \\
// as the source of the image. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
package cstr.est.awt;
import java.util.*;
import java.lang.*;
import java.awt.*;
import java.awt.image.*;
import cstr.est.*;
public class WaveImageSource implements ImageProducer
{
static ColorModel cmodel;
static {
cmodel = new IndexColorModel(24, 5, new byte[]
{
-1, -1, -1,
-32, 110, 70,
-64, 100, 60,
-96, 90, 50,
-127, 80, 40
},
0, false);
}
Wave wave;
int channel;
int x;
int chunk;
int width;
int height;
int amplitude;
Vector consumers;
public WaveImageSource(Wave w, int c,
int xoff, int xlen,
int hsize, int vsize)
{
wave = w;
channel=c;
x = xoff;
chunk = xlen;
width = hsize;
height = vsize;
amplitude = w.amplitude(channel) + 100;
consumers = new Vector(1);
}
public WaveImageSource(Wave w, int vsize)
{
this(w, 0, 0, w.num_samples(), w.num_samples(), vsize);
}
public WaveImageSource(Wave w)
{
this(w, 0, 0, w.num_samples(), w.num_samples(), 150);
}
public void addConsumer(ImageConsumer ic)
{
if (!consumers.contains(ic))
consumers.addElement(ic);
}
public boolean isConsumer(ImageConsumer ic)
{
return consumers.contains(ic);
}
public void removeConsumer(ImageConsumer ic)
{
consumers.removeElement(ic);
}
public void startProduction(ImageConsumer ic)
{
addConsumer(ic);
produce();
}
public void requestTopDownLeftRightResend(ImageConsumer ic)
{
produce();
}
private void sendHints(int hints)
{
int i;
for(i=0; i<consumers.size(); i++)
{
ImageConsumer ic = (ImageConsumer)consumers.elementAt(i);
if (ic != null)
ic.setHints(hints);
}
}
private void sendColorModel()
{
int i;
for(i=0; i<consumers.size(); i++)
{
ImageConsumer ic = (ImageConsumer)consumers.elementAt(i);
if (ic != null)
ic.setColorModel(cmodel);
}
}
private void sendDimensions()
{
int i;
for(i=0; i<consumers.size(); i++)
{
ImageConsumer ic = (ImageConsumer)consumers.elementAt(i);
if (ic != null)
ic.setDimensions(chunk, height);
}
}
private void sendLine(byte [] line, int l, int n)
{
int i;
for(i=0; i<consumers.size(); i++)
{
ImageConsumer ic = (ImageConsumer)consumers.elementAt(i);
if (ic != null)
ic.setPixels(0, l, chunk, n, cmodel, line, 0, chunk);
}
}
private void sendComplete(int status)
{
int i;
for(i=0; i<consumers.size(); i++)
{
ImageConsumer ic = (ImageConsumer)consumers.elementAt(i);
if (ic != null)
ic.imageComplete(status);
}
}
protected void produce()
{
System.out.println("start prod");
sendHints(ImageConsumer.SINGLEFRAME
| ImageConsumer.SINGLEPASS
| ImageConsumer.TOPDOWNLEFTRIGHT);
sendColorModel();
sendDimensions();
int nlines=30;
byte [] line = new byte[chunk*nlines];
System.out.println("start send");
for(int l=0; l < height ; l+=nlines)
{
int n = height-l>nlines?nlines:height-l;
System.out.println("g");
wave.cpp_getScanlines(channel, line, l, n,
x, chunk,
width, height,
amplitude);
System.out.println("s");
sendLine(line, l, n);
}
System.out.println("end send");
sendComplete(ImageConsumer.STATICIMAGEDONE);
System.out.println("end prod");
}
}

View File

@@ -0,0 +1,47 @@
###########################################################################
## ##
## Centre for Speech Technology Research ##
## University of Edinburgh, UK ##
## Copyright (c) 1996 ##
## All Rights Reserved. ##
## ##
## Permission is hereby granted, free of charge, to use and distribute ##
## this software and its documentation without restriction, including ##
## without limitation the rights to use, copy, modify, merge, publish, ##
## distribute, sublicense, and/or sell copies of this work, and to ##
## permit persons to whom this work is furnished to do so, subject to ##
## the following conditions: ##
## 1. The code must retain the above copyright notice, this list of ##
## conditions and the following disclaimer. ##
## 2. Any modifications must be clearly marked as such. ##
## 3. Original authors' names are not deleted. ##
## 4. The authors' names are not used to endorse or promote products ##
## derived from this software without specific prior written ##
## permission. ##
## ##
## THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK ##
## DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ##
## ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT ##
## SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE ##
## FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ##
## WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN ##
## AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ##
## ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF ##
## THIS SOFTWARE. ##
## ##
###########################################################################
TOP=../../../..
DIRNAME=java/common/cstr/testPrograms
BUILD_DIRS =
JAVA_CLASSES = WaveTest PlayWave
NEED_JAVA=1
FILES = Makefile $(JAVA_CLASSES:=.java)
ALL = .java
-include ../../Makefile.version
include $(TOP)/config/common_make_rules

View File

@@ -0,0 +1,66 @@
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Centre for Speech Technology Research \\
// University of Edinburgh, UK \\
// Copyright (c) 1996,1997 \\
// All Rights Reserved. \\
// Permission is hereby granted, free of charge, to use and distribute \\
// this software and its documentation without restriction, including \\
// without limitation the rights to use, copy, modify, merge, publish, \\
// distribute, sublicense, and/or sell copies of this work, and to \\
// permit persons to whom this work is furnished to do so, subject to \\
// the following conditions: \\
// 1. The code must retain the above copyright notice, this list of \\
// conditions and the following disclaimer. \\
// 2. Any modifications must be clearly marked as such. \\
// 3. Original authors' names are not deleted. \\
// 4. The authors' names are not used to endorse or promote products \\
// derived from this software without specific prior written \\
// permission. \\
// THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK \\
// DISCLAIM ALL WARRANTIES With REGARD TO THIS SOFTWARE, INCLUDING \\
// ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT \\
// SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE \\
// FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES \\
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN \\
// AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, \\
// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF \\
// THIS SOFTWARE. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
// -------------------------------------------------------------------- \\
// Test program to play waveforms. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
package cstr.testPrograms;
import java.lang.*;
import java.util.*;
import java.io.*;
import java.awt.*;
import cstr.est.*;
public class PlayWave
{
public static void main(String [] args)
{
File file = new File(args[0]);
try {
Wave wv = new Wave(file);
wv.play();
} catch (Exception ex) {
System.out.println("Error: "+ex+" "+ex.getMessage());
ex.printStackTrace();
}
// If we get here play has finished, but stupid JMF
// has left threads running so the *%!%!%!*!* interpreter won't
// exit.
System.exit(0);
}
}

View File

@@ -0,0 +1,158 @@
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Centre for Speech Technology Research \\
// University of Edinburgh, UK \\
// Copyright (c) 1996,1997 \\
// All Rights Reserved. \\
// Permission is hereby granted, free of charge, to use and distribute \\
// this software and its documentation without restriction, including \\
// without limitation the rights to use, copy, modify, merge, publish, \\
// distribute, sublicense, and/or sell copies of this work, and to \\
// permit persons to whom this work is furnished to do so, subject to \\
// the following conditions: \\
// 1. The code must retain the above copyright notice, this list of \\
// conditions and the following disclaimer. \\
// 2. Any modifications must be clearly marked as such. \\
// 3. Original authors' names are not deleted. \\
// 4. The authors' names are not used to endorse or promote products \\
// derived from this software without specific prior written \\
// permission. \\
// THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK \\
// DISCLAIM ALL WARRANTIES With REGARD TO THIS SOFTWARE, INCLUDING \\
// ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT \\
// SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE \\
// FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES \\
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN \\
// AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, \\
// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF \\
// THIS SOFTWARE. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
// Date: Friday 12th September 1997 \\
// -------------------------------------------------------------------- \\
// Simple test program to see if wave class works. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
package cstr.testPrograms;
import java.awt.*;
import java.util.*;
import java.awt.event.*;
import java.awt.image.*;
import java.lang.*;
import java.io.*;
import cstr.awt.*;
import cstr.est.*;
import cstr.est.awt.*;
public class WaveTest
{
public static void useage(String com)
{
System.out.println("Useage: WaveTest FILENAME " + com);
System.exit(1);
}
public static int save(Wave wv, int pos, String[] args)
{
if (args.length - pos <3)
useage("save NEWFILENAME FORMAT");
try {
wv.save(args[pos+1], args[pos+2]);
} catch (IOException e) {
System.out.println("Save Error: " + e.getMessage());
System.exit(1);
}
return 3;
}
public static int display(Wave wv, int pos, String[] args)
{
if (args.length - pos <1)
useage("display");
ImageProducer prod = new WaveImageSource(wv, 0, 400, 500, 1500, 150);
ImageCanvas canvas = new ImageCanvas(prod);
ScrollWindow win = new ScrollWindow(wv.name(), canvas, 500, 250);
try {
win.setVisible(true);
} catch (AWTError e) {
System.out.println("Exit: " + e.getMessage());
}
return 1;
}
public static int resample(Wave wv, int pos, String[] args)
{
if (args.length - pos < 2)
useage("resample RATE");
int rate=0;
try {
rate = Integer.decode(args[pos+1]).intValue();
} catch (NumberFormatException e) {
System.out.println("Sample rate must be integer > 0 not " + args[pos+1]);
System.exit(1);
}
if (rate <= 0)
{
System.out.println("Sample rate must be > 0");
System.exit(1);
}
wv.resample(rate);
return 2;
}
public static void main(String [] args)
{
System.runFinalizersOnExit(true);
Wave wv = new Wave();
if (args.length < 1)
{
useage("COMMAND {ARGS...} ...");
return;
}
try {
wv.load(args[0]);
} catch (FileNotFoundException e) {
System.out.println("Load Error: " + e.getMessage());
return;
}
int pos=1;
while (pos < args.length)
{
if (args[pos].equals("save"))
pos += save(wv, pos, args);
else if (args[pos].equals("resample"))
pos += resample(wv, pos, args);
else if (args[pos].equals("display"))
pos += display(wv, pos, args);
else
useage("save/resample/display ...");
}
}
}

View File

@@ -0,0 +1,56 @@
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Centre for Speech Technology Research \\
// University of Edinburgh, UK \\
// Copyright (c) 1996,1997 \\
// All Rights Reserved. \\
// Permission is hereby granted, free of charge, to use and distribute \\
// this software and its documentation without restriction, including \\
// without limitation the rights to use, copy, modify, merge, publish, \\
// distribute, sublicense, and/or sell copies of this work, and to \\
// permit persons to whom this work is furnished to do so, subject to \\
// the following conditions: \\
// 1. The code must retain the above copyright notice, this list of \\
// conditions and the following disclaimer. \\
// 2. Any modifications must be clearly marked as such. \\
// 3. Original authors' names are not deleted. \\
// 4. The authors' names are not used to endorse or promote products \\
// derived from this software without specific prior written \\
// permission. \\
// THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK \\
// DISCLAIM ALL WARRANTIES With REGARD TO THIS SOFTWARE, INCLUDING \\
// ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT \\
// SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE \\
// FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES \\
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN \\
// AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, \\
// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF \\
// THIS SOFTWARE. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
// -------------------------------------------------------------------- \\
// Exception thrown when an attempt to look for a value which is not \\
// in an Enum. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
package cstr.util ;
import java.lang.*;
public class BadValueException extends Exception
{
public BadValueException()
{
super();
}
public BadValueException(String m)
{
super(m);
}
}

View File

@@ -0,0 +1,117 @@
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Centre for Speech Technology Research \\
// University of Edinburgh, UK \\
// Copyright (c) 1996,1997 \\
// All Rights Reserved. \\
// Permission is hereby granted, free of charge, to use and distribute \\
// this software and its documentation without restriction, including \\
// without limitation the rights to use, copy, modify, merge, publish, \\
// distribute, sublicense, and/or sell copies of this work, and to \\
// permit persons to whom this work is furnished to do so, subject to \\
// the following conditions: \\
// 1. The code must retain the above copyright notice, this list of \\
// conditions and the following disclaimer. \\
// 2. Any modifications must be clearly marked as such. \\
// 3. Original authors' names are not deleted. \\
// 4. The authors' names are not used to endorse or promote products \\
// derived from this software without specific prior written \\
// permission. \\
// THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK \\
// DISCLAIM ALL WARRANTIES With REGARD TO THIS SOFTWARE, INCLUDING \\
// ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT \\
// SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE \\
// FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES \\
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN \\
// AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, \\
// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF \\
// THIS SOFTWARE. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
// -------------------------------------------------------------------- \\
// Simple Enumerated type superclass. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
package cstr.util ;
import java.lang.*;
import java.util.*;
import java.awt.*;
public abstract class Enum
{
String name;
String longName;
Object info;
int index;
abstract public EnumValues getValuesTable();
protected static EnumValues init(String n)
{
return new EnumValues(n);
}
protected Enum(String s, String ls, Object o)
{
setup(s, ls, o);
}
protected Enum(String s, String ls, boolean real)
{
setup(s, ls, real?null:Enum.class);
}
protected void setup(String s, String ls, Object o)
{
name=s;
longName=ls;
info=o;
EnumValues values = getValuesTable();
index=values.add(this);
}
protected void alias(String a)
{
EnumValues values = getValuesTable();
values.add(this, a);
}
protected static Enum getValue(String s, EnumValues values)
throws IllegalArgumentException
{
return values.getValue(s);
}
protected static Object getValues(EnumValues values)
{
return (Object)values.getValues();
}
public boolean isReal()
{
return info != Enum.class;
}
public String toString()
{
return name;
}
public String toString(boolean lng)
{
return lng?longName:name;
}
public Object getInfo()
{
return info;
}
}

View File

@@ -0,0 +1,103 @@
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Centre for Speech Technology Research \\
// University of Edinburgh, UK \\
// Copyright (c) 1996,1997 \\
// All Rights Reserved. \\
// Permission is hereby granted, free of charge, to use and distribute \\
// this software and its documentation without restriction, including \\
// without limitation the rights to use, copy, modify, merge, publish, \\
// distribute, sublicense, and/or sell copies of this work, and to \\
// permit persons to whom this work is furnished to do so, subject to \\
// the following conditions: \\
// 1. The code must retain the above copyright notice, this list of \\
// conditions and the following disclaimer. \\
// 2. Any modifications must be clearly marked as such. \\
// 3. Original authors' names are not deleted. \\
// 4. The authors' names are not used to endorse or promote products \\
// derived from this software without specific prior written \\
// permission. \\
// THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK \\
// DISCLAIM ALL WARRANTIES With REGARD TO THIS SOFTWARE, INCLUDING \\
// ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT \\
// SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE \\
// FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES \\
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN \\
// AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, \\
// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF \\
// THIS SOFTWARE. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
// -------------------------------------------------------------------- \\
// Mechanics of an enumerated type. Wrapped in a class for inheritance \\
// purposes. NOte this is a public class all of whose mechanics are \\
// package local, we can get hold of these from anywhere, but can't \\
// do a thing with them, in fact only cstr.util.Enum is supposed to go \\
// near this. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
package cstr.util ;
import java.lang.*;
import java.util.*;
public class EnumValues
{
protected String name;
protected Hashtable table;
protected int n;
protected Enum [] values=null;
EnumValues(String n)
{
name=n;
table=new Hashtable();
}
int add(Enum v)
{
table.put(v.toString(),
v);
table.put(v.toString(true),
v);
if (v.info != Enum.class)
return n++;
else
return -1;
}
void add(Enum v, String a)
{
table.put(a,v);
}
Enum getValue(String s)
throws IllegalArgumentException
{
Enum v = (Enum)table.get(s);
if (v==null)
throw new IllegalArgumentException(name+":"+s);
return v;
}
Enum [] getValues()
{
if (values == null)
{
values = new Enum[n];
Enumeration vs = table.elements();
while (vs.hasMoreElements())
{
Enum e = (Enum)vs.nextElement();
if (e.index >=0)
values[e.index] = e;
}
}
return values;
}
}

View File

@@ -0,0 +1,46 @@
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Centre for Speech Technology Research \\
// University of Edinburgh, UK \\
// Copyright (c) 1996,1997 \\
// All Rights Reserved. \\
// Permission is hereby granted, free of charge, to use and distribute \\
// this software and its documentation without restriction, including \\
// without limitation the rights to use, copy, modify, merge, publish, \\
// distribute, sublicense, and/or sell copies of this work, and to \\
// permit persons to whom this work is furnished to do so, subject to \\
// the following conditions: \\
// 1. The code must retain the above copyright notice, this list of \\
// conditions and the following disclaimer. \\
// 2. Any modifications must be clearly marked as such. \\
// 3. Original authors' names are not deleted. \\
// 4. The authors' names are not used to endorse or promote products \\
// derived from this software without specific prior written \\
// permission. \\
// THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK \\
// DISCLAIM ALL WARRANTIES With REGARD TO THIS SOFTWARE, INCLUDING \\
// ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT \\
// SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE \\
// FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES \\
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN \\
// AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, \\
// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF \\
// THIS SOFTWARE. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
// -------------------------------------------------------------------- \\
// Interface just for something with a name. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
package cstr.util;
import java.lang.*;
public interface Featured
{
public String getFeature(String n);
}

View File

@@ -0,0 +1,50 @@
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Centre for Speech Technology Research \\
// University of Edinburgh, UK \\
// Copyright (c) 1996,1997 \\
// All Rights Reserved. \\
// Permission is hereby granted, free of charge, to use and distribute \\
// this software and its documentation without restriction, including \\
// without limitation the rights to use, copy, modify, merge, publish, \\
// distribute, sublicense, and/or sell copies of this work, and to \\
// permit persons to whom this work is furnished to do so, subject to \\
// the following conditions: \\
// 1. The code must retain the above copyright notice, this list of \\
// conditions and the following disclaimer. \\
// 2. Any modifications must be clearly marked as such. \\
// 3. Original authors' names are not deleted. \\
// 4. The authors' names are not used to endorse or promote products \\
// derived from this software without specific prior written \\
// permission. \\
// THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK \\
// DISCLAIM ALL WARRANTIES With REGARD TO THIS SOFTWARE, INCLUDING \\
// ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT \\
// SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE \\
// FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES \\
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN \\
// AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, \\
// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF \\
// THIS SOFTWARE. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
// -------------------------------------------------------------------- \\
// Something which can paint of course. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
package cstr.util ;
import java.lang.*;
import java.util.*;
import java.awt.*;
import java.awt.image.*;
public interface ImagePainter extends Painter
{
public ImageProducer make_image(Rectangle r);
}

View File

@@ -0,0 +1,47 @@
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Centre for Speech Technology Research \\
// University of Edinburgh, UK \\
// Copyright (c) 1996,1997 \\
// All Rights Reserved. \\
// Permission is hereby granted, free of charge, to use and distribute \\
// this software and its documentation without restriction, including \\
// without limitation the rights to use, copy, modify, merge, publish, \\
// distribute, sublicense, and/or sell copies of this work, and to \\
// permit persons to whom this work is furnished to do so, subject to \\
// the following conditions: \\
// 1. The code must retain the above copyright notice, this list of \\
// conditions and the following disclaimer. \\
// 2. Any modifications must be clearly marked as such. \\
// 3. Original authors' names are not deleted. \\
// 4. The authors' names are not used to endorse or promote products \\
// derived from this software without specific prior written \\
// permission. \\
// THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK \\
// DISCLAIM ALL WARRANTIES With REGARD TO THIS SOFTWARE, INCLUDING \\
// ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT \\
// SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE \\
// FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES \\
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN \\
// AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, \\
// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF \\
// THIS SOFTWARE. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
// -------------------------------------------------------------------- \\
// Interface just for something with a unique key. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
package cstr.util;
import java.lang.*;
public interface Keyed
{
public Object getKey();
}

View File

@@ -0,0 +1,109 @@
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Centre for Speech Technology Research \\
// University of Edinburgh, UK \\
// Copyright (c) 1996,1997 \\
// All Rights Reserved. \\
// Permission is hereby granted, free of charge, to use and distribute \\
// this software and its documentation without restriction, including \\
// without limitation the rights to use, copy, modify, merge, publish, \\
// distribute, sublicense, and/or sell copies of this work, and to \\
// permit persons to whom this work is furnished to do so, subject to \\
// the following conditions: \\
// 1. The code must retain the above copyright notice, this list of \\
// conditions and the following disclaimer. \\
// 2. Any modifications must be clearly marked as such. \\
// 3. Original authors' names are not deleted. \\
// 4. The authors' names are not used to endorse or promote products \\
// derived from this software without specific prior written \\
// permission. \\
// THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK \\
// DISCLAIM ALL WARRANTIES With REGARD TO THIS SOFTWARE, INCLUDING \\
// ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT \\
// SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE \\
// FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES \\
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN \\
// AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, \\
// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF \\
// THIS SOFTWARE. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
// -------------------------------------------------------------------- \\
// Like a Hashtable but for keys of type long. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
package cstr.util ;
import java.lang.*;
import java.util.*;
public final class LongHash
{
LongBucket [] buckets;
public LongHash()
{
this(20);
}
public LongHash(int n)
{
buckets = new LongBucket[n];
}
private void debugDump()
{
System.out.println("");
for(int i=0; i<buckets.length; i++)
{
int n=0;
for(LongBucket bk=buckets[i]; bk!=null; bk=bk.next)
n++;
System.out.print("["+n+"]");
}
System.out.println("");
}
public void put(long k, Object v)
{
int b = doHash(k, buckets.length);
buckets[b] = new LongBucket(k, v, buckets[b]);
// debugDump();
}
public Object get(long k)
{
int b = doHash(k, buckets.length);
for(LongBucket bk=buckets[b]; bk!=null; bk=bk.next)
if (bk.key==k)
return bk.value;
return null;
}
private int doHash(long k, int l)
{
return (int)((k>>4)%l);
}
private final class LongBucket
{
long key;
Object value;
LongBucket next;
public LongBucket(long k, Object v, LongBucket n)
{
key=k;
value=v;
next=n;
}
}
}

View File

@@ -0,0 +1,48 @@
###########################################################################
## ##
## Centre for Speech Technology Research ##
## University of Edinburgh, UK ##
## Copyright (c) 1996 ##
## All Rights Reserved. ##
## ##
## Permission is hereby granted, free of charge, to use and distribute ##
## this software and its documentation without restriction, including ##
## without limitation the rights to use, copy, modify, merge, publish, ##
## distribute, sublicense, and/or sell copies of this work, and to ##
## permit persons to whom this work is furnished to do so, subject to ##
## the following conditions: ##
## 1. The code must retain the above copyright notice, this list of ##
## conditions and the following disclaimer. ##
## 2. Any modifications must be clearly marked as such. ##
## 3. Original authors' names are not deleted. ##
## 4. The authors' names are not used to endorse or promote products ##
## derived from this software without specific prior written ##
## permission. ##
## ##
## THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK ##
## DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ##
## ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT ##
## SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE ##
## FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ##
## WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN ##
## AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ##
## ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF ##
## THIS SOFTWARE. ##
## ##
###########################################################################
TOP=../../../..
DIRNAME=java/common/cstr/util
BUILD_DIRS =
JAVA_CLASSES = SparseArray LongHash Featured Named Keyed \
TraceStream Trace Painter ImagePainter PaintPainter PaintCache \
BadValueException EnumValues Enum
FILES = Makefile $(JAVA_CLASSES:=.java)
ALL = .java
-include ../../Makefile.version
include $(TOP)/config/common_make_rules

View File

@@ -0,0 +1,47 @@
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Centre for Speech Technology Research \\
// University of Edinburgh, UK \\
// Copyright (c) 1996,1997 \\
// All Rights Reserved. \\
// Permission is hereby granted, free of charge, to use and distribute \\
// this software and its documentation without restriction, including \\
// without limitation the rights to use, copy, modify, merge, publish, \\
// distribute, sublicense, and/or sell copies of this work, and to \\
// permit persons to whom this work is furnished to do so, subject to \\
// the following conditions: \\
// 1. The code must retain the above copyright notice, this list of \\
// conditions and the following disclaimer. \\
// 2. Any modifications must be clearly marked as such. \\
// 3. Original authors' names are not deleted. \\
// 4. The authors' names are not used to endorse or promote products \\
// derived from this software without specific prior written \\
// permission. \\
// THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK \\
// DISCLAIM ALL WARRANTIES With REGARD TO THIS SOFTWARE, INCLUDING \\
// ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT \\
// SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE \\
// FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES \\
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN \\
// AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, \\
// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF \\
// THIS SOFTWARE. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
// -------------------------------------------------------------------- \\
// Interface just for something with a name. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
package cstr.util;
import java.lang.*;
public interface Named
{
public String getName();
public void setName(String Name);
}

View File

@@ -0,0 +1,402 @@
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Centre for Speech Technology Research \\
// University of Edinburgh, UK \\
// Copyright (c) 1996,1997 \\
// All Rights Reserved. \\
// Permission is hereby granted, free of charge, to use and distribute \\
// this software and its documentation without restriction, including \\
// without limitation the rights to use, copy, modify, merge, publish, \\
// distribute, sublicense, and/or sell copies of this work, and to \\
// permit persons to whom this work is furnished to do so, subject to \\
// the following conditions: \\
// 1. The code must retain the above copyright notice, this list of \\
// conditions and the following disclaimer. \\
// 2. Any modifications must be clearly marked as such. \\
// 3. Original authors' names are not deleted. \\
// 4. The authors' names are not used to endorse or promote products \\
// derived from this software without specific prior written \\
// permission. \\
// THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK \\
// DISCLAIM ALL WARRANTIES With REGARD TO THIS SOFTWARE, INCLUDING \\
// ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT \\
// SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE \\
// FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES \\
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN \\
// AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, \\
// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF \\
// THIS SOFTWARE. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
// -------------------------------------------------------------------- \\
// An abstration which stands between a component and the AWT to cache \\
// the information painted in an array of images. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
package cstr.util ;
import java.lang.*;
import java.util.*;
import java.awt.*;
import java.awt.image.*;
public class PaintCache
{
protected Image [] chunks;
protected Thread [] threads;
protected int chunkSize;
protected int numChunks;
protected Painter painter;
protected Component comp;
protected int width;
protected int height;
protected int running;
protected int topPriority;
Image dummy;
public PaintCache(Component c, Painter p)
{
this(c, p, 400);
}
public PaintCache(Component c, Painter p, int cs)
{
comp=c;
painter=p;
chunkSize=cs;
chunks=null;
running=0;
topPriority=Thread.currentThread().getPriority()-1;
}
protected void finalize()
{
if (threads!=null)
for(int i=0; i<threads.length; i++)
if (threads[i]!= null)
threads[i].stop();
}
public synchronized void updated(int w, int h)
{
if (w != width || h != height)
{
width = w;
height = h;
if (threads!=null)
for(int i=0; i<threads.length; i++)
if (threads[i]!= null)
threads[i].stop();
running=0;
numChunks = w / chunkSize+1;
if (numChunks*chunkSize < w)
numChunks++;
chunks = new Image[numChunks+1];
threads = new Thread[numChunks+1];
dummy = comp.createImage(chunkSize, height);
Graphics ig = dummy.getGraphics();
ig.setColor(Color.red);
ig.drawLine(0,0,chunkSize,height);
ig.drawLine(0,height,chunkSize,0);
}
}
protected synchronized Image dummyImage()
{
return dummy;
}
protected synchronized void dumpP()
{
System.out.print("Threads: ");
for(int i=0; i<threads.length; i++)
if (threads[i]!= null && threads[i].isAlive())
System.out.print(threads[i].getPriority());
else
System.out.print("_");
System.out.println("");
}
public synchronized void zap(int i)
{
if (i<threads.length && threads[i] == Thread.currentThread())
{
int op=threads[i].getPriority();
threads[i]=null;
int maxi=-1, max=0;
for(int ti=0; ti<threads.length; ti++)
if (threads[ti]!= null && threads[ti].isAlive())
{
int p = threads[ti].getPriority();
// if (p>Thread.MIN_PRIORITY && p < op)
//threads[ti].setPriority(p+1);
if (p>max)
{
max=p;
maxi=ti;
}
}
if (maxi>=0)
{
// System.out.println("top="+maxi+"="+topPriority);
threads[maxi].setPriority(topPriority);
}
// dumpP();
}
}
protected synchronized void checkChunk(int i, Graphics g)
{
if (i<chunks.length)
{
if (chunks[i] == null)
{
if (painter instanceof ImagePainter)
{
ImagePainter ipainter = (ImagePainter)painter;
chunks[i] = dummy;
Rectangle r = new Rectangle(i*chunkSize, 0,
chunkSize, height);
Thread pt = new Thread(new IPaintingThread(i,
ipainter,
r,
this,
g,
chunkSize,
height));
threads[i]=pt;
pt.start();
pt.setPriority(Thread.MIN_PRIORITY);
}
else
{
PaintPainter ppainter = (PaintPainter)painter;
chunks[i] = comp.createImage(chunkSize, height);
Graphics ig = chunks[i].getGraphics();
ig.setColor(Color.red);
ig.drawLine(0,0,chunkSize,height);
ig.drawLine(0,height,chunkSize,0);
ig.setColor(g.getColor());
Rectangle r = new Rectangle(i*chunkSize, 0, chunkSize, height);
Thread pt = new Thread(new PaintingThread(i,
ppainter,
r,
ig,
this,
g,
chunkSize,
height));
threads[i]=pt;
pt.start();
pt.setPriority(Thread.MIN_PRIORITY);
}
}
else if (threads[i] != null && threads[i].isAlive())
{
for(int ti=0; ti<threads.length; ti++)
{
Thread t = threads[ti];
if (t != null && t.isAlive())
{
int p;
if (i!=ti)
{
int op = t.getPriority();
if (op> Thread.MIN_PRIORITY)
// p= topPriority-1;
p= Thread.MIN_PRIORITY+1;
else
p =Thread.MIN_PRIORITY;
}
else
p = topPriority;
// p = Thread.MAX_PRIORITY;
if (p>=Thread.MIN_PRIORITY)
t.setPriority(p);
}
}
// dumpP();
}
}
}
public void paint(Graphics g)
{
Rectangle r = g.getClipBounds();
int c1 = r.x / chunkSize;
int cn = (r.x+r.width) / chunkSize;
if (cn >= chunks.length)
cn = chunks.length-1;
if ( c1 == cn)
{
checkChunk(c1, g);
int ix = r.x % chunkSize;
g.drawImage(chunks[c1],
r.x, r.y, r.x+r.width, r.y+r.height,
ix, r.y, ix+r.width, r.y+r.height,
comp);
}
else
{
int ix = r.x % chunkSize;
int wx = r.x;
int w = chunkSize - ix;
checkChunk(c1, g);
g.drawImage(chunks[c1],
wx, r.y, wx+w, r.y+r.height,
ix, r.y, ix+w, r.y+r.height,
comp);
for(int c = c1+1; c < cn; c++)
{
ix = 0;
wx = c * chunkSize;
w = chunkSize;
checkChunk(c, g);
g.drawImage(chunks[c],
wx, r.y, wx+w, r.y+r.height,
ix, r.y, ix+w, r.y+r.height,
comp);
}
ix = 0;
wx = cn * chunkSize;
w = (r.x + r.width) % chunkSize;
checkChunk(cn, g);
g.drawImage(chunks[cn],
wx, r.y, wx+w, r.y+r.height,
ix, r.y, ix+w, r.y+r.height,
comp);
}
}
protected synchronized void blit(Graphics g, int i)
{
g.setClip(0,0, width, height);
if (i<chunks.length)
g.drawImage(chunks[i],
i*chunkSize, 0,
Color.green,
null);
}
class PaintingThread implements Runnable
{
int index;
PaintPainter painter;
Rectangle rect;
Graphics ig;
PaintCache parent;
Graphics g;
int w,h;
public PaintingThread(int i,
PaintPainter i_painter,
Rectangle i_rect,
Graphics i_ig,
PaintCache i_parent,
Graphics i_g,
int i_w,
int i_h)
{
index=i;
painter=i_painter;
rect=i_rect;
ig=i_ig.create();
parent=i_parent;
g=i_g.create();
w=i_w;
h=i_h;
}
public void run()
{
// System.out.println("start "+rect.x);
painter.real_paint(ig, rect);
Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
parent.zap(index);
parent.blit(g, index);
// System.out.println("end "+rect.x);
}
}
class IPaintingThread implements Runnable
{
int index;
ImagePainter painter;
Rectangle rect;
PaintCache parent;
Graphics g;
int w,h;
public IPaintingThread(int i,
ImagePainter i_painter,
Rectangle i_rect,
PaintCache i_parent,
Graphics i_g,
int i_w,
int i_h)
{
index=i;
painter=i_painter;
rect=i_rect;
parent=i_parent;
g=i_g.create();
w=i_w;
h=i_h;
}
public void run()
{
ImageProducer src = painter.make_image(rect);
if (src==null)
chunks[index] = parent.dummyImage();
else
chunks[index] = comp.createImage(src);
Thread.currentThread().setPriority(Thread.MAX_PRIORITY);
parent.zap(index);
parent.blit(g, index);
// System.out.println("end "+rect.x);
}
}
}

View File

@@ -0,0 +1,50 @@
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Centre for Speech Technology Research \\
// University of Edinburgh, UK \\
// Copyright (c) 1996,1997 \\
// All Rights Reserved. \\
// Permission is hereby granted, free of charge, to use and distribute \\
// this software and its documentation without restriction, including \\
// without limitation the rights to use, copy, modify, merge, publish, \\
// distribute, sublicense, and/or sell copies of this work, and to \\
// permit persons to whom this work is furnished to do so, subject to \\
// the following conditions: \\
// 1. The code must retain the above copyright notice, this list of \\
// conditions and the following disclaimer. \\
// 2. Any modifications must be clearly marked as such. \\
// 3. Original authors' names are not deleted. \\
// 4. The authors' names are not used to endorse or promote products \\
// derived from this software without specific prior written \\
// permission. \\
// THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK \\
// DISCLAIM ALL WARRANTIES With REGARD TO THIS SOFTWARE, INCLUDING \\
// ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT \\
// SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE \\
// FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES \\
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN \\
// AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, \\
// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF \\
// THIS SOFTWARE. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
// -------------------------------------------------------------------- \\
// Something which can paint of course. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
package cstr.util ;
import java.lang.*;
import java.util.*;
import java.awt.*;
import java.awt.image.*;
public interface PaintPainter extends Painter
{
public void real_paint(Graphics g, Rectangle r);
}

View File

@@ -0,0 +1,49 @@
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Centre for Speech Technology Research \\
// University of Edinburgh, UK \\
// Copyright (c) 1996,1997 \\
// All Rights Reserved. \\
// Permission is hereby granted, free of charge, to use and distribute \\
// this software and its documentation without restriction, including \\
// without limitation the rights to use, copy, modify, merge, publish, \\
// distribute, sublicense, and/or sell copies of this work, and to \\
// permit persons to whom this work is furnished to do so, subject to \\
// the following conditions: \\
// 1. The code must retain the above copyright notice, this list of \\
// conditions and the following disclaimer. \\
// 2. Any modifications must be clearly marked as such. \\
// 3. Original authors' names are not deleted. \\
// 4. The authors' names are not used to endorse or promote products \\
// derived from this software without specific prior written \\
// permission. \\
// THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK \\
// DISCLAIM ALL WARRANTIES With REGARD TO THIS SOFTWARE, INCLUDING \\
// ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT \\
// SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE \\
// FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES \\
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN \\
// AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, \\
// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF \\
// THIS SOFTWARE. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
// -------------------------------------------------------------------- \\
// Something which can paint of course. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
package cstr.util ;
import java.lang.*;
import java.util.*;
import java.awt.*;
public interface Painter
{
public void paint(Graphics g);
}

View File

@@ -0,0 +1,103 @@
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Centre for Speech Technology Research \\
// University of Edinburgh, UK \\
// Copyright (c) 1996,1997 \\
// All Rights Reserved. \\
// Permission is hereby granted, free of charge, to use and distribute \\
// this software and its documentation without restriction, including \\
// without limitation the rights to use, copy, modify, merge, publish, \\
// distribute, sublicense, and/or sell copies of this work, and to \\
// permit persons to whom this work is furnished to do so, subject to \\
// the following conditions: \\
// 1. The code must retain the above copyright notice, this list of \\
// conditions and the following disclaimer. \\
// 2. Any modifications must be clearly marked as such. \\
// 3. Original authors' names are not deleted. \\
// 4. The authors' names are not used to endorse or promote products \\
// derived from this software without specific prior written \\
// permission. \\
// THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK \\
// DISCLAIM ALL WARRANTIES With REGARD TO THIS SOFTWARE, INCLUDING \\
// ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT \\
// SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE \\
// FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES \\
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN \\
// AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, \\
// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF \\
// THIS SOFTWARE. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
// Date: Tue Feb 17 1998 \\
// -------------------------------------------------------------------- \\
// An array with only a few entries. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
package cstr.util ;
import java.lang.*;
import java.util.*;
import java.awt.*;
public class SparseArray
{
int [] keys;
Object [] vals;
int used;
int size;
public SparseArray(int initn)
{
used=0;
size = initn;
keys = new int[size];
vals = new Object[size];
}
public SparseArray()
{
this(10);
}
public void put(int n, Object v)
{
for(int i=0; i<used; i++)
if (keys[i] == n)
{
vals[i] = v;
return;
}
if (used == size)
{
size+=10;
int [] newk = new int[size];
Object [] newv = new Object[size];
for(int j=0; j<used; j++)
{
newk[j] = keys[j];
newv[j] = vals[j];
}
keys=newk;
vals=newv;
}
keys[used] = n;
vals[used] = v;
used++;
}
public Object get(int n)
{
for(int i=0; i<used; i++)
if (keys[i] == n)
return vals[i];
return null;
}
}

View File

@@ -0,0 +1,163 @@
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Centre for Speech Technology Research \\
// University of Edinburgh, UK \\
// Copyright (c) 1996,1997 \\
// All Rights Reserved. \\
// Permission is hereby granted, free of charge, to use and distribute \\
// this software and its documentation without restriction, including \\
// without limitation the rights to use, copy, modify, merge, publish, \\
// distribute, sublicense, and/or sell copies of this work, and to \\
// permit persons to whom this work is furnished to do so, subject to \\
// the following conditions: \\
// 1. The code must retain the above copyright notice, this list of \\
// conditions and the following disclaimer. \\
// 2. Any modifications must be clearly marked as such. \\
// 3. Original authors' names are not deleted. \\
// 4. The authors' names are not used to endorse or promote products \\
// derived from this software without specific prior written \\
// permission. \\
// THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK \\
// DISCLAIM ALL WARRANTIES With REGARD TO THIS SOFTWARE, INCLUDING \\
// ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT \\
// SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE \\
// FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES \\
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN \\
// AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, \\
// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF \\
// THIS SOFTWARE. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
// -------------------------------------------------------------------- \\
// Simple Trace package. Multiple tracing streams which can be turned \\
// on and off. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
package cstr.util ;
import java.lang.*;
import java.util.*;
import java.awt.*;
public final class Trace
{
protected static Hashtable streams= new Hashtable(5);
protected static boolean enabled=false;
protected static TraceStream def_st;
static {
init("Trace");
def_st=(TraceStream)streams.get("Trace");
def_st.setOn(true);
}
public static void init(String which)
{
StringTokenizer tok = new StringTokenizer(which, ",");
while (tok.hasMoreElements())
{
String name=tok.nextToken();
streams.put(name, new TraceStream(name, false, false));
}
}
public static void setEnable(boolean e)
{
enabled=e;
}
public static void setOn(String which, boolean o)
{
TraceStream st=(TraceStream)streams.get(which);
if (st!=null)
{
st.setOn(o);
if (o)
enabled=true;
}
else
{
pl("Unknown Trace Stream "+which);
}
}
public static void setOn(boolean o)
{
def_st.setOn(o);
if (o)
enabled=true;
}
public static void setSave(String which, boolean s)
{
TraceStream st=(TraceStream)streams.get(which);
if (st!=null)
st.setSave(s);
else
{
p("Unknown Trace Stream "+which);
nl();
}
}
public static void setSave(boolean s)
{
def_st.setSave(s);
}
public static void p(String which, String what)
{
if (enabled)
{
TraceStream st=(TraceStream)streams.get(which);
if (st==null)
st = def_st;
st.p(what);
}
}
public static void pl(String which, String what)
{
if (enabled)
{
TraceStream st=(TraceStream)streams.get(which);
if (st==null)
st = def_st;
st.pl(what);
}
}
public static void nl(String which)
{
if (enabled)
{
TraceStream st=(TraceStream)streams.get(which);
if (st==null)
st = def_st;
st.nl();
}
}
public static void p(String what)
{
def_st.print(what);
}
public static void pl(String what)
{
def_st.pl(what);
}
public static void nl()
{
def_st.nl();
}
}

View File

@@ -0,0 +1,130 @@
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Centre for Speech Technology Research \\
// University of Edinburgh, UK \\
// Copyright (c) 1996,1997 \\
// All Rights Reserved. \\
// Permission is hereby granted, free of charge, to use and distribute \\
// this software and its documentation without restriction, including \\
// without limitation the rights to use, copy, modify, merge, publish, \\
// distribute, sublicense, and/or sell copies of this work, and to \\
// permit persons to whom this work is furnished to do so, subject to \\
// the following conditions: \\
// 1. The code must retain the above copyright notice, this list of \\
// conditions and the following disclaimer. \\
// 2. Any modifications must be clearly marked as such. \\
// 3. Original authors' names are not deleted. \\
// 4. The authors' names are not used to endorse or promote products \\
// derived from this software without specific prior written \\
// permission. \\
// THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK \\
// DISCLAIM ALL WARRANTIES With REGARD TO THIS SOFTWARE, INCLUDING \\
// ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT \\
// SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE \\
// FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES \\
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN \\
// AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, \\
// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF \\
// THIS SOFTWARE. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
// -------------------------------------------------------------------- \\
// A single stream of trace output. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
package cstr.util ;
import java.lang.*;
import java.util.*;
import java.awt.*;
// Record for a single stream
public final class TraceStream
{
protected String name;
protected boolean off;
protected boolean bol;
protected Vector saved;
public TraceStream(String n)
{
this(n, false, false);
}
public TraceStream(String n, boolean o, boolean s)
{
name=n;
setOn(o);
setSave(s);
bol=true;
Trace.streams.put(name, this);
}
public void setOn(boolean o)
{
off=!o;
}
public void setSave(boolean s)
{
if (s && saved==null)
saved=new Vector(5);
if (!s && saved != null)
{
Vector pending=saved;
saved=null;
for(int i=0; i<pending.size(); i++)
print((String)pending.elementAt(i));
}
}
public void print(String s)
{
if (off) return;
if (bol)
{
bol=false;
print(name);
print(": ");
}
if (saved!=null)
saved.addElement(s);
else
{
System.out.print(s);
if (s.endsWith("\n"))
bol=true;
}
}
public void nl()
{
if (Trace.enabled)
print("\n");
}
public void p(String what)
{
if (Trace.enabled)
print(what);
}
public void pl(String what)
{
if (Trace.enabled)
{
print(what);
nl();
}
}
}

47
java/cpp_version/Makefile Normal file
View File

@@ -0,0 +1,47 @@
###########################################################################
## ##
## Centre for Speech Technology Research ##
## University of Edinburgh, UK ##
## Copyright (c) 1996 ##
## All Rights Reserved. ##
## ##
## Permission is hereby granted, free of charge, to use and distribute ##
## this software and its documentation without restriction, including ##
## without limitation the rights to use, copy, modify, merge, publish, ##
## distribute, sublicense, and/or sell copies of this work, and to ##
## permit persons to whom this work is furnished to do so, subject to ##
## the following conditions: ##
## 1. The code must retain the above copyright notice, this list of ##
## conditions and the following disclaimer. ##
## 2. Any modifications must be clearly marked as such. ##
## 3. Original authors' names are not deleted. ##
## 4. The authors' names are not used to endorse or promote products ##
## derived from this software without specific prior written ##
## permission. ##
## ##
## THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK ##
## DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ##
## ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT ##
## SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE ##
## FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ##
## WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN ##
## AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ##
## ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF ##
## THIS SOFTWARE. ##
## ##
###########################################################################
TOP=../..
DIRNAME=java/cpp_version
FILES = Makefile Makefile.version
BUILD_DIRS=cstr
NEED_JAVA=true
ALL = .sub_directories .javalib
include $(TOP)/config/common_make_rules
-include Makefile.version

View File

@@ -0,0 +1,42 @@
###########################################################################
## ##
## Centre for Speech Technology Research ##
## University of Edinburgh, UK ##
## Copyright (c) 1996 ##
## All Rights Reserved. ##
## ##
## Permission is hereby granted, free of charge, to use and distribute ##
## this software and its documentation without restriction, including ##
## without limitation the rights to use, copy, modify, merge, publish, ##
## distribute, sublicense, and/or sell copies of this work, and to ##
## permit persons to whom this work is furnished to do so, subject to ##
## the following conditions: ##
## 1. The code must retain the above copyright notice, this list of ##
## conditions and the following disclaimer. ##
## 2. Any modifications must be clearly marked as such. ##
## 3. Original authors' names are not deleted. ##
## 4. The authors' names are not used to endorse or promote products ##
## derived from this software without specific prior written ##
## permission. ##
## ##
## THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK ##
## DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ##
## ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT ##
## SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE ##
## FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ##
## WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN ##
## AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ##
## ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF ##
## THIS SOFTWARE. ##
## ##
###########################################################################
## Suplimental make information for this version
CODE_VERSION=cpp
LOCAL_JAVA_CLASS_LIBRARY=$(TOP)/lib/est_$(CODE_VERSION).jar
LOCAL_JAVA_CLASSPATH=$(EST_HOME)/speech_tools/lib/est_$(CODE_VERSION).jar
JAVA_TOP_PACK=cstr
LOCAL_JAVA_ROOT=$(TOP)/java/$(CODE_VERSION)_version_build

View File

@@ -0,0 +1,51 @@
###########################################################################
## ##
## Centre for Speech Technology Research ##
## University of Edinburgh, UK ##
## Copyright (c) 1996 ##
## All Rights Reserved. ##
## ##
## Permission is hereby granted, free of charge, to use and distribute ##
## this software and its documentation without restriction, including ##
## without limitation the rights to use, copy, modify, merge, publish, ##
## distribute, sublicense, and/or sell copies of this work, and to ##
## permit persons to whom this work is furnished to do so, subject to ##
## the following conditions: ##
## 1. The code must retain the above copyright notice, this list of ##
## conditions and the following disclaimer. ##
## 2. Any modifications must be clearly marked as such. ##
## 3. Original authors' names are not deleted. ##
## 4. The authors' names are not used to endorse or promote products ##
## derived from this software without specific prior written ##
## permission. ##
## ##
## THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK ##
## DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ##
## ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT ##
## SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE ##
## FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ##
## WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN ##
## AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ##
## ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF ##
## THIS SOFTWARE. ##
## ##
###########################################################################
TOP=../../..
DIRNAME=java/cpp_version/cstr
ALL_DIRS = est
BUILD_DIRS = awt est util testPrograms
NEED_JAVA = true
FILES = Makefile
ALL = .sub_directories
-include ../../../Makefile.version
include $(TOP)/config/common_make_rules

View File

@@ -0,0 +1,278 @@
/*************************************************************************/
/* */
/* Centre for Speech Technology Research */
/* University of Edinburgh, UK */
/* Copyright (c) 1995,1996 */
/* All Rights Reserved. */
/* */
/* Permission is hereby granted, free of charge, to use and distribute */
/* this software and its documentation without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of this work, and to */
/* permit persons to whom this work is furnished to do so, subject to */
/* the following conditions: */
/* 1. The code must retain the above copyright notice, this list of */
/* conditions and the following disclaimer. */
/* 2. Any modifications must be clearly marked as such. */
/* 3. Original authors' names are not deleted. */
/* 4. The authors' names are not used to endorse or promote products */
/* derived from this software without specific prior written */
/* permission. */
/* */
/* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */
/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
/* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */
/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
/* THIS SOFTWARE. */
/* */
/*************************************************************************/
/* */
/* Author: Richard Caley <rjc@cstr.ed.ac.uk> */
/* ------------------------------------------------------------------- */
/* Interface between java and C++ for EST_Features. */
/* */
/*************************************************************************/
#include <stdio.h>
#include "jni_Features.h"
#include "EST_Features.h"
static jclass features_class;
static jmethodID features_cons;
static jclass string_class;
static jclass float_class;
static jmethodID float_cons;
static jclass int_class;
static jmethodID int_cons;
static jfieldID handle_field;
static inline short abs(short s) { return s>0?s:-s; }
JNIEXPORT jboolean JNICALL
Java_cstr_est_Features_initialise_1cpp (JNIEnv *env, jclass myclass)
{
features_class = (jclass)env->NewGlobalRef(myclass);
handle_field = env->GetFieldID(myclass, "cpp_handle", "J");
if (!handle_field)
{
printf("can't find handle!\n");
return 0;
}
features_cons = env->GetMethodID(features_class, "<init>", "(J)V");
if (!features_cons)
{
printf("can't find features_cons!\n");
return 0;
}
string_class = (jclass)env->NewGlobalRef(env->FindClass("java/lang/String"));
float_class = (jclass)env->NewGlobalRef(env->FindClass("java/lang/Float"));
float_cons = env->GetMethodID(float_class, "<init>", "(F)V");
if (!float_cons)
{
printf("can't find float_cons!\n");
return 0;
}
int_class = (jclass)env->NewGlobalRef(env->FindClass("java/lang/Integer"));
int_cons = env->GetMethodID(int_class, "<init>", "(I)V");
return 1;
}
JNIEXPORT jboolean JNICALL
Java_cstr_est_Features_finalise_1cpp (JNIEnv *env, jclass myclass)
{
(void)env;
(void)myclass;
return 1;
}
JNIEXPORT jboolean JNICALL
Java_cstr_est_Features_create_1cpp_1features(JNIEnv *env,
jobject self,
jlong handle
)
{
EST_Features *features = (handle==0L
? (new EST_Features)
: (EST_Features *)handle
);
// printf("create features %p\n", features);
env->SetLongField(self, handle_field, (jlong)features);
return 1;
}
JNIEXPORT jboolean JNICALL
Java_cstr_est_Features_destroy_1cpp_1features (JNIEnv *env, jobject self)
{
EST_Features *features = (EST_Features *) env->GetLongField(self, handle_field);
// printf("destroy features %p\n", features);
delete features;
return 1;
}
JNIEXPORT jobjectArray JNICALL
Java_cstr_est_Features_cpp_1featureNames (JNIEnv *env, jobject self)
{
EST_Features *f = (EST_Features *) env->GetLongField(self, handle_field);
int n;
EST_Features::Entries p;
n=0;
for (p.begin(*f); p != 0; ++p)
n++;
jobjectArray names = env->NewObjectArray(n, string_class, NULL);
p.beginning();
for(int i=0; i<n; i++)
{
jstring fn = env->NewStringUTF(p->k);
env->SetObjectArrayElement(names, i, fn);
++p;
}
return names;
}
JNIEXPORT jstring JNICALL
Java_cstr_est_Features_cpp_1getS(JNIEnv *env,
jobject self,
jstring jname,
jstring jdef)
{
EST_Features *f = (EST_Features *) env->GetLongField(self, handle_field);
const char *name = env->GetStringUTFChars(jname, 0);
EST_Val def;
const EST_Val &val = f->val_path(name, def);
env->ReleaseStringUTFChars(jname, name);
if (&def == &val)
return jdef;
return env->NewStringUTF(val.S());
}
JNIEXPORT jfloat JNICALL
Java_cstr_est_Features_cpp_1getF(JNIEnv *env,
jobject self,
jstring jname,
jfloat def)
{
EST_Features *f = (EST_Features *) env->GetLongField(self, handle_field);
const char *name = env->GetStringUTFChars(jname, 0);
float val = f->F(name, def);
env->ReleaseStringUTFChars(jname, name);
return val;
}
JNIEXPORT jobject JNICALL
Java_cstr_est_Features_cpp_1get(JNIEnv *env,
jobject self,
jstring jname,
jobject jdef)
{
EST_Features *f = (EST_Features *) env->GetLongField(self, handle_field);
const char *name = env->GetStringUTFChars(jname, 0);
EST_Val def("hidden");
const EST_Val &val = f->val(name, def);
env->ReleaseStringUTFChars(jname, name);
if (&def == &val)
{
//fprintf(stderr, "get %s =%s\n", name, "def");
return jdef;
}
jobject jval;
val_type t = val.type();
//fprintf(stderr, "get %s =%s (%s)\n", name, (const char *)val.S(), t);
if (t==val_type_feats)
{
jval = env->NewObject(features_class, features_cons, (jlong)feats(val));
}
else if (t==val_float)
{
jval = env->NewObject(float_class, float_cons, (jfloat)val.F());
}
else if (t==val_int)
{
jval = env->NewObject(int_class, int_cons, (jint)val.I());
}
else
{
jval = env->NewStringUTF(val.S());
}
return jval;
}
JNIEXPORT void JNICALL
Java_cstr_est_Features_cpp_1set__Ljava_lang_String_2F(JNIEnv *env, jobject self, jstring jname, jfloat val)
{
EST_Features *f = (EST_Features *) env->GetLongField(self, handle_field);
const char *name = env->GetStringUTFChars(jname, 0);
f->set(name, val);
env->ReleaseStringUTFChars(jname, name);
}
JNIEXPORT void JNICALL
Java_cstr_est_Features_cpp_1set__Ljava_lang_String_2Ljava_lang_String_2(JNIEnv *env, jobject self, jstring jname, jstring jval)
{
EST_Features *f = (EST_Features *) env->GetLongField(self, handle_field);
const char *name = env->GetStringUTFChars(jname, 0);
const char *val = env->GetStringUTFChars(jval, 0);
f->set(name, val);
env->ReleaseStringUTFChars(jname, name);
env->ReleaseStringUTFChars(jval, val);
}
JNIEXPORT jboolean JNICALL
Java_cstr_est_Features_cpp_1present(JNIEnv *env, jobject self, jstring jname)
{
EST_Features *f = (EST_Features *) env->GetLongField(self, handle_field);
const char *name = env->GetStringUTFChars(jname, 0);
int val = f->present(name);
env->ReleaseStringUTFChars(jname, name);
return val;
}

View File

@@ -0,0 +1,216 @@
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Centre for Speech Technology Research \\
// University of Edinburgh, UK \\
// Copyright (c) 1996,1997 \\
// All Rights Reserved. \\
// Permission is hereby granted, free of charge, to use and distribute \\
// this software and its documentation without restriction, including \\
// without limitation the rights to use, copy, modify, merge, publish, \\
// distribute, sublicense, and/or sell copies of this work, and to \\
// permit persons to whom this work is furnished to do so, subject to \\
// the following conditions: \\
// 1. The code must retain the above copyright notice, this list of \\
// conditions and the following disclaimer. \\
// 2. Any modifications must be clearly marked as such. \\
// 3. Original authors' names are not deleted. \\
// 4. The authors' names are not used to endorse or promote products \\
// derived from this software without specific prior written \\
// permission. \\
// THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK \\
// DISCLAIM ALL WARRANTIES With REGARD TO THIS SOFTWARE, INCLUDING \\
// ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT \\
// SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE \\
// FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES \\
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN \\
// AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, \\
// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF \\
// THIS SOFTWARE. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
// -------------------------------------------------------------------- \\
// EST Features mapped to Java. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
package cstr.est;
import java.lang.*;
import java.util.*;
import cstr.util.*;
public class Features
implements Featured
{
private long cpp_handle;
private boolean mine;
private String [] cachedFeatureNames;
public Features()
{
this(0L, true);
}
public Features(long handle)
{
this(handle, false);
}
Features(long handle, boolean m)
{
// System.out.println("create "+handle+":"+m);
create_cpp_features(handle);
mine=m;
}
protected void finalize() throws Throwable
{
if (mine)
destroy_cpp_features();
super.finalize();
}
private native String [] cpp_featureNames();
public String [] names()
{
if (cachedFeatureNames ==null)
cachedFeatureNames = cpp_featureNames();
return cachedFeatureNames;
}
public void getPaths(String prefix, Vector names, boolean nodes, boolean leaves)
{
String [] fns = names();
// System.err.println("getFeatureNames:"+fns.length);
for(int i=0; i<fns.length; i++)
{
Object v = get(fns[i]);
// System.err.println("="+fns[i]+":"+v+":"+v.getClass());
if (v==null)
continue;
else if (v instanceof cstr.est.Features)
{
//System.err.println("Features");
if ( prefix==null )
{
if (nodes)
names.addElement(fns[i]);
((Features)v).getPaths(fns[i], names, nodes, leaves);
}
else
{
if (nodes)
names.addElement(prefix + "." + fns[i]);
((Features)v).getPaths(prefix + "." + fns[i], names, nodes, leaves);
}
}
else
{
// System.err.println("Other:"+v.getClass());
if ( prefix==null )
{
if (leaves)
names.addElement(fns[i]);
}
else
{
if (leaves)
names.addElement(prefix + "." + fns[i]);
}
}
}
}
private native boolean cpp_present(String n);
public boolean present(String n)
{
return cpp_present(n);
}
private native String cpp_getS(String n, String def);
public String getS(String n)
{
return cpp_getS(n, "");
}
public String getS(String n, String def)
{
return cpp_getS(n, def);
}
public String getFeature(String n)
{
return cpp_getS(n, "");
}
private native float cpp_getF(String n, float def);
public float getF(String n)
{
return cpp_getF(n,(float)0.0);
}
public float getF(String n, float def)
{
return cpp_getF(n,def);
}
private native Object cpp_get(String n, Object def);
public Object get(String n)
{
return cpp_get(n,null);
}
public Object get(String n, Object def)
{
return cpp_get(n,def);
}
private native void cpp_set(String n, float val);
public void set(String n, float val)
{
cpp_set(n, val);
}
private native void cpp_set(String n, String val);
public void set(String n, String val)
{
cpp_set(n, val);
}
public final int hashCode()
{
return (int)cpp_handle;
}
public boolean equals(Object i)
{
return i instanceof Features && ((Features)i).cpp_handle == cpp_handle;
}
private native static boolean initialise_cpp();
private native static boolean finalise_cpp();
private native boolean create_cpp_features(long handle);
private native boolean destroy_cpp_features();
static {
System.loadLibrary("estjava");
if (!initialise_cpp())
throw new ExceptionInInitializerError("Features C++ fails");
}
}

View File

@@ -0,0 +1,281 @@
/*************************************************************************/
/* */
/* Centre for Speech Technology Research */
/* University of Edinburgh, UK */
/* Copyright (c) 1995,1996 */
/* All Rights Reserved. */
/* */
/* Permission is hereby granted, free of charge, to use and distribute */
/* this software and its documentation without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of this work, and to */
/* permit persons to whom this work is furnished to do so, subject to */
/* the following conditions: */
/* 1. The code must retain the above copyright notice, this list of */
/* conditions and the following disclaimer. */
/* 2. Any modifications must be clearly marked as such. */
/* 3. Original authors' names are not deleted. */
/* 4. The authors' names are not used to endorse or promote products */
/* derived from this software without specific prior written */
/* permission. */
/* */
/* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */
/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
/* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */
/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
/* THIS SOFTWARE. */
/* */
/*************************************************************************/
/* */
/* Author: Richard Caley <rjc@cstr.ed.ac.uk> */
/* ------------------------------------------------------------------- */
/* Interface between java and C++ for EST_Item. */
/* */
/*************************************************************************/
#include <stdio.h>
#include "jni_Item.h"
#include "ling_class/EST_Item.h"
#include "ling_class/EST_item_aux.h"
static jobject item_class;
static jfieldID handle_field;
static inline short abs(short s) { return s>0?s:-s; }
JNIEXPORT jboolean JNICALL
Java_cstr_est_Item_initialise_1cpp (JNIEnv *env, jclass myclass)
{
item_class = env->NewGlobalRef(myclass);
handle_field = env->GetFieldID(myclass, "cpp_handle", "J");
if (!handle_field)
{
printf("can't find handle!\n");
return 0;
}
return 1;
}
JNIEXPORT jboolean JNICALL
Java_cstr_est_Item_finalise_1cpp (JNIEnv *env, jclass myclass)
{
(void)env;
(void)myclass;
return 1;
}
JNIEXPORT jboolean JNICALL
Java_cstr_est_Item_create_1cpp_1item(JNIEnv *env,
jobject self,
jlong handle
)
{
EST_Item *item =(handle == 0L
? (new EST_Item)
: (EST_Item *)handle
);
// printf("create item %p\n", item);
env->SetLongField(self, handle_field, (jlong)item);
return 1;
}
JNIEXPORT jboolean JNICALL
Java_cstr_est_Item_destroy_1cpp_1item (JNIEnv *env, jobject self)
{
EST_Item *item = (EST_Item *) env->GetLongField(self, handle_field);
// printf("destroy item %p\n", item);
delete item;
return 1;
}
JNIEXPORT jstring JNICALL
Java_cstr_est_Item_cpp_1name(JNIEnv *env, jobject self)
{
EST_Item *item = (EST_Item *) env->GetLongField(self, handle_field);
EST_String name = item->name();
return env->NewStringUTF(name);
}
JNIEXPORT jstring JNICALL
Java_cstr_est_Item_cpp_1getS(JNIEnv *env, jobject self, jstring jname, jstring jdef)
{
EST_Item *item = (EST_Item *) env->GetLongField(self, handle_field);
const char *name = env->GetStringUTFChars(jname, 0);
EST_feat_status status=efs_ok;
// cout << "GetS " << name << "\n";
EST_String val= "";
val = getString(*item, name, EST_String::Empty, status);
// cout << "<GetS " << name << "=" << val << "\n";
env->ReleaseStringUTFChars(jname, name);
if (status != efs_ok)
return jdef;
// cout << "return\n";
return env->NewStringUTF(val);
}
JNIEXPORT jfloat JNICALL
Java_cstr_est_Item_cpp_1getF(JNIEnv *env, jobject self, jstring jname, jfloat def)
{
EST_Item *item = (EST_Item *) env->GetLongField(self, handle_field);
const char *name = env->GetStringUTFChars(jname, 0);
EST_feat_status status=efs_ok;
float val = getFloat(*item, name, def, status);
env->ReleaseStringUTFChars(jname, name);
return val;
}
JNIEXPORT void JNICALL
Java_cstr_est_Item_cpp_1set__Ljava_lang_String_2F(JNIEnv *env, jobject self, jstring jname, jfloat val)
{
EST_Item *item = (EST_Item *) env->GetLongField(self, handle_field);
const char *name = env->GetStringUTFChars(jname, 0);
item->set(name, val);
env->ReleaseStringUTFChars(jname, name);
}
JNIEXPORT void JNICALL
Java_cstr_est_Item_cpp_1set__Ljava_lang_String_2Ljava_lang_String_2(JNIEnv *env, jobject self, jstring jname, jstring jval)
{
EST_Item *item = (EST_Item *) env->GetLongField(self, handle_field);
const char *name = env->GetStringUTFChars(jname, 0);
const char *val = env->GetStringUTFChars(jval, 0);
item->set(name, val);
env->ReleaseStringUTFChars(jname, name);
env->ReleaseStringUTFChars(jval, val);
}
JNIEXPORT jfloat JNICALL
Java_cstr_est_Item_cpp_1getStartTime(JNIEnv *env, jobject self)
{
EST_Item *item = (EST_Item *) env->GetLongField(self, handle_field);
return item?start(*item):0.0;
}
JNIEXPORT jfloat JNICALL
Java_cstr_est_Item_cpp_1getMidTime(JNIEnv *env, jobject self)
{
EST_Item *item = (EST_Item *) env->GetLongField(self, handle_field);
return item?mid(*item):0.0;
}
JNIEXPORT jfloat JNICALL
Java_cstr_est_Item_cpp_1getTime(JNIEnv *env, jobject self)
{
EST_Item *item = (EST_Item *) env->GetLongField(self, handle_field);
return item?time(*item):0.0;
}
JNIEXPORT jfloat JNICALL
Java_cstr_est_Item_cpp_1getEndTime(JNIEnv *env, jobject self)
{
EST_Item *item = (EST_Item *) env->GetLongField(self, handle_field);
return item?end(*item):0.0;
}
JNIEXPORT jlong JNICALL
Java_cstr_est_Item_cpp_1getContent(JNIEnv *env, jobject self)
{
EST_Item *item = (EST_Item *) env->GetLongField(self, handle_field);
EST_Item_Content *itemc = item->contents();
return (long)itemc;
}
JNIEXPORT jstring JNICALL
Java_cstr_est_Item_cpp_1type(JNIEnv *env, jobject self)
{
EST_Item *item = (EST_Item *) env->GetLongField(self, handle_field);
const char *type;
if (parent(item) != NULL || daughter1(item) != NULL)
type = "tree";
else
type = "linear";
return env->NewStringUTF(type);
}
JNIEXPORT jlong JNICALL
Java_cstr_est_Item_cpp_1next(JNIEnv *env, jobject self)
{
EST_Item *item = (EST_Item *) env->GetLongField(self, handle_field);
return (long)item->next();
}
JNIEXPORT jlong JNICALL
Java_cstr_est_Item_cpp_1prev(JNIEnv *env, jobject self)
{
EST_Item *item = (EST_Item *) env->GetLongField(self, handle_field);
return (long)item->prev();
}
JNIEXPORT jlong JNICALL
Java_cstr_est_Item_cpp_1up(JNIEnv *env, jobject self)
{
EST_Item *item = (EST_Item *) env->GetLongField(self, handle_field);
return (long)item->up();
}
JNIEXPORT jlong JNICALL
Java_cstr_est_Item_cpp_1down(JNIEnv *env, jobject self)
{
EST_Item *item = (EST_Item *) env->GetLongField(self, handle_field);
return (long)item->down();
}
JNIEXPORT jlong JNICALL
Java_cstr_est_Item_cpp_1insert_1after(JNIEnv *env, jobject self)
{
EST_Item *item = (EST_Item *) env->GetLongField(self, handle_field);
return (long)item->insert_after();
}
JNIEXPORT jlong JNICALL
Java_cstr_est_Item_cpp_1insert_1before(JNIEnv *env, jobject self)
{
EST_Item *item = (EST_Item *) env->GetLongField(self, handle_field);
return (long)item->insert_before();
}

View File

@@ -0,0 +1,298 @@
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Centre for Speech Technology Research \\
// University of Edinburgh, UK \\
// Copyright (c) 1996,1997 \\
// All Rights Reserved. \\
// Permission is hereby granted, free of charge, to use and distribute \\
// this software and its documentation without restriction, including \\
// without limitation the rights to use, copy, modify, merge, publish, \\
// distribute, sublicense, and/or sell copies of this work, and to \\
// permit persons to whom this work is furnished to do so, subject to \\
// the following conditions: \\
// 1. The code must retain the above copyright notice, this list of \\
// conditions and the following disclaimer. \\
// 2. Any modifications must be clearly marked as such. \\
// 3. Original authors' names are not deleted. \\
// 4. The authors' names are not used to endorse or promote products \\
// derived from this software without specific prior written \\
// permission. \\
// THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK \\
// DISCLAIM ALL WARRANTIES With REGARD TO THIS SOFTWARE, INCLUDING \\
// ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT \\
// SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE \\
// FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES \\
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN \\
// AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, \\
// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF \\
// THIS SOFTWARE. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
// Date: Tue Mar 31 1998 \\
// -------------------------------------------------------------------- \\
// Java wrapper around items. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
package cstr.est;
import java.lang.*;
import java.util.*;
import java.awt.*;
import cstr.util.*;
import java.io.*;
public class Item
implements Named, Keyed, Featured
{
private long cpp_handle;
private boolean mine;
private Utterance utterance;
private Item_Content contents;
public Item()
{
this(0L, true, null);
}
public Item(long handle)
{
this(handle, false, null);
}
public Item(long handle, Utterance utterance)
{
this(handle, false, utterance);
}
Item(long handle, boolean m, Utterance from_utterance)
{
utterance = from_utterance;
create_cpp_item(handle);
mine=m;
}
protected void finalize() throws Throwable
{
if (mine)
destroy_cpp_item();
super.finalize();
}
protected final Item getItem(long handle)
{
Item i;
if (utterance != null)
i = utterance.getItem(handle);
else
i = new Item(handle);
return i;
}
public long getHandle()
{
return cpp_handle;
}
private native String cpp_name();
public String name()
{
return cpp_name();
}
public String getName()
{
return cpp_name();
}
private native void cpp_setName(String name);
public void setName(String name)
{
cpp_setName(name);
}
private native long cpp_getContent();
public final Item_Content getContent()
{
if (contents==null)
contents = new Item_Content(cpp_getContent());
return contents;
}
public final Object getKey()
{
return getContent();
}
public final int hashCode()
{
return (int)cpp_getContent();
}
public final boolean equals(Object i)
{
return i instanceof Item && ((Item)i).cpp_handle == cpp_handle;
}
private native String cpp_getS(String n, String def);
public String getS(String n, String def)
{
return cpp_getS(n, def);
}
public String getS(String n)
{
return cpp_getS(n, "");
}
public String getFeature(String n)
{
return cpp_getS(n, "");
}
private native float cpp_getF(String n, float def);
public float getF(String n, float def)
{
return cpp_getF(n, def);
}
public float getF(String n)
{
return cpp_getF(n, 0);
}
private native void cpp_set(String n, float val);
public void set(String n, float val)
{
cpp_set(n, val);
}
private native void cpp_set(String n, String val);
public void set(String n, String val)
{
cpp_set(n, val);
}
private native String cpp_type();
public String type()
{
return cpp_type();
}
private native float cpp_getStartTime();
public float getStartTime()
{
return cpp_getStartTime();
}
private native float cpp_getMidTime();
public float getMidTime()
{
return cpp_getMidTime();
}
private native float cpp_getTime();
public float getTime()
{
return cpp_getTime();
}
private native float cpp_getEndTime();
public float getEndTime()
{
return cpp_getEndTime();
}
private native long cpp_next();
public Item next()
{
long h = cpp_next();
if (h==0)
return null;
else
return getItem(h);
}
private native long cpp_prev();
public Item prev()
{
long h = cpp_prev();
if (h==0)
return null;
else
return getItem(h);
}
private native long cpp_up();
public Item up()
{
long h = cpp_up();
if (h==0)
return null;
else
return getItem(h);
}
private native long cpp_down();
public Item down()
{
long h = cpp_down();
if (h==0)
return null;
else
return getItem(h);
}
private native long cpp_insert_after();
public Item insert_after()
{
long h = cpp_insert_after();
if (h==0)
return null;
else
return getItem(h);
}
private native long cpp_insert_before();
public Item insert_before()
{
long h = cpp_insert_before();
if (h==0)
return null;
else
return getItem(h);
}
private native static boolean initialise_cpp();
private native static boolean finalise_cpp();
private native boolean create_cpp_item(long handle);
private native boolean destroy_cpp_item();
static {
System.loadLibrary("estjava");
if (!initialise_cpp())
throw new ExceptionInInitializerError("Item C++ fails");
}
}

View File

@@ -0,0 +1,402 @@
/*************************************************************************/
/* */
/* Centre for Speech Technology Research */
/* University of Edinburgh, UK */
/* Copyright (c) 1995,1996 */
/* All Rights Reserved. */
/* */
/* Permission is hereby granted, free of charge, to use and distribute */
/* this software and its documentation without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of this work, and to */
/* permit persons to whom this work is furnished to do so, subject to */
/* the following conditions: */
/* 1. The code must retain the above copyright notice, this list of */
/* conditions and the following disclaimer. */
/* 2. Any modifications must be clearly marked as such. */
/* 3. Original authors' names are not deleted. */
/* 4. The authors' names are not used to endorse or promote products */
/* derived from this software without specific prior written */
/* permission. */
/* */
/* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */
/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
/* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */
/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
/* THIS SOFTWARE. */
/* */
/*************************************************************************/
/* */
/* Author: Richard Caley <rjc@cstr.ed.ac.uk> */
/* ------------------------------------------------------------------- */
/* Interface between java and C++ for EST_Item_Content. */
/* */
/*************************************************************************/
#include <stdio.h>
#include "jni_Item_Content.h"
#include "ling_class/EST_Item_Content.h"
#include "ling_class/EST_item_content_aux.h"
#include "ling_class/EST_item_aux.h"
#include "ling_class/EST_Relation.h"
static jclass features_class;
static jmethodID features_cons;
static jclass string_class;
static jclass float_class;
static jmethodID float_cons;
static jclass int_class;
static jmethodID int_cons;
static jobject itemContent_class;
static jfieldID handle_field;
static inline short abs(short s) { return s>0?s:-s; }
JNIEXPORT jboolean JNICALL
Java_cstr_est_Item_1Content_initialise_1cpp (JNIEnv *env, jclass myclass)
{
itemContent_class = env->NewGlobalRef(myclass);
handle_field = env->GetFieldID(myclass, "cpp_handle", "J");
if (!handle_field)
{
printf("can't find handle!\n");
return 0;
}
features_class = (jclass)env->NewGlobalRef(env->FindClass("cstr/est/Features"));
features_cons = env->GetMethodID(features_class, "<init>", "(J)V");
if (!features_cons)
{
printf("can't find features_cons!\n");
return 0;
}
string_class = (jclass)env->NewGlobalRef(env->FindClass("java/lang/String"));
float_class = (jclass)env->NewGlobalRef(env->FindClass("java/lang/Float"));
float_cons = env->GetMethodID(float_class, "<init>", "(F)V");
if (!float_cons)
{
printf("can't find float_cons!\n");
return 0;
}
int_class = (jclass)env->NewGlobalRef(env->FindClass("java/lang/Integer"));
int_cons = env->GetMethodID(int_class, "<init>", "(I)V");
return 1;
}
JNIEXPORT jboolean JNICALL
Java_cstr_est_Item_1Content_finalise_1cpp (JNIEnv *env, jclass myclass)
{
(void)env;
(void)myclass;
return 1;
}
JNIEXPORT jboolean JNICALL
Java_cstr_est_Item_1Content_create_1cpp_1itemContent(JNIEnv *env,
jobject self,
jlong handle
)
{
EST_Item_Content *itemContent = (handle==0L
? (new EST_Item_Content)
: (EST_Item_Content *)handle
);
// printf("create itemContent %p\n", itemContent);
env->SetLongField(self, handle_field, (jlong)itemContent);
return 1;
}
JNIEXPORT jboolean JNICALL
Java_cstr_est_Item_1Content_destroy_1cpp_1itemContent (JNIEnv *env, jobject self)
{
EST_Item_Content *itemContent = (EST_Item_Content *) env->GetLongField(self, handle_field);
// printf("destroy itemContent %p\n", itemContent);
delete itemContent;
return 1;
}
JNIEXPORT jobjectArray JNICALL
Java_cstr_est_Item_1Content_cpp_1featureNames (JNIEnv *env, jobject self)
{
EST_Item_Content *item = (EST_Item_Content *) env->GetLongField(self, handle_field);
int n;
EST_Features::Entries p;
n=0;
for (p.begin(item->f); p != 0; ++p)
n++;
jobjectArray names = env->NewObjectArray(n, string_class, NULL);
p.beginning();
for(int i=0; i<n; i++)
{
jstring fn = env->NewStringUTF(p->k);
env->SetObjectArrayElement(names, i, fn);
++p;
}
return names;
}
JNIEXPORT jlong JNICALL
Java_cstr_est_Item_1Content_cpp_1getItem__(JNIEnv *env,
jobject self)
{
EST_Item_Content *item_c = (EST_Item_Content *) env->GetLongField(self, handle_field);
if (item_c->relations.length() == 0)
return 0L;
EST_Litem *p;
p = item_c->relations.list.head();
EST_Item *i = item(item_c->relations.list(p).v);
return (long)i;
}
JNIEXPORT jlong JNICALL
Java_cstr_est_Item_1Content_cpp_1getItem__Ljava_lang_String_2(JNIEnv *env,
jobject self,
jstring jrelName)
{
EST_Item_Content *item_c = (EST_Item_Content *) env->GetLongField(self, handle_field);
const char * relName = env->GetStringUTFChars(jrelName, 0);
EST_Item *i = item_c->Relation(relName);
env->ReleaseStringUTFChars(jrelName, relName);
return (long)i;
}
JNIEXPORT jlong JNICALL
Java_cstr_est_Item_1Content_cpp_1getItem__J(JNIEnv *env,
jobject self,
jlong relh)
{
EST_Item_Content *item_c = (EST_Item_Content *) env->GetLongField(self, handle_field);
EST_Relation *rel = (EST_Relation *)relh;
EST_Item *i = item_c->Relation(rel->name());
return (long)i;
}
JNIEXPORT jstring JNICALL
Java_cstr_est_Item_1Content_cpp_1getS(JNIEnv *env,
jobject self,
jstring jname,
jstring jdef,
jlong relHandle)
{
EST_Item_Content *item_c = (EST_Item_Content *) env->GetLongField(self, handle_field);
EST_Relation *rel = (EST_Relation *)relHandle;
const char *name = env->GetStringUTFChars(jname, 0);
EST_String val;
EST_feat_status stat=efs_ok;
if (rel != NULL)
{
// cout << "getS " << name << " in " << rel->name() << "\n";
EST_Item *item = item_c->Relation(rel->name());
val = getString(*item, name, EST_String::Empty, stat);
}
else
{
// cout << "getS " << name << " in no relation \n";
val = getString(*item_c, name, EST_String::Empty, stat);
}
env->ReleaseStringUTFChars(jname, name);
if (stat != efs_ok)
return jdef;
return env->NewStringUTF(val);
}
JNIEXPORT jfloat JNICALL
Java_cstr_est_Item_1Content_cpp_1getF(JNIEnv *env,
jobject self,
jstring jname,
jfloat def,
jlong relHandle)
{
EST_Item_Content *item_c = (EST_Item_Content *) env->GetLongField(self, handle_field);
EST_Relation *rel = (EST_Relation *)relHandle;
const char *name = env->GetStringUTFChars(jname, 0);
float val;
EST_feat_status stat=efs_ok;
if (rel != NULL)
{
EST_Item *item = item_c->Relation(rel->name());
val = getFloat(*item, name, def, stat);
}
else
val = getFloat(*item_c, name, def, stat);
env->ReleaseStringUTFChars(jname, name);
return val;
}
JNIEXPORT jobject JNICALL
Java_cstr_est_Item_1Content_cpp_1get(JNIEnv *env,
jobject self,
jstring jname,
jobject jdef,
jlong relHandle)
{
EST_Item_Content *item_c = (EST_Item_Content *) env->GetLongField(self, handle_field);
EST_Relation *rel = (EST_Relation *)relHandle;
const char *name = env->GetStringUTFChars(jname, 0);
EST_Val def("hidden");
const EST_Val *val;
if (rel != NULL)
{
EST_Item *item = item_c->Relation(rel->name());
val = &(item->f(name, def));
}
else
val = &(item_c)->f(name, def);
env->ReleaseStringUTFChars(jname, name);
if (&def == val)
{
//fprintf(stderr, "get %s =%s\n", name, "def");
return jdef;
}
jobject jval;
val_type t = val->type();
//fprintf(stderr, "get %s =%s (%s)\n", name, (const char *)val->S(), t);
if (t==val_type_feats)
{
jval = env->NewObject(features_class, features_cons, (jlong)feats(*val));
}
else if (t==val_float)
{
jval = env->NewObject(float_class, float_cons, (jfloat)val->F());
}
else if (t==val_int)
{
jval = env->NewObject(int_class, int_cons, (jint)val->I());
}
else
{
jval = env->NewStringUTF(val->S());
}
return jval;
}
JNIEXPORT void JNICALL
Java_cstr_est_Item_1Content_cpp_1set__Ljava_lang_String_2F(JNIEnv *env, jobject self, jstring jname, jfloat val)
{
EST_Item_Content *item = (EST_Item_Content *) env->GetLongField(self, handle_field);
const char *name = env->GetStringUTFChars(jname, 0);
item->f.set(name, val);
env->ReleaseStringUTFChars(jname, name);
}
JNIEXPORT void JNICALL
Java_cstr_est_Item_1Content_cpp_1set__Ljava_lang_String_2Ljava_lang_String_2(JNIEnv *env, jobject self, jstring jname, jstring jval)
{
EST_Item_Content *item = (EST_Item_Content *) env->GetLongField(self, handle_field);
const char *name = env->GetStringUTFChars(jname, 0);
const char *val = env->GetStringUTFChars(jval, 0);
item->f.set(name, val);
env->ReleaseStringUTFChars(jname, name);
env->ReleaseStringUTFChars(jval, val);
}
JNIEXPORT jboolean JNICALL
Java_cstr_est_Item_1Content_cpp_1featurePresent(JNIEnv *env, jobject self, jstring jname)
{
EST_Item_Content *item = (EST_Item_Content *) env->GetLongField(self, handle_field);
const char *name = env->GetStringUTFChars(jname, 0);
int val = item->f.present(name);
env->ReleaseStringUTFChars(jname, name);
return val;
}
JNIEXPORT jlong JNICALL
Java_cstr_est_Item_1Content_cpp_1getFeatures(JNIEnv *env, jobject self)
{
EST_Item_Content *item = (EST_Item_Content *) env->GetLongField(self, handle_field);
return item?(long)(EST_Features *)&(item->f):0L;
}
JNIEXPORT jfloat JNICALL
Java_cstr_est_Item_1Content_cpp_1getTime(JNIEnv *env, jobject self)
{
EST_Item_Content *item = (EST_Item_Content *) env->GetLongField(self, handle_field);
return item?time(*item):-1.0;
}
JNIEXPORT jfloat JNICALL
Java_cstr_est_Item_1Content_cpp_1getMidTime(JNIEnv *env, jobject self)
{
EST_Item_Content *item = (EST_Item_Content *) env->GetLongField(self, handle_field);
return item?mid(*item):-1.0;
}
JNIEXPORT jfloat JNICALL
Java_cstr_est_Item_1Content_cpp_1getStartTime(JNIEnv *env, jobject self)
{
EST_Item_Content *item = (EST_Item_Content *) env->GetLongField(self, handle_field);
return item?start(*item):-1.0;
}
JNIEXPORT jfloat JNICALL
Java_cstr_est_Item_1Content_cpp_1getEndTime(JNIEnv *env, jobject self)
{
EST_Item_Content *item = (EST_Item_Content *) env->GetLongField(self, handle_field);
return item?end(*item):-1.0;
}

View File

@@ -0,0 +1,256 @@
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Centre for Speech Technology Research \\
// University of Edinburgh, UK \\
// Copyright (c) 1996,1997 \\
// All Rights Reserved. \\
// Permission is hereby granted, free of charge, to use and distribute \\
// this software and its documentation without restriction, including \\
// without limitation the rights to use, copy, modify, merge, publish, \\
// distribute, sublicense, and/or sell copies of this work, and to \\
// permit persons to whom this work is furnished to do so, subject to \\
// the following conditions: \\
// 1. The code must retain the above copyright notice, this list of \\
// conditions and the following disclaimer. \\
// 2. Any modifications must be clearly marked as such. \\
// 3. Original authors' names are not deleted. \\
// 4. The authors' names are not used to endorse or promote products \\
// derived from this software without specific prior written \\
// permission. \\
// THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK \\
// DISCLAIM ALL WARRANTIES With REGARD TO THIS SOFTWARE, INCLUDING \\
// ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT \\
// SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE \\
// FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES \\
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN \\
// AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, \\
// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF \\
// THIS SOFTWARE. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
// Date: Wed Feb 25 1998 \\
// -------------------------------------------------------------------- \\
// Items in a stream. Wrapper around EST_StreamItem. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
package cstr.est;
import java.lang.*;
import java.util.*;
import java.awt.*;
import cstr.util.*;
public class Item_Content
implements Featured
{
private long cpp_handle;
private boolean mine;
private String [] cachedFeatureNames;
public Item_Content()
{
this(0L, true);
}
public Item_Content(long handle)
{
this(handle, false);
}
Item_Content(long handle, boolean m)
{
create_cpp_itemContent(handle);
mine=m;
}
protected void finalize() throws Throwable
{
if (mine)
destroy_cpp_itemContent();
super.finalize();
}
private native long cpp_getItem();
public Item getItem()
{
return new Item(cpp_getItem());
}
private native long cpp_getItem(String relName);
public Item getItem(String relName)
{
long h = cpp_getItem(relName);
return h==0L?null:new Item(h);
}
private native long cpp_getItem(long relh);
public Item getItem(Relation rel)
{
long h = cpp_getItem(rel.getHandle());
return h==0L?null:new Item(h);
}
private native String [] cpp_featureNames();
public String [] featureNames()
{
if (cachedFeatureNames ==null)
cachedFeatureNames = cpp_featureNames();
return cachedFeatureNames;
}
private native boolean cpp_featurePresent(String n);
public boolean featurePresent(String n)
{
return cpp_featurePresent(n);
}
private native String cpp_getS(String n, String def, long r);
public String getS(String n, Relation r)
{
return cpp_getS(n, "", r.getHandle());
}
public String getSdef(String n, String def, Relation r)
{
return cpp_getS(n, def, r.getHandle());
}
public String getS(String n)
{
return cpp_getS(n, "", 0L);
}
public String getFeature(String n)
{
return cpp_getS(n, "", 0L);
}
private native float cpp_getF(String n, float def, long r);
public float getF(String n, Relation r)
{
return cpp_getF(n,(float)0.0,r.getHandle());
}
public float getF(String n, float def, Relation r)
{
return cpp_getF(n,def,r.getHandle());
}
public float getF(String n)
{
return cpp_getF(n,(float)0.0,0L);
}
private native Object cpp_get(String n, Object def, long r);
public Object get(String n, Relation r)
{
return cpp_get(n,null,r.getHandle());
}
public Object get(String n, Object def, Relation r)
{
return cpp_get(n,def,r.getHandle());
}
public Object get(String n)
{
return cpp_get(n,null,0L);
}
private native void cpp_set(String n, float val);
public void set(String n, float val)
{
cpp_set(n, val);
}
private native void cpp_set(String n, String val);
public void set(String n, String val)
{
cpp_set(n, val);
}
public String name()
{
return cpp_getS("name", "<NONAME>", 0L);
}
public String getName()
{
return cpp_getS("name", "<NONAME>", 0L);
}
private native long cpp_getFeatures();
public Features getFeatures()
{
long fh = cpp_getFeatures();
return new Features(fh);
}
private native float cpp_getStartTime();
public float getStartTime()
{
return cpp_getStartTime();
}
private native float cpp_getMidTime();
public float getMidTime()
{
return cpp_getMidTime();
}
private native float cpp_getTime();
public float getTime()
{
return cpp_getTime();
}
private native float cpp_getEndTime();
public float getEndTime()
{
return cpp_getEndTime();
}
public final int hashCode()
{
return (int)cpp_handle;
}
public boolean equals(Object i)
{
return i instanceof Item_Content && ((Item_Content)i).cpp_handle == cpp_handle;
}
private native static boolean initialise_cpp();
private native static boolean finalise_cpp();
private native boolean create_cpp_itemContent(long handle);
private native boolean destroy_cpp_itemContent();
static {
System.loadLibrary("estjava");
if (!initialise_cpp())
throw new ExceptionInInitializerError("Item_Content C++ fails");
}
}

View File

@@ -0,0 +1,69 @@
###########################################################################
## ##
## Centre for Speech Technology Research ##
## University of Edinburgh, UK ##
## Copyright (c) 1996 ##
## All Rights Reserved. ##
## ##
## Permission is hereby granted, free of charge, to use and distribute ##
## this software and its documentation without restriction, including ##
## without limitation the rights to use, copy, modify, merge, publish, ##
## distribute, sublicense, and/or sell copies of this work, and to ##
## permit persons to whom this work is furnished to do so, subject to ##
## the following conditions: ##
## 1. The code must retain the above copyright notice, this list of ##
## conditions and the following disclaimer. ##
## 2. Any modifications must be clearly marked as such. ##
## 3. Original authors' names are not deleted. ##
## 4. The authors' names are not used to endorse or promote products ##
## derived from this software without specific prior written ##
## permission. ##
## ##
## THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK ##
## DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ##
## ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT ##
## SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE ##
## FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ##
## WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN ##
## AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ##
## ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF ##
## THIS SOFTWARE. ##
## ##
###########################################################################
TOP=../../../..
DIRNAME = java/cpp_version/cstr/est
JUST_BUILD_DIRS = awt
ALL_DIRS =
LOCAL_JAVA_NATIVE_CLASSES = Wave Track \
Utterance Relation Item Item_Content \
Sigpr Features
JAVA_NATIVE_CLASSES = $(LOCAL_JAVA_NATIVE_CLASSES)
LOCAL_JAVA_CLASSES = $(LOCAL_JAVA_NATIVE_CLASSES) \
TrackFileFormat UtteranceFileFormat
JAVA_CLASSES = $(LOCAL_JAVA_CLASSES) \
ServerConnection SocketsFile
NEED_JAVA=true
NO_DEPEND=1
CPPSRCS = $(JAVA_NATIVE_CLASSES:=.cc)
SRCS = $(CPPSRCS)
OBJS_estjava = $(SRCS:.cc=.o)
FILES = $(LOCAL_JAVA_NATIVE_CLASSES:=.cc) $(LOCAL_JAVA_CLASSES:%=%.java) Makefile skeleton.cc skeleton.java
ALL = .java .buildlib
-include ../../Makefile.version
include $(TOP)/config/common_make_rules
foo:
: $(PROJECT_LIBRARIES)

View File

@@ -0,0 +1,256 @@
/*************************************************************************/
/* */
/* Centre for Speech Technology Research */
/* University of Edinburgh, UK */
/* Copyright (c) 1995,1996 */
/* All Rights Reserved. */
/* */
/* Permission is hereby granted, free of charge, to use and distribute */
/* this software and its documentation without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of this work, and to */
/* permit persons to whom this work is furnished to do so, subject to */
/* the following conditions: */
/* 1. The code must retain the above copyright notice, this list of */
/* conditions and the following disclaimer. */
/* 2. Any modifications must be clearly marked as such. */
/* 3. Original authors' names are not deleted. */
/* 4. The authors' names are not used to endorse or promote products */
/* derived from this software without specific prior written */
/* permission. */
/* */
/* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */
/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
/* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */
/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
/* THIS SOFTWARE. */
/* */
/*************************************************************************/
/* */
/* Author: Richard Caley <rjc@cstr.ed.ac.uk> */
/* ------------------------------------------------------------------- */
/* Interface between java and C++ for EST_Relation. */
/* */
/*************************************************************************/
#include <stdio.h>
#include "jni_Relation.h"
#include "ling_class/EST_Relation.h"
#include "ling_class/EST_Item.h"
static jobject relation_class;
static jfieldID handle_field;
static inline short abs(short s) { return s>0?s:-s; }
JNIEXPORT jboolean JNICALL
Java_cstr_est_Relation_initialise_1cpp (JNIEnv *env, jclass myclass)
{
relation_class = env->NewGlobalRef(myclass);
handle_field = env->GetFieldID(myclass, "cpp_handle", "J");
if (!handle_field)
{
printf("can't find handle!\n");
return 0;
}
return 1;
}
JNIEXPORT jboolean JNICALL
Java_cstr_est_Relation_finalise_1cpp (JNIEnv *env, jclass myclass)
{
(void)env;
(void)myclass;
return 1;
}
JNIEXPORT jboolean JNICALL
Java_cstr_est_Relation_create_1cpp_1relation(JNIEnv *env,
jobject self,
jlong handle
)
{
EST_Relation *relation =(handle == 0L
? (new EST_Relation)
: (EST_Relation *)handle
);
// printf("create relation %p\n", relation);
env->SetLongField(self, handle_field, (jlong)relation);
return 1;
}
JNIEXPORT jboolean JNICALL
Java_cstr_est_Relation_destroy_1cpp_1relation (JNIEnv *env, jobject self)
{
EST_Relation *relation = (EST_Relation *) env->GetLongField(self, handle_field);
// printf("destroy relation %p\n", relation);
delete relation;
return 1;
}
JNIEXPORT jstring JNICALL
Java_cstr_est_Relation_cpp_1name(JNIEnv *env, jobject self)
{
EST_Relation *relation = (EST_Relation *) env->GetLongField(self, handle_field);
return env->NewStringUTF(relation->name());
}
JNIEXPORT jstring JNICALL
Java_cstr_est_Relation_cpp_1getFeature (JNIEnv *env, jobject self,
jstring jn)
{
EST_Relation *relation = (EST_Relation *) env->GetLongField(self, handle_field);
const char *n = env->GetStringUTFChars(jn, 0);
const char *v = (relation->f.present(n)
? (const char *)relation->f.S(n)
: "");
env->ReleaseStringUTFChars(jn, n);
return env->NewStringUTF(v);
}
JNIEXPORT jstring JNICALL
Java_cstr_est_Relation_cpp_1type(JNIEnv *env, jobject self)
{
EST_Relation *relation = (EST_Relation *) env->GetLongField(self, handle_field);
EST_Item * hd = relation->head();
const char *type;
if (!hd)
type = "empty";
else
{
type = "linear";
while (hd)
{
if (hd->up() || hd->down())
{
type = "tree";
break;
}
hd=hd->next();
}
}
return env->NewStringUTF(type);
}
JNIEXPORT jstring JNICALL
Java_cstr_est_Relation_cpp_1load (JNIEnv *env, jobject self, jstring jfilename)
{
EST_Relation *stream = (EST_Relation *) env->GetLongField(self, handle_field);
const char *filename = env->GetStringUTFChars(jfilename, 0);
const char *res = "";
EST_read_status stat = stream->load(filename);
env->ReleaseStringUTFChars(jfilename, filename);
if (stat == read_format_error)
res = "stream format error";
else if (stat == read_error)
res = "stream load error";
return env->NewStringUTF(res);
}
JNIEXPORT jstring JNICALL
Java_cstr_est_Relation_cpp_1save (JNIEnv *env, jobject self, jstring jfilename, jstring jformat)
{
EST_Relation *stream = (EST_Relation *) env->GetLongField(self, handle_field);
const char *filename = env->GetStringUTFChars(jfilename, 0);
const char *format = env->GetStringUTFChars(jformat, 0);
const char *res = "";
EST_write_status stat = stream->save(filename);
env->ReleaseStringUTFChars(jfilename, filename);
env->ReleaseStringUTFChars(jformat, format);
if (stat == write_error)
res = "stream save error";
return env->NewStringUTF(res);
}
JNIEXPORT jlong JNICALL
Java_cstr_est_Relation_cpp_1head(JNIEnv *env, jobject self)
{
EST_Relation *relation = (EST_Relation *) env->GetLongField(self, handle_field);
EST_Item *item = relation->head();
return (long)item;
}
JNIEXPORT jlong JNICALL
Java_cstr_est_Relation_cpp_1tail(JNIEnv *env, jobject self)
{
EST_Relation *relation = (EST_Relation *) env->GetLongField(self, handle_field);
EST_Item * item = relation->tail();
return (long)item;
}
JNIEXPORT jlong JNICALL
Java_cstr_est_Relation_cpp_1append(JNIEnv *env, jobject self)
{
EST_Relation *relation = (EST_Relation *) env->GetLongField(self, handle_field);
EST_Item * item = relation->append();
return (long)item;
}
JNIEXPORT void JNICALL
Java_cstr_est_Relation_cpp_1removeItemList(JNIEnv *env,
jobject self,
jlong ihandle
)
{
EST_Relation *relation = (EST_Relation *) env->GetLongField(self, handle_field);
EST_Item * item = (EST_Item *)ihandle;
remove_item_list(relation, item);
}
JNIEXPORT jlong JNICALL
Java_cstr_est_Relation_cpp_1findItem(JNIEnv *env, jobject self, jfloat time)
{
EST_Relation *relation = (EST_Relation *) env->GetLongField(self, handle_field);
EST_Item * item = relation->head();
while (item!=NULL && item->F("end", 0.0) < time)
item = item->next();
return (long)item;
}
JNIEXPORT jfloat JNICALL
Java_cstr_est_Relation_cpp_1getEndTime(JNIEnv *env, jobject self)
{
EST_Relation *relation = (EST_Relation *) env->GetLongField(self, handle_field);
EST_Item *item = relation->tail();
return item?item->F("end",0.0):0.0;
}

View File

@@ -0,0 +1,365 @@
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Centre for Speech Technology Research \\
// University of Edinburgh, UK \\
// Copyright (c) 1996,1997 \\
// All Rights Reserved. \\
// Permission is hereby granted, free of charge, to use and distribute \\
// this software and its documentation without restriction, including \\
// without limitation the rights to use, copy, modify, merge, publish, \\
// distribute, sublicense, and/or sell copies of this work, and to \\
// permit persons to whom this work is furnished to do so, subject to \\
// the following conditions: \\
// 1. The code must retain the above copyright notice, this list of \\
// conditions and the following disclaimer. \\
// 2. Any modifications must be clearly marked as such. \\
// 3. Original authors' names are not deleted. \\
// 4. The authors' names are not used to endorse or promote products \\
// derived from this software without specific prior written \\
// permission. \\
// THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK \\
// DISCLAIM ALL WARRANTIES With REGARD TO THIS SOFTWARE, INCLUDING \\
// ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT \\
// SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE \\
// FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES \\
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN \\
// AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, \\
// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF \\
// THIS SOFTWARE. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
// Date: Tue Mar 31 1998 \\
// -------------------------------------------------------------------- \\
// Java wrapper around relations. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
package cstr.est ;
import java.lang.*;
import java.util.*;
import java.awt.*;
import java.io.*;
import cstr.util.*;
public class Relation
implements Featured
{
private long cpp_handle;
private Utterance utterance;
private boolean mine;
public Relation()
{
this(0L, null, true);
}
public Relation(long handle)
{
this(handle, null, false);
}
public Relation(long handle, Utterance u)
{
this(handle, u, false);
}
Relation(long handle, Utterance u, boolean m)
{
create_cpp_relation(handle);
utterance=u;
mine=m;
}
protected void finalize() throws Throwable
{
if (mine)
destroy_cpp_relation();
super.finalize();
}
protected final Item getItem(long handle)
{
Item i;
if (utterance != null)
i = utterance.getItem(handle);
else
i = new Item(handle);
return i;
}
private native String cpp_name();
public String name()
{
return cpp_name();
}
public String getName()
{
return cpp_name();
}
public long getHandle()
{
return cpp_handle;
}
public boolean equals(Object o)
{
return o instanceof Relation && ((Relation)o).cpp_handle == cpp_handle;
}
private native String cpp_type();
public String type()
{
return cpp_type();
}
private native String cpp_getFeature(String n);
public String getFeature(String n)
{
if (n.equals("_NAME_"))
return getName();
else
return cpp_getFeature(n);
}
public String getS(String n)
{
if (n.equals("_NAME_"))
return getName();
else
return cpp_getFeature(n);
}
public String [] featureNames()
{
return featureNames(false, true);
}
public String [] featureNames(boolean nodes, boolean leaves)
{
Vector names = new Vector();
Hashtable found = new Hashtable();
Enumeration is = getElements();
while (is.hasMoreElements())
{
Item item = (Item)is.nextElement();
Item_Content cont = item.getContent();
Vector paths = new Vector();
cont.getFeatures().getPaths(null, paths, nodes, leaves);
for(int i=0; i< paths.size(); i++)
{
String name = (String)paths.elementAt(i);
if (found.get(name) != null)
continue;
for(int p=0; p<names.size(); p++)
{
int cmp = name.compareTo((String)names.elementAt(p));
if (cmp>0)
continue;
if (cmp< 0)
{
names.insertElementAt(name, p);
found.put(name,name);
}
name=null;
break;
}
if (name != null)
{
names.addElement(name);
found.put(name, name);
}
}
}
String [] ns = new String[names.size()];
for(int i=0; i<names.size(); i++)
ns[i] = (String)names.elementAt(i);
return ns;
}
public void setUtterance(Utterance u)
{
utterance=u;
}
public Utterance getUtterance()
{
return utterance;
}
private native String cpp_load(String filename);
public void load(String filename) throws FileNotFoundException
{
String res = cpp_load(filename);
if (!res.equals(""))
throw new FileNotFoundException(res);
// findTimePoints();
}
private native String cpp_save(String filename, String format);
public void save(String filename, String format) throws IOException
{
String res = cpp_save(filename, format);
if (!res.equals(""))
throw new IOException(res);
}
private native float cpp_getEndTime();
public float getEndTime()
{
return cpp_getEndTime();
}
public Enumeration getElements()
{
return new RelationEnumeration(this);
}
public Enumeration getElements(float from, float to)
{
return new RelationEnumeration(this, from, to);
}
private native long cpp_head();
public Item head()
{
long h = cpp_head();
if (h != 0)
return getItem(h);
else
return null;
}
private native long cpp_tail();
public Item tail()
{
long h = cpp_tail();
if (h != 0)
return getItem(h);
else
return null;
}
private native long cpp_append();
public Item append()
{
long h = cpp_append();
if (h != 0)
return getItem(h);
else
return null;
}
private native void cpp_removeItemList(long itemh);
public void removeItemList(Item i)
{
cpp_removeItemList(i.getHandle());
}
private native long cpp_findItem(float time);
public Item findItem(float time)
{
long p = cpp_findItem(time);
return p==0L?null:getItem(p);
}
private native static boolean initialise_cpp();
private native static boolean finalise_cpp();
private native boolean create_cpp_relation(long handle);
private native boolean destroy_cpp_relation();
static {
System.loadLibrary("estjava");
if (!initialise_cpp())
throw new ExceptionInInitializerError("Relation C++ fails");
}
static class RelationEnumeration implements Enumeration
{
private Relation relation;
private Item current;
private float endTime;
public RelationEnumeration(Relation st)
{
relation = st;
current = st.head();
endTime = (float)-1.0;
}
public RelationEnumeration(Relation st, float from, float to)
{
relation = st;
current = st.findItem(from);
endTime = to;
}
public boolean hasMoreElements()
{
return current != null;
}
public Object nextElement()
{
Item n = current;
current = n.down();
if (current == null)
current = n.next();
if (current == null)
{
current=n;
while (current.prev()!=null)
current=current.prev();
current = current.up();
while (current != null && current.next()==null)
{
while (current.prev()!=null)
current=current.prev();
current=current.up();
}
if (current != null)
current = current.next();
}
if (current != null && endTime >= 0 && current.getEndTime() > endTime)
current = null;
return n;
}
}
}

View File

@@ -0,0 +1,68 @@
/************************************************************************/
/* */
/* Centre for Speech Technology Research */
/* University of Edinburgh, UK */
/* Copyright (c) 1996,1997 */
/* All Rights Reserved. */
/* */
/* Permission is hereby granted, free of charge, to use and distribute */
/* this software and its documentation without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of this work, and to */
/* permit persons to whom this work is furnished to do so, subject to */
/* the following conditions: */
/* 1. The code must retain the above copyright notice, this list of */
/* conditions and the following disclaimer. */
/* 2. Any modifications must be clearly marked as such. */
/* 3. Original authors' names are not deleted. */
/* 4. The authors' names are not used to endorse or promote products */
/* derived from this software without specific prior written */
/* permission. */
/* */
/* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */
/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
/* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */
/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
/* THIS SOFTWARE. */
/* */
/*************************************************************************/
/* */
/* Author: Richard Caley (rjc@cstr.ed.ac.uk) */
/* -------------------------------------------------------------------- */
/* Interface to signal processing code. */
/* */
/*************************************************************************/
#include <stdio.h>
#include <signal.h>
#include "jni_Sigpr.h"
#include "sigpr/EST_spectrogram.h"
#include "sigpr/EST_misc_sigpr.h"
JNIEXPORT void JNICALL
Java_cstr_est_Sigpr_cpp_1spectrogram(JNIEnv *env, jclass myclass,
jlong waveh, jlong trackh,
jfloat shift,
jfloat length,
jint order,
jfloat floor,
jfloat ceil)
{
(void)env;
(void)myclass;
EST_Wave *wave = (EST_Wave *)waveh;
EST_Track *sg = (EST_Track *)trackh;
EST_Wave pwave;
EST_pre_emphasis(*wave, pwave, 0.94);
raw_spectrogram(*sg, pwave, length, shift, order);
scale_spectrogram(*sg, 1.0, floor, ceil);
}

View File

@@ -0,0 +1,70 @@
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Centre for Speech Technology Research \\
// University of Edinburgh, UK \\
// Copyright (c) 1996,1997 \\
// All Rights Reserved. \\
// Permission is hereby granted, free of charge, to use and distribute \\
// this software and its documentation without restriction, including \\
// without limitation the rights to use, copy, modify, merge, publish, \\
// distribute, sublicense, and/or sell copies of this work, and to \\
// permit persons to whom this work is furnished to do so, subject to \\
// the following conditions: \\
// 1. The code must retain the above copyright notice, this list of \\
// conditions and the following disclaimer. \\
// 2. Any modifications must be clearly marked as such. \\
// 3. Original authors' names are not deleted. \\
// 4. The authors' names are not used to endorse or promote products \\
// derived from this software without specific prior written \\
// permission. \\
// THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK \\
// DISCLAIM ALL WARRANTIES With REGARD TO THIS SOFTWARE, INCLUDING \\
// ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT \\
// SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE \\
// FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES \\
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN \\
// AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, \\
// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF \\
// THIS SOFTWARE. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
// -------------------------------------------------------------------- \\
// Signal Processing Tools \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
package cstr.est;
import java.lang.*;
import java.util.*;
import java.awt.*;
public class Sigpr
{
private native static void cpp_spectrogram(long whandle,
long thandle,
float shift,
float length,
int order,
float floor,
float ceil);
public static Track spectrogram(Wave wv,
float shift,
float length,
int order,
float floor,
float ceil)
{
Track sg = new Track();
cpp_spectrogram(wv.getHandle(), sg.getHandle(),
shift, length, order, floor, ceil);
return sg;
}
}

View File

@@ -0,0 +1,319 @@
/*************************************************************************/
/* */
/* Centre for Speech Technology Research */
/* University of Edinburgh, UK */
/* Copyright (c) 1995,1996 */
/* All Rights Reserved. */
/* */
/* Permission is hereby granted, free of charge, to use and distribute */
/* this software and its documentation without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of this work, and to */
/* permit persons to whom this work is furnished to do so, subject to */
/* the following conditions: */
/* 1. The code must retain the above copyright notice, this list of */
/* conditions and the following disclaimer. */
/* 2. Any modifications must be clearly marked as such. */
/* 3. Original authors' names are not deleted. */
/* 4. The authors' names are not used to endorse or promote products */
/* derived from this software without specific prior written */
/* permission. */
/* */
/* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */
/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
/* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */
/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
/* THIS SOFTWARE. */
/* */
/*************************************************************************/
/* */
/* Author: Richard Caley <rjc@cstr.ed.ac.uk> */
/* ------------------------------------------------------------------- */
/* Interface Between Java And C++ For Est_Track. */
/* */
/*************************************************************************/
#include <stdio.h>
#include "jni_Track.h"
#include "EST_Track.h"
#include "EST_track_aux.h"
static jobject track_class;
static jfieldID handle_field;
static inline short abs(short s) { return s>0?s:-s; }
static jint frame_before(EST_Track *track, jfloat t)
{
if (track->equal_space())
{
float s = track->shift();
int f = (int)(t/s)-1;
if (f<0)
f=0;
// fprintf(stderr, "fb t=%f s=%f f=%d\n", t, s, f);
return f;
}
else
{
int f=0;
for(int i=0; i<track->num_frames(); f=i++)
if (track->t(i)>=t)
break;
return f;
}
}
static jint frame_after(EST_Track *track, jfloat t)
{
if (track->equal_space())
{
float s = track->shift();
int f = (int)(t/s)+1;
if (f>track->num_frames())
f=track->num_frames();
// fprintf(stderr, "fa t=%f s=%f f=%d\n", t, s, f);
return f;
}
else
{
int i;
for(i=0; i<track->num_frames(); i++)
if (track->t(i)>=t)
break;
return i;
}
}
JNIEXPORT jboolean JNICALL
Java_cstr_est_Track_initialise_1cpp (JNIEnv *env, jclass myclass)
{
track_class = env->NewGlobalRef(myclass);
handle_field = env->GetFieldID(myclass, "cpp_handle", "J");
if (!handle_field)
{
printf("can't find handle!\n");
return 0;
}
return 1;
}
JNIEXPORT jboolean JNICALL
Java_cstr_est_Track_finalise_1cpp (JNIEnv *env, jclass myclass)
{
(void)env;
(void)myclass;
return 1;
}
JNIEXPORT jboolean JNICALL
Java_cstr_est_Track_create_1cpp_1track(JNIEnv *env, jobject self)
{
EST_Track *track = new EST_Track;
// printf("create track %p\n", track);
env->SetLongField(self, handle_field, (jlong)track);
return 1;
}
JNIEXPORT jboolean JNICALL
Java_cstr_est_Track_destroy_1cpp_1track (JNIEnv *env, jobject self)
{
EST_Track *track = (EST_Track *) env->GetLongField(self, handle_field);
// printf("destroy track %p\n", track);
delete track;
return 1;
}
JNIEXPORT jstring JNICALL
Java_cstr_est_Track_cpp_1name (JNIEnv *env, jobject self)
{
EST_Track *track = (EST_Track *) env->GetLongField(self, handle_field);
return env->NewStringUTF(track->name());
}
JNIEXPORT jstring JNICALL
Java_cstr_est_Track_cpp_1load (JNIEnv *env, jobject self, jstring jfilename)
{
EST_Track *track = (EST_Track *) env->GetLongField(self, handle_field);
const char *filename = env->GetStringUTFChars(jfilename, 0);
const char *res = "";
EST_read_status stat = track->load(filename);
env->ReleaseStringUTFChars(jfilename, filename);
if (stat == read_format_error)
res = "track format error";
else if (stat == read_error)
res = "track load error";
return env->NewStringUTF(res);
}
JNIEXPORT jstring JNICALL
Java_cstr_est_Track_cpp_1save (JNIEnv *env, jobject self,
jstring jfilename, jstring jformat,
jfloat start,
jfloat end)
{
EST_Track *track = (EST_Track *) env->GetLongField(self, handle_field);
const char *filename = env->GetStringUTFChars(jfilename, 0);
const char *format = env->GetStringUTFChars(jformat, 0);
const char *res = "";
int sframe = frame_before(track, start);
int eframe = frame_after(track, end);
EST_Track segment;
track->sub_track(segment,
sframe, eframe-sframe,
0, EST_ALL);
EST_write_status stat = segment.save(filename, format);
env->ReleaseStringUTFChars(jfilename, filename);
env->ReleaseStringUTFChars(jformat, format);
if (stat == write_error)
res = "track save error";
return env->NewStringUTF(res);
}
JNIEXPORT jint JNICALL
Java_cstr_est_Track_cpp_1num_1frames(JNIEnv *env, jobject self)
{
EST_Track *track = (EST_Track *) env->GetLongField(self, handle_field);
return track->num_frames();
}
JNIEXPORT jint JNICALL
Java_cstr_est_Track_cpp_1num_1channels(JNIEnv *env, jobject self)
{
EST_Track *track = (EST_Track *) env->GetLongField(self, handle_field);
return track->num_channels();
}
JNIEXPORT jfloat JNICALL
Java_cstr_est_Track_cpp_1getEndTime(JNIEnv *env, jobject self)
{
EST_Track *track = (EST_Track *) env->GetLongField(self, handle_field);
int f = track->num_frames()-1;
return f>=0?track->t(f):0.0;
}
JNIEXPORT jstring JNICALL
Java_cstr_est_Track_cpp_1channelName(JNIEnv *env, jobject self,
jint i)
{
EST_Track *track = (EST_Track *) env->GetLongField(self, handle_field);
EST_String cname(i>=0 && i < track->num_channels()
?track->channel_name(i)
:EST_String::Empty);
return env->NewStringUTF(cname);
}
JNIEXPORT jint JNICALL
Java_cstr_est_Track_cpp_1channelPosition(JNIEnv *env, jobject self,
jstring jname)
{
EST_Track *track = (EST_Track *) env->GetLongField(self, handle_field);
const char *name = env->GetStringUTFChars(jname, 0);
int p = track->channel_position(name);
env->ReleaseStringUTFChars(jname, name);
return p;
}
JNIEXPORT jfloat JNICALL
Java_cstr_est_Track_a__II(JNIEnv *env, jobject self,
jint f, jint c)
{
EST_Track *track = (EST_Track *) env->GetLongField(self, handle_field);
return track->a((int)f,(int)c);
}
JNIEXPORT jfloat JNICALL
Java_cstr_est_Track_a__FI(JNIEnv *env, jobject self,
jfloat t, jint c)
{
EST_Track *track = (EST_Track *) env->GetLongField(self, handle_field);
return track->a((float)t,(int)c);
}
JNIEXPORT jfloat JNICALL
Java_cstr_est_Track_cpp_1t(JNIEnv *env, jobject self,
jint f)
{
EST_Track *track = (EST_Track *) env->GetLongField(self, handle_field);
return track->t((int)f);
}
JNIEXPORT jboolean JNICALL
Java_cstr_est_Track_cpp_1val(JNIEnv *env, jobject self,
jint f)
{
EST_Track *track = (EST_Track *) env->GetLongField(self, handle_field);
return track->val((int)f);
}
JNIEXPORT jint JNICALL
Java_cstr_est_Track_cpp_1frameBefore(JNIEnv *env, jobject self,
jfloat t)
{
EST_Track *track = (EST_Track *) env->GetLongField(self, handle_field);
return frame_before(track, t);
}
JNIEXPORT jint JNICALL
Java_cstr_est_Track_cpp_1frameAfter(JNIEnv *env, jobject self,
jfloat t)
{
EST_Track *track = (EST_Track *) env->GetLongField(self, handle_field);
return frame_after(track, t);
}
JNIEXPORT jint JNICALL
Java_cstr_est_Track_cpp_1frameNearest(JNIEnv *env, jobject self,
jfloat t)
{
EST_Track *track = (EST_Track *) env->GetLongField(self, handle_field);
return track->index(t);
}

View File

@@ -0,0 +1,188 @@
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Centre for Speech Technology Research \\
// University of Edinburgh, UK \\
// Copyright (c) 1996,1997 \\
// All Rights Reserved. \\
// Permission is hereby granted, free of charge, to use and distribute \\
// this software and its documentation without restriction, including \\
// without limitation the rights to use, copy, modify, merge, publish, \\
// distribute, sublicense, and/or sell copies of this work, and to \\
// permit persons to whom this work is furnished to do so, subject to \\
// the following conditions: \\
// 1. The code must retain the above copyright notice, this list of \\
// conditions and the following disclaimer. \\
// 2. Any modifications must be clearly marked as such. \\
// 3. Original authors' names are not deleted. \\
// 4. The authors' names are not used to endorse or promote products \\
// derived from this software without specific prior written \\
// permission. \\
// THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK \\
// DISCLAIM ALL WARRANTIES With REGARD TO THIS SOFTWARE, INCLUDING \\
// ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT \\
// SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE \\
// FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES \\
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN \\
// AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, \\
// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF \\
// THIS SOFTWARE. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
// Date: Friday 12th September 1997 \\
// -------------------------------------------------------------------- \\
// Wrapper around the EST_Track class. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
package cstr.est;
import java.util.*;
import java.lang.*;
import java.io.*;
public class Track
{
private long cpp_handle;
public Track()
{
create_cpp_track();
}
protected void finalize() throws Throwable
{
destroy_cpp_track();
super.finalize();
}
public long getHandle()
{
return cpp_handle;
}
private native String cpp_name();
public String name()
{
return cpp_name();
}
private native String cpp_load(String filename);
public void load(File filename) throws FileNotFoundException
{
String res = cpp_load(filename.getPath());
if (!res.equals(""))
throw new FileNotFoundException(res);
}
private native String cpp_save(String filename, String format, float start, float end);
public void save(File filename, TrackFileFormat format, float start, float end)
throws IOException
{
String res = cpp_save(filename.getPath(), format.toString(), start, end);
if (!res.equals(""))
throw new IOException(res);
}
public void save(File filename, float start, float end)
throws IOException
{
String res = cpp_save(filename.getPath(),
TrackFileFormat.EST_BINARY.toString(),
start, end);
if (!res.equals(""))
throw new IOException(res);
}
private native int cpp_num_frames();
public int num_frames()
{
return cpp_num_frames();
}
private native int cpp_num_channels();
public int num_channels()
{
return cpp_num_channels();
}
private native String cpp_channelName(int i);
public String channelName(int i)
{
return cpp_channelName(i);
}
private native int cpp_channelPosition(String n);
public int channelPosition(String n)
{
return cpp_channelPosition(n);
}
public native float a(int i, int c);
public native float a(float t, int c);
private native float cpp_t(int i);
public float t(int i)
{
return cpp_t(i);
}
private native boolean cpp_val(int i);
public boolean val(int i)
{
return cpp_val(i);
}
private native int cpp_frameBefore(float time);
public int frameBefore(float time)
{
return cpp_frameBefore(time);
}
private native int cpp_frameAfter(float time);
public int frameAfter(float time)
{
return cpp_frameAfter(time);
}
private native int cpp_frameNearest(float time);
public int frameNearest(float time)
{
return cpp_frameNearest(time);
}
private native float cpp_getEndTime();
public float getEndTime()
{
return cpp_getEndTime();
}
private native static boolean initialise_cpp();
private native static boolean finalise_cpp();
private native boolean create_cpp_track();
private native boolean destroy_cpp_track();
static {
System.loadLibrary("estjava");
if (!initialise_cpp())
throw new ExceptionInInitializerError("Track C++ fails");
}
}

View File

@@ -0,0 +1,95 @@
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Centre for Speech Technology Research \\
// University of Edinburgh, UK \\
// Copyright (c) 1996,1997 \\
// All Rights Reserved. \\
// Permission is hereby granted, free of charge, to use and distribute \\
// this software and its documentation without restriction, including \\
// without limitation the rights to use, copy, modify, merge, publish, \\
// distribute, sublicense, and/or sell copies of this work, and to \\
// permit persons to whom this work is furnished to do so, subject to \\
// the following conditions: \\
// 1. The code must retain the above copyright notice, this list of \\
// conditions and the following disclaimer. \\
// 2. Any modifications must be clearly marked as such. \\
// 3. Original authors' names are not deleted. \\
// 4. The authors' names are not used to endorse or promote products \\
// derived from this software without specific prior written \\
// permission. \\
// THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK \\
// DISCLAIM ALL WARRANTIES With REGARD TO THIS SOFTWARE, INCLUDING \\
// ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT \\
// SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE \\
// FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES \\
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN \\
// AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, \\
// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF \\
// THIS SOFTWARE. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
// -------------------------------------------------------------------- \\
// Enumerated type of track file formats. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
package cstr.est ;
import java.lang.*;
import java.util.*;
import java.awt.*;
import cstr.util.*;
public class TrackFileFormat extends Enum
{
static EnumValues values = init("TrackFileFormat");
public static TrackFileFormat DUMMY = new TrackFileFormat("dummy", "Dummy TrackFileFormat Value Fnord", false);
public static TrackFileFormat UNKNOWN = new TrackFileFormat("unknown", "Unknown TrackFileFormat Value Fnord", false);
public static TrackFileFormat EST_BINARY = new TrackFileFormat("est_binary", "Est (binary)");
public static TrackFileFormat EST_ASCII = new TrackFileFormat("est", "Est (ascii)");
public static TrackFileFormat ESPS = new TrackFileFormat("esps", "Entropic FEA");
public static TrackFileFormat HTK = new TrackFileFormat("htk", "HTK");
public static TrackFileFormat HTK_FBANK = new TrackFileFormat("htk_fbank", "HTK (Filter Bank)");
public static TrackFileFormat HTK_MFCC = new TrackFileFormat("htk_mfcc", "HTK (MFCC)");
public static TrackFileFormat HTK_USER= new TrackFileFormat("htk_user", "HTK (user defined)");
public static TrackFileFormat HTK_DISCRETE = new TrackFileFormat("htk_discrete", "HTK (discrete)");
public static TrackFileFormat XMG = new TrackFileFormat("xmg", "Xmg");
public static TrackFileFormat EMA = new TrackFileFormat("ema", "EMA");
public static TrackFileFormat EMA_SWAPPED = new TrackFileFormat("ema_swapped", "EMA (swapped)");
public static TrackFileFormat ASCII = new TrackFileFormat("ascii", "ASCII");
public TrackFileFormat(String s, String ls)
{
super(s, ls, null);
}
public TrackFileFormat(String s, String ls, boolean real)
{
super(s, ls, real);
}
public EnumValues getValuesTable()
{
return values;
}
public static TrackFileFormat getValue(String s)
throws IllegalArgumentException
{
return (TrackFileFormat)getValue(s, values);
}
public static Enum [] getValues()
{
return (Enum [])getValues(values);
}
}

View File

@@ -0,0 +1,233 @@
/*************************************************************************/
/* */
/* Centre for Speech Technology Research */
/* University of Edinburgh, UK */
/* Copyright (c) 1995,1996 */
/* All Rights Reserved. */
/* */
/* Permission is hereby granted, free of charge, to use and distribute */
/* this software and its documentation without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of this work, and to */
/* permit persons to whom this work is furnished to do so, subject to */
/* the following conditions: */
/* 1. The code must retain the above copyright notice, this list of */
/* conditions and the following disclaimer. */
/* 2. Any modifications must be clearly marked as such. */
/* 3. Original authors' names are not deleted. */
/* 4. The authors' names are not used to endorse or promote products */
/* derived from this software without specific prior written */
/* permission. */
/* */
/* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */
/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
/* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */
/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
/* THIS SOFTWARE. */
/* */
/*************************************************************************/
/* */
/* Author: Richard Caley <rjc@cstr.ed.ac.uk> */
/* ------------------------------------------------------------------- */
/* Interface between java and C++ for EST_Utterance. */
/* */
/*************************************************************************/
#include <stdio.h>
#include "jni_Utterance.h"
#include "ling_class/EST_Utterance.h"
static jobject utterance_class;
static jfieldID handle_field;
static inline short abs(short s) { return s>0?s:-s; }
JNIEXPORT jboolean JNICALL
Java_cstr_est_Utterance_initialise_1cpp (JNIEnv *env, jclass myclass)
{
utterance_class = env->NewGlobalRef(myclass);
handle_field = env->GetFieldID(myclass, "cpp_handle", "J");
if (!handle_field)
{
printf("can't find handle!\n");
return 0;
}
return 1;
}
JNIEXPORT jboolean JNICALL
Java_cstr_est_Utterance_finalise_1cpp (JNIEnv *env, jclass myclass)
{
(void)env;
(void)myclass;
return 1;
}
JNIEXPORT jboolean JNICALL
Java_cstr_est_Utterance_create_1cpp_1utterance(JNIEnv *env, jobject self)
{
EST_Utterance *utterance = new EST_Utterance;
// printf("create utterance %p\n", utterance);
env->SetLongField(self, handle_field, (jlong)utterance);
return 1;
}
JNIEXPORT jboolean JNICALL
Java_cstr_est_Utterance_destroy_1cpp_1utterance (JNIEnv *env, jobject self)
{
EST_Utterance *utterance = (EST_Utterance *) env->GetLongField(self, handle_field);
// printf("destroy utterance %p\n", utterance);
if (utterance)
delete utterance;
return 1;
}
JNIEXPORT jint JNICALL
Java_cstr_est_Utterance_cpp_1num_1relations(JNIEnv *env, jobject self)
{
EST_Utterance *utterance = (EST_Utterance *)env->GetLongField(self, handle_field);
return utterance->num_relations();
}
JNIEXPORT jboolean JNICALL
Java_cstr_est_Utterance_cpp_1has_1relation(JNIEnv *env,
jobject self,
jstring jname)
{
EST_Utterance *utterance = (EST_Utterance *)env->GetLongField(self, handle_field);
const char *name = env->GetStringUTFChars(jname, 0);
bool has = utterance->relation_present(name);
env->ReleaseStringUTFChars(jname, name);
return has;
}
JNIEXPORT jlong JNICALL Java_cstr_est_Utterance_cpp_1relation_1n(JNIEnv *env,
jobject self,
jint n)
{
EST_Utterance *utterance = (EST_Utterance *)env->GetLongField(self, handle_field);
EST_Relation * rel=NULL;
EST_Features::Entries p;
for(p.begin(utterance->relations); p && n>0; ++p,n--)
;
if (n==0)
rel = relation(p->v);
return (jlong)rel;
}
JNIEXPORT jlong JNICALL
Java_cstr_est_Utterance_cpp_1relation(JNIEnv *env,
jobject self,
jstring jname)
{
EST_Utterance *utterance = (EST_Utterance *)env->GetLongField(self, handle_field);
const char *name = env->GetStringUTFChars(jname, 0);
if (!utterance->relation_present(name))
return (jlong)0l;
EST_Relation * rel = utterance->relation(name);
env->ReleaseStringUTFChars(jname, name);
return (jlong)rel;
}
JNIEXPORT jlong JNICALL
Java_cstr_est_Utterance_cpp_1create_1relation(JNIEnv *env,
jobject self,
jstring jname)
{
EST_Utterance *utterance = (EST_Utterance *)env->GetLongField(self, handle_field);
const char *name = env->GetStringUTFChars(jname, 0);
if (utterance->relation_present(name))
return (jlong)0l;
EST_Relation * rel = utterance->create_relation(name);
env->ReleaseStringUTFChars(jname, name);
return (jlong)rel;
}
JNIEXPORT jstring JNICALL
Java_cstr_est_Utterance_cpp_1load (JNIEnv *env, jobject self, jstring jfilename)
{
EST_Utterance *utterance = (EST_Utterance *) env->GetLongField(self, handle_field);
const char *filename = env->GetStringUTFChars(jfilename, 0);
EST_String fn(filename);
EST_read_status stat = read_ok;
CATCH_ERRORS()
{
env->ReleaseStringUTFChars(jfilename, filename);
return env->NewStringUTF(EST_error_message);
}
stat = utterance->load(fn);
END_CATCH_ERRORS();
env->ReleaseStringUTFChars(jfilename, filename);
const char *res = "";
if (stat == read_format_error)
res = "utterance format error";
else if (stat != read_ok)
res = "utterance load error";
return env->NewStringUTF(res);
}
JNIEXPORT jstring JNICALL
Java_cstr_est_Utterance_cpp_1save (JNIEnv *env, jobject self, jstring jfilename, jstring jformat)
{
const EST_Utterance *utterance = (EST_Utterance *) env->GetLongField(self, handle_field);
const char *filename = env->GetStringUTFChars(jfilename, 0);
const char *format = env->GetStringUTFChars(jformat, 0);
const char *res = "";
EST_write_status stat = format[0]=='\0'
? utterance->save(filename)
: utterance->save(filename,format);
env->ReleaseStringUTFChars(jfilename, filename);
env->ReleaseStringUTFChars(jformat, format);
if (stat == write_error)
res = "utterance save error";
return env->NewStringUTF(res);
}

View File

@@ -0,0 +1,169 @@
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Centre for Speech Technology Research \\
// University of Edinburgh, UK \\
// Copyright (c) 1996,1997 \\
// All Rights Reserved. \\
// Permission is hereby granted, free of charge, to use and distribute \\
// this software and its documentation without restriction, including \\
// without limitation the rights to use, copy, modify, merge, publish, \\
// distribute, sublicense, and/or sell copies of this work, and to \\
// permit persons to whom this work is furnished to do so, subject to \\
// the following conditions: \\
// 1. The code must retain the above copyright notice, this list of \\
// conditions and the following disclaimer. \\
// 2. Any modifications must be clearly marked as such. \\
// 3. Original authors' names are not deleted. \\
// 4. The authors' names are not used to endorse or promote products \\
// derived from this software without specific prior written \\
// permission. \\
// THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK \\
// DISCLAIM ALL WARRANTIES With REGARD TO THIS SOFTWARE, INCLUDING \\
// ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT \\
// SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE \\
// FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES \\
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN \\
// AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, \\
// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF \\
// THIS SOFTWARE. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
// Date: Friday 12th September 1997 \\
// -------------------------------------------------------------------- \\
// Wrapper around the EST_Utterance class. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
package cstr.est;
import java.util.*;
import java.lang.*;
import java.io.*;
import cstr.util.*;
public class Utterance
{
private long cpp_handle;
private LongHash cache;
public Utterance()
{
create_cpp_utterance();
cache = new LongHash(200);
}
protected void finalize() throws Throwable
{
destroy_cpp_utterance();
super.finalize();
}
final Item getItem(long handle)
{
Item i;
i = (Item)cache.get(handle);
if (i==null)
{
i = new Item(handle, this);
cache.put(handle, i);
}
return i;
}
private native int cpp_num_relations();
public int num_relations()
{
return cpp_num_relations();
}
private native boolean cpp_has_relation(String name);
public boolean has_relation(String n)
{
return cpp_has_relation(n);
}
private native long cpp_relation_n(int n);
public Relation relation(int n)
{
return new Relation(cpp_relation_n(n), this);
}
private native long cpp_relation(String name);
public Relation relation(String n)
{
long rel_h = cpp_relation(n);
if (rel_h==0)
return null;
else
return new Relation(rel_h, this);
}
private native long cpp_create_relation(String name);
public Relation create_relation(String name)
{
long rel_h = cpp_create_relation(name);
if (rel_h==0)
return null;
else
return new Relation(rel_h, this);
}
private native String cpp_load(String filename);
public void load(String filename) throws FileNotFoundException
{
String res = cpp_load(filename);
if (!res.equals(""))
throw new FileNotFoundException(res);
}
private native String cpp_save(String filename, String format);
public void save(String filename, UtteranceFileFormat format) throws IOException
{
String res = cpp_save(filename, format.toString());
if (!res.equals(""))
throw new IOException(res);
}
public void save(String filename) throws IOException
{
save(filename, UtteranceFileFormat.EST_ASCII);
}
private native int cpp_findItem(float time);
public int findItem(float time)
{
return cpp_findItem(time);
}
private native float cpp_getEndTime();
public float getEndTime()
{
return cpp_getEndTime();
}
private native static boolean initialise_cpp();
private native static boolean finalise_cpp();
private native boolean create_cpp_utterance();
private native boolean destroy_cpp_utterance();
static {
System.loadLibrary("estjava");
if (!initialise_cpp())
throw new ExceptionInInitializerError("Utterance C++ fails");
}
}

View File

@@ -0,0 +1,88 @@
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Centre for Speech Technology Research \\
// University of Edinburgh, UK \\
// Copyright (c) 1996,1997 \\
// All Rights Reserved. \\
// Permission is hereby granted, free of charge, to use and distribute \\
// this software and its documentation without restriction, including \\
// without limitation the rights to use, copy, modify, merge, publish, \\
// distribute, sublicense, and/or sell copies of this work, and to \\
// permit persons to whom this work is furnished to do so, subject to \\
// the following conditions: \\
// 1. The code must retain the above copyright notice, this list of \\
// conditions and the following disclaimer. \\
// 2. Any modifications must be clearly marked as such. \\
// 3. Original authors' names are not deleted. \\
// 4. The authors' names are not used to endorse or promote products \\
// derived from this software without specific prior written \\
// permission. \\
// THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK \\
// DISCLAIM ALL WARRANTIES With REGARD TO THIS SOFTWARE, INCLUDING \\
// ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT \\
// SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE \\
// FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES \\
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN \\
// AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, \\
// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF \\
// THIS SOFTWARE. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
// -------------------------------------------------------------------- \\
// Enumerated type of utterance file formats. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
package cstr.est ;
import java.lang.*;
import java.util.*;
import java.awt.*;
import cstr.util.*;
public class UtteranceFileFormat extends Enum
{
static EnumValues values = init("UtteranceFileFormat");
public static UtteranceFileFormat DUMMY = new UtteranceFileFormat("dummy", "Dummy UtteranceFileFormat Value", false);
public static UtteranceFileFormat UNKNOWN = new UtteranceFileFormat("unknown", "Unknown UtteranceFileFormat Value", false);
public static UtteranceFileFormat EST_ASCII = new UtteranceFileFormat("est", "Est (ascii)");
public static UtteranceFileFormat XLABEL = new UtteranceFileFormat("xlabel", "Xwaves Label File");
public static UtteranceFileFormat GENXML = new UtteranceFileFormat("genxml", "Generic XML");
public UtteranceFileFormat(String s, String ls)
{
super(s, ls, null);
}
public UtteranceFileFormat(String s, String ls, boolean real)
{
super(s, ls, real);
}
public EnumValues getValuesTable()
{
return values;
}
public static UtteranceFileFormat getValue(String s)
throws IllegalArgumentException
{
return (UtteranceFileFormat)getValue(s, values);
}
public static Enum [] getValues()
{
return (Enum [])getValues(values);
}
}

View File

@@ -0,0 +1,355 @@
/*************************************************************************/
/* */
/* Centre for Speech Technology Research */
/* University of Edinburgh, UK */
/* Copyright (c) 1995,1996 */
/* All Rights Reserved. */
/* */
/* Permission is hereby granted, free of charge, to use and distribute */
/* this software and its documentation without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of this work, and to */
/* permit persons to whom this work is furnished to do so, subject to */
/* the following conditions: */
/* 1. The code must retain the above copyright notice, this list of */
/* conditions and the following disclaimer. */
/* 2. Any modifications must be clearly marked as such. */
/* 3. Original authors' names are not deleted. */
/* 4. The authors' names are not used to endorse or promote products */
/* derived from this software without specific prior written */
/* permission. */
/* */
/* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */
/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
/* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */
/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
/* THIS SOFTWARE. */
/* */
/*************************************************************************/
/* */
/* */
/* Author: Richard Caley <rjc@cstr.ed.ac.uk> */
/* ------------------------------------------------------------------- */
/* Interface between java and C++ for EST_Wave. */
/* */
/*************************************************************************/
#include <stdio.h>
#include <signal.h>
#include "jni_Wave.h"
#include "EST_Wave.h"
#include "EST_wave_aux.h"
#include "EST_audio.h"
#include "EST_inline_utils.h"
static jobject wave_class;
static jfieldID handle_field;
static inline short abs(short s) { return s>=0?s:-s; }
static EST_Option wave_play_ops;
JNIEXPORT jboolean JNICALL
Java_cstr_est_Wave_initialise_1cpp (JNIEnv *env, jclass myclass)
{
wave_class = env->NewGlobalRef(myclass);
handle_field = env->GetFieldID(myclass, "cpp_handle", "J");
if (!handle_field)
{
printf("can't find handle!\n");
return 0;
}
return 1;
}
JNIEXPORT jboolean JNICALL
Java_cstr_est_Wave_finalise_1cpp (JNIEnv *env, jclass myclass)
{
(void)env;
(void)myclass;
return 1;
}
JNIEXPORT jboolean JNICALL
Java_cstr_est_Wave_create_1cpp_1wave(JNIEnv *env, jobject self)
{
EST_Wave *wave = new EST_Wave;
env->SetLongField(self, handle_field, (jlong)wave);
return 1;
}
JNIEXPORT jboolean JNICALL
Java_cstr_est_Wave_destroy_1cpp_1wave (JNIEnv *env, jobject self)
{
EST_Wave *wave = (EST_Wave *) env->GetLongField(self, handle_field);
delete wave;
return 1;
}
JNIEXPORT jstring JNICALL
Java_cstr_est_Wave_cpp_1name (JNIEnv *env, jobject self)
{
EST_Wave *wave = (EST_Wave *) env->GetLongField(self, handle_field);
return env->NewStringUTF(wave->name());
}
JNIEXPORT void JNICALL
Java_cstr_est_Wave_cpp_1setName (JNIEnv *env, jobject self, jstring jname)
{
EST_Wave *wave = (EST_Wave *) env->GetLongField(self, handle_field);
const char *name=env->GetStringUTFChars(jname, 0);
wave->set_name(name);
env->ReleaseStringUTFChars(jname, name);
}
JNIEXPORT jstring JNICALL
Java_cstr_est_Wave_cpp_1load (JNIEnv *env, jobject self, jstring jfilename)
{
EST_Wave *wave = (EST_Wave *) env->GetLongField(self, handle_field);
const char *filename = env->GetStringUTFChars(jfilename, 0);
const char *res = "";
EST_read_status stat = wave->load(filename);
env->ReleaseStringUTFChars(jfilename, filename);
if (stat == read_format_error)
res = "wave format error";
else if (stat == read_error)
res = "wave load error";
return env->NewStringUTF(res);
}
JNIEXPORT jstring JNICALL
Java_cstr_est_Wave_cpp_1save (JNIEnv *env, jobject self, jstring jfilename, jstring jformat)
{
EST_Wave *wave = (EST_Wave *) env->GetLongField(self, handle_field);
const char *filename = env->GetStringUTFChars(jfilename, 0);
const char *format = env->GetStringUTFChars(jformat, 0);
const char *res = "";
EST_write_status stat = wave->save(filename, format);
env->ReleaseStringUTFChars(jfilename, filename);
env->ReleaseStringUTFChars(jformat, format);
if (stat == write_error)
res = "wave save error";
return env->NewStringUTF(res);
}
JNIEXPORT void JNICALL
Java_cstr_est_Wave_cpp_1resample (JNIEnv *env, jobject self, jint rate)
{
EST_Wave *wave = (EST_Wave *) env->GetLongField(self, handle_field);
wave->resample(rate);
}
JNIEXPORT void JNICALL
Java_cstr_est_Wave_cpp_1set_1play_1ops(JNIEnv *env, jclass myclass,
jstring jprotocol,
jstring jcommand,
jstring jserver
)
{
(void)myclass;
const char *protocol = env->GetStringUTFChars(jprotocol, 0);
const char *command = env->GetStringUTFChars(jcommand, 0);
const char *server = env->GetStringUTFChars(jserver, 0);
if (*protocol)
wave_play_ops.add_item("-p",protocol);
if (*command)
wave_play_ops.add_item("-command",command);
if (*server)
wave_play_ops.add_item("-display",server);
wave_play_ops.add_item("-otype","riff");
env->ReleaseStringUTFChars(jprotocol, protocol);
env->ReleaseStringUTFChars(jcommand, command);
env->ReleaseStringUTFChars(jserver, server);
}
JNIEXPORT void JNICALL
Java_cstr_est_Wave_cpp_1play (JNIEnv *env, jobject self,
jfloat start_t, jfloat end_t)
{
EST_Wave *wave = (EST_Wave *) env->GetLongField(self, handle_field);
EST_Wave wv;
int start = (int)(start_t * wave->sample_rate() + 0.5);
int end = (int)(end_t * wave->sample_rate() + 0.5);
wave_subwave(wv, *wave, start, end-start);
// EST_write_status st = wv.save("/tmp/est_java_wave", "nist");
play_wave(wv, wave_play_ops);
}
JNIEXPORT void JNICALL
Java_cstr_est_Wave_cpp_1play_1all (JNIEnv *env, jobject self)
{
EST_Wave *wave = (EST_Wave *) env->GetLongField(self, handle_field);
play_wave(*wave, wave_play_ops);
}
JNIEXPORT jint JNICALL
Java_cstr_est_Wave_cpp_1num_1channels(JNIEnv *env, jobject self)
{
EST_Wave *wave = (EST_Wave *) env->GetLongField(self, handle_field);
return wave->num_channels();
}
JNIEXPORT jint JNICALL
Java_cstr_est_Wave_cpp_1num_1samples(JNIEnv *env, jobject self)
{
EST_Wave *wave = (EST_Wave *) env->GetLongField(self, handle_field);
return wave->num_samples();
}
JNIEXPORT jint JNICALL
Java_cstr_est_Wave_cpp_1sample_1rate(JNIEnv *env, jobject self)
{
EST_Wave *wave = (EST_Wave *) env->GetLongField(self, handle_field);
return wave->sample_rate();
}
JNIEXPORT jint JNICALL
Java_cstr_est_Wave_cpp_1amplitude(JNIEnv *env, jobject self,
jint c)
{
EST_Wave *wave = (EST_Wave *) env->GetLongField(self, handle_field);
short a=0;
for(int i=0; i<wave->num_samples(); i++)
{
short p = wave->a(i,c);
if (abs(p) > a)
a=abs(p);
}
return a;
}
JNIEXPORT jint JNICALL
Java_cstr_est_Wave_a__II(JNIEnv *env, jobject self,
jint x,
jint c)
{
EST_Wave *wave = (EST_Wave *) env->GetLongField(self, handle_field);
return wave->a(x,c);
}
JNIEXPORT jint JNICALL
Java_cstr_est_Wave_a__FI(JNIEnv *env, jobject self,
jfloat t,
jint c)
{
EST_Wave *wave = (EST_Wave *) env->GetLongField(self, handle_field);
return wave->a(irint(t*wave->sample_rate()),c);
}
JNIEXPORT void JNICALL
Java_cstr_est_Wave_cpp_1getScanlines(JNIEnv *env, jobject self,
jint c,
jbyteArray line,
jint lstart, jint lnum,
jint xoff, jint chunk,
jint width, jint height,
jint amp)
{
EST_Wave *wave = (EST_Wave *) env->GetLongField(self, handle_field);
jbyte *pixels = env->GetByteArrayElements(line, 0);
int num_samples = wave->num_samples();
short *data = wave->values().memory();
int channels = wave->num_channels();
for(int l=lstart; l<lstart+lnum; l++)
{
int min = (int)((float)(height - l)*amp*2.0/height-amp+0.5);
int max = (int)((float)(height - l+1)*amp*2.0/height-amp+0.5);
jbyte *lpixels = pixels + (l-lstart)*chunk;
short la=0;
int from=(int)((float)xoff*num_samples/width+0.5);
for(int i=xoff; i<xoff+chunk; i++)
{
int fl=0;
int to = (int)((i+1.0)*num_samples/width+0.5);
for(int j=from; j<to; j++)
{
short a = data[j*channels + c];
if ((a>min && la <=max)|| (la > min && a <=max))
fl++;
la=a;
}
lpixels[i-xoff] = fl<5?fl:4;
from=to;
}
}
}
JNIEXPORT jint JNICALL
Java_cstr_est_Wave_cpp_1getMin(JNIEnv *env, jobject self,
jint c, jint x1, jint x2)
{
EST_Wave *wave = (EST_Wave *) env->GetLongField(self, handle_field);
int minv=64000;
if (x1<0) x1 = 0;
if (x2>wave->num_samples()) x2 = wave->num_samples();
for(int x=x1; x<x2; x++)
{
short v = wave->a(x,c);
if (v<minv)
minv=v;
}
return minv;
}
JNIEXPORT jint JNICALL
Java_cstr_est_Wave_cpp_1getMax(JNIEnv *env, jobject self,
jint c, jint x1, jint x2)
{
EST_Wave *wave = (EST_Wave *) env->GetLongField(self, handle_field);
int maxv=-64000;
if (x1<0) x1 = 0;
if (x2>wave->num_samples()) x2 = wave->num_samples();
for(int x=x1; x<x2; x++)
{
short v = wave->a(x, c);
if (v>maxv)
maxv=v;
}
return maxv;
}

View File

@@ -0,0 +1,227 @@
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Centre for Speech Technology Research \\
// University of Edinburgh, UK \\
// Copyright (c) 1996,1997 \\
// All Rights Reserved. \\
// Permission is hereby granted, free of charge, to use and distribute \\
// this software and its documentation without restriction, including \\
// without limitation the rights to use, copy, modify, merge, publish, \\
// distribute, sublicense, and/or sell copies of this work, and to \\
// permit persons to whom this work is furnished to do so, subject to \\
// the following conditions: \\
// 1. The code must retain the above copyright notice, this list of \\
// conditions and the following disclaimer. \\
// 2. Any modifications must be clearly marked as such. \\
// 3. Original authors' names are not deleted. \\
// 4. The authors' names are not used to endorse or promote products \\
// derived from this software without specific prior written \\
// permission. \\
// THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK \\
// DISCLAIM ALL WARRANTIES With REGARD TO THIS SOFTWARE, INCLUDING \\
// ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT \\
// SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE \\
// FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES \\
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN \\
// AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, \\
// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF \\
// THIS SOFTWARE. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
// Date: Friday 12th September 1997 \\
// -------------------------------------------------------------------- \\
// Wrapper around the EST_Wave class. This is pretty horrible in that \\
// it uses a long to hold a pointer to a wave. There must be a better \\
// way. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
package cstr.est;
import java.util.*;
import java.lang.*;
import java.io.*;
public class Wave
{
long cpp_handle;
int [] amplitudes;
public Wave()
{
create_cpp_wave();
}
public Wave(byte [] bytes)
throws UnsupportedEncodingException
{
if (!parse(bytes))
{
throw new UnsupportedEncodingException("Can't create Wave from this bytestream");
}
}
public Wave(File file)
throws UnsupportedEncodingException, IOException
{
throw new IOException("Can't load from files yet");
}
protected void finalize() throws Throwable
{
destroy_cpp_wave();
super.finalize();
}
public long getHandle()
{
return cpp_handle;
}
private native String cpp_name();
public String name()
{
return cpp_name();
}
private native void cpp_setName(String name);
public void setName(String name)
{
cpp_setName(name);
}
public String getName()
{
return cpp_name();
}
private native String cpp_load(String filename);
public void load(String filename) throws FileNotFoundException
{
String res = cpp_load(filename);
if (!res.equals(""))
throw new FileNotFoundException(res);
amplitudes = new int[num_channels()];
}
private native String cpp_save(String filename, String format);
public void save(String filename, String format) throws IOException
{
String res = cpp_save(filename, format);
if (!res.equals(""))
throw new IOException(res);
}
private native void cpp_resample(int rate);
public void resample(int rate)
{
cpp_resample(rate);
}
private static native void cpp_set_play_ops(String protocol,
String command,
String server);
public static void set_play_ops(String protocol,
String command,
String server)
{
cpp_set_play_ops(protocol, command, server);
}
private native void cpp_play(float start, float end);
public void play(float start, float end)
{
System.out.println("play st");
if (end > start)
cpp_play(start, end);
System.out.println("play end");
}
private native void cpp_play_all();
public void play()
{
cpp_play_all();
}
private native int cpp_num_samples();
public int num_samples()
{
return cpp_num_samples();
}
private native int cpp_num_channels();
public int num_channels()
{
return cpp_num_channels();
}
private native int cpp_sample_rate();
public int sample_rate()
{
return cpp_sample_rate();
}
private native int cpp_amplitude(int c);
public int amplitude(int c)
{
if (amplitudes[c] > 0)
return amplitudes[c];
int a = cpp_amplitude(c);
amplitudes[c] = a;
return a;
}
public native int a(int x, int c);
public native int a(float t, int c);
native public void cpp_getScanlines(int c,
byte[] line,
int lstart, int lnum,
int x, int chunk,
int width, int height,
int amplitude
);
public boolean parse(byte[] bytes)
{
return false;
}
native public final int cpp_getMin(int c, int x1, int x2);
native public final int cpp_getMax(int c, int x1, int x2);
private native static boolean initialise_cpp();
private native static boolean finalise_cpp();
private native boolean create_cpp_wave();
private native boolean destroy_cpp_wave();
static {
System.loadLibrary("estjava");
if (!initialise_cpp())
throw new ExceptionInInitializerError("Wave C++ fails");
}
}

View File

@@ -0,0 +1,135 @@
/*************************************************************************/
/* */
/* Centre for Speech Technology Research */
/* University of Edinburgh, UK */
/* Copyright (c) 1996 */
/* All Rights Reserved. */
/* */
/* Permission is hereby granted, free of charge, to use and distribute */
/* this software and its documentation without restriction, including */
/* without limitation the rights to use, copy, modify, merge, publish, */
/* distribute, sublicense, and/or sell copies of this work, and to */
/* permit persons to whom this work is furnished to do so, subject to */
/* the following conditions: */
/* 1. The code must retain the above copyright notice, this list of */
/* conditions and the following disclaimer. */
/* 2. Any modifications must be clearly marked as such. */
/* 3. Original authors' names are not deleted. */
/* 4. The authors' names are not used to endorse or promote products */
/* derived from this software without specific prior written */
/* permission. */
/* */
/* THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK */
/* DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING */
/* ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT */
/* SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE */
/* FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES */
/* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN */
/* AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, */
/* ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF */
/* THIS SOFTWARE. */
/* */
/*************************************************************************/
#include <stdio.h>
#include "jni_Skeleton.h"
#include "ling_class/EST_Skeleton.h"
static jobject skeleton_class;
static jfieldID handle_field;
static inline short abs(short s) { return s>0?s:-s; }
JNIEXPORT jboolean JNICALL
Java_cstr_est_Skeleton_initialise_1cpp (JNIEnv *env, jclass myclass)
{
skeleton_class = env->NewGlobalRef(myclass);
handle_field = env->GetFieldID(myclass, "handle", "J");
if (!handle_field)
{
printf("can't find handle!\n");
return 0;
}
return 1;
}
JNIEXPORT jboolean JNICALL
Java_cstr_est_Skeleton_finalise_1cpp (JNIEnv *env, jclass myclass)
{
(void)env;
(void)myclass;
return 1;
}
JNIEXPORT jboolean JNICALL
Java_cstr_est_Skeleton_create_11skeleton(JNIEnv *env, jobject self)
{
EST_Skeleton *skeleton = new EST_Skeleton;
// printf("create skeleton %p\n", skeleton);
env->SetLongField(self, handle_field, (jlong)skeleton);
return 1;
}
JNIEXPORT jboolean JNICALL
Java_cstr_est_Skeleton_destroy_11skeleton (JNIEnv *env, jobject self)
{
EST_Skeleton *skeleton = (EST_Skeleton *) env->GetLongField(self, handle_field);
// printf("destroy skeleton %p\n", skeleton);
delete skeleton;
return 1;
}
JNIEXPORT jstring JNICALL
Java_cstr_est_Skeleton_1name(JNIEnv *env, jobject self)
{
EST_Skeleton *skeleton = (EST_Skeleton *) env->GetLongField(self, handle_field);
return env->NewStringUTF(skeleton->name());
}
JNIEXPORT jstring JNICALL
Java_cstr_est_Skeleton_1load (JNIEnv *env, jobject self, jstring jfilename)
{
EST_Skeleton *skeleton = (EST_Skeleton *) env->GetLongField(self, handle_field);
const char *filename = env->GetStringUTFChars(jfilename, 0);
const char *res = "";
EST_read_status stat = skeleton->load(filename);
env->ReleaseStringUTFChars(jfilename, filename);
if (stat == read_format_error)
res = "skeleton format error";
else if (stat == read_error)
res = "skeleton load error";
return env->NewStringUTF(res);
}
JNIEXPORT jstring JNICALL
Java_cstr_est_Skeleton_1save (JNIEnv *env, jobject self, jstring jfilename, jstring jformat)
{
const EST_Skeleton *skeleton = (EST_Skeleton *) env->GetLongField(self, handle_field);
const char *filename = env->GetStringUTFChars(jfilename, 0);
const char *format = env->GetStringUTFChars(jformat, 0);
const char *res = "";
EST_write_status stat = skeleton->save(filename,format);
env->ReleaseStringUTFChars(jfilename, filename);
env->ReleaseStringUTFChars(jformat, format);
if (stat == write_error)
res = "skeleton save error";
return env->NewStringUTF(res);
}

View File

@@ -0,0 +1,105 @@
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Centre for Speech Technology Research \\
// University of Edinburgh, UK \\
// Copyright (c) 1996,1997 \\
// All Rights Reserved. \\
// Permission is hereby granted, free of charge, to use and distribute \\
// this software and its documentation without restriction, including \\
// without limitation the rights to use, copy, modify, merge, publish, \\
// distribute, sublicense, and/or sell copies of this work, and to \\
// permit persons to whom this work is furnished to do so, subject to \\
// the following conditions: \\
// 1. The code must retain the above copyright notice, this list of \\
// conditions and the following disclaimer. \\
// 2. Any modifications must be clearly marked as such. \\
// 3. Original authors' names are not deleted. \\
// 4. The authors' names are not used to endorse or promote products \\
// derived from this software without specific prior written \\
// permission. \\
// THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK \\
// DISCLAIM ALL WARRANTIES With REGARD TO THIS SOFTWARE, INCLUDING \\
// ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT \\
// SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE \\
// FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES \\
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN \\
// AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, \\
// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF \\
// THIS SOFTWARE. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
// Date: Tue Mar 31 1998 \\
// -------------------------------------------------------------------- \\
// Java wrapper around relations. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
package cstr.est.cpp ;
import java.lang.*;
import java.util.*;
import java.awt.*;
import java.io.*;
public class skeleton
{
private long cpp_handle;
public Skeleton()
{
create_cpp_utterance();
}
protected void finalize() throws Throwable
{
destroy_cpp_utterance();
super.finalize();
}
private native String cpp_name();
public String name()
{
return cpp_name();
}
private native String cpp_load(String filename);
public void load(String filename) throws FileNotFoundException
{
String res = cpp_load(filename);
if (!res.equals(""))
throw new FileNotFoundException(res);
}
private native int cpp_findItem(float time);
public int findItem(float time)
{
return cpp_findItem(time);
}
private native float cpp_getEndTime();
public float getEndTime()
{
return cpp_getEndTime();
}
private native static boolean initialise_cpp();
private native static boolean finalise_cpp();
private native boolean create_cpp_utterance();
private native boolean destroy_cpp_utterance();
static {
System.loadLibrary("estjava");
if (!initialise_cpp())
throw new ExceptionInInitializerError("Skeleton C++ fails");
}
}

67
java/java.mak Normal file
View File

@@ -0,0 +1,67 @@
###########################################################################
## ##
## Centre for Speech Technology Research ##
## University of Edinburgh, UK ##
## Copyright (c) 1996 ##
## All Rights Reserved. ##
## ##
## Permission is hereby granted, free of charge, to use and distribute ##
## this software and its documentation without restriction, including ##
## without limitation the rights to use, copy, modify, merge, publish, ##
## distribute, sublicense, and/or sell copies of this work, and to ##
## permit persons to whom this work is furnished to do so, subject to ##
## the following conditions: ##
## 1. The code must retain the above copyright notice, this list of ##
## conditions and the following disclaimer. ##
## 2. Any modifications must be clearly marked as such. ##
## 3. Original authors' names are not deleted. ##
## 4. The authors' names are not used to endorse or promote products ##
## derived from this software without specific prior written ##
## permission. ##
## ##
## THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK ##
## DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ##
## ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT ##
## SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE ##
## FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ##
## WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN ##
## AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ##
## ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF ##
## THIS SOFTWARE. ##
## ##
###########################################################################
## ##
## Author: Richard Caley (rjc@cstr.ed.ac.uk) ##
## Date: Wed May 27 1998 ##
## -------------------------------------------------------------------- ##
## Make rules for Java module ##
## ##
###########################################################################
INCLUDE_JAVA=1
MOD_DESC_JAVA=Basic Java classes
ifeq ($(DIRNAME),.)
EXTRA_LIB_BUILD_DIRS := java $(EXTRA_LIB_BUILD_DIRS)
endif
include $(EST)/config/compilers/$(JAVA_COMPILER).mak
ifndef JAVA_COMPILER
.config_error:: FORCE
@echo "+--------------------------------------------------"
@echo "| No Java compiler specified"
@echo "+--------------------------------------------------"
@exit 1
endif
ifeq ($(JAVA_COMPILER),none)
.config_error:: FORCE
@echo "+--------------------------------------------------"
@echo "| No Java compiler specified"
@echo "+--------------------------------------------------"
@exit 1
endif

71
java/java_cpp.mak Normal file
View File

@@ -0,0 +1,71 @@
###########################################################################
## ##
## Centre for Speech Technology Research ##
## University of Edinburgh, UK ##
## Copyright (c) 1996 ##
## All Rights Reserved. ##
## ##
## Permission is hereby granted, free of charge, to use and distribute ##
## this software and its documentation without restriction, including ##
## without limitation the rights to use, copy, modify, merge, publish, ##
## distribute, sublicense, and/or sell copies of this work, and to ##
## permit persons to whom this work is furnished to do so, subject to ##
## the following conditions: ##
## 1. The code must retain the above copyright notice, this list of ##
## conditions and the following disclaimer. ##
## 2. Any modifications must be clearly marked as such. ##
## 3. Original authors' names are not deleted. ##
## 4. The authors' names are not used to endorse or promote products ##
## derived from this software without specific prior written ##
## permission. ##
## ##
## THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK ##
## DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ##
## ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT ##
## SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE ##
## FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ##
## WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN ##
## AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ##
## ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF ##
## THIS SOFTWARE. ##
## ##
###########################################################################
## ##
## Author: Richard Caley (rjc@cstr.ed.ac.uk) ##
## Date: Wed May 27 1998 ##
## -------------------------------------------------------------------- ##
## Make rules for Java module ##
## ##
###########################################################################
INCLUDE_JAVA_CPP=1
MOD_DESC_JAVA_CPP=Java interface to C++ classes
PROJECT_LIBRARIES := $(PROJECT_LIBRARIES_JAVA) $(PROJECT_LIBRARIES)
PROJECT_SHARED_LIBRARIES := $(PROJECT_SHARED_LIBRARIES) $(PROJECT_LIBRARIES_JAVA)
PROJECT_ALL_LIBRARIES := $(PROJECT_ALL_LIBRARIES) $(PROJECT_LIBRARIES_JAVA)
ifeq ($(DIRNAME),java)
VERSION_DIRS += cpp_version
endif
ifndef SHARED
.config_error:: FORCE
@echo "+--------------------------------------------------"
@echo "| Must compile SHARED to include Java support."
@echo "+--------------------------------------------------"
@exit 1
endif
ifndef INCLUDE_JAVA
.config_error:: FORCE
@echo "+--------------------------------------------------"
@echo "| Must include java support to get Java C++ support"
@echo "| of C++ classes"
@echo "+--------------------------------------------------"
@exit 1
endif

61
java/java_media.mak Normal file
View File

@@ -0,0 +1,61 @@
###########################################################################
## ##
## Centre for Speech Technology Research ##
## University of Edinburgh, UK ##
## Copyright (c) 1996 ##
## All Rights Reserved. ##
## ##
## Permission is hereby granted, free of charge, to use and distribute ##
## this software and its documentation without restriction, including ##
## without limitation the rights to use, copy, modify, merge, publish, ##
## distribute, sublicense, and/or sell copies of this work, and to ##
## permit persons to whom this work is furnished to do so, subject to ##
## the following conditions: ##
## 1. The code must retain the above copyright notice, this list of ##
## conditions and the following disclaimer. ##
## 2. Any modifications must be clearly marked as such. ##
## 3. Original authors' names are not deleted. ##
## 4. The authors' names are not used to endorse or promote products ##
## derived from this software without specific prior written ##
## permission. ##
## ##
## THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK ##
## DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ##
## ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT ##
## SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE ##
## FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ##
## WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN ##
## AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ##
## ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF ##
## THIS SOFTWARE. ##
## ##
###########################################################################
## ##
## Author: Richard Caley (rjc@cstr.ed.ac.uk) ##
## Date: Wed May 27 1998 ##
## -------------------------------------------------------------------- ##
## Make rules for Java module ##
## ##
###########################################################################
INCLUDE_JAVA_MEDIA=1
MOD_DESC_JAVA_MEDIA=Java interface with Media API support
ifeq ($(DIRNAME),java)
VERSION_DIRS += media_version
endif
SYSTEM_JAVA_CLASSPATH:=$(SYSTEM_JAVA_MEDIA_CLASSPATH):$(SYSTEM_JAVA_CLASSPATH)
SYSTEM_LD_LIBRARY_PATH:=$(SYSTEM_JAVA_MEDIA_LIBRARY):$(SYSTEM_LD_LIBRARY_PATH)
ifndef INCLUDE_JAVA
.config_error:: FORCE
@echo "+--------------------------------------------------"
@echo "| Must include java support to get Java media API"
@echo "| support."
@echo "+--------------------------------------------------"
@exit 1
endif

View File

@@ -0,0 +1,47 @@
###########################################################################
## ##
## Centre for Speech Technology Research ##
## University of Edinburgh, UK ##
## Copyright (c) 1996 ##
## All Rights Reserved. ##
## ##
## Permission is hereby granted, free of charge, to use and distribute ##
## this software and its documentation without restriction, including ##
## without limitation the rights to use, copy, modify, merge, publish, ##
## distribute, sublicense, and/or sell copies of this work, and to ##
## permit persons to whom this work is furnished to do so, subject to ##
## the following conditions: ##
## 1. The code must retain the above copyright notice, this list of ##
## conditions and the following disclaimer. ##
## 2. Any modifications must be clearly marked as such. ##
## 3. Original authors' names are not deleted. ##
## 4. The authors' names are not used to endorse or promote products ##
## derived from this software without specific prior written ##
## permission. ##
## ##
## THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK ##
## DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ##
## ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT ##
## SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE ##
## FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ##
## WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN ##
## AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ##
## ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF ##
## THIS SOFTWARE. ##
## ##
###########################################################################
TOP=../..
DIRNAME=java/media_version
FILES = Makefile Makefile.version
BUILD_DIRS=cstr
NEED_JAVA=true
ALL = .sub_directories .javalib
include $(TOP)/config/common_make_rules
-include Makefile.version

View File

@@ -0,0 +1,42 @@
###########################################################################
## ##
## Centre for Speech Technology Research ##
## University of Edinburgh, UK ##
## Copyright (c) 1996 ##
## All Rights Reserved. ##
## ##
## Permission is hereby granted, free of charge, to use and distribute ##
## this software and its documentation without restriction, including ##
## without limitation the rights to use, copy, modify, merge, publish, ##
## distribute, sublicense, and/or sell copies of this work, and to ##
## permit persons to whom this work is furnished to do so, subject to ##
## the following conditions: ##
## 1. The code must retain the above copyright notice, this list of ##
## conditions and the following disclaimer. ##
## 2. Any modifications must be clearly marked as such. ##
## 3. Original authors' names are not deleted. ##
## 4. The authors' names are not used to endorse or promote products ##
## derived from this software without specific prior written ##
## permission. ##
## ##
## THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK ##
## DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ##
## ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT ##
## SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE ##
## FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ##
## WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN ##
## AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ##
## ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF ##
## THIS SOFTWARE. ##
## ##
###########################################################################
## Suplimental make information for this version
CODE_VERSION=media
LOCAL_JAVA_CLASS_LIBRARY=$(TOP)/lib/est_$(CODE_VERSION).jar
LOCAL_JAVA_CLASSPATH=$(EST_HOME)/speech_tools/lib/est_$(CODE_VERSION).jar
JAVA_TOP_PACK=cstr
LOCAL_JAVA_ROOT=$(TOP)/java/$(CODE_VERSION)_version_build

View File

@@ -0,0 +1,51 @@
###########################################################################
## ##
## Centre for Speech Technology Research ##
## University of Edinburgh, UK ##
## Copyright (c) 1996 ##
## All Rights Reserved. ##
## ##
## Permission is hereby granted, free of charge, to use and distribute ##
## this software and its documentation without restriction, including ##
## without limitation the rights to use, copy, modify, merge, publish, ##
## distribute, sublicense, and/or sell copies of this work, and to ##
## permit persons to whom this work is furnished to do so, subject to ##
## the following conditions: ##
## 1. The code must retain the above copyright notice, this list of ##
## conditions and the following disclaimer. ##
## 2. Any modifications must be clearly marked as such. ##
## 3. Original authors' names are not deleted. ##
## 4. The authors' names are not used to endorse or promote products ##
## derived from this software without specific prior written ##
## permission. ##
## ##
## THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK ##
## DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ##
## ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT ##
## SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE ##
## FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ##
## WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN ##
## AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ##
## ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF ##
## THIS SOFTWARE. ##
## ##
###########################################################################
TOP=../../..
DIRNAME=java/media_version/cstr
ALL_DIRS = est
BUILD_DIRS = awt est util testPrograms
NEED_JAVA = true
FILES = Makefile
ALL = .sub_directories
-include ../../../Makefile.version
include $(TOP)/config/common_make_rules

View File

@@ -0,0 +1,134 @@
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Centre for Speech Technology Research \\
// University of Edinburgh, UK \\
// Copyright (c) 1996,1997 \\
// All Rights Reserved. \\
// Permission is hereby granted, free of charge, to use and distribute \\
// this software and its documentation without restriction, including \\
// without limitation the rights to use, copy, modify, merge, publish, \\
// distribute, sublicense, and/or sell copies of this work, and to \\
// permit persons to whom this work is furnished to do so, subject to \\
// the following conditions: \\
// 1. The code must retain the above copyright notice, this list of \\
// conditions and the following disclaimer. \\
// 2. Any modifications must be clearly marked as such. \\
// 3. Original authors' names are not deleted. \\
// 4. The authors' names are not used to endorse or promote products \\
// derived from this software without specific prior written \\
// permission. \\
// THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK \\
// DISCLAIM ALL WARRANTIES With REGARD TO THIS SOFTWARE, INCLUDING \\
// ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT \\
// SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE \\
// FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES \\
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN \\
// AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, \\
// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF \\
// THIS SOFTWARE. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
// -------------------------------------------------------------------- \\
// Pretended EST_Features class. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
package cstr.est;
import java.lang.*;
import java.util.*;
import cstr.util.*;
public class Features
implements Featured
{
String [] cachedFeatureNames;
public Features()
{
this(0L, true);
}
public Features(long handle)
{
this(handle, false);
}
Features(long handle, boolean m)
{
}
protected void finalize() throws Throwable
{
super.finalize();
}
public String [] names()
{
if (cachedFeatureNames ==null)
cachedFeatureNames = new String [0];
return cachedFeatureNames;
}
public void getPaths(String prefix, Vector names, boolean paths, boolean leaves)
{
}
public boolean present(String n)
{
return false;
}
public String getS(String n)
{
return "";
}
public String getS(String n, String def)
{
return def;
}
public String getFeature(String n)
{
return "";
}
public float getF(String n)
{
return (float)0.0;
}
public float getF(String n, float def)
{
return def;
}
public Object get(String n)
{
return null;
}
public Object get(String n, Object def)
{
return def;
}
public void set(String n, float val)
{
}
public void set(String n, String val)
{
}
static {
}
}

View File

@@ -0,0 +1,164 @@
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Centre for Speech Technology Research \\
// University of Edinburgh, UK \\
// Copyright (c) 1996,1997 \\
// All Rights Reserved. \\
// Permission is hereby granted, free of charge, to use and distribute \\
// this software and its documentation without restriction, including \\
// without limitation the rights to use, copy, modify, merge, publish, \\
// distribute, sublicense, and/or sell copies of this work, and to \\
// permit persons to whom this work is furnished to do so, subject to \\
// the following conditions: \\
// 1. The code must retain the above copyright notice, this list of \\
// conditions and the following disclaimer. \\
// 2. Any modifications must be clearly marked as such. \\
// 3. Original authors' names are not deleted. \\
// 4. The authors' names are not used to endorse or promote products \\
// derived from this software without specific prior written \\
// permission. \\
// THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK \\
// DISCLAIM ALL WARRANTIES With REGARD TO THIS SOFTWARE, INCLUDING \\
// ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT \\
// SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE \\
// FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES \\
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN \\
// AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, \\
// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF \\
// THIS SOFTWARE. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
// Date: Tue Mar 31 1998 \\
// -------------------------------------------------------------------- \\
// Java wrapper around items. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
package cstr.est;
import java.lang.*;
import java.util.*;
import java.awt.*;
import cstr.util.*;
import java.io.*;
public class Item
implements Named, Keyed, Featured
{
public Item()
{
this(0L, true, null);
}
public Item(long handle)
{
this(handle, false, null);
}
public Item(long handle, Object utterance)
{
this(handle, false, utterance);
}
Item(long handle, boolean m, Object from_utterance)
{
}
protected void finalize() throws Throwable
{
super.finalize();
}
protected final Item getItem(long handle)
{
return null;
}
public String name()
{
return null;
}
public String getName()
{
return null;
}
public void setName(String name)
{
}
public final Item_Content getContent()
{
return null;
}
public final Object getKey()
{
return null;
}
public String getS(String n)
{
return null;
}
public String getS(String n, String def)
{
return def;
}
public String getFeature(String n)
{
return null;
}
public float getF(String n)
{
return (float)0.0;
}
public String type()
{
return null;
}
public float getStartTime()
{
return (float)0.0;
}
public float getMidTime()
{
return (float)0.0;
}
public float getEndTime()
{
return (float)0.0;
}
public Item next()
{
return null;
}
public Item prev()
{
return null;
}
public Item up()
{
return null;
}
public Item down()
{
return null;
}
}

View File

@@ -0,0 +1,132 @@
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Centre for Speech Technology Research \\
// University of Edinburgh, UK \\
// Copyright (c) 1996,1997 \\
// All Rights Reserved. \\
// Permission is hereby granted, free of charge, to use and distribute \\
// this software and its documentation without restriction, including \\
// without limitation the rights to use, copy, modify, merge, publish, \\
// distribute, sublicense, and/or sell copies of this work, and to \\
// permit persons to whom this work is furnished to do so, subject to \\
// the following conditions: \\
// 1. The code must retain the above copyright notice, this list of \\
// conditions and the following disclaimer. \\
// 2. Any modifications must be clearly marked as such. \\
// 3. Original authors' names are not deleted. \\
// 4. The authors' names are not used to endorse or promote products \\
// derived from this software without specific prior written \\
// permission. \\
// THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK \\
// DISCLAIM ALL WARRANTIES With REGARD TO THIS SOFTWARE, INCLUDING \\
// ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT \\
// SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE \\
// FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES \\
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN \\
// AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, \\
// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF \\
// THIS SOFTWARE. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
// Date: Wed Feb 25 1998 \\
// -------------------------------------------------------------------- \\
// Items in a stream. Wrapper around EST_StreamItem. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
package cstr.est ;
import java.lang.*;
import java.util.*;
import java.awt.*;
import cstr.util.*;
public class Item_Content
implements Featured
{
public Item_Content()
{
this(0L, true);
}
public Item_Content(long handle)
{
this(handle, false);
}
Item_Content(long handle, boolean m)
{
}
protected void finalize() throws Throwable
{
super.finalize();
}
public String name()
{
return "DUMMY";
}
public String getName()
{
return name();
}
public Features getFeatures()
{
return new Features();
}
public Item getItem()
{
return null;
}
public String [] featureNames()
{
return null;
}
public boolean featurePresent(String n)
{
return false;
}
public String getS(String n)
{
return null;
}
public String getFeature(String n)
{
return null;
}
public float getF(String n)
{
return (float)0.0;
}
public float getStartTime()
{
return (float)0.0;
}
public float getMidTime()
{
return (float)0.0;
}
public float getEndTime()
{
return (float)0.0;
}
}

View File

@@ -0,0 +1,58 @@
###########################################################################
## ##
## Centre for Speech Technology Research ##
## University of Edinburgh, UK ##
## Copyright (c) 1996 ##
## All Rights Reserved. ##
## ##
## Permission is hereby granted, free of charge, to use and distribute ##
## this software and its documentation without restriction, including ##
## without limitation the rights to use, copy, modify, merge, publish, ##
## distribute, sublicense, and/or sell copies of this work, and to ##
## permit persons to whom this work is furnished to do so, subject to ##
## the following conditions: ##
## 1. The code must retain the above copyright notice, this list of ##
## conditions and the following disclaimer. ##
## 2. Any modifications must be clearly marked as such. ##
## 3. Original authors' names are not deleted. ##
## 4. The authors' names are not used to endorse or promote products ##
## derived from this software without specific prior written ##
## permission. ##
## ##
## THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK ##
## DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING ##
## ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT ##
## SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE ##
## FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES ##
## WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN ##
## AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ##
## ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF ##
## THIS SOFTWARE. ##
## ##
###########################################################################
TOP=../../../..
DIRNAME = java/media_version/cstr/est
JUST_BUILD_DIRS = awt
ALL_DIRS =
LOCAL_JAVA_NATIVE_CLASSES =
JAVA_NATIVE_CLASSES =$(LOCAL_JAVA_NATIVE_CLASSES)
LOCAL_JAVA_CLASSES = $(LOCAL_JAVA_NATIVE_CLASSES) Wave WaveDataSource Item_Content Item Features
JAVA_CLASSES = $(LOCAL_JAVA_CLASSES) SocketsFile ServerConnection
CPPSRCS = $(JAVA_NATIVE_CLASSES:%=%.cc)
SRCS = $(CPPSRCS)
OBJS_estjava = $(SRCS:.cc=.o)
FILES = $(LOCAL_JAVA_CLASSES:%=%.java) $(LOCAL_JAVA_NATIVE_CLASSES:%=%.cc) Makefile
ALL = .java
-include ../../Makefile.version
include $(TOP)/config/common_make_rules

View File

@@ -0,0 +1,351 @@
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Centre for Speech Technology Research \\
// University of Edinburgh, UK \\
// Copyright (c) 1996,1997 \\
// All Rights Reserved. \\
// Permission is hereby granted, free of charge, to use and distribute \\
// this software and its documentation without restriction, including \\
// without limitation the rights to use, copy, modify, merge, publish, \\
// distribute, sublicense, and/or sell copies of this work, and to \\
// permit persons to whom this work is furnished to do so, subject to \\
// the following conditions: \\
// 1. The code must retain the above copyright notice, this list of \\
// conditions and the following disclaimer. \\
// 2. Any modifications must be clearly marked as such. \\
// 3. Original authors' names are not delete. \\
// 4. The authors' names are not used to endorse or promote products \\
// derived from this software without specific prior written \\
// permission. \\
// THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK \\
// DISCLAIM ALL WARRANTIES With REGARD TO THIS SOFTWARE, INCLUDING \\
// ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT \\
// SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE \\
// FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES \\
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN \\
// AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, \\
// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF \\
// THIS SOFTWARE. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
// -------------------------------------------------------------------- \\
// A simple java wave class. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
package cstr.est ;
import java.lang.*;
import java.util.*;
import java.net.*;
import java.io.*;
import javax.media.*;
import javax.media.protocol.*;
class PlayWatcher
implements ControllerListener
{
private boolean finished;
public PlayWatcher()
{
finished=false;
}
public synchronized void waitForPlay()
{
while (!finished)
try {
this.wait();
} catch (InterruptedException e) {
}
}
public synchronized void controllerUpdate(ControllerEvent e)
{
Player p = (Player)e.getSourceController();
if (e instanceof StopEvent)
{
p.removeControllerListener(this);
p.deallocate();
p.close();
finished=true;
this.notifyAll();
}
}
}
public class Wave
{
int amplitude_cache=-1;
short [] samples;
// byte [] sbytes;
int channels;
int sample_rate;
File fn;
public Wave()
{
samples=null;
fn=null;
}
public Wave(byte [] bytes)
throws UnsupportedEncodingException
{
fn=null;
if (!parse(bytes))
{
throw new UnsupportedEncodingException("Can't create Wave from this bytestream");
}
}
public Wave(File file)
throws UnsupportedEncodingException, IOException
{
fn=null;
FileInputStream is = new FileInputStream(file);
int n=0;
byte [] buf = new byte[n];
while (true)
{
byte [] ibuf = new byte[10240];
int nr = is.read(ibuf, 0, 10240);
if (nr == -1)
break;
if (n==0)
{
buf = ibuf;
n = nr;
}
else
{
byte [] nbuf = new byte[n+nr];
for(int i=0; i<n; i++)
nbuf[i] = buf[i];
for(int i=0; i<nr; i++)
nbuf[i+n] = ibuf[i];
buf=nbuf;
n += nr;
}
}
if (!parse(buf))
{
throw new UnsupportedEncodingException("Can't create Wave from this bytestream");
}
}
public void finalize()
{
if (fn != null)
fn.delete();
}
public String name()
{
return toString();
}
public void resample(int rate)
{
}
public int amplitude(int c)
{
if (amplitude_cache<0)
for(int i=0; i<samples.length; i++)
{
short d=samples[i];
if (d>=0 && d > amplitude_cache)
amplitude_cache=d;
if (d<0 && -d > amplitude_cache)
amplitude_cache=-d;
}
return amplitude_cache;
}
public int num_samples()
{
return samples.length;
}
public void cpp_getScanlines(int c,
byte[] line,
int lstart, int lnum,
int x, int chunk,
int width, int height,
int amplitude
)
{
}
private File mkFilename()
{
StringBuffer fn= new StringBuffer(50);
fn.append("/tmp/jsapi_");
fn.append(this.toString());
fn.append(".au");
return new File(fn.toString());
}
private final int mkint(byte b0, byte b1, byte b2, byte b3)
{
int r = (((short)b3) & 255);
r += (((short)b2) & 255) << 8;
r += (((short)b1) & 255) << 16;
r += (((short)b0) & 255) << 24;
return r;
}
private final short mkshort(byte b0, byte b1)
{
short r = (short)(((short)b1) & 255);
r += (short)(((short)b0) & 255) << 8;
return r;
}
public boolean parse(byte[] bytes)
{
int magic = (bytes[0] <<24) + (bytes[1] <<16) + (bytes[2] <<8) + bytes[3];
int smagic = (bytes[3] <<24) + (bytes[2] <<16) + (bytes[1] <<8) + bytes[0];
if (magic == 0x2e736e64)
{
// Sun snd, shorts, unswapped
int hdr_size = mkint(bytes[4], bytes[5], bytes[6], bytes[7]);
int hdr_data_size = mkint(bytes[8], bytes[9], bytes[10], bytes[11]);
int hdr_encoding = mkint(bytes[12], bytes[13], bytes[14], bytes[15]);
int hdr_sample_rate = mkint(bytes[16], bytes[17], bytes[18], bytes[19]);
int hdr_channels = mkint(bytes[20], bytes[21], bytes[22], bytes[23]);
if (hdr_encoding != 3)
return false;
sample_rate = hdr_sample_rate;
channels = hdr_channels;
int pos = hdr_size;
int nsamples = (bytes.length-pos)/2/channels;
// System.out.println("sr="+sample_rate+" c="+channels+" nsamp="+nsamples);
samples = new short[nsamples];
//sbytes = new byte[nsamples*2];
for(int s=0; s<nsamples; s++, pos+=2)
{
samples[s] = mkshort(bytes[pos], bytes[pos+1]);
//sbytes[s*2] = bytes[pos];
//sbytes[s*2+1] = bytes[pos+1];
}
return true;
}
return false;
}
public void play()
{
playMedia();
}
public void playMedia()
{
if (samples != null)
try {
DataSource source = new WaveDataSource(this);
source.connect();
Player player = Manager.createPlayer(source);
//System.err.println("content type="+source.getContentType());
PlayWatcher pw = new PlayWatcher();
player.addControllerListener(pw);
// player.prefetch();
player.start();
pw.waitForPlay();
} catch (IOException ex) {
//System.err.println("Can't play "+fn+": "+ex.getMessage());
// } catch (NoDataSourceException ex) {
// System.err.println("No player for "+fn+": "+ex.getMessage());
} catch (NoPlayerException ex) {
System.err.println("No player for "+fn+": "+ex.getMessage());
}
}
public void playFile()
{
fn=mkFilename();
try {
FileOutputStream os = new FileOutputStream(fn);
// os.write(bytes);
os.close();
} catch (IOException ex) {
System.err.println("IO Exception: "+ex.getMessage());
return;
}
if (fn != null)
{
try {
MediaLocator locator = new MediaLocator(new URL("file:"+fn));
DataSource source = Manager.createDataSource(locator);
Player player = Manager.createPlayer(source);
//System.err.println("content type="+source.getContentType());
PlayWatcher pw = new PlayWatcher();
player.addControllerListener(pw);
player.prefetch();
player.start();
pw.waitForPlay();
} catch (IOException ex) {
System.err.println("Can't play "+fn+": "+ex.getMessage());
} catch (NoDataSourceException ex) {
System.err.println("No player for "+fn+": "+ex.getMessage());
} catch (NoPlayerException ex) {
System.err.println("No player for "+fn+": "+ex.getMessage());
}
}
}
public void stop()
{
}
public void load(String filename) throws FileNotFoundException
{
throw new FileNotFoundException("Load Not yet Implemented");
}
public void save(String filename, String format) throws IOException
{
throw new IOException("Save Not yet Implemented");
}
}

View File

@@ -0,0 +1,249 @@
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Centre for Speech Technology Research \\
// University of Edinburgh, UK \\
// Copyright (c) 1996,1997 \\
// All Rights Reserved. \\
// Permission is hereby granted, free of charge, to use and distribute \\
// this software and its documentation without restriction, including \\
// without limitation the rights to use, copy, modify, merge, publish, \\
// distribute, sublicense, and/or sell copies of this work, and to \\
// permit persons to whom this work is furnished to do so, subject to \\
// the following conditions: \\
// 1. The code must retain the above copyright notice, this list of \\
// conditions and the following disclaimer. \\
// 2. Any modifications must be clearly marked as such. \\
// 3. Original authors' names are not deleted. \\
// 4. The authors' names are not used to endorse or promote products \\
// derived from this software without specific prior written \\
// permission. \\
// THE UNIVERSITY OF EDINBURGH AND THE CONTRIBUTORS TO THIS WORK \\
// DISCLAIM ALL WARRANTIES With REGARD TO THIS SOFTWARE, INCLUDING \\
// ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT \\
// SHALL THE UNIVERSITY OF EDINBURGH NOR THE CONTRIBUTORS BE LIABLE \\
// FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES \\
// WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN \\
// AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, \\
// ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF \\
// THIS SOFTWARE. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
// \\
// Author: Richard Caley (rjc@cstr.ed.ac.uk) \\
// -------------------------------------------------------------------- \\
// Connect a wave to the media API as a dource of sound to play. \\
// \\
//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\//\\
package cstr.est ;
import java.lang.*;
import java.util.*;
import java.net.*;
import java.io.*;
import javax.media.*;
import javax.media.protocol.*;
class WavePullSourceStream implements PullSourceStream
{
ContentDescriptor cd;
Wave wave;
byte [] header;
int hpos;
int pos;
int length;
public WavePullSourceStream(Wave wv)
{
wave=wv;
pos=-1;
hpos=0;
cd = new ContentDescriptor("audio.basic");
header = new byte[24];
fill_in_header(header, 0);
}
public ContentDescriptor getContentDescriptor()
{
return cd;
}
public long getContentLength()
{
return 24L + wave.samples.length*2;
}
public boolean endOfStream()
{
return pos >= wave.samples.length;
}
public boolean willReadBlock()
{
return false;
}
private final void insert_int(byte b[], int p, int v)
{
b[p++] = (byte)((v >>24)&255);
b[p++] = (byte)((v >>16)&255);
b[p++] = (byte)((v >>8)&255);
b[p++] = (byte)((v)&255);
}
private int fill_in_header(byte b[], int p)
{
insert_int(b, p, 0x2e736e64);
insert_int(b, p+4, 24);
insert_int(b, p+8, wave.samples.length*2);
insert_int(b, p+12, 3);
insert_int(b, p+16, wave.sample_rate);
insert_int(b, p+20, wave.channels);
return 24;
}
public int read(byte buffer[],
int offset,
int length)
{
int n=0;
// System.out.println("read o="+offset+" l="+length);
if (pos == -2)
return -1;
if (pos < 0)
{
n = header.length;
if (n > length)
n = length;
for(int b=0; b<n; b++)
buffer[offset++] = header[b+hpos];
hpos += n;
if (hpos >= header.length)
pos=0;
return n;
}
int nsamp = length/2;
// System.out.println("\tnsamp="+nsamp+" pos="+pos+" len="+wave.samples.length);
if (nsamp > wave.samples.length-pos)
nsamp = wave.samples.length-pos;
// System.out.println("\tnsamp="+nsamp);
for(int s=0; s<nsamp; s++)
{
short samp = wave.samples[s+pos];
buffer[offset++] = (byte)((samp>>8)&255);
buffer[offset++] = (byte)(samp&255);
// buffer[offset++] = wave.sbytes[(s+pos)*2];
// buffer[offset++] = wave.sbytes[(s+pos)*2+1];
}
if (nsamp==0)
pos =-2;
else
pos += nsamp;
return nsamp*2;
}
public Object[] getControls()
{
return new Object[0];
}
public Object getControl(String controlType)
{
return null;
}
}
public class WaveDataSource extends PullDataSource
{
MediaLocator locator;
Wave wave;
WavePullSourceStream stream;
public WaveDataSource(Wave wv)
{
super();
wave=wv;
}
public void connect()
{
stream = new WavePullSourceStream(wave);
}
public void disconnect()
{
stream = null;
}
public void initCheck()
throws Error
{
if (stream==null)
throw new Error("Uninitialised Data Source Error");
}
public String getContentType()
{
if (stream != null)
return stream.getContentDescriptor().getContentType();
return "audio.basic";
}
public void setLocator(MediaLocator l)
{
locator=l;
}
public MediaLocator getLocator()
{
return locator;
}
public void start()
{
initCheck();
}
public void stop()
{
initCheck();
}
public PullSourceStream[] getStreams()
{
initCheck();
return new PullSourceStream[] {stream};
}
public Time getDuration()
{
initCheck();
return new Time((double)wave.samples.length/(double)wave.sample_rate);
}
public Object[] getControls()
{
return new Object[0];
}
public Object getControl(String controlType)
{
return null;
}
}