Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ core:
teletype:
+$(MAKE) -f scripts/teletype.mk

example:
+$(MAKE) -f scripts/example.mk

core-clean:
+$(MAKE) -f scripts/core.mk clean

Expand All @@ -60,15 +63,15 @@ pbl-clean:
+$(MAKE) -f scripts/pbl.mk clean

emu:
+$(MAKE) -f scripts/lua.mk ARCH=linux
+$(MAKE) -f scripts/miniz.mk ARCH=linux
+$(MAKE) -f scripts/lodepng.mk ARCH=linux
+$(MAKE) -f scripts/lua.mk
+$(MAKE) -f scripts/miniz.mk
+$(MAKE) -f scripts/lodepng.mk
+$(MAKE) -f scripts/emu.mk

emu-clean:
+$(MAKE) -f scripts/lua.mk ARCH=linux clean
+$(MAKE) -f scripts/miniz.mk ARCH=linux clean
+$(MAKE) -f scripts/lodepng.mk ARCH=linux clean
+$(MAKE) -f scripts/lua.mk clean
+$(MAKE) -f scripts/miniz.mk clean
+$(MAKE) -f scripts/lodepng.mk clean
+$(MAKE) -f scripts/emu.mk clean

dist-clean:
Expand Down
17 changes: 6 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ Edit this file with your own values to configure various items like key mappings
Packages encapsulate unit presets (*.unit), unit definitions (*.lua), and shared libraries (*.so) into one shareable bundle along with any necessary assets (e.g. sound files and so on). The core units are also distributed as a package, so let's use the core package as an example. First, to compile and create the core package, execute:

```bash
make core ARCH=linux
make core
```

Next, let's go over the two main methods for installing packages.
Expand Down Expand Up @@ -188,7 +188,7 @@ First, you will need to install the TI-RTOS development tools for the AM335x.
4. ***When asked, please set the destination folder to ```~/ti```.*** This is the path assumed by the project makefiles. If instead you install to a different folder then before executing any cross-compilation commands, you will need to set the TI_INSTALL_DIR shell environment variable to the actual path that you used. If you don't want to change your shell environment then you can also pass the path on the commandline like this:

```bash
make core TI_INSTALL_DIR=~/your-path-to-ti-sdk
make core TI_INSTALL_DIR=~/your-path-to-ti-sdk ARCH=am355x
```

This documentation will assume that you used the default location.
Expand All @@ -206,7 +206,7 @@ sudo apt install swig python3 zip gcc-multilib
A good test of your build environment is to see if you can successfully build the factory mods:

```bash
make core teletype
make core teletype ARCH=am355x
```

## USB Functions
Expand All @@ -223,21 +223,16 @@ All build outputs are placed in a sub folder composed of the build profile and t
* debug: No optimizations. Logging enabled.
* release: All optimizations enabled. Logging disabled.

And here are the 2 supported target architectures:
And here are the 3 supported target architectures:

* am335x
* linux
* darwin (OSX)

So for example, if I execute the following make command:

```bash
make core PROFILE=debug ARCH=linux
```

Then the build outputs will be placed in the ```debug/linux``` directory of the project root. Generally, the default profile is **testing** and the default architecture for everything except the emulator is **am335x**. So if you execute just:

```bash
make core
```

