ptttl v0.2.0
C implementation of a PTTTL parser. PTTTL is a superset of NOKIA's RTTTL that adds polyphony & vibrato.
|
Parser for RTTTL (Ring Tone Text Transfer Language) and PTTTL (Polyphonic Tone Text Transfer Language, superset of RTTTL which supports polyphony) More...
#include <stdint.h>
Go to the source code of this file.
Classes | |
struct | ptttl_output_note_t |
struct | ptttl_parser_input_stream_t |
struct | ptttl_parser_input_iface_t |
struct | ptttl_parser_error_t |
struct | ptttl_parser_t |
Macros | |
#define | PTTTL_VERSION "v0.2.0" |
#define | PTTTL_MAX_CHANNELS_PER_FILE (16u) |
#define | PTTTL_MAX_NAME_LEN (256u) |
#define | PTTTL_NOTE_VIBRATO_FREQ(note) (((note)->vibrato_settings) & 0xffffu) |
#define | PTTTL_NOTE_VIBRATO_VAR(note) ((((note)->vibrato_settings) >> 16u) & 0xffffu) |
#define | PTTTL_NOTE_VALUE(note) (((note)->note_settings) & 0x7fu) |
#define | PTTTL_NOTE_DURATION(note) ((((note)->note_settings) >> 7u) & 0xffffu) |
Functions | |
ptttl_parser_error_t | ptttl_parser_error (ptttl_parser_t *state) |
int | ptttl_parse_init (ptttl_parser_t *parser, ptttl_parser_input_iface_t iface) |
int | ptttl_parse_next (ptttl_parser_t *parser, uint32_t channel_idx, ptttl_output_note_t *note) |
Parser for RTTTL (Ring Tone Text Transfer Language) and PTTTL (Polyphonic Tone Text Transfer Language, superset of RTTTL which supports polyphony)
Converts a PTTTL or RTTTL source file into a stream of ptttl_output_note_t objects, which is an intermediate representation that can be processed by ptttl_sample_generator.c to obtain PCM audio samples.
Requires stdint.h, strtoul() from stdlib.h, and memset() from string.h.
See https://github.com/eriknyquist/ptttl for more details about PTTTL.
#define PTTTL_MAX_CHANNELS_PER_FILE (16u) |
Maximum number of channels (note lanes) allowed in a single PTTTL file. This setting will significantly affect the size of the ptttl_parser_t and ptttl_sample_generator_t structs– more channels makes them larger.
#define PTTTL_MAX_NAME_LEN (256u) |
Maximum size of the name (first colon-separated field in a PTTTL or RTTTL file). This name is stored directly in the ptttl_parser_t struct, so changing this size directly affects the size of the ptttl_parser_t struct.
int ptttl_parse_init | ( | ptttl_parser_t * | parser, |
ptttl_parser_input_iface_t | iface | ||
) |
Initializes the PTTTL parser for a particular PTTTL/RTTTL input text. Must be called once before attempting to parse a PTTTL/RTTTL input text with ptttl_parse_next.
parser | Pointer to parser object to initialize |
iface | Input interface for reading PTTTL/RTTTL source text |
int ptttl_parse_next | ( | ptttl_parser_t * | parser, |
uint32_t | channel_idx, | ||
ptttl_output_note_t * | note | ||
) |
Read PTTTL/RTTTL source text for the next note of the specified channel, and produce an intermediate representation of the note that can be used to generate audio data.
parser | Pointer to initialized parser object |
channel_idx | Channel number to get next note for. Channel numbers are in the same order that the channel occurs in the PTTTL/RTTTL source text, starting from 0. |
note | Pointer to location to store intermediate representation of PTTTL/RTTTL note |
ptttl_parser_error_t ptttl_parser_error | ( | ptttl_parser_t * | state | ) |
Return error info after ptttl_parse_init or ptttl_parse_next has returned -1