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.
Files changed (143) hide show
  1. checksums.yaml +4 -4
  2. data/LICENSE +21 -0
  3. data/README.md +152 -0
  4. data/ext/audio/audio.c +541 -43
  5. data/ext/audio/audio.h +34 -0
  6. data/ext/audio/delay_node.c +185 -0
  7. data/ext/audio/delay_node.h +51 -0
  8. data/ext/audio/extconf.rb +12 -110
  9. data/ext/audio/miniaudio.h +95844 -0
  10. data/ext/audio/reverb_node.c +224 -0
  11. data/ext/audio/reverb_node.h +63 -0
  12. data/lib/dummy_audio.rb +94 -0
  13. data/lib/native_audio.rb +78 -7
  14. metadata +12 -132
  15. data/assets/include/SDL2/SDL.h +0 -233
  16. data/assets/include/SDL2/SDL_assert.h +0 -326
  17. data/assets/include/SDL2/SDL_atomic.h +0 -415
  18. data/assets/include/SDL2/SDL_audio.h +0 -1500
  19. data/assets/include/SDL2/SDL_bits.h +0 -126
  20. data/assets/include/SDL2/SDL_blendmode.h +0 -198
  21. data/assets/include/SDL2/SDL_clipboard.h +0 -141
  22. data/assets/include/SDL2/SDL_config.h +0 -61
  23. data/assets/include/SDL2/SDL_config_android.h +0 -194
  24. data/assets/include/SDL2/SDL_config_emscripten.h +0 -218
  25. data/assets/include/SDL2/SDL_config_iphoneos.h +0 -217
  26. data/assets/include/SDL2/SDL_config_macosx.h +0 -277
  27. data/assets/include/SDL2/SDL_config_minimal.h +0 -95
  28. data/assets/include/SDL2/SDL_config_ngage.h +0 -89
  29. data/assets/include/SDL2/SDL_config_os2.h +0 -207
  30. data/assets/include/SDL2/SDL_config_pandora.h +0 -141
  31. data/assets/include/SDL2/SDL_config_windows.h +0 -331
  32. data/assets/include/SDL2/SDL_config_wingdk.h +0 -253
  33. data/assets/include/SDL2/SDL_config_winrt.h +0 -220
  34. data/assets/include/SDL2/SDL_config_xbox.h +0 -235
  35. data/assets/include/SDL2/SDL_copying.h +0 -20
  36. data/assets/include/SDL2/SDL_cpuinfo.h +0 -594
  37. data/assets/include/SDL2/SDL_egl.h +0 -2352
  38. data/assets/include/SDL2/SDL_endian.h +0 -348
  39. data/assets/include/SDL2/SDL_error.h +0 -163
  40. data/assets/include/SDL2/SDL_events.h +0 -1166
  41. data/assets/include/SDL2/SDL_filesystem.h +0 -149
  42. data/assets/include/SDL2/SDL_gamecontroller.h +0 -1074
  43. data/assets/include/SDL2/SDL_gesture.h +0 -117
  44. data/assets/include/SDL2/SDL_guid.h +0 -100
  45. data/assets/include/SDL2/SDL_haptic.h +0 -1341
  46. data/assets/include/SDL2/SDL_hidapi.h +0 -451
  47. data/assets/include/SDL2/SDL_hints.h +0 -2569
  48. data/assets/include/SDL2/SDL_image.h +0 -2173
  49. data/assets/include/SDL2/SDL_joystick.h +0 -1066
  50. data/assets/include/SDL2/SDL_keyboard.h +0 -353
  51. data/assets/include/SDL2/SDL_keycode.h +0 -358
  52. data/assets/include/SDL2/SDL_loadso.h +0 -115
  53. data/assets/include/SDL2/SDL_locale.h +0 -103
  54. data/assets/include/SDL2/SDL_log.h +0 -404
  55. data/assets/include/SDL2/SDL_main.h +0 -275
  56. data/assets/include/SDL2/SDL_messagebox.h +0 -193
  57. data/assets/include/SDL2/SDL_metal.h +0 -113
  58. data/assets/include/SDL2/SDL_misc.h +0 -79
  59. data/assets/include/SDL2/SDL_mixer.h +0 -2784
  60. data/assets/include/SDL2/SDL_mouse.h +0 -465
  61. data/assets/include/SDL2/SDL_mutex.h +0 -471
  62. data/assets/include/SDL2/SDL_name.h +0 -33
  63. data/assets/include/SDL2/SDL_opengl.h +0 -2132
  64. data/assets/include/SDL2/SDL_opengl_glext.h +0 -13209
  65. data/assets/include/SDL2/SDL_opengles.h +0 -39
  66. data/assets/include/SDL2/SDL_opengles2.h +0 -52
  67. data/assets/include/SDL2/SDL_opengles2_gl2.h +0 -656
  68. data/assets/include/SDL2/SDL_opengles2_gl2ext.h +0 -4033
  69. data/assets/include/SDL2/SDL_opengles2_gl2platform.h +0 -27
  70. data/assets/include/SDL2/SDL_opengles2_khrplatform.h +0 -311
  71. data/assets/include/SDL2/SDL_pixels.h +0 -644
  72. data/assets/include/SDL2/SDL_platform.h +0 -261
  73. data/assets/include/SDL2/SDL_power.h +0 -88
  74. data/assets/include/SDL2/SDL_quit.h +0 -58
  75. data/assets/include/SDL2/SDL_rect.h +0 -376
  76. data/assets/include/SDL2/SDL_render.h +0 -1919
  77. data/assets/include/SDL2/SDL_revision.h +0 -6
  78. data/assets/include/SDL2/SDL_rwops.h +0 -841
  79. data/assets/include/SDL2/SDL_scancode.h +0 -438
  80. data/assets/include/SDL2/SDL_sensor.h +0 -322
  81. data/assets/include/SDL2/SDL_shape.h +0 -155
  82. data/assets/include/SDL2/SDL_stdinc.h +0 -830
  83. data/assets/include/SDL2/SDL_surface.h +0 -997
  84. data/assets/include/SDL2/SDL_system.h +0 -623
  85. data/assets/include/SDL2/SDL_syswm.h +0 -386
  86. data/assets/include/SDL2/SDL_test.h +0 -69
  87. data/assets/include/SDL2/SDL_test_assert.h +0 -105
  88. data/assets/include/SDL2/SDL_test_common.h +0 -236
  89. data/assets/include/SDL2/SDL_test_compare.h +0 -69
  90. data/assets/include/SDL2/SDL_test_crc32.h +0 -124
  91. data/assets/include/SDL2/SDL_test_font.h +0 -168
  92. data/assets/include/SDL2/SDL_test_fuzzer.h +0 -386
  93. data/assets/include/SDL2/SDL_test_harness.h +0 -134
  94. data/assets/include/SDL2/SDL_test_images.h +0 -78
  95. data/assets/include/SDL2/SDL_test_log.h +0 -67
  96. data/assets/include/SDL2/SDL_test_md5.h +0 -129
  97. data/assets/include/SDL2/SDL_test_memory.h +0 -63
  98. data/assets/include/SDL2/SDL_test_random.h +0 -115
  99. data/assets/include/SDL2/SDL_thread.h +0 -464
  100. data/assets/include/SDL2/SDL_timer.h +0 -222
  101. data/assets/include/SDL2/SDL_touch.h +0 -150
  102. data/assets/include/SDL2/SDL_ttf.h +0 -2316
  103. data/assets/include/SDL2/SDL_types.h +0 -29
  104. data/assets/include/SDL2/SDL_version.h +0 -204
  105. data/assets/include/SDL2/SDL_video.h +0 -2150
  106. data/assets/include/SDL2/SDL_vulkan.h +0 -215
  107. data/assets/include/SDL2/begin_code.h +0 -187
  108. data/assets/include/SDL2/close_code.h +0 -40
  109. data/assets/macos/universal/lib/libFLAC.a +0 -0
  110. data/assets/macos/universal/lib/libSDL2.a +0 -0
  111. data/assets/macos/universal/lib/libSDL2_mixer.a +0 -0
  112. data/assets/macos/universal/lib/libmodplug.a +0 -0
  113. data/assets/macos/universal/lib/libmpg123.a +0 -0
  114. data/assets/macos/universal/lib/libogg.a +0 -0
  115. data/assets/macos/universal/lib/libvorbis.a +0 -0
  116. data/assets/macos/universal/lib/libvorbisfile.a +0 -0
  117. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libFLAC.a +0 -0
  118. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libSDL2.a +0 -0
  119. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libSDL2_mixer.a +0 -0
  120. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libmodplug.a +0 -0
  121. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libmpg123.a +0 -0
  122. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libogg.a +0 -0
  123. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libopus.a +0 -0
  124. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libopusfile.a +0 -0
  125. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libsndfile.a +0 -0
  126. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libstdc++.a +0 -0
  127. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libvorbis.a +0 -0
  128. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libvorbisfile.a +0 -0
  129. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libz.a +0 -0
  130. data/assets/windows/mingw-w64-x86_64/lib/libFLAC.a +0 -0
  131. data/assets/windows/mingw-w64-x86_64/lib/libSDL2.a +0 -0
  132. data/assets/windows/mingw-w64-x86_64/lib/libSDL2_mixer.a +0 -0
  133. data/assets/windows/mingw-w64-x86_64/lib/libmodplug.a +0 -0
  134. data/assets/windows/mingw-w64-x86_64/lib/libmpg123.a +0 -0
  135. data/assets/windows/mingw-w64-x86_64/lib/libogg.a +0 -0
  136. data/assets/windows/mingw-w64-x86_64/lib/libopus.a +0 -0
  137. data/assets/windows/mingw-w64-x86_64/lib/libopusfile.a +0 -0
  138. data/assets/windows/mingw-w64-x86_64/lib/libsndfile.a +0 -0
  139. data/assets/windows/mingw-w64-x86_64/lib/libstdc++.a +0 -0
  140. data/assets/windows/mingw-w64-x86_64/lib/libvorbis.a +0 -0
  141. data/assets/windows/mingw-w64-x86_64/lib/libvorbisfile.a +0 -0
  142. data/assets/windows/mingw-w64-x86_64/lib/libz.a +0 -0
  143. data/ext/audio/extconf.h +0 -3
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 3bf44a7a337d94bcc47dc2cb5904837cd36984e9ea1b80768d1c5f624cc77dc3
4
- data.tar.gz: ddaece9c35182a2935d4c1d3f1da13d9dbfb7d4f2c0e41b385da8216b2927b05
3
+ metadata.gz: a9a953a3fe6e4bd23e99278c28dbd273bc08268105382a4dae34854e3917aa64
4
+ data.tar.gz: af2a5c84a91fa2957984d4c36637bbe914f38fab7d26903406051eb2456dbc96
5
5
  SHA512:
6
- metadata.gz: d11e81e4ecd9de4b8eef28dbcc5a9405e6b366117c11971e74bbaa683ea40ce5751be264d23ca04a0f099e02435f5b84eea405cc0fc0f0f0dc26a07d277622a3
7
- data.tar.gz: 71b722055b3d9ed5054bad005470828a691f7d1082723c0237645930a816923d77de97d4a681a89d68bbbb9b8f818cf987b196f761dea9beba874bf7de394839
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"