From d52d5d89cf85b910132515be43f2d3250395cd39 Mon Sep 17 00:00:00 2001 From: Isaiah Odhner Date: Wed, 8 Aug 2018 14:13:58 -0400 Subject: [PATCH] Add noisy returns --- src/Fretboard.coffee | 10 +++++++++- src/GuitarString.coffee | 1 + src/TablatureEditor.coffee | 11 ++++++++++- src/app.coffee | 25 +++++++++++++++++++++++-- src/audio-setup.coffee | 1 + src/tablature.coffee | 1 + 6 files changed, 45 insertions(+), 4 deletions(-) diff --git a/src/Fretboard.coffee b/src/Fretboard.coffee index b9ad681..b05a6bf 100644 --- a/src/Fretboard.coffee +++ b/src/Fretboard.coffee @@ -107,12 +107,13 @@ class @Fretboard prevent = (e)-> e.preventDefault() - no + return false update_pointer_position = (e)=> offset = $canvas.offset() @pointerX = e.pageX - offset.left @pointerY = e.pageY - offset.top + return $$.on "pointermove", update_pointer_position @@ -124,6 +125,7 @@ class @Fretboard prevent(e) $canvas.focus() $$.on "pointermove", prevent # make it so you don't select text in the textarea when dragging from the canvas + return $$.on "pointerup blur", (e)=> $$.off "pointermove", prevent # but let you drag other times @@ -131,6 +133,7 @@ class @Fretboard @pointerOpen = off @pointerBend = off string.release() for string in @strings + return # @TODO: pointercancel/blur/Esc @@ -147,6 +150,7 @@ class @Fretboard # @fret_scale = Math.sqrt(@canvas.width) * 50 @fret_scale = Math.min(Math.sqrt(@canvas.width) * 50, 2138) # @x = OSW + Math.max(0, (@canvas.width - @w)/2) # to center it + return draw: => ctx = @canvas.getContext("2d") @@ -160,6 +164,7 @@ class @Fretboard ctx.moveTo(x1, y1) ctx.lineTo(x2, y2) ctx.stroke() + return drawBentLine = (x1, y1, x2, y2, controlPointXOffset, controlPointYOffset, ss, lw)=> ctx.strokeStyle = ss if ss? @@ -172,6 +177,7 @@ class @Fretboard x2, y2 ) ctx.stroke() + return drawVibratingString = (x1, y1, x2, y2, stringAmplitudeData, ss, lw)=> amplitudeToPixels = 3 @@ -202,6 +208,7 @@ class @Fretboard drawBentLine(x1, y1, x2, y2, 0, yBend, ss, lw) ctx.restore() + return drawFingerHoldOrOpenNote = (fretX, fretW, stringY, stringHeight, stringBendY=0)=> ctx.beginPath() @@ -217,6 +224,7 @@ class @Fretboard ctx.fillRect(fretX + 5 - fretW, stringY - stringHeight/2, fretW - 5, stringHeight) ctx.fillRect(fretX - 5, stringY - stringHeight/2, 10, stringHeight) ctx.fill() + return ctx.save() ctx.translate(@x, @y) diff --git a/src/GuitarString.coffee b/src/GuitarString.coffee index dab7d95..0fb1e55 100644 --- a/src/GuitarString.coffee +++ b/src/GuitarString.coffee @@ -17,6 +17,7 @@ class @GuitarString @data = e.outputBuffer.getChannelData(0) for i in [0..@data.length] @data[i] = @getSampleData() + return @script_processor.connect(pre) @started = no diff --git a/src/TablatureEditor.coffee b/src/TablatureEditor.coffee index c33b503..d17f8b1 100644 --- a/src/TablatureEditor.coffee +++ b/src/TablatureEditor.coffee @@ -57,6 +57,8 @@ class @TablatureEditor @positions.push column last_column_had_digit = column_has_digit column++ + + return # The following is based on the default multi-selection block selection code: # https://github.com/ajaxorg/ace/blob/master/lib/ace/mouse/multi_select_handler.js @@ -116,6 +118,7 @@ class @TablatureEditor rectSel.forEach(@editor.addSelectionMarker, @editor) @editor.updateSelectionMarkers() @editor.$blockScrolling-- + return @editor.$blockScrolling++ @@ -148,13 +151,15 @@ class @TablatureEditor @editor.inVirtualSelectionMode = false @editor.$mouseHandler.$clickSelection = null @editor.$blockScrolling-- + return onSelectionInterval = blockSelect event.capture(@editor.container, onMouseSelection, onMouseSelectionEnd) timerId = setInterval(onSelectionInterval, 20) - return e.preventDefault() + e.preventDefault() + return showPlayingNote: (pos, note)-> @removePlayingNote(pos, note) @@ -165,11 +170,13 @@ class @TablatureEditor range = new Range(note.s, column, note.s, column+1) marker = @editor.getSession().addMarker(range, "playing-note", "text") # text? @playing_note_highlight_markers[key] = marker + return removePlayingNote: (pos, note)-> key = "#{note.s}:#{pos}" existing_marker = @playing_note_highlight_markers[key] @editor.getSession().removeMarker existing_marker if existing_marker + return showPlaybackPosition: (pos)-> column = @positions[pos] @@ -190,9 +197,11 @@ class @TablatureEditor # delta_pageX = pageX_2 - pageX_1 # @editor.renderer.scrollToX column * delta_pageX # @editor.renderer.scrollToX column * 7 + return hidePlaybackPosition: -> for marker in @column_highlight_markers @editor.getSession().removeMarker marker @column_highlight_markers = [] + return diff --git a/src/app.coffee b/src/app.coffee index f6210ca..c198e5a 100644 --- a/src/app.coffee +++ b/src/app.coffee @@ -5,6 +5,7 @@ @tuning = "eBGDAE" # backwards @strings = ("#{string_name}|-" for string_name in @tuning) @pos = 0 + return toJSON: -> @notes toString: -> song.strings.join("\n") @@ -25,6 +26,7 @@ if song.notes.length is 1 tablature_editor.showPlaybackPosition(song.pos) + return song.clear() @@ -55,11 +57,13 @@ do update_scale_highlighting = -> else scale_notes = teoria.scale(scale_start, scale_name).notes() scale_midi_values = (scale_note.midi() % 12 for scale_note in scale_notes) + return # disable_outside_scale = disable_outside_scale_checkbox.checked # disable_outside_scale_checkbox.onchange = (e)-> # disable_outside_scale = e.target.checked # update_scale_highlighting() +# return scale_select.addEventListener "change", update_scale_highlighting scale_start_select.addEventListener "change", update_scale_highlighting @@ -85,32 +89,42 @@ tablature_presets_select.addEventListener "change", (e)-> load_tablature(tabs_text) xhr.open "GET", path xhr.send() + return @fretboard = new Fretboard() $(fretboard.canvas).appendTo(".fretboard-area") $tablature_error = $(".tablature-error") -$tablature_error.dismiss = -> @hide().attr("aria-hidden", "true").text("") -$tablature_error.message = (message)-> @show().attr("aria-hidden", "false").text(message) +$tablature_error.dismiss = -> + @hide().attr("aria-hidden", "true").text("") + return +$tablature_error.message = (message)-> + @show().attr("aria-hidden", "false").text(message) + return tablature_editor = new TablatureEditor($(".tablature-editor")[0]) tablature_editor.showPlaybackPosition(song.pos) undo_button.addEventListener "click", -> tablature_editor.editor.undo() + return redo_button.addEventListener "click", -> tablature_editor.editor.redo() + return do update_multi_row_selection_mode = -> tablature_editor.multi_row_selection_mode = multi_row_selection_mode_input.checked + return multi_row_selection_mode_input.addEventListener "change", update_multi_row_selection_mode do update_overwrite_mode = -> tablature_editor.editor.session.setOverwrite(overwrite_mode_input.checked) + return overwrite_mode_input.addEventListener "change", update_overwrite_mode tablature_editor.editor.session.on "changeOverwrite", -> overwrite_mode_input.checked = tablature_editor.editor.session.getOverwrite() + return $theme = $(".theme") @@ -127,11 +141,13 @@ for theme_name, theme of Fretboard.themes $theme.on "change", -> fretboard.theme = Fretboard.themes[$theme.val()] try localStorage.guitar_theme = $theme.val() + return do animate = => fretboard.draw() requestAnimationFrame(animate) + return $$ = $(window) @@ -141,6 +157,7 @@ $$.on "keyup", (e)-> sustain = off for string in fretboard.strings string.release() + return $$.on "keydown", (e)-> key = e.keyCode @@ -188,6 +205,8 @@ $$.on "keydown", (e)-> $$.off "keyup", onkeyup tablature_editor.showPlaybackPosition(song.pos) + return + return $$.on "blur", -> string.stop() for string in fretboard.strings @@ -198,6 +217,7 @@ $$.on "blur", -> tablature_editor.editor.on "blur", -> text = tablature_editor.editor.getValue() load_tablature(text) + return load_tablature = (text)-> if text isnt "#{song}" and text @@ -224,3 +244,4 @@ load_tablature = (text)-> tablature_editor.showPlaybackPosition(song.pos) else $tablature_error.dismiss() + return diff --git a/src/audio-setup.coffee b/src/audio-setup.coffee index b3e76dd..650d6f8 100644 --- a/src/audio-setup.coffee +++ b/src/audio-setup.coffee @@ -5,6 +5,7 @@ tuna = new Tuna(actx) connect = (nodes...)-> for node, i in nodes when next = nodes[i+1] node.connect next.input ? next.destination ? next + return # # # # # # # # # # # # diff --git a/src/tablature.coffee b/src/tablature.coffee index fe94d03..de1a082 100644 --- a/src/tablature.coffee +++ b/src/tablature.coffee @@ -34,6 +34,7 @@ parseTabs = (tablature)-> if current_block.tuning.toUpperCase() is tuning.toUpperCase() current_block.tuning = tuning current_block = null + return for line in lines if line.match(/[-–—]/)