audio_cpp 0.1.0 → 0.2.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/CHANGELOG.md +8 -1
- data/README.md +58 -8
- data/ext/audio_cpp/builder.rb +18 -10
- data/lib/audio_cpp/native.rb +3 -3
- data/lib/audio_cpp/version.rb +6 -3
- 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: a6494ed8421e649603d5bc2aa6fadd60c4c5b80924bb61634573d4f269f49be9
|
|
4
|
+
data.tar.gz: cbe1920e27d2b40f0f44fd66aca0f0375f92590ddfa0af81975af72890f4ac4f
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3fda6c0fcdb8b5f4b2ea0443c128a7b369c6aefbeb883172dd75fbaec67d4670086d45e521f15e4702eeb8fcbe8d00c4b7f10e6eddc9ca43824146eb477ae031
|
|
7
|
+
data.tar.gz: 1ea6d4dd3fc90fc35d4ada12028fe73a80764aa9ecf91d177b865c79d52819bee4418b639f6002ea6b7dd3e9626b9acb3371f862fe333ab9aa2afc1ede14ca09
|
data/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,13 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## 0.
|
|
3
|
+
## 0.2.0 (2026-12-03)
|
|
4
|
+
|
|
5
|
+
- A build refused because the fetched ref is not the pinned commit now says how to build it anyway (`AUDIOCPP_COMMIT=<sha>`).
|
|
6
|
+
- The default engine is upstream audio.cpp `c3ff640d` (main, 2026-12-03; C ABI 0.5), fetched by commit SHA and verified. The amx-community fork stays available for Intel AMX through `AUDIOCPP_GIT_URL`, `AUDIOCPP_GIT_REF` and `AUDIOCPP_COMMIT` (README, "Intel AMX (optional)").
|
|
7
|
+
- Expected C ABI 0.5; libraries with ABI 0.4 are still accepted. `audiocpp_stream_set_event_callback` (new in 0.5) is not bound; streaming stays pull-based.
|
|
8
|
+
- Behaviour changes against 0.1.0 (built from the fork): word confidence is 0 on upstream (only the fork reports it); GigaAM hotwords, the GigaAM CTC revision and plain openai/whisper checkpoints in `crisperwhisper` are fork additions — build the fork (README, "Intel AMX (optional)") if you need them. On our test files, transcripts, speaker turns and GigaEdge audio are byte-identical to 0.1.0 with the same models; a word start can move by one encoder frame (40 ms).
|
|
9
|
+
|
|
10
|
+
## 0.1.0 (2026-12-03)
|
|
4
11
|
|
|
5
12
|
- First version: FFI bindings to every function of audio.cpp's C API (ABI 0.4), with an ABI check at load.
|
|
6
13
|
- `AudioCpp::Model`, `Session`, `Stream`: block forms, `#close`, GC finalizers without double frees; native calls serialised per model; long calls release the GVL.
|
data/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# audio_cpp
|
|
2
2
|
|
|
3
|
+
[](https://rubygems.org/gems/audio_cpp)
|
|
4
|
+
|
|
3
5
|
Ruby bindings to [audio.cpp](https://github.com/0xShug0/audio.cpp), a C++/ggml runtime for audio models: speech recognition (offline and streaming), speaker diarization, text to speech and more, in-process, on the CPU or a GPU.
|
|
4
6
|
|
|
5
7
|
The gem talks to audio.cpp's stable C API (`include/audiocpp.h`) through [FFI](https://github.com/ffi/ffi) and adds a small Ruby layer on top: models and sessions with deterministic cleanup, results as plain Ruby values, pull-based streaming, and a pure-Ruby WAV reader and writer.
|
|
@@ -12,14 +14,20 @@ Bindings to audio.cpp; not affiliated with its authors.
|
|
|
12
14
|
gem install audio_cpp
|
|
13
15
|
```
|
|
14
16
|
|
|
15
|
-
|
|
17
|
+
or in a Gemfile:
|
|
18
|
+
|
|
19
|
+
```ruby
|
|
20
|
+
gem "audio_cpp", "~> 0.2"
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
The gem ships no prebuilt binary (see [docs/precompiled-gems.md](docs/precompiled-gems.md)): installing it fetches audio.cpp at a pinned commit, verifies the commit SHA, and builds `libaudiocpp` with CMake into the gem's directory. You need `cmake` (3.21+), `git` and a C++17 compiler (Debian/Ubuntu: `apt install cmake g++ git`; macOS: `xcode-select --install && brew install cmake`). `ninja` is used when present.
|
|
16
24
|
|
|
17
25
|
By default the gem builds a short list of popular families (about 1.5 minutes with 8 jobs on a recent x86 server; longer on a laptop):
|
|
18
26
|
|
|
19
27
|
| Family | What |
|
|
20
28
|
|---|---|
|
|
21
29
|
| `gigaam_asr` | GigaAM v3/v4/Multilingual speech recognition, offline and streaming |
|
|
22
|
-
| `crisperwhisper` | Whisper (`openai/whisper-*` checkpoints
|
|
30
|
+
| `crisperwhisper` | CrisperWhisper 2.0, a Whisper model for verbatim transcription, offline and streaming (plain `openai/whisper-*` checkpoints run on this family only in the AMX fork, see below) |
|
|
23
31
|
| `parakeet_tdt` | NVIDIA Parakeet-TDT, offline and streaming |
|
|
24
32
|
| `nemotron_3_diar` | Nemotron 3 Diarization (who spoke when) |
|
|
25
33
|
| `kokoro_tts` | Kokoro 82M text to speech (most languages need eSpeak-ng data, see audio.cpp's `docs/espeak_phonemizer.md`) |
|
|
@@ -59,6 +67,37 @@ Only WAV is read by the gem (16-bit PCM or 32-bit float, any rate and channel co
|
|
|
59
67
|
|
|
60
68
|
## Quick start
|
|
61
69
|
|
|
70
|
+
### Round trip in one file
|
|
71
|
+
|
|
72
|
+
https://github.com/user-attachments/assets/1f143105-a944-4cbc-a741-8dafef4c2d1b
|
|
73
|
+
|
|
74
|
+
[`examples/round_trip.rb`](examples/round_trip.rb) downloads two models, synthesizes a Russian phrase with GigaEdge TTS,
|
|
75
|
+
saves it and recognizes it again with GigaAM-v4 (about 50 lines, every step timed):
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
gem install audio_cpp
|
|
79
|
+
ruby examples/round_trip.rb # models go to ./models; MODELS=dir to reuse a folder
|
|
80
|
+
```
|
|
81
|
+
|
|
82
|
+
A first run on a MacBook Air M1 (the downloads take most of it; a second run starts in under a second):
|
|
83
|
+
|
|
84
|
+
```
|
|
85
|
+
[13:42:43] 1. Models in /Users/you/models
|
|
86
|
+
gigaedge-tts: 207 of 207 MB
|
|
87
|
+
[13:43:04] gigaedge-tts-f16.gguf, 207 MB
|
|
88
|
+
gigaam-v4: 270 of 270 MB
|
|
89
|
+
[13:43:31] gigaam-v4-rnnt-q8_0.gguf, 270 MB
|
|
90
|
+
[13:43:31] done in 47.8 s
|
|
91
|
+
[13:43:31] 2. Synthesizing «Привет! Это проверка синтеза и распознавания речи.»
|
|
92
|
+
[13:43:34] done in 3.4 s
|
|
93
|
+
[13:43:34] 3. Saved /Users/you/demo.wav (4.0 s of speech)
|
|
94
|
+
[13:43:34] 4. Recognizing it
|
|
95
|
+
[13:43:34] done in 0.5 s
|
|
96
|
+
[13:43:34] «Привет! Это проверка синтеза и распознавания речи.»
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
The synthesized phrase from that run: [`examples/round_trip-demo.wav`](examples/round_trip-demo.wav) (4 s, 24 kHz).
|
|
100
|
+
|
|
62
101
|
### Speech recognition
|
|
63
102
|
|
|
64
103
|
```ruby
|
|
@@ -79,7 +118,7 @@ end
|
|
|
79
118
|
|
|
80
119
|
```ruby
|
|
81
120
|
model.session(options: {"gigaam_asr.head" => "raw"}) # lowercase, no punctuation
|
|
82
|
-
session.transcribe(audio, language: "es"
|
|
121
|
+
session.transcribe(audio, language: "es") # Multilingual-v2's language hint
|
|
83
122
|
model.options(:session).map(&:name) # what the model accepts
|
|
84
123
|
```
|
|
85
124
|
|
|
@@ -99,7 +138,7 @@ AudioCpp::Model.load("gigaam-v4-rnnt-q8_0.gguf") do |model|
|
|
|
99
138
|
end
|
|
100
139
|
```
|
|
101
140
|
|
|
102
|
-
Events carry what is new since the previous event. Text a model decodes only when the stream ends is in the `Result` of `finish`, not in an event, so take the final transcript from there. For a whole file there is a shortcut that pushes the model's preferred chunks:
|
|
141
|
+
Events carry what is new since the previous event. Text a model decodes only when the stream ends is in the `Result` of `finish`, not in an event, so take the final transcript from there. The gem pulls events (`audiocpp_stream_push` and `audiocpp_stream_next_event`); it does not bind the push-style `audiocpp_stream_set_event_callback` that C ABI 0.5 added. For a whole file there is a shortcut that pushes the model's preferred chunks:
|
|
103
142
|
|
|
104
143
|
```ruby
|
|
105
144
|
result = session.stream_audio("speech.wav") { |event| print event.text }
|
|
@@ -266,7 +305,7 @@ audio.cpp loads GGUF files (and some families' original safetensors packages). P
|
|
|
266
305
|
|
|
267
306
|
| Model | Family | Where |
|
|
268
307
|
|---|---|---|
|
|
269
|
-
| GigaAM-v4 RNN-T
|
|
308
|
+
| GigaAM-v4 RNN-T (Russian, English; offline and streaming) | `gigaam_asr` | [amx-community/GigaAM-v4-GGUF](https://huggingface.co/amx-community/GigaAM-v4-GGUF) |
|
|
270
309
|
| GigaAM v3, Multilingual, Multilingual-v2 | `gigaam_asr` | [audio-cpp/audio.cpp-gguf](https://huggingface.co/audio-cpp/audio.cpp-gguf/tree/main/GigaAM-ASR-GGUF) |
|
|
271
310
|
| GigaEdge TTS (Russian, two voices) | `gigaedge_tts` | [amx-community/GigaEdge-TTS-GGUF](https://huggingface.co/amx-community/GigaEdge-TTS-GGUF) |
|
|
272
311
|
| Nemotron 3 Diarization (up to 8 speakers) | `nemotron_3_diar` | [audio-cpp/Nemotron-3-Diarization-GGUF](https://huggingface.co/audio-cpp/Nemotron-3-Diarization-GGUF) |
|
|
@@ -288,19 +327,30 @@ Silero VAD ships with audio.cpp; the gem build installs it next to the library,
|
|
|
288
327
|
|
|
289
328
|
## Supported families
|
|
290
329
|
|
|
291
|
-
`AudioCpp.families` lists what the loaded library was built with (the default build has the seven families above, the names Parakeet-TDT also answers to — `fluid_speech`, `haas_asr`, `phonon2_asr`, `underdog_bark3` — and the two VADs). A full build of the pinned commit (`AUDIOCPP_MODELS=full`) has
|
|
330
|
+
`AudioCpp.families` lists what the loaded library was built with (the default build has the seven families above, the names Parakeet-TDT also answers to — `fluid_speech`, `haas_asr`, `phonon2_asr`, `underdog_bark3` — and the two VADs). A full build of the pinned commit (`AUDIOCPP_MODELS=full`) has 165:
|
|
292
331
|
|
|
293
|
-
`ace_step`, `apollo`, `ast_audioset`, `audio8_asr`, `audio8_tts`, `audio_flamingo`, `audiosr`, `auk`, `breeze_tts`, `bs_roformer`, `builtin_audio_utils`, `canary_asr`, `ced`, `chatterbox`, `chatterbox_turbo`, `citrinet_asr`, `cohere_asr`, `confucius4_r2t2`, `confucius4_tts`, `controlfoley`, `cosyvoice3`, `crisperwhisper`, `dettato`, `ditto`, `dots_tts`, `dramabox`, `earshot_vad`, `echo_tts`, `edda_asr`, `f5_tts`, `firered_audio`, `firered_vad`, `fireredtts3`, `fish_audio`, `fish_drama3`, `fluid_speech`, `foundation_1`, `fun_asr_nano`, `gigaam_asr`, `gigaedge_tts`, `glm_tts`, `gradium_phonon`, `granite5asr`, `granite_speech5`, `haas_asr`, `heartmula`, `higgs_audio_stt`, `higgs_audio_tts`, `htdemucs`, `htdemucs_6stems`, `hviske_asr`, `hviske_asr_v6`, `index_echo`, `index_tts2`, `inflect_v2`, `irodori_tts`, `kale_tts`, `kitten_tts`, `kitten_tts2`, `kokoro_tts`, `kroko_asr`, `kugelaudio`, `latentsync`, `lfm2_audio`, `lfm3_audio`, `lfm_d1_omni`, `liveavatar`, `m5_tts`, `magenta_realtime_2`, `magpie_tts`, `marblenet_vad`, `maya1`, `meanvc2`, `mel_band_roformer`, `micro_wake_word`, `midashenglm_gen`, `ming3_audio`, `ming3_tts`, `minimax_h3`, `minimax_music3`, `miocodec`, `miotts`, `mira_tts`, `mms_forced_aligner`, `moonshine_asr`, `moss_soundeffect`, `moss_transcribe_diarize`, `moss_tts_local`, `moss_tts_nano`, `moss_tts_v15`, `moss_ttsd`, `moss_voicegen`, `mossformer2`, `mulacover`, `muscriptor`, `nemo_conformer_ctc`, `nemotron_3_diar`, `nemotron_asr`, `nemotron_transcribe`, `neutts`, `niagara_asr`, `omnivoice`, `open_wake_word`, `outetts`, `owsm`, `owsm_ctc`, `parakeet_tdt`, `personaplex`, `phonon2_asr`, `piper_tts`, `plapre`, `pocket_tts`, `pocket_tts_small`, `pulsevad`, `qwen3_asr`, `qwen3_forced_aligner`, `qwen3_tts`, `realtime_reuse`, `reuse`, `reverb`, `rosvot`, `rvc`, `sam_audio`, `samsone`, `sanotts`, `seed_vc`, `sense_asr`, `sheetsage2`, `sherpa_kws`, `sidon`, `silero_vad`, `smart_turn`, `soprano_tts`, `sopro_tts`, `sortformer_diar`, `sortformer_diar_v2`, `soulx_flashhead`, `soulx_singer`, `stable_audio`, `supertonic`, `talkinghead`, `tf_gridnet`, `tiny_voca`, `tone_color_vc`, `underdog_bark3`, `universr`, `vevo2`, `vibeasr`, `vibevoice`, `vibevoice_asr`, `vibevoice_asr_streaming`, `vieneu_v3_turbo`, `voice_isolator`, `voxcpm1`, `voxcpm2`, `voxmel_tts`, `voxtral_realtime`, `voxtral_tts`, `whistle_asr`, `xtts_v2`, `yue2`, `zipvoice`, `zonos2`, `zonos3`.
|
|
332
|
+
`ace_step`, `apollo`, `ast_audioset`, `audio8_asr`, `audio8_tts`, `audio_flamingo`, `audiosr`, `auk`, `breeze_tts`, `bs_roformer`, `builtin_audio_utils`, `canary_asr`, `ced`, `chatterbox`, `chatterbox_turbo`, `citrinet_asr`, `cohere_asr`, `confucius4_r2t2`, `confucius4_tts`, `controlfoley`, `cosyvoice3`, `crisperwhisper`, `dettato`, `ditto`, `dots_tts`, `dramabox`, `earshot2_vad`, `earshot_vad`, `echo_tts`, `edda_asr`, `f5_tts`, `firered_audio`, `firered_vad`, `fireredtts3`, `fish_audio`, `fish_drama3`, `fluid_speech`, `foundation_1`, `fun_asr_nano`, `gigaam_asr`, `gigaedge_tts`, `glm_tts`, `gradium_phonon`, `granite5asr`, `granite_speech5`, `haas_asr`, `heartmula`, `higgs_audio_stt`, `higgs_audio_tts`, `htdemucs`, `htdemucs_6stems`, `hviske_asr`, `hviske_asr_v6`, `index_echo`, `index_tts2`, `inflect_v2`, `irodori_tts`, `kale_tts`, `kitten_tts`, `kitten_tts2`, `kokoro_tts`, `kroko_asr`, `kugelaudio`, `latentsync`, `lfm2_audio`, `lfm3_audio`, `lfm_d1_omni`, `liveavatar`, `m5_tts`, `magenta_realtime_2`, `magpie_tts`, `marblenet_vad`, `maya1`, `meanvc2`, `mel_band_roformer`, `micro_wake_word`, `midashenglm_gen`, `ming3_audio`, `ming3_tts`, `minimax_h3`, `minimax_music3`, `miocodec`, `miotts`, `mira_tts`, `mms_forced_aligner`, `moonshine_asr`, `moss_soundeffect`, `moss_transcribe_diarize`, `moss_tts_local`, `moss_tts_nano`, `moss_tts_v15`, `moss_ttsd`, `moss_voicegen`, `mossformer2`, `mulacover`, `muscriptor`, `nemo_conformer_ctc`, `nemotron_3_diar`, `nemotron_asr`, `nemotron_transcribe`, `neutts`, `niagara_asr`, `omnivoice`, `open_wake_word`, `outetts`, `owsm`, `owsm_ctc`, `parakeet_tdt`, `personaplex`, `phonon2_asr`, `piper_tts`, `plapre`, `pocket_tts`, `pocket_tts_small`, `pulsevad`, `qwen3_asr`, `qwen3_forced_aligner`, `qwen3_tts`, `realtime_reuse`, `reuse`, `reverb`, `rosvot`, `rvc`, `sam_audio`, `samsone`, `sanotts`, `seed_vc`, `sense_asr`, `sheetsage2`, `sherpa_kws`, `sidon`, `silero_vad`, `smart_turn`, `soprano_tts`, `sopro_tts`, `sortformer_diar`, `sortformer_diar_v2`, `soulx_flashhead`, `soulx_singer`, `stable_audio`, `supertonic`, `talkinghead`, `tf_gridnet`, `tiny_voca`, `tone_color_vc`, `underdog_bark3`, `universr`, `vevo2`, `vibeasr`, `vibevoice`, `vibevoice_asr`, `vibevoice_asr_streaming`, `vieneu_v3_turbo`, `voice_isolator`, `voxcpm1`, `voxcpm2`, `voxmel_tts`, `voxtral_realtime`, `voxtral_tts`, `whistle_asr`, `xtts_v2`, `yue2`, `zipvoice`, `zonos2`, `zonos3`.
|
|
294
333
|
|
|
295
334
|
## Platforms
|
|
296
335
|
|
|
297
|
-
- Linux x86_64, CPU. The
|
|
336
|
+
- Linux x86_64, CPU. The gem builds upstream [0xShug0/audio.cpp](https://github.com/0xShug0/audio.cpp) at a pinned `main` commit; see "Intel AMX (optional)" below for the fork.
|
|
298
337
|
- macOS arm64, CPU or Metal. The library is built with Metal (shaders embedded), but sessions run on the CPU unless you ask: `model.session(backend: "metal")`. The default backend is `"cpu"` on every platform.
|
|
299
338
|
- Other backends (CUDA, Vulkan, ...) through `AUDIOCPP_CMAKE_ARGS`; untested by this gem.
|
|
300
339
|
- Windows is not supported yet.
|
|
301
340
|
|
|
302
341
|
Ruby 3.1 or newer.
|
|
303
342
|
|
|
343
|
+
### Intel AMX (optional)
|
|
344
|
+
|
|
345
|
+
The [amx-community fork](https://github.com/amx-community/audio.cpp) adds Intel AMX paths (Sapphire Rapids and newer Xeons; on other CPUs they stay off) and a few GigaAM and Whisper extras that are not upstream yet: GigaAM-v4 word confidence, hotwords and the `ctc` revision, plain `openai/whisper-*` checkpoints on the `crisperwhisper` family. Its texts are not always bit for bit those of upstream, because the AMX paths round to BF16 or INT8. To build the gem against it:
|
|
346
|
+
|
|
347
|
+
```bash
|
|
348
|
+
AUDIOCPP_GIT_URL=https://github.com/amx-community/audio.cpp.git AUDIOCPP_GIT_REF=amx-2026-12-02-97bf100 \
|
|
349
|
+
AUDIOCPP_COMMIT=dd52d2f1431c9434ffe9b7d3edbba4e47034f9c8 gem install audio_cpp
|
|
350
|
+
```
|
|
351
|
+
|
|
352
|
+
The fork at that tag has C ABI 0.4, which this version of the gem still accepts.
|
|
353
|
+
|
|
304
354
|
## Development
|
|
305
355
|
|
|
306
356
|
```bash
|
data/ext/audio_cpp/builder.rb
CHANGED
|
@@ -7,10 +7,12 @@ require "rbconfig"
|
|
|
7
7
|
require "shellwords"
|
|
8
8
|
|
|
9
9
|
module AudioCppBuild
|
|
10
|
-
# The audio.cpp commit this gem version is built and tested against
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
10
|
+
# The audio.cpp commit this gem version is built and tested against:
|
|
11
|
+
# upstream main (no release tag carries the families this gem tests), fetched
|
|
12
|
+
# by its SHA. Intel AMX users can build the amx-community fork instead, see
|
|
13
|
+
# the README.
|
|
14
|
+
GIT_URL = "https://github.com/0xShug0/audio.cpp.git"
|
|
15
|
+
COMMIT = "c3ff640dba79c584936e1ce6aa058770ff8fc0c9"
|
|
14
16
|
|
|
15
17
|
class BuildError < StandardError; end
|
|
16
18
|
|
|
@@ -28,9 +30,9 @@ module AudioCppBuild
|
|
|
28
30
|
# model targets, e.g. "gigaam_asr,nemotron_3_diar"
|
|
29
31
|
# AUDIOCPP_SOURCE_DIR build this existing checkout instead of fetching
|
|
30
32
|
# AUDIOCPP_GIT_URL fetch from another remote or a local mirror
|
|
31
|
-
# AUDIOCPP_GIT_REF tag or branch to fetch (default:
|
|
32
|
-
# AUDIOCPP_COMMIT full SHA the fetched ref must resolve to
|
|
33
|
-
#
|
|
33
|
+
# AUDIOCPP_GIT_REF tag or branch to fetch (default: AUDIOCPP_COMMIT itself)
|
|
34
|
+
# AUDIOCPP_COMMIT full SHA the fetched ref must resolve to (default:
|
|
35
|
+
# the pinned COMMIT)
|
|
34
36
|
# AUDIOCPP_BUILD_DIR keep sources and the build tree here (reused by
|
|
35
37
|
# later builds); by default a temporary tree is
|
|
36
38
|
# deleted once the library is installed
|
|
@@ -93,8 +95,9 @@ module AudioCppBuild
|
|
|
93
95
|
def fetch
|
|
94
96
|
url = @env.fetch("AUDIOCPP_GIT_URL", GIT_URL)
|
|
95
97
|
commit = @env.fetch("AUDIOCPP_COMMIT", COMMIT)
|
|
96
|
-
#
|
|
97
|
-
ref = @env
|
|
98
|
+
# Without a ref the commit is fetched by its SHA (GitHub serves any reachable one).
|
|
99
|
+
ref = @env["AUDIOCPP_GIT_REF"].to_s.strip
|
|
100
|
+
ref = commit if ref.empty?
|
|
98
101
|
raise BuildError, "AUDIOCPP_COMMIT must be a full 40-character SHA, got #{commit.inspect}" unless commit.match?(/\A\h{40}\z/)
|
|
99
102
|
|
|
100
103
|
source = File.join(@work_dir, "audio.cpp")
|
|
@@ -111,7 +114,12 @@ module AudioCppBuild
|
|
|
111
114
|
sh "git", "-C", source, "-c", "advice.detachedHead=false", "checkout", "--quiet", "FETCH_HEAD"
|
|
112
115
|
actual = head(source)
|
|
113
116
|
unless actual == commit
|
|
114
|
-
|
|
117
|
+
hint = if @env.key?("AUDIOCPP_COMMIT")
|
|
118
|
+
"check that AUDIOCPP_GIT_REF and AUDIOCPP_COMMIT name the same commit"
|
|
119
|
+
else
|
|
120
|
+
"this gem version is tested with #{commit}; to build #{actual} anyway, also set AUDIOCPP_COMMIT=#{actual}"
|
|
121
|
+
end
|
|
122
|
+
raise BuildError, "audio.cpp #{ref} from #{url} is #{actual}, expected #{commit}; refusing to build it (#{hint})"
|
|
115
123
|
end
|
|
116
124
|
|
|
117
125
|
log "audio.cpp verified at #{commit}"
|
data/lib/audio_cpp/native.rb
CHANGED
|
@@ -28,15 +28,15 @@ module AudioCpp
|
|
|
28
28
|
attach_function :audiocpp_abi_version, [], :uint32
|
|
29
29
|
|
|
30
30
|
# Raises AbiMismatchError unless the loaded library has this gem's ABI
|
|
31
|
-
# major and at least
|
|
31
|
+
# major and at least ABI_MIN_MINOR (docs/c_api.md, "Versioning").
|
|
32
32
|
def self.check_abi!(version = audiocpp_abi_version)
|
|
33
33
|
major = version >> 16
|
|
34
34
|
minor = (version >> 8) & 0xff
|
|
35
|
-
return version if major == ABI_MAJOR && minor >=
|
|
35
|
+
return version if major == ABI_MAJOR && minor >= ABI_MIN_MINOR
|
|
36
36
|
|
|
37
37
|
raise AbiMismatchError,
|
|
38
38
|
"#{LIBRARY} has C ABI #{major}.#{minor}.#{version & 0xff}; " \
|
|
39
|
-
"audio_cpp #{VERSION} needs #{ABI_MAJOR}.#{
|
|
39
|
+
"audio_cpp #{VERSION} needs #{ABI_MAJOR}.#{ABI_MIN_MINOR} or a later #{ABI_MAJOR}.x"
|
|
40
40
|
end
|
|
41
41
|
check_abi!
|
|
42
42
|
|
data/lib/audio_cpp/version.rb
CHANGED
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
module AudioCpp
|
|
4
|
-
VERSION = "0.
|
|
4
|
+
VERSION = "0.2.0"
|
|
5
5
|
|
|
6
6
|
# The C ABI these bindings were written against (include/audiocpp.h).
|
|
7
|
-
# A library with another major, or an older minor, is refused at load time.
|
|
8
7
|
ABI_MAJOR = 0
|
|
9
|
-
ABI_MINOR =
|
|
8
|
+
ABI_MINOR = 5
|
|
9
|
+
# The oldest minor they accept: 0.5 only added audiocpp_stream_set_event_callback,
|
|
10
|
+
# which these bindings do not use. Another major, or an older minor, is
|
|
11
|
+
# refused at load time.
|
|
12
|
+
ABI_MIN_MINOR = 4
|
|
10
13
|
end
|