public void AddPartial(int startMs, double freqHz, int attackMs, int releaseMs, float level, float balance = 0f, float curve = -4.0f, int bendIndex = -1) { Partial p = Partials.MakePartial(_format.sampleRate, freqHz, attackMs, releaseMs, level, curve); int start = Partials.MsToSamples(startMs, _format.sampleRate); int length = p.envelope.GetLength(); var part = new Part { startSample = start, endSample = start + length, partial = p, balance16 = Partial.MakeBalance16(balance), // -1..1 -> 0..FFFF }; if (0 <= bendIndex) { if (bendIndex < _bends.Count) { part.bend = _bends[bendIndex]; _bends[bendIndex].refCount += 1; } else { } } _parts.Add(part); _parts.Sort(Part.CompareStart); }