-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvibration.html
More file actions
233 lines (233 loc) · 9.16 KB
/
vibration.html
File metadata and controls
233 lines (233 loc) · 9.16 KB
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
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
<!DOCTYPE html>
<html>
<head>
<!--
Author: Mattthew Brauer, twitter @mattthew
MIT license
-->
<title>Vibration Pattern Generator - Generate oscillating vibration patterns with Navigator.vibrate()</title>
<meta name="viewport" content="width=device-width">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.1.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/sylvester/0.1.3/sylvester.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jqueryui-touch-punch/0.2.3/jquery.ui.touch-punch.min.js"></script>
<script src="assets/spline-editor.js"></script>
<script src="assets/vibration.js"></script>
<link href="https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.css" rel="stylesheet" type="text/css">
<link href="https://fonts.googleapis.com/css?family=Raleway:400,700" rel="stylesheet" type="text/css">
<link href="assets/vibration.css" rel="stylesheet" type="text/css">
</head>
<body>
<div id="about">
<p>
<strong id="supported">
Warning: This browser doesn't support navigator.vibrate()
</strong>
</p>
<p>
<strong>Background:</strong> The browser cannot directly control the strength or frequency of the device's vibration motor. However, it can simulate this control by rapidly cycling the vibration motor ON and OFF and by changing the time-length of the ON and OFF phase of each cycle - like a Morse code.
</p>
<p>
This generator allows you to create and test (feel) these ON/OFF patterns based on your pattern settings (if supported by the browser and device). The vibration motor is accessed with the Javascript function: navigator.vibrate() . Once you discover a pattern you like, copy the Javascript code displayed below.
</p>
<p>
One <strong>cycle</strong> includes the time-length of the ON phase (device vibration) and the OFF phase (pause). Each setting effects the time-length of one or both of these two phases, and each setting is measured in milliseconds (except sputter).
</p>
<p>
The <strong>size/grit</strong> setting effects only the ON phases, and effects every cycle in the pattern equally. A higher setting is like a larger grit of sand paper. It feels both "louder" - because it increases the ratio of ON over OFF - and rougher - because small changes in power are less noticeable.
</p>
<p>
The <strong>power x time</strong> curve effects only the OFF phases, and effects each cycle individually. The horizontal axis covers the duration of the pattern. The lower a point along the curve is on the vertical axis, the longer the OFF phase. At the lowest point, the OFF phase is 25 milliseconds, and at the highest point, it is zero. Therefore, a flat line along the top produces constant vibration.
</p>
<p>
Control points on the curve are not draggable. Instead, tap anywhere to create to create a new control point, or tap a control point to delete it. You can rotate your device for a larger working area.
</p>
<p>
The <strong>duration</strong> of the pattern is the sum all of the ON phases and OFF phases for every cycle in the pattern. Duration is maintained despite the other settings by changing the number of cycles. For example, if the size/grit setting is increased, thereby increasing the time-length of every cycle in the pattern, then the "sample rate" along the power x time curve is decreased.
</p>
<p>
The <strong>sputter</strong> setting effects only the ON phases. It adds randomness to the time-length of each cycle. At 0% sputter, the ON time-length is constant throughout the pattern and equal to the size/grit setting. At 100% sputter, each single ON phase is a random time-length between zero the entire duration of the pattern. Just a little sputter is very noticeable and values over 10% aren't useful.
</p>
<p>
An open source project on <a href="https://github.com/jmattthew/vibration-generator" target="_blank">GitHub</a> by <a href="https://twitter.com/mattthew" target="_blank">@mattthew</a>.
</p>
<p>
<strong>Tap pattern to copy to clipboard:</strong>
</p>
<p id="printout">
<span>Patterns will display here after any tapping "play >"</span>
</p>
</div>
<div id="header">
<p>
Swipe down help. Swipe left for more.
</p>
<h1>
Haptic Vibration Pattern Generator
</h1>
</div>
<div id="tests">
<div id="test1" class="test_even">
<div>
<div id="visuals1" class="checkbox"><div></div></div>
<span id="visuals_label1" class="checkbox_label">Visuals: OFF</span>
</div>
<div>
<span class="label">Sputter %</span>
<span class="display" id="sputter_display1">0</span>
<div class="slider">
<div id="sputter_slide1" class="sputter_slide"></div>
</div>
</div>
<div>
<span class="label">Size/Grit</span>
<span class="display" id="roughness_display1">0</span>
<div class="slider">
<div id="roughness_slide1" class="roughness_slide"></div>
</div>
</div>
<div>
<span class="label">Duration</span>
<span class="display" id="duration_display1">0</span>
<div class="slider">
<div id="duration_slide1" class="duration_slide"></div>
</div>
</div>
<div>
<span id="intensity_label1" class="label intensity_label">Power x Time</span>
<div class="spline_holder">
<div id="spline1" class="spline"></div>
<div id="spline_cover1" class="spline_cover"></div>
</div>
</div>
<div>
<button id="play1" class="play">
<span>play</span>
<div></div>
</button>
</div>
</div>
<div id="test2" class="test_odd">
<div>
<div id="visuals2" class="checkbox"><div></div></div>
<span id="visuals_label2" class="checkbox_label">Visuals: OFF</span>
</div>
<div>
<span class="label">Sputter %</span>
<span class="display" id="sputter_display2">0</span>
<div class="slider">
<div id="sputter_slide2" class="sputter_slide"></div>
</div>
</div>
<div>
<span class="label">Size/Grit</span>
<span class="display" id="roughness_display2">0</span>
<div class="slider">
<div id="roughness_slide2" class="roughness_slide"></div>
</div>
</div>
<div>
<span class="label">Duration</span>
<span class="display" id="duration_display2">0</span>
<div class="slider">
<div id="duration_slide2" class="duration_slide"></div>
</div>
</div>
<div>
<span id="intensity_label2" class="label intensity_label">Power x Time</span>
<div class="spline_holder">
<div id="spline2" class="spline"></div>
<div id="spline_cover2" class="spline_cover"></div>
</div>
</div>
<div>
<button id="play2" class="play">
<span>play</span>
<div></div>
</button>
</div>
</div>
<div id="test3" class="test_even">
<div>
<div id="visuals3" class="checkbox"><div></div></div>
<span id="visuals_label3" class="checkbox_label">Visuals: OFF</span>
</div>
<div>
<span class="label">Sputter %</span>
<span class="display" id="sputter_display3">0</span>
<div class="slider">
<div id="sputter_slide3" class="sputter_slide"></div>
</div>
</div>
<div>
<span class="label">Size/Grit</span>
<span class="display" id="roughness_display3">0</span>
<div class="slider">
<div id="roughness_slide3" class="roughness_slide"></div>
</div>
</div>
<div>
<span class="label">Duration</span>
<span class="display" id="duration_display3">0</span>
<div class="slider">
<div id="duration_slide3" class="duration_slide"></div>
</div>
</div>
<div>
<span id="intensity_label3" class="label intensity_label">Power x Time</span>
<div class="spline_holder">
<div id="spline3" class="spline"></div>
<div id="spline_cover3" class="spline_cover"></div>
</div>
</div>
<div>
<button id="play3" class="play">
<span>play</span>
<div></div>
</button>
</div>
</div>
<div id="test4" class="test_odd">
<div>
<div id="visuals4" class="checkbox"><div></div></div>
<span id="visuals_label4" class="checkbox_label">Visuals: OFF</span>
</div>
<div>
<span class="label">Sputter %</span>
<span class="display" id="sputter_display4">0</span>
<div class="slider">
<div id="sputter_slide4" class="sputter_slide"></div>
</div>
</div>
<div>
<span class="label">Size/Grit</span>
<span class="display" id="roughness_display4">0</span>
<div class="slider">
<div id="roughness_slide4" class="roughness_slide"></div>
</div>
</div>
<div>
<span class="label">Duration</span>
<span class="display" id="duration_display4">0</span>
<div class="slider">
<div id="duration_slide4" class="duration_slide"></div>
</div>
</div>
<div>
<span id="intensity_label4" class="label intensity_label">Power x Time</span>
<div class="spline_holder">
<div id="spline4" class="spline"></div>
<div id="spline_cover4" class="spline_cover"></div>
</div>
</div>
<div>
<button id="play4" class="play">
<span>play</span>
<div></div>
</button>
</div>
</div>
</div>
<body>
</html>