public override void invert(int pitch, Tonality tonality)
 {
     foreach (Note n in this.noteList)
     {
         n.invert(pitch, tonality);
     }
 }
 public override void modulate(Tonality oldTonality, int[] targetScale)
 {
     foreach (Note n in this.noteList)
     {
         n.modulate(oldTonality, targetScale);
     }
 }
 public override void RachmaninoffInvert(int pitch, Tonality tonality)
 {
     foreach (Note n in this.noteList)
     {
         n.RachmaninoffInvert(pitch, tonality);
     }
 }
Beispiel #4
0
 internal void harmonizate(Tonality tonality)
 {
     int[] scale = tonality.getScale();
     for (int i = 0; i < this.musicItemList.Count; i++)
     {
         MusicItem mi = musicItemList[i];
         if (mi.isChord())
         {
             continue;
         }
         Note  high  = (Note)mi;
         Chord chord = new Chord();
         chord.add(high);
         int found = 0;
         int pitch = high.getPitch() - 2; // Substracting 2 to avoid 2-intervals
         while (found < 2 && pitch > 0)
         {
             pitch--;
             if (tonality.isinTriad(pitch))
             {
                 chord.add(new Note(pitch, high.getDuration()));
                 found++;
             }
         }
         musicItemList[i] = chord;
     }
 }
Beispiel #5
0
 public void modulate(Tonality oldTonality, int[] targetScale)
 {
     foreach (MusicItem mi in this.musicItemList)
     {
         mi.modulate(oldTonality, targetScale);
     }
 }
Beispiel #6
0
        internal void RachmaninoffInvert()
        {
            foreach (Voice v in this.voiceList)
            {
                v.RachmaninoffInvert(tonality);
            }

            tonality = tonality.getRelative();
        }
Beispiel #7
0
 private Motif(List <Voice> voiceList, int parentId, Variation variation, Tonality tonality, SortedList <Harmony, int> harmonyList)
 {
     this.voiceList   = voiceList;
     this.id          = Tune.generateMotifID();
     this.parentId    = parentId;
     this.variation   = variation;
     this.tonality    = tonality;
     this.name        = "";
     this.harmonyList = harmonyList;
 }
Beispiel #8
0
 /**
  * New motif
  **/
 public Motif()
 {
     this.voiceList   = new List <Voice>();
     this.id          = Tune.generateMotifID();
     this.parentId    = -1;
     this.variation   = new NullVariation();
     this.tonality    = new Tonality();
     this.name        = "";
     this.harmonyList = new SortedList <Harmony, int>();
 }
Beispiel #9
0
        internal void modulate(Tonality newTonality)
        {
            Tonality oldTonality = this.tonality;

            this.tonality = newTonality;

            int[] oldScale = oldTonality.getScale();
            int[] newScale = newTonality.getScale();
            int[] oldTriad = oldTonality.getTriad();
            int[] newTriad = newTonality.getTriad();

            int[] permutatedTriad = Note.getClosestPermutation(oldTriad, newTriad);

            //Si una nota pertenecía a la tonalidad (por lo tanto estará en su escala oldScale[i]), la nota será reemplazada por targetScale[i]
            int[] targetScale = new int[newScale.Count()];

            if (permutatedTriad[0] == newTriad[1])
            {
                targetScale[0] = permutatedTriad[0];
                targetScale[1] = newScale[3];
                targetScale[2] = permutatedTriad[1];
                targetScale[3] = newScale[5];
                targetScale[4] = permutatedTriad[2];
                targetScale[5] = newScale[1];
                targetScale[6] = newScale[1];
                if (Note.getNoteDistance(oldScale[3], newScale[6]) < Note.getNoteDistance(oldScale[3], newScale[5]))
                {
                    targetScale[3] = newScale[6];
                }
            }
            else if (permutatedTriad[0] == newTriad[2])
            {
                targetScale[0] = permutatedTriad[0];
                targetScale[1] = newScale[5];
                targetScale[2] = permutatedTriad[1];
                targetScale[3] = newScale[1];
                targetScale[4] = permutatedTriad[2];
                targetScale[5] = newScale[3];
                targetScale[6] = newScale[3];
                if (Note.getNoteDistance(oldScale[1], newScale[6]) < Note.getNoteDistance(oldScale[1], newScale[5]))
                {
                    targetScale[1] = newScale[6];
                }
            }
            else //Si la triada está sin permutar (permutatedTriad[0] == newTriad[0])
            {
                targetScale = newScale;
            }

            //Aplicamos el transporte voz a voz
            foreach (Voice v in this.voiceList)
            {
                v.modulate(oldTonality, targetScale);
            }
        }
        public override void invert(int p, Tonality tonality)
        {
            if (this.isSilence())
            {
                return;
            }

            int      distance   = this.pitch - p;
            bool     inTonality = tonality.hasNote(p);
            Interval interval   = new Interval(distance, inTonality);

            interval.invert(false, true, true);
            this.pitch = p + interval.toPitch();
        }
