From: Brendan Hansen Date: Sun, 27 Feb 2022 23:04:01 +0000 (-0600) Subject: added OpenAL module X-Git-Url: https://git.brendanfh.com/?a=commitdiff_plain;h=93993c5e3aa6872a86f359a3fd629dd35989d001;p=onyx.git added OpenAL module --- diff --git a/include/onyx_library.h b/include/onyx_library.h index c0c0335a..4361c753 100644 --- a/include/onyx_library.h +++ b/include/onyx_library.h @@ -97,4 +97,4 @@ typedef struct WasmFuncDefinition { #define PTR WASM_I32 #endif -#define ONYX_PTR(p) (p != 0 ? (runtime->wasm_memory_data(runtime->wasm_memory) + p) : NULL) +#define ONYX_PTR(p) ((void*) (p != 0 ? (runtime->wasm_memory_data(runtime->wasm_memory) + p) : NULL)) diff --git a/modules/openal/build.sh b/modules/openal/build.sh new file mode 100644 index 00000000..32d64a11 --- /dev/null +++ b/modules/openal/build.sh @@ -0,0 +1,3 @@ +#/bin/sh + +gcc -shared -fPIC modules/openal/onyx_openal.c -lopenal -I include -I lib/common/include -o ./modules/openal/onyx_openal.so \ No newline at end of file diff --git a/modules/openal/module.onyx b/modules/openal/module.onyx new file mode 100644 index 00000000..353e3629 --- /dev/null +++ b/modules/openal/module.onyx @@ -0,0 +1,557 @@ +package openal + +#library "onyx_openal" + +ALCdevice :: #distinct u64 +ALCcontext :: #distinct u64 +ALCextfunc :: #distinct u64 + +#foreign "onyx_openal" { + alGenBuffers :: (n: i32, buffers: ^u32) -> void --- + alDeleteBuffers :: (n: i32, buffers: ^u32) -> void --- + alIsBuffer :: (buffer: u32) -> bool --- + alBufferData :: (buffer: u32, format: i32, data: rawptr, size: i32, freq: i32) -> void --- + alBufferf :: (buffer: u32, param: i32, value: f32) -> void --- + alBuffer3f :: (buffer: u32, param: i32, v1, v2, v3: f32) -> void --- + alBufferfv :: (buffer: u32, param: i32, values: ^f32) -> void --- + alBufferi :: (buffer: u32, param: i32, value: i32) -> void --- + alBuffer3i :: (buffer: u32, param: i32, v1, v2, v3: i32) -> void --- + alBufferiv :: (buffer: u32, param: i32, values: ^i32) -> void --- + alGetBufferf :: (buffer: u32, param: i32, value: ^f32) -> void --- + alGetBuffer3f :: (buffer: u32, param: i32, v1, v2, v3: ^f32) -> void --- + alGetBufferfv :: (buffer: u32, param: i32, values: ^f32) -> void --- + alGetBufferi :: (buffer: u32, param: i32, value: ^i32) -> void --- + alGetBuffer3i :: (buffer: u32, param: i32, v1, v2, v3: ^i32) -> void --- + alGetBufferiv :: (buffer: u32, param: i32, values: ^i32) -> void --- + + alGenSources :: (n: i32, sources: ^u32) -> void --- + alDeleteSources :: (n: i32, sources: ^u32) -> void --- + alIsSource :: (source: u32) -> bool --- + alSourcef :: (source: u32, param: i32, value: f32) -> void --- + alSource3f :: (source: u32, param: i32, v1, v2, v3: f32) -> void --- + alSourcefv :: (source: u32, param: i32, values: ^f32) -> void --- + alSourcei :: (source: u32, param: i32, value: i32) -> void --- + alSource3i :: (source: u32, param: i32, v1, v2, v3: i32) -> void --- + alSourceiv :: (source: u32, param: i32, values: ^i32) -> void --- + alGetSourcef :: (source: u32, param: i32, value: ^f32) -> void --- + alGetSource3f :: (source: u32, param: i32, v1, v2, v3: ^f32) -> void --- + alGetSourcefv :: (source: u32, param: i32, values: ^f32) -> void --- + alGetSourcei :: (source: u32, param: i32, value: ^i32) -> void --- + alGetSource3i :: (source: u32, param: i32, v1, v2, v3: ^i32) -> void --- + alGetSourceiv :: (source: u32, param: i32, values: ^i32) -> void --- + alSourcePlay :: (source: u32) -> void --- + alSourcePlayv :: (n: i32, sources: ^u32) -> void --- + alSourcePause :: (source: u32) -> void --- + alSourcePausev :: (n: i32, sources: ^u32) -> void --- + alSourceStop :: (source: u32) -> void --- + alSourceStopv :: (n: i32, sources: ^u32) -> void --- + alSourceRewind :: (source: u32) -> void --- + alSourceRewindv :: (n: i32, sources: ^u32) -> void --- + alSourceQueueBuffers :: (source: u32, n: i32, buffers: ^u32) -> void --- + alSourceUnqueueBuffers :: (source: u32, n: i32, buffers: ^u32) -> void --- + + alListenerf :: (param: i32, value: f32) -> void --- + alListener3f :: (param: i32, v1, v2, v3: f32) -> void --- + alListenerfv :: (param: i32, values: ^f32) -> void --- + alListeneri :: (param: i32, value: i32) -> void --- + alListener3i :: (param: i32, v1, v2, v3: i32) -> void --- + alListeneriv :: (param: i32, values: ^i32) -> void --- + alGetListenerf :: (param: i32, value: ^f32) -> void --- + alGetListener3f :: (param: i32, v1, v2, v3: ^f32) -> void --- + alGetListenerfv :: (param: i32, values: ^f32) -> void --- + alGetListeneri :: (param: i32, value: ^i32) -> void --- + alGetListener3i :: (param: i32, v1, v2, v3: ^i32) -> void --- + alGetListeneriv :: (param: i32, values: ^i32) -> void --- + + alEnable :: (capability: i32) -> void --- + alDisable :: (capability: i32) -> void --- + alIsEnabled :: (capability: i32) -> bool --- + alGetBoolean :: (param: i32) -> bool --- + alGetDouble :: (param: i32) -> f64 --- + alGetFloat :: (param: i32) -> f32 --- + alGetInteger :: (param: i32) -> i32 --- + alGetBooleanv :: (param: i32, data: ^bool) -> void --- + alGetDoublev :: (param: i32, data: ^f64) -> void --- + alGetFloatv :: (param: i32, data: ^f32) -> void --- + alGetIntegerv :: (param: i32, data: ^i32) -> void --- + alDistanceModel :: (value: i32) -> void --- + alDopplerFactor :: (value: f32) -> void --- + alSpeedOfSound :: (value: f32) -> void --- + + alGetError :: () -> i32 --- + + alcCreateContext :: (device: ALCdevice, attrlist: ^i32) -> ALCcontext --- + alcMakeContextCurrent :: (context: ALCcontext) -> bool --- + alcProcessContext :: (context: ALCcontext) -> void --- + alcSuspendContext :: (context: ALCcontext) -> void --- + alcDestroyContext :: (context: ALCcontext) -> void --- + alcGetCurrentContext :: () -> ALCcontext --- + alcGetContextsDevice :: (context: ALCcontext) -> ALCdevice --- + alcGetError :: (device: ALCdevice) -> i32 --- + + alcOpenDevice :: (name: cstr) -> ALCdevice --- + alcCloseDevice :: (device: ALCdevice) -> bool --- + + alcIsExtensionPresent :: (device: ALCdevice, extName: cstr) -> bool --- + alcGetProcAddress :: (device: ALCdevice, funcName: cstr) -> ALCextfunc --- + alcGetEnumValue :: (device: ALCdevice, enumName: cstr) -> i32 --- + alcGetIntegerv :: (device: ALCdevice, param: i32, size: i32, data: ^i32) -> void --- + + alcCaptureOpenDevice :: (name: cstr, freq: u32, format: i32, buffersize: i32) -> ALCdevice --- + alcCaptureCloseDevice :: (device: ALCdevice) -> bool --- + alcCaptureStart :: (device: ALCdevice) -> void --- + alcCaptureStop :: (device: ALCdevice) -> void --- + alcCaptureSamples :: (device: ALCdevice, buf: rawptr, samples: i32) -> void --- + + // This returns a C-allocated string, which is not supported at the moment. + // alGetString :: (device: ALCdevice, param:i32) -> cstr --- + // alcGetString :: (device: ALCdevice, param:i32) -> cstr --- +} + +AL_FALSE :: 0 + +AL_TRUE :: 1 + + +/** + * Relative source. + * Type: ALboolean + * Range: [AL_TRUE, AL_FALSE] + * Default: AL_FALSE + * + * Specifies if the Source has relative coordinates. + */ +AL_SOURCE_RELATIVE :: 0x202 + + +/** + * Inner cone angle, in degrees. + * Type: ALint, ALfloat + * Range: [0 - 360] + * Default: 360 + * + * The angle covered by the inner cone, where the source will not attenuate. + */ +AL_CONE_INNER_ANGLE :: 0x1001 + +/** + * Outer cone angle, in degrees. + * Range: [0 - 360] + * Default: 360 + * + * The angle covered by the outer cone, where the source will be fully + * attenuated. + */ +AL_CONE_OUTER_ANGLE :: 0x1002 + +/** + * Source pitch. + * Type: ALfloat + * Range: [0.5 - 2.0] + * Default: 1.0 + * + * A multiplier for the frequency (sample rate) of the source's buffer. + */ +AL_PITCH :: 0x1003 + +/** + * Source or listener position. + * Type: ALfloat[3], ALint[3] + * Default: {0, 0, 0} + * + * The source or listener location in three dimensional space. + * + * OpenAL, like OpenGL, uses a right handed coordinate system, where in a + * frontal default view X (thumb) points right, Y points up (index finger), and + * Z points towards the viewer/camera (middle finger). + * + * To switch from a left handed coordinate system, flip the sign on the Z + * coordinate. + */ +AL_POSITION :: 0x1004 + +/** + * Source direction. + * Type: ALfloat[3], ALint[3] + * Default: {0, 0, 0} + * + * Specifies the current direction in local space. + * A zero-length vector specifies an omni-directional source (cone is ignored). + */ +AL_DIRECTION :: 0x1005 + +/** + * Source or listener velocity. + * Type: ALfloat[3], ALint[3] + * Default: {0, 0, 0} + * + * Specifies the current velocity in local space. + */ +AL_VELOCITY :: 0x1006 + +/** + * Source looping. + * Type: ALboolean + * Range: [AL_TRUE, AL_FALSE] + * Default: AL_FALSE + * + * Specifies whether source is looping. + */ +AL_LOOPING :: 0x1007 + +/** + * Source buffer. + * Type: ALuint + * Range: any valid Buffer. + * + * Specifies the buffer to provide sound samples. + */ +AL_BUFFER :: 0x1009 + +/** + * Source or listener gain. + * Type: ALfloat + * Range: [0.0 - ] + * + * A value of 1.0 means unattenuated. Each division by 2 equals an attenuation + * of about -6dB. Each multiplicaton by 2 equals an amplification of about + * +6dB. + * + * A value of 0.0 is meaningless with respect to a logarithmic scale; it is + * silent. + */ +AL_GAIN :: 0x100A + +/** + * Minimum source gain. + * Type: ALfloat + * Range: [0.0 - 1.0] + * + * The minimum gain allowed for a source, after distance and cone attenation is + * applied (if applicable). + */ +AL_MIN_GAIN :: 0x100D + +/** + * Maximum source gain. + * Type: ALfloat + * Range: [0.0 - 1.0] + * + * The maximum gain allowed for a source, after distance and cone attenation is + * applied (if applicable). + */ +AL_MAX_GAIN :: 0x100E + +/** + * Listener orientation. + * Type: ALfloat[6] + * Default: {0.0, 0.0, -1.0, 0.0, 1.0, 0.0} + * + * Effectively two three dimensional vectors. The first vector is the front (or + * "at") and the second is the top (or "up"). + * + * Both vectors are in local space. + */ +AL_ORIENTATION :: 0x100F + +/** + * Source state (query only). + * Type: ALint + * Range: [AL_INITIAL, AL_PLAYING, AL_PAUSED, AL_STOPPED] + */ +AL_SOURCE_STATE :: 0x1010 + +/** Source state value. */ +AL_INITIAL :: 0x1011 +AL_PLAYING :: 0x1012 +AL_PAUSED :: 0x1013 +AL_STOPPED :: 0x1014 + +/** + * Source Buffer Queue size (query only). + * Type: ALint + * + * The number of buffers queued using alSourceQueueBuffers, minus the buffers + * removed with alSourceUnqueueBuffers. + */ +AL_BUFFERS_QUEUED :: 0x1015 + +/** + * Source Buffer Queue processed count (query only). + * Type: ALint + * + * The number of queued buffers that have been fully processed, and can be + * removed with alSourceUnqueueBuffers. + * + * Looping sources will never fully process buffers because they will be set to + * play again for when the source loops. + */ +AL_BUFFERS_PROCESSED :: 0x1016 + +/** + * Source reference distance. + * Type: ALfloat + * Range: [0.0 - ] + * Default: 1.0 + * + * The distance in units that no attenuation occurs. + * + * At 0.0, no distance attenuation ever occurs on non-linear attenuation models. + */ +AL_REFERENCE_DISTANCE :: 0x1020 + +/** + * Source rolloff factor. + * Type: ALfloat + * Range: [0.0 - ] + * Default: 1.0 + * + * Multiplier to exaggerate or diminish distance attenuation. + * + * At 0.0, no distance attenuation ever occurs. + */ +AL_ROLLOFF_FACTOR :: 0x1021 + +/** + * Outer cone gain. + * Type: ALfloat + * Range: [0.0 - 1.0] + * Default: 0.0 + * + * The gain attenuation applied when the listener is outside of the source's + * outer cone. + */ +AL_CONE_OUTER_GAIN :: 0x1022 + +/** + * Source maximum distance. + * Type: ALfloat + * Range: [0.0 - ] + * Default: +inf + * + * The distance above which the source is not attenuated any further with a + * clamped distance model, or where attenuation reaches 0.0 gain for linear + * distance models with a default rolloff factor. + */ +AL_MAX_DISTANCE :: 0x1023 + +/** Source buffer position, in seconds */ +AL_SEC_OFFSET :: 0x1024 +/** Source buffer position, in sample frames */ +AL_SAMPLE_OFFSET :: 0x1025 +/** Source buffer position, in bytes */ +AL_BYTE_OFFSET :: 0x1026 + +/** + * Source type (query only). + * Type: ALint + * Range: [AL_STATIC, AL_STREAMING, AL_UNDETERMINED] + * + * A Source is Static if a Buffer has been attached using AL_BUFFER. + * + * A Source is Streaming if one or more Buffers have been attached using + * alSourceQueueBuffers. + * + * A Source is Undetermined when it has the NULL buffer attached using + * AL_BUFFER. + */ +AL_SOURCE_TYPE :: 0x1027 + +/** Source type value. */ +AL_STATIC :: 0x1028 +AL_STREAMING :: 0x1029 +AL_UNDETERMINED :: 0x1030 + +/** Buffer format specifier. */ +AL_FORMAT_MONO8 :: 0x1100 +AL_FORMAT_MONO16 :: 0x1101 +AL_FORMAT_STEREO8 :: 0x1102 +AL_FORMAT_STEREO16 :: 0x1103 + +/** Buffer frequency (query only). */ +AL_FREQUENCY :: 0x2001 +/** Buffer bits per sample (query only). */ +AL_BITS :: 0x2002 +/** Buffer channel count (query only). */ +AL_CHANNELS :: 0x2003 +/** Buffer data size (query only). */ +AL_SIZE :: 0x2004 + +/** + * Buffer state. + * + * Not for public use. + */ +AL_UNUSED :: 0x2010 +AL_PENDING :: 0x2011 +AL_PROCESSED :: 0x2012 + + +/** No error. */ +AL_NO_ERROR :: 0 + +/** Invalid name paramater passed to AL call. */ +AL_INVALID_NAME :: 0xA001 + +/** Invalid enum parameter passed to AL call. */ +AL_INVALID_ENUM :: 0xA002 + +/** Invalid value parameter passed to AL call. */ +AL_INVALID_VALUE :: 0xA003 + +/** Illegal AL call. */ +AL_INVALID_OPERATION :: 0xA004 + +/** Not enough memory. */ +AL_OUT_OF_MEMORY :: 0xA005 + + +/** Context string: Vendor ID. */ +AL_VENDOR :: 0xB001 +/** Context string: Version. */ +AL_VERSION :: 0xB002 +/** Context string: Renderer ID. */ +AL_RENDERER :: 0xB003 +/** Context string: Space-separated extension list. */ +AL_EXTENSIONS :: 0xB004 + + +/** + * Doppler scale. + * Type: ALfloat + * Range: [0.0 - ] + * Default: 1.0 + * + * Scale for source and listener velocities. + */ +AL_DOPPLER_FACTOR :: 0xC000 + +/** + * Doppler velocity (deprecated). + * + * A multiplier applied to the Speed of Sound. + */ +AL_DOPPLER_VELOCITY :: 0xC001 + +/** + * Speed of Sound, in units per second. + * Type: ALfloat + * Range: [0.0001 - ] + * Default: 343.3 + * + * The speed at which sound waves are assumed to travel, when calculating the + * doppler effect. + */ +AL_SPEED_OF_SOUND :: 0xC003 + +/** + * Distance attenuation model. + * Type: ALint + * Range: [AL_NONE, AL_INVERSE_DISTANCE, AL_INVERSE_DISTANCE_CLAMPED, + * AL_LINEAR_DISTANCE, AL_LINEAR_DISTANCE_CLAMPED, + * AL_EXPONENT_DISTANCE, AL_EXPONENT_DISTANCE_CLAMPED] + * Default: AL_INVERSE_DISTANCE_CLAMPED + * + * The model by which sources attenuate with distance. + * + * None - No distance attenuation. + * Inverse - Doubling the distance halves the source gain. + * Linear - Linear gain scaling between the reference and max distances. + * Exponent - Exponential gain dropoff. + * + * Clamped variations work like the non-clamped counterparts, except the + * distance calculated is clamped between the reference and max distances. + */ +AL_DISTANCE_MODEL :: 0xD000 + +/** Distance model value. */ +AL_INVERSE_DISTANCE :: 0xD001 +AL_INVERSE_DISTANCE_CLAMPED :: 0xD002 +AL_LINEAR_DISTANCE :: 0xD003 +AL_LINEAR_DISTANCE_CLAMPED :: 0xD004 +AL_EXPONENT_DISTANCE :: 0xD005 +AL_EXPONENT_DISTANCE_CLAMPED :: 0xD006 + + + +/** Context attribute: Hz. */ +ALC_FREQUENCY :: 0x1007 + +/** Context attribute: Hz. */ +ALC_REFRESH :: 0x1008 + +/** Context attribute: AL_TRUE or AL_FALSE. */ +ALC_SYNC :: 0x1009 + +/** Context attribute: requested Mono (3D) Sources. */ +ALC_MONO_SOURCES :: 0x1010 + +/** Context attribute: requested Stereo Sources. */ +ALC_STEREO_SOURCES :: 0x1011 + +/** No error. */ +ALC_NO_ERROR :: 0 + +/** Invalid device handle. */ +ALC_INVALID_DEVICE :: 0xA001 + +/** Invalid context handle. */ +ALC_INVALID_CONTEXT :: 0xA002 + +/** Invalid enum parameter passed to an ALC call. */ +ALC_INVALID_ENUM :: 0xA003 + +/** Invalid value parameter passed to an ALC call. */ +ALC_INVALID_VALUE :: 0xA004 + +/** Out of memory. */ +ALC_OUT_OF_MEMORY :: 0xA005 + + +/** Runtime ALC version. */ +ALC_MAJOR_VERSION :: 0x1000 +ALC_MINOR_VERSION :: 0x1001 + +/** Context attribute list properties. */ +ALC_ATTRIBUTES_SIZE :: 0x1002 +ALC_ALL_ATTRIBUTES :: 0x1003 + +/** String for the default device specifier. */ +ALC_DEFAULT_DEVICE_SPECIFIER :: 0x1004 +/** + * String for the given device's specifier. + * + * If device handle is NULL, it is instead a null-char separated list of + * strings of known device specifiers (list ends with an empty string). + */ +ALC_DEVICE_SPECIFIER :: 0x1005 +/** String for space-separated list of ALC extensions. */ +ALC_EXTENSIONS :: 0x1006 + + +/** Capture extension */ +ALC_EXT_CAPTURE :: 1 +/** + * String for the given capture device's specifier. + * + * If device handle is NULL, it is instead a null-char separated list of + * strings of known capture device specifiers (list ends with an empty string). + */ +ALC_CAPTURE_DEVICE_SPECIFIER :: 0x310 +/** String for the default capture device specifier. */ +ALC_CAPTURE_DEFAULT_DEVICE_SPECIFIER :: 0x311 +/** Number of sample frames available for capture. */ +ALC_CAPTURE_SAMPLES :: 0x312 + + +/** Enumerate All extension */ +ALC_ENUMERATE_ALL_EXT :: 1 +/** String for the default extended device specifier. */ +ALC_DEFAULT_ALL_DEVICES_SPECIFIER :: 0x1012 +/** + * String for the given extended device's specifier. + * + * If device handle is NULL, it is instead a null-char separated list of + * strings of known extended device specifiers (list ends with an empty string). + */ +ALC_ALL_DEVICES_SPECIFIER :: 0x1013 diff --git a/modules/openal/onyx_openal.c b/modules/openal/onyx_openal.c new file mode 100644 index 00000000..52d2673e --- /dev/null +++ b/modules/openal/onyx_openal.c @@ -0,0 +1,240 @@ +#define ONYX_LIBRARY_NAME onyx_openal +#include "onyx_library.h" +#include +#include + +#define P(i, k) (params->data[i].of.k) + +ONYX_DEF(alGenBuffers, (INT, PTR), ()) { + alGenBuffers(params->data[0].of.i32, ONYX_PTR(params->data[1].of.i32)); + return NULL; +} + +ONYX_DEF(alDeleteBuffers, (INT, PTR), ()) { + alDeleteBuffers(params->data[0].of.i32, ONYX_PTR(params->data[1].of.i32)); + return NULL; +} + +ONYX_DEF(alIsBuffer, (INT), (BOOL)) { + results->data[0] = WASM_I32_VAL(alIsBuffer(params->data[0].of.i32)); + return NULL; +} + +ONYX_DEF(alBufferData, (INT, INT, PTR, INT, INT), ()) { + alBufferData( + params->data[0].of.i32, + params->data[1].of.i32, + ONYX_PTR(params->data[2].of.i32), + params->data[3].of.i32, + params->data[4].of.i32); + return NULL; +} + +ONYX_DEF(alBufferf, (INT, INT, FLOAT), ()) { alBufferf(P(0, i32), P(1, i32), P(2, f32)); return NULL; } +ONYX_DEF(alBuffer3f, (INT, INT, FLOAT, FLOAT, FLOAT), ()) { alBuffer3f(P(0, i32), P(1, i32), P(2, f32), P(3, f32), P(4, f32)); return NULL; } +ONYX_DEF(alBufferfv, (INT, INT, PTR), ()) { alBufferfv(P(0, i32), P(1, i32), ONYX_PTR(P(2, i32))); return NULL; } +ONYX_DEF(alBufferi, (INT, INT, INT), ()) { alBufferi(P(0, i32), P(1, i32), P(2, i32)); return NULL; } +ONYX_DEF(alBuffer3i, (INT, INT, INT, INT, INT), ()) { alBuffer3i(P(0, i32), P(1, i32), P(2, i32), P(3, i32), P(4, i32)); return NULL; } +ONYX_DEF(alBufferiv, (INT, INT, PTR), ()) { alBufferiv(P(0, i32), P(1, i32), ONYX_PTR(P(2, i32))); return NULL; } +ONYX_DEF(alGetBufferf, (INT, INT, PTR), ()) { alGetBufferf(P(0, i32), P(1, i32), ONYX_PTR(P(2, i32))); return NULL; } +ONYX_DEF(alGetBuffer3f, (INT, INT, PTR, PTR, PTR), ()) { alGetBuffer3f(P(0, i32), P(1, i32), ONYX_PTR(P(2, i32)), ONYX_PTR(P(3, i32)), ONYX_PTR(P(4, i32))); return NULL; } +ONYX_DEF(alGetBufferfv, (INT, INT, PTR), ()) { alGetBufferfv(P(0, i32), P(1, i32), ONYX_PTR(P(2, i32))); return NULL; } +ONYX_DEF(alGetBufferi, (INT, INT, PTR), ()) { alGetBufferi(P(0, i32), P(1, i32), ONYX_PTR(P(2, i32))); return NULL; } +ONYX_DEF(alGetBuffer3i, (INT, INT, PTR, PTR, PTR), ()) { alGetBuffer3i(P(0, i32), P(1, i32), ONYX_PTR(P(2, i32)), ONYX_PTR(P(3, i32)), ONYX_PTR(P(4, i32))); return NULL; } +ONYX_DEF(alGetBufferiv, (INT, INT, PTR), ()) { alGetBufferiv(P(0, i32), P(1, i32), ONYX_PTR(P(2, i32))); return NULL; } + +ONYX_DEF(alGenSources, (INT, PTR), ()) { + alGenSources(params->data[0].of.i32, ONYX_PTR(params->data[1].of.i32)); + return NULL; +} + +ONYX_DEF(alDeleteSources, (INT, PTR), ()) { + alDeleteSources(params->data[0].of.i32, ONYX_PTR(params->data[1].of.i32)); + return NULL; +} + +ONYX_DEF(alIsSource, (INT), (BOOL)) { + results->data[0] = WASM_I32_VAL(alIsSource(params->data[0].of.i32)); + return NULL; +} + +ONYX_DEF(alSourcef, (INT, INT, FLOAT), ()) { alSourcef(P(0, i32), P(1, i32), P(2, f32)); return NULL; } +ONYX_DEF(alSource3f, (INT, INT, FLOAT, FLOAT, FLOAT), ()) { alSource3f(P(0, i32), P(1, i32), P(2, f32), P(3, f32), P(4, f32)); return NULL; } +ONYX_DEF(alSourcefv, (INT, INT, PTR), ()) { alSourcefv(P(0, i32), P(1, i32), ONYX_PTR(P(2, i32))); return NULL; } +ONYX_DEF(alSourcei, (INT, INT, INT), ()) { alSourcei(P(0, i32), P(1, i32), P(2, i32)); return NULL; } +ONYX_DEF(alSource3i, (INT, INT, INT, INT, INT), ()) { alSource3i(P(0, i32), P(1, i32), P(2, i32), P(3, i32), P(4, i32)); return NULL; } +ONYX_DEF(alSourceiv, (INT, INT, PTR), ()) { alSourceiv(P(0, i32), P(1, i32), ONYX_PTR(P(2, i32))); return NULL; } +ONYX_DEF(alGetSourcef, (INT, INT, PTR), ()) { alGetSourcef(P(0, i32), P(1, i32), ONYX_PTR(P(2, i32))); return NULL; } +ONYX_DEF(alGetSource3f, (INT, INT, PTR, PTR, PTR), ()) { alGetSource3f(P(0, i32), P(1, i32), ONYX_PTR(P(2, i32)), ONYX_PTR(P(3, i32)), ONYX_PTR(P(4, i32))); return NULL; } +ONYX_DEF(alGetSourcefv, (INT, INT, PTR), ()) { alGetSourcefv(P(0, i32), P(1, i32), ONYX_PTR(P(2, i32))); return NULL; } +ONYX_DEF(alGetSourcei, (INT, INT, PTR), ()) { alGetSourcei(P(0, i32), P(1, i32), ONYX_PTR(P(2, i32))); return NULL; } +ONYX_DEF(alGetSource3i, (INT, INT, PTR, PTR, PTR), ()) { alGetSource3i(P(0, i32), P(1, i32), ONYX_PTR(P(2, i32)), ONYX_PTR(P(3, i32)), ONYX_PTR(P(4, i32))); return NULL; } +ONYX_DEF(alGetSourceiv, (INT, INT, PTR), ()) { alGetSourceiv(P(0, i32), P(1, i32), ONYX_PTR(P(2, i32))); return NULL; } + +ONYX_DEF(alSourcePlay, (INT), ()) { alSourcePlay(P(0, i32)); return NULL; } +ONYX_DEF(alSourcePlayv, (INT, PTR), ()) { alSourcePlayv(P(0, i32), ONYX_PTR(P(1, i32))); return NULL; } +ONYX_DEF(alSourcePause, (INT), ()) { alSourcePause(P(0, i32)); return NULL; } +ONYX_DEF(alSourcePausev, (INT, PTR), ()) { alSourcePausev(P(0, i32), ONYX_PTR(P(1, i32))); return NULL; } +ONYX_DEF(alSourceStop, (INT), ()) { alSourceStop(P(0, i32)); return NULL; } +ONYX_DEF(alSourceStopv, (INT, PTR), ()) { alSourceStopv(P(0, i32), ONYX_PTR(P(1, i32))); return NULL; } +ONYX_DEF(alSourceRewind, (INT), ()) { alSourceRewind(P(0, i32)); return NULL; } +ONYX_DEF(alSourceRewindv, (INT, PTR), ()) { alSourceRewindv(P(0, i32), ONYX_PTR(P(1, i32))); return NULL; } +ONYX_DEF(alSourceQueueBuffers, (INT, INT, PTR), ()) { alSourceQueueBuffers(P(0, i32), P(1, i32), ONYX_PTR(P(2, i32))); return NULL; } +ONYX_DEF(alSourceUnqueueBuffers, (INT, INT, PTR), ()) { alSourceUnqueueBuffers(P(0, i32), P(1, i32), ONYX_PTR(P(2, i32))); return NULL; } + +ONYX_DEF(alListenerf, (INT, FLOAT), ()) { alListenerf(P(0, i32), P(1, f32)); return NULL; } +ONYX_DEF(alListener3f, (INT, FLOAT, FLOAT, FLOAT), ()) { alListener3f(P(0, i32), P(1, f32), P(2, f32), P(3, f32)); return NULL; } +ONYX_DEF(alListenerfv, (INT, PTR), ()) { alListenerfv(P(0, i32), ONYX_PTR(P(1, i32))); return NULL; } +ONYX_DEF(alListeneri, (INT, INT), ()) { alListeneri(P(0, i32), P(1, i32)); return NULL; } +ONYX_DEF(alListener3i, (INT, INT, INT, INT), ()) { alListener3i(P(0, i32), P(1, i32), P(2, i32), P(3, i32)); return NULL; } +ONYX_DEF(alListeneriv, (INT, PTR), ()) { alListeneriv(P(0, i32), ONYX_PTR(P(1, i32))); return NULL; } + +ONYX_DEF(alGetListenerf, (INT, PTR), ()) { alGetListenerf(P(0, i32), ONYX_PTR(P(1, i32))); return NULL; } +ONYX_DEF(alGetListener3f, (INT, PTR, PTR, PTR), ()) { alGetListener3f(P(0, i32), ONYX_PTR(P(1, i32)), ONYX_PTR(P(2, i32)), ONYX_PTR(P(3, i32))); return NULL; } +ONYX_DEF(alGetListenerfv, (INT, PTR), ()) { alGetListenerfv(P(0, i32), ONYX_PTR(P(1, i32))); return NULL; } +ONYX_DEF(alGetListeneri, (INT, PTR), ()) { alGetListeneri(P(0, i32), ONYX_PTR(P(1, i32))); return NULL; } +ONYX_DEF(alGetListener3i, (INT, PTR, PTR, PTR), ()) { alGetListener3i(P(0, i32), ONYX_PTR(P(1, i32)), ONYX_PTR(P(2, i32)), ONYX_PTR(P(3, i32))); return NULL; } +ONYX_DEF(alGetListeneriv, (INT, PTR), ()) { alGetListeneriv(P(0, i32), ONYX_PTR(P(1, i32))); return NULL; } + +ONYX_DEF(alEnable, (INT), ()) { alEnable(P(0, i32)); return NULL; } +ONYX_DEF(alDisable, (INT), ()) { alDisable(P(0, i32)); return NULL; } +ONYX_DEF(alIsEnabled, (INT), (BOOL)) { results->data[0] = WASM_I32_VAL(alIsEnabled(P(0, i32))); return NULL; } +ONYX_DEF(alGetBoolean, (INT), (BOOL)) { results->data[0] = WASM_I32_VAL(alGetBoolean(P(0, i32))); return NULL; } +ONYX_DEF(alGetDouble, (INT), (DOUBLE)) { results->data[0] = WASM_F64_VAL(alGetDouble(P(0, i32))); return NULL; } +ONYX_DEF(alGetFloat, (INT), (FLOAT)) { results->data[0] = WASM_F32_VAL(alGetFloat(P(0, i32))); return NULL; } +ONYX_DEF(alGetInteger, (INT), (INT)) { results->data[0] = WASM_I32_VAL(alGetInteger(P(0, i32))); return NULL; } +ONYX_DEF(alGetBooleanv, (INT, PTR), ()) { alGetBooleanv(P(0, i32), ONYX_PTR(P(1, i32))); return NULL; } +ONYX_DEF(alGetDoublev, (INT, PTR), ()) { alGetDoublev(P(0, i32), ONYX_PTR(P(1, i32))); return NULL; } +ONYX_DEF(alGetFloatv, (INT, PTR), ()) { alGetFloatv(P(0, i32), ONYX_PTR(P(1, i32))); return NULL; } +ONYX_DEF(alGetIntegerv, (INT, PTR), ()) { alGetIntegerv(P(0, i32), ONYX_PTR(P(1, i32))); return NULL; } +ONYX_DEF(alDistanceModel, (INT), ()) { alDistanceModel(P(0, i32)); return NULL; } +ONYX_DEF(alDopplerFactor, (FLOAT), ()) { alDistanceModel(P(0, f32)); return NULL; } +ONYX_DEF(alSpeedOfSound, (FLOAT), ()) { alDistanceModel(P(0, f32)); return NULL; } + +ONYX_DEF(alGetError, (), (INT)) { results->data[0] = WASM_I32_VAL(alGetError()); return NULL; } + +ONYX_DEF(alcCreateContext, (LONG, PTR), (LONG)) { wasm_val_init_ptr(&results->data[0], alcCreateContext((ALCdevice *) P(0, i64), ONYX_PTR(P(1, i32)))); return NULL; } +ONYX_DEF(alcMakeContextCurrent, (LONG), (BOOL)) { results->data[0] = WASM_I32_VAL(alcMakeContextCurrent((ALCcontext *) P(0, i64))); return NULL; } +ONYX_DEF(alcProcessContext, (LONG), ()) { alcProcessContext((ALCcontext *) P(0, i64)); return NULL; } +ONYX_DEF(alcSuspendContext, (LONG), ()) { alcSuspendContext((ALCcontext *) P(0, i64)); return NULL; } +ONYX_DEF(alcDestroyContext, (LONG), ()) { alcDestroyContext((ALCcontext *) P(0, i64)); return NULL; } +ONYX_DEF(alcGetCurrentContext, (), (LONG)) { wasm_val_init_ptr(&results->data[0], alcGetCurrentContext()); return NULL; } +ONYX_DEF(alcGetContextsDevice, (LONG), (LONG)) { wasm_val_init_ptr(&results->data[0], alcGetContextsDevice((ALCcontext *) P(0, i64))); return NULL; } +ONYX_DEF(alcGetError, (LONG), (INT)) { results->data[0] = WASM_I32_VAL(alcGetError((ALCdevice *) P(0, i64))); return NULL; } +ONYX_DEF(alcOpenDevice, (PTR), (LONG)) { wasm_val_init_ptr(&results->data[0], alcOpenDevice(ONYX_PTR(P(0, i32)))); return NULL; } +ONYX_DEF(alcCloseDevice, (LONG), (BOOL)) { results->data[0] = WASM_I32_VAL(alcCloseDevice((ALCdevice *) P(0, i64))); return NULL; } + +ONYX_DEF(alcIsExtensionPresent, (LONG, PTR), (BOOL)) { results->data[0] = WASM_I32_VAL(alcIsExtensionPresent((ALCdevice *) P(0, i64), ONYX_PTR(P(1, i32)))); return NULL; } +ONYX_DEF(alcGetProcAddress, (LONG, PTR), (LONG)) { wasm_val_init_ptr(&results->data[0], alcGetProcAddress((ALCdevice *) P(0, i64), ONYX_PTR(P(1, i32)))); return NULL; } +ONYX_DEF(alcGetEnumValue, (LONG, PTR), (INT)) { results->data[0] = WASM_I32_VAL(alcGetEnumValue((ALCdevice *) P(0, i64), ONYX_PTR(P(1, i32)))); return NULL; } +ONYX_DEF(alcGetIntegerv, (LONG, INT, INT, PTR), ()) { alcGetIntegerv((ALCdevice *) P(0, i64), P(1, i32), P(2, i32), ONYX_PTR(P(3, i32))); return NULL; } + +ONYX_DEF(alcCaptureOpenDevice, (PTR, INT, INT, INT), (LONG)) { + wasm_val_init_ptr(&results->data[0], alcCaptureOpenDevice(ONYX_PTR(P(0, i32)), P(1, i32), P(2, i32), P(3, i32))); + return NULL; +} +ONYX_DEF(alcCaptureCloseDevice, (LONG), (BOOL)) { results->data[0] = WASM_I32_VAL(alcCaptureCloseDevice((ALCdevice *) P(0, i64))); return NULL; } +ONYX_DEF(alcCaptureStart, (LONG), ()) { alcCaptureStart((ALCdevice *) P(0, i64)); return NULL; } +ONYX_DEF(alcCaptureStop, (LONG), ()) { alcCaptureStop((ALCdevice *) P(0, i64)); return NULL; } +ONYX_DEF(alcCaptureSamples, (LONG, PTR, INT), ()) { alcCaptureSamples((ALCdevice *) P(0, i64), ONYX_PTR(P(1, i32)), P(2, i32)); return NULL; } + + +ONYX_LIBRARY { + ONYX_FUNC(alGenBuffers) + ONYX_FUNC(alDeleteBuffers) + ONYX_FUNC(alIsBuffer) + ONYX_FUNC(alBufferData) + ONYX_FUNC(alBufferf) + ONYX_FUNC(alBuffer3f) + ONYX_FUNC(alBufferfv) + ONYX_FUNC(alBufferi) + ONYX_FUNC(alBuffer3i) + ONYX_FUNC(alBufferiv) + ONYX_FUNC(alGetBufferf) + ONYX_FUNC(alGetBuffer3f) + ONYX_FUNC(alGetBufferfv) + ONYX_FUNC(alGetBufferi) + ONYX_FUNC(alGetBuffer3i) + ONYX_FUNC(alGetBufferiv) + + ONYX_FUNC(alGenSources) + ONYX_FUNC(alDeleteSources) + ONYX_FUNC(alIsSource) + ONYX_FUNC(alSourcef) + ONYX_FUNC(alSource3f) + ONYX_FUNC(alSourcefv) + ONYX_FUNC(alSourcei) + ONYX_FUNC(alSource3i) + ONYX_FUNC(alSourceiv) + ONYX_FUNC(alGetSourcef) + ONYX_FUNC(alGetSource3f) + ONYX_FUNC(alGetSourcefv) + ONYX_FUNC(alGetSourcei) + ONYX_FUNC(alGetSource3i) + ONYX_FUNC(alGetSourceiv) + ONYX_FUNC(alSourcePlay) + ONYX_FUNC(alSourcePlayv) + ONYX_FUNC(alSourcePause) + ONYX_FUNC(alSourcePausev) + ONYX_FUNC(alSourceStop) + ONYX_FUNC(alSourceStopv) + ONYX_FUNC(alSourceRewind) + ONYX_FUNC(alSourceRewindv) + ONYX_FUNC(alSourceQueueBuffers) + ONYX_FUNC(alSourceUnqueueBuffers) + + ONYX_FUNC(alListenerf) + ONYX_FUNC(alListener3f) + ONYX_FUNC(alListenerfv) + ONYX_FUNC(alListeneri) + ONYX_FUNC(alListener3i) + ONYX_FUNC(alListeneriv) + ONYX_FUNC(alGetListenerf) + ONYX_FUNC(alGetListener3f) + ONYX_FUNC(alGetListenerfv) + ONYX_FUNC(alGetListeneri) + ONYX_FUNC(alGetListener3i) + ONYX_FUNC(alGetListeneriv) + + ONYX_FUNC(alEnable) + ONYX_FUNC(alDisable) + ONYX_FUNC(alIsEnabled) + ONYX_FUNC(alGetBoolean) + ONYX_FUNC(alGetDouble) + ONYX_FUNC(alGetFloat) + ONYX_FUNC(alGetInteger) + ONYX_FUNC(alGetBooleanv) + ONYX_FUNC(alGetDoublev) + ONYX_FUNC(alGetFloatv) + ONYX_FUNC(alGetIntegerv) + ONYX_FUNC(alDistanceModel) + ONYX_FUNC(alDopplerFactor) + ONYX_FUNC(alSpeedOfSound) + + ONYX_FUNC(alGetError) + + ONYX_FUNC(alcCreateContext) + ONYX_FUNC(alcMakeContextCurrent) + ONYX_FUNC(alcProcessContext) + ONYX_FUNC(alcSuspendContext) + ONYX_FUNC(alcDestroyContext) + ONYX_FUNC(alcGetCurrentContext) + ONYX_FUNC(alcGetContextsDevice) + ONYX_FUNC(alcGetError) + + ONYX_FUNC(alcOpenDevice) + ONYX_FUNC(alcCloseDevice) + + ONYX_FUNC(alcIsExtensionPresent) + ONYX_FUNC(alcGetProcAddress) + ONYX_FUNC(alcGetEnumValue) + ONYX_FUNC(alcGetIntegerv) + + ONYX_FUNC(alcCaptureOpenDevice) + ONYX_FUNC(alcCaptureCloseDevice) + ONYX_FUNC(alcCaptureStart) + ONYX_FUNC(alcCaptureStop) + ONYX_FUNC(alcCaptureSamples) + + NULL +}; \ No newline at end of file diff --git a/modules/openal/onyx_openal.so b/modules/openal/onyx_openal.so new file mode 100755 index 00000000..77bd2065 Binary files /dev/null and b/modules/openal/onyx_openal.so differ