Then the build outputs will appear in the ```testing/am335x``` directory of the project root. See the [top-level Makefile](Makefile) for more details.
Then the build outputs will be placed in the ```debug/linux``` directory of the project root. Generally, the default profile is **testing** and the default architecture is determined by your OS (`uname -s`). See the [top-level Makefile](Makefile) for more details.
7 changes: 4 additions & 3 deletions arch/linux/hal/fileops.c
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#include <hal/fileops.h>
#include <sys/stat.h>
#include <sys/statfs.h>
#include <sys/param.h>
#include <sys/mount.h>
#include <unistd.h>
#include <fcntl.h>
#include <errno.h>
Expand Down Expand Up @@ -155,7 +156,7 @@ int diskFreeSpaceMB(const char *path)
struct statfs fsinfo;
if (statfs(path, &fsinfo) == 0)
{
uint64_t bytes = fsinfo.f_frsize * fsinfo.f_blocks;
uint64_t bytes = fsinfo.f_bsize * fsinfo.f_blocks;
return (int)(bytes / 1024 / 1024);
}
return 0;
Expand All @@ -166,7 +167,7 @@ int diskTotalSpaceMB(const char *path)
struct statfs fsinfo;
if (statfs(path, &fsinfo) == 0)
{
uint64_t bytes = fsinfo.f_frsize * fsinfo.f_bavail;
uint64_t bytes = fsinfo.f_bsize * fsinfo.f_bavail;
return (int)(bytes / 1024 / 1024);
}
return 0;
Expand Down
4 changes: 2 additions & 2 deletions hal/pump/rfifo4.c
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#include <hal/log.h>
#include <hal/constants.h>
#include "rfifo4.h"
#include <malloc.h>
#include <stdlib.h>

