Sound Byte Libs 0.5.1-340-gab5b79a
C++ firmware library for audio applications on 32-bit ARM Cortex-M processors
Loading...
Searching...
No Matches
drain.hpp File Reference

Feed every byte a MIDI source has waiting into a parser. More...

Detailed Description

Feed every byte a MIDI source has waiting into a parser.

The source is any type with static byte access in one of two shapes, detected at compile time:

  • available() -> bool and read_byte() -> uint8_t: a UART driver.
  • read(uint8_t* buf, uint32_t max) -> uint32_t, returning 0 when empty: sbl::usb::MidiPort, or any port that hands over bytes in blocks.

Usage:

sbl::midi::drain<sbl::driver::Uart<1>>(parser); // DIN/TRS MIDI
sbl::midi::drain<sbl::usb::MidiPort>(parser); // USB MIDI

The transport is the caller's: this header includes no hardware or USB code. Non-blocking: it returns once the source is empty.

Definition in file drain.hpp.

#include <cstdint>
#include <type_traits>
#include <utility>
#include <sbl/protocol/midi/parser.hpp>

Go to the source code of this file.

Namespaces

namespace  sbl
 Root namespace for all Sound Byte Libs code.
 
namespace  sbl::midi
 MIDI parser, encoder, SMF and sequencer.
 

Functions

template<typename Source , typename Thru >
uint32_t sbl::midi::drain (Parser &parser, Thru &&thru)
 Push everything Source has waiting into parser, copying it to a thru.
 
template<typename Source >
uint32_t sbl::midi::drain (Parser &parser)
 Push everything Source has waiting into parser
 

Variables

constexpr uint32_t sbl::midi::DRAIN_CHUNK = 64