WaveBeans / wavebeans

Audio Processing. On scale.
https://wavebeans.io
Apache License 2.0
24 stars 0 forks source link

Input as function #18

Closed asubb closed 4 years ago

asubb commented 4 years ago

There should be a way to create input as a function.

The signature of the function is: (Long, Float) -> T?, where the Long parameter is the index of the sample on the timeline, the float is desired sample rate, and T is the output type.

For example the sine might be generated this way:

val amplitude = 1.0
val frequency = 440.0
Input {x, sampleRate -> sampleOf(amplitude * cos(x / sampleRate * 2 * PI * frequency)) }

The returning value is defined by the function, if returned null that means this is the end of the stream.

asubb commented 4 years ago

Implemented in https://github.com/asubb/wavebeans/pull/20