added airflow/breath

This commit is contained in:
Lucas Pleß 2014-04-17 17:27:19 +02:00
parent 7e0bc24273
commit f396266715
5 changed files with 96 additions and 21 deletions

View File

@ -6,6 +6,8 @@
<artifactId>psychose</artifactId>
<groupId>psy</groupId>
<packaging>jar</packaging>
<dependencies>
<dependency>
<groupId>com.illposed.osc</groupId>
@ -33,4 +35,23 @@
</repository>
</repositories>
<build>
<plugins>
<plugin>
<artifactId>maven-assembly-plugin</artifactId>
<configuration>
<archive>
<manifest>
<mainClass>MainForm</mainClass>
</manifest>
</archive>
<descriptorRefs>
<descriptorRef>jar-with-dependencies</descriptorRef>
</descriptorRefs>
</configuration>
</plugin>
</plugins>
</build>
</project>

View File

@ -1,14 +1,14 @@
<?xml version="1.0" encoding="UTF-8"?>
<form xmlns="http://www.intellij.com/uidesigner/form/" version="1" bind-to-class="ActorDisplay">
<grid id="27dc6" binding="actorPanel" layout-manager="GridLayoutManager" row-count="8" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<grid id="27dc6" binding="actorPanel" layout-manager="GridLayoutManager" row-count="9" column-count="2" same-size-horizontally="false" same-size-vertically="false" hgap="-1" vgap="-1">
<margin top="4" left="6" bottom="4" right="6"/>
<constraints>
<xy x="20" y="20" width="220" height="220"/>
<xy x="20" y="20" width="220" height="250"/>
</constraints>
<properties>
<background color="-16777216"/>
<foreground color="-1"/>
<minimumSize width="220" height="220"/>
<minimumSize width="220" height="250"/>
<preferredSize width="0" height="0"/>
</properties>
<border type="line">
@ -22,12 +22,12 @@
<properties>
<font name="Droid Sans Mono" size="20"/>
<foreground color="-1"/>
<text value="Pulse"/>
<text value="Puls"/>
</properties>
</component>
<vspacer id="1290">
<constraints>
<grid row="7" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
<grid row="8" column="0" row-span="1" col-span="1" vsize-policy="6" hsize-policy="1" anchor="0" fill="2" indent="0" use-parent-layout="false"/>
</constraints>
</vspacer>
<component id="d0a2" class="javax.swing.JLabel" binding="lblPulse">
@ -77,7 +77,7 @@
<properties>
<font name="Droid Sans Mono" size="20"/>
<foreground color="-1"/>
<text value="Heart"/>
<text value="Herz"/>
</properties>
</component>
<component id="e1c6d" class="javax.swing.JLabel" binding="lblOxy">
@ -120,16 +120,6 @@
<text value="-"/>
</properties>
</component>
<component id="9b787" class="javax.swing.JLabel" binding="lblCaption">
<constraints>
<grid row="0" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Droid Sans Mono" size="28" style="1"/>
<foreground color="-1"/>
<text value="Label"/>
</properties>
</component>
<component id="4d72a" class="javax.swing.JLabel">
<constraints>
<grid row="6" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
@ -150,6 +140,36 @@
<text value="-"/>
</properties>
</component>
<component id="9b787" class="javax.swing.JLabel" binding="lblCaption">
<constraints>
<grid row="0" column="0" row-span="1" col-span="2" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Droid Sans Mono" size="28" style="1"/>
<foreground color="-1"/>
<text value="Label"/>
</properties>
</component>
<component id="29a78" class="javax.swing.JLabel">
<constraints>
<grid row="7" column="0" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="8" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Droid Sans Mono" size="20"/>
<foreground color="-1"/>
<text value="Atem"/>
</properties>
</component>
<component id="bb84f" class="javax.swing.JLabel" binding="lblBreath">
<constraints>
<grid row="7" column="1" row-span="1" col-span="1" vsize-policy="0" hsize-policy="0" anchor="4" fill="0" indent="0" use-parent-layout="false"/>
</constraints>
<properties>
<font name="Droid Sans Mono" size="20"/>
<foreground color="-1"/>
<text value="-"/>
</properties>
</component>
</children>
</grid>
</form>

View File

@ -19,6 +19,7 @@ public class ActorDisplay {
private JLabel lblEkg;
private JLabel lblEmg;
private JLabel lblTemperature;
private JLabel lblBreath;
private int counterHeartbeat = 0;
private int counterPulse = 0;
@ -26,6 +27,7 @@ public class ActorDisplay {
private int counterEkg = 0;
private int counterEmg = 0;
private int counterTemperature = 0;
private int counterBreath = 0;
private int timeout = 20; // 20 * 100ms
@ -33,6 +35,11 @@ public class ActorDisplay {
lblCaption.setText(caption);
}
public void setBreath(String breath) {
lblBreath.setText(breath);
counterBreath = 0;
}
public void setTemperature(String temperature) {
lblTemperature.setText(temperature);
counterTemperature = 0;
@ -108,6 +115,12 @@ public class ActorDisplay {
lblHeartbeat.setForeground(onColor);
}
if(++counterBreath > timeout) {
lblBreath.setForeground(offColor);
} else {
lblBreath.setForeground(onColor);
}
}
});
timer.setRepeats(true);

View File

@ -24,9 +24,9 @@ public class MainForm {
osCclient = client;
osCclient.startReceiver();
addActor("merle", "Merle", actor1);
addActor("uwe", "Uwe", actor2);
addActor("bjoern", "Björn", actor3);
addActor("merle", "Proband 1", actor1);
addActor("uwe", "Proband 2", actor2);
addActor("bjoern", "Proband 3", actor3);
}
@ -69,12 +69,21 @@ public class MainForm {
}
}
});
osCclient.addListener("/" + actor.toLowerCase() + "/airFlow", new OSCListener() {
@Override
public void acceptMessage(Date time, OSCMessage message) {
if (message.getArguments().length == 1) {
actorDisplay.setBreath(message.getArguments()[0].toString());
}
}
});
}
public static void main(String[] args) {
try {
final ChaOSCclient chaOSCclient = new ChaOSCclient("localhost", 7110);
final ChaOSCclient chaOSCclient = new ChaOSCclient("chaosc", 7110);
final MainForm mainForm = new MainForm(chaOSCclient);
final JFrame frame = new JFrame("MainForm");

View File

@ -1,14 +1,17 @@
import javax.sound.midi.*;
import java.io.File;
import java.util.HashSet;
public class Test {
public static final int NOTE_ON = 0x90;
public static final int NOTE_OFF = 0x80;
public static final String[] NOTE_NAMES = {"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B"};
public static final String[] NOTE_NAMES = {"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "H"};
public static void main(String[] args) throws Exception {
Sequence sequence = MidiSystem.getSequence(new File("/home/lucas/jake-avril_14th.mid"));
HashSet<String> notes = new HashSet<String>();
int trackNumber = 0;
for (Track track : sequence.getTracks()) {
trackNumber++;
@ -28,6 +31,9 @@ public class Test {
String noteName = NOTE_NAMES[note];
int velocity = sm.getData2();
System.out.println("Note on, " + noteName + octave + " key=" + key + " velocity: " + velocity);
notes.add(noteName+octave);
} else if (sm.getCommand() == NOTE_OFF) {
int key = sm.getData1();
int octave = (key / 12)-1;
@ -44,6 +50,12 @@ public class Test {
}
System.out.println();
}
System.out.println(notes);
}
}