onClock and onTransport Sync To Host Issue



  • Hey to all, I'm having some problems getting the onClock, and Transport callback to sync to my host. I'm trying to fire the OnClock after checking to see if the Transport Host was played or stop.

    For some reason, The below snippet is not triggering the transport callback

        function onTransport(isStart){
                if(isStart){
                Console.print("Start");
                Synth.setClockSpeed(16);
          }
    
               if(isStart != 1 ){
               Console.print("Stop");
               Synth.setClockSpeed(0);
         }
    

    }

    I have several samples map to my sampler and the simple sequencer below is not sequencing. it seems as if the onClock callback is not triggering. Any advice? Thanks

         var x = [48,51,55,60,63,67,72,75];
         var index = 0;
    
        function onClock()
       {
            index = parseInt(Math.ceil(Engine.getPlayHead().ppqPosition*8.0));
            Synth.playNote(x[index%x.length],127);
       }


  • Whoops, this is indeed not implemented anymore. The reason was that I added these methods a long time ago, but never actually used them so they were removed when I spotted those things lurking around when profiling.

    Do you really need this? Actually the reason that this is abandoned is that I could do all time related things with the timer callback and to be honest the support for stuff like transport notification varies between hosts so you can't expect this to work 100% on every DAW.

    But I'll update the docs and remove those 🙂



  • Ok ,thanks for the heads up. I actually got the onTimer to work perfectly with syncing to the tempo using Tempo.getValue(), and Engine.getMilliSecondsForTempo() . I like the Time Signature feature built in such as below!! Sweet

         const var Tempo = Content.addKnob("Tempo", 0, 0);
         // [JSON Tempo]
        Content.setPropertiesFromJSON("Tempo", {
           "max": 10,
           "mode": "TempoSync",
           "stepSize": 1
         });
    

    Quick question, your right about the onTransport, its not working in Abelton. Is there any other method to listen for when the Transport, play and stop buttons are pressed?

    And lastly, Is there any api docs explaing the 1st, and 2nd object parameter in Content.setPropertiesFromJSON? I'm wondering in detail about what mode, max , stepSize etc.. (Please keep this feature 🙂



  • Ok when my host is playing, I'm getting a 0 value when using Engine.getPlayHead() within my onTimer:

             Console.print(Math.ceil(Engine.getPlayHead().ppqPosition));
    

    If I can somehow get the play position at any given moment, I can listen when the Transport has been played or stop at any given time. Is this method still working?



  • Taken from the HISE source code hi_core/MainController.cpp:

    void MainController::storePlayheadIntoDynamicObject(AudioPlayHead::CurrentPositionInfo &/*newPosition*/)
    {
    	//static const Identifier bpmId("bpm");
    	//static const Identifier timeSigNumerator("timeSigNumerator");
    	//static const Identifier timeSigDenominator("timeSigDenominator");
    	//static const Identifier timeInSamples("timeInSamples");
    	//static const Identifier timeInSeconds("timeInSeconds");
    	//static const Identifier editOriginTime("editOriginTime");
    	//static const Identifier ppqPosition("ppqPosition");
    	//static const Identifier ppqPositionOfLastBarStart("ppqPositionOfLastBarStart");
    	//static const Identifier frameRate("frameRate");
    	//static const Identifier isPlaying("isPlaying");
    	//static const Identifier isRecording("isRecording");
    	//static const Identifier ppqLoopStart("ppqLoopStart");
    	//static const Identifier ppqLoopEnd("ppqLoopEnd");
    	//static const Identifier isLooping("isLooping");
    
    	//ScopedLock sl(getLock());
    
    	//hostInfo->setProperty(bpmId, newPosition.bpm);
    	//hostInfo->setProperty(timeSigNumerator, newPosition.timeSigNumerator);
    	//hostInfo->setProperty(timeSigDenominator, newPosition.timeSigDenominator);
    	//hostInfo->setProperty(timeInSamples, newPosition.timeInSamples);
    	//hostInfo->setProperty(timeInSeconds, newPosition.timeInSeconds);
    	//hostInfo->setProperty(editOriginTime, newPosition.editOriginTime);
    	//hostInfo->setProperty(ppqPosition, newPosition.ppqPosition);
    	//hostInfo->setProperty(ppqPositionOfLastBarStart, newPosition.ppqPositionOfLastBarStart);
    	//hostInfo->setProperty(frameRate, newPosition.frameRate);
    	//hostInfo->setProperty(isPlaying, newPosition.isPlaying);
    	//hostInfo->setProperty(isRecording, newPosition.isRecording);
    	//hostInfo->setProperty(ppqLoopStart, newPosition.ppqLoopStart);
    	//hostInfo->setProperty(ppqLoopEnd, newPosition.ppqLoopEnd);
    	//hostInfo->setProperty(isLooping, newPosition.isLooping);
    }
    

    As you can see, it's just commented out - you can try to remove the comments for every property that you need and check if it passes down the info to the scripting call (I think it should work). Eg for enabling just the transport, try this:

    MainController::storePlayheadIntoDynamicObject(AudioPlayHead::CurrentPositionInfo &/*newPosition*/)
    {
    	//static const Identifier bpmId("bpm");
    	//static const Identifier timeSigNumerator("timeSigNumerator");
    	//static const Identifier timeSigDenominator("timeSigDenominator");
    	//static const Identifier timeInSamples("timeInSamples");
    	//static const Identifier timeInSeconds("timeInSeconds");
    	//static const Identifier editOriginTime("editOriginTime");
    	//static const Identifier ppqPosition("ppqPosition");
    	//static const Identifier ppqPositionOfLastBarStart("ppqPositionOfLastBarStart");
    	//static const Identifier frameRate("frameRate");
    	static const Identifier isPlaying("isPlaying");
    	//static const Identifier isRecording("isRecording");
    	//static const Identifier ppqLoopStart("ppqLoopStart");
    	//static const Identifier ppqLoopEnd("ppqLoopEnd");
    	//static const Identifier isLooping("isLooping");
    
    	ScopedLock sl(getLock());
    
    	//hostInfo->setProperty(bpmId, newPosition.bpm);
    	//hostInfo->setProperty(timeSigNumerator, newPosition.timeSigNumerator);
    	//hostInfo->setProperty(timeSigDenominator, newPosition.timeSigDenominator);
    	//hostInfo->setProperty(timeInSamples, newPosition.timeInSamples);
    	//hostInfo->setProperty(timeInSeconds, newPosition.timeInSeconds);
    	//hostInfo->setProperty(editOriginTime, newPosition.editOriginTime);
    	//hostInfo->setProperty(ppqPosition, newPosition.ppqPosition);
    	//hostInfo->setProperty(ppqPositionOfLastBarStart, newPosition.ppqPositionOfLastBarStart);
    	//hostInfo->setProperty(frameRate, newPosition.frameRate);
    	hostInfo->setProperty(isPlaying, newPosition.isPlaying);
    	//hostInfo->setProperty(isRecording, newPosition.isRecording);
    	//hostInfo->setProperty(ppqLoopStart, newPosition.ppqLoopStart);
    	//hostInfo->setProperty(ppqLoopEnd, newPosition.ppqLoopEnd);
    	//hostInfo->setProperty(isLooping, newPosition.isLooping);
    }
    

    Obviously, you need to rebuild HISE for this 🙂



  • Thanks, this did work! Got those properties to work very well. I'm creating a very basic sequencer but the timing is way off. The isPlaying property is working, along with all properties, its just onTimer, and the transport tick/metronome is not syncing together properly. The onTimer should sync with the metronome beat, but its not.. any advice on this?? The below snippet is what im working on

            const var Tempo = Content.addKnob("Tempo", 0, 0);
        // [JSON Tempo]
           Content.setPropertiesFromJSON("Tempo", {
                "max": 10,
                "mode": "TempoSync",
                "stepSize": 1
    
          });
         Synth.startTimer(Engine.getMilliSecondsForTempo(Tempo.getValue()) / 1000.0);
    
         function onTimer(){
    
        if(Engine.getPlayHead().isPlaying ){
     	     	 	
              if( parseInt(Math.ceil(Engine.getPlayHead().ppqPosition)) == 1){
     		        Synth.playNote(48,127);
                }
     	  if( parseInt(Math.ceil(Engine.getPlayHead().ppqPosition)) == 2){
     	      	        Synth.playNote(48,127);
     	   }
     	   if( parseInt(Math.ceil(Engine.getPlayHead().ppqPosition)) == 3){
     		        Synth.playNote(48,127);
     	   }
     	  if( parseInt(Math.ceil(Engine.getPlayHead().ppqPosition)) == 4){
     		        Synth.playNote(48,127);
     	    }
         Synth.startTimer(Engine.getMilliSecondsForTempo(Tempo.getValue()) / 1000.0);
               
             }	  	 
          }

 

2
Online

353
Users

1.1k
Topics

7.6k
Posts