Esempio n. 1
0
        public SongReader Transpose(Chord songChord)
        {
            if (_songReader.SongChord.IsMajor() != songChord.IsMajor())
            {
                throw new WrongScaleConversionException(songChord.ToString(), _songReader.SongChord.ToString());
            }

            var result     = new SongReader(songChord);
            int difference = (12 - (_songReader.SongChord.GetPositionOnKeyboard() - songChord.GetPositionOnKeyboard()));

            var newSongIdentities = new List <SongEntity>();

            foreach (var identity in _songReader.SongIdentities)
            {
                if (identity is Chord)
                {
                    Chord oldChord = identity as Chord;
                    Chord newChord = MoveChord(_songReader.SongChord, oldChord, difference);
                    newSongIdentities.Add(newChord);
                }
                else
                {
                    newSongIdentities.Add(identity);
                }
            }
            result.SongIdentities = newSongIdentities;
            return(result);
        }
Esempio n. 2
0
        public SongReader Transpose(int semiTones, bool bSharp)
        {
            Chord newSongChord = MoveChord(_songReader.SongChord, _songReader.SongChord, semiTones);

            var newSongIdentities = new List <SongEntity>();

            foreach (var identity in _songReader.SongIdentities)
            {
                if (identity is Chord)
                {
                    Chord oldChord = identity as Chord;
                    Chord newChord = MoveChord(_songReader.SongChord, oldChord, semiTones);
                    newSongIdentities.Add(newChord);
                }
                else
                {
                    newSongIdentities.Add(identity);
                }
            }
            var result = new SongReader(newSongChord);

            result.SongIdentities = newSongIdentities;
            return(result);
        }
Esempio n. 3
0
 public ChordTransposer(SongReader songReader)
 {
     _songReader = songReader;
 }