mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-07 07:14:56 +01:00
NO-OP: clang-format
This commit is contained in:
parent
fd3220c3d7
commit
ecbd8732de
1 changed files with 179 additions and 177 deletions
|
|
@ -20,15 +20,15 @@
|
|||
#define _GNU_SOURCE
|
||||
#endif
|
||||
|
||||
#include <cstring>
|
||||
#include <string>
|
||||
#include <algorithm>
|
||||
#include <cstring>
|
||||
#include <map>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
|
||||
#include <math.h>
|
||||
#include <pthread.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
|
||||
#define AFS_URN "urn:ardour:a-fluidsynth"
|
||||
|
||||
|
|
@ -44,7 +44,6 @@
|
|||
|
||||
#include "fluidsynth.h"
|
||||
|
||||
#include <lv2/lv2plug.in/ns/lv2core/lv2.h>
|
||||
#include <lv2/lv2plug.in/ns/ext/atom/atom.h>
|
||||
#include <lv2/lv2plug.in/ns/ext/atom/forge.h>
|
||||
#include <lv2/lv2plug.in/ns/ext/atom/util.h>
|
||||
|
|
@ -54,6 +53,7 @@
|
|||
#include <lv2/lv2plug.in/ns/ext/state/state.h>
|
||||
#include <lv2/lv2plug.in/ns/ext/urid/urid.h>
|
||||
#include <lv2/lv2plug.in/ns/ext/worker/worker.h>
|
||||
#include <lv2/lv2plug.in/ns/lv2core/lv2.h>
|
||||
|
||||
enum {
|
||||
FS_PORT_CONTROL = 0,
|
||||
|
|
@ -190,7 +190,7 @@ load_sf2 (AFluidSynth* self, const char* fn)
|
|||
}
|
||||
|
||||
int chn;
|
||||
fluid_preset_t *preset;
|
||||
fluid_preset_t* preset;
|
||||
fluid_sfont_iteration_start (sfont);
|
||||
pthread_mutex_lock (&self->bp_lock);
|
||||
for (chn = 0; (preset = fluid_sfont_iteration_next (sfont)); ++chn) {
|
||||
|
|
@ -199,7 +199,9 @@ load_sf2 (AFluidSynth* self, const char* fn)
|
|||
fluid_preset_get_banknum (preset), fluid_preset_get_num (preset));
|
||||
}
|
||||
#ifndef LV2_EXTENDED
|
||||
else { break ; }
|
||||
else {
|
||||
break;
|
||||
}
|
||||
#else
|
||||
self->presets[fluid_preset_get_banknum (preset)].push_back (
|
||||
BankProgram (
|
||||
|
|
@ -263,15 +265,18 @@ inform_ui (AFluidSynth* self)
|
|||
static float
|
||||
db_to_coeff (float db)
|
||||
{
|
||||
if (db <= -80) { return 0; }
|
||||
else if (db >= 20) { return 10; }
|
||||
if (db <= -80) {
|
||||
return 0;
|
||||
} else if (db >= 20) {
|
||||
return 10;
|
||||
}
|
||||
return powf (10.f, .05f * db);
|
||||
}
|
||||
|
||||
static void
|
||||
parse_mts (AFluidSynth* self, const uint8_t* data, uint32_t len)
|
||||
{
|
||||
assert (data[0] == 0xf0 && data [3] == 0x08 && len > 11);
|
||||
assert (data[0] == 0xf0 && data[3] == 0x08 && len > 11);
|
||||
if (data[4] == 0x01 && len == 408) {
|
||||
/* bulk transfer
|
||||
* 0xf0, 0x7e, -- non-realtime sysex
|
||||
|
|
@ -288,8 +293,8 @@ parse_mts (AFluidSynth* self, const uint8_t* data, uint32_t len)
|
|||
int key[128];
|
||||
double pitch[128];
|
||||
for (int i = 0; i < 128; ++i) {
|
||||
const uint32_t note = data [off];
|
||||
const uint32_t fract = (data [off + 1] << 7) | data[off + 2];
|
||||
const uint32_t note = data[off];
|
||||
const uint32_t fract = (data[off + 1] << 7) | data[off + 2];
|
||||
key[i] = i;
|
||||
pitch[i] = note * 100.f + fract / 163.83;
|
||||
off += 3;
|
||||
|
|
@ -299,7 +304,7 @@ parse_mts (AFluidSynth* self, const uint8_t* data, uint32_t len)
|
|||
/* tuning bank */ 0,
|
||||
/* tuning prog */ prog,
|
||||
128, key, pitch,
|
||||
/* apply */1 );
|
||||
/* apply */ 1);
|
||||
if (rv == FLUID_OK) {
|
||||
for (int c = 0; c < 16; ++c) {
|
||||
fluid_synth_activate_tuning (self->synth, c, 0, prog, 0);
|
||||
|
|
@ -319,8 +324,8 @@ parse_mts (AFluidSynth* self, const uint8_t* data, uint32_t len)
|
|||
* cent_lsb, -- LSB of fractional part (1/16384 semitone = 100/16384 cents = .0061 cent units
|
||||
* 0xf7 -- 12 bytesin total
|
||||
*/
|
||||
const uint32_t note = data [8];
|
||||
const uint32_t fract = (data [9] << 7) | data[10];
|
||||
const uint32_t note = data[8];
|
||||
const uint32_t fract = (data[9] << 7) | data[10];
|
||||
|
||||
int prog = 0; // data[2]
|
||||
int key = data[7];
|
||||
|
|
@ -330,7 +335,7 @@ parse_mts (AFluidSynth* self, const uint8_t* data, uint32_t len)
|
|||
/* tuning bank */ 0,
|
||||
/* tuning prog */ prog,
|
||||
1, &key, &pitch,
|
||||
/* apply */1 );
|
||||
/* apply */ 1);
|
||||
if (rv == FLUID_OK) {
|
||||
for (int c = 0; c < 16; ++c) {
|
||||
fluid_synth_activate_tuning (self->synth, c, 0, prog, 0);
|
||||
|
|
@ -359,7 +364,7 @@ instantiate (const LV2_Descriptor* descriptor,
|
|||
|
||||
LV2_URID_Map* map = NULL;
|
||||
|
||||
for (int i=0; features[i] != NULL; ++i) {
|
||||
for (int i = 0; features[i] != NULL; ++i) {
|
||||
if (!strcmp (features[i]->URI, LV2_URID__map)) {
|
||||
map = (LV2_URID_Map*)features[i]->data;
|
||||
} else if (!strcmp (features[i]->URI, LV2_LOG__log)) {
|
||||
|
|
@ -442,7 +447,7 @@ instantiate (const LV2_Descriptor* descriptor,
|
|||
|
||||
pthread_mutex_init (&self->bp_lock, NULL);
|
||||
#ifdef LV2_EXTENDED
|
||||
self->presets = BPMap();
|
||||
self->presets = BPMap ();
|
||||
#endif
|
||||
self->panic = false;
|
||||
self->inform_ui = false;
|
||||
|
|
@ -502,6 +507,7 @@ static void
|
|||
deactivate (LV2_Handle instance)
|
||||
{
|
||||
AFluidSynth* self = (AFluidSynth*)instance;
|
||||
|
||||
self->panic = true;
|
||||
}
|
||||
|
||||
|
|
@ -577,17 +583,17 @@ run (LV2_Handle instance, uint32_t n_samples)
|
|||
|
||||
uint32_t offset = 0;
|
||||
|
||||
LV2_ATOM_SEQUENCE_FOREACH (self->control, ev) {
|
||||
LV2_ATOM_SEQUENCE_FOREACH (self->control, ev)
|
||||
{
|
||||
const LV2_Atom_Object* obj = (LV2_Atom_Object*)&ev->body;
|
||||
if (ev->body.type == self->atom_Blank || ev->body.type == self->atom_Object) {
|
||||
if (obj->body.otype == self->patch_Get) {
|
||||
self->inform_ui = false;
|
||||
inform_ui (self);
|
||||
}
|
||||
else if (obj->body.otype == self->patch_Set) {
|
||||
} else if (obj->body.otype == self->patch_Set) {
|
||||
const LV2_Atom* file_path = parse_patch_msg (self, obj);
|
||||
if (file_path && !self->reinit_in_progress && !self->queue_reinit) {
|
||||
const char *fn = (const char*)(file_path+1);
|
||||
const char* fn = (const char*)(file_path + 1);
|
||||
strncpy (self->queue_sf2_file_path, fn, 1023);
|
||||
self->queue_sf2_file_path[1023] = '\0';
|
||||
self->reinit_in_progress = true;
|
||||
|
|
@ -595,15 +601,14 @@ run (LV2_Handle instance, uint32_t n_samples)
|
|||
self->schedule->schedule_work (self->schedule->handle, sizeof (int), &magic);
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (ev->body.type == self->midi_MidiEvent) {
|
||||
} else if (ev->body.type == self->midi_MidiEvent) {
|
||||
if (ev->time.frames >= n_samples || self->reinit_in_progress) {
|
||||
continue;
|
||||
}
|
||||
if (ev->body.size > 3) {
|
||||
if (ev->body.size > 11) {
|
||||
const uint8_t* const data = (const uint8_t*)(ev + 1);
|
||||
if (data[0] == 0xf0 && (data[1] & 0x7e) == 0x7e && data [3] == 0x08) {
|
||||
if (data[0] == 0xf0 && (data[1] & 0x7e) == 0x7e && data[3] == 0x08) {
|
||||
parse_mts (self, data, ev->body.size);
|
||||
}
|
||||
}
|
||||
|
|
@ -638,7 +643,7 @@ run (LV2_Handle instance, uint32_t n_samples)
|
|||
assert (chn >= 0 && chn < 16);
|
||||
if (data[1] == 0x00) {
|
||||
self->program_state[chn].bank &= 0x7f;
|
||||
self->program_state[chn].bank |= (data[2] &0x7f) << 7;
|
||||
self->program_state[chn].bank |= (data[2] & 0x7f) << 7;
|
||||
}
|
||||
if (data[1] == 0x20) {
|
||||
self->program_state[chn].bank &= 0x3F80;
|
||||
|
|
@ -675,9 +680,9 @@ run (LV2_Handle instance, uint32_t n_samples)
|
|||
|
||||
/* emit stateChanged */
|
||||
LV2_Atom_Forge_Frame frame;
|
||||
lv2_atom_forge_frame_time(&self->forge, 0);
|
||||
x_forge_object(&self->forge, &frame, 1, self->state_Changed);
|
||||
lv2_atom_forge_pop(&self->forge, &frame);
|
||||
lv2_atom_forge_frame_time (&self->forge, 0);
|
||||
x_forge_object (&self->forge, &frame, 1, self->state_Changed);
|
||||
lv2_atom_forge_pop (&self->forge, &frame);
|
||||
|
||||
/* send .sf2 filename */
|
||||
inform_ui (self);
|
||||
|
|
@ -708,7 +713,8 @@ run (LV2_Handle instance, uint32_t n_samples)
|
|||
}
|
||||
}
|
||||
|
||||
static void cleanup (LV2_Handle instance)
|
||||
static void
|
||||
cleanup (LV2_Handle instance)
|
||||
{
|
||||
AFluidSynth* self = (AFluidSynth*)instance;
|
||||
delete_fluid_synth (self->synth);
|
||||
|
|
@ -739,7 +745,6 @@ work (LV2_Handle instance,
|
|||
return LV2_WORKER_ERR_UNKNOWN;
|
||||
}
|
||||
|
||||
|
||||
self->initialized = load_sf2 (self, self->queue_sf2_file_path);
|
||||
|
||||
if (self->initialized) {
|
||||
|
|
@ -843,7 +848,7 @@ save (LV2_Handle instance,
|
|||
|
||||
for (int i = 0; features[i]; ++i) {
|
||||
if (!strcmp (features[i]->URI, LV2_STATE__mapPath)) {
|
||||
map_path = (LV2_State_Map_Path*) features[i]->data;
|
||||
map_path = (LV2_State_Map_Path*)features[i]->data;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -871,10 +876,10 @@ save (LV2_Handle instance,
|
|||
if (0 != fluid_synth_tuning_iteration_next (self->synth, &tbank, &tprog)) {
|
||||
VectorOfDouble vod;
|
||||
vod.vb.child_type = self->atom_Double;
|
||||
vod.vb.child_size = sizeof(double);
|
||||
vod.vb.child_size = sizeof (double);
|
||||
fluid_synth_tuning_dump (self->synth, tbank, tprog, NULL, 0, vod.pitch);
|
||||
store (handle, self->afs_tuning,
|
||||
(void*) &vod, sizeof(LV2_Atom_Vector_Body) + 128 * sizeof(double),
|
||||
(void*)&vod, sizeof (LV2_Atom_Vector_Body) + 128 * sizeof (double),
|
||||
self->atom_Vector,
|
||||
LV2_STATE_IS_POD);
|
||||
}
|
||||
|
|
@ -902,10 +907,10 @@ restore (LV2_Handle instance,
|
|||
|
||||
for (int i = 0; features[i]; ++i) {
|
||||
if (!strcmp (features[i]->URI, LV2_STATE__mapPath)) {
|
||||
map_path = (LV2_State_Map_Path*) features[i]->data;
|
||||
map_path = (LV2_State_Map_Path*)features[i]->data;
|
||||
}
|
||||
#ifdef LV2_STATE__freePath
|
||||
else if (!strcmp(features[i]->URI, LV2_STATE__freePath)) {
|
||||
else if (!strcmp (features[i]->URI, LV2_STATE__freePath)) {
|
||||
free_path = (LV2_State_Free_Path*)features[i]->data;
|
||||
}
|
||||
#endif
|
||||
|
|
@ -924,7 +929,7 @@ restore (LV2_Handle instance,
|
|||
return LV2_STATE_ERR_NO_PROPERTY;
|
||||
}
|
||||
|
||||
char* apath = map_path->absolute_path (map_path->handle, (const char*) value);
|
||||
char* apath = map_path->absolute_path (map_path->handle, (const char*)value);
|
||||
strncpy (self->queue_sf2_file_path, apath, 1023);
|
||||
self->queue_sf2_file_path[1023] = '\0';
|
||||
self->queue_reinit = true;
|
||||
|
|
@ -940,22 +945,21 @@ restore (LV2_Handle instance,
|
|||
}
|
||||
|
||||
value = retrieve (handle, self->afs_tuning, &size, &type, &valflags);
|
||||
if (value
|
||||
&& size == sizeof(LV2_Atom_Vector_Body) + 128 * sizeof(double)
|
||||
&& type == self->atom_Vector) {
|
||||
memcpy(self->queue_tuning, LV2_ATOM_BODY(value), 128 * sizeof(double));
|
||||
if (value && size == sizeof (LV2_Atom_Vector_Body) + 128 * sizeof (double) && type == self->atom_Vector) {
|
||||
memcpy (self->queue_tuning, LV2_ATOM_BODY (value), 128 * sizeof (double));
|
||||
self->queue_retune = true;
|
||||
}
|
||||
|
||||
return LV2_STATE_SUCCESS;
|
||||
}
|
||||
|
||||
static std::string xml_escape (const std::string& s)
|
||||
static std::string
|
||||
xml_escape (const std::string& s)
|
||||
{
|
||||
std::string r (s);
|
||||
std::replace (r.begin (), r.end(), '"', '\'');
|
||||
std::replace (r.begin (), r.end (), '"', '\'');
|
||||
size_t pos = 0;
|
||||
while((pos = r.find ("&", pos)) != std::string::npos) {
|
||||
while ((pos = r.find ("&", pos)) != std::string::npos) {
|
||||
r.replace (pos, 1, "&");
|
||||
pos += 4;
|
||||
}
|
||||
|
|
@ -970,13 +974,13 @@ mn_file (LV2_Handle instance)
|
|||
char* rv = NULL;
|
||||
char tmp[1024];
|
||||
|
||||
rv = (char*) calloc (1, sizeof (char));
|
||||
rv = (char*)calloc (1, sizeof (char));
|
||||
|
||||
#define pf(...) \
|
||||
do { \
|
||||
snprintf (tmp, sizeof(tmp), __VA_ARGS__); \
|
||||
tmp[sizeof(tmp) - 1] = '\0'; \
|
||||
rv = (char*)realloc (rv, strlen (rv) + strlen(tmp) + 1); \
|
||||
snprintf (tmp, sizeof (tmp), __VA_ARGS__); \
|
||||
tmp[sizeof (tmp) - 1] = '\0'; \
|
||||
rv = (char*)realloc (rv, strlen (rv) + strlen (tmp) + 1); \
|
||||
strcat (rv, tmp); \
|
||||
} while (0)
|
||||
|
||||
|
|
@ -986,8 +990,8 @@ mn_file (LV2_Handle instance)
|
|||
" <Author/>\n"
|
||||
" <MasterDeviceNames>\n"
|
||||
" <Manufacturer>Ardour Foundation</Manufacturer>\n"
|
||||
" <Model>%s:%p</Model>\n", AFS_URN, (void*) self);
|
||||
|
||||
" <Model>%s:%p</Model>\n",
|
||||
AFS_URN, (void*)self);
|
||||
|
||||
pf (" <CustomDeviceMode Name=\"Default\">\n");
|
||||
pf (" <ChannelNameSetAssignments>\n");
|
||||
|
|
@ -1014,16 +1018,16 @@ mn_file (LV2_Handle instance)
|
|||
|
||||
for (BPMap::const_iterator i = ps.begin (); i != ps.end (); ++i, ++bn) {
|
||||
pf (" <PatchBank Name=\"Patch Bank %d\">\n", i->first);
|
||||
if (i->second.size() > 0) {
|
||||
if (i->second.size () > 0) {
|
||||
pf (" <MIDICommands>\n");
|
||||
pf (" <ControlChange Control=\"0\" Value=\"%d\"/>\n", (i->first >> 7) & 127);
|
||||
pf (" <ControlChange Control=\"32\" Value=\"%d\"/>\n", i->first & 127);
|
||||
pf (" </MIDICommands>\n");
|
||||
pf (" <PatchNameList>\n");
|
||||
int n = 0;
|
||||
for (BPList::const_iterator j = i->second.begin(); j != i->second.end(); ++j, ++n) {
|
||||
for (BPList::const_iterator j = i->second.begin (); j != i->second.end (); ++j, ++n) {
|
||||
pf (" <Patch Number=\"%d\" Name=\"%s\" ProgramChange=\"%d\"/>\n",
|
||||
n, xml_escape (j->name).c_str(), j->program);
|
||||
n, xml_escape (j->name).c_str (), j->program);
|
||||
}
|
||||
pf (" </PatchNameList>\n");
|
||||
}
|
||||
|
|
@ -1050,8 +1054,7 @@ mn_file (LV2_Handle instance)
|
|||
|
||||
pf (
|
||||
" </MasterDeviceNames>\n"
|
||||
"</MIDINameDocument>"
|
||||
);
|
||||
"</MIDINameDocument>");
|
||||
|
||||
//printf("-----\n%s\n------\n", rv);
|
||||
return rv;
|
||||
|
|
@ -1061,8 +1064,8 @@ static char*
|
|||
mn_model (LV2_Handle instance)
|
||||
{
|
||||
AFluidSynth* self = (AFluidSynth*)instance;
|
||||
char* rv = (char*) malloc (64 * sizeof (char));
|
||||
snprintf (rv, 64, "%s:%p", AFS_URN, (void*) self);
|
||||
char* rv = (char*)malloc (64 * sizeof (char));
|
||||
snprintf (rv, 64, "%s:%p", AFS_URN, (void*)self);
|
||||
rv[63] = 0;
|
||||
return rv;
|
||||
}
|
||||
|
|
@ -1080,8 +1083,7 @@ extension_data (const char* uri)
|
|||
if (!strcmp (uri, LV2_WORKER__interface)) {
|
||||
static const LV2_Worker_Interface worker = { work, work_response, NULL };
|
||||
return &worker;
|
||||
}
|
||||
else if (!strcmp (uri, LV2_STATE__interface)) {
|
||||
} else if (!strcmp (uri, LV2_STATE__interface)) {
|
||||
static const LV2_State_Interface state = { save, restore };
|
||||
return &state;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue