sequencer.vue 7.7 KB

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