internal void TonaltySwitchMajMin() { if (ValidSelection) { Program.EditManager.BeforePreformEdit(Info, "修改关系大小调"); for (int i = selectionLeftBeatID; i < selectionRightBeatID; ++i) { Info.beats[i].Tonalty = Tonalty.RelativeTonalty(Info.beats[i].Tonalty); } } }
internal void TonaltyModify(string newTonalty) { if (ValidSelection) { Tonalty tonalty = new Tonalty(newTonalty); Program.EditManager.BeforePreformEdit(Info, "修改调性为" + newTonalty); for (int i = selectionLeftBeatID; i < selectionRightBeatID; ++i) { Info.beats[i].Tonalty = tonalty; } } }
public void PerformInputChordIDUnderTonalty(int id, Tonalty tonalty) { if (ValidPointer) { Chord chord = GetChordFromInputUnderTonalty(id, tonalty); Program.EditManager.BeforePreformEdit(Info, "绘制 " + GetChordLabelTextUnderTonalty(id, tonalty) + " 和弦"); for (int i = pointLeftBeatID; i < pointRightBeatID; ++i) { Info.beats[i].ChordTag = chord; } } }
public void ClickOnChromas(int x, int y) { Tonalty tonalty = GetCurrentTonalty(); if (ChromaMode != TimelineChromaMode.None) { int id = GetChromaID(y); if (ChromaMode != TimelineChromaMode.FrameScale || tonalty.IsOnNaturalScale(id)) { Program.MidiManager.PlaySingleNote(id); } } }
public Chord GetChordFromInputUnderTonalty(int id, Tonalty tonalty) { if (id >= 12) { return(new Chord((Chord.NonChordTypeEnum)(id - 12))); } else if (TL.RelativeLabel && tonalty.Root != -1) { int scale = tonalty.Root + id >= 12 ? tonalty.Root + id - 12 : tonalty.Root + id; return(new Chord(scale, DefaultRelativeMajMin[id] ^ TL.IsShiftDown)); } else { return(new Chord(id, !TL.IsShiftDown)); } }
public void RefreshInterface() { tabControl1_SelectedIndexChanged(null, null); Triggers.ChordLabelChangeTrigger = true; RelativeLabelTonalty = Tonalty.NoTonalty; if (Program.TL != null) { trackBarVolumeMain.DataBindings.Clear(); trackBarVolumeMain.DataBindings.Add("Value", Program.TL, "VolumeMain", true, DataSourceUpdateMode.OnPropertyChanged); trackBarVolumeMIDI.DataBindings.Clear(); trackBarVolumeMIDI.DataBindings.Add("Value", Program.MidiManager, "VolumeNote", true, DataSourceUpdateMode.OnPropertyChanged); trackBarMIDIDelay.DataBindings.Clear(); trackBarMIDIDelay.DataBindings.Add("Value", Program.MidiManager, "NoteDelay", true, DataSourceUpdateMode.OnPropertyChanged); checkBoxAutoPlayChord.DataBindings.Clear(); checkBoxAutoPlayChord.DataBindings.Add("Checked", Program.TL.ChordEditor, "AutoPlayMidi", true, DataSourceUpdateMode.OnPropertyChanged); comboBox_Metre.Text = Program.TL.Info.MetreNumber.ToString(); //if (Program.TL.Info.Tonalty != -1) // comboBox_GLTonalty.SelectedIndex = Program.TL.Info.Tonalty; comboBoxAlignBeats.Items.Clear(); Program.TL.ChordEditor.AlignBeats = new List <int>(); int bd = Program.TL.Info.MetreNumber; for (int i = 1; i < bd; ++i) { if (bd % i == 0) { comboBoxAlignBeats.Items.Add(i + "拍"); Program.TL.ChordEditor.AlignBeats.Add(i); } } int index = comboBoxAlignBeats.Items.Count; for (int i = 1; i *bd <= 12 || i == 1; i *= 2) { comboBoxAlignBeats.Items.Add(i + "小节"); Program.TL.ChordEditor.AlignBeats.Add(i * bd); } comboBoxAlignBeats.SelectedIndex = index; radioButtonAbsolute.DataBindings.Clear(); radioButtonAbsolute.DataBindings.Add("Checked", Program.TL, "NotRelativeLabel", true, DataSourceUpdateMode.OnPropertyChanged); radioButtonRelative.DataBindings.Clear(); radioButtonRelative.DataBindings.Add("Checked", Program.TL, "RelativeLabel", true, DataSourceUpdateMode.OnPropertyChanged); Text = "Edit Mode: " + Program.SoundFileName; } else { Text = "Chord Editor"; } }
public void DrawTonaltyAt(Tonalty tonalty, int graphicPosition, int restrictedLength) { TL.G.DrawString(tonalty.ToString(), tonaltyFont, tonaltyBrush, new Rectangle(graphicPosition, 0, restrictedLength, ChromaTextHeight)); if (tonalty == null) { return; } for (int j = 0; j < 12; ++j) { if (ChromaMode != TimelineChromaMode.FrameScale || tonalty.IsOnNaturalScale(j)) { TL.G.DrawString(tonalty.NoteNameUnderTonalty(j), noteFont, noteBackBrush, new Rectangle(graphicPosition + fontShadowDX, chromaTextStart + (11 - j) * ChromaHeight + fontShadowDY, restrictedLength, ChromaTextHeight)); TL.G.DrawString(tonalty.NoteNameUnderTonalty(j), noteFont, noteFrontBrush, new Rectangle(graphicPosition, chromaTextStart + (11 - j) * ChromaHeight, restrictedLength, ChromaTextHeight)); } } }
private void timer1_Tick(object sender, EventArgs e) { if (Program.TL != null) { Program.TL.Draw(); //if (Triggers.ChordLabelChangeTrigger) //{ Tonalty currentTonalty = Program.TL.ChromaVisualizer.GetCurrentTonalty(); if (Triggers.ChordLabelChangeTrigger || RelativeLabelTonalty.ToString() != currentTonalty.ToString()) { Triggers.ChordLabelChangeTrigger = false; RelativeLabelTonalty = currentTonalty; for (int i = 0; i < 15; ++i) { ChordLabels[i].Text = Program.TL.ChordEditor.GetChordLabelTextUnderTonalty(i, RelativeLabelTonalty); } } //} } }
public void DrawTonalty() { double tempLeftMostTime = TL.LeftMostTime, tempRightMostTime = TL.RightMostTime; int left = BeatEditor.GetPreviousBeatID(tempLeftMostTime) - 1, right = BeatEditor.GetNextBeatID(tempRightMostTime); // Get the previous of previous beat of the left bound and the next beat of the right bound. if (left < 0) { left = 0; } // Tonalty of the last beat is wrong and useless if (right >= Info.beats.Count - 1) { right = Info.beats.Count - 2; } Tonalty lastTonalty = null; int rightPos = TL.TargetRightPos; for (int i = right; i >= left; --i) { int pos = TL.Time2Pos(Info.beats[i].Time); if (pos <= 0) { lastTonalty = Info.beats[i].Tonalty; break; } if (i == 0 || Info.beats[i - 1].Tonalty.ToString() != Info.beats[i].Tonalty.ToString()) { DrawTonaltyAt(Info.beats[i].Tonalty, pos, rightPos - pos); rightPos = pos; } } if (lastTonalty != null) { DrawTonaltyAt(lastTonalty, 0, rightPos); } }
public void DrawChroma() { if (Info.chroma == null) { return; } int lpos = TL.Time2Pos(0); if (lpos < 0) { lpos = 0; } Tonalty tonalty = GetCurrentTonalty(); if (ChromaMode != TimelineChromaMode.None) { if (Prepared) { int pos1 = TL.Time2Pos(0); int pos2 = TL.Time2Pos(Info.MP3Length); for (int j = 0; j < 12; ++j) { if (ChromaMode != TimelineChromaMode.FrameScale || tonalty.IsOnNaturalScale(j)) { if (ChromaMode == TimelineChromaMode.Global) { int percent = (int)((Info.GlobalChroma[j] / Info.MaxGlobalChroma) * 255); TL.G.FillRectangle(new SolidBrush(Color.FromArgb(percent, percent, percent)), new Rectangle(0, ChromaStart + (11 - j) * ChromaHeight, TL.TargetRightPos, ChromaHeight)); } else { TL.G.DrawImage(chromaBitmaps[j], new Rectangle(pos1, ChromaStart + (11 - j) * ChromaHeight, pos2 - pos1, ChromaHeight)); } } } } /*foreach (Chroma.ChromaFrame frame in Info.chroma.Frames) * { * double time = frame.Time; * int pos = TL.Time2Pos(time); * int len = (int)(Info.chroma.FrameLength * TL.TimeScale + 1); * if (pos + len >= 0 && pos <= TL.TargetRightPos) * { * for (int j = 0; j < 12; ++j) * { * int percent = (int)((frame.D[j] / Info.chroma.GlobalMax) * 255); * TL.G.FillRectangle(new SolidBrush(Color.FromArgb(percent, percent, percent)), new Rectangle(pos, ChromaStart + (11 - j) * ChromaHeight, len, ChromaHeight)); * } * } * }*/ } if (TL.IsMouseInControl && TL.CurrentMouseMode == Timeline.MouseMode.Chroma && ChromaMode != TimelineChromaMode.None) { int id = GetChromaID(TL.MousePosY); if (ChromaMode != TimelineChromaMode.FrameScale || tonalty.IsOnNaturalScale(id)) { int pos1 = Math.Max(0, TL.Time2Pos(0)); int pos2 = Math.Max(TL.TargetRightPos - 1, TL.Time2Pos(Info.MP3Length)); TL.G.DrawRectangle(chromaSelectPen, new Rectangle(pos1, ChromaStart + (11 - id) * ChromaHeight, pos2 - pos1, ChromaHeight)); } } }
public string GetChordLabelTextUnderTonalty(int id, Tonalty tonalty) { return(TL.RelativeLabel && tonalty.Root != -1 ? GetChordFromInputUnderTonalty(id, tonalty).ToString(tonalty) : GetChordFromInputUnderTonalty(id, tonalty).ToString()); }