PebbleOS
Loading...
Searching...
No Matches
Data Structures | Enumerations | Functions
note_sequence.h File Reference
#include <pbl/kernel/compiler.h>
#include <stdbool.h>
#include <stdint.h>

Data Structures

struct  SpeakerNote
 A single note in a sequence. More...
 
struct  NoteSequenceState
 Playback state of a note sequence. More...
 

Enumerations

enum  SpeakerWaveform {
  SpeakerWaveformSine = 0 , SpeakerWaveformSquare , SpeakerWaveformTriangle , SpeakerWaveformSawtooth ,
  SpeakerWaveformCount
}
 Waveform used to synthesize a note. More...
 

Functions

void note_seq_init (NoteSequenceState *s, const SpeakerNote *notes, uint32_t count, uint32_t sample_rate)
 Initialize a note sequence player.
 
uint32_t note_seq_fill (NoteSequenceState *s, int16_t *out, uint32_t max_samples)
 Fill an output buffer with synthesized PCM samples.
 
void note_seq_deinit (NoteSequenceState *s)
 Clean up note sequence state.
 
uint32_t note_phase_inc (uint8_t midi_note, uint32_t sample_rate)
 Compute the per-sample phase increment of a MIDI note.
 
int16_t note_synth_sample (uint8_t waveform, uint32_t phase_acc, uint32_t phase_inc, uint8_t velocity)
 Synthesize one PCM sample of a waveform.
 
uint32_t note_midi_freq_x256 (uint8_t midi_note)
 Get the frequency of a MIDI note.
 

Data Structure Documentation

◆ SpeakerNote

struct SpeakerNote

A single note in a sequence.

Data Fields
uint16_t duration_ms Note duration in ms (max 10000).
uint8_t midi_note MIDI note number (0-127, 60=C4).

0 = rest (silence).

uint8_t reserved Reserved, set to 0.
uint8_t velocity Volume 0-127 (0 = use global volume).
uint8_t waveform SpeakerWaveform value.

Enumeration Type Documentation

◆ SpeakerWaveform

Waveform used to synthesize a note.

Enumerator
SpeakerWaveformSine 

Sine wave.

SpeakerWaveformSquare 

Square wave.

SpeakerWaveformTriangle 

Triangle wave.

SpeakerWaveformSawtooth 

Sawtooth wave.

SpeakerWaveformCount 

Number of waveforms.