public static void MetalCore() { Music m = new Music(); m.Bpm = 540; MetalCore core = new MetalCore(); Piano piano = new Piano(); Piece Intro = new Piece(); Intro[0].Add(core, PName.OpenHat); Intro[4].Add(core, PName.OpenHat); Intro[8].Add(core, PName.OpenHat); Intro[12].Add(core, PName.OpenHat); Intro.Create(); Intro.Create(); Intro.Create(); #region BKD 段落1 Piece Break1 = new Piece(); Break1[0].Add(core, PName.Crash).Add(core, PName.OpenHat); Break1[4].Add(core, PName.Crash); Break1[8].Add(core, PName.Crash).Add(core, PName.Snare, 1, 16, 60, 1); Break1[12].Add(core, PName.Crash); Break1.Create(); Break1.Create(); Break1.Create(); var kicks = GetRandomUnrepeatArray(0, 15, 5); foreach (int i in kicks) { Break1[i].Add(core, PName.Kick, 1, 2, 60, 0.8F); } #endregion Thread.Sleep(100); #region BKD 段落2 Piece Break2 = new Piece(); Break2[0].Add(core, PName.Crash).Add(core, PName.OpenHat); Break2[4].Add(core, PName.Crash); Break2[8].Add(core, PName.OpenHat).Add(core, PName.Snare, 1, 16, 60, 1); Break2[12].Add(core, PName.Crash); Break2.Create(); Break2.Create(); Break2.Create(); var kicks2 = GetRandomUnrepeatArray(0, 15, 5); foreach (int i in kicks2) { Break2[i].Add(core, PName.Kick, 1, 2, 60, 0.8F); } #endregion Thread.Sleep(100); #region BKD 段落3 Piece Break3 = new Piece(); Break3[0].Add(core, PName.Crash).Add(core, PName.OpenHat); Break3[4].Add(core, PName.Crash); Break3[8].Add(core, PName.OpenHat).Add(core, PName.Snare, 1, 16, 60, 1); Break3[12].Add(core, PName.Crash); Break3.Create(); Break3.Create(); Break3.Create(); var kicks3 = GetRandomUnrepeatArray(0, 15, 5); foreach (int i in kicks3) { Break3[i].Add(core, PName.Kick, 1, 2, 60, 0.8F); } #endregion #region 钢琴段落 Piece mainPiano = new Piece(); Piece pnPiece = new Piece(); pnPiece[0].Add(piano, PName.C, 4, 8, 60, 0.8F); pnPiece[6].Add(piano, PName.F, 4, 8, 60, 0.8F); pnPiece[12].Add(piano, PName.G, 4, 8, 60, 0.8F); pnPiece[18].Add(piano, PName.Bb, 4, 8, 60, 0.8F); pnPiece[24].Add(piano, PName.G, 4, 8, 60, 0.8F); pnPiece[28].Add(piano, PName.F, 4, 8, 60, 0.8F); pnPiece[32 + GetRandom(0, 5)].Add(piano, PName.C, 4, 8, 60, 0.8F); pnPiece[38 + GetRandom(0, 5)].Add(piano, PName.F, 4, 8, 60, 0.8F); pnPiece[44 + GetRandom(0, 5)].Add(piano, PName.G, 4, 8, 60, 0.8F); pnPiece[50 + GetRandom(0, 5)].Add(piano, PName.Bb, 4, 8, 60, 0.8F); pnPiece[56 + GetRandom(0, 5)].Add(piano, PName.G, 4, 8, 60, 0.8F); pnPiece[60 + GetRandom(0, 4)].Add(piano, PName.F, 4, 8, 60, 0.8F); //var pns= GetRandomUnrepeatArray(0, 15, 24); var a = pnPiece[63]; mainPiano.AddPiece(pnPiece); mainPiano.AddPiece(pnPiece); mainPiano.AddPiece(pnPiece); mainPiano.AddPiece(pnPiece); #endregion #region 空段落 Piece empty = new Piece(); //a = empty[63]; #endregion m.AddPiece(Intro); m.AddPiece(Break1); m.AddPiece(Break2); m.AddPiece(Break1); m.AddPiece(Break2); m.AddPiece(Break1); m.AddPiece(Break3); m.AddPiece(Break1); m.AddPiece(Break2); m.AddPiece(Intro); m.AddPiece(Intro); m.AddPiece(Break1); m.AddPiece(Break2); m.AddPieceAt(mainPiano, 16); //m.AddPieceAt(mainPiano, 18); //m.AddPieceAt(mainPiano, 20); //m.AddPieceAt(mainPiano, 22); m.PlayAllLoop(); }
public void Play() { Iinstrument drum = new Drum(); Iinstrument piano = new Piano(); Music m = new Music(); Piece drumPiece = new Piece();//创建段落区块,区块与区块可以合并。 Piece PianoPiece = new Piece(); Piece Intro = new Piece(); //开头 Piece MainPiece = new Piece(); //主歌 m.Bpm = 150; int pieceCount = 0; Piece P1 = new Piece(); Piece P2 = new Piece(); #region 钢琴节奏 Piece pianoRythm = new Piece(); Piece pianoRythm1 = new Piece(); pianoRythm1.Create().Add(piano, PName.F, 2, 8, 60, 0.7F); pianoRythm1.Create().Add(piano, PName.C, 3, 8, 60, 0.7F); pianoRythm1.Create().Add(piano, PName.E, 3, 8, 60, 0.7F); pianoRythm1.Create().Add(piano, PName.C, 3, 8, 60, 0.7F); pianoRythm1.Create().Add(piano, PName.F, 2, 8, 60, 0.7F); pianoRythm1.Create().Add(piano, PName.C, 3, 8, 60, 0.7F); pianoRythm1.Create().Add(piano, PName.E, 3, 8, 60, 0.7F); pianoRythm1.Create().Add(piano, PName.C, 3, 8, 60, 0.7F); Piece pianoRythm2 = new Piece(); pianoRythm2.Create().Add(piano, PName.G, 2, 8, 60, 0.7F); pianoRythm2.Create().Add(piano, PName.B, 2, 8, 60, 0.7F); pianoRythm2.Create().Add(piano, PName.D, 3, 8, 60, 0.7F); pianoRythm2.Create().Add(piano, PName.B, 2, 8, 60, 0.7F); pianoRythm2.Create().Add(piano, PName.G, 2, 8, 60, 0.7F); pianoRythm2.Create().Add(piano, PName.B, 2, 8, 60, 0.7F); pianoRythm2.Create().Add(piano, PName.D, 3, 8, 60, 0.7F); pianoRythm2.Create().Add(piano, PName.B, 2, 8, 60, 0.7F); Piece pianoRythm3 = new Piece(); pianoRythm3.Create().Add(piano, PName.A, 2, 8, 60, 0.7F); pianoRythm3.Create().Add(piano, PName.C, 3, 8, 60, 0.7F); pianoRythm3.Create().Add(piano, PName.E, 3, 8, 60, 0.7F); pianoRythm3.Create().Add(piano, PName.C, 3, 8, 60, 0.7F); pianoRythm3.Create().Add(piano, PName.A, 2, 8, 60, 0.7F); pianoRythm3.Create().Add(piano, PName.C, 3, 8, 60, 0.7F); pianoRythm3.Create().Add(piano, PName.E, 3, 8, 60, 0.7F); pianoRythm3.Create().Add(piano, PName.C, 3, 8, 60, 0.7F); pianoRythm.AddPiece(pianoRythm1); pianoRythm.AddPiece(pianoRythm2); pianoRythm.AddPiece(pianoRythm3); pianoRythm.AddPiece(pianoRythm3); pieceCount = pianoRythm.GetNotes().Count(); pianoRythm.GetNotes().Select(i => i.GetNotes().Select(ii => ii.Volume = 0.3F)); #endregion #region 钢琴主音 Piece pianoSolo = new Piece(); pianoSolo[0].Add(piano, PName.A, 3); pianoSolo[1].Add(piano, PName.E, 4); pianoSolo[2].Add(piano, PName.A, 3); pianoSolo[3].Add(piano, PName.G, 3); pianoSolo[4].Add(piano, PName.A, 3); pianoSolo[11].Add(piano, PName.G, 3); pianoSolo[12].Add(piano, PName.A, 3); pianoSolo[13].Add(piano, PName.E, 4); pianoSolo[14].Add(piano, PName.A, 3); pianoSolo[15].Add(piano, PName.G, 3); pianoSolo[16].Add(piano, PName.A, 3); pianoSolo[17].Add(piano, PName.E, 4); pianoSolo[18].Add(piano, PName.A, 3); pianoSolo[19].Add(piano, PName.G, 3); pianoSolo[20].Add(piano, PName.A, 3); pianoSolo[23].Add(piano, PName.E, 3); pianoSolo[24].Add(piano, PName.G, 3); pianoSolo[27].Add(piano, PName.D, 3); pianoSolo[28].Add(piano, PName.E, 3); pianoSolo[29].Add(piano, PName.G, 3); pianoSolo[30].Add(piano, PName.A, 3); pianoSolo[31].Add(piano, PName.B, 3); pianoSolo[32].Add(piano, PName.A, 3); pianoSolo[33].Add(piano, PName.E, 4); pianoSolo[34].Add(piano, PName.A, 3); pianoSolo[35].Add(piano, PName.G, 3); pianoSolo[36].Add(piano, PName.A, 3); pianoSolo[43].Add(piano, PName.G, 3); pianoSolo[44].Add(piano, PName.A, 3); pianoSolo[45].Add(piano, PName.E, 4); pianoSolo[46].Add(piano, PName.B, 3); pianoSolo[47].Add(piano, PName.C, 4); pianoSolo[48].Add(piano, PName.B, 3); pianoSolo[49].Add(piano, PName.C, 4); pianoSolo[50].Add(piano, PName.B, 3); pianoSolo[51].Add(piano, PName.A, 3); pianoSolo[52].Add(piano, PName.E, 3); pianoSolo[59].Add(piano, PName.D, 3); pianoSolo[60].Add(piano, PName.E, 3); pianoSolo[61].Add(piano, PName.G, 3); pianoSolo[62].Add(piano, PName.A, 3); pianoSolo[63].Add(piano, PName.B, 3); #endregion #region 鼓节奏 Piece DrumPiece1 = new Piece(); DrumPiece1.Create().Add(drum, PName.OpenHat).Add(drum, PName.Kick); DrumPiece1.Create().Add(drum, PName.CloseHat); DrumPiece1.Create().Add(drum, PName.CloseHat).Add(drum, PName.Snare); DrumPiece1.Create().Add(drum, PName.CloseHat); DrumPiece1.Create().Add(drum, PName.CloseHat).Add(drum, PName.Kick); DrumPiece1.Create().Add(drum, PName.CloseHat).Add(drum, PName.Kick); DrumPiece1.Create().Add(drum, PName.CloseHat).Add(drum, PName.Snare); DrumPiece1.Create().Add(drum, PName.CloseHat); DrumPiece1.Create().Add(drum, PName.CloseHat).Add(drum, PName.Kick); DrumPiece1.Create().Add(drum, PName.CloseHat).Add(drum, PName.Kick); DrumPiece1.Create().Add(drum, PName.CloseHat).Add(drum, PName.Snare); DrumPiece1.Create().Add(drum, PName.CloseHat).Add(drum, PName.Kick); DrumPiece1.Create().Add(drum, PName.CloseHat).Add(drum, PName.Kick); DrumPiece1.Create().Add(drum, PName.CloseHat).Add(drum, PName.Kick); DrumPiece1.Create().Add(drum, PName.CloseHat).Add(drum, PName.Snare); DrumPiece1.Create().Add(drum, PName.CloseHat); #endregion P1.AddPiece(pianoRythm); P1.AddPiece(pianoRythm); P1.AddPieceAt(pianoSolo, 0); P2.AddPiece(DrumPiece1); P2.AddPiece(DrumPiece1); P2.AddPiece(DrumPiece1); P2.AddPiece(DrumPiece1); P2.AddPieceAt(P1, 0); m.AddPiece(P1); m.AddPiece(P2); m.PlayAll(); }