NO-OP: whitespace (remove vi modelines)

This commit is contained in:
Robin Gareus 2019-02-28 20:56:23 +01:00
parent 9131cd17a0
commit 959947e7f8
No known key found for this signature in database
GPG key ID: A090BCE02CF57F04
6 changed files with 688 additions and 693 deletions

View file

@ -42,82 +42,82 @@ static uint32_t synth_sound (void *, uint32_t written, uint32_t nframes, fl
#include "rsynth.c"
typedef enum {
RSY_MIDIIN = 0,
RSY_OUTL,
RSY_OUTR
RSY_MIDIIN = 0,
RSY_OUTL,
RSY_OUTR
} PortIndex;
typedef struct {
const LV2_Atom_Sequence* midiin;
float* outL;
float* outR;
const LV2_Atom_Sequence* midiin;
float* outL;
float* outR;
LV2_URID_Map* map;
LV2_URID midi_MidiEvent;
LV2_URID_Map* map;
LV2_URID midi_MidiEvent;
double SampleRateD;
void *synth;
bool xmas;
double SampleRateD;
void *synth;
bool xmas;
} RSynth;
/* main LV2 */
static LV2_Handle
instantiate(const LV2_Descriptor* descriptor,
double rate,
const char* bundle_path,
const LV2_Feature* const* features)
instantiate (const LV2_Descriptor* descriptor,
double rate,
const char* bundle_path,
const LV2_Feature* const* features)
{
(void) descriptor; /* unused variable */
(void) bundle_path; /* unused variable */
(void) descriptor; /* unused variable */
(void) bundle_path; /* unused variable */
if (rate < 8000) {
fprintf(stderr, "RSynth.lv2 error: unsupported sample-rate (must be > 8k)\n");
return NULL;
}
RSynth* self = (RSynth*)calloc(1, sizeof(RSynth));
if(!self) {
return NULL;
}
if (rate < 8000) {
fprintf(stderr, "RSynth.lv2 error: unsupported sample-rate (must be > 8k)\n");
return NULL;
}
RSynth* self = (RSynth*)calloc(1, sizeof(RSynth));
if(!self) {
return NULL;
}
self->SampleRateD = rate;
self->SampleRateD = rate;
int i;
for (i=0; features[i]; ++i) {
if (!strcmp(features[i]->URI, LV2_URID__map)) {
self->map = (LV2_URID_Map*)features[i]->data;
}
}
int i;
for (i=0; features[i]; ++i) {
if (!strcmp(features[i]->URI, LV2_URID__map)) {
self->map = (LV2_URID_Map*)features[i]->data;
}
}
if (!self->map) {
fprintf(stderr, "RSynth.lv2 error: Host does not support urid:map\n");
free(self);
return NULL;
}
if (!self->map) {
fprintf(stderr, "RSynth.lv2 error: Host does not support urid:map\n");
free(self);
return NULL;
}
self->midi_MidiEvent = self->map->map(self->map->handle, LV2_MIDI__MidiEvent);
self->midi_MidiEvent = self->map->map(self->map->handle, LV2_MIDI__MidiEvent);
self->synth = synth_alloc();
synth_init(self->synth, rate);
self->synth = synth_alloc();
synth_init(self->synth, rate);
#ifndef PLATFORM_WINDOWS // easter egg is for sane platforms with native support for localtime_r only
struct tm date;
time_t now;
time(&now);
localtime_r(&now, &date);
if (getenv("ITSXMAS") || (date.tm_mon == 11 /*dec*/ && date.tm_mday == 25)) {
printf("reasonable synth.lv2 says: happy holidays!\n");
self->xmas = true;
}
struct tm date;
time_t now;
time(&now);
localtime_r(&now, &date);
if (getenv("ITSXMAS") || (date.tm_mon == 11 /*dec*/ && date.tm_mday == 25)) {
printf("reasonable synth.lv2 says: happy holidays!\n");
self->xmas = true;
}
#endif
return (LV2_Handle)self;
return (LV2_Handle)self;
}
static void
connect_port(LV2_Handle handle,
uint32_t port,
void* data)
connect_port (LV2_Handle handle,
uint32_t port,
void* data)
{
RSynth* self = (RSynth*)handle;
@ -135,76 +135,76 @@ connect_port(LV2_Handle handle,
}
static void
run(LV2_Handle handle, uint32_t n_samples)
run (LV2_Handle handle, uint32_t n_samples)
{
RSynth* self = (RSynth*)handle;
float* audio[2];
RSynth* self = (RSynth*)handle;
float* audio[2];
audio[0] = self->outL;
audio[1] = self->outR;
audio[0] = self->outL;
audio[1] = self->outR;
uint32_t written = 0;
uint32_t written = 0;
/* Process incoming MIDI events */
if (self->midiin) {
LV2_Atom_Event const* ev = (LV2_Atom_Event const*)((uintptr_t)((&(self->midiin)->body) + 1)); // lv2_atom_sequence_begin
while( // !lv2_atom_sequence_is_end
(const uint8_t*)ev < ((const uint8_t*) &(self->midiin)->body + (self->midiin)->atom.size)
)
{
if (ev->body.type == self->midi_MidiEvent) {
/* Process incoming MIDI events */
if (self->midiin) {
LV2_Atom_Event const* ev = (LV2_Atom_Event const*)((uintptr_t)((&(self->midiin)->body) + 1)); // lv2_atom_sequence_begin
while( // !lv2_atom_sequence_is_end
(const uint8_t*)ev < ((const uint8_t*) &(self->midiin)->body + (self->midiin)->atom.size)
)
{
if (ev->body.type == self->midi_MidiEvent) {
#ifdef DEBUG_MIDI_EVENT // debug midi messages in synth -- not rt-safe(!)
printf ("%5d (%d):", ev->time.frames, ev->body.size);
for (uint8_t i = 0; i < ev->body.size; ++i) {
printf (" %02x", ((const uint8_t*)(ev+1))[i]);
}
printf ("\n");
printf ("%5d (%d):", ev->time.frames, ev->body.size);
for (uint8_t i = 0; i < ev->body.size; ++i) {
printf (" %02x", ((const uint8_t*)(ev+1))[i]);
}
printf ("\n");
#endif
if (written + BUFFER_SIZE_SAMPLES < ev->time.frames
&& ev->time.frames < n_samples) {
/* first synthesize sound up until the message timestamp */
written = synth_sound(self->synth, written, ev->time.frames, audio);
}
/* send midi message to synth */
if (self->xmas) {
synth_parse_xmas(self->synth, (const uint8_t*)(ev+1), ev->body.size);
} else {
synth_parse_midi(self->synth, (const uint8_t*)(ev+1), ev->body.size);
}
}
ev = (LV2_Atom_Event const*) // lv2_atom_sequence_next()
((uintptr_t)((const uint8_t*)ev + sizeof(LV2_Atom_Event) + ((ev->body.size + 7) & ~7)));
}
}
if (written + BUFFER_SIZE_SAMPLES < ev->time.frames
&& ev->time.frames < n_samples) {
/* first synthesize sound up until the message timestamp */
written = synth_sound(self->synth, written, ev->time.frames, audio);
}
/* send midi message to synth */
if (self->xmas) {
synth_parse_xmas(self->synth, (const uint8_t*)(ev+1), ev->body.size);
} else {
synth_parse_midi(self->synth, (const uint8_t*)(ev+1), ev->body.size);
}
}
ev = (LV2_Atom_Event const*) // lv2_atom_sequence_next()
((uintptr_t)((const uint8_t*)ev + sizeof(LV2_Atom_Event) + ((ev->body.size + 7) & ~7)));
}
}
/* synthesize [remaining] sound */
synth_sound(self->synth, written, n_samples, audio);
/* synthesize [remaining] sound */
synth_sound(self->synth, written, n_samples, audio);
}
static void
cleanup(LV2_Handle handle)
{
RSynth* self = (RSynth*)handle;
synth_free(self->synth);
free(handle);
RSynth* self = (RSynth*)handle;
synth_free(self->synth);
free(handle);
}
static const void*
extension_data(const char* uri)
{
(void) uri; /* unused variable */
return NULL;
(void) uri; /* unused variable */
return NULL;
}
static const LV2_Descriptor descriptor = {
RSY_URI,
instantiate,
connect_port,
NULL,
run,
NULL,
cleanup,
extension_data
RSY_URI,
instantiate,
connect_port,
NULL,
run,
NULL,
cleanup,
extension_data
};
#if defined(COMPILER_MSVC)
@ -215,12 +215,10 @@ __attribute__ ((visibility ("default")))
const LV2_Descriptor*
lv2_descriptor(uint32_t idx)
{
switch (idx) {
case 0:
return &descriptor;
default:
return NULL;
}
switch (idx) {
case 0:
return &descriptor;
default:
return NULL;
}
}
/* vi:set ts=8 sts=2 sw=2 et: */