Skip to content

Commit 359c215

Browse files
committed
Merge branch 'develop' into HEAD
2 parents 317e8f9 + 848455c commit 359c215

42 files changed

Lines changed: 7107 additions & 216 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.github/workflows/c-cpp.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: C/C++ CI
2+
3+
on:
4+
push:
5+
branches: [ master, develop ]
6+
pull_request:
7+
branches: [ master, develop ]
8+
9+
jobs:
10+
build:
11+
12+
runs-on: ubuntu-latest
13+
14+
steps:
15+
- uses: actions/checkout@v2
16+
with:
17+
submodules: true
18+
- name: Setup arm-none-eabi-gcc
19+
uses: fiam/arm-none-eabi-gcc@v1
20+
with:
21+
release: '9-2020-q2' # The arm-none-eabi-gcc release to use.
22+
- name: Setup emsdk
23+
uses: mymindstorm/setup-emsdk@v7
24+
with:
25+
version: 2.0.10
26+
- name: make
27+
run: make
28+
- name: make check
29+
run: make check

.gitmodules

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[submodule "Libraries/DaisySP"]
2+
path = Libraries/DaisySP
3+
url = https://github.com/electro-smith/DaisySP.git
4+
branch = master

FaustCode/owl.cpp

Lines changed: 30 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
#include "Patch.h"
4040
#include "VoltsPerOctave.h"
4141

42-
// We have to undefine min/max from Owl's basicmaths.h, otherwise they cause
42+
// We have to undefine min/max from OWL's basicmaths.h, otherwise they cause
4343
// errors when Faust calls functions with the same names in std:: namespace
4444
#undef min
4545
#undef max
@@ -54,10 +54,11 @@
5454
#include "faust/gui/UI.h"
5555
#include "faust/gui/meta.h"
5656

57-
static float fFreq, fGain, fGate;
57+
static float fKey, fFreq, fGain, fGate;
5858
static float fBend = 1.0f;
5959

