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

gfx.GFX_TOP, gfx.GFX_BOTTOM, gfx.GFX_LEFT, gfx.GFX_RIGHT -> gfx.TOP, gfx.BOTTOM, gfx.LEFT, gfx.RIGHT

Also commented and moved tests/audio to examples/audio because the code is quite clean, and we lack examples.
This commit is contained in:
Reuh 2015-12-30 19:15:46 +01:00
parent 73b5c55133
commit b87b2676e6
7 changed files with 31 additions and 30 deletions

View file

@ -0,0 +1,53 @@
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")) -- Load audio file
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() -- Play audio (an audio can be played multiple times at the same time)
end
if keys.down.up then
speed = speed + 0.01
test:speed(speed) -- Set the audio object default speed, will affect the next time it is played
audio.speed(nil, speed) -- Set the speed of all the currently playing channels
end
if keys.down.down then
speed = speed - 0.01
test:speed(speed) -- See above
audio.speed(nil, speed)
end
if keys.down.left then
leftBalance = leftBalance + 0.1
test:mix(1-leftBalance, leftBalance) -- Set the audio mix: left speaker will be at leftBalance% and right speaker 1-leftBalance%.
-- Like with test:speed(), it won't affect the currently playing audios but the nexts test:play() will have theses mix paramters.
audio.mix(nil, leftBalance, 1-leftBalance) -- Set the mix of all currently playing channels
end
if keys.down.right then
leftBalance = leftBalance - 0.1
test:mix(1-leftBalance, leftBalance) -- See above
audio.mix(nil, leftBalance, 1-leftBalance)
end
gfx.start(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.stop()
gfx.render()
end
test:unload() -- Unload audio file

Binary file not shown.

View file

@ -47,19 +47,19 @@ while ctr.run() do
dMul = hid.pos3d()
gfx.start(gfx.GFX_TOP, gfx.GFX_LEFT)
gfx.start(gfx.TOP, gfx.LEFT)
drawStuffIn3D(-1)
gfx.stop()
gfx.start(gfx.GFX_TOP, gfx.GFX_RIGHT)
gfx.start(gfx.TOP, gfx.RIGHT)
drawStuffIn3D(1)
gfx.stop()
gfx.start(gfx.GFX_BOTTOM)
gfx.start(gfx.BOTTOM)
gfx.color.setDefault(gfx.color.RGBA8(0, 0, 0))
gfx.text(5, 5, "FPS: "..math.ceil(gfx.getFPS()))