native_audio 0.1.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 (156) hide show
  1. checksums.yaml +7 -0
  2. data/assets/include/GL/glew.h +26427 -0
  3. data/assets/include/GLES2/gl2.h +656 -0
  4. data/assets/include/GLES2/gl2ext.h +3949 -0
  5. data/assets/include/GLES2/gl2ext_angle.h +701 -0
  6. data/assets/include/GLES2/gl2platform.h +27 -0
  7. data/assets/include/GLES3/gl3.h +1192 -0
  8. data/assets/include/GLES3/gl31.h +1507 -0
  9. data/assets/include/GLES3/gl32.h +1808 -0
  10. data/assets/include/GLES3/gl3platform.h +27 -0
  11. data/assets/include/KHR/khrplatform.h +290 -0
  12. data/assets/include/SDL2/SDL.h +233 -0
  13. data/assets/include/SDL2/SDL_assert.h +326 -0
  14. data/assets/include/SDL2/SDL_atomic.h +415 -0
  15. data/assets/include/SDL2/SDL_audio.h +1500 -0
  16. data/assets/include/SDL2/SDL_bits.h +126 -0
  17. data/assets/include/SDL2/SDL_blendmode.h +198 -0
  18. data/assets/include/SDL2/SDL_clipboard.h +141 -0
  19. data/assets/include/SDL2/SDL_config.h +61 -0
  20. data/assets/include/SDL2/SDL_config_android.h +194 -0
  21. data/assets/include/SDL2/SDL_config_emscripten.h +218 -0
  22. data/assets/include/SDL2/SDL_config_iphoneos.h +217 -0
  23. data/assets/include/SDL2/SDL_config_macosx.h +277 -0
  24. data/assets/include/SDL2/SDL_config_minimal.h +95 -0
  25. data/assets/include/SDL2/SDL_config_ngage.h +89 -0
  26. data/assets/include/SDL2/SDL_config_os2.h +207 -0
  27. data/assets/include/SDL2/SDL_config_pandora.h +141 -0
  28. data/assets/include/SDL2/SDL_config_windows.h +331 -0
  29. data/assets/include/SDL2/SDL_config_wingdk.h +253 -0
  30. data/assets/include/SDL2/SDL_config_winrt.h +220 -0
  31. data/assets/include/SDL2/SDL_config_xbox.h +235 -0
  32. data/assets/include/SDL2/SDL_copying.h +20 -0
  33. data/assets/include/SDL2/SDL_cpuinfo.h +594 -0
  34. data/assets/include/SDL2/SDL_egl.h +2352 -0
  35. data/assets/include/SDL2/SDL_endian.h +348 -0
  36. data/assets/include/SDL2/SDL_error.h +163 -0
  37. data/assets/include/SDL2/SDL_events.h +1166 -0
  38. data/assets/include/SDL2/SDL_filesystem.h +149 -0
  39. data/assets/include/SDL2/SDL_gamecontroller.h +1074 -0
  40. data/assets/include/SDL2/SDL_gesture.h +117 -0
  41. data/assets/include/SDL2/SDL_guid.h +100 -0
  42. data/assets/include/SDL2/SDL_haptic.h +1341 -0
  43. data/assets/include/SDL2/SDL_hidapi.h +451 -0
  44. data/assets/include/SDL2/SDL_hints.h +2569 -0
  45. data/assets/include/SDL2/SDL_image.h +2173 -0
  46. data/assets/include/SDL2/SDL_joystick.h +1066 -0
  47. data/assets/include/SDL2/SDL_keyboard.h +353 -0
  48. data/assets/include/SDL2/SDL_keycode.h +358 -0
  49. data/assets/include/SDL2/SDL_loadso.h +115 -0
  50. data/assets/include/SDL2/SDL_locale.h +103 -0
  51. data/assets/include/SDL2/SDL_log.h +404 -0
  52. data/assets/include/SDL2/SDL_main.h +275 -0
  53. data/assets/include/SDL2/SDL_messagebox.h +193 -0
  54. data/assets/include/SDL2/SDL_metal.h +113 -0
  55. data/assets/include/SDL2/SDL_misc.h +79 -0
  56. data/assets/include/SDL2/SDL_mixer.h +2784 -0
  57. data/assets/include/SDL2/SDL_mouse.h +465 -0
  58. data/assets/include/SDL2/SDL_mutex.h +471 -0
  59. data/assets/include/SDL2/SDL_name.h +33 -0
  60. data/assets/include/SDL2/SDL_opengl.h +2132 -0
  61. data/assets/include/SDL2/SDL_opengl_glext.h +13209 -0
  62. data/assets/include/SDL2/SDL_opengles.h +39 -0
  63. data/assets/include/SDL2/SDL_opengles2.h +52 -0
  64. data/assets/include/SDL2/SDL_opengles2_gl2.h +656 -0
  65. data/assets/include/SDL2/SDL_opengles2_gl2ext.h +4033 -0
  66. data/assets/include/SDL2/SDL_opengles2_gl2platform.h +27 -0
  67. data/assets/include/SDL2/SDL_opengles2_khrplatform.h +311 -0
  68. data/assets/include/SDL2/SDL_pixels.h +644 -0
  69. data/assets/include/SDL2/SDL_platform.h +261 -0
  70. data/assets/include/SDL2/SDL_power.h +88 -0
  71. data/assets/include/SDL2/SDL_quit.h +58 -0
  72. data/assets/include/SDL2/SDL_rect.h +376 -0
  73. data/assets/include/SDL2/SDL_render.h +1919 -0
  74. data/assets/include/SDL2/SDL_revision.h +6 -0
  75. data/assets/include/SDL2/SDL_rwops.h +841 -0
  76. data/assets/include/SDL2/SDL_scancode.h +438 -0
  77. data/assets/include/SDL2/SDL_sensor.h +322 -0
  78. data/assets/include/SDL2/SDL_shape.h +155 -0
  79. data/assets/include/SDL2/SDL_stdinc.h +830 -0
  80. data/assets/include/SDL2/SDL_surface.h +997 -0
  81. data/assets/include/SDL2/SDL_system.h +623 -0
  82. data/assets/include/SDL2/SDL_syswm.h +386 -0
  83. data/assets/include/SDL2/SDL_test.h +69 -0
  84. data/assets/include/SDL2/SDL_test_assert.h +105 -0
  85. data/assets/include/SDL2/SDL_test_common.h +236 -0
  86. data/assets/include/SDL2/SDL_test_compare.h +69 -0
  87. data/assets/include/SDL2/SDL_test_crc32.h +124 -0
  88. data/assets/include/SDL2/SDL_test_font.h +168 -0
  89. data/assets/include/SDL2/SDL_test_fuzzer.h +386 -0
  90. data/assets/include/SDL2/SDL_test_harness.h +134 -0
  91. data/assets/include/SDL2/SDL_test_images.h +78 -0
  92. data/assets/include/SDL2/SDL_test_log.h +67 -0
  93. data/assets/include/SDL2/SDL_test_md5.h +129 -0
  94. data/assets/include/SDL2/SDL_test_memory.h +63 -0
  95. data/assets/include/SDL2/SDL_test_random.h +115 -0
  96. data/assets/include/SDL2/SDL_thread.h +464 -0
  97. data/assets/include/SDL2/SDL_timer.h +222 -0
  98. data/assets/include/SDL2/SDL_touch.h +150 -0
  99. data/assets/include/SDL2/SDL_ttf.h +2316 -0
  100. data/assets/include/SDL2/SDL_types.h +29 -0
  101. data/assets/include/SDL2/SDL_version.h +204 -0
  102. data/assets/include/SDL2/SDL_video.h +2150 -0
  103. data/assets/include/SDL2/SDL_vulkan.h +215 -0
  104. data/assets/include/SDL2/begin_code.h +187 -0
  105. data/assets/include/SDL2/close_code.h +40 -0
  106. data/assets/macos/universal/lib/libFLAC.a +0 -0
  107. data/assets/macos/universal/lib/libSDL2.a +0 -0
  108. data/assets/macos/universal/lib/libSDL2_image.a +0 -0
  109. data/assets/macos/universal/lib/libSDL2_mixer.a +0 -0
  110. data/assets/macos/universal/lib/libSDL2_ttf.a +0 -0
  111. data/assets/macos/universal/lib/libmodplug.a +0 -0
  112. data/assets/macos/universal/lib/libmpg123.a +0 -0
  113. data/assets/macos/universal/lib/libogg.a +0 -0
  114. data/assets/macos/universal/lib/libvorbis.a +0 -0
  115. data/assets/macos/universal/lib/libvorbisfile.a +0 -0
  116. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libFLAC.a +0 -0
  117. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libSDL2.a +0 -0
  118. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libSDL2_mixer.a +0 -0
  119. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libglew32.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/libssp.a +1 -0
  127. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libstdc++.a +0 -0
  128. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libvorbis.a +0 -0
  129. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libvorbisfile.a +0 -0
  130. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libz.a +0 -0
  131. data/assets/windows/mingw-w64-ucrt-x86_64/lib/libzstd.a +0 -0
  132. data/assets/windows/mingw-w64-x86_64/lib/libFLAC.a +0 -0
  133. data/assets/windows/mingw-w64-x86_64/lib/libSDL2.a +0 -0
  134. data/assets/windows/mingw-w64-x86_64/lib/libSDL2_mixer.a +0 -0
  135. data/assets/windows/mingw-w64-x86_64/lib/libglew32.a +0 -0
  136. data/assets/windows/mingw-w64-x86_64/lib/libmodplug.a +0 -0
  137. data/assets/windows/mingw-w64-x86_64/lib/libmpg123.a +0 -0
  138. data/assets/windows/mingw-w64-x86_64/lib/libogg.a +0 -0
  139. data/assets/windows/mingw-w64-x86_64/lib/libopus.a +0 -0
  140. data/assets/windows/mingw-w64-x86_64/lib/libopusfile.a +0 -0
  141. data/assets/windows/mingw-w64-x86_64/lib/libsndfile.a +0 -0
  142. data/assets/windows/mingw-w64-x86_64/lib/libssp.a +1 -0
  143. data/assets/windows/mingw-w64-x86_64/lib/libstdc++.a +0 -0
  144. data/assets/windows/mingw-w64-x86_64/lib/libvorbis.a +0 -0
  145. data/assets/windows/mingw-w64-x86_64/lib/libvorbisfile.a +0 -0
  146. data/assets/windows/mingw-w64-x86_64/lib/libz.a +0 -0
  147. data/assets/windows/mingw-w64-x86_64/lib/libzstd.a +0 -0
  148. data/ext/Makefile +270 -0
  149. data/ext/audio.c +80 -0
  150. data/ext/audio.o +0 -0
  151. data/ext/extconf.h +3 -0
  152. data/ext/extconf.rb +177 -0
  153. data/ext/mkmf.log +7 -0
  154. data/lib/audio.bundle +0 -0
  155. data/lib/native_audio.rb +50 -0
  156. metadata +198 -0
