예제 #1
0
        /// <summary>
        /// Toggles a riff at the given position.
        /// </summary>
        /// <param name="newRiff">Riff to toggle.</param>
        /// <param name="pos">Measure to toggle.</param>
        public void ToggleRiff(Riff newRiff, int pos)
        {
            SongPiece songPiece = _songPieces[_songPieceIndices[pos]];
            Measure   measure   = _measures[songPiece.MeasureIndices[0]];

            // For each riff in measure
            foreach (int r in measure.RiffIndices)
            {
                Riff riff = _riffs[r];

                // Skip if riff not the same instrument
                if (riff.Instrument != newRiff.Instrument)
                {
                    continue;
                }

                // Remove riff if it exists
                if (newRiff == riff)
                {
                    measure.RiffIndices.Remove(newRiff.Index);
                }

                // Replace riff with new one
                else
                {
                    measure.RiffIndices.Remove(riff.Index);
                    measure.RiffIndices.InsertSorted <int>(newRiff.Index, false);
                }

                return;
            }

            // Riff not already there
            measure.RiffIndices.InsertSorted <int>(newRiff.Index, false);
        }
예제 #2
0
 /// <summary>
 /// Adds a riff to the song and assigns it an index,
 /// and does the same with all of its beats.
 /// </summary>
 /// <param name="riff">Riff to register.</param>
 public void RegisterRiff(Riff riff)
 {
     riff.Index = _riffs.Count;
     _riffs.Add(riff);
     for (int i = 0; i < 16; i++)
     {
         Beat beat = new Beat();
         beat.Index = _beats.Count;
         riff.BeatIndices.Add(beat.Index);
         _beats.Add(beat);
     }
 }
예제 #3
0
        /// <summary>
        /// Plays all notes at the given position.
        /// </summary>
        /// <param name="pos">Beat at which to play notes.</param>
        public void PlaySongPiece(int pos)
        {
            int     measureNum = pos / 4;
            Song    song       = MusicManager.Instance.CurrentSong;
            Measure measure    = song.Measures[measureNum];

            // Play all riffs
            foreach (int r in measure.RiffIndices)
            {
                Riff riff = song.Riffs[r];
                riff.PlayRiff(pos % 4);
            }
        }
예제 #4
0
        /// <summary>
        /// Adds a riff to the current song.
        /// </summary>
        public Riff AddRiff()
        {
            // Create a new riff
            Riff temp = new Riff();

            // Register the riff with the current song
            _currentSong.RegisterRiff(temp);

            // Update riff editor
            RiffEditor.CurrentRiff = temp;

            // Update song arrange
            SongArrangeMenu.Instance.SelectedRiffIndex = temp.Index;
            SongArrangeMenu.Instance.Refresh();

            return(temp);
        }