Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New plugin: BFold (was: Timbre) (wavefolder) #238

Open
wants to merge 21 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
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
41 changes: 26 additions & 15 deletions .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,8 @@ install:
- cmd: git submodule update --init --recursive

- cmd: echo "Get SuperCollider"
- cmd: git clone --recursive --depth 1 https://github.com/supercollider/supercollider ../supercollider
# can shallow clone, no submodules needed (no supernova)
- cmd: git clone --depth 1 https://github.com/supercollider/supercollider ../supercollider

# FFTW3, including lib prep
- cmd: echo "Install fftw"
Expand All @@ -54,21 +55,31 @@ before_build:
- cd build

build_script:
- cmake -G "%CMAKE_GENERATOR%" -DSC_PATH=../../supercollider -DFFTW3F_INCLUDE_DIR=../fftw -DFFTW3F_LIBRARY=../fftw/libfftw3f-3.lib ..
- cmake -G "%CMAKE_GENERATOR%" -DSC_PATH=../../supercollider -DFFTW3F_INCLUDE_DIR=../fftw -DFFTW3F_LIBRARY=../fftw/libfftw3f-3.lib -DCMAKE_INSTALL_PREFIX="%APPVEYOR_BUILD_FOLDER%/build/install" ..
- cmake --build . --target install --config %CMAKE_CONFIGURATION%

# TODO
# artifacts:
# - path: artifacts
# name: art_folder
after_build:
# create archive name; either the version (if tagged) or commit hash
- ps: |
if (Test-Path env:APPVEYOR_REPO_TAG_NAME) {
$env:VERSION_SLUG=$env:APPVEYOR_REPO_TAG_NAME | % { $_ -replace "Version-","" }
$env:ZIP_NAME="sc3-plugins-$env:VERSION_SLUG-Windows-$env:ARCH-VS.zip"
} else {
$env:ZIP_NAME="sc3-plugins-$env:APPVEYOR_REPO_COMMIT-Windows-$env:ARCH-VS.zip"
}
- ps: 7z a -mx7 $env:ZIP_NAME install

artifacts:
- path: build/%ZIP_NAME%
name: Plugins

# TODO
# github releases - only tags
# - provider: GitHub
# description: appveyor_$(APPVEYOR_REPO_TAG_NAME)
# artifact: installer
# auth_token:
# secure: rxXJNY+6n25Th9R4+7qI+AcnTj0wCAMSnBGH2+5s7DlVLrAGsSY6+EEDbeHWGGeI
# prerelease: true
# on:
# appveyor_repo_tag: true
deploy:
- provider: GitHub
description: appveyor_$(APPVEYOR_REPO_TAG_NAME)
artifact: Plugins
auth_token:
secure: 4uMFrJ2Vc3ju6OtWpQ9chRce/2JHNhfy/sjX+w+KFTNDvmSPD5CqdEuwFp/+Ln/s
prerelease: true
on:
appveyor_repo_tag: true
38 changes: 19 additions & 19 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,33 +1,34 @@
language: objective-c
language: cpp

os:
- osx
matrix:
fast_finish: true
include:
- os: linux
sudo: required
dist: trusty
- os: osx

cache:
- ccache
- apt
- bundler

before_install:
- ifmac () { if [[ $TRAVIS_OS_NAME == osx ]]; then eval $@; fi; }
- iflin () { if [[ $TRAVIS_OS_NAME == linux ]]; then eval $@; fi; }
- ifmac brew install cmake || true
- iflin sudo add-apt-repository -y ppa:ubuntu-toolchain-r/test
- iflin sudo add-apt-repository -y ppa:andykimpe/cmake # backport of cmake 2.8.12
- iflin sudo add-apt-repository -y ppa:ondrej/php5 # libicu-dev 52
- iflin sudo apt-get update
- iflin sudo apt-get install libicu-dev=52.1-1+debphp.org~precise+1 gcc-4.7 g++-4.7 aptitude build-essential libfftw3-dev libxt-dev pkg-config cmake=2.8.12.2-3 libstdc++5
- iflin sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.6 40 --slave /usr/bin/g++ g++ /usr/bin/g++-4.6
- iflin sudo update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-4.7 60 --slave /usr/bin/g++ g++ /usr/bin/g++-4.7
- iflin sudo update-alternatives --auto gcc
- git clone https://github.com/supercollider/supercollider.git
- iflin sudo apt-get install libicu-dev libfftw3-dev libxt-dev pkg-config libstdc++5
- git clone --depth 1 https://github.com/supercollider/supercollider.git
- cd supercollider
- git submodule update --init --depth 1 external_libraries/nova-tt external_libraries/nova-simd
- cd ..