data/ext/Makefile ADDED
@@ -0,0 +1,270 @@
1
+
2
+ SHELL = /bin/sh
3
+
4
+ # V=0 quiet, V=1 verbose. other values don't work.
5
+ V = 0
6
+ V0 = $(V:0=)
7
+ Q1 = $(V:1=)
8
+ Q = $(Q1:0=@)
9
+ ECHO1 = $(V:1=@ :)
10
+ ECHO = $(ECHO1:0=@ echo)
11
+ NULLCMD = :
12
+
13
+ #### Start of system configuration section. ####
14
+
15
+ srcdir = .
16
+ topdir = /Users/maxhatfull/.rubies/ruby-3.3.5/include/ruby-3.3.0
17
+ hdrdir = $(topdir)
18
+ arch_hdrdir = /Users/maxhatfull/.rubies/ruby-3.3.5/include/ruby-3.3.0/arm64-darwin23
19
+ PATH_SEPARATOR = :
20
+ VPATH = $(srcdir):$(arch_hdrdir)/ruby:$(hdrdir)/ruby
21
+ prefix = $(DESTDIR)/Users/maxhatfull/.rubies/ruby-3.3.5
22
+ rubysitearchprefix = $(rubylibprefix)/$(sitearch)
23
+ rubyarchprefix = $(rubylibprefix)/$(arch)
24
+ rubylibprefix = $(libdir)/$(RUBY_BASE_NAME)
25
+ exec_prefix = $(prefix)
26
+ vendorarchhdrdir = $(vendorhdrdir)/$(sitearch)
27
+ sitearchhdrdir = $(sitehdrdir)/$(sitearch)
28
+ rubyarchhdrdir = $(rubyhdrdir)/$(arch)
29
+ vendorhdrdir = $(rubyhdrdir)/vendor_ruby
30
+ sitehdrdir = $(rubyhdrdir)/site_ruby
31
+ rubyhdrdir = $(includedir)/$(RUBY_VERSION_NAME)
32
+ vendorarchdir = $(vendorlibdir)/$(sitearch)
33
+ vendorlibdir = $(vendordir)/$(ruby_version)
34
+ vendordir = $(rubylibprefix)/vendor_ruby
35
+ sitearchdir = $(sitelibdir)/$(sitearch)
36
+ sitelibdir = $(sitedir)/$(ruby_version)
37
+ sitedir = $(rubylibprefix)/site_ruby
38
+ rubyarchdir = $(rubylibdir)/$(arch)
39
+ rubylibdir = $(rubylibprefix)/$(ruby_version)
40
+ sitearchincludedir = $(includedir)/$(sitearch)
41
+ archincludedir = $(includedir)/$(arch)
42
+ sitearchlibdir = $(libdir)/$(sitearch)
43
+ archlibdir = $(libdir)/$(arch)
44
+ ridir = $(datarootdir)/$(RI_BASE_NAME)
45
+ mandir = $(datarootdir)/man
46
+ localedir = $(datarootdir)/locale
47
+ libdir = $(exec_prefix)/lib
48
+ psdir = $(docdir)
49
+ pdfdir = $(docdir)
50
+ dvidir = $(docdir)
51
+ htmldir = $(docdir)
52
+ infodir = $(datarootdir)/info
53
+ docdir = $(datarootdir)/doc/$(PACKAGE)
54
+ oldincludedir = $(DESTDIR)/usr/include
55
+ includedir = $(SDKROOT)$(prefix)/include
56
+ runstatedir = $(localstatedir)/run
57
+ localstatedir = $(prefix)/var
58
+ sharedstatedir = $(prefix)/com
59
+ sysconfdir = $(prefix)/etc
60
+ datadir = $(datarootdir)
61
+ datarootdir = $(prefix)/share
62
+ libexecdir = $(exec_prefix)/libexec
63
+ sbindir = $(exec_prefix)/sbin
64
+ bindir = $(exec_prefix)/bin
65
+ archdir = $(rubyarchdir)
66
+
67
+
68
+ CC_WRAPPER =
69
+ CC = clang
70
+ CXX = clang++
71
+ LIBRUBY = $(LIBRUBY_A)
72
+ LIBRUBY_A = lib$(RUBY_SO_NAME)-static.a
73
+ LIBRUBYARG_SHARED =
74
+ LIBRUBYARG_STATIC = -l$(RUBY_SO_NAME)-static -framework CoreFoundation $(MAINLIBS)
75
+ empty =
76
+ OUTFLAG = -o $(empty)
77
+ COUTFLAG = -o $(empty)
78
+ CSRCFLAG = $(empty)
79
+
80
+ RUBY_EXTCONF_H = extconf.h
81
+ cflags = -fdeclspec $(optflags) $(debugflags) $(warnflags)
82
+ cxxflags =
83
+ optflags = -O3 -fno-fast-math
84
+ debugflags = -ggdb3
85
+ warnflags = -Wall -Wextra -Wextra-tokens -Wdeprecated-declarations -Wdivision-by-zero -Wdiv-by-zero -Wimplicit-function-declaration -Wimplicit-int -Wpointer-arith -Wshorten-64-to-32 -Wwrite-strings -Wold-style-definition -Wmissing-noreturn -Wno-cast-function-type -Wno-constant-logical-operand -Wno-long-long -Wno-missing-field-initializers -Wno-overlength-strings -Wno-parentheses-equality -Wno-self-assign -Wno-tautological-compare -Wno-unused-parameter -Wno-unused-value -Wunused-variable -Wmisleading-indentation -Wundef
86
+ cppflags =
87
+ CCDLFLAGS = -fno-common
88
+ CFLAGS = $(CCDLFLAGS) $(cflags) -pipe -std=c11 -I../assets/include $(ARCH_FLAG)
89
+ INCFLAGS = -I. -I$(arch_hdrdir) -I$(hdrdir)/ruby/backward -I$(hdrdir) -I$(srcdir)
90
+ DEFS =
91
+ CPPFLAGS = -DRUBY_EXTCONF_H=\"$(RUBY_EXTCONF_H)\" -I/opt/homebrew/opt/readline/include -I/opt/homebrew/opt/libyaml/include -I/opt/homebrew/opt/gdbm/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT $(DEFS) $(cppflags)
92
+ CXXFLAGS = $(CCDLFLAGS) -fdeclspec $(ARCH_FLAG)
93
+ ldflags = -L. -fstack-protector-strong -L/opt/homebrew/opt/readline/lib -L/opt/homebrew/opt/libyaml/lib -L/opt/homebrew/opt/gdbm/lib /Users/maxhatfull/dev/native_audio/ext/../assets/macos/universal/lib/libSDL2.a /Users/maxhatfull/dev/native_audio/ext/../assets/macos/universal/lib/libSDL2_mixer.a /Users/maxhatfull/dev/native_audio/ext/../assets/macos/universal/lib/libmpg123.a /Users/maxhatfull/dev/native_audio/ext/../assets/macos/universal/lib/libogg.a /Users/maxhatfull/dev/native_audio/ext/../assets/macos/universal/lib/libFLAC.a /Users/maxhatfull/dev/native_audio/ext/../assets/macos/universal/lib/libvorbis.a /Users/maxhatfull/dev/native_audio/ext/../assets/macos/universal/lib/libvorbisfile.a /Users/maxhatfull/dev/native_audio/ext/../assets/macos/universal/lib/libmodplug.a -lz -liconv -lstdc++ -Wl,-framework,Cocoa -Wl,-framework,Carbon -Wl,-framework,GameController -Wl,-framework,ForceFeedback -Wl,-framework,OpenGL -Wl,-framework,AudioToolbox -Wl,-framework,CoreAudio -Wl,-framework,IOKit -Wl,-framework,CoreHaptics -Wl,-framework,CoreVideo -Wl,-framework,Metal
94
+ dldflags = -L/opt/homebrew/opt/readline/lib -L/opt/homebrew/opt/libyaml/lib -L/opt/homebrew/opt/gdbm/lib -Wl,-undefined,dynamic_lookup -bundle_loader '$(BUILTRUBY)'
95
+ ARCH_FLAG = -arch arm64
96
+ DLDFLAGS = $(ldflags) $(dldflags) $(ARCH_FLAG)
97
+ LDSHARED = $(CC) -dynamic -bundle
98
+ LDSHAREDXX = $(CXX) -dynamic -bundle
99
+ AR = ar
100
+ EXEEXT =
101
+
102
+ RUBY_INSTALL_NAME = $(RUBY_BASE_NAME)
103
+ RUBY_SO_NAME = ruby.3.3
104
+ RUBYW_INSTALL_NAME =
105
+ RUBY_VERSION_NAME = $(RUBY_BASE_NAME)-$(ruby_version)
106
+ RUBYW_BASE_NAME = rubyw
107
+ RUBY_BASE_NAME = ruby
108
+
109
+ arch = arm64-darwin23
110
+ sitearch = $(arch)
111
+ ruby_version = 3.3.0
112
+ ruby = $(bindir)/$(RUBY_BASE_NAME)
113
+ RUBY = $(ruby)
114
+ BUILTRUBY = $(bindir)/$(RUBY_BASE_NAME)
115
+ ruby_headers = $(hdrdir)/ruby.h $(hdrdir)/ruby/backward.h $(hdrdir)/ruby/ruby.h $(hdrdir)/ruby/defines.h $(hdrdir)/ruby/missing.h $(hdrdir)/ruby/intern.h $(hdrdir)/ruby/st.h $(hdrdir)/ruby/subst.h $(arch_hdrdir)/ruby/config.h $(RUBY_EXTCONF_H)
116
+
117
+ RM = rm -f
118
+ RM_RF = rm -fr
119
+ RMDIRS = rmdir -p
120
+ MAKEDIRS = mkdir -p
121
+ INSTALL = /usr/bin/install -c
122
+ INSTALL_PROG = $(INSTALL) -m 0755
123
+ INSTALL_DATA = $(INSTALL) -m 644
124
+ COPY = cp
125
+ TOUCH = exit >
126
+
127
+ #### End of system configuration section. ####
128
+
129
+ preload =
130
+ libpath = . $(libdir) /opt/homebrew/opt/readline/lib /opt/homebrew/opt/libyaml/lib /opt/homebrew/opt/gdbm/lib
131
+ LIBPATH = -L. -L$(libdir) -L/opt/homebrew/opt/readline/lib -L/opt/homebrew/opt/libyaml/lib -L/opt/homebrew/opt/gdbm/lib
132
+ DEFFILE =
133
+
134
+ CLEANFILES = mkmf.log
135
+ DISTCLEANFILES =
136
+ DISTCLEANDIRS =
137
+
138
+ extout =
139
+ extout_prefix =
140
+ target_prefix =
141
+ LOCAL_LIBS =
142
+ LIBS = -lpthread
143
+ ORIG_SRCS = audio.c
144
+ SRCS = $(ORIG_SRCS)
145
+ OBJS = audio.o
146
+ HDRS = $(srcdir)/extconf.h
147
+ LOCAL_HDRS =
148
+ TARGET = audio
149
+ TARGET_NAME = audio
150
+ TARGET_ENTRY = Init_$(TARGET_NAME)
151
+ DLLIB = $(TARGET).bundle
152
+ EXTSTATIC =
153
+ STATIC_LIB =
154
+
155
+ TIMESTAMP_DIR = .
156
+ BINDIR = $(bindir)
157
+ RUBYCOMMONDIR = $(sitedir)$(target_prefix)
158
+ RUBYLIBDIR = $(sitelibdir)$(target_prefix)
159
+ RUBYARCHDIR = $(sitearchdir)$(target_prefix)
160
+ HDRDIR = $(sitehdrdir)$(target_prefix)
161
+ ARCHHDRDIR = $(sitearchhdrdir)$(target_prefix)
162
+ TARGET_SO_DIR =
163
+ TARGET_SO = $(TARGET_SO_DIR)$(DLLIB)
164
+ CLEANLIBS = $(TARGET_SO) $(TARGET_SO).dSYM
165
+ CLEANOBJS = $(OBJS) *.bak
166
+ TARGET_SO_DIR_TIMESTAMP = $(TIMESTAMP_DIR)/.sitearchdir.time
167
+
168
+ all: $(DLLIB)
169
+ static: $(STATIC_LIB)
170
+ .PHONY: all install static install-so install-rb
171
+ .PHONY: clean clean-so clean-static clean-rb
172
+
173
+ clean-static::
174
+ clean-rb-default::
175
+ clean-rb::
176
+ clean-so::
177
+ clean: clean-so clean-static clean-rb-default clean-rb
178
+ -$(Q)$(RM_RF) $(CLEANLIBS) $(CLEANOBJS) $(CLEANFILES) .*.time
179
+
180
+ distclean-rb-default::
181
+ distclean-rb::
182
+ distclean-so::
183
+ distclean-static::
184
+ distclean: clean distclean-so distclean-static distclean-rb-default distclean-rb
185
+ -$(Q)$(RM) Makefile $(RUBY_EXTCONF_H) conftest.* mkmf.log
186
+ -$(Q)$(RM) core ruby$(EXEEXT) *~ $(DISTCLEANFILES)
187
+ -$(Q)$(RMDIRS) $(DISTCLEANDIRS) 2> /dev/null || true
188
+
189
+ realclean: distclean
190
+ install: install-so install-rb
191
+
192
+ install-so: $(DLLIB) $(TARGET_SO_DIR_TIMESTAMP)
193
+ $(INSTALL_PROG) $(DLLIB) $(RUBYARCHDIR)
194
+ clean-static::
195
+ -$(Q)$(RM) $(STATIC_LIB)
196
+ install-rb: pre-install-rb do-install-rb install-rb-default
197
+ install-rb-default: pre-install-rb-default do-install-rb-default
198
+ pre-install-rb: Makefile
199
+ pre-install-rb-default: Makefile
200
+ do-install-rb:
201
+ do-install-rb-default:
202
+ pre-install-rb-default:
203
+ @$(NULLCMD)
204
+ $(TARGET_SO_DIR_TIMESTAMP):
205
+ $(Q) $(MAKEDIRS) $(@D) $(RUBYARCHDIR)
206
+ $(Q) $(TOUCH) $@
207
+
208
+ site-install: site-install-so site-install-rb
209
+ site-install-so: install-so
210
+ site-install-rb: install-rb
211
+
212
+ .SUFFIXES: .c .m .cc .mm .cxx .cpp .o .S
213
+
214
+ .cc.o:
215
+ $(ECHO) compiling $(<)
216
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
217
+
218
+ .cc.S:
219
+ $(ECHO) translating $(<)
220
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
221
+
222
+ .mm.o:
223
+ $(ECHO) compiling $(<)
224
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
225
+
226
+ .mm.S:
227
+ $(ECHO) translating $(<)
228
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
229
+
230
+ .cxx.o:
231
+ $(ECHO) compiling $(<)
232
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
233
+
234
+ .cxx.S:
235
+ $(ECHO) translating $(<)
236
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
237
+
238
+ .cpp.o:
239
+ $(ECHO) compiling $(<)
240
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
241
+
242
+ .cpp.S:
243
+ $(ECHO) translating $(<)
244
+ $(Q) $(CXX) $(INCFLAGS) $(CPPFLAGS) $(CXXFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
245
+
246
+ .c.o:
247
+ $(ECHO) compiling $(<)
248
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
249
+
250
+ .c.S:
251
+ $(ECHO) translating $(<)
252
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
253
+
254
+ .m.o:
255
+ $(ECHO) compiling $(<)
256
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -c $(CSRCFLAG)$<
257
+
258
+ .m.S:
259
+ $(ECHO) translating $(<)
260
+ $(Q) $(CC) $(INCFLAGS) $(CPPFLAGS) $(CFLAGS) $(COUTFLAG)$@ -S $(CSRCFLAG)$<
261
+
262
+ $(TARGET_SO): $(OBJS) Makefile
263
+ $(ECHO) linking shared-object $(DLLIB)
264
+ -$(Q)$(RM) $(@)
265
+ $(Q) $(LDSHARED) -o $@ $(OBJS) $(LIBPATH) $(DLDFLAGS) $(LOCAL_LIBS) $(LIBS)
266
+ $(Q) $(POSTLINK)
267
+
268
+
269
+
270
+ $(OBJS): $(HDRS) $(ruby_headers)
data/ext/audio.c ADDED
@@ -0,0 +1,80 @@
1
+ #include <ruby.h>
2
+ #include "extconf.h"
3
+ #include <SDL2/SDL.h>
4
+ #include <SDL2/SDL_mixer.h>
5
+
6
+ Mix_Chunk *sounds[1024];
7
+ int sound_count = 0;
8
+
9
+ VALUE audio_play(VALUE self, VALUE channel_id, VALUE clip)
10
+ {
11
+ Mix_Chunk *sound = sounds[NUM2INT(clip)];
12
+ int channel = Mix_PlayChannel(NUM2INT(channel_id), sound, 0);
13
+ return rb_int2inum(channel);
14
+ }
15
+
16
+ VALUE audio_load(VALUE self, VALUE file)
17
+ {
18
+ Mix_Chunk *sound = NULL;
19
+ sound = Mix_LoadWAV(StringValueCStr(file));
20
+ if(sound == NULL)
21
+ {
22
+ fprintf(stderr, "Unable to load WAV file: %s\n", Mix_GetError());
23
+ }
24
+
25
+ sounds[0] = sound;
26
+ sound_count++;
27
+
28
+ return rb_int2inum(sound_count - 1);
29
+ }
30
+
31
+ VALUE audio_set_pos(VALUE self, VALUE channel_id, VALUE angle, VALUE distance)
32
+ {
33
+ Mix_SetPosition(NUM2INT(channel_id), NUM2INT(angle), NUM2INT(distance));
34
+ return Qnil;
35
+ }
36
+
37
+ VALUE audio_stop(VALUE self, VALUE channel_id)
38
+ {
39
+ Mix_HaltChannel(NUM2INT(channel_id));
40
+ return Qnil;
41
+ }
42
+
43
+ VALUE audio_pause(VALUE self, VALUE channel_id)
44
+ {
45
+ Mix_Pause(NUM2INT(channel_id));
46
+ return Qnil;
47
+ }
48
+
49
+ VALUE audio_resume(VALUE self, VALUE channel_id)
50
+ {
51
+ Mix_Resume(NUM2INT(channel_id));
52
+ return Qnil;
53
+ }
54
+
55
+ VALUE audio_set_volume(VALUE self, VALUE channel_id, VALUE volume)
56
+ {
57
+ Mix_Volume(NUM2INT(channel_id), NUM2INT(volume));
58
+ return Qnil;
59
+ }
60
+
61
+ void Init_audio()
62
+ {
63
+ if (SDL_Init(SDL_INIT_AUDIO) != 0) { exit(1); }
64
+
65
+ int audio_rate = 22050;
66
+ Uint16 audio_format = AUDIO_S16SYS;
67
+ int audio_channels = 2;
68
+ int audio_buffers = 4096;
69
+
70
+ if(Mix_OpenAudio(audio_rate, audio_format, audio_channels, audio_buffers) != 0) { exit(1); }
71
+
72
+ VALUE mAudio = rb_define_module("Audio");
73
+ rb_define_singleton_method(mAudio, "load", audio_load, 1);
74
+ rb_define_singleton_method(mAudio, "play", audio_play, 2);
75
+ rb_define_singleton_method(mAudio, "set_pos", audio_set_pos, 3);
76
+ rb_define_singleton_method(mAudio, "stop", audio_stop, 1);
77
+ rb_define_singleton_method(mAudio, "pause", audio_pause, 1);
78
+ rb_define_singleton_method(mAudio, "resume", audio_resume, 1);
79
+ rb_define_singleton_method(mAudio, "set_volume", audio_set_volume, 2);
80
+ }
data/ext/audio.o ADDED
Binary file
data/ext/extconf.h ADDED
@@ -0,0 +1,3 @@
1
+ #ifndef EXTCONF_H
2
+ #define EXTCONF_H
3
+ #endif
data/ext/extconf.rb ADDED
@@ -0,0 +1,177 @@
1
+
2
+ require 'mkmf'
3
+
4
+ case RUBY_PLATFORM
5
+ when /darwin/
6
+ $PLATFORM = :macos
7
+ when /linux/
8
+ $PLATFORM = :linux
9
+ if `cat /etc/os-release` =~ /raspbian/
10
+ $PLATFORM = :linux_rpi
11
+ end
12
+ when /bsd/
13
+ $PLATFORM = :bsd
14
+ when /mingw/
15
+ $PLATFORM = :windows
16
+ else
17
+ $PLATFORM = nil
18
+ end
19
+ $errors = [] # Holds errors
20
+
21
+ # Helper functions #############################################################
22
+
23
+ # Print installation errors
24
+ def print_errors
25
+ puts "
26
+ #{"== #{"Ruby 2D Installation Errors".error} =======================================\n"}
27
+ #{$errors.join("\n ")}\n
28
+ #{"======================================================================"}"
29
+ end
30
+
31
+ # Add compiler and linker flags
32
+ def add_flags(type, flags)
33
+ case type
34
+ when :c
35
+ $CFLAGS << " #{flags} "
36
+ when :ld
37
+ $LDFLAGS << " #{flags} "
38
+ end
39
+ end
40
+
41
+ # Check for SDL libraries
42
+ def check_sdl
43
+ unless have_library('SDL2') && have_library('SDL2_mixer')
44
+
45
+ $errors << "Couldn't find packages needed."
46
+
47
+ case $platform
48
+ when :linux, :linux_rpi
49
+ # Fedora and CentOS
50
+ if system('which yum')
51
+ $errors << "Install the following packages using `yum` (or `dnf`) and try again:\n" <<
52
+ " SDL2-devel SDL2_mixer-devel".bold
53
+
54
+ # Arch
55
+ elsif system('which pacman')
56
+ $errors << "Install the following packages using `pacman` and try again:\n" <<
57
+ " sdl2 sdl2_mixer".bold
58
+
59
+ # openSUSE
60
+ elsif system('which zypper')
61
+ $errors << "Install the following packages using `zypper` and try again:\n" <<
62
+ " libSDL2-devel libSDL2_mixer-devel".bold
63
+
64
+ # Ubuntu, Debian, and Mint
65
+ # `apt` must be last because openSUSE has it aliased to `zypper`
66
+ elsif system('which apt')
67
+ $errors << "Install the following packages using `apt` and try again:\n" <<
68
+ " libsdl2-dev libsdl2-mixer-dev".bold
69
+ end
70
+ when :bsd
71
+ $errors << "Install the following packages using `pkg` and try again:\n" <<
72
+ " sdl2 sdl2_mixer".bold
73
+ end
74
+
75
+ $errors << "" << "See #{"ruby2d.com".bold} for additional help."
76
+ print_errors; exit
77
+ end
78
+ end
79
+
80
+ # Set Raspberry Pi flags
81
+ def set_rpi_flags
82
+ if $platform == :linux_rpi
83
+ add_flags(:c, '-I/opt/vc/include')
84
+ add_flags(:ld, '-L/opt/vc/lib -lbrcmGLESv2')
85
+ end
86
+ end
87
+
88
+ # Set flags for Linux and BSD
89
+ def set_linux_bsd_flags
90
+ check_sdl
91
+ set_rpi_flags
92
+ add_flags(:ld, "-lSDL2 -lSDL2_mixer -lm")
93
+ if $PLATFORM == :linux then add_flags(:ld, '-lGL') end
94
+ end
95
+
96
+
97
+ # Use SDL and other libraries installed by the user (not those bundled with the gem)
98
+ def use_usr_libs
99
+ case $PLATFORM
100
+ when :macos
101
+ add_flags(:c, `sdl2-config --cflags`)
102
+ add_flags(:c, '-I/opt/homebrew/include')
103
+ add_flags(:ld, `sdl2-config --libs`)
104
+ add_flags(:ld, '-lSDL2 -lSDL2_image -lSDL2_mixer -lSDL2_ttf')
105
+ add_flags(:ld, '-Wl,-framework,OpenGL')
106
+ when :windows
107
+ add_flags(:ld, '-lSDL2 -lSDL2_mixer')
108
+ add_flags(:ld, '-lopengl32 -lglew32')
109
+ when :linux_rpi
110
+ set_linux_bsd_flags
111
+ end
112
+ end
113
+
114
+
115
+ # Configure native extension ###################################################
116
+
117
+ # Build Ruby 2D native extention using libraries installed by user
118
+ # To use install flag: `gem install ruby2d -- dev`
119
+ if ARGV.include? 'dev'
120
+ use_usr_libs
121
+
122
+ # Use libraries provided by the gem (default)
123
+ else
124
+ add_flags(:c, '-std=c11')
125
+
126
+ case $PLATFORM
127
+ when :macos
128
+ add_flags(:c, '-I../assets/include')
129
+ ldir = "#{Dir.pwd}/../assets/macos/universal/lib"
130
+
131
+ add_flags(:ld, "#{ldir}/libSDL2.a #{ldir}/libSDL2_mixer.a")
132
+ add_flags(:ld, "#{ldir}/libmpg123.a #{ldir}/libogg.a #{ldir}/libFLAC.a #{ldir}/libvorbis.a #{ldir}/libvorbisfile.a #{ldir}/libmodplug.a")
133
+ add_flags(:ld, "-lz -liconv -lstdc++")
134
+ add_flags(:ld, "-Wl,-framework,Cocoa -Wl,-framework,Carbon -Wl,-framework,GameController -Wl,-framework,ForceFeedback -Wl,-framework,OpenGL -Wl,-framework,AudioToolbox -Wl,-framework,CoreAudio -Wl,-framework,IOKit -Wl,-framework,CoreHaptics -Wl,-framework,CoreVideo -Wl,-framework,Metal")
135
+
136
+ when :windows
137
+ add_flags(:c, '-I../assets/include')
138
+
139
+ if RUBY_PLATFORM =~ /ucrt/
140
+ ldir = "#{Dir.pwd}/../assets/windows/mingw-w64-ucrt-x86_64/lib"
141
+ else
142
+ ldir = "#{Dir.pwd}/../assets/windows/mingw-w64-x86_64/lib"
143
+ end
144
+
145
+ # Start linker flags (needed to avoid circular dependencies)
146
+ add_flags(:ld, "-Wl,--start-group")
147
+
148
+ # SDL2
149
+ add_flags(:ld, "#{ldir}/libSDL2.a")
150
+
151
+ # SDL2_mixer
152
+ add_flags(:ld, "#{ldir}/libSDL2_mixer.a")
153
+ add_flags(:ld, "#{ldir}/libmpg123.a #{ldir}/libFLAC.a #{ldir}/libvorbis.a #{ldir}/libvorbisfile.a #{ldir}/libogg.a "\
154
+ "#{ldir}/libmodplug.a #{ldir}/libopus.a #{ldir}/libopusfile.a #{ldir}/libsndfile.a")
155
+
156
+ # Other dependencies
157
+ add_flags(:ld, "#{ldir}/libglew32.a #{ldir}/libstdc++.a #{ldir}/libz.a")
158
+ add_flags(:ld, '-lmingw32 -lopengl32 -lole32 -loleaut32 -limm32 -lversion -lwinmm -lrpcrt4 -mwindows -lsetupapi -ldwrite')
159
+
160
+ # End linker flags
161
+ add_flags(:ld, "-Wl,--end-group")
162
+
163
+ when :linux, :linux_rpi, :bsd
164
+ set_linux_bsd_flags
165
+
166
+ # If can't detect the platform, use libraries installed by the user
167
+ else
168
+ use_usr_libs
169
+ end
170
+ end
171
+
172
+ $CFLAGS.gsub!(/\n/, ' ') # remove newlines in flags, they can cause problems
173
+ $LDFLAGS.gsub!(/\n/, ' ') # remove newlines in flags, they can cause problems
174
+
175
+ # Create Makefile
176
+ create_header
177
+ create_makefile('audio')
data/ext/mkmf.log ADDED
@@ -0,0 +1,7 @@
1
+ extconf.h is:
2
+ /* begin */
3
+ 1: #ifndef EXTCONF_H
4
+ 2: #define EXTCONF_H
5
+ 3: #endif
6
+ /* end */
7
+
data/lib/audio.bundle ADDED
Binary file
@@ -0,0 +1,50 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative './audio'
4
+
5
+ module NativeAudio
6
+ class Clip
7
+ attr_reader :clip
8
+
9
+ def initialize(path)
10
+ @path = path
11
+ @clip = Audio.load(path)
12
+ end
13
+ end
14
+
15
+ class AudioSource
16
+ def initialize(clip)
17
+ @clip = clip
18
+ @channel = AudioSource.channels.count
19
+ AudioSource.channels << self
20
+ end
21
+
22
+ def play
23
+ Audio.play(@channel, @clip.clip)
24
+ end
25
+
26
+ def stop
27
+ Audio.stop(@channel)
28
+ end
29
+
30
+ def pause
31
+ Audio.pause(@channel)
32
+ end
33
+
34
+ def resume
35
+ Audio.resume(@channel)
36
+ end
37
+
38
+ def set_pos(angle, distance)
39
+ Audio.set_pos(@channel, angle, distance)
40
+ end
41
+
42
+ def set_volume(volume)
43
+ Audio.set_volume(@channel, volume)
44
+ end
45
+
46
+ def self.channels
47
+ @channels ||= []
48
+ end
49
+ end
50
+ end