Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

In this Discussion

Algorithmic generator

Could you maybe give me an example of how I'm supposed to enter in the algorithms thanks

Comments

  • edited May 2019

    Yep!

    First look at line 139, void algo. The block of code there is divided in four different "cases", like so:

        case 0:
              sample = t*(t>>parameters[0]) ^ (t<<parameters[1] ^ t); // 14-8-1
              t = t + parameters[2];
              break;
    

    There, (on any of these "cases"), you can replace the code after sample = with your own algorithm.

    Most important thing to remember with respect to examples you'll find online is that you must keep multiplications to a minimum and completely avoid divisions. Instead, use bit shifts (either << or >>), which are equivalent to multiplying or dividing by powers of two but don't take nearly as much computing power.

    Also notice that I use parameters[0], parameters[1], and parameters[2]. These are the three parameters you can change in real time with the knob, with ranges from 0 to 15.

    So, first you write something like this:

     case 0:
          sample = t*(t>>14) ^ (t<<8 ^ t); 
          t = t + 1;
          break;
    

    Then you decide which of those numbers you want to change with the knob, and also their initial values -that's how you end up with

     sample = t*(t>>parameters[0]) ^ (t<<parameters[1] ^ t); // 14-8-1
              t = t + parameters[2];
    

    (Notice that I took note of the initial values as a comment, after //)

    Finally, in the block of code starting in line 166, void initializeAlgoParameters, search for the same "case" you replaced, and change the values of the three parameters to the values you want.

      case 0:
          parameters[0] = 14;
          parameters[1] = 8;
          parameters[2] = 1;
          break;
    

    That's it! I hope it doesn't sound too hard -it's not, really ^_^´

  • thanx man...that helps a lot
Sign In or Register to comment.