ChannelOut from variable?

Discussion in 'PangoScript, Universe and Midi Templates' started by tribble, Sep 14, 2014.

  1. tribble

    tribble Member


    I've been playing with mapping APC40 values to abstract generator parameters. I've gotten inconsistent results, I think mostly due to the values coming from the APC40 not always being in a useful range for the control I've mapped it to.

    But that aside, what I would like to do is control the rate of change of an abstract generator parameter from a Beyond channel. I figured I could set up a global variable to have the current value, and then when the MIDI control channel value is in a certain range, I can add or subtract an amount from that global variable value and send that value to the BEYOND channel, where the abstract generator would pick it up as configured.

    However, I cannot seem to get the ChannelOut pangoscript command to accept anything other than an extvalue as an input, which does not help, as I can map those directly to the abstract generator parameters.

    How can I supply calculated values to ChannelOut to better control the abstract generator?

  2. tribble

    tribble Member

    More details

    I sort of have this working, but I do not understand the ranges of values that go in to the beyond "channel" and how those drive the values that get fed to the abstract generator parameter that channel is connected to.

    In the pangoscript editor for my connected apc40, in the initialization script area, I put this:

    globalvar g100Value
    globalvar g100AdjValue
    g100Value = 1
    g100AdjValue = 64
    In the Background Script area, I made a script like this:

    if (g100AdjValue < 60 ) g100Value = g100Value + ((g100AdjValue - 64) / 20)
    if (g100AdjValue > 68 ) g100Value = g100Value + ((g100AdjValue - 64) / 20)
    if (g100Value < 1) g100Value = 1
    if (g100Value  > 500) g100Value = 500
    ChannelOut 100, g100Value
    (These values I have determined experimentally. What is the relationship between the channel value and what happens in the abstract editor? I've noticed that the channel value impact gets capped at whatever current setting the manual slider has when you switch over to channel control, which I don't understand why that happens... it leads to very inconsistent results with the channel inputs if you are not careful where the slider is before switching over to channel control. And then there is the set of sliders in the control mapping dialog, and I don't understand how those mix in.)

    Then, in the control change handler script for the particular knob I want to control the rate, I put this script:

    g100AdjValue = extvalue(1, 127)
    (Is there a set of values to pass to extvalue that will be most efficient in terms of speed, or does the remapping process happen regardless?)

    So, my question is, how does the value of "g100Value" map to, say, the normal 1-50 range the slider provides for "X period"?

    Getting really close to what I'm looking for! The only remaining issue is the phase jumps in the abstract when changing parameter values. It's as if the value is changed relative to time 0, and the current time used to draw the image, as opposed to tracking the values continuously and applying the current delta as indicated by the controls. I've used the latter approach in my own software and it produces a much smoother live effect IMHO. Or, I may have something in beyond misconfigured; still learning! :D

    Thanks for any info or clarifications!
  3. ENOT

    ENOT Software Developer Staff Member

    Hi Tribble,

    A few comments and recommendations from my side. First of all it would be good to know about what abstract generator you talk about. BEYOND has 3 - LD2000 Classic, Abstraction and Shape. They use different logic behind. LD2000 Classic is a state based model, and change of parameters will give smooth result. Abstraction and Shape are formula based, where argument is time, and it means - no state at all. For such model if you change the speed it will cause a visual jump, but if you change amplitude or phase then it will be smooth. Consider it as a cos(time*speed+phase)*amplitude.

    Abstraction is relatively old part and offer only Channels. Shape and LD2000 Classic generators offer Input dialog, where you can mao the slider/parameter to a Channel, or FFT, of DMX, or MIDI CC or, or, or. This is script-free method, it works fast and simple.

    Channels. Channels is internal global array of 256 normalized float point values. Some parts can write to it, some will read. It is a global, uniform method of communication between the parts of program. No need to use any global variables in the script, the channel already is at the “global variableâ€￾.

    Object Style access. Step by step we provide an access to BEYOND objects in Object style. The Shape, LD2000 Classic editors has “yellow tagâ€￾ button. As soon as you assign an identifier, then this internal object become an object accessible from PangoScript, Universe, OSC, etc. There is Object Tree window, you will see your abstract there. Objects are visible in all scripts in BEYOND, what means that your abstract will be a global variable. The is second way how to modify your abstract.

    Channels… in addition to ChannelOut, channels can be accessed in Object style, see Object Tree window. ChannelOut is not the only way. For both cases, if you modify Channel value then ensure that it look correct in Channel tab. Pay attention that the channel is actually a mixer of 3 things, plus mass-spring filter, It may inject some unexpected results. But, look at Channel tab and see how it look.

    ExtValue. Yes, this is oldest style of things, it allow take input value (as example, from MIDI it will be 0..127) and map to the range. Function has two parameters - min and max, it define the range. So, if you want control the amplitude, then the most possibly you will need ExtValue(0,100) - the range from 0 to 100.

    If the script used in MIDI to PangoScript tab, then BEYOND supply into this script a few parameters - midi message, data1 and data2. You can read them by means of param() function. This allow work for DMX to PangoScript. So - Param(1), Param(2), Param(3). For CC you need to use Param(3). I don`t remember, if this function use zero based indexing, then Param(2).
    As example, in MIDI to PangoScript table the code can be like this

    Channels.1.Value = Param(3)/127


    Channels.1.Value = ExtValue(0,1)


    ChannelOut 1, ExtValue(0,1000)

    As a rule, such point-to-point connections can be done by means of one script line.

    Best Regards,
  4. tribble

    tribble Member

    Alexey, thanks so much for the in-depth reply! Things are clearer now.

    Regarding the abstract editor, I was referring to the editor that comes up when you click in a blank cue and choose "Create... new abstraction." Is that the older module you were referring to? I have not yet played with the "new shape" or "LD2000 style abstract." I will get there! Which of them, in your opinion, is the most powerful / flexible? I will try them all out eventually.

  5. ENOT

    ENOT Software Developer Staff Member


    I think it is not right to compare Classic LD2000 style and Shape/Abstraction, they based on different conceptions. My recommendation - use what you like more. Personally I like Shape more because it is easier to use. In coming build you will see that Abstraction now can use BEYOND effects what add some additional fun.