anyone built non signal lfos?

    Jan 11 2012 | 12:07 pm
    I would like to build a simple lfo with sine/triangle/ramp-up/ramp-down and random waveforms using native max objects and have them as basic/simple as possible
    Have you made something like this?

    • Jan 11 2012 | 1:03 pm
      You are not alone !
      It is a pitty, that we dont have a simple, native max lfo object.
      So we all building our own, which is very inefficient.
      There ale good tutorials building signal rate lfos here:
      There is also an javascript version, which is non signal:
    • Jan 11 2012 | 1:03 pm
      What do you need it for? I get this odd feeling classes have started again. Why not just use a signal based one and snapshot~ it?
    • Jan 11 2012 | 1:31 pm
      mine are based on [line].
      think of [line] as your master-[phasor~] and then use its output to make up cosine or tri modulators.
      this way it is also pretty straightforward to implement phase distortion, as you only need to apply it to
      the master [line]. the same is true for AM and FM (well FM is tricky)
    • Jan 11 2012 | 1:33 pm
      this would be my approach:
      edit: of course I forgot about line, which would simplify my patch somewhat; thanks Roman
    • Jan 11 2012 | 1:55 pm
      of course, if someone creates only MIDI data he could work in 7 or 8 bit and use a counter.
      but line is also cool when you give the user a parameter where he can change the resolution.
      i wouldnt like to run a data LFO with 5 millisecond intervals in a sequencer app. :)
    • Jan 11 2012 | 10:03 pm
      @ Terry McDermott
      Could you get the same results with a more friendly looking patch :)
      @ MuShoo
      Its not homework, Im just thinking it would be cool to learn an other approach than snapshot~
      Thanks all!
    • Jan 11 2012 | 11:56 pm
      not sure what you mean by friendly, but heres a version using line as roman suggested
    • Jan 12 2012 | 2:24 am
      Here's yet another (didactic) solution.
      The canonical way to get cyclic "oscillator" behavior is, for every sample number (n), take a step of a certain size (increment) at a certain rate of speed (samplerate) wrapping around to stay within a specific range (length) such that you complete a certain number of cycles (frequency). What you'll get is an index (x) that you can use to look up values in a table, or as input to an equation, to get a result (y).
      What should the step size (the increment) be? It's determined by the formula
      increment = n*frequency*length/samplerate.
      [I learned the above from Elements of Computer Music by F. Richard Moore.]
      In this example patch, the counter object produces the sample number (n), triggered by metro producing the desired number of bangs per second (the sample rate). I arbitrarily chose a "length" of 1000 because it gives a reasonable degree of precision and makes the math simple.
      Set an LFO rate you want (e.g., 0.25 for a cycle every four seconds) and a sample rate you want (e.g. 20 samples per second).
      The expr calculates a sine, but you could use any formula. If you want a lookup table of floats, you can use buffer~ and peek~, as shown in the far right part of the patch. (In this example, I fill it with one cycle of a sine wave on load, then use it as a 1000-element lookup table.)
      If this seems useful to you, you could encapsulate the core part of it and use it as an abstraction.
    • Jan 12 2012 | 9:01 am
      In addition to the Elements of Computer Music, a clear example of this idea can be found in Hal Chamberlin's "Musical Applications of Microprocessors," which is where I learned it.
    • May 04 2012 | 2:58 pm
      nice thread.
      i have this idea of a non-signal phasor with a lenth independent playbackrate - so when changing the length the frequency of the playback doesnt change. is this somehow possible without recalculation the frequency
      everytime i change the durration/length to be played?
      of course i checked christophers example patch wich is very interessting.
      maybe iam blind, but could it be that the phasor part doent work correct?
      when setting the lfo speed to 0 it should stay at the actual position but instead it always jumps back to 0. and there are also some modulations in
      position when changing the lfo speed.
      thanks for help,