void rfifo4_alloc(rfifo4_t *fifo, int length)
{
Expand All @@ -10,7 +10,7 @@ void rfifo4_alloc(rfifo4_t *fifo, int length)
fifo->wpos = 0;
fifo->numread = length;
int bytes = length * 2 * sizeof(float32x4_t);
fifo->buffer = (float32x4_t *)memalign(CACHELINE_SIZE_MAX, bytes);
posix_memalign((void **)&fifo->buffer, CACHELINE_SIZE_MAX, bytes);
logAssert(fifo->buffer);
bzero(fifo->buffer, bytes);
fifo->length = length;
Expand Down
88 changes: 88 additions & 0 deletions mods/example/AR.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
#include <example/AR.h>
#include <od/extras/LookupTables.h>
#include <od/constants.h>
#include <od/config.h>
#include <hal/ops.h>

namespace example {

AR::AR() {
addInput(mGateInput);
addInput(mLoopInput);
addInput(mAttack);
addInput(mRelease);
addOutput(mOutput);

mAttackStage = &od::LookupTables::ConcaveParabolicRise;
mReleaseStage = &od::LookupTables::ConcaveParabolicFall;
}

AR::~AR() { }

void AR::process() {
float *gate = mGateInput.buffer();
float *loop = mLoopInput.buffer();
float *attack = mAttack.buffer();
float *release = mRelease.buffer();
float *out = mOutput.buffer();

mAttackPhaseChange = globalConfig.samplePeriod / MAX(0.0001f, attack[0]);
mReleasePhaseChange = globalConfig.samplePeriod / MAX(0.0001f, release[0]);

for (int i = 0; i < FRAMELENGTH; i++) {
out[i] = next(gate[i], loop[i]);
}
}

inline float AR::next(float currentGate, float currentLoop) {
switch (mStage) {
case 0:
if (currentGate > 0.5f || currentLoop > 0.5f) {
mStage = 1;
mPhase = 0.0f;
mCapture = mCurrentValue;
}
break;

case 1:
mPhase += mAttackPhaseChange;
if (mPhase < 1.0f) {
mCurrentValue = mCapture + (1.0f - mCapture) * mAttackStage->get(mPhase);
} else {
mCapture = mCurrentValue;
mPhase = 0.0f;
mStage = 2;
}
break;

case 2:
mCurrentValue = 1.0f;
if (currentGate < 0.5f) {
mCapture = mCurrentValue;
mPhase = 0.0f;
mStage = 3;
}
break;

case 3:
mPhase += mReleasePhaseChange;
if (mPhase < 1.0f) {
mCurrentValue = mCapture * mReleaseStage->get(mPhase);
} else {
mCapture = 0.0f;
mPhase = 0.0f;
mStage = 0;

// Force to zero, possible discontinuity
mCurrentValue = 0.0f;

if (currentLoop > 0.5f) {
mStage = 1;
}
}
break;
}

return mCurrentValue;
}
}
35 changes: 35 additions & 0 deletions mods/example/AR.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
#pragma once

#include <od/extras/LookupTable.h>
#include <od/objects/Object.h>

namespace example {
class AR : public od::Object {
public:
AR();
virtual ~AR();

#ifndef SWIGLUA
virtual void process();
od::Inlet mGateInput{"Gate"};
od::Inlet mLoopInput{"Loop"};
od::Inlet mAttack{"Attack"};
od::Inlet mRelease{"Release"};
od::Outlet mOutput{"Out"};
#endif

private:
float next(float currentGate, float currentLoop);

int mStage = 0;

float mPhase = 0.0f;
float mCapture = 0.0f;
float mAttackPhaseChange = 0.0f;
float mReleasePhaseChange = 0.0f;
float mCurrentValue = 0.0f;

od::LookupTable *mAttackStage = NULL;
od::LookupTable *mReleaseStage = NULL;
};
}
110 changes: 110 additions & 0 deletions mods/example/assets/AR.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
local app = app
local libexample = require "example.libexample"
local Class = require "Base.Class"
local Unit = require "Unit"
local GainBias = require "Unit.ViewControl.GainBias"
local InputGate = require "Unit.ViewControl.InputGate"
local Gate = require "Unit.ViewControl.Gate"
local Encoder = require "Encoder"

local AR = Class {}
AR:include(Unit)

function AR:init(args)
args.title = "AR"
args.mnemonic = "En"
Unit.init(self, args)
end

function AR:onLoadGraph(channelCount)
if channelCount == 2 then
self:loadStereoGraph()
else
self:loadMonoGraph()
end
end

function AR:loadMonoGraph()
local gate = self:addObject("gate", app.Comparator())
gate:setGateMode()
local loop = self:addObject("loop", app.Comparator())
loop:setToggleMode()
local ar = self:addObject("ar", libexample.AR())
local attack = self:addObject("attack", app.GainBias())
local release = self:addObject("release", app.GainBias())
local attackRange = self:addObject("attackRange", app.MinMax())
local releaseRange = self:addObject("releaseRange", app.MinMax())

connect(self, "In1", gate, "In")
connect(gate, "Out", ar, "Gate")
connect(loop, "Out", ar, "Loop")
connect(ar, "Out", self, "Out1")

connect(attack, "Out", ar, "Attack")
connect(release, "Out", ar, "Release")

connect(attack, "Out", attackRange, "In")
connect(release, "Out", releaseRange, "In")

self:addMonoBranch("loop", loop, "In", loop, "Out")
self:addMonoBranch("attack", attack, "In", attack, "Out")
self:addMonoBranch("release", release, "In", release, "Out")
end

function AR:loadStereoGraph()
self:loadMonoGraph()
connect(self.objects.ar, "Out", self, "Out2")
end

local views = {
expanded = {
"input",
"loop",
"attack",
"release"
},
collapsed = {}
}

function AR:onLoadViews(objects, branches)
local controls = {}

controls.input = InputGate {
button = "input",
description = "Unit Input",
comparator = objects.gate
}

controls.loop = Gate {
button = "loop",
description = "Loop",
branch = branches.loop,
comparator = objects.loop
}

controls.attack = GainBias {
button = "A",
branch = branches.attack,
description = "Attack",
gainbias = objects.attack,
range = objects.attackRange,
biasMap = Encoder.getMap("ADSR"),
biasUnits = app.unitSecs,
initialBias = 0.050
}

controls.release = GainBias {
button = "R",
branch = branches.release,
description = "Release",
gainbias = objects.release,
range = objects.releaseRange,
biasMap = Encoder.getMap("ADSR"),
biasUnits = app.unitSecs,
initialBias = 0.100
}

return controls, views
end

return AR
13 changes: 13 additions & 0 deletions mods/example/assets/toc.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
return {
title = "Example Library",
author = "tomf",
name = "example",
keyword = "",
units = {
{
title = "AR",
moduleName = "AR",
keywords = ""
}
}
}
14 changes: 14 additions & 0 deletions mods/example/example.cpp.swig
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
%module example_libexample
%include <od/glue/mod.cpp.swig>

%{

#undef SWIGLUA

#include <example/AR.h>

#define SWIGLUA

%}

%include <example/AR.h>
Loading