Expanded AudioPlayHead functionality



  • Any chance we can have access to the AudioPlayHead?
    I see we have:

    Engine.getPlayHead()
    

    I think I'm looking for

    getCurrentPosition()
    

    so I can grab the ppqPosition of the Playback Head.



  • @dustbro if you're referring to the MidiPlayer you have this:

    MIDIPlay.getPlaybackPosition()
    


  • @ulrik I think that's the position of the midi player. Im trying to get the playback position of the DAW so i can synchronize the two.



  • @dustbro ok, I understand. 👍



  • @dustbro

    Engine.getPlayHead() returns an object, any idea what properties the object has?



  • @d-healey the scripting API says:

    Allows access to the data of the host (playing status, timeline, etc...). */
    

    The JUCE Audio Processor says:

        /** Returns the current AudioPlayHead object that should be used to find
            out the state and position of the playhead.
    
            You can ONLY call this from your processBlock() method! Calling it at other
            times will produce undefined behaviour, as the host may not have any context
            in which a time would make sense, and some hosts will almost certainly have
            multithreading issues if it's not called on the audio thread.
    
            The AudioPlayHead object that is returned can be used to get the details about
            the time of the start of the block currently being processed. But do not
            store this pointer or use it outside of the current audio callback, because
            the host may delete or re-use it.
    
            If the host can't or won't provide any time info, this will return nullptr.
        */
        AudioPlayHead* getPlayHead() const noexcept                 { return playHead; }
    

    I think it's currently being used to get the sample position for processing audio. There's a whole subclass to the Audio Play Head that we don't have access to yet. It would allow us to:

    //==============================================================================
    /**
        A subclass of AudioPlayHead can supply information about the position and
        status of a moving play head during audio playback.
    
        One of these can be supplied to an AudioProcessor object so that it can find
        out about the position of the audio that it is rendering.
    
        @see AudioProcessor::setPlayHead, AudioProcessor::getPlayHead
    
        @tags{Audio}
    */
    class JUCE_API  AudioPlayHead
    {
    protected:
        //==============================================================================
        AudioPlayHead() = default;
    
    public:
        virtual ~AudioPlayHead() = default;
    
        //==============================================================================
        /** Frame rate types. */
        enum FrameRateType
        {
            fps23976        = 0,
            fps24           = 1,
            fps25           = 2,
            fps2997         = 3,
            fps30           = 4,
            fps2997drop     = 5,
            fps30drop       = 6,
            fps60           = 7,
            fps60drop       = 8,
            fpsUnknown      = 99
        };
    
        //==============================================================================
        /** This structure is filled-in by the AudioPlayHead::getCurrentPosition() method.
        */
        struct JUCE_API  CurrentPositionInfo
        {
            /** The tempo in BPM */
            double bpm;
    
            /** Time signature numerator, e.g. the 3 of a 3/4 time sig */
            int timeSigNumerator;
            /** Time signature denominator, e.g. the 4 of a 3/4 time sig */
            int timeSigDenominator;
    
            /** The current play position, in samples from the start of the timeline. */
            int64 timeInSamples;
            /** The current play position, in seconds from the start of the timeline. */
            double timeInSeconds;
    
            /** For timecode, the position of the start of the timeline, in seconds from 00:00:00:00. */
            double editOriginTime;
    
            /** The current play position, in units of quarter-notes. */
            double ppqPosition;
    
            /** The position of the start of the last bar, in units of quarter-notes.
    
                This is the time from the start of the timeline to the start of the current
                bar, in ppq units.
    
                Note - this value may be unavailable on some hosts, e.g. Pro-Tools. If
                it's not available, the value will be 0.
            */
            double ppqPositionOfLastBarStart;
    
            /** The video frame rate, if applicable. */
            FrameRateType frameRate;
    
            /** True if the transport is currently playing. */
            bool isPlaying;
    
            /** True if the transport is currently recording.
    
                (When isRecording is true, then isPlaying will also be true).
            */
            bool isRecording;
    
            /** The current cycle start position in units of quarter-notes.
                Note that not all hosts or plugin formats may provide this value.
                @see isLooping
            */
            double ppqLoopStart;
    
            /** The current cycle end position in units of quarter-notes.
                Note that not all hosts or plugin formats may provide this value.
                @see isLooping
            */
            double ppqLoopEnd;
    
            /** True if the transport is currently looping. */
            bool isLooping;
    


  • @d-healey The subclass is currently commented out in HISE source code, and when i remove the comment, it doesn't compile 🤷


Log in to reply
 

7
Online

551
Users

2.1k
Topics

16.1k
Posts