native_audio 0.3.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/LICENSE +21 -0
- data/README.md +152 -0
- data/ext/audio/audio.c +541 -43
- data/ext/audio/audio.h +34 -0
- data/ext/audio/delay_node.c +185 -0
- data/ext/audio/delay_node.h +51 -0
- data/ext/audio/extconf.rb +12 -110
- data/ext/audio/miniaudio.h +95844 -0
- data/ext/audio/reverb_node.c +224 -0
- data/ext/audio/reverb_node.h +63 -0
- data/lib/dummy_audio.rb +94 -0
- data/lib/native_audio.rb +78 -7
- metadata +12 -132
- data/assets/include/SDL2/SDL.h +0 -233
- data/assets/include/SDL2/SDL_assert.h +0 -326
- data/assets/include/SDL2/SDL_atomic.h +0 -415
- data/assets/include/SDL2/SDL_audio.h +0 -1500
- data/assets/include/SDL2/SDL_bits.h +0 -126
- data/assets/include/SDL2/SDL_blendmode.h +0 -198
- data/assets/include/SDL2/SDL_clipboard.h +0 -141
- data/assets/include/SDL2/SDL_config.h +0 -61
- data/assets/include/SDL2/SDL_config_android.h +0 -194
- data/assets/include/SDL2/SDL_config_emscripten.h +0 -218
- data/assets/include/SDL2/SDL_config_iphoneos.h +0 -217
- data/assets/include/SDL2/SDL_config_macosx.h +0 -277
- data/assets/include/SDL2/SDL_config_minimal.h +0 -95
- data/assets/include/SDL2/SDL_config_ngage.h +0 -89
- data/assets/include/SDL2/SDL_config_os2.h +0 -207
- data/assets/include/SDL2/SDL_config_pandora.h +0 -141
- data/assets/include/SDL2/SDL_config_windows.h +0 -331
- data/assets/include/SDL2/SDL_config_wingdk.h +0 -253
- data/assets/include/SDL2/SDL_config_winrt.h +0 -220
- data/assets/include/SDL2/SDL_config_xbox.h +0 -235
- data/assets/include/SDL2/SDL_copying.h +0 -20
- data/assets/include/SDL2/SDL_cpuinfo.h +0 -594
- data/assets/include/SDL2/SDL_egl.h +0 -2352
- data/assets/include/SDL2/SDL_endian.h +0 -348
- data/assets/include/SDL2/SDL_error.h +0 -163
- data/assets/include/SDL2/SDL_events.h +0 -1166
- data/assets/include/SDL2/SDL_filesystem.h +0 -149
- data/assets/include/SDL2/SDL_gamecontroller.h +0 -1074
- data/assets/include/SDL2/SDL_gesture.h +0 -117
- data/assets/include/SDL2/SDL_guid.h +0 -100
- data/assets/include/SDL2/SDL_haptic.h +0 -1341
- data/assets/include/SDL2/SDL_hidapi.h +0 -451
- data/assets/include/SDL2/SDL_hints.h +0 -2569
- data/assets/include/SDL2/SDL_image.h +0 -2173
- data/assets/include/SDL2/SDL_joystick.h +0 -1066
- data/assets/include/SDL2/SDL_keyboard.h +0 -353
- data/assets/include/SDL2/SDL_keycode.h +0 -358
- data/assets/include/SDL2/SDL_loadso.h +0 -115
- data/assets/include/SDL2/SDL_locale.h +0 -103
- data/assets/include/SDL2/SDL_log.h +0 -404
- data/assets/include/SDL2/SDL_main.h +0 -275
- data/assets/include/SDL2/SDL_messagebox.h +0 -193
- data/assets/include/SDL2/SDL_metal.h +0 -113
- data/assets/include/SDL2/SDL_misc.h +0 -79
- data/assets/include/SDL2/SDL_mixer.h +0 -2784
- data/assets/include/SDL2/SDL_mouse.h +0 -465
- data/assets/include/SDL2/SDL_mutex.h +0 -471
- data/assets/include/SDL2/SDL_name.h +0 -33
- data/assets/include/SDL2/SDL_opengl.h +0 -2132
- data/assets/include/SDL2/SDL_opengl_glext.h +0 -13209
- data/assets/include/SDL2/SDL_opengles.h +0 -39
- data/assets/include/SDL2/SDL_opengles2.h +0 -52
- data/assets/include/SDL2/SDL_opengles2_gl2.h +0 -656
- data/assets/include/SDL2/SDL_opengles2_gl2ext.h +0 -4033
- data/assets/include/SDL2/SDL_opengles2_gl2platform.h +0 -27
- data/assets/include/SDL2/SDL_opengles2_khrplatform.h +0 -311
- data/assets/include/SDL2/SDL_pixels.h +0 -644
- data/assets/include/SDL2/SDL_platform.h +0 -261
- data/assets/include/SDL2/SDL_power.h +0 -88
- data/assets/include/SDL2/SDL_quit.h +0 -58
- data/assets/include/SDL2/SDL_rect.h +0 -376
- data/assets/include/SDL2/SDL_render.h +0 -1919
- data/assets/include/SDL2/SDL_revision.h +0 -6
- data/assets/include/SDL2/SDL_rwops.h +0 -841
- data/assets/include/SDL2/SDL_scancode.h +0 -438
- data/assets/include/SDL2/SDL_sensor.h +0 -322
- data/assets/include/SDL2/SDL_shape.h +0 -155
- data/assets/include/SDL2/SDL_stdinc.h +0 -830
- data/assets/include/SDL2/SDL_surface.h +0 -997
- data/assets/include/SDL2/SDL_system.h +0 -623
- data/assets/include/SDL2/SDL_syswm.h +0 -386
- data/assets/include/SDL2/SDL_test.h +0 -69
- data/assets/include/SDL2/SDL_test_assert.h +0 -105
- data/assets/include/SDL2/SDL_test_common.h +0 -236
- data/assets/include/SDL2/SDL_test_compare.h +0 -69
- data/assets/include/SDL2/SDL_test_crc32.h +0 -124
- data/assets/include/SDL2/SDL_test_font.h +0 -168
- data/assets/include/SDL2/SDL_test_fuzzer.h +0 -386
- data/assets/include/SDL2/SDL_test_harness.h +0 -134
- data/assets/include/SDL2/SDL_test_images.h +0 -78
- data/assets/include/SDL2/SDL_test_log.h +0 -67
- data/assets/include/SDL2/SDL_test_md5.h +0 -129
- data/assets/include/SDL2/SDL_test_memory.h +0 -63
- data/assets/include/SDL2/SDL_test_random.h +0 -115
- data/assets/include/SDL2/SDL_thread.h +0 -464
- data/assets/include/SDL2/SDL_timer.h +0 -222
- data/assets/include/SDL2/SDL_touch.h +0 -150
- data/assets/include/SDL2/SDL_ttf.h +0 -2316
- data/assets/include/SDL2/SDL_types.h +0 -29
- data/assets/include/SDL2/SDL_version.h +0 -204
- data/assets/include/SDL2/SDL_video.h +0 -2150
- data/assets/include/SDL2/SDL_vulkan.h +0 -215
- data/assets/include/SDL2/begin_code.h +0 -187
- data/assets/include/SDL2/close_code.h +0 -40
- data/assets/macos/universal/lib/libFLAC.a +0 -0
- data/assets/macos/universal/lib/libSDL2.a +0 -0
- data/assets/macos/universal/lib/libSDL2_mixer.a +0 -0
- data/assets/macos/universal/lib/libmodplug.a +0 -0
- data/assets/macos/universal/lib/libmpg123.a +0 -0
- data/assets/macos/universal/lib/libogg.a +0 -0
- data/assets/macos/universal/lib/libvorbis.a +0 -0
- data/assets/macos/universal/lib/libvorbisfile.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libFLAC.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libSDL2.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libSDL2_mixer.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libmodplug.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libmpg123.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libogg.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libopus.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libopusfile.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libsndfile.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libstdc++.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libvorbis.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libvorbisfile.a +0 -0
- data/assets/windows/mingw-w64-ucrt-x86_64/lib/libz.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libFLAC.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libSDL2.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libSDL2_mixer.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libmodplug.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libmpg123.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libogg.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libopus.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libopusfile.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libsndfile.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libstdc++.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libvorbis.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libvorbisfile.a +0 -0
- data/assets/windows/mingw-w64-x86_64/lib/libz.a +0 -0
- data/ext/audio/extconf.h +0 -3
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: a9a953a3fe6e4bd23e99278c28dbd273bc08268105382a4dae34854e3917aa64
|
|
4
|
+
data.tar.gz: af2a5c84a91fa2957984d4c36637bbe914f38fab7d26903406051eb2456dbc96
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: '094beb2919f1a5e0b9e18ea7ac5e5776f5f5ed5eb213f9aac5c976ec3e74cb740ba73632f3bab2acb589afc4d2f12a1fe8485b3ddd59b5bc71d8d21fa758f357'
|
|
7
|
+
data.tar.gz: b0c335b765410df6cfbae2a730f921388e5761639f96b329113ef398527dd46f9067680a55e0fb7541cf801784158f07b744f07e9570251ea0485503b573c81f
|
data/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2025 Max Hatfull
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
data/README.md
ADDED
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
# What is native_audio?
|
|
2
|
+
|
|
3
|
+
Native audio is a thin wrapper around miniaudio for simple audio playback from Ruby, with built-in support for delay and reverb effects.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
Add this line to your application's Gemfile:
|
|
8
|
+
|
|
9
|
+
```ruby
|
|
10
|
+
gem 'native_audio'
|
|
11
|
+
```
|
|
12
|
+
And then execute:
|
|
13
|
+
|
|
14
|
+
$ bundle
|
|
15
|
+
|
|
16
|
+
## Usage
|
|
17
|
+
|
|
18
|
+
```ruby
|
|
19
|
+
require 'native_audio'
|
|
20
|
+
|
|
21
|
+
# Load a clip
|
|
22
|
+
clip = NativeAudio::Clip.new('path/to/sound.wav')
|
|
23
|
+
|
|
24
|
+
# Check duration
|
|
25
|
+
clip.duration # => seconds
|
|
26
|
+
|
|
27
|
+
# Create an audio source to manage playback
|
|
28
|
+
source = NativeAudio::AudioSource.new(clip)
|
|
29
|
+
|
|
30
|
+
# Play the clip
|
|
31
|
+
source.play
|
|
32
|
+
|
|
33
|
+
# Pause and resume
|
|
34
|
+
source.pause
|
|
35
|
+
source.resume
|
|
36
|
+
|
|
37
|
+
# Set pitch (1.0 = normal, 0.5 = octave down, 2.0 = octave up)
|
|
38
|
+
source.set_pitch(1.5)
|
|
39
|
+
|
|
40
|
+
# Set position relative to listener (angle: 0-360, distance: 0-255)
|
|
41
|
+
source.set_pos(90, 200) # right side, mid distance
|
|
42
|
+
|
|
43
|
+
# Set volume (0-128)
|
|
44
|
+
source.set_volume(64)
|
|
45
|
+
|
|
46
|
+
# Loop playback
|
|
47
|
+
source.set_looping(true)
|
|
48
|
+
|
|
49
|
+
# Stop the clip
|
|
50
|
+
source.stop
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## Effects
|
|
54
|
+
|
|
55
|
+
Each audio source has a built-in effects chain:
|
|
56
|
+
|
|
57
|
+
```
|
|
58
|
+
sound ──▶ delay ──▶ reverb ──▶ output
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
### Delay Taps
|
|
62
|
+
|
|
63
|
+
Add discrete echo effects with up to 16 taps per source:
|
|
64
|
+
|
|
65
|
+
```ruby
|
|
66
|
+
source.play
|
|
67
|
+
|
|
68
|
+
# Add delay taps (returns a DelayTap object)
|
|
69
|
+
tap1 = source.add_delay_tap(time_ms: 200, volume: 0.5)
|
|
70
|
+
tap2 = source.add_delay_tap(time_ms: 400, volume: 0.3)
|
|
71
|
+
|
|
72
|
+
# Modify taps at runtime
|
|
73
|
+
tap1.volume = 0.4
|
|
74
|
+
tap1.time_ms = 250
|
|
75
|
+
|
|
76
|
+
# Remove a tap
|
|
77
|
+
tap2.remove
|
|
78
|
+
|
|
79
|
+
# Query active taps
|
|
80
|
+
source.delay_taps # => [tap1]
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
### Reverb
|
|
84
|
+
|
|
85
|
+
Add room ambience with a Schroeder reverb:
|
|
86
|
+
|
|
87
|
+
```ruby
|
|
88
|
+
source.play
|
|
89
|
+
|
|
90
|
+
# Enable reverb with custom settings
|
|
91
|
+
source.set_reverb(
|
|
92
|
+
room_size: 0.7, # 0.0 = small room, 1.0 = large hall
|
|
93
|
+
damping: 0.5, # 0.0 = bright, 1.0 = muffled
|
|
94
|
+
wet: 0.4, # reverb signal level
|
|
95
|
+
dry: 1.0 # original signal level
|
|
96
|
+
)
|
|
97
|
+
|
|
98
|
+
# Or just enable with defaults
|
|
99
|
+
source.enable_reverb
|
|
100
|
+
source.enable_reverb(false) # disable
|
|
101
|
+
```
|
|
102
|
+
|
|
103
|
+
### Combining Effects
|
|
104
|
+
|
|
105
|
+
Delay and reverb work together - each echo gets reverb applied:
|
|
106
|
+
|
|
107
|
+
```ruby
|
|
108
|
+
source.play
|
|
109
|
+
|
|
110
|
+
# Slapback echo with room reverb
|
|
111
|
+
source.add_delay_tap(time_ms: 150, volume: 0.4)
|
|
112
|
+
source.set_reverb(room_size: 0.5, wet: 0.3, dry: 1.0)
|
|
113
|
+
```
|
|
114
|
+
|
|
115
|
+
## Environment Variables
|
|
116
|
+
|
|
117
|
+
### `NATIVE_AUDIO_DRIVER`
|
|
118
|
+
|
|
119
|
+
Set `NATIVE_AUDIO_DRIVER=null` to use miniaudio's null backend. This initializes the audio engine but outputs no sound - useful for CI/testing on systems without audio hardware.
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
NATIVE_AUDIO_DRIVER=null ruby your_script.rb
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### `DUMMY_AUDIO_BACKEND`
|
|
126
|
+
|
|
127
|
+
Set `DUMMY_AUDIO_BACKEND=true` to bypass miniaudio entirely and use a pure Ruby dummy backend. The C extension still loads (validating it compiles correctly), but no audio engine is initialized and all audio calls are no-ops.
|
|
128
|
+
|
|
129
|
+
```bash
|
|
130
|
+
DUMMY_AUDIO_BACKEND=true ruby your_script.rb
|
|
131
|
+
```
|
|
132
|
+
|
|
133
|
+
> **Note:** On Windows Server (e.g., GitHub Actions runners), miniaudio's null backend crashes due to threading issues in headless environments. Use `DUMMY_AUDIO_BACKEND=true` instead. macOS and Linux work fine with `NATIVE_AUDIO_DRIVER=null`.
|
|
134
|
+
|
|
135
|
+
## Development
|
|
136
|
+
|
|
137
|
+
```bash
|
|
138
|
+
bundle install
|
|
139
|
+
bundle exec rake compile
|
|
140
|
+
```
|
|
141
|
+
|
|
142
|
+
To test:
|
|
143
|
+
|
|
144
|
+
```bash
|
|
145
|
+
ruby test_audio.rb
|
|
146
|
+
```
|
|
147
|
+
|
|
148
|
+
## Releasing
|
|
149
|
+
|
|
150
|
+
1. Update the version in `native_audio.gemspec`
|
|
151
|
+
2. Go to GitHub Actions → "Release to RubyGems"
|
|
152
|
+
3. Click "Run workflow" → "Run workflow"
|