Skip to content

Instantly share code, notes, and snippets.

all:
children:
workers:
hosts:
pico2:
ansible_host: 192.168.0.202
pico3:
ansible_host: 192.168.0.203
pico4:
ansible_host: 192.168.0.204
@alanwhite
alanwhite / BeamEnum.java
Last active November 27, 2021 23:16
Code snippets for music note beam modelling
package xyz.arwhite.music.models;
public enum BeamEnum {
BACKWARD_HOOK { public String toString() {
return "backward hook";
}},
BEGIN { public String toString() {
return "begin";
@alanwhite
alanwhite / BaseNoteModel.java
Created November 27, 2021 22:51
Representing optional beams in the note class
public class BaseNoteModel extends StaffElementModel {
// snip ...
/*
* A note or rest can have multiple beams
*/
private Optional<List<BeamEnum>> beams = Optional.empty();
// snip ...
@alanwhite
alanwhite / MeasurePartsModels.java
Created November 27, 2021 23:04
Cramming extracts of the musical measure and part models into a single gist for the sake of a blog post
public class MeasureModel extends ScoreContainerModel {
// snip ...
private List<PartModel> parts = new ArrayList<PartModel>();
// snip ...
public List<PartModel> getParts() {
return parts;
@alanwhite
alanwhite / AutoBeamSimpleTimeAlgo1.java
Created December 4, 2021 15:40
Example tests for the simplest autobeam algo
class AutoBeamSimpleTestAlgo1 {
// for divisions = 840
private static Map<Integer, Integer> durations = Map.of(
BaseNoteModel.semiBreve, 3360,
BaseNoteModel.minim, 1680,
BaseNoteModel.crotchet, 840,
BaseNoteModel.quaver, 420,
BaseNoteModel.semiQuaver, 210,
BaseNoteModel.demiSemiQuaver, 105,
public class Divisions {
public static int divisionsPerBeat(MusicalContext mcx) {
var div = mcx.getDivisions() * 4;
var top = mcx.getTimeSig().getTop();
var bot = mcx.getTimeSig().getBottom();
var bpb = TimeSigUtil.beatsPerBar(mcx.getTimeSig());
return (div * top) / bot / bpb;
@alanwhite
alanwhite / TimeSigUtils.java
Last active December 4, 2021 16:38
Helper class for exposing characteristics of a time signature
public class TimeSigUtil {
public static boolean isCompoundTime(TimeSigModel model) {
if ( model.getTop() == 3 )
return false;
if ( model.getTop() % 3 == 0 )
return true;
@alanwhite
alanwhite / AutoBeamSimple.java
Last active December 20, 2021 08:36
Simple algo to automatically add beams to music
package xyz.arwhite.music.helpers;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
import xyz.arwhite.music.models.BaseNoteModel;
import xyz.arwhite.music.models.BeamEnum;
@alanwhite
alanwhite / AutoBeamCommon.java
Last active December 20, 2021 08:36
Algo that implements a common beam style for music, where the primary subdivision of the beat is used to direct hooks
package xyz.arwhite.music.helpers;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
import java.util.Optional;
import java.util.stream.Collectors;
import xyz.arwhite.music.models.BaseNoteModel;
import xyz.arwhite.music.models.BeamEnum;
@alanwhite
alanwhite / AbstractAutoBeam.java
Created December 20, 2021 08:37
Base class with utility methods for classes implementing automatic beaming algos
package xyz.arwhite.music.helpers;
import java.util.ArrayList;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;
import xyz.arwhite.music.models.BaseNoteModel;
import xyz.arwhite.music.models.BeamEnum;
import xyz.arwhite.music.models.MeasureModel;