Exemplo n.º 1
0
        public void Save_Tone(MusicTrack track)
        {
            backups_tone.Clear();

            foreach (var noteID in Selected_Tone)
            {
                backups_tone.Add(noteID, track.Melody[noteID].Tone);
            }
        }
Exemplo n.º 2
0
        public void Save_Time(MusicTrack track)
        {
            backups_start.Clear();
            backups_end.Clear();

            foreach (var noteID in Selected_Start)
            {
                backups_start.Add(noteID, track.Melody[noteID].Duration.Start);
            }

            foreach (var noteID in Selected_End)
            {
                backups_end.Add(noteID, track.Melody[noteID].Duration.End);
            }
        }
Exemplo n.º 3
0
        public void Restore_Tone(MusicTrack track)
        {
            foreach (var kvp in backups_tone)
            {
                var oldnote =
                    track.Melody[kvp.Key];

                track
                .Melody
                .UpdateNote(
                    kvp.Key,
                    oldnote.Duration,
                    kvp.Value
                    );
            }

            backups_tone.Clear();
        }
Exemplo n.º 4
0
        public void Restore_Time(MusicTrack track)
        {
            foreach (var kvp in backups_start)
            {
                var oldnote =
                    track.Melody[kvp.Key];

                track
                .Melody
                .UpdateNote(
                    kvp.Key,
                    new Duration {
                    Start = kvp.Value,
                    End   = oldnote.Duration.End
                },
                    oldnote.Tone
                    );
            }

            foreach (var kvp in backups_end)
            {
                var oldnote =
                    track.Melody[kvp.Key];

                track
                .Melody
                .UpdateNote(
                    kvp.Key,
                    new Duration {
                    Start = oldnote.Duration.Start,
                    End   = kvp.Value
                },
                    oldnote.Tone
                    );
            }

            backups_start.Clear();
            backups_end.Clear();
        }
Exemplo n.º 5
0
        SemiTone Effect_ToneChanged_affect(SemiTone tone, Time time, int delta, CaretMode mode, MusicTrack track)
        {
            if (mode.HasFlag(CaretMode.Absolute))
            {
                return(new SemiTone(delta));
            }
            else if (!mode.HasFlag(CaretMode.Delta))
            {
                throw new InvalidOperationException();
            }

            if (mode.HasFlag(CaretMode.SemiTones))
            {
                tone += delta;
            }
            else if (mode.HasFlag(CaretMode.WholeTones))
            {
                var keysig =
                    track
                    .Adornment
                    .KeySignatures
                    .Intersecting(time)
                    .First()
                    .Value;

                if (delta > 0)
                {
                    while (delta-- > 0)
                    {
                        tone = keysig.Right(tone);
                    }
                }
                else if (delta < 0)
                {
                    while (delta++ < 0)
                    {
                        tone = keysig.Left(tone);
                    }
                }
            }
            else
            {
                throw new InvalidOperationException();
            }

            return(tone);
        }