Forum

    • Register
    • Login
    • Search
    • Categories

    Solved Can You Determine if HISE's Output Ever Clipped?

    General Questions
    3
    9
    216
    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.
    • clevername27
      clevername27 last edited by

      Is there an efficient way to know if the output has ever clipped? Thank you.

      ustk 1 Reply Last reply Reply Quote 0
      • ustk
        ustk @clevername27 last edited by ustk

        @clevername27 With a scriptFX:

        // Main interface script
        global = _peakValue = 0.0;
        
        // in a scriptFX processBlock
        for (c in channels)
        {
            for (s in c)
            {
                if (Math.abs(s) > _peakValue)
                    _peakValue = s;
            }
        }
        

        Then read the global with a timer, reset it with a button if you need...
        Note that this is not true peak.

        Alternatively, this might be more elegant and lighter on CPU:

        // oninit
        reg mag;
        
        // processBlock
        for (c in channels)
        {
            mag = c.getMagnitude(0, c.length);
        	
            if (mag > _peakValue)
                _peakValue = mag;
        }
        

        In fact, it can even be reduced to:

        for (c in channels)
        {
             _peakValue = Math.max(_peakValue, c.getMagnitude(0, c.length));
        }
        

        I cannot help pressing F5 in the forum...
        Studio427 Audio - Audio Instruments & FX Plugins for music production. Website - Facebook

        d.healey 1 Reply Last reply Reply Quote 1
        • d.healey
          d.healey @ustk last edited by

          @ustk Won't this work with a regular script too like we do for VU meters?

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

          ustk 2 Replies Last reply Reply Quote 0
          • ustk
            ustk @d.healey last edited by ustk

            @d-healey I reckon we treated the topic a while ago. For what I remember, I was saying that when you read the VU current level meter, you get the value at this exact moment. There's no memory for what happened in between. For this you need to test all samples (or the buffer's magnitude) and record it for when you are ready to read it.

            I cannot help pressing F5 in the forum...
            Studio427 Audio - Audio Instruments & FX Plugins for music production. Website - Facebook

            1 Reply Last reply Reply Quote 1
            • ustk
              ustk @d.healey last edited by ustk

              @d-healey I have made the tests, current level reading, peak, and true peak, and the results were indisputable (and compared against commercial measuring tools too)

              I cannot help pressing F5 in the forum...
              Studio427 Audio - Audio Instruments & FX Plugins for music production. Website - Facebook

              1 Reply Last reply Reply Quote 2
              • ustk
                ustk last edited by

                @d-healey I have corrected the second solution above that had a mistake...

                I cannot help pressing F5 in the forum...
                Studio427 Audio - Audio Instruments & FX Plugins for music production. Website - Facebook

                clevername27 1 Reply Last reply Reply Quote 0
                • clevername27
                  clevername27 @ustk last edited by clevername27

                  @ustk Thank you @d-healey and @ustk for your suggestions. I had thought Engine.getMasterPeakLevel on a timer would be most efficient—but my concern with all these approaches is that we're only measuring the peak at a given moment—and missing all the possible peaks in between taking measurements. Do your or the Engine function search the current buffer for peaks, or is it simply moment by moment? Than you.

                  ustk 1 Reply Last reply Reply Quote 0
                  • ustk
                    ustk @clevername27 last edited by

                    @clevername27 That is what I am saying, my solution gives you the real peak (not to be mistaken with true peak) and should be the way to go.
                    On the contrary and as you said, a mesure of the meter (current level or master peak level) will give you the reading only at one moment which is a no go for telling if the signal ever passed above 0dB. It's good for a level visualisation only.

                    I cannot help pressing F5 in the forum...
                    Studio427 Audio - Audio Instruments & FX Plugins for music production. Website - Facebook

                    clevername27 1 Reply Last reply Reply Quote 1
                    • Topic is now a regular thread  clevername27 clevername27 
                    • Topic has been marked as a question  clevername27 clevername27 
                    • Topic has been marked as solved  clevername27 clevername27 
                    • clevername27
                      clevername27 @ustk last edited by

                      @ustk, @d-healey Thank you!

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

                      10
                      Online

                      983
                      Users

                      6.6k
                      Topics

                      60.8k
                      Posts