expose audio to twnlua
This commit is contained in:
parent
d5b42fa242
commit
9d0a2cab81
@ -34,7 +34,7 @@ def default(parameter):
|
||||
def to_table(typedesc, variable, indent = 0):
|
||||
binding = ' ' * indent + "lua_createtable(L, 0, %i);\n" % len(typedesc["fields"])
|
||||
for field in typedesc["fields"]:
|
||||
if field["type"] == "float":
|
||||
if field["type"] == "float" or field["type"] == "uint8_t":
|
||||
binding += ' ' * indent + "lua_pushnumber(L, (double)(%s));\n" % (variable + ".%s" % field["name"])
|
||||
elif field["type"] == "bool":
|
||||
binding += ' ' * indent + "lua_pushboolean(L, (%s));\n" % (variable + ".%s" % field["name"])
|
||||
@ -50,8 +50,8 @@ def from_table(typedesc, variable, indent = 0):
|
||||
binding = ""
|
||||
for field in typedesc["fields"]:
|
||||
binding += ' ' * indent + "lua_getfield(L, -1, \"%s\");\n" % field["name"]
|
||||
if field["type"] == "float":
|
||||
binding += ' ' * indent + "%s = (float)lua_tonumber(L, -1);\n" % (variable + ".%s" % field["name"])
|
||||
if field["type"] == "float" or field["type"] == "uint8_t":
|
||||
binding += ' ' * indent + "%s = (%s)lua_tonumber(L, -1);\n" % (variable + ".%s" % field["name"], field["type"])
|
||||
elif field["type"] == "bool":
|
||||
binding += ' ' * indent + "%s = lua_toboolean(L, -1);\n" % (variable + ".%s" % field["name"])
|
||||
elif field["type"] in api["types"]:
|
||||
|
@ -9,7 +9,7 @@
|
||||
/* plays audio file at specified channel or at scratch channel if NULL is passed, without ability to refer to it later */
|
||||
/* path path must contain valid file extension to infer which file format it is */
|
||||
/* supported formats: .ogg, .xm */
|
||||
TWN_API void audio_play(const char *path,
|
||||
TWN_API void audio_play(const char *audio,
|
||||
const char *channel, /* optional */
|
||||
bool repeat, /* default: false */
|
||||
float volume, /* default: 1.0f, range: 0.0f to 1.0f */
|
||||
|
@ -213,6 +213,30 @@
|
||||
{ "name": "textures", "type": "char *", "default": {} }
|
||||
]
|
||||
},
|
||||
|
||||
"audio_play": {
|
||||
"module": "audio",
|
||||
"symbol": "play",
|
||||
"header": "twn_audio.h",
|
||||
"params": [
|
||||
{ "name": "audio", "type": "char *" },
|
||||
{ "name": "channel", "type": "char *", "default": {} },
|
||||
{ "name": "repeat", "type": "bool", "default": false },
|
||||
{ "name": "volume", "type": "float", "default": 1.0 },
|
||||
{ "name": "panning", "type": "float", "default": 0.0 }
|
||||
]
|
||||
},
|
||||
|
||||
"audio_parameter": {
|
||||
"module": "audio",
|
||||
"symbol": "parameter",
|
||||
"header": "twn_audio.h",
|
||||
"params": [
|
||||
{ "name": "channel", "type": "char *" },
|
||||
{ "name": "parameter", "type": "char *" },
|
||||
{ "name": "value", "type": "float" }
|
||||
]
|
||||
}
|
||||
},
|
||||
|
||||
"types": {
|
||||
|
Loading…
Reference in New Issue
Block a user