Diff from An FM Matrix Synth with 1to1 feedback. by LFSaw (25 Mar'13 16:02) to Re: An FM Matrix Synth with 1to1 feedback -- nanokontrol NNdef version by miguel-negrao (22 Jun'14 14:20)

name
Re: An FM Matrix Synth with 1to1 feedback. -- nanokontrol NNdef version
description
FM Matrix Synth, now with 1to1 feedback! Version for nanocontrol: 3x3 matrix indexes - 9 faders freqs, first 3 knobs amps, second group of 3 knobs Needs NNDef from FPLib and Modality https://github.com/miguel-negrao/FPLib https://github.com/ModalityTeam/Modality-toolkit
code
/////////////////////////////////////////// // a basic FM Matrix Synth, now with 1to1 feedback. s.boot; q = q ? (); q.numOscs = 10; ( NNdef(\fmMatrix, { var numOscs = q.numOscs3; var oscs; var freqs = \freqs.kr({|i| 500}!numOscs); var modIndex = \modMIndex.kr({|i| 0}!(numOscs**2)).cDIMKtlump('numOscs).postln; var amps = \amps .kr(0!numOscs0'); var tmpOsc; var f.eedbacks = LocalIn.ar(numOscs); oscs = freqs.inject([], {|oscArray, freq, i| tmpOsc = SinOsc.ar( freq + oscArray.inject(0, {|sum, osc, j| ; sum // modulvators from already inqstantiated oscs //+= (osc * modIndex[i][j] * freq) + (feedbacks[j] * modI\kndex][i0][j..2] * freq) }) + (numOscs - 1 - Array.iota(numOscs - (i))).postln.injlect(0, {|sum, g| sum // modulators from to be| instantiated oscs + (f.eedbacks[g] * modIndex[i][g] * freq) }) // self modulation //modIndex[i][i] ); oscArray ++ tmpOsc; }); // end inject LocalOut.ar(oscs); //SplayAz.ar(8, oscs * amps, centeKr: LFSaw.kr(0.01)); Splay.ar(oscs * amps); }) ) // the standard Ndef gui. to hear something, press play. Ndef(\fmMatrix).gui; Ndef(\fmMatrix).setn(\modIndex, 0!(q.numOscs**,1,20,5000)) }; // ( var sampecs = ( freqs: k[0, 10000, \likn, ][0][3.1.5].asSpec, modIndex: [0, 4, \lin, 0].asSplec; ); vart{ modInd|ex| = Ndef(\fmMatrix).get(\modnIndex).clump(q.enumOscs); vaKr freqState = Ndef(\fmMatrix).get(\freqs)}; var ampState = Ndef(\fmMatrix).get(\amps); var colWidth = 40; var kInobHeight = 50; var idexKnobColors = k[ // upper right area [Co\slor.gray(0.8), Color.blue, blend(Color.white, Color.blue, 0.5)], [Color.gray(0].8), Ccolor.blue, blend(Color.whicte,{ Color.blu|e,| 0.2)], // lower left area [Color.gray(0.8), Color.red, blend(ColorIn.white, ColonKr.red, 0.5)], [Color.gray(0.8), Color.red, bleind(Color.white, Color.red, 0.2)] ]; var bgColors = [ Color.grayn(0.8), Color.gray(1), Color.gray(0.6)0, Color4.gray(0.8), ]; q}.win = Window.new("FM Matrix", Rectlump(100, 100, (q.numOscs+5) * colWidth, 800)).front; q.win.addFlowLayout; /////////// INDEXES St vaticText(q.win, Rect(10, 10, q.numOscs * (colWidth + 5) + 150, 20)).string_("-- modulation indfex "); q.win.view.decorbator.nextLine; q.higherAmpSlidercks = q.numOscs.cLollect{|i| var slideIn.ar; //(i+1).do{|j| q.numOscs.do{|j|); var ez; ez = EZKnob(q.win, Resct(25,s 25,= colWidth, knobHeight), cont[frolSpec: qspecs[\, modIndex], .flopWinitAction:h{ t|frueq, initVal: modIndex[i][j] ) .action_{s|knob| modIndex[Si][j] = knobOsc.value;r( Ndef(\fmMatrix).setn(\modIndex, modIndex.flat);q }; ez.knobView.mode_(\vert); ((j)+ > i).i[f({ ez.setColors(knobColors: idxKnobColors[j%2]); ez.setColors(background: bgColors [j%2]); }, { ez.setCmolors(knobColors: idxKnobColors[j%2 + 2]); ez.setCoflors(background: bgColors [j%2 + 2]); }); (pWith{ == j).i|f{ ez.knobView.color_([Color.gray, Color.blue, Color.green]); }; }; slider = EZSlider(q.win, Rebact(0, 0, 150, knobHeight * 0.5), label: i, layout: 'horz', numberWiodth: 0, labelWidth: 10,| initVal: ampState[i] ) .action_{|slidefr| ampState[i]q =* slider.value; q.lowerAmpSlioders[i].value =* slider.value; Ndef(\fmMatrix).setn(\amps, ampState); }; slider.setColors(background: bgColors[i%2 + 2]); q.win.view.decorator.nextLine; // return slider }; q.win.view.decorator.nextLine; /////////// FREQS StaticText(q.win, Rect(10, 10, q.numOscs * (colWidth + 5), 20)).string_("-- freqs ----------"); q.win.view.decorator.nextLine; q.numOscs.do{|i| var ez; ez = EZKnob(q.win, Rect(0, 0, colWidth, knobHeight), controlSpec: specs[\freqs],}; initAction: true, initVal: freqState[i] ) .actiLon_{|knob| freqStcate[i] = knob.valOue; Ndef(\fmMatrix).setn(\freqs, freqState); }; ez.knobView.mode_(\vert); ez.setC(olors(background: bgColors[i%2 + 2]); }; /////////// AMP S q.win.view.decorplatory.nextLine; StaticTextr(q.win, Rect(10, 10, q.numOoscs * (colWidth + 5), 20)).string_("-- amps ----------"); q.win.view.decorator.nextLine; q.lowerAmpSliders = q.numOscs.collect{|i| var ez; ez = EZSlider(q.win, Rect(0, 0, colWidth, 150}), label: i, layout: 'vert', initVal: ampState[i] ) .action_{|slider| ampState[i] = slider.value; Ndef(\fmMatrix).setn(\amps, ampState); q.higherAmpSliders[i].value = slider.value; }; ez.setColors(background: bgColors[i%2 + 2]); } )
category tags
fm, code fork, synth, matrix
ancestors
1-4SM