Skip to content

Commit

Permalink
Upper Octave Pedaling (#219)
Browse files Browse the repository at this point in the history
  • Loading branch information
wbaldoumas authored Dec 23, 2024
1 parent ab6f70b commit d7ac3c6
Show file tree
Hide file tree
Showing 7 changed files with 116 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ public sealed record AggregateOrnamentationConfiguration(ISet<OrnamentationConfi
new(OrnamentationType.DecorateThird, ConfigurationStatus.Enabled, 60),
new(OrnamentationType.OctavePedal, ConfigurationStatus.Enabled, 80),
new(OrnamentationType.OctavePedalPassingTone, ConfigurationStatus.Enabled, 80),
new(OrnamentationType.OctavePedalArpeggio, ConfigurationStatus.Enabled, 80)
new(OrnamentationType.OctavePedalArpeggio, ConfigurationStatus.Enabled, 80),
new(OrnamentationType.UpperOctavePedal, ConfigurationStatus.Enabled, 80),
new(OrnamentationType.UpperOctavePedalPassingTone, ConfigurationStatus.Enabled, 80),
new(OrnamentationType.UpperOctavePedalArpeggio, ConfigurationStatus.Enabled, 80)
}
);
}
7 changes: 5 additions & 2 deletions src/BaroquenMelody.Library/Midi/MidiExampleGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,11 @@ public MidiFile GenerateExampleOrnamentationMidiFile(OrnamentationType ornamenta
OrnamentationType.DelayedDoublePickup => new BaroquenNote(Instrument.One, Note.Get(compositionConfiguration.Scale.Mediant, 4), compositionConfiguration.DefaultNoteTimeSpan),
OrnamentationType.DecorateThird => new BaroquenNote(Instrument.One, Note.Get(compositionConfiguration.Scale.Tonic, 4), compositionConfiguration.DefaultNoteTimeSpan),
OrnamentationType.OctavePedal => new BaroquenNote(Instrument.One, Note.Get(compositionConfiguration.Scale.Tonic, 4), compositionConfiguration.DefaultNoteTimeSpan),
OrnamentationType.OctavePedalPassingTone => new BaroquenNote(Instrument.One, Note.Get(compositionConfiguration.Scale.Tonic, 4), compositionConfiguration.DefaultNoteTimeSpan),
OrnamentationType.OctavePedalArpeggio => new BaroquenNote(Instrument.One, Note.Get(compositionConfiguration.Scale.Tonic, 4), compositionConfiguration.DefaultNoteTimeSpan),
OrnamentationType.OctavePedalPassingTone => new BaroquenNote(Instrument.One, Note.Get(compositionConfiguration.Scale.Mediant, 4), compositionConfiguration.DefaultNoteTimeSpan),
OrnamentationType.OctavePedalArpeggio => new BaroquenNote(Instrument.One, Note.Get(compositionConfiguration.Scale.Dominant, 4), compositionConfiguration.DefaultNoteTimeSpan),
OrnamentationType.UpperOctavePedal => new BaroquenNote(Instrument.One, Note.Get(compositionConfiguration.Scale.Tonic, 4), compositionConfiguration.DefaultNoteTimeSpan),
OrnamentationType.UpperOctavePedalPassingTone => new BaroquenNote(Instrument.One, Note.Get(compositionConfiguration.Scale.Mediant, 4), compositionConfiguration.DefaultNoteTimeSpan),
OrnamentationType.UpperOctavePedalArpeggio => 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 @@ -555,6 +555,63 @@ public IEnumerable<OrnamentationProcessorConfiguration> Create(OrnamentationConf
)
);
break;
case OrnamentationType.UpperOctavePedal:
processorConfigurations.Add(
new OrnamentationProcessorConfiguration(
OrnamentationType.UpperOctavePedal,
InputPolicies:
[
wantsToOrnament,
_hasNoOrnamentation,
new IsIntervalWithinInstrumentRange(compositionConfiguration, 7),
new Not<OrnamentationItem>(new IsApplicableInterval(compositionConfiguration, PassingToneInterval)),
new Not<OrnamentationItem>(new IsApplicableInterval(compositionConfiguration, 4))
],
OutputPolicies: [logOrnamentation],
Translations: [7, 0, 7],
ShouldNotInvert,
TranslationInversionIndices: new HashSet<int>().ToFrozenSet()
)
);
break;
case OrnamentationType.UpperOctavePedalPassingTone:
processorConfigurations.Add(
new OrnamentationProcessorConfiguration(
OrnamentationType.UpperOctavePedalPassingTone,
InputPolicies:
[
wantsToOrnament,
_hasNoOrnamentation,
new IsIntervalWithinInstrumentRange(compositionConfiguration, 7),
new IsApplicableInterval(compositionConfiguration, PassingToneInterval).Or(_isRepeatedNote)
],
OutputPolicies: [logOrnamentation],
Translations: [7, 1, 7],
ShouldInvertBasedOnDirection,
TranslationInversionIndices: new HashSet<int> { 1 }.ToFrozenSet()
)
);
break;
case OrnamentationType.UpperOctavePedalArpeggio:
processorConfigurations.Add(
new OrnamentationProcessorConfiguration(
OrnamentationType.UpperOctavePedalArpeggio,
InputPolicies:
[
wantsToOrnament,
_hasNoOrnamentation,
_hasNextBeat,
_isDescending,
new IsIntervalWithinInstrumentRange(compositionConfiguration, 7),
new IsApplicableInterval(compositionConfiguration, 4).Or(_isRepeatedNote),
],
OutputPolicies: [logOrnamentation],
Translations: [7, 2, 7],
ShouldNotInvert,
TranslationInversionIndices: new HashSet<int>().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 @@ -32,6 +32,9 @@ internal static class OrnamentationTypeExtensions
{ OrnamentationType.OctavePedal, 3 },
{ OrnamentationType.OctavePedalPassingTone, 3 },
{ OrnamentationType.OctavePedalArpeggio, 3 },
{ OrnamentationType.UpperOctavePedal, 3 },
{ OrnamentationType.UpperOctavePedalPassingTone, 3 },
{ OrnamentationType.UpperOctavePedalArpeggio, 3 },
{ OrnamentationType.None, 0 },
{ OrnamentationType.Sustain, 0 },
{ OrnamentationType.MidSustain, 0 },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,4 +151,19 @@ public enum OrnamentationType : byte
/// An octave pedal with an arpeggio.
/// </summary>
OctavePedalArpeggio,

/// <summary>
/// An octave pedal above the starting note.
/// </summary>
UpperOctavePedal,

/// <summary>
/// An upper octave pedal with a passing tone.
/// </summary>
UpperOctavePedalPassingTone,

/// <summary>
/// An upper octave pedal with an arpeggio.
/// </summary>
UpperOctavePedalArpeggio,
}
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,18 @@ internal sealed class MusicalTimeSpanCalculator : IMusicalTimeSpanCalculator
OrnamentationType.OctavePedalArpeggio when meter == Meter.ThreeFour => MusicalTimeSpan.Quarter.Dotted(1),
OrnamentationType.OctavePedalArpeggio when meter == Meter.FiveEight => MusicalTimeSpan.Quarter,

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

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

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

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

Expand Down Expand Up @@ -251,6 +263,18 @@ internal sealed class MusicalTimeSpanCalculator : IMusicalTimeSpanCalculator
OrnamentationType.OctavePedalArpeggio when meter == Meter.ThreeFour => MusicalTimeSpan.Eighth,
OrnamentationType.OctavePedalArpeggio when meter == Meter.FiveEight => MusicalTimeSpan.Eighth,

OrnamentationType.UpperOctavePedal when meter == Meter.FourFour => MusicalTimeSpan.Eighth,
OrnamentationType.UpperOctavePedal when meter == Meter.ThreeFour => MusicalTimeSpan.Eighth,
OrnamentationType.UpperOctavePedal when meter == Meter.FiveEight => MusicalTimeSpan.Eighth,

OrnamentationType.UpperOctavePedalPassingTone when meter == Meter.FourFour => MusicalTimeSpan.Eighth,
OrnamentationType.UpperOctavePedalPassingTone when meter == Meter.ThreeFour => MusicalTimeSpan.Eighth,
OrnamentationType.UpperOctavePedalPassingTone when meter == Meter.FiveEight => MusicalTimeSpan.Eighth,

OrnamentationType.UpperOctavePedalArpeggio when meter == Meter.FourFour => MusicalTimeSpan.Eighth,
OrnamentationType.UpperOctavePedalArpeggio when meter == Meter.ThreeFour => MusicalTimeSpan.Eighth,
OrnamentationType.UpperOctavePedalArpeggio when meter == Meter.FiveEight => MusicalTimeSpan.Eighth,

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,10 @@ public void ConfigurableOrnamentations_returns_expected_values()
OrnamentationType.DecorateThird,
OrnamentationType.OctavePedal,
OrnamentationType.OctavePedalPassingTone,
OrnamentationType.OctavePedalArpeggio
OrnamentationType.OctavePedalArpeggio,
OrnamentationType.UpperOctavePedal,
OrnamentationType.UpperOctavePedalPassingTone,
OrnamentationType.UpperOctavePedalArpeggio
};

