Skip to content

Commit

Permalink
Move to MVN
Browse files Browse the repository at this point in the history
Library is moved to maven
  • Loading branch information
rikkimongoose committed Mar 30, 2013
1 parent 480817d commit 0bfc56a
Show file tree
Hide file tree
Showing 121 changed files with 7,639 additions and 8,059 deletions.
46 changes: 46 additions & 0 deletions TarsosDSP/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<groupId>be.hogent.tarsos.dsp</groupId>
<artifactId>TarsosDSP</artifactId>
<version>1.4</version>
<packaging>jar</packaging>

<name>TarsosDSP</name>
<url>http://maven.apache.org</url>

<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
<testResources>
<testResource>
<directory>${project.basedir}/src/test/java</directory>
<excludes>
<exclude>*.java</exclude>
</excludes>
</testResource>
</testResources>
</build>

<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
</properties>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.11</version>
<scope>test</scope>
</dependency>
</dependencies>
</project>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -23,133 +23,133 @@
* for credits and info, see README.
*
*/
package be.hogent.tarsos.dsp.mfcc;

import java.io.*;
import java.util.StringTokenizer;

public class DCT {

int f[][];
int g[][];
int inv[][];

static public void main(String args[]) {

int fm[][] = new int[8][8];

if ( args.length != 1 ) {
System.out.println("usage: java DCT <matrix-filename>");
return;
}

File f = new File(args[0]);
if ( !f.canRead() ) {
System.out.println("Error! can't open "+args[0]+" for reading");
return;
}
try {
BufferedReader br = new BufferedReader(new FileReader(f));
for ( int i = 0; i < 8; i++ ) {
String line = br.readLine();
StringTokenizer tok = new StringTokenizer(line,", ");
if ( tok.countTokens() != 8 ) {
System.out.println("Error! File format error: 8 tokens required!");
throw new IOException("Error");
}
for ( int j = 0; j < 8; j++ ) {
String numstr = tok.nextToken();
int num = Integer.parseInt(numstr);
fm[i][j] = num;
}
}
}
catch ( FileNotFoundException e ) {
System.out.println("Error! can't create FileReader for "+args[0]);
return;
}
catch ( IOException e ) {
System.out.println("Error! during read of "+args[0]);
return;
}
catch ( NumberFormatException e ) {
System.out.println("Error! NumberFormatExecption");
return;
}

DCT dct = new DCT(fm);
dct.transform();
dct.printout();
dct.inverse();
dct.printoutinv();
}

public DCT(int f[][]) {
this.f = f;
}

public void transform() {
g = new int[8][8];

for ( int i = 0; i < 8; i++ ) {
for ( int j = 0; j < 8; j++ ) {
double ge = 0.0;
for ( int x = 0; x < 8; x++ ) {
for ( int y = 0; y < 8; y++ ) {
double cg1 = (2.0*(double)x+1.0)*(double)i*Math.PI/16.0;
double cg2 = (2.0*(double)y+1.0)*(double)j*Math.PI/16.0;

ge += ((double)f[x][y]) * Math.cos(cg1) * Math.cos(cg2);

}
}
double ci = ((i==0)?1.0/Math.sqrt(2.0):1.0);
double cj = ((j==0)?1.0/Math.sqrt(2.0):1.0);
ge *= ci * cj * 0.25;
g[i][j] = (int)Math.round(ge);
}
}
}


public void inverse() {
inv = new int[8][8];

for ( int x = 0; x < 8; x++ ) {
for ( int y = 0; y < 8; y++ ) {
double ge = 0.0;
for ( int i = 0; i < 8; i++ ) {
double cg1 = (2.0*(double)x + 1.0)*(double)i*Math.PI/16.0;
double ci = ((i==0)?1.0/Math.sqrt(2.0):1.0);
for ( int j = 0; j < 8; j++ ) {
double cg2 = (2.0*(double)y + 1.0)*(double)j*Math.PI/16.0;
double cj = ((j==0)?1.0/Math.sqrt(2.0):1.0);
double cij4 = ci*cj*0.25;
ge += cij4 * Math.cos(cg1) * Math.cos(cg2) * (double)g[i][j];
}
}
inv[x][y] = (int)Math.round(ge);
}
}
}

public void printout() {
for ( int i = 0; i < 8; i++ ) {
System.out.print("\n");
for ( int k = 0; k < 8; k++ ) {
System.out.print(g[i][k]+" ");
}
}
}

public void printoutinv() {
for ( int i = 0; i < 8; i++ ) {
System.out.print("\n");
for ( int k = 0; k < 8; k++ ) {
System.out.print(inv[i][k]+" ");
}
}
}
}


