Reorganise test files, test jlibpipe in exec.sound

This commit is contained in:
2016-07-14 08:53:26 +01:00
parent 717f79bcf6
commit 3040708f80
10 changed files with 7 additions and 4 deletions

View File

@@ -16,6 +16,8 @@
*/
package pipe;
import com.github.boukefalos.jlibloader.Native;
/**
* @author Vikram S Khatri vikram.khatri@us.ibm.com
*/
@@ -26,7 +28,7 @@ public class Pipe {
static final int PIPE_WAIT = 0x00000000;
static {
System.loadLibrary("pipe");
Native.load("com.github.boukefalos", "jlibpipe");
}
public static final native int CreateNamedPipe(

View File

@@ -95,8 +95,8 @@ public class TestPipe {
public static void main(String[] args) {
String pipeName = "\\\\.\\pipe\\detest";
String fileName = "txt/bla.txt";
//fileName = "C:\\Users\\Rik\\Music\\Artists\\+44\\When Your Heart Stops Beating\\+44 - 155.mp3";
String fileName = "txt/mp3";
fileName = "C:\\Users\\Rik\\Music\\Artists\\+44\\When Your Heart Stops Beating\\+44 - 155.mp3";
TestPipe testPipe = new TestPipe(pipeName, fileName);
testPipe.runPipe();
}

View File

@@ -1,71 +0,0 @@
/**
* Copyright (C) 2016 Rik Veenboer <rik.veenboer@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package test;
import javax.sound.sampled.*;
public class SoundAudit {
public static void main(String[] args) { try {
System.out.println("OS: "+System.getProperty("os.name")+" "+
System.getProperty("os.version")+"/"+
System.getProperty("os.arch")+"\nJava: "+
System.getProperty("java.version")+" ("+
System.getProperty("java.vendor")+")\n");
for (Mixer.Info thisMixerInfo : AudioSystem.getMixerInfo()) {
System.out.println("Mixer: "+thisMixerInfo.getDescription()+
" ["+thisMixerInfo.getName()+"]");
Mixer thisMixer = AudioSystem.getMixer(thisMixerInfo);
for (Line.Info thisLineInfo:thisMixer.getSourceLineInfo()) {
if (thisLineInfo.getLineClass().getName().equals(
"javax.sound.sampled.Port")) {
Line thisLine = thisMixer.getLine(thisLineInfo);
thisLine.open();
System.out.println(" Source Port: "
+thisLineInfo.toString());
for (Control thisControl : thisLine.getControls()) {
System.out.println(AnalyzeControl(thisControl));}
thisLine.close();}}
for (Line.Info thisLineInfo:thisMixer.getTargetLineInfo()) {
if (thisLineInfo.getLineClass().getName().equals(
"javax.sound.sampled.Port")) {
Line thisLine = thisMixer.getLine(thisLineInfo);
thisLine.open();
System.out.println(" Target Port: "
+thisLineInfo.toString());
for (Control thisControl : thisLine.getControls()) {
System.out.println(AnalyzeControl(thisControl));}
thisLine.close();}}}
} catch (Exception e) {e.printStackTrace();}}
public static String AnalyzeControl(Control thisControl) {
String type = thisControl.getType().toString();
if (thisControl instanceof BooleanControl) {
return " Control: "+type+" (boolean)"; }
if (thisControl instanceof CompoundControl) {
System.out.println(" Control: "+type+
" (compound - values below)");
String toReturn = "";
for (Control children:
((CompoundControl)thisControl).getMemberControls()) {
toReturn+=" "+AnalyzeControl(children)+"\n";}
return toReturn.substring(0, toReturn.length()-1);}
if (thisControl instanceof EnumControl) {
return " Control:"+type+" (enum: "+thisControl.toString()+")";}
if (thisControl instanceof FloatControl) {
return " Control: "+type+" (float: from "+
((FloatControl) thisControl).getMinimum()+" to "+
((FloatControl) thisControl).getMaximum()+")";}
return " Control: unknown type";}
}

View File

@@ -1,56 +0,0 @@
/**
* Copyright (C) 2016 Rik Veenboer <rik.veenboer@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package test;
import javax.sound.sampled.AudioFormat;
import sound.Consumer;
import sound.Producer;
import sound.Source;
import sound.consumer.Port;
import sound.consumer.Shoutcast;
import sound.producer.Stream;
public class Test {
public static void main(String[] args) {
AudioFormat audioFormat = new AudioFormat(AudioFormat.Encoding.PCM_SIGNED, 48000f, 16, 2, 4, 48000f, true);
try {
//Producer p1 = new Target("Line-In (Creative SB X-Fi)");
//Producer p2 = new Target("Line 1 (Virtual Audio Cable)", audioFormat);
//p2.start();
Producer p3 = new Stream("http://ics2gss.omroep.nl:80/3fm-bb-mp3");
Producer p4 = new Stream("http://sc7.mystreamserver.com:8004");
Consumer c1 = new Source("Java Sound Audio Engine");
Consumer c2 = new Port("Speakers (Creative SB X-Fi)");
Consumer c3 = new Shoutcast();
//Consumer c4 = new Player();
//Consumer c5 = new Writer(new File("stream.out"));
//Utils.write(p3.getInputStream(), new File("stream.out"));
//Utils.play(p3.getInputStream());
c3.start(p4);
//while (true) {
//Thread.sleep(300000);
//c1.stop();
//}
} catch (Exception e) {
e.printStackTrace();
}
}
}

View File

@@ -1,50 +0,0 @@
/**
* Copyright (C) 2016 Rik Veenboer <rik.veenboer@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package test.lines;
import javax.sound.sampled.AudioFormat;
import javax.sound.sampled.AudioSystem;
import javax.sound.sampled.Line;
import javax.sound.sampled.LineUnavailableException;
import javax.sound.sampled.Mixer;
import javax.sound.sampled.SourceDataLine;
import javax.sound.sampled.TargetDataLine;
public class Main {
public static void main(String[] args) {
System.out.println(System.getProperty("javax.sound.sampled.SourceDataLine"));
new AudioFormat(44100, 16, 2, true, false);
for (Mixer.Info mixerInfo : AudioSystem.getMixerInfo()) {
Mixer mixer = AudioSystem.getMixer(mixerInfo);
for (Line.Info lineInfo : mixer.getTargetLineInfo()) {
try {
Line line = mixer.getLine(lineInfo);
if (mixer.isLineSupported(lineInfo)) {
if (line instanceof TargetDataLine) {
new TargetLine(mixer, (TargetDataLine) line);
}/* else if (line instanceof SourceDataLine) {
new SourceLine(mixer, (SourceDataLine) line);
}*/
}
} catch (LineUnavailableException e) {}
}
}
}
}

