public static object Pratnja() { MelodyBase melody = new MelodyAtomic(new object[] { 0, 2 }, 2); MelodyComposite melodyComp = new MelodyComposite("A A1 A2 Ar1", melody); Melody12Tone m12tone = new Melody12Tone(melodyComp, TwelveToneSet.majorScale, 64); return(m12tone); }
public static Melody12Tone Albinoni() { RhythmPattern rhythm = new RhythmPattern(3, 4, "1h.qh.q 1 2"); MelodyBase melody = new MelodyAtomic(rhythm, new object[] { 4, 3, 2, 1, 0, 0, -1 }); MelodyComposite melodyComp = new MelodyComposite("AA+", melody); Melody12Tone m12tone = new Melody12Tone(melodyComp, TwelveToneSet.minorHarmonicScale, 64, 100); return(m12tone); }
public static Melody12Tone MrSandman() { MelodyBase melody = new MelodyAtomic(new object[] { 0, 2, 4, 6 }, 2); var melody2 = new MelodyReversed(new MelodyDiffEnd(melody, new[] { new NoteWithDuration(5, new Fraction(1, 2)) })); MelodyComposite melodyComp = new MelodyComposite("ABA+", melody, melody2); Melody12Tone m12tone = new Melody12Tone(melodyComp, TwelveToneSet.majorScale, 60, 150); return(m12tone); }
public static Melody12Tone OggyMelody() { RhythmPattern rhythm = new RhythmPattern(3, 2, "hh11"); MelodyBase melody = new MelodyAtomic(rhythm, new object[] { 0, 1, 2, 0 }); MelodyBase melodyEnd = new MelodyAtomic(new RhythmPattern(3, 2, "3"), new object[] { 0 }); MelodyComposite melody2 = new MelodyComposite("AA-A--B", melody, melodyEnd); Melody12Tone m12tone = new Melody12Tone(melody2, TwelveToneSet.minorScale, 64, 100); return(m12tone); }
static void Main(string[] args) { if (args.Length < 1) { Console.WriteLine("Playing all songs:"); foreach (MethodInfo mi in typeof(Compositions).GetMethods()) { if (mi.GetParameters().Length == 0 && mi.ReturnType == typeof(Melody12Tone)) { Console.Write(mi.Name + " "); Main(new[] { mi.Name }); Console.WriteLine(); Console.WriteLine("Wait for 1 second..."); Thread.Sleep(1000); } } Console.WriteLine(); return; } if (args.Length == 2 && args[0] == "midi") { var composition = MidiFileReader.Read(args[1]); composition.PlayBack( note => { midiOut.Send(MidiMessage.StartNote(note, 100, 1).RawData); midiOut.Send(MidiMessage.StartNote(note + 4, 100, 1).RawData); }, note => midiOut.Send(MidiMessage.StopNote(note, 100, 1).RawData)); return; } if (args[0] == "RandomSequencer") { RandomSequencer(); return; } MethodInfo miStatic = typeof(Compositions).GetMethod(args[0]); Func <Melody12Tone> dgComposition = Delegate.CreateDelegate(typeof(Func <Melody12Tone>), miStatic) as Func <Melody12Tone>; Melody12Tone m12tone = dgComposition(); List <int> lastnotes = new List <int>(); foreach (var nwd in m12tone.Notes()) { foreach (int note in lastnotes) { midiOut.Send(MidiMessage.StopNote(note, 100, 1).RawData); } // Play the note, and if it's pause mute the last note if (!nwd.IsPause) { Note note = nwd; lastnotes = new List <int>(); do { midiOut.Send(MidiMessage.StartNote(note.note, 100, 1).RawData); lastnotes.Add(note.note); //note = note.otherNote; } while (false /*note != null*/); } else { foreach (var note in lastnotes) { midiOut.Send(MidiMessage.StartNote(note, 0, 1).RawData); } } Fraction fract = nwd.Duration; Console.Write(fract + " "); Thread.Sleep(60 * 1000 * fract.p / fract.q / m12tone.tempo); } // Mute the last note(s) foreach (var note in lastnotes) { midiOut.Send(MidiMessage.StartNote(note, 0, 1).RawData); } }