Beispiel #11
0
        internal void RachmaninoffInvert(Tonality tonality)
        {
            int mean = this.pitchMean();

            int thirdPitch = tonality.getScale()[2];

            thirdPitch = Note.convertToClosestPitch(mean, thirdPitch);

            //Aplicar inversion
            foreach (MusicItem mi in this.musicItemList)
            {
                mi.RachmaninoffInvert(thirdPitch, tonality);
            }
        }
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            Tonality t = obj as Tonality;

            if ((Tonality)t == null)
            {
                return(false);
            }

            return(this.accidentals == t.accidentals && this.mode == t.mode);
        }
Beispiel #13
0
        public void invert(Tonality tonality)
        {
            int mean = this.pitchMean();

            int tonicPitch = tonality.getTonicPitch();

            if (tonality.getMode() == Tonality.MINOR)
            {
                tonicPitch += 3;
            }

            tonicPitch = Note.convertToClosestPitch(mean, tonicPitch);

            //Apply inversion
            foreach (MusicItem mi in this.musicItemList)
            {
                mi.invert(tonicPitch, tonality);
            }
        }
        public override void modulate(Tonality oldTonality, int[] targetScale)
        {
            if (this.isSilence())
            {
                return;
            }

            int[] oldScale = oldTonality.getScale();

            //Modificamos la altura de la nota solo si pertenecía a la tonalidad.
            for (int i = 0; i < oldScale.Length; i++)
            {
                if (Note.isSameNote(this.pitch, oldScale[i]))
                {
                    this.pitch = convertToClosestPitch(pitch, targetScale[i]);
                    return;
                }
            }
        }
        public override void RachmaninoffInvert(int p, Tonality tonality)
        {
            if (this.isSilence())
            {
                return;
            }

            int doubleDistance = 0;

            if (tonality.getMode() == Tonality.MAJOR)
            {
                doubleDistance = this.pitch * 2 - (p * 2 - 1);
            }
            else
            {
                doubleDistance = this.pitch * 2 - (p * 2 + 1);
            }

            this.pitch -= doubleDistance;
        }
Beispiel #16
0
        internal void interpolate(Tonality tonality)
        {
            int percentage = RNG.generate(10, 50);

            List <int> nonSilentNotes = getNonSilentNotes();

            int number = Math.Max(percentage * nonSilentNotes.Count / 100, 1);

            for (int i = 0; i < number; i++)
            {
                int       element = RNG.generate(0, nonSilentNotes.Count - 1);
                MusicItem mi      = musicItemList[nonSilentNotes[element]];

                int newNotePitch = Note.convertToClosestPitch(mi.pitchMean(), tonality.getRandomPitchFromScale(70));

                /*
                 * SplitNote = true: Divide note length by half and add a random note after it
                 * SplitNote = false: Substitute a silence with a random note.
                 */
                bool splitNote = true;
                if (element != musicItemList.Count - 1 && musicItemList[nonSilentNotes[element] + 1].isSilence() && RNG.generateBool())
                {
                    splitNote = false;
                }

                if (splitNote)
                {
                    mi.changeDuration(new Duration(1, 2));
                    musicItemList.Insert(nonSilentNotes[element] + 1, new Note(newNotePitch, mi.getDuration()));
                }
                else
                {
                    musicItemList[nonSilentNotes[element] + 1] = new Note(newNotePitch, musicItemList[nonSilentNotes[element] + 1].getDuration());
                }

                nonSilentNotes = getNonSilentNotes();
            }
        }
 public abstract void invert(int pitch, Tonality tonality);
Beispiel #18
0
 public void setTonality(Tonality t)
 {
     this.tonality = t;
 }
 public abstract void modulate(Tonality oldTonality, int[] targetScale);
 public abstract void RachmaninoffInvert(int pitch, Tonality tonality);