HISE Logo Forum
    • Categories
    • Register
    • Login

    Lend me your brain

    Scheduled Pinned Locked Moved Scripting
    10 Posts 4 Posters 319 Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • d.healeyD
      d.healey
      last edited by d.healey

      I'm sure this is easy for someone but it's giving me a headache. I want this code to print the numbers 1 to 49... help!

      for (i = 1; i < 50; i++)
      {
          for (j = i+2; j < 50; j++)
          {
              Console.print(/*Magic*/);
          }
      }
      

      Libre Wave - Freedom respecting instruments and effects
      My Patreon - HISE tutorials
      YouTube Channel - Public HISE tutorials

      ustkU 1 Reply Last reply Reply Quote 0
      • Dan KorneffD
        Dan Korneff
        last edited by

        Could you add another variable?

        for (i = 1; i < 50; i++)
        {
        
            
            for (j = i+2; j < 50; j++)
            {
                var ii = ii+1;
                Console.print(Math.range(ii, 1, 49));
            }
        }
        

        This will print 1:49.... and then print 49 about 200 more times

        Dan Korneff - Producer / Mixer / Audio Nerd

        d.healeyD 1 Reply Last reply Reply Quote 0
        • d.healeyD
          d.healey @Dan Korneff
          last edited by

          @dustbro Nice idea :) But I need it to print 1-49 as the loops complete naturally. It's for a progress bar, so having it hang on 49 for a while won't work.

          Libre Wave - Freedom respecting instruments and effects
          My Patreon - HISE tutorials
          YouTube Channel - Public HISE tutorials

          1 Reply Last reply Reply Quote 0
          • Christoph HartC
            Christoph Hart
            last edited by

            Huh? Why not just

            for (i = 1; i < 50; i++)
            {
                Console.print(i);
                
                for (j = i+2; j < 50; j++)
                {
                   // most important loop in the world...    
                }
            }
            
            1 Reply Last reply Reply Quote 0
            • ustkU
              ustk @d.healey
              last edited by

              @d-healey actually you can't in the second loop, simply because it runs only 47 times...

              for (i = 1; i < 50; i++)
              {
                  var flag = true;
                  
                  for (j = i+2; j < 50; j++)
                  {
                      if (flag){
                          
                          Console.print(i);
                          flag = false;
                      }
                  }
              }
              

              Can't help pressing F5 in the forum...

              1 Reply Last reply Reply Quote 0
              • Dan KorneffD
                Dan Korneff
                last edited by

                for (i = 1; i < 50; i++)
                {
                
                    
                    for (j = i+2; j < 50; j++)
                    {
                        var ii = ii+1;
                        Console.print(Math.round(ii/23));
                    }
                }
                

                This would give you 0:49 in series

                Dan Korneff - Producer / Mixer / Audio Nerd

                ustkU d.healeyD 2 Replies Last reply Reply Quote 0
                • ustkU
                  ustk @Dan Korneff
                  last edited by

                  @dustbro cool solution ;)
                  Just to add an if not 0 and baam…

                  Can't help pressing F5 in the forum...

                  1 Reply Last reply Reply Quote 0
                  • d.healeyD
                    d.healey @Dan Korneff
                    last edited by

                    @dustbro That's doesn't work. I get 00000000000000000000000,111111111111111111111111,222222222222222222 etc.

                    @Christoph-Hart said in Lend me your brain:

                    Huh? Why not just

                    for (i = 1; i < 50; i++)
                    {
                        Console.print(i);
                        
                        for (j = i+2; j < 50; j++)
                        {
                           // most important loop in the world...    
                        }
                    }
                    

                    Ooo well this might work 😱

                    Libre Wave - Freedom respecting instruments and effects
                    My Patreon - HISE tutorials
                    YouTube Channel - Public HISE tutorials

                    1 Reply Last reply Reply Quote 0
                    • Christoph HartC
                      Christoph Hart
                      last edited by

                      OK everybody go home, I found the cleanest solution:

                      
                      inline function getStart()
                      {
                          return Engine.getHostBpm() * Engine.getSamplesForQuarterBeats(800);
                      }
                      
                      inline function getEnd()
                      {
                          return getStart() + 50 * getDelta();
                      }
                      
                      inline function getDelta()
                      {
                          return Engine.getFilterModeList()[2] + Math.min(Engine.getSampleRate(), Engine.getDeviceType().length);
                      }
                      
                      for (i = getStart() + getDelta(); i < getEnd(); i += getDelta())
                      {
                          Console.print((i - getStart()) / getDelta());
                      }
                      
                      ustkU 1 Reply Last reply Reply Quote 6
                      • ustkU
                        ustk @Christoph Hart
                        last edited by

                        @Christoph-Hart 😂

                        Can't help pressing F5 in the forum...

                        1 Reply Last reply Reply Quote 0
                        • First post
                          Last post

                        38

                        Online

                        1.7k

                        Users

                        11.7k

                        Topics

                        102.0k

                        Posts