Forum
    • Categories
    • Register
    • Login

    HISE as MIDI Clock Slave

    Scheduled Pinned Locked Moved Scripting
    2 Posts 2 Posters 18 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.
    • J
      j28
      last edited by

      Hello!
      I am brand new to HISE and I set out to create an open source sequencer focused on live performance.

      For the time being I need the sequencer to receive the MIDI clock from a DAW via IAC Driver Bus (on Mac).

      I configured HISE MIDI settings to receive from the DAW and I can see that the noteOn/noteOff messages are firing up inside HISE, but I cannot get HISE to see the clock messages coming from the DAW.

      It is my understanding that I need to use the TransportHandler to make this work. But when I do that I still can't get HISE to follow the DAW's tempo.

      I am simply putting the code below in the onInit function of the root container and I can see the Transport Handler works (based on the console messages logging each new bar), the tempo changes from the DAW are simply not coming through.

      What am I doing wrong? I am using the latest version of HISE (I did a git pull a day ago and built it in XCode).

      const var TransportHandler = Engine.createTransportHandler();
      // Configure for MIDI clock slave with fallback to internal
      TransportHandler.setSyncMode(2); // PREFER_EXTERNAL = 2
      TransportHandler.setEnableGrid(true, 4); // Enable grid with 4 steps per bar
      Console.print("TransportHandler initialized - MIDI Clock Slave Mode");
      // Variables for bar detection and BPM tracking
      reg beatCount = 0;
      reg barCount = 0;
      reg lastBPM = 120.0; // Default BPM for comparison
      // Create timer for monitoring beats
      const var beatTimer = Engine.createTimerObject();
      // Set timer callback
      beatTimer.setTimerCallback(function()
      {
      	// Get current BPM from Engine
      	reg currentBPM = Engine.getHostBpm();
      	// Print status every 30 callbacks (~3 seconds)
      	if (Math.random() < 0.033)
      	{
      		Console.print("Status: BPM=" + Math.round(currentBPM) + ", Bar=" + barCount + ", Beat=" + beatCount);
      	}
      	// Check for BPM changes
      	if (Math.abs(currentBPM - lastBPM) > 0.1) // Detect BPM changes (with small threshold)
      	{
      		Console.print("BPM changed: " + Math.round(lastBPM) + " -> " + Math.round(currentBPM));
      		lastBPM = currentBPM;
      		// Recalculate timer interval based on new BPM
      		reg newMsPerBeat = 60000 / currentBPM;
      		beatTimer.stopTimer();
      		beatTimer.startTimer(newMsPerBeat);
      	}
      	// Try to get beat position
      	beatCount = beatCount + 1;
      	// Every 4 beats = 1 bar
      	if (beatCount >= 4)
      	{
      		beatCount = 0;
      		barCount = barCount + 1;
      		Console.print("Bar: " + barCount);
      	}
      });
      // Calculate timer interval based on BPM
      reg bpm = Engine.getHostBpm();
      reg msPerBeat = 60000 / bpm;
      // Start timer at beat rate
      beatTimer.startTimer(msPerBeat);
      // No onController function needed - MIDI clock is handled by TransportHandler
      Console.print("Bar counter initialized - BPM: " + bpm);
      
      

      Screenshot 2026-01-21 at 1.14.14 AM.png Screenshot 2026-01-21 at 1.14.30 AM.png

      David HealeyD 1 Reply Last reply Reply Quote 0
      • David HealeyD
        David Healey @j28
        last edited by

        @j28 Have you seen the MIDI player module? It's basically a sequencer.

        Free HISE Bootcamp Full Course for beginners.
        YouTube Channel - Public HISE tutorials
        My Patreon - HISE tutorials

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

        12

        Online

        2.1k

        Users

        13.3k

        Topics

        115.0k

        Posts