Class: WaitUp::Pipeline
- Inherits:
-
Object
- Object
- WaitUp::Pipeline
- Defined in:
- lib/wait_up/pipeline.rb
Overview
Wait Up pipeline class
Instance Attribute Summary collapse
-
#filename ⇒ Object
readonly
Returns the value of attribute filename.
-
#tempo ⇒ Object
readonly
Returns the value of attribute tempo.
Instance Method Summary collapse
- #audiosink ⇒ Object
-
#initialize(filename, tempo) ⇒ Pipeline
constructor
A new instance of Pipeline.
- #play ⇒ Object
- #play_bin ⇒ Object
- #postconverter ⇒ Object
- #preconverter ⇒ Object
- #sink_bin ⇒ Object
- #speed_changer ⇒ Object
Constructor Details
#initialize(filename, tempo) ⇒ Pipeline
Returns a new instance of Pipeline.
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/wait_up/pipeline.rb', line 8 def initialize(filename, tempo) @filename = filename @tempo = tempo play_bin.set_property 'uri', "file://#{File.absolute_path(filename)}" sink_bin.add audiosink sink_bin.add postconverter sink_bin.add speed_changer speed_changer.link_many [postconverter, audiosink] sink_pad = Gst::GhostPad.new 'sink', speed_changer.iterate_sink_pads.first sink_bin.add_pad sink_pad play_bin.set_property 'audio-sink', GObject::Value.wrap_instance(sink_bin) play_bin.set_state :paused play_bin.get_state(-1) end |
Instance Attribute Details
#filename ⇒ Object (readonly)
Returns the value of attribute filename.
6 7 8 |
# File 'lib/wait_up/pipeline.rb', line 6 def filename @filename end |
#tempo ⇒ Object (readonly)
Returns the value of attribute tempo.
6 7 8 |
# File 'lib/wait_up/pipeline.rb', line 6 def tempo @tempo end |
Instance Method Details
#audiosink ⇒ Object
46 47 48 |
# File 'lib/wait_up/pipeline.rb', line 46 def audiosink @audiosink ||= Gst::ElementFactory.make('autoaudiosink', 'audiosink') end |
#play ⇒ Object
28 29 30 |
# File 'lib/wait_up/pipeline.rb', line 28 def play play_bin.set_state :playing end |
#play_bin ⇒ Object
32 33 34 |
# File 'lib/wait_up/pipeline.rb', line 32 def play_bin @play_bin ||= Gst::ElementFactory.make 'playbin', nil end |
#postconverter ⇒ Object
50 51 52 |
# File 'lib/wait_up/pipeline.rb', line 50 def postconverter @postconverter ||= Gst::ElementFactory.make('audioconvert', 'postconverter') end |
#preconverter ⇒ Object
54 55 56 |
# File 'lib/wait_up/pipeline.rb', line 54 def preconverter @preconverter ||= Gst::ElementFactory.make('audioconvert', 'preconverter') end |
#sink_bin ⇒ Object
36 37 38 |
# File 'lib/wait_up/pipeline.rb', line 36 def sink_bin @sink_bin ||= Gst::Bin.new('sinkbin') end |
#speed_changer ⇒ Object
40 41 42 43 44 |
# File 'lib/wait_up/pipeline.rb', line 40 def speed_changer @speed_changer ||= Gst::ElementFactory.make('pitch', 'speed changer').tap do |element| element.set_property 'tempo', tempo end end |