win32-sound 0.4.0 → 0.4.1

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES CHANGED
@@ -1,3 +1,9 @@
1
+ == 0.4.1 - 27-Jul-2007
2
+ * Changed SoundError to Sound::Error.
3
+ * Added a Rakefile with tasks for installation and testing.
4
+ * Removed the install.rb file. Installation is now handled via a rake task.
5
+ * Documentation updates.
6
+
1
7
  == 0.4.0 - 26-Feb-2006
2
8
  * Now pure Ruby only.
3
9
  * Documentation updates and reorganization.
data/MANIFEST CHANGED
@@ -1,11 +1,8 @@
1
- MANIFEST
2
- CHANGES
3
- README
4
- install.rb
5
- win32-sound.gempsec
6
-
7
- examples/sound_test.rb
8
-
9
- lib/win32/sound.rb
10
-
11
- test/tc_sound.rb
1
+ * MANIFEST
2
+ * CHANGES
3
+ * README
4
+ * Rakefile
5
+ * win32-sound.gempsec
6
+ * examples/sound_test.rb
7
+ * lib/win32/sound.rb
8
+ * test/tc_sound.rb
data/README CHANGED
@@ -2,68 +2,64 @@
2
2
  A package for playing with sound on Windows.
3
3
 
4
4
  == Prerequisites
5
- This package requires Ruby 1.8.0 or later.
5
+ This package requires Ruby 1.8.0 or later. Ruby 1.8.2 or later is
6
+ recommended.
6
7
 
7
8
  == Installation instructions
8
- === Gem installation
9
- ruby win32-sound.gemspect
10
- gem install win32-sound-X.X.X.gem
11
-
12
- === Manual installation
13
- ruby install.rb
14
- ri lib\win32\sound.rb (to generate documentation)
9
+ rake test (optional)
10
+ rake install (non-gem) or rake install_gem (gem)
15
11
 
16
12
  == Synopsis
17
- require "win32/sound"
13
+ require 'win32/sound'
18
14
  include Win32
19
-
15
+
20
16
  # Get the current volume of the waveform-audio output device.
21
17
  p Sound.volume.join(", ") # left channel, right channel
22
-
18
+
23
19
  # Play a system sound
24
20
  Sound.play("SystemAsterisk",Sound::ALIAS)
25
-
21
+
26
22
  # Play a wav file
27
23
  Sound.play("somefile.wav")
28
24
 
29
25
  == Acknowledgements
30
26
  API ideas derived (or not) from Perl's Win32::Sound module and Python's
31
27
  winsound package.
32
-
28
+
33
29
  == Known Bugs
34
- None that I'm aware of. Please report any bugs on the Win32 Utils home
30
+ None that I'm aware of. Please report any bugs on the Win32 Utils home
35
31
  page at http://rubyforge.org/projects/win32utils.
36
32
 
37
33
  == Questions and Comments
38
34
  Please post questions and/or comments on one of the forums on the project
39
- page at http://rubyforge.org/projects/win32utils. Click the 'Forums' tab.
35
+ page at http://rubyforge.org/projects/win32utils. Click the 'Forums' tab.
40
36
 
41
37
  == Future Plans
42
38
  Add ability to retrieve information about WAV files.
43
39
  Add MIDI support?
44
-
40
+
45
41
  == Developer's Notes
46
42
  The MessageBeep() function, which the Python "winsound" module contains,
47
- is intentionally omitted here. I felt it was redundant, because you can
43
+ is intentionally omitted here. I felt it was redundant, because you can
48
44
  achieve the same effect with something like
49
45
  Sound.play("SystemAsterisk", Sound::ALIAS).
50
46
 
51
47
  == License
52
48
  Ruby's
53
-
49
+
54
50
  == Copyright
55
- (C) 2004-2006, Daniel J. Berger, All Rights Reserved
56
-
51
+ (C) 2004-2007, Daniel J. Berger, All Rights Reserved
52
+
57
53
  == Warranty
58
54
  This package is provided "as is" and without any express or
59
55
  implied warranties, including, without limitation, the implied
60
56
  warranties of merchantability and fitness for a particular purpose.
61
-
57
+
62
58
  == Author(s)
63
59
  Daniel Berger
64
- djberg96 at gmail dot com
65
- imperator/mok on IRC (irc.freenode.net)
66
-
60
+ djberg96 at nospam at gmail dot com
61
+ imperator on IRC (irc.freenode.net)
62
+
67
63
  Park Heesob
68
- phasis at nownuri dot net
64
+ phasis at nospam at nownuri dot net
69
65
  phasis68 on IRC (irc.freenode.net)
