1
0
Fork 0
mirror of https://github.com/ctruLua/ctruLua.git synced 2025-10-28 00:39:30 +00:00

ADDED AUDIO! WAV working perfectly

Added libogg, libvorbis and libvorbisfile to 3ds_portlibs. You will need to compile thems using make build-portlibs. Opening OGG files works but they play badly.

Added a very simple error handler in main.lua

Added audio example.

Renamed isGfxInitialised to isGfxInitialized.

Did you know? The audio module is the longest ctrµLua module.
This commit is contained in:
Reuh 2015-12-27 19:54:58 +01:00
parent 716c42b849
commit bda9de4d1c
10 changed files with 985 additions and 17 deletions

View file

@ -8,6 +8,22 @@ repeat
local file = require("openfile")("Choose a Lua file to execute", nil, ".lua", "exist")
if file then
fs.setDirectory(file:match("^(.-)[^/]*$"))
dofile(file)
local success, err = pcall(dofile, file)
if not success then
local gfx = require("ctr.gfx")
local hid = require("ctr.hid")
gfx.set3D(false)
gfx.color.setDefault(0xFFFFFFFF)
gfx.color.setBackground(0xFF000000)
gfx.font.setDefault()
while true do
hid.read()
if hid.keys().down.start then break end
gfx.startFrame(gfx.GFX_TOP)
gfx.wrappedText(0, 0, err, gfx.TOP_WIDTH)
gfx.endFrame()
gfx.render()
end
end
end
until not file

View file

@ -0,0 +1,52 @@
local ctr = require("ctr")
local hid = require("ctr.hid")
local gfx = require("ctr.gfx")
local audio = require("ctr.audio")
local test = assert(audio.load("test.wav"))
local channel = -1
local speed = 1
local leftBalance = 0.5
while true do
hid.read()
local keys = hid.keys()
if keys.down.start then break end
if keys.down.a then
channel = test:play()
end
if keys.down.up then
speed = speed + 0.01
test:speed(speed)
audio.speed(nil, speed)
end
if keys.down.down then
speed = speed - 0.01
test:speed(speed)
audio.speed(nil, speed)
end
if keys.down.left then
leftBalance = leftBalance + 0.1
test:mix(1-leftBalance, leftBalance)
audio.mix(nil, leftBalance, 1-leftBalance)
end
if keys.down.right then
leftBalance = leftBalance - 0.1
test:mix(1-leftBalance, leftBalance)
audio.mix(nil, leftBalance, 1-leftBalance)
end
gfx.startFrame(gfx.GFX_TOP)
gfx.text(5, 5, "Audio test! "..tostring(test:time()).."/"..tostring(test:duration()).."s")
gfx.text(5, 25, "Last audio played on channel "..tostring(channel))
gfx.text(5, 65, "Speed: "..(speed*100).."% - Left balance: "..(leftBalance*100).."%")
gfx.endFrame()
gfx.render()
end
test:unload()

Binary file not shown.