diff --git a/.gitmodules b/.gitmodules index d341a3721f..958a6d6af4 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "libs/nova-simd"] path = libs/nova-simd url = git://github.com/timblechmann/nova-simd.git +[submodule "source/StkInst/stk"] + path = source/StkInst/stk + url = https://github.com/thestk/stk.git diff --git a/source/CMakeLists.txt b/source/CMakeLists.txt index b65af85e2c..8ae8bbeb5c 100644 --- a/source/CMakeLists.txt +++ b/source/CMakeLists.txt @@ -120,6 +120,7 @@ set(PLUGIN_DIRS_EXTRA NCAnalysisUGens OteyPianoUGens PitchDetection + StkInst StkUGens TJUGens ) @@ -272,6 +273,30 @@ else() endif() endif() +# StkInst +file(GLOB STKinstSources "StkInst/stk/src/*.cpp") +file(GLOB UnneededSTKinstSources "StkInst/stk/src/Rt*.cpp" + "StkInst/stk/src/Inet*.cpp" + "StkInst/stk/src/Socket.cpp" + "StkInst/stk/src/Tcp*.cpp" + "StkInst/stk/src/UdpSocket.cpp" + "StkInst/stk/src/Thread.cpp" + "StkInst/stk/src/Mutex.cpp" +) +list(REMOVE_ITEM STKinstSources ${UnneededSTKinstSources}) +include_directories(StkInst/stk) +include_directories(StkInst/stk/include) +include_directories(StkInst/stk/src/include) + +include (${CMAKE_ROOT}/Modules/TestBigEndian.cmake) +add_definitions("-D_STK_DEBUG_") + +TEST_BIG_ENDIAN(is_big_endian) +if(NOT is_big_endian) + add_definitions("-D__LITTLE_ENDIAN__") +endif() + +BUILD_PLUGIN(StkInst "StkInst/StkInst.cpp;${STKinstSources}" "" "StkInst") # StkUGens file(GLOB STKSources "StkUGens/stk-4.4.2/src/*.cpp") file(GLOB UnneededSTKSources "StkUGens/stk-4.4.2/src/Rt*.cpp" @@ -288,6 +313,8 @@ include_directories(StkUGens/stk-4.4.2/include) include_directories(StkUGens/stk-4.4.2/src/include) BUILD_PLUGIN(StkUGens "StkUGens/StkAll.cpp;${STKSources}" "" "StkUGens") + + # NCAnalysisUGens file(GLOB NCAnalysisSources NCAnalysisUGens/*cpp) if(APPLE) diff --git a/source/StkInst/README.md b/source/StkInst/README.md new file mode 100644 index 0000000000..b8cdaf78c0 --- /dev/null +++ b/source/StkInst/README.md @@ -0,0 +1,2 @@ +# StkInst +Stk wraping for SC diff --git a/source/StkInst/StkInst.cpp b/source/StkInst/StkInst.cpp new file mode 100644 index 0000000000..d36730cc40 --- /dev/null +++ b/source/StkInst/StkInst.cpp @@ -0,0 +1,421 @@ +#include "SC_PlugIn.h" +InterfaceTable *ft; +World * gWorld; + +// STK Instrument Classes +#include "Clarinet.h" +#include "BlowHole.h" +#include "Saxofony.h" +#include "Flute.h" +#include "Brass.h" +#include "BlowBotl.h" +#include "Bowed.h" +#include "Plucked.h" +#include "StifKarp.h" +#include "Sitar.h" +#include "Mandolin.h" +#include "Rhodey.h" +#include "Wurley.h" +#include "TubeBell.h" +#include "HevyMetl.h" +#include "PercFlut.h" +#include "BeeThree.h" +#include "FMVoices.h" +#include "VoicForm.h" +#include "Moog.h" +#include "Simple.h" +#include "Drummer.h" +#include "BandedWG.h" +#include "Shakers.h" +#include "ModalBar.h" +#include "Mesh2D.h" +#include "Resonate.h" +#include "Whistle.h" + +/* +void* operator new (unsigned int size) +{ + void* ptr = RTAlloc(gWorld, size); + return ptr; +} +void operator delete(void* ptr) noexcept +{ + RTFree(gWorld, ptr); +} +*/ + +using namespace stk; + + +#define NUM_INSTS 28 + +// The order of the following list is important. The location of a particular +// instrument in the list should correspond to that instrument's ProgramChange +// number (i.e. Clarinet = ProgramChange 0). +char insts[NUM_INSTS][10] = { "Clarinet", "BlowHole", "Saxofony", "Flute", "Brass", + "BlowBotl", "Bowed", "Plucked", "StifKarp", "Sitar", "Mandolin", + "Rhodey", "Wurley", "TubeBell", "HevyMetl", "PercFlut", + "BeeThree", "FMVoices", "VoicForm", "Moog", "Simple", "Drummer", + "BandedWG", "Shakers", "ModalBar", "Mesh2D", "Resonate", "Whistle" }; +#define GETMEM(Inst) RTAlloc(gWorld, sizeof(Inst)) + +void * getmem(int number){ + + void *mem=0; + if (number==0) mem = GETMEM(Clarinet); + else if (number==1) mem = GETMEM(BlowHole); + else if (number==2) mem = GETMEM(Saxofony); + else if (number==3) mem = GETMEM(Flute); + else if (number==4) mem = GETMEM(Brass); + else if (number==5) mem = GETMEM(BlowBotl); + else if (number==6) mem = GETMEM(Bowed); + else if (number==7) mem = GETMEM(Plucked); + else if (number==8) mem = GETMEM(StifKarp); + else if (number==9) mem = GETMEM(Sitar); + else if (number==10) mem = GETMEM(Mandolin); + + else if (number==11) mem = GETMEM(Rhodey); + else if (number==12) mem = GETMEM(Wurley); + else if (number==13) mem = GETMEM(TubeBell); + else if (number==14) mem = GETMEM(HevyMetl); + else if (number==15) mem = GETMEM(PercFlut); + else if (number==16) mem = GETMEM(BeeThree); + else if (number==17) mem = GETMEM(FMVoices); + + else if (number==18) mem = GETMEM(VoicForm); + else if (number==19) mem = GETMEM(Moog); + else if (number==20) mem = GETMEM(Simple); + else if (number==21) mem = GETMEM(Drummer); + else if (number==22) mem = GETMEM(BandedWG); + else if (number==23) mem = GETMEM(Shakers); + else if (number==24) mem = GETMEM(ModalBar); + else if (number==25) mem = GETMEM(Mesh2D); + else if (number==26) mem = GETMEM(Resonate); + else if (number==27) mem = GETMEM(Whistle); + + return mem; +} +int voiceByNumber(int number, Instrmnt **instrument) +{ + int temp = number; + void *mem = getmem(number); + if (number==0) *instrument = new(mem) Clarinet(10.0); + else if (number==1) *instrument = new(mem) BlowHole(10.0); + else if (number==2) *instrument = new(mem) Saxofony(10.0); + else if (number==3) *instrument = new(mem) Flute(10.0); + else if (number==4) *instrument = new(mem) Brass(10.0); + else if (number==5) *instrument = new(mem) BlowBotl; + else if (number==6) *instrument = new(mem) Bowed(10.0); + else if (number==7) *instrument = new(mem) Plucked(5.0); + else if (number==8) *instrument = new(mem) StifKarp(5.0); + else if (number==9) *instrument = new(mem) Sitar(5.0); + else if (number==10) *instrument = new(mem) Mandolin(5.0); + + else if (number==11) *instrument = new(mem) Rhodey; + else if (number==12) *instrument = new(mem) Wurley; + else if (number==13) *instrument = new(mem) TubeBell; + else if (number==14) *instrument = new(mem) HevyMetl; + else if (number==15) *instrument = new(mem) PercFlut; + else if (number==16) *instrument = new(mem) BeeThree; + else if (number==17) *instrument = new(mem) FMVoices; + + else if (number==18) *instrument = new(mem) VoicForm; + else if (number==19) *instrument = new(mem) Moog; + else if (number==20) *instrument = new(mem) Simple; + else if (number==21) *instrument = new(mem) Drummer; + else if (number==22) *instrument = new(mem) BandedWG; + else if (number==23) *instrument = new(mem) Shakers; + else if (number==24) *instrument = new(mem) ModalBar; + else if (number==25) *instrument = new(mem) Mesh2D(10, 10); + else if (number==26) *instrument = new(mem) Resonate; + else if (number==27) *instrument = new(mem) Whistle; + + else { + printf("\nUnknown instrument or program change requested!\n"); + temp = -1; + } + + return temp; +} + + +struct StkInst : public Unit +{ + Instrmnt * inst; + bool gate; + float freq; + float ampat; + float amprel; + + int m_valueSize; + int m_valueOffset; + float *m_values; + float *old_values; + bool do_freq; + int instNumber; + //StkInst(Unit *unit); + //~StkInst(){}; +}; + +extern "C" +{ + void StkInst_next(StkInst *unit, int inNumSamples); + void StkInst_Ctor(StkInst* unit); + void StkInst_Dtor(StkInst* unit); +} + +static void Unit_next_nop(StkInst * unit, int inNumSamples) +{} +void StkInst_Ctor(StkInst* unit) { + + gWorld = unit->mWorld; + Stk::setSampleRate( SAMPLERATE ); + + unit->gate = false; + unit->freq = IN0(0); + unit->ampat = 1; + unit->amprel = 1; + unit->m_values = 0; + unit->old_values = 0; + unit->do_freq = true; + const int kVarOffset = 5; + + unit->instNumber = IN0(4); + unit->m_valueSize = unit->mNumInputs - kVarOffset; + //Print("StkInst\n"); + //Print("StkInst %d,%f;%f,%d,%d\n",unit->instNumber,unit->freq,unit->ampat,unit->mNumInputs,unit->m_valueSize); + //make it pair + unit->m_valueSize = floor(unit->m_valueSize /2.0) * 2.0; + if(unit->m_valueSize > 0){ + const int valuesAllocSize = unit->m_valueSize * sizeof(float); + char * chunk = (char*)RTAlloc(unit->mWorld, valuesAllocSize*2); + if (!chunk) { + Print("StkInst: RT memory allocation failed on values\n"); + SETCALC(Unit_next_nop); + return; + } + unit->m_values = (float*)chunk; + unit->old_values = (float*)(chunk + valuesAllocSize); + for (int i=0; im_valueSize; i++) + unit->old_values[i] = -1; //set old values to something imposible + } + + unit->inst = NULL; + try { + if(voiceByNumber(unit->instNumber,&(unit->inst))==-1){ + Print("StkInst: RT memory allocation failed on instrument\n"); + SETCALC(Unit_next_nop); + return; + } + } + catch ( StkError & e) { + Print("StkInst: Error on creation %s",e.getMessageCString()); + SETCALC(Unit_next_nop); + return; + } + + SETCALC(StkInst_next); +} + +void StkInst_Dtor(StkInst* unit) +{ + //delete unit->m_values; + //delete unit->inst; + RTFree(unit->mWorld, unit->m_values); + RTFree(unit->mWorld, unit->inst); + +} + +void StkInst_next(StkInst *unit, int inNumSamples) +{ + float *out = OUT(0); + + float freq = IN0(0); + bool gate = IN0(1) > 0.f; + float ampat = IN0(2); + float amprel = IN0(3); + + + float *values = unit->m_values; + float *old_values = unit->old_values; + int valueSize = unit->m_valueSize; + int valueOffset = 5; + for (int i=0; iinst->controlChange(values[i], values[i+1]); + old_values[i + 1] = values[i+1]; + } + } + if(unit->do_freq && freq != unit->freq){ + unit->inst->setFrequency(freq); + unit->freq = freq; + } + + if(gate != unit->gate){ + if(gate){ + //Print("Starting freq %f\n",freq); + unit->inst->noteOn(freq, ampat); + }else{ + //Print("Stopping\n"); + unit->inst->noteOff(amprel); + } + unit->gate = gate; + } + + for (int i=0; i < inNumSamples; ++i) + { + out[i] = unit->inst->tick();// * 7.5f; // Scaled to approx +-1 + } + +} + +////////////////StkMesh2D +struct StkMesh2D : public Unit +{ + Mesh2D * inst; + bool gate; + float ampat; + float XD; + float YD; + float Xpos; + float Ypos; + float decay; + +}; + +extern "C" +{ + void StkMesh2D_next(StkMesh2D *unit, int inNumSamples); + void StkMesh2D_Ctor(StkMesh2D* unit); + void StkMesh2D_Dtor(StkMesh2D* unit); +} + +static void StkMesh2D_next_nop(StkMesh2D * unit, int inNumSamples) +{} +void StkMesh2D_Ctor(StkMesh2D* unit) { + gWorld = unit->mWorld; + Stk::setSampleRate( SAMPLERATE ); + unit->gate = false; + unit->ampat = IN0(2); + unit->XD = IN0(3); + unit->YD = IN0(4); + unit->Xpos = IN0(5); + unit->Ypos = IN0(6); + unit->decay = IN0(7); + + void* mem = RTAlloc(unit->mWorld,sizeof(Mesh2D)); + if (!mem) { + Print("StkMesh2D: RT memory allocation failed on values\n"); + SETCALC(Unit_next_nop); + return; + } + unit->inst = new(mem) Mesh2D(unit->XD,unit->YD); + if(unit->inst==NULL){ + Print("StkMesh2D: RT memory allocation failed on instrument\n"); + SETCALC(StkMesh2D_next_nop); + return; + } + //Print("Mesh created\n"); + unit->inst->setDecay(unit->decay); + SETCALC(StkMesh2D_next); + //Print("Mesh created2\n"); +} + +void StkMesh2D_Dtor(StkMesh2D* unit) +{ + + //delete unit->inst; + RTFree(unit->mWorld, unit->inst); +} + +void StkMesh2D_next(StkMesh2D *unit, int inNumSamples) +{ + float *out = OUT(0); + + float *inp = IN(0); + bool gate = IN0(1) > 0.f; + unit->ampat = IN0(2); + unit->XD = IN0(3); + unit->YD = IN0(4); + unit->Xpos = IN0(5); + unit->Ypos = IN0(6); + unit->decay = IN0(7); + //for(int i=1;i<8;i++) + // Print("IN(%d) is %f",i,IN0(i)); + //Print("\n"); + unit->inst->setInputPosition(unit->Xpos,unit->Ypos); + if(gate != unit->gate){ + if(gate){ + Print("Starting mesh %f\n",unit->ampat); + unit->inst->noteOn(10, unit->ampat); + }else{ + Print("Stopping\n"); + unit->inst->noteOff(0); + } + unit->gate = gate; + } + + for (int i=0; i < inNumSamples; ++i) + { + //out[i] = unit->inst->tick(); + out[i] = unit->inst->inputTick(inp[i]); + } + +} +/////////////////////////////////////// +struct StkGlobals : public Unit +{ + char *rawwavePath; + bool showWarnings; + bool printErrors; + int m_valueSize; + +}; +extern "C" +{ + void StkGlobals_next(StkGlobals *unit, int inNumSamples); + void StkGlobals_Ctor(StkGlobals* unit); +} + +void StkGlobals_next(StkGlobals *unit, int inNumSamples){ + NodeEnd(&unit->mParent->mNode); +} +void StkGlobals_Ctor(StkGlobals* unit) { + gWorld = unit->mWorld; + Stk::setSampleRate( SAMPLERATE ); + unit->showWarnings = IN0(0) > 0; + unit->printErrors = IN0(1) > 0; + + const int kVarOffset = 2; + unit->m_valueSize = unit->mNumInputs - kVarOffset; + + if(unit->m_valueSize > 0){ + const int valuesAllocSize = (unit->m_valueSize +1)* sizeof(char); + char * chunk = (char*)RTAlloc(unit->mWorld, valuesAllocSize); + if (!chunk) { + Print("StkGlobals: RT memory allocation failed on values\n"); + SETCALC(Unit_next_nop); + return; + } + unit->rawwavePath = chunk; + for(int i=0; i< unit->m_valueSize; i++) + unit->rawwavePath[i] = IN0(i + kVarOffset); + + unit->rawwavePath[unit->m_valueSize] = 0; //null termination + Stk::setRawwavePath(unit->rawwavePath); + } + Stk::showWarnings(unit->showWarnings); + Stk::printErrors(unit->printErrors); + RTFree(unit->mWorld,unit->rawwavePath); + SETCALC(StkGlobals_next); +} +//////////////////////////////////////// +PluginLoad(StkUnit){ + ft = inTable; + DefineDtorUnit(StkInst); + DefineDtorUnit(StkMesh2D); + DefineSimpleUnit(StkGlobals); +} \ No newline at end of file diff --git a/source/StkInst/sc/HelpSource/Classes/Stk.schelp b/source/StkInst/sc/HelpSource/Classes/Stk.schelp new file mode 100644 index 0000000000..722bce5d48 --- /dev/null +++ b/source/StkInst/sc/HelpSource/Classes/Stk.schelp @@ -0,0 +1,52 @@ +TITLE:: Stk +summary:: Wrapping Synthesis toolkit. +related:: Classes/StkInst, Classes/StkGlobals +categories:: UGens>PhysicalModels + + +Description:: + +Wrapping of Synthesis toolkit physical model instruments +https://ccrma.stanford.edu/software/stk/index.html + +You can get the number from those instruments: +"Clarinet", "BlowHole", "Saxofony", "Flute", "Brass", +"BlowBotl", "Bowed", "Plucked", "StifKarp", "Sitar", "Mandolin", +"Rhodey", "Wurley", "TubeBell", "HevyMetl", "PercFlut", +"BeeThree", "FMVoices", "VoicForm", "Moog", "Simple", "Drummer", +"BandedWG", "Shakers", "ModalBar", "Mesh2D", "Resonate", "Whistle" + +Classmethods:: + +method::at +Method for getting instrument number from instrument name and giving it to StkInst + +argument::name +The name of the instrument + + +Examples:: + +code:: +//Define bow synthdef +( +SynthDef(\helpStkbowed,{arg out=0,freq=220,gate=1,amp=1,bowpressure = 64, bowposition = 17, vibfreq=50, vibgain=1, loudness=128; + var sig,env; + env = EnvGen.kr(Env.asr(0,1,0.1),gate,doneAction:2); + sig = StkInst.ar(Stk.at("Bowed"),freq, gate, amp, 0.5,[2,bowpressure,4,bowposition,11,vibfreq,1,vibgain,128,loudness])*env; + Out.ar(out, sig.dup); +}).add; +) + +//Use it. +( + +Pbind( + \instrument, \helpStkbowed, + \dur , 0.25, + \degree, Pseq([1,5,7+3], inf), + \amp , Pseq([0.9,0.7,0.5],inf), + \bowposition , Pseq([10,20,30,40,50,60],inf) +).play; +) +:: diff --git a/source/StkInst/sc/HelpSource/Classes/StkGlobals.schelp b/source/StkInst/sc/HelpSource/Classes/StkGlobals.schelp new file mode 100644 index 0000000000..af61e45486 --- /dev/null +++ b/source/StkInst/sc/HelpSource/Classes/StkGlobals.schelp @@ -0,0 +1,55 @@ +TITLE:: StkGlobals +summary:: Wrapping Synthesis toolkit. +related:: Classes/Stk, Classes/StkInst +categories:: UGens>PhysicalModels + + +Description:: + +Wrapping of Synthesis toolkit physical model instruments +https://ccrma.stanford.edu/software/stk/index.html + +Classmethods:: + +method::ar + +argument::showWarnings +Let Stk showWarnings, 0 for false 1 for true. + +argument::printErrors +Let Stk printErrors, 0 for false 1 for true. + +argument::rawfilepath +Tells Stk where to look for its audio files. + + + +Examples:: + +code:: + +//a instrument that uses waveforms/////////////////// +//first set rawfilepath to let Stk know where to look +{StkGlobals.ar(1,1,Platform.userExtensionDir ++"/SC3Plugins/StkInst/rawwaves")}.play; + +//Define mandolin synthdef +( +SynthDef(\helpMandolin,{arg out=0,freq=220,gate=1,amp=1; + var sig,env; + env = EnvGen.kr(Env.asr(0,1,0.1),gate,doneAction:2); + sig = StkInst.ar(Stk.at("Mandolin"),freq, gate, amp, 0.5)*env; + Out.ar(out, sig.dup); +}).add; +) + +//Use it. +( + +Pbind( + \instrument, \helpMandolin, + \dur , 0.25, + \degree, Pseq([1,5,7+3], inf), + \amp , Pseq([0.9,0.7,0.5],inf), +).play; +) +:: diff --git a/source/StkInst/sc/HelpSource/Classes/StkInst.schelp b/source/StkInst/sc/HelpSource/Classes/StkInst.schelp new file mode 100644 index 0000000000..15c6fab439 --- /dev/null +++ b/source/StkInst/sc/HelpSource/Classes/StkInst.schelp @@ -0,0 +1,85 @@ +TITLE:: StkInst +summary:: Wrapping Synthesis toolkit. +related:: Classes/Stk, Classes/StkGlobals +categories:: UGens>PhysicalModels + + +Description:: + +Wrapping of Synthesis toolkit physical model instruments +https://ccrma.stanford.edu/software/stk/index.html + +Classmethods:: + +method::ar + +argument::instNumber +The number identifying which instrument is used (Can be setted with Stk Array) + +argument::freq +Sound frequency. + +argument::gate +Does noteOn on 0 to 1 changes and noteOff on 1 to 0 changes. + +argument::onamp +Amplitude used on noteOn. + +argument::offamp +Amplitude used on noteOff. + +argument::args +Array of control numbers and control values (most of them 0-128) according to Stk. + + + +Examples:: + +code:: +//Define bow synthdef +( +SynthDef(\helpStkbowed,{arg out=0,freq=220,gate=1,amp=1,bowpressure = 64, bowposition = 17, vibfreq=50, vibgain=1, loudness=128; + var sig,env; + env = EnvGen.kr(Env.asr(0,1,0.1),gate,doneAction:2); + sig = StkInst.ar(Stk.at("Bowed"),freq, gate, amp, 0.5,[2,bowpressure,4,bowposition,11,vibfreq,1,vibgain,128,loudness])*env; + Out.ar(out, sig.dup); +}).add; +) + +//Use it. +( + +Pbind( + \instrument, \helpStkbowed, + \dur , 0.25, + \degree, Pseq([1,5,7+3], inf), + \amp , Pseq([0.9,0.7,0.5],inf), + \bowposition , Pseq([10,20,30,40,50,60],inf) +).play; +) + +//now a instrument that uses waveforms/////////////////// +//first set rawfilepath to let Stk know where to look +{StkGlobals.ar(1,1,Platform.userExtensionDir ++"/SC3Plugins/StkInst/rawwaves")}.play; + +//Define mandolin synthdef +( +SynthDef(\helpMandolin,{arg out=0,freq=220,gate=1,amp=1; + var sig,env; + env = EnvGen.kr(Env.asr(0,1,0.1),gate,doneAction:2); + sig = StkInst.ar(Stk.at("Mandolin"),freq, gate, amp, 0.5)*env; + Out.ar(out, sig.dup); +}).add; +) + +//Use it. +( + +Pbind( + \instrument, \helpMandolin, + \dur , 0.25, + \degree, Pseq([1,5,7+3], inf), + \amp , Pseq([0.9,0.7,0.5],inf), +).play; +) +:: diff --git a/source/StkInst/sc/classes/StkInst.sc b/source/StkInst/sc/classes/StkInst.sc new file mode 100644 index 0000000000..d4cd0b8a59 --- /dev/null +++ b/source/StkInst/sc/classes/StkInst.sc @@ -0,0 +1,39 @@ + + +Stk{ + + classvar names; + classvar namenumber; + *initClass{ + names = Array.with("Clarinet", "BlowHole", "Saxofony", "Flute", "Brass", + "BlowBotl", "Bowed", "Plucked", "StifKarp", "Sitar", "Mandolin", + "Rhodey", "Wurley", "TubeBell", "HevyMetl", "PercFlut", + "BeeThree", "FMVoices", "VoicForm", "Moog", "Simple", "Drummer", + "BandedWG", "Shakers", "ModalBar", "Mesh2D", "Resonate", "Whistle"); + + namenumber = Dictionary.new; + names.do({arg item,i; namenumber[item] = i;}); + } + + *at { arg preset; + ^namenumber[preset]; + } +} + +StkInst : UGen { + *ar { arg instNumber=6,freq=220,gate=1,onamp=1,offamp=0.5,args; + ^this.multiNewList(['audio', freq,gate,onamp,offamp,instNumber]++ args.asArray); + } +} + +StkBowedI { + *ar {arg freq=220,gate=1, onamp=1, offamp=1, bowpressure = 64, bowposition = 64, vibfreq=64, vibgain=64, loudness=64; + ^StkInst.ar(Stk.at("Bowed"),freq,gate,onamp,offamp,[2,bowpressure,4,bowposition,11,vibfreq,1,vibgain,128,loudness]); + } +} +StkGlobals : UGen { + *ar { arg showWarnings, printErrors, rawfilepath; + var ascii = rawfilepath.ascii; + ^this.multiNewList(['audio', showWarnings, printErrors].addAll(ascii)); + } +} \ No newline at end of file diff --git a/source/StkInst/stk b/source/StkInst/stk new file mode 160000 index 0000000000..f3b1f35a8c --- /dev/null +++ b/source/StkInst/stk @@ -0,0 +1 @@ +Subproject commit f3b1f35a8c2fe0c4855cad78408434938b0fb83a diff --git a/source/StkInst/stkinsttest.lua b/source/StkInst/stkinsttest.lua new file mode 100644 index 0000000000..458ffce957 --- /dev/null +++ b/source/StkInst/stkinsttest.lua @@ -0,0 +1,80 @@ +--UGen definitions +Stknames ={ "Clarinet", "BlowHole", "Saxofony", "Flute", "Brass", + "BlowBotl", "Bowed", "Plucked", "StifKarp", "Sitar", "Mandolin", + "Rhodey", "Wurley", "TubeBell", "HevyMetl", "PercFlut", + "BeeThree", "FMVoices", "VoicForm", "Moog", "Simple", "Drummer", + "BandedWG", "Shakers", "ModalBar", "Mesh2D", "Resonate", "Whistle" } + +Stk = {} +for i,v in ipairs(Stknames) do + Stk[v] = i - 1 +end + +StkInst = UGen:new{name="StkInst"} +function StkInst.ar(instNumber,freq,gate,ampat,amprel,args) + local freq = freq or 231;gate = gate or 1;ampat = ampat or 1;amprel=amprel or 0;instNumber =instNumber or 6;args = args or {}; + return StkInst:MultiNew(concatTables({2,freq, gate,ampat,amprel,instNumber},args)) +end + +StkGlobals = UGen:new{name="StkGlobals"} +function StkGlobals.ar(showWarnings, printErrors, rawfilepath) + showWarnings = showWarnings or 1;printErrors = printErrors or 1;rawfilepath = rawfilepath or "" + local ascii = {rawfilepath:byte(1,-1)} + return StkGlobals:MultiNew(concatTables({2,showWarnings, printErrors},ascii)) +end + +------------------------some synthdefs +SynthDef("help_stkBowed",{out=0,freq=200,gate=1,amp=1,bowvel=65,pres=94,pos=16,vf=50,vg=1},function() + + local env = EnvGen.kr{Env.asr(0,1,0.1),gate,doneAction=2} + local sig = StkInst.ar(Stk.Bowed,freq,gate,amp,0.5,{2,pres,4,pos,1,vg,11,vf}) + Out.ar(out,sig:dup()) +end):store() + +SynthDef("help_stkClarinet",{out=0,freq=200,gate=1,stiff=50,pres= 111,noise=24,vf=60,vg=1},function() + local sig = StkInst.ar(Stk.Clarinet,freq,gate,1,0.05,{2,stiff,128,pres,4,noise,1,vg,11,vf}) + Out.ar(out,sig:dup()) +end):store() + +SynthDef("help_stkBrass",{out=0,freq=200,gate=1,amp=1,stiff=50,pres= 111,noise=24,vf=60,vg=1},function() + local env = EnvGen.kr{Env.asr(0,1,0.1),gate,doneAction=2} + local sig = StkInst.ar(Stk.Brass,freq,gate,amp,0.05)--,{2,stiff,128,pres,4,noise,1,vg,11,vf}) + Out.ar(out,sig:dup()) +end):store() + + +SynthDef("help_VoicForm",{out=0,freq=200,gate=1,amp=1,phon=8,loud=50,mix=65,vf=60,vg=20},function() + StkGlobals.ar(1,1,[[C:\SupercolliderRepos\Mios\stk-4.5.0\stk-4.5.0\rawwaves\]]) + local env = EnvGen.kr{Env.asr(0.3,1,0.1),gate,doneAction=2} + local sig = StkInst.ar(Stk.VoicForm,freq,gate,amp,0.05,{4,phon,2,mix,128,loud,1,vg,11,vf})*env--,{2,stiff,128,pres,4,noise,1,vg,11,vf}) + Out.ar(out,sig:dup()) +end):store() + +SynthDef("help_stkS",{out=0,freq=200,gate=1,amp=1,vowel=120,tilt= 50,targ=50,noise=24,vf=60,vg=1},function() + --StkGlobals.ir(1,1,[[C:\SupercolliderRepos\Mios\stk-4.5.0\stk-4.5.0\rawwaves\]]) + local env = EnvGen.kr{Env.asr(0,1,0.1),gate,doneAction=2} + local sig = StkInst.ar(Stk.Mesh2D,freq,gate,amp,0.5)--,{2,vowel,4,tilt,128,targ})*env--,{16,3})--,{2,stiff,128,pres,4,noise,1,vg,11,vf}) + Out.ar(out,sig:dup()) +end):store() + +SynthDef("stkglobals",{},function() + StkGlobals.ar(1,1,[[C:/SupercolliderRepos/Mios/stk-4.5.0/stk-4.5.0/rawwaves/]]) +end):play() +------------------------------------use it +local sclua = require "sclua.Server" +local s = sclua.Server() + +--sinte = s.Synth("help_stkS",{freq=200}) + +instgui=InstrumentsGUI("help_stkS",false) +MidiToOsc.AddChannel(0,instgui,{0.1},mmm)--,{{"bowsoundboard"}},false) + +--[[ +sinte:set{freq = 300} +sinte:set{pos = 10} +sinte:set{gate = 0} + +sinte:set{bowvel=0} +sinte:set{pres=0} +sinte:set{gate = 1} +--]] \ No newline at end of file