16 #ifndef PTTTL_SAMPLE_GENERATOR_H
17 #define PTTTL_SAMPLE_GENERATOR_H
34 #ifndef PTTTL_SAMPLE_GENERATOR_NUM_HARMONICS
35 #define PTTTL_SAMPLE_GENERATOR_NUM_HARMONICS 16
41 #define PTTTL_SAMPLE_GENERATOR_CONFIG_DEFAULT {.sample_rate=44100u, .attack_samples=100u, \
42 .decay_samples=500u, .amplitude=0.8f}
93 unsigned int sample_rate,
147 unsigned int current_sample;
214 uint32_t *num_samples, int16_t *samples);
Parser for RTTTL (Ring Tone Text Transfer Language) and PTTTL (Polyphonic Tone Text Transfer Language...
#define PTTTL_MAX_CHANNELS_PER_FILE
Definition: ptttl_parser.h:46
ptttl_waveform_type_e
Definition: ptttl_sample_generator.h:49
@ WAVEFORM_TYPE_NOKIA
Mimics the sound of a Nokia 3310 phone.
Definition: ptttl_sample_generator.h:54
@ WAVEFORM_TYPE_TRIANGLE
Generates a triangle wave.
Definition: ptttl_sample_generator.h:51
@ WAVEFORM_TYPE_SINE
Generates a sine wave.
Definition: ptttl_sample_generator.h:50
@ WAVEFORM_TYPE_SQUARE
Generates a square wave.
Definition: ptttl_sample_generator.h:53
@ WAVEFORM_TYPE_SAWTOOTH
Generates a sawtooth wave.
Definition: ptttl_sample_generator.h:52
float(* ptttl_waveform_generator_t)(float x, float p, unsigned int s, void *wgendata)
Definition: ptttl_sample_generator.h:70
int ptttl_sample_generator_set_custom_waveform(ptttl_sample_generator_t *generator, uint32_t channel, const ptttl_waveform_t *waveform)
void(* ptttl_waveform_note_setup_t)(uint32_t channel_idx, uint8_t note_number, unsigned int sample_rate, void *wgendata)
Definition: ptttl_sample_generator.h:91
int ptttl_sample_generator_generate(ptttl_sample_generator_t *generator, uint32_t *num_samples, int16_t *samples)
int ptttl_sample_generator_create(ptttl_parser_t *parser, ptttl_sample_generator_t *generator, ptttl_sample_generator_config_t *config)
int ptttl_sample_generator_set_waveform(ptttl_sample_generator_t *generator, uint32_t channel, ptttl_waveform_type_e type)
Definition: ptttl_sample_generator.h:116
unsigned int start_sample
The sample index on which this note started.
Definition: ptttl_sample_generator.h:121
float phasor_state
Phasor state for vibrato (frequency modulation)
Definition: ptttl_sample_generator.h:127
uint32_t vibrato_variance
Vibrato variance, in HZ.
Definition: ptttl_sample_generator.h:119
uint32_t vibrato_frequency
Vibrato frequency, in HZ.
Definition: ptttl_sample_generator.h:118
unsigned int sine_index
Monotonically increasing index for sinf() function, note pitch.
Definition: ptttl_sample_generator.h:120
unsigned int num_samples
Number of samples this note runs for.
Definition: ptttl_sample_generator.h:122
ptttl_waveform_t waveform
Waveform generator functions.
Definition: ptttl_sample_generator.h:117
float sample_error
Accumulated sample count error for this note.
Definition: ptttl_sample_generator.h:128
unsigned int note_number
Piano key number for this note, 1-88.
Definition: ptttl_sample_generator.h:125
float pitch_hz
Note pitch in Hz.
Definition: ptttl_sample_generator.h:126
unsigned int attack
Note attack length, in samples.
Definition: ptttl_sample_generator.h:123
unsigned int decay
Note decay length, in samples.
Definition: ptttl_sample_generator.h:124
Definition: ptttl_parser.h:167
Definition: ptttl_sample_generator.h:135
float amplitude
Amplitude of generated samples between 0.0-1.0, with 1.0 being full volume.
Definition: ptttl_sample_generator.h:139
unsigned int sample_rate
Sampling rate in samples per second (Hz)
Definition: ptttl_sample_generator.h:136
unsigned int attack_samples
no. of samples to ramp from 0 to full volume, at note start
Definition: ptttl_sample_generator.h:137
unsigned int decay_samples
no. of samples to ramp from full volume to 0, at note end
Definition: ptttl_sample_generator.h:138
Definition: ptttl_sample_generator.h:146