source: main/trunk/model-sites-dev/respooled/collect/popup-video-respooled/js/midi/synesthesia.js@ 29863

Last change on this file since 29863 was 29863, checked in by davidb, 9 years ago

First cut at respooled site/collection

File size: 10.2 KB
Line 
1/*
2 ----------------------------------------------------------
3 MIDI.Synesthesia : 0.3.1 : 2012-01-06
4 ----------------------------------------------------------
5 Peacock: “Instruments to perform color-music: Two centuries of technological experimentation,” Leonardo, 21 (1988), 397-406.
6 Gerstner: Karl Gerstner, The Forms of Color 1986
7 Klein: Colour-Music: The art of light, London: Crosby Lockwood and Son, 1927.
8 Jameson: “Visual music in a visual programming language,” IEEE Symposium on Visual Languages, 1999, 111-118.
9 Helmholtz: Treatise on Physiological Optics, New York: Dover Books, 1962
10 Jones: The art of light & color, New York: Van Nostrand Reinhold, 1972
11 ----------------------------------------------------------
12 Reference: http://rhythmiclight.com/archives/ideas/colorscales.html
13 ----------------------------------------------------------
14*/
15
16if (typeof MIDI === 'undefined') var MIDI = {};
17
18MIDI.Synesthesia = MIDI.Synesthesia || {};
19
20(function(root) {
21 root.data = {
22 'Isaac Newton (1704)': {
23 format: 'HSL',
24 ref: 'Gerstner, p.167',
25 english: ['red',null,'orange',null,'yellow','green',null,'blue',null,'indigo',null,'violet'],
26 0: [ 0, 96, 51 ], // C
27 1: [ 0, 0, 0 ], // C#
28 2: [ 29, 94, 52 ], // D
29 3: [ 0, 0, 0 ], // D#
30 4: [ 60, 90, 60 ], // E
31 5: [ 135, 76, 32 ], // F
32 6: [ 0, 0, 0 ], // F#
33 7: [ 248, 82, 28 ], // G
34 8: [ 0, 0, 0 ], // G#
35 9: [ 302, 88, 26 ], // A
36 10: [ 0, 0, 0 ], // A#
37 11: [ 325, 84, 46 ] // B
38 },
39 'Louis Bertrand Castel (1734)': {
40 format: 'HSL',
41 ref: 'Peacock, p.400',
42 english: ['blue','blue-green','green','olive green','yellow','yellow-orange','orange','red','crimson','violet','agate','indigo'],
43 0: [ 248, 82, 28 ],
44 1: [ 172, 68, 34 ],
45 2: [ 135, 76, 32 ],
46 3: [ 79, 59, 36 ],
47 4: [ 60, 90, 60 ],
48 5: [ 49, 90, 60 ],
49 6: [ 29, 94, 52 ],
50 7: [ 360, 96, 51 ],
51 8: [ 1, 89, 33 ],
52 9: [ 325, 84, 46 ],
53 10: [ 273, 80, 27 ],
54 11: [ 302, 88, 26 ]
55 },
56 'George Field (1816)': {
57 format: 'HSL',
58 ref: 'Klein, p.69',
59 english: ['blue',null,'purple',null,'red','orange',null,'yellow',null,'yellow green',null,'green'],
60 0: [ 248, 82, 28 ],
61 1: [ 0, 0, 0 ],
62 2: [ 302, 88, 26 ],
63 3: [ 0, 0, 0 ],
64 4: [ 360, 96, 51 ],
65 5: [ 29, 94, 52 ],
66 6: [ 0, 0, 0 ],
67 7: [ 60, 90, 60 ],
68 8: [ 0, 0, 0 ],
69 9: [ 79, 59, 36 ],
70 10: [ 0, 0, 0 ],
71 11: [ 135, 76, 32 ]
72 },
73 'D. D. Jameson (1844)': {
74 format: 'HSL',
75 ref: 'Jameson, p.12',
76 english: ['red','red-orange','orange','orange-yellow','yellow','green','green-blue','blue','blue-purple','purple','purple-violet','violet'],
77 0: [ 360, 96, 51 ],
78 1: [ 14, 91, 51 ],
79 2: [ 29, 94, 52 ],
80 3: [ 49, 90, 60 ],
81 4: [ 60, 90, 60 ],
82 5: [ 135, 76, 32 ],
83 6: [ 172, 68, 34 ],
84 7: [ 248, 82, 28 ],
85 8: [ 273, 80, 27 ],
86 9: [ 302, 88, 26 ],
87 10: [ 313, 78, 37 ],
88 11: [ 325, 84, 46 ]
89 },
90 'Theodor Seemann (1881)': {
91 format: 'HSL',
92 ref: 'Klein, p.86',
93 english: ['carmine','scarlet','orange','yellow-orange','yellow','green','green blue','blue','indigo','violet','brown','black'],
94 0: [ 0, 58, 26 ],
95 1: [ 360, 96, 51 ],
96 2: [ 29, 94, 52 ],
97 3: [ 49, 90, 60 ],
98 4: [ 60, 90, 60 ],
99 5: [ 135, 76, 32 ],
100 6: [ 172, 68, 34 ],
101 7: [ 248, 82, 28 ],
102 8: [ 302, 88, 26 ],
103 9: [ 325, 84, 46 ],
104 10: [ 0, 58, 26 ],
105 11: [ 0, 0, 3 ]
106 },
107 'A. Wallace Rimington (1893)': {
108 format: 'HSL',
109 ref: 'Peacock, p.402',
110 english: ['deep red','crimson','orange-crimson','orange','yellow','yellow-green','green','blueish green','blue-green','indigo','deep blue','violet'],
111 0: [ 360, 96, 51 ],
112 1: [ 1, 89, 33 ],
113 2: [ 14, 91, 51 ],
114 3: [ 29, 94, 52 ],
115 4: [ 60, 90, 60 ],
116 5: [ 79, 59, 36 ],
117 6: [ 135, 76, 32 ],
118 7: [ 163, 62, 40 ],
119 8: [ 172, 68, 34 ],
120 9: [ 302, 88, 26 ],
121 10: [ 248, 82, 28 ],
122 11: [ 325, 84, 46 ]
123 },
124 'Bainbridge Bishop (1893)': {
125 format: 'HSL',
126 ref: 'Bishop, p.11',
127 english: ['red','orange-red or scarlet','orange','gold or yellow-orange','yellow or green-gold','yellow-green','green','greenish-blue or aquamarine','blue','indigo or violet-blue','violet','violet-red','red'],
128 0: [ 360, 96, 51 ],
129 1: [ 1, 89, 33 ],
130 2: [ 29, 94, 52 ],
131 3: [ 50, 93, 52 ],
132 4: [ 60, 90, 60 ],
133 5: [ 73, 73, 55 ],
134 6: [ 135, 76, 32 ],
135 7: [ 163, 62, 40 ],
136 8: [ 302, 88, 26 ],
137 9: [ 325, 84, 46 ],
138 10: [ 343, 79, 47 ],
139 11: [ 360, 96, 51 ]
140 },
141 'H. von Helmholtz (1910)': {
142 format: 'HSL',
143 ref: 'Helmholtz, p.22',
144 english: ['yellow','green','greenish blue','cayan-blue','indigo blue','violet','end of red','red','red','red','red orange','orange'],
145 0: [ 60, 90, 60 ],
146 1: [ 135, 76, 32 ],
147 2: [ 172, 68, 34 ],
148 3: [ 211, 70, 37 ],
149 4: [ 302, 88, 26 ],
150 5: [ 325, 84, 46 ],
151 6: [ 330, 84, 34 ],
152 7: [ 360, 96, 51 ],
153 8: [ 10, 91, 43 ],
154 9: [ 10, 91, 43 ],
155 10: [ 8, 93, 51 ],
156 11: [ 28, 89, 50 ]
157 },
158 'Alexander Scriabin (1911)': {
159 format: 'HSL',
160 ref: 'Jones, p.104',
161 english: ['red','violet','yellow','steely with the glint of metal','pearly blue the shimmer of moonshine','dark red','bright blue','rosy orange','purple','green','steely with a glint of metal','pearly blue the shimmer of moonshine'],
162 0: [ 360, 96, 51 ],
163 1: [ 325, 84, 46 ],
164 2: [ 60, 90, 60 ],
165 3: [ 245, 21, 43 ],
166 4: [ 211, 70, 37 ],
167 5: [ 1, 89, 33 ],
168 6: [ 248, 82, 28 ],
169 7: [ 29, 94, 52 ],
170 8: [ 302, 88, 26 ],
171 9: [ 135, 76, 32 ],
172 10: [ 245, 21, 43 ],
173 11: [ 211, 70, 37 ]
174 },
175 'Adrian Bernard Klein (1930)': {
176 format: 'HSL',
177 ref: 'Klein, p.209',
178 english: ['dark red','red','red orange','orange','yellow','yellow green','green','blue-green','blue','blue violet','violet','dark violet'],
179 0: [ 0, 91, 40 ],
180 1: [ 360, 96, 51 ],
181 2: [ 14, 91, 51 ],
182 3: [ 29, 94, 52 ],
183 4: [ 60, 90, 60 ],
184 5: [ 73, 73, 55 ],
185 6: [ 135, 76, 32 ],
186 7: [ 172, 68, 34 ],
187 8: [ 248, 82, 28 ],
188 9: [ 292, 70, 31 ],
189 10: [ 325, 84, 46 ],
190 11: [ 330, 84, 34 ]
191 },
192 'August Aeppli (1940)': {
193 format: 'HSL',
194 ref: 'Gerstner, p.169',
195 english: ['red',null,'orange',null,'yellow',null,'green','blue-green',null,'ultramarine blue','violet','purple'],
196 0: [ 0, 96, 51 ],
197 1: [ 0, 0, 0 ],
198 2: [ 29, 94, 52 ],
199 3: [ 0, 0, 0 ],
200 4: [ 60, 90, 60 ],
201 5: [ 0, 0, 0 ],
202 6: [ 135, 76, 32 ],
203 7: [ 172, 68, 34 ],
204 8: [ 0, 0, 0 ],
205 9: [ 211, 70, 37 ],
206 10: [ 273, 80, 27 ],
207 11: [ 302, 88, 26 ]
208 },
209 'I. J. Belmont (1944)': {
210 ref: 'Belmont, p.226',
211 english: ['red','red-orange','orange','yellow-orange','yellow','yellow-green','green','blue-green','blue','blue-violet','violet','red-violet'],
212 0: [ 360, 96, 51 ],
213 1: [ 14, 91, 51 ],
214 2: [ 29, 94, 52 ],
215 3: [ 50, 93, 52 ],
216 4: [ 60, 90, 60 ],
217 5: [ 73, 73, 55 ],
218 6: [ 135, 76, 32 ],
219 7: [ 172, 68, 34 ],
220 8: [ 248, 82, 28 ],
221 9: [ 313, 78, 37 ],
222 10: [ 325, 84, 46 ],
223 11: [ 338, 85, 37 ]
224 },
225 'Steve Zieverink (2004)': {
226 format: 'HSL',
227 ref: 'Cincinnati Contemporary Art Center',
228 english: ['yellow-green','green','blue-green','blue','indigo','violet','ultra violet','infra red','red','orange','yellow-white','yellow'],
229 0: [ 73, 73, 55 ],
230 1: [ 135, 76, 32 ],
231 2: [ 172, 68, 34 ],
232 3: [ 248, 82, 28 ],
233 4: [ 302, 88, 26 ],
234 5: [ 325, 84, 46 ],
235 6: [ 326, 79, 24 ],
236 7: [ 1, 89, 33 ],
237 8: [ 360, 96, 51 ],
238 9: [ 29, 94, 52 ],
239 10: [ 62, 78, 74 ],
240 11: [ 60, 90, 60 ]
241 },
242 'Circle of Fifths (Johnston 2003)': {
243 format: 'RGB',
244 ref: 'Joseph Johnston',
245 english: ['yellow', 'blue', 'orange', 'teal', 'red', 'green', 'purple', 'light orange', 'light blue', 'dark orange', 'dark green', 'violet' ],
246 0: [ 255, 255, 0 ],
247 1: [ 50, 0, 255 ],
248 2: [ 255, 150, 0 ],
249 3: [ 0, 210, 180 ],
250 4: [ 255, 0, 0 ],
251 5: [ 130, 255, 0 ],
252 6: [ 150, 0, 200 ],
253 7: [ 255, 195, 0 ],
254 8: [ 30, 130, 255 ],
255 9: [ 255, 100, 0 ],
256 10: [ 0, 200, 0 ],
257 11: [ 225, 0, 225 ]
258 },
259 'Circle of Fifths (Wheatman 2002)': {
260 format: 'HEX',
261 ref: 'Stuart Wheatman', // http://www.valleysfamilychurch.org/
262 english: [],
263 data: ['#122400', '#2E002E', '#002914', '#470000', '#002142', '#2E2E00', '#290052', '#003D00', '#520029', '#003D3D', '#522900', '#000080', '#244700', '#570057', '#004D26', '#7A0000', '#003B75', '#4C4D00', '#47008F', '#006100', '#850042', '#005C5C', '#804000', '#0000C7', '#366B00', '#80007F', '#00753B', '#B80000', '#0057AD', '#6B6B00', '#6600CC', '#008A00', '#B8005C', '#007F80', '#B35900', '#2424FF', '#478F00', '#AD00AD', '#00994D', '#F00000', '#0073E6', '#8F8F00', '#8A14FF', '#00AD00', '#EB0075', '#00A3A3', '#E07000', '#6B6BFF', '#5CB800', '#DB00DB', '#00C261', '#FF5757', '#3399FF', '#ADAD00', '#B56BFF', '#00D600', '#FF57AB', '#00C7C7', '#FF9124', '#9999FF', '#6EDB00', '#FF29FF', '#00E070', '#FF9999', '#7ABDFF', '#D1D100', '#D1A3FF', '#00FA00', '#FFA3D1', '#00E5E6', '#FFC285', '#C2C2FF', '#80FF00', '#FFA8FF', '#00E070', '#FFCCCC', '#C2E0FF', '#F0F000', '#EBD6FF', '#ADFFAD', '#FFD6EB', '#8AFFFF', '#FFEBD6', '#EBEBFF', '#E0FFC2', '#FFEBFF', '#E5FFF2', '#FFF5F5'] }
264 };
265
266 root.map = function(type) {
267 var data = {};
268 var blend = function(a, b) {
269 return [ // blend two colors and round results
270 (a[0] * 0.5 + b[0] * 0.5 + 0.5) >> 0,
271 (a[1] * 0.5 + b[1] * 0.5 + 0.5) >> 0,
272 (a[2] * 0.5 + b[2] * 0.5 + 0.5) >> 0
273 ];
274 };
275 ///
276 var syn = root.data;
277 var colors = syn[type] || syn['D. D. Jameson (1844)'];
278 for (var note = 0, pclr, H, S, L; note <= 88; note ++) { // creates mapping for 88 notes
279 if (colors.data) {
280 data[note] = {
281 hsl: colors.data[note],
282 hex: colors.data[note]
283 };
284 } else {
285 var clr = colors[(note + 9) % 12];
286 ///
287 switch(colors.format) {
288 case 'RGB':
289 clr = Color.Space(clr, 'RGB>HSL');
290 H = clr.H >> 0;
291 S = clr.S >> 0;
292 L = clr.L >> 0;
293 break;
294 case 'HSL':
295 H = clr[0];
296 S = clr[1];
297 L = clr[2];
298 break;
299 }
300 ///
301 if (H === S && S === L) { // note color is unset
302 clr = blend(pclr, colors[(note + 10) % 12]);
303 }
304 ///
305// var amount = L / 10;
306// var octave = note / 12 >> 0;
307// var octaveLum = L + amount * octave - 3.0 * amount; // map luminance to octave
308 ///
309 data[note] = {
310 hsl: 'hsla(' + H + ',' + S + '%,' + L + '%, 1)',
311 hex: Color.Space({H: H, S: S, L: L}, 'HSL>RGB>HEX>W3')
312 };
313 ///
314 pclr = clr;
315 }
316 }
317 return data;
318 };
319
320})(MIDI.Synesthesia);
Note: See TracBrowser for help on using the repository browser.