Class: Deftones::Music::TransportTime
- Inherits:
-
Object
- Object
- Deftones::Music::TransportTime
- Defined in:
- lib/deftones/music/transport_time.rb
Instance Attribute Summary collapse
-
#transport ⇒ Object
readonly
Returns the value of attribute transport.
-
#value ⇒ Object
readonly
Returns the value of attribute value.
Class Method Summary collapse
Instance Method Summary collapse
- #dispose ⇒ Object
- #disposed? ⇒ Boolean
- #from_type(type) ⇒ Object
-
#initialize(value, transport: Deftones.transport) ⇒ TransportTime
constructor
A new instance of TransportTime.
- #quantize(subdiv, percent = 1.0) ⇒ Object
- #to_bars_beats_sixteenths ⇒ Object
- #to_frequency ⇒ Object
- #to_midi ⇒ Object
- #to_milliseconds ⇒ Object
- #to_notation ⇒ Object
- #to_s ⇒ Object (also: #toString)
- #to_samples(sample_rate = Deftones.context.sample_rate) ⇒ Object
- #to_seconds ⇒ Object
- #to_ticks ⇒ Object
- #value_of ⇒ Object
Constructor Details
#initialize(value, transport: Deftones.transport) ⇒ TransportTime
Returns a new instance of TransportTime.
8 9 10 11 12 |
# File 'lib/deftones/music/transport_time.rb', line 8 def initialize(value, transport: Deftones.transport) @value = value @transport = transport @disposed = false end |
Instance Attribute Details
#transport ⇒ Object (readonly)
Returns the value of attribute transport.
6 7 8 |
# File 'lib/deftones/music/transport_time.rb', line 6 def transport @transport end |
#value ⇒ Object (readonly)
Returns the value of attribute value.
6 7 8 |
# File 'lib/deftones/music/transport_time.rb', line 6 def value @value end |
Class Method Details
.parse(value, bpm: Deftones.transport.bpm, time_signature: Deftones.transport.time_signature, ppq: Deftones.transport.ppq) ⇒ Object
87 88 89 90 |
# File 'lib/deftones/music/transport_time.rb', line 87 def parse(value, bpm: Deftones.transport.bpm, time_signature: Deftones.transport.time_signature, ppq: Deftones.transport.ppq) Time.parse(value, bpm: bpm, time_signature: time_signature, ppq: ppq) end |
Instance Method Details
#dispose ⇒ Object
67 68 69 70 |
# File 'lib/deftones/music/transport_time.rb', line 67 def dispose @disposed = true self end |
#disposed? ⇒ Boolean
72 73 74 |
# File 'lib/deftones/music/transport_time.rb', line 72 def disposed? @disposed end |
#from_type(type) ⇒ Object
55 56 57 58 59 60 61 62 63 64 65 |
# File 'lib/deftones/music/transport_time.rb', line 55 def from_type(type) @value = if type.respond_to?(:to_bars_beats_sixteenths) type. elsif type.respond_to?(:value_of) type.value_of else type end self end |
#quantize(subdiv, percent = 1.0) ⇒ Object
51 52 53 |
# File 'lib/deftones/music/transport_time.rb', line 51 def quantize(subdiv, percent = 1.0) UnitHelpers.quantize_seconds(to_seconds, subdiv, transport: transport, percent: percent) end |
#to_bars_beats_sixteenths ⇒ Object
27 28 29 |
# File 'lib/deftones/music/transport_time.rb', line 27 def transport.seconds_to_position(to_seconds) end |
#to_frequency ⇒ Object
31 32 33 |
# File 'lib/deftones/music/transport_time.rb', line 31 def to_frequency 1.0 / [to_seconds, 1.0e-6].max end |
#to_midi ⇒ Object
35 36 37 |
# File 'lib/deftones/music/transport_time.rb', line 35 def to_midi Note.to_midi(Note.from_frequency(to_frequency)) end |
#to_milliseconds ⇒ Object
39 40 41 |
# File 'lib/deftones/music/transport_time.rb', line 39 def to_milliseconds to_seconds * 1000.0 end |
#to_notation ⇒ Object
47 48 49 |
# File 'lib/deftones/music/transport_time.rb', line 47 def to_notation UnitHelpers.closest_notation(to_seconds, transport: transport) end |
#to_s ⇒ Object Also known as: toString
76 77 78 |
# File 'lib/deftones/music/transport_time.rb', line 76 def to_s value.to_s end |
#to_samples(sample_rate = Deftones.context.sample_rate) ⇒ Object
43 44 45 |
# File 'lib/deftones/music/transport_time.rb', line 43 def to_samples(sample_rate = Deftones.context.sample_rate) UnitHelpers.samples_for_seconds(to_seconds, sample_rate) end |
#to_seconds ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/deftones/music/transport_time.rb', line 14 def to_seconds self.class.parse( value, bpm: transport.bpm, time_signature: transport.time_signature, ppq: transport.ppq ) end |
#to_ticks ⇒ Object
23 24 25 |
# File 'lib/deftones/music/transport_time.rb', line 23 def to_ticks transport.seconds_to_ticks(to_seconds) end |
#value_of ⇒ Object
82 83 84 |
# File 'lib/deftones/music/transport_time.rb', line 82 def value_of to_seconds end |