1module Equalizer exposing (..)
2
3import Coordinates exposing (Coordinates)
4import Json.Decode
5import Json.Encode
6
7
8
9-- 🌳
10
11
12type Knob
13 = Low
14 | Mid
15 | High
16 | Volume
17
18
19type alias KnobOperation =
20 { knob : Knob
21 , startingPosition : Coordinates
22 }
23
24
25type alias Settings =
26 { low : Float
27 , mid : Float
28 , high : Float
29 , volume : Float
30 }
31
32
33maxAngle : Float
34maxAngle =
35 135
36
37
38
39-- 🔱
40
41
42defaultSettings : Settings
43defaultSettings =
44 { low = 0
45 , mid = 0
46 , high = 0
47 , volume = 0.5
48 }
49
50
51encodeSettings : Settings -> Json.Encode.Value
52encodeSettings settings =
53 Json.Encode.object
54 [ ( "low", Json.Encode.float settings.low )
55 , ( "mid", Json.Encode.float settings.mid )
56 , ( "high", Json.Encode.float settings.high )
57 , ( "volume", Json.Encode.float settings.volume )
58 ]
59
60
61settingsDecoder : Json.Decode.Decoder Settings
62settingsDecoder =
63 Json.Decode.map4
64 Settings
65 (Json.Decode.field "low" Json.Decode.float)
66 (Json.Decode.field "mid" Json.Decode.float)
67 (Json.Decode.field "high" Json.Decode.float)
68 (Json.Decode.field "volume" Json.Decode.float)