Skip to content

Commit

Permalink
Double Pedal Passing Tone Ornamentation (#229)
Browse files Browse the repository at this point in the history
  • Loading branch information
wbaldoumas authored Jan 12, 2025
1 parent 4ed422f commit a1df86a
Show file tree
Hide file tree
Showing 7 changed files with 40 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@ public sealed record AggregateOrnamentationConfiguration(ISet<OrnamentationConfi
new(OrnamentationType.UpperOctavePedalPassingTone, ConfigurationStatus.Enabled, 80),
new(OrnamentationType.UpperOctavePedalArpeggio, ConfigurationStatus.Enabled, 80),
new(OrnamentationType.TriplePickup, ConfigurationStatus.Enabled, 25),
new(OrnamentationType.SequencedThirds, ConfigurationStatus.Enabled, 25)
new(OrnamentationType.SequencedThirds, ConfigurationStatus.Enabled, 25),
new(OrnamentationType.DoublePedalPassingTone, ConfigurationStatus.Enabled, 25)
}
);
}
1 change: 1 addition & 0 deletions src/BaroquenMelody.Library/Midi/MidiExampleGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,7 @@ public MidiFile GenerateExampleOrnamentationMidiFile(OrnamentationType ornamenta
OrnamentationType.UpperOctavePedalArpeggio => new BaroquenNote(Instrument.One, Note.Get(compositionConfiguration.Scale.Dominant, 4), compositionConfiguration.DefaultNoteTimeSpan),
OrnamentationType.TriplePickup => new BaroquenNote(Instrument.One, Note.Get(compositionConfiguration.Scale.Mediant, 4), compositionConfiguration.DefaultNoteTimeSpan),
OrnamentationType.SequencedThirds => new BaroquenNote(Instrument.One, Note.Get(compositionConfiguration.Scale.Subdominant, 3), compositionConfiguration.DefaultNoteTimeSpan),
OrnamentationType.DoublePedalPassingTone => new BaroquenNote(Instrument.One, Note.Get(compositionConfiguration.Scale.Dominant, 4), compositionConfiguration.DefaultNoteTimeSpan),
_ => throw new ArgumentOutOfRangeException(nameof(ornamentationType), ornamentationType, "Ornamentation type not supported.")
};
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@ ILogger logger

private const int PassingToneInterval = 2;

private const int DoublePedalPassingToneInterval = 4;

private const int RootPedalInterval = -3;

private const int ThirdPedalInterval = -2;
Expand Down Expand Up @@ -654,6 +656,23 @@ public IEnumerable<OrnamentationProcessorConfiguration> Create(OrnamentationConf
)
);
break;
case OrnamentationType.DoublePedalPassingTone:
processorConfigurations.Add(
new OrnamentationProcessorConfiguration(
OrnamentationType.DoublePedalPassingTone,
InputPolicies:
[
wantsToOrnament,
_hasNoOrnamentation,
new IsApplicableInterval(compositionConfiguration, DoublePedalPassingToneInterval)
],
OutputPolicies: [logOrnamentation],
Translations: [0, 1, 0, 2, 0, 3, 0],
ShouldInvertBasedOnDirection,
TranslationInversionIndices: new HashSet<int> { 1, 3, 5 }.ToFrozenSet()
)
);
break;
case OrnamentationType.None:
case OrnamentationType.Sustain:
case OrnamentationType.MidSustain:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ internal static class OrnamentationTypeExtensions
{ OrnamentationType.UpperOctavePedalPassingTone, 3 },
{ OrnamentationType.UpperOctavePedalArpeggio, 3 },
{ OrnamentationType.SequencedThirds, 7 },
{ OrnamentationType.DoublePedalPassingTone, 7 },
{ OrnamentationType.None, 0 },
{ OrnamentationType.Sustain, 0 },
{ OrnamentationType.MidSustain, 0 },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -176,4 +176,9 @@ public enum OrnamentationType : byte
/// A sequence of thirds.
/// </summary>
SequencedThirds,

/// <summary>
/// A double pedal with passing tones connecting two notes.
/// </summary>
DoublePedalPassingTone
}
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,10 @@ internal sealed class MusicalTimeSpanCalculator : IMusicalTimeSpanCalculator
OrnamentationType.SequencedThirds when meter == Meter.ThreeFour => MusicalTimeSpan.Quarter + MusicalTimeSpan.Sixteenth,
OrnamentationType.SequencedThirds when meter == Meter.FiveEight => MusicalTimeSpan.Eighth.Dotted(1),

OrnamentationType.DoublePedalPassingTone when meter == Meter.FourFour => MusicalTimeSpan.Sixteenth,
OrnamentationType.DoublePedalPassingTone when meter == Meter.ThreeFour => MusicalTimeSpan.Quarter + MusicalTimeSpan.Sixteenth,
OrnamentationType.DoublePedalPassingTone when meter == Meter.FiveEight => MusicalTimeSpan.Eighth.Dotted(1),

OrnamentationType.MidSustain => Zero,
OrnamentationType.Rest => Zero,

Expand Down Expand Up @@ -291,6 +295,10 @@ internal sealed class MusicalTimeSpanCalculator : IMusicalTimeSpanCalculator
OrnamentationType.SequencedThirds when meter == Meter.ThreeFour => MusicalTimeSpan.Sixteenth,
OrnamentationType.SequencedThirds when meter == Meter.FiveEight => MusicalTimeSpan.Sixteenth,

OrnamentationType.DoublePedalPassingTone when meter == Meter.FourFour => MusicalTimeSpan.Sixteenth,
OrnamentationType.DoublePedalPassingTone when meter == Meter.ThreeFour => MusicalTimeSpan.Sixteenth,
OrnamentationType.DoublePedalPassingTone when meter == Meter.FiveEight => MusicalTimeSpan.Sixteenth,

OrnamentationType.MidSustain => Zero,
OrnamentationType.Rest => Zero,

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ public void ConfigurableOrnamentations_returns_expected_values()
OrnamentationType.UpperOctavePedalPassingTone,
OrnamentationType.UpperOctavePedalArpeggio,
OrnamentationType.TriplePickup,
OrnamentationType.SequencedThirds
OrnamentationType.SequencedThirds,
OrnamentationType.DoublePedalPassingTone
};

// act
Expand Down Expand Up @@ -123,7 +124,8 @@ public void Randomize_dispatches_expected_actions()
{ OrnamentationType.UpperOctavePedalPassingTone, new OrnamentationConfiguration(OrnamentationType.UpperOctavePedalPassingTone, ConfigurationStatus.Enabled, 100) },
{ OrnamentationType.UpperOctavePedalArpeggio, new OrnamentationConfiguration(OrnamentationType.UpperOctavePedalArpeggio, ConfigurationStatus.Enabled, 100) },
{ OrnamentationType.TriplePickup, new OrnamentationConfiguration(OrnamentationType.TriplePickup, ConfigurationStatus.Enabled, 100) },
{ OrnamentationType.SequencedThirds, new OrnamentationConfiguration(OrnamentationType.SequencedThirds, ConfigurationStatus.Enabled, 100) }
{ OrnamentationType.SequencedThirds, new OrnamentationConfiguration(OrnamentationType.SequencedThirds, ConfigurationStatus.Enabled, 100) },
{ OrnamentationType.DoublePedalPassingTone, new OrnamentationConfiguration(OrnamentationType.DoublePedalPassingTone, ConfigurationStatus.Enabled, 100) }
};

_mockState.Value.Returns(new CompositionOrnamentationConfigurationState(configurations));
Expand Down

0 comments on commit a1df86a

Please sign in to comment.