Skip to content

Commit

Permalink
Merge pull request #87 from pingdynasty/develop
Browse files Browse the repository at this point in the history
OwlProgram v21.1
  • Loading branch information
pingdynasty authored Feb 16, 2021
2 parents 3b7a82d + 685aa71 commit b71d248
Show file tree
Hide file tree
Showing 23 changed files with 643 additions and 2,922 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/c-cpp.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ jobs:
- name: Setup arm-none-eabi-gcc
uses: fiam/arm-none-eabi-gcc@v1
with:
release: '9-2020-q2' # The arm-none-eabi-gcc release to use.
release: '10-2020-q4'
- name: Setup emsdk
uses: mymindstorm/setup-emsdk@v7
with:
Expand Down
4 changes: 4 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
[submodule "Libraries/DaisySP"]
path = Libraries/DaisySP
url = https://github.com/electro-smith/DaisySP.git
branch = master
49 changes: 28 additions & 21 deletions FaustCode/owl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
#include "Patch.h"
#include "VoltsPerOctave.h"

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

static float fFreq, fGain, fGate;
static float fKey, fFreq, fGain, fGate;
static float fBend = 1.0f;

class MonoVoiceAllocator {
float& key;
float& freq;
float& gain;
float& gate;
Expand All @@ -66,8 +67,9 @@ class MonoVoiceAllocator {
uint8_t lastNote = 0;

public:
MonoVoiceAllocator(float& fq, float& gn, float& gt, float& bd)
: freq(fq)
MonoVoiceAllocator(float& ky, float& fq, float& gn, float& gt, float& bd)
: key(ky)
, freq(fq)
, gain(gn)
, gate(gt)
, bend(bd) {
Expand Down Expand Up @@ -114,6 +116,7 @@ class MonoVoiceAllocator {
void noteOn(uint8_t note, uint16_t velocity, uint16_t delay) {
if (lastNote < 16)
notes[lastNote++] = note;
key = note;
freq = noteToHz(note);
gain = velocityToGain(velocity);
gate = 1.0f;
Expand All @@ -130,11 +133,12 @@ class MonoVoiceAllocator {
notes[i] = notes[i + 1];
i++;
}
freq = noteToHz(notes[lastNote - 1]);
key = notes[lastNote - 1];
freq = noteToHz(key);
}
else {
gate = 0.0f;
lastNote = 0;
lastNote = 0;
}
}
void allNotesOff() {
Expand All @@ -153,8 +157,7 @@ enum ParserState {
* To enable MIDI in current patch, add this to source Faust file:
* declare options "[midi:on]";
*
* You can also add descrpiption to be displayed with debugMessage function like
* this:
* You can also add a description to be displayed like this:
* declare message "Hello World";
*
* To add V/Oct scaling support, use something likes this:
Expand Down Expand Up @@ -251,8 +254,8 @@ class MetaData : public Meta {

/**************************************************************************************
*
* OwlParameter : object used by OwlUI to ensures the connection between an Owl
* parameter and a Faust widget
* OwlParameter : object used by OwlUI to ensures the connection between an OWL
* parameter and a FAUST widget
*
***************************************************************************************/

Expand Down Expand Up @@ -349,8 +352,8 @@ class OwlButton : public OwlParameterBase {
* OwlUI : Faust User Interface builder. Passed to buildUserInterface OwlU
* ensures the mapping between owl parameters and faust widgets. It relies on
* specific metadata "...[OWL:PARAMETER_X]..." in widget's label for that. For
* example any faust widget with metadata [OWL:PARAMETER_B] will be controlled
* by PARAMETER_B (the second knob).
* example any faust widget with metadata [OWL:B] will be controlled by
* PARAMETER_B (the second knob).
*
***************************************************************************************/

Expand All @@ -359,7 +362,7 @@ class OwlButton : public OwlParameterBase {
#define NO_PARAMETER ((PatchParameterId)-1)
#define NO_BUTTON ((PatchButtonId)-1)

MonoVoiceAllocator allocator(fFreq, fGain, fGate, fBend);
MonoVoiceAllocator allocator(fKey, fFreq, fGain, fGate, fBend);
VoltsPerOctave* fVOctInput;
VoltsPerOctave* fVOctOutput;

Expand All @@ -385,6 +388,10 @@ class OwlUI : public UI {
fParameterTable[fParameterIndex++] =
new OwlVariable(fPatch, &fBend, zone, label, init, lo, hi);
}
else if (meta.midiOn && strcasecmp(label, "key") == 0) {
fParameterTable[fParameterIndex++] =
new OwlVariable(fPatch, &fKey, zone, label, init, lo, hi);
}
else if (fParameter != NO_PARAMETER) {
fParameterTable[fParameterIndex++] =
new OwlParameter(fPatch, fParameter, zone, label, init, lo, hi);
Expand Down Expand Up @@ -451,7 +458,7 @@ class OwlUI : public UI {
delete fVOctOutput;
}

// should be called before compute() to update widget's zones registered as Owl parameters
// should be called before compute() to update widget's zones registered as OWL parameters
void update() {
for (int i = 0; i < fParameterIndex; i++)
fParameterTable[i]->update();
Expand Down Expand Up @@ -513,7 +520,6 @@ class OwlUI : public UI {
if (strcasecmp(k, "OWL") == 0) {
if (strncasecmp(id, "PARAMETER_", 10) == 0)
id += 10;

if (strlen(id) == 1) {
// Single char parameter name.
// Note that we can use I - P as aliases for AA-AH.
Expand Down Expand Up @@ -581,12 +587,13 @@ class OwlUI : public UI {
else if (strcasecmp(id, "PUSH") == 0)
fButton = PUSHBUTTON;
}
else if (strcasecmp(k, "midi") == 0) {
// todo!
// if (strcasecmp(id,"pitchwheel") == 0) fParameter = PARAMETER_G;
// // mapped to pitch wheel declare(&fHslider1, "midi",
// "pitchwheel"); declare(&fButton1, "midi", "ctrl 64");
}
// else if (strcasecmp(k, "midi") == 0) {
// if (strcasecmp(id, "pitchwheel") == 0){ // PB
// }else if (strcasecmp(id, "ctrl") == 0){ // CC
// }else if (strcasecmp(id, "chanpress") == 0){ // AT
// }else if (strcasecmp(id, "pgm") == 0){ // PC
// }
// }
}

// -- V/Oct
Expand Down
22 changes: 22 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
v21.1
-----

* SOUL integration
* Maximilian integration
* DaisySP integration
* Added FAUST 'key' MIDI parameter (complements 'freq', 'gain', 'gate' and 'bend')
* Added StateVariableFilter DSP class
* Fixed Bus Error regression on legacy hardware
* Automatically zero-initialise all heap allocations

v21.0
-----

* Matches release v21.0 of OpenWare
* Add support for patch resources

Prehistory
-----------

A wise old OWL sat in an oak

2 changes: 1 addition & 1 deletion LibSource/ComplexShortArray.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ void ComplexShortArray::complexByComplexMultiplication(ComplexShortArray operand
#ifdef ARM_CORTEX
arm_cmplx_mult_cmplx_q15((int16_t*)getData(), (int16_t*)operand2.getData(), (int16_t*)result.getData(), size );
#else
assert(false, "TODO");
ASSERT(false, "TODO");
float *pSrcA=(float*)data;
float *pSrcB=(float*)operand2;
float *pDst=(float*)result;
Expand Down
4 changes: 2 additions & 2 deletions LibSource/Resource.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ class Resource {
~Resource(){}
protected:
Resource(const char* name, size_t size, void* data)
: name(name), size(size), data((uint8_t*)data) {}
: name(name), size(size), data((uint8_t*)data), allocated(false) {}
const char* name;
uint8_t* data;
size_t size;
uint8_t* data;
bool allocated;
};
#endif
6 changes: 3 additions & 3 deletions LibSource/ScreenBuffer.h
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,6 @@
#include "device.h"
#include "message.h"

#ifndef swap
#define swap(a, b) { int t = a; a = b; b = t; }
#endif

template<typename Colour, Colour BLACK, Colour WHITE>
class ScreenBuffer {
Expand All @@ -22,6 +19,9 @@ class ScreenBuffer {
uint16_t textcolor;
uint16_t textbgcolor;
bool wrap;

inline void swap(int& a, int& b) { int t = a; a = b; b = t; };

public:
ScreenBuffer(uint16_t w, uint16_t h) :
width(w), height(h), pixels(NULL),
Expand Down
2 changes: 1 addition & 1 deletion LibSource/ShortFastFourierTransform.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ ShortFastFourierTransform::ShortFastFourierTransform(int aSize){
}

ShortFastFourierTransform::~ShortFastFourierTransform(){
assert(false, "TODO");
ASSERT(false, "TODO");
ComplexShortArray::destroy(temp);
}

Expand Down
Loading

0 comments on commit b71d248

Please sign in to comment.