XJ music engine  1.9.6
In-game runtime engine for XJ music.
Classes | Public Member Functions | Static Public Member Functions | Public Attributes | Protected Member Functions | Static Protected Member Functions | Protected Attributes | List of all members
XJ::Craft Class Reference

#include <Craft.h>

Inheritance diagram for XJ::Craft:
XJ::FabricationWrapper XJ::BackgroundCraft XJ::BeatCraft XJ::DetailCraft XJ::MacroMainCraft XJ::TransitionCraft

Classes

class  ChoiceIndexProvider
 
class  InstrumentProvider
 
class  LambdaChoiceIndexProvider
 
class  LambdaInstrumentProvider
 
class  Section
 

Public Member Functions

 Craft (Fabricator *fabricator)
 
bool isIntroSegment (const SegmentChoice *choice) const
 
bool isOutroSegment (const SegmentChoice *choice) const
 
bool isSilentEntireSegment (const SegmentChoice *choice) const
 
bool isActiveEntireSegment (const SegmentChoice *choice) const
 
void craftNoteEventArrangements (float tempo, const SegmentChoice *choice, bool defaultAtonal)
 
void precomputeDeltas (const std::function< bool(const SegmentChoice *)> &choiceFilter, const ChoiceIndexProvider &setChoiceIndexProvider, const std::vector< std::string > &layersInCraftOrder, const std::set< std::string > &layerPrioritizationSearches, const int numLayersIncoming)
 
std::optional< const Program * > chooseFreshProgram (Program::Type programType, std::optional< Instrument::Type > voicingType) const
 
std::optional< const Instrument * > chooseFreshInstrument (Instrument::Type type, const std::set< std::string > &requireEventNames) const
 
std::optional< const InstrumentAudio * > chooseFreshInstrumentAudio (const std::set< Instrument::Type > &types, const std::set< Instrument::Mode > &modes, const std::set< UUID > &avoidIds, const std::set< std::string > &preferredEvents) const
 
std::optional< const InstrumentAudio * > selectNewChordPartInstrumentAudio (const Instrument *instrument, const Chord &chord) const
 
std::set< const InstrumentAudio * > selectGeneralAudioIntensityLayers (const Instrument *instrument) const
 

Static Public Member Functions

static bool inBounds (int floor, int ceiling, float value)
 
static bool isUnlimitedIn (const SegmentChoice &choice)
 
static bool isUnlimitedOut (const SegmentChoice &choice)
 

Public Attributes

ChoiceIndexProvider choiceIndexProvider = {}
 

Protected Member Functions

std::set< const Program * > programsDirectlyBound (const std::set< const Program * > &programs) const
 
std::set< const Instrument * > instrumentsDirectlyBound (const std::set< const Instrument * > &instruments) const
 
std::set< const InstrumentAudio * > audiosDirectlyBound (const std::set< const InstrumentAudio * > &instrumentAudios) const
 
std::set< const InstrumentAudio * > audiosPublished (const std::set< const InstrumentAudio * > &instrumentAudios) const
 
bool computeMute (Instrument::Type instrumentType) const
 
void pickInstrumentAudio (const SegmentChoiceArrangement *arrangement, const InstrumentAudio *audio, long startAtSegmentMicros, long lengthMicros, const std::string &event) const
 
std::set< const InstrumentAudio * > selectAudioIntensityLayers (std::set< const InstrumentAudio * > audios, const int layers) const
 
void craftNoteEvents (float tempo, const ProgramSequence *sequence, const std::set< const ProgramVoice * > &voices, LambdaInstrumentProvider instrumentProvider)
 
void craftChordParts (float tempo, const Instrument *instrument)
 
void craftChordParts (float tempo, const Instrument *instrument, const SegmentChoice *choice)
 
void craftEventParts (float tempo, const Instrument *instrument, const Program *program)
 
int computeDeltaIn (const SegmentChoice *choice)
 
int computeDeltaOut (const SegmentChoice *choice)
 
