示例#1
0
 //Переход к параметрам трека
 private void параметрыToolStripMenuItem_Click(object sender, EventArgs e)
 {
     menuStop_Click(null, null);
     EditMode = EditModes.Properties;
     DrawAll();
     //if (EditMode != EditModes.Edit & EditMode != EditModes.Select) return;
     //Готовим контролы для диалогового окна
     TControls = new TControl[7];
     TControls[0] = new TControl(34, 8, CurrentProject.SongName, 20);
     TControls[1] = new TControl(34, 10, CurrentProject.AlbumName, 20);
     TControls[2] = new TControl(34, 12, CurrentProject.AutorName, 20);
     TControls[3] = new TControl(40, 14, CurrentProject.PatternLen, 3, 4, Pattern.MaxPatternLen);
     TControls[4] = new TControl(40, 16, CurrentProject.TaktLen, 3, 2, 16);
     TControls[5] = new TControl(31, 18, "   OK   ");
     TControls[6] = new TControl(41, 18, " Отмена ");
     K = 0;
     DrawProperties();
     RefreshScreen();
 }
示例#2
0
        //Управление с клавиатуры
        private void FormMain_KeyDown(object sender, KeyEventArgs e)
        {
            switch (EditMode)
            {
                #region Редактирование паттерна
                case EditModes.Edit:
                    //Оставка плеера, если он запущен
                    if (Audio.player.Mode != Player.Modes.Stop) menuStop_Click(null, null);
                    //Простое перемещение по паттерну
                    if (e.KeyCode == Keys.Up & !e.Shift)
                    {
                        if (Selected) Selected = false;
                        if (PKursorY > 0) PKursorY--;
                        else
                            if (TKursor > 0)
                        {
                            TKursor--;
                            PKursorY = CurrentProject.Patterns[CurrentProject.Track[TKursor]].Len - 1;
                        }
                    }
                    if (e.KeyCode == Keys.Down & !e.Shift)
                    {
                        if (Selected) Selected = false;
                        if (PKursorY < CurrentProject.Patterns[CurrentProject.Track[TKursor]].Len - 1) PKursorY++;
                        else if (TKursor < CurrentProject.TrackLen - 1) { TKursor++; PKursorY = 0; }
                    }
                    if (e.KeyCode == Keys.Left & !e.Shift)
                    {
                        if (Selected) Selected = false;
                        if (PKursorX > 0) { PKursorX--; if (PShift > PKursorX) PShift = PKursorX; }
                    }
                    if (e.KeyCode == Keys.Right & !e.Shift)
                    {
                        if (Selected) Selected = false;
                        if (PKursorX < CurrentProject.ChannelCount - 1)
                        {
                            PKursorX++;
                            if (PShift < PKursorX - Columns + 1) PShift = PKursorX - Columns + 1;
                            DrawPattern();
                        }
                    }
                    //Выделение
                    if (e.KeyCode == Keys.Up & e.Shift)
                    {
                        StartSelect();
                        if (PKursorY > 0) { PKursorY--; SelectY2 = PKursorY; }
                    }
                    if (e.KeyCode == Keys.Down & e.Shift)
                    {
                        StartSelect();
                        if (PKursorY < CurrentProject.Patterns[CurrentProject.Track[CurrentProject.Track[TKursor]]].Len - 1)
                        { PKursorY++; SelectY2 = PKursorY; }
                    }
                    if (e.KeyCode == Keys.Left & e.Shift)
                    {
                        StartSelect();
                        if (PKursorX > 0) { PKursorX--; SelectX2 = PKursorX; if (PShift > PKursorX) PShift = PKursorX; }
                    }
                    if (e.KeyCode == Keys.Right & e.Shift)
                    {
                        StartSelect();
                        if (PKursorX < CurrentProject.ChannelCount - 1)
                        {
                            PKursorX++;
                            SelectX2 = PKursorX;
                            if (PShift < PKursorX - Columns + 1) PShift = PKursorX - Columns + 1;
                            DrawPattern();
                        }
                    }
                    //Нота
                    int key = KeyToNote(e, true);
                    if (key > 0) //Проигрывание ноты
                    {
                        CurrentProject.Patterns[CurrentProject.Track[TKursor]].Note[PKursorX, PKursorY] = (byte)key;
                        Audio.PlayTrack(CurrentProject, TKursor, PKursorY);
                        PKursorY += AutoStep;
                        if (PKursorY >= CurrentProject.Patterns[CurrentProject.Track[TKursor]].Len)
                            PKursorY -= CurrentProject.Patterns[CurrentProject.Track[TKursor]].Len;
                        HistoryChange();
                    }
                    if (e.KeyCode == Keys.Space & !e.Control) //Расстановка пробелоа
                    {
                        PKursorY += AutoStep;
                        if (PKursorY >= CurrentProject.Patterns[CurrentProject.Track[TKursor]].Len)
                            PKursorY -= CurrentProject.Patterns[CurrentProject.Track[TKursor]].Len;
                    }
                    //Проигрывание позиции
                    if (e.KeyCode == Keys.Enter & !e.Control) Audio.PlayTrack(CurrentProject, TKursor, PKursorY);
                    //Копипаст и прочее редактирование
                    if (e.KeyCode == Keys.Delete && e.Shift) menucut_Click(null, null);     //Shift + Del - вырезать
                    if (e.KeyCode == Keys.Insert && e.Control) menucopy_Click(null, null);  //Ctrl + Insert - копировать
                    if (e.KeyCode == Keys.Insert && e.Shift) menupaste_Click(null, null);   //Shift + Insert - вставить
                    if (e.KeyCode == Keys.Delete) Delete();                                 //Delete - удалить
                    //Регулирование параметров
                    if (e.KeyCode == Keys.NumPad1) { Octave = 1; Flash = 10; FlashParam = 1; }
                    if (e.KeyCode == Keys.NumPad2) { Octave = 2; Flash = 10; FlashParam = 1; }
                    if (e.KeyCode == Keys.NumPad3) { Octave = 3; Flash = 10; FlashParam = 1; }
                    if (e.KeyCode == Keys.NumPad4) { Octave = 4; Flash = 10; FlashParam = 1; }
                    if (e.KeyCode == Keys.NumPad5) { Octave = 5; Flash = 10; FlashParam = 1; }
                    if (e.KeyCode == Keys.NumPad6) { Octave = 6; Flash = 10; FlashParam = 1; }
                    if (e.KeyCode == Keys.Add & !e.Control)
                    {
                        CurrentProject.Tempo++;
                        if (CurrentProject.Tempo > 999) CurrentProject.Tempo = 999;
                        Flash = 10;
                        FlashParam = 0;
                        HistoryChange();
                    }
                    if (e.KeyCode == Keys.Subtract & !e.Control)
                    {
                        CurrentProject.Tempo--;
                        if (CurrentProject.Tempo < 1) CurrentProject.Tempo = 1;
                        Flash = 10;
                        FlashParam = 0;
                        HistoryChange();
                    }
                    if (e.KeyCode == Keys.Multiply)
                    {
                        AutoStep++;
                        if (AutoStep > 4) AutoStep = 4;
                        Flash = 10;
                        FlashParam = 2;
                    }
                    if (e.KeyCode == Keys.Divide)
                    {
                        AutoStep--;
                        if (AutoStep == 255) AutoStep = 0;
                        Flash = 10;
                        FlashParam = 2;
                    }
                    //Быстрые натсройки микшера
                    if (e.KeyCode == Keys.Add & e.Control)
                    {
                        if (CurrentProject.Channels[PKursorX].Volume < 100) CurrentProject.Channels[PKursorX].Volume += 5;
                        Flash = 10;
                        FlashParam = 3;
                        HistoryChange();
                    }
                    if (e.KeyCode == Keys.Subtract & e.Control)
                    {
                        if (CurrentProject.Channels[PKursorX].Volume > 0) CurrentProject.Channels[PKursorX].Volume -= 5;
                        Flash = 10;
                        FlashParam = 3;
                        HistoryChange();
                    }
                    if (e.KeyCode == Keys.Space & e.Control) { MuteTogle(PKursorX); Flash = 10; FlashParam = 4; DrawPanel(); }
                    if (e.KeyCode == Keys.Enter & e.Control) { OnAllChannels(); Flash = 10; FlashParam = 4; DrawPanel(); }
                    if (e.KeyCode == Keys.S & e.Control & e.Alt) { Solo(PKursorX); Flash = 10; FlashParam = 4; DrawPanel(); }
                    if (e.KeyCode == Keys.Tab) EditMode = EditModes.Track;
                    DrawTrack();
                    DrawPattern();
                    DrawPanel();
                    Refresh();
                    break;
                #endregion
                #region Редактирование трека
                case EditModes.Track:
                    if (Audio.player.Mode != Player.Modes.Stop) menuStop_Click(null, null);
                    //Простое перемещение по треку
                    if (e.KeyCode == Keys.Left & !e.Control & TKursor > 0) { TKursor--; PKursorY = 0; }
                    if (e.KeyCode == Keys.Right & !e.Control & TKursor < CurrentProject.TrackLen - 1) { TKursor++; PKursorY = 0; }
                    //Перемещение паттернов
                    if (e.KeyCode == Keys.Left & e.Control & TKursor > 0)
                    {
                        int temp = CurrentProject.Track[TKursor - 1];
                        CurrentProject.Track[TKursor - 1] = CurrentProject.Track[TKursor];
                        CurrentProject.Track[TKursor] = temp;
                        TKursor--;
                        HistoryChange();
                    }
                    if (e.KeyCode == Keys.Right & e.Control & TKursor < CurrentProject.TrackLen - 1)
                    {
                        int temp = CurrentProject.Track[TKursor + 1];
                        CurrentProject.Track[TKursor + 1] = CurrentProject.Track[TKursor];
                        CurrentProject.Track[TKursor] = temp;
                        TKursor++;
                        HistoryChange();
                    }
                    //Создание нового паттерна
                    if (e.KeyCode == Keys.N && PushPats())
                    {
                        //Находим минимальный доступный номер
                        int n = 0;
                        bool est;
                        do
                        {
                            est = false;
                            for (int i = 0; i < CurrentProject.TrackLen; i++)
                                if (CurrentProject.Track[i] == n) est = true;
                            if (est) n++;
                        } while (est);
                        //Надо ли создавать новый паттерн, или воскрешать удалённый
                        if (n >= CurrentProject.Patterns.Count)
                        {
                            if (n < Project.MaxPatternsCound)
                            {
                                CurrentProject.Patterns.Add(new Pattern(CurrentProject.PatternLen));
                                CurrentProject.Track[++TKursor] = n;
                                PKursorY = 0;
                                HistoryChange();
                            }
                        }
                        else
                        {
                            CurrentProject.Track[++TKursor] = n;
                            PKursorY = 0;
                            HistoryChange();
                        }
                    }
                    //Дублирование паттерна
                    if (e.KeyCode == Keys.D && PushPats())
                    {
                        CurrentProject.Track[++TKursor] = CurrentProject.Track[TKursor - 1];
                        HistoryChange();
                    }
                    //Клонирование паттерна
                    if (e.KeyCode == Keys.C && PushPats())
                    {
                        //Находим минимальный доступный номер
                        int n = 0;
                        bool est;
                        do
                        {
                            est = false;
                            for (int i = 0; i < CurrentProject.TrackLen; i++)
                                if (CurrentProject.Track[i] == n) est = true;
                            if (est) n++;
                        } while (est);
                        //Создаём новый паттерн и копируем в него предыдущий (ох.... тестировать будет мучительно)
                        if (n < CurrentProject.Patterns.Count)
                            CurrentProject.Patterns[n] = new Pattern(CurrentProject.Patterns[CurrentProject.Track[TKursor]].Len);
                        else
                            CurrentProject.Patterns.Add(new Pattern(CurrentProject.Patterns[CurrentProject.Track[TKursor]].Len));
                        CurrentProject.Track[TKursor + 1] = n;
                        CurrentProject.Patterns[n].Len = CurrentProject.Patterns[CurrentProject.Track[TKursor]].Len;
                        for (int i = 0; i < Pattern.MaxPatternLen; i++)
                            for (int j = 0; j < Audio.MaxChannels; j++)
                                CurrentProject.Patterns[n].Note[j, i] = CurrentProject.Patterns[CurrentProject.Track[TKursor]].Note[j, i];
                        PKursorY = 0;
                        TKursor++;
                        HistoryChange();
                    }
                    //Удаление паттерна
                    if (e.KeyCode == Keys.Delete & CurrentProject.TrackLen > 1)
                    {
                        for (int i = TKursor; i < CurrentProject.TrackLen; i++)
                            CurrentProject.Track[i] = CurrentProject.Track[i + 1];
                        CurrentProject.TrackLen--;
                        if (TKursor > CurrentProject.TrackLen - 1) TKursor = CurrentProject.TrackLen - 1;
                        PKursorY = 0;
                        HistoryChange();
                    }
                    //Изменение размера паттерна
                    if (e.KeyCode == Keys.Add)
                    {
                        CurrentProject.Patterns[CurrentProject.Track[TKursor]].ResizeBy(1);
                        Flash = 10;
                        HistoryChange();
                    }
                    if (e.KeyCode == Keys.Subtract)
                    {
                        CurrentProject.Patterns[CurrentProject.Track[TKursor]].ResizeBy(-1);
                        Flash = 10;
                        if (PKursorY > CurrentProject.Patterns[CurrentProject.Track[TKursor]].Len - 1)
                            PKursorY = CurrentProject.Patterns[CurrentProject.Track[TKursor]].Len - 1;
                        HistoryChange();
                    }
                    if (e.KeyCode == Keys.Escape | e.KeyCode == Keys.Enter | e.KeyCode == Keys.Tab) EditMode = EditModes.Edit;
                    DrawTrack();
                    DrawPattern();
                    DrawPanel();
                    Refresh();
                    break;
                #endregion
                #region Параметры трека и настройки синтезатора и микшер
                case EditModes.Properties:
                    if (Audio.player.Mode != Player.Modes.Stop) menuStop_Click(null, null); //Оставка плеера, если он запущен
                    if (e.KeyCode == Keys.Left | e.KeyCode == Keys.Up | (e.KeyCode == Keys.Tab & e.Shift))
                    { TControls[K].ToInt32(); K--; if (K < 0) K = 6; }
                    if (e.KeyCode == Keys.Right | e.KeyCode == Keys.Down | (e.KeyCode == Keys.Tab & !e.Shift))
                    { TControls[K].ToInt32(); K++; if (K > 6) K = 0; }
                    //if (e.KeyCode == Keys.Tab & e.Shift) { K--; if (K < 0) K = TControls.Count() - 1; }
                    if (e.KeyCode == Keys.Back) TControls[K].DeleteLastChar();
                    if (e.KeyCode == Keys.Add) TControls[K].Add();
                    if (e.KeyCode == Keys.Subtract) TControls[K].Sub();
                    DrawControls();
                    RefreshScreen();
                    if (e.KeyCode == Keys.Enter)
                    {
                        if (K == 6)
                        {
                            EditMode = EditModes.Edit;
                            DrawAll();
                        }
                        else
                        {
                            //Пользователь хочет применить изменения пропертисов
                            int oldPatternLen = CurrentProject.PatternLen;
                            CurrentProject.SongName = TControls[0].ToString();
                            CurrentProject.AlbumName = TControls[1].ToString();
                            CurrentProject.AutorName = TControls[2].ToString();
                            CurrentProject.PatternLen = Convert.ToInt32(TControls[3].ToInt32());
                            CurrentProject.TaktLen = Convert.ToInt32(TControls[4].ToInt32());
                            if (CurrentProject.PatternLen == oldPatternLen)
                            {
                                EditMode = EditModes.Edit;
                                DrawAll();
                                HistoryChange();
                            }
                            else
                            {
                                EditMode = EditModes.PropertiesApply;
                                TControls = new TControl[2];
                                TControls[0] = new TControl(25, 14, " Изменить ");
                                TControls[1] = new TControl(37, 14, " Только для новых ");
                                K = 0;
                                DrawPropertiesApply();
                            }
                        }
                    }
                    if (e.KeyCode == Keys.Escape) { EditMode = EditModes.Edit; DrawAll(); }
                    break;
                #endregion
                #region Вопрос об изменении размера имеющихся паттернов
                case EditModes.PropertiesApply:
                    if (e.KeyCode == Keys.Up | e.KeyCode == Keys.Down | e.KeyCode == Keys.Left | e.KeyCode == Keys.Right |
                        e.KeyCode == Keys.Tab)
                    { K = 1 - K; DrawControls(); RefreshScreen(); }
                    if (e.KeyCode == Keys.Enter)
                    {
                        if (K == 0)
                        {
                            //Изменяем длину всех паттернов
                            foreach (Pattern pat in CurrentProject.Patterns) pat.Resize(CurrentProject.PatternLen);
                            if (PKursorY >= CurrentProject.PatternLen) PKursorY = CurrentProject.PatternLen - 1;
                            HistoryChange();
                        }
                        EditMode = EditModes.Edit;
                        DrawAll();
                    }
                    if (e.KeyCode == Keys.Escape) { EditMode = EditModes.Edit; DrawAll(); }
                    break;
                #endregion
                #region Настройка синтезатора
                case EditModes.SinSetup:
                    if (Audio.player.Mode != Player.Modes.Stop) menuStop_Click(null, null); //Оставка плеера, если он запущен
                    if (TControls[K].Type != TControl.Types.Table)
                    {
                        if (e.KeyCode == Keys.Left | e.KeyCode == Keys.Up) K--;
                        if (e.KeyCode == Keys.Right | e.KeyCode == Keys.Down) K++;
                    }
                    else
                    {
                        if (e.KeyCode == Keys.Left && TControls[K].TabControl(TControl.Keys.Left)) K--;
                        if (e.KeyCode == Keys.Up && TControls[K].TabControl(TControl.Keys.Up)) K--;
                        if (e.KeyCode == Keys.Right && TControls[K].TabControl(TControl.Keys.Right)) K++;
                        if (e.KeyCode == Keys.Down && TControls[K].TabControl(TControl.Keys.Down)) K++;
                        if (e.KeyCode == Keys.Delete) { TControls[K].TabControl(TControl.Keys.Del); HistoryChange(); }
                    }
                    if (e.KeyCode == Keys.Back) { TControls[K].DeleteLastChar(); HistoryChange(); }
                    if (e.KeyCode == Keys.Add) { TControls[K].Add(); HistoryChange(); }
                    if (e.KeyCode == Keys.Subtract) { TControls[K].Sub(); HistoryChange(); }
                    if (e.KeyCode == Keys.Tab & !e.Shift) { K++; if (K > TControls.Count() - 1) K = 0; }
                    if (e.KeyCode == Keys.Tab & e.Shift) { K--; if (K < 0) K = TControls.Count() - 1; }
                    if (K < 0) K = TControls.Count() - 1;
                    if (K > TControls.Count() - 1) K = 0;
                    //Если выбран другой канал
                    if (PKursorX != TControls[0].ToInt32())
                    {
                        PKursorX = TControls[0].ToInt32();
                        настройкаToolStripMenuItem_Click(null, null);
                    }
                    //Что если длина или повтор орнамента изменились, меняем его контрол
                    TControls[7].Max = TControls[6].ToInt32();// - 1;
                    TControls[8].TabResize(TControls[6].ToInt32(), TControls[7].ToInt32());
                    DrawControls();
                    RefreshScreen();
                    //Поменялись длины атаки и затухания
                    CurrentProject.Channels[PKursorX].Atack = TControls[3].ToInt32();
                    CurrentProject.Channels[PKursorX].Hold = TControls[4].ToInt32();
                    CurrentProject.Channels[PKursorX].FadeOut = TControls[5].ToInt32();
                    //Если хотим просто воспроизвести ноту
                    int note = KeyToNote(e, false);
                    if (note > 0) Audio.player.sinthesizer[PKursorX].Play(note);
                    //Копируем канал в другой
                    if (e.KeyCode == Keys.Enter & K == 2)
                    {
                        CurrentProject.Channels[TControls[1].ToInt32()] =
                            (Channel)CurrentProject.Channels[TControls[0].ToInt32()].Copy();

                        TXT.PrintAT(51, 3, 0, 14, "Скопировано!");
                        Refresh();
                    }
                    //Выходим из настройки синтезатора
                    if (e.KeyCode == Keys.Escape | (e.KeyCode == Keys.Enter & K != 2)) { EditMode = EditModes.Edit; DrawAll(); }
                    break;
                #endregion
                #region Настройка микшера
                case EditModes.Mixer:
                    if (e.KeyCode == Keys.Left)
                    {
                        if (PKursorX > 0)
                        {
                            PKursorX--;
                            if (PShift > PKursorX) PShift = PKursorX;
                        }
                    }
                    if (e.KeyCode == Keys.Right)
                    {
                        if (PKursorX < CurrentProject.ChannelCount - 1)
                        {
                            PKursorX++;
                            if (PShift < PKursorX - Columns + 1) PShift = PKursorX - Columns + 1;
                        }
                    }
                    if (e.KeyCode == Keys.Add && CurrentProject.Channels[PKursorX].Volume < 100)
                    {
                        CurrentProject.Channels[PKursorX].Volume += 5;
                        HistoryChange();
                    }
                    if (e.KeyCode == Keys.Subtract && CurrentProject.Channels[PKursorX].Volume > 0)
                    {
                        CurrentProject.Channels[PKursorX].Volume -= 5;
                        HistoryChange();
                    }
                    //Переключатели Mute
                    if (e.KeyCode == Keys.Space) MuteTogle(PKursorX);
                    if (e.KeyCode == Keys.S) Solo(PKursorX);
                    if (e.KeyCode == Keys.Enter) OnAllChannels();
                    DrawAll();
                    DrawMixer();
                    Refresh();
                    if (e.KeyCode == Keys.Escape) { EditMode = EditModes.Edit; menuStop_Click(null, null); DrawAll(); }
                    break;
                #endregion

            }
        }
