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

@ -20,28 +20,22 @@
#include <math.h> #include <math.h>
#include "ardour/iec1ppmdsp.h" #include "ardour/iec1ppmdsp.h"
float Iec1ppmdsp::_w1; float Iec1ppmdsp::_w1;
float Iec1ppmdsp::_w2; float Iec1ppmdsp::_w2;
float Iec1ppmdsp::_w3; float Iec1ppmdsp::_w3;
float Iec1ppmdsp::_g; float Iec1ppmdsp::_g;
Iec1ppmdsp::Iec1ppmdsp (void)
: _z1 (0)
, _z2 (0)
, _m (0)
, _res (true)
{}
Iec1ppmdsp::Iec1ppmdsp (void) : Iec1ppmdsp::~Iec1ppmdsp (void) {}
_z1 (0),
_z2 (0),
_m (0),
_res (true)
{
}
void
Iec1ppmdsp::~Iec1ppmdsp (void) Iec1ppmdsp::process (float const* p, int n)
{
}
void Iec1ppmdsp::process (float const *p, int n)
{ {
float z1, z2, m, t; float z1, z2, m, t;
@ -51,8 +45,7 @@ void Iec1ppmdsp::process (float const *p, int n)
_res = false; _res = false;
n /= 4; n /= 4;
while (n--) while (n--) {
{
z1 *= _w3; z1 *= _w3;
z2 *= _w3; z2 *= _w3;
t = fabsf (*p++); t = fabsf (*p++);
@ -76,25 +69,25 @@ void Iec1ppmdsp::process (float const *p, int n)
_m = m; _m = m;
} }
float
float Iec1ppmdsp::read (void) Iec1ppmdsp::read (void)
{ {
_res = true; _res = true;
return _g * _m; return _g * _m;
} }
void Iec1ppmdsp::reset () void
Iec1ppmdsp::reset ()
{ {
_z1 = _z2 = _m = .0f; _z1 = _z2 = _m = .0f;
_res = true; _res = true;
} }
void Iec1ppmdsp::init (float fsamp) void
Iec1ppmdsp::init (float fsamp)
{ {
_w1 = 450.0f / fsamp; _w1 = 450.0f / fsamp;
_w2 = 1300.0f / fsamp; _w2 = 1300.0f / fsamp;
_w3 = 1.0f - 5.4f / fsamp; _w3 = 1.0f - 5.4f / fsamp;
_g = 0.5108f; _g = 0.5108f;
} }
/* vi:set ts=8 sts=8 sw=4: */

View file

@ -20,28 +20,22 @@
#include <math.h> #include <math.h>
#include "ardour/iec2ppmdsp.h" #include "ardour/iec2ppmdsp.h"
float Iec2ppmdsp::_w1; float Iec2ppmdsp::_w1;
float Iec2ppmdsp::_w2; float Iec2ppmdsp::_w2;
float Iec2ppmdsp::_w3; float Iec2ppmdsp::_w3;
float Iec2ppmdsp::_g; float Iec2ppmdsp::_g;
Iec2ppmdsp::Iec2ppmdsp (void)
: _z1 (0)
, _z2 (0)
, _m (0)
, _res (true)
{}
Iec2ppmdsp::Iec2ppmdsp (void) : Iec2ppmdsp::~Iec2ppmdsp (void) {}
_z1 (0),
_z2 (0),
_m (0),
_res (true)
{
}
void
Iec2ppmdsp::~Iec2ppmdsp (void) Iec2ppmdsp::process (float const* p, int n)
{
}
void Iec2ppmdsp::process (float const *p, int n)
{ {
float z1, z2, m, t; float z1, z2, m, t;
@ -51,8 +45,7 @@ void Iec2ppmdsp::process (float const *p, int n)
_res = false; _res = false;
n /= 4; n /= 4;
while (n--) while (n--) {
{
z1 *= _w3; z1 *= _w3;
z2 *= _w3; z2 *= _w3;
t = fabsf (*p++); t = fabsf (*p++);
@ -76,25 +69,25 @@ void Iec2ppmdsp::process (float const *p, int n)
_m = m; _m = m;
} }
float
float Iec2ppmdsp::read (void) Iec2ppmdsp::read (void)
{ {
_res = true; _res = true;
return _g * _m; return _g * _m;
} }
void Iec2ppmdsp::reset () void
Iec2ppmdsp::reset ()
{ {
_z1 = _z2 = _m = .0f; _z1 = _z2 = _m = .0f;
_res = true; _res = true;
} }
void Iec2ppmdsp::init (float fsamp) void
Iec2ppmdsp::init (float fsamp)
{ {
_w1 = 200.0f / fsamp; _w1 = 200.0f / fsamp;
_w2 = 860.0f / fsamp; _w2 = 860.0f / fsamp;
_w3 = 1.0f - 4.0f / fsamp; _w3 = 1.0f - 4.0f / fsamp;
_g = 0.5141f; _g = 0.5141f;
} }
/* vi:set ts=8 sts=8 sw=4: */

View file

@ -20,35 +20,26 @@
#include <math.h> #include <math.h>
#include "ardour/kmeterdsp.h" #include "ardour/kmeterdsp.h"
float Kmeterdsp::_omega; float Kmeterdsp::_omega;
Kmeterdsp::Kmeterdsp (void)
: _z1 (0)
, _z2 (0)
, _rms (0)
, _flag (false)
{}
Kmeterdsp::Kmeterdsp (void) : Kmeterdsp::~Kmeterdsp (void) {}
_z1 (0),
_z2 (0),
_rms (0),
_flag (false)
{
}
void
Kmeterdsp::~Kmeterdsp (void) Kmeterdsp::init (int fsamp)
{
}
void Kmeterdsp::init (int fsamp)
{ {
_omega = 9.72f / fsamp; // ballistic filter coefficient _omega = 9.72f / fsamp; // ballistic filter coefficient
} }
void Kmeterdsp::process (float const *p, int n) void
Kmeterdsp::process (float const* p, int n)
{ {
// Called by JACK's process callback.
//
// p : pointer to sample buffer
// n : number of samples to process
float s, z1, z2; float s, z1, z2;
// Get filter state. // Get filter state.
@ -58,8 +49,7 @@ void Kmeterdsp::process (float const *p, int n)
// Perform filtering. The second filter is evaluated // Perform filtering. The second filter is evaluated
// only every 4th sample - this is just an optimisation. // only every 4th sample - this is just an optimisation.
n /= 4; // Loop is unrolled by 4. n /= 4; // Loop is unrolled by 4.
while (n--) while (n--) {
{
s = *p++; s = *p++;
s *= s; s *= s;
z1 += _omega * (s - z1); // Update first filter. z1 += _omega * (s - z1); // Update first filter.
@ -77,36 +67,35 @@ void Kmeterdsp::process (float const *p, int n)
if (isnan(z1)) z1 = 0; if (isnan(z1)) z1 = 0;
if (isnan(z2)) z2 = 0; if (isnan(z2)) z2 = 0;
// Save filter state. The added constants avoid denormals. // Save filter state. The added constants avoid denormals.
_z1 = z1 + 1e-20f; _z1 = z1 + 1e-20f;
_z2 = z2 + 1e-20f; _z2 = z2 + 1e-20f;
s = sqrtf (2.0f * z2); s = sqrtf (2.0f * z2);
if (_flag) // Display thread has read the rms value. if (_flag) {
{ // Display thread has read the rms value.
_rms = s; _rms = s;
_flag = false; _flag = false;
} } else {
else
{
// Adjust RMS value and update maximum since last read(). // Adjust RMS value and update maximum since last read().
if (s > _rms) _rms = s; if (s > _rms) _rms = s;
} }
} }
/* Returns highest _rms value since last call */ /* Returns highest _rms value since last call */
float Kmeterdsp::read () float
Kmeterdsp::read ()
{ {
float rv= _rms; float rv= _rms;
_flag = true; // Resets _rms in next process(). _flag = true; // Resets _rms in next process().
return rv; return rv;
} }
void Kmeterdsp::reset () void
Kmeterdsp::reset ()
{ {
_z1 = _z2 = _rms = .0f; _z1 = _z2 = _rms = .0f;
_flag = false; _flag = false;
} }
/* vi:set ts=8 sts=8 sw=4: */

View file

@ -480,5 +480,3 @@ void gdither_runf(GDither s, uint32_t channel, uint32_t length,
s->clamp_l); s->clamp_l);
} }
} }
/* vi:set ts=8 sts=4 sw=4: */