// act
Expand Down Expand Up @@ -113,7 +116,10 @@ public void Randomize_dispatches_expected_actions()
{ OrnamentationType.DecorateThird, new OrnamentationConfiguration(OrnamentationType.DecorateThird, ConfigurationStatus.Enabled, 100) },
{ OrnamentationType.OctavePedal, new OrnamentationConfiguration(OrnamentationType.OctavePedal, ConfigurationStatus.Enabled, 100) },
{ OrnamentationType.OctavePedalPassingTone, new OrnamentationConfiguration(OrnamentationType.OctavePedalPassingTone, ConfigurationStatus.Enabled, 100) },
{ OrnamentationType.OctavePedalArpeggio, new OrnamentationConfiguration(OrnamentationType.OctavePedalArpeggio, ConfigurationStatus.Enabled, 100) }
{ OrnamentationType.OctavePedalArpeggio, new OrnamentationConfiguration(OrnamentationType.OctavePedalArpeggio, ConfigurationStatus.Enabled, 100) },
{ OrnamentationType.UpperOctavePedal, new OrnamentationConfiguration(OrnamentationType.UpperOctavePedal, ConfigurationStatus.Enabled, 100) },
{ OrnamentationType.UpperOctavePedalPassingTone, new OrnamentationConfiguration(OrnamentationType.UpperOctavePedalPassingTone, ConfigurationStatus.Enabled, 100) },
{ OrnamentationType.UpperOctavePedalArpeggio, new OrnamentationConfiguration(OrnamentationType.UpperOctavePedalArpeggio, ConfigurationStatus.Enabled, 100) }
};

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

0 comments on commit d7ac3c6

Please sign in to comment.