Permalink
Browse files

Enhanced JSound::Devices::Recorder to record floating point seconds, …

…instead integer seconds (which wasn't particularly useful.

Also updated some docs.
[fixes #14738591]
  • Loading branch information...
adamjmurray committed Jun 30, 2011
1 parent 49fec5f commit 91dcdb639e56eb87de51e5a9bbfa3a7741ae5210
Showing with 44 additions and 11 deletions.
  1. +10 −1 INTRO.md
  2. +11 −4 README.md
  3. +5 −0 Rakefile
  4. +1 −1 jsound.gemspec
  5. +4 −2 lib/jsound/midi/devices/recorder.rb
  6. +13 −3 spec/jsound/midi/devices/recorder_spec.rb
View
@@ -7,7 +7,7 @@ Java's cross-platform standard library includes a
[sound API for MIDI and sampled sound](http://download.oracle.com/javase/tutorial/sound/index.html).
JSound builds on this API and provides a Ruby interface via [JRuby](http://jruby.org).
-For now, JSound is focusd on use of the [javax.sound.midi API](http://download.oracle.com/javase/7/docs/api/javax/sound/midi/package-summary.html)
+For now, JSound is focused on use of the [javax.sound.midi API](http://download.oracle.com/javase/7/docs/api/javax/sound/midi/package-summary.html)
in Ruby scripts and applications.
Support for the [javax.sound.samples API](http://download.oracle.com/javase/7/docs/api/javax/sound/sampled/package-summary.html)
may arrive in the future.
@@ -123,6 +123,15 @@ Some of the {JSound::Midi::DeviceList} methods will automatically open the devic
The {JSound::Midi::DeviceList#method_missing} behavior for DeviceList provides a convenient way to
find and automatically open devices.
+<br>
+### Known Issues ###
+
+See http://github.com/adamjmurray/jsound/wiki/Known-Issues for the most up-to-date list of known issues.
+
+<br>
+### Feature Requests and Bug Reports ###
+
+https://github.com/adamjmurray/jsound/issues (requires a github account)
<br>
### OS X ###
View
@@ -21,7 +21,7 @@ License: Distributed under a permissive BSD-style license, see LICENSE.txt
Documentation
-------------
-Gem: http://rubydoc.info/gems/jsound/0.1.2/frames
+Gem: http://rubydoc.info/gems/jsound/0.1.3/frames
Latest for source: http://rubydoc.info/github/adamjmurray/jsound/master/frames
@@ -32,11 +32,15 @@ Development Notes
### Run Tests ###
- rake spec
+Test with current version of JRuby:
-and to quickly check compatibility with multiple JRuby versions via rvm:
+ jruby -S rake spec
- rvm jruby-1.5.6,jruby-1.6.2 rake spec:fast
+Test with all supported versions of JRuby (requires [rvm](https://rvm.beginrescueend.com/), JRuby 1.5.6, and JRuby 1.6.2):
+
+ rake spec:xversion
+
+spec:xversion must pass for a pull request to be accepted or for a release of the jsound gem.
### Generate Docs ###
@@ -58,6 +62,9 @@ https://www.pivotaltracker.com/projects/85719
Changelog
---------
+* June 29, 2011, version 0.1.3
+ - enhanced JSound::Devices::Recorder to record floating point seconds, instead integer seconds (which wasn't particularly useful)
+
* June 18, 2011, version 0.1.2
- added a "Hash of mappings" feature to Transformer, for easy implementation of simple transformation patterns
- improved examples
View
@@ -16,4 +16,9 @@ namespace :spec do
RSpec::Core::RakeTask.new(:fast) do |spec|
spec.rspec_opts = ["--color", "--fail-fast"]
end
+
+ desc "Run RSpecs tests on mutiple versions of JRuby: JRuby 1.5.6, and JRuby 1.6.2"
+ task :xversion do
+ fail unless system("rvm jruby-1.5.6,jruby-1.6.2 rake -f #{__FILE__} spec:fast")
+ end
end
View
@@ -1,6 +1,6 @@
Gem::Specification.new do |spec|
spec.name = 'jsound'
- spec.version = '0.1.2'
+ spec.version = '0.1.3'
spec.summary = 'Ruby wrapper for the Java sound API'
spec.description = "A Ruby interface for Java's javax.sound API. Runs on the JVM via JRuby."
@@ -5,7 +5,9 @@ module Devices
# A Device that records incoming messages, and the timestamp at which they were received.
class Recorder < Device
- # The recorded [message,timestamp] pairs
+ # The recorded [message,timestamp] pairs.
+ #
+ # Timestamps are in floating point seconds.
attr_reader :messages_with_timestamps
# The recorded messages without timestamps
@@ -50,7 +52,7 @@ def output= device
end
def message(message)
- @messages_with_timestamps << [message, Time.now.to_i] if recording?
+ @messages_with_timestamps << [message, Time.now.to_f] if recording?
end
end
@@ -38,12 +38,22 @@ module JSound::Midi::Devices
describe '#messages_with_timestamps' do
it 'should return all recorded [message,timestamp] pairs in an Array' do
recorder.start
- time = Time.now.to_i
+ start_time = Time.now.to_f
recorder <= :one
recorder <= 2
recorder <= 'three'
- # assuming this test all happens within a small fraction of a second:
- recorder.messages_with_timestamps.should == [[:one,time], [2,time], ['three',time]]
+ mwt = recorder.messages_with_timestamps
+
+ message1, time1 = *mwt[0]
+ message2, time2 = *mwt[1]
+ message3, time3 = *mwt[2]
+ [message1, message2, message3].should == [:one, 2, 'three']
+ time1.should be_a Float
+ time1.should be_within(0.01).of start_time
+ time2.should be_within(0.015).of start_time
+ time3.should be_within(0.02).of start_time
+ time1.should <= time2
+ time2.should <= time3
end
end

0 comments on commit 91dcdb6

Please sign in to comment.