Hi Tomaso and welcome to the forums!
There are basically three ways to do this (in ascending order of complexity):
1) Use the Range operator. This source will generate a sequence of values between Start and Count, which you can parameterize in the workflow. You can rescale the ramp to be between any values by using the Rescale operator. This is probably the easiest way.
2) Use the Scan operator. This operator allows you to implement output feedback in bonsai. It's a nested operator, which means you have to write the workflow inside. The way it works is that every value you place in the WorkflowOutput will be fedback to the input Source1. This feedback is combined with the actual input to the node. For example, to create an accumulator in this way:
This method can be useful for building non-linear, or conditional, accumulators, since you can use all the power of Bonsai workflows to decide how your accumulation is computed.
3) Use a CSharpSource and write your own custom script operator (2.4-preview only). If you are using the preview, you can try the new C# script support. Insert a CSharpSource operator into the workflow, and double-click on it to launch the editor. Any parameters you include in the source will be directly configurable in the workflow. For example, here is a source that outputs a sequence of elements generated from a for loop:
using Bonsai;
using System;
using System.ComponentModel;
using System.Collections.Generic;
using System.Linq;
using System.Reactive.Linq;
[Combinator]
[Description("")]
[WorkflowElementCategory(ElementCategory.Source)]
public class Loop
{
public int Iterations { get; set; }
public IObservable<int> Process()
{
return Observable.Defer(() =>
{
var values = new int[Iterations];
for (int i = 0; i < values.Length; i++)
{
values[i] = i;
}
return values.ToObservable();
});
}
}
This last method has maximum flexibility as you can use all Bonsai features, all of reactive, and all of C# to generate your values.
There are lots of variants of each of these methods that you could use to generate elements depending on what you need, but hope this helps!