uMIDI
The swiss army knife for quick and easy developement of MIDI applications.
Functions
math.c File Reference

Implementation of mathematical functions. More...

#include "math.h"
#include "midi.h"
Include dependency graph for math.c:

Functions

void init_linear_from_midi (struct linear_range *const config)
 Initializes a linear function to map from MIDI values to an arbitrary integer range. More...
 
void init_linear_to_midi (struct linear_range *config)
 Initializes a linear function to map from an arbitrary integer range to MIDI values. More...
 
uint16_t linear_from_midi (const struct linear_range *const config, midi_value_t midi_value)
 Yields an integer in the configured range that corresponds to the given MIDI value. More...
 
midi_value_t linear_to_midi (const struct linear_range *config, uint16_t input)
 Yields the MIDI value [0,127] from a given integer in the configured range. More...
 

Detailed Description

Implementation of mathematical functions.

Function Documentation

◆ init_linear_from_midi()

void init_linear_from_midi ( struct linear_range config)

Initializes a linear function to map from MIDI values to an arbitrary integer range.

Parameters
configthe configuration of the linear function to initialize

◆ init_linear_to_midi()

void init_linear_to_midi ( struct linear_range config)

Initializes a linear function to map from an arbitrary integer range to MIDI values.

Parameters
configthe configuration of the linear function to initialize

◆ linear_from_midi()

uint16_t linear_from_midi ( const struct linear_range config,
midi_value_t  midi_value 
)

Yields an integer in the configured range that corresponds to the given MIDI value.

Parameters
configthe configuration of the linear function
midi_valuethe MIDI value to convert [0,127]
Returns
the input scaled to the configured range

◆ linear_to_midi()

midi_value_t linear_to_midi ( const struct linear_range config,
uint16_t  input 
)

Yields the MIDI value [0,127] from a given integer in the configured range.

Parameters
configthe configuration of the linear function
inputthe integer to convert to a MIDI value
Returns
the input scaled to the MIDI range [0,127]