Пример #1
0
        private void buildTestPattern()
        {
            if (testSong != null && currentArpeggioDefinition != null && !loadingControls)
            {
                initializeTestPattern();
                int     patternIdx    = 0;
                Pattern current       = testSong.Patterns[0];
                int     targetChannel = currentArpeggioDefinition.TargetChannelIdx;

                if (currentArpeggioDefinition.Length > 0)
                {
                    bool noteActive = false;

                    current.PopulateInstruments(targetChannel);

                    int i = 0;
                    while (patternIdx < current.Length)
                    {
                        ChannelNote oldNote = current.Lines[patternIdx].Notes[targetChannel];

                        if (currentArpeggioDefinition.ActiveNotes[i])
                        {
                            ChannelNote note = SerializationUtils.Clone(currentArpeggioDefinition.BaseNote);
                            note.Transpose(currentArpeggioDefinition.Intervals[i], currentArpeggioDefinition.BaseNote.Octave);
                            current.Lines[patternIdx].Notes[targetChannel] = note;
                            noteActive = true;
                        }
                        else if (currentArpeggioDefinition.SilencedNotes[i])
                        {
                            noteActive = false;
                            if (!oldNote.HasValue)
                            {
                                current.Lines[patternIdx].Notes[targetChannel] = ChannelNote.SilenceNote;
                            }
                        }
                        else if (noteActive)
                        {
                            current.Lines[patternIdx].Notes[targetChannel] = ChannelNote.EmptyNote;
                        }

                        patternIdx++;
                        i = (i + 1) % currentArpeggioDefinition.Length;
                    }

                    current.OptimizeInstrumentUsage(targetChannel);
                }
            }
        }
Пример #2
0
        private void pbWave_Paint(object sender, PaintEventArgs e)
        {
            float steps = ((2.0f * MaxArpeggioInterval) + 1);

            RectangleF rectInterval =
                new RectangleF(0, 0, STEP_WIDTH, STEP_HEIGHT);

            Brush currentBrush;
            Point brushPt1 = Point.Empty, brushPt2 = Point.Empty;

            List <int> intervals = getIntervalsForScale();

            float y = 0;

            ChannelNote noteToPaint = SerializationUtils.Clone(this.currentArpeggioDefinition.BaseNote);

            noteToPaint.Transpose(MaxArpeggioInterval, noteToPaint.Octave);

            for (int i = 0; i < steps; i++)
            {
                int remainder = (int)(MaxArpeggioInterval - i) % 12;
                if (remainder < 0)
                {
                    remainder += 12;
                }

                if (intervals.Contains(remainder))
                {
                    e.Graphics.FillRectangle(Brushes.DarkGreen, 0, y, pbWave.ClientRectangle.Width, STEP_HEIGHT);
                }

                e.Graphics.DrawLine(Pens.LimeGreen, 0, y, pbWave.ClientRectangle.Width, y);

                string noteText = string.Format("{0}{1}{2}", noteToPaint.Octave, noteToPaint.Note, noteToPaint.HasSeminote ? "#" : "");
                e.Graphics.DrawString(noteText, this.Font, Brushes.LimeGreen, 0, y);

                y += STEP_HEIGHT;
                noteToPaint.Transpose(-1, noteToPaint.Octave);
            }
            e.Graphics.DrawLine(Pens.LimeGreen, 0, y, pbWave.ClientRectangle.Width, y);

            e.Graphics.DrawLine(Pens.LimeGreen, 0, 0, 0, pbWave.ClientRectangle.Height);

            rectInterval.X = rectInterval.Width;
            for (int i = 0; i < this.currentArpeggioDefinition.Length; i++)
            {
                e.Graphics.DrawLine(Pens.LimeGreen, rectInterval.X, 0, rectInterval.X, pbWave.ClientRectangle.Height);

                if (this.currentArpeggioDefinition.ActiveNotes[i] || this.currentArpeggioDefinition.SilencedNotes[i])
                {
                    int interval = this.currentArpeggioDefinition.Intervals[i];
                    rectInterval.Y = (MaxArpeggioInterval - interval) * STEP_HEIGHT;

                    brushPt1.X = (int)Math.Round(rectInterval.Left + 1);
                    brushPt2.X = (int)Math.Round(rectInterval.Right - 1);

                    if (this.currentArpeggioDefinition.ActiveNotes[i])
                    {
                        currentBrush = new LinearGradientBrush(brushPt1, brushPt2,
                                                               Color.DarkRed, Color.Red);// Brushes.Aqua;

                        e.Graphics.FillRectangle(currentBrush,
                                                 rectInterval.X + 1, rectInterval.Y + 1,
                                                 rectInterval.Width - 2, rectInterval.Height - 2);

                        currentBrush.Dispose();
                    }
                    else
                    {
                        currentBrush = new LinearGradientBrush(brushPt1, brushPt2,
                                                               Color.FromArgb(192, 64, 0), Color.Orange);// Brushes.Aqua;

                        e.Graphics.FillRectangle(currentBrush,
                                                 rectInterval.X + 1, rectInterval.Y + 1,
                                                 rectInterval.Width - 2, rectInterval.Height - 2);

                        currentBrush.Dispose();
                    }
                }
                rectInterval.X += rectInterval.Width;
            }
            e.Graphics.DrawLine(Pens.LimeGreen, rectInterval.X, 0, rectInterval.X, pbWave.ClientRectangle.Height);
        }