6060
class MonoVoiceAllocator {
61+
float& key;
6162
float& freq;
6263
float& gain;
6364
float& gate;
@@ -66,8 +67,9 @@ class MonoVoiceAllocator {
6667
uint8_t lastNote = 0;
6768

6869
public:
69-
MonoVoiceAllocator(float& fq, float& gn, float& gt, float& bd)
70-
: freq(fq)
70+
MonoVoiceAllocator(float& ky, float& fq, float& gn, float& gt, float& bd)
71+
: key(ky)
72+
, freq(fq)
7173
, gain(gn)
7274
, gate(gt)
7375
, bend(bd) {
@@ -114,6 +116,7 @@ class MonoVoiceAllocator {
114116
void noteOn(uint8_t note, uint16_t velocity, uint16_t delay) {
115117
if (lastNote < 16)
116118
notes[lastNote++] = note;
119+
key = note;
117120
freq = noteToHz(note);
118121
gain = velocityToGain(velocity);
119122
gate = 1.0f;
@@ -130,11 +133,12 @@ class MonoVoiceAllocator {
130133
notes[i] = notes[i + 1];
131134
i++;
132135
}
133-
freq = noteToHz(notes[lastNote - 1]);
136+
key = notes[lastNote - 1];
137+
freq = noteToHz(key);
134138
}
135139
else {
136140
gate = 0.0f;
137-
lastNote = 0;
141+
lastNote = 0;
138142
}
139143
}
140144
void allNotesOff() {
@@ -153,8 +157,7 @@ enum ParserState {
153157
* To enable MIDI in current patch, add this to source Faust file:
154158
* declare options "[midi:on]";
155159
*
156-
* You can also add descrpiption to be displayed with debugMessage function like
157-
* this:
160+
* You can also add a description to be displayed like this:
158161
* declare message "Hello World";
159162
*
160163
* To add V/Oct scaling support, use something likes this:
@@ -251,8 +254,8 @@ class MetaData : public Meta {
251254

252255
/**************************************************************************************
253256
*
254-
* OwlParameter : object used by OwlUI to ensures the connection between an Owl
255-
* parameter and a Faust widget
257+
* OwlParameter : object used by OwlUI to ensures the connection between an OWL
258+
* parameter and a FAUST widget
256259
*
257260
***************************************************************************************/
258261

@@ -374,8 +377,8 @@ class OwlCheckbox : public OwlParameterBase {
374377
* OwlUI : Faust User Interface builder. Passed to buildUserInterface OwlU
375378
* ensures the mapping between owl parameters and faust widgets. It relies on
376379
* specific metadata "...[OWL:PARAMETER_X]..." in widget's label for that. For
377-
* example any faust widget with metadata [OWL:PARAMETER_B] will be controlled
378-
* by PARAMETER_B (the second knob).
380+
* example any faust widget with metadata [OWL:B] will be controlled by
381+
* PARAMETER_B (the second knob).
379382
*
380383
***************************************************************************************/
381384

@@ -384,7 +387,7 @@ class OwlCheckbox : public OwlParameterBase {
384387
#define NO_PARAMETER ((PatchParameterId)-1)
385388
#define NO_BUTTON ((PatchButtonId)-1)
386389

387-
MonoVoiceAllocator allocator(fFreq, fGain, fGate, fBend);
390+
MonoVoiceAllocator allocator(fKey, fFreq, fGain, fGate, fBend);
388391
VoltsPerOctave* fVOctInput;
389392
VoltsPerOctave* fVOctOutput;
390393

@@ -410,6 +413,10 @@ class OwlUI : public UI {
410413
fParameterTable[fParameterIndex++] =
411414
new OwlVariable(fPatch, &fBend, zone, label, init, lo, hi);
412415
}
416+
else if (meta.midiOn && strcasecmp(label, "key") == 0) {
417+
fParameterTable[fParameterIndex++] =
418+
new OwlVariable(fPatch, &fKey, zone, label, init, lo, hi);
419+
}
413420
else if (fParameter != NO_PARAMETER) {
414421
fParameterTable[fParameterIndex++] =
415422
new OwlParameter(fPatch, fParameter, zone, label, init, lo, hi);
@@ -424,19 +431,7 @@ class OwlUI : public UI {
424431
if(label[strlen(label) - 1] != '>')
425432
debugMessage("Add '>' character for output parameters");
426433
if (fParameterIndex < MAXOWLPARAMETERS) {
427-
if (meta.midiOn && strcasecmp(label, "freq") == 0) {
428-
fParameterTable[fParameterIndex++] =
429-
new OwlVariable(fPatch, &fFreq, zone, label, lo, lo, hi, true);
430-
}
431-
else if (meta.midiOn && strcasecmp(label, "gain") == 0) {
432-
fParameterTable[fParameterIndex++] =
433-
new OwlVariable(fPatch, &fGain, zone, label, lo, lo, hi, true);
434-
}
435-
else if (meta.midiOn && strcasecmp(label, "bend") == 0) {
436-
fParameterTable[fParameterIndex++] =
437-
new OwlVariable(fPatch, &fBend, zone, label, lo, lo, hi, true);
438-
}
439-
else if (fParameter != NO_PARAMETER) {
434+
if (fParameter != NO_PARAMETER) {
440435
fParameterTable[fParameterIndex++] = new OwlParameter(
441436
fPatch, fParameter, zone, label, lo, lo, hi, true);
442437
}
@@ -503,7 +498,7 @@ class OwlUI : public UI {
503498
delete fVOctOutput;
504499
}
505500

506-
// should be called before compute() to update widget's zones registered as Owl parameters
501+
// should be called before compute() to update widget's zones registered as OWL parameters
507502
void update() {
508503
for (int i = 0; i < fParameterIndex; i++)
509504
fParameterTable[i]->update();
@@ -565,7 +560,6 @@ class OwlUI : public UI {
565560
if (strcasecmp(k, "OWL") == 0) {
566561
if (strncasecmp(id, "PARAMETER_", 10) == 0)
567562
id += 10;
568-
569563
if (strlen(id) == 1) {
570564
// Single char parameter name.
571565
// Note that we can use I - P as aliases for AA-AH.
@@ -610,7 +604,7 @@ class OwlUI : public UI {
610604
std::min(int(PARAMETER_DH), param_tmp + *id - '0'));
611605
}
612606
}
613-
else if (param_tmp == PARAMETER_B && *id >= '0' && *id <= '9') {
607+
else if (param_tmp == PARAMETER_B && *id > '0' && *id <= '9') {
614608
fButton = PatchButtonId(BUTTON_A + *id - '1');
615609
}
616610
else {
@@ -633,12 +627,13 @@ class OwlUI : public UI {
633627
else if (strcasecmp(id, "PUSH") == 0)
634628
fButton = PUSHBUTTON;
635629
}
636-
else if (strcasecmp(k, "midi") == 0) {
637-
// todo!
638-
// if (strcasecmp(id,"pitchwheel") == 0) fParameter = PARAMETER_G;
639-
// // mapped to pitch wheel declare(&fHslider1, "midi",
640-
// "pitchwheel"); declare(&fButton1, "midi", "ctrl 64");
641-
}
630+
// else if (strcasecmp(k, "midi") == 0) {
631+
// if (strcasecmp(id, "pitchwheel") == 0){ // PB
632+
// }else if (strcasecmp(id, "ctrl") == 0){ // CC
633+
// }else if (strcasecmp(id, "chanpress") == 0){ // AT
634+
// }else if (strcasecmp(id, "pgm") == 0){ // PC
635+
// }
636+
// }
642637
}
643638

644639
// -- V/Oct

GenSource/GenPatch.hpp

Lines changed: 25 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,11 +155,12 @@ class GenPatch : public Patch {
155155
CommonState *context;
156156
GenParameterBase* params[GEN_OWL_MAX_PARAM_COUNT];
157157
size_t param_count = 0;
158-
float freq = 440.0f;
159-
float gain = 0.0f;
160-
float gate = 0.0f;
161-
float bend = 1.0;
158+
float freq = 440.0f;
159+
float gain = 0.0f;
160+
float gate = 0.0f;
161+
float bend = 1.0;
162162
MonoVoiceAllocator allocator;
163+
float** buffers;
163164
public:
164165
GenPatch() : allocator(freq, gain, gate, bend) {
165166
context = (CommonState*)gen::create(getSampleRate(), getBlockSize());
@@ -195,12 +196,23 @@ class GenPatch : public Patch {
195196
params[param_count++] = new GenParameter(this, context, name, (PatchParameterId)index, i);
196197
}
197198
}
199+
buffers = new float*[gen::num_outputs()];
200+
size_t channels = getNumberOfChannels();
201+
debugMessage("SR/CH/BS", (int)getSampleRate(), getNumberOfChannels(), getBlockSize());
202+
char name[] = "Out0>";
203+
for(int ch=channels; ch<gen::num_outputs(); ++ch){
204+
buffers[ch] = new float[getBlockSize()];
205+
name[3] = '1'+ch;
206+
registerParameter((PatchParameterId)(PARAMETER_F+(ch-channels)), name);
207+
}
198208
}
199209

200210
~GenPatch() {
201211
gen::destroy(context);
202212
for(int i=0; i<param_count; ++i)
203213
delete params[i];
214+
for(int i=getNumberOfChannels(); i<gen::num_outputs(); ++i)
215+
delete[] buffers[i];
204216
}
205217

206218
void processMidi(MidiMessage msg){
@@ -210,8 +222,15 @@ class GenPatch : public Patch {
210222
void processAudio(AudioBuffer &buffer) {
211223
for(int i=0; i<param_count; ++i)
212224
params[i]->update(this, context);
213-
float* outputs[] = {buffer.getSamples(0), buffer.getSamples(1) };
214-
gen::perform(context, outputs, 2, outputs, 2, buffer.getSize());
225+
size_t channels = buffer.getChannels();
226+
size_t ch;
227+
for(ch=0; ch<channels; ++ch)
228+
buffers[ch] = buffer.getSamples(ch);
229+
gen::perform(context, buffers, channels, buffers, gen::num_outputs(), buffer.getSize());
230+
for(int ch=channels; ch<gen::num_outputs(); ++ch){
231+
float avg = FloatArray(buffers[ch], buffer.getSize()).getMean();
232+
setParameterValue((PatchParameterId)(PARAMETER_F+(ch-channels)), avg);
233+
}
215234
}
216235
};
217236

LibSource/FloatArray.cpp

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -410,11 +410,8 @@ void FloatArray::noise(){
410410
void FloatArray::noise(float min, float max){
411411
float amplitude = fabsf(max-min);
412412
float offset = min;
413-
ASSERT(getSize()>10, "10<getSize");
414-
ASSERT(size==getSize(), "getSize");
415-
for(size_t n=0; n<size; n++){
416-
data[n]=(rand()/(RAND_MAX+1.0f)) * amplitude + offset;
417-
}
413+
for(size_t n=0; n<size; n++)
414+
data[n] = randf() * amplitude + offset;
418415
}
419416

420417

LibSource/MidiStatus.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ enum MidiStatus {
1818
RESERVED_F4 = 0xF4,
1919
RESERVED_F5 = 0xF5,
2020
TUNE_REQUEST = 0xF6,
21-
SYSEX_EOX = 0xF7,
21+
SYSEX_EOX = 0xF7,
2222
SYSTEM_REAL_TIME = 0xF8,
2323
TIMING_CLOCK = 0xF8,
2424
RESERVED_F9 = 0xF9,

LibSource/NoiseOscillator.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ class WhiteNoiseOscillator : public Oscillator {
2424
// https://en.wikipedia.org/wiki/Single-precision_floating-point_format
2525
return x.f;
2626
#else
27-
return (rand()/(RAND_MAX+1.0f)) * 2 - 1;
27+
return (rand()/(float)RAND_MAX) * 2 - 1;
2828
#endif
2929
}
3030

LibSource/Patch.cpp

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "PatchProcessor.h"
77
#include "basicmaths.h"
88
#include "main.h"
9+
#include "message.h"
910

1011
AudioBuffer::~AudioBuffer(){}
1112

@@ -28,6 +29,13 @@ int Patch::getBlockSize(){
2829
return getProgramVector()->audio_blocksize;
2930
}
3031

32+
int Patch::getNumberOfChannels(){
33+
uint8_t format = getProgramVector()->audio_format;
34+
if((format & 0xf0) == AUDIO_FORMAT_24B32 && (format & 0x0f) > 0)
35+
return format & 0x0f;
36+
return 2;
37+
}
38+
3139
float Patch::getParameterValue(PatchParameterId pid){
3240
// return getInitialisingPatchProcessor()->getParameterValue(pid);
3341
// if(pid < getProgramVector()->parameters_size)
@@ -84,6 +92,13 @@ void Patch::sendMidi(MidiMessage msg){
8492

8593
#endif /* USE_MIDI_CALLBACK */
8694

95+
Resource* Patch::getResource(const char* name){
96+
Resource* resource = Resource::load(name);
97+
if(resource == NULL)
98+
error(CONFIGURATION_ERROR_STATUS, "Missing Resource");
99+
return resource;
100+
}
101+
87102
#include "MemoryBuffer.hpp"
88103
AudioBuffer* AudioBuffer::create(int channels, int samples){
89104
return new ManagedMemoryBuffer(channels, samples);

LibSource/Patch.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
#include "device.h"
55
#include "basicmaths.h"
6+
#include "Resource.h"
67
#include "FloatArray.h"
78
#include "PatchParameter.h"
89
#include "SmoothValue.h"
@@ -57,6 +58,7 @@ class Patch {
5758
int getSamplesSinceButtonPressed(PatchButtonId bid);
5859
void setButton(PatchButtonId bid, uint16_t value, uint16_t samples=0);
5960
int getBlockSize();
61+
int getNumberOfChannels();
6062
float getSampleRate();
6163
AudioBuffer* createMemoryBuffer(int channels, int samples);
6264
float getElapsedBlockTime();
@@ -69,6 +71,12 @@ class Patch {
6971
virtual void processMidi(MidiMessage msg);
7072
virtual void sendMidi(MidiMessage msg);
7173
#endif /* USE_MIDI_CALLBACK */
74+
/**
75+
* Get a resource (such as a stored FloatArray) from the firmware.
76+
* If the resource does not exist, this raises an error.
77+
* If the resource exists but is not memory mapped, this will allocate new memory.
78+
*/
79+
Resource* getResource(const char* name);
7280
};
7381

7482
#endif // __Patch_h__

LibSource/PitchDetector.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class FourierPitchDetector{
4747
int getSize(){
4848
return fft.getSize();
4949
}
50-
void setsamplingRate(float asamplingRate){
50+
void setSamplingRate(float asamplingRate){
5151
samplingRate=asamplingRate;
5252
}
5353
void setMinFrequency(float aMinFrequency){

0 commit comments

Comments
 (0)