- Protected Member Functions inherited from XJ::FabricationWrapper
 FabricationWrapper (Fabricator *fabricator)
 
FabricationException exception (const std::string &message) const
 
std::string formatLog (const std::string &message) const
 
void reportMissing (const std::map< std::string, std::string > &traces) const
 

Static Protected Member Functions

static std::set< const Program * > programsPublished (const std::set< const Program * > &programs)
 
static std::set< const Instrument * > instrumentsPublished (const std::set< const Instrument * > &instruments)
 

Protected Attributes

std::map< std::string, int > deltaIns
 
std::map< std::string, int > deltaOuts
 
std::set< Instrument::TypefinalizeAudioLengthsForInstrumentTypes
 
- Protected Attributes inherited from XJ::FabricationWrapper
Fabricatorfabricator
 

Detailed Description

Arrangement of Segment Events is a common foundation for all craft

Constructor & Destructor Documentation

◆ Craft()

Craft::Craft ( Fabricator fabricator)
explicit

Must extend this class and inject

Parameters
fabricatorinternal

Member Function Documentation

◆ audiosDirectlyBound()

std::set< const InstrumentAudio * > Craft::audiosDirectlyBound ( const std::set< const InstrumentAudio * > &  instrumentAudios) const
protected

Filter only the directly bound instrumentAudios

Parameters
instrumentAudiosto filter
Returns
filtered instrumentAudios

◆ audiosPublished()

std::set< const InstrumentAudio * > Craft::audiosPublished ( const std::set< const InstrumentAudio * > &  instrumentAudios) const
protected

Filter only the published instrumentAudios

Parameters
instrumentAudiosto filter
Returns
filtered instrumentAudios

◆ chooseFreshInstrument()

std::optional< const Instrument * > Craft::chooseFreshInstrument ( Instrument::Type  type,
const std::set< std::string > &  requireEventNames 
) const

Choose instrument

Choose drum instrument to fulfill beat program event names https://github.com/xjmusic/xjmusic/issues/253

Parameters
typeof instrument to choose from
requireEventNamesinstrument candidates are required to have event names https://github.com/xjmusic/xjmusic/issues/253
Returns
Instrument

◆ chooseFreshInstrumentAudio()

std::optional< const InstrumentAudio * > Craft::chooseFreshInstrumentAudio ( const std::set< Instrument::Type > &  types,
const std::set< Instrument::Mode > &  modes,
const std::set< UUID > &  avoidIds,
const std::set< std::string > &  preferredEvents 
) const

Percussion-type Loop-mode instrument audios are chosen in order of priority https://github.com/xjmusic/xjmusic/issues/255

Choose drum instrument to fulfill beat program event names https://github.com/xjmusic/xjmusic/issues/253

Parameters
typesof instrument to choose from
modesof instrument to choose from
avoidIdsto avoid, or empty list
preferredEventsinstrument candidates are required to have event names https://github.com/xjmusic/xjmusic/issues/253
Returns
Instrument

◆ chooseFreshProgram()

std::optional< const Program * > Craft::chooseFreshProgram ( Program::Type  programType,
std::optional< Instrument::Type voicingType 
) const

Choose a fresh program based on a set of memes

Parameters
programTypeto choose
voicingType(optional) for which to choose a program for– and the program is required to have this type of voice
Returns
Program

◆ computeDeltaIn()

int Craft::computeDeltaIn ( const SegmentChoice choice)
protected

Get the delta in for the given voice

Parameters
choicefor which to get delta in
Returns
delta in for given voice

◆ computeDeltaOut()

int Craft::computeDeltaOut ( const SegmentChoice choice)
protected

Get the delta out for the given voice

Parameters
choicefor which to get delta out
Returns
delta out for given voice

◆ computeMute()

bool Craft::computeMute ( Instrument::Type  instrumentType) const
protected

Compute a mute value, based on the template config

Parameters
instrumentTypeof instrument for which to compute mute
Returns
true if muted

◆ craftChordParts() [1/2]

