uMIDI
The swiss army knife for quick and easy developement of MIDI applications.
|
Waveform function generator. More...
Go to the source code of this file.
Data Structures | |
struct | wave_settings |
Wave configuration. More... | |
struct | wave_state |
Internal state of a wave. More... | |
struct | wave |
The settings and internal state of a wave. More... | |
Macros | |
#define | RANDOM_WAVE_STEP_SIZE 4 |
Step size of the random wave. More... | |
#define | STAIR_WAVE_STEPS 5 |
Number of levels in the stair wave. More... | |
#define | WAVE_STEPS 100 |
Number of different output levels of waves. More... | |
#define | TAP_TEMPO_BUFFER_SIZE 3 |
Tap tempo buffer size. More... | |
#define | TAP_TEMPO_TASK_FREQUENCY F_TASK_SLOW |
Tap tempo background task frequency. More... | |
Enumerations | |
enum | direction { DIRECTION_DOWN, DIRECTION_UP } |
Step counter direction. More... | |
enum | waveform { WAVE_OFF, WAVE_SINE, WAVE_TRIANGLE, WAVE_SAW_UP, WAVE_SAW_DOWN, WAVE_SQUARE, WAVE_STAIRS, WAVE_RANDOM } |
Enumeration of available waveforms. More... | |
Functions | |
void | configure_tap_tempo_wave (struct wave *const wave) |
Configures a wave for tap tempo functionality. More... | |
void | init_wave (struct wave *wave, enum waveform waveform, midi_value_t speed, midi_value_t amplitude, midi_value_t offset) |
Initializes a wave. More... | |
void | register_tap (void) |
Registers a tempo tap event. More... | |
void | reset_wave (struct wave *const wave) |
Resets a wave. More... | |
void | set_frequency (struct wave *wave, fixed_t frequency) |
Updates the frequency of a wave. More... | |
void | set_speed (struct wave *wave, midi_value_t speed) |
Updates the speed of a wave. More... | |
void | set_waveform (struct wave *wave, enum waveform waveform) |
Updates the waveform of a wave. More... | |
void | tap_tempo_task (void) |
Background task for the tap tempo function. More... | |
midi_value_t | update_wave (struct wave *wave) |
Computes the current wave output value. More... | |
Waveform function generator.
#define RANDOM_WAVE_STEP_SIZE 4 |
Step size of the random wave.
The output will change in a random direction by this amount
#define STAIR_WAVE_STEPS 5 |
Number of levels in the stair wave.
#define TAP_TEMPO_BUFFER_SIZE 3 |
Tap tempo buffer size.
The tempo is computed as an average over this many tapped tempo values.
#define TAP_TEMPO_TASK_FREQUENCY F_TASK_SLOW |
Tap tempo background task frequency.
#define WAVE_STEPS 100 |
Number of different output levels of waves.
enum direction |
enum waveform |
void configure_tap_tempo_wave | ( | struct wave *const | wave | ) |
Configures a wave for tap tempo functionality.
wave | the wave to configure |
void init_wave | ( | struct wave * | wave, |
enum waveform | waveform, | ||
midi_value_t | speed, | ||
midi_value_t | amplitude, | ||
midi_value_t | offset | ||
) |
void register_tap | ( | void | ) |
Registers a tempo tap event.
This function must be called whenever a tempo tap event occurrs. It sets an internal flag to inform the background task about the event.
void reset_wave | ( | struct wave *const | wave | ) |
Resets a wave.
Re-initializes all internal counters and states of the supplied wave
wave | the wave to reset |
Updates the frequency of a wave.
wave | the wave to update |
frequency | the new frequency |
void set_speed | ( | struct wave * | wave, |
midi_value_t | speed | ||
) |
Updates the speed of a wave.
Sets the wave frequency to the given speed in [BPM], adding an offset of 15 BPM.
wave | the wave to update |
speed | the new speed in [BPM] |
Updates the waveform of a wave.
wave | the wave to update |
waveform | the new waveform |
void tap_tempo_task | ( | void | ) |
Background task for the tap tempo function.
This function must be registered as a slow background task. It computes a frequency from an incrementing internal counter and the task frequency and updates the speed of the wave configured for tap tempo operation.
midi_value_t update_wave | ( | struct wave * | wave | ) |
Computes the current wave output value.
This function must be called in a fast background task. Over time the output value follows the configured waveform.
wave | the wave whose output should be computed |