Skip to content
Browse files

added web audio monkeypatch, converted to current method names

  • Loading branch information...
1 parent 7707f75 commit 27f4c6ac3b710eb53d775043d1f11b4f470578fa @halfbyte committed Jul 10, 2014
View
3 Gemfile
@@ -5,8 +5,6 @@ gem 'rails', '3.2.11'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
-
-gem 'mysql2'
gem 'json'
gem 'jquery-rails'
gem 'haml'
@@ -19,7 +17,6 @@ gem 'gelf'
gem 'lograge'
gem 'omniauth-soundcloud'
-gem 'unicorn'
# Gems used only for assets and not required
# in production environments by default.
View
1 app/assets/javascripts/application.js
@@ -23,6 +23,7 @@
//= require cloudtracker
//= require models/mod
+//= require web_audio_monkeypatch
//= require player
//= require buffer_conversions
//= require tracker
View
22 app/assets/javascripts/player.coffee
@@ -104,7 +104,7 @@ class window.CT2.player.Player
constructor: ->
@module = null
@channels = []
- @context = new webkitAudioContext()
+ @context = new AudioContext()
for i in [0..3]
@channels.push(new window.CT2.player.Channel(this))
@@ -120,10 +120,10 @@ class window.CT2.player.Player
@separation = 0.7
@splitter = @context.createChannelSplitter(2)
@merger = @context.createChannelMerger(2)
- @gain_rtl = @context.createGainNode()
- @gain_rtr = @context.createGainNode()
- @gain_ltl = @context.createGainNode()
- @gain_ltr = @context.createGainNode()
+ @gain_rtl = @context.createGain()
+ @gain_rtr = @context.createGain()
+ @gain_ltl = @context.createGain()
+ @gain_ltr = @context.createGain()
@gain_rtl.gain.value = 1.0 - @separation
@gain_ltr.gain.value = 1.0 - @separation
@@ -204,29 +204,29 @@ class window.CT2.player.Player
@pattern_only = true
@playing = true
@cur_row = 0
- console.log 'PLAYING PATTERN', pattern
+ # console.log 'PLAYING PATTERN', pattern
stop: ->
# @stop_nodes()
@playing = false
for ch in [0..3]
@mixer.voices[ch].volume = 0
@channels[ch].volume = 0
- console.log 'STOPPING'
+ # console.log 'STOPPING'
# stop_nodes: ->
# @render_node.onaudioprocess = null
# @render_node.disconnect(@splitter)
prep_nodes: ->
if not @render_node?
- @render_node = @context.createJavaScriptNode(2048, 2, 2)
+ @render_node = @context.createScriptProcessor(2048, 2, 2)
@render_node.connect(@splitter)
@render_node.onaudioprocess = @js_render
js_render: (e) =>
- console.log("js_render", e)
+ # console.log("js_render", e)
length = e.outputBuffer.getChannelData(0).length
l_buf = e.outputBuffer.getChannelData(0)
r_buf = e.outputBuffer.getChannelData(1)
@@ -327,7 +327,7 @@ class window.CT2.player.Player
if (!@cur_tick)
if note.sample
- console.log("ns:", note.sample, "ch:", ch, "line: ", @cur_row)
+ # console.log("ns:", note.sample, "ch:", ch, "line: ", @cur_row)
channel.sample = note.sample
channel.finetune = @module.samples[note.sample - 1].finetune
channel.volume = @module.samples[note.sample - 1].volume
@@ -495,7 +495,7 @@ class window.CT2.player.Player
render: (l_buf, r_buf) ->
len = l_buf.length
- console.log("render", len, @tick_rate)
+ # console.log("render", len, @tick_rate)
for i in [0...len]
l_buf[i] = 0.0
for i in [0...len]
View
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.