LCOV - code coverage report
Current view: top level - src/MIDI_Senders - PitchBendSender.hpp (source / functions) Coverage Total Hit
Test: 73449d9b107c772cf65493691543348214e5d5eb Lines: 100.0 % 5 5
Test Date: 2026-06-06 17:44:35 Functions: 50.0 % 2 1
Legend: Lines:     hit not hit

            Line data    Source code
       1              : #pragma once
       2              : 
       3              : #include <AH/Math/IncreaseBitDepth.hpp>
       4              : #include <Control_Surface/Control_Surface_Class.hpp>
       5              : 
       6              : BEGIN_CS_NAMESPACE
       7              : 
       8              : /**
       9              :  * @brief   Class that sends continuous MIDI pitch bend messages with a 
      10              :  *          resolution of 14 bits.
      11              :  * 
      12              :  * @tparam  INPUT_PRECISION_BITS
      13              :  *          The resolution of the input values. For example, if 
      14              :  *          @p INPUT_PRECISION_BITS == 10, the send function expects a @p value
      15              :  *          between 0 and 1023.
      16              :  * 
      17              :  * @ingroup MIDI_Senders
      18              :  */
      19              : template <uint8_t INPUT_PRECISION_BITS>
      20              : class PitchBendSender {
      21              :   public:
      22              :     /// Send a MIDI pitch bend message with the given value and channel+cable.
      23              :     /// address.getAddress() is ignored.
      24              :     /// Value should be @p INPUT_PRECISION_BITS wide.
      25            9 :     static void send(uint16_t value, MIDIAddress address) {
      26            9 :         value = AH::increaseBitDepth<14, precision(), uint16_t>(value);
      27              :         // ignore address byte, just use channel and cable numbers
      28            9 :         MIDIChannelCable channelCN = address.getChannelCable();
      29            9 :         Control_Surface.sendPitchBend(channelCN, value);
      30            9 :     }
      31              : 
      32              :     /// Get this sender's precision.
      33              :     constexpr static uint8_t precision() {
      34              :         static_assert(INPUT_PRECISION_BITS <= 14,
      35              :                       "Maximum pitch bend resolution is 14 bits");
      36              :         return INPUT_PRECISION_BITS;
      37              :     }
      38              : };
      39              : 
      40              : END_CS_NAMESPACE
        

Generated by: LCOV version 2.4-beta