public override PxPre.Phonics.GenBase SpawnGenerator( float freq, float beatsPerSec, int samplesPerSec, float amp, WiringDocument spawnFrom, WiringCollection collection) { float off = this.offset.GetWavelength(freq, beatsPerSec); float len = this.attack.GetWavelength(freq, beatsPerSec); if (this.input.IsConnected() == false) { return (new PxPre.Phonics.GenLinAttackEmpty( (int)(off * samplesPerSec), (int)(len * samplesPerSec))); } PxPre.Phonics.GenBase ip = this.input.Reference.SpawnGenerator( freq, beatsPerSec, samplesPerSec, amp, spawnFrom, collection); return(new PxPre.Phonics.GenLinAttack( (int)(off * samplesPerSec), (int)(len * samplesPerSec), ip)); }
public override PxPre.Phonics.GenBase SpawnGenerator( float freq, float beatsPerSec, int samplesPerSec, float amp, WiringDocument spawnFrom, WiringCollection collection) { if (this.input.IsConnected() == false) { return(null); } PxPre.Phonics.GenBase gb = this.input.Reference.SpawnGenerator( freq, beatsPerSec, samplesPerSec, amp, spawnFrom, collection); float timeStall = this.holdTime.GetWavelength(freq, beatsPerSec); return(new PxPre.Phonics.GenHold(gb, (int)(timeStall * samplesPerSec))); }
public override PxPre.Phonics.GenBase SpawnGenerator( float freq, float beatsPerSec, int samplesPerSec, float amp, WiringDocument spawnFrom, WiringCollection collection) { if (this.input.IsConnected() == false) { return(null); } PxPre.Phonics.GenBase gb = this.input.Reference.SpawnGenerator( freq, beatsPerSec, samplesPerSec, amp, spawnFrom, collection); float factor = this.factor.value; float integrateFactor = Mathf.Lerp(1.0f, 10.0f, factor); float decayFactor = Mathf.Lerp(0.9f, 0.999f, factor); return(new PxPre.Phonics.GenSmear(gb, integrateFactor, decayFactor)); }
public override PxPre.Phonics.GenBase SpawnGenerator( float freq, float beatsPerSec, int samplesPerSec, float amp, WiringDocument spawnFrom, WiringCollection collection) { if (this.input.IsConnected() == false) { return(ZeroGen()); } PxPre.Phonics.GenBase gb = this.input.Reference.SpawnGenerator( freq, beatsPerSec, samplesPerSec, amp, spawnFrom, collection); float len = this.offset.GetWavelength(freq, beatsPerSec); return (new PxPre.Phonics.GenDelay( samplesPerSec, gb, this.voiceCt.value, len, this.dampen.value)); }
public override PxPre.Phonics.GenBase SpawnGenerator( float freq, float beatsPerSec, int samplesPerSec, float amp, WiringDocument spawnFrom, WiringCollection collection) { float useFreq = this.timeLen.GetFrequency( freq, beatsPerSec); float finalGain = amp * this.gain.value; if (finalGain == 1.0f) { return (new PxPre.Phonics.GenSawtoothWaveUnit( useFreq, 0.0, samplesPerSec)); } else { return (new PxPre.Phonics.GenSawtoothWave( useFreq, 0.0, samplesPerSec, finalGain)); } }
public override PxPre.Phonics.GenBase SpawnGenerator( float freq, float beatsPerSec, int samplesPerSec, float amp, WiringDocument spawnFrom, WiringCollection collection) { if (this.connectionA.IsConnected() == false && this.connectionB.IsConnected() == false) { return(ZeroGen()); } if (this.connectionA.IsConnected() == false) { return (this.connectionB.Reference.SpawnGenerator( freq, beatsPerSec, samplesPerSec, amp, spawnFrom, collection)); } if (this.connectionB.IsConnected() == false) { return (this.connectionA.Reference.SpawnGenerator( freq, beatsPerSec, samplesPerSec, amp, spawnFrom, collection)); } PxPre.Phonics.GenBase gba = this.connectionA.Reference.SpawnGenerator( freq, beatsPerSec, samplesPerSec, amp, spawnFrom, collection); PxPre.Phonics.GenBase gbb = this.connectionB.Reference.SpawnGenerator( freq, beatsPerSec, samplesPerSec, amp, spawnFrom, collection); return (new PxPre.Phonics.GenAdd( gba, gbb)); }
public override PxPre.Phonics.GenBase SpawnGenerator( float freq, float beatsPerSec, int samplesPerSec, float amp, WiringDocument spawnFrom, WiringCollection collection) { if (string.IsNullOrEmpty(reference.referenceGUID) == true) { return(ZeroGen()); } WiringDocument wd = collection.GetDocument(reference.referenceGUID); // The last one is a check against cyclic redundancy. There are // other things that prevent this, but if for some reason those // fail, we check one last time and just shut down the process // with a zero signal. if (wd == null || wd.Output == null || wd == spawnFrom) { return(ZeroGen()); } return (wd.Output.SpawnGenerator( freq, beatsPerSec, samplesPerSec, amp, spawnFrom, collection)); }
public override PxPre.Phonics.GenBase SpawnGenerator( float freq, float beatsPerSec, int samplesPerSec, float amp, WiringDocument spawnFrom, WiringCollection collection) { float len = this.release.GetWavelength(freq, beatsPerSec); if (this.input.IsConnected() == false) { return (new PxPre.Phonics.GenReleaseEmpty( samplesPerSec, len)); } PxPre.Phonics.GenBase gb = this.input.Reference.SpawnGenerator( freq, beatsPerSec, samplesPerSec, amp, spawnFrom, collection); return (new PxPre.Phonics.GenRelease( samplesPerSec, gb, len)); }
public override PxPre.Phonics.GenBase SpawnGenerator( float freq, float beatsPerSec, int samplesPerSec, float amp, WiringDocument spawnFrom, WiringCollection collection) { if (this.input.IsConnected() == false) { return(ZeroGen()); } PxPre.Phonics.GenBase gb = this.input.Reference.SpawnGenerator( freq, beatsPerSec, samplesPerSec, amp, spawnFrom, collection); return (new PxPre.Phonics.GenMAD( gb, this.mul.value, this.add.value)); }
/// <summary> /// Create a GenBase based off the node's parameters and connections. /// </summary> /// <param name="freq">The frequency of the note being generated.</param> /// <param name="beatsPerSec">The BPM of the node.</param> /// <param name="samplesPerSec">The samples per second of the PCM being generated.</param> /// <param name="amp">The amplitude generators should generate at.</param> /// <returns>The GenBase generator.</returns> public abstract PxPre.Phonics.GenBase SpawnGenerator( float freq, float beatsPerSec, int samplesPerSec, float amp, WiringDocument spawnFrom, WiringCollection collection);
public bool TreeAppearsValid(WiringCollection wc, WiringDocument owner) { if (this.conInput.IsConnected() == false) { return(false); } Queue <LLDNBase> toScan = new Queue <LLDNBase>(); toScan.Enqueue(this.conInput.Reference); while (toScan.Count > 0) { LLDNBase f = toScan.Dequeue(); if (f.CanMakeNoise() == true) { return(true); } if (f.nodeType == NodeType.Reference && wc != null) { LLDNReference refr = f as LLDNReference; if (refr != null && string.IsNullOrEmpty(refr.reference.referenceGUID) == false && owner != null) { WiringDocument refWD = wc.GetDocument(refr.reference.referenceGUID); if (refWD != null) { if (refWD == owner) { return(false); } if (refWD.Output != null) { toScan.Enqueue(refWD.Output); } } } } foreach (ParamConnection pc in f.GetParamConnections()) { if (pc.IsConnected() == false) { continue; } if (f.VerifyConnectionUsed(pc) == false) { continue; } toScan.Enqueue(pc.Reference); } } return(false); }
public override PxPre.Phonics.GenBase SpawnGenerator( float freq, float beatsPerSec, int samplesPerSec, float amp, WiringDocument spawnFrom, WiringCollection collection) { return(new PxPre.Phonics.GenConstant(this.floatVal.value)); }
public override PxPre.Phonics.GenBase SpawnGenerator( float freq, float beatsPerSec, int samplesPerSec, float amp, WiringDocument spawnFrom, WiringCollection collection) { return(null); }
public string GetProcessedWiringName(WiringCollection wc) { string convName = System.Text.RegularExpressions.Regex.Replace( this.name, "{<[\\w]*>}", (m) => { return(ProcessConvertingMatch(m, this, wc)); }); return(convName); }
public override PxPre.Phonics.GenBase SpawnGenerator( float freq, float beatsPerSec, int samplesPerSec, float amp, WiringDocument spawnFrom, WiringCollection collection) { if (this.input.IsConnected() == false) { return(ZeroGen()); } PxPre.Phonics.GenBase gb = this.input.Reference.SpawnGenerator( freq, beatsPerSec, samplesPerSec, amp, spawnFrom, collection); float offset = this.offset.GetWavelength(freq, beatsPerSec); float record = this.recordAmt.GetWavelength(freq, beatsPerSec); PxPre.Phonics.GenCycle.OffsetPass offsetType = PxPre.Phonics.GenCycle.OffsetPass.Pass; switch (this.offsetType.value) { default: case (int)PxPre.Phonics.GenCycle.OffsetPass.Pass: offsetType = PxPre.Phonics.GenCycle.OffsetPass.Pass; break; case (int)PxPre.Phonics.GenCycle.OffsetPass.Silent: offsetType = PxPre.Phonics.GenCycle.OffsetPass.Silent; break; case (int)PxPre.Phonics.GenCycle.OffsetPass.Hold: offsetType = PxPre.Phonics.GenCycle.OffsetPass.Hold; break; } return (new PxPre.Phonics.GenCycle( (int)(offset * samplesPerSec), (int)(record * samplesPerSec), offsetType, gb)); }
public override PxPre.Phonics.GenBase SpawnGenerator( float freq, float beatsPerSec, int samplesPerSec, float amp, WiringDocument spawnFrom, WiringCollection collection) { PxPre.Phonics.GenBase ret = null; if (this.gate.Value == true) { if (this.inputA.IsConnected() == true) { ret = this.inputA.Reference.SpawnGenerator( freq, beatsPerSec, samplesPerSec, amp, spawnFrom, collection); } } else { if (this.inputB.IsConnected() == true) { ret = this.inputB.Reference.SpawnGenerator( freq, beatsPerSec, samplesPerSec, amp, spawnFrom, collection); } } if (ret == null) { return(ZeroGen()); } return(ret); }
public override PxPre.Phonics.GenBase SpawnGenerator( float freq, float beatsPerSec, int samplesPerSec, float amp, WiringDocument spawnFrom, WiringCollection collection) { float useFreq = this.timeLen.GetFrequency( freq, beatsPerSec); return (new PxPre.Phonics.GenTriangleWave( useFreq, samplesPerSec, amp * this.gain.value)); }
public override PxPre.Phonics.GenBase SpawnGenerator( float freq, float beatsPerSec, int samplesPerSec, float amp, WiringDocument spawnFrom, WiringCollection collection) { float finalGain = amp * this.gain.value; if (finalGain == 1.0f) { return(new PxPre.Phonics.GenWhiteUnit()); } else { return(new PxPre.Phonics.GenWhite(finalGain)); } }
public override PxPre.Phonics.GenBase SpawnGenerator( float freq, float beatsPerSec, int samplesPerSec, float amp, WiringDocument spawnFrom, WiringCollection collection) { if (this.conInput == null || this.conInput.IsConnected() == false) { return(ZeroGen()); } return(this.conInput.Reference.SpawnGenerator( freq, beatsPerSec, samplesPerSec, amp, spawnFrom, collection)); }
public PxPre.Phonics.GenBase CreateGenerator( float freq, float beatsPerSec, float mastervol, int samplesPerSec, WiringDocument spawnFrom, WiringCollection collection) { if (this.output == null) { return(null); } return (this.output.SpawnGenerator( freq, beatsPerSec, samplesPerSec, mastervol, spawnFrom, collection)); }
public override PxPre.Phonics.GenBase SpawnGenerator( float freq, float beatsPerSec, int samplesPerSec, float amp, WiringDocument spawnFrom, WiringCollection collection) { if (this.input.IsConnected() == false) { return(null); } PxPre.Phonics.GenBase gb = this.input.Reference.SpawnGenerator( freq, beatsPerSec, samplesPerSec, amp, spawnFrom, collection); if (gb != null) { switch (this.clampType.value) { case enumFull: return(new PxPre.Phonics.GenClampFull(gb)); case enumPos: return(new PxPre.Phonics.GenClampPos(gb)); case enumNeg: return(new PxPre.Phonics.GenClampNeg(gb)); } } return(ZeroGen()); }
public override PxPre.Phonics.GenBase SpawnGenerator( float freq, float beatsPerSec, int samplesPerSec, float amp, WiringDocument spawnFrom, WiringCollection collection) { if (this.input.IsConnected() == false) { return (new PxPre.Phonics.GenADSREmpty( samplesPerSec, this.paramOffset.value, this.paramAttackTime.value, this.paramDecayTime.value, this.paramSustainVal.value, this.paramRelease.value)); } PxPre.Phonics.GenBase gb = this.input.Reference.SpawnGenerator( freq, beatsPerSec, samplesPerSec, amp, spawnFrom, collection); return(new PxPre.Phonics.GenADSR( gb, samplesPerSec, this.paramOffset.value, this.paramAttackTime.value, this.paramDecayTime.value, this.paramSustainVal.value, this.paramRelease.value)); }
public override PxPre.Phonics.GenBase SpawnGenerator( float freq, float beatsPerSec, int samplesPerSec, float amp, WiringDocument spawnFrom, WiringCollection collection) { if (this.input.IsConnected() == false) { return(null); } PxPre.Phonics.GenBase gb = this.input.Reference.SpawnGenerator( freq, beatsPerSec, samplesPerSec, amp, spawnFrom, collection); int mode = this.outputType.value; if (mode == enumPos) { return(new PxPre.Phonics.GenSignPos(samplesPerSec, gb)); } else if (mode == enumNeg) { return(new PxPre.Phonics.GenSignNeg(samplesPerSec, gb)); } else { return(new PxPre.Phonics.GenSign(samplesPerSec, gb)); } }
public override PxPre.Phonics.GenBase SpawnGenerator( float freq, float beatsPerSec, int samplesPerSec, float amp, WiringDocument spawnFrom, WiringCollection collection) { float len = this.duration.GetWavelength(freq, beatsPerSec); if (this.input.IsConnected() == false) { return (new PxPre.Phonics.GenLinDecayEmpty( this.offset.value, len, this.sustain.value, samplesPerSec)); } PxPre.Phonics.GenBase ip = this.input.Reference.SpawnGenerator( freq, beatsPerSec, samplesPerSec, amp, spawnFrom, collection); return(new PxPre.Phonics.GenLinDecay( this.offset.value, len, this.sustain.value, samplesPerSec, ip)); }
public override PxPre.Phonics.GenBase SpawnGenerator( float freq, float beatsPerSec, int samplesPerSec, float amp, WiringDocument spawnFrom, WiringCollection collection) { if (this.input.IsConnected() == false) { return(ZeroGen()); } float f = freq; float fmod = Mathf.Pow(2.0f, this.freqOff.value); List <PxPre.Phonics.GenBase> gens = new List <PxPre.Phonics.GenBase>(); for (int i = 0; i < phonicCt.value; ++i) { PxPre.Phonics.GenBase gb = this.input.Reference.SpawnGenerator( f, beatsPerSec, samplesPerSec, amp, spawnFrom, collection); gens.Add(gb); amp *= this.dampen.value; f *= fmod; } return(new PxPre.Phonics.GenBatch(gens.ToArray())); }
public override PxPre.Phonics.GenBase SpawnGenerator( float freq, float beatsPerSec, int samplesPerSec, float amp, WiringDocument spawnFrom, WiringCollection collection) { if (this.connectionA.IsConnected() == false && this.connectionB.IsConnected() == false) { return(ZeroGen()); } PxPre.Phonics.GenBase ga = null; if (this.connectionA.IsConnected() == true) { ga = this.connectionA.Reference.SpawnGenerator( freq, beatsPerSec, samplesPerSec, amp, spawnFrom, collection); } PxPre.Phonics.GenBase gb = null; if (this.connectionB.IsConnected() == true) { gb = this.connectionB.Reference.SpawnGenerator( freq, beatsPerSec, samplesPerSec, amp, spawnFrom, collection); } PxPre.Phonics.GenBase gf = null; if (this.connectionFactor.IsConnected() == true) { gf = this.connectionFactor.Reference.SpawnGenerator( freq, beatsPerSec, samplesPerSec, amp, spawnFrom, collection); } else { // If we have both inputs but no factor, return halfsies if (ga != null && gb == null) { gf = new PxPre.Phonics.GenConstant(0.5f); } // Or else just return which-ever is valid else if (ga == null) { return(gb); } else { return(ga); } } if (ga == null) { ga = ZeroGen(); } if (gb == null) { gb = ZeroGen(); } return(new PxPre.Phonics.GenLerp(ga, gb, gf)); }
public override PxPre.Phonics.GenBase SpawnGenerator( float freq, float beatsPerSec, int samplesPerSec, float amp, WiringDocument spawnFrom, WiringCollection collection) { if (this.input.IsConnected() == false) { return(ZeroGen()); } PxPre.Phonics.GenBase gb = this.input.Reference.SpawnGenerator( freq, beatsPerSec, samplesPerSec, amp, spawnFrom, collection); bool passOnStut = this.pass.value; bool startOnPlay = this.start.value; float stutterTime = this.stutterTime.GetWavelength(freq, beatsPerSec); float stutterPer = this.stutterPercent.value; // If the parameter is set to something ineffective, // just bypass the stutter and optimize it out. if (stutterPer == 1.0f) { if (startOnPlay == true) { return(gb); } else { return(ZeroGen()); } } if (stutterPer == 0.0f) { if (startOnPlay == true) { return(ZeroGen()); } else { return(gb); } } int windowSamples = (int)(stutterTime * samplesPerSec); windowSamples = Mathf.Max(windowSamples, 2); // int playSamples = (int)(stutterPer * windowSamples); playSamples = Mathf.Max(playSamples, 1); // int stutterSamples = windowSamples - playSamples; if (passOnStut == true) { return (new PxPre.Phonics.GenStutterPass( gb, playSamples, stutterSamples, startOnPlay)); } else { return (new PxPre.Phonics.GenStutterHold( gb, playSamples, stutterSamples, startOnPlay)); } }
public static string ProcessConvertingMatch(System.Text.RegularExpressions.Match m, WiringDocument wd, WiringCollection wc) { if (m.Value == "{<idx>}") { int idx = wc.GetWiringIndex(wd); if (idx == -1) { return("--"); } return((idx + 1).ToString()); } return(m.Value); }
public bool GuessMakesNoise(WiringCollection collection, HashSet <WiringDocument> encountered = null) { if (this.output == null) { return(false); } if (encountered == null) { encountered = new HashSet <WiringDocument>(); } encountered.Add(this); Queue <LLDNBase> toScan = new Queue <LLDNBase>(); toScan.Enqueue(this.output); List <LLDNReference> refs = new List <LLDNReference>(); while (toScan.Count > 0) { LLDNBase check = toScan.Dequeue(); foreach (ParamConnection pc in check.GetParamConnections()) { if (pc.IsConnected() == false) { continue; } LLDNBase gb = pc.Reference; LLDNReference gnr = gb as LLDNReference; if (gnr != null && collection != null) { // Check these after everything else in the current doc. refs.Add(gnr); } else { if (gb.CanMakeNoise() == true) { return(true); } toScan.Enqueue(gb); } } } foreach (LLDNReference gnr in refs) { if (gnr.reference == null) { continue; } WiringDocument wd = collection.GetDocument(gnr.reference.referenceGUID); if (encountered.Contains(wd) == true) { continue; } if (wd.GuessMakesNoise(collection, encountered) == true) { return(true); } } return(false); }