audite 0.1.5 → 0.1.6

Sign up to get free protection for your applications and to get access to all the features.
data/.gitignore CHANGED
@@ -1,4 +1,5 @@
1
1
  *~
2
+ *.gem
2
3
  ext/*/Makefile
3
4
  ext/*/*.o
4
5
  ext/*/*.bundle
data/Gemfile ADDED
@@ -0,0 +1,5 @@
1
+ source "http://rubygems.org"
2
+ group :test do
3
+ gem "rspec", :require => "spec"
4
+ end
5
+
data/LICENSE ADDED
@@ -0,0 +1,7 @@
1
+ Copyright (c) 2013 Matthias Georgi
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
4
+
5
+ The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
6
+
7
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md CHANGED
@@ -12,11 +12,15 @@ libmp123 and portaudio.
12
12
  * Progress information
13
13
  * Simple level meter
14
14
 
15
- ## Player
15
+ ## Usage
16
16
 
17
- Audite ships an example player, just try `audite test.mp3`.
17
+ Audite ships an example player:
18
18
 
19
- ## Example
19
+ ```
20
+ audite test.mp3
21
+ ```
22
+
23
+ ## API Example
20
24
 
21
25
  ```
22
26
  require 'audite'
@@ -49,3 +53,16 @@ brew install mpg123
49
53
 
50
54
  gem install audite
51
55
  ```
56
+
57
+
58
+ ## Debian / Ubuntu Install
59
+ ```
60
+ apt-get install libportaudiocpp0 portaudio19-dev libmpg123-dev
61
+ gem install audite
62
+ ```
63
+
64
+ ## Soundcloud2000
65
+
66
+ Audite provides the audio engine for [Soundcloud2000][1]
67
+
68
+ [1]: https://github.com/grobie/soundcloud2000
@@ -2,7 +2,7 @@ $:.push File.expand_path("../lib", __FILE__)
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = "audite"
5
- s.version = "0.1.5"
5
+ s.version = "0.1.6"
6
6
  s.author = "Matthias Georgi"
7
7
  s.email = "matti.georgi@gmail.com"
8
8
  s.homepage = "http://georgi.github.com/audite"
@@ -66,9 +66,11 @@ VALUE rb_mpg123_read(VALUE self, VALUE _size)
66
66
  for (i = 0; i < size; i++) {
67
67
  rb_ary_store(result, i, rb_float_new(buffer[i]));
68
68
  }
69
+ free(buffer);
69
70
  return result;
70
71
  }
71
72
  else {
73
+ free(buffer);
72
74
  rb_raise(rb_eStandardError, "%s", mpg123_plain_strerror(err));
73
75
  }
74
76
  }
@@ -1,15 +1,24 @@
1
1
  require 'mkmf'
2
2
 
3
3
  unless have_header('portaudio.h')
4
- puts "please install portaudio headers"
4
+ puts "portaudio.h not found"
5
+ puts "please brew install portaudio"
6
+ puts "or apt-get install portaudio19-dev"
5
7
  exit
6
8
  end
7
9
 
8
10
  unless have_library('portaudio')
9
- puts "please install portaudio lib"
11
+ puts "lib portaudio not found"
12
+ puts "brew install portaudio"
13
+ puts "or apt-get install portaudio19-dev"
10
14
  exit
11
15
  end
12
16
 
13
- have_type('PaStreamCallbackTimeInfo', 'portaudio.h')
17
+ unless have_type('PaStreamCallbackTimeInfo', 'portaudio.h')
18
+ puts "portaudio19 not found"
19
+ puts "brew install portaudio"
20
+ puts "or apt-get install portaudio19-dev"
21
+ exit
22
+ end
14
23
 
15
24
  create_makefile('portaudio')
@@ -28,20 +28,12 @@ void free_portaudio(void *ptr)
28
28
  }
29
29
  }
30
30
 
31
- #ifdef HAVE_TYPE_PASTREAMCALLBACKTIMEINFO
32
31
  static int paCallback(const void *inputBuffer,
33
32
  void *outputBuffer,
34
33
  unsigned long framesPerBuffer,
35
34
  const PaStreamCallbackTimeInfo* timeInfo,
36
35
  PaStreamCallbackFlags statusFlags,
37
36
  void *userData )
38
- #else
39
- static int paCallback(void *inputBuffer,
40
- void *outputBuffer,
41
- unsigned long framesPerBuffer,
42
- PaTimestamp outTime,
43
- void *userData )
44
- #endif
45
37
  {
46
38
  Portaudio *portaudio = (Portaudio *) userData;
47
39
  float *out = (float*) outputBuffer;
@@ -61,7 +53,10 @@ static int paCallback(void *inputBuffer,
61
53
 
62
54
  VALUE rb_portaudio_new(VALUE klass)
63
55
  {
56
+ PaStreamParameters outputParameters;
57
+ const PaDeviceInfo *deviceInfo;
64
58
  PaError err;
59
+ int device, numDevices;
65
60
  VALUE self;
66
61
  Portaudio *portaudio = (Portaudio *) malloc(sizeof(Portaudio));
67
62
 
@@ -77,9 +72,6 @@ VALUE rb_portaudio_new(VALUE klass)
77
72
  paFloat32, /* 32 bit floating point output */
78
73
  44100, /* 44100 sample rate*/
79
74
  4096, /* frames per buffer */
80
- #ifndef HAVE_TYPE_PASTREAMCALLBACKTIMEINFO
81
- 1, /* number of buffer */
82
- #endif
83
75
  paCallback, /* this is your callback function */
84
76
  (void*) portaudio);
85
77
 
@@ -137,7 +137,7 @@ class Audite
137
137
  end
138
138
 
139
139
  def level(slice)
140
- slice.inject(0) {|s, i| s + i.abs } / slice.size
140
+ slice.map {|i| i.abs }.max
141
141
  end
142
142
 
143
143
  def rewind(seconds = 2)
Binary file
@@ -0,0 +1,14 @@
1
+ require 'audite'
2
+
3
+ describe Audite do
4
+ it "loads and reports on an mp3" do
5
+ player = Audite.new
6
+ player.load(File.dirname(__FILE__)+'/30sec.mp3')
7
+ player.length.should eq(1326351)
8
+ player.length_in_seconds.should eq(30.075986394557827)
9
+ end
10
+ it "generates an error on a non-existant mp3" do
11
+ player = Audite.new
12
+ expect {player.load('/tmp/file.mp3')}.to raise_error
13
+ end
14
+ end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: audite
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.5
4
+ version: 0.1.6
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-01-27 00:00:00.000000000 Z
12
+ date: 2013-01-28 00:00:00.000000000 Z
13
13
  dependencies: []
14
14
  description: Portable mp3 player built on mpg123 and portaudio
15
15
  email: matti.georgi@gmail.com
@@ -22,6 +22,8 @@ extra_rdoc_files:
22
22
  - README.md
23
23
  files:
24
24
  - .gitignore
25
+ - Gemfile
26
+ - LICENSE
25
27
  - README.md
26
28
  - audite.gemspec
27
29
  - bin/audite
@@ -30,6 +32,8 @@ files:
30
32
  - ext/portaudio/extconf.rb
31
33
  - ext/portaudio/portaudio.c
32
34
  - lib/audite.rb
35
+ - spec/30sec.mp3
36
+ - spec/audite_spec.rb
33
37
  homepage: http://georgi.github.com/audite
34
38
  licenses: []
35
39
  post_install_message: