lame 0.0.3 → 0.0.5
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.
- checksums.yaml +7 -0
- data/.github/workflows/ci.yml +47 -0
- data/.travis.yml +3 -4
- data/README.md +51 -19
- data/docs/lame-3.101.h +1357 -0
- data/lame.gemspec +2 -1
- data/lib/lame/buffer.rb +1 -1
- data/lib/lame/encoder.rb +10 -11
- data/lib/lame/encoding/interleaved_int_buffer_encoder.rb +15 -0
- data/lib/lame/encoding/long_buffer_encoder.rb +1 -1
- data/lib/lame/encoding/stereo_buffer_encoder.rb +1 -0
- data/lib/lame/ffi/functions.rb +99 -38
- data/lib/lame/ffi.rb +2 -0
- data/lib/lame/version.rb +1 -1
- data/lib/lame.rb +2 -0
- data/spec/buffer_spec.rb +8 -8
- data/spec/configuration_spec.rb +76 -76
- data/spec/decoder_spec.rb +34 -34
- data/spec/decoding/decoded_frame_spec.rb +7 -7
- data/spec/decoding/id3_tag_parser_spec.rb +3 -3
- data/spec/decoding/mp3_data_header_parser_spec.rb +21 -21
- data/spec/decoding/mpeg_audio_frame_finder_spec.rb +15 -15
- data/spec/decoding/mpeg_audio_frame_matcher_spec.rb +2 -2
- data/spec/decoding/single_frame_decoder_spec.rb +36 -35
- data/spec/decoding/stream_decoder_spec.rb +10 -10
- data/spec/delegation_spec.rb +37 -37
- data/spec/encoder_spec.rb +100 -100
- data/spec/encoding/flusher_spec.rb +16 -16
- data/spec/encoding/id3_spec.rb +38 -38
- data/spec/encoding/interleaved_buffer_encoder_spec.rb +32 -25
- data/spec/encoding/stereo_buffer_encoder_spec.rb +34 -33
- data/spec/encoding/vbr_info_spec.rb +16 -16
- data/spec/ffi/decode_flags_spec.rb +3 -2
- data/spec/ffi/encoding_spec.rb +22 -22
- data/spec/ffi/global_flags_spec.rb +166 -160
- data/spec/ffi/id3tag_spec.rb +26 -26
- data/spec/ffi/mp3_data_spec.rb +3 -3
- data/spec/integration/encoding_spec.rb +75 -3
- data/spec/integration/id3_tags_spec.rb +18 -18
- data/spec/lib/custom_matchers.rb +4 -4
- data/spec/lib/wave_file_generator.rb +9 -9
- data/spec/spec_helper.rb +14 -10
- metadata +58 -67
checksums.yaml
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
---
|
|
2
|
+
SHA256:
|
|
3
|
+
metadata.gz: b1dbd68980ebd6f4bddace81b1c4a3f5a3ea6e92c0b88ea159ba4552ee26bf89
|
|
4
|
+
data.tar.gz: 9974a5a4d7cae8bf8c5511bcdc64391ccbbc0dd1fad3a6c61be6733f60fd5b5d
|
|
5
|
+
SHA512:
|
|
6
|
+
metadata.gz: 253e7848d81e9dea55800b37c54f6e239bfb7d3ca7eb5679ebe3ead683918c3856052adf09d5c9b05666685afd08348b27b1529c7643f4f0c43f47063ed55241
|
|
7
|
+
data.tar.gz: 88592750da789b2c01f8dc9a9aa93386b56aeb4597cf0d1495aa8042257e6107f4a753b27c2974e3161e26f19072b1c8b0aae4e859975a3f035c9e93751460f3
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
name: CI
|
|
2
|
+
|
|
3
|
+
on:
|
|
4
|
+
push:
|
|
5
|
+
branches: [ main, master ]
|
|
6
|
+
pull_request:
|
|
7
|
+
branches: [ main, master ]
|
|
8
|
+
workflow_dispatch:
|
|
9
|
+
|
|
10
|
+
jobs:
|
|
11
|
+
test:
|
|
12
|
+
runs-on: ubuntu-latest
|
|
13
|
+
|
|
14
|
+
strategy:
|
|
15
|
+
fail-fast: false
|
|
16
|
+
matrix:
|
|
17
|
+
ruby-version:
|
|
18
|
+
- '3.3'
|
|
19
|
+
- '3.4'
|
|
20
|
+
- '4.0'
|
|
21
|
+
- 'ruby-head'
|
|
22
|
+
- 'jruby'
|
|
23
|
+
- 'truffleruby'
|
|
24
|
+
|
|
25
|
+
steps:
|
|
26
|
+
- name: Check out code
|
|
27
|
+
uses: actions/checkout@v4
|
|
28
|
+
|
|
29
|
+
- name: Install system dependencies
|
|
30
|
+
run: |
|
|
31
|
+
sudo apt-get update
|
|
32
|
+
sudo apt-get install -qq libmp3lame-dev
|
|
33
|
+
|
|
34
|
+
- name: Set up Ruby
|
|
35
|
+
uses: ruby/setup-ruby@v1
|
|
36
|
+
with:
|
|
37
|
+
ruby-version: ${{ matrix.ruby-version }}
|
|
38
|
+
bundler-cache: true
|
|
39
|
+
|
|
40
|
+
- name: Run tests
|
|
41
|
+
run: bundle exec rake
|
|
42
|
+
|
|
43
|
+
- name: Upload coverage to Coveralls
|
|
44
|
+
if: matrix.ruby-version == '3.4'
|
|
45
|
+
uses: coverallsapp/github-action@v2
|
|
46
|
+
with:
|
|
47
|
+
file: coverage/lcov.info
|
data/.travis.yml
CHANGED
data/README.md
CHANGED
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
# LAME
|
|
2
2
|
|
|
3
|
-
[](http://badge.fury.io/rb/lame)
|
|
4
|
+
[](https://github.com/rdvdijk/lame/actions/workflows/ci.yml)
|
|
5
5
|
[](https://coveralls.io/r/rdvdijk/lame)
|
|
6
6
|
|
|
7
7
|
FFI powered library for the [LAME MP3 encoder](http://lame.sourceforge.net/).
|
|
8
8
|
|
|
9
9
|
## Installation
|
|
10
10
|
|
|
11
|
+
### Installing the gem
|
|
12
|
+
|
|
11
13
|
Add this line to your application's Gemfile:
|
|
12
14
|
|
|
13
15
|
gem 'lame'
|
|
@@ -20,6 +22,16 @@ Or install it yourself as:
|
|
|
20
22
|
|
|
21
23
|
$ gem install lame
|
|
22
24
|
|
|
25
|
+
### Installing LAME
|
|
26
|
+
|
|
27
|
+
To use this gem, you need to have the LAME development library (`libmp3lame-dev`) installed.
|
|
28
|
+
|
|
29
|
+
Ubuntu/Debian: `sudo apt-get install libmp3lame-dev`
|
|
30
|
+
|
|
31
|
+
Mac OS X with Homebrew: `brew install lame`
|
|
32
|
+
|
|
33
|
+
Or build it from source, visit the [LAME website](http://lame.sourceforge.net/).
|
|
34
|
+
|
|
23
35
|
## Usage
|
|
24
36
|
|
|
25
37
|
Create a default `LAME::Encoder` with default settings:
|
|
@@ -54,27 +66,28 @@ See all encoding methods in the Encoding section below.
|
|
|
54
66
|
|
|
55
67
|
### Configuration
|
|
56
68
|
|
|
57
|
-
|
|
69
|
+
Here are all the encoding configuration options. The values use here are the
|
|
70
|
+
defaults. You can set any option prior to encoding.
|
|
58
71
|
|
|
59
72
|
```ruby
|
|
60
|
-
# These are the defaults:
|
|
61
73
|
encoder.configure do |config|
|
|
74
|
+
config.bitrate = 128
|
|
75
|
+
config.quality = 3
|
|
76
|
+
config.mode = :join_stereo
|
|
77
|
+
|
|
62
78
|
config.number_of_samples = 4294967295
|
|
63
|
-
config.input_samplerate = 44100
|
|
64
79
|
config.number_of_channels = 2
|
|
80
|
+
config.input_samplerate = 44100
|
|
81
|
+
config.output_samplerate = 44100
|
|
65
82
|
config.scale = 0.95
|
|
66
83
|
config.scale_left = 1.0
|
|
67
84
|
config.scale_left = 1.0
|
|
68
|
-
config.output_samplerate = 44100
|
|
69
85
|
config.analysis = false
|
|
70
86
|
config.decode_only = false
|
|
71
|
-
config.quality = 3
|
|
72
|
-
config.mode = :join_stereo
|
|
73
87
|
config.force_mid_side = false
|
|
74
88
|
config.free_format = false
|
|
75
89
|
config.replay_gain = false
|
|
76
90
|
config.decode_on_the_fly = false
|
|
77
|
-
config.bitrate = 128
|
|
78
91
|
config.preset = :EXTREME # no LAME default
|
|
79
92
|
config.copyright = false
|
|
80
93
|
config.original = true
|
|
@@ -89,11 +102,11 @@ encoder.configure do |config|
|
|
|
89
102
|
config.emphasis = false
|
|
90
103
|
|
|
91
104
|
# auto-detected by default
|
|
92
|
-
config.asm_optimization.mmx
|
|
93
|
-
config.asm_optimization.
|
|
94
|
-
config.asm_optimization.sse
|
|
105
|
+
config.asm_optimization.mmx = true
|
|
106
|
+
config.asm_optimization.amd_3dnow = true
|
|
107
|
+
config.asm_optimization.sse = true
|
|
95
108
|
|
|
96
|
-
# these
|
|
109
|
+
# these options can't be "unset" once set to true
|
|
97
110
|
config.id3.v2 = false
|
|
98
111
|
config.id3.v1_only = false
|
|
99
112
|
config.id3.v2_only = false
|
|
@@ -101,6 +114,15 @@ encoder.configure do |config|
|
|
|
101
114
|
config.id3.v2_padding = false
|
|
102
115
|
config.id3.v2_padding_size = 128
|
|
103
116
|
|
|
117
|
+
config.id3.write_automatic = true
|
|
118
|
+
config.id3.title = nil
|
|
119
|
+
config.id3.artist = nil
|
|
120
|
+
config.id3.album = nil
|
|
121
|
+
config.id3.year = nil
|
|
122
|
+
config.id3.comment = nil
|
|
123
|
+
config.id3.track = nil
|
|
124
|
+
config.id3.genre = nil
|
|
125
|
+
|
|
104
126
|
config.quantization.reservoir = true
|
|
105
127
|
config.quantization.comp = 9
|
|
106
128
|
config.quantization.comp_short = 9
|
|
@@ -136,8 +158,8 @@ end
|
|
|
136
158
|
|
|
137
159
|
### Encoding
|
|
138
160
|
|
|
139
|
-
See `spec/integration/encoding_spec.rb
|
|
140
|
-
to an MP3 file.
|
|
161
|
+
See [`encoding_spec.rb`](spec/integration/encoding_spec.rb) for examples how
|
|
162
|
+
to encode a WAV file to an MP3 file.
|
|
141
163
|
|
|
142
164
|
The available encoding functions are:
|
|
143
165
|
|
|
@@ -174,13 +196,23 @@ The `left` and `right` are arrays of sample values for the given data type.
|
|
|
174
196
|
|
|
175
197
|
### Decoding
|
|
176
198
|
|
|
177
|
-
See `spec/integration/decoding_spec.rb
|
|
178
|
-
to an WAV file.
|
|
199
|
+
See [`decoding_spec.rb`](spec/integration/decoding_spec.rb) for examples how
|
|
200
|
+
to decode an MP3 file to an WAV file.
|
|
179
201
|
|
|
180
202
|
### Development
|
|
181
203
|
|
|
182
204
|
This section contains some references used during development of this gem.
|
|
183
205
|
|
|
206
|
+
#### Testing
|
|
207
|
+
|
|
208
|
+
Run the unit tests with rspec:
|
|
209
|
+
|
|
210
|
+
$ rspec
|
|
211
|
+
|
|
212
|
+
Run the integration tests by using the `slow` tag:
|
|
213
|
+
|
|
214
|
+
$ rspec -t slow
|
|
215
|
+
|
|
184
216
|
#### ID3v2 tags
|
|
185
217
|
|
|
186
218
|
To use ID3v2 tags in files, see this post on the `lame-dev` mailing list:
|
|
@@ -195,7 +227,7 @@ So:
|
|
|
195
227
|
4. Write id3v1 tag at end of file
|
|
196
228
|
5. Write vbr 'lametag' at start of audio (using the size of the id3v2 tag)
|
|
197
229
|
|
|
198
|
-
See the example code in `spec/integration/encoding_spec.rb
|
|
230
|
+
See the example code in [`encoding_spec.rb`](spec/integration/encoding_spec.rb).
|
|
199
231
|
|
|
200
232
|
#### Decoding
|
|
201
233
|
|
|
@@ -225,7 +257,7 @@ After this, we are ready to decode MP3 data.
|
|
|
225
257
|
5. Handle the decoded audio.
|
|
226
258
|
6. Now repeat this process (`GOTO 1`) until the end of the MP3 file.
|
|
227
259
|
|
|
228
|
-
See the example code in `spec/integration/decoding_spec.rb
|
|
260
|
+
See the example code in [`decoding_spec.rb`](spec/integration/decoding_spec.rb).
|
|
229
261
|
|
|
230
262
|
## Contributing
|
|
231
263
|
|