#include <stdio.h>
#include <errno.h>
#include <math.h>
#include <signal.h>
#include <getopt.h>
#define PERIOD_NSEC (SPA_NSEC_PER_SEC/8)
struct port {
};
struct data {
struct port *port;
uint32_t clock_id;
int64_t offset;
uint64_t position;
};
{
struct data *data = userdata;
struct port *port = data->port;
uint64_t sample_offset, sample_period, sample_position, cycle;
if (data->clock_id != position->
clock.
id) {
data->clock_id = position->
clock.
id;
}
cycle = sample_position / sample_period;
if (sample_position % sample_period != 0)
++cycle;
sample_offset = cycle*sample_period - sample_position;
return;
return;
while (sample_offset < position->clock.duration) {
if (cycle % 2 == 0) {
uint32_t event = 0x20903c7f;
pw_log_info(
"note on at %"PRIu64, sample_position + sample_offset);
} else {
uint32_t event = 0x20803c7f;
pw_log_info(
"note off at %"PRIu64, sample_position + sample_offset);
}
sample_offset += sample_period;
++cycle;
}
}
{
struct data *data = userdata;
switch (state) {
data->offset = 0;
data->position = 0;
break;
default:
break;
}
}
.process = on_process,
};
static void do_quit(void *userdata, int signal_number)
{
struct data *data = userdata;
}
int main(int argc, char *argv[])
{
struct data data = {};
"midi-src",
NULL),
&filter_events,
&data);
sizeof(struct port),
NULL),
NULL, 0);
NULL, 0) < 0) {
fprintf(stderr, "can't connect\n");
return -1;
}
return 0;
}