From 7f7273fff4d43d71c3ab3b2ab2faf4f4198b2127 Mon Sep 17 00:00:00 2001 From: Joshua Granick Date: Fri, 6 Jan 2017 17:39:10 -0800 Subject: [PATCH] Initial Vorbis bindings, rename lime.audio to lime.media --- docs/ImportAll.hx | 26 +- include.xml | 1 + lime/Lib.hx | 1 + lime/_backend/flash/FlashApplication.hx | 2 +- lime/_backend/flash/FlashAudioSource.hx | 4 +- lime/_backend/html5/HTML5Application.hx | 2 +- lime/_backend/html5/HTML5AudioSource.hx | 4 +- lime/_backend/native/NativeApplication.hx | 2 +- lime/_backend/native/NativeAudioSource.hx | 10 +- lime/_backend/native/NativeCFFI.hx | 32 + lime/app/Preloader.hx | 2 +- lime/audio/ALAudioContext.hx | 647 +------------ lime/audio/ALCAudioContext.hx | 150 +-- lime/audio/AudioBuffer.hx | 452 +-------- lime/audio/AudioContext.hx | 16 +- lime/audio/AudioManager.hx | 155 +-- lime/audio/AudioSource.hx | 174 +--- lime/audio/FlashAudioContext.hx | 217 +---- lime/audio/HTML5AudioContext.hx | 530 +---------- lime/audio/WebAudioContext.hx | 49 +- lime/audio/fmod/FMODChannel.hx | 54 +- lime/audio/fmod/FMODMode.hx | 16 +- lime/audio/fmod/FMODSound.hx | 36 +- lime/audio/howlerjs/Howl.hx | 330 +------ lime/audio/howlerjs/Howler.hx | 95 +- lime/audio/openal/AL.hx | 892 +----------------- lime/audio/openal/ALBuffer.hx | 19 +- lime/audio/openal/ALC.hx | 225 +---- lime/audio/openal/ALContext.hx | 20 +- lime/audio/openal/ALDevice.hx | 20 +- lime/audio/openal/ALSource.hx | 19 +- lime/media/ALAudioContext.hx | 649 +++++++++++++ lime/media/ALCAudioContext.hx | 152 +++ lime/media/AudioBuffer.hx | 454 +++++++++ lime/media/AudioContext.hx | 18 + lime/media/AudioManager.hx | 157 +++ lime/media/AudioSource.hx | 176 ++++ lime/media/FlashAudioContext.hx | 219 +++++ lime/media/HTML5AudioContext.hx | 532 +++++++++++ lime/media/WebAudioContext.hx | 49 + lime/media/codecs/vorbis/Vorbis.hx | 27 + lime/media/codecs/vorbis/VorbisComment.hx | 18 + lime/media/codecs/vorbis/VorbisFile.hx | 385 ++++++++ lime/media/codecs/vorbis/VorbisInfo.hx | 23 + lime/media/fmod/FMODChannel.hx | 54 ++ lime/media/fmod/FMODMode.hx | 16 + lime/media/fmod/FMODSound.hx | 36 + lime/media/howlerjs/Howl.hx | 330 +++++++ lime/media/howlerjs/Howler.hx | 95 ++ lime/media/openal/AL.hx | 892 ++++++++++++++++++ lime/media/openal/ALBuffer.hx | 19 + lime/media/openal/ALC.hx | 225 +++++ lime/media/openal/ALContext.hx | 20 + lime/media/openal/ALDevice.hx | 20 + lime/media/openal/ALSource.hx | 19 + lime/utils/AssetCache.hx | 2 +- lime/utils/AssetLibrary.hx | 2 +- lime/utils/Assets.hx | 2 +- project/Build.xml | 18 +- project/include/hx/CFFIPrimePatch.h | 756 --------------- .../include/{audio => media}/AudioBuffer.h | 4 +- .../{audio/format => media/containers}/OGG.h | 6 +- .../{audio/format => media/containers}/WAV.h | 6 +- project/include/system/CFFIPointer.h | 3 +- project/src/ExternalInterface.cpp | 15 +- project/src/graphics/cairo/CairoBindings.cpp | 3 +- .../src/graphics/opengl/OpenGLBindings.cpp | 3 +- project/src/{audio => media}/AudioBuffer.cpp | 2 +- project/src/media/codecs/VorbisBindings.cpp | 511 ++++++++++ .../format => media/containers}/OGG.cpp | 2 +- .../format => media/containers}/WAV.cpp | 2 +- .../openal/OpenALBindings.cpp | 3 +- project/src/net/curl/CURLBindings.cpp | 3 +- project/src/system/JNI.cpp | 3 +- 74 files changed, 5232 insertions(+), 4901 deletions(-) create mode 100644 lime/media/ALAudioContext.hx create mode 100644 lime/media/ALCAudioContext.hx create mode 100644 lime/media/AudioBuffer.hx create mode 100644 lime/media/AudioContext.hx create mode 100644 lime/media/AudioManager.hx create mode 100644 lime/media/AudioSource.hx create mode 100644 lime/media/FlashAudioContext.hx create mode 100644 lime/media/HTML5AudioContext.hx create mode 100644 lime/media/WebAudioContext.hx create mode 100644 lime/media/codecs/vorbis/Vorbis.hx create mode 100644 lime/media/codecs/vorbis/VorbisComment.hx create mode 100644 lime/media/codecs/vorbis/VorbisFile.hx create mode 100644 lime/media/codecs/vorbis/VorbisInfo.hx create mode 100644 lime/media/fmod/FMODChannel.hx create mode 100644 lime/media/fmod/FMODMode.hx create mode 100644 lime/media/fmod/FMODSound.hx create mode 100644 lime/media/howlerjs/Howl.hx create mode 100644 lime/media/howlerjs/Howler.hx create mode 100644 lime/media/openal/AL.hx create mode 100644 lime/media/openal/ALBuffer.hx create mode 100644 lime/media/openal/ALC.hx create mode 100644 lime/media/openal/ALContext.hx create mode 100644 lime/media/openal/ALDevice.hx create mode 100644 lime/media/openal/ALSource.hx delete mode 100644 project/include/hx/CFFIPrimePatch.h rename project/include/{audio => media}/AudioBuffer.h (91%) rename project/include/{audio/format => media/containers}/OGG.h (61%) rename project/include/{audio/format => media/containers}/WAV.h (86%) rename project/src/{audio => media}/AudioBuffer.cpp (98%) create mode 100644 project/src/media/codecs/VorbisBindings.cpp rename project/src/{audio/format => media/containers}/OGG.cpp (99%) rename project/src/{audio/format => media/containers}/WAV.cpp (99%) rename project/src/{audio => media}/openal/OpenALBindings.cpp (99%) diff --git a/docs/ImportAll.hx b/docs/ImportAll.hx index f94966deb..7ec1520c8 100644 --- a/docs/ImportAll.hx +++ b/docs/ImportAll.hx @@ -9,19 +9,19 @@ import lime.app.IModule; import lime.app.Module; import lime.app.Preloader; import lime.app.Promise; -import lime.audio.openal.AL; -import lime.audio.openal.ALC; -import lime.audio.openal.ALContext; -import lime.audio.openal.ALDevice; -import lime.audio.ALAudioContext; -import lime.audio.ALCAudioContext; -import lime.audio.AudioBuffer; -import lime.audio.AudioContext; -import lime.audio.AudioManager; -import lime.audio.AudioSource; -import lime.audio.FlashAudioContext; -import lime.audio.HTML5AudioContext; -import lime.audio.WebAudioContext; +import lime.media.openal.AL; +import lime.media.openal.ALC; +import lime.media.openal.ALContext; +import lime.media.openal.ALDevice; +import lime.media.ALAudioContext; +import lime.media.ALCAudioContext; +import lime.media.AudioBuffer; +import lime.media.AudioContext; +import lime.media.AudioManager; +import lime.media.AudioSource; +import lime.media.FlashAudioContext; +import lime.media.HTML5AudioContext; +import lime.media.WebAudioContext; import lime.graphics.cairo.Cairo; import lime.graphics.cairo.CairoAntialias; import lime.graphics.cairo.CairoContent; diff --git a/include.xml b/include.xml index 11eb319f4..9908faf12 100644 --- a/include.xml +++ b/include.xml @@ -14,6 +14,7 @@ + diff --git a/lime/Lib.hx b/lime/Lib.hx index 0c73c5f56..00b35b14c 100644 --- a/lime/Lib.hx +++ b/lime/Lib.hx @@ -31,6 +31,7 @@ class Lib { Compiler.define ("lime-cffi"); Compiler.define ("native"); Compiler.define ("lime-curl"); + Compiler.define ("lime-vorbis"); } diff --git a/lime/_backend/flash/FlashApplication.hx b/lime/_backend/flash/FlashApplication.hx index 738c5663a..c8fd85fc2 100644 --- a/lime/_backend/flash/FlashApplication.hx +++ b/lime/_backend/flash/FlashApplication.hx @@ -11,7 +11,7 @@ import flash.ui.Multitouch; import flash.Lib; import lime.app.Application; import lime.app.Config; -import lime.audio.AudioManager; +import lime.media.AudioManager; import lime.graphics.Renderer; import lime.ui.KeyCode; import lime.ui.KeyModifier; diff --git a/lime/_backend/flash/FlashAudioSource.hx b/lime/_backend/flash/FlashAudioSource.hx index 08d6e0858..25cec1522 100644 --- a/lime/_backend/flash/FlashAudioSource.hx +++ b/lime/_backend/flash/FlashAudioSource.hx @@ -2,10 +2,10 @@ package lime._backend.flash; import flash.media.SoundChannel; -import lime.audio.AudioSource; +import lime.media.AudioSource; import lime.math.Vector4; -@:access(lime.audio.AudioBuffer) +@:access(lime.media.AudioBuffer) class FlashAudioSource { diff --git a/lime/_backend/html5/HTML5Application.hx b/lime/_backend/html5/HTML5Application.hx index cf7525828..d4fd5ad43 100644 --- a/lime/_backend/html5/HTML5Application.hx +++ b/lime/_backend/html5/HTML5Application.hx @@ -5,7 +5,7 @@ import js.html.KeyboardEvent; import js.Browser; import lime.app.Application; import lime.app.Config; -import lime.audio.AudioManager; +import lime.media.AudioManager; import lime.graphics.Renderer; import lime.ui.GamepadAxis; import lime.ui.KeyCode; diff --git a/lime/_backend/html5/HTML5AudioSource.hx b/lime/_backend/html5/HTML5AudioSource.hx index b4f22cff9..2cf104d27 100644 --- a/lime/_backend/html5/HTML5AudioSource.hx +++ b/lime/_backend/html5/HTML5AudioSource.hx @@ -1,10 +1,10 @@ package lime._backend.html5; -import lime.audio.AudioSource; +import lime.media.AudioSource; import lime.math.Vector4; -@:access(lime.audio.AudioBuffer) +@:access(lime.media.AudioBuffer) class HTML5AudioSource { diff --git a/lime/_backend/native/NativeApplication.hx b/lime/_backend/native/NativeApplication.hx index f6161cbf6..4d4de1b9f 100644 --- a/lime/_backend/native/NativeApplication.hx +++ b/lime/_backend/native/NativeApplication.hx @@ -5,7 +5,7 @@ import haxe.Timer; import lime._backend.native.NativeCFFI; import lime.app.Application; import lime.app.Config; -import lime.audio.AudioManager; +import lime.media.AudioManager; import lime.graphics.opengl.GL; import lime.graphics.ConsoleRenderContext; import lime.graphics.GLRenderContext; diff --git a/lime/_backend/native/NativeAudioSource.hx b/lime/_backend/native/NativeAudioSource.hx index 16c6815cd..2279ca64c 100644 --- a/lime/_backend/native/NativeAudioSource.hx +++ b/lime/_backend/native/NativeAudioSource.hx @@ -2,10 +2,10 @@ package lime._backend.native; import haxe.Timer; -import lime.audio.AudioManager; -import lime.audio.AudioSource; -import lime.audio.openal.AL; -import lime.audio.openal.ALSource; +import lime.media.AudioManager; +import lime.media.AudioSource; +import lime.media.openal.AL; +import lime.media.openal.ALSource; import lime.math.Vector4; #if !lime_debug @@ -13,7 +13,7 @@ import lime.math.Vector4; @:noDebug #end -@:access(lime.audio.AudioBuffer) +@:access(lime.media.AudioBuffer) class NativeAudioSource { diff --git a/lime/_backend/native/NativeCFFI.hx b/lime/_backend/native/NativeCFFI.hx index 2517f15ce..f01eb04c8 100644 --- a/lime/_backend/native/NativeCFFI.hx +++ b/lime/_backend/native/NativeCFFI.hx @@ -534,5 +534,37 @@ class NativeCFFI { @:cffi private static function lime_gl_viewport (x:Int, y:Int, width:Int, height:Int):Void; #end + #if (lime_cffi && !macro && lime_vorbis) + @:cffi private static function lime_vorbis_file_bitrate (vorbisFile:Dynamic, bitstream:Int):Int; + @:cffi private static function lime_vorbis_file_bitrate_instant (vorbisFile:Dynamic):Int; + @:cffi private static function lime_vorbis_file_clear (vorbisFile:Dynamic):Void; + @:cffi private static function lime_vorbis_file_comment (vorbisFile:Dynamic, bitstream:Int):Dynamic; + @:cffi private static function lime_vorbis_file_crosslap (vorbisFile:Dynamic, otherVorbisFile:Dynamic):Dynamic; + @:cffi private static function lime_vorbis_file_from_bytes (bytes:Dynamic):Dynamic; + @:cffi private static function lime_vorbis_file_from_file (path:String):Dynamic; + @:cffi private static function lime_vorbis_file_info (vorbisFile:Dynamic, bitstream:Int):Dynamic; + @:cffi private static function lime_vorbis_file_pcm_seek (vorbisFile:Dynamic, posLow:Dynamic, posHigh:Dynamic):Int; + @:cffi private static function lime_vorbis_file_pcm_seek_lap (vorbisFile:Dynamic, posLow:Dynamic, posHigh:Dynamic):Int; + @:cffi private static function lime_vorbis_file_pcm_seek_page (vorbisFile:Dynamic, posLow:Dynamic, posHigh:Dynamic):Int; + @:cffi private static function lime_vorbis_file_pcm_seek_page_lap (vorbisFile:Dynamic, posLow:Dynamic, posHigh:Dynamic):Int; + @:cffi private static function lime_vorbis_file_raw_seek (vorbisFile:Dynamic, posLow:Dynamic, posHigh:Dynamic):Int; + @:cffi private static function lime_vorbis_file_raw_seek_lap (vorbisFile:Dynamic, posLow:Dynamic, posHigh:Dynamic):Int; + @:cffi private static function lime_vorbis_file_pcm_tell (vorbisFile:Dynamic):Dynamic; + @:cffi private static function lime_vorbis_file_pcm_total (vorbisFile:Dynamic, bitstream:Int):Dynamic; + @:cffi private static function lime_vorbis_file_raw_tell (vorbisFile:Dynamic):Dynamic; + @:cffi private static function lime_vorbis_file_raw_total (vorbisFile:Dynamic, bitstream:Int):Dynamic; + @:cffi private static function lime_vorbis_file_read (vorbisFile:Dynamic, buffer:Dynamic, length:Int, bigendianp:Bool, word:Int, signed:Bool):Dynamic; + @:cffi private static function lime_vorbis_file_read_float (vorbisFile:Dynamic, pcmChannels:Dynamic, samples:Int):Dynamic; + @:cffi private static function lime_vorbis_file_seekable (vorbisFile:Dynamic):Bool; + @:cffi private static function lime_vorbis_file_serial_number (vorbisFile:Dynamic, bitstream:Int):Int; + @:cffi private static function lime_vorbis_file_streams (vorbisFile:Dynamic):Int; + @:cffi private static function lime_vorbis_file_time_seek (vorbisFile:Dynamic, s:Float):Int; + @:cffi private static function lime_vorbis_file_time_seek_lap (vorbisFile:Dynamic, s:Float):Int; + @:cffi private static function lime_vorbis_file_time_seek_page (vorbisFile:Dynamic, s:Float):Int; + @:cffi private static function lime_vorbis_file_time_seek_page_lap (vorbisFile:Dynamic, s:Float):Int; + @:cffi private static function lime_vorbis_file_time_tell (vorbisFile:Dynamic):Float; + @:cffi private static function lime_vorbis_file_time_total (vorbisFile:Dynamic, bitstream:Int):Float; + #end + } \ No newline at end of file diff --git a/lime/app/Preloader.hx b/lime/app/Preloader.hx index 68decdb56..3eca377f4 100644 --- a/lime/app/Preloader.hx +++ b/lime/app/Preloader.hx @@ -4,7 +4,7 @@ package lime.app; import haxe.io.Bytes; import haxe.io.Path; import lime.app.Event; -import lime.audio.AudioBuffer; +import lime.media.AudioBuffer; import lime.utils.AssetLibrary; import lime.utils.Assets; import lime.utils.AssetType; diff --git a/lime/audio/ALAudioContext.hx b/lime/audio/ALAudioContext.hx index 40fc16650..0be66a39d 100644 --- a/lime/audio/ALAudioContext.hx +++ b/lime/audio/ALAudioContext.hx @@ -1,649 +1,4 @@ package lime.audio; -import lime.audio.openal.AL; -import lime.audio.openal.ALBuffer; -import lime.audio.openal.ALSource; -import lime.utils.ArrayBufferView; - -#if !lime_debug -@:fileXml('tags="haxe,release"') -@:noDebug -#end - - -class ALAudioContext { - - - public var NONE:Int = 0; - public var FALSE:Int = 0; - public var TRUE:Int = 1; - public var SOURCE_RELATIVE:Int = 0x202; - public var CONE_INNER_ANGLE:Int = 0x1001; - public var CONE_OUTER_ANGLE:Int = 0x1002; - public var PITCH:Int = 0x1003; - public var POSITION:Int = 0x1004; - public var DIRECTION:Int = 0x1005; - public var VELOCITY:Int = 0x1006; - public var LOOPING:Int = 0x1007; - public var BUFFER:Int = 0x1009; - public var GAIN:Int = 0x100A; - public var MIN_GAIN:Int = 0x100D; - public var MAX_GAIN:Int = 0x100E; - public var ORIENTATION:Int = 0x100F; - public var SOURCE_STATE:Int = 0x1010; - public var INITIAL:Int = 0x1011; - public var PLAYING:Int = 0x1012; - public var PAUSED:Int = 0x1013; - public var STOPPED:Int = 0x1014; - public var BUFFERS_QUEUED:Int = 0x1015; - public var BUFFERS_PROCESSED:Int = 0x1016; - public var REFERENCE_DISTANCE:Int = 0x1020; - public var ROLLOFF_FACTOR:Int = 0x1021; - public var CONE_OUTER_GAIN:Int = 0x1022; - public var MAX_DISTANCE:Int = 0x1023; - public var SEC_OFFSET:Int = 0x1024; - public var SAMPLE_OFFSET:Int = 0x1025; - public var BYTE_OFFSET:Int = 0x1026; - public var SOURCE_TYPE:Int = 0x1027; - public var STATIC:Int = 0x1028; - public var STREAMING:Int = 0x1029; - public var UNDETERMINED:Int = 0x1030; - public var FORMAT_MONO8:Int = 0x1100; - public var FORMAT_MONO16:Int = 0x1101; - public var FORMAT_STEREO8:Int = 0x1102; - public var FORMAT_STEREO16:Int = 0x1103; - public var FREQUENCY:Int = 0x2001; - public var BITS:Int = 0x2002; - public var CHANNELS:Int = 0x2003; - public var SIZE:Int = 0x2004; - public var NO_ERROR:Int = 0; - public var INVALID_NAME:Int = 0xA001; - public var INVALID_ENUM:Int = 0xA002; - public var INVALID_VALUE:Int = 0xA003; - public var INVALID_OPERATION:Int = 0xA004; - public var OUT_OF_MEMORY:Int = 0xA005; - public var VENDOR:Int = 0xB001; - public var VERSION:Int = 0xB002; - public var RENDERER:Int = 0xB003; - public var EXTENSIONS:Int = 0xB004; - public var DOPPLER_FACTOR:Int = 0xC000; - public var SPEED_OF_SOUND:Int = 0xC003; - public var DOPPLER_VELOCITY:Int = 0xC001; - public var DISTANCE_MODEL:Int = 0xD000; - public var INVERSE_DISTANCE:Int = 0xD001; - public var INVERSE_DISTANCE_CLAMPED:Int = 0xD002; - public var LINEAR_DISTANCE:Int = 0xD003; - public var LINEAR_DISTANCE_CLAMPED:Int = 0xD004; - public var EXPONENT_DISTANCE:Int = 0xD005; - public var EXPONENT_DISTANCE_CLAMPED:Int = 0xD006; - - - public function new () { - - - - } - - - public function bufferData (buffer:ALBuffer, format:Int, data:ArrayBufferView, size:Int, freq:Int):Void { - - AL.bufferData (buffer, format, data, size, freq); - - } - - - public function buffer3f (buffer:ALBuffer, param:Int, value1:Float, value2:Float, value3:Float):Void { - - AL.buffer3f (buffer, param, value1, value2, value3); - - } - - - public function buffer3i (buffer:ALBuffer, param:Int, value1:Int, value2:Int, value3:Int):Void { - - AL.buffer3i (buffer, param, value1, value2, value3); - - } - - - public function bufferf (buffer:ALBuffer, param:Int, value:Float):Void { - - AL.bufferf (buffer, param, value); - - } - - - public function bufferfv (buffer:ALBuffer, param:Int, values:Array):Void { - - AL.bufferfv (buffer, param, values); - - } - - - public function bufferi (buffer:ALBuffer, param:Int, value:Int):Void { - - AL.bufferi (buffer, param, value); - - } - - - public function bufferiv (buffer:ALBuffer, param:Int, values:Array):Void { - - AL.bufferiv (buffer, param, values); - - } - - - public function deleteBuffer (buffer:ALBuffer):Void { - - AL.deleteBuffer (buffer); - - } - - - public function deleteBuffers (buffers:Array):Void { - - AL.deleteBuffers (buffers); - - } - - - public function deleteSource (source:ALSource):Void { - - AL.deleteSource (source); - - } - - - public function deleteSources (sources:Array):Void { - - AL.deleteSources (sources); - - } - - - public function disable (capability:Int):Void { - - AL.disable (capability); - - } - - - public function distanceModel (distanceModel:Int):Void { - - AL.distanceModel (distanceModel); - - } - - - public function dopplerFactor (value:Float):Void { - - AL.dopplerFactor (value); - - } - - - public function dopplerVelocity (value:Float):Void { - - AL.dopplerVelocity (value); - - } - - - public function enable (capability:Int):Void { - - AL.enable (capability); - - } - - - public function genSource ():ALSource { - - return AL.genSource (); - - } - - - public function genSources (n:Int):Array { - - return AL.genSources (n); - - } - - - public function genBuffer ():ALBuffer { - - return AL.genBuffer (); - - } - - - public function genBuffers (n:Int):Array { - - return AL.genBuffers (n); - - } - - - public function getBoolean (param:Int):Bool { - - return AL.getBoolean (param); - - } - - - public function getBooleanv (param:Int, count:Int = 1 ):Array { - - return AL.getBooleanv (param, count); - - } - - - public function getBuffer3f (buffer:ALBuffer, param:Int):Array { - - return AL.getBuffer3f (buffer, param); - - } - - - public function getBuffer3i (buffer:ALBuffer, param:Int):Array { - - return AL.getBuffer3i (buffer, param); - - } - - - public function getBufferf (buffer:ALBuffer, param:Int):Float { - - return AL.getBufferf (buffer, param); - - } - - - public function getBufferfv (buffer:ALBuffer, param:Int, count:Int = 1):Array { - - return AL.getBufferfv (buffer, param, count); - - } - - - public function getBufferi (buffer:ALBuffer, param:Int):Int { - - return AL.getBufferi (buffer, param); - - } - - - public function getBufferiv (buffer:ALBuffer, param:Int, count:Int = 1):Array { - - return AL.getBufferiv (buffer, param, count); - - } - - - public function getDouble (param:Int):Float { - - return AL.getDouble (param); - - } - - - public function getDoublev (param:Int, count:Int = 1):Array { - - return AL.getDoublev (param, count); - - } - - - public function getEnumValue (ename:String):Int { - - return AL.getEnumValue (ename); - - } - - - public function getError ():Int { - - return AL.getError (); - - } - - - public function getErrorString ():String { - - return AL.getErrorString (); - - } - - - public function getFloat (param:Int):Float { - - return AL.getFloat (param); - - } - - - public function getFloatv (param:Int, count:Int = 1):Array { - - return AL.getFloatv (param, count); - - } - - - public function getInteger (param:Int):Int { - - return AL.getInteger (param); - - } - - - public function getIntegerv (param:Int, count:Int = 1):Array { - - return AL.getIntegerv (param, count); - - } - - - public function getListener3f (param:Int):Array { - - return AL.getListener3f (param); - - } - - - public function getListener3i (param:Int):Array { - - return AL.getListener3i (param); - - } - - - public function getListenerf (param:Int):Float { - - return AL.getListenerf (param); - - } - - - public function getListenerfv (param:Int, count:Int = 1):Array { - - return AL.getListenerfv (param, count); - - } - - - public function getListeneri (param:Int):Int { - - return AL.getListeneri (param); - - } - - - public function getListeneriv (param:Int, count:Int = 1):Array { - - return AL.getListeneriv (param, count); - - } - - - public function getProcAddress (fname:String):Dynamic { - - return AL.getProcAddress (fname); - - } - - - public function getSource3f (source:ALSource, param:Int):Array { - - return AL.getSource3f (source, param); - - } - - - public function getSourcef (source:ALSource, param:Int):Float { - - return AL.getSourcef (source, param); - - } - - - public function getSource3i (source:ALSource, param:Int):Array { - - return AL.getSource3i (source, param); - - } - - - public function getSourcefv (source:ALSource, param:Int, count:Int = 1):Array { - - return AL.getSourcefv (source, param); - - } - - - public function getSourcei (source:ALSource, param:Int):Dynamic { - - return AL.getSourcei (source, param); - - } - - - public function getSourceiv (source:ALSource, param:Int, count:Int = 1):Array { - - return AL.getSourceiv (source, param, count); - - } - - - public function getString (param:Int):String { - - return AL.getString (param); - - } - - - public function isBuffer (buffer:ALBuffer):Bool { - - return AL.isBuffer (buffer); - - } - - - public function isEnabled (capability:Int):Bool { - - return AL.isEnabled (capability); - - } - - - public function isExtensionPresent (extname:String):Bool { - - return AL.isExtensionPresent (extname); - - } - - - public function isSource (source:ALSource):Bool { - - return AL.isSource (source); - - } - - - public function listener3f (param:Int, value1:Float, value2:Float, value3:Float):Void { - - AL.listener3f (param, value1, value2, value3); - - } - - - public function listener3i (param:Int, value1:Int, value2:Int, value3:Int):Void { - - AL.listener3i (param, value1, value2, value3); - - } - - - public function listenerf (param:Int, value:Float):Void { - - AL.listenerf (param, value); - - } - - - public function listenerfv (param:Int, values:Array):Void { - - AL.listenerfv (param, values); - - } - - - public function listeneri (param:Int, value:Int):Void { - - AL.listeneri (param, value); - - } - - - public function listeneriv (param:Int, values:Array):Void { - - AL.listeneriv (param, values); - - } - - - public function source3f (source:ALSource, param:Int, value1:Float, value2:Float, value3:Float):Void { - - AL.source3f (source, param, value1, value2, value3); - - } - - - public function source3i (source:ALSource, param:Int, value1:Int, value2:Int, value3:Int):Void { - - AL.source3i (source, param, value1, value2, value3); - - } - - - public function sourcef (source:ALSource, param:Int, value:Float):Void { - - AL.sourcef (source, param, value); - - } - - - public function sourcefv (source:ALSource, param:Int, values:Array):Void { - - AL.sourcefv (source, param, values); - - } - - - public function sourcei (source:ALSource, param:Int, value:Dynamic):Void { - - AL.sourcei (source, param, value); - - } - - - public function sourceiv (source:ALSource, param:Int, values:Array):Void { - - AL.sourceiv (source, param, values); - - } - - - public function sourcePlay (source:ALSource):Void { - - AL.sourcePlay (source); - - } - - - public function sourcePlayv (sources:Array):Void { - - AL.sourcePlayv (sources); - - } - - - public function sourceStop (source:ALSource):Void { - - AL.sourceStop (source); - - } - - - public function sourceStopv (sources:Array):Void { - - AL.sourceStopv (sources); - - } - - - public function sourceRewind (source:ALSource):Void { - - AL.sourceRewind (source); - - } - - - public function sourceRewindv (sources:Array):Void { - - AL.sourceRewindv (sources); - - } - - - public function sourcePause (source:ALSource):Void { - - AL.sourcePause (source); - - } - - - public function sourcePausev (sources:Array):Void { - - AL.sourcePausev (sources); - - } - - - public function sourceQueueBuffer (source:ALSource, buffer:ALBuffer):Void { - - AL.sourceQueueBuffer (source, buffer); - - } - - - public function sourceQueueBuffers (source:ALSource, nb:Int, buffers:Array):Void { - - AL.sourceQueueBuffers (source, nb, buffers); - - } - - - public function sourceUnqueueBuffer (source:ALSource):Int { - - return AL.sourceUnqueueBuffer (source); - - } - - - public function sourceUnqueueBuffers (source:ALSource, nb:Int):Array { - - return AL.sourceUnqueueBuffers (source, nb); - - } - - - public function speedOfSound (value:Float):Void { - - AL.speedOfSound (value); - - } - - -} \ No newline at end of file +@:deprecated("The lime.audio package has been moved to lime.media.*") typedef ALAudioContext = lime.media.openal.ALAudioContext; \ No newline at end of file diff --git a/lime/audio/ALCAudioContext.hx b/lime/audio/ALCAudioContext.hx index 4a9adc463..c3ccb0b33 100644 --- a/lime/audio/ALCAudioContext.hx +++ b/lime/audio/ALCAudioContext.hx @@ -1,152 +1,4 @@ package lime.audio; -import lime.audio.openal.ALC; -import lime.audio.openal.ALContext; -import lime.audio.openal.ALDevice; - -#if !lime_debug -@:fileXml('tags="haxe,release"') -@:noDebug -#end - - -class ALCAudioContext { - - - public var FALSE:Int = 0; - public var TRUE:Int = 1; - public var FREQUENCY:Int = 0x1007; - public var REFRESH:Int = 0x1008; - public var SYNC:Int = 0x1009; - public var MONO_SOURCES:Int = 0x1010; - public var STEREO_SOURCES:Int = 0x1011; - public var NO_ERROR:Int = 0; - public var INVALID_DEVICE:Int = 0xA001; - public var INVALID_CONTEXT:Int = 0xA002; - public var INVALID_ENUM:Int = 0xA003; - public var INVALID_VALUE:Int = 0xA004; - public var OUT_OF_MEMORY:Int = 0xA005; - public var ATTRIBUTES_SIZE:Int = 0x1002; - public var ALL_ATTRIBUTES:Int = 0x1003; - public var DEFAULT_DEVICE_SPECIFIER:Int = 0x1004; - public var DEVICE_SPECIFIER:Int = 0x1005; - public var EXTENSIONS:Int = 0x1006; - public var ENUMERATE_ALL_EXT:Int = 1; - public var DEFAULT_ALL_DEVICES_SPECIFIER:Int = 0x1012; - public var ALL_DEVICES_SPECIFIER:Int = 0x1013; - - - public function new () { - - - - } - - - public function closeDevice (device:ALDevice):Bool { - - return ALC.closeDevice (device); - - } - - - public function createContext (device:ALDevice, attrlist:Array = null):ALContext { - - return ALC.createContext (device, attrlist); - - } - - - public function destroyContext (context:ALContext):Void { - - ALC.destroyContext (context); - - } - - - public function getContextsDevice (context:ALContext):ALDevice { - - return ALC.getContextsDevice (context); - - } - - - public function getCurrentContext ():ALContext { - - return ALC.getCurrentContext (); - - } - - - public function getError (device:ALDevice):Int { - - return ALC.getError (device); - - } - - - public function getErrorString (device:ALDevice):String { - - return ALC.getErrorString (device); - - } - - - public function getIntegerv (device:ALDevice, param:Int, count:Int = 1):Array { - - return ALC.getIntegerv (device, param, count); - - } - - - public function getString (device:ALDevice, param:Int):String { - - return ALC.getString (device, param); - - } - - - public function makeContextCurrent (context:ALContext):Bool { - - return ALC.makeContextCurrent (context); - - } - - - public function openDevice (deviceName:String = null):ALDevice { - - return ALC.openDevice (deviceName); - - } - - - public function pauseDevice (device:ALDevice):Void { - - ALC.pauseDevice (device); - - } - - - public function processContext (context:ALContext):Void { - - ALC.processContext (context); - - } - - - public function resumeDevice (device:ALDevice):Void { - - ALC.resumeDevice (device); - - } - - - public function suspendContext (context:ALContext):Void { - - ALC.suspendContext (context); - - } - - -} \ No newline at end of file +@:deprecated("The lime.audio package has been moved to lime.media.*") typedef ALCAudioContext = lime.media.openal.ALCAudioContext; \ No newline at end of file diff --git a/lime/audio/AudioBuffer.hx b/lime/audio/AudioBuffer.hx index 357657a41..5806ec9be 100644 --- a/lime/audio/AudioBuffer.hx +++ b/lime/audio/AudioBuffer.hx @@ -1,454 +1,4 @@ package lime.audio; -import haxe.io.Bytes; -import haxe.io.Path; -import lime._backend.native.NativeCFFI; -import lime.app.Future; -import lime.app.Promise; -import lime.audio.openal.AL; -import lime.audio.openal.ALBuffer; -import lime.utils.UInt8Array; - -#if howlerjs -import lime.audio.howlerjs.Howl; -#end -#if (js && html5) -import js.html.Audio; -#elseif flash -import flash.media.Sound; -import flash.net.URLRequest; -#elseif lime_console -import lime.audio.fmod.FMODMode; -import lime.audio.fmod.FMODSound; -#end - -@:access(lime._backend.native.NativeCFFI) -@:access(lime.Assets) - -#if !lime_debug -@:fileXml('tags="haxe,release"') -@:noDebug -#end - - -class AudioBuffer { - - - public var bitsPerSample:Int; - public var channels:Int; - public var data:UInt8Array; - public var sampleRate:Int; - public var src (get, set):Dynamic; - - @:noCompletion private var __srcAudio:#if (js && html5) Audio #else Dynamic #end; - @:noCompletion private var __srcBuffer:#if lime_cffi ALBuffer #else Dynamic #end; - @:noCompletion private var __srcCustom:Dynamic; - @:noCompletion private var __srcFMODSound:#if lime_console FMODSound #else Dynamic #end; - @:noCompletion private var __srcHowl:#if howlerjs Howl #else Dynamic #end; - @:noCompletion private var __srcSound:#if flash Sound #else Dynamic #end; - - - public function new () { - - - - } - - - public function dispose ():Void { - - #if (js && html5 && howlerjs) - - __srcHowl.unload (); - - #elseif lime_console - if (channels > 0) { - - src.release (); - channels = 0; - - } - #end - - } - - - #if lime_console - @:void - private static function finalize (a:AudioBuffer):Void { - - a.dispose (); - - } - #end - - - public static function fromBytes (bytes:Bytes):AudioBuffer { - - if (bytes == null) return null; - - #if lime_console - - lime.Lib.notImplemented ("AudioBuffer.fromBytes"); - - #elseif (lime_cffi && !macro) - #if !cs - - var audioBuffer = new AudioBuffer (); - audioBuffer.data = new UInt8Array (Bytes.alloc (0)); - - return NativeCFFI.lime_audio_load (bytes, audioBuffer); - - #else - - var data:Dynamic = NativeCFFI.lime_audio_load (bytes, null); - - if (data != null) { - - var audioBuffer = new AudioBuffer (); - audioBuffer.bitsPerSample = data.bitsPerSample; - audioBuffer.channels = data.channels; - audioBuffer.data = new UInt8Array (@:privateAccess new Bytes (data.data.length, data.data.b)); - audioBuffer.sampleRate = data.sampleRate; - return audioBuffer; - - } - - #end - #end - - return null; - - } - - - public static function fromFile (path:String):AudioBuffer { - - if (path == null) return null; - - #if (js && html5 && howlerjs) - - var audioBuffer = new AudioBuffer (); - audioBuffer.__srcHowl = new Howl ({ src: [ path ] }); - return audioBuffer; - - #elseif flash - - switch (Path.extension (path)) { - - case "ogg", "wav": return null; - default: - - } - - var audioBuffer = new AudioBuffer (); - audioBuffer.__srcSound = new Sound (new URLRequest (path)); - return audioBuffer; - - #elseif lime_console - - var mode = StringTools.endsWith(path, ".wav") ? FMODMode.LOOP_OFF : FMODMode.LOOP_NORMAL; - var sound:FMODSound = FMODSound.fromFile (path, mode); - - if (sound.valid) { - - // TODO(james4k): AudioBuffer needs sound info filled in - // TODO(james4k): probably move fmod.Sound creation to AudioSource, - // and keep AudioBuffer as raw data. not as efficient for typical - // use, but probably less efficient to do complex copy-on-read - // mechanisms and such. also, what do we do for compressed sounds? - // usually don't want to decompress large music files. I suppose we - // can specialize for those and not allow data access. - var audioBuffer = new AudioBuffer (); - audioBuffer.bitsPerSample = 0; - audioBuffer.channels = 1; - audioBuffer.data = null; - audioBuffer.sampleRate = 0; - audioBuffer.__srcFMODSound = sound; - cpp.vm.Gc.setFinalizer (audioBuffer, cpp.Function.fromStaticFunction (finalize)); - return audioBuffer; - - } - - #elseif (lime_cffi && !macro) - #if !cs - - var audioBuffer = new AudioBuffer (); - audioBuffer.data = new UInt8Array (Bytes.alloc (0)); - - return NativeCFFI.lime_audio_load (path, audioBuffer); - - #else - - var data:Dynamic = NativeCFFI.lime_audio_load (path, null); - - if (data != null) { - - var audioBuffer = new AudioBuffer (); - audioBuffer.bitsPerSample = data.bitsPerSample; - audioBuffer.channels = data.channels; - audioBuffer.data = new UInt8Array (@:privateAccess new Bytes (data.data.length, data.data.b)); - audioBuffer.sampleRate = data.sampleRate; - return audioBuffer; - - } - - return null; - - #end - #else - - return null; - - #end - - } - - - public static function fromFiles (paths:Array):AudioBuffer { - - #if (js && html5 && howlerjs) - - var audioBuffer = new AudioBuffer (); - audioBuffer.__srcHowl = new Howl ({ src: paths }); - return audioBuffer; - - #else - - var buffer = null; - - for (path in paths) { - - buffer = AudioBuffer.fromFile (path); - if (buffer != null) break; - - } - - return buffer; - - #end - - } - - - public static function fromURL (url:String, handler:AudioBuffer->Void):Void { - - #if (js && html5 && howlerjs) - - var audioBuffer = new AudioBuffer (); - audioBuffer.__srcHowl = new Howl ({ src: [ url ] }); - audioBuffer.__srcHowl.on ("load", function () { handler (audioBuffer); }); - audioBuffer.__srcHowl.on ("loaderror", function () { handler (null); }); - audioBuffer.__srcHowl.load (); - - #else - - if (url != null && url.indexOf ("http://") == -1 && url.indexOf ("https://") == -1) { - - handler (AudioBuffer.fromFile (url)); - - } else { - - // TODO: Support streaming sound - - #if flash - - var loader = new flash.net.URLLoader (); - loader.addEventListener (flash.events.Event.COMPLETE, function (_) { - handler (AudioBuffer.fromBytes (cast loader.data)); - }); - loader.addEventListener (flash.events.IOErrorEvent.IO_ERROR, function (_) { - handler (null); - }); - loader.load (new flash.net.URLRequest (url)); - - #else - - //var loader = new URLLoader (); - //loader.onComplete.add (function (_) { - //var bytes = Bytes.ofString (loader.data); - //handler (AudioBuffer.fromBytes (bytes)); - //}); - //loader.onIOError.add (function (_, msg) { - //handler (null); - //}); - //loader.load (new URLRequest (url)); - - #end - - } - - #end - - } - - - public static function loadFromFile (path:String):Future { - - var promise = new Promise (); - - var audioBuffer = AudioBuffer.fromFile (path); - - if (audioBuffer != null) { - - #if flash - - audioBuffer.__srcSound.addEventListener (flash.events.Event.COMPLETE, function (event) { - - promise.complete (audioBuffer); - - }); - - audioBuffer.__srcSound.addEventListener (flash.events.ProgressEvent.PROGRESS, function (event) { - - promise.progress (event.bytesLoaded, event.bytesTotal); - - }); - - audioBuffer.__srcSound.addEventListener (flash.events.IOErrorEvent.IO_ERROR, promise.error); - - #elseif (js && html5 && howlerjs) - - if (audioBuffer != null) { - - audioBuffer.__srcHowl.on ("load", function () { - - promise.complete (audioBuffer); - - }); - - audioBuffer.__srcHowl.on ("loaderror", function () { - - promise.error (null); - - }); - - audioBuffer.__srcHowl.load (); - - } - - #else - - promise.complete (audioBuffer); - - #end - - } else { - - promise.error (null); - - } - - return promise.future; - - } - - - public static function loadFromFiles (paths:Array):Future { - - var promise = new Promise (); - - #if (js && html5 && howlerjs) - - var audioBuffer = AudioBuffer.fromFiles (paths); - - if (audioBuffer != null) { - - audioBuffer.__srcHowl.on ("load", function () { - - promise.complete (audioBuffer); - - }); - - audioBuffer.__srcHowl.on ("loaderror", function () { - - promise.error (null); - - }); - - audioBuffer.__srcHowl.load (); - - } else { - - promise.error (null); - - } - - #else - - promise.completeWith (new Future (function () return fromFiles (paths), true)); - - #end - - return promise.future; - - } - - - - - // Get & Set Methods - - - - - private function get_src ():Dynamic { - - #if (js && html5) - #if howlerjs - - return __srcHowl; - - #else - - return __srcAudio; - - #end - #elseif flash - - return __srcSound; - - #elseif lime_console - - return __srcFMODSound; - - #else - - return __srcCustom; - - #end - - } - - - private function set_src (value:Dynamic):Dynamic { - - #if (js && html5) - #if howlerjs - - return __srcHowl = value; - - #else - - return __srcAudio = value; - - #end - #elseif flash - - return __srcSound = value; - - #elseif lime_console - - return __srcFMODSound = value; - - #else - - return __srcCustom = value; - - #end - - } - - -} \ No newline at end of file +@:deprecated("The lime.audio package has been moved to lime.media.*") typedef AudioBuffer = lime.media.AudioBuffer; \ No newline at end of file diff --git a/lime/audio/AudioContext.hx b/lime/audio/AudioContext.hx index d001538e2..3492582e3 100644 --- a/lime/audio/AudioContext.hx +++ b/lime/audio/AudioContext.hx @@ -1,18 +1,4 @@ package lime.audio; -import lime.audio.ALAudioContext; -import lime.audio.FlashAudioContext; -import lime.audio.HTML5AudioContext; -import lime.audio.WebAudioContext; - - -enum AudioContext { - - OPENAL (alc:ALCAudioContext, al:ALAudioContext); - HTML5 (context:HTML5AudioContext); - WEB (context:WebAudioContext); - FLASH (context:FlashAudioContext); - CUSTOM (data:Dynamic); - -} \ No newline at end of file +@:deprecated("The lime.audio package has been moved to lime.media.*") typedef AudioContext = lime.media.AudioContext; \ No newline at end of file diff --git a/lime/audio/AudioManager.hx b/lime/audio/AudioManager.hx index 6b204e0bd..cfe9d9967 100644 --- a/lime/audio/AudioManager.hx +++ b/lime/audio/AudioManager.hx @@ -1,157 +1,4 @@ package lime.audio; -import lime.audio.openal.AL; -import lime.audio.openal.ALC; -import lime.audio.openal.ALContext; -import lime.audio.openal.ALDevice; - -#if (js && html5) -import js.Browser; -#end - -#if !lime_debug -@:fileXml('tags="haxe,release"') -@:noDebug -#end - - -class AudioManager { - - - public static var context:AudioContext; - - - public static function init (context:AudioContext = null) { - - if (AudioManager.context == null) { - - if (context == null) { - - #if (js && html5) - - try { - - untyped __js__ ("window.AudioContext = window.AudioContext || window.webkitAudioContext;"); - AudioManager.context = WEB (cast untyped __js__ ("new AudioContext ()")); - - } catch (e:Dynamic) { - - AudioManager.context = HTML5 (new HTML5AudioContext ()); - - } - - #elseif flash - - AudioManager.context = FLASH (new FlashAudioContext ()); - - #elseif lime_console - - // TODO - AudioManager.context = CUSTOM (null); - - #else - - AudioManager.context = OPENAL (new ALCAudioContext (), new ALAudioContext ()); - - var device = ALC.openDevice (); - var ctx = ALC.createContext (device); - ALC.makeContextCurrent (ctx); - ALC.processContext (ctx); - - #end - - } else { - - AudioManager.context = context; - - } - - } - - } - - - public static function resume ():Void { - - if (context != null) { - - switch (context) { - - case OPENAL (alc, al): - - var currentContext = alc.getCurrentContext (); - - if (currentContext != null) { - - var device = alc.getContextsDevice (currentContext); - alc.resumeDevice (device); - alc.processContext (currentContext); - - } - - default: - - } - - } - - } - - - public static function shutdown ():Void { - - if (context != null) { - - switch (context) { - - case OPENAL (alc, al): - - var currentContext = alc.getCurrentContext (); - - if (currentContext != null) { - - var device = alc.getContextsDevice (currentContext); - alc.makeContextCurrent (null); - alc.destroyContext (currentContext); - alc.closeDevice (device); - - } - - default: - - } - - } - - } - - - public static function suspend ():Void { - - if (context != null) { - - switch (context) { - - case OPENAL (alc, al): - - var currentContext = alc.getCurrentContext (); - - if (currentContext != null) { - - alc.suspendContext (currentContext); - var device = alc.getContextsDevice (currentContext); - alc.pauseDevice (device); - - } - - default: - - } - - } - - } - - -} +@:deprecated("The lime.audio package has been moved to lime.media.*") typedef AudioManager = lime.media.AudioManager; \ No newline at end of file diff --git a/lime/audio/AudioSource.hx b/lime/audio/AudioSource.hx index b56d5e1d2..a9f9963f0 100644 --- a/lime/audio/AudioSource.hx +++ b/lime/audio/AudioSource.hx @@ -1,176 +1,4 @@ package lime.audio; -import lime.app.Event; -import lime.audio.openal.AL; -import lime.audio.openal.ALSource; -import lime.math.Vector4; - -#if !lime_debug -@:fileXml('tags="haxe,release"') -@:noDebug -#end - - -class AudioSource { - - - public var onComplete = new EventVoid> (); - - public var buffer:AudioBuffer; - public var currentTime (get, set):Int; - public var gain (get, set):Float; - public var length (get, set):Int; - public var loops (get, set):Int; - public var offset:Int; - public var position (get, set):Vector4; - - @:noCompletion private var backend:AudioSourceBackend; - - - public function new (buffer:AudioBuffer = null, offset:Int = 0, length:Null = null, loops:Int = 0) { - - this.buffer = buffer; - this.offset = offset; - - backend = new AudioSourceBackend (this); - - if (length != null && length != 0) { - - this.length = length; - - } - - this.loops = loops; - - if (buffer != null) { - - init (); - - } - - } - - - public function dispose ():Void { - - backend.dispose (); - - } - - - private function init ():Void { - - backend.init (); - - } - - - public function play ():Void { - - backend.play (); - - } - - - public function pause ():Void { - - backend.pause (); - - } - - - public function stop ():Void { - - backend.stop (); - - } - - - - - // Get & Set Methods - - - - - private function get_currentTime ():Int { - - return backend.getCurrentTime (); - - } - - - private function set_currentTime (value:Int):Int { - - return backend.setCurrentTime (value); - - } - - - private function get_gain ():Float { - - return backend.getGain (); - - } - - - private function set_gain (value:Float):Float { - - return backend.setGain (value); - - } - - - private function get_length ():Int { - - return backend.getLength (); - - } - - - private function set_length (value:Int):Int { - - return backend.setLength (value); - - } - - - private function get_loops ():Int { - - return backend.getLoops (); - - } - - - private function set_loops (value:Int):Int { - - return backend.setLoops (value); - - } - - - private function get_position ():Vector4 { - - return backend.getPosition (); - - } - - - private function set_position (value:Vector4):Vector4 { - - return backend.setPosition (value); - - } - - -} - - -#if flash -@:noCompletion private typedef AudioSourceBackend = lime._backend.flash.FlashAudioSource; -#elseif (js && html5) -@:noCompletion private typedef AudioSourceBackend = lime._backend.html5.HTML5AudioSource; -#else -@:noCompletion private typedef AudioSourceBackend = lime._backend.native.NativeAudioSource; -#end \ No newline at end of file +@:deprecated("The lime.audio package has been moved to lime.media.*") typedef AudioSource = lime.media.AudioSource; \ No newline at end of file diff --git a/lime/audio/FlashAudioContext.hx b/lime/audio/FlashAudioContext.hx index a7eeb4da1..aa34e8675 100644 --- a/lime/audio/FlashAudioContext.hx +++ b/lime/audio/FlashAudioContext.hx @@ -1,219 +1,4 @@ package lime.audio; -#if flash -import flash.media.Sound; -#end - - -class FlashAudioContext { - - - public function new () { - - - - } - - - public function createBuffer (stream:Dynamic /*URLRequest*/ = null, context:Dynamic /*SoundLoaderContext*/ = null):AudioBuffer { - - #if flash - var buffer = new AudioBuffer (); - buffer.src = new Sound (stream, context); - return buffer; - #else - return null; - #end - - } - - - public function getBytesLoaded (buffer:AudioBuffer):UInt { - - #if flash - if (buffer.src != null) { - - return buffer.src.bytesLoaded; - - } - #end - - return 0; - - } - - - public function getBytesTotal (buffer:AudioBuffer):Int { - - #if flash - if (buffer.src != null) { - - return buffer.src.bytesTotal; - - } - #end - - return 0; - - } - - - public function getID3 (buffer:AudioBuffer):Dynamic /*ID3Info*/ { - - #if flash - if (buffer.src != null) { - - return buffer.src.id3; - - } - #end - - return null; - - } - - - public function getIsBuffering (buffer:AudioBuffer):Bool { - - #if flash - if (buffer.src != null) { - - return buffer.src.isBuffering; - - } - #end - - return false; - - } - - - public function getIsURLInaccessible (buffer:AudioBuffer):Bool { - - #if flash - if (buffer.src != null) { - - return buffer.src.isURLInaccessible; - - } - #end - - return false; - - } - - - public function getLength (buffer:AudioBuffer):Float { - - #if flash - if (buffer.src != null) { - - return buffer.src.length; - - } - #end - - return 0; - - } - - - public function getURL (buffer:AudioBuffer):String { - - #if flash - if (buffer.src != null) { - - return buffer.src.url; - - } - #end - - return null; - - } - - - public function close (buffer:AudioBuffer):Void { - - #if flash - if (buffer.src != null) { - - buffer.src.close (); - - } - #end - - } - - - public function extract (buffer:AudioBuffer, target:Dynamic /*flash.utils.ByteArray*/, length:Float, startPosition:Float = -1):Float { - - #if flash - if (buffer.src != null) { - - return buffer.src.extract (target, length, startPosition); - - } - #end - - return 0; - - } - - - public function load (buffer:AudioBuffer, stream:Dynamic /*flash.net.URLRequest*/, context:Dynamic /*SoundLoaderContext*/ = null):Void { - - #if flash - if (buffer.src != null) { - - buffer.src.load (stream, context); - - } - #end - - } - - - public function loadCompressedDataFromByteArray (buffer:AudioBuffer, bytes:Dynamic /*flash.utils.ByteArray*/, bytesLength:UInt):Void { - - #if flash11 - if (buffer.src != null) { - - buffer.src.loadCompressedDataFromByteArray (bytes, bytesLength); - - } - #end - - } - - - public function loadPCMFromByteArray (buffer:AudioBuffer, bytes:Dynamic /*flash.utils.ByteArray*/, samples:UInt, format:String = null, stereo:Bool = true, sampleRate:Float = 44100):Void { - - #if flash11 - if (buffer.src != null) { - - buffer.src.loadPCMFromByteArray (bytes, samples, format, stereo, sampleRate); - - } - #end - - } - - - public function play (buffer:AudioBuffer, startTime:Float = 0, loops:Int = 0, sndTransform:Dynamic /*SoundTransform*/ = null):Dynamic /*SoundChannel*/ { - - #if flash - if (buffer.src != null) { - - return buffer.src.play (startTime, loops, sndTransform); - - } - #end - - return null; - - } - - -} \ No newline at end of file +@:deprecated("The lime.audio package has been moved to lime.media.*") typedef FlashAudioContext = lime.media.FlashAudioContext; \ No newline at end of file diff --git a/lime/audio/HTML5AudioContext.hx b/lime/audio/HTML5AudioContext.hx index 89fe42ba5..08b379d88 100644 --- a/lime/audio/HTML5AudioContext.hx +++ b/lime/audio/HTML5AudioContext.hx @@ -1,532 +1,4 @@ package lime.audio; -#if (js && html5) -import js.html.Audio; -#end - -@:access(lime.audio.AudioBuffer) - - -class HTML5AudioContext { - - - public var HAVE_CURRENT_DATA:Int = 2; - public var HAVE_ENOUGH_DATA:Int = 4; - public var HAVE_FUTURE_DATA:Int = 3; - public var HAVE_METADATA:Int = 1; - public var HAVE_NOTHING:Int = 0; - public var NETWORK_EMPTY:Int = 0; - public var NETWORK_IDLE:Int = 1; - public var NETWORK_LOADING:Int = 2; - public var NETWORK_NO_SOURCE:Int = 3; - - - public function new () { - - - - } - - - public function canPlayType (buffer:AudioBuffer, type:String):String { - - #if (js && html5) - if (buffer.__srcAudio != null) { - - return buffer.__srcAudio.canPlayType (type); - - } - #end - - return null; - - } - - - public function createBuffer (urlString:String = null):AudioBuffer { - - #if (js && html5) - var buffer = new AudioBuffer (); - buffer.__srcAudio = new Audio (); - buffer.__srcAudio.src = urlString; - return buffer; - #else - return null; - #end - - } - - - public function getAutoplay (buffer:AudioBuffer):Bool { - - #if (js && html5) - if (buffer.__srcAudio != null) { - - return buffer.__srcAudio.autoplay; - - } - #end - - return false; - - } - - - public function getBuffered (buffer:AudioBuffer):Dynamic /*TimeRanges*/ { - - #if (js && html5) - if (buffer.__srcAudio != null) { - - return buffer.__srcAudio.buffered; - - } - #end - - return null; - - } - - - public function getCurrentSrc (buffer:AudioBuffer):String { - - #if (js && html5) - if (buffer.__srcAudio != null) { - - return buffer.__srcAudio.currentSrc; - - } - #end - - return null; - - } - - - public function getCurrentTime (buffer:AudioBuffer):Float { - - #if (js && html5) - if (buffer.__srcAudio != null) { - - return buffer.__srcAudio.currentTime; - - } - #end - - return 0; - - } - - - public function getDefaultPlaybackRate (buffer:AudioBuffer):Float { - - #if (js && html5) - if (buffer.__srcAudio != null) { - - return buffer.__srcAudio.defaultPlaybackRate; - - } - #end - - return 1; - - } - - - public function getDuration (buffer:AudioBuffer):Float { - - #if (js && html5) - if (buffer.__srcAudio != null) { - - return buffer.__srcAudio.duration; - - } - #end - - return 0; - - } - - - public function getEnded (buffer:AudioBuffer):Bool { - - #if (js && html5) - if (buffer.__srcAudio != null) { - - return buffer.__srcAudio.ended; - - } - #end - - return false; - - } - - - public function getError (buffer:AudioBuffer):Dynamic /*MediaError*/ { - - #if (js && html5) - if (buffer.__srcAudio != null) { - - return buffer.__srcAudio.error; - - } - #end - - return null; - - } - - - public function getLoop (buffer:AudioBuffer):Bool { - - #if (js && html5) - if (buffer.__srcAudio != null) { - - return buffer.__srcAudio.loop; - - } - #end - - return false; - - } - - - public function getMuted (buffer:AudioBuffer):Bool { - - #if (js && html5) - if (buffer.__srcAudio != null) { - - return buffer.__srcAudio.muted; - - } - #end - - return false; - - } - - - public function getNetworkState (buffer:AudioBuffer):Int { - - #if (js && html5) - if (buffer.__srcAudio != null) { - - return buffer.__srcAudio.networkState; - - } - #end - - return 0; - - } - - - public function getPaused (buffer:AudioBuffer):Bool { - - #if (js && html5) - if (buffer.__srcAudio != null) { - - return buffer.__srcAudio.paused; - - } - #end - - return false; - - } - - - public function getPlaybackRate (buffer:AudioBuffer):Float { - - #if (js && html5) - if (buffer.__srcAudio != null) { - - return buffer.__srcAudio.playbackRate; - - } - #end - - return 1; - - } - - - public function getPlayed (buffer:AudioBuffer):Dynamic /*TimeRanges*/ { - - #if (js && html5) - if (buffer.__srcAudio != null) { - - return buffer.__srcAudio.played; - - } - #end - - return null; - - } - - - public function getPreload (buffer:AudioBuffer):String { - - #if (js && html5) - if (buffer.__srcAudio != null) { - - return buffer.__srcAudio.preload; - - } - #end - - return null; - - } - - - public function getReadyState (buffer:AudioBuffer):Int { - - #if (js && html5) - if (buffer.__srcAudio != null) { - - return buffer.__srcAudio.readyState; - - } - #end - - return 0; - - } - - - public function getSeekable (buffer:AudioBuffer):Dynamic /*TimeRanges*/ { - - #if (js && html5) - if (buffer.__srcAudio != null) { - - return buffer.__srcAudio.seekable; - - } - #end - - return null; - - } - - - public function getSeeking (buffer:AudioBuffer):Bool { - - #if (js && html5) - if (buffer.__srcAudio != null) { - - return buffer.__srcAudio.seeking; - - } - #end - - return false; - - } - - - public function getSrc (buffer:AudioBuffer):String { - - #if (js && html5) - if (buffer.__srcAudio != null) { - - return buffer.__srcAudio.src; - - } - #end - - return null; - - } - - - public function getStartTime (buffer:AudioBuffer):Float { - - #if (js && html5) - if (buffer.__srcAudio != null) { - - return buffer.__srcAudio.playbackRate; - - } - #end - - return 0; - - } - - - public function getVolume (buffer:AudioBuffer):Float { - - #if (js && html5) - if (buffer.__srcAudio != null) { - - return buffer.__srcAudio.volume; - - } - #end - - return 1; - - } - - - public function load (buffer:AudioBuffer):Void { - - #if (js && html5) - if (buffer.__srcAudio != null) { - - return buffer.__srcAudio.load (); - - } - #end - - } - - - public function pause (buffer:AudioBuffer):Void { - - #if (js && html5) - if (buffer.__srcAudio != null) { - - return buffer.__srcAudio.pause (); - - } - #end - - } - - - public function play (buffer:AudioBuffer):Void { - - #if (js && html5) - if (buffer.__srcAudio != null) { - - return buffer.__srcAudio.play (); - - } - #end - - } - - - public function setAutoplay (buffer:AudioBuffer, value:Bool):Void { - - #if (js && html5) - if (buffer.__srcAudio != null) { - - buffer.__srcAudio.autoplay = value; - - } - #end - - } - - - public function setCurrentTime (buffer:AudioBuffer, value:Float):Void { - - #if (js && html5) - if (buffer.__srcAudio != null) { - - buffer.__srcAudio.currentTime = value; - - } - #end - - } - - - public function setDefaultPlaybackRate (buffer:AudioBuffer, value:Float):Void { - - #if (js && html5) - if (buffer.__srcAudio != null) { - - buffer.__srcAudio.defaultPlaybackRate = value; - - } - #end - - } - - - public function setLoop (buffer:AudioBuffer, value:Bool):Void { - - #if (js && html5) - if (buffer.__srcAudio != null) { - - buffer.__srcAudio.loop = value; - - } - #end - - } - - - public function setMuted (buffer:AudioBuffer, value:Bool):Void { - - #if (js && html5) - if (buffer.__srcAudio != null) { - - buffer.__srcAudio.muted = value; - - } - #end - - } - - - public function setPlaybackRate (buffer:AudioBuffer, value:Float):Void { - - #if (js && html5) - if (buffer.__srcAudio != null) { - - buffer.__srcAudio.playbackRate = value; - - } - #end - - } - - - public function setPreload (buffer:AudioBuffer, value:String):Void { - - #if (js && html5) - if (buffer.__srcAudio != null) { - - buffer.__srcAudio.preload = value; - - } - #end - - } - - - public function setSrc (buffer:AudioBuffer, value:String):Void { - - #if (js && html5) - if (buffer.__srcAudio != null) { - - buffer.__srcAudio.src = value; - - } - #end - - } - - - public function setVolume (buffer:AudioBuffer, value:Float):Void { - - #if (js && html5) - if (buffer.__srcAudio != null) { - - buffer.__srcAudio.volume = value; - - } - #end - - } - - -} \ No newline at end of file +@:deprecated("The lime.audio package has been moved to lime.media.*") typedef HTML5AudioContext = lime.media.HTML5AudioContext; \ No newline at end of file diff --git a/lime/audio/WebAudioContext.hx b/lime/audio/WebAudioContext.hx index cb0a9dc39..d7ba0228b 100644 --- a/lime/audio/WebAudioContext.hx +++ b/lime/audio/WebAudioContext.hx @@ -1,49 +1,4 @@ -package lime.audio; #if (!js || !html5 || display) +package lime.audio; -class WebAudioContext { - - - public var activeSourceCount (default, null):Int; - public var currentTime (default, null):Float; - public var destination (default, null):Dynamic /*AudioDestinationNode*/; - public var listener (default, null):Dynamic /*AudioListener*/; - public var oncomplete:Dynamic /*js.html.EventListener*/; - public var sampleRate (default, null):Float; - - - public function new () { - - - - } - - - public function createAnalyser ():Dynamic /*AnalyserNode*/ { return null; } - public function createBiquadFilter ():Dynamic /*BiquadFilterNode*/ { return null; } - @:overload(function(numberOfChannels:Int, numberOfFrames:Int, sampleRate:Float):Dynamic /*AudioBuffer*/ {}) - public function createBuffer (buffer:Dynamic /*js.html.ArrayBuffer*/, mixToMono:Bool):Dynamic /*AudioBuffer*/ { return null; } - public function createBufferSource ():Dynamic /*AudioBufferSourceNode*/ { return null; } - public function createChannelMerger (?numberOfInputs:Int):Dynamic /*ChannelMergerNode*/ { return null; } - public function createChannelSplitter (?numberOfOutputs:Int):Dynamic /*ChannelSplitterNode*/ { return null; } - public function createConvolver ():Dynamic /*ConvolverNode*/ { return null; } - public function createDelay (?maxDelayTime:Float):Dynamic /*DelayNode*/ { return null; } - public function createDynamicsCompressor ():Dynamic /*DynamicsCompressorNode*/ { return null; } - public function createGain ():Dynamic /*GainNode*/ { return null; } - public function createMediaElementSource (mediaElement:Dynamic /*js.html.MediaElement*/):Dynamic /*MediaElementAudioSourceNode*/ { return null; } - public function createMediaStreamSource (mediaStream:Dynamic /*js.html.rtc.MediaStream*/):Dynamic /*MediaStreamAudioSourceNode*/ { return null; } - public function createOscillator ():Dynamic /*OscillatorNode*/ { return null; } - public function createPanner ():Dynamic /*PannerNode*/ { return null; } - public function createScriptProcessor (bufferSize:Int, ?numberOfInputChannels:Int, ?numberOfOutputChannels:Int):Dynamic /*ScriptProcessorNode*/ { return null; } - public function createWaveShaper ():Dynamic /*WaveShaperNode*/ { return null; } - public function createWaveTable (real:Dynamic /*js.html.Float32Array*/, imag:Dynamic /*js.html.Float32Array*/):Dynamic /*WaveTable*/ { return null; } - public function decodeAudioData (audioData:Dynamic /*js.html.ArrayBuffer*/, successCallback:Dynamic /*AudioBufferCallback*/, ?errorCallback:Dynamic /*AudioBufferCallback*/):Void {} - public function startRendering ():Void {} - - -} - - -#else -typedef WebAudioContext = js.html.audio.AudioContext; -#end \ No newline at end of file +@:deprecated("The lime.audio package has been moved to lime.media.*") typedef WebAudioContext = lime.media.WebAudioContext; \ No newline at end of file diff --git a/lime/audio/fmod/FMODChannel.hx b/lime/audio/fmod/FMODChannel.hx index 26c7dd71c..a95d07f6f 100644 --- a/lime/audio/fmod/FMODChannel.hx +++ b/lime/audio/fmod/FMODChannel.hx @@ -1,54 +1,4 @@ -package lime.audio.fmod; -#if lime_console +package lime.media.fmod; -import lime.ConsoleIncludePaths; - - -@:include("ConsoleFmodChannel.h") -@:native("cpp::Struct") -extern class FMODChannel { - - - // valid is true if this represents a valid handle to a channel. - public var valid (get, never):Bool; - - - // pause sets channel to a paused state. - public function pause ():Void; - - // resume sets channel to an unpaused state. - public function resume ():Void; - - // stop stops the channel from playing, making it available for another - // sound to use. - public function stop ():Void; - - - // getLoopCount retrieves the current loop count for the channel. - public function getLoopCount ():Int; - - // setLoopCount sets the channel to loop count times before stopping. - public function setLoopCount (count:Int):Void; - - // getVolume retrieves the current linear volume level of the channel. - public function getVolume ():cpp.Float32; - - // setVolume sets the channel's linear volume level. - public function setVolume (volume:cpp.Float32):Void; - - - // INVALID represents an invalid channel handle - public static var INVALID (get, never):FMODChannel; - - - private function get_valid ():Bool; - - @:native("lime::ConsoleFmodChannel") - private static function get_INVALID ():FMODChannel; - - -} - - -#end +@:deprecated("The lime.audio package has been moved to lime.media.*") typedef FMODChannel = lime.media.fmod.FMODChannel; \ No newline at end of file diff --git a/lime/audio/fmod/FMODMode.hx b/lime/audio/fmod/FMODMode.hx index 3ee04842f..254a424be 100644 --- a/lime/audio/fmod/FMODMode.hx +++ b/lime/audio/fmod/FMODMode.hx @@ -1,16 +1,4 @@ -package lime.audio.fmod; -#if lime_console +package lime.media.fmod; -import lime.ConsoleIncludePaths; - - -@:enum abstract FMODMode(Int) { - - var LOOP_OFF = 0x00000001; - var LOOP_NORMAL = 0x00000002; - -} - - -#end +@:deprecated("The lime.audio package has been moved to lime.media.*") typedef FMODMode = lime.media.fmod.FMODMode; \ No newline at end of file diff --git a/lime/audio/fmod/FMODSound.hx b/lime/audio/fmod/FMODSound.hx index 7ad4e6e7d..938133964 100644 --- a/lime/audio/fmod/FMODSound.hx +++ b/lime/audio/fmod/FMODSound.hx @@ -1,36 +1,4 @@ -package lime.audio.fmod; -#if lime_console +package lime.media.fmod; -import lime.ConsoleIncludePaths; - - -@:include("ConsoleFmodSound.h") -@:native("cpp::Struct") -extern class FMODSound { - - - // valid returns true if this represents a valid handle to a sound. - public var valid (get, never):Bool; - - - // fromFile creates a sound from the named file. - @:native("lime::ConsoleFmodSound::fromFile") - public static function fromFile (name:String, mode:FMODMode):FMODSound; - - - // play plays the sound and returns the channel it was assigned. - public function play ():FMODChannel; - - - // release releases the sound. - public function release ():Void; - - - private function get_valid ():Bool; - - -} - - -#end +@:deprecated("The lime.audio package has been moved to lime.media.*") typedef FMODSound = lime.media.fmod.FMODSound; \ No newline at end of file diff --git a/lime/audio/howlerjs/Howl.hx b/lime/audio/howlerjs/Howl.hx index dc98032b2..16c0c6c60 100644 --- a/lime/audio/howlerjs/Howl.hx +++ b/lime/audio/howlerjs/Howl.hx @@ -1,330 +1,4 @@ -package lime.audio.howlerjs; #if (!js || !html5 || display) +package lime.media.howlerjs; -import haxe.Constraints.Function; - - -class Howl { - - - public function new (options:HowlOptions) { - - - - } - - - /** - * Get the duration of this sound. Passing a sound id will return the sprite duration. - * @param id The sound id to check. If none is passed, return full source duration. - * @return Audio duration in seconds. - */ - public function duration (?id:Int):Int { - - return 0; - - } - - - /** - * Fade a currently playing sound between two volumes (if no id is passsed, all sounds will fade). - * @param from The value to fade from (0.0 to 1.0). - * @param to The volume to fade to (0.0 to 1.0). - * @param len Time in milliseconds to fade. - * @param id The sound id (omit to fade all sounds). - * @return - */ - public function fade (from:Float, to:Float, len:Int, ?id:Int):Howl { - - return this; - - } - - - /** - * Load the audio file. - * @return - */ - public function load ():Howl { - - return this; - - } - - - /** - * Get/set the loop parameter on a sound. This method can optionally take 0, 1 or 2 arguments. - * loop() -> Returns the group's loop value. - * loop(id) -> Returns the sound id's loop value. - * loop(loop) -> Sets the loop value for all sounds in this Howl group. - * loop(loop, id) -> Sets the loop value of passed sound id. - * @return Returns self or current loop value. - */ - public function loop (?loop:Dynamic, ?id:Int):Dynamic { - - return null; - - } - - - /** - * Mute/unmute a single sound or all sounds in this Howl group. - * @param muted Set to true to mute and false to unmute. - * @param id The sound ID to update (omit to mute/unmute all). - * @return - */ - public function mute (muted:Bool, ?id:Int):Howl { - - return this; - - } - - - /** - * Remove a custom event. Call without parameters to remove all events. - * @param event Event name. - * @param fn Listener to remove. Leave empty to remove all. - * @param id (optional) Only remove events for this sound. - * @return - */ - public function off (event:String, fn:Function, ?id:Int):Howl { - - return this; - - } - - - /** - * Listen to a custom event. - * @param event Event name. - * @param fn Listener to call. - * @param id (optional) Only listen to events for this sound. - * @return - */ - public function on (event:String, fn:Function, ?id:Int):Howl { - - return this; - - } - - - /** - * Listen to a custom event and remove it once fired. - * @param event Event name. - * @param fn Listener to call. - * @param id (optional) Only listen to events for this sound. - * @return - */ - public function once (event:String, fn:Function, ?id:Int):Howl { - - return this; - - } - - - /** - * Pause playback and save current position. - * @param id The sound ID (empty to pause all in group). - * @return - */ - public function pause (?id:Int):Howl { - - return this; - - } - - - /** - * Play a sound or resume previous playback. - * @param sprite Sprite name for sprite playback or sound id to continue previous. - * @return Sound ID. - */ - public function play (?sprite:Dynamic):Int { - - return 0; - - } - - - /** - * Check if a specific sound is currently playing or not (if id is provided), or check if at least one of the sounds in the group is playing or not. - * @param id The sound id to check. If none is passed, the whole sound group is checked. - * @return True if playing and false if not. - */ - public function playing (?id:Int):Bool { - - return false; - - } - - - /** - * Get/set the playback rate of a sound. This method can optionally take 0, 1 or 2 arguments. - * rate() -> Returns the first sound node's current playback rate. - * rate(id) -> Returns the sound id's current playback rate. - * rate(rate) -> Sets the playback rate of all sounds in this Howl group. - * rate(rate, id) -> Sets the playback rate of passed sound id. - * @return Returns self or the current playback rate. - */ - public function rate (?rate:Float, ?id:Int):Dynamic { - - return null; - - } - - - /** - * Get/set the seek position of a sound (in seconds). This method can optionally take 0, 1 or 2 arguments. - * seek() -> Returns the first sound node's current seek position. - * seek(id) -> Returns the sound id's current seek position. - * seek(seek) -> Sets the seek position of the first sound node. - * seek(seek, id) -> Sets the seek position of passed sound id. - * @return Returns self or the current seek position. - */ - public function seek (?seek:Float, ?id:Int):Dynamic { - - return null; - - } - - - /** - * Returns the current loaded state of this Howl. - * @return 'unloaded', 'loading', 'loaded' - */ - public function state ():String { - - return null; - - } - - - /** - * Stop playback and reset to start. - * @param id The sound ID (empty to stop all in group). - * @return - */ - public function stop (?id:Int):Howl { - - return this; - - } - - - /** - * Unload and destroy the current Howl object. - * This will immediately stop all sound instances attached to this group. - */ - public function unload ():Void { - - - - } - - - /** - * Get/set the volume of this sound or of the Howl group. This method can optionally take 0, 1 or 2 arguments. - * volume() -> Returns the group's volume value. - * volume(id) -> Returns the sound id's current volume. - * volume(vol) -> Sets the volume of all sounds in this Howl group. - * volume(vol, id) -> Sets the volume of passed sound id. - * @return Returns self or current volume. - */ - public function volume (?vol:Float, ?id:Int):Dynamic { - - return null; - - } - - -} - - - -#else - - -import haxe.Constraints.Function; -import haxe.extern.EitherType; - -@:native("Howl") - - -extern class Howl { - - - public function new (options:HowlOptions); - - public function duration (?id:Int):Int; - public function fade (from:Float, to:Float, len:Int, ?id:Int):Howl; - public function load ():Howl; - - @:overload(function(id:Int):Bool {}) - @:overload(function(loop:Bool):Howl {}) - @:overload(function(loop:Bool, id:Int):Howl {}) - public function loop ():Bool; - - public function mute (muted:Bool, ?id:Int):Howl; - public function off (event:String, fn:Function, ?id:Int):Howl; - public function on (event:String, fn:Function, ?id:Int):Howl; - public function once (event:String, fn:Function, ?id:Int):Howl; - public function pause (?id:Int):Howl; - - @:overload(function(id:Int):Int {}) - public function play (?sprite:String):Int; - - public function playing (?id:Int):Bool; - - @:overload(function(id:Int):Float {}) - @:overload(function(rate:Float):Howl {}) - @:overload(function(rate:Float, id:Int):Howl {}) - public function rate ():Float; - - public function state ():String; - - @:overload(function(id:Int):Float {}) - @:overload(function(seek:Float):Howl {}) - @:overload(function(seek:Float, id:Int):Howl {}) - public function seek ():Float; - - public function stop (?id:Int):Howl; - public function unload ():Void; - - @:overload(function(id:Int):Float {}) - @:overload(function(vol:Float):Howl {}) - @:overload(function(vol:Float, id:Int):Howl {}) - public function volume ():Float; - - -} - - -#end - - -typedef HowlOptions = { - - src:Array, - ?volume:Float, - ?html5:Bool, - ?loop:Bool, - ?preload:Bool, - ?autoplay:Bool, - ?mute:Bool, - ?sprite:Dynamic, - ?rate:Float, - ?pool:Float, - ?format:Array, - ?onload:Function, - ?onloaderror:Function, - ?onplay:Function, - ?onend:Function, - ?onpause:Function, - ?onstop:Function, - ?onmute:Function, - ?onvolume:Function, - ?onrate:Function, - ?onseek:Function, - ?onfade:Function - -} \ No newline at end of file +@:deprecated("The lime.audio package has been moved to lime.media.*") typedef Howl = lime.media.howlerjs.Howl; \ No newline at end of file diff --git a/lime/audio/howlerjs/Howler.hx b/lime/audio/howlerjs/Howler.hx index 212d54897..e8607b8b2 100644 --- a/lime/audio/howlerjs/Howler.hx +++ b/lime/audio/howlerjs/Howler.hx @@ -1,95 +1,4 @@ -package lime.audio.howlerjs; #if (!js || !html5 || display) +package lime.media.howlerjs; -class Howler { - - - public static var autoSuspend:Bool; - public static var ctx:WebAudioContext; - public static var masterGain:Dynamic; - public static var mobileAutoEnable:Bool; - public static var noAudio:Bool; - public static var usingWebAudio:Bool; - - - /** - * Check for codec support of specific extension. - * @param ext Audio file extention. - * @return - */ - public static function codecs (ext:String):Bool { - - return false; - - } - - - /** - * Handle muting and unmuting globally. - * @param muted Is muted or not. - */ - public static function mute (muted:Bool):Class { - - return Howler; - - } - - - /** - * Unload and destroy all currently loaded Howl objects. - * @return - */ - public static function unload ():Class { - - return Howler; - - } - - - /** - * Get/set the global volume for all sounds. - * @param vol Volume from 0.0 to 1.0. - * @return Returns self or current volume. - */ - public static function volume (?vol:Float):Dynamic { - - if (vol != null) return Howler; - return vol; - - } - - -} - - - -#else - - -import haxe.extern.EitherType; -import js.html.audio.GainNode; -import lime.audio.WebAudioContext; - -@:native("Howler") - - -extern class Howler { - - - public static var autoSuspend:Bool; - public static var ctx:WebAudioContext; - public static var masterGain:GainNode; - public static var mobileAutoEnable:Bool; - public static var noAudio:Bool; - public static var usingWebAudio:Bool; - - public static function codecs (ext:String):Bool; - public static function mute (muted:Bool):Howler; - public static function unload ():Howler; - public static function volume (?vol:Float):EitherType; - - -} - - -#end \ No newline at end of file +@:deprecated("The lime.audio package has been moved to lime.media.*") typedef Howler = lime.media.howlerjs.Howler; \ No newline at end of file diff --git a/lime/audio/openal/AL.hx b/lime/audio/openal/AL.hx index fde77b2e6..f91d1bf5b 100644 --- a/lime/audio/openal/AL.hx +++ b/lime/audio/openal/AL.hx @@ -1,892 +1,4 @@ -package lime.audio.openal; +package lime.media.openal; -import lime._backend.native.NativeCFFI; -import lime.system.CFFIPointer; -import lime.utils.ArrayBufferView; - -#if !lime_debug -@:fileXml('tags="haxe,release"') -@:noDebug -#end - -@:access(lime._backend.native.NativeCFFI) - - -class AL { - - - public static inline var NONE:Int = 0; - public static inline var FALSE:Int = 0; - public static inline var TRUE:Int = 1; - public static inline var SOURCE_RELATIVE:Int = 0x202; - public static inline var CONE_INNER_ANGLE:Int = 0x1001; - public static inline var CONE_OUTER_ANGLE:Int = 0x1002; - public static inline var PITCH:Int = 0x1003; - public static inline var POSITION:Int = 0x1004; - public static inline var DIRECTION:Int = 0x1005; - public static inline var VELOCITY:Int = 0x1006; - public static inline var LOOPING:Int = 0x1007; - public static inline var BUFFER:Int = 0x1009; - public static inline var GAIN:Int = 0x100A; - public static inline var MIN_GAIN:Int = 0x100D; - public static inline var MAX_GAIN:Int = 0x100E; - public static inline var ORIENTATION:Int = 0x100F; - public static inline var SOURCE_STATE:Int = 0x1010; - public static inline var INITIAL:Int = 0x1011; - public static inline var PLAYING:Int = 0x1012; - public static inline var PAUSED:Int = 0x1013; - public static inline var STOPPED:Int = 0x1014; - public static inline var BUFFERS_QUEUED:Int = 0x1015; - public static inline var BUFFERS_PROCESSED:Int = 0x1016; - public static inline var REFERENCE_DISTANCE:Int = 0x1020; - public static inline var ROLLOFF_FACTOR:Int = 0x1021; - public static inline var CONE_OUTER_GAIN:Int = 0x1022; - public static inline var MAX_DISTANCE:Int = 0x1023; - public static inline var SEC_OFFSET:Int = 0x1024; - public static inline var SAMPLE_OFFSET:Int = 0x1025; - public static inline var BYTE_OFFSET:Int = 0x1026; - public static inline var SOURCE_TYPE:Int = 0x1027; - public static inline var STATIC:Int = 0x1028; - public static inline var STREAMING:Int = 0x1029; - public static inline var UNDETERMINED:Int = 0x1030; - public static inline var FORMAT_MONO8:Int = 0x1100; - public static inline var FORMAT_MONO16:Int = 0x1101; - public static inline var FORMAT_STEREO8:Int = 0x1102; - public static inline var FORMAT_STEREO16:Int = 0x1103; - public static inline var FREQUENCY:Int = 0x2001; - public static inline var BITS:Int = 0x2002; - public static inline var CHANNELS:Int = 0x2003; - public static inline var SIZE:Int = 0x2004; - public static inline var NO_ERROR:Int = 0; - public static inline var INVALID_NAME:Int = 0xA001; - public static inline var INVALID_ENUM:Int = 0xA002; - public static inline var INVALID_VALUE:Int = 0xA003; - public static inline var INVALID_OPERATION:Int = 0xA004; - public static inline var OUT_OF_MEMORY:Int = 0xA005; - public static inline var VENDOR:Int = 0xB001; - public static inline var VERSION:Int = 0xB002; - public static inline var RENDERER:Int = 0xB003; - public static inline var EXTENSIONS:Int = 0xB004; - public static inline var DOPPLER_FACTOR:Int = 0xC000; - public static inline var SPEED_OF_SOUND:Int = 0xC003; - public static inline var DOPPLER_VELOCITY:Int = 0xC001; - public static inline var DISTANCE_MODEL:Int = 0xD000; - public static inline var INVERSE_DISTANCE:Int = 0xD001; - public static inline var INVERSE_DISTANCE_CLAMPED:Int = 0xD002; - public static inline var LINEAR_DISTANCE:Int = 0xD003; - public static inline var LINEAR_DISTANCE_CLAMPED:Int = 0xD004; - public static inline var EXPONENT_DISTANCE:Int = 0xD005; - public static inline var EXPONENT_DISTANCE_CLAMPED:Int = 0xD006; - - - public static function bufferData (buffer:ALBuffer, format:Int, data:ArrayBufferView, size:Int, freq:Int):Void { - - #if (lime_cffi && lime_openal && !macro) - NativeCFFI.lime_al_buffer_data (buffer, format, data, size, freq); - #end - - } - - - public static function buffer3f (buffer:ALBuffer, param:Int, value1:Float, value2:Float, value3:Float):Void { - - #if (lime_cffi && lime_openal && !macro) - NativeCFFI.lime_al_buffer3f (buffer, param, value1, value2, value3); - #end - - } - - - public static function buffer3i (buffer:ALBuffer, param:Int, value1:Int, value2:Int, value3:Int):Void { - - #if (lime_cffi && lime_openal && !macro) - NativeCFFI.lime_al_buffer3i (buffer, param, value1, value2, value3); - #end - - } - - - public static function bufferf (buffer:ALBuffer, param:Int, value:Float):Void { - - #if (lime_cffi && lime_openal && !macro) - NativeCFFI.lime_al_bufferf (buffer, param, value); - #end - - } - - - public static function bufferfv (buffer:ALBuffer, param:Int, values:Array):Void { - - #if (lime_cffi && lime_openal && !macro) - NativeCFFI.lime_al_bufferfv (buffer, param, values); - #end - - } - - - public static function bufferi (buffer:ALBuffer, param:Int, value:Int):Void { - - #if (lime_cffi && lime_openal && !macro) - NativeCFFI.lime_al_bufferi (buffer, param, value); - #end - - } - - - public static function bufferiv (buffer:ALBuffer, param:Int, values:Array):Void { - - #if (lime_cffi && lime_openal && !macro) - NativeCFFI.lime_al_bufferiv (buffer, param, values); - #end - - } - - - public static function deleteBuffer (buffer:ALBuffer):Void { - - #if (lime_cffi && lime_openal && !macro) - NativeCFFI.lime_al_delete_buffer (buffer); - #end - - } - - - public static function deleteBuffers (buffers:Array):Void { - - #if (lime_cffi && lime_openal && !macro) - NativeCFFI.lime_al_delete_buffers (buffers.length, buffers); - #end - - } - - - public static function deleteSource (source:ALSource):Void { - - #if (lime_cffi && lime_openal && !macro) - NativeCFFI.lime_al_delete_source (source); - #end - - } - - - public static function deleteSources (sources:Array):Void { - - #if (lime_cffi && lime_openal && !macro) - NativeCFFI.lime_al_delete_sources (sources.length, sources); - #end - - } - - - public static function disable (capability:Int):Void { - - #if (lime_cffi && lime_openal && !macro) - NativeCFFI.lime_al_disable (capability); - #end - - } - - - public static function distanceModel (distanceModel:Int):Void { - - #if (lime_cffi && lime_openal && !macro) - NativeCFFI.lime_al_distance_model (distanceModel); - #end - - } - - - public static function dopplerFactor (value:Float):Void { - - #if (lime_cffi && lime_openal && !macro) - NativeCFFI.lime_al_doppler_factor (value); - #end - - } - - - public static function dopplerVelocity (value:Float):Void { - - #if (lime_cffi && lime_openal && !macro) - NativeCFFI.lime_al_doppler_velocity (value); - #end - - } - - - public static function enable (capability:Int):Void { - - #if (lime_cffi && lime_openal && !macro) - NativeCFFI.lime_al_enable (capability); - #end - - } - - - public static function genSource ():ALSource { - - #if (lime_cffi && lime_openal && !macro) - return NativeCFFI.lime_al_gen_source (); - #else - return null; - #end - - } - - - public static function genSources (n:Int):Array { - - #if (lime_cffi && lime_openal && !macro) - return NativeCFFI.lime_al_gen_sources (n); - #else - return null; - #end - - } - - - public static function genBuffer ():ALBuffer { - - #if (lime_cffi && lime_openal && !macro) - return NativeCFFI.lime_al_gen_buffer (); - #else - return null; - #end - - } - - - public static function genBuffers (n:Int):Array { - - #if (lime_cffi && lime_openal && !macro) - return NativeCFFI.lime_al_gen_buffers (n); - #else - return null; - #end - - } - - - public static function getBoolean (param:Int):Bool { - - #if (lime_cffi && lime_openal && !macro) - return NativeCFFI.lime_al_get_boolean (param); - #else - return false; - #end - - } - - - public static function getBooleanv (param:Int, count:Int = 1):Array { - - #if (lime_cffi && lime_openal && !macro) - return NativeCFFI.lime_al_get_booleanv (param, 1); - #else - return null; - #end - - } - - - public static function getBuffer3f (buffer:ALBuffer, param:Int):Array { - - #if (lime_cffi && lime_openal && !macro) - return NativeCFFI.lime_al_get_buffer3f (buffer, param); - #else - return null; - #end - - } - - - public static function getBuffer3i (buffer:ALBuffer, param:Int):Array { - - #if (lime_cffi && lime_openal && !macro) - return NativeCFFI.lime_al_get_buffer3i (buffer, param); - #else - return null; - #end - - } - - - public static function getBufferf (buffer:ALBuffer, param:Int):Float { - - #if (lime_cffi && lime_openal && !macro) - return NativeCFFI.lime_al_get_bufferf (buffer, param); - #else - return 0; - #end - - } - - - public static function getBufferfv (buffer:ALBuffer, param:Int, count:Int = 1):Array { - - #if (lime_cffi && lime_openal && !macro) - return NativeCFFI.lime_al_get_bufferfv (buffer, param, count); - #else - return null; - #end - - } - - - public static function getBufferi (buffer:ALBuffer, param:Int):Int { - - #if (lime_cffi && lime_openal && !macro) - return NativeCFFI.lime_al_get_bufferi (buffer, param); - #else - return 0; - #end - - } - - - public static function getBufferiv (buffer:ALBuffer, param:Int, count:Int = 1):Array { - - #if (lime_cffi && lime_openal && !macro) - return NativeCFFI.lime_al_get_bufferiv (buffer, param, count); - #else - return null; - #end - - } - - - public static function getDouble (param:Int):Float { - - #if (lime_cffi && lime_openal && !macro) - return NativeCFFI.lime_al_get_double (param); - #else - return 0; - #end - - } - - - public static function getDoublev (param:Int, count:Int = 1):Array { - - #if (lime_cffi && lime_openal && !macro) - return NativeCFFI.lime_al_get_doublev (param, count); - #else - return null; - #end - - } - - - public static function getEnumValue (ename:String):Int { - - #if (lime_cffi && lime_openal && !macro) - return NativeCFFI.lime_al_get_enum_value (ename); - #else - return 0; - #end - - } - - - public static function getError ():Int { - - #if (lime_cffi && lime_openal && !macro) - return NativeCFFI.lime_al_get_error (); - #else - return 0; - #end - - } - - - public static function getErrorString ():String { - - return switch (getError ()) { - - case INVALID_NAME: "INVALID_NAME: Invalid parameter name"; - case INVALID_ENUM: "INVALID_ENUM: Invalid enum value"; - case INVALID_VALUE: "INVALID_VALUE: Invalid parameter value"; - case INVALID_OPERATION: "INVALID_OPERATION: Illegal operation or call"; - case OUT_OF_MEMORY: "OUT_OF_MEMORY: OpenAL has run out of memory"; - default: ""; - - } - - } - - - public static function getFloat (param:Int):Float { - - #if (lime_cffi && lime_openal && !macro) - return NativeCFFI.lime_al_get_float (param); - #else - return 0; - #end - - } - - - public static function getFloatv (param:Int, count:Int = 1):Array { - - #if (lime_cffi && lime_openal && !macro) - return NativeCFFI.lime_al_get_floatv (param, count); - #else - return null; - #end - - } - - - public static function getInteger (param:Int):Int { - - #if (lime_cffi && lime_openal && !macro) - return NativeCFFI.lime_al_get_integer (param); - #else - return 0; - #end - - } - - - public static function getIntegerv (param:Int, count:Int = 1):Array { - - #if (lime_cffi && lime_openal && !macro) - return NativeCFFI.lime_al_get_integerv (param, count); - #else - return null; - #end - - } - - - public static function getListener3f (param:Int):Array { - - #if (lime_cffi && lime_openal && !macro) - return NativeCFFI.lime_al_get_listener3f (param); - #else - return null; - #end - - } - - - public static function getListener3i (param:Int):Array { - - #if (lime_cffi && lime_openal && !macro) - return NativeCFFI.lime_al_get_listener3i (param); - #else - return null; - #end - - } - - - public static function getListenerf (param:Int):Float { - - #if (lime_cffi && lime_openal && !macro) - return NativeCFFI.lime_al_get_listenerf (param); - #else - return 0; - #end - - } - - - public static function getListenerfv (param:Int, count:Int = 1):Array { - - #if (lime_cffi && lime_openal && !macro) - return NativeCFFI.lime_al_get_listenerfv (param, count); - #else - return null; - #end - - } - - - public static function getListeneri (param:Int):Int { - - #if (lime_cffi && lime_openal && !macro) - return NativeCFFI.lime_al_get_listeneri (param); - #else - return 0; - #end - - } - - - public static function getListeneriv (param:Int, count:Int = 1):Array { - - #if (lime_cffi && lime_openal && !macro) - return NativeCFFI.lime_al_get_listeneriv (param, count); - #else - return null; - #end - - } - - - public static function getProcAddress (fname:String):Dynamic { - - #if (lime_cffi && lime_openal && !macro) - return NativeCFFI.lime_al_get_proc_address (fname); - #else - return null; - #end - - } - - - public static function getSource3f (source:ALSource, param:Int):Array { - - #if (lime_cffi && lime_openal && !macro) - return NativeCFFI.lime_al_get_source3f (source, param); - #else - return null; - #end - - } - - - public static function getSourcef (source:ALSource, param:Int):Float { - - #if (lime_cffi && lime_openal && !macro) - return NativeCFFI.lime_al_get_sourcef (source, param); - #else - return 0; - #end - - } - - - public static function getSource3i (source:ALSource, param:Int):Array { - - #if (lime_cffi && lime_openal && !macro) - return NativeCFFI.lime_al_get_source3i (source, param); - #else - return null; - #end - - } - - - public static function getSourcefv (source:ALSource, param:Int, count:Int = 1):Array { - - #if (lime_cffi && lime_openal && !macro) - return NativeCFFI.lime_al_get_sourcefv (source, param, count); - #else - return null; - #end - - } - - - public static function getSourcei (source:ALSource, param:Int):Dynamic { - - #if (lime_cffi && lime_openal && !macro) - return NativeCFFI.lime_al_get_sourcei (source, param); - #else - return 0; - #end - - } - - - public static function getSourceiv (source:ALSource, param:Int, count:Int = 1):Array { - - #if (lime_cffi && lime_openal && !macro) - return NativeCFFI.lime_al_get_sourceiv (source, param, count); - #else - return null; - #end - - } - - - public static function getString (param:Int):String { - - #if (lime_cffi && lime_openal && !macro) - return NativeCFFI.lime_al_get_string (param); - #else - return null; - #end - - } - - - public static function isBuffer (buffer:ALBuffer):Bool { - - #if (lime_cffi && lime_openal && !macro) - return NativeCFFI.lime_al_is_buffer (buffer); - #else - return false; - #end - - } - - - public static function isEnabled (capability:Int):Bool { - - #if (lime_cffi && lime_openal && !macro) - return NativeCFFI.lime_al_is_enabled (capability); - #else - return false; - #end - - } - - - public static function isExtensionPresent (extname:String):Bool { - - #if (lime_cffi && lime_openal && !macro) - return NativeCFFI.lime_al_is_extension_present (extname); - #else - return false; - #end - - } - - - public static function isSource (source:ALSource):Bool { - - #if (lime_cffi && lime_openal && !macro) - return NativeCFFI.lime_al_is_source (source); - #else - return false; - #end - - } - - - public static function listener3f (param:Int, value1:Float, value2:Float, value3:Float):Void { - - #if (lime_cffi && lime_openal && !macro) - NativeCFFI.lime_al_listener3f (param, value1, value2, value3); - #end - - } - - - public static function listener3i (param:Int, value1:Int, value2:Int, value3:Int):Void { - - #if (lime_cffi && lime_openal && !macro) - NativeCFFI.lime_al_listener3i (param, value1, value2, value3); - #end - - } - - - public static function listenerf (param:Int, value:Float):Void { - - #if (lime_cffi && lime_openal && !macro) - NativeCFFI.lime_al_listenerf (param, value); - #end - - } - - - public static function listenerfv (param:Int, values:Array):Void { - - #if (lime_cffi && lime_openal && !macro) - NativeCFFI.lime_al_listenerfv (param, values); - #end - - } - - - public static function listeneri (param:Int, value:Int):Void { - - #if (lime_cffi && lime_openal && !macro) - NativeCFFI.lime_al_listeneri (param, value); - #end - - } - - - public static function listeneriv (param:Int, values:Array):Void { - - #if (lime_cffi && lime_openal && !macro) - NativeCFFI.lime_al_listeneriv (param, values); - #end - - } - - - public static function source3f (source:ALSource, param:Int, value1:Float, value2:Float, value3:Float):Void { - - #if (lime_cffi && lime_openal && !macro) - NativeCFFI.lime_al_source3f (source, param, value1, value2, value3); - #end - - } - - - public static function source3i (source:ALSource, param:Int, value1:Int, value2:Int, value3:Int):Void { - - #if (lime_cffi && lime_openal && !macro) - NativeCFFI.lime_al_source3i (source, param, value1, value2, value3); - #end - - } - - - public static function sourcef (source:ALSource, param:Int, value:Float):Void { - - #if (lime_cffi && lime_openal && !macro) - NativeCFFI.lime_al_sourcef (source, param, value); - #end - - } - - - public static function sourcefv (source:ALSource, param:Int, values:Array):Void { - - #if (lime_cffi && lime_openal && !macro) - NativeCFFI.lime_al_sourcefv (source, param, values); - #end - - } - - - public static function sourcei (source:ALSource, param:Int, value:Dynamic):Void { - - #if (lime_cffi && lime_openal && !macro) - NativeCFFI.lime_al_sourcei (source, param, value); - #end - - } - - - public static function sourceiv (source:ALSource, param:Int, values:Array):Void { - - #if (lime_cffi && lime_openal && !macro) - NativeCFFI.lime_al_sourceiv (source, param, values); - #end - - } - - - public static function sourcePlay (source:ALSource):Void { - - #if (lime_cffi && lime_openal && !macro) - NativeCFFI.lime_al_source_play (source); - #end - - } - - - public static function sourcePlayv (sources:Array):Void { - - #if (lime_cffi && lime_openal && !macro) - NativeCFFI.lime_al_source_playv (sources.length, sources); - #end - - } - - - public static function sourceStop (source:ALSource):Void { - - #if (lime_cffi && lime_openal && !macro) - NativeCFFI.lime_al_source_stop (source); - #end - - } - - - public static function sourceStopv (sources:Array):Void { - - #if (lime_cffi && lime_openal && !macro) - NativeCFFI.lime_al_source_stopv (sources.length, sources); - #end - - } - - - public static function sourceRewind (source:ALSource):Void { - - #if (lime_cffi && lime_openal && !macro) - NativeCFFI.lime_al_source_rewind (source); - #end - - } - - - public static function sourceRewindv (sources:Array):Void { - - #if (lime_cffi && lime_openal && !macro) - NativeCFFI.lime_al_source_rewindv (sources.length, sources); - #end - - } - - - public static function sourcePause (source:ALSource):Void { - - #if (lime_cffi && lime_openal && !macro) - NativeCFFI.lime_al_source_pause (source); - #end - - } - - - public static function sourcePausev (sources:Array):Void { - - #if (lime_cffi && lime_openal && !macro) - NativeCFFI.lime_al_source_pausev (sources.length, sources); - #end - - } - - - public static function sourceQueueBuffer (source:ALSource, buffer:ALBuffer):Void { - - #if (lime_cffi && lime_openal && !macro) - var buffers:Array = [ buffer ]; - NativeCFFI.lime_al_source_queue_buffers (source, 1, buffers); - #end - - } - - - public static function sourceQueueBuffers (source:ALSource, nb:Int, buffers:Array):Void { - - #if (lime_cffi && lime_openal && !macro) - NativeCFFI.lime_al_source_queue_buffers (source, nb, buffers); - #end - - } - - - public static function sourceUnqueueBuffer (source:ALSource):ALBuffer { - - #if (lime_cffi && lime_openal && !macro) - var res = NativeCFFI.lime_al_source_unqueue_buffers (source, 1); - return res[0]; - #else - return 0; - #end - - } - - - public static function sourceUnqueueBuffers (source:ALSource, nb:Int):Array { - - #if (lime_cffi && lime_openal && !macro) - return NativeCFFI.lime_al_source_unqueue_buffers (source, nb); - #else - return null; - #end - - } - - - public static function speedOfSound (value:Float):Void { - - #if (lime_cffi && lime_openal && !macro) - NativeCFFI.lime_al_speed_of_sound (value); - #end - - } - - -} \ No newline at end of file +@:deprecated("The lime.audio package has been moved to lime.media.*") typedef AL = lime.media.openal.AL; \ No newline at end of file diff --git a/lime/audio/openal/ALBuffer.hx b/lime/audio/openal/ALBuffer.hx index 963936584..1a081776d 100644 --- a/lime/audio/openal/ALBuffer.hx +++ b/lime/audio/openal/ALBuffer.hx @@ -1,19 +1,4 @@ -package lime.audio.openal; +package lime.media.openal; -import lime.system.CFFIPointer; - -@:allow(lime.audio.openal.AL) - - -abstract ALBuffer(CFFIPointer) from CFFIPointer to CFFIPointer { - - - private inline function new (handle:CFFIPointer) { - - this = handle; - - } - - -} \ No newline at end of file +@:deprecated("The lime.audio package has been moved to lime.media.*") typedef ALBuffer = lime.media.openal.ALBuffer; \ No newline at end of file diff --git a/lime/audio/openal/ALC.hx b/lime/audio/openal/ALC.hx index 23b908e94..6d53c99fa 100644 --- a/lime/audio/openal/ALC.hx +++ b/lime/audio/openal/ALC.hx @@ -1,225 +1,4 @@ -package lime.audio.openal; +package lime.media.openal; -import lime._backend.native.NativeCFFI; -import lime.system.CFFIPointer; - -#if !lime_debug -@:fileXml('tags="haxe,release"') -@:noDebug -#end - -@:access(lime._backend.native.NativeCFFI) - - -class ALC { - - - public static inline var FALSE:Int = 0; - public static inline var TRUE:Int = 1; - public static inline var FREQUENCY:Int = 0x1007; - public static inline var REFRESH:Int = 0x1008; - public static inline var SYNC:Int = 0x1009; - public static inline var MONO_SOURCES:Int = 0x1010; - public static inline var STEREO_SOURCES:Int = 0x1011; - public static inline var NO_ERROR:Int = 0; - public static inline var INVALID_DEVICE:Int = 0xA001; - public static inline var INVALID_CONTEXT:Int = 0xA002; - public static inline var INVALID_ENUM:Int = 0xA003; - public static inline var INVALID_VALUE:Int = 0xA004; - public static inline var OUT_OF_MEMORY:Int = 0xA005; - public static inline var ATTRIBUTES_SIZE:Int = 0x1002; - public static inline var ALL_ATTRIBUTES:Int = 0x1003; - public static inline var DEFAULT_DEVICE_SPECIFIER:Int = 0x1004; - public static inline var DEVICE_SPECIFIER:Int = 0x1005; - public static inline var EXTENSIONS:Int = 0x1006; - public static inline var ENUMERATE_ALL_EXT:Int = 1; - public static inline var DEFAULT_ALL_DEVICES_SPECIFIER:Int = 0x1012; - public static inline var ALL_DEVICES_SPECIFIER:Int = 0x1013; - - - public static function closeDevice (device:ALDevice):Bool { - - #if (lime_cffi && lime_openal && !macro) - return NativeCFFI.lime_alc_close_device (device); - #else - return false; - #end - - } - - - public static function createContext (device:ALDevice, attrlist:Array = null):ALContext { - - #if (lime_cffi && lime_openal && !macro) - var handle:Dynamic = NativeCFFI.lime_alc_create_context (device, attrlist); - - if (handle != null) { - - return new ALContext (handle); - - } - #end - - return null; - - } - - - public static function destroyContext (context:ALContext):Void { - - #if (lime_cffi && lime_openal && !macro) - NativeCFFI.lime_alc_destroy_context (context); - #end - - } - - - public static function getContextsDevice (context:ALContext):ALDevice { - - #if (lime_cffi && lime_openal && !macro) - var handle:Dynamic = NativeCFFI.lime_alc_get_contexts_device (context); - - if (handle != null) { - - return new ALDevice (handle); - - } - #end - - return null; - - } - - - public static function getCurrentContext ():ALContext { - - #if (lime_cffi && lime_openal && !macro) - var handle:Dynamic = NativeCFFI.lime_alc_get_current_context (); - - if (handle != null) { - - return new ALContext (handle); - - } - #end - - return null; - - } - - - public static function getError (device:ALDevice):Int { - - #if (lime_cffi && lime_openal && !macro) - return NativeCFFI.lime_alc_get_error (device); - #else - return 0; - #end - - } - - - public static function getErrorString (device:ALDevice):String { - - return switch (getError (device)) { - - case INVALID_DEVICE: "INVALID_DEVICE: Invalid device (or no device?)"; - case INVALID_CONTEXT: "INVALID_CONTEXT: Invalid context (or no context?)"; - case INVALID_ENUM: "INVALID_ENUM: Invalid enum value"; - case INVALID_VALUE: "INVALID_VALUE: Invalid param value"; - case OUT_OF_MEMORY: "OUT_OF_MEMORY: OpenAL has run out of memory"; - default: ""; - - } - - } - - - public static function getIntegerv (device:ALDevice, param:Int, size:Int):Array { - - #if (lime_cffi && lime_openal && !macro) - return NativeCFFI.lime_alc_get_integerv (device, param, size); - #else - return null; - #end - - } - - - public static function getString (device:ALDevice, param:Int):String { - - #if (lime_cffi && lime_openal && !macro) - return NativeCFFI.lime_alc_get_string (device, param); - #else - return null; - #end - - } - - - public static function makeContextCurrent (context:ALContext):Bool { - - #if (lime_cffi && lime_openal && !macro) - return NativeCFFI.lime_alc_make_context_current (context); - #else - return false; - #end - - } - - - public static function openDevice (deviceName:String = null):ALDevice { - - #if (lime_cffi && lime_openal && !macro) - var handle:Dynamic = NativeCFFI.lime_alc_open_device (deviceName); - - if (handle != null) { - - return new ALDevice (handle); - - } - #end - - return null; - - } - - - public static function pauseDevice (device:ALDevice):Void { - - #if (lime_cffi && lime_openal && !macro) - NativeCFFI.lime_alc_pause_device (device); - #end - - } - - - public static function processContext (context:ALContext):Void { - - #if (lime_cffi && lime_openal && !macro) - NativeCFFI.lime_alc_process_context (context); - #end - - } - - - public static function resumeDevice (device:ALDevice):Void { - - #if (lime_cffi && lime_openal && !macro) - NativeCFFI.lime_alc_resume_device (device); - #end - - } - - - public static function suspendContext (context:ALContext):Void { - - #if (lime_cffi && lime_openal && !macro) - NativeCFFI.lime_alc_suspend_context (context); - #end - - } - - -} \ No newline at end of file +@:deprecated("The lime.audio package has been moved to lime.media.*") typedef ALC = lime.media.openal.ALC; \ No newline at end of file diff --git a/lime/audio/openal/ALContext.hx b/lime/audio/openal/ALContext.hx index 1aedec2c3..8f941e8cd 100644 --- a/lime/audio/openal/ALContext.hx +++ b/lime/audio/openal/ALContext.hx @@ -1,20 +1,4 @@ -package lime.audio.openal; +package lime.media.openal; -import lime.system.CFFIPointer; - -@:allow(lime.audio.openal.AL) -@:allow(lime.audio.openal.ALC) - - -abstract ALContext(CFFIPointer) from CFFIPointer to CFFIPointer { - - - private inline function new (handle:CFFIPointer) { - - this = handle; - - } - - -} \ No newline at end of file +@:deprecated("The lime.audio package has been moved to lime.media.*") typedef ALContext = lime.media.openal.ALContext; \ No newline at end of file diff --git a/lime/audio/openal/ALDevice.hx b/lime/audio/openal/ALDevice.hx index bec8702f0..f34cc2387 100644 --- a/lime/audio/openal/ALDevice.hx +++ b/lime/audio/openal/ALDevice.hx @@ -1,20 +1,4 @@ -package lime.audio.openal; +package lime.media.openal; -import lime.system.CFFIPointer; - -@:allow(lime.audio.openal.AL) -@:allow(lime.audio.openal.ALC) - - -abstract ALDevice(CFFIPointer) from CFFIPointer to CFFIPointer { - - - private inline function new (handle:CFFIPointer) { - - this = handle; - - } - - -} \ No newline at end of file +@:deprecated("The lime.audio package has been moved to lime.media.*") typedef ALDevice = lime.media.openal.ALDevice; \ No newline at end of file diff --git a/lime/audio/openal/ALSource.hx b/lime/audio/openal/ALSource.hx index 339b7c55d..a08ca74b4 100644 --- a/lime/audio/openal/ALSource.hx +++ b/lime/audio/openal/ALSource.hx @@ -1,19 +1,4 @@ -package lime.audio.openal; +package lime.media.openal; -import lime.system.CFFIPointer; - -@:allow(lime.audio.openal.AL) - - -abstract ALSource(CFFIPointer) from CFFIPointer to CFFIPointer { - - - private inline function new (handle:CFFIPointer) { - - this = handle; - - } - - -} \ No newline at end of file +@:deprecated("The lime.audio package has been moved to lime.media.*") typedef ALSource = lime.media.openal.ALSource; \ No newline at end of file diff --git a/lime/media/ALAudioContext.hx b/lime/media/ALAudioContext.hx new file mode 100644 index 000000000..f3fb6f716 --- /dev/null +++ b/lime/media/ALAudioContext.hx @@ -0,0 +1,649 @@ +package lime.media; + + +import lime.media.openal.AL; +import lime.media.openal.ALBuffer; +import lime.media.openal.ALSource; +import lime.utils.ArrayBufferView; + +#if !lime_debug +@:fileXml('tags="haxe,release"') +@:noDebug +#end + + +class ALAudioContext { + + + public var NONE:Int = 0; + public var FALSE:Int = 0; + public var TRUE:Int = 1; + public var SOURCE_RELATIVE:Int = 0x202; + public var CONE_INNER_ANGLE:Int = 0x1001; + public var CONE_OUTER_ANGLE:Int = 0x1002; + public var PITCH:Int = 0x1003; + public var POSITION:Int = 0x1004; + public var DIRECTION:Int = 0x1005; + public var VELOCITY:Int = 0x1006; + public var LOOPING:Int = 0x1007; + public var BUFFER:Int = 0x1009; + public var GAIN:Int = 0x100A; + public var MIN_GAIN:Int = 0x100D; + public var MAX_GAIN:Int = 0x100E; + public var ORIENTATION:Int = 0x100F; + public var SOURCE_STATE:Int = 0x1010; + public var INITIAL:Int = 0x1011; + public var PLAYING:Int = 0x1012; + public var PAUSED:Int = 0x1013; + public var STOPPED:Int = 0x1014; + public var BUFFERS_QUEUED:Int = 0x1015; + public var BUFFERS_PROCESSED:Int = 0x1016; + public var REFERENCE_DISTANCE:Int = 0x1020; + public var ROLLOFF_FACTOR:Int = 0x1021; + public var CONE_OUTER_GAIN:Int = 0x1022; + public var MAX_DISTANCE:Int = 0x1023; + public var SEC_OFFSET:Int = 0x1024; + public var SAMPLE_OFFSET:Int = 0x1025; + public var BYTE_OFFSET:Int = 0x1026; + public var SOURCE_TYPE:Int = 0x1027; + public var STATIC:Int = 0x1028; + public var STREAMING:Int = 0x1029; + public var UNDETERMINED:Int = 0x1030; + public var FORMAT_MONO8:Int = 0x1100; + public var FORMAT_MONO16:Int = 0x1101; + public var FORMAT_STEREO8:Int = 0x1102; + public var FORMAT_STEREO16:Int = 0x1103; + public var FREQUENCY:Int = 0x2001; + public var BITS:Int = 0x2002; + public var CHANNELS:Int = 0x2003; + public var SIZE:Int = 0x2004; + public var NO_ERROR:Int = 0; + public var INVALID_NAME:Int = 0xA001; + public var INVALID_ENUM:Int = 0xA002; + public var INVALID_VALUE:Int = 0xA003; + public var INVALID_OPERATION:Int = 0xA004; + public var OUT_OF_MEMORY:Int = 0xA005; + public var VENDOR:Int = 0xB001; + public var VERSION:Int = 0xB002; + public var RENDERER:Int = 0xB003; + public var EXTENSIONS:Int = 0xB004; + public var DOPPLER_FACTOR:Int = 0xC000; + public var SPEED_OF_SOUND:Int = 0xC003; + public var DOPPLER_VELOCITY:Int = 0xC001; + public var DISTANCE_MODEL:Int = 0xD000; + public var INVERSE_DISTANCE:Int = 0xD001; + public var INVERSE_DISTANCE_CLAMPED:Int = 0xD002; + public var LINEAR_DISTANCE:Int = 0xD003; + public var LINEAR_DISTANCE_CLAMPED:Int = 0xD004; + public var EXPONENT_DISTANCE:Int = 0xD005; + public var EXPONENT_DISTANCE_CLAMPED:Int = 0xD006; + + + public function new () { + + + + } + + + public function bufferData (buffer:ALBuffer, format:Int, data:ArrayBufferView, size:Int, freq:Int):Void { + + AL.bufferData (buffer, format, data, size, freq); + + } + + + public function buffer3f (buffer:ALBuffer, param:Int, value1:Float, value2:Float, value3:Float):Void { + + AL.buffer3f (buffer, param, value1, value2, value3); + + } + + + public function buffer3i (buffer:ALBuffer, param:Int, value1:Int, value2:Int, value3:Int):Void { + + AL.buffer3i (buffer, param, value1, value2, value3); + + } + + + public function bufferf (buffer:ALBuffer, param:Int, value:Float):Void { + + AL.bufferf (buffer, param, value); + + } + + + public function bufferfv (buffer:ALBuffer, param:Int, values:Array):Void { + + AL.bufferfv (buffer, param, values); + + } + + + public function bufferi (buffer:ALBuffer, param:Int, value:Int):Void { + + AL.bufferi (buffer, param, value); + + } + + + public function bufferiv (buffer:ALBuffer, param:Int, values:Array):Void { + + AL.bufferiv (buffer, param, values); + + } + + + public function deleteBuffer (buffer:ALBuffer):Void { + + AL.deleteBuffer (buffer); + + } + + + public function deleteBuffers (buffers:Array):Void { + + AL.deleteBuffers (buffers); + + } + + + public function deleteSource (source:ALSource):Void { + + AL.deleteSource (source); + + } + + + public function deleteSources (sources:Array):Void { + + AL.deleteSources (sources); + + } + + + public function disable (capability:Int):Void { + + AL.disable (capability); + + } + + + public function distanceModel (distanceModel:Int):Void { + + AL.distanceModel (distanceModel); + + } + + + public function dopplerFactor (value:Float):Void { + + AL.dopplerFactor (value); + + } + + + public function dopplerVelocity (value:Float):Void { + + AL.dopplerVelocity (value); + + } + + + public function enable (capability:Int):Void { + + AL.enable (capability); + + } + + + public function genSource ():ALSource { + + return AL.genSource (); + + } + + + public function genSources (n:Int):Array { + + return AL.genSources (n); + + } + + + public function genBuffer ():ALBuffer { + + return AL.genBuffer (); + + } + + + public function genBuffers (n:Int):Array { + + return AL.genBuffers (n); + + } + + + public function getBoolean (param:Int):Bool { + + return AL.getBoolean (param); + + } + + + public function getBooleanv (param:Int, count:Int = 1 ):Array { + + return AL.getBooleanv (param, count); + + } + + + public function getBuffer3f (buffer:ALBuffer, param:Int):Array { + + return AL.getBuffer3f (buffer, param); + + } + + + public function getBuffer3i (buffer:ALBuffer, param:Int):Array { + + return AL.getBuffer3i (buffer, param); + + } + + + public function getBufferf (buffer:ALBuffer, param:Int):Float { + + return AL.getBufferf (buffer, param); + + } + + + public function getBufferfv (buffer:ALBuffer, param:Int, count:Int = 1):Array { + + return AL.getBufferfv (buffer, param, count); + + } + + + public function getBufferi (buffer:ALBuffer, param:Int):Int { + + return AL.getBufferi (buffer, param); + + } + + + public function getBufferiv (buffer:ALBuffer, param:Int, count:Int = 1):Array { + + return AL.getBufferiv (buffer, param, count); + + } + + + public function getDouble (param:Int):Float { + + return AL.getDouble (param); + + } + + + public function getDoublev (param:Int, count:Int = 1):Array { + + return AL.getDoublev (param, count); + + } + + + public function getEnumValue (ename:String):Int { + + return AL.getEnumValue (ename); + + } + + + public function getError ():Int { + + return AL.getError (); + + } + + + public function getErrorString ():String { + + return AL.getErrorString (); + + } + + + public function getFloat (param:Int):Float { + + return AL.getFloat (param); + + } + + + public function getFloatv (param:Int, count:Int = 1):Array { + + return AL.getFloatv (param, count); + + } + + + public function getInteger (param:Int):Int { + + return AL.getInteger (param); + + } + + + public function getIntegerv (param:Int, count:Int = 1):Array { + + return AL.getIntegerv (param, count); + + } + + + public function getListener3f (param:Int):Array { + + return AL.getListener3f (param); + + } + + + public function getListener3i (param:Int):Array { + + return AL.getListener3i (param); + + } + + + public function getListenerf (param:Int):Float { + + return AL.getListenerf (param); + + } + + + public function getListenerfv (param:Int, count:Int = 1):Array { + + return AL.getListenerfv (param, count); + + } + + + public function getListeneri (param:Int):Int { + + return AL.getListeneri (param); + + } + + + public function getListeneriv (param:Int, count:Int = 1):Array { + + return AL.getListeneriv (param, count); + + } + + + public function getProcAddress (fname:String):Dynamic { + + return AL.getProcAddress (fname); + + } + + + public function getSource3f (source:ALSource, param:Int):Array { + + return AL.getSource3f (source, param); + + } + + + public function getSourcef (source:ALSource, param:Int):Float { + + return AL.getSourcef (source, param); + + } + + + public function getSource3i (source:ALSource, param:Int):Array { + + return AL.getSource3i (source, param); + + } + + + public function getSourcefv (source:ALSource, param:Int, count:Int = 1):Array { + + return AL.getSourcefv (source, param); + + } + + + public function getSourcei (source:ALSource, param:Int):Dynamic { + + return AL.getSourcei (source, param); + + } + + + public function getSourceiv (source:ALSource, param:Int, count:Int = 1):Array { + + return AL.getSourceiv (source, param, count); + + } + + + public function getString (param:Int):String { + + return AL.getString (param); + + } + + + public function isBuffer (buffer:ALBuffer):Bool { + + return AL.isBuffer (buffer); + + } + + + public function isEnabled (capability:Int):Bool { + + return AL.isEnabled (capability); + + } + + + public function isExtensionPresent (extname:String):Bool { + + return AL.isExtensionPresent (extname); + + } + + + public function isSource (source:ALSource):Bool { + + return AL.isSource (source); + + } + + + public function listener3f (param:Int, value1:Float, value2:Float, value3:Float):Void { + + AL.listener3f (param, value1, value2, value3); + + } + + + public function listener3i (param:Int, value1:Int, value2:Int, value3:Int):Void { + + AL.listener3i (param, value1, value2, value3); + + } + + + public function listenerf (param:Int, value:Float):Void { + + AL.listenerf (param, value); + + } + + + public function listenerfv (param:Int, values:Array):Void { + + AL.listenerfv (param, values); + + } + + + public function listeneri (param:Int, value:Int):Void { + + AL.listeneri (param, value); + + } + + + public function listeneriv (param:Int, values:Array):Void { + + AL.listeneriv (param, values); + + } + + + public function source3f (source:ALSource, param:Int, value1:Float, value2:Float, value3:Float):Void { + + AL.source3f (source, param, value1, value2, value3); + + } + + + public function source3i (source:ALSource, param:Int, value1:Int, value2:Int, value3:Int):Void { + + AL.source3i (source, param, value1, value2, value3); + + } + + + public function sourcef (source:ALSource, param:Int, value:Float):Void { + + AL.sourcef (source, param, value); + + } + + + public function sourcefv (source:ALSource, param:Int, values:Array):Void { + + AL.sourcefv (source, param, values); + + } + + + public function sourcei (source:ALSource, param:Int, value:Dynamic):Void { + + AL.sourcei (source, param, value); + + } + + + public function sourceiv (source:ALSource, param:Int, values:Array):Void { + + AL.sourceiv (source, param, values); + + } + + + public function sourcePlay (source:ALSource):Void { + + AL.sourcePlay (source); + + } + + + public function sourcePlayv (sources:Array):Void { + + AL.sourcePlayv (sources); + + } + + + public function sourceStop (source:ALSource):Void { + + AL.sourceStop (source); + + } + + + public function sourceStopv (sources:Array):Void { + + AL.sourceStopv (sources); + + } + + + public function sourceRewind (source:ALSource):Void { + + AL.sourceRewind (source); + + } + + + public function sourceRewindv (sources:Array):Void { + + AL.sourceRewindv (sources); + + } + + + public function sourcePause (source:ALSource):Void { + + AL.sourcePause (source); + + } + + + public function sourcePausev (sources:Array):Void { + + AL.sourcePausev (sources); + + } + + + public function sourceQueueBuffer (source:ALSource, buffer:ALBuffer):Void { + + AL.sourceQueueBuffer (source, buffer); + + } + + + public function sourceQueueBuffers (source:ALSource, nb:Int, buffers:Array):Void { + + AL.sourceQueueBuffers (source, nb, buffers); + + } + + + public function sourceUnqueueBuffer (source:ALSource):Int { + + return AL.sourceUnqueueBuffer (source); + + } + + + public function sourceUnqueueBuffers (source:ALSource, nb:Int):Array { + + return AL.sourceUnqueueBuffers (source, nb); + + } + + + public function speedOfSound (value:Float):Void { + + AL.speedOfSound (value); + + } + + +} \ No newline at end of file diff --git a/lime/media/ALCAudioContext.hx b/lime/media/ALCAudioContext.hx new file mode 100644 index 000000000..4c23fa902 --- /dev/null +++ b/lime/media/ALCAudioContext.hx @@ -0,0 +1,152 @@ +package lime.media; + + +import lime.media.openal.ALC; +import lime.media.openal.ALContext; +import lime.media.openal.ALDevice; + +#if !lime_debug +@:fileXml('tags="haxe,release"') +@:noDebug +#end + + +class ALCAudioContext { + + + public var FALSE:Int = 0; + public var TRUE:Int = 1; + public var FREQUENCY:Int = 0x1007; + public var REFRESH:Int = 0x1008; + public var SYNC:Int = 0x1009; + public var MONO_SOURCES:Int = 0x1010; + public var STEREO_SOURCES:Int = 0x1011; + public var NO_ERROR:Int = 0; + public var INVALID_DEVICE:Int = 0xA001; + public var INVALID_CONTEXT:Int = 0xA002; + public var INVALID_ENUM:Int = 0xA003; + public var INVALID_VALUE:Int = 0xA004; + public var OUT_OF_MEMORY:Int = 0xA005; + public var ATTRIBUTES_SIZE:Int = 0x1002; + public var ALL_ATTRIBUTES:Int = 0x1003; + public var DEFAULT_DEVICE_SPECIFIER:Int = 0x1004; + public var DEVICE_SPECIFIER:Int = 0x1005; + public var EXTENSIONS:Int = 0x1006; + public var ENUMERATE_ALL_EXT:Int = 1; + public var DEFAULT_ALL_DEVICES_SPECIFIER:Int = 0x1012; + public var ALL_DEVICES_SPECIFIER:Int = 0x1013; + + + public function new () { + + + + } + + + public function closeDevice (device:ALDevice):Bool { + + return ALC.closeDevice (device); + + } + + + public function createContext (device:ALDevice, attrlist:Array = null):ALContext { + + return ALC.createContext (device, attrlist); + + } + + + public function destroyContext (context:ALContext):Void { + + ALC.destroyContext (context); + + } + + + public function getContextsDevice (context:ALContext):ALDevice { + + return ALC.getContextsDevice (context); + + } + + + public function getCurrentContext ():ALContext { + + return ALC.getCurrentContext (); + + } + + + public function getError (device:ALDevice):Int { + + return ALC.getError (device); + + } + + + public function getErrorString (device:ALDevice):String { + + return ALC.getErrorString (device); + + } + + + public function getIntegerv (device:ALDevice, param:Int, count:Int = 1):Array { + + return ALC.getIntegerv (device, param, count); + + } + + + public function getString (device:ALDevice, param:Int):String { + + return ALC.getString (device, param); + + } + + + public function makeContextCurrent (context:ALContext):Bool { + + return ALC.makeContextCurrent (context); + + } + + + public function openDevice (deviceName:String = null):ALDevice { + + return ALC.openDevice (deviceName); + + } + + + public function pauseDevice (device:ALDevice):Void { + + ALC.pauseDevice (device); + + } + + + public function processContext (context:ALContext):Void { + + ALC.processContext (context); + + } + + + public function resumeDevice (device:ALDevice):Void { + + ALC.resumeDevice (device); + + } + + + public function suspendContext (context:ALContext):Void { + + ALC.suspendContext (context); + + } + + +} \ No newline at end of file diff --git a/lime/media/AudioBuffer.hx b/lime/media/AudioBuffer.hx new file mode 100644 index 000000000..3452ee7fa --- /dev/null +++ b/lime/media/AudioBuffer.hx @@ -0,0 +1,454 @@ +package lime.media; + + +import haxe.io.Bytes; +import haxe.io.Path; +import lime._backend.native.NativeCFFI; +import lime.app.Future; +import lime.app.Promise; +import lime.media.openal.AL; +import lime.media.openal.ALBuffer; +import lime.utils.UInt8Array; + +#if howlerjs +import lime.media.howlerjs.Howl; +#end +#if (js && html5) +import js.html.Audio; +#elseif flash +import flash.media.Sound; +import flash.net.URLRequest; +#elseif lime_console +import lime.media.fmod.FMODMode; +import lime.media.fmod.FMODSound; +#end + +@:access(lime._backend.native.NativeCFFI) +@:access(lime.Assets) + +#if !lime_debug +@:fileXml('tags="haxe,release"') +@:noDebug +#end + + +class AudioBuffer { + + + public var bitsPerSample:Int; + public var channels:Int; + public var data:UInt8Array; + public var sampleRate:Int; + public var src (get, set):Dynamic; + + @:noCompletion private var __srcAudio:#if (js && html5) Audio #else Dynamic #end; + @:noCompletion private var __srcBuffer:#if lime_cffi ALBuffer #else Dynamic #end; + @:noCompletion private var __srcCustom:Dynamic; + @:noCompletion private var __srcFMODSound:#if lime_console FMODSound #else Dynamic #end; + @:noCompletion private var __srcHowl:#if howlerjs Howl #else Dynamic #end; + @:noCompletion private var __srcSound:#if flash Sound #else Dynamic #end; + + + public function new () { + + + + } + + + public function dispose ():Void { + + #if (js && html5 && howlerjs) + + __srcHowl.unload (); + + #elseif lime_console + if (channels > 0) { + + src.release (); + channels = 0; + + } + #end + + } + + + #if lime_console + @:void + private static function finalize (a:AudioBuffer):Void { + + a.dispose (); + + } + #end + + + public static function fromBytes (bytes:Bytes):AudioBuffer { + + if (bytes == null) return null; + + #if lime_console + + lime.Lib.notImplemented ("AudioBuffer.fromBytes"); + + #elseif (lime_cffi && !macro) + #if !cs + + var audioBuffer = new AudioBuffer (); + audioBuffer.data = new UInt8Array (Bytes.alloc (0)); + + return NativeCFFI.lime_audio_load (bytes, audioBuffer); + + #else + + var data:Dynamic = NativeCFFI.lime_audio_load (bytes, null); + + if (data != null) { + + var audioBuffer = new AudioBuffer (); + audioBuffer.bitsPerSample = data.bitsPerSample; + audioBuffer.channels = data.channels; + audioBuffer.data = new UInt8Array (@:privateAccess new Bytes (data.data.length, data.data.b)); + audioBuffer.sampleRate = data.sampleRate; + return audioBuffer; + + } + + #end + #end + + return null; + + } + + + public static function fromFile (path:String):AudioBuffer { + + if (path == null) return null; + + #if (js && html5 && howlerjs) + + var audioBuffer = new AudioBuffer (); + audioBuffer.__srcHowl = new Howl ({ src: [ path ] }); + return audioBuffer; + + #elseif flash + + switch (Path.extension (path)) { + + case "ogg", "wav": return null; + default: + + } + + var audioBuffer = new AudioBuffer (); + audioBuffer.__srcSound = new Sound (new URLRequest (path)); + return audioBuffer; + + #elseif lime_console + + var mode = StringTools.endsWith(path, ".wav") ? FMODMode.LOOP_OFF : FMODMode.LOOP_NORMAL; + var sound:FMODSound = FMODSound.fromFile (path, mode); + + if (sound.valid) { + + // TODO(james4k): AudioBuffer needs sound info filled in + // TODO(james4k): probably move fmod.Sound creation to AudioSource, + // and keep AudioBuffer as raw data. not as efficient for typical + // use, but probably less efficient to do complex copy-on-read + // mechanisms and such. also, what do we do for compressed sounds? + // usually don't want to decompress large music files. I suppose we + // can specialize for those and not allow data access. + var audioBuffer = new AudioBuffer (); + audioBuffer.bitsPerSample = 0; + audioBuffer.channels = 1; + audioBuffer.data = null; + audioBuffer.sampleRate = 0; + audioBuffer.__srcFMODSound = sound; + cpp.vm.Gc.setFinalizer (audioBuffer, cpp.Function.fromStaticFunction (finalize)); + return audioBuffer; + + } + + #elseif (lime_cffi && !macro) + #if !cs + + var audioBuffer = new AudioBuffer (); + audioBuffer.data = new UInt8Array (Bytes.alloc (0)); + + return NativeCFFI.lime_audio_load (path, audioBuffer); + + #else + + var data:Dynamic = NativeCFFI.lime_audio_load (path, null); + + if (data != null) { + + var audioBuffer = new AudioBuffer (); + audioBuffer.bitsPerSample = data.bitsPerSample; + audioBuffer.channels = data.channels; + audioBuffer.data = new UInt8Array (@:privateAccess new Bytes (data.data.length, data.data.b)); + audioBuffer.sampleRate = data.sampleRate; + return audioBuffer; + + } + + return null; + + #end + #else + + return null; + + #end + + } + + + public static function fromFiles (paths:Array):AudioBuffer { + + #if (js && html5 && howlerjs) + + var audioBuffer = new AudioBuffer (); + audioBuffer.__srcHowl = new Howl ({ src: paths }); + return audioBuffer; + + #else + + var buffer = null; + + for (path in paths) { + + buffer = AudioBuffer.fromFile (path); + if (buffer != null) break; + + } + + return buffer; + + #end + + } + + + public static function fromURL (url:String, handler:AudioBuffer->Void):Void { + + #if (js && html5 && howlerjs) + + var audioBuffer = new AudioBuffer (); + audioBuffer.__srcHowl = new Howl ({ src: [ url ] }); + audioBuffer.__srcHowl.on ("load", function () { handler (audioBuffer); }); + audioBuffer.__srcHowl.on ("loaderror", function () { handler (null); }); + audioBuffer.__srcHowl.load (); + + #else + + if (url != null && url.indexOf ("http://") == -1 && url.indexOf ("https://") == -1) { + + handler (AudioBuffer.fromFile (url)); + + } else { + + // TODO: Support streaming sound + + #if flash + + var loader = new flash.net.URLLoader (); + loader.addEventListener (flash.events.Event.COMPLETE, function (_) { + handler (AudioBuffer.fromBytes (cast loader.data)); + }); + loader.addEventListener (flash.events.IOErrorEvent.IO_ERROR, function (_) { + handler (null); + }); + loader.load (new flash.net.URLRequest (url)); + + #else + + //var loader = new URLLoader (); + //loader.onComplete.add (function (_) { + //var bytes = Bytes.ofString (loader.data); + //handler (AudioBuffer.fromBytes (bytes)); + //}); + //loader.onIOError.add (function (_, msg) { + //handler (null); + //}); + //loader.load (new URLRequest (url)); + + #end + + } + + #end + + } + + + public static function loadFromFile (path:String):Future { + + var promise = new Promise (); + + var audioBuffer = AudioBuffer.fromFile (path); + + if (audioBuffer != null) { + + #if flash + + audioBuffer.__srcSound.addEventListener (flash.events.Event.COMPLETE, function (event) { + + promise.complete (audioBuffer); + + }); + + audioBuffer.__srcSound.addEventListener (flash.events.ProgressEvent.PROGRESS, function (event) { + + promise.progress (event.bytesLoaded, event.bytesTotal); + + }); + + audioBuffer.__srcSound.addEventListener (flash.events.IOErrorEvent.IO_ERROR, promise.error); + + #elseif (js && html5 && howlerjs) + + if (audioBuffer != null) { + + audioBuffer.__srcHowl.on ("load", function () { + + promise.complete (audioBuffer); + + }); + + audioBuffer.__srcHowl.on ("loaderror", function () { + + promise.error (null); + + }); + + audioBuffer.__srcHowl.load (); + + } + + #else + + promise.complete (audioBuffer); + + #end + + } else { + + promise.error (null); + + } + + return promise.future; + + } + + + public static function loadFromFiles (paths:Array):Future { + + var promise = new Promise (); + + #if (js && html5 && howlerjs) + + var audioBuffer = AudioBuffer.fromFiles (paths); + + if (audioBuffer != null) { + + audioBuffer.__srcHowl.on ("load", function () { + + promise.complete (audioBuffer); + + }); + + audioBuffer.__srcHowl.on ("loaderror", function () { + + promise.error (null); + + }); + + audioBuffer.__srcHowl.load (); + + } else { + + promise.error (null); + + } + + #else + + promise.completeWith (new Future (function () return fromFiles (paths), true)); + + #end + + return promise.future; + + } + + + + + // Get & Set Methods + + + + + private function get_src ():Dynamic { + + #if (js && html5) + #if howlerjs + + return __srcHowl; + + #else + + return __srcAudio; + + #end + #elseif flash + + return __srcSound; + + #elseif lime_console + + return __srcFMODSound; + + #else + + return __srcCustom; + + #end + + } + + + private function set_src (value:Dynamic):Dynamic { + + #if (js && html5) + #if howlerjs + + return __srcHowl = value; + + #else + + return __srcAudio = value; + + #end + #elseif flash + + return __srcSound = value; + + #elseif lime_console + + return __srcFMODSound = value; + + #else + + return __srcCustom = value; + + #end + + } + + +} \ No newline at end of file diff --git a/lime/media/AudioContext.hx b/lime/media/AudioContext.hx new file mode 100644 index 000000000..6a6ad1897 --- /dev/null +++ b/lime/media/AudioContext.hx @@ -0,0 +1,18 @@ +package lime.media; + + +import lime.media.ALAudioContext; +import lime.media.FlashAudioContext; +import lime.media.HTML5AudioContext; +import lime.media.WebAudioContext; + + +enum AudioContext { + + OPENAL (alc:ALCAudioContext, al:ALAudioContext); + HTML5 (context:HTML5AudioContext); + WEB (context:WebAudioContext); + FLASH (context:FlashAudioContext); + CUSTOM (data:Dynamic); + +} \ No newline at end of file diff --git a/lime/media/AudioManager.hx b/lime/media/AudioManager.hx new file mode 100644 index 000000000..6c5437375 --- /dev/null +++ b/lime/media/AudioManager.hx @@ -0,0 +1,157 @@ +package lime.media; + + +import lime.media.openal.AL; +import lime.media.openal.ALC; +import lime.media.openal.ALContext; +import lime.media.openal.ALDevice; + +#if (js && html5) +import js.Browser; +#end + +#if !lime_debug +@:fileXml('tags="haxe,release"') +@:noDebug +#end + + +class AudioManager { + + + public static var context:AudioContext; + + + public static function init (context:AudioContext = null) { + + if (AudioManager.context == null) { + + if (context == null) { + + #if (js && html5) + + try { + + untyped __js__ ("window.AudioContext = window.AudioContext || window.webkitAudioContext;"); + AudioManager.context = WEB (cast untyped __js__ ("new AudioContext ()")); + + } catch (e:Dynamic) { + + AudioManager.context = HTML5 (new HTML5AudioContext ()); + + } + + #elseif flash + + AudioManager.context = FLASH (new FlashAudioContext ()); + + #elseif lime_console + + // TODO + AudioManager.context = CUSTOM (null); + + #else + + AudioManager.context = OPENAL (new ALCAudioContext (), new ALAudioContext ()); + + var device = ALC.openDevice (); + var ctx = ALC.createContext (device); + ALC.makeContextCurrent (ctx); + ALC.processContext (ctx); + + #end + + } else { + + AudioManager.context = context; + + } + + } + + } + + + public static function resume ():Void { + + if (context != null) { + + switch (context) { + + case OPENAL (alc, al): + + var currentContext = alc.getCurrentContext (); + + if (currentContext != null) { + + var device = alc.getContextsDevice (currentContext); + alc.resumeDevice (device); + alc.processContext (currentContext); + + } + + default: + + } + + } + + } + + + public static function shutdown ():Void { + + if (context != null) { + + switch (context) { + + case OPENAL (alc, al): + + var currentContext = alc.getCurrentContext (); + + if (currentContext != null) { + + var device = alc.getContextsDevice (currentContext); + alc.makeContextCurrent (null); + alc.destroyContext (currentContext); + alc.closeDevice (device); + + } + + default: + + } + + } + + } + + + public static function suspend ():Void { + + if (context != null) { + + switch (context) { + + case OPENAL (alc, al): + + var currentContext = alc.getCurrentContext (); + + if (currentContext != null) { + + alc.suspendContext (currentContext); + var device = alc.getContextsDevice (currentContext); + alc.pauseDevice (device); + + } + + default: + + } + + } + + } + + +} diff --git a/lime/media/AudioSource.hx b/lime/media/AudioSource.hx new file mode 100644 index 000000000..31fef5896 --- /dev/null +++ b/lime/media/AudioSource.hx @@ -0,0 +1,176 @@ +package lime.media; + + +import lime.app.Event; +import lime.media.openal.AL; +import lime.media.openal.ALSource; +import lime.math.Vector4; + +#if !lime_debug +@:fileXml('tags="haxe,release"') +@:noDebug +#end + + +class AudioSource { + + + public var onComplete = new EventVoid> (); + + public var buffer:AudioBuffer; + public var currentTime (get, set):Int; + public var gain (get, set):Float; + public var length (get, set):Int; + public var loops (get, set):Int; + public var offset:Int; + public var position (get, set):Vector4; + + @:noCompletion private var backend:AudioSourceBackend; + + + public function new (buffer:AudioBuffer = null, offset:Int = 0, length:Null = null, loops:Int = 0) { + + this.buffer = buffer; + this.offset = offset; + + backend = new AudioSourceBackend (this); + + if (length != null && length != 0) { + + this.length = length; + + } + + this.loops = loops; + + if (buffer != null) { + + init (); + + } + + } + + + public function dispose ():Void { + + backend.dispose (); + + } + + + private function init ():Void { + + backend.init (); + + } + + + public function play ():Void { + + backend.play (); + + } + + + public function pause ():Void { + + backend.pause (); + + } + + + public function stop ():Void { + + backend.stop (); + + } + + + + + // Get & Set Methods + + + + + private function get_currentTime ():Int { + + return backend.getCurrentTime (); + + } + + + private function set_currentTime (value:Int):Int { + + return backend.setCurrentTime (value); + + } + + + private function get_gain ():Float { + + return backend.getGain (); + + } + + + private function set_gain (value:Float):Float { + + return backend.setGain (value); + + } + + + private function get_length ():Int { + + return backend.getLength (); + + } + + + private function set_length (value:Int):Int { + + return backend.setLength (value); + + } + + + private function get_loops ():Int { + + return backend.getLoops (); + + } + + + private function set_loops (value:Int):Int { + + return backend.setLoops (value); + + } + + + private function get_position ():Vector4 { + + return backend.getPosition (); + + } + + + private function set_position (value:Vector4):Vector4 { + + return backend.setPosition (value); + + } + + +} + + +#if flash +@:noCompletion private typedef AudioSourceBackend = lime._backend.flash.FlashAudioSource; +#elseif (js && html5) +@:noCompletion private typedef AudioSourceBackend = lime._backend.html5.HTML5AudioSource; +#else +@:noCompletion private typedef AudioSourceBackend = lime._backend.native.NativeAudioSource; +#end \ No newline at end of file diff --git a/lime/media/FlashAudioContext.hx b/lime/media/FlashAudioContext.hx new file mode 100644 index 000000000..c880d1959 --- /dev/null +++ b/lime/media/FlashAudioContext.hx @@ -0,0 +1,219 @@ +package lime.media; + + +#if flash +import flash.media.Sound; +#end + + +class FlashAudioContext { + + + public function new () { + + + + } + + + public function createBuffer (stream:Dynamic /*URLRequest*/ = null, context:Dynamic /*SoundLoaderContext*/ = null):AudioBuffer { + + #if flash + var buffer = new AudioBuffer (); + buffer.src = new Sound (stream, context); + return buffer; + #else + return null; + #end + + } + + + public function getBytesLoaded (buffer:AudioBuffer):UInt { + + #if flash + if (buffer.src != null) { + + return buffer.src.bytesLoaded; + + } + #end + + return 0; + + } + + + public function getBytesTotal (buffer:AudioBuffer):Int { + + #if flash + if (buffer.src != null) { + + return buffer.src.bytesTotal; + + } + #end + + return 0; + + } + + + public function getID3 (buffer:AudioBuffer):Dynamic /*ID3Info*/ { + + #if flash + if (buffer.src != null) { + + return buffer.src.id3; + + } + #end + + return null; + + } + + + public function getIsBuffering (buffer:AudioBuffer):Bool { + + #if flash + if (buffer.src != null) { + + return buffer.src.isBuffering; + + } + #end + + return false; + + } + + + public function getIsURLInaccessible (buffer:AudioBuffer):Bool { + + #if flash + if (buffer.src != null) { + + return buffer.src.isURLInaccessible; + + } + #end + + return false; + + } + + + public function getLength (buffer:AudioBuffer):Float { + + #if flash + if (buffer.src != null) { + + return buffer.src.length; + + } + #end + + return 0; + + } + + + public function getURL (buffer:AudioBuffer):String { + + #if flash + if (buffer.src != null) { + + return buffer.src.url; + + } + #end + + return null; + + } + + + public function close (buffer:AudioBuffer):Void { + + #if flash + if (buffer.src != null) { + + buffer.src.close (); + + } + #end + + } + + + public function extract (buffer:AudioBuffer, target:Dynamic /*flash.utils.ByteArray*/, length:Float, startPosition:Float = -1):Float { + + #if flash + if (buffer.src != null) { + + return buffer.src.extract (target, length, startPosition); + + } + #end + + return 0; + + } + + + public function load (buffer:AudioBuffer, stream:Dynamic /*flash.net.URLRequest*/, context:Dynamic /*SoundLoaderContext*/ = null):Void { + + #if flash + if (buffer.src != null) { + + buffer.src.load (stream, context); + + } + #end + + } + + + public function loadCompressedDataFromByteArray (buffer:AudioBuffer, bytes:Dynamic /*flash.utils.ByteArray*/, bytesLength:UInt):Void { + + #if flash11 + if (buffer.src != null) { + + buffer.src.loadCompressedDataFromByteArray (bytes, bytesLength); + + } + #end + + } + + + public function loadPCMFromByteArray (buffer:AudioBuffer, bytes:Dynamic /*flash.utils.ByteArray*/, samples:UInt, format:String = null, stereo:Bool = true, sampleRate:Float = 44100):Void { + + #if flash11 + if (buffer.src != null) { + + buffer.src.loadPCMFromByteArray (bytes, samples, format, stereo, sampleRate); + + } + #end + + } + + + public function play (buffer:AudioBuffer, startTime:Float = 0, loops:Int = 0, sndTransform:Dynamic /*SoundTransform*/ = null):Dynamic /*SoundChannel*/ { + + #if flash + if (buffer.src != null) { + + return buffer.src.play (startTime, loops, sndTransform); + + } + #end + + return null; + + } + + +} \ No newline at end of file diff --git a/lime/media/HTML5AudioContext.hx b/lime/media/HTML5AudioContext.hx new file mode 100644 index 000000000..f85698180 --- /dev/null +++ b/lime/media/HTML5AudioContext.hx @@ -0,0 +1,532 @@ +package lime.media; + + +#if (js && html5) +import js.html.Audio; +#end + +@:access(lime.media.AudioBuffer) + + +class HTML5AudioContext { + + + public var HAVE_CURRENT_DATA:Int = 2; + public var HAVE_ENOUGH_DATA:Int = 4; + public var HAVE_FUTURE_DATA:Int = 3; + public var HAVE_METADATA:Int = 1; + public var HAVE_NOTHING:Int = 0; + public var NETWORK_EMPTY:Int = 0; + public var NETWORK_IDLE:Int = 1; + public var NETWORK_LOADING:Int = 2; + public var NETWORK_NO_SOURCE:Int = 3; + + + public function new () { + + + + } + + + public function canPlayType (buffer:AudioBuffer, type:String):String { + + #if (js && html5) + if (buffer.__srcAudio != null) { + + return buffer.__srcAudio.canPlayType (type); + + } + #end + + return null; + + } + + + public function createBuffer (urlString:String = null):AudioBuffer { + + #if (js && html5) + var buffer = new AudioBuffer (); + buffer.__srcAudio = new Audio (); + buffer.__srcAudio.src = urlString; + return buffer; + #else + return null; + #end + + } + + + public function getAutoplay (buffer:AudioBuffer):Bool { + + #if (js && html5) + if (buffer.__srcAudio != null) { + + return buffer.__srcAudio.autoplay; + + } + #end + + return false; + + } + + + public function getBuffered (buffer:AudioBuffer):Dynamic /*TimeRanges*/ { + + #if (js && html5) + if (buffer.__srcAudio != null) { + + return buffer.__srcAudio.buffered; + + } + #end + + return null; + + } + + + public function getCurrentSrc (buffer:AudioBuffer):String { + + #if (js && html5) + if (buffer.__srcAudio != null) { + + return buffer.__srcAudio.currentSrc; + + } + #end + + return null; + + } + + + public function getCurrentTime (buffer:AudioBuffer):Float { + + #if (js && html5) + if (buffer.__srcAudio != null) { + + return buffer.__srcAudio.currentTime; + + } + #end + + return 0; + + } + + + public function getDefaultPlaybackRate (buffer:AudioBuffer):Float { + + #if (js && html5) + if (buffer.__srcAudio != null) { + + return buffer.__srcAudio.defaultPlaybackRate; + + } + #end + + return 1; + + } + + + public function getDuration (buffer:AudioBuffer):Float { + + #if (js && html5) + if (buffer.__srcAudio != null) { + + return buffer.__srcAudio.duration; + + } + #end + + return 0; + + } + + + public function getEnded (buffer:AudioBuffer):Bool { + + #if (js && html5) + if (buffer.__srcAudio != null) { + + return buffer.__srcAudio.ended; + + } + #end + + return false; + + } + + + public function getError (buffer:AudioBuffer):Dynamic /*MediaError*/ { + + #if (js && html5) + if (buffer.__srcAudio != null) { + + return buffer.__srcAudio.error; + + } + #end + + return null; + + } + + + public function getLoop (buffer:AudioBuffer):Bool { + + #if (js && html5) + if (buffer.__srcAudio != null) { + + return buffer.__srcAudio.loop; + + } + #end + + return false; + + } + + + public function getMuted (buffer:AudioBuffer):Bool { + + #if (js && html5) + if (buffer.__srcAudio != null) { + + return buffer.__srcAudio.muted; + + } + #end + + return false; + + } + + + public function getNetworkState (buffer:AudioBuffer):Int { + + #if (js && html5) + if (buffer.__srcAudio != null) { + + return buffer.__srcAudio.networkState; + + } + #end + + return 0; + + } + + + public function getPaused (buffer:AudioBuffer):Bool { + + #if (js && html5) + if (buffer.__srcAudio != null) { + + return buffer.__srcAudio.paused; + + } + #end + + return false; + + } + + + public function getPlaybackRate (buffer:AudioBuffer):Float { + + #if (js && html5) + if (buffer.__srcAudio != null) { + + return buffer.__srcAudio.playbackRate; + + } + #end + + return 1; + + } + + + public function getPlayed (buffer:AudioBuffer):Dynamic /*TimeRanges*/ { + + #if (js && html5) + if (buffer.__srcAudio != null) { + + return buffer.__srcAudio.played; + + } + #end + + return null; + + } + + + public function getPreload (buffer:AudioBuffer):String { + + #if (js && html5) + if (buffer.__srcAudio != null) { + + return buffer.__srcAudio.preload; + + } + #end + + return null; + + } + + + public function getReadyState (buffer:AudioBuffer):Int { + + #if (js && html5) + if (buffer.__srcAudio != null) { + + return buffer.__srcAudio.readyState; + + } + #end + + return 0; + + } + + + public function getSeekable (buffer:AudioBuffer):Dynamic /*TimeRanges*/ { + + #if (js && html5) + if (buffer.__srcAudio != null) { + + return buffer.__srcAudio.seekable; + + } + #end + + return null; + + } + + + public function getSeeking (buffer:AudioBuffer):Bool { + + #if (js && html5) + if (buffer.__srcAudio != null) { + + return buffer.__srcAudio.seeking; + + } + #end + + return false; + + } + + + public function getSrc (buffer:AudioBuffer):String { + + #if (js && html5) + if (buffer.__srcAudio != null) { + + return buffer.__srcAudio.src; + + } + #end + + return null; + + } + + + public function getStartTime (buffer:AudioBuffer):Float { + + #if (js && html5) + if (buffer.__srcAudio != null) { + + return buffer.__srcAudio.playbackRate; + + } + #end + + return 0; + + } + + + public function getVolume (buffer:AudioBuffer):Float { + + #if (js && html5) + if (buffer.__srcAudio != null) { + + return buffer.__srcAudio.volume; + + } + #end + + return 1; + + } + + + public function load (buffer:AudioBuffer):Void { + + #if (js && html5) + if (buffer.__srcAudio != null) { + + return buffer.__srcAudio.load (); + + } + #end + + } + + + public function pause (buffer:AudioBuffer):Void { + + #if (js && html5) + if (buffer.__srcAudio != null) { + + return buffer.__srcAudio.pause (); + + } + #end + + } + + + public function play (buffer:AudioBuffer):Void { + + #if (js && html5) + if (buffer.__srcAudio != null) { + + return buffer.__srcAudio.play (); + + } + #end + + } + + + public function setAutoplay (buffer:AudioBuffer, value:Bool):Void { + + #if (js && html5) + if (buffer.__srcAudio != null) { + + buffer.__srcAudio.autoplay = value; + + } + #end + + } + + + public function setCurrentTime (buffer:AudioBuffer, value:Float):Void { + + #if (js && html5) + if (buffer.__srcAudio != null) { + + buffer.__srcAudio.currentTime = value; + + } + #end + + } + + + public function setDefaultPlaybackRate (buffer:AudioBuffer, value:Float):Void { + + #if (js && html5) + if (buffer.__srcAudio != null) { + + buffer.__srcAudio.defaultPlaybackRate = value; + + } + #end + + } + + + public function setLoop (buffer:AudioBuffer, value:Bool):Void { + + #if (js && html5) + if (buffer.__srcAudio != null) { + + buffer.__srcAudio.loop = value; + + } + #end + + } + + + public function setMuted (buffer:AudioBuffer, value:Bool):Void { + + #if (js && html5) + if (buffer.__srcAudio != null) { + + buffer.__srcAudio.muted = value; + + } + #end + + } + + + public function setPlaybackRate (buffer:AudioBuffer, value:Float):Void { + + #if (js && html5) + if (buffer.__srcAudio != null) { + + buffer.__srcAudio.playbackRate = value; + + } + #end + + } + + + public function setPreload (buffer:AudioBuffer, value:String):Void { + + #if (js && html5) + if (buffer.__srcAudio != null) { + + buffer.__srcAudio.preload = value; + + } + #end + + } + + + public function setSrc (buffer:AudioBuffer, value:String):Void { + + #if (js && html5) + if (buffer.__srcAudio != null) { + + buffer.__srcAudio.src = value; + + } + #end + + } + + + public function setVolume (buffer:AudioBuffer, value:Float):Void { + + #if (js && html5) + if (buffer.__srcAudio != null) { + + buffer.__srcAudio.volume = value; + + } + #end + + } + + +} \ No newline at end of file diff --git a/lime/media/WebAudioContext.hx b/lime/media/WebAudioContext.hx new file mode 100644 index 000000000..5d9186d05 --- /dev/null +++ b/lime/media/WebAudioContext.hx @@ -0,0 +1,49 @@ +package lime.media; #if (!js || !html5 || display) + + +class WebAudioContext { + + + public var activeSourceCount (default, null):Int; + public var currentTime (default, null):Float; + public var destination (default, null):Dynamic /*AudioDestinationNode*/; + public var listener (default, null):Dynamic /*AudioListener*/; + public var oncomplete:Dynamic /*js.html.EventListener*/; + public var sampleRate (default, null):Float; + + + public function new () { + + + + } + + + public function createAnalyser ():Dynamic /*AnalyserNode*/ { return null; } + public function createBiquadFilter ():Dynamic /*BiquadFilterNode*/ { return null; } + @:overload(function(numberOfChannels:Int, numberOfFrames:Int, sampleRate:Float):Dynamic /*AudioBuffer*/ {}) + public function createBuffer (buffer:Dynamic /*js.html.ArrayBuffer*/, mixToMono:Bool):Dynamic /*AudioBuffer*/ { return null; } + public function createBufferSource ():Dynamic /*AudioBufferSourceNode*/ { return null; } + public function createChannelMerger (?numberOfInputs:Int):Dynamic /*ChannelMergerNode*/ { return null; } + public function createChannelSplitter (?numberOfOutputs:Int):Dynamic /*ChannelSplitterNode*/ { return null; } + public function createConvolver ():Dynamic /*ConvolverNode*/ { return null; } + public function createDelay (?maxDelayTime:Float):Dynamic /*DelayNode*/ { return null; } + public function createDynamicsCompressor ():Dynamic /*DynamicsCompressorNode*/ { return null; } + public function createGain ():Dynamic /*GainNode*/ { return null; } + public function createMediaElementSource (mediaElement:Dynamic /*js.html.MediaElement*/):Dynamic /*MediaElementAudioSourceNode*/ { return null; } + public function createMediaStreamSource (mediaStream:Dynamic /*js.html.rtc.MediaStream*/):Dynamic /*MediaStreamAudioSourceNode*/ { return null; } + public function createOscillator ():Dynamic /*OscillatorNode*/ { return null; } + public function createPanner ():Dynamic /*PannerNode*/ { return null; } + public function createScriptProcessor (bufferSize:Int, ?numberOfInputChannels:Int, ?numberOfOutputChannels:Int):Dynamic /*ScriptProcessorNode*/ { return null; } + public function createWaveShaper ():Dynamic /*WaveShaperNode*/ { return null; } + public function createWaveTable (real:Dynamic /*js.html.Float32Array*/, imag:Dynamic /*js.html.Float32Array*/):Dynamic /*WaveTable*/ { return null; } + public function decodeAudioData (audioData:Dynamic /*js.html.ArrayBuffer*/, successCallback:Dynamic /*AudioBufferCallback*/, ?errorCallback:Dynamic /*AudioBufferCallback*/):Void {} + public function startRendering ():Void {} + + +} + + +#else +typedef WebAudioContext = js.html.audio.AudioContext; +#end \ No newline at end of file diff --git a/lime/media/codecs/vorbis/Vorbis.hx b/lime/media/codecs/vorbis/Vorbis.hx new file mode 100644 index 000000000..f7b0b4944 --- /dev/null +++ b/lime/media/codecs/vorbis/Vorbis.hx @@ -0,0 +1,27 @@ +package lime.media.codecs.vorbis; + + +class Vorbis { + + + public static inline var FALSE = -1; + public static inline var EOF = -2; + public static inline var HOLE = -3; + + public static inline var EREAD = -128; + public static inline var EFAULT = -129; + public static inline var EIMPL = -130; + public static inline var EINVAL = -131; + public static inline var ENOTVORBIS = -132; + public static inline var EBADHEADER = -133; + public static inline var EVERSION = -134; + public static inline var ENOTAUDIO = -135; + public static inline var EBADPACKET = -136; + public static inline var EBADLINK = -137; + public static inline var ENOSEEK = -138; + + + // TODO: Vorbis primitives + + +} \ No newline at end of file diff --git a/lime/media/codecs/vorbis/VorbisComment.hx b/lime/media/codecs/vorbis/VorbisComment.hx new file mode 100644 index 000000000..8d2bb65f4 --- /dev/null +++ b/lime/media/codecs/vorbis/VorbisComment.hx @@ -0,0 +1,18 @@ +package lime.media.codecs.vorbis; + + +class VorbisComment { + + + public var userComments:Array; + public var vendor:String; + + + public function new () { + + + + } + + +} \ No newline at end of file diff --git a/lime/media/codecs/vorbis/VorbisFile.hx b/lime/media/codecs/vorbis/VorbisFile.hx new file mode 100644 index 000000000..6814b10ba --- /dev/null +++ b/lime/media/codecs/vorbis/VorbisFile.hx @@ -0,0 +1,385 @@ +package lime.media.codecs.vorbis; + + +import haxe.Int64; +import haxe.io.Bytes; +import lime._backend.native.NativeCFFI; + +@:access(lime._backend.native.NativeCFFI) + + +class VorbisFile { + + + public var bitstream (default, null):Int; + + private var handle:Dynamic; + + + private function new (handle:Dynamic) { + + this.handle = handle; + + } + + + public function bitrate (bitstream:Int = -1):Int { + + #if (lime_cffi && lime_vorbis && !macro) + return NativeCFFI.lime_vorbis_file_bitrate (handle, bitstream); + #else + return 0; + #end + + } + + + public function bitrateInstant ():Int { + + #if (lime_cffi && lime_vorbis && !macro) + return NativeCFFI.lime_vorbis_file_bitrate_instant (handle); + #else + return 0; + #end + + } + + + public function clear ():Void { + + #if (lime_cffi && lime_vorbis && !macro) + NativeCFFI.lime_vorbis_file_clear (handle); + #end + + } + + + public function comment (bitstream:Int = -1):VorbisComment { + + #if (lime_cffi && lime_vorbis && !macro) + var data = NativeCFFI.lime_vorbis_file_comment (handle, bitstream); + + if (data != null) { + + var comment = new VorbisComment (); + comment.userComments = data.userComments; + comment.vendor = data.vendor; + return comment; + + } + #end + + return null; + + } + + + public function crosslap (other:VorbisFile):Int { + + #if (lime_cffi && lime_vorbis && !macro) + return NativeCFFI.lime_vorbis_file_crosslap (handle, other.handle); + #else + return 0; + #end + + } + + + public static function fromBytes (bytes:Bytes):VorbisFile { + + #if (lime_cffi && lime_vorbis && !macro) + var handle = NativeCFFI.lime_vorbis_file_from_bytes (bytes); + + if (handle != null) { + + return new VorbisFile (handle); + + } + #end + + return null; + + } + + + public static function fromFile (path:String):VorbisFile { + + #if (lime_cffi && lime_vorbis && !macro) + var handle = NativeCFFI.lime_vorbis_file_from_file (path); + + if (handle != null) { + + return new VorbisFile (handle); + + } + #end + + return null; + + } + + + public function info (bitstream:Int = -1):VorbisInfo { + + #if (lime_cffi && lime_vorbis && !macro) + var data = NativeCFFI.lime_vorbis_file_info (handle, bitstream); + + if (data != null) { + + var info = new VorbisInfo (); + info.bitrateLower = data.bitrateLower; + info.bitrateNominal = data.bitrateNominal; + info.bitrateUpper = data.bitrateUpper; + info.channels = data.channels; + info.rate = data.rate; + info.version = data.version; + return info; + + } + #end + + return null; + + } + + + public function pcmSeek (pos:Int64):Int { + + #if (lime_cffi && lime_vorbis && !macro) + return NativeCFFI.lime_vorbis_file_pcm_seek (handle, pos.low, pos.high); + #else + return 0; + #end + + } + + + public function pcmSeekLap (pos:Int64):Int { + + #if (lime_cffi && lime_vorbis && !macro) + return NativeCFFI.lime_vorbis_file_pcm_seek_lap (handle, pos.low, pos.high); + #else + return 0; + #end + + } + + + public function pcmSeekPage (pos:Int64):Int { + + #if (lime_cffi && lime_vorbis && !macro) + return NativeCFFI.lime_vorbis_file_pcm_seek_page (handle, pos.low, pos.high); + #else + return 0; + #end + + } + + + public function pcmSeekPageLap (pos:Int64):Int { + + #if (lime_cffi && lime_vorbis && !macro) + return NativeCFFI.lime_vorbis_file_pcm_seek_page_lap (handle, pos.low, pos.high); + #else + return 0; + #end + + } + + + public function pcmTell ():Int64 { + + #if (lime_cffi && lime_vorbis && !macro) + return NativeCFFI.lime_vorbis_file_pcm_tell (handle); + #else + return 0; + #end + + } + + + + public function pcmTotal (bitstream:Int = -1):Int64 { + + #if (lime_cffi && lime_vorbis && !macro) + return NativeCFFI.lime_vorbis_file_pcm_total (handle, bitstream); + #else + return 0; + #end + + } + + + public function rawSeek (pos:Int64):Int { + + #if (lime_cffi && lime_vorbis && !macro) + return NativeCFFI.lime_vorbis_file_raw_seek (handle, pos.low, pos.high); + #else + return 0; + #end + + } + + + public function rawSeekLap (pos:Int64):Int { + + #if (lime_cffi && lime_vorbis && !macro) + return NativeCFFI.lime_vorbis_file_raw_seek_lap (handle, pos.low, pos.high); + #else + return 0; + #end + + } + + + public function rawTell ():Int64 { + + #if (lime_cffi && lime_vorbis && !macro) + return NativeCFFI.lime_vorbis_file_raw_tell (handle); + #else + return 0; + #end + + } + + + public function rawTotal (bitstream:Int = -1):Int64 { + + #if (lime_cffi && lime_vorbis && !macro) + return NativeCFFI.lime_vorbis_file_raw_total (handle, bitstream); + #else + return 0; + #end + + } + + + public function read (buffer:Bytes, length:Int = 4096, bigEndianPacking:Bool = false, wordSize:Int = 2, signed:Bool = true):Int { + + #if (lime_cffi && lime_vorbis && !macro) + var data = NativeCFFI.lime_vorbis_file_read (handle, buffer, length, bigEndianPacking, wordSize, signed); + bitstream = data.bitstream; + return data.returnValue; + #else + return 0; + #end + + } + + + //public function readFilter (buffer:Bytes, length:Int = 4096, endianness:Endian = LITTLE_ENDIAN, wordSize:Int = 2, signed:Bool = true, bitstream:Int = 0, filter, filter_param + + + public function readFloat (pcmChannels:Bytes, samples:Int):Int { + + #if (lime_cffi && lime_vorbis && !macro) + var data = NativeCFFI.lime_vorbis_file_read_float (handle, pcmChannels, samples); + bitstream = data.bitstream; + return data.returnValue; + #else + return 0; + #end + + } + + + public function seekable ():Bool { + + #if (lime_cffi && lime_vorbis && !macro) + return NativeCFFI.lime_vorbis_file_seekable (handle); + #else + return false; + #end + + } + + + public function serialNumber (bitstream:Int = -1):Int { + + #if (lime_cffi && lime_vorbis && !macro) + return NativeCFFI.lime_vorbis_file_serial_number (handle, bitstream); + #else + return 0; + #end + + } + + + public function streams ():Int { + + #if (lime_cffi && lime_vorbis && !macro) + return NativeCFFI.lime_vorbis_file_streams (handle); + #else + return 0; + #end + + } + + + public function timeSeek (s:Float):Int { + + #if (lime_cffi && lime_vorbis && !macro) + return NativeCFFI.lime_vorbis_file_time_seek (handle, s); + #else + return 0; + #end + + } + + + public function timeSeekLap (s:Float):Int { + + #if (lime_cffi && lime_vorbis && !macro) + return NativeCFFI.lime_vorbis_file_time_seek_lap (handle, s); + #else + return 0; + #end + + } + + + public function timeSeekPage (s:Float):Int { + + #if (lime_cffi && lime_vorbis && !macro) + return NativeCFFI.lime_vorbis_file_time_seek_page (handle, s); + #else + return 0; + #end + + } + + + public function timeSeekPageLap (s:Float):Int { + + #if (lime_cffi && lime_vorbis && !macro) + return NativeCFFI.lime_vorbis_file_time_seek_page_lap (handle, s); + #else + return 0; + #end + + } + + + public function timeTell ():Float { + + #if (lime_cffi && lime_vorbis && !macro) + return NativeCFFI.lime_vorbis_file_time_tell (handle); + #else + return 0; + #end + + } + + + public function timeTotal (bitstream:Int = -1):Float { + + #if (lime_cffi && lime_vorbis && !macro) + return NativeCFFI.lime_vorbis_file_time_total (handle, bitstream); + #else + return 0; + #end + + } + + +} \ No newline at end of file diff --git a/lime/media/codecs/vorbis/VorbisInfo.hx b/lime/media/codecs/vorbis/VorbisInfo.hx new file mode 100644 index 000000000..66c591686 --- /dev/null +++ b/lime/media/codecs/vorbis/VorbisInfo.hx @@ -0,0 +1,23 @@ +package lime.media.codecs.vorbis; + + +class VorbisInfo { + + + public var bitrateLower:Int; + public var bitrateNominal:Int; + public var bitrateUpper:Int; + //public var bitrateWindow:Int; + public var channels:Int; + public var rate:Int; + public var version:Int; + + + public function new () { + + + + } + + +} \ No newline at end of file diff --git a/lime/media/fmod/FMODChannel.hx b/lime/media/fmod/FMODChannel.hx new file mode 100644 index 000000000..c779d3fed --- /dev/null +++ b/lime/media/fmod/FMODChannel.hx @@ -0,0 +1,54 @@ +package lime.media.fmod; +#if lime_console + + +import lime.ConsoleIncludePaths; + + +@:include("ConsoleFmodChannel.h") +@:native("cpp::Struct") +extern class FMODChannel { + + + // valid is true if this represents a valid handle to a channel. + public var valid (get, never):Bool; + + + // pause sets channel to a paused state. + public function pause ():Void; + + // resume sets channel to an unpaused state. + public function resume ():Void; + + // stop stops the channel from playing, making it available for another + // sound to use. + public function stop ():Void; + + + // getLoopCount retrieves the current loop count for the channel. + public function getLoopCount ():Int; + + // setLoopCount sets the channel to loop count times before stopping. + public function setLoopCount (count:Int):Void; + + // getVolume retrieves the current linear volume level of the channel. + public function getVolume ():cpp.Float32; + + // setVolume sets the channel's linear volume level. + public function setVolume (volume:cpp.Float32):Void; + + + // INVALID represents an invalid channel handle + public static var INVALID (get, never):FMODChannel; + + + private function get_valid ():Bool; + + @:native("lime::ConsoleFmodChannel") + private static function get_INVALID ():FMODChannel; + + +} + + +#end diff --git a/lime/media/fmod/FMODMode.hx b/lime/media/fmod/FMODMode.hx new file mode 100644 index 000000000..ef4890dda --- /dev/null +++ b/lime/media/fmod/FMODMode.hx @@ -0,0 +1,16 @@ +package lime.media.fmod; +#if lime_console + + +import lime.ConsoleIncludePaths; + + +@:enum abstract FMODMode(Int) { + + var LOOP_OFF = 0x00000001; + var LOOP_NORMAL = 0x00000002; + +} + + +#end diff --git a/lime/media/fmod/FMODSound.hx b/lime/media/fmod/FMODSound.hx new file mode 100644 index 000000000..5d7d014ee --- /dev/null +++ b/lime/media/fmod/FMODSound.hx @@ -0,0 +1,36 @@ +package lime.media.fmod; +#if lime_console + + +import lime.ConsoleIncludePaths; + + +@:include("ConsoleFmodSound.h") +@:native("cpp::Struct") +extern class FMODSound { + + + // valid returns true if this represents a valid handle to a sound. + public var valid (get, never):Bool; + + + // fromFile creates a sound from the named file. + @:native("lime::ConsoleFmodSound::fromFile") + public static function fromFile (name:String, mode:FMODMode):FMODSound; + + + // play plays the sound and returns the channel it was assigned. + public function play ():FMODChannel; + + + // release releases the sound. + public function release ():Void; + + + private function get_valid ():Bool; + + +} + + +#end diff --git a/lime/media/howlerjs/Howl.hx b/lime/media/howlerjs/Howl.hx new file mode 100644 index 000000000..879eaaeaf --- /dev/null +++ b/lime/media/howlerjs/Howl.hx @@ -0,0 +1,330 @@ +package lime.media.howlerjs; #if (!js || !html5 || display) + + +import haxe.Constraints.Function; + + +class Howl { + + + public function new (options:HowlOptions) { + + + + } + + + /** + * Get the duration of this sound. Passing a sound id will return the sprite duration. + * @param id The sound id to check. If none is passed, return full source duration. + * @return Audio duration in seconds. + */ + public function duration (?id:Int):Int { + + return 0; + + } + + + /** + * Fade a currently playing sound between two volumes (if no id is passsed, all sounds will fade). + * @param from The value to fade from (0.0 to 1.0). + * @param to The volume to fade to (0.0 to 1.0). + * @param len Time in milliseconds to fade. + * @param id The sound id (omit to fade all sounds). + * @return + */ + public function fade (from:Float, to:Float, len:Int, ?id:Int):Howl { + + return this; + + } + + + /** + * Load the audio file. + * @return + */ + public function load ():Howl { + + return this; + + } + + + /** + * Get/set the loop parameter on a sound. This method can optionally take 0, 1 or 2 arguments. + * loop() -> Returns the group's loop value. + * loop(id) -> Returns the sound id's loop value. + * loop(loop) -> Sets the loop value for all sounds in this Howl group. + * loop(loop, id) -> Sets the loop value of passed sound id. + * @return Returns self or current loop value. + */ + public function loop (?loop:Dynamic, ?id:Int):Dynamic { + + return null; + + } + + + /** + * Mute/unmute a single sound or all sounds in this Howl group. + * @param muted Set to true to mute and false to unmute. + * @param id The sound ID to update (omit to mute/unmute all). + * @return + */ + public function mute (muted:Bool, ?id:Int):Howl { + + return this; + + } + + + /** + * Remove a custom event. Call without parameters to remove all events. + * @param event Event name. + * @param fn Listener to remove. Leave empty to remove all. + * @param id (optional) Only remove events for this sound. + * @return + */ + public function off (event:String, fn:Function, ?id:Int):Howl { + + return this; + + } + + + /** + * Listen to a custom event. + * @param event Event name. + * @param fn Listener to call. + * @param id (optional) Only listen to events for this sound. + * @return + */ + public function on (event:String, fn:Function, ?id:Int):Howl { + + return this; + + } + + + /** + * Listen to a custom event and remove it once fired. + * @param event Event name. + * @param fn Listener to call. + * @param id (optional) Only listen to events for this sound. + * @return + */ + public function once (event:String, fn:Function, ?id:Int):Howl { + + return this; + + } + + + /** + * Pause playback and save current position. + * @param id The sound ID (empty to pause all in group). + * @return + */ + public function pause (?id:Int):Howl { + + return this; + + } + + + /** + * Play a sound or resume previous playback. + * @param sprite Sprite name for sprite playback or sound id to continue previous. + * @return Sound ID. + */ + public function play (?sprite:Dynamic):Int { + + return 0; + + } + + + /** + * Check if a specific sound is currently playing or not (if id is provided), or check if at least one of the sounds in the group is playing or not. + * @param id The sound id to check. If none is passed, the whole sound group is checked. + * @return True if playing and false if not. + */ + public function playing (?id:Int):Bool { + + return false; + + } + + + /** + * Get/set the playback rate of a sound. This method can optionally take 0, 1 or 2 arguments. + * rate() -> Returns the first sound node's current playback rate. + * rate(id) -> Returns the sound id's current playback rate. + * rate(rate) -> Sets the playback rate of all sounds in this Howl group. + * rate(rate, id) -> Sets the playback rate of passed sound id. + * @return Returns self or the current playback rate. + */ + public function rate (?rate:Float, ?id:Int):Dynamic { + + return null; + + } + + + /** + * Get/set the seek position of a sound (in seconds). This method can optionally take 0, 1 or 2 arguments. + * seek() -> Returns the first sound node's current seek position. + * seek(id) -> Returns the sound id's current seek position. + * seek(seek) -> Sets the seek position of the first sound node. + * seek(seek, id) -> Sets the seek position of passed sound id. + * @return Returns self or the current seek position. + */ + public function seek (?seek:Float, ?id:Int):Dynamic { + + return null; + + } + + + /** + * Returns the current loaded state of this Howl. + * @return 'unloaded', 'loading', 'loaded' + */ + public function state ():String { + + return null; + + } + + + /** + * Stop playback and reset to start. + * @param id The sound ID (empty to stop all in group). + * @return + */ + public function stop (?id:Int):Howl { + + return this; + + } + + + /** + * Unload and destroy the current Howl object. + * This will immediately stop all sound instances attached to this group. + */ + public function unload ():Void { + + + + } + + + /** + * Get/set the volume of this sound or of the Howl group. This method can optionally take 0, 1 or 2 arguments. + * volume() -> Returns the group's volume value. + * volume(id) -> Returns the sound id's current volume. + * volume(vol) -> Sets the volume of all sounds in this Howl group. + * volume(vol, id) -> Sets the volume of passed sound id. + * @return Returns self or current volume. + */ + public function volume (?vol:Float, ?id:Int):Dynamic { + + return null; + + } + + +} + + + +#else + + +import haxe.Constraints.Function; +import haxe.extern.EitherType; + +@:native("Howl") + + +extern class Howl { + + + public function new (options:HowlOptions); + + public function duration (?id:Int):Int; + public function fade (from:Float, to:Float, len:Int, ?id:Int):Howl; + public function load ():Howl; + + @:overload(function(id:Int):Bool {}) + @:overload(function(loop:Bool):Howl {}) + @:overload(function(loop:Bool, id:Int):Howl {}) + public function loop ():Bool; + + public function mute (muted:Bool, ?id:Int):Howl; + public function off (event:String, fn:Function, ?id:Int):Howl; + public function on (event:String, fn:Function, ?id:Int):Howl; + public function once (event:String, fn:Function, ?id:Int):Howl; + public function pause (?id:Int):Howl; + + @:overload(function(id:Int):Int {}) + public function play (?sprite:String):Int; + + public function playing (?id:Int):Bool; + + @:overload(function(id:Int):Float {}) + @:overload(function(rate:Float):Howl {}) + @:overload(function(rate:Float, id:Int):Howl {}) + public function rate ():Float; + + public function state ():String; + + @:overload(function(id:Int):Float {}) + @:overload(function(seek:Float):Howl {}) + @:overload(function(seek:Float, id:Int):Howl {}) + public function seek ():Float; + + public function stop (?id:Int):Howl; + public function unload ():Void; + + @:overload(function(id:Int):Float {}) + @:overload(function(vol:Float):Howl {}) + @:overload(function(vol:Float, id:Int):Howl {}) + public function volume ():Float; + + +} + + +#end + + +typedef HowlOptions = { + + src:Array, + ?volume:Float, + ?html5:Bool, + ?loop:Bool, + ?preload:Bool, + ?autoplay:Bool, + ?mute:Bool, + ?sprite:Dynamic, + ?rate:Float, + ?pool:Float, + ?format:Array, + ?onload:Function, + ?onloaderror:Function, + ?onplay:Function, + ?onend:Function, + ?onpause:Function, + ?onstop:Function, + ?onmute:Function, + ?onvolume:Function, + ?onrate:Function, + ?onseek:Function, + ?onfade:Function + +} \ No newline at end of file diff --git a/lime/media/howlerjs/Howler.hx b/lime/media/howlerjs/Howler.hx new file mode 100644 index 000000000..ea962824b --- /dev/null +++ b/lime/media/howlerjs/Howler.hx @@ -0,0 +1,95 @@ +package lime.media.howlerjs; #if (!js || !html5 || display) + + +class Howler { + + + public static var autoSuspend:Bool; + public static var ctx:WebAudioContext; + public static var masterGain:Dynamic; + public static var mobileAutoEnable:Bool; + public static var noAudio:Bool; + public static var usingWebAudio:Bool; + + + /** + * Check for codec support of specific extension. + * @param ext Audio file extention. + * @return + */ + public static function codecs (ext:String):Bool { + + return false; + + } + + + /** + * Handle muting and unmuting globally. + * @param muted Is muted or not. + */ + public static function mute (muted:Bool):Class { + + return Howler; + + } + + + /** + * Unload and destroy all currently loaded Howl objects. + * @return + */ + public static function unload ():Class { + + return Howler; + + } + + + /** + * Get/set the global volume for all sounds. + * @param vol Volume from 0.0 to 1.0. + * @return Returns self or current volume. + */ + public static function volume (?vol:Float):Dynamic { + + if (vol != null) return Howler; + return vol; + + } + + +} + + + +#else + + +import haxe.extern.EitherType; +import js.html.audio.GainNode; +import lime.media.WebAudioContext; + +@:native("Howler") + + +extern class Howler { + + + public static var autoSuspend:Bool; + public static var ctx:WebAudioContext; + public static var masterGain:GainNode; + public static var mobileAutoEnable:Bool; + public static var noAudio:Bool; + public static var usingWebAudio:Bool; + + public static function codecs (ext:String):Bool; + public static function mute (muted:Bool):Howler; + public static function unload ():Howler; + public static function volume (?vol:Float):EitherType; + + +} + + +#end \ No newline at end of file diff --git a/lime/media/openal/AL.hx b/lime/media/openal/AL.hx new file mode 100644 index 000000000..2cd5dd982 --- /dev/null +++ b/lime/media/openal/AL.hx @@ -0,0 +1,892 @@ +package lime.media.openal; + + +import lime._backend.native.NativeCFFI; +import lime.system.CFFIPointer; +import lime.utils.ArrayBufferView; + +#if !lime_debug +@:fileXml('tags="haxe,release"') +@:noDebug +#end + +@:access(lime._backend.native.NativeCFFI) + + +class AL { + + + public static inline var NONE:Int = 0; + public static inline var FALSE:Int = 0; + public static inline var TRUE:Int = 1; + public static inline var SOURCE_RELATIVE:Int = 0x202; + public static inline var CONE_INNER_ANGLE:Int = 0x1001; + public static inline var CONE_OUTER_ANGLE:Int = 0x1002; + public static inline var PITCH:Int = 0x1003; + public static inline var POSITION:Int = 0x1004; + public static inline var DIRECTION:Int = 0x1005; + public static inline var VELOCITY:Int = 0x1006; + public static inline var LOOPING:Int = 0x1007; + public static inline var BUFFER:Int = 0x1009; + public static inline var GAIN:Int = 0x100A; + public static inline var MIN_GAIN:Int = 0x100D; + public static inline var MAX_GAIN:Int = 0x100E; + public static inline var ORIENTATION:Int = 0x100F; + public static inline var SOURCE_STATE:Int = 0x1010; + public static inline var INITIAL:Int = 0x1011; + public static inline var PLAYING:Int = 0x1012; + public static inline var PAUSED:Int = 0x1013; + public static inline var STOPPED:Int = 0x1014; + public static inline var BUFFERS_QUEUED:Int = 0x1015; + public static inline var BUFFERS_PROCESSED:Int = 0x1016; + public static inline var REFERENCE_DISTANCE:Int = 0x1020; + public static inline var ROLLOFF_FACTOR:Int = 0x1021; + public static inline var CONE_OUTER_GAIN:Int = 0x1022; + public static inline var MAX_DISTANCE:Int = 0x1023; + public static inline var SEC_OFFSET:Int = 0x1024; + public static inline var SAMPLE_OFFSET:Int = 0x1025; + public static inline var BYTE_OFFSET:Int = 0x1026; + public static inline var SOURCE_TYPE:Int = 0x1027; + public static inline var STATIC:Int = 0x1028; + public static inline var STREAMING:Int = 0x1029; + public static inline var UNDETERMINED:Int = 0x1030; + public static inline var FORMAT_MONO8:Int = 0x1100; + public static inline var FORMAT_MONO16:Int = 0x1101; + public static inline var FORMAT_STEREO8:Int = 0x1102; + public static inline var FORMAT_STEREO16:Int = 0x1103; + public static inline var FREQUENCY:Int = 0x2001; + public static inline var BITS:Int = 0x2002; + public static inline var CHANNELS:Int = 0x2003; + public static inline var SIZE:Int = 0x2004; + public static inline var NO_ERROR:Int = 0; + public static inline var INVALID_NAME:Int = 0xA001; + public static inline var INVALID_ENUM:Int = 0xA002; + public static inline var INVALID_VALUE:Int = 0xA003; + public static inline var INVALID_OPERATION:Int = 0xA004; + public static inline var OUT_OF_MEMORY:Int = 0xA005; + public static inline var VENDOR:Int = 0xB001; + public static inline var VERSION:Int = 0xB002; + public static inline var RENDERER:Int = 0xB003; + public static inline var EXTENSIONS:Int = 0xB004; + public static inline var DOPPLER_FACTOR:Int = 0xC000; + public static inline var SPEED_OF_SOUND:Int = 0xC003; + public static inline var DOPPLER_VELOCITY:Int = 0xC001; + public static inline var DISTANCE_MODEL:Int = 0xD000; + public static inline var INVERSE_DISTANCE:Int = 0xD001; + public static inline var INVERSE_DISTANCE_CLAMPED:Int = 0xD002; + public static inline var LINEAR_DISTANCE:Int = 0xD003; + public static inline var LINEAR_DISTANCE_CLAMPED:Int = 0xD004; + public static inline var EXPONENT_DISTANCE:Int = 0xD005; + public static inline var EXPONENT_DISTANCE_CLAMPED:Int = 0xD006; + + + public static function bufferData (buffer:ALBuffer, format:Int, data:ArrayBufferView, size:Int, freq:Int):Void { + + #if (lime_cffi && lime_openal && !macro) + NativeCFFI.lime_al_buffer_data (buffer, format, data, size, freq); + #end + + } + + + public static function buffer3f (buffer:ALBuffer, param:Int, value1:Float, value2:Float, value3:Float):Void { + + #if (lime_cffi && lime_openal && !macro) + NativeCFFI.lime_al_buffer3f (buffer, param, value1, value2, value3); + #end + + } + + + public static function buffer3i (buffer:ALBuffer, param:Int, value1:Int, value2:Int, value3:Int):Void { + + #if (lime_cffi && lime_openal && !macro) + NativeCFFI.lime_al_buffer3i (buffer, param, value1, value2, value3); + #end + + } + + + public static function bufferf (buffer:ALBuffer, param:Int, value:Float):Void { + + #if (lime_cffi && lime_openal && !macro) + NativeCFFI.lime_al_bufferf (buffer, param, value); + #end + + } + + + public static function bufferfv (buffer:ALBuffer, param:Int, values:Array):Void { + + #if (lime_cffi && lime_openal && !macro) + NativeCFFI.lime_al_bufferfv (buffer, param, values); + #end + + } + + + public static function bufferi (buffer:ALBuffer, param:Int, value:Int):Void { + + #if (lime_cffi && lime_openal && !macro) + NativeCFFI.lime_al_bufferi (buffer, param, value); + #end + + } + + + public static function bufferiv (buffer:ALBuffer, param:Int, values:Array):Void { + + #if (lime_cffi && lime_openal && !macro) + NativeCFFI.lime_al_bufferiv (buffer, param, values); + #end + + } + + + public static function deleteBuffer (buffer:ALBuffer):Void { + + #if (lime_cffi && lime_openal && !macro) + NativeCFFI.lime_al_delete_buffer (buffer); + #end + + } + + + public static function deleteBuffers (buffers:Array):Void { + + #if (lime_cffi && lime_openal && !macro) + NativeCFFI.lime_al_delete_buffers (buffers.length, buffers); + #end + + } + + + public static function deleteSource (source:ALSource):Void { + + #if (lime_cffi && lime_openal && !macro) + NativeCFFI.lime_al_delete_source (source); + #end + + } + + + public static function deleteSources (sources:Array):Void { + + #if (lime_cffi && lime_openal && !macro) + NativeCFFI.lime_al_delete_sources (sources.length, sources); + #end + + } + + + public static function disable (capability:Int):Void { + + #if (lime_cffi && lime_openal && !macro) + NativeCFFI.lime_al_disable (capability); + #end + + } + + + public static function distanceModel (distanceModel:Int):Void { + + #if (lime_cffi && lime_openal && !macro) + NativeCFFI.lime_al_distance_model (distanceModel); + #end + + } + + + public static function dopplerFactor (value:Float):Void { + + #if (lime_cffi && lime_openal && !macro) + NativeCFFI.lime_al_doppler_factor (value); + #end + + } + + + public static function dopplerVelocity (value:Float):Void { + + #if (lime_cffi && lime_openal && !macro) + NativeCFFI.lime_al_doppler_velocity (value); + #end + + } + + + public static function enable (capability:Int):Void { + + #if (lime_cffi && lime_openal && !macro) + NativeCFFI.lime_al_enable (capability); + #end + + } + + + public static function genSource ():ALSource { + + #if (lime_cffi && lime_openal && !macro) + return NativeCFFI.lime_al_gen_source (); + #else + return null; + #end + + } + + + public static function genSources (n:Int):Array { + + #if (lime_cffi && lime_openal && !macro) + return NativeCFFI.lime_al_gen_sources (n); + #else + return null; + #end + + } + + + public static function genBuffer ():ALBuffer { + + #if (lime_cffi && lime_openal && !macro) + return NativeCFFI.lime_al_gen_buffer (); + #else + return null; + #end + + } + + + public static function genBuffers (n:Int):Array { + + #if (lime_cffi && lime_openal && !macro) + return NativeCFFI.lime_al_gen_buffers (n); + #else + return null; + #end + + } + + + public static function getBoolean (param:Int):Bool { + + #if (lime_cffi && lime_openal && !macro) + return NativeCFFI.lime_al_get_boolean (param); + #else + return false; + #end + + } + + + public static function getBooleanv (param:Int, count:Int = 1):Array { + + #if (lime_cffi && lime_openal && !macro) + return NativeCFFI.lime_al_get_booleanv (param, 1); + #else + return null; + #end + + } + + + public static function getBuffer3f (buffer:ALBuffer, param:Int):Array { + + #if (lime_cffi && lime_openal && !macro) + return NativeCFFI.lime_al_get_buffer3f (buffer, param); + #else + return null; + #end + + } + + + public static function getBuffer3i (buffer:ALBuffer, param:Int):Array { + + #if (lime_cffi && lime_openal && !macro) + return NativeCFFI.lime_al_get_buffer3i (buffer, param); + #else + return null; + #end + + } + + + public static function getBufferf (buffer:ALBuffer, param:Int):Float { + + #if (lime_cffi && lime_openal && !macro) + return NativeCFFI.lime_al_get_bufferf (buffer, param); + #else + return 0; + #end + + } + + + public static function getBufferfv (buffer:ALBuffer, param:Int, count:Int = 1):Array { + + #if (lime_cffi && lime_openal && !macro) + return NativeCFFI.lime_al_get_bufferfv (buffer, param, count); + #else + return null; + #end + + } + + + public static function getBufferi (buffer:ALBuffer, param:Int):Int { + + #if (lime_cffi && lime_openal && !macro) + return NativeCFFI.lime_al_get_bufferi (buffer, param); + #else + return 0; + #end + + } + + + public static function getBufferiv (buffer:ALBuffer, param:Int, count:Int = 1):Array { + + #if (lime_cffi && lime_openal && !macro) + return NativeCFFI.lime_al_get_bufferiv (buffer, param, count); + #else + return null; + #end + + } + + + public static function getDouble (param:Int):Float { + + #if (lime_cffi && lime_openal && !macro) + return NativeCFFI.lime_al_get_double (param); + #else + return 0; + #end + + } + + + public static function getDoublev (param:Int, count:Int = 1):Array { + + #if (lime_cffi && lime_openal && !macro) + return NativeCFFI.lime_al_get_doublev (param, count); + #else + return null; + #end + + } + + + public static function getEnumValue (ename:String):Int { + + #if (lime_cffi && lime_openal && !macro) + return NativeCFFI.lime_al_get_enum_value (ename); + #else + return 0; + #end + + } + + + public static function getError ():Int { + + #if (lime_cffi && lime_openal && !macro) + return NativeCFFI.lime_al_get_error (); + #else + return 0; + #end + + } + + + public static function getErrorString ():String { + + return switch (getError ()) { + + case INVALID_NAME: "INVALID_NAME: Invalid parameter name"; + case INVALID_ENUM: "INVALID_ENUM: Invalid enum value"; + case INVALID_VALUE: "INVALID_VALUE: Invalid parameter value"; + case INVALID_OPERATION: "INVALID_OPERATION: Illegal operation or call"; + case OUT_OF_MEMORY: "OUT_OF_MEMORY: OpenAL has run out of memory"; + default: ""; + + } + + } + + + public static function getFloat (param:Int):Float { + + #if (lime_cffi && lime_openal && !macro) + return NativeCFFI.lime_al_get_float (param); + #else + return 0; + #end + + } + + + public static function getFloatv (param:Int, count:Int = 1):Array { + + #if (lime_cffi && lime_openal && !macro) + return NativeCFFI.lime_al_get_floatv (param, count); + #else + return null; + #end + + } + + + public static function getInteger (param:Int):Int { + + #if (lime_cffi && lime_openal && !macro) + return NativeCFFI.lime_al_get_integer (param); + #else + return 0; + #end + + } + + + public static function getIntegerv (param:Int, count:Int = 1):Array { + + #if (lime_cffi && lime_openal && !macro) + return NativeCFFI.lime_al_get_integerv (param, count); + #else + return null; + #end + + } + + + public static function getListener3f (param:Int):Array { + + #if (lime_cffi && lime_openal && !macro) + return NativeCFFI.lime_al_get_listener3f (param); + #else + return null; + #end + + } + + + public static function getListener3i (param:Int):Array { + + #if (lime_cffi && lime_openal && !macro) + return NativeCFFI.lime_al_get_listener3i (param); + #else + return null; + #end + + } + + + public static function getListenerf (param:Int):Float { + + #if (lime_cffi && lime_openal && !macro) + return NativeCFFI.lime_al_get_listenerf (param); + #else + return 0; + #end + + } + + + public static function getListenerfv (param:Int, count:Int = 1):Array { + + #if (lime_cffi && lime_openal && !macro) + return NativeCFFI.lime_al_get_listenerfv (param, count); + #else + return null; + #end + + } + + + public static function getListeneri (param:Int):Int { + + #if (lime_cffi && lime_openal && !macro) + return NativeCFFI.lime_al_get_listeneri (param); + #else + return 0; + #end + + } + + + public static function getListeneriv (param:Int, count:Int = 1):Array { + + #if (lime_cffi && lime_openal && !macro) + return NativeCFFI.lime_al_get_listeneriv (param, count); + #else + return null; + #end + + } + + + public static function getProcAddress (fname:String):Dynamic { + + #if (lime_cffi && lime_openal && !macro) + return NativeCFFI.lime_al_get_proc_address (fname); + #else + return null; + #end + + } + + + public static function getSource3f (source:ALSource, param:Int):Array { + + #if (lime_cffi && lime_openal && !macro) + return NativeCFFI.lime_al_get_source3f (source, param); + #else + return null; + #end + + } + + + public static function getSourcef (source:ALSource, param:Int):Float { + + #if (lime_cffi && lime_openal && !macro) + return NativeCFFI.lime_al_get_sourcef (source, param); + #else + return 0; + #end + + } + + + public static function getSource3i (source:ALSource, param:Int):Array { + + #if (lime_cffi && lime_openal && !macro) + return NativeCFFI.lime_al_get_source3i (source, param); + #else + return null; + #end + + } + + + public static function getSourcefv (source:ALSource, param:Int, count:Int = 1):Array { + + #if (lime_cffi && lime_openal && !macro) + return NativeCFFI.lime_al_get_sourcefv (source, param, count); + #else + return null; + #end + + } + + + public static function getSourcei (source:ALSource, param:Int):Dynamic { + + #if (lime_cffi && lime_openal && !macro) + return NativeCFFI.lime_al_get_sourcei (source, param); + #else + return 0; + #end + + } + + + public static function getSourceiv (source:ALSource, param:Int, count:Int = 1):Array { + + #if (lime_cffi && lime_openal && !macro) + return NativeCFFI.lime_al_get_sourceiv (source, param, count); + #else + return null; + #end + + } + + + public static function getString (param:Int):String { + + #if (lime_cffi && lime_openal && !macro) + return NativeCFFI.lime_al_get_string (param); + #else + return null; + #end + + } + + + public static function isBuffer (buffer:ALBuffer):Bool { + + #if (lime_cffi && lime_openal && !macro) + return NativeCFFI.lime_al_is_buffer (buffer); + #else + return false; + #end + + } + + + public static function isEnabled (capability:Int):Bool { + + #if (lime_cffi && lime_openal && !macro) + return NativeCFFI.lime_al_is_enabled (capability); + #else + return false; + #end + + } + + + public static function isExtensionPresent (extname:String):Bool { + + #if (lime_cffi && lime_openal && !macro) + return NativeCFFI.lime_al_is_extension_present (extname); + #else + return false; + #end + + } + + + public static function isSource (source:ALSource):Bool { + + #if (lime_cffi && lime_openal && !macro) + return NativeCFFI.lime_al_is_source (source); + #else + return false; + #end + + } + + + public static function listener3f (param:Int, value1:Float, value2:Float, value3:Float):Void { + + #if (lime_cffi && lime_openal && !macro) + NativeCFFI.lime_al_listener3f (param, value1, value2, value3); + #end + + } + + + public static function listener3i (param:Int, value1:Int, value2:Int, value3:Int):Void { + + #if (lime_cffi && lime_openal && !macro) + NativeCFFI.lime_al_listener3i (param, value1, value2, value3); + #end + + } + + + public static function listenerf (param:Int, value:Float):Void { + + #if (lime_cffi && lime_openal && !macro) + NativeCFFI.lime_al_listenerf (param, value); + #end + + } + + + public static function listenerfv (param:Int, values:Array):Void { + + #if (lime_cffi && lime_openal && !macro) + NativeCFFI.lime_al_listenerfv (param, values); + #end + + } + + + public static function listeneri (param:Int, value:Int):Void { + + #if (lime_cffi && lime_openal && !macro) + NativeCFFI.lime_al_listeneri (param, value); + #end + + } + + + public static function listeneriv (param:Int, values:Array):Void { + + #if (lime_cffi && lime_openal && !macro) + NativeCFFI.lime_al_listeneriv (param, values); + #end + + } + + + public static function source3f (source:ALSource, param:Int, value1:Float, value2:Float, value3:Float):Void { + + #if (lime_cffi && lime_openal && !macro) + NativeCFFI.lime_al_source3f (source, param, value1, value2, value3); + #end + + } + + + public static function source3i (source:ALSource, param:Int, value1:Int, value2:Int, value3:Int):Void { + + #if (lime_cffi && lime_openal && !macro) + NativeCFFI.lime_al_source3i (source, param, value1, value2, value3); + #end + + } + + + public static function sourcef (source:ALSource, param:Int, value:Float):Void { + + #if (lime_cffi && lime_openal && !macro) + NativeCFFI.lime_al_sourcef (source, param, value); + #end + + } + + + public static function sourcefv (source:ALSource, param:Int, values:Array):Void { + + #if (lime_cffi && lime_openal && !macro) + NativeCFFI.lime_al_sourcefv (source, param, values); + #end + + } + + + public static function sourcei (source:ALSource, param:Int, value:Dynamic):Void { + + #if (lime_cffi && lime_openal && !macro) + NativeCFFI.lime_al_sourcei (source, param, value); + #end + + } + + + public static function sourceiv (source:ALSource, param:Int, values:Array):Void { + + #if (lime_cffi && lime_openal && !macro) + NativeCFFI.lime_al_sourceiv (source, param, values); + #end + + } + + + public static function sourcePlay (source:ALSource):Void { + + #if (lime_cffi && lime_openal && !macro) + NativeCFFI.lime_al_source_play (source); + #end + + } + + + public static function sourcePlayv (sources:Array):Void { + + #if (lime_cffi && lime_openal && !macro) + NativeCFFI.lime_al_source_playv (sources.length, sources); + #end + + } + + + public static function sourceStop (source:ALSource):Void { + + #if (lime_cffi && lime_openal && !macro) + NativeCFFI.lime_al_source_stop (source); + #end + + } + + + public static function sourceStopv (sources:Array):Void { + + #if (lime_cffi && lime_openal && !macro) + NativeCFFI.lime_al_source_stopv (sources.length, sources); + #end + + } + + + public static function sourceRewind (source:ALSource):Void { + + #if (lime_cffi && lime_openal && !macro) + NativeCFFI.lime_al_source_rewind (source); + #end + + } + + + public static function sourceRewindv (sources:Array):Void { + + #if (lime_cffi && lime_openal && !macro) + NativeCFFI.lime_al_source_rewindv (sources.length, sources); + #end + + } + + + public static function sourcePause (source:ALSource):Void { + + #if (lime_cffi && lime_openal && !macro) + NativeCFFI.lime_al_source_pause (source); + #end + + } + + + public static function sourcePausev (sources:Array):Void { + + #if (lime_cffi && lime_openal && !macro) + NativeCFFI.lime_al_source_pausev (sources.length, sources); + #end + + } + + + public static function sourceQueueBuffer (source:ALSource, buffer:ALBuffer):Void { + + #if (lime_cffi && lime_openal && !macro) + var buffers:Array = [ buffer ]; + NativeCFFI.lime_al_source_queue_buffers (source, 1, buffers); + #end + + } + + + public static function sourceQueueBuffers (source:ALSource, nb:Int, buffers:Array):Void { + + #if (lime_cffi && lime_openal && !macro) + NativeCFFI.lime_al_source_queue_buffers (source, nb, buffers); + #end + + } + + + public static function sourceUnqueueBuffer (source:ALSource):ALBuffer { + + #if (lime_cffi && lime_openal && !macro) + var res = NativeCFFI.lime_al_source_unqueue_buffers (source, 1); + return res[0]; + #else + return 0; + #end + + } + + + public static function sourceUnqueueBuffers (source:ALSource, nb:Int):Array { + + #if (lime_cffi && lime_openal && !macro) + return NativeCFFI.lime_al_source_unqueue_buffers (source, nb); + #else + return null; + #end + + } + + + public static function speedOfSound (value:Float):Void { + + #if (lime_cffi && lime_openal && !macro) + NativeCFFI.lime_al_speed_of_sound (value); + #end + + } + + +} \ No newline at end of file diff --git a/lime/media/openal/ALBuffer.hx b/lime/media/openal/ALBuffer.hx new file mode 100644 index 000000000..cfc4522eb --- /dev/null +++ b/lime/media/openal/ALBuffer.hx @@ -0,0 +1,19 @@ +package lime.media.openal; + + +import lime.system.CFFIPointer; + +@:allow(lime.media.openal.AL) + + +abstract ALBuffer(CFFIPointer) from CFFIPointer to CFFIPointer { + + + private inline function new (handle:CFFIPointer) { + + this = handle; + + } + + +} \ No newline at end of file diff --git a/lime/media/openal/ALC.hx b/lime/media/openal/ALC.hx new file mode 100644 index 000000000..7726f0326 --- /dev/null +++ b/lime/media/openal/ALC.hx @@ -0,0 +1,225 @@ +package lime.media.openal; + + +import lime._backend.native.NativeCFFI; +import lime.system.CFFIPointer; + +#if !lime_debug +@:fileXml('tags="haxe,release"') +@:noDebug +#end + +@:access(lime._backend.native.NativeCFFI) + + +class ALC { + + + public static inline var FALSE:Int = 0; + public static inline var TRUE:Int = 1; + public static inline var FREQUENCY:Int = 0x1007; + public static inline var REFRESH:Int = 0x1008; + public static inline var SYNC:Int = 0x1009; + public static inline var MONO_SOURCES:Int = 0x1010; + public static inline var STEREO_SOURCES:Int = 0x1011; + public static inline var NO_ERROR:Int = 0; + public static inline var INVALID_DEVICE:Int = 0xA001; + public static inline var INVALID_CONTEXT:Int = 0xA002; + public static inline var INVALID_ENUM:Int = 0xA003; + public static inline var INVALID_VALUE:Int = 0xA004; + public static inline var OUT_OF_MEMORY:Int = 0xA005; + public static inline var ATTRIBUTES_SIZE:Int = 0x1002; + public static inline var ALL_ATTRIBUTES:Int = 0x1003; + public static inline var DEFAULT_DEVICE_SPECIFIER:Int = 0x1004; + public static inline var DEVICE_SPECIFIER:Int = 0x1005; + public static inline var EXTENSIONS:Int = 0x1006; + public static inline var ENUMERATE_ALL_EXT:Int = 1; + public static inline var DEFAULT_ALL_DEVICES_SPECIFIER:Int = 0x1012; + public static inline var ALL_DEVICES_SPECIFIER:Int = 0x1013; + + + public static function closeDevice (device:ALDevice):Bool { + + #if (lime_cffi && lime_openal && !macro) + return NativeCFFI.lime_alc_close_device (device); + #else + return false; + #end + + } + + + public static function createContext (device:ALDevice, attrlist:Array = null):ALContext { + + #if (lime_cffi && lime_openal && !macro) + var handle:Dynamic = NativeCFFI.lime_alc_create_context (device, attrlist); + + if (handle != null) { + + return new ALContext (handle); + + } + #end + + return null; + + } + + + public static function destroyContext (context:ALContext):Void { + + #if (lime_cffi && lime_openal && !macro) + NativeCFFI.lime_alc_destroy_context (context); + #end + + } + + + public static function getContextsDevice (context:ALContext):ALDevice { + + #if (lime_cffi && lime_openal && !macro) + var handle:Dynamic = NativeCFFI.lime_alc_get_contexts_device (context); + + if (handle != null) { + + return new ALDevice (handle); + + } + #end + + return null; + + } + + + public static function getCurrentContext ():ALContext { + + #if (lime_cffi && lime_openal && !macro) + var handle:Dynamic = NativeCFFI.lime_alc_get_current_context (); + + if (handle != null) { + + return new ALContext (handle); + + } + #end + + return null; + + } + + + public static function getError (device:ALDevice):Int { + + #if (lime_cffi && lime_openal && !macro) + return NativeCFFI.lime_alc_get_error (device); + #else + return 0; + #end + + } + + + public static function getErrorString (device:ALDevice):String { + + return switch (getError (device)) { + + case INVALID_DEVICE: "INVALID_DEVICE: Invalid device (or no device?)"; + case INVALID_CONTEXT: "INVALID_CONTEXT: Invalid context (or no context?)"; + case INVALID_ENUM: "INVALID_ENUM: Invalid enum value"; + case INVALID_VALUE: "INVALID_VALUE: Invalid param value"; + case OUT_OF_MEMORY: "OUT_OF_MEMORY: OpenAL has run out of memory"; + default: ""; + + } + + } + + + public static function getIntegerv (device:ALDevice, param:Int, size:Int):Array { + + #if (lime_cffi && lime_openal && !macro) + return NativeCFFI.lime_alc_get_integerv (device, param, size); + #else + return null; + #end + + } + + + public static function getString (device:ALDevice, param:Int):String { + + #if (lime_cffi && lime_openal && !macro) + return NativeCFFI.lime_alc_get_string (device, param); + #else + return null; + #end + + } + + + public static function makeContextCurrent (context:ALContext):Bool { + + #if (lime_cffi && lime_openal && !macro) + return NativeCFFI.lime_alc_make_context_current (context); + #else + return false; + #end + + } + + + public static function openDevice (deviceName:String = null):ALDevice { + + #if (lime_cffi && lime_openal && !macro) + var handle:Dynamic = NativeCFFI.lime_alc_open_device (deviceName); + + if (handle != null) { + + return new ALDevice (handle); + + } + #end + + return null; + + } + + + public static function pauseDevice (device:ALDevice):Void { + + #if (lime_cffi && lime_openal && !macro) + NativeCFFI.lime_alc_pause_device (device); + #end + + } + + + public static function processContext (context:ALContext):Void { + + #if (lime_cffi && lime_openal && !macro) + NativeCFFI.lime_alc_process_context (context); + #end + + } + + + public static function resumeDevice (device:ALDevice):Void { + + #if (lime_cffi && lime_openal && !macro) + NativeCFFI.lime_alc_resume_device (device); + #end + + } + + + public static function suspendContext (context:ALContext):Void { + + #if (lime_cffi && lime_openal && !macro) + NativeCFFI.lime_alc_suspend_context (context); + #end + + } + + +} \ No newline at end of file diff --git a/lime/media/openal/ALContext.hx b/lime/media/openal/ALContext.hx new file mode 100644 index 000000000..5c908e1f9 --- /dev/null +++ b/lime/media/openal/ALContext.hx @@ -0,0 +1,20 @@ +package lime.media.openal; + + +import lime.system.CFFIPointer; + +@:allow(lime.media.openal.AL) +@:allow(lime.media.openal.ALC) + + +abstract ALContext(CFFIPointer) from CFFIPointer to CFFIPointer { + + + private inline function new (handle:CFFIPointer) { + + this = handle; + + } + + +} \ No newline at end of file diff --git a/lime/media/openal/ALDevice.hx b/lime/media/openal/ALDevice.hx new file mode 100644 index 000000000..06c554417 --- /dev/null +++ b/lime/media/openal/ALDevice.hx @@ -0,0 +1,20 @@ +package lime.media.openal; + + +import lime.system.CFFIPointer; + +@:allow(lime.media.openal.AL) +@:allow(lime.media.openal.ALC) + + +abstract ALDevice(CFFIPointer) from CFFIPointer to CFFIPointer { + + + private inline function new (handle:CFFIPointer) { + + this = handle; + + } + + +} \ No newline at end of file diff --git a/lime/media/openal/ALSource.hx b/lime/media/openal/ALSource.hx new file mode 100644 index 000000000..67c6c5e44 --- /dev/null +++ b/lime/media/openal/ALSource.hx @@ -0,0 +1,19 @@ +package lime.media.openal; + + +import lime.system.CFFIPointer; + +@:allow(lime.media.openal.AL) + + +abstract ALSource(CFFIPointer) from CFFIPointer to CFFIPointer { + + + private inline function new (handle:CFFIPointer) { + + this = handle; + + } + + +} \ No newline at end of file diff --git a/lime/utils/AssetCache.hx b/lime/utils/AssetCache.hx index c634fb928..4b4720d3c 100644 --- a/lime/utils/AssetCache.hx +++ b/lime/utils/AssetCache.hx @@ -2,7 +2,7 @@ package lime.utils; import lime._macros.AssetsMacro; -import lime.audio.AudioBuffer; +import lime.media.AudioBuffer; import lime.graphics.Image; #if !lime_debug diff --git a/lime/utils/AssetLibrary.hx b/lime/utils/AssetLibrary.hx index 21fef55bc..0c6ad5364 100644 --- a/lime/utils/AssetLibrary.hx +++ b/lime/utils/AssetLibrary.hx @@ -4,7 +4,7 @@ package lime.utils; import lime.app.Event; import lime.app.Future; import lime.app.Promise; -import lime.audio.AudioBuffer; +import lime.media.AudioBuffer; import lime.graphics.Image; import lime.text.Font; import lime.utils.AssetType; diff --git a/lime/utils/Assets.hx b/lime/utils/Assets.hx index e0a79e00d..5f699d78b 100644 --- a/lime/utils/Assets.hx +++ b/lime/utils/Assets.hx @@ -6,7 +6,7 @@ import haxe.Unserializer; import lime.app.Event; import lime.app.Promise; import lime.app.Future; -import lime.audio.AudioBuffer; +import lime.media.AudioBuffer; import lime.graphics.Image; import lime.text.Font; import lime.utils.Bytes; diff --git a/project/Build.xml b/project/Build.xml index f32be95a1..ee8c4ba25 100644 --- a/project/Build.xml +++ b/project/Build.xml @@ -123,7 +123,7 @@ - + @@ -135,7 +135,7 @@ - + @@ -206,6 +206,16 @@ +
+ + + + + + + +
+
@@ -217,8 +227,6 @@
- - @@ -227,6 +235,8 @@ + + diff --git a/project/include/hx/CFFIPrimePatch.h b/project/include/hx/CFFIPrimePatch.h deleted file mode 100644 index cdd6f94bc..000000000 --- a/project/include/hx/CFFIPrimePatch.h +++ /dev/null @@ -1,756 +0,0 @@ -#ifndef HX_CFFIPRIME_INCLUDED -#define HX_CFFIPRIME_INCLUDED - -#include "hx/CFFI.h" - - -#ifdef HXCPP_JS_PRIME -#include -typedef std::string HxString; -#else -struct HxString -{ - inline HxString(const HxString &inRHS) - { - length = inRHS.length; - __s = inRHS.__s; - } - inline HxString(const char *inS,int inLen=-1) : length(inLen), __s(inS) - { - if (length<0) - for(length=0; __s[length]; length++) { } - } - - inline int size() { return length; } - inline const char *c_str() { return __s; } - - inline HxString() : length(0), __s(0) { } - - int length; - const char *__s; - -}; -#endif - - -namespace cffi -{ - -inline value alloc_pointer(void *inPtr) { return alloc_abstract((vkind)(0x100 + 2),inPtr); } - - -template struct SigType { enum { Char='?' }; }; -template<> struct SigType { enum { Char='b' }; }; -template<> struct SigType { enum { Char='i' }; }; -template<> struct SigType { enum { Char='f' }; }; -template<> struct SigType { enum { Char='d' }; }; -template<> struct SigType { enum { Char='o' }; }; -template<> struct SigType { enum { Char='v' }; }; -template<> struct SigType { enum { Char='c' }; }; -template<> struct SigType { enum { Char='s' }; }; - -template -bool CheckSig0( RET (func)(), const char *inSig) -{ - return SigType::Char==inSig[0] && - 0 == inSig[1]; -} - - -template -bool CheckSig1( RET (func)(A0), const char *inSig) -{ - return SigType::Char==inSig[0] && - SigType::Char==inSig[1] && - 0 == inSig[2]; -} - - -template -bool CheckSig2( RET (func)(A0,A1), const char *inSig) -{ - return SigType::Char==inSig[0] && - SigType::Char==inSig[1] && - SigType::Char==inSig[2] && - 0 == inSig[3]; -} - - -template -bool CheckSig3( RET (func)(A0,A1,A2), const char *inSig) -{ - return SigType::Char==inSig[0] && - SigType::Char==inSig[1] && - SigType::Char==inSig[2] && - SigType::Char==inSig[3] && - 0 == inSig[4]; -} - - -template -bool CheckSig4( RET (func)(A0,A1,A2,A3), const char *inSig) -{ - return SigType::Char==inSig[0] && - SigType::Char==inSig[1] && - SigType::Char==inSig[2] && - SigType::Char==inSig[3] && - SigType::Char==inSig[4] && - 0 == inSig[5]; -} - - -template -bool CheckSig5( RET (func)(A0,A1,A2,A3,A4), const char *inSig) -{ - return SigType::Char==inSig[0] && - SigType::Char==inSig[1] && - SigType::Char==inSig[2] && - SigType::Char==inSig[3] && - SigType::Char==inSig[4] && - SigType::Char==inSig[5] && - 0 == inSig[6]; -} - -template -bool CheckSig6( RET (func)(A0,A1,A2,A3,A4,A5), const char *inSig) -{ - return SigType::Char==inSig[0] && - SigType::Char==inSig[1] && - SigType::Char==inSig[2] && - SigType::Char==inSig[3] && - SigType::Char==inSig[4] && - SigType::Char==inSig[5] && - SigType::Char==inSig[6] && - 0 == inSig[7]; -} - - -template -bool CheckSig7( RET (func)(A0,A1,A2,A3,A4,A5,A6), const char *inSig) -{ - return SigType::Char==inSig[0] && - SigType::Char==inSig[1] && - SigType::Char==inSig[2] && - SigType::Char==inSig[3] && - SigType::Char==inSig[4] && - SigType::Char==inSig[5] && - SigType::Char==inSig[6] && - SigType::Char==inSig[7] && - 0 == inSig[8]; -} - -template -bool CheckSig8( RET (func)(A0,A1,A2,A3,A4,A5,A6,A7), const char *inSig) -{ - return SigType::Char==inSig[0] && - SigType::Char==inSig[1] && - SigType::Char==inSig[2] && - SigType::Char==inSig[3] && - SigType::Char==inSig[4] && - SigType::Char==inSig[5] && - SigType::Char==inSig[6] && - SigType::Char==inSig[7] && - SigType::Char==inSig[8] && - 0 == inSig[9]; -} - - -template -bool CheckSig9( RET (func)(A0,A1,A2,A3,A4,A5,A6,A7,A8), const char *inSig) -{ - return SigType::Char==inSig[0] && - SigType::Char==inSig[1] && - SigType::Char==inSig[2] && - SigType::Char==inSig[3] && - SigType::Char==inSig[4] && - SigType::Char==inSig[5] && - SigType::Char==inSig[6] && - SigType::Char==inSig[7] && - SigType::Char==inSig[8] && - SigType::Char==inSig[9] && - 0 == inSig[10]; -} - -template -bool CheckSig10( RET (func)(A0,A1,A2,A3,A4,A5,A6,A7,A8,A9), const char *inSig) -{ - return SigType::Char==inSig[0] && - SigType::Char==inSig[1] && - SigType::Char==inSig[2] && - SigType::Char==inSig[3] && - SigType::Char==inSig[4] && - SigType::Char==inSig[5] && - SigType::Char==inSig[6] && - SigType::Char==inSig[7] && - SigType::Char==inSig[8] && - SigType::Char==inSig[9] && - SigType::Char==inSig[10] && - 0 == inSig[11]; -} - -template -bool CheckSig11( RET (func)(A0,A1,A2,A3,A4,A5,A6,A7,A8,A9, A10), const char *inSig) -{ - return SigType::Char==inSig[0] && - SigType::Char==inSig[1] && - SigType::Char==inSig[2] && - SigType::Char==inSig[3] && - SigType::Char==inSig[4] && - SigType::Char==inSig[5] && - SigType::Char==inSig[6] && - SigType::Char==inSig[7] && - SigType::Char==inSig[8] && - SigType::Char==inSig[9] && - SigType::Char==inSig[10] && - SigType::Char==inSig[11] && - 0 == inSig[12]; -} - - -template -bool CheckSig12( RET (func)(A0,A1,A2,A3,A4,A5,A6,A7,A8,A9, A10, A11), const char *inSig) -{ - return SigType::Char==inSig[0] && - SigType::Char==inSig[1] && - SigType::Char==inSig[2] && - SigType::Char==inSig[3] && - SigType::Char==inSig[4] && - SigType::Char==inSig[5] && - SigType::Char==inSig[6] && - SigType::Char==inSig[7] && - SigType::Char==inSig[8] && - SigType::Char==inSig[9] && - SigType::Char==inSig[10] && - SigType::Char==inSig[11] && - SigType::Char==inSig[12] && - 0 == inSig[13]; -} - - - - -inline value ToValue(int inVal) { return alloc_int(inVal); } -inline value ToValue(float inVal) { return alloc_float(inVal); } -inline value ToValue(double inVal) { return alloc_float(inVal); } -inline value ToValue(value inVal) { return inVal; } -inline value ToValue(bool inVal) { return alloc_bool(inVal); } -inline value ToValue(HxString inVal) { return alloc_string_len(inVal.c_str(),inVal.size()); } - -struct AutoValue -{ - value mValue; - - inline operator int() { return val_int(mValue); } - inline operator value() { return mValue; } - inline operator double() { return val_number(mValue); } - inline operator float() { return val_number(mValue); } - inline operator bool() { return val_bool(mValue); } - inline operator const char *() { return val_string(mValue); } - inline operator HxString() { return HxString(val_string(mValue), val_strlen(mValue)); } -}; - - - -} // end namespace cffi - - -#define PRIME_ARG_DECL0 -#define PRIME_ARG_DECL1 cffi::AutoValue a0 -#define PRIME_ARG_DECL2 PRIME_ARG_DECL1, cffi::AutoValue a1 -#define PRIME_ARG_DECL3 PRIME_ARG_DECL2, cffi::AutoValue a2 -#define PRIME_ARG_DECL4 PRIME_ARG_DECL3, cffi::AutoValue a3 -#define PRIME_ARG_DECL5 PRIME_ARG_DECL4, cffi::AutoValue a4 - -#define PRIME_ARG_LIST0 -#define PRIME_ARG_LIST1 a0 -#define PRIME_ARG_LIST2 PRIME_ARG_LIST1, a1 -#define PRIME_ARG_LIST3 PRIME_ARG_LIST2, a2 -#define PRIME_ARG_LIST4 PRIME_ARG_LIST3, a3 -#define PRIME_ARG_LIST5 PRIME_ARG_LIST4, a4 -#define PRIME_ARG_LIST6 arg[0],arg[1],arg[2],arg[3],arg[4],arg[5] -#define PRIME_ARG_LIST7 PRIME_ARG_LIST6 ,arg[6] -#define PRIME_ARG_LIST8 PRIME_ARG_LIST7 ,arg[7] -#define PRIME_ARG_LIST9 PRIME_ARG_LIST8 ,arg[8] -#define PRIME_ARG_LIST10 PRIME_ARG_LIST9 ,arg[9] -#define PRIME_ARG_LIST11 PRIME_ARG_LIST10 ,arg[10] -#define PRIME_ARG_LIST12 PRIME_ARG_LIST11 ,arg[11] - - - -#ifdef HXCPP_JS_PRIME - -#define DEFINE_PRIME0(func) EMSCRIPTEN_BINDINGS(func) { function(#func, &func); } -#define DEFINE_PRIME1(func) EMSCRIPTEN_BINDINGS(func) { function(#func, &func); } -#define DEFINE_PRIME2(func) EMSCRIPTEN_BINDINGS(func) { function(#func, &func); } -#define DEFINE_PRIME3(func) EMSCRIPTEN_BINDINGS(func) { function(#func, &func); } -#define DEFINE_PRIME4(func) EMSCRIPTEN_BINDINGS(func) { function(#func, &func); } -#define DEFINE_PRIME5(func) EMSCRIPTEN_BINDINGS(func) { function(#func, &func); } -#define DEFINE_PRIME6(func) EMSCRIPTEN_BINDINGS(func) { function(#func, &func); } -#define DEFINE_PRIME7(func) EMSCRIPTEN_BINDINGS(func) { function(#func, &func); } -#define DEFINE_PRIME8(func) EMSCRIPTEN_BINDINGS(func) { function(#func, &func); } -#define DEFINE_PRIME9(func) EMSCRIPTEN_BINDINGS(func) { function(#func, &func); } -#define DEFINE_PRIME10(func) EMSCRIPTEN_BINDINGS(func) { function(#func, &func); } -#define DEFINE_PRIME11(func) EMSCRIPTEN_BINDINGS(func) { function(#func, &func); } -#define DEFINE_PRIME12(func) EMSCRIPTEN_BINDINGS(func) { function(#func, &func); } - - -#define DEFINE_PRIME0v(func) EMSCRIPTEN_BINDINGS(func) { function(#func, &func); } -#define DEFINE_PRIME1v(func) EMSCRIPTEN_BINDINGS(func) { function(#func, &func); } -#define DEFINE_PRIME2v(func) EMSCRIPTEN_BINDINGS(func) { function(#func, &func); } -#define DEFINE_PRIME3v(func) EMSCRIPTEN_BINDINGS(func) { function(#func, &func); } -#define DEFINE_PRIME4v(func) EMSCRIPTEN_BINDINGS(func) { function(#func, &func); } -#define DEFINE_PRIME5(func) EMSCRIPTEN_BINDINGS(func) { function(#func, &func); } -#define DEFINE_PRIME6v(func) EMSCRIPTEN_BINDINGS(func) { function(#func, &func); } -#define DEFINE_PRIME7vv(func) EMSCRIPTEN_BINDINGS(func) { function(#func, &func); } -#define DEFINE_PRIME8v(func) EMSCRIPTEN_BINDINGS(func) { function(#func, &func); } -#define DEFINE_PRIME9v(func) EMSCRIPTEN_BINDINGS(func) { function(#func, &func); } -#define DEFINE_PRIME10v(func) EMSCRIPTEN_BINDINGS(func) { function(#func, &func); } -#define DEFINE_PRIME11v(func) EMSCRIPTEN_BINDINGS(func) { function(#func, &func); } -#define DEFINE_PRIME12v(func) EMSCRIPTEN_BINDINGS(func) { function(#func, &func); } - - -#elif STATIC_LINK - - -#define DEFINE_PRIME0(func) extern "C" { \ - EXPORT value func##__prime(const char *inSig) { \ - if (!cffi::CheckSig0(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ - value func##__wrap() { return cffi::ToValue( func() ); } \ - EXPORT void *func##__0() { return (void*)(&func##__wrap); } \ - int __reg_##func##__prime = hx_register_prim(#func "__prime",(void *)(&func##__prime)); \ - int __reg_##func = hx_register_prim(#func "__0",(void *)(&func##__wrap)); \ -} - -#define DEFINE_PRIME0v(func) extern "C" { \ - EXPORT value func##__prime(const char *inSig) { \ - if (!cffi::CheckSig0(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ - value func##__wrap() { func(); return alloc_null(); } \ - EXPORT void *func##__0() { return (void*)(&func##__wrap); } \ - int __reg_##func##__prime = hx_register_prim(#func "__prime",(void *)(&func##__prime)); \ - int __reg_##func = hx_register_prim(#func "__0",(void *)(&func##__wrap)); \ -} - - -#define DEFINE_PRIME1(func) extern "C" { \ - EXPORT void *func##__prime(const char *inSig) { \ - if (!cffi::CheckSig1(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ - value func##__wrap(PRIME_ARG_DECL1) { return cffi::ToValue( func(PRIME_ARG_LIST1) ); } \ - EXPORT void *func##__1() { return (void*)(&func##__wrap); } \ - int __reg_##func##__prime = hx_register_prim(#func "__prime",(void *)(&func##__prime)); \ - int __reg_##func = hx_register_prim(#func "__1",(void *)(&func##__wrap)); \ -} - -#define DEFINE_PRIME1v(func) extern "C" { \ - EXPORT void *func##__prime(const char *inSig) { \ - if (!cffi::CheckSig1(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ - value func##__wrap(PRIME_ARG_DECL1) { func(PRIME_ARG_LIST1); return alloc_null(); } \ - EXPORT void *func##__1() { return (void*)(&func##__wrap); } \ - int __reg_##func##__prime = hx_register_prim(#func "__prime",(void *)(&func##__prime)); \ - int __reg_##func = hx_register_prim(#func "__1",(void *)(&func##__wrap)); \ -} - - -#define DEFINE_PRIME2(func) extern "C" { \ - EXPORT void *func##__prime(const char *inSig) { \ - if (!cffi::CheckSig2(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ - value func##__wrap(PRIME_ARG_DECL2) { return cffi::ToValue( func(PRIME_ARG_LIST2) ); } \ - EXPORT void *func##__2() { return (void*)(&func##__wrap); } \ - int __reg_##func##__prime = hx_register_prim(#func "__prime",(void *)(&func##__prime)); \ - int __reg_##func = hx_register_prim(#func "__2",(void *)(&func##__wrap)); \ -} - -#define DEFINE_PRIME2v(func) extern "C" { \ - EXPORT void *func##__prime(const char *inSig) { \ - if (!cffi::CheckSig2(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ - value func##__wrap(PRIME_ARG_DECL2) { func(PRIME_ARG_LIST2); return alloc_null(); } \ - EXPORT void *func##__2() { return (void*)(&func##__wrap); } \ - int __reg_##func##__prime = hx_register_prim(#func "__prime",(void *)(&func##__prime)); \ - int __reg_##func = hx_register_prim(#func "__2",(void *)(&func##__wrap)); \ -} - - -#define DEFINE_PRIME3(func) extern "C" { \ - EXPORT void *func##__prime(const char *inSig) { \ - if (!cffi::CheckSig3(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ - value func##__wrap(PRIME_ARG_DECL3) { return cffi::ToValue( func(PRIME_ARG_LIST3) ); } \ - EXPORT void *func##__3() { return (void*)(&func##__wrap); } \ - int __reg_##func##__prime = hx_register_prim(#func "__prime",(void *)(&func##__prime)); \ - int __reg_##func = hx_register_prim(#func "__3",(void *)(&func##__wrap)); \ -} - -#define DEFINE_PRIME3v(func) extern "C" { \ - EXPORT void *func##__prime(const char *inSig) { \ - if (!cffi::CheckSig3(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ - value func##__wrap(PRIME_ARG_DECL3) { func(PRIME_ARG_LIST3); return alloc_null(); } \ - EXPORT void *func##__3() { return (void*)(&func##__wrap); } \ - int __reg_##func##__prime = hx_register_prim(#func "__prime",(void *)(&func##__prime)); \ - int __reg_##func = hx_register_prim(#func "__3",(void *)(&func##__wrap)); \ -} - - -#define DEFINE_PRIME4(func) extern "C" { \ - EXPORT void *func##__prime(const char *inSig) { \ - if (!cffi::CheckSig4(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ - value func##__wrap(PRIME_ARG_DECL4) { return cffi::ToValue( func(PRIME_ARG_LIST4) ); } \ - EXPORT void *func##__4() { return (void*)(&func##__wrap); } \ - int __reg_##func##__prime = hx_register_prim(#func "__prime",(void *)(&func##__prime)); \ - int __reg_##func = hx_register_prim(#func "__4",(void *)(&func##__wrap)); \ -} - -#define DEFINE_PRIME4v(func) extern "C" { \ - EXPORT void *func##__prime(const char *inSig) { \ - if (!cffi::CheckSig4(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ - value func##__wrap(PRIME_ARG_DECL4) { func(PRIME_ARG_LIST4); return alloc_null(); } \ - EXPORT void *func##__4() { return (void*)(&func##__wrap); } \ - int __reg_##func##__prime = hx_register_prim(#func "__prime",(void *)(&func##__prime)); \ - int __reg_##func = hx_register_prim(#func "__4",(void *)(&func##__wrap)); \ -} - - -#define DEFINE_PRIME5(func) extern "C" { \ - EXPORT void *func##__prime(const char *inSig) { \ - if (!cffi::CheckSig5(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ - value func##__wrap(PRIME_ARG_DECL5) { return cffi::ToValue( func(PRIME_ARG_LIST5) ); } \ - EXPORT void *func##__5() { return (void*)(&func##__wrap); } \ - int __reg_##func##__prime = hx_register_prim(#func "__prime",(void *)(&func##__prime)); \ - int __reg_##func = hx_register_prim(#func "__5",(void *)(&func##__wrap)); \ -} - -#define DEFINE_PRIME5v(func) extern "C" { \ - EXPORT void *func##__prime(const char *inSig) { \ - if (!cffi::CheckSig5(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ - value func##__wrap(PRIME_ARG_DECL5) { func(PRIME_ARG_LIST5); return alloc_null(); } \ - EXPORT void *func##__5() { return (void*)(&func##__wrap); } \ - int __reg_##func##__prime = hx_register_prim(#func "__prime",(void *)(&func##__prime)); \ - int __reg_##func = hx_register_prim(#func "__5",(void *)(&func##__wrap)); \ -} - - -#define DEFINE_PRIME6(func) extern "C" { \ - EXPORT void *func##__prime(const char *inSig) { \ - if (!cffi::CheckSig6(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ - value func##__wrap(cffi::AutoValue *arg,int) { return cffi::ToValue( func(PRIME_ARG_LIST6) ); } \ - EXPORT void *func##__MULT() { return (void*)(&func##__wrap); } \ - int __reg_##func##__prime = hx_register_prim(#func "__prime",(void *)(&func##__prime)); \ - int __reg_##func = hx_register_prim(#func "__MULT",(void *)(&func##__wrap)); \ -} - -#define DEFINE_PRIME6v(func) extern "C" { \ - EXPORT void *func##__prime(const char *inSig) { \ - if (!cffi::CheckSig6(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ - value func##__wrap(cffi::AutoValue *arg, int) { func(PRIME_ARG_LIST6); return alloc_null(); } \ - EXPORT void *func##__MULT() { return (void*)(&func##__wrap); } \ - int __reg_##func##__prime = hx_register_prim(#func "__prime",(void *)(&func##__prime)); \ - int __reg_##func = hx_register_prim(#func "__MULT",(void *)(&func##__wrap)); \ -} - - -#define DEFINE_PRIME7(func) extern "C" { \ - EXPORT void *func##__prime(const char *inSig) { \ - if (!cffi::CheckSig7(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ - value func##__wrap(cffi::AutoValue *arg,int) { return cffi::ToValue( func(PRIME_ARG_LIST7) ); } \ - EXPORT void *func##__MULT() { return (void*)(&func##__wrap); } \ - int __reg_##func##__prime = hx_register_prim(#func "__prime",(void *)(&func##__prime)); \ - int __reg_##func = hx_register_prim(#func "__MULT",(void *)(&func##__wrap)); \ -} - -#define DEFINE_PRIME7v(func) extern "C" { \ - EXPORT void *func##__prime(const char *inSig) { \ - if (!cffi::CheckSig7(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ - value func##__wrap(cffi::AutoValue *arg, int) { func(PRIME_ARG_LIST7); return alloc_null(); } \ - EXPORT void *func##__MULT() { return (void*)(&func##__wrap); } \ - int __reg_##func##__prime = hx_register_prim(#func "__prime",(void *)(&func##__prime)); \ - int __reg_##func = hx_register_prim(#func "__MULT",(void *)(&func##__wrap)); \ -} - -#define DEFINE_PRIME8(func) extern "C" { \ - EXPORT void *func##__prime(const char *inSig) { \ - if (!cffi::CheckSig8(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ - value func##__wrap(cffi::AutoValue *arg,int) { return cffi::ToValue( func(PRIME_ARG_LIST8) ); } \ - EXPORT void *func##__MULT() { return (void*)(&func##__wrap); } \ - int __reg_##func##__prime = hx_register_prim(#func "__prime",(void *)(&func##__prime)); \ - int __reg_##func = hx_register_prim(#func "__MULT",(void *)(&func##__wrap)); \ -} - -#define DEFINE_PRIME8v(func) extern "C" { \ - EXPORT void *func##__prime(const char *inSig) { \ - if (!cffi::CheckSig8(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ - value func##__wrap(cffi::AutoValue *arg, int) { func(PRIME_ARG_LIST8); return alloc_null(); } \ - EXPORT void *func##__MULT() { return (void*)(&func##__wrap); } \ - int __reg_##func##__prime = hx_register_prim(#func "__prime",(void *)(&func##__prime)); \ - int __reg_##func = hx_register_prim(#func "__MULT",(void *)(&func##__wrap)); \ -} - - -#define DEFINE_PRIME9(func) extern "C" { \ - EXPORT void *func##__prime(const char *inSig) { \ - if (!cffi::CheckSig9(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ - value func##__wrap(cffi::AutoValue *arg,int) { return cffi::ToValue( func(PRIME_ARG_LIST9) ); } \ - EXPORT void *func##__MULT() { return (void*)(&func##__wrap); } \ - int __reg_##func##__prime = hx_register_prim(#func "__prime",(void *)(&func##__prime)); \ - int __reg_##func = hx_register_prim(#func "__MULT",(void *)(&func##__wrap)); \ -} - -#define DEFINE_PRIME9v(func) extern "C" { \ - EXPORT void *func##__prime(const char *inSig) { \ - if (!cffi::CheckSig9(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ - value func##__wrap(cffi::AutoValue *arg, int) { func(PRIME_ARG_LIST9); return alloc_null(); } \ - EXPORT void *func##__MULT() { return (void*)(&func##__wrap); } \ - int __reg_##func##__prime = hx_register_prim(#func "__prime",(void *)(&func##__prime)); \ - int __reg_##func = hx_register_prim(#func "__MULT",(void *)(&func##__wrap)); \ -} - -#define DEFINE_PRIME10(func) extern "C" { \ - EXPORT void *func##__prime(const char *inSig) { \ - if (!cffi::CheckSig10(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ - value func##__wrap(cffi::AutoValue *arg,int) { return cffi::ToValue( func(PRIME_ARG_LIST10) ); } \ - EXPORT void *func##__MULT() { return (void*)(&func##__wrap); } \ - int __reg_##func##__prime = hx_register_prim(#func "__prime",(void *)(&func##__prime)); \ - int __reg_##func = hx_register_prim(#func "__MULT",(void *)(&func##__wrap)); \ -} - -#define DEFINE_PRIME10v(func) extern "C" { \ - EXPORT void *func##__prime(const char *inSig) { \ - if (!cffi::CheckSig10(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ - value func##__wrap(cffi::AutoValue *arg, int) { func(PRIME_ARG_LIST10); return alloc_null(); } \ - EXPORT void *func##__MULT() { return (void*)(&func##__wrap); } \ - int __reg_##func##__prime = hx_register_prim(#func "__prime",(void *)(&func##__prime)); \ - int __reg_##func = hx_register_prim(#func "__MULT",(void *)(&func##__wrap)); \ -} - - -#define DEFINE_PRIME11(func) extern "C" { \ - EXPORT void *func##__prime(const char *inSig) { \ - if (!cffi::CheckSig11(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ - value func##__wrap(cffi::AutoValue *arg,int) { return cffi::ToValue( func(PRIME_ARG_LIST11) ); } \ - EXPORT void *func##__MULT() { return (void*)(&func##__wrap); } \ - int __reg_##func##__prime = hx_register_prim(#func "__prime",(void *)(&func##__prime)); \ - int __reg_##func = hx_register_prim(#func "__MULT",(void *)(&func##__wrap)); \ -} - -#define DEFINE_PRIME11v(func) extern "C" { \ - EXPORT void *func##__prime(const char *inSig) { \ - if (!cffi::CheckSig11(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ - value func##__wrap(cffi::AutoValue *arg, int) { func(PRIME_ARG_LIST11); return alloc_null(); } \ - EXPORT void *func##__MULT() { return (void*)(&func##__wrap); } \ - int __reg_##func##__prime = hx_register_prim(#func "__prime",(void *)(&func##__prime)); \ - int __reg_##func = hx_register_prim(#func "__MULT",(void *)(&func##__wrap)); \ -} - - -#define DEFINE_PRIME12(func) extern "C" { \ - EXPORT void *func##__prime(const char *inSig) { \ - if (!cffi::CheckSig12(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ - value func##__wrap(cffi::AutoValue *arg,int) { return cffi::ToValue( func(PRIME_ARG_LIST12) ); } \ - EXPORT void *func##__MULT() { return (void*)(&func##__wrap); } \ - int __reg_##func##__prime = hx_register_prim(#func "__prime",(void *)(&func##__prime)); \ - int __reg_##func = hx_register_prim(#func "__MULT",(void *)(&func##__wrap)); \ -} - -#define DEFINE_PRIME12v(func) extern "C" { \ - EXPORT void *func##__prime(const char *inSig) { \ - if (!cffi::CheckSig12(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ - value func##__wrap(cffi::AutoValue *arg, int) { func(PRIME_ARG_LIST12); return alloc_null(); } \ - EXPORT void *func##__MULT() { return (void*)(&func##__wrap); } \ - int __reg_##func##__prime = hx_register_prim(#func "__prime",(void *)(&func##__prime)); \ - int __reg_##func = hx_register_prim(#func "__MULT",(void *)(&func##__wrap)); \ -} - - -#else - - -#define DEFINE_PRIME0(func) extern "C" { \ - EXPORT value func##__prime(const char *inSig) { \ - if (!cffi::CheckSig0(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ - value func##__wrap() { return cffi::ToValue( func() ); } \ - EXPORT void *func##__0() { return (void*)(&func##__wrap); } \ -} - -#define DEFINE_PRIME0v(func) extern "C" { \ - EXPORT value func##__prime(const char *inSig) { \ - if (!cffi::CheckSig0(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ - value func##__wrap() { func(); return alloc_null(); } \ - EXPORT void *func##__0() { return (void*)(&func##__wrap); } \ -} - - -#define DEFINE_PRIME1(func) extern "C" { \ - EXPORT void *func##__prime(const char *inSig) { \ - if (!cffi::CheckSig1(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ - value func##__wrap(PRIME_ARG_DECL1) { return cffi::ToValue( func(PRIME_ARG_LIST1) ); } \ - EXPORT void *func##__1() { return (void*)(&func##__wrap); } \ -} - -#define DEFINE_PRIME1v(func) extern "C" { \ - EXPORT void *func##__prime(const char *inSig) { \ - if (!cffi::CheckSig1(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ - value func##__wrap(PRIME_ARG_DECL1) { func(PRIME_ARG_LIST1); return alloc_null(); } \ - EXPORT void *func##__1() { return (void*)(&func##__wrap); } \ -} - - -#define DEFINE_PRIME2(func) extern "C" { \ - EXPORT void *func##__prime(const char *inSig) { \ - if (!cffi::CheckSig2(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ - value func##__wrap(PRIME_ARG_DECL2) { return cffi::ToValue( func(PRIME_ARG_LIST2) ); } \ - EXPORT void *func##__2() { return (void*)(&func##__wrap); } \ -} - -#define DEFINE_PRIME2v(func) extern "C" { \ - EXPORT void *func##__prime(const char *inSig) { \ - if (!cffi::CheckSig2(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ - value func##__wrap(PRIME_ARG_DECL2) { func(PRIME_ARG_LIST2); return alloc_null(); } \ - EXPORT void *func##__2() { return (void*)(&func##__wrap); } \ -} - - -#define DEFINE_PRIME3(func) extern "C" { \ - EXPORT void *func##__prime(const char *inSig) { \ - if (!cffi::CheckSig3(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ - value func##__wrap(PRIME_ARG_DECL3) { return cffi::ToValue( func(PRIME_ARG_LIST3) ); } \ - EXPORT void *func##__3() { return (void*)(&func##__wrap); } \ -} - -#define DEFINE_PRIME3v(func) extern "C" { \ - EXPORT void *func##__prime(const char *inSig) { \ - if (!cffi::CheckSig3(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ - value func##__wrap(PRIME_ARG_DECL3) { func(PRIME_ARG_LIST3); return alloc_null(); } \ - EXPORT void *func##__3() { return (void*)(&func##__wrap); } \ -} - - -#define DEFINE_PRIME4(func) extern "C" { \ - EXPORT void *func##__prime(const char *inSig) { \ - if (!cffi::CheckSig4(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ - value func##__wrap(PRIME_ARG_DECL4) { return cffi::ToValue( func(PRIME_ARG_LIST4) ); } \ - EXPORT void *func##__4() { return (void*)(&func##__wrap); } \ -} - -#define DEFINE_PRIME4v(func) extern "C" { \ - EXPORT void *func##__prime(const char *inSig) { \ - if (!cffi::CheckSig4(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ - value func##__wrap(PRIME_ARG_DECL4) { func(PRIME_ARG_LIST4); return alloc_null(); } \ - EXPORT void *func##__4() { return (void*)(&func##__wrap); } \ -} - - -#define DEFINE_PRIME5(func) extern "C" { \ - EXPORT void *func##__prime(const char *inSig) { \ - if (!cffi::CheckSig5(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ - value func##__wrap(PRIME_ARG_DECL5) { return cffi::ToValue( func(PRIME_ARG_LIST5) ); } \ - EXPORT void *func##__5() { return (void*)(&func##__wrap); } \ -} - -#define DEFINE_PRIME5v(func) extern "C" { \ - EXPORT void *func##__prime(const char *inSig) { \ - if (!cffi::CheckSig5(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ - value func##__wrap(PRIME_ARG_DECL5) { func(PRIME_ARG_LIST5); return alloc_null(); } \ - EXPORT void *func##__5() { return (void*)(&func##__wrap); } \ -} - - -#define DEFINE_PRIME6(func) extern "C" { \ - EXPORT void *func##__prime(const char *inSig) { \ - if (!cffi::CheckSig6(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ - value func##__wrap(cffi::AutoValue *arg,int) { return cffi::ToValue( func(PRIME_ARG_LIST6) ); } \ - EXPORT void *func##__MULT() { return (void*)(&func##__wrap); } \ -} - -#define DEFINE_PRIME6v(func) extern "C" { \ - EXPORT void *func##__prime(const char *inSig) { \ - if (!cffi::CheckSig6(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ - value func##__wrap(cffi::AutoValue *arg, int) { func(PRIME_ARG_LIST6); return alloc_null(); } \ - EXPORT void *func##__MULT() { return (void*)(&func##__wrap); } \ -} - - -#define DEFINE_PRIME7(func) extern "C" { \ - EXPORT void *func##__prime(const char *inSig) { \ - if (!cffi::CheckSig7(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ - value func##__wrap(cffi::AutoValue *arg,int) { return cffi::ToValue( func(PRIME_ARG_LIST7) ); } \ - EXPORT void *func##__MULT() { return (void*)(&func##__wrap); } \ -} - -#define DEFINE_PRIME7v(func) extern "C" { \ - EXPORT void *func##__prime(const char *inSig) { \ - if (!cffi::CheckSig7(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ - value func##__wrap(cffi::AutoValue *arg, int) { func(PRIME_ARG_LIST7); return alloc_null(); } \ - EXPORT void *func##__MULT() { return (void*)(&func##__wrap); } \ -} - -#define DEFINE_PRIME8(func) extern "C" { \ - EXPORT void *func##__prime(const char *inSig) { \ - if (!cffi::CheckSig8(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ - value func##__wrap(cffi::AutoValue *arg,int) { return cffi::ToValue( func(PRIME_ARG_LIST8) ); } \ - EXPORT void *func##__MULT() { return (void*)(&func##__wrap); } \ -} - -#define DEFINE_PRIME8v(func) extern "C" { \ - EXPORT void *func##__prime(const char *inSig) { \ - if (!cffi::CheckSig8(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ - value func##__wrap(cffi::AutoValue *arg, int) { func(PRIME_ARG_LIST8); return alloc_null(); } \ - EXPORT void *func##__MULT() { return (void*)(&func##__wrap); } \ -} - - -#define DEFINE_PRIME9(func) extern "C" { \ - EXPORT void *func##__prime(const char *inSig) { \ - if (!cffi::CheckSig9(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ - value func##__wrap(cffi::AutoValue *arg,int) { return cffi::ToValue( func(PRIME_ARG_LIST9) ); } \ - EXPORT void *func##__MULT() { return (void*)(&func##__wrap); } \ -} - -#define DEFINE_PRIME9v(func) extern "C" { \ - EXPORT void *func##__prime(const char *inSig) { \ - if (!cffi::CheckSig9(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ - value func##__wrap(cffi::AutoValue *arg, int) { func(PRIME_ARG_LIST9); return alloc_null(); } \ - EXPORT void *func##__MULT() { return (void*)(&func##__wrap); } \ -} - -#define DEFINE_PRIME10(func) extern "C" { \ - EXPORT void *func##__prime(const char *inSig) { \ - if (!cffi::CheckSig10(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ -} - -#define DEFINE_PRIME10v(func) extern "C" { \ - EXPORT void *func##__prime(const char *inSig) { \ - if (!cffi::CheckSig10(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ - value func##__wrap(cffi::AutoValue *arg, int) { func(PRIME_ARG_LIST10); return alloc_null(); } \ - EXPORT void *func##__MULT() { return (void*)(&func##__wrap); } \ -} - - -#define DEFINE_PRIME11(func) extern "C" { \ - EXPORT void *func##__prime(const char *inSig) { \ - if (!cffi::CheckSig11(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ - value func##__wrap(cffi::AutoValue *arg,int) { return cffi::ToValue( func(PRIME_ARG_LIST11) ); } \ - EXPORT void *func##__MULT() { return (void*)(&func##__wrap); } \ -} - -#define DEFINE_PRIME11v(func) extern "C" { \ - EXPORT void *func##__prime(const char *inSig) { \ - if (!cffi::CheckSig11(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ - value func##__wrap(cffi::AutoValue *arg, int) { func(PRIME_ARG_LIST11); return alloc_null(); } \ - EXPORT void *func##__MULT() { return (void*)(&func##__wrap); } \ -} - - -#define DEFINE_PRIME12(func) extern "C" { \ - EXPORT void *func##__prime(const char *inSig) { \ - if (!cffi::CheckSig12(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ - value func##__wrap(cffi::AutoValue *arg,int) { return cffi::ToValue( func(PRIME_ARG_LIST12) ); } \ - EXPORT void *func##__MULT() { return (void*)(&func##__wrap); } \ -} - -#define DEFINE_PRIME12v(func) extern "C" { \ - EXPORT void *func##__prime(const char *inSig) { \ - if (!cffi::CheckSig12(func,inSig)) return 0; return cffi::alloc_pointer((void*)&func); } \ - value func##__wrap(cffi::AutoValue *arg, int) { func(PRIME_ARG_LIST12); return alloc_null(); } \ - EXPORT void *func##__MULT() { return (void*)(&func##__wrap); } \ -} -#endif - -#endif - - diff --git a/project/include/audio/AudioBuffer.h b/project/include/media/AudioBuffer.h similarity index 91% rename from project/include/audio/AudioBuffer.h rename to project/include/media/AudioBuffer.h index 154261047..6817b3968 100644 --- a/project/include/audio/AudioBuffer.h +++ b/project/include/media/AudioBuffer.h @@ -1,5 +1,5 @@ -#ifndef LIME_AUDIO_AUDIO_BUFFER_H -#define LIME_AUDIO_AUDIO_BUFFER_H +#ifndef LIME_MEDIA_AUDIO_BUFFER_H +#define LIME_MEDIA_AUDIO_BUFFER_H #include diff --git a/project/include/audio/format/OGG.h b/project/include/media/containers/OGG.h similarity index 61% rename from project/include/audio/format/OGG.h rename to project/include/media/containers/OGG.h index 7559b3a5e..dd730a40d 100644 --- a/project/include/audio/format/OGG.h +++ b/project/include/media/containers/OGG.h @@ -1,8 +1,8 @@ -#ifndef LIME_AUDIO_FORMAT_OGG_H -#define LIME_AUDIO_FORMAT_OGG_H +#ifndef LIME_MEDIA_CONTAINERS_OGG_H +#define LIME_MEDIA_CONTAINERS_OGG_H -#include