FastLED 3.9.7
Loading...
Searching...
No Matches
util.h
1#ifndef UTIL_H_
2#define UTIL_H_
3
4#include <stdint.h>
5
6#include "./ApproximatingFunction.h"
7#include "./settings.h"
8
9#ifndef round
10#define round(x) ((x)>=0?(long)((x)+0.5):(long)((x)-0.5))
11#endif // round
12
13/*
14// C - 0, C# - 1, D - 2, D# - 3... B - 11.
15// http://cote.cc/w/wp-content/uploads/drupal/blog/logic-midi-note-numbers.png
16*/
17uint8_t FundamentalNote(int midi_note);
18
19float mapf(float x, float in_min, float in_max, float out_min, float out_max);
20
21// Given an input time.
22float AttackRemapFactor(uint32_t delta_t_ms);
23
24float MapDecayTime(uint8_t key_idx);
25
26// Returns a value in the range 1->0 indicating how intense the note is. This
27// value will go to 0 as time progresses, and will be 1 when the note is first
28// pressed.
29float CalcDecayFactor(bool sustain_pedal_on,
30 bool key_on,
31 int key_idx,
32 float velocity,
33 bool dampened_key,
34 float time_elapsed_ms);
35
36float ToBrightness(int velocity);
37
38#endif // UTIL_H_