wait_up 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 08dd0a312d7c05cab5f82a82f590ece6372912e3
4
+ data.tar.gz: 4e152ff496e74fb188b5b84bd06d69e30b56f707
5
+ SHA512:
6
+ metadata.gz: edf77f5f1edb09cd9257dd629a05d66a1db528aefaa1b890b8ccccc3330d3e8624e251c3faa013471b981aa6ae8720b8725799cc9ca46a13b0ba9a2c21b7fbf7
7
+ data.tar.gz: 77b19223b591b192b44eece8884a80772d68edef6c72d66f7d8b9890bdf8026a0ae705e5de4fb3604a7ba4a8662c58a604edbdd2a5dec792441146176a0216a6
@@ -0,0 +1,5 @@
1
+ # Change log
2
+
3
+ ## 0.0.1 2016-02-05
4
+
5
+ * Initial release
data/Gemfile ADDED
@@ -0,0 +1,3 @@
1
+ source 'http://rubygems.org'
2
+
3
+ gemspec
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2015 Matijs van Zuijlen
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ 'Software'), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17
+ IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18
+ CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19
+ TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20
+ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
@@ -0,0 +1,52 @@
1
+ # Wait Up
2
+
3
+ Play sound files slowly so you can follow along.
4
+
5
+ This will be a port of playitslowly to Ruby + GirFFI.
6
+
7
+ ## Usage
8
+
9
+ Command-line:
10
+
11
+ wait_up-cli [file] [tempo]
12
+
13
+ GUI (just a stub right now):
14
+
15
+ wait_up
16
+
17
+ Press Ctrl-Q to quit.
18
+
19
+ ## Install
20
+
21
+ gem install wait_up
22
+
23
+ ## Dependencies
24
+
25
+ Wait Up needs some additional software installed in order to work.
26
+
27
+ ### Debian
28
+
29
+ Wait Up needs at least the following:
30
+
31
+ sudo apt-get install libgirepository1.0-dev gobject-introspection
32
+
33
+ More to be determined
34
+
35
+ ### Other OS
36
+
37
+ To be determined. Please contribute back your experience in getting Wait Up running
38
+ on your favorite operation system.
39
+
40
+ ## Contributing
41
+
42
+ Contributions are welcome! Please feel free to create issues or pull requests
43
+ on GitHub.
44
+
45
+ If you want to run the tests, you may need to install additional packages:
46
+
47
+ sudo apt-get install gir1.2-atspi-2.0 libatk-adaptor
48
+
49
+ ## License
50
+
51
+ Copyright © 2015–2016 [Matijs van Zuijlen](http://www.matijs.net).
52
+ See LICENSE for details.
@@ -0,0 +1,23 @@
1
+ require 'rake/clean'
2
+ require 'bundler/gem_tasks'
3
+ require 'rake/testtask'
4
+
5
+ namespace :test do
6
+ Rake::TestTask.new(:unit) do |t|
7
+ t.libs = ['lib']
8
+ t.test_files = FileList['test/unit/*_test.rb']
9
+ t.warning = true
10
+ end
11
+
12
+ Rake::TestTask.new(:end_to_end) do |t|
13
+ t.libs = ['lib']
14
+ t.test_files = FileList['test/end_to_end/*_test.rb']
15
+ t.warning = true
16
+ end
17
+
18
+ task all: [:unit, :end_to_end]
19
+ end
20
+
21
+ task test: 'test:all'
22
+
23
+ task default: 'test'
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../lib/wait_up'
3
+
4
+ Gtk.init
5
+
6
+ WaitUp::Application.new
7
+
8
+ Gtk.main
@@ -0,0 +1,30 @@
1
+ #!/usr/bin/env ruby
2
+ require_relative '../lib/wait_up/pipeline'
3
+
4
+ unless ARGV.length == 2
5
+ warn 'Usage: wait_up-cli [file] [tempo]'
6
+ exit 1
7
+ end
8
+ filename = ARGV[0]
9
+ tempo = ARGV[1].to_f
10
+
11
+ Gst.init
12
+
13
+ pipeline = WaitUp::Pipeline.new(filename, tempo)
14
+ mainloop = GLib::MainLoop.new(GLib::MainContext.default, true)
15
+
16
+ bus = pipeline.play_bin.bus
17
+ bus.add_signal_watch
18
+
19
+ bus.signal_connect 'message' do |_bus, message, _ud|
20
+ case message.type
21
+ when :error
22
+ mainloop.quit
23
+ when :eos
24
+ mainloop.quit
25
+ end
26
+ end
27
+
28
+ pipeline.play
29
+
30
+ mainloop.run
@@ -0,0 +1 @@
1
+ require_relative 'wait_up/application'
@@ -0,0 +1,65 @@
1
+ require 'gir_ffi-gtk3'
2
+
3
+ module WaitUp
4
+ # Main Wait Up application class
5
+ class Application
6
+ def initialize
7
+ setup_gui
8
+ connect_signals
9
+ @win.show_all
10
+ end
11
+
12
+ private
13
+
14
+ def connect_signals
15
+ connect_key_press_event_signal
16
+ connect_destroy_signal
17
+ connect_slide_signal
18
+ connect_file_chooser_signal
19
+ end
20
+
21
+ def connect_destroy_signal
22
+ @win.signal_connect('destroy') { Gtk.main_quit }
23
+ end
24
+
25
+ def connect_key_press_event_signal
26
+ @win.signal_connect 'key-press-event' do |_wdg, evt, _ud|
27
+ handle_key(evt) if evt.state[:control_mask]
28
+ false
29
+ end
30
+ end
31
+
32
+ def handle_key(evt)
33
+ case evt.keyval
34
+ when 'q'.ord
35
+ @win.destroy
36
+ end
37
+ end
38
+
39
+ def connect_slide_signal
40
+ @timeline.signal_connect 'format-value' do |_scale, value, _user_data|
41
+ ">#{value}<"
42
+ end
43
+ end
44
+
45
+ def connect_file_chooser_signal
46
+ @chooser.signal_connect 'file-set' do |_widget, _user_data|
47
+ puts @chooser.filename
48
+ end
49
+ end
50
+
51
+ def setup_gui
52
+ @win = Gtk::Window.new :toplevel
53
+ @grid = Gtk::Grid.new
54
+ @grid.orientation = :vertical
55
+ @win.add @grid
56
+ @chooser = Gtk::FileChooserButton.new('Hello!', :open)
57
+ @grid.add @chooser
58
+ @timeline = Gtk::Scale.new_with_range :horizontal, 0.0, 10.0, 0.1
59
+ @timeline.hexpand = true
60
+ @grid.add @timeline
61
+ @volume = Gtk::VolumeButton.new
62
+ @grid.add @volume
63
+ end
64
+ end
65
+ end
@@ -0,0 +1,58 @@
1
+ require 'gir_ffi-gst'
2
+
3
+ module WaitUp
4
+ # Wait Up pipeline class
5
+ class Pipeline
6
+ attr_reader :filename, :tempo
7
+
8
+ def initialize(filename, tempo)
9
+ @filename = filename
10
+ @tempo = tempo
11
+
12
+ play_bin.set_property 'uri', "file://#{File.absolute_path(filename)}"
13
+
14
+ sink_bin.add audiosink
15
+ sink_bin.add postconverter
16
+ sink_bin.add speed_changer
17
+
18
+ speed_changer.link_many [postconverter, audiosink]
19
+
20
+ sink_pad = Gst::GhostPad.new 'sink', speed_changer.iterate_sink_pads.first
21
+ sink_bin.add_pad sink_pad
22
+
23
+ play_bin.set_property 'audio-sink', GObject::Value.wrap_instance(sink_bin)
24
+ play_bin.set_state :paused
25
+ play_bin.get_state(-1)
26
+ end
27
+
28
+ def play
29
+ play_bin.set_state :playing
30
+ end
31
+
32
+ def play_bin
33
+ @play_bin ||= Gst::ElementFactory.make 'playbin', nil
34
+ end
35
+
36
+ def sink_bin
37
+ @sink_bin ||= Gst::Bin.new('sinkbin')
38
+ end
39
+
40
+ def speed_changer
41
+ @speed_changer ||= Gst::ElementFactory.make('pitch', 'speed changer').tap do |element|
42
+ element.set_property 'tempo', tempo
43
+ end
44
+ end
45
+
46
+ def audiosink
47
+ @audiosink ||= Gst::ElementFactory.make('autoaudiosink', 'audiosink')
48
+ end
49
+
50
+ def postconverter
51
+ @postconverter ||= Gst::ElementFactory.make('audioconvert', 'postconverter')
52
+ end
53
+
54
+ def preconverter
55
+ @preconverter ||= Gst::ElementFactory.make('audioconvert', 'preconverter')
56
+ end
57
+ end
58
+ end
@@ -0,0 +1,27 @@
1
+ require_relative '../test_helper'
2
+ require 'atspi_app_driver'
3
+
4
+ # Test driver for the Wait Up application.
5
+ class WaitUpDriver < AtspiAppDriver
6
+ def initialize
7
+ super 'wait_up'
8
+ end
9
+ end
10
+
11
+ describe 'The Wait Up application' do
12
+ before do
13
+ @driver = WaitUpDriver.new
14
+ @driver.boot
15
+ end
16
+
17
+ it 'starts and can be quit with Ctrl-q' do
18
+ @driver.press_ctrl_q
19
+
20
+ status = @driver.cleanup
21
+ status.exitstatus.must_equal 0
22
+ end
23
+
24
+ after do
25
+ @driver.cleanup
26
+ end
27
+ end
@@ -0,0 +1 @@
1
+ require 'minitest/autorun'
@@ -0,0 +1,78 @@
1
+ require_relative '../test_helper'
2
+ require_relative '../../lib/wait_up/pipeline'
3
+
4
+ Gst.init
5
+
6
+ def next_element(element)
7
+ # FIXME: Reduce the number of necessary chained calls here.
8
+ pad = element.iterate_src_pads.first
9
+ peer = pad.get_peer if pad
10
+ peer.parent if peer
11
+ end
12
+
13
+ describe WaitUp::Pipeline do
14
+ # Empty mp3 file from http://www.xamuel.com/blank-mp3s/
15
+ let(:filename) { File.join(File.dirname(__FILE__), '..', 'fixtures', 'point1sec.mp3') }
16
+ let(:instance) { WaitUp::Pipeline.new filename, 0.9 }
17
+
18
+ describe '#sink_bin' do
19
+ let(:sink_bin) { instance.sink_bin }
20
+
21
+ it 'returns a Gst::Bin' do
22
+ sink_bin.must_be_instance_of Gst::Bin
23
+ end
24
+
25
+ it 'has the correct build-up' do
26
+ iter = sink_bin.iterate_elements
27
+ iter.map(&:name).must_equal ['speed changer', 'postconverter', 'audiosink']
28
+ end
29
+
30
+ it 'has the elements all linked up' do
31
+ iter = sink_bin.iterate_elements
32
+
33
+ iter.to_a.each_cons(2) do |src, dst|
34
+ next_element(src).
35
+ must_equal dst, "Expected #{src.name} to link up to #{dst.name}"
36
+ end
37
+ end
38
+
39
+ it 'must have the state :paused' do
40
+ sink_bin.get_state(0)[1].must_equal :paused
41
+ end
42
+
43
+ it 'must be linked up to a source' do
44
+ sink_bin.iterate_sink_pads.first.get_peer.wont_be_nil
45
+ end
46
+ end
47
+
48
+ describe '#play_bin' do
49
+ let(:play_bin) { instance.play_bin }
50
+
51
+ it 'must have the state :paused' do
52
+ play_bin.get_state(0)[1].must_equal :paused
53
+ end
54
+
55
+ it 'has the correct source set up' do
56
+ source = play_bin.get_property('source').get_value
57
+ source.uri.must_equal "file://#{File.absolute_path filename}"
58
+ end
59
+ end
60
+
61
+ describe '#speed_changer' do
62
+ let(:speed_changer) { instance.speed_changer }
63
+ it 'returns a Gst::Element' do
64
+ speed_changer.must_be_kind_of Gst::Element
65
+ end
66
+
67
+ it 'has the correct tempo' do
68
+ speed_changer.get_property('tempo').must_be_close_to 0.9
69
+ end
70
+ end
71
+
72
+ describe '#play' do
73
+ it "sets the play bin's state to :playing" do
74
+ instance.play
75
+ instance.play_bin.get_state(0)[1].must_equal :playing
76
+ end
77
+ end
78
+ end
metadata ADDED
@@ -0,0 +1,160 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: wait_up
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Matijs van Zuijlen
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-02-05 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: gir_ffi-gtk
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: 0.9.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 0.9.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: gir_ffi-gst
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 0.0.5
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 0.0.5
41
+ - !ruby/object:Gem::Dependency
42
+ name: gir_ffi
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: 0.9.2
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: 0.9.2
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '10.1'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '10.1'
69
+ - !ruby/object:Gem::Dependency
70
+ name: minitest
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '5.5'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '5.5'
83
+ - !ruby/object:Gem::Dependency
84
+ name: atspi_app_driver
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - '='
88
+ - !ruby/object:Gem::Version
89
+ version: 0.0.5
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - '='
95
+ - !ruby/object:Gem::Version
96
+ version: 0.0.5
97
+ - !ruby/object:Gem::Dependency
98
+ name: pry
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: 0.10.2
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: 0.10.2
111
+ description:
112
+ email:
113
+ - matijs@matijs.net
114
+ executables:
115
+ - wait_up
116
+ - wait_up-cli
117
+ extensions: []
118
+ extra_rdoc_files: []
119
+ files:
120
+ - Changelog.md
121
+ - Gemfile
122
+ - LICENSE
123
+ - README.md
124
+ - Rakefile
125
+ - bin/wait_up
126
+ - bin/wait_up-cli
127
+ - lib/wait_up.rb
128
+ - lib/wait_up/application.rb
129
+ - lib/wait_up/pipeline.rb
130
+ - test/end_to_end/basic_run_test.rb
131
+ - test/test_helper.rb
132
+ - test/unit/pipeline_test.rb
133
+ homepage: http://www.github.com/mvz/wait_up
134
+ licenses:
135
+ - MIT
136
+ metadata: {}
137
+ post_install_message:
138
+ rdoc_options: []
139
+ require_paths:
140
+ - lib
141
+ required_ruby_version: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ required_rubygems_version: !ruby/object:Gem::Requirement
147
+ requirements:
148
+ - - ">="
149
+ - !ruby/object:Gem::Version
150
+ version: '0'
151
+ requirements: []
152
+ rubyforge_project:
153
+ rubygems_version: 2.5.1
154
+ signing_key:
155
+ specification_version: 4
156
+ summary: Play sound files slowly so you can follow along
157
+ test_files:
158
+ - test/test_helper.rb
159
+ - test/unit/pipeline_test.rb
160
+ - test/end_to_end/basic_run_test.rb