rubysketch 0.5.18 → 0.5.19

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 9a57b4fcc0eb7699cf1bc5207145f4621d4f1b807d390d8fbe9f06f3cc9eba78
4
- data.tar.gz: 384dfcb3495eeadf390f5f74c86c99cef32b91a0926cedfa1848225e1aa8a98b
3
+ metadata.gz: 1ccfda24e6b2342ff8e946b61bcdfa18fc751e6d55a4fd08f3b31ff9c35088b0
4
+ data.tar.gz: 748ac2d377d700c504b3149f51829c099ca56c7dce65b9bd61d905eabb0935b4
5
5
  SHA512:
6
- metadata.gz: 82ea2f25e3299991344f514aa3495a4b68b32d3097bcff0e1913dddae19756521c55edcf892ba7eda5b9acf05e25530e379359f78332d566b2b824fea41270f1
7
- data.tar.gz: 453434d0c6d9f80a138b40654441b8b7cf133e1bf6a3c19b241e06fd1710836a28ecf9816edd0bad8910b7870dd88098ed83244892649c84f00a39725916424c
6
+ metadata.gz: c9849d91ec8fa229958d3ce120415705be94faef3833d7eeda6c2c7168870570eb8e646905828dab81cef2113628c672b26c9482b8fc42a80636f0e7daa9845a
7
+ data.tar.gz: b46818c44fa441f5d1bce35d8aa5d09111ce6a6888e01f7cb54502bb23a69bc7bae41f3d2853cb7989b675684a205054563bd102069b618b199d1766d1ca69fd
data/ChangeLog.md CHANGED
@@ -1,6 +1,11 @@
1
1
  # rubysketch ChangeLog
2
2
 
3
3
 
4
+ ## [v0.5.19] - 2023-06-27
5
+
6
+ - add loadSound() and RubySketch::Sound class
7
+
8
+
4
9
  ## [v0.5.18] - 2023-06-22
5
10
 
6
11
  - Update dependencies
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.18
1
+ 0.5.19
@@ -6,6 +6,7 @@ require 'rubysketch/window'
6
6
  require 'rubysketch/helper'
7
7
 
8
8
  require 'rubysketch/sprite'
9
+ require 'rubysketch/sound'
9
10
  require 'rubysketch/context'
10
11
 
11
12
 
@@ -4,6 +4,7 @@ module RubySketch
4
4
  class Context < Processing::Context
5
5
 
6
6
  Sprite = RubySketch::Sprite
7
+ Sound = RubySketch::Sound
7
8
 
8
9
  # @private
9
10
  def initialize(window)
@@ -112,6 +113,16 @@ module RubySketch
112
113
  end
113
114
  end
114
115
 
116
+ # Loads sound file.
117
+ #
118
+ # @param [String] path path for sound file
119
+ #
120
+ # @return [Sound] sound object
121
+ #
122
+ def loadSound(path)
123
+ Sound.load path
124
+ end
125
+
115
126
  # Sets gravity for the physics engine.
116
127
  #
117
128
  # @overload gravity(vec)
@@ -0,0 +1,57 @@
1
+ module RubySketch
2
+
3
+
4
+ # Sound object.
5
+ #
6
+ class Sound
7
+
8
+ # @private
9
+ def initialize(sound)
10
+ @sound = sound
11
+ @players = []
12
+ end
13
+
14
+ # Play sound.
15
+ #
16
+ # @param [Numeric] gain volume for playing sound
17
+ #
18
+ # @return [nil] nil
19
+ #
20
+ def play(gain: 1.0)
21
+ clean_stopped_players
22
+ @players.push @sound.play(gain: gain)
23
+ nil
24
+ end
25
+
26
+ # Stop playing sounds.
27
+ #
28
+ # @return [nil] nil
29
+ #
30
+ def stop()
31
+ @players.each &:stop
32
+ @players.clear
33
+ nil
34
+ end
35
+
36
+ # Load a sound file.
37
+ #
38
+ # @param [String] path file path
39
+ #
40
+ # @return [Sound] sound object
41
+ #
42
+ def self.load(path)
43
+ f = Beeps::FileIn.new path
44
+ self.new Beeps::Sound.new(f, f.seconds, nchannels: f.nchannels)
45
+ end
46
+
47
+ private
48
+
49
+ # @private
50
+ def clean_stopped_players()
51
+ @players.delete_if {|p| not p.playing?}
52
+ end
53
+
54
+ end# Sound
55
+
56
+
57
+ end# RubySketch
data/rubysketch.gemspec CHANGED
@@ -27,10 +27,10 @@ Gem::Specification.new do |s|
27
27
 
