Ramp and stay at highest value

hey,
this is quite a simple one, but its late.
How can i play a Synth which ramps up a value and then stays there infinitly.
for example:
freq = Line.kr(50.0, 400.0, 2). and then it should stay at 400 for ever.

thanks

Also late here, but I thought of:

Env([50,400],2).kr(gate:1)

hey thanks @elgiano always a pleasure :slight_smile:
different question but somehow related:
i want to use Blip.ar like this:
source = Blip.ar(freq, harm);`in the SynthDef and add additional harmonics via MIDI CC for the Synth while its playing.
how can you do this gradually without any jumps?

MIDIdef.cc(\harm, {
	| val, num, chan, src |
	var harm;
	harm = val.linlin(0, 127, 1.0, 30.0);
	~drone.set(\harm, harm);
}, 18);
1 Like

Line.kr should do exactly what you describe – did you not get the results you expected with it?

{ var freq = Line.kr(50, 400, 2).poll; SinOsc.ar(freq) * 0.1 }.play; // using poll to see Line.kr output in Post window
1 Like

By “gradually without any jumps” do you mean something like this?

(
{
	arg freq = 100, numHarm = 20;
	var snd = Blip.ar(freq, numHarm) * 0.2;
	snd = LPF.ar(snd, MouseX.kr(freq, freq * numHarm));
}.scope
)

@Bruno yes Line.kr is working. should have tested with a more obvious sound like a SinOsc. Thanks

1 Like

this is doing the glissando effect i was searching for. But im not sure what to put in the SynthDef instead of MouseX and in the MidiDef to Control the smooth addition of harmonics via MIDI CC.
I was trying this and also looking at Lag and VarLag (not sure if these are right for this instance):

sig = LPF.ar(sig, Line.kr(freq, freq * numHarm));
MIDIdef.cc(\numHarm, {
	| val, num, chan, src |
	var numHarm;
	numHarm = val.linlin(0, 127, 1.0, 30.0);
	~drone.set(\numHarm, numHarm);
}, 18);

This is not working.
I Think Im generally stuck with combining LFOs, Ramps etc. for modulation, additional harmonics, triggerRate, freq etc. in the SynthDef with Patterns or Routines and Midi CC at the same time. thanks alot for your help :slight_smile:

For smoothing control values from external sources, use Lag, not Line.

hjh

Can you send the full code of your SynthDef? It’s easier to help when we see the complete snippet.

this is the full code:

(
SynthDef(\drone, {
	arg freq=150, numHarm=1, amp=0.01, out=0;

    var sig;

	sig = Blip.ar(freq, numHarm);

	sig = LPF.ar(sig, Line.kr(freq, freq * numHarm));

	sig = sig * amp;
	Out.ar(out, sig);
}).add;
)

(
~drone = Synth(\drone,
	[
		\freq, 150,
]);

MIDIdef.cc(\numHarm, {

	| val, num, chan, src |
	var numHarm;

	//[val, num].postln;
	numHarm = val.linlin(0, 127, 1, 30);
	~drone.set(\numHarm, numHarm);

}, 17);
)

not sure how to use Lag instead of Line as suggested
thanks :slight_smile:

Use

Lag.kr(numharm)

instead of Line.kr.

You can also control the amount of lag time with the second argument:

Lag.kr(number, 1)

(The number 1 here means, ‘take 1 second to reach new value from old value’)

B