Skip to content
This repository
Browse code

added web audio monkeypatch, converted to current method names

  • Loading branch information...
commit 27f4c6ac3b710eb53d775043d1f11b4f470578fa 1 parent 7707f75
Jan Krutisch authored
3  Gemfile
@@ -5,8 +5,6 @@ gem 'rails', '3.2.11'
5 5 # Bundle edge Rails instead:
6 6 # gem 'rails', :git => 'git://github.com/rails/rails.git'
7 7
8   -
9   -gem 'mysql2'
10 8 gem 'json'
11 9 gem 'jquery-rails'
12 10 gem 'haml'
@@ -19,7 +17,6 @@ gem 'gelf'
19 17 gem 'lograge'
20 18
21 19 gem 'omniauth-soundcloud'
22   -gem 'unicorn'
23 20
24 21 # Gems used only for assets and not required
25 22 # in production environments by default.
1  app/assets/javascripts/application.js
@@ -23,6 +23,7 @@
23 23
24 24 //= require cloudtracker
25 25 //= require models/mod
  26 +//= require web_audio_monkeypatch
26 27 //= require player
27 28 //= require buffer_conversions
28 29 //= require tracker
22 app/assets/javascripts/player.coffee
@@ -104,7 +104,7 @@ class window.CT2.player.Player
104 104 constructor: ->
105 105 @module = null
106 106 @channels = []
107   - @context = new webkitAudioContext()
  107 + @context = new AudioContext()
108 108
109 109 for i in [0..3]
110 110 @channels.push(new window.CT2.player.Channel(this))
@@ -120,10 +120,10 @@ class window.CT2.player.Player
120 120 @separation = 0.7
121 121 @splitter = @context.createChannelSplitter(2)
122 122 @merger = @context.createChannelMerger(2)
123   - @gain_rtl = @context.createGainNode()
124   - @gain_rtr = @context.createGainNode()
125   - @gain_ltl = @context.createGainNode()
126   - @gain_ltr = @context.createGainNode()
  123 + @gain_rtl = @context.createGain()
  124 + @gain_rtr = @context.createGain()
  125 + @gain_ltl = @context.createGain()
  126 + @gain_ltr = @context.createGain()
127 127
128 128 @gain_rtl.gain.value = 1.0 - @separation
129 129 @gain_ltr.gain.value = 1.0 - @separation
@@ -204,7 +204,7 @@ class window.CT2.player.Player
204 204 @pattern_only = true
205 205 @playing = true
206 206 @cur_row = 0
207   - console.log 'PLAYING PATTERN', pattern
  207 + # console.log 'PLAYING PATTERN', pattern
208 208
209 209 stop: ->
210 210 # @stop_nodes()
@@ -212,7 +212,7 @@ class window.CT2.player.Player
212 212 for ch in [0..3]
213 213 @mixer.voices[ch].volume = 0
214 214 @channels[ch].volume = 0
215   - console.log 'STOPPING'
  215 + # console.log 'STOPPING'
216 216
217 217 # stop_nodes: ->
218 218 # @render_node.onaudioprocess = null
@@ -220,13 +220,13 @@ class window.CT2.player.Player
220 220
221 221 prep_nodes: ->
222 222 if not @render_node?
223   - @render_node = @context.createJavaScriptNode(2048, 2, 2)
  223 + @render_node = @context.createScriptProcessor(2048, 2, 2)
224 224 @render_node.connect(@splitter)
225 225 @render_node.onaudioprocess = @js_render
226 226
227 227
228 228 js_render: (e) =>
229   - console.log("js_render", e)
  229 + # console.log("js_render", e)
230 230 length = e.outputBuffer.getChannelData(0).length
231 231 l_buf = e.outputBuffer.getChannelData(0)
232 232 r_buf = e.outputBuffer.getChannelData(1)
@@ -327,7 +327,7 @@ class window.CT2.player.Player
327 327 if (!@cur_tick)
328 328
329 329 if note.sample
330   - console.log("ns:", note.sample, "ch:", ch, "line: ", @cur_row)
  330 + # console.log("ns:", note.sample, "ch:", ch, "line: ", @cur_row)
331 331 channel.sample = note.sample
332 332 channel.finetune = @module.samples[note.sample - 1].finetune
333 333 channel.volume = @module.samples[note.sample - 1].volume
@@ -495,7 +495,7 @@ class window.CT2.player.Player
495 495
496 496 render: (l_buf, r_buf) ->
497 497 len = l_buf.length
498   - console.log("render", len, @tick_rate)
  498 + # console.log("render", len, @tick_rate)
499 499 for i in [0...len]
500 500 l_buf[i] = 0.0
501 501 for i in [0...len]
0  vendor/assets/javascripts/web_audio_monkeypatch.js
No changes.

0 comments on commit 27f4c6a

Please sign in to comment.
Something went wrong with that request. Please try again.