void Craft::craftChordParts ( float  tempo,
const Instrument instrument 
)
protected

Chord instrument mode https://github.com/xjmusic/xjmusic/issues/235

Parameters
tempoof main program
instrumentfor which to craft choices @on failure

◆ craftChordParts() [2/2]

void Craft::craftChordParts ( float  tempo,
const Instrument instrument,
const SegmentChoice choice 
)
protected

Chord instrument mode https://github.com/xjmusic/xjmusic/issues/235

Parameters
tempoof main program
instrumentchosen
choicefor which to craft chord parts @on failure

◆ craftEventParts()

void Craft::craftEventParts ( float  tempo,
const Instrument instrument,
const Program program 
)
protected

Event instrument mode

Parameters
tempoof main program
instrumentfor which to craft choices
programfor which to craft choices @on failure

◆ craftNoteEventArrangements()

void Craft::craftNoteEventArrangements ( float  tempo,
const SegmentChoice choice,
bool  defaultAtonal 
)

Craft the arrangement for a given voice

Choice inertia https://github.com/xjmusic/xjmusic/issues/242 Perform the inertia analysis, and determine whether they actually use the new choice or not IMPORTANT** If the previously chosen instruments are for the previous main program as the current segment, the inertia scores are not actually added to the regular scores or used to make choices– this would prevent new choices from being made. Inertia must be its own layer of calculation, a question of whether the choices will be followed or whether the inertia will be followed thus the new choices have been made, we know where we're going next, but we aren't actually using them yet until we hit the next main program in full, N segments later.

Ends with a pass to set the actual length of one-shot audio picks One-shot instruments cut off when other notes played with same instrument, or at end of segment https://github.com/xjmusic/xjmusic/issues/243

Parameters
tempoof main program
choiceto craft arrangements for
defaultAtonalwhether to default to a single atonal note, if no voicings are available @on failure

◆ craftNoteEvents()

void Craft::craftNoteEvents ( float  tempo,
const ProgramSequence sequence,
const std::set< const ProgramVoice * > &  voices,
LambdaInstrumentProvider  instrumentProvider 
)
protected

Segments have intensity arcs; automate mixer layers in and out of each main program https://github.com/xjmusic/xjmusic/issues/233

Parameters
tempoof main program
sequencefor which to craft choices
voicesfor which to craft choices
instrumentProviderfrom which to get instruments @on failure

◆ inBounds()

bool Craft::inBounds ( int  floor,
int  ceiling,
float  value 
)
static

Whether a position is in the given bounds

Parameters
floorof boundary
ceilingof boundary
valueto test for within bounds
Returns
true if value is within bounds (inclusive)

◆ instrumentsDirectlyBound()

std::set< const Instrument * > Craft::instrumentsDirectlyBound ( const std::set< const Instrument * > &  instruments) const
protected

Filter only the directly bound instruments

Parameters
instrumentsto filter
Returns
filtered instruments

◆ instrumentsPublished()

std::set< const Instrument * > Craft::instrumentsPublished ( const std::set< const Instrument * > &  instruments)
staticprotected

Filter only the published instruments

Parameters
instrumentsto filter
Returns
filtered instruments

◆ isActiveEntireSegment()

bool Craft::isActiveEntireSegment ( const SegmentChoice choice) const

Whether the given choice is fully active during the current segment

Parameters
choiceto test for activation
Returns
true if this choice is active the entire time

◆ isIntroSegment()

bool Craft::isIntroSegment ( const SegmentChoice choice) const

Whether the current segment contains the delta in for the given choice

Parameters
choiceto test whether the current segment contains this choice delta in
Returns
true if the current segment contains the given choice's delta in

◆ isOutroSegment()

bool Craft::isOutroSegment ( const SegmentChoice choice) const

Whether the current segment contains the delta out for the given choice

Parameters
choiceto test whether the current segment contains this choice delta out
Returns
true if the current segment contains the given choice's delta out

◆ isSilentEntireSegment()

