HISE Logo Forum
    • Categories
    • Register
    • Login

    Sub dividing DAW synced timer

    Scheduled Pinned Locked Moved General Questions
    10 Posts 2 Posters 283 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.
    • B
      Blake.Manternach
      last edited by

      Hello,

      I've been working on a sequencer plugin for some time, I've got a working POC that syncs with the daw by using a transport handler and the on grid callback to play midi notes every time the daw increments a step. However, I want my plugin to have the ability to play 8th notes and triplets and subdivide the beats coming from the daw...any ideas on how to implement this? I'm assuming I'll have to switch from using transport handler completely to a timer object but wondering how best to keep that timer object in sync with the Daws metronome including live tempo changes

      LindonL 1 Reply Last reply Reply Quote 0
      • LindonL
        Lindon @Blake.Manternach
        last edited by

        @Blake-Manternach set your Grid to a very small increment (say 1/96) and implement a counter in your transport call back: so 1/4 = 24/96 - so to get 1/4 beat playback fire when the counter = 24 and then reset...

        HISE Development for hire.
        www.channelrobot.com

        B 1 Reply Last reply Reply Quote 3
        • B
          Blake.Manternach @Lindon
          last edited by

          @Lindon
          Yes that'd be a work around, to just subdivide using the DAW however I'd like to accomplish this without the DAW if possible - so if the DAW grid is set to 4/4 I want to be able to subdivide eighth notes or 16ths based on that....I'm imagining the only way to accomplish this is going to be to have my own timer object running in conjunction w/ the DAW and trying to keep it perfectly in sync w/ the DAW however I'm nervous it could potentially fall out of sync after some time especially after tempo changes if they were to happen live within the DAW. Maybe this just straight up isn't possible and what you're suggesting by setting the grid in the DAW is the only workaround?

          @d-healey any ideas on this?

          LindonL 1 Reply Last reply Reply Quote 0
          • LindonL
            Lindon @Blake.Manternach
            last edited by Lindon

            @Blake-Manternach said in Sub dividing DAW synced timer:

            @Lindon
            Yes that'd be a work around, to just subdivide using the DAW however I'd like to accomplish this without the DAW if possible - so if the DAW grid is set to 4/4 I want to be able to subdivide eighth notes or 16ths based on that....I'm imagining the only way to accomplish this is going to be to have my own timer object running in conjunction w/ the DAW and trying to keep it perfectly in sync w/ the DAW however I'm nervous it could potentially fall out of sync after some time especially after tempo changes if they were to happen live within the DAW. Maybe this just straight up isn't possible and what you're suggesting by setting the grid in the DAW is the only workaround?

            @d-healey any ideas on this?

            This approach has nothing to do with the DAW. ...I am not suggesting you set the grid in the DAW, set it in your Transport handler...

            In your plugin set your transport handler to use the grid, set the grid to some very small value (like say 1/64),

            TransportHandler.setEnableGrid(bool shouldBeEnabled, int tempoFactor)

            At this point the DAW is set to 4/4 so you are going to get your callback called 16 times per beat....

            now have a counter in your transport handlers grid call back:

            if counter == 0 - this is a quarter beat, so do something
            counter++
            if counter > 16 set the counter = 0 - again a quarter beat...so do something

            same logic if you want 1/16ths

            if counter == 0 - do something...
            counter++
            if counter > 4, set counter = 0 - do something...

            use the modulo(remainder %) function to decide when to do something...

            HISE Development for hire.
            www.channelrobot.com

            LindonL 1 Reply Last reply Reply Quote 1
            • LindonL
              Lindon @Lindon
              last edited by

              @Lindon I'd show you an example only now I cant get the GridChange function to work,.. can anyone debug this very simple bit of code?

              reg Kounter = 0;
              const var th = Engine.createTransportHandler();
              th.setEnableGrid(true,18);
              inline function onGrid(a,b,c) 
              {
              	Console.print(Kounter);
              	Kounter++;
              };
              
              th.setOnGridChange(true, onGrid);
              

              HISE Development for hire.
              www.channelrobot.com

              LindonL 1 Reply Last reply Reply Quote 1
              • LindonL
                Lindon @Lindon
                last edited by

                @Lindon yeah forgot the

                th.setSyncMode(th.PreferExternal);

                HISE Development for hire.
                www.channelrobot.com

                LindonL 1 Reply Last reply Reply Quote 1
                • LindonL
                  Lindon @Lindon
                  last edited by

                  @Lindon ok so like this:

                  Content.makeFrontInterface(600, 600);
                  reg Kounter = 0;
                  const var th = Engine.createTransportHandler();
                  th.setSyncMode(th.PreferExternal);
                  th.setEnableGrid(true,18);
                  inline function onGrid(a,b,c) 
                  {
                  
                  	Console.print("K:" + (Kounter%4 ));
                  	if (Kounter%4 == 0)  
                  	   Console.print("do something...");
                  	Kounter++;
                  };
                  
                  th.setOnGridChange(true, onGrid);
                  

                  HISE Development for hire.
                  www.channelrobot.com

                  LindonL 1 Reply Last reply Reply Quote 1
                  • LindonL
                    Lindon @Lindon
                    last edited by Lindon

                    @Lindon whilst we are here.. can anyone tell me what a,b and c are in the function params???

                    I see in the snippet browser

                    (index, timestamp, isFirst)

                    index of what?
                    timestamp of what?
                    isFirst, of what?

                    HISE Development for hire.
                    www.channelrobot.com

                    B 1 Reply Last reply Reply Quote 1
                    • B
                      Blake.Manternach @Lindon
                      last edited by

                      @Lindon ah had no idea that's what the grid did, thank you so much for the clarification

                      LindonL 1 Reply Last reply Reply Quote 0
                      • LindonL
                        Lindon @Blake.Manternach
                        last edited by Lindon

                        @Blake-Manternach said in Sub dividing DAW synced timer:

                        @Lindon ah had no idea that's what the grid did, thank you so much for the clarification

                        no problem - it only goes up to a resolution of 1/32 however, but that should be OK for most cases..nope thats a "bug" in my system - seems to go all the way to 1/64T now....

                        HISE Development for hire.
                        www.channelrobot.com

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

                        34

                        Online

                        1.7k

                        Users

                        11.9k

                        Topics

                        103.5k

                        Posts