示例#3
0
 //Переход к настройке синтезатора
 private void настройкаToolStripMenuItem_Click(object sender, EventArgs e)
 {
     menuStop_Click(null, null);
     EditMode = EditModes.SinSetup;
     DrawAll();
     //if (EditMode != EditModes.Edit & EditMode != EditModes.Select) return;
     TControls = new TControl[10];
     TControls[0] = new TControl(23, 3, PKursorX, 3, 0, CurrentProject.ChannelCount - 1);
     TControls[1] = new TControl(46, 3, PKursorX, 3, 0, CurrentProject.ChannelCount - 1);
     TControls[2] = new TControl(51, 3, " Копировать ");
     TControls[3] = new TControl(27, 5, CurrentProject.Channels[PKursorX].Atack, 3, 0, 999);
     TControls[4] = new TControl(43, 5, CurrentProject.Channels[PKursorX].Hold, 3, 0, 999);
     TControls[5] = new TControl(59, 5, CurrentProject.Channels[PKursorX].FadeOut, 3, 0, 999);
     TControls[6] = new TControl(36, 9, CurrentProject.Channels[PKursorX].Len, 2, 1, 64);
     TControls[7] = new TControl(48, 9, CurrentProject.Channels[PKursorX].Repeat, 2, 0, 63);
     TControls[8] = new TControl(26, 12, CurrentProject.Channels[PKursorX]);
     TControls[9] = new TControl(53, 23, " Закрыть ");
     K = 0;
     DrawSinSetup();
     RefreshScreen();
 }