28
28
  s.add_runtime_dependency 'xot', '~> 0.1.39'
29
29
  s.add_runtime_dependency 'rucy', '~> 0.1.39'
30
- s.add_runtime_dependency 'beeps', '~> 0.1.40'
30
+ s.add_runtime_dependency 'beeps', '~> 0.1.41'
31
31
  s.add_runtime_dependency 'rays', '~> 0.1.43'
32
- s.add_runtime_dependency 'reflexion', '~> 0.1.46'
33
- s.add_runtime_dependency 'processing', '~> 0.5.19'
32
+ s.add_runtime_dependency 'reflexion', '~> 0.1.47'
33
+ s.add_runtime_dependency 'processing', '~> 0.5.20'
34
34
 
35
35
  s.add_development_dependency 'rake'
36
36
  s.add_development_dependency 'test-unit'
@@ -0,0 +1,33 @@
1
+ # -*- coding: utf-8 -*-
2
+
3
+
4
+ require_relative 'helper'
5
+
6
+
7
+ class TestSound < Test::Unit::TestCase
8
+
9
+ RS = RubySketch
10
+ B = Beeps
11
+
12
+ PATH = 'test.wav'
13
+
14
+ def sound()
15
+ RS::Sound.load PATH
16
+ end
17
+
18
+ def setup()
19
+ B::Sound.new(B::Oscillator.new >> B::Gain.new(gain: 0), 0.1).save PATH
20
+ end
21
+
22
+ def teardown()
23
+ B::SoundPlayer.stop_all
24
+ File.delete PATH if File.exist?(PATH)
25
+ end
26
+
27
+ def test_play_stop()
28
+ s = sound
29
+ assert_nothing_raised {s.play}
30
+ assert_nothing_raised {s.stop}
31
+ end
32
+
33
+ end# TestSound
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rubysketch
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.5.18
4
+ version: 0.5.19
5
5
  platform: ruby
6
6
  authors:
7
7
  - xordog
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-06-22 00:00:00.000000000 Z
11
+ date: 2023-06-26 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: xot
@@ -44,14 +44,14 @@ dependencies:
44
44
  requirements:
45
45
  - - "~>"
46
46
  - !ruby/object:Gem::Version
47
- version: 0.1.40
47
+ version: 0.1.41
48
48
  type: :runtime
49
49
  prerelease: false
50
50
  version_requirements: !ruby/object:Gem::Requirement
51
51
  requirements:
52
52
  - - "~>"
53
53
  - !ruby/object:Gem::Version
54
- version: 0.1.40
54
+ version: 0.1.41
55
55
  - !ruby/object:Gem::Dependency
56
56
  name: rays
57
57
  requirement: !ruby/object:Gem::Requirement
@@ -72,28 +72,28 @@ dependencies:
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: 0.1.46
75
+ version: 0.1.47
76
76
  type: :runtime
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: 0.1.46
82
+ version: 0.1.47
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: processing
85
85
  requirement: !ruby/object:Gem::Requirement
86
86
  requirements:
87
87
  - - "~>"
88
88
  - !ruby/object:Gem::Version
89
- version: 0.5.19
89
+ version: 0.5.20
90
90
  type: :runtime
91
91
  prerelease: false
92
92
  version_requirements: !ruby/object:Gem::Requirement
93
93
  requirements:
94
94
  - - "~>"
95
95
  - !ruby/object:Gem::Version
96
- version: 0.5.19
96
+ version: 0.5.20
97
97
  - !ruby/object:Gem::Dependency
98
98
  name: rake
99
99
  requirement: !ruby/object:Gem::Requirement
@@ -163,6 +163,7 @@ files:
163
163
  - lib/rubysketch/context.rb
164
164
  - lib/rubysketch/extension.rb
165
165
  - lib/rubysketch/helper.rb
166
+ - lib/rubysketch/sound.rb
166
167
  - lib/rubysketch/sprite.rb
167
168
  - lib/rubysketch/window.rb
168
169
  - pod.rake
@@ -170,6 +171,7 @@ files:
170
171
  - src/RubySketch.h
171
172
  - src/RubySketch.mm
172
173
  - test/helper.rb
174
+ - test/test_sound.rb
173
175
  - test/test_sprite.rb
174
176
  homepage: https://github.com/xord/rubysketch
175
177
  licenses:
@@ -196,4 +198,5 @@ specification_version: 4
196
198
  summary: A game engine based on the Processing API.
197
199
  test_files:
198
200
  - test/helper.rb
201
+ - test/test_sound.rb
199
202
  - test/test_sprite.rb