@@ -0,0 +1,22 @@
1
+ require 'rake'
2
+ require 'rake/testtask'
3
+
4
+ desc "Install the win32-sound package (non-gem)"
5
+ task :install do
6
+ dest = File.join(Config::CONFIG['sitelibdir'], 'win32')
7
+ Dir.mkdir(dest) unless File.exists? dest
8
+ cp 'lib/win32/sound.rb', dest, :verbose => true
9
+ end
10
+
11
+ desc "Install the win32-sound package as a gem"
12
+ task :install_gem do
13
+ ruby 'win32-sound.gemspec'
14
+ file = Dir["*.gem"].first
15
+ sh "gem install #{file}"
16
+ end
17
+
18
+ Rake::TestTask.new do |t|
19
+ t.libs << 'lib'
20
+ t.warning = true
21
+ t.test_files = FileList['test/tc*']
22
+ end
@@ -1,8 +1,9 @@
1
1
  require 'Win32API'
2
2
  module Win32
3
- class SoundError < StandardError; end
4
3
  class Sound
5
- VERSION = '0.4.0'
4
+ class Error < StandardError; end
5
+
6
+ VERSION = '0.4.1'
6
7
  LOW_FREQUENCY = 37
7
8
  HIGH_FREQUENCY = 32767
8
9
  MAX_VOLUME = 0xFFFF
@@ -49,7 +50,7 @@ module Win32
49
50
  0.upto(@@auxGetNumDevs.call){ |i| devs << "AUX#{i}" }
50
51
  0.upto(@@mixerGetNumDevs.call){ |i| devs << "MIXER#{i}" }
51
52
  rescue Exception => err
52
- raise SoundError, get_last_error
53
+ raise Error, get_last_error
53
54
  end
54
55
 
55
56
  devs
@@ -62,11 +63,11 @@ module Win32
62
63
  # The duration is in milliseconds.
63
64
  def self.beep(frequency, duration)
64
65
  if frequency > HIGH_FREQUENCY || frequency < LOW_FREQUENCY
65
- raise SoundError, 'invalid frequency'
66
+ raise Error, 'invalid frequency'
66
67
  end
67
68
 
68
69
  if 0 == @@Beep.call(frequency, duration)
69
- raise SoundError, get_last_error
70
+ raise Error, get_last_error
70
71
  end
71
72
  self
72
73
  end
@@ -81,7 +82,7 @@ module Win32
81
82
  end
82
83
 
83
84
  if 0 == @@PlaySound.call(0, 0, flags)
84
- raise SoundError, get_last_error
85
+ raise Error, get_last_error
85
86
  end
86
87
  self
87
88
  end
@@ -134,7 +135,7 @@ module Win32
134
135
  # until the sound ends.
135
136
  def self.play(sound, flags = 0)
136
137
  if 0 == @@PlaySound.call(sound, 0, flags)
137
- raise SoundError, get_last_error
138
+ raise Error, get_last_error
138
139
  end
139
140
  self
140
141
  end
@@ -153,7 +154,7 @@ module Win32
153
154
  volume = lvolume | rvolume << 16
154
155
 
155
156
  if @@waveOutSetVolume.call(-1, volume) != 0
156
- raise SoundError, get_last_error
157
+ raise Error, get_last_error
157
158
  end
158
159
  self
159
160
  end
@@ -163,7 +164,7 @@ module Win32
163
164
  def self.wave_volume
164
165
  volume = [0].pack('L')
165
166
  if @@waveOutGetVolume.call(-1, volume) != 0
166
- raise SoundError, get_last_error
167
+ raise Error, get_last_error
167
168
  end
168
169
  volume = volume.unpack('L').first
169
170
  [low_word(volume), high_word(volume)]
@@ -199,4 +200,4 @@ module Win32
199
200
  buf.split(0.chr).first.chomp
200
201
  end
201
202
  end
202
- end
203
+ end
@@ -1,16 +1,9 @@
1
- ###########################################
1
+ ##########################################################################
2
2
  # tc_sound.rb
3
3
  #
4
- # Test suite for the win32-sound package.
5
- ############################################
6
- base = File.basename(Dir.pwd)
7
-
8
- if base == "test" || base =~ /win32-sound/
9
- Dir.chdir("..") if base == "test"
10
- $LOAD_PATH.unshift Dir.pwd + '/lib'
11
- Dir.chdir("test") if base =~ /win32-sound/
12
- end
13
-
4
+ # Test suite for the win32-sound package. You should run this test case
5
+ # via the 'rake test' task.
6
+ ##########################################################################
14
7
  puts "You may hear some funny noises - don't panic"
15
8
  sleep 1
16
9
 
@@ -24,14 +17,14 @@ class TC_Sound < Test::Unit::TestCase
24
17
  end