bool Craft::isSilentEntireSegment ( const SegmentChoice choice) const

Whether the given choice is silent during the entire segment

Parameters
choiceto test for silence
Returns
true if choice is silent the entire segment

◆ isUnlimitedIn()

bool Craft::isUnlimitedIn ( const SegmentChoice choice)
static

Whether a given choice has deltaIn unlimited

Parameters
choiceto test
Returns
true if deltaIn is unlimited

◆ isUnlimitedOut()

bool Craft::isUnlimitedOut ( const SegmentChoice choice)
static

Whether a given choice has deltaOut unlimited

Parameters
choiceto test
Returns
true if deltaOut is unlimited

◆ pickInstrumentAudio()

void Craft::pickInstrumentAudio ( const SegmentChoiceArrangement arrangement,
const InstrumentAudio audio,
long  startAtSegmentMicros,
long  lengthMicros,
const std::string &  event 
) const
protected

Pick the transition

Parameters
arrangementto pick
audioto pick
startAtSegmentMicrosto pick
lengthMicrosto pick
eventto pick @on failure

◆ precomputeDeltas()

void Craft::precomputeDeltas ( const std::function< bool(const SegmentChoice *)> &  choiceFilter,
const ChoiceIndexProvider setChoiceIndexProvider,
const std::vector< std::string > &  layersInCraftOrder,
const std::set< std::string > &  layerPrioritizationSearches,
const int  numLayersIncoming 
)

Precompute all deltas for a given program. This is where deltaIns and deltaOuts values come from.

Precompute deltas dynamically based on whatever is extending the arranger– Don't have anything in this class that's proprietary to beat or detail– abstract that out into provider interfaces

Segments have intensity arcs; automate mixer layers in and out of each main program https://github.com/xjmusic/xjmusic/issues/233

Shift deltas so 2x more time is spent on construction than deconstruction

Vary the high plateau between delta in and out across layers

@on failure

◆ programsDirectlyBound()

std::set< const Program * > Craft::programsDirectlyBound ( const std::set< const Program * > &  programs) const
protected

Filter only the directly bound programs

Parameters
programsto filter
Returns
filtered programs

◆ programsPublished()

std::set< const Program * > Craft::programsPublished ( const std::set< const Program * > &  programs)
staticprotected

Filter only the published programs

Parameters
programsto filter
Returns
filtered programs

◆ selectAudioIntensityLayers()

std::set< const InstrumentAudio * > Craft::selectAudioIntensityLayers ( std::set< const InstrumentAudio * >  audios,
const int  layers 
) const
protected

Pick one audio for each desired intensity level, by layering the audios by intensity and picking one from each layer. Divide the audios into layers (ergo grouping them by intensity ascending) and pick one audio per layer.

Parameters
audiosfrom which to pick layers
layersnumber of layers to pick
Returns
picked audios

◆ selectGeneralAudioIntensityLayers()

std::set< const InstrumentAudio * > Craft::selectGeneralAudioIntensityLayers ( const Instrument instrument) const

Select audios for the given instrument

Parameters
instrumentfor which to pick audio
Returns
drum-type Instrument

◆ selectNewChordPartInstrumentAudio()

std::optional< const InstrumentAudio * > Craft::selectNewChordPartInstrumentAudio ( const Instrument instrument,
const Chord chord 
) const

Select a new random instrument audio based on a pattern event

Parameters
instrumentof which to score available audios, and make a selection
chordto match
Returns
matched new audio

Member Data Documentation

◆ choiceIndexProvider

ChoiceIndexProvider XJ::Craft::choiceIndexProvider = {}

◆ deltaIns

std::map<std::string, int> XJ::Craft::deltaIns
protected

◆ deltaOuts

std::map<std::string, int> XJ::Craft::deltaOuts
protected

◆ finalizeAudioLengthsForInstrumentTypes

std::set<Instrument::Type> XJ::Craft::finalizeAudioLengthsForInstrumentTypes
protected

The documentation for this class was generated from the following files: