Class: Webmidi::Middleware::VelocityScale
- Defined in:
- lib/webmidi/middleware/velocity_scale.rb
Instance Method Summary collapse
- #call(message) ⇒ Object
-
#initialize(app, factor: 1.0, min: 0, max: 127, curve: :linear, **options) ⇒ VelocityScale
constructor
A new instance of VelocityScale.
Constructor Details
#initialize(app, factor: 1.0, min: 0, max: 127, curve: :linear, **options) ⇒ VelocityScale
Returns a new instance of VelocityScale.
6 7 8 9 10 11 12 13 14 |
# File 'lib/webmidi/middleware/velocity_scale.rb', line 6 def initialize(app, factor: 1.0, min: 0, max: 127, curve: :linear, **) super(app, **) (factor, min, max, curve) @factor = factor @min = min @max = max @curve = curve @include_note_off = .fetch(:include_note_off, true) end |
Instance Method Details
#call(message) ⇒ Object
16 17 18 19 20 21 22 23 24 |
# File 'lib/webmidi/middleware/velocity_scale.rb', line 16 def call() if () scaled = apply_curve(.velocity) scaled_msg = .with(velocity: scaled) @app.call(scaled_msg) else @app.call() end end |