before_script:
- mkdir BUILD
- cd BUILD
- cmake -DCMAKE_INSTALL_PREFIX:PATH=$PWD/SC3plugins -DCMAKE_BUILD_TYPE=Release -DSC_PATH=../supercollider ..
- mkdir BUILD && cd BUILD
- cmake -DCMAKE_INSTALL_PREFIX:PATH=$PWD/SC3plugins -DCMAKE_BUILD_TYPE=Release -DSC_PATH=../supercollider -DSUPERNOVA=ON ..

script:
- make install
- iflin make -j
- ifmac make install
- ifmac mkdir -p $HOME/artifacts
- ifmac zip -q -r $HOME/artifacts/Plugins-$TRAVIS_COMMIT.zip SC3plugins

Expand Down Expand Up @@ -69,10 +70,9 @@ deploy:
condition: $TRAVIS_OS_NAME = osx && ! -z $GITHUB_KEY
tags: true
all_branches: true
after-deploy:
after_deploy:
- "echo S3 Build Location: $S3_URL"


notifications:
on_success: change
on_failure: change
Expand Down
3 changes: 1 addition & 2 deletions source/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@ if (SUPERNOVA)
include_directories(${SC_PATH}/external_libraries/nova-tt)
# actually just boost.atomic
include_directories(${SC_PATH}/external_libraries/boost)
include_directories(${SC_PATH}/external_libraries/boost_lockfree)
include_directories(${SC_PATH}/external_libraries/boost-lockfree)
endif()

