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
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// delay_node.c - Multi-tap delay node implementation
|
|
3
|
+
// ============================================================================
|
|
4
|
+
|
|
5
|
+
#include <stdlib.h>
|
|
6
|
+
#include <string.h>
|
|
7
|
+
#include "delay_node.h"
|
|
8
|
+
|
|
9
|
+
// ============================================================================
|
|
10
|
+
// DSP Callback
|
|
11
|
+
// ============================================================================
|
|
12
|
+
|
|
13
|
+
static void multi_tap_delay_process(ma_node *pNode, const float **ppFramesIn,
|
|
14
|
+
ma_uint32 *pFrameCountIn, float **ppFramesOut,
|
|
15
|
+
ma_uint32 *pFrameCountOut)
|
|
16
|
+
{
|
|
17
|
+
multi_tap_delay_node *node = (multi_tap_delay_node *)pNode;
|
|
18
|
+
const float *pFramesIn = ppFramesIn[0];
|
|
19
|
+
float *pFramesOut = ppFramesOut[0];
|
|
20
|
+
ma_uint32 frameCount = *pFrameCountOut;
|
|
21
|
+
ma_uint32 numChannels = node->channels;
|
|
22
|
+
|
|
23
|
+
for (ma_uint32 iFrame = 0; iFrame < frameCount; iFrame++) {
|
|
24
|
+
for (ma_uint32 iChannel = 0; iChannel < numChannels; iChannel++) {
|
|
25
|
+
ma_uint32 sampleIndex = iFrame * numChannels + iChannel;
|
|
26
|
+
float inputSample = pFramesIn[sampleIndex];
|
|
27
|
+
|
|
28
|
+
// Write to circular buffer
|
|
29
|
+
ma_uint32 writeIndex = (node->write_pos * numChannels) + iChannel;
|
|
30
|
+
node->buffer[writeIndex] = inputSample;
|
|
31
|
+
|
|
32
|
+
// Start with dry signal
|
|
33
|
+
float outputSample = inputSample;
|
|
34
|
+
|
|
35
|
+
// Mix in all active taps
|
|
36
|
+
for (ma_uint32 iTap = 0; iTap < MAX_TAPS_PER_CHANNEL; iTap++) {
|
|
37
|
+
if (node->taps[iTap].active) {
|
|
38
|
+
ma_uint32 delayFrames = node->taps[iTap].delay_frames;
|
|
39
|
+
if (delayFrames > 0 && delayFrames <= node->buffer_size) {
|
|
40
|
+
ma_uint32 readPos = (node->write_pos + node->buffer_size - delayFrames) % node->buffer_size;
|
|
41
|
+
ma_uint32 readIndex = (readPos * numChannels) + iChannel;
|
|
42
|
+
outputSample += node->buffer[readIndex] * node->taps[iTap].volume;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
pFramesOut[sampleIndex] = outputSample;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// Advance write position
|
|
51
|
+
node->write_pos = (node->write_pos + 1) % node->buffer_size;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
static ma_node_vtable g_multi_tap_delay_vtable = {
|
|
56
|
+
multi_tap_delay_process,
|
|
57
|
+
NULL, // onGetRequiredInputFrameCount
|
|
58
|
+
1, // inputBusCount
|
|
59
|
+
1, // outputBusCount
|
|
60
|
+
0 // flags
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
// ============================================================================
|
|
64
|
+
// Lifecycle
|
|
65
|
+
// ============================================================================
|
|
66
|
+
|
|
67
|
+
ma_result multi_tap_delay_init(multi_tap_delay_node *pNode, ma_node_graph *pNodeGraph,
|
|
68
|
+
ma_uint32 sampleRate, ma_uint32 numChannels)
|
|
69
|
+
{
|
|
70
|
+
if (pNode == NULL) {
|
|
71
|
+
return MA_INVALID_ARGS;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
memset(pNode, 0, sizeof(*pNode));
|
|
75
|
+
|
|
76
|
+
pNode->sample_rate = sampleRate;
|
|
77
|
+
pNode->channels = numChannels;
|
|
78
|
+
pNode->buffer_size = (ma_uint32)(sampleRate * MAX_DELAY_SECONDS);
|
|
79
|
+
pNode->write_pos = 0;
|
|
80
|
+
pNode->tap_count = 0;
|
|
81
|
+
|
|
82
|
+
// Allocate circular buffer (frames * channels)
|
|
83
|
+
pNode->buffer = (float *)calloc(pNode->buffer_size * numChannels, sizeof(float));
|
|
84
|
+
if (pNode->buffer == NULL) {
|
|
85
|
+
return MA_OUT_OF_MEMORY;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
// Initialize all taps as inactive
|
|
89
|
+
for (int i = 0; i < MAX_TAPS_PER_CHANNEL; i++) {
|
|
90
|
+
pNode->taps[i].active = MA_FALSE;
|
|
91
|
+
pNode->taps[i].delay_frames = 0;
|
|
92
|
+
pNode->taps[i].volume = 0.0f;
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
// Set up node configuration
|
|
96
|
+
ma_uint32 channelsArray[1] = { numChannels };
|
|
97
|
+
ma_node_config nodeConfig = ma_node_config_init();
|
|
98
|
+
nodeConfig.vtable = &g_multi_tap_delay_vtable;
|
|
99
|
+
nodeConfig.pInputChannels = channelsArray;
|
|
100
|
+
nodeConfig.pOutputChannels = channelsArray;
|
|
101
|
+
|
|
102
|
+
return ma_node_init(pNodeGraph, &nodeConfig, NULL, &pNode->base);
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
void multi_tap_delay_uninit(multi_tap_delay_node *pNode)
|
|
106
|
+
{
|
|
107
|
+
if (pNode == NULL) {
|
|
108
|
+
return;
|
|
109
|
+
}
|
|
110
|
+
|
|
111
|
+
ma_node_uninit(&pNode->base, NULL);
|
|
112
|
+
|
|
113
|
+
if (pNode->buffer != NULL) {
|
|
114
|
+
free(pNode->buffer);
|
|
115
|
+
pNode->buffer = NULL;
|
|
116
|
+
}
|
|
117
|
+
}
|
|
118
|
+
|
|
119
|
+
// ============================================================================
|
|
120
|
+
// Tap Management
|
|
121
|
+
// ============================================================================
|
|
122
|
+
|
|
123
|
+
int multi_tap_delay_add_tap(multi_tap_delay_node *pNode, float time_ms, float volume)
|
|
124
|
+
{
|
|
125
|
+
if (pNode == NULL) {
|
|
126
|
+
return -1;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
// Find first inactive tap slot
|
|
130
|
+
for (int i = 0; i < MAX_TAPS_PER_CHANNEL; i++) {
|
|
131
|
+
if (!pNode->taps[i].active) {
|
|
132
|
+
ma_uint32 delayFrames = (ma_uint32)((time_ms / 1000.0f) * pNode->sample_rate);
|
|
133
|
+
if (delayFrames > pNode->buffer_size) {
|
|
134
|
+
delayFrames = pNode->buffer_size;
|
|
135
|
+
}
|
|
136
|
+
pNode->taps[i].delay_frames = delayFrames;
|
|
137
|
+
pNode->taps[i].volume = volume;
|
|
138
|
+
pNode->taps[i].active = MA_TRUE;
|
|
139
|
+
pNode->tap_count++;
|
|
140
|
+
return i;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
return -1; // No slots available
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
void multi_tap_delay_remove_tap(multi_tap_delay_node *pNode, int tap_id)
|
|
148
|
+
{
|
|
149
|
+
if (pNode == NULL || tap_id < 0 || tap_id >= MAX_TAPS_PER_CHANNEL) {
|
|
150
|
+
return;
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
if (pNode->taps[tap_id].active) {
|
|
154
|
+
pNode->taps[tap_id].active = MA_FALSE;
|
|
155
|
+
pNode->taps[tap_id].delay_frames = 0;
|
|
156
|
+
pNode->taps[tap_id].volume = 0.0f;
|
|
157
|
+
pNode->tap_count--;
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
void multi_tap_delay_set_volume(multi_tap_delay_node *pNode, int tap_id, float volume)
|
|
162
|
+
{
|
|
163
|
+
if (pNode == NULL || tap_id < 0 || tap_id >= MAX_TAPS_PER_CHANNEL) {
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
if (pNode->taps[tap_id].active) {
|
|
168
|
+
pNode->taps[tap_id].volume = volume;
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
void multi_tap_delay_set_time(multi_tap_delay_node *pNode, int tap_id, float time_ms)
|
|
173
|
+
{
|
|
174
|
+
if (pNode == NULL || tap_id < 0 || tap_id >= MAX_TAPS_PER_CHANNEL) {
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
|
|
178
|
+
if (pNode->taps[tap_id].active) {
|
|
179
|
+
ma_uint32 delayFrames = (ma_uint32)((time_ms / 1000.0f) * pNode->sample_rate);
|
|
180
|
+
if (delayFrames > pNode->buffer_size) {
|
|
181
|
+
delayFrames = pNode->buffer_size;
|
|
182
|
+
}
|
|
183
|
+
pNode->taps[tap_id].delay_frames = delayFrames;
|
|
184
|
+
}
|
|
185
|
+
}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// ============================================================================
|
|
2
|
+
// delay_node.h - Multi-tap delay node for native_audio
|
|
3
|
+
// ============================================================================
|
|
4
|
+
|
|
5
|
+
#ifndef DELAY_NODE_H
|
|
6
|
+
#define DELAY_NODE_H
|
|
7
|
+
|
|
8
|
+
#include "miniaudio.h"
|
|
9
|
+
|
|
10
|
+
// ============================================================================
|
|
11
|
+
// Constants
|
|
12
|
+
// ============================================================================
|
|
13
|
+
|
|
14
|
+
#define MAX_TAPS_PER_CHANNEL 16
|
|
15
|
+
#define MAX_DELAY_SECONDS 2.0f
|
|
16
|
+
|
|
17
|
+
// ============================================================================
|
|
18
|
+
// Types
|
|
19
|
+
// ============================================================================
|
|
20
|
+
|
|
21
|
+
typedef struct {
|
|
22
|
+
ma_uint32 delay_frames;
|
|
23
|
+
float volume;
|
|
24
|
+
ma_bool32 active;
|
|
25
|
+
} delay_tap;
|
|
26
|
+
|
|
27
|
+
typedef struct {
|
|
28
|
+
ma_node_base base;
|
|
29
|
+
float *buffer;
|
|
30
|
+
ma_uint32 buffer_size; // Size in frames
|
|
31
|
+
ma_uint32 write_pos;
|
|
32
|
+
ma_uint32 channels; // Audio channels (stereo = 2)
|
|
33
|
+
delay_tap taps[MAX_TAPS_PER_CHANNEL];
|
|
34
|
+
ma_uint32 tap_count;
|
|
35
|
+
ma_uint32 sample_rate;
|
|
36
|
+
} multi_tap_delay_node;
|
|
37
|
+
|
|
38
|
+
// ============================================================================
|
|
39
|
+
// Public API
|
|
40
|
+
// ============================================================================
|
|
41
|
+
|
|
42
|
+
ma_result multi_tap_delay_init(multi_tap_delay_node *pNode, ma_node_graph *pNodeGraph,
|
|
43
|
+
ma_uint32 sampleRate, ma_uint32 numChannels);
|
|
44
|
+
void multi_tap_delay_uninit(multi_tap_delay_node *pNode);
|
|
45
|
+
|
|
46
|
+
int multi_tap_delay_add_tap(multi_tap_delay_node *pNode, float time_ms, float volume);
|
|
47
|
+
void multi_tap_delay_remove_tap(multi_tap_delay_node *pNode, int tap_id);
|
|
48
|
+
void multi_tap_delay_set_volume(multi_tap_delay_node *pNode, int tap_id, float volume);
|
|
49
|
+
void multi_tap_delay_set_time(multi_tap_delay_node *pNode, int tap_id, float time_ms);
|
|
50
|
+
|
|
51
|
+
#endif // DELAY_NODE_H
|
data/ext/audio/extconf.rb
CHANGED
|
@@ -1,115 +1,17 @@
|
|
|
1
1
|
require 'mkmf'
|
|
2
2
|
|
|
3
|
-
#
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
when /darwin/
|
|
10
|
-
|
|
11
|
-
when /
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
case type
|
|
16
|
-
when :c then $CFLAGS << " #{flags} "
|
|
17
|
-
when :ld then $LDFLAGS << " #{flags} "
|
|
18
|
-
end
|
|
3
|
+
# miniaudio linking requirements per platform:
|
|
4
|
+
# - macOS: CoreFoundation, CoreAudio, AudioToolbox frameworks
|
|
5
|
+
# - Linux: pthread, dl, m (math)
|
|
6
|
+
# - Windows: uses native APIs via runtime linking, no extra libs needed
|
|
7
|
+
|
|
8
|
+
case RUBY_PLATFORM
|
|
9
|
+
when /darwin/
|
|
10
|
+
$LDFLAGS << " -framework CoreFoundation -framework CoreAudio -framework AudioToolbox "
|
|
11
|
+
when /linux/
|
|
12
|
+
$LDFLAGS << " -ldl -lpthread -lm "
|
|
13
|
+
when /mingw|mswin/
|
|
14
|
+
# Windows uses runtime linking to native audio APIs
|
|
19
15
|
end
|
|
20
16
|
|
|
21
|
-
def check_sdl
|
|
22
|
-
return if have_library('SDL2') && have_library('SDL2_mixer')
|
|
23
|
-
|
|
24
|
-
msg = ["SDL2 libraries not found."]
|
|
25
|
-
|
|
26
|
-
if PLATFORM == :linux
|
|
27
|
-
if system('which apt >/dev/null 2>&1')
|
|
28
|
-
msg << "Install with: sudo apt install libsdl2-dev libsdl2-mixer-dev"
|
|
29
|
-
elsif system('which dnf >/dev/null 2>&1') || system('which yum >/dev/null 2>&1')
|
|
30
|
-
msg << "Install with: sudo dnf install SDL2-devel SDL2_mixer-devel"
|
|
31
|
-
elsif system('which pacman >/dev/null 2>&1')
|
|
32
|
-
msg << "Install with: sudo pacman -S sdl2 sdl2_mixer"
|
|
33
|
-
elsif system('which zypper >/dev/null 2>&1')
|
|
34
|
-
msg << "Install with: sudo zypper install libSDL2-devel libSDL2_mixer-devel"
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
abort msg.join("\n")
|
|
39
|
-
end
|
|
40
|
-
|
|
41
|
-
def set_linux_flags
|
|
42
|
-
check_sdl
|
|
43
|
-
add_flags(:ld, "-lSDL2 -lSDL2_mixer -lm")
|
|
44
|
-
end
|
|
45
|
-
|
|
46
|
-
def use_dev_libs
|
|
47
|
-
case PLATFORM
|
|
48
|
-
when :macos
|
|
49
|
-
add_flags(:c, `sdl2-config --cflags`)
|
|
50
|
-
add_flags(:c, '-I/opt/homebrew/include')
|
|
51
|
-
add_flags(:ld, `sdl2-config --libs`)
|
|
52
|
-
add_flags(:ld, '-lSDL2 -lSDL2_mixer')
|
|
53
|
-
when :windows
|
|
54
|
-
add_flags(:ld, '-lSDL2 -lSDL2_mixer')
|
|
55
|
-
when :linux
|
|
56
|
-
set_linux_flags
|
|
57
|
-
end
|
|
58
|
-
end
|
|
59
|
-
|
|
60
|
-
def use_bundled_libs
|
|
61
|
-
add_flags(:c, '-std=c11')
|
|
62
|
-
|
|
63
|
-
case PLATFORM
|
|
64
|
-
when :macos
|
|
65
|
-
add_flags(:c, "-I#{ASSETS_DIR}/include")
|
|
66
|
-
ldir = "#{ASSETS_DIR}/macos/universal/lib"
|
|
67
|
-
|
|
68
|
-
add_flags(:ld, "#{ldir}/libSDL2.a #{ldir}/libSDL2_mixer.a")
|
|
69
|
-
add_flags(:ld, "#{ldir}/libmpg123.a #{ldir}/libogg.a #{ldir}/libFLAC.a")
|
|
70
|
-
add_flags(:ld, "#{ldir}/libvorbis.a #{ldir}/libvorbisfile.a #{ldir}/libmodplug.a")
|
|
71
|
-
add_flags(:ld, "-lz -liconv -lstdc++")
|
|
72
|
-
|
|
73
|
-
frameworks = %w[Cocoa Carbon GameController ForceFeedback
|
|
74
|
-
AudioToolbox CoreAudio IOKit CoreHaptics CoreVideo Metal]
|
|
75
|
-
add_flags(:ld, frameworks.map { |f| "-Wl,-framework,#{f}" }.join(' '))
|
|
76
|
-
|
|
77
|
-
when :windows
|
|
78
|
-
add_flags(:c, "-I#{ASSETS_DIR}/include")
|
|
79
|
-
|
|
80
|
-
ldir = if RUBY_PLATFORM =~ /ucrt/
|
|
81
|
-
"#{ASSETS_DIR}/windows/mingw-w64-ucrt-x86_64/lib"
|
|
82
|
-
else
|
|
83
|
-
"#{ASSETS_DIR}/windows/mingw-w64-x86_64/lib"
|
|
84
|
-
end
|
|
85
|
-
|
|
86
|
-
add_flags(:ld, "-Wl,--start-group")
|
|
87
|
-
add_flags(:ld, "#{ldir}/libSDL2.a #{ldir}/libSDL2_mixer.a")
|
|
88
|
-
add_flags(:ld, "#{ldir}/libmpg123.a #{ldir}/libFLAC.a #{ldir}/libvorbis.a")
|
|
89
|
-
add_flags(:ld, "#{ldir}/libvorbisfile.a #{ldir}/libogg.a #{ldir}/libmodplug.a")
|
|
90
|
-
add_flags(:ld, "#{ldir}/libopus.a #{ldir}/libopusfile.a #{ldir}/libsndfile.a")
|
|
91
|
-
add_flags(:ld, "#{ldir}/libstdc++.a #{ldir}/libz.a")
|
|
92
|
-
add_flags(:ld, '-lmingw32 -lole32 -loleaut32 -limm32')
|
|
93
|
-
add_flags(:ld, '-lversion -lwinmm -lrpcrt4 -mwindows -lsetupapi -ldwrite')
|
|
94
|
-
add_flags(:ld, "-Wl,--end-group")
|
|
95
|
-
|
|
96
|
-
when :linux
|
|
97
|
-
set_linux_flags
|
|
98
|
-
|
|
99
|
-
else
|
|
100
|
-
use_dev_libs
|
|
101
|
-
end
|
|
102
|
-
end
|
|
103
|
-
|
|
104
|
-
# Main configuration
|
|
105
|
-
if ARGV.include?('dev')
|
|
106
|
-
use_dev_libs
|
|
107
|
-
else
|
|
108
|
-
use_bundled_libs
|
|
109
|
-
end
|
|
110
|
-
|
|
111
|
-
$CFLAGS.gsub!(/\n/, ' ')
|
|
112
|
-
$LDFLAGS.gsub!(/\n/, ' ')
|
|
113
|
-
|
|
114
|
-
create_header
|
|
115
17
|
create_makefile('audio')
|