Sound and effects help

Hi all,

I'm implementing some effects in a little looper project and need some help with a couple of things:

  1. In Lua the delay effect doesn't have a setLength() method like the C equivalent, in order to change the delay length I'm having to hack it, unsurpringly this crashes on hardware if you change too quickly (debounce is definitely needed), am I missing something or is it just a gap in the API?
delayAEffect:setAmountListener(function(value)
	--todo debounce?
	sound.removeEffect(delayFx)
	delay = map(value, 0.0, 1.0, 0.0, 5.0)--remap the normalised value to 0 to 5 seconds
	delayFx = sound.delayline.new(delay)
	sound.addEffect(delayFx)
end)
  1. In order to boost recorded audio a little I'm applying overdrive, I've seen in example code :setGain(2.0) but can't find any documentation on valid ranges. I assume with most params unless otherwise specified it's a normalised 0.0 to 1.0 value but that doesn't seem the case here.
overdriveEffect:setAmountListener(function(value)
	overdrive:setGain(map(value, 0.0, 1.0, 0.0, 3.0))--map normalised value to 0.0 - 3.0
end)
  1. Lastly just confirming when I add a delay line tap I don't need to do anything else to attach it to an audio source if I'm not using channels? When the user changes the delay length I'm adding a couple of taps like so:
delayAEffect:setAmountListener(function(value)
	--todo debounce?
	sound.removeEffect(delayFx)
	delay = map(value, 0.0, 1.0, 0.01, 5.0)
	delayFx = sound.delayline.new(delay)
	sound.addEffect(delayFx)
	delayTapA = delayFx:addTap(delay)
	delayTapB = delayFx:addTap(delay)
end)

They can then mutate the tap delay anywhere within the new delay max, does this all sound correct?

delayTapA:setDelay(map(value, 0.0, 1.0, 0.0, delay))

Thanks in advance for any help, I think I'm just missing a bit of clarity on a few things and there's a bit of guesswork going on

Sorry this one slipped through the cracks! I think you've already worked this out, but I'll follow up here just for the record.

The delay is an effect you can add to a channel--its input is the sum of the sources in the channel with any previous effects applied, and its output is whatever went in <length of delay line> seconds ago multiplied by the mix parameter. Its length isn't meant to be changed on the fly, since that requires reallocating the ring buffer. If you want a variable delay, you instead set the delay line's length to the maximum time you'll need and add a tap. In this usage, you'll likely also want to set the delay line's mix parameter to 0, so that it doesn't output anything itself.

The tap is an audio source, so it needs to be explicitly added to a channel before it's audible. In the Lua interface we automatically add synths and file/sampleplayers to the default channel when they're triggered, if they haven't been assigned to another channel, but there's no equivalent action with the taps so that has to be done by hand. (Unfortunately, we don't have a "get default channel" function in Lua like we do in the C interface, so until I get that added you'll have to put the taps on a separate channel created with snd.channel.new().)

It looks like we don't have any Lua examples using delay line taps. I'll try and fix that soon.

As for the overdrive gain, the value is clamped to 0-7. I think somewhere else I'd said the max gain in 127, but I was misreading the code. (Or maybe I'm misreading it now! :person_shrugging:) But I think anything above 7 is going to be pretty much indistinguishable. You can always add a second overdrive to get up to 49x if you really need it. :slight_smile:

1 Like