Beispiel #1
0
        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);
        }
Beispiel #2
0
 static void AddNote(PartialProvider pp, double cents, Partial[] partials)
 {
     foreach (Partial p in partials)
     {
         double c     = cents + p.rational.ToCents();
         double hz    = Partials.CentsToHz(c);
         double level = Math.Pow(p.harmonicity, 7.0f);
         pp.AddPartial(
             hz,
             10, (int)(2000 * p.harmonicity),
             (float)(level / partials.Length),
             -4f
             );
     }
     pp.FlushPartials();
 }
Beispiel #3
0
 static void AddNote(PartialTimeline timeline, int startMs, double cents, Partial[] partials, int bendIndex = -1)
 {
     foreach (Partial p in partials)
     {
         double c     = cents + p.rational.ToCents();
         double hz    = Partials.CentsToHz(c);
         double level = Math.Pow(p.harmonicity, 2.0f); // !!! was 7.0f
         timeline.AddPartial(
             startMs,
             hz,
             10, (int)(2000 * p.harmonicity),
             level: (float)(level / partials.Length),
             balance: 0f,
             curve: -4f,
             bendIndex: bendIndex
             );
     }
 }
Beispiel #4
0
        static void AddNote(PartialProvider pp, Rational r0)
        {
            string[] rs = new string[] { "1", "2", "3", "4", "81/16", "6" };
            float [] ls = new float [] { 1f, .04f, .8f, .08f, .8f, .1f };

            double c0 = r0.ToCents();

            for (int i = 0; i < rs.Length; ++i)
            {
                Rational r  = Rational.Parse(rs[i]);
                double   c  = c0 + r.ToCents();
                double   hz = Partials.CentsToHz(c);
                pp.AddPartial(
                    hz,
                    10, (int)(2000 * ls[i]),
                    ls[i] * .1f,
                    -4f
                    );
            }
            pp.FlushPartials();
        }
Beispiel #5
0
        public void AddPartial(double freqHz, int attackMs, int releaseMs, float level, float curve = -4.0f)
        {
            Partial p = Partials.MakePartial(_format.sampleRate, freqHz, attackMs, releaseMs, level, curve);

            _preparedPartials.Add(p);
        }
Beispiel #6
0
        public void AddFrequency(double freqHz, int durationMs, float level)
        {
            Partial p = Partials.MakeFrequency(_format.sampleRate, freqHz, durationMs, level);

            _preparedPartials.Add(p);
        }
Beispiel #7
0
 public void MakeStep()   // !!! might be IBend.MakeStep()
 {
     currentFactor   = Partials.CentsToFactor(_currentSample * centsPerSample);
     _currentSample += 1;
 }