Skip to content

Commit

Permalink
Lower tom in skipHours.
Browse files Browse the repository at this point in the history
  • Loading branch information
DamonHD committed May 31, 2024
1 parent ffad99d commit 612c2eb
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 7 deletions.
1 change: 1 addition & 0 deletions RELEASES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ or release/freeze points.
SIGNIFICANT CHANGES SINCE LAST RELEASE
======================================

DHD20240531: -feedHitsSummary type 1 uses lower tom in skipHours.



Expand Down
34 changes: 28 additions & 6 deletions javasrc/org/hd/d/statsHouse/feedHits/GenerateSummary.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import java.util.SortedSet;
import java.util.TreeSet;

import org.hd.d.statsHouse.feedHits.data.FeedStatus;
import org.hd.d.statsHouse.feedHits.data.FeedStatusBlock;
import org.hd.d.statsHouse.feedHits.data.FeedStatusBlocks;
import org.hd.d.statsHouse.generic.NoteAndVelocity;
Expand Down Expand Up @@ -75,6 +76,9 @@ public static MIDITune summary1(final List<String> dirnames) throws IOException
final float[] normalisedBytesPerHour = new float[nTotalHours];
float normalisedHitsPerHourMax = 0;
float normalisedBytesPerHourMax = 0;
// Capture skipHours.
final boolean[] isSkipHour = new boolean[nTotalHours];

int hourIndex = 0;
for(final FeedStatusBlock fsb : fsbs.blocks())
{
Expand All @@ -83,12 +87,24 @@ public static MIDITune summary1(final List<String> dirnames) throws IOException
// For the 24h in each block.
for(int h = 0; h < 24; ++h)
{
final float nh = fsb.records().get(h).hits() / nDaysF;
final float nb = fsb.records().get(h).bytes() / nDaysF;
final FeedStatus feedStatus = fsb.records().get(h);
final float nh = feedStatus.hits() / nDaysF;
final float nb = feedStatus.bytes() / nDaysF;
normalisedHitsPerHour[hourIndex] = nh;
normalisedBytesPerHour[hourIndex] = nb;
if(nh > normalisedHitsPerHourMax) { normalisedHitsPerHourMax = nh; }
if(nb > normalisedBytesPerHourMax) { normalisedBytesPerHourMax = nb; }

// Is a skipHour if non-zero "SH" hits
// OR "SH" key absent and time >=22:00 and < 08:00.
final Integer hitsHS = feedStatus.getColsMap().get("SH");
if(null != hitsHS) { if(hitsHS > 0) { isSkipHour[hourIndex] = true; } }
else
{
final int hourOfDay = hourIndex % 24;
if((hourOfDay < 8) || (hourOfDay >= 22)) { isSkipHour[hourIndex] = true; }
}

++hourIndex;
}
}
Expand All @@ -114,22 +130,28 @@ public static MIDITune summary1(final List<String> dirnames) throws IOException
final SortedSet<MIDIPlayableBar.StartNoteVelocityDuration> notes = new TreeSet<>();

final byte DRUMB = MIDIPercusssionInstrument.HI_MID_TOM.instrument0;
final byte DRUMH = MIDIPercusssionInstrument.LOW_MID_TOM.instrument0;
// final byte DRUMH = MIDIPercusssionInstrument.ACOUSTIC_BASE_DRUM.instrument0;
final byte vDRUM = MIDIGen.DEFAULT_MAX_MELODY_VELOCITY;

for(int b = 0; b < nHoursPerBar; ++b)
{
final int hour = h+b;

// Push hits tone even lower in skip hours.
final byte DRUMH = (isSkipHour[h+b] ?
MIDIPercusssionInstrument.LOW_TOM :
MIDIPercusssionInstrument.LOW_MID_TOM)
.instrument0;

final int beatStart = b * MIDIGen.DEFAULT_CLKSPQTR;
// On beat: bytes
final float intB = normalisedBytesPerHour[h+b] / normalisedBytesPerHourMax;
final float intB = normalisedBytesPerHour[hour] / normalisedBytesPerHourMax;
//System.out.println(intB);
notes.add(new MIDIPlayableBar.StartNoteVelocityDuration(
beatStart,
new NoteAndVelocity(DRUMB, (byte) Math.round(vDRUM * intB)),
MIDIGen.DEFAULT_CLKSPQTR/2-1));
// Off beat: hits
final float intH = normalisedHitsPerHour[h+b] / normalisedHitsPerHourMax;
final float intH = normalisedHitsPerHour[hour] / normalisedHitsPerHourMax;
//System.out.println(intH);
notes.add(new MIDIPlayableBar.StartNoteVelocityDuration(
beatStart + MIDIGen.DEFAULT_CLKSPQTR/2,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,12 @@ public enum MIDIPercusssionInstrument

OPEN_HI_HAT(46),

LOW_FLOOR_TOM(41),
HIGH_FLOOR_TOM(43),
LOW_TOM(45),
LOW_MID_TOM(47),
HI_MID_TOM(48);
HI_MID_TOM(48),
HI_TOM(50);

/**Raw zero-based instrument number. */
public final byte instrument0;
Expand Down

0 comments on commit 612c2eb

Please sign in to comment.