mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-06 13:30:01 -05:00
pw-cat: rework midifile a little
Move the code to read and write midi into the midifile helper and simplify things a bit.
This commit is contained in:
parent
edbf1ff500
commit
b7dbf4bbc1
3 changed files with 250 additions and 115 deletions
|
|
@ -25,55 +25,30 @@
|
|||
#include <stdio.h>
|
||||
|
||||
#include <spa/utils/defs.h>
|
||||
#include <spa/utils/list.h>
|
||||
|
||||
struct midi_file;
|
||||
|
||||
struct midi_event {
|
||||
struct spa_list link;
|
||||
|
||||
struct midi_track *track;
|
||||
|
||||
uint32_t track;
|
||||
double sec;
|
||||
uint8_t status;
|
||||
uint8_t meta;
|
||||
|
||||
uint8_t *data;
|
||||
uint32_t size;
|
||||
};
|
||||
|
||||
struct midi_track {
|
||||
struct spa_list link;
|
||||
|
||||
uint8_t *data;
|
||||
uint32_t size;
|
||||
|
||||
uint8_t *p;
|
||||
int64_t tick;
|
||||
uint8_t running_status;
|
||||
unsigned int eof:1;
|
||||
};
|
||||
|
||||
struct midi_file {
|
||||
uint8_t *data;
|
||||
size_t size;
|
||||
|
||||
uint32_t length;
|
||||
struct midi_file_info {
|
||||
uint16_t format;
|
||||
uint16_t ntracks;
|
||||
uint16_t division;
|
||||
uint32_t tempo;
|
||||
|
||||
struct spa_list tracks;
|
||||
|
||||
uint8_t *p;
|
||||
int64_t tick;
|
||||
double tick_sec;
|
||||
double tick_start;
|
||||
};
|
||||
|
||||
int midi_file_init(struct midi_file *mf, const char *mode,
|
||||
void *data, size_t size);
|
||||
struct midi_file *
|
||||
midi_file_open(const char *filename, const char *mode, struct midi_file_info *info);
|
||||
|
||||
int midi_file_add_track(struct midi_file *mf, struct midi_track *track);
|
||||
int midi_file_close(struct midi_file *mf);
|
||||
|
||||
int midi_file_peek_event(struct midi_file *mf, struct midi_event *event);
|
||||
int midi_file_consume_event(struct midi_file *mf, struct midi_event *event);
|
||||
int midi_file_consume_event(struct midi_file *mf, const struct midi_event *event);
|
||||
|
||||
int midi_file_add_event(struct midi_file *mf, const struct midi_event *event);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue