• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

mbarbin / fingerboard / 113

23 Dec 2025 04:24PM UTC coverage: 95.592% (-0.7%) from 96.328%
113

Pull #9

github

web-flow
Merge f4a989aa2 into 8bac1be2d
Pull Request #9: Prepare printer refactor

677 of 709 new or added lines in 47 files covered. (95.49%)

18 existing lines in 3 files now uncovered.

3708 of 3879 relevant lines covered (95.59%)

18858.71 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

68.27
/src/note.ml
1
(**********************************************************************************)
2
(*  Fingerboard - a microtonal geography of the cello fingerboard                 *)
3
(*  Copyright (C) 2022-2024 Mathieu Barbin <mathieu.barbin@gmail.com>             *)
4
(*                                                                                *)
5
(*  This file is part of Fingerboard.                                             *)
6
(*                                                                                *)
7
(*  Fingerboard is free software: you can redistribute it and/or modify it under  *)
8
(*  the terms of the GNU Affero General Public License as published by the Free   *)
9
(*  Software Foundation, either version 3 of the License, or any later version.   *)
10
(*                                                                                *)
11
(*  Fingerboard is distributed in the hope that it will be useful, but WITHOUT    *)
12
(*  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or         *)
13
(*  FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License   *)
14
(*  for more details.                                                             *)
15
(*                                                                                *)
16
(*  You should have received a copy of the GNU Affero General Public License      *)
17
(*  along with Fingerboard. If not, see <https://www.gnu.org/licenses/>.          *)
18
(**********************************************************************************)
19

20
module Letter_name = struct
21
  type t =
1,182,255✔
UNCOV
22
    | A
×
UNCOV
23
    | B
×
UNCOV
24
    | C
×
UNCOV
25
    | D
×
UNCOV
26
    | E
×
UNCOV
27
    | F
×
UNCOV
28
    | G
×
29
  [@@deriving compare, enumerate, equal, hash]
30

31
  let constructor_name = function
32
    | A -> "A"
5,218✔
33
    | B -> "B"
5,216✔
34
    | C -> "C"
5,313✔
35
    | D -> "D"
5,284✔
36
    | E -> "E"
5,309✔
37
    | F -> "F"
5,171✔
38
    | G -> "G"
5,199✔
39
  ;;
40

41
  let to_dyn t = Dyn.variant (constructor_name t) []
92✔
NEW
42
  let sexp_of_t t = Dyn.to_sexp (to_dyn t)
×
43
  let to_string = constructor_name
44

45
  let succ = function
46
    | A -> B
79,480✔
47
    | B -> C
77,306✔
48
    | C -> D
76,130✔
49
    | D -> E
78,590✔
50
    | E -> F
80,443✔
51
    | F -> G
80,893✔
52
    | G -> A
80,772✔
53
  ;;
54

55
  let pred = function
56
    | A -> G
15,988✔
57
    | B -> A
15,377✔
58
    | C -> B
14,632✔
59
    | D -> C
15,498✔
60
    | E -> D
15,994✔
61
    | F -> E
16,215✔
62
    | G -> F
16,221✔
63
  ;;
64

65
  let semitons_step ~from =
66
    match from with
437,125✔
67
    | A -> 2
63,098✔
68
    | B -> 1
61,628✔
69
    | C -> 2
59,666✔
70
    | D -> 2
61,588✔
71
    | E -> 1
63,353✔
72
    | F -> 2
63,856✔
73
    | G -> 2
63,936✔
74
  ;;
75

76
  let succ_octave_designation t ~octave_designation =
77
    octave_designation + if equal t B then 1 else 0
77,304✔
78
  ;;
79

80
  let pred_octave_designation t ~octave_designation =
81
    octave_designation - if equal t C then 1 else 0
14,632✔
82
  ;;
83
end
84

85
module Symbol = struct
86
  type t =
23,720✔
87
    | Triple_flat
×
88
    | Double_flat
×
89
    | Flat
×
UNCOV
90
    | Natural
×
UNCOV
91
    | Sharp
×
92
    | Double_sharp
×
93
    | Triple_sharp
×
94
  [@@deriving compare, enumerate, equal, hash]
95

96
  let constructor_name = function
NEW
97
    | Triple_flat -> "Triple_flat"
×
NEW
98
    | Double_flat -> "Double_flat"
×
NEW
99
    | Flat -> "Flat"
×
100
    | Natural -> "Natural"
91✔
101
    | Sharp -> "Sharp"
1✔
NEW
102
    | Double_sharp -> "Double_sharp"
×
NEW
103
    | Triple_sharp -> "Triple_sharp"
×
104
  ;;
105

106
  let to_dyn t = Dyn.variant (constructor_name t) []
92✔
NEW
107
  let sexp_of_t t = Dyn.to_sexp (to_dyn t)
×
108

109
  let to_string = function
110
    | Triple_flat -> "bbb"
2,496✔
111
    | Double_flat -> "bb"
3,281✔
112
    | Flat -> "b"
6,960✔
113
    | Natural -> ""
10,890✔
114
    | Sharp -> "#"
7,200✔
115
    | Double_sharp -> "##"
3,295✔
116
    | Triple_sharp -> "###"
2,496✔
117
  ;;
118

119
  let prefix_notation = function
120
    | Triple_flat -> "bbb"
×
121
    | Double_flat -> "bb"
×
122
    | Flat -> "b"
×
123
    | Natural -> ""
×
124
    | Sharp -> "#"
×
125
    | Double_sharp -> "x"
×
126
    | Triple_sharp -> "#x"
×
127
  ;;
128

129
  let semitons_shift = function
130
    | Triple_flat -> -3
10,676✔
131
    | Double_flat -> -2
12,246✔
132
    | Flat -> -1
20,055✔
133
    | Natural -> 0
29,135✔
134
    | Sharp -> 1
20,330✔
135
    | Double_sharp -> 2
12,274✔
136
    | Triple_sharp -> 3
10,676✔
137
  ;;
138

139
  let succ = function
140
    | Triple_flat -> Some Double_flat
1,684✔
141
    | Double_flat -> Some Flat
2,621✔
142
    | Flat -> Some Natural
3,765✔
143
    | Natural -> Some Sharp
3,577✔
144
    | Sharp -> Some Double_sharp
2,629✔
145
    | Double_sharp -> Some Triple_sharp
1,684✔
146
    | Triple_sharp -> None
×
147
  ;;
148

149
  let pred = function
150
    | Triple_flat -> None
×
151
    | Double_flat -> Some Triple_flat
1,684✔
152
    | Flat -> Some Double_flat
2,621✔
153
    | Natural -> Some Flat
3,656✔
154
    | Sharp -> Some Natural
3,577✔
155
    | Double_sharp -> Some Sharp
2,629✔
156
    | Triple_sharp -> Some Double_sharp
1,684✔
157
  ;;
158
end
159

UNCOV
160
type t =
×
161
  { letter_name : Letter_name.t
47,800✔
162
  ; symbol : Symbol.t
×
163
  ; octave_designation : Octave_designation.t
164
  }
165
[@@deriving compare, equal, hash]
166

167
let to_dyn { letter_name; symbol; octave_designation } =
168
  Dyn.record
92✔
169
    [ "letter_name", letter_name |> Letter_name.to_dyn
92✔
170
    ; "symbol", symbol |> Symbol.to_dyn
92✔
171
    ; "octave_designation", octave_designation |> Octave_designation.to_dyn
92✔
172
    ]
173
;;
174

NEW
175
let sexp_of_t t = Dyn.to_sexp (to_dyn t)
×
176

177
let to_string { letter_name; symbol; octave_designation } =
178
  Letter_name.to_string letter_name
36,618✔
179
  ^ Symbol.to_string symbol
36,618✔
180
  ^ Int.to_string octave_designation
36,618✔
181
;;
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc