Skip to content

Commit

Permalink
Update 12/18/21
Browse files Browse the repository at this point in the history
For syncing files. Also fixed Log4J vulnerability.
  • Loading branch information
Rusettsten committed Dec 18, 2021
1 parent feda7cf commit 408234d
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 11 deletions.
2 changes: 1 addition & 1 deletion photon/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
<dependency>
<groupId>org.apache.logging.log4j</groupId>
<artifactId>log4j-core</artifactId>
<version>2.14.0</version>
<version>2.15.0</version>
</dependency>
<dependency>
<groupId>org.yaml</groupId>
Expand Down
2 changes: 1 addition & 1 deletion photon/src/main/java/com/strikete/photon/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public static void main(String[] args) throws IOException {
BeatProcessor beatProcessor = new BeatProcessor(photon);

while(true) {
photon.updateOscObjects();
//photon.updateOscObjects();
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
Expand Down
35 changes: 28 additions & 7 deletions photon/src/main/java/com/strikete/photon/temp/BeatProcessor.java
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStreamReader;
import java.text.DecimalFormat;
import java.util.ArrayList;

import com.strikete.photon.Photon;
Expand All @@ -16,6 +17,7 @@ public class BeatProcessor {
*/
private static ArrayList<BeatTime> beatTimes = new ArrayList<BeatTime>();
private Photon photon;
private static final DecimalFormat df = new DecimalFormat("0.00");

/*
* METHODS
Expand All @@ -30,8 +32,8 @@ public static void readFile() throws IOException {

String strLine;
int currentSample = 0;
float amplitudeThreshold = (float) -7.000;
float amplitudeFloor = (float) -40.000;
float amplitudeThreshold = (float) -3.000;
float amplitudeFloor = (float) -49.000;
boolean activeBeat = false;
int activeBeatStartingSample = 0;

Expand Down Expand Up @@ -76,17 +78,18 @@ public void recordCues() {
for(int x = 0; x < beatTimes.size(); x++) {
String oldCueNum = Integer.toString(cueCount);
cueCount++;
double oldFollowTime = (beatTimes.get(x).startSeconds-oldCueTime);
String senderMessageOldFollow = "Cue " + oldCueNum + " Follow " + Double.toString(oldFollowTime) + " #";
float oldFollowTime = (beatTimes.get(x).startSeconds-oldCueTime);
String senderMessageOldFollow = "Cue " + oldCueNum + " Follow " + df.format(oldFollowTime) + " #";
photon.sender.sendOscMessage("/eos/newcmd",senderMessageOldFollow);

String cueNum = Integer.toString(cueCount); //New Cue Creation
String senderMessage = "Cue " + cueNum + " ##";
photon.sender.sendOscMessage("/eos/newcmd",senderMessage);
photon.sender.sendOscMessage("/eos/newcmd","Chan 1 Thru 3 @ 100 #");
String senderMessage2 = "Cue " + cueNum + " Time 0.1 #";
String senderMessage2 = "Cue " + cueNum + " Time 0.0 #";
photon.sender.sendOscMessage("/eos/newcmd", senderMessage2);
double followTime = (beatTimes.get(x).endSeconds - beatTimes.get(x).startSeconds);
String senderMessage3 = "Cue " + cueNum + " Follow " + Double.toString(followTime) + " #";
float followTime = (beatTimes.get(x).endSeconds - beatTimes.get(x).startSeconds);
String senderMessage3 = "Cue " + cueNum + " Follow " + df.format(followTime) + " #";
photon.sender.sendOscMessage("/eos/newcmd", senderMessage3);

cueCount++;
Expand All @@ -97,11 +100,27 @@ public void recordCues() {
photon.sender.sendOscMessage("/eos/newcmd","Chan 1 Thru 3 @ 0 #");
senderMessage2 = "Cue " + cueNum + " Time 0.6 #";
oldCueTime = beatTimes.get(x).endSeconds;
photon.sender.sendOscMessage("/eos/newcmd",senderMessage2);

}

}

public float findAverageBeatTime() {
ArrayList<Float> averageList = new ArrayList<Float>();
for(int x = 1; x < beatTimes.size(); x++) {
float time = beatTimes.get(x).startSeconds-beatTimes.get(x-1).startSeconds;
if(time <= 1) {
averageList.add(time);
}
}
double averageBig = 0;
for(int y = 0; y < averageList.size(); y++) {
averageBig = averageBig + averageList.get(y);
}
return (float) (averageBig / averageList.size());
}

/*
* CONSTRUCTOR
*/
Expand All @@ -115,6 +134,8 @@ public BeatProcessor(Photon photonIn) {
}

setupCueRecording();
System.out.println(findAverageBeatTime());

recordCues();

}
Expand Down
5 changes: 3 additions & 2 deletions photon/src/main/java/com/strikete/photon/temp/BeatTime.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ public class BeatTime {
public BeatTime(int startSampleNumIn, int endSampleNumIn) {
this.startSampleNumber = startSampleNumIn;
this.endSampleNumber = endSampleNumIn;
this.startSeconds = startSampleNumIn / 8000;
this.endSeconds = endSampleNumIn / 8000;
float modifier = (float) 8000.00;
this.startSeconds = startSampleNumIn / modifier;
this.endSeconds = endSampleNumIn / modifier;
}
}

0 comments on commit 408234d

Please sign in to comment.