Skip to content

Commit

Permalink
V5.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
DamonHD committed May 30, 2024
1 parent 186ac88 commit ffad99d
Show file tree
Hide file tree
Showing 7 changed files with 132 additions and 251 deletions.
7 changes: 7 additions & 0 deletions RELEASES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,13 @@ SIGNIFICANT CHANGES SINCE LAST RELEASE
RELEASES
========

20240530:
freezepoint name: V5.3.1 (main)
Changes since last freezepoint (developer/mgr initials and brief description):
DHD20240530: build system adjusted.
DHD20240530: -feedHitsSummary type 1 implemented.


20240527:
freezepoint name: V5.3.0 (main)
Changes since last freezepoint (developer/mgr initials and brief description):
Expand Down
20 changes: 10 additions & 10 deletions build.xml
Original file line number Diff line number Diff line change
Expand Up @@ -34,12 +34,16 @@ Licensed under the Apache License, Version 2.0 (the "License");
<property name="app.name" value="statsHouse"/>
<property name="app.version.major" value="5"/>
<property name="app.version.minor" value="3"/>
<property name="app.version.micro" value="0"/>
<property name="app.version.micro" value="1"/>
<property name="app.version" value="${app.version.major}.${app.version.minor}.${app.version.micro}"/>
<!-- Version excluding the "micro" portion, thus reflecting only significant API/functionality changes. -->
<property name="app.version.notmicro" value="${app.version.major}.${app.version.minor}"/>

<!-- Optimised JAR -->
<property name="dist.jar" value="${app.name}-${app.version}.jar"/>
<!-- Optimised minified JAR for core statsHouse only -->
<property name="shdist.jar" value="${app.name}-${app.version}.min.jar"/>


<!-- Target/minimum JDK/JSE version for build and run. -->
<property name="JDKVER" value="18"/>
Expand Down Expand Up @@ -204,14 +208,14 @@ Licensed under the Apache License, Version 2.0 (the "License");
</target>

<!-- Super-optimised and shrunk org.hd.d.statsHouse.Main JAR -->
<target name="core.jar.edhMainsuperopt"
<target name="core.jar.shMainsuperopt"
depends="core.jar.opt"
description="builds the shrunk optimised/release org.hd.d.statsHouse.Main JAR">
<proguard
verbose="true">
<!-- -printconfiguration -->
-injars ${build.dir.opt}/${dist.jar}
-outjars ${build.dir.opt}/${app.name}Main.${dist.jar}
-outjars ${build.dir.opt}/${shdist.jar}
-libraryjars ${java.home}/jmods/java.base.jmod(!**.jar;!module-info.class)
-libraryjars ${java.home}/jmods/java.desktop.jmod(!**.jar;!module-info.class)
<!--
Expand All @@ -232,13 +236,9 @@ Licensed under the Apache License, Version 2.0 (the "License");
-dontobfuscate <!-- leave all class/method names etc for easiest debugging -->
-keepattributes SourceFile,LineNumberTable <!-- Keep minimum for exception debugging. -->
</proguard>
<echo message="Release org.hd.d.statsHouse.Main JAR now at ${build.dir.opt}/statsHouseMain.${dist.jar} ..." />
<echo message="Release org.hd.d.statsHouse.Main JAR now at ${build.dir.opt}/${shdist.jar} ..." />
</target>







<!-- =================================================================== -->
Expand Down Expand Up @@ -337,12 +337,12 @@ Licensed under the Apache License, Version 2.0 (the "License");
<!-- Builds debug and optimised code from scratch, and tests it. -->
<!-- =================================================================== -->
<target name="all"
depends="clean,core.test.opt,core.jar.opt,core.jar.edhMainsuperopt"
depends="clean,core.test.opt,core.jar.opt,core.jar.shMainsuperopt"
description="cleans, then does optimised/release build and test">
<echo message="Builds and tests complete."/>
</target>
<!-- depends="clean,core.jar.opt,src.snapshot" -->
<!-- depends="clean,core.jar.opt,core.jar.edhMainsuperopt,src.snapshot" -->
<!-- depends="clean,core.jar.opt,core.jar.shMainsuperopt,src.snapshot" -->

