lua-users home
lua-l archive

Quite remarkable! (Lua as a waveform visualisator)

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


I eventually did it only the "userdata int array" way, as suggested on the list, and the results are quite remarkable:
Lua:
[iMac:~/TestBox/Sources/luax-perforce] asko% ./luax Apps/sdl_mixer/sdlwav.lua
	out_darwin/luax_gui -w -l kernel -v Apps/sdl_mixer/sdlwav.lua
	Lua 5.1 (work4) Copyright (C) 1994-2004 Tecgraf, PUC-Rio
USES 'lib.sdl2' (global): /Users/asko/TestBox/Sources/luax-perforce/Modules/SDL2/sdl2_wrap.lua USES 'lib.sdl_mixer' (global): /Users/asko/TestBox/Sources/luax-perforce/Modules/SDL_mixer/ sdl_mixer_wrap.lua
	Opened audio at 44100 Hz 16 bit stereo, 512 samples buffered
	fps=13.70
Native C:
[iMac:~/TestBox/Sources/luax-perforce] asko% Apps/sdl_mixer/sdlwav Apps/sdl_mixer/funky.mp3
	Opened audio at 44100 Hz 16 bit stereo, 512 bytes audio buffer
	fps=43.22
The application is an SDL mixer demo that plays a tune and simultaneously shows its waveform on the screen. The 43->13 fps change is hardly noticable to the eye, certainly much less than I expected (the C code is tight, and the mixed sound data is passed as 2048 bytes per callback). Well done, Lua!! :)
-ak
 a) table:
	+ conceptually "the right thing"
	- performance must be lowest?
Have you tested it? If performance is low, you can try to reuse a table
(instead of creating a new one for each call).
b) ... (lots of integer values):
	+ fast to send, fast to receive
	- is there a limit to the number of args one can get? is 10000 too
many?
Far too many.
-- Roberto

AltStyle によって変換されたページ (->オリジナル) /