< Summary

Information
Class: MusicTheory.Theory.Harmony.VoiceRanges
Assembly: MusicTheory
File(s): /home/runner/work/MusicTheory/MusicTheory/Theory/Harmony/Voice.cs
Line coverage
90%
Covered lines: 19
Uncovered lines: 2
Coverable lines: 21
Total lines: 38
Line coverage: 90.4%
Branch coverage
84%
Covered branches: 11
Total branches: 13
Branch coverage: 84.6%
Method coverage

Feature is only available for sponsors

Upgrade to PRO version

Metrics

MethodBranch coverage Crap Score Cyclomatic complexity Line coverage
Base(...)87.5%8887.5%
Make(...)100%11100%
get_Soprano()100%11100%
get_Alto()100%11100%
get_Tenor()100%11100%
get_Bass()100%11100%
ForVoice(...)80%5587.5%

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
 5public readonly record struct VoiceRange(int MinMidi, int MaxMidi, int WarnMinMidi, int WarnMaxMidi)
 6{
 7    public bool InHardRange(int midi) => midi >= MinMidi && midi <= MaxMidi;
 8    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)を警告許容
 154414    private static (int min,int max) Base(string name) => name switch
 154415    {
 41516        "S" => (60, 81), // C4..A5
 38717        "A" => (55, 74), // G3..D5
 37318        "T" => (48, 69), // C3..A4
 36919        "B" => (41, 62), // F2..D4
 020        _ => (60,81)
 154421    };
 22    private static VoiceRange Make((int min,int max) b)
 154423        => new(b.min, b.max, b.min-4, b.max+4);
 24
 41525    public static VoiceRange Soprano => Make(Base("S"));
 38726    public static VoiceRange Alto    => Make(Base("A"));
 37327    public static VoiceRange Tenor   => Make(Base("T"));
 36928    public static VoiceRange Bass    => Make(Base("B"));
 29
 152230    public static VoiceRange ForVoice(Voice v) => v switch
 152231    {
 40532        Voice.Soprano => Soprano,
 38333        Voice.Alto => Alto,
 36934        Voice.Tenor => Tenor,
 36535        Voice.Bass => Bass,
 036        _ => Soprano
 152237    };
 38}