< Summary

Information
Class: MusicTheory.Theory.Harmony.VoiceRange
Assembly: MusicTheory
File(s): /home/runner/work/MusicTheory/MusicTheory/Theory/Harmony/Voice.cs
Line coverage
100%
Covered lines: 3
Uncovered lines: 0
Coverable lines: 3
Total lines: 38
Line coverage: 100%
Branch coverage
100%
Covered branches: 4
Total branches: 4
Branch coverage: 100%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
get_MinMidi()100%11100%
InHardRange(...)100%22100%
InWarnRange(...)100%22100%

File(s)

/home/runner/work/MusicTheory/MusicTheory/Theory/Harmony/Voice.cs

#LineLine coverage
 1namespace MusicTheory.Theory.Harmony;
 2
 3public enum Voice { Soprano, Alto, Tenor, Bass }
 4
 40515public readonly record struct VoiceRange(int MinMidi, int MaxMidi, int WarnMinMidi, int WarnMaxMidi)
 6{
 7977    public bool InHardRange(int midi) => midi >= MinMidi && midi <= MaxMidi;
 11958    public bool InWarnRange(int midi) => midi >= WarnMinMidi && midi <= WarnMaxMidi;
 9}
 10
 11public static class VoiceRanges
 12{
 13    // 目安: (Sop C4-A5),(Alt G3-D5),(Ten C3-A4),(Bs F2-D4) とし ±長三度(±4semitones)を警告許容
 14    private static (int min,int max) Base(string name) => name switch
 15    {
 16        "S" => (60, 81), // C4..A5
 17        "A" => (55, 74), // G3..D5
 18        "T" => (48, 69), // C3..A4
 19        "B" => (41, 62), // F2..D4
 20        _ => (60,81)
 21    };
 22    private static VoiceRange Make((int min,int max) b)
 23        => new(b.min, b.max, b.min-4, b.max+4);
 24
 25    public static VoiceRange Soprano => Make(Base("S"));
 26    public static VoiceRange Alto    => Make(Base("A"));
 27    public static VoiceRange Tenor   => Make(Base("T"));
 28    public static VoiceRange Bass    => Make(Base("B"));
 29
 30    public static VoiceRange ForVoice(Voice v) => v switch
 31    {
 32        Voice.Soprano => Soprano,
 33        Voice.Alto => Alto,
 34        Voice.Tenor => Tenor,
 35        Voice.Bass => Bass,
 36        _ => Soprano
 37    };
 38}