include_directories(${CMAKE_SOURCE_DIR}/include/)
Expand Down Expand Up @@ -106,6 +104,7 @@ set(PLUGIN_DIRS
SLUGens
SummerUGens
TagSystemUGens
VAfxUGens
VBAPUGens
VOSIMUGens
)
Expand Down
6 changes: 3 additions & 3 deletions source/DWGUGens/sc/HelpSource/Classes/DWGPluckedStiff.schelp
Original file line number Diff line number Diff line change
Expand Up @@ -47,10 +47,10 @@ Examples::
code::
//Define pluck synthdef
(
SynthDef(\help_dwgpluckedstiff, { |out=0, freq=440, amp=0.5, gate=1, c3=20, pan=0,fB = 80|
SynthDef(\help_dwgpluckedstiff, { |out=0, freq=440, amp=0.5, gate=1, c3=20, pan=0, rel=1, fB = 80|
var env = Env.new([0,1, 1, 0],[0.001,0.006, 0.0005],[5,-5, -8]);
var inp = amp * LFClipNoise.ar(2000) * EnvGen.ar(env,gate);
var son = DWGPluckedStiff.ar(freq, amp, gate,0.1,1,c3,inp,fB);
var son = DWGPluckedStiff.ar(freq, amp, gate,0.1,1,c3,inp,rel,fB);
DetectSilence.ar(son, 0.001, doneAction:2);
Out.ar(out, Pan2.ar(son * 0.1, pan));
}).add;
Expand All @@ -69,7 +69,7 @@ Pbind(
\instrument, \help_dwgpluckedstiff,
\scale ,a,
\delta , Pseq([1,0.5,0.5,0.5,0.5,0.5,0.5,1,0.5,0.5,1,1]*0.25,inf),
\dur , 2,
\dur , 0.9,
\degree, Pseq([1,8,8,8,8,8,8,-6,Prand([9,10,11],1),1,7,8]-8, inf),
\amp , Pwhite(0.2,0.8),
\c3 , Pseq([Pseq([1400],24),Pseq([300],24)],inf),
Expand Down
1 change: 0 additions & 1 deletion source/StkInst/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,6 @@ if(SUPERNOVA)
endif()
set_property(TARGET ${PROJECT}_supernova APPEND PROPERTY COMPILE_DEFINITIONS "SUPERNOVA")
include_directories(${SC_PATH}/external_libraries
${SC_PATH}/external_libraries/boost-lockfree
${SC_PATH}/external_libraries/nova-simd
${SC_PATH}/external_libraries/nova-tt
)
Expand Down
96 changes: 96 additions & 0 deletions source/VAfxUGens/BFold.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#include "SC_PlugIn.hpp"
#include <math.h>

// InterfaceTable contains pointers to functions in the host (server).
static InterfaceTable *ft;

// declare struct to hold unit generator state
struct BFold : public SCUnit{

// Constructor usually does 3 things.
// 1. set the calculation function.
// 2. initialize the unit generator state variables.
// 3. calculate one sample of output.
public:
BFold() {
// 1. set the calculation function.
set_calc_function<BFold,&BFold::next>();

// 3. calculate one sample of output.
next(1);

}

private:
// The calculation function executes once per control period
// which is typically 64 samples.

// calculation function for an audio rate frequency argument
void next(int inNumSamples)
{
// get the pointer to the output buffer
float *outBuf = out(0);

// get the pointer to the input buffer
const float *sig = in(0);
const float *fold = in(1);
const float offset = in0(2);

// perform a loop for the number of samples in the control period.
// If this unit is audio rate then inNumSamples will be 64 or whatever
// the block size is. If this unit is control rate then inNumSamples will
// be 1.
for (int i=0; i < inNumSamples; ++i)
{
float sgn;
float sigNorm;
float sigAbs;
float fold1 = 0.f;
float fold2 = 0.f;
float fold3 = 0.f;
float fold4 = 0.f;
float fold5 = 0.f;

sigNorm = offset*0.6 + (fold[i]*5.4 +0.6)*sig[i];
// sigNorm = 0.5 + 2.f*sig[i]*0.6;
sigAbs = fabs(sigNorm);
sgn = copysignf(1.0, sig[i]);

if (sigAbs >= 0.6) {
fold1 = 0.8333*sigNorm - 0.5*sgn;
fold1 *= -12.f;
if (sigAbs >= 1.8) {
fold2 = 0.5743*sigNorm - 1.0338*sgn;
fold2 *= 17.647;
if (sigAbs >= 2.994) {
fold3 = 0.3768*sigNorm - 1.1281*sgn;
fold3 *= -27.777;
if (sigAbs >= 4.08) {
fold4 = 0.2673*sigNorm - 1.0907*sgn;
fold4 *= 36.363;
if (sigAbs >= 5.46) {
fold5 = 0.2829*sigNorm - 1.5446*sgn;
fold5 *= -21.438;
}
}
}
}
}
// out must be written last for in place operation
outBuf[i] = (fold1 + fold2 + fold3 + fold4 + fold5 + 5.f * sigNorm)/3.f;
}
}

};

// the entry point is called by the host when the plug-in is loaded
PluginLoad(VAfxUGens)
{
// InterfaceTable *inTable implicitly given as argument to the load function
ft = inTable; // store pointer to InterfaceTable

// registerUnit takes the place of the Define*Unit functions. It automatically checks for the presence of a
// destructor function.
// However, it does not seem to be possible to disable buffer aliasing with the C++ header.
registerUnit<BFold>(ft, "BFold");
}
14 changes: 14 additions & 0 deletions source/VAfxUGens/sc/BFold.sc
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
BFold : UGen {
*ar { arg in, fold=0.0, offset=0.0;
^this.multiNew('audio', in, fold, offset)
}
patrickdupuis marked this conversation as resolved.
Show resolved Hide resolved
checkInputs {
[0, 1].do { |i|
(inputs[i].rate != 'audio').if {
^(" input at index " + i + "(" + inputs.at(i) +
") is not audio rate");
};
};
^this.checkValidInputs;
}
}
28 changes: 28 additions & 0 deletions source/VAfxUGens/sc/HelpSource/Classes/BFold.schelp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
class:: BFold
summary:: Wavefolder virtual analog model
categories:: UGens>Filters

patrickdupuis marked this conversation as resolved.
Show resolved Hide resolved

Description::
A model of the "timbre" circuit of the Buchla 259 Complex Wave Generator. The model follows the circuit modelling as seen on the paper link::http://www.dafx17.eca.ed.ac.uk/papers/DAFx17_paper_82.pdf::, using 5 folds.


classmethods::

method::ar

argument::in
Input signal.

argument::fold
Folding amount (audio rate). Useful range: [0, ..]

argument::offset
Input offset (control rate). Useful range: [-1, 1].


Examples::

code::
{BFold.ar(SinOsc.ar(200), K2A.ar(MouseX.kr(0,3)), MouseY.kr(-1,1))}.scope
::