Class: MIDIMessage::Process::Filter
- Inherits:
-
Object
- Object
- MIDIMessage::Process::Filter
- Includes:
- Processor
- Defined in:
- lib/midi-message/process/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(prop, bandwidth, options = {}) ⇒ Filter
constructor
A new instance of Filter.
- #process_single(message) ⇒ Object
Methods included from Processor
Constructor Details
#initialize(prop, bandwidth, options = {}) ⇒ Filter
Returns a new instance of Filter.
14 15 16 17 18 19 20 |
# File 'lib/midi-message/process/filter.rb', line 14 def initialize(prop, bandwidth, = {}) @bandwidth = [bandwidth].flatten @property = prop @reject = [:reject] || false initialize_processor() end |
Instance Attribute Details
#bandwidth ⇒ Object (readonly)
Returns the value of attribute bandwidth.
12 13 14 |
# File 'lib/midi-message/process/filter.rb', line 12 def bandwidth @bandwidth end |
#property ⇒ Object (readonly)
Returns the value of attribute property.
12 13 14 |
# File 'lib/midi-message/process/filter.rb', line 12 def property @property end |
#reject ⇒ Object (readonly)
Returns the value of attribute reject.
12 13 14 |
# File 'lib/midi-message/process/filter.rb', line 12 def reject @reject end |
Instance Method Details
#process_single(message) ⇒ Object
22 23 24 25 26 |
# File 'lib/midi-message/process/filter.rb', line 22 def process_single() val = .send(@property) result = @bandwidth.map { |bw| val >= bw.min && val <= bw.max ? : nil } result.include?() ^ @reject ? : nil end |