internal void GetBeforeInterlude3(Clytemnestra clytemnestra, TrkDef wind1, TrkDef furies2, Palette cheepsPalette) { int[] cheepIndices = { 4, 8, 2, 6, 10, 0, 1, 3, 5, 7, 9, 11 }; int[] transpositions = { 2, 1, 3, 0, 4, -3, 5, 10, 6, 9, 7, 8 }; double[] velocityfactors = { 0.32, 0.31, 0.34, 0.3, 0.35, 0.37, 0.36, 0.43, 0.37, 0.42, 0.39, 0.4 }; int[] msPositions = { furies2[8].MsPosition + 200, furies2[12].MsPosition + 100, furies2[24].MsPosition + 300, furies2[30].MsPosition + 400, furies2[40].MsPosition + 500, clytemnestra[122].MsPosition, clytemnestra[132].MsPosition + 110, clytemnestra[141].MsPosition + 220, clytemnestra[150].MsPosition + 330, clytemnestra[158].MsPosition + 440, clytemnestra[164].MsPosition + 550, clytemnestra[173].MsPosition, }; for(int i = 0; i < cheepsPalette.Count; ++i) { MidiChordDef cheep = cheepsPalette.UniqueDurationDef(cheepIndices[i]) as MidiChordDef; Debug.Assert(cheep != null); cheep.MsPosition = msPositions[i]; cheep.MsDuration *= 2; cheep.AdjustVelocities(velocityfactors[i]); cheep.Transpose(transpositions[i]); InsertInRest(cheep); } AlignObjectAtIndex(11, 12, 13, clytemnestra[123].MsPosition); AlignObjectAtIndex(21, 22, 23, clytemnestra[168].MsPosition); }
private void MidiEventDemoButton_Click(object sender, EventArgs e) { Button button = sender as Button; if(button != null) { PaletteForm paletteForm = this._paletteForm as PaletteForm; Palette palette = null; IUniqueDef iud = null; OutputDevice outputDevice = M.Preferences.GetMidiOutputDevice(M.Preferences.PreferredOutputDevice); int midiChannel = 0; int index = int.Parse(button.Text) - 1; if(index >= 0 && index < _midiEventDemoButtons.Count) { if(paletteForm != null) { palette = new Palette(paletteForm); if(palette.IsPercussionPalette) { outputDevice = M.Preferences.GetMidiOutputDevice("Microsoft GS Wavetable Synth"); midiChannel = 9; } } iud = palette.UniqueDurationDef(index); if(iud is RestDef) { _midiEventDemoButtons[index].Hide(); this._restLabels[0].Select(); // just to deselect everything Refresh(); // shows "rest" behind button Thread.Sleep(iud.MsDuration); _midiEventDemoButtons[index].Show(); Refresh(); } else { _midiEventDemoButtons[index].Select(); Refresh(); MidiChordDef midiChordDef = iud as MidiChordDef; Debug.Assert(midiChordDef != null); MidiChord midiChord = new MidiChord(midiChannel, midiChordDef, outputDevice); midiChord.Send(); //sends in this thread (blocks the current thread -- keeping the button selected) } } } }
private void GetSnores(int firstRestMsDuration, Clytemnestra clytemnestra, Trk wind1, Palette snoresPalette) { List<IUniqueDef> snores = new List<IUniqueDef>(); int msPosition = 0; IUniqueDef firstRest = new RestDef(msPosition, firstRestMsDuration); snores.Add(firstRest); msPosition += firstRestMsDuration; #region prelude + verse1 int[] transpositions1 = { 0, 0, 0, 0, 0, 1, 0 }; for(int i = 0; i < 7; ++i) { IUniqueDef snore = snoresPalette.UniqueDurationDef(i); snore.MsPositionReTrk = msPosition; msPosition += snore.MsDuration; MidiChordDef iumdd = snore as MidiChordDef; if(iumdd != null) { iumdd.Transpose(transpositions1[i]); iumdd.PitchWheelDeviation = 3; } snores.Add(snore); RestDef rest = new RestDef(msPosition, 2500); msPosition += rest.MsDuration; snores.Add(rest); } #endregion double factor; double msDuration; double restDuration; int[] transpositions2 = { 1, 1, 2, 2, 3, 3, 4, 4, 5, 5 }; double[] factors = { 0.93, 0.865, 0.804, 0.748, 0.696, 0.647, 0.602, 0.56, 0.52, 0.484 }; for(int i = 0; i < 10; ++i) { IUniqueDef snore = snoresPalette.UniqueDurationDef(i / 2); snore.MsPositionReTrk = msPosition; factor = factors[i]; msDuration = snore.MsDuration * factor; snore.MsDuration = (int)msDuration; msPosition += snore.MsDuration; MidiChordDef iumdd = snore as MidiChordDef; if(iumdd != null) { iumdd.Transpose(transpositions2[i]); iumdd.PitchWheelDeviation = 20; } //iumdd.MidiVelocity = (byte)((double)snore.MidiVelocity * factor * factor); snores.Add(snore); restDuration = 2500 / factor; RestDef rest = new RestDef(msPosition, (int)restDuration); msPosition += rest.MsDuration; snores.Add(rest); } snores[snores.Count - 1].MsDuration = clytemnestra.EndMsPosition - snores[snores.Count - 1].MsPositionReTrk; this._uniqueDefs = snores; AdjustVelocitiesHairpin(13, Count, 0.25); #region alignments before Interlude3 AlignObjectAtIndex(7, 8, 9, clytemnestra[3].MsPositionReTrk); AlignObjectAtIndex(8, 9, 10, clytemnestra[7].MsPositionReTrk); AlignObjectAtIndex(9, 10, 11, clytemnestra[16].MsPositionReTrk); AlignObjectAtIndex(10, 11, 12, clytemnestra[24].MsPositionReTrk); AlignObjectAtIndex(11, 12, 13, clytemnestra[39].MsPositionReTrk); AlignObjectAtIndex(12, 13, 14, clytemnestra[42].MsPositionReTrk); AlignObjectAtIndex(14, 34, Count, wind1[38].MsPositionReTrk); // rest at start of Interlude3 #endregion RemoveScorePitchWheelCommands(0, 13); // pitchwheeldeviation is 20 for R2M }
private void AddGrowlsToInterlude2AndVerse3(Clytemnestra clytemnestra, Palette growlsPalette) { int[] growlIndices = { 0,2,5,1 }; //int[] transpositions = { 0,0,0,0 }; //double[] velocityfactors = { 1,1,1,1 }; int[] msPositions = { this[24].MsPositionReTrk + 200, this[26].MsPositionReTrk + 200, this[30].MsPositionReTrk + 200, this[32].MsPositionReTrk + 200, }; int[] msDurations = { this[24].MsDuration / 2, this[26].MsDuration / 2, this[30].MsDuration / 2, this[32].MsDuration / 2 }; for(int i = 3; i >= 0; --i) { MidiChordDef growl = growlsPalette.UniqueDurationDef(growlIndices[i]) as MidiChordDef; Debug.Assert(growl != null); growl.MsPositionReTrk = msPositions[i]; growl.MsDuration = msDurations[i]; //growl.AdjustVelocities(velocityfactors[i]); //growl.Transpose(transpositions[i]); InsertInRest(growl); } AgglomerateRestOrChordAt(40); AlignObjectAtIndex(34, 35, 36, clytemnestra[140].MsPositionReTrk); AlignObjectAtIndex(35, 36, 37, clytemnestra[141].MsPositionReTrk); AlignObjectAtIndex(38, 39, 40, clytemnestra[162].MsPositionReTrk); }
private void WriteVoiceMidiDurationDefs1(TrkDef trkDef, Palette palette) { int bar1ChordMsSeparation = 1500; int msPosition = 0; for(int i = 0; i < palette.Count;++i) { IUniqueDef noteDef = palette.UniqueDurationDef(i); noteDef.MsPosition = msPosition; RestDef restDef = new RestDef(msPosition + noteDef.MsDuration, bar1ChordMsSeparation - noteDef.MsDuration); msPosition += bar1ChordMsSeparation; trkDef.UniqueDefs.Add(noteDef); trkDef.UniqueDefs.Add(restDef); } }
private TrkDef GetF1Postlude(Palette f1PostludePalette, Krystal krystal, List<int> strandIndices, Dictionary<string, int> msPositions) { TrkDef f1p = f1PostludePalette.NewTrkDef(this.MidiChannel, krystal); List<int> f1eStrandDurations = GetStrandDurations(f1p, strandIndices); for(int i = f1p.Count - 1; i > 0; --i) { if(strandIndices.Contains(i)) { RestDef umrd = new RestDef(f1p[i].MsPosition, f1eStrandDurations[strandIndices.IndexOf(i)] / 4); f1p.Insert(i, umrd); } } f1p.StartMsPosition = msPositions["postlude"]; f1p.RemoveBetweenMsPositions(msPositions["endOfPiece"], int.MaxValue); return f1p; }
private TrkDef GetF1FinalePart1(Palette palette, Krystal krystal, List<int> strandIndices, Dictionary<string, int> msPositions) { TrkDef f1FinalePart1 = palette.NewTrkDef(0, krystal); List<int> f1eStrandDurations = GetStrandDurations(f1FinalePart1, strandIndices); int extraTime = 1000; int diff = extraTime / f1FinalePart1.Count; for(int i = f1FinalePart1.Count - 1; i > 0; --i) { if(strandIndices.Contains(i)) { RestDef umrd = new RestDef(f1FinalePart1[i].MsPosition, f1eStrandDurations[strandIndices.IndexOf(i)] + extraTime); extraTime -= diff; f1FinalePart1.Insert(i, umrd); } } f1FinalePart1.StartMsPosition = msPositions["interlude3Bar2"]; f1FinalePart1.RemoveBetweenMsPositions(msPositions["verse4EsCaped"], int.MaxValue); if(f1FinalePart1[f1FinalePart1.Count - 1] is RestDef) { f1FinalePart1[f1FinalePart1.Count - 1].MsDuration = msPositions["verse4EsCaped"] - f1FinalePart1[f1FinalePart1.Count - 1].MsPosition; } return f1FinalePart1; }
private Trk GetWind3(int midiChannel, Palette palette, Krystal krystal) { Trk wind3 = palette.NewTrk(midiChannel, krystal); wind3.Transpose(0, wind3.Count, -13); wind3.StepwiseGliss(74, wind3.Count, 19); return wind3; }
private void GetFlutters(int firstRestMsDuration, Palette palette) { // each flutter begins with a chord, and ends with a rest. Trk furies3FlutterSequence1 = GetFlutter1(palette); furies3FlutterSequence1.AdjustVelocities(0.7); Trk furies3FlutterSequence2 = GetNextFlutterSequence(furies3FlutterSequence1, 0.89, 1); Trk furies3FlutterSequence3 = GetNextFlutterSequence(furies3FlutterSequence2, 0.89, 1); Trk furies3FlutterSequence4 = GetNextFlutterSequence(furies3FlutterSequence3, 0.89, 1); Trk furies3FlutterSequence5 = GetNextFlutterSequence(furies3FlutterSequence4, 0.89, 1); Trk furies3FlutterSequence6 = GetNextFlutterSequence(furies3FlutterSequence5, 0.89, 2); Trk furies3FlutterSequence7 = GetNextFlutterSequence(furies3FlutterSequence6, 0.89, 2); Trk furies3FlutterSequence8 = GetNextFlutterSequence(furies3FlutterSequence7, 0.89, 2); Trk furies3FlutterSequence9 = GetNextFlutterSequence(furies3FlutterSequence8, 0.89, 3); Trk furies3FlutterSequence10 = GetNextFlutterSequence(furies3FlutterSequence9, 0.89, 3); Trk furies3FlutterSequence11 = GetNextFlutterSequence(furies3FlutterSequence10, 0.89, 4); Trk furies3FlutterSequence12 = GetNextFlutterSequence(furies3FlutterSequence11, 0.89, 5); Furies3 f3 = new Furies3(2, firstRestMsDuration); f3.AddRange(furies3FlutterSequence1); f3.AddRange(furies3FlutterSequence2); f3.AddRange(furies3FlutterSequence3); f3.AddRange(furies3FlutterSequence4); f3.AddRange(furies3FlutterSequence5); f3.AddRange(furies3FlutterSequence6); f3.AddRange(furies3FlutterSequence7); f3.AddRange(furies3FlutterSequence8); f3.AddRange(furies3FlutterSequence9); f3.AddRange(furies3FlutterSequence10); f3.AddRange(furies3FlutterSequence11); f3.AddRange(furies3FlutterSequence12); this._uniqueDefs = f3.UniqueDefs; }
private List<IUniqueDef> GetTicksSequence(Palette ticksPalette) { List<IUniqueDef> ticksSequence = new List<IUniqueDef>(); int msPosition = 0; int[] transpositions = { 12, 14, 17 }; for(int i = 0; i < 3; ++i) { int[] contour = K.Contour(7, 4, 10 - i); for(int j = 6; j >= 0; --j) { IUniqueDef ticks = ticksPalette.UniqueDurationDef(contour[j] - 1); ticks.MsPositionReTrk = msPosition; msPosition += ticks.MsDuration; MidiChordDef iumdd = ticks as MidiChordDef; if(iumdd != null) { iumdd.Transpose(transpositions[i] + contour[j]); iumdd.AdjustVelocities(0.6); } ticksSequence.Add(ticks); } } return ticksSequence; }
private Trk GetFlutter1(Palette palette) { List<IUniqueDef> flutter1 = new List<IUniqueDef>(); int msPosition = 0; for(int i = 0; i < 7; ++i) { int[] contour = K.Contour(7, 11, 7); IUniqueDef flutter = palette.UniqueDurationDef(contour[i] - 1); flutter.MsPositionReTrk = msPosition; msPosition += flutter.MsDuration; flutter1.Add(flutter); if(i != 3 && i != 5) { RestDef rest = new RestDef(msPosition, flutter.MsDuration); msPosition += rest.MsDuration; flutter1.Add(rest); } } Trk furies3FlutterSequence1 = new Trk(this.MidiChannel, flutter1); return furies3FlutterSequence1; }
/// <summary> /// These ticks are "stolen" by Furies2 later. /// </summary> /// <param name="furies3"></param> /// <param name="ticksPalette"></param> private void AddTicks(Palette ticksPalette) { List<int> TickInsertionIndices = new List<int>() { 66,69,72,78,81,84,87, 89,92,95,99,102,105,109, 112,115,119,122,125,129,132 }; List<IUniqueDef> ticksList = GetTicksSequence(ticksPalette); Debug.Assert(TickInsertionIndices.Count == ticksList.Count); // 21 objects for(int i = ticksList.Count-1; i >= 0; --i) { Insert(TickInsertionIndices[i], ticksList[i]); } }
internal void GetChirpsInInterlude2AndVerse3(Trk furies1, Trk furies2, Clytemnestra clytemnestra, Trk wind1, Palette chirpsPalette) { int[] chirpIndices = { 4, 8, 2, 6, 10, 0 }; int[] transpositions = { 2, 1, 3, 0, 4, 5 }; //double[] velocityfactors = { 0.3, 0.31, 0.32, 0.34, 0.35, 0.36, 0.37, 0.39, 0.4, 0.42, 0.43, 0.45 }; double[] velocityfactors = { 0.32, 0.34, 0.36, 0.38, 0.40, 0.42 }; int[] msPositions = { this[112].MsPositionReTrk + 200, this[129].MsPositionReTrk + 500, clytemnestra[118].MsPositionReTrk, clytemnestra[138].MsPositionReTrk + 250, clytemnestra[151].MsPositionReTrk, furies2[57].MsPositionReTrk }; for(int i = 5; i >=0; --i) { MidiChordDef cheep = chirpsPalette.MidiChordDef(chirpIndices[i]); cheep.MsPositionReTrk = msPositions[i]; cheep.AdjustVelocities(velocityfactors[i]); cheep.Transpose(transpositions[i]); InsertInRest(cheep); } AlignObjectAtIndex(25, 30, 31, clytemnestra[65].MsPositionReTrk); AlignObjectAtIndex(140, 141, 142, clytemnestra[119].MsPositionReTrk); AlignObjectAtIndex(142, 143, 144, clytemnestra[140].MsPositionReTrk); AlignObjectAtIndex(144, 145, 146, clytemnestra[152].MsPositionReTrk); AlignObjectAtIndex(146, 147, 148, furies1[23].MsPositionReTrk); AgglomerateRestOrChordAt(114); }
private void AddFuries2ChirpsForInterlude2AndVerse3(Clytemnestra clytemnestra, Trk wind1, Palette chirpsPalette) { int[] chirpIndices = { 4, 6, 10, 0, 1, 3, 5, 7, 9, 11 }; int[] transpositions = { 2, 0, 4, 11, 5, 10, 6, 9, 7, 8 }; double[] velocityfactors = { 0.32, 0.3, 0.35, 0.45, 0.36, 0.43, 0.37, 0.42, 0.39, 0.4 }; IUniqueDef c3 = chirpsPalette.UniqueDurationDef(chirpIndices[3]); IUniqueDef c7 = chirpsPalette.UniqueDurationDef(chirpIndices[7]); int[] msPositions = { this[2].MsPositionReTrk, this[6].MsPositionReTrk, this[16].MsPositionReTrk, this[26].MsPositionReTrk, this[26].MsPositionReTrk + c3.MsDuration, clytemnestra[129].MsPositionReTrk, clytemnestra[143].MsPositionReTrk + 110, clytemnestra[156].MsPositionReTrk + 220, clytemnestra[156].MsPositionReTrk + 220 + c7.MsDuration, clytemnestra[168].MsPositionReTrk + 330, }; for(int i = 9; i >=0 ; --i) { MidiChordDef cheep = chirpsPalette.MidiChordDef(chirpIndices[i]); cheep.MsPositionReTrk = msPositions[i]; //cheep.MsDuration *= 2; cheep.AdjustVelocities(velocityfactors[i]); cheep.Transpose(transpositions[i]); InsertInRest(cheep); } AlignObjectAtIndex(50, 51, 52, clytemnestra[130].MsPositionReTrk); AlignObjectAtIndex(55, 56, 57, clytemnestra[159].MsPositionReTrk); AgglomerateRestOrChordAt(31); }
private TrkDef GetF1FinalePart2(Palette f1FinalePalette2, Krystal krystal, List<int> strandIndices, Dictionary<string, int> msPositions) { TrkDef f1FinalePart2 = f1FinalePalette2.NewTrkDef(this.MidiChannel, krystal); List<int> f1eStrandDurations = GetStrandDurations(f1FinalePart2, strandIndices); int extraTime = 500; int diff = extraTime / f1FinalePart2.Count; for(int i = f1FinalePart2.Count - 1; i > 0; --i) { if(strandIndices.Contains(i)) { RestDef umrd = new RestDef(f1FinalePart2[i].MsPosition, f1eStrandDurations[strandIndices.IndexOf(i)] + extraTime); extraTime -= diff; f1FinalePart2.Insert(i, umrd); } } f1FinalePart2.StartMsPosition = msPositions["verse4EsCaped"]; f1FinalePart2.RemoveBetweenMsPositions(msPositions["verse5Calls"], int.MaxValue); if(f1FinalePart2[f1FinalePart2.Count - 1] is RestDef) { f1FinalePart2[f1FinalePart2.Count - 1].MsDuration = msPositions["postlude"] - f1FinalePart2[f1FinalePart2.Count - 1].MsPosition; } return f1FinalePart2; }
/// <summary> /// Returns either a new RestDef or a new MidiChordDef /// In both cases, MsPosition is set to zero, Lyric is set to null. /// </summary> private DurationDef GetDurationDef() { DurationDef rval = null; if(this.ChordDensityTextBox.Text == "0") { int msDuration = 0; try { msDuration = int.Parse(this.DurationTextBox.Text); } catch { Debug.Assert(false); } Debug.Assert(msDuration > 0); rval = new RestDef(0, msDuration); } else { Palette palette = new Palette(this); rval = palette.MidiChordDef(0); } return rval; }
private void WriteVoiceMidiDurationDefs1(Trk trk, Palette palette) { trk.MsPositionReContainer = 0; int msPositionReFirstIUD = 0; int bar1ChordMsSeparation = 1500; for(int i = 0; i < palette.Count; ++i) { IUniqueDef durationDef = palette.UniqueDurationDef(i); durationDef.MsPositionReFirstUD = msPositionReFirstIUD; RestDef restDef = new RestDef(msPositionReFirstIUD + durationDef.MsDuration, bar1ChordMsSeparation - durationDef.MsDuration); msPositionReFirstIUD += bar1ChordMsSeparation; trk.UniqueDefs.Add(durationDef); trk.UniqueDefs.Add(restDef); } }