25
18
 
26
19
  def test_version
27
- assert_equal("0.4.0", Sound::VERSION)
20
+ assert_equal("0.4.1", Sound::VERSION)
28
21
  end
29
22
 
30
23
  def test_beep
31
24
  assert_respond_to(Sound, :beep)
32
25
  assert_nothing_raised{ Sound.beep(55,100) }
33
26
 
34
- assert_raises(SoundError){ Sound.beep(0,100) }
27
+ assert_raises(Sound::Error){ Sound.beep(0,100) }
35
28
  assert_raises(ArgumentError){ Sound.beep }
36
29
  assert_raises(ArgumentError){ Sound.beep(500) }
37
30
  assert_raises(ArgumentError){ Sound.beep(500,500,5) }
@@ -72,7 +65,7 @@ class TC_Sound < Test::Unit::TestCase
72
65
  end
73
66
 
74
67
  def test_expected_errors
75
- assert_raises(SoundError){ Sound.beep(-1, 1) }
68
+ assert_raises(Sound::Error){ Sound.beep(-1, 1) }
76
69
  end
77
70
 
78
71
  def test_constants
@@ -92,4 +85,4 @@ class TC_Sound < Test::Unit::TestCase
92
85
  def teardown
93
86
  @wav = nil
94
87
  end
95
- end
88
+ end
@@ -0,0 +1,27 @@
1
+ require "rubygems"
2
+
3
+ spec = Gem::Specification.new do |gem|
4
+ gem.name = "win32-sound"
5
+ gem.version = "0.4.1"
6
+ gem.author = "Daniel J. Berger"
7
+ gem.email = "djberg96@gmail.com"
8
+ gem.homepage = "http://www.rubyforge.org/projects/win32utils"
9
+ gem.platform = Gem::Platform::RUBY
10
+ gem.summary = "A library for playing with sound on MS Windows."
11
+ gem.description = "A library for playing with sound on MS Windows."
12
+ gem.test_file = "test/tc_sound.rb"
13
+ gem.has_rdoc = true
14
+ gem.require_path = "lib"
15
+ gem.extra_rdoc_files = ['CHANGES', 'README', 'MANIFEST']
16
+ gem.rubyforge_project = "win32utils"
17
+
18
+ files = Dir["doc/*"] + Dir["examples/*"] + Dir["lib/win32/*"]
19
+ files += Dir["test/*"] + Dir["[A-Z]*"]
20
+ files.delete_if{ |item| item.include?("CVS") }
21
+ gem.files = files
22
+ end
23
+
24
+ if $0 == __FILE__
25
+ Gem.manage_gems
26
+ Gem::Builder.new(spec).build
27
+ end
metadata CHANGED
@@ -1,17 +1,17 @@
1
1
  --- !ruby/object:Gem::Specification
2
- rubygems_version: 0.8.11
2
+ rubygems_version: 0.9.2
3
3
  specification_version: 1
4
4
  name: win32-sound
5
5
  version: !ruby/object:Gem::Version
6
- version: 0.4.0
7
- date: 2006-02-26 00:00:00 -07:00
8
- summary: A package for playing with sound on Windows.
6
+ version: 0.4.1
7
+ date: 2007-07-27 00:00:00 -06:00
8
+ summary: A library for playing with sound on MS Windows.
9
9
  require_paths:
10
10
  - lib
11
11
  email: djberg96@gmail.com
12
12
  homepage: http://www.rubyforge.org/projects/win32utils
13
13
  rubyforge_project: win32utils
14
- description: A package for playing with sound on Windows.
14
+ description: A library for playing with sound on MS Windows.
15
15
  autorequire:
16
16
  default_executable:
17
17
  bindir: bin
@@ -25,6 +25,7 @@ required_ruby_version: !ruby/object:Gem::Version::Requirement
25
25
  platform: ruby
26
26
  signing_key:
27
27
  cert_chain:
28
+ post_install_message:
28
29
  authors:
29
30
  - Daniel J. Berger
30
31
  files:
@@ -32,8 +33,13 @@ files:
32
33
  - lib/win32/sound.rb
33
34
  - test/tc_sound.rb
34
35
  - CHANGES
36
+ - examples
37
+ - lib
35
38
  - MANIFEST
39
+ - Rakefile
36
40
  - README
41
+ - test
42
+ - win32-sound.gemspec
37
43
  test_files:
38
44
  - test/tc_sound.rb
39
45
  rdoc_options: []
@@ -41,6 +47,7 @@ rdoc_options: []
41
47
  extra_rdoc_files:
42
48
  - CHANGES
43
49
  - README
50
+ - MANIFEST
44
51
  executables: []
45
52
 
46
53
  extensions: []