2019-05-13 08:44:44 +00:00
|
|
|
#= require jquery-3.4.1.slim.js
|
2019-05-13 08:43:28 +00:00
|
|
|
|
2020-02-09 11:00:28 +00:00
|
|
|
$(document).data( "tempo", 80)
|
|
|
|
$(document).data( "sides", 3)
|
|
|
|
|
2019-05-13 08:34:12 +00:00
|
|
|
$(document).ready ->
|
2020-02-09 11:00:28 +00:00
|
|
|
current_col = 0
|
|
|
|
|
|
|
|
# append audio elements to buttons:
|
|
|
|
$(".sequencer-button").data( "side", 1 )
|
|
|
|
for row in [1..4]
|
|
|
|
for side in [1..$(document).data("sides")]
|
|
|
|
$("audio#row" + row ).clone().attr("id","").appendTo(".sequencer-button[row=" + row + "]")
|
2019-05-13 08:43:28 +00:00
|
|
|
|
2020-02-09 11:00:28 +00:00
|
|
|
setInterval =>
|
|
|
|
playCol(current_col)
|
|
|
|
if (current_col <= 6)
|
|
|
|
current_col++
|
|
|
|
else
|
|
|
|
current_col = 0
|
|
|
|
, 15000 / $(document).data("tempo")
|
2019-05-13 09:13:11 +00:00
|
|
|
|
2020-02-09 11:00:28 +00:00
|
|
|
playCol = (col) ->
|
|
|
|
$('.sequencer-button').removeClass('activated')
|
|
|
|
for row in [1..4]
|
|
|
|
current_button = $('.sequencer-button').eq(col + ( row - 1) * 8)
|
|
|
|
current_button.addClass('activated')
|
|
|
|
if ( current_button.prop('checked') )
|
|
|
|
side = current_button.data("side")
|
|
|
|
try
|
|
|
|
current_button.children(":eq(" + (side - 1) + ")")[0].play()
|
|
|
|
catch e
|
|
|
|
console.log "Error playing sound."
|
|
|
|
if (side >= $(document).data("sides"))
|
|
|
|
current_button.data("side", 1)
|
|
|
|
side = 1
|
|
|
|
else
|
|
|
|
current_button.data("side", side + 1)
|