public Band() { this.drummer = new Drummer(); this.bassPlayer = new BassPlayer(); this.singer = new Singer(); this.trianglist = new Trianglist(); }
static void Main(string[] args) { Drummer first = new Drummer(); first.name = "John Bonham"; first.band = "Led Zeppelin"; Drummer second = new Drummer("Mitch Mitchell", "Jimi Hendrix Experience"); Drummer third = new Drummer("Keith Moon", "The Who"); Drummer fourth = new Drummer("Jimmy Chamberlin", "The Smashing Pumpkins"); Drummer fifth = new Drummer("Dave Grohl", "Nirvana"); Console.WriteLine("-----------------------"); Console.WriteLine("Top 5 Favorite Drummers"); Console.WriteLine("-----------------------"); Console.WriteLine("1.) Name: " + first.name + " | Band: " + first.band); Console.WriteLine("2.) Name: " + second.name + " | Band: " + second.band); Console.WriteLine("3.) Name: " + third.name + " | Band: " + third.band); Console.WriteLine("4.) Name: " + fourth.name + " | Band: " + fourth.band); Console.WriteLine("5.) Name: " + fifth.name + " | Band: " + fifth.band); }
public override void Run() { // Create a clock running at the specified beats per minute. int beatsPerMinute = 180; Clock clock = new Clock(beatsPerMinute); // Prompt user to choose an output device (or if there is only one, use that one. OutputDevice outputDevice = ExampleUtil.ChooseOutputDeviceFromConsole(); if (outputDevice == null) { Console.WriteLine("No output devices, so can't run this example."); ExampleUtil.PressAnyKeyToContinue(); return; } outputDevice.Open(); // Prompt user to choose an input device (or if there is only one, use that one). InputDevice inputDevice = ExampleUtil.ChooseInputDeviceFromConsole(); if (inputDevice != null) { inputDevice.Open(); } Arpeggiator arpeggiator = new Arpeggiator(inputDevice, outputDevice, clock); Drummer drummer = new Drummer(clock, outputDevice, 4); clock.Start(); if (inputDevice != null) { inputDevice.StartReceiving(clock); } bool done = false; while (!done) { Console.Clear(); Console.WriteLine("BPM = {0}, Playing = {1}, Arpeggiator Mode = {2}", clock.BeatsPerMinute, clock.IsRunning, arpeggiator.Status); Console.WriteLine("Escape : Quit"); Console.WriteLine("Down : Slower"); Console.WriteLine("Up: Faster"); Console.WriteLine("Left: Previous Chord or Scale"); Console.WriteLine("Right: Next Chord or Scale"); Console.WriteLine("Space = Toggle Play"); Console.WriteLine("Enter = Toggle Scales/Chords"); ConsoleKey key = Console.ReadKey(true).Key; Pitch pitch; if (key == ConsoleKey.Escape) { done = true; } else if (key == ConsoleKey.DownArrow) { clock.BeatsPerMinute -= 2; } else if (key == ConsoleKey.UpArrow) { clock.BeatsPerMinute += 2; } else if (key == ConsoleKey.RightArrow) { arpeggiator.Change(1); } else if (key == ConsoleKey.LeftArrow) { arpeggiator.Change(-1); } else if (key == ConsoleKey.Spacebar) { if (clock.IsRunning) { clock.Stop(); if (inputDevice != null) { inputDevice.StopReceiving(); } outputDevice.SilenceAllNotes(); } else { clock.Start(); if (inputDevice != null) { inputDevice.StartReceiving(clock); } } } else if (key == ConsoleKey.Enter) { arpeggiator.ToggleMode(); } else if (ExampleUtil.IsMockPitch(key, out pitch)) { // We've hit a QUERTY key which is meant to simulate a MIDI note, so // send the Note On to the output device and tell the arpeggiator. NoteOnMessage noteOn = new NoteOnMessage(outputDevice, 0, pitch, 100, clock.Time); clock.Schedule(noteOn); arpeggiator.NoteOn(noteOn); // We don't get key release events for the console, so schedule a // simulated Note Off one beat from now. NoteOffMessage noteOff = new NoteOffMessage(outputDevice, 0, pitch, 100, clock.Time + 1); CallbackMessage.CallbackType noteOffCallback = beatTime => { arpeggiator.NoteOff(noteOff); }; clock.Schedule(new CallbackMessage(beatTime => arpeggiator.NoteOff(noteOff), noteOff.Time)); } } if (clock.IsRunning) { clock.Stop(); if (inputDevice != null) { inputDevice.StopReceiving(); } outputDevice.SilenceAllNotes(); } outputDevice.Close(); if (inputDevice != null) { inputDevice.Close(); inputDevice.RemoveAllEventHandlers(); } // All done. }
public override void Run() { if (OutputDevice.InstalledDevices.Count == 0) { Console.WriteLine("Can't do anything with no output device."); return; } float beatsPerMinute = 180; Clock clock = new Clock(beatsPerMinute); OutputDevice outputDevice = OutputDevice.InstalledDevices[0]; outputDevice.Open(); Drummer drummer = new Drummer(clock, outputDevice, 4); InputDevice inputDevice = null; if (InputDevice.InstalledDevices.Count > 0) { // Just pick the first input device. This will throw an exception if there isn't // one. inputDevice = InputDevice.InstalledDevices[0]; inputDevice.Open(); } Scaler scaler = new Scaler(clock, inputDevice, outputDevice); clock.Start(); if (inputDevice != null) { inputDevice.StartReceiving(clock); } bool done = false; while (!done) { Console.Clear(); Console.WriteLine("BPM = {0}, Playing = {1}, Scale = {2}", clock.BeatsPerMinute, clock.IsRunning, scaler.GetScaletoUse()); Console.WriteLine("Escape : Quit"); Console.WriteLine("Down : Slower"); Console.WriteLine("Up: Faster"); Console.WriteLine("Left: Previous Scale"); Console.WriteLine("Right: Next Scale"); Console.WriteLine("Space = Toggle Play"); ConsoleKey key = Console.ReadKey(true).Key; Note note; if (key == ConsoleKey.Escape) { done = true; } else if (key == ConsoleKey.DownArrow) { clock.BeatsPerMinute -= 2; } else if (key == ConsoleKey.UpArrow) { clock.BeatsPerMinute += 2; } else if (key == ConsoleKey.RightArrow) { scaler.NextScale(); } else if (key == ConsoleKey.LeftArrow) { scaler.PreviousScale(); } else if (key == ConsoleKey.Spacebar) { if (clock.IsRunning) { clock.Stop(); if (inputDevice != null) { inputDevice.StopReceiving(); } outputDevice.SilenceAllNotes(); } else { clock.Start(); if (inputDevice != null) { inputDevice.StartReceiving(clock); } } } else if (key == ConsoleKey.D1) { NoteOnMessage msg = new NoteOnMessage(outputDevice, Channel.Channel1, Note.C4, 80, clock.BeatTime); NoteOffMessage msg2 = new NoteOffMessage(outputDevice, Channel.Channel1, Note.C4, 80, clock.BeatTime+0.99f); clock.Schedule(msg); clock.Schedule(msg2); scaler.NoteOn(msg); } else if (ExampleUtil.IsMockNote(key, out note)) { NoteOnMessage noteOn = new NoteOnMessage(outputDevice, 0, note, 100, clock.BeatTime); NoteOffMessage noteOff = new NoteOffMessage(outputDevice, 0, note, 100, clock.BeatTime + 1); clock.Schedule(noteOn); clock.Schedule(noteOff); scaler.NoteOn(noteOn); } } if (clock.IsRunning) { clock.Stop(); if (inputDevice != null) { inputDevice.StopReceiving(); } outputDevice.SilenceAllNotes(); } outputDevice.Close(); if (inputDevice != null) { inputDevice.Close(); } }
public Band() { this.drummer = new Drummer(); this.bassPlayer = new BassPlayer(); this.singer = new Singer(); }
public override void Run() { if (OutputDevice.InstalledDevices.Count == 0) { Console.WriteLine("Can't do anything with no output device."); return; } float beatsPerMinute = 180; Clock clock = new Clock(beatsPerMinute); OutputDevice outputDevice = OutputDevice.InstalledDevices[0]; outputDevice.Open(); Drummer drummer = new Drummer(clock, outputDevice, 4); InputDevice inputDevice = null; if (InputDevice.InstalledDevices.Count > 0) { // Just pick the first input device. This will throw an exception if there isn't // one. inputDevice = InputDevice.InstalledDevices[0]; inputDevice.Open(); } Scaler scaler = new Scaler(clock, inputDevice, outputDevice); clock.Start(); if (inputDevice != null) { inputDevice.StartReceiving(clock); } bool done = false; while (!done) { Console.Clear(); Console.WriteLine("BPM = {0}, Playing = {1}, Scale = {2}", clock.BeatsPerMinute, clock.IsRunning, scaler.GetScaletoUse()); Console.WriteLine("Escape : Quit"); Console.WriteLine("Down : Slower"); Console.WriteLine("Up: Faster"); Console.WriteLine("Left: Previous Scale"); Console.WriteLine("Right: Next Scale"); Console.WriteLine("Space = Toggle Play"); ConsoleKey key = Console.ReadKey(true).Key; Note note; if (key == ConsoleKey.Escape) { done = true; } else if (key == ConsoleKey.DownArrow) { clock.BeatsPerMinute -= 2; } else if (key == ConsoleKey.UpArrow) { clock.BeatsPerMinute += 2; } else if (key == ConsoleKey.RightArrow) { scaler.NextScale(); } else if (key == ConsoleKey.LeftArrow) { scaler.PreviousScale(); } else if (key == ConsoleKey.Spacebar) { if (clock.IsRunning) { clock.Stop(); if (inputDevice != null) { inputDevice.StopReceiving(); } outputDevice.SilenceAllNotes(); } else { clock.Start(); if (inputDevice != null) { inputDevice.StartReceiving(clock); } } } else if (key == ConsoleKey.D1) { NoteOnMessage msg = new NoteOnMessage(outputDevice, Channel.Channel1, Note.C4, 80, clock.BeatTime); NoteOffMessage msg2 = new NoteOffMessage(outputDevice, Channel.Channel1, Note.C4, 80, clock.BeatTime + 0.99f); clock.Schedule(msg); clock.Schedule(msg2); scaler.NoteOn(msg); } else if (ExampleUtil.IsMockNote(key, out note)) { NoteOnMessage noteOn = new NoteOnMessage(outputDevice, 0, note, 100, clock.BeatTime); NoteOffMessage noteOff = new NoteOffMessage(outputDevice, 0, note, 100, clock.BeatTime + 1); clock.Schedule(noteOn); clock.Schedule(noteOff); scaler.NoteOn(noteOn); } } if (clock.IsRunning) { clock.Stop(); if (inputDevice != null) { inputDevice.StopReceiving(); } outputDevice.SilenceAllNotes(); } outputDevice.Close(); if (inputDevice != null) { inputDevice.Close(); } }
public static PlayerUnit create_punit(int ID, int owner_ID) { PlayerUnit pu = null; if (ID == WARRIOR) { pu = new Warrior(); } else if (ID == SPEARMAN) { pu = new Spearman(); } else if (ID == ARCHER) { pu = new Archer(); } else if (ID == MINER) { pu = new Miner(); } else if (ID == INSPIRATOR) { pu = new Inspirator(); } else if (ID == SEEKER) { pu = new Seeker(); } else if (ID == GUARDIAN) { pu = new Guardian(); } else if (ID == ARBALEST) { pu = new Arbalest(); } else if (ID == SKIRMISHER) { pu = new Skirmisher(); } else if (ID == PALADIN) { pu = new Paladin(); } else if (ID == MENDER) { pu = new Mender(); } else if (ID == DRUMMER) { pu = new Drummer(); } else if (ID == PIKEMAN) { pu = new Pikeman(); } else if (ID == CARTER) { pu = new Carter(); } else if (ID == DRAGOON) { pu = new Dragoon(); } else if (ID == SCOUT) { pu = new Scout(); } else if (ID == SHIELD_MAIDEN) { pu = new ShieldMaiden(); } pu.owner_ID = owner_ID; return(pu); }