package be.hogent.tarsos.dsp.mfcc;

import java.io.*;
import java.util.StringTokenizer;

public class DCT {

int f[][];
int g[][];
int inv[][];

static public void main(String args[]) {

int fm[][] = new int[8][8];

if ( args.length != 1 ) {
System.out.println("usage: java DCT <matrix-filename>");
return;
}

File f = new File(args[0]);
if ( !f.canRead() ) {
System.out.println("Error! can't open "+args[0]+" for reading");
return;
}
try {
BufferedReader br = new BufferedReader(new FileReader(f));
for ( int i = 0; i < 8; i++ ) {
String line = br.readLine();
StringTokenizer tok = new StringTokenizer(line,", ");
if ( tok.countTokens() != 8 ) {
System.out.println("Error! File format error: 8 tokens required!");
throw new IOException("Error");
}
for ( int j = 0; j < 8; j++ ) {
String numstr = tok.nextToken();
int num = Integer.parseInt(numstr);
fm[i][j] = num;
}
}
}
catch ( FileNotFoundException e ) {
System.out.println("Error! can't create FileReader for "+args[0]);
return;
}
catch ( IOException e ) {
System.out.println("Error! during read of "+args[0]);
return;
}
catch ( NumberFormatException e ) {
System.out.println("Error! NumberFormatExecption");
return;
}

DCT dct = new DCT(fm);
dct.transform();
dct.printout();
dct.inverse();
dct.printoutinv();
}

public DCT(int f[][]) {
this.f = f;
}

public void transform() {
g = new int[8][8];

for ( int i = 0; i < 8; i++ ) {
for ( int j = 0; j < 8; j++ ) {
double ge = 0.0;
for ( int x = 0; x < 8; x++ ) {
for ( int y = 0; y < 8; y++ ) {
double cg1 = (2.0*(double)x+1.0)*(double)i*Math.PI/16.0;
double cg2 = (2.0*(double)y+1.0)*(double)j*Math.PI/16.0;

ge += ((double)f[x][y]) * Math.cos(cg1) * Math.cos(cg2);

}
}
double ci = ((i==0)?1.0/Math.sqrt(2.0):1.0);
double cj = ((j==0)?1.0/Math.sqrt(2.0):1.0);
ge *= ci * cj * 0.25;
g[i][j] = (int)Math.round(ge);
}
}
}


public void inverse() {
inv = new int[8][8];

for ( int x = 0; x < 8; x++ ) {
for ( int y = 0; y < 8; y++ ) {
double ge = 0.0;
for ( int i = 0; i < 8; i++ ) {
double cg1 = (2.0*(double)x + 1.0)*(double)i*Math.PI/16.0;
double ci = ((i==0)?1.0/Math.sqrt(2.0):1.0);
for ( int j = 0; j < 8; j++ ) {
double cg2 = (2.0*(double)y + 1.0)*(double)j*Math.PI/16.0;
double cj = ((j==0)?1.0/Math.sqrt(2.0):1.0);
double cij4 = ci*cj*0.25;
ge += cij4 * Math.cos(cg1) * Math.cos(cg2) * (double)g[i][j];
}
}
inv[x][y] = (int)Math.round(ge);
}
}
}

public void printout() {
for ( int i = 0; i < 8; i++ ) {
System.out.print("\n");
for ( int k = 0; k < 8; k++ ) {
System.out.print(g[i][k]+" ");
}
}
}

public void printoutinv() {
for ( int i = 0; i < 8; i++ ) {
System.out.print("\n");
for ( int k = 0; k < 8; k++ ) {
System.out.print(inv[i][k]+" ");
}
}
}
}


Loading

0 comments on commit 0bfc56a

Please sign in to comment.