View file

@ -63,7 +63,7 @@ typedef struct {
/* main LV2 */ /* main LV2 */
static LV2_Handle static LV2_Handle
instantiate(const LV2_Descriptor* descriptor, instantiate (const LV2_Descriptor* descriptor,
double rate, double rate,
const char* bundle_path, const char* bundle_path,
const LV2_Feature* const* features) const LV2_Feature* const* features)
@ -115,7 +115,7 @@ instantiate(const LV2_Descriptor* descriptor,
} }
static void static void
connect_port(LV2_Handle handle, connect_port (LV2_Handle handle,
uint32_t port, uint32_t port,
void* data) void* data)
{ {
@ -135,7 +135,7 @@ connect_port(LV2_Handle handle,
} }
static void static void
run(LV2_Handle handle, uint32_t n_samples) run (LV2_Handle handle, uint32_t n_samples)
{ {
RSynth* self = (RSynth*)handle; RSynth* self = (RSynth*)handle;
float* audio[2]; float* audio[2];
@ -222,5 +222,3 @@ lv2_descriptor(uint32_t idx)
return NULL; return NULL;
} }
} }
/* vi:set ts=8 sts=2 sw=2 et: */

View file

@ -1,6 +1,6 @@
/* reasonable simple synth /* reasonably simple synth
* *
* Copyright (C) 2013 Robin Gareus <robin@gareus.org> * Copyright (C) 2013, 2019 Robin Gareus <robin@gareus.org>
* *
* This program is free software; you can redistribute it and/or modify * This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by * it under the terms of the GNU General Public License as published by
@ -85,8 +85,11 @@ typedef struct _RSSynthChannel {
} RSSynthChannel; } RSSynthChannel;
typedef void (*SynthFunction) (RSSynthChannel* sc, typedef void (*SynthFunction) (RSSynthChannel* sc,
const uint8_t note, const float vol, const float pc, const uint8_t note,
const size_t n_samples, float* left, float* right); const float vol,
const float pc,
const size_t n_samples,
float* left, float* right);
typedef struct { typedef struct {
uint32_t boffset; uint32_t boffset;
@ -100,7 +103,6 @@ typedef struct {
uint32_t xmas_off; uint32_t xmas_off;
} RSSynthesizer; } RSSynthesizer;
/* initialize ADSR values /* initialize ADSR values
* *
* @param rate sample-rate * @param rate sample-rate
@ -110,10 +112,11 @@ typedef struct {
* @param avol attack gain [0..1] * @param avol attack gain [0..1]
* @param svol sustain volume level [0..1] * @param svol sustain volume level [0..1]
*/ */
static void init_adsr(ADSRcfg *adsr, const double rate, static void
init_adsr (ADSRcfg *adsr, const double rate,
const uint32_t a, const uint32_t d, const uint32_t r, const uint32_t a, const uint32_t d, const uint32_t r,
const float avol, const float svol) { const float avol, const float svol)
{
adsr->vol[0] = avol; adsr->vol[0] = avol;
adsr->vol[1] = svol; adsr->vol[1] = svol;
adsr->tme[0] = a * rate / 1000.0; adsr->tme[0] = a * rate / 1000.0;
@ -132,8 +135,9 @@ static void init_adsr(ADSRcfg *adsr, const double rate,
} }
/* calculate per-sample, per-key envelope */ /* calculate per-sample, per-key envelope */
static inline float adsr_env(RSSynthChannel *sc, const uint8_t note) { static inline float
adsr_env(RSSynthChannel *sc, const uint8_t note)
{
if (sc->adsr_cnt[note] < sc->adsr.off[0]) { if (sc->adsr_cnt[note] < sc->adsr.off[0]) {
// attack // attack
const uint32_t p = ++sc->adsr_cnt[note]; const uint32_t p = ++sc->adsr_cnt[note];
@ -177,13 +181,13 @@ static inline float adsr_env(RSSynthChannel *sc, const uint8_t note) {
} }
} }
/*****************************************************************************/ /*****************************************************************************/
/* piano like sound w/slight stereo phase */ /* piano like sound w/slight stereo phase */
static void synthesize_sineP (RSSynthChannel* sc, static void
synthesize_sineP (RSSynthChannel* sc,
const uint8_t note, const float vol, const float fq, const uint8_t note, const float vol, const float fq,
const size_t n_samples, float* left, float* right) { const size_t n_samples, float* left, float* right)
{
size_t i; size_t i;
float phase = sc->phase[note]; float phase = sc->phase[note];
@ -215,15 +219,17 @@ static void synthesize_sineP (RSSynthChannel* sc,
sc->phase[note] = phase; sc->phase[note] = phase;
} }
static const ADSRcfg piano_adsr = {{ 5, 800, 100}, { 1.0, 0.0}, {0,0,0}}; static const ADSRcfg piano_adsr = {{ 5, 800, 100}, { 1.0, 0.0}, {0, 0, 0}};
/*****************************************************************************/ /*****************************************************************************/
/* process note - move through ADSR states, count active keys,.. */ /* process note - move through ADSR states, count active keys,.. */
static void process_key (void *synth, static void
process_key (void *synth,
const uint8_t chn, const uint8_t note, const uint8_t chn, const uint8_t note,
const size_t n_samples, float *left, float *right) const size_t n_samples,
float *left, float *right)
{ {
RSSynthesizer* rs = (RSSynthesizer*)synth; RSSynthesizer* rs = (RSSynthesizer*)synth;
RSSynthChannel* sc = &rs->sc[chn]; RSSynthChannel* sc = &rs->sc[chn];
@ -292,7 +298,9 @@ static void process_key (void *synth,
} }
/* synthesize a BUFFER_SIZE_SAMPLES's of audio-data */ /* synthesize a BUFFER_SIZE_SAMPLES's of audio-data */
static void synth_fragment (void *synth, const size_t n_samples, float *left, float *right) { static void
synth_fragment (void *synth, const size_t n_samples, float *left, float *right)
{
RSSynthesizer* rs = (RSSynthesizer*)synth; RSSynthesizer* rs = (RSSynthesizer*)synth;
memset (left, 0, n_samples * sizeof(float)); memset (left, 0, n_samples * sizeof(float));
memset (right, 0, n_samples * sizeof(float)); memset (right, 0, n_samples * sizeof(float));
@ -322,9 +330,10 @@ static void synth_fragment (void *synth, const size_t n_samples, float *left, fl
#endif #endif
} }
static void synth_reset_channel(RSSynthChannel* sc) { static void
int k; synth_reset_channel(RSSynthChannel* sc)
for (k=0; k < 128; ++k) { {
for (int k = 0; k < 128; ++k) {
sc->adsr_cnt[k] = 0; sc->adsr_cnt[k] = 0;
sc->adsr_amp[k] = 0; sc->adsr_amp[k] = 0;
sc->phase[k] = -10; sc->phase[k] = -10;
@ -334,7 +343,9 @@ static void synth_reset_channel(RSSynthChannel* sc) {
sc->keycomp = 0; sc->keycomp = 0;
} }
static void synth_reset(void *synth) { static void
synth_reset(void *synth)
{
RSSynthesizer* rs = (RSSynthesizer*)synth; RSSynthesizer* rs = (RSSynthesizer*)synth;
int c; int c;
for (c=0; c < 16; ++c) { for (c=0; c < 16; ++c) {
@ -343,9 +354,11 @@ static void synth_reset(void *synth) {
rs->kcgain = 0; rs->kcgain = 0;
} }
static void synth_load(RSSynthChannel *sc, const double rate, static void
synth_load (RSSynthChannel *sc, const double rate,
SynthFunction synthesize, SynthFunction synthesize,
ADSRcfg const * const adsr) { ADSRcfg const * const adsr)
{
synth_reset_channel(sc); synth_reset_channel(sc);
init_adsr(&sc->adsr, rate, init_adsr(&sc->adsr, rate,
adsr->tme[0], adsr->tme[1], adsr->tme[2], adsr->tme[0], adsr->tme[1], adsr->tme[2],
@ -353,11 +366,12 @@ static void synth_load(RSSynthChannel *sc, const double rate,
sc->synthesize = synthesize; sc->synthesize = synthesize;
} }
/** /**
* internal abstraction of MIDI data handling * internal abstraction of MIDI data handling
*/ */
static void synth_process_midi_event(void *synth, struct rmidi_event_t *ev) { static void
synth_process_midi_event(void *synth, struct rmidi_event_t *ev)
{
RSSynthesizer* rs = (RSSynthesizer*)synth; RSSynthesizer* rs = (RSSynthesizer*)synth;
switch(ev->type) { switch(ev->type) {
case NOTE_ON: case NOTE_ON:
@ -406,7 +420,9 @@ static void synth_process_midi_event(void *synth, struct rmidi_event_t *ev) {
* @param out pointer to stereo output buffers * @param out pointer to stereo output buffers
* @return end of buffer (written + nframes) * @return end of buffer (written + nframes)
*/ */
static uint32_t synth_sound (void *synth, uint32_t written, const uint32_t nframes, float **out) { static uint32_t
synth_sound (void *synth, uint32_t written, const uint32_t nframes, float **out)
{
RSSynthesizer* rs = (RSSynthesizer*)synth; RSSynthesizer* rs = (RSSynthesizer*)synth;
while (written < nframes) { while (written < nframes) {
@ -436,7 +452,9 @@ static uint32_t synth_sound (void *synth, uint32_t written, const uint32_t nfram
* @param data 8bit midi message * @param data 8bit midi message
* @param size number of bytes in the midi-message * @param size number of bytes in the midi-message
*/ */
static void synth_parse_midi(void *synth, const uint8_t *data, const size_t size) { static void
synth_parse_midi (void *synth, const uint8_t *data, const size_t size)
{
if (size < 2 || size > 3) return; if (size < 2 || size > 3) return;
// All messages need to be 3 bytes; except program-changes: 2bytes. // All messages need to be 3 bytes; except program-changes: 2bytes.
if (size == 2 && (data[0] & 0xf0) != 0xC0) return; if (size == 2 && (data[0] & 0xf0) != 0xC0) return;
@ -475,7 +493,9 @@ static void synth_parse_midi(void *synth, const uint8_t *data, const size_t size
static const uint8_t jingle[] = { 71 ,71 ,71 ,71 ,71 ,71 ,71 ,74 ,67 ,69 ,71 ,72 ,72 ,72 ,72 ,72 ,71 ,71 ,71 ,71 ,71 ,69 ,69 ,71 ,69 ,74 ,71 ,71 ,71 ,71 ,71 ,71 ,71 ,74 ,67 ,69 ,71 ,72 ,72 ,72 ,72 ,72 ,71 ,71 ,71 ,71 ,74 ,74 ,72 ,69 ,67 ,62 ,62 ,71 ,69 ,67 ,62 ,62 ,62 ,62 ,71 ,69 ,67 ,64 ,64 ,64 ,72 ,71 ,69 ,66 ,74 ,76 ,74 ,72 ,69 ,71 ,62 ,62 ,71 ,69 ,67 ,62 ,62 ,62 ,62 ,71 ,69 ,67 ,64 ,64 ,64 ,72 ,71 ,69 ,74 ,74 ,74 ,74 ,76 ,74 ,72 ,69 ,67 ,74 ,71 ,71 ,71 ,71 ,71 ,71 ,71 ,74 ,67 ,69 ,71 ,72 ,72 ,72 ,72 ,72 ,71 ,71 ,71 ,71 ,71 ,69 ,69 ,71 ,69 ,74 ,71 ,71 ,71 ,71 ,71 ,71 ,71 ,74 ,67 ,69 ,71 ,72 ,72 ,72 ,72 ,72 ,71 ,71 ,71 ,71 ,74 ,74 ,72 ,69 ,67 }; static const uint8_t jingle[] = { 71 ,71 ,71 ,71 ,71 ,71 ,71 ,74 ,67 ,69 ,71 ,72 ,72 ,72 ,72 ,72 ,71 ,71 ,71 ,71 ,71 ,69 ,69 ,71 ,69 ,74 ,71 ,71 ,71 ,71 ,71 ,71 ,71 ,74 ,67 ,69 ,71 ,72 ,72 ,72 ,72 ,72 ,71 ,71 ,71 ,71 ,74 ,74 ,72 ,69 ,67 ,62 ,62 ,71 ,69 ,67 ,62 ,62 ,62 ,62 ,71 ,69 ,67 ,64 ,64 ,64 ,72 ,71 ,69 ,66 ,74 ,76 ,74 ,72 ,69 ,71 ,62 ,62 ,71 ,69 ,67 ,62 ,62 ,62 ,62 ,71 ,69 ,67 ,64 ,64 ,64 ,72 ,71 ,69 ,74 ,74 ,74 ,74 ,76 ,74 ,72 ,69 ,67 ,74 ,71 ,71 ,71 ,71 ,71 ,71 ,71 ,74 ,67 ,69 ,71 ,72 ,72 ,72 ,72 ,72 ,71 ,71 ,71 ,71 ,71 ,69 ,69 ,71 ,69 ,74 ,71 ,71 ,71 ,71 ,71 ,71 ,71 ,74 ,67 ,69 ,71 ,72 ,72 ,72 ,72 ,72 ,71 ,71 ,71 ,71 ,74 ,74 ,72 ,69 ,67 };
static void synth_parse_xmas(void *synth, const uint8_t *data, const size_t size) { static void
synth_parse_xmas(void *synth, const uint8_t *data, const size_t size)
{
RSSynthesizer* rs = (RSSynthesizer*)synth; RSSynthesizer* rs = (RSSynthesizer*)synth;
if (size < 2 || size > 3) return; if (size < 2 || size > 3) return;
// All messages need to be 3 bytes; except program-changes: 2bytes. // All messages need to be 3 bytes; except program-changes: 2bytes.
@ -519,7 +539,8 @@ static void synth_parse_xmas(void *synth, const uint8_t *data, const size_t size
* @param synth synth-handle * @param synth synth-handle
* @param rate sample-rate * @param rate sample-rate
*/ */
static void synth_init(void *synth, double rate) { static void
synth_init(void* synth, double rate) {
RSSynthesizer* rs = (RSSynthesizer*)synth; RSSynthesizer* rs = (RSSynthesizer*)synth;
rs->rate = rate; rs->rate = rate;
rs->boffset = BUFFER_SIZE_SAMPLES; rs->boffset = BUFFER_SIZE_SAMPLES;
@ -549,7 +570,9 @@ static void synth_init(void *synth, double rate) {
* *
* @return synth-handle * @return synth-handle
*/ */
static void * synth_alloc(void) { static void*
synth_alloc(void)
{
return calloc(1, sizeof(RSSynthesizer)); return calloc(1, sizeof(RSSynthesizer));
} }
@ -557,7 +580,8 @@ static void * synth_alloc(void) {
* release synth data structure * release synth data structure
* @param synth synth-handle * @param synth synth-handle
*/ */
static void synth_free(void *synth) { static void
synth_free(void *synth)
{
free(synth); free(synth);
} }
/* vi:set ts=8 sts=2 sw=2 et: */