public MusicClipSet GetFirstClipSet() { clipSets.Clear(); ChordProgression chordProgression; if (previousChordProgression == null) { chordProgression = chordProgressionLibrary.GetRandomChordProgression(); } else { chordProgression = chordProgressionLibrary.GetRandomChordProgressionOtherThan(previousChordProgression); } previousChordProgression = chordProgression; Key key = GetRandomEnum <Key>(); Rhythm rhythm = GetRandomEnum <Rhythm>(); Tempo tempo = GetRandomEnum <Tempo>(); Debug.Log($"First clip created with Tempo: {tempo}, Rhythm: {rhythm}, Key: {key} and Chord Progression: {chordProgression.name}"); MusicClipSet clipSet = GenerateClipSetWithParameters(key, tempo, rhythm, chordProgression); clipSets.Add(clipSet); return(clipSet); }
public void Create_progression_with_lower_case() { var cp = new ChordProgression("iv v i").SetKey(Key.Default); var pattern = cp.GetPattern(); Assert.Equal("F4MIN G4MIN C4MIN", pattern.ToString(), StringComparer.OrdinalIgnoreCase); }
private void GenerateTutorialClips() { ChordProgression chordProgression = chordProgressionLibrary.GetFirstChordProgression(); Rhythm rhythm = GetRandomEnum <Rhythm>(); Tempo tempo = GetRandomEnum <Tempo>(); Key key = GetRandomEnum <Key>(); for (int i = 0; i < loopCount; i++) { for (int j = 0; j < 2; j++) { MusicalChange change = GetRandomMusicalChange(); if (change == MusicalChange.Tempo) { tempo = GetRandomEnumOtherThan(tempo); } else { rhythm = GetRandomEnumOtherThan(rhythm); } int chordIndex = 0; for (int k = 0; k < 4; k++) { PercussionMusicClip percussionClip = percussionClipLibrary.GetRandomClipWithRhythmAndTempo(rhythm, tempo); InputMusicClip inputClip = inputClipLibrary.GetClipWithInstrumentAndChord( Instrument.ElectricGuitar, KeyNotationToChordHelper.GetChord(key, chordProgression.chords[chordIndex])); MusicClip clip = new MusicClip(percussionClip, inputClip, null); musicMixer.QueueClip(clip); chordIndex++; } } } }
public void Create_progression_without_key() { var cp = new ChordProgression("IV V I"); var pattern = cp.GetPattern(); pattern.ToString().Should().BeEquivalentTo("F4MAJ G4MAJ C4MAJ"); }
public void Test_all_chords_as_with_underscore() { ChordProgression cp = new ChordProgression("I IV V").AllChordsAs("$!i $0q $1h $2w"); cp.GetPattern().ToString().Should().Be("C4MAJi F4MAJi G4MAJi C4MAJq F4MAJh G4MAJw"); cp = new ChordProgression("I IV V").AllChordsAs("$0q $1h $2w $!i"); cp.GetPattern().ToString().Should().Be("C4MAJq F4MAJh G4MAJw C4MAJi F4MAJi G4MAJi"); }
public void Parse(string input, string scaleString, string[] expectedChords) { var chordProgression = ChordProgression.Parse(input, Scale.Parse(scaleString)); CollectionAssert.AreEqual( expectedChords.Select(c => Chord.Parse(c)).ToArray(), chordProgression.Chords, "Chords are invalid."); }
public MusicClipSet(MusicClip[] musicClips, Key key, Rhythm rhythm, Tempo tempo, ChordProgression chordProgression, bool isEmpty) { MusicClips = musicClips; Key = key; Rhythm = rhythm; Tempo = tempo; ChordProgression = chordProgression; IsEmpty = isEmpty; }
public void Test_each_chord_as() { ChordProgression cp = new ChordProgression("iv v i").EachChordAs("$0q $1q $2q"); cp.GetPattern().ToString().Should().Be("F4q G#4q C5q G4q Bb4q D5q C4q Eb4q G4q"); cp = new ChordProgression("I IV V").EachChordAs("$0q $1h $2w"); cp.GetPattern().ToString().Should().Be("C4q E4h G4w F4q A4h C5w G4q B4h D5w"); }
public void Test_all_chords_as() { ChordProgression cp = new ChordProgression("iv v i").AllChordsAs("$0q $1q $2q"); cp.GetPattern().ToString().Should().Be("F4MINq G4MINq C4MINq"); cp = new ChordProgression("I IV V").AllChordsAs("$0q $1h $2w"); cp.GetPattern().ToString().Should().Be("C4MAJq F4MAJh G4MAJw"); }
void CreateChordProgression(Scale scale) { int numberOfChords = 4; chords.Add(new Chord(scale, 1, Chord_Type.MAJ)); for (int i = 0; i < numberOfChords - 1; i++) { chords.Add(ChordProgression.GetNextChordMajor(chords [i])); } }
public void Test_get_chord() { var cp = new ChordProgression("I-vi7-ii-V7"); // This is a turnaround Chord[] chords = cp.SetKey(new Key("Amaj")).GetChords(); var checklist = new List <Chord> { new Chord("A4maj"), new Chord("F#5min7"), new Chord("B4min"), new Chord("E5maj7") }; checklist.SequenceEqual(chords).Should().BeTrue(); }
public ChordProgression GetRandomChordProgressionOtherThan(ChordProgression chordProgression) { List <ChordProgression> otherChordProgressions = new List <ChordProgression>(chordProgressions); if (!otherChordProgressions.Contains(chordProgression)) { Debug.LogError($"Chord progression {chordProgression} not found in the Library"); return(null); } otherChordProgressions.Remove(chordProgression); Random random = new Random(); int index = random.Next(otherChordProgressions.Count); return(otherChordProgressions[index]); }
public static ChordProgression ChordGen(Scale Scale, int duration = 1, int Root = 0, int Offset1 = 2, int Offset2 = 4) { ChordProgression ChordList = new ChordProgression(); ChordList.Chords.Add(new Chord(Scale.Steps[Root], Scale.Steps[Offset1], Scale.Steps[Offset2])); for (int i = 1; i < Scale.Steps.Count * duration; i++) { ChordList.Chords.Add(new Chord( Scale.Steps[i % Scale.Steps.Count], Scale.Steps[(i + Offset1) % Scale.Steps.Count], Scale.Steps[(i + Offset2) % Scale.Steps.Count] )); } return(ChordList); }
internal SongSection(SongInfo songInfo, SectionType type, ChordProgression chordProgression) { Type = type; _songInfo = songInfo; _measures = songInfo.Parameters.MeasuresPerSection(type); Chords = GetChordProgression(songInfo.Parameters.GuitarTuning.Pitches[0], chordProgression); _repeats = songInfo.Parameters.RepeatsPerSection(type, _measures); Lead = SoloLeadGenerator.GetSoloLead(_songInfo, _measures * _songInfo.TimeSignature.BeatCount, Chords); _drumstyle = songInfo.Parameters.DrumStyle(Type); var groove = GetGroove(); _drumstyle.Generate(groove); var riff = RiffGenerator.Rhythm(songInfo.TimeSignature, groove.Beats.ToList(), songInfo.Parameters.RiffResolutionFunc(type), songInfo.Feel).ToList(); _strummer = new RiffStrummer(riff); }
// and keep track of repeating themes to come back to // phrases - maybe pick a length for each upcoming phrase? // dynamics - needs to know if it's in a loud/active part of the song or not // throw in random seeds somewhere to make it more unpredictable? // make close intervals more likely? Or have a setting that determines how likely they are? // there needs to be a musical heuristic - sense of direction // state machine? Different states based on dynamics, activity, phrase length, etc. // maybe one state machine for melody and one for accompaniment // quiet state -> building state (transition) -> big state // we should introduce syncopation as well void Start() { spawnPoints = GameObject.FindGameObjectsWithTag("SpawnPoint"); beatsPerSecond = 60f / tempoBPM; sixteenthsPerSecond = 15f / tempoBPM; nextBeatCounter = beatsPerSecond; // so we get a note on the first beat and arpeggios line up chords = new ChordProgression(0, mode); if (s != null) { Destroy(s); } s = this; frequencyOfArpeggios = Random.Range(0, 10); }
public void DetermineSamplesToAdd(float songPosition) { for (int i = 0; i < chords[currentChord].notes.Length; i++) { AddSampleToScore(samples[chords[currentChord].notes[i]], songPosition); } int lastChord = currentChord; currentChord++; if (currentChord >= chords.Count) { currentChord = 0; } chords [currentChord] = ChordProgression.GetNextChordMajor(chords [lastChord]); }
public static ChordProgression ChordGen(Scale Scale, List <int> ProgPattern, List <int> ColorPattern, int duration = 1, int Root = 1, int Offset1 = 2, int Offset2 = 4) { ChordProgression ChordList = new ChordProgression(); ChordProgression PureList = new ChordProgression(); int counter = 0; //Use Progression Pattern if (ProgPattern != null) { foreach (var chordNum in ProgPattern) { var scaleIndex = chordNum - 1; var root = Scale.Steps[scaleIndex % Scale.Steps.Count]; //Do we need to add an octave? bool octPlus = (scaleIndex + Offset1) >= Scale.Steps.Count; var c2 = Scale.Steps[(scaleIndex + Offset1) % Scale.Steps.Count]; var third = octPlus ? c2 + Scale.Divisions : c2; octPlus = (scaleIndex + Offset2) >= Scale.Steps.Count; var c3 = Scale.Steps[(scaleIndex + Offset2) % Scale.Steps.Count]; var fifth = octPlus ? c3 + Scale.Divisions : c3; var chord = new Chord( root, third, fifth ); if (ColorPattern != null && ColorPattern.Count > 0) { var colorNum = ColorPattern[counter % ColorPattern.Count]; if (colorNum > Scale.Steps.Count) { chord.Notes.Add(Scale.Steps[(scaleIndex + (colorNum - 1)) % Scale.Steps.Count] + Scale.Divisions); } else { chord.Notes.Add(Scale.Steps[(scaleIndex + (colorNum - 1)) % Scale.Steps.Count]); } } PureList.Chords.Add(chord); counter++; } } else //Otherwise default to all scale roots { for (int step = 0; step < Scale.Steps.Count; step++) { var root = Scale.Steps[step % Scale.Steps.Count]; //Do we need to add an octave? bool octPlus = (step + Offset1) >= Scale.Steps.Count; var c2 = Scale.Steps[(step + Offset1) % Scale.Steps.Count]; var third = octPlus ? c2 + Scale.Divisions : c2; octPlus = (step + Offset2) >= Scale.Steps.Count; var c3 = Scale.Steps[(step + Offset2) % Scale.Steps.Count]; var fifth = octPlus ? c3 + Scale.Divisions : c3; var chord = new Chord( root, third, fifth ); if (ColorPattern != null && ColorPattern.Count > 0) { var colorNum = ColorPattern[counter % ColorPattern.Count]; if (colorNum > Scale.Steps.Count) { chord.Notes.Add(Scale.Steps[(step + colorNum) % Scale.Steps.Count] + Scale.Divisions); } else { chord.Notes.Add(Scale.Steps[(step + colorNum) % Scale.Steps.Count]); } } PureList.Chords.Add(chord); counter++; } } for (int i = 0; i < duration; i++) { ChordList.Chords.AddRange(PureList.Chords); } return(ChordList); }
public void Test_each_chord_as_with_underscore() { ChordProgression cp = new ChordProgression("I IV V").EachChordAs("$!q $0q $1h $2w"); cp.GetPattern().ToString().Should().Be("C4MAJq C4q E4h G4w F4MAJq F4q A4h C5w G4MAJq G4q B4h D5w"); }
private List <Tuple <int, Chord> > GetChordProgression(MidiPitch lowestPossibleNote, ChordProgression progression) { var chordList = progression .Chords .Take(Randomizer.Clamp(Randomizer.NextNormalized(3, 1), 2, 3)) .Select(c => TransposeForLowestNote(lowestPossibleNote, TransposeForKey(_songInfo.Parameters.MajorKey, c))) .ToList(); return(AssignChords(chordList, _measures * _songInfo.TimeSignature.BeatCount)); }
public void Create_progression_with_dashes() { var cp = new ChordProgression("I-vi7-ii-V7").SetKey(new Key("Amajw")); var pattern = cp.GetPattern(); // pattern.ToString().Should().BeEquivalentTo("A4MAJw F#5MIN7w B4MINw E5MAJ7w"); }
public static ChordProgression Inversion(ChordProgression chordList, List <int> octList, List <int> inversionList, Key key) { ChordProgression chordInvList = new ChordProgression(); List <int> invOrder = new List <int>(); int specInv; int c1; int c2; int c3; int c4; int counter = 0; foreach (var chord in chordList.Chords) { if (inversionList != null && inversionList.Count != 0) { invOrder = new List <int>(new int[] { 0, 1, 2 }); specInv = inversionList[counter % inversionList.Count]; c1 = NoteLogic.OctaveAdjust(chord.Notes[specInv], octList[counter % octList.Count]); c1 = c1 + key.Offset; invOrder.Remove(specInv); invOrder.Shuffle(); } else { invOrder = new List <int>(new int[] { 0, 1, 2 }); specInv = invOrder[0]; invOrder.Remove(specInv); c1 = NoteLogic.OctaveAdjust(chord.Notes[specInv], octList[counter % octList.Count]); c1 = c1 + key.Offset; } int octShift1; if (invOrder[0] < specInv) { octShift1 = 1; } else { octShift1 = 0; } c2 = NoteLogic.OctaveAdjust(chord.Notes[invOrder[0]], octList[counter % octList.Count] + octShift1); c2 = c2 + key.Offset; int octShift2; if (invOrder[1] < invOrder[0]) { octShift2 = octShift1 + 1; } else { octShift2 = octShift1; } c3 = NoteLogic.OctaveAdjust(chord.Notes[invOrder[1]], octList[counter % octList.Count] + octShift2); c3 = c3 + key.Offset; if (chord.Notes.Count == 4) { c4 = NoteLogic.OctaveAdjust(chord.Notes[3], octList[counter % octList.Count]); c4 = c4 + key.Offset; chordInvList.Chords.Add(new Chord(c1, c2, c3, c4)); } else { chordInvList.Chords.Add(new Chord(c1, c2, c3)); } counter++; } return(chordInvList); }
public void Test_chord_progression_with_inversions() { ChordProgression cp = new ChordProgression("I II^ III^^ IV^^^ v^^^ vi^^ vii^"); cp.GetPattern().ToString().Should().Be("C4MAJ D4MAJ^ E4MAJ^^ F4MAJ^^^ G4MIN^^^ A4MIN^^ B4MIN^"); }
public void Test_all_chords_as_with_underscore_and_inversions() { ChordProgression cp = new ChordProgression("iv v i").AllChordsAs("$!q $!^q $!^^q"); cp.GetPattern().ToString().Should().Be("F4MINq G4MINq C4MINq F4MIN^q G4MIN^q C4MIN^q F4MIN^^q G4MIN^^q C4MIN^^q"); }
public void Test_all_chords_as_and_each_chord_as() { ChordProgression cp = new ChordProgression("I IV V").AllChordsAs("$2 $1 $0").EachChordAs("$2 $1 $0"); cp.GetPattern().ToString().Should().Be("D5 B4 G4 C5 A4 F4 G4 E4 C4"); }
public void Test_all_chords_as_with_inversion() { ChordProgression cp = new ChordProgression("iv v i").AllChordsAs("$0q $0^q $0^^q $1q $1^q $1^^q $2q $2^q $2^^q"); cp.GetPattern().ToString().Should().Be("F4MINq F4MIN^q F4MIN^^q G4MINq G4MIN^q G4MIN^^q C4MINq C4MIN^q C4MIN^^q"); }
public void Test_each_chord_as_with_inversion() { ChordProgression cp = new ChordProgression("iv v i").EachChordAs("$!q $!^q $!^^q"); cp.GetPattern().ToString().Should().Be("F4MINq F4MIN^q F4MIN^^q G4MINq G4MIN^q G4MIN^^q C4MINq C4MIN^q C4MIN^^q"); }