Exemplo n.º 1
0
        private void StartInversion()
        {
            var scale       = ChosenScale;
            var progression = Triad.ChordGen(scale, ProgressionPattern, ColorPattern, Repeat);
            var chordInv    = Triad.Inversion(progression, OctavePattern, InversionPattern, ChosenKey);
            var counter     = 0;

            RemainingCount = chordInv.Chords.Count;

            ThreadPool.QueueUserWorkItem(
                o =>
            {
                foreach (var chord in chordInv.Chords)
                {
                    SetNotes(chord.Notes);

                    MidiLogic.PlayChord(_mOut, SelectedChannel, 127, chord.Notes.ToArray());
                    Thread.Sleep(LengthPattern[counter % LengthPattern.Count]);
                    MidiLogic.StopChord(_mOut, SelectedChannel, 127, chord.Notes.ToArray());
                    counter++;
                    RemainingCount -= 1;
                }
            }
                );
        }
Exemplo n.º 2
0
 private void _mIn_MessageReceived(object sender, MidiInMessageEventArgs e)
 {
     //Only regard event if it matches selected channel
     if (e.MidiEvent.Channel == SelectedChannel)
     {
         if (e.MidiEvent.CommandCode == MidiCommandCode.NoteOn)
         {
             var noteOnEvent = (NoteEvent)e.MidiEvent;
             PlayFromInput(noteOnEvent);
         }
         if (e.MidiEvent.CommandCode == MidiCommandCode.NoteOff)
         {
             var noteEvent = (NoteEvent)e.MidiEvent;
             MidiLogic.StopNote(_mOut, SelectedChannel, noteEvent.NoteNumber);
         }
     }
 }
Exemplo n.º 3
0
        private void PlayFromInput(NoteEvent noteEvent)
        {
            if (noteEvent.Velocity > 0)
            {
                SetInputKey(noteEvent);
            }

            if (!ChordMode)
            {
                S1Value = noteEvent.NoteNumber;
                MidiLogic.PlayNote(_mOut, SelectedChannel, noteEvent.NoteNumber, noteEvent.Velocity);
            }
            else
            {
                var chord = Triad.InputChordGen(noteEvent.NoteNumber, TriadShapeEnum.Major);
                if (noteEvent.Velocity > 0)
                {
                    SetNotes(chord.Notes);
                }

                MidiLogic.PlayChord(_mOut, SelectedChannel, noteEvent.Velocity, chord.Notes.ToArray());
            }
        }
Exemplo n.º 4
0
 private void Strum4E()
 {
     MidiLogic.StopNote(_mOut, SelectedChannel, S4Value);
 }
Exemplo n.º 5
0
 private void Strum4B()
 {
     MidiLogic.PlayNote(_mOut, SelectedChannel, S4Value);
 }
Exemplo n.º 6
0
        private void StartMelody(int line)
        {
            var scale   = ChosenScale;
            int counter = 0;

            ThreadPool.QueueUserWorkItem(
                o =>
            {
                if (ProgressionPattern != null && ProgressionPattern.Count > 0)
                {
                    foreach (var root in ProgressionPattern)
                    {
                        var adjustedNote = NoteLogic.OctaveC[OctavePattern[counter % OctavePattern.Count] + 4] + scale.Steps[root % scale.Steps.Count] + ChosenKey.Offset;

                        switch (line)
                        {
                        case 1:
                            S1Value = adjustedNote;
                            break;

                        case 2:
                            S2Value = adjustedNote;
                            break;

                        case 3:
                            S3Value = adjustedNote;
                            break;

                        case 4:
                            S4Value = adjustedNote;
                            break;
                        }

                        MidiLogic.PlayNote(_mOut, SelectedChannel, adjustedNote);
                        Thread.Sleep(LengthPattern[counter % LengthPattern.Count]);
                        MidiLogic.StopNote(_mOut, SelectedChannel, adjustedNote);
                        counter++;
                    }
                }
                else
                {
                    for (int i = 0; i < scale.Steps.Count; i++)
                    {
                        var adjustedNote = NoteLogic.OctaveC[OctavePattern[counter % OctavePattern.Count] + 4] + scale.Steps[i % scale.Steps.Count] + ChosenKey.Offset;

                        switch (line)
                        {
                        case 1:
                            S1Value = adjustedNote;
                            break;

                        case 2:
                            S2Value = adjustedNote;
                            break;

                        case 3:
                            S3Value = adjustedNote;
                            break;

                        case 4:
                            S4Value = adjustedNote;
                            break;
                        }

                        MidiLogic.PlayNote(_mOut, SelectedChannel, adjustedNote);
                        Thread.Sleep(LengthPattern[counter % LengthPattern.Count]);
                        MidiLogic.StopNote(_mOut, SelectedChannel, adjustedNote);
                        counter++;
                    }
                }
            });
        }