-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathbjorklund.h
executable file
·127 lines (124 loc) · 8.69 KB
/
bjorklund.h
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
// Copyright 2016 Richard R. Goodwin / Audio Morphology / Tim Churches
//
// Authors: Richard R. Goodwin ([email protected])
// Tim Churches: https://github.com/timchurches
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
// See http://creativecommons.org/licenses/MIT/ for more information.
//-------------------------------------------------------------------------------
// The values in the tables below were computed by Tim Churches using a Python
// implementation of E. Bjorklund's algorithm from his paper entitled 'The Theory
// of Rep-Rate Pattern Generation in the SNS Timing Systems' and released under
// the licence below, which I include in full.
//--------------------------------------------------------------------------------
// Copyright (c) 2016 Tim Churches
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
//
// Bjorklund (Euclidean) patterns, generated by resources/bjorklund.py
/* All that these are are bit-wise patterns representing the 'most symmetrical'
* distribution of a given number of triggers within a given number of beats.
*
* Bjorklund's aglorithm uses a recursive method for dividing beats into steps
* and then dividing any remaining beats into those etc etc.
*
* The end result is surprisingly musical, and generates rhythms that are
* recognisable from various cultures.
*/
static uint32_t bjorklund_patterns[31][33] = {
// 2 step patterns
{0,1,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
// 3 step patterns
{0,1,3,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 },
// 4 step patterns
{0,1,5,7,15,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
// 5 step patterns
{0,1,5,21,15,31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
// 6 step patterns
{0,1,9,21,27,31,63,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
// 7 step patterns
{0,1,9,21,85,91,63,127,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
// 8 step patterns
{0,1,17,73,85,109,119,127,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
// 9 step patterns
{0,1,17,73,85,341,219,375,255,511,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
// 10 step patterns
{0,1,33,73,165,341,693,731,495,511,1023,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
// 11 step patterns
{0,1,33,273,585,341,1365,877,955,1519,1023,2047,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
// 12 step patterns
{0,1,65,273,585,1189,1365,1717,1755,1911,2015,2047,4095,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
// 13 step patterns
{0,1,65,273,585,1321,1365,5461,5549,5851,6007,6111,4095,8191,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
// 14 step patterns
{0,1,129,1057,1161,4681,2709,5461,10965,7021,11739,7927,8127,8191,16383,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
// 15 step patterns
{0,1,129,1057,4369,4681,5285,5461,21845,22197,14043,15291,15855,24511,16383,32767,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
// 16 step patterns
{0,1,257,1057,4369,4681,18761,19093,21845,27349,28013,46811,30583,48623,32639,32767,65535,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
// 17 step patterns
{0,1,257,4161,4369,17545,37449,38053,21845,87381,54965,56173,60891,96119,64495,98175,65535,131071,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
// 18 step patterns
{0,1,513,4161,8721,18577,37449,42281,43605,87381,174933,177581,112347,187835,192375,128991,130815,131071,262143,0,0,0,0,0,0,0,0,0,0,0,0,0,0},
// 19 step patterns
{0,1,513,4161,33825,69905,37449,84297,86693,87381,349525,350901,355693,374491,244667,253687,391135,392959,262143,524287,0,0,0,0,0,0,0,0,0,0,0,0,0},
// 20 step patterns
{0,1,1025,16513,33825,69905,74825,299593,169125,305749,349525,437077,710325,449389,749275,489335,507375,520159,523775,524287,1048575,0,0,0,0,0,0,0,0,0,0,0,0},
// 21 step patterns
{0,1,1025,16513,33825,69905,148617,299593,600361,346773,349525,1398101,1403605,896429,898779,1502683,1537911,1555951,1040319,1572351,1048575,2097151,0,0,0,0,0,0,0,0,0,0,0},
// 22 step patterns
{0,1,2049,16513,67617,270865,559377,299593, 198665,1217701,698709,1398101,2796885,1758901,1796973,2995931,1956795,2027383,3112431,3137471,2096127,2097151,4194303,0,0,0,0,0,0,0,0,0,0},
// 23 step patterns
{0,1,2049,65793,266305,279073,1118481,1123401,2396745,1353001,2443925,1398101,5592405,3500757,5682605,3595117,3895003,3914683,6156023,4127727,4177855,6290431,4194303,8388607,0,0,0,0,0,0,0,0,0},
// 24 step patterns
{0,1,4097,65793,266305,1082401,1118481,2245769,2396745,4802889,4871333,4893013,5592405,6991189,7034549,7171437,7190235,7794139,7829367,8118007,8255455,8355711,8386559,8388607,16777215,0,0,0,0,0,0,0,0},
// 25 step patterns
{0,1,4097,65793,266305,1082401,1118481,2377873,2396745,5392969,5412005,5581461,5592405,22369621,22391509,22730421,22768493,23967451,24042939,24606583,16236015,25032671,25132927,25163775,16777215,33554431,0,0,0,0,0,0,0},
// 26 step patterns
{0,1,8193,262657,532545,1082401,2236689,4753681,4792905,19173961,10822953,11096741,11183445,22369621,44741973,44915381,45462957,28760941,47937243,48094139,49215351,49790447,50067423,33488767,33550335,33554431,67108863,0,0,0,0,0,0},
// 27 step patterns
{0,1,8193,262657,2113665,4261921,4465169,17895697,9577609,19173961,21580105,38966437,22325845,22369621,89478485,89566037,56284853,91057517,57521883,95907291,62634939,98496375,66026991,66580447,66977535,100659199,67108863,134217727,0,0,0,0,0},
// 28 step patterns
{0,1,16385,262657,2113665,4327489,17318945,17895697,19022985,19173961,76698185,43296041,44386965,78292309,89478485,111850837,179661525,181843373,115039085,191739611,192343515,125269879,129883895,199195631,133160895,201195263,134209535,134217727,268435455,0,0,0,0},
// 29 step patterns
{0,1,16385,1049601,2113665,17043521,34636833,17895697,71600273,71901769,153391689,153692457,88757413,156543573,89478485,357913941,223783765,359356085,229485997,230087533,249263835,250469819,393705335,259776247,264174575,401596351,268173055,402644991,268435455,536870911,0,0,0},
// 30 step patterns
{0,1,32769,1049601,4227201,17043521,34636833,69345553,143167761,76620873,153391689,306858313,173184165,312822421,178951509,357913941,715838805,448096981,727373493,460025197,460175067,767258331,501070779,518977399,519552495,528349151,803200959,536346111,536854527,536870911,1073741823,0,0},
// 31 step patterns
{0,1,32769,1049601,16843009,17043521,34636833,138682897,286331153,287458441,153391689,345133641,614802729,623530661,357739093,357913941,1431655765,1432005461,900422325,917878189,1457216365,1533916891,997649883,1002159035,1038020471,1593294319,1602090975,1069531071,1610087935,1610596351,1073741823,2147483647,0},
// 32 step patterns
{0,1,65537,4196353,16843009,67641409,69272609,142885409,286331153,304367761,306778697,1227133513,1229539657,1246925989,1251297941,1252693333,1431655765,1789580629,1792371413,1801115317,1835887981,1840700269,3067852507,3077496251,2004318071,3151884023,3186605551,2130442207,2139062143,2146434559,2147450879,2147483647,4294967295 }
};