Beispiel #1
0
    public void changeNote(int melody, int chordBass, PitchUtils.ChordType chordType)
    {
        if (!playMusic)
        {
            return;
        }
        curChord     = chordBass;
        curChordType = chordType;
        //Debug.Log("Chord: " + chordBass); // Note is between 0 and 6
        //Debug.Log("Melody: " + melody); // Note is also between 0 and 6

        if (!(melody == prevMelody)) // don't play repeating melody notes
        {
            midiMelody.CurrentNote = getModeNote(melody) + 48;

            midiMelody.PlayOneNote();
            prevMelody = melody;
        }

        if (chordBass == prevChord)
        {
            return;                         // don't play the same chord again if it hasn't changed
        }
        prevChord = chordBass;
        int MidiNote = -1; // We need to map it to the correct Midi Note between 0 and 12

        MidiNote = getModeNote(chordBass);

        int inversion = -1;

        if (melody == chordBass)
        {
            inversion = 1;
        }
        else if ((melody == (chordBass + 3)) || (melody == (chordBass + 4)))
        {
            inversion = 2;
        }

        midiChords.CurrentNote = MidiNote + 48; // put it in a reasonable octave
        if (chordType == PitchUtils.ChordType.Major)
        {
            midiChords.PlayMajorChord(inversion);
        }
        else if (chordType == PitchUtils.ChordType.Minor)
        {
            midiChords.PlayMinorChord(inversion);
        }
        else if (chordType == PitchUtils.ChordType.Dim)
        {
            midiChords.PlayDiminishedChord(inversion);
        }
    }
Beispiel #2
0
 public Chord(int note, PitchUtils.ChordType type)
 {
     this.note        = note;
     this.type        = type;
     this.transitions = new Dictionary <int, List <int> >();
 }