Skip to content
Browse files

added filter frequency controls

  • Loading branch information...
1 parent bc3a268 commit 657e6bbd9c8391c09a6373ef82d36a67d5df3f19 Adam Murray committed Feb 12, 2012
Showing with 33 additions and 1 deletion.
  1. +1 −0 src/app.html
  2. +5 −0 src/models/audioNodeChoice.js
  3. +25 −0 src/views/filterControlsView.js
  4. +2 −1 src/views/filtersView.js
View
1 src/app.html
@@ -39,6 +39,7 @@
<script src="views/lowpassFilterView.js"></script>
<script src="views/highpassFilterView.js"></script>
<script src="views/bandpassFilterView.js"></script>
+ <script src="views/filterControlsView.js"></script>
<script src="views/filtersView.js"></script>
<script src="views/waveShaperCleanView.js"></script>
<script src="views/waveShaperDirtyView.js"></script>
View
5 src/models/audioNodeChoice.js
@@ -72,6 +72,11 @@ Maw.AudioNodeChoice = Maw.AudioNode.extend({
setPlaybackRateOfSelectedWavetable: function(rate) {
var node = this.getPath('selectedNode.node');
if(node && node.playbackRate) node.playbackRate.value = rate;
+ },
+
+ setCutoffFrequencyOfSelectedFilter: function(cutoff) {
+ var node = this.getPath('selectedNode.node');
+ if(node && node.frequency) node.frequency.value = cutoff;
}
});
View
25 src/views/filterControlsView.js
@@ -0,0 +1,25 @@
+Maw.FilterControlsView = Ember.View.extend({
+ title: '',
+ min: 0,
+ max: 100,
+ step: 1,
+ value: 0,
+ unit: '',
+
+ classNames: ['slider'],
+
+ defaultTemplate: SC.Handlebars.compile(
+ '<div style="white-space: pre;">frequency:&nbsp;<input type="range" {{bindAttr min="min" max="max" step="step" value="value"}}></div>'
+ ),
+
+ change: function() {
+ Ember.run.once(this, this._updateElementValue);
+ },
+
+ _updateElementValue: function() {
+ var value = this.$('input').val();
+ var cutoff = value * 200;
+ Maw.get('filterChoices').setCutoffFrequencyOfSelectedFilter(cutoff);
+ Ember.set(this, 'value', value);
+ }
+});
View
3 src/views/filtersView.js
@@ -7,7 +7,8 @@ Maw.FiltersView = Ember.ContainerView.extend({
Maw.NoFilterView,
Maw.LowpassFilterView,
Maw.HighpassFilterView,
- Maw.BandpassFilterView
+ Maw.BandpassFilterView,
+ Maw.FilterControlsView
],
didInsertElement: function() {

0 comments on commit 657e6bb

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