sequencer.vue 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264
  1. <template>
  2. <section class="sequencer" v-on:mouseover="displayControls()" v-on:mouseleave="hideControls()" >
  3. <!--<span class="sequence-controls-wrapper">-->
  4. <div class="options-wrapper">
  5. <div class="control-bar">
  6. <div class="sequence-options">
  7. <div class="option-icon" id="icon-slots"></div>
  8. <div class="option-icon" id="icon-euclid"></div>
  9. <div class="option-icon" id="icon-sample"></div>
  10. <div class="option-icon" id="icon-delete"></div>
  11. </div>
  12. <div class="sequence-bar">
  13. <range-slider class="slider" min="1" step="1" v-model="slotSlider" v-on:input="assignEuclidean(slotSlider, pulseSlider)" ></range-slider>
  14. <input id="pulseSlider"/>
  15. <range-slider class="slider" min="1" :max="slotSlider" step="1" v-model="pulseSlider" v-on:input ="assignEuclidean(slotSlider, pulseSlider)" ></range-slider>
  16. <input id="pulseSlider" value="3" />
  17. </div>
  18. </div>
  19. </div>
  20. <div class="sequencerLine">
  21. <div class="slot" v-for="(slot, slotid) in euclideanList" :key="slotid">
  22. <beat :id="'slot'+slotid" v-if="slot === 1"></beat>
  23. <div v-else class="emptySlot"></div>
  24. </div>
  25. </div>
  26. <!--<</span>-->
  27. <div>
  28. <!--<div class="control-menu" style="margin-top:5em;" :class="[{'displayControls': controlIsDisplayed}]">-->
  29. <div class="control-menu" style="margin-top:5em;">
  30. </div>
  31. </div>
  32. </section>
  33. </template>
  34. <script>
  35. import RangeSlider from 'vue-range-slider'
  36. // you probably need to import built-in style
  37. import 'vue-range-slider/dist/vue-range-slider.css'
  38. import beat from '~/components/beat.vue'
  39. export default {
  40. props: [ 'line' ],
  41. data() {
  42. // return {
  43. // id: line.id,
  44. // slotSlider: line.slotSlider,
  45. // pulseSlider: line.pulseSlider,
  46. // euclideanList: line.euclideanList,
  47. // controlIsDisplayed: line.controlIsDisplayed
  48. // };
  49. this.line.euclideanList = this.bjorklund(this.line.slotSlider, this.line.pulseSlider);
  50. return this.line;
  51. },
  52. components: {
  53. RangeSlider,
  54. beat
  55. },
  56. methods: {
  57. displayControls: function (){
  58. this.controlIsDisplayed = true;
  59. },
  60. hideControls: function (){
  61. this.controlIsDisplayed = false;
  62. }
  63. /*,
  64. barOpacity: function (){
  65. this.setOpacity = true;
  66. }*/,
  67. bjorklund: function (slots, pulses) {
  68. var pattern = [],
  69. count = [],
  70. remainder = [pulses],
  71. divisor = slots - pulses,
  72. level = 0,
  73. build_pattern = function(lv) {
  74. if (lv == -1) {
  75. pattern.push(0);
  76. } else if (lv == -2) {
  77. pattern.push(1);
  78. } else {
  79. for (var x = 0; x < count[lv]; x++) {
  80. build_pattern(lv - 1);
  81. }
  82. if (remainder[lv]) {
  83. build_pattern(lv - 2);
  84. }
  85. }
  86. }
  87. while (remainder[level] > 1) {
  88. count.push(Math.floor(divisor / remainder[level]));
  89. remainder.push(divisor % remainder[level]);
  90. divisor = remainder[level];
  91. level++;
  92. }
  93. count.push(divisor);
  94. build_pattern(level);
  95. return pattern.reverse();},
  96. assignEuclidean: function (a,b) {
  97. this.euclideanList = this.bjorklund(a,b);
  98. }
  99. }
  100. }
  101. </script>
  102. <style>
  103. .container {
  104. min-height: 100vh;
  105. display: flex;
  106. justify-content: center;
  107. align-items: center;
  108. text-align: center;
  109. }
  110. .title {
  111. font-family: "Quicksand", "Source Sans Pro", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif; /* 1 */
  112. display: block;
  113. font-weight: 300;
  114. font-size: 100px;
  115. color: #35495e;
  116. letter-spacing: 1px;
  117. }
  118. .subtitle {
  119. font-weight: 300;
  120. font-size: 42px;
  121. color: #526488;
  122. word-spacing: 5px;
  123. padding-bottom: 15px;
  124. }
  125. .links {
  126. padding-top: 15px;
  127. }
  128. .active{
  129. background-color:black;
  130. width:100%;
  131. height:40%
  132. }
  133. .control-menu{
  134. display: none;
  135. }
  136. .displayControls{
  137. display:flex !important;
  138. }
  139. .sequence-options{
  140. width:auto;
  141. height: 3em;
  142. z-index: 2;
  143. background-color: red;
  144. display: none;
  145. }
  146. .option-icon{
  147. width:3em;
  148. height: 3em;
  149. background:white;
  150. }
  151. #icon-slots{
  152. background-image: url("~/assets/img/squares.png");
  153. background-repeat: no-repeat;
  154. background-position: center;
  155. }
  156. #icon-euclid{
  157. background-image: url("~/assets/img/pixel.png");
  158. background-repeat: no-repeat;
  159. background-position: center;
  160. }
  161. #icon-sample{
  162. background-image: url("~/assets/img/bell.png");
  163. background-repeat: no-repeat;
  164. background-position: center;
  165. }
  166. #icon-delete{
  167. background-image: url("~/assets/img/close.png");
  168. background-repeat: no-repeat;
  169. background-position: center;
  170. }
  171. .options-wrapper{
  172. background-color: darkgoldenrod;
  173. width:3em;
  174. height: 3em;
  175. display:flex;
  176. background-image: url("~/assets/img/squares.png");
  177. background-repeat: no-repeat;
  178. background-position: center;
  179. z-index: 2;
  180. }
  181. .options-wrapper:hover > .control-bar > .sequence-options{
  182. display:block;
  183. position: absolute;
  184. margin-left:3em;
  185. display: flex;
  186. overflow-x: auto;
  187. }
  188. .sequence-bar{
  189. display:none;
  190. }
  191. .options-wrapper:hover > .control-bar > .sequence-options + .sequence-bar{
  192. display: block;
  193. flex:1 1 100%;
  194. background: blue;
  195. overflow-x: auto;
  196. position: absolute;
  197. width:100%;
  198. margin-left:15em;
  199. height:3em;
  200. }
  201. .options-menu{
  202. width:5em;
  203. height: 3em;
  204. z-index: 1;
  205. background-color: dimgrey;
  206. display: none;
  207. }
  208. .sequencer{
  209. display:flex;
  210. }
  211. .sequencerLine{
  212. display:flex;
  213. height:3em;
  214. width:100%;
  215. background-color:firebrick;
  216. }
  217. .slot-wrapper{
  218. display:flex;
  219. height:3em;
  220. width:auto;
  221. background-color:firebrick;
  222. }
  223. .slot{
  224. flex:1 1 auto;
  225. background-color:beige;
  226. border-left:1pt solid aquamarine;
  227. border-right:1pt solid aquamarine;
  228. border-top: transparent !important;
  229. border-bottom: transparent !important;
  230. }
  231. .activeSlot{
  232. flex:1 1 auto;
  233. display: flex;
  234. flex-direction: column;
  235. }
  236. </style>