Skip to content

Commit

Permalink
simple multitrack capabilities
Browse files Browse the repository at this point in the history
  • Loading branch information
stevegraham committed Jan 30, 2012
1 parent 3b8bfca commit c331b82
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 23 deletions.
34 changes: 21 additions & 13 deletions app/jpc.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

25 changes: 15 additions & 10 deletions coffeescripts/jpc.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ $(document).ready ->
$('#display').click (event) ->
if Display.buffer
time = event.offsetX * (Display.buffer.duration / canvas.width)
console.log time

ctx.strokeStyle = '#1c211a'

Expand Down Expand Up @@ -42,34 +41,40 @@ $(document).ready ->

class Sequencer
constructor: ->
@track = []
@tracks = []
@timers = []
@position = 0

$('#pads button').bind 'mousedown', (event) =>
if @recording
timeDelta = new Date().getTime() - @timeStamp
@track.push [timeDelta, event.target]
@current_track.push [timeDelta, event.target]


record: ->
@timeStamp = new Date().getTime()
@timeStamp = new Date().getTime()
@current_track = []
@tracks.push @current_track

@play()
@recording = true
@recording = true

play: ->
@recording = false
@timers = @track.map (pair, index) ->
func = -> $(pair[1]).trigger 'mousedown'
window.setTimeout func, pair[0]
if @tracks.length != 0
@timers = @tracks.reduce (a,b) -> a.concat b
@timers = @timers.map (pair, index) ->
func = -> $(pair[1]).trigger 'mousedown'
window.setTimeout func, pair[0]

@recording = false

stop: ->
@recording = false
#$('#pads button').unbind 'mousedown'
@timers.map (timer) -> window.clearTimeout timer
@timers = []

deleteTrack: (track_id) ->
undo: -> @tracks.pop()

audioContext = new webkitAudioContext

Expand Down

0 comments on commit c331b82

Please sign in to comment.