Class: MIDIFX::Filter
- Inherits:
-
Object
- Object
- MIDIFX::Filter
- Defined in:
- lib/midi-fx/filter.rb
Overview
Use the Filter superclass when you need a multi-band filter
Direct Known Subclasses
BandPassFilter, BandRejectFilter, HighPassFilter, LowPassFilter
Instance Attribute Summary collapse
-
#bandwidth ⇒ Object
readonly
Returns the value of attribute bandwidth.
-
#property ⇒ Object
readonly
Returns the value of attribute property.
-
#reject ⇒ Object
readonly
Returns the value of attribute reject.
Instance Method Summary collapse
-
#initialize(property, bandwidth, options = {}) ⇒ Filter
constructor
A new instance of Filter.
- #process(message) ⇒ Object
Constructor Details
#initialize(property, bandwidth, options = {}) ⇒ Filter
Returns a new instance of Filter.
8 9 10 11 12 13 |
# File 'lib/midi-fx/filter.rb', line 8 def initialize(property, bandwidth, = {}) @bandwidth = [bandwidth].flatten @property = property @reject = [:reject] || false @name = [:name] end |
Instance Attribute Details
#bandwidth ⇒ Object (readonly)
Returns the value of attribute bandwidth.
6 7 8 |
# File 'lib/midi-fx/filter.rb', line 6 def bandwidth @bandwidth end |
#property ⇒ Object (readonly)
Returns the value of attribute property.
6 7 8 |
# File 'lib/midi-fx/filter.rb', line 6 def property @property end |
#reject ⇒ Object (readonly)
Returns the value of attribute reject.
6 7 8 |
# File 'lib/midi-fx/filter.rb', line 6 def reject @reject end |
Instance Method Details
#process(message) ⇒ Object
15 16 17 18 19 20 21 22 23 24 |
# File 'lib/midi-fx/filter.rb', line 15 def process() val = .send(@property) result = @bandwidth.map do |bw| case bw when Range then val >= bw.min && val <= bw.max ? : nil when Numeric then val == bw ? : nil end end result.include?() ^ @reject ? : nil end |