Trying the new stuff in 0.11.0
Posted: Thu Jul 27, 2017 5:42 pm
LÖVE 0.11.0 hasn't been released yet, but we can still try some of the new stuff in progress by using the nightly builds (Windows, Linux (the ones with "minor" in the name), and I'm not sure if this Mac build is for 0.11.0 or the current version).
You can read some of the changes here: http://www.love2d.org/wiki/0.11.0
And about some of the audio stuff here: https://love2d.org/wiki/Effect_Constant ... Candidates
So here's some of the stuff I've been checking out...
You can now press Ctrl+C to copy error messages. Neat!
You can use QueueableSources to play sounds (from SoundData) seamlessly one after the other.
You can use RecordingDevices to record sound, and turn it into SoundData for playing. This example records for a couple of seconds (based on the number of samples that I've set) when you press a key, then when you press a key again it stops recording and plays back what it recorded.
This example uses recording and a QueueableSource to play back what is recorded after a delay.
Filters and effects can be put on audio. This example attenuates higher frequencies, hold the down or up arrow to change the amount (I've including a white noise file in the .love file too so you can hear what it sounds like on that if you want).
Maybe someone could give an example for audio effects?
You can read some of the changes here: http://www.love2d.org/wiki/0.11.0
And about some of the audio stuff here: https://love2d.org/wiki/Effect_Constant ... Candidates
So here's some of the stuff I've been checking out...
You can now press Ctrl+C to copy error messages. Neat!
You can use QueueableSources to play sounds (from SoundData) seamlessly one after the other.
Code: Select all
function love.load()
sd1 = love.sound.newSoundData('1.mp3')
sd2 = love.sound.newSoundData('2.mp3')
sd3 = love.sound.newSoundData('3.mp3')
sd4 = love.sound.newSoundData('4.mp3')
qs = love.audio.newQueueableSource(sd1:getSampleRate(), sd1:getBitDepth(), sd1:getChannels())
qs:queue(sd1)
qs:queue(sd2)
qs:queue(sd3)
qs:queue(sd4)
love.audio.play(qs)
end
Code: Select all
function love.load()
rds = love.audio.getRecordingDevices()
rd = rds[1]
end
function love.keypressed()
if rd:isRecording() then
local sounddata = rd:getData()
rd:stop()
local source = love.audio.newSource(sounddata)
love.audio.play(source)
else
local sampleRate = 8000
local bitDepth = 16
local channels = 1
local samples = sampleRate * 2
rd:start(samples, sampleRate, bitDepth, channels)
end
end
function love.draw()
love.graphics.print(
'is recording: '..tostring(rd:isRecording())..'\n'..
'samples: '..rd:getSampleCount()..'\n\n'..
'sample rate: '..rd:getSampleRate()..'\n'..
'bit depth: '..rd:getBitDepth()..'\n'..
'channels: '..rd:getChannels()
)
end
Code: Select all
function love.load()
rds = love.audio.getRecordingDevices()
rd = rds[1]
qs = love.audio.newQueueableSource(rd:getSampleRate(), rd:getBitDepth(), rd:getChannels())
rd:start()
end
function love.update(dt)
if rd:getSampleCount() > 4000 then
qs:queue(rd:getData())
qs:play()
end
end
function love.draw()
love.graphics.print('sample count: '..rd:getSampleCount())
end
Code: Select all
function love.load()
love.keyboard.setKeyRepeat(true)
source = love.audio.newSource('loop.mp3', 'static')
source:setLooping(true)
love.audio.play(source)
highgain = 1
end
function love.keypressed(key)
if key == 'up' then
highgain = math.min(highgain + 0.01, 1)
elseif key == 'down' then
highgain = math.max(highgain - 0.01, 0)
end
source:setFilter({ type = "lowpass", highgain = highgain })
end
function love.draw()
love.graphics.print(highgain)
end