|
|
@@ -45,32 +45,35 @@ sys.taskInit(function()
|
|
|
fatfs.mount("SD", 0, TF_CS, 24000000)
|
|
|
local data, err = fatfs.getfree("SD")
|
|
|
local buff = zbuff.create(1024)
|
|
|
- local in_buff = zbuff.create(8 * 1024 + 512)
|
|
|
+ local in_buff = zbuff.create(2 * 1024 + 512)
|
|
|
if data then
|
|
|
log.info("fatfs", "getfree", json.encode(data))
|
|
|
f = io.open("/sd/music/test1.mp3", "rb")
|
|
|
if f then
|
|
|
log.debug("find mp3")
|
|
|
- data = f:read(8192)
|
|
|
+ data = f:read(2048)
|
|
|
codecr = codec.create(codec.MP3)
|
|
|
local result, AudioFormat, NumChannels, SampleRate, BitsPerSample, is_signed = codec.get_audio_info(codecr, data)
|
|
|
if result then
|
|
|
- buff:resize(SampleRate * 2)
|
|
|
+ buff:resize(65536)
|
|
|
in_buff:copy(nil, data)
|
|
|
result = codec.get_audio_data(codecr, in_buff, buff)
|
|
|
log.debug("start", audio.start(0, AudioFormat, NumChannels, SampleRate, BitsPerSample, is_signed))
|
|
|
audio.write(0, buff)
|
|
|
- data = f:read(8192)
|
|
|
+ data = f:read(2048)
|
|
|
in_buff:copy(nil, data)
|
|
|
result = codec.get_audio_data(codecr, in_buff, buff)
|
|
|
audio.write(0, buff)
|
|
|
- data = f:read(8192)
|
|
|
+ data = f:read(2048)
|
|
|
+ buff:resize(1024)
|
|
|
while data and #data > 0 do
|
|
|
sys.waitUntil("moredata", 2000)
|
|
|
in_buff:copy(nil, data)
|
|
|
+ buff:resize(65536)
|
|
|
result = codec.get_audio_data(codecr, in_buff, buff)
|
|
|
audio.write(0, buff)
|
|
|
- data = f:read(8192)
|
|
|
+ buff:resize(1024)
|
|
|
+ data = f:read(2048)
|
|
|
end
|
|
|
sys.waitUntil("playover", 2000)
|
|
|
codec.release(codecr)
|
|
|
@@ -83,6 +86,7 @@ sys.taskInit(function()
|
|
|
data = nil
|
|
|
f = io.open("/sd/music/test.wav", "rb")
|
|
|
if f then
|
|
|
+ buff:resize(1024)
|
|
|
buff:seek(0, zbuff.SEEK_SET)
|
|
|
buff:copy(0, f:read(12))
|
|
|
if buff:query(0, 4) == 'RIFF' and buff:query(8, 4) == 'WAVE' then
|