summaryrefslogtreecommitdiff
path: root/src/lib/sounds.ml
blob: ec1ddf20b5bd8a60cf18b81afef28fdaa69eadc1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
module type T = sig

  type t
  val muted : t -> t

  val a : [`Closed | `Opened] -> t
  val e : [`Closed | `Opened] -> t
  val eu : [`Closed | `Opened] -> t

  val o : [`Closed | `Opened] -> t
  val schwa : unit -> t
  val i : [`Closed | `Opened] -> t


  val nasal: t -> t

  val none: t

  val p: t
  val b: t
  val t: t
  val k: t
  val f: t
  val s: unit -> t
  val ch: unit -> t
  val z: unit -> t

  val n: unit -> t

  val r: unit -> t
  val l: unit -> t

  val is_voyel : t -> bool
  val is_nasal : t -> bool

end

module T = struct
  type kind =
    | None
    | Voyel

  type t =
    { repr : string
    ; muted : bool
    ; kind : kind
    ; nasal : bool
    }
end

module Repr = struct

  let a = "a"
  and a_nasal = "@"

  and o_nasal = "§"

end

module S = struct

  include T

  let is_voyel t = t.kind = Voyel
  let is_nasal t = t.nasal

  let none =
    { repr = "."
    ; muted = false
    ; kind = None
    ; nasal = false }

  let nasal t =
    match t.repr with
    | "a" -> { t with repr = Repr.a_nasal ; nasal = true }
    | "o" -> { t with repr = Repr.o_nasal ; nasal = true }
    | _ -> t

  let muted f =
    { none with
      repr = "(" ^ f.repr ^ ")"
    ; muted = true }

  let a _ =
    { none with repr = Repr.a }

  let e = function
    | `Closed -> { none with repr = "e" }
    | `Opened -> { none with repr = "E" }

  let eu = function
    | `Closed -> { none with repr = "2" }
    | `Opened -> { none with repr = "9" }


  let schwa () =
    { none with repr = "°" }

  let o _ =
    { none with repr = "o" }

  let i _ =
    { none with repr = "i" }

  let p =
    { none with repr = "p" }

  let b =
    { none with repr = "b" }

  let t =
    { none with repr = "t" }

  let k =
    { none with repr = "k" }

  let f =
    { none with repr = "f" }

  let s () =
    { none with repr = "s" }

  let ch () =
    { none with repr = "S" }

  let z () =
    { none with repr = "z" }

  let n () =
    { none with
      repr = "n"
    ; nasal = true }

  let l () =
    { none with repr = "L" }

  let r () =
    { none with repr = "R" }

end

include S