rockbox_ffi 0.4.0 → 0.5.0
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 +4 -4
- data/README.md +24 -11
- data/lib/rockbox_ffi/ffi.rb +2 -0
- data/lib/rockbox_ffi/player.rb +16 -0
- data/lib/rockbox_ffi/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 98d2db65260fc33b5cfd9cf8963c2f96b782079c999ded173f64611a1f3d2554
|
|
4
|
+
data.tar.gz: 8b6fa4f9f221aad0367c913cc6ce494ea97ce62d3658309cc6ed8252003e28d1
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 97340abbfae011f7f3f09a0463046c4831eef6d429ea6d0f1ea0a814a8aac085a12309d46fe7e5ee670772aed59cf9045cbfe72606bdf34e0aab685c534aab04
|
|
7
|
+
data.tar.gz: b28b979145c98b851ab27cf731fb9929603a946a17435e656cb2f350af594bc8fefe525545c6bd2dafa3dd3a6236dcf998b672636f3d09ce16c95b94069d3d3d
|
data/README.md
CHANGED
|
@@ -5,7 +5,8 @@
|
|
|
5
5
|

|
|
6
6
|

|
|
7
7
|
|
|
8
|
-
Ruby bindings for the Rockbox **DSP**, **metadata**,
|
|
8
|
+
Ruby bindings for the Rockbox **DSP**, **metadata**, **codecs**, and
|
|
9
|
+
**playback** engine,
|
|
9
10
|
via [`fiddle`](https://docs.ruby-lang.org/en/master/Fiddle.html) (Ruby stdlib)
|
|
10
11
|
over the prebuilt `librockbox_ffi` shared library. No native extension is
|
|
11
12
|
compiled — the gem `dlopen`s the shared library at load time.
|
|
@@ -53,28 +54,40 @@ RockboxFFI::Dsp.open(44_100) do |dsp|
|
|
|
53
54
|
processed = dsp.process(samples) # Array<Integer>
|
|
54
55
|
end
|
|
55
56
|
|
|
57
|
+
# --- codecs (decode a file to PCM, one chunk at a time) ---------------
|
|
58
|
+
RockboxFFI::Decoder.open("song.flac") do |dec|
|
|
59
|
+
dec.metadata[:title] # tags from the open file
|
|
60
|
+
dec.each_chunk do |samples, sample_rate| # Array<Integer>, Hz
|
|
61
|
+
# samples: interleaved-stereo signed 16-bit PCM
|
|
62
|
+
end
|
|
63
|
+
dec.finished # => [true, 0] (0 = clean)
|
|
64
|
+
end
|
|
65
|
+
|
|
56
66
|
# --- playback (needs an output device) --------------------------------
|
|
57
67
|
RockboxFFI::Player.open(volume: 0.8) do |player|
|
|
58
68
|
player.set_replaygain(RockboxFFI::ReplayGainMode::TRACK, 0.0, true)
|
|
59
69
|
player.set_crossfade(RockboxFFI::CrossfadeMode::ALWAYS)
|
|
60
|
-
|
|
70
|
+
# Queue entries may be local files, http(s):// URLs to remote media,
|
|
71
|
+
# or live-radio / streaming URLs — mix and match freely.
|
|
72
|
+
player.set_queue(["a.flac", "https://example.com/b.mp3", "http://radio.example/stream"])
|
|
61
73
|
player.play
|
|
62
74
|
player.status # => {state: "playing", index: 0, ...}
|
|
63
75
|
end
|
|
64
76
|
```
|
|
65
77
|
|
|
66
|
-
`Dsp` and `Player` own native resources. Use the block form
|
|
67
|
-
them automatically, or call `#close` yourself; a GC
|
|
68
|
-
as a backstop.
|
|
78
|
+
`Dsp`, `Decoder`, and `Player` own native resources. Use the block form
|
|
79
|
+
(`.open`) to close them automatically, or call `#close` yourself; a GC
|
|
80
|
+
finalizer frees the handle as a backstop.
|
|
69
81
|
|
|
70
82
|
## API
|
|
71
83
|
|
|
72
|
-
| Namespace
|
|
73
|
-
|
|
|
74
|
-
| `RockboxFFI::Metadata`
|
|
75
|
-
| `RockboxFFI::Dsp`
|
|
76
|
-
| `RockboxFFI::
|
|
77
|
-
| `RockboxFFI
|
|
84
|
+
| Namespace | Contents |
|
|
85
|
+
| ---------------------- | ------------------------------------------------------------------------------------------ |
|
|
86
|
+
| `RockboxFFI::Metadata` | `read(path) => Hash`, `probe(filename) => String \| nil` |
|
|
87
|
+
| `RockboxFFI::Dsp` | EQ / tone / surround / compressor / ReplayGain, `process(samples)` |
|
|
88
|
+
| `RockboxFFI::Decoder` | codec engine: `metadata`, `each_chunk` / `next_chunk`, `seek_ms`, `elapsed_ms`, `finished` |
|
|
89
|
+
| `RockboxFFI::Player` | queue + transport + crossfade + ReplayGain, `status => Hash` |
|
|
90
|
+
| `RockboxFFI::*Mode` | `DspReplayGainMode`, `ReplayGainMode`, `CrossfadeMode`, `MixMode` |
|
|
78
91
|
|
|
79
92
|
Rich values (metadata, player status) cross the FFI boundary as JSON and come
|
|
80
93
|
back as Hashes with **symbol keys**. Sample buffers are plain `Array<Integer>`
|
data/lib/rockbox_ffi/ffi.rb
CHANGED
|
@@ -115,6 +115,8 @@ module RockboxFFI
|
|
|
115
115
|
extern "void rb_player_set_queue_json(void*, void*)"
|
|
116
116
|
extern "void rb_player_enqueue(void*, void*)"
|
|
117
117
|
extern "void rb_player_insert_json(void*, void*, int32_t, size_t)"
|
|
118
|
+
extern "void rb_player_remove(void*, size_t)"
|
|
119
|
+
extern "void rb_player_clear_queue(void*)"
|
|
118
120
|
extern "void* rb_player_queue_json(void*)"
|
|
119
121
|
extern "void rb_player_play(void*)"
|
|
120
122
|
extern "void rb_player_pause(void*)"
|
data/lib/rockbox_ffi/player.rb
CHANGED
|
@@ -114,6 +114,22 @@ module RockboxFFI
|
|
|
114
114
|
self
|
|
115
115
|
end
|
|
116
116
|
|
|
117
|
+
# Remove the track at +index+ (0-based) from the queue. An out-of-range
|
|
118
|
+
# index is ignored. Removing a track before the current one keeps the
|
|
119
|
+
# current track playing; removing the currently-playing track hard-cuts to
|
|
120
|
+
# the track that slides into its place; removing the last remaining track
|
|
121
|
+
# stops playback.
|
|
122
|
+
def remove(index)
|
|
123
|
+
Lib.rb_player_remove(@ptr, Integer(index))
|
|
124
|
+
self
|
|
125
|
+
end
|
|
126
|
+
|
|
127
|
+
# Empty the queue and stop playback (also clears any saved resume state).
|
|
128
|
+
def clear_queue
|
|
129
|
+
Lib.rb_player_clear_queue(@ptr)
|
|
130
|
+
self
|
|
131
|
+
end
|
|
132
|
+
|
|
117
133
|
# The current queue as an Array of String paths/URLs.
|
|
118
134
|
def queue
|
|
119
135
|
s = RockboxFFI.take_string(Lib.rb_player_queue_json(@ptr))
|
data/lib/rockbox_ffi/version.rb
CHANGED