lua-users home
lua-l archive

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


On Sun, Sep 04, 2011 at 04:59:23PM +0200, Luciano de Souza wrote:
> 
> I know to create the wave files, but I am not able to join them. I have 
> never read binary files in Lua and I don't know how to do it. 

It's this simple:

file1 = io.open("file1.wav","*a")
header1 = file1:sub(1,44)
body1 = file1:sub(45)

file2 = io.open("file2.wav","*a")
header2 = file2:sub(1,44)
body2 = file2:sub(45)

header3 = combine(header1,header2) -- you seem to know how

io.open("file3.wav","w"):write(header3..body1..body2)

Dirk