Example #1
0
 public static CellState[,] GenerateSong(Automatone automatone, Random random, MusicTheory theory)
 {
     InputParameters.Instance.Tempo = (ushort)(theory.MIN_TEMPO + InputParameters.Instance.SongSpeed * (theory.MAX_TEMPO - theory.MIN_TEMPO));
     InputParameters.Instance.TimeSignatureN = (int)(2 + random.NextDouble() / 4 * (13 - 2));
     InputParameters.Instance.TimeSignatureD = (int)Math.Pow(2, (int)(1 + random.NextDouble() * 2));
     Song s = new Song(theory, random);
     NoteThread thread = new NoteThread(s.Notes, InputParameters.Instance.TimeSignature);
     int gridWidth = s.MeasureCount * s.MeasureLength;
     CellState[,] grid = new CellState[Automatone.PIANO_SIZE,gridWidth];
     foreach (List<Note> nts in s.Notes)
     {
         foreach (Note n in nts)
         {
             grid[n.GetOctave() * MusicTheory.OCTAVE_SIZE + n.GetNoteName().ChromaticIndex - Automatone.LOWEST_NOTE_CHROMATIC_NUMBER, (int)Math.Min(n.GetStartMeasure() * s.MeasureLength + n.GetStartBeat() * Automatone.SUBBEATS_PER_WHOLE_NOTE, gridWidth - 1)] = CellState.START;
             for (int i = 1; i < n.GetRemainingDuration() * Automatone.SUBBEATS_PER_WHOLE_NOTE; i++)
             {
                 if (grid[n.GetOctave() * MusicTheory.OCTAVE_SIZE + n.GetNoteName().ChromaticIndex - Automatone.LOWEST_NOTE_CHROMATIC_NUMBER, (int)Math.Min(n.GetStartMeasure() * s.MeasureLength + n.GetStartBeat() * Automatone.SUBBEATS_PER_WHOLE_NOTE + i, gridWidth - 1)] == CellState.SILENT)
                 {
                     grid[n.GetOctave() * MusicTheory.OCTAVE_SIZE + n.GetNoteName().ChromaticIndex - Automatone.LOWEST_NOTE_CHROMATIC_NUMBER, (int)Math.Min(n.GetStartMeasure() * s.MeasureLength + n.GetStartBeat() * Automatone.SUBBEATS_PER_WHOLE_NOTE + i, gridWidth - 1)] = CellState.HOLD;
                 }
             }
         }
     }
     automatone.MeasureLength = s.MeasureLength;
     return grid;
 }
Example #2
0
 public static String WriteSong(Automatone automatone)
 {
     NoteThread thread = new NoteThread(GridPanel.Instance.SongCells, automatone.MeasureLength, InputParameters.Instance.TimeSignature);
     return thread.ToString();
 }