summaryrefslogtreecommitdiff
path: root/src/lib/sounds/sounds.ml
blob: a2035b7a9d9c0dd8b0a17e87718aead9fb6aa42a (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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
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 u : t


  val nasal: t -> t

  val none: t

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

  val n: t
  val m: t

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

  val semi_voyel_w: t

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

  type code =
    | None
    | SZ
    | Voyel_A
    | Voyel_O

  val code : t -> code

end

module T = struct
  type kind =
    | None
    | Voyel

  type code =
    | None
    | SZ
    | Voyel_A
    | Voyel_O

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

end

module Repr = struct

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

  and o = "o"
  and o_nasal = "§"

  and i = "i"
  and u = "y"

  and p = "p"
  and b = "b"
  and t = "t"
  and d = "d"

  and k = "k"
  and g = "g"

  and f = "f"

  and ch = "S"

  and s = "s"
  and z = "z"

  and m = "m"
  and n = "n"

  and l = "L"
  and r = "R"

  and w = "w"
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
    ; code = None }

  let voyel =
    { none with kind = Voyel }

  let code t = t.code

  let nasal t =
    match t.code with
    | Voyel_A -> { t with repr = Repr.a_nasal ; nasal = true }
    | Voyel_O -> { t with repr = Repr.o_nasal ; nasal = true }
    | _ -> t

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

  let a _ =
    { voyel with repr = Repr.a ; code = Voyel_A }

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

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


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

  let o _ =
    { voyel with repr = Repr.o ; code = Voyel_O }

  let i _ =
    { voyel with repr = Repr.i }

  let u =
    { voyel with repr = Repr.u }

  let p =
    { none with repr = Repr.p }

  let b =
    { none with repr = Repr.b }

  let t =
    { none with repr = Repr.t }

  let d =
    { none with repr = Repr.d }

  let k =
    { none with repr = Repr.k }

  let f =
    { none with repr = Repr.f }

  let s () =
    { none with repr = Repr.s }

  let sz () =
    { (s()) with code = SZ }

  let ch () =
    { none with repr = Repr.ch }

  let z () =
    { none with repr = Repr.z }

  let n =
    { none with repr = Repr.n ; nasal = true }

  let m =
    { none with repr = Repr.m ; nasal = true }

  let l () =
    { none with repr = Repr.l }

  let r () =
    { none with repr = Repr.r }

  let semi_voyel_w =
    { none with repr = Repr.w }
end

include S