Cross-platform digital signal processing designs using Java and C6128011Abstract A platform-independent software-implemented digital signal processing system in a computer system. The digital signal processing system is comprised of a digital signal processing unit implemented in C program code which receives data and applies a process to generate therefrom a computer file representative of a processed response. The digital signal processing system also is comprised of a graphical user interface implemented in Java program code, which generates two-dimensional graphic images and text on the computer system's user output device, and is for receiving user-selected process parameters and for displaying the results of the processed response. In addition, the digital signal processing system is comprised of an interface code which provides communication between the graphical user interface and the digital signal processing unit. The interface code is implemented in Java program code and operable such that the digital signal processing unit and graphical user interface, in combination, are platform-independent. In this manner, the present invention provides a DSP software program that includes a graphical user interface section but yet can be operated across multiple computer system platforms without needing to be redesigned or customized for each platform. Claims What is claimed is: Description TECHNICAL FIELD
______________________________________
Code Section A - Exemplary Front-End GUI
______________________________________
/**
* Class fegui - Top Front End GUI
* @version %I% %G%
* @see fefir, feiir, fegd
*/
import java.awt.*;
import java.awt.event.*;
public class fegui extends Frame implements ActionListener {
Toolkit toolkit = this.getToolkit();.sub.--
Image i = toolkit.getImage("sony.bmp");
public fegui(String title) {
super(title);
this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
}
);
this.setFont(new Font("Helvetica",Font.BOLD,16));
this.setIconImage(i);
MenuBar menubar = new MenuBar();
this.setMenuBar(menubar);
Menu filter = new Menu("Design Options");
menubar.add(filter);
MenuItem fir = new MenuItem("IIR filters", new
MenuShortcut(KeyEvent.VK.sub.-- F));
fir.setActionCommand("fir");
fir.addActionListener(this);
filter.add(fir);
MenuItem iir = new MenuItem("IIR filters", new
MenuShortcut(KeyEvent.VK.sub.-- I));
iir.setActionCommand("iir");
iir.adActionLstener(this);
filter.add(iir);
MenuItem gd = new MenuItem("General I/O", new
MenuShortcut(KeyEvent.VK.sub.-- G));
gd.setActionCommand("gd");
gd.addActionListener(this);
filter.add(gd);
MenuItem quit = new MenuItem("Quit", new
MenuShortcut(KeyEvent.VK.sub.-- Q));
quit.setActionCommand("quit");
quit.addActionListener(this);
filter.add(quit);
Menu help = new Menu("Help");
menubar.add(help);
menubar.setHelpMenu(help);
MenuItem about = new MenuItem("About", new
MenuShortcut(KeyEvent.VK.sub.-- H));
about.setActionCommand("about");
about.addActionListener(this);
help.add(about);
MenuItem frh = new MenuItem("FIR HELP", new
MenuShortcut(KeyEvent.VK.sub.-- B));
firh.SetActionCommand("firh");
firh.addActionListener(this);
help.add(firh);
MenuItem iirh = new MenuItem("IIR HELP", new
MenuShortcut(KeyEvent.VK.sub.-- C));
iirh.setActionCommand("iirh");
iirh.addActionListener(this);
help.add(iirh);
MenuItem gdh = new MenuItem("G I(O HELP", new
MenuShortcut(KeyEventVK.sub.-- D));
gdh.setActionCommand("gdh");
gdh.addActionListener(this);
help.add(gdh);
}
public void actionPerformed(ActionEvent e) {
String command = e.getActionCommand();
if (command.equals("quit")) {
YesNoDialog d = new YesNoDialog
(this, "Quit?", "Are you sure you want to quit?",
"Yes", "No", null);
d.addActionListener(new ActionListener()
public void actionPerformed(ActionEvent e) {
if (e.getActionCommand().equals("yes"))
System.exit(0);
}
}
);
d.show();
}
else if (command.equals("fir")) {
Frame f = new fefir("FIR DESIGN");
f.setSize(500,150);
f.show();
}
else if (command.equals("iir")) {
Frame f = new feiir("IIR DESIGN");
f.setSize(800,150);
f.show();
}
else if (command.equals("gd")) {
Frame f = new fegd("General Design");
f.setSize(600,150);
f.show();
}
else if (command.equals("about")) {
InfoDialog d1 = new InfoDialog();
d1.show();
}
else if (command.equals("firh")) {
InfoDialog d2 = new InfoDialog(this, "FIR HELP",
"FIR filter design:.backslash.n" +
"<iband>- 1 - lowpass; 2 - highpass;
3 - bandpass; 4 - bandstop.backslash.n" +
"<1>- order of filter.backslash.n" +
"<wndo>- 1 - rectangular; 2 - tapered rectangular;
3- triangular; 4 - Hanning; 5 - Hanning, 6
Blackman.backslash.n" +
"<fln>- normalized low cut-off frequency between 0 and 1.backslash.n" +
"<fhn>- normalized high cut-off frequency between 0 and 1.backslash.n" +
"output files:.backslash.n" +
"fra.data - amplitude response (501 sets of x-y points).backslash.n" +
"firp.data - phase reponse (501 sets of x-y points).backslash.n" +
"firi.data - impulse response (length = <1> + 1)");
d2.show();
}
else if (command.equals("iirh")) {
InfoDialog d3 = new InfoDialog(this, "IIR HELP",
"IIR filter design:\n" +
"<ifilt>- 1 - Chebl-passband ripple;2 - cheb2-stopband ripple;
3 - Butterworth-no ripple.backslash.n" +
"<iband>- 1 - lowpass; 2 - highpass;
3 - bandpass; 4 - bandstop.backslash.n" +
number of sections in cascade.backslash.n" +
order of each section -
2 for <iband>= 1, 2; 4 for <iband> = 3, 4.backslash.n" +
"<nf1>, <nf2>; <nf3>,
normalized frequency between 0 and 1.backslash.n" +
dB of stopband rejection,
only for Cheb. filters.backslash.n" +
"output files:.backslash.n" +
"iira.data - amplitude response (501 sets of x-y points).backslash.n" +
"iirp.data - phase reponse (501 sets of x-y points).backslash.n" +
"iirc.data - coefficients for each section.backslash.n" +
"Notice - only for IIR..backslash.n" +
"Insert 0s to the following options when they are
not used for filter design,.backslash.n" +
"1. <nf3> and <nf4> are not used any lowpass or highpass.backslash.n" +
"2. <nf2> is not used with lowpass Butterworth..backslash.n" +
"3. <nf1> is not used with highpass Butterworth.".backslash.n" +
"4. <nf1> and nf4 are not used with bandpass Butterworth..backslash.n" +
"5. <nf2> and nf3 are not used with bandstop Butterworth..backslash.n" +
"6. <ndb> dB of stopband rejection. only for Cheb. filters.");
d3 show(),
}
else if(command equals("gdh")) {
InfoDialog d4 = new InfoDialog(this,
"General I/O HELP",
"General design:.backslash.n" +
input the title for this plot.backslash.n" +
1 - put file name>
the file shall contain 2-stride X-Y input.backslash.n" +
input the X-axis name for this plot.backslash.n" +
input the Y-axis name for this plot");
d4.show();
}
}
public static void main(String args[]) {
Frame f = new fegui("Digital Filter Design");
f.setSize(400,100);
f.show();
}
}
______________________________________
With reference still to FIG. 3, in the present embodiment, front-end GUI 310 then interfaces with a program corresponding to the filter design specified by the user. FEFIR 316 corresponds to a FIR filter design, FEIIR 317 corresponds to an IIR filter design, and FEGD 318 corresponds to a General Input and Output design. Depending on the type of filter selected by the user, DSP 200 implements either FEFIR 316, FEIIR 317 or FEGD 318. Each of these programs is a continuation of the process initiated by front-end GUI 310 enabling the user to specify the design parameters for the type of filter the user has selected. Each of these programs causes a menu or icon to be displayed, which the user then uses to specify the desired design parameters for the filter. These programs are implemented using the Java program code. An example of FEFIR 316 specified in accordance with one embodiment of the present invention is described in Code Section B below. (FEIIR 317 specified in accordance with one embodiment of the present invention is described in Code Section C below. FEGD 318 specified in accordance with one embodiment of the present invention is described in Code Section D below.)
______________________________________
Code Section B - Exemplary FEFIR
______________________________________
/**
* Class fefir - The 2nd level Front End GUI
* @version %I% %G%
* @see fegui, feiir, fegd
*/
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class fefir extends Frame implements ActionListener {
String args1[] = new String[6];
Toolkit toolkit = this.getToolkit();
Image i = toolkit.getImage("fir.bmp");
public fefir(String title) {
super(title);
this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
e.getWindow().dispose();}
});
MenuBar menubar = new MenuBar();
this.setMenuBar(menubar);
Menu commit = new Menu("Commit");
menubar.add(commit);
MenuItem amp = new MenuItem("Amplitude", new
MenuShortcut(KeyEvent.VK.sub.-- A));
amp.setActionCommand("amp");
amp.addActionListener(this);
commit.add(amp);
MenuItem phase = new MenuItem("Phase", new
MenuShortcut(KeyEvent.VK.sub.-- P));
phase.setActionCommand("phase");
phase.addActionListener(this);
commit.add(phase);
MenuItem imp = new MenuItem("Impulse", new
MenuShortcut(KeyEvent.VK.sub.-- I));
imp.setActionCommand("imp");
imp.addActionListener(this);
commit.add(imp);
this.setFont(new Font("Helvetica",Font.BOLD,14));
this.setIconImage(i);
this.setLayout(new GridLayout(1,5,2,2));
Panel column1 = new Panel();
this.add(column1,"");
TextField textfield1 = new Textfield(5);
column1.add(new Label("<iband>:"));
column1.add(textfield1);
Panel column2 = new Panel();
this.ad(column2"");
TextField textfield2 = new Textfield(5);
column2.add(new Label("<l>:"));
column2;add(textfield2);
Panel column3 = new Panel();
this.add(column3,"");
TextField textfield3 = new TextField(5);
column3.add(new Label("<wndo>:"));
column3.add(textfield3);
Panel column4 = new Panel();
this.add(column4,"");
TextField textfield4 = new Textfield(5);
column4.add(new Label("<fln>:"));
column4.add(textfield4);
Panel column5 = new Panel();
this.add(column5,"");
Textfield textfield5 = new TextField(5);
column5.add(new Label("<fhn>:"));
column5.add(textfield);
texffield1.addTextListener(new TextListener() {
public void textValueChanged(TextEvent e) {
args1[0] = ((TextField)e.getSource()).getText();
/*
System.out.println(args1[0] +".backslash.n");
*/
}
});
textfield2.addTextListener(new TextListener() {
public void textValueChanged(TextEvent e) {
args1[1] = ((TextField)e.getSource()).getText();
*/
System.out.println(args1[1] +".backslash.n");
*/
}
});
textfield3.addTextListener(new TextListener() {
public void textValueChanged(TextEvent e) {
args1[2] = (TextField)e.getSource()).getText();
/*
System.out.println(args1[2] +".backslash.n");
*/
}
});
textfield4.addTextListener(new TextListener() {
public void textValueChanged(TextEvent e) {
args1[3] = ((TextField)e.getSource()).getText();
*/
System.out.println(args 1[3] +".backslash.n");
*/
}
});
textfield5.addTextListener(new TextListener() {
public void textValueChanged(TextEvent e) {
args1[4] = ((TextField)e.getSource()).getText();
*/
System.out.println(args1[4] +".backslash.n");
*/
}
});
}
public void actionPerformed(ActionEvent e) {
String command = e.getActionCommand();
if (command.equals("amp")) {
args1[5] = "0";
}
else if(command.equals("phase")) {
args1[5] = "1";
}
else if (command.equals("imp")) {
args1[5] = "2";
}
exfir.args = args1;
0 - exfir applet = new exfir();
Framef = new AppletFrm("FIR Digital Filter Design",
applet,500,500);
if(applet.error!=0)f.dispose();
}
/*
public static void main(String[] args) {
Frame f = new fefir("FIR DESIGN");
f.pack();
f.show();
}
*/
}
______________________________________
With reference to FIG. 3, an example of FEIIR 317 specified in accordance with one embodiment of the present invention is described in Code Section C below.
______________________________________
Code Section C - Exemplary FEIIR
______________________________________
/**
* Class feiir - The 2nd level Front End GUI
* @version %I% %G%
* @see fegui, fefff, fegd
*/
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class feiir extends Frame implements ActionListener {
String args1[] = new String[10];
Toolkit toolkit = this.getToolkit();
Image i = toolkit.getImage("iir.bmp");
public feifr(String title) {
super(title);
this.addWindowListener(newWindowAdapter() {
public void windowClosing(WindowEvent e) {
e.getwindow().dispose(); }
});
MenuBar menubar = new MenuBar();
this.setMenuBar(menubar);
Menu commit = new Menu("Commit");
menubar.add(commit);
MenuItem amp = new MenuItem("Amplitude", new
MenuShortcut(KeyEvent.VK.sub.-- S));
amp.setActionCommand("amp");
amp.addActionListener(this);
commit.add(amp);
MenuItem phase = new MenuItem("Phase", new
MenuShortcut(KeyEvent.VK.sub.-- T));
phase.setActionCommand("phase");
phase.addActionListener(this);
commit.add(phase);
this.setFont(new Font("Helvetica",Font.BOLD,14));
this.setIconImage(i);
this.setLayout(new GridLayout(1,9,2,2));
Panel column1 = new Panel();
this.add(column1,"");
TextField textfield1 = new Textfield(5);
column1.add(new Label("<ifilt>:"));
column1.add(textfield1);
Panel column2 = new Panel();
this.add(column2,"");
TextField textfield2 = new Texfield(5);
column2.add(new Label("<iband>:"));
column2.add(textfield2);
Panel column3 = new Panel();
this.add(column3,"");
TextField textfield3 = new TextField(5);
column3.add(new Label("<ns>:"));
column3.add(textfield3);
Panel column4 = new Panel();
this.add(column4,"");
TextField textfield4 = new TextField(5);
column4.add(new Label("<ls>:"));
column4.add(textfield4);
Panel column5 = new Panel();
this.add(column5,"");
Textfield textfield5 = new TextField(5);
column5.add(new Label("<nfl>:"));
column5.add(textfield5);
Panel column6 = new Panel();
this.add(column6,""); :
TextField textfield6 = new TextField(5);
column6.add(new Label("<nf2>:"));
column6.add(textfield6);
Panel column7 = new Panel();
this.add(column7,"");
TextField textfield7 = new TextField(5);
column7.add(new Label("<nf3>:"));
column7.add(textfield7);
Panel column8 = new Panel();
this.add(column8,"");
Textfield textfield8 = new TextField(5);
column8.add(new Label("<nf4>:"));
column8.add(textfield8);
Panel column9 = new Panel();
this.add(column9,"");
TextField textfield9 = new Textfield(5);
column9.add(new Label("<ndb>:"));
column9.add(textfield9);
textfield1.addTextListener(new TextListener() {
public void textValueChanged(TextEvent e) {
args1[0] = (TextField)e.getSource()).getText();
/*
System.out.println(args1[0] +".backslash.n");
*/
}
});
textfield2.addTextListener(new TextListener() {
public void textValueChanged(TextEvent e) {
args1[1] = (TextField)e.getSource()).getText();
/*
System.out.prinln(args1[1] +".backslash.n");
*/
}
});
textfield3.addTextListener(new TextListener() {
public void textValueChangedTextEvent e) {
args1[2] = (TextField)e.getSource()).getText();
/*
System.out.println(args1[2] +".backslash.n");
*/
}
});
textfield4.addTextListener(new TextListener() {
public void textValueChangedTextEvent e) {
args1[3] = (TextField)e.getSource()).getText();
/*
System.out.println(args1[3] +".backslash.n");
*/
}
});
textfield5.addTextListener(new TextListener() {
public void textValueChangedTextEvent e) {
args1[4] = (TextField)e.getSource()).getText();
/*
System.out.println(argsl[4] +".backslash.n");
*/
}
});
textfield6.addTextListener(new TextListener() {
public void textValueChangedTextEvent e) {
args1[5] (TextField)e.getSource()).getText();
/*
System.out println(args1[5] +".backslash.n"),
*/
}
});
textfield7.addTextListener(new TextListener() {
public void textValueChanged(TextEvent e) {
args1[6] = (TextField)e.getsource()).getText();
/*
System.out.println(args1[6] +".backslash.n");
*/
}
});
textfield8.addTextListener(newTextListener() {
public void textValueChanged(TextEvent e) {
args1[7] = ((TextField)e.getSource()).getText();
/*
System.out.println(args1[7] +".backslash.n");
*/
textfield9.addTextListener(new TextListener() {
public void textValueChanged(TextEvent e) {
args1[8] = (TextField)e.getSource()).getText();
/*
System.out.println(args1[8] +".backslash.n");
*/
}
});
public void actionPerformed(ActionEvent e) {
String command = e.getActionCommand();
if(command.equals("amp")) {
args1[9] = "0";
}
else if (command.equals("phase")) {
args1[9] ="1";
}
exiir.args = args1;
exiir applet = new exiir();
Frame f = new AppletFrm("IIR Digital Filter Design",
applet,500,500);
if(applet.error!= 0)f.dispose();
}
/*
public static void main(String[] args) {
Frame f = new feiir("IIR DESIGN");
f.pack();
f.show();
}
*/
}
______________________________________
With reference to FIG. 3, an example of FEGD 318 specified in accordance with one embodiment of the present invention is described in Code Section D below.
______________________________________
Code Section D - Exemplary FEGD
______________________________________
import java.applet.*;
import java.awt.*;
import java.awt.event.*;
public class fegd extends Frame implements ActionListener {
String args1[] = new String[4];
Toolkit toolkit = this.getToolkit();
Image i= toolkit.getImage("gd.bmp");
public fegd(String title) {
super(title);
this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
e.getWindow().dispose(); }
});
MenuBar menubar = new MenuBar();
this.setMenuBar(menubar);
Menu commit = new Menu("Commit");
menubar.add(commit);
MenuItem plot = new MenuItem("Plot", new
MenuShortcut(KeyEvent.VK.sub.-- P));
plot.setActionCommand("plot");
plot.addActionListener(this);
commit.add(plot);
this.setFont(new Font("Helvetica",Font.BOLD,14));
this.setIconImage(i);
this.setLayout(new GridLayout(1,4,2,2));
Panel column1 = new Panel();
this.add(column1,"");
TextField textfield1 = new TextField(10);
column1.add(new Label("<plot title>:"));
column1.add(textfieldl);
Panel column2 = new Panel();
this.add(column2,""),
TextField textfield2 = new TextField(10);
column2.add(new Label("<input file name>:"));
column2.add(textfield2);
Panel column3 = new Panel();
this.add(column3,"");
TextField textfield3 = new TextField(10);
column3.add(new Label("<X-axis name>:"));
column3.add(textfield3);
Panel column4 = new Panel();
this.add(column4,"");
TextField textfield4 = new Textfield(10);
column4.add(new Label("<Y-anix name>:"));
column4.add(textfield4);
textfield1.addTextListener(new TextListener() {
public void textValueChanged(TextEvent e)
args1[0] = ((TextField)e.getSource()).getText();
/*
System.out.println(args1[0] +".backslash.n");
*/
});
textfield2.addTextListener(new TextListener() {
public void textValueChanged(TextEvent e) {
args1[1] = ((TextField)e.getSource()).getText();
/*
System.out.println(args1[1] +".backslash.n");
*/
}
});
textfield3.addTextListener(new TextListener() {
public void textValueChanged(TextEvent e)
args1[2] = (TextField)e.getSource()).getText();
/*
System.out.println(args1[2] +".backslash.n");
*/
}
});
textfield4.addTextListener(new TextListener() {
public void textValueChanged(TextEvent e) {
args1[3] = ((TextField)e.getSource()).getText();
/*
System.out.println(args1[3] +".backslash.n");
*/
}
});
}
public void actionPerformed(ActionEvent e) {
String command = e.getActionCommand();
if(command.equals("plot")) {
exgd.args = args1;
exgd applet = new exgd();
Frame f = new AppleFrm("General Design",
applet,500,500);
}
}
/*
public static void main(String[] args) {
Frame f= new feiir("GENERAL DESIGN");
f.pack();
f.show();
}
*/
}
______________________________________
Continuing with reference to FIG. 3, AppletFrm 320 is used to generate windows on display device 105 of FIG. 1. These windows are used to display the menus and icons generated by graphical user interface 215, and also to display the graphical results of the digital signal processing. AppletFrm 320 is also used to enable the user to print the results directly from the display window. The user can resize the window displays by manipulating the computer system's user input device (e.g., cursor control device 107 of FIG. 1) or by inputting preferred values into a table displayed within the window by the graphical user interface. AppletFrm 320 is implemented using the Java program code. An example of AppletFrm 320 specified in accordance with one embodiment of the present invention is described in Code Section E below.
______________________________________
Code Section E - Exemplary AppletFrm
______________________________________
/**
* Class AppletFrm - Interface between Standalone app. and Applet
* @version %I% %G%
* @see fefir, feiir, fegd, exfir, exiir, exgd
*/
import java.applet.*;
importjava.awt.*;
import java.awt.event.*;
*import java.util.*;
public class AppletFrm extends Frame {.sub.--
private Properties printprefs = new Properties();
Toolkit toolkit = this.getToolkit();
Image i = toolkit.getImage("plot.bmp");
public AppletFrm(final String title,
final Applet applet, int width,
int height){
super(title);
// Add a print button.
this.setIconImage(i);
Button b = new Button("Print");
this.add(b,"South");
this.add(applet,"Center");
this.setSize(width,height);
this.show();
// Call the print() method when the button is clicked.
// Note anonymous class.
b.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent e) { print(title); }
});
this.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e)
{e.getWindow().dispose();}
});
applet.init();
applet.start();
}
void print(String title) {
// Obtain a Printjob and a Graphics object to use with it
Toolkit toolkit = this.getToolkit();
PrintJob job = toolkit.getPrintJob(this,title,printprefs);
if (job == null) return; // If the user clicked Cancel in the print
dialog
Graphics g = job.getGraphics();
// Finish up.
g.dispose(); //End the page
job.end(); //End the job
}
}
______________________________________
With reference again to FIG. 3, in the present embodiment, AppletFrm 320 interfaces with either EXFIR 326 corresponding to a FIR filter design, EXIIR 327 corresponding to an IIR filter design, or EXGD 328 corresponding to a general input and output design, depending on the type of filter selected by the user. These programs communicate with C dynamic libraries 335 to receive the processed data. Then, using the windows generated by AppletFrm 320, the processed data is displayed as plots and figures and/or printed. These programs are implemented using the Java program code. An example of EXFIR 326 specified in accordance with one embodiment of the present invention is described in Code Section F below. (EXIIR 327 specified in accordance with one embodiment of the present invention is described in Code Section G below. EXGD 328 specified in accordance with one embodiment of the present invention is described in Code Section H below.)
______________________________________
Code Section F - Exemplary EXFIR
______________________________________
/**
* Class exfir- excution unit for fefir
* @version %I% %G%
* @see fefir
*/
import java.awt.*;
import java.applet.*;
import java.io.FileInputStream;
import graphics.*;
import firdesign;
public class exfir extends Applet {
LoadData dynamic;
G2Dint graph;
Label title;
DataSet data1;
Axis xaxis;
Axis yaxis;
Double d2str;
int i2str;
int error;
static String args[];
String argsdown;
public void init() {
int i;
int j;
double args 1[] = new double[args.length];
for(i = 0; i < args.length - 1 ; i++)
{
d2str = Double.valueOf(args[i]);
args 1[i] = d2str.doubleValue();
}
argsdown = new firdesign().firdd(args1);
/*
*/
System.out.println("The error is:" + argsdown);
/*
error = Integer.parseInt(argsdown);
if (error ! = 0)
{
switch(error) {
case 1:
System.err.println("ERROR 1 - Invalid order of filter <l>
1 <= 0 .vertline..vertline. 1 > 100.backslash.n");
this.destroy();
break;
case 2:
System.err.println("ERROR 2 - Invalid window type <wndo >
wndo < 1 .vertline..vertline. wndo > 6.backslash.n");
this.destroy();
break;
case 3:
System.err.println("ERROR 3 - Invalid filter type <iband >
iband < 1 .vertline..vertline. iband > 4.backslash.n");
this.destroy();
break;
case4:
System.err.println("ERROR 4 - Invalid cut-off frequency
< fln > <fhn > .backslash.n");
System.err.println("fln < 0.0 .vertline..vertline.
fln > 0.5 .vertline..vertline. (iband >= 3 && fln >=
fhn) .vertline..vertline. (iband >= 3 && fhn >= 0.5)
.backslash.n");
this.destroy();
break;
default:
System.err.println("ERROR = "+argsdown);
this.destroy();
}
}
graph = new2 G2Dint();
dynamic = new LoadData();
graph.borderTop = 30;
graph.borderBottom = 10;
graph.borderRight = 60;
graph.setDataBackground(new Color(50,50,200));
graph.setGraphBackground(new Color(135,206,235));
/*
** Build the title and place it at the top of the graph
*/
graph.setFont(new Font("TimesRoman", Font.PLAIN,25));
title = new Label("FIR", Label.CENTER);
title.setFont(new Font("TimesRoman",Font.PLAIN,25));
setLayout(new BorderLayout());
add("North", title);
add("Center", graph);
xaxis = graph.createXAxis();
yaxis = graph.createYAxis();
i2str = Integer.parseInt(args[5]);
switch(i2str) {
case 0:
try {
data1 = dynamic.loadDataSet
(new FileInputStream("fira.data"), graph);
} catch (Exception e) {
System.out.println("Failed to load data file!");
}
xaxis.setTitleText("Frequency");
yaxis.setTitleText("Amplitude");
break;
case 1:
try {
/*
** Start a new thread and load the data
*/
data1 = dynamic.loadDataSet(new FileInputStream
("firp.data"), graph);
} catch (Exception e) {
System.out.println("Failed to load data file!");
}
xaxis.setTitleText("Frequency");
yaxis.setTitleText("Degree");
break;
case 2:
try {
data1 = dynamic.loadDataSet(new FileInputStream
("firi.data"),graph);
} catch (Exception e) {
System.out.println("Failed to load data file!");
}
xaxis.setTitleText("Order");
yaxis.setTitleText("Amplitude");
break;
default:
System.out.println("Failed to load data file!");
break;
}
/*
** Specify the data line color
*/
data1.linecolor = new Color(255,255,0);
/*
** Instantiate the xaxis and attach the dataset.
/*
xaxis.attachDataSet(data1);
xaxis.setTitleColor(Color.black);
xaxis.setTitleFont(new Font("TimesRoman",Font.ITALIC,25));
xaxis.setLabelFont(new Font("Helvetica",Font.PLAIN,20));
/*
** Instantiate the yaxis and attach the dataset.
*/
yaxis.attachDataSet(data1);
yaxis.setTitleColor(Color.black);
yaxis.setTitleFont(new Font("TimesRoman",Font.ITALIC,25));
yaxis.setLabelFont(new Font("Helvetica",Font.PLAIN,20));
data1.xaxis.maximum = 1.0;
data1.xaxis.minimum = 0.0;
data1.yaxis.maximum = 1.5;
data1.yaxis.minimum = 0.0;
}
}
______________________________________
With reference to FIG. 3, an example of EXIIR 327 specified in accordance with one embodiment of the present invention is described in Code Section G below.
______________________________________
Code Section G - Exemplary EXIIR
______________________________________
/**
* Class exiir - excution unit for feiir
* @version %I% %G%
* @seefeiir
*/
import java.awt.*;
import java.applet.*;
import java.io.FileInputStream;
import graphics.*;
import iirdesign;
public class exiir extends Applet {
LoadData dynamic;
G2Dint graph;
Label title;
DataSet data1;
Axis xaxis;
Axis yaxis;
Double d2str;
int i2str;
int error;
static String args[];
String argsdown;
public void init() {
int i;
int j;
double args1[] = new double[args.length];
for(i = 0; i < args.length -1 ; i++)
}
d2str = Double.valueOf(args[i]);
args1[i] = d2str.doubleValue();
}
argsdown = new iirdesign().iirdd(args1);
/*
System.out.println("The error is:" + argsdown);
*/
error = Integer.parseInt(argsdown);
if(error != 0)
{
switch(error) {
case 1:
System.err.println("ERROR 1 - all zero transfer function.backslash.n");
this.destroy();
break;
case 2:
System.err.println("ERROR 2 - invalid transfer function.backslash.n");
this.destroy();
break;
case 3:
System.err.println("ERROR 3 - filter order exceeds array size
.backslash.n");
this.destroy();
break;
case 4:
System.err.println("ERROR 4 - invalid filter type parameter
<iband >-.backslash.n");
System.err.println("iband < 1 .vertline..vertline. iband
> 4.backslash.n");
this.destroy();
break;
case 5:
System.err.println("ERROR 5 -
invalid cut-off frequency.backslash.n");
this.destroy();
break;
case 6:
System.err.println("ERROR 6 -
out of range on <ifilt > or <iband> or <ns> .backslash.n");
System.err.println("(ifilt <1 .vertline..vertline.
ifilt> 3) .vertline..vertline. (iband <1 .vertline..vertline. iband > 4)
.vertline..vertline. ns =< 0.backslash.n");
this.destroy();
break;
case7:
System.err.printin("ERROR 7 - invalid cut-off frequecy .backslash.n");
this.destroy();
break;
default:
System.err.println("ERROR = "+argsdown);
this.destroy();
}
}
graph = new G2Dint();
dynamic = new LoadData();
graph.borderTop = 30;
graph.borderBottom = 10;
graph.borderRight = 60;
graph.setDataBackground(new Color(50,50,200));
graph.setGraphBackground(new Color(135,206,235));
/*
** Build the title and place it at the top of the graph
*/
graph.setFont(new Font("TimesRoman",Font.PLAIN,25));
title new Label("IIR", Label.CENTER);
title.setFont(new Font("TimesRoman",Font.PLAIN,25));
setLayout(new BorderLayout());
add("North", title);
add("Center", graph);
xaxis = graph.createXAxis();
yaxis = graph.createYAxis();
i2str = Integer.parseInt(args[9]);
switch(i2str) {
case 0:
try {
data1 = dynamic.loadDataSet
(new FileInputStream("iira.data"), graph);
} catch Exception e) {
System.out.println("Failed to load data file!");
}
xaxis.setTitleText("Frequency");
yaxis.setTitleText("Amplitude");
break;
case 1:
try {
/*
** Start a new thread and load the data
*/
data1 = dynamic.loadDataSet
(new FileInputStream("iirp.data"), graph);
} catch Exception e) {
System.out.println("Failed to load data file!");
}
xaxis.setTitleText("Frequency");
yaxis.setTitleText("Degree");
break;
default:
System.out.println("Failed to load data file!");
break;
}
/*
** Specify the data line color.
*/
data1.linecolor = new Color(255,255,0);
/*
** Instantiate the xaxis and attach the dataset.
*/
xaxis.attachDataset(data1);
xaxis.setTitleColor(Color.black);
xaxis.setTitleFont(new Font("TimesRoman",Font.ITALIC,25)),
xaxis.setLabelFont(new Font("Helvetica",Font.PLAIN,20));
/*
** Instantiate the yaxis and attach the dataset.
*/
yaxis.attachDataSet(data1);
yaxis.setTitleColor(Color.black);
yaxis.setTitleFont(new Font("TimesRoman",Font.ITALIC,25));
yaxis.setLabelFont(new Font("Helvetica",Font.PLAIN,20));
data1.xaxis.maximum = 1.0;
data1.xaxis.minimum = 0.0;
data1.yaxis.maximum = 1.5;
data1.yaxis.minimum = 0.0;
}
}
______________________________________
With reference to FIG. 3, an example of EXGD 328 specified in accordance with one embodiment of the present invention is described in Code Section H below.
______________________________________
Code Section H - Exemplary EXGD
______________________________________
/**
* Class exgd - excution unit for fegd
* @version %I% %G%
* @see fegd
*/
import java.awt.*;
import java.applet.*;
import java.io.FileInputStream;
import graphics.*;
public class exgd extends Applet {
LoadData dynamic;
G2Dint graph;
Label title;
DataSet data1;
Axis xaxis;
Axis yaxis;
Double d2str;
int error;
static String args[];
public void init() {
int i;
int j;
graph = new G2Dint();
dynamic = new LoadData();
graph.borderTop = 30;
graph.borderBottom = 10;
graph.borderRight = 60;
graph.setDataBackground(new Color(50,50,200));
graph.setGraphBackground(new Color(135,206,235));
/*
** Build the title and place it at the top of the graph
*/
graph.setFont(new Font("TimesRoman",Font.PLAIN,25));
title = new Label(args[0], Label.CENTER);
title.setFont(new Font("TimesRoman",Font.PLAIN,25));
setLayout(new BorderLayout());
add("North", title);
add("Center", graph);
xaxis = graph.createXAxis();
yaxis = graph.createYAxis();
try {
data1 = dynamic.loadDataSet(new FileInputStream(args[1]), graph);
} catch (Exception e) {
System.err.println("Failed to load data file!");
}
xaxis.setTitleText(args[2]);
yaxis.setTitleText(args[3]);
/*
** Specify the data line color
*/
data1.linecolor = new Color(255,255,0);
*/
** Instantiate the xaxis and attach the dataset.
/*
xaxis.attachDataSet(data1);
xaxis.setTitleColor(Color.black);
xaxis.setTitleFont(new Font("TimesRoman",Font.ITALIC,25));
xaxis.setLabelFont(new Font("Helvetica",Font.PLAIN,20));
/*
** Instantiate the yaxis and attach the dataset.
*/
yaxis.attachDataSet(data 1);.
yaxis.setTitleColor(Color.black);
yaxis.setTitleFont(new Font("TimesRoman",Font.ITALIC,25)),
yaxis.setLabelFont(new Font("Helvetica",Font.PLAIN,20));
data1.xaxis.maximum = 1.0;
data1.xaxis.minimum = 0.0;
data1.yaxis.maximum = 1.5;
data1.yaxis.minimum = 0.0;
}
}
______________________________________
With reference still to FIG. 3, in the present embodiment, native interface 220 serves to provide the interface between the Java program code utilized in the preceding steps of DSP 200 and the C program code utilized in C dynamic libraries 335. Native interface 220 is written in Java program code but, from the perspective of the C library, it functions like a C program, and in this manner it enables a Java program to call a C library. Native interface 220 is written such that it is platform-independent. Native interface 220 and C dynamic libraries 335 function integrally so that C dynamic libraries 335 and the Java graphical user interface 215 are able to communicate. Native interface 220 utilizes either FIRDESIGN 331 corresponding to a FIR filter design or IIRDESIGN 332 corresponding to an IIR filter design. A program corresponding to a General Input and Output design is not required in native interface 220 because processing of data is not associated with this design; instead, data input by the user are only plotted. An example of FIRDESIGN 331 specified in accordance with one embodiment of the present invention is described in Code Section I below.
______________________________________
Code Section I - Exemplary FIRDESIGN
______________________________________
/**
* Class firdesign - Dynamic link C-library
* @version %I% %G%
* @see exfir
*/
class firdesign {
public firdesign() {};
public native String firdd(double argsup[]);
static{
System.loadLibrary("fird");
}
}
______________________________________
An example of IIRDESIGN 332 specified in accordance with one embodiment of the present invention is described in Code Section J below.
______________________________________
Code Section J - Exemplary IIRDESIGN
______________________________________
/**
Class iirdesign - Dynamic link C-library
* @version %I% %G%
* @see exiir
*/
class iirdesign {
public iirdesign() {};
public native String iirdd(double argsup[]);
static {
System.loadLibrary("iird");
}
}
______________________________________
With reference again to FIG. 3, C dynamic libraries 335 provide the FIR and IIR execution cores used to process the data. C dynamic libraries 335 are implemented by digital signal processing unit 225 of FIGS. 2A and 2B. C dynamic libraries 335 process both static and dynamic (time-variant and continuous) data, and output a two-dimensional display in accordance with graphical user interface 215 described above. C dynamic libraries 335 are used for the process calculations for FIR and IIR and also write the respective output files for each, including the coefficients of each filter. The processes employed in C dynamic libraries 335 are known in the art, such as those found in "Signal Processing Algorithms in MATLAB," published by Prentice Hall, 1996. However, it is understood that the present invention could use other processes for digital signal processing. C dynamic libraries 335 are implemented using the C program code. Thus, the present embodiment of the present invention advantageously uses the C program code for the timing critical portion of digital signal processing, because C is more efficient than Java for that purpose and requires less computational resources. The present embodiment advantageously utilizes the Java program code for the graphical user interface, because Java provides a more user-friendly interface for that purpose. In summary, with reference to FIG. 3, in one embodiment of the present invention, a user would execute DSP 200 using executable 205 of FIG. 2B. Alternatively, a user executes DSP 200 using a Java interpreter (e.g., virtual machine 210 of FIG. 2A). In the present embodiment, the present invention then generates a display on the computer system's output device (that is, a menu bar or icon is displayed on the computer system's display monitor or like device). Using the displayed graphical user interface of the present invention, the user selects the type of filter to be applied to the data that are to be analyzed. Based on this input, the present invention generates and displays additional menus or icons to receive filter design parameters that are specified by the user. The data are processed by C dynamic libraries 335 according to the filter selected by the user, and displayed on the computer system's output device in accordance with the user's specifications. The user can manipulate the display using the graphical user interface provided by the present invention, or can print the results. Thus, the present invention provides an easy-to-use DSP method that is compatible with a user's experience. The present invention is also not limited to a single type of platform. With reference now to FIG. 4A, the application of one embodiment of the present invention on the Microsoft Windows 95 platform is demonstrated. Menu bar 410 is generated using front-end graphical user interface 310 and AppletFrm 320 (FIG. 3) and displayed on the display device of a computer system (e.g., display device 105 of FIG. 1). With reference to FIG. 4B, the application of one embodiment of the present invention on the Solaris platform is demonstrated. Icons 420a, 420b, 420c 420d and 420e of display 420 are generated using front-end graphical user interface 310 and AppletFrm 320, and displayed on the display device of a computer system (e.g., display device 105 of FIG. 1). With references to FIGS. 4A and 4B, the user would utilize menu bar 410 and display 420 to select the type of filter (e.g., FIR, IIR or general input and output) to be applied for the digital signal processing. With reference next to FIG. 5A, once the type of filter has been selected, the design window for that filter type is displayed on the computer system's display device. The design window is generated for the selected filter type using FEFIR 316, FEIIR 317 or FEGD 318 and AppletFrm 320 of FIG. 3. In accordance with one embodiment of the present invention, window 510 for a FIR filter is illustrated on the Solaris platform. Using window 510, the user specifies the parameters to be used to design the filter, such as the type of window (e.g., Hamming) and other like parameters known in the art. With reference now to FIG. 5B, in a similar manner, window 520 for an IIR filter is illustrated on the Windows 95 platform. In the same manner as illustrated by FIGS. 5A and 5B, a similar window is generated for the general input and output design. With reference to FIG. 6A, the results of the digital signal processing are illustrated on the computer system's display device. The results are generated using C dynamic libraries 335 of FIG. 3, and depending on the type of filter are displayed using either EXFIR 326, EXIIR 327 or EXGD 328 and AppletFrm 320 of FIG. 3. In accordance with one embodiment, plot 610 showing amplitude response of a FIR filter is illustrated on the Solaris platform. With reference to FIG. 6B, in a similar manner, plot 620 showing amplitude response of an IIR filter is illustrated on the Windows 95 platform. In the same manner as that illustrated by FIGS. 6A and 6B, a similar window is generated for the general input and output design. With reference to FIG. 7, the application of one embodiment of the present invention as a constellation display tool is illustrated for a Solaris platform. Constellation display 710 simulates the real and imaginary parts of a signal. Constellation display 710 is a real-time DSP design that processes time-variant and continuous input data. The display is updated at a predetermined frequency (e.g., once per second) using a single Java thread. Embodiments of the present invention are demonstrated above for the Solaris and Windows 95 platforms. However, it is understood that the present invention is not limited to these platforms and may be practiced on other platforms. In addition, it is understood that FIR designs, IIR designs, or general input and output designs can be used with each platform. Thus, the present invention provides a method that allows a single version of digital signal processing software 200 to perform on more than one type of platform. The present invention also provides a method that accomplishes the above need and is compatible with existing computer systems and the experience of current users. The preferred embodiment of the present invention, Cross-Platform DSP Designs Using Java and C, is thus described. While the present invention has been described in particular embodiments, it should be appreciated that the present invention should not be construed as limited by such embodiments, but rather construed according to the following claims.
|
Same subclass Same class Consider this |
||||||||||
