Exemplo n.º 1
0
int w_newSoundData(lua_State *L)
{
    SoundData *t = 0;

    if (lua_isnumber(L, 1))
    {
        int samples = luaL_checkint(L, 1);
        int sampleRate = luaL_optint(L, 2, Decoder::DEFAULT_SAMPLE_RATE);
        int bits = luaL_optint(L, 3, Decoder::DEFAULT_BITS);
        int channels = luaL_optint(L, 4, Decoder::DEFAULT_CHANNELS);

        try
        {
            t = instance->newSoundData(samples, sampleRate, bits, channels);
        }
        catch(love::Exception &e)
        {
            return luaL_error(L, e.what());
        }

    }
    // Must be string or decoder.
    else
    {

        // Convert to Decoder, if necessary.
        if (!luax_istype(L, 1, SOUND_DECODER_T))
        {
            w_newDecoder(L);
            lua_replace(L, 1);
        }

        try
        {
            t = instance->newSoundData(luax_checkdecoder(L, 1));
        }
        catch(love::Exception &e)
        {
            return luaL_error(L, e.what());
        }
    }

    luax_newtype(L, "SoundData", SOUND_SOUND_DATA_T, (void *)t);

    return 1;
}
Exemplo n.º 2
0
int w_Decoder_getBitDepth(lua_State *L)
{
	Decoder *t = luax_checkdecoder(L, 1);
	lua_pushinteger(L, t->getBitDepth());
	return 1;
}
Exemplo n.º 3
0
int w_Decoder_getSampleRate(lua_State *L)
{
	Decoder *t = luax_checkdecoder(L, 1);
	lua_pushinteger(L, t->getSampleRate());
	return 1;
}
Exemplo n.º 4
0
int w_Decoder_getChannels(lua_State *L)
{
	Decoder *t = luax_checkdecoder(L, 1);
	lua_pushinteger(L, t->getChannels());
	return 1;
}