View File

@@ -1,35 +0,0 @@
/**
* Copyright (C) 2016 Rik Veenboer <rik.veenboer@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package test.lines;
import javax.sound.sampled.Mixer;
import javax.sound.sampled.SourceDataLine;
public class SourceLine {
//private Mixer mixer;
private SourceDataLine line;
public SourceLine(Mixer mixer, SourceDataLine line) {
//this.mixer = mixer;
this.line = line;
System.out.println("SOURCE " + mixer.getMixerInfo().getName() + " || " + line.getLineInfo());
}
public int write(byte[] bytes, int offset, int length) {
return line.write(bytes, offset, length);
}
}

View File

@@ -1,35 +0,0 @@
/**
* Copyright (C) 2016 Rik Veenboer <rik.veenboer@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
package test.lines;
import javax.sound.sampled.Mixer;
import javax.sound.sampled.TargetDataLine;
public class TargetLine {
//private Mixer mixer;
private TargetDataLine line;
public TargetLine(Mixer mixer, TargetDataLine line) {
//this.mixer = mixer;
this.line = line;
System.out.println("TARGET " + mixer.getMixerInfo().getName() + " || " + line.getLineInfo());
}
public int read(byte[] bytes, int offset, int length) {
return line.read(bytes, offset, length);
}
}