<!-- =================================================================== -->
<!-- Cleans up generated intermediate stuff -->
Expand Down
110 changes: 88 additions & 22 deletions javasrc/org/hd/d/statsHouse/Main.java
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.io.ByteArrayOutputStream;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.Reader;
Expand All @@ -34,7 +35,9 @@
import java.util.Objects;
import java.util.regex.Pattern;

import javax.sound.midi.InvalidMidiDataException;
import javax.sound.midi.MidiSystem;
import javax.sound.midi.MidiUnavailableException;
import javax.sound.midi.Sequence;
import javax.sound.midi.Sequencer;
import javax.sound.sampled.AudioFileFormat;
Expand All @@ -44,6 +47,7 @@
import org.hd.d.statsHouse.data.DataBounds;
import org.hd.d.statsHouse.data.EOUDataCSV;
import org.hd.d.statsHouse.data.FileUtils;
import org.hd.d.statsHouse.feedHits.GenerateSummary;
import org.hd.d.statsHouse.midi.MIDIConstant;
import org.hd.d.statsHouse.midi.MIDIGen;
import org.hd.d.statsHouse.midi.MIDITune;
Expand All @@ -65,6 +69,7 @@ private static void printOptions()
System.err.println(" Read independent command lines from specified file or stdin if '-'");
System.err.println(" Do not process further command-line arguments.");
System.err.println(" infilename.csv (-play|<outfilename>.(csv|mid|wav)))");
System.err.println(" -feedHitsSummary -play|<outfilename>.mid <typeN> {feedHitsDataDir}*");
GenerationParameters.printOptions();
System.err.println();
System.err.println(" This syntax may be used, one per line, in the command file.");
Expand Down Expand Up @@ -173,10 +178,27 @@ public static void runCommands(final List<List<String>> cmdlines, final boolean
if(argCount < 2)
{ throw new IllegalArgumentException("too few arguments: at least input.csv and -play or output.csv or output.mid required"); }

final String inputFileName = cmdline.get(0);
final String outputFileName = cmdline.get(1);

try {
if("-feedHitsSummary".equals(cmdline.get(0)))
{
// feedHits integration
if(argCount < 4) { throw new IllegalArgumentException("too few arguments to -feedHitsSummary"); }
final String outputFileName = cmdline.get(1);
final MIDITune mt = GenerateSummary.summary(Integer.parseInt(cmdline.get(2), 10), cmdline.subList(3, cmdline.size()));

final Sequence s = MIDIGen.genFromTuneSequence(mt, null, null);

// Play it immediately!
if("-play".equals(outputFileName))
{ playIt(s); }
else
{ saveIt(s, outputFileName); }

continue;
}

final String inputFileName = cmdline.get(0);
final String outputFileName = cmdline.get(1);
// Remaining optional args determine GenerationParameters.
// Use the final component of the input file name as the tune name.
// TODO strip extension
Expand Down Expand Up @@ -241,24 +263,25 @@ public static void runCommands(final List<List<String>> cmdlines, final boolean
}
else if("-play".equals(outputFileName))
{
// Get default sequencer.
try(final Sequencer sequencer = MidiSystem.getSequencer())
{
if(null == sequencer)
{
throw new UnsupportedOperationException("MIDI sequencer not available.");
}

// Acquire resources and make operational.
sequencer.open();

sequencer.setSequence(s);
final long usLength = sequencer.getMicrosecondLength();
System.out.println(String.format("INFO: duration %.1fs...", usLength / 1_000_000f));
sequencer.start();
while(sequencer.isRunning()) { Thread.sleep(1000); }
Thread.sleep(1000); // Allow for some graceful decay of the sound!
}
playIt(s);
// // Get default sequencer.
// try(final Sequencer sequencer = MidiSystem.getSequencer())
// {
// if(null == sequencer)
// {
// throw new UnsupportedOperationException("MIDI sequencer not available.");
// }
//
// // Acquire resources and make operational.
// sequencer.open();
//
// sequencer.setSequence(s);
// final long usLength = sequencer.getMicrosecondLength();
// System.out.println(String.format("INFO: duration %.1fs...", usLength / 1_000_000f));
// sequencer.start();
// while(sequencer.isRunning()) { Thread.sleep(1000); }
// Thread.sleep(1000); // Allow for some graceful decay of the sound!
// }
}
else
{
Expand All @@ -269,11 +292,54 @@ else if("-play".equals(outputFileName))
catch(final Exception e)
{
e.printStackTrace();
throw new RuntimeException("failed processing input " + inputFileName, e);
throw new RuntimeException("failed processing command " + cmdline, e);
}
}
}

/**Save the MIDI sequence; never null.
* @throws InvalidMidiDataException
* @throws IOException
*/
private static final void saveIt(final Sequence s, final String outputFileName)
throws InvalidMidiDataException, IOException
{
// Generate MIDI binary file.
try (ByteArrayOutputStream baos = new ByteArrayOutputStream(256))
{
MidiSystem.write(s, MIDIConstant.PREFERRED_MIDI_FILETYPE, baos);
FileUtils.replacePublishedFile(outputFileName, baos.toByteArray(), true);
}
}

/**Play the MIDI Sequence; never null.
* @throws InvalidMidiDataException
* @throws MidiUnavailableException
* @throws InterruptedException
*/
private static final void playIt(final Sequence s)
throws InvalidMidiDataException, MidiUnavailableException, InterruptedException
{
// Get default sequencer.
try(final Sequencer sequencer = MidiSystem.getSequencer())
{
if(null == sequencer)
{
throw new UnsupportedOperationException("MIDI sequencer not available.");
}

// Acquire resources and make operational.
sequencer.open();

sequencer.setSequence(s);
final long usLength = sequencer.getMicrosecondLength();
System.out.println(String.format("INFO: duration %.1fs...", usLength / 1_000_000f));
sequencer.start();
while(sequencer.isRunning()) { Thread.sleep(1000); }
Thread.sleep(1000); // Allow for some graceful decay of the sound!
}
}

/**Get version number as a.b.c String, else null if not available. */
public static final String getManifestVersion()
{ return(Main.class.getPackage().getImplementationVersion()); }
Expand Down
4 changes: 2 additions & 2 deletions javasrc/org/hd/d/statsHouse/feedHits/GenerateSummary.java
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public static MIDITune summary1(final List<String> dirnames) throws IOException
(byte) 0, // MIDIPercusssionInstrument.ACOUSTIC_BASE_DRUM.instrument0,
MIDIConstant.DEFAULT_VOLUME,
(MIDIConstant.DEFAULT_PAN),
"hits and bytes per hour");
"bytes&hits by hour");
// Bytes-per-hour track.
final List<MIDIPlayableBar> pbBytes = new ArrayList<>(nDataBars);

Expand Down Expand Up @@ -130,7 +130,7 @@ public static MIDITune summary1(final List<String> dirnames) throws IOException
MIDIGen.DEFAULT_CLKSPQTR/2-1));
// Off beat: hits
final float intH = normalisedHitsPerHour[h+b] / normalisedHitsPerHourMax;
System.out.println(intH);
//System.out.println(intH);
notes.add(new MIDIPlayableBar.StartNoteVelocityDuration(
beatStart + MIDIGen.DEFAULT_CLKSPQTR/2,
new NoteAndVelocity(DRUMH, (byte) Math.round(vDRUM * intH)),
Expand Down
Loading

0 comments on commit ffad99d

Please sign in to comment.