void EigthNotes(ChordProgression p, Random r) { foreach (var c in p.chords) { var numBeats = c.Duration / p.BeatDuration; var maxEigths = numBeats * 2; var numEigthsComposed = 0; while (numEigthsComposed < maxEigths) { var e = 1; if (numEigthsComposed + e > maxEigths) { e = maxEigths - numEigthsComposed; } numEigthsComposed += e; var n = c.Tonic; while (n > 50) { n -= 12; } chords.Add(new PlayableNote( n, e * p.BeatDuration / 2, c.Velocity)); } // Console.WriteLine (numBeats); } }
public Melody(ChordProgression p, Random r, int octave) { int prevNote = -1; OctaveShift = octave; foreach (var c in p.chords) { var numBeats = c.Duration / p.BeatDuration; var maxEigths = numBeats * 2; var numEigthsComposed = 0; while (numEigthsComposed < maxEigths) { var e = 1 + r.Next((3 * maxEigths) / 4); if (numEigthsComposed + e > maxEigths) { e = maxEigths - numEigthsComposed; } numEigthsComposed += e; var n = PickNote(c.Chord.GetNotes(c.Tonic), r, prevNote) + octave * 12; chords.Add(new PlayableNote( n, e * p.BeatDuration / 2, c.Velocity)); } // Console.WriteLine (numBeats); } }
public Section(Random r, ArrangementInstruments ins, ChordProgression prog, int melodyOctave) { this.ins = ins; Progression = prog; Melody = new Melody(Progression, r, melodyOctave); Bassline = new Bassline(Progression, r); Percussion = new PercussionLine(Progression, r); }
void SonClave(ChordProgression p, Random r) { var beatNumber = 0; foreach (var c in p.chords) { var chordBeats = c.Duration / p.BeatDuration; var dur = 4 * p.BeatDuration; Console.WriteLine("Bass dur = {0}", dur); var vel = c.Velocity + 10; var n = c.Tonic; while (n > 50) { n -= 12; } while (chordBeats > 0) { switch (beatNumber) { case 0: chords.Add(new PlayableNote(n, (dur * 3) / 16, vel)); chords.Add(new PlayableNote(n, (dur * 1) / 16, vel)); break; case 1: case 2: chords.Add(new PlayableRest(dur / 8)); chords.Add(new PlayableNote(n, dur / 8, vel)); break; case 3: chords.Add(new PlayableNote(n, dur / 4, vel)); break; } chordBeats--; beatNumber = (beatNumber + 1) % 4; } } }
public Bassline(ChordProgression p, Random r) { // SonClave (p, r); EigthNotes(p, r); }
void Rock(ChordProgression p, Random r) { // // Hi Hat // foreach (var c in p.chords) { var numBeats = c.Duration / p.BeatDuration; var maxEigths = numBeats * 2; var numEigthsComposed = 0; var loud = true; while (numEigthsComposed < maxEigths) { var e = 1; if (numEigthsComposed + e > maxEigths) { e = maxEigths - numEigthsComposed; } numEigthsComposed += e; hiHat.Add(new PlayableNote( 42, e * p.BeatDuration / 2, loud ? c.Velocity : c.Velocity / 2)); loud = !loud; } // Console.WriteLine (numBeats); } // // Bass // var beatNumber = 0; foreach (var c in p.chords) { var chordBeats = c.Duration / p.BeatDuration; while (chordBeats > 0) { switch (beatNumber) { case 0: case 2: bass.Add(new PlayableNote( 36, p.BeatDuration, c.Velocity + 20)); snare.Add(new PlayableRest(p.BeatDuration)); break; case 1: case 3: bass.Add(new PlayableRest(p.BeatDuration)); snare.Add(new PlayableNote( 37, p.BeatDuration, c.Velocity)); break; } chordBeats--; beatNumber = (beatNumber + 1) % 4; } // Console.WriteLine (numBeats); } }
public PercussionLine(ChordProgression p, Random r) { Rock(p, r); }