Ejemplo n.º 1
0
 /// <summary>
 /// Create in the Piano to the passed to Measure?
 /// </summary>
 /// <param name="ID">the noteID</param>
 /// <param name="start">the time when the Note was pressed</param>
 /// <param name="time">the Timing of the Note</param>
 /// <param name="music">The key the music is in</param>
 public Note(int ID, DateTime start, Timing time, Chromatic music)
 {
     NoteID    = ID;
     NoteStart = start;
     NoteTime  = time;
     MusicKey  = music;
 }
Ejemplo n.º 2
0
        /// <summary>
        /// User starts up the Piano and Sheet Music Forms
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void uxOpen_Click(object sender, EventArgs e)
        {
            Chromatic type = Chromatic.Natural;

            if (uxSharp.Checked == true)
            {
                type = Chromatic.Sharp;
            }
            if (uxFlats.Checked)
            {
                type = Chromatic.Flat;
            }

            // Positions the Forms so they aren't on top of each other
            SheetMusic sheet = new SheetMusic();

            sheet.Location = new Point(500, 200);
            Piano piano = new Piano(Convert.ToInt32(BPM.Text), type, sheet);

            piano.Location = new Point(250, 0);

            // Shows the Piano and hides the Main Form
            piano.Show();
            this.Hide();
        }
Ejemplo n.º 3
0
 public Currency(Blacksmith_whetstone blacksmith_whetstone, Armourer_scrap armourer_scrap, Glassblower_bauble glassblower_bauble, Gemcutter_prism gemcutter_prism, Cartographer_chisel cartographer_chisel, Transmutation transmutation, Alteration alteration, Annulment annulment, Chance chance, Augment augment, Exalted exalted, Mirror mirror, Regal regal, Alchemy alchemy, Chaos chaos, Blessed blessed, Divine divine, Jeweller jeweller, Fusing fusing, Chromatic chromatic, Scouring scouring, Regret regret, Vaal vaal, Silver_coin silver_coin, Perandus_coin perandus_coin, Apprentice_sextant apprentice_sextant, Journeyman_sextant journeyman_sextant, Master_sextant master_sextant)
 {
     this.blacksmith_whetstone = blacksmith_whetstone;
     this.armourer_scrap       = armourer_scrap;
     this.glassblower_bauble   = glassblower_bauble;
     this.gemcutter_prism      = gemcutter_prism;
     this.cartographer_chisel  = cartographer_chisel;
     this.transmutation        = transmutation;
     this.alteration           = alteration;
     this.annulment            = annulment;
     this.chance             = chance;
     this.augment            = augment;
     this.exalted            = exalted;
     this.mirror             = mirror;
     this.regal              = regal;
     this.alchemy            = alchemy;
     this.chaos              = chaos;
     this.blessed            = blessed;
     this.divine             = divine;
     this.jeweller           = jeweller;
     this.fusing             = fusing;
     this.chromatic          = chromatic;
     this.scouring           = scouring;
     this.regret             = regret;
     this.vaal               = vaal;
     this.silver_coin        = silver_coin;
     this.perandus_coin      = perandus_coin;
     this.apprentice_sextant = apprentice_sextant;
     this.journeyman_sextant = journeyman_sextant;
     this.master_sextant     = master_sextant;
 }
Ejemplo n.º 4
0
 public static void Main(string[] args)
 {
     if (args.Length == 0)
     {
         Console.WriteLine("Here are some tests:");
         MajorScale CSharpMajor = new MajorScale(Chromatic.Cs);
         CSharpMajor.PrintScale();
         MajorScale FSharpMajor = new MajorScale(Chromatic.Fs);
         FSharpMajor.PrintScale();
         NaturalMinorScale DMinor = new NaturalMinorScale(Chromatic.D);
         DMinor.PrintScale();
         NaturalMinorScale AMinor = new NaturalMinorScale(Chromatic.A);
         AMinor.PrintScale();
     }
     else if (args[0] == "--i")
     {
         bool running = true;
         while (running)
         {
             Console.WriteLine("Enter a musical note -- no flats! (Ex: Cs)");
             string n = Console.ReadLine();
             try
             {
                 Chromatic note = (Chromatic)Enum.Parse(typeof(Chromatic), n);
                 Console.WriteLine("Major (M) or minor (m)?");
                 string s = Console.ReadLine();
                 if (s == "M")
                 {
                     MajorScale scale = new MajorScale(note);
                     scale.PrintScale();
                 }
                 else if (s == "m")
                 {
                     NaturalMinorScale scale = new NaturalMinorScale(note);
                     scale.PrintScale();
                 }
                 else
                 {
                     throw new Exception();
                 }
             }
             catch
             {
                 Console.WriteLine("Sorry, invalid note.");
             }
             Console.WriteLine("Want to try again?  (y/n)");
             string again = Console.ReadLine();
             if (again == "n")
             {
                 running = false;
             }
         }
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// User starts up the Piano and Sheet Music Forms
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void uxOpen_Click(object sender, EventArgs e)
        {
            bool      rests = true;
            Chromatic type  = Chromatic.Natural;

            if (Off.Checked == false && On.Checked == false)
            {
                MessageBox.Show("Must Select to Show Rests or Not before continuing");
            }
            else if (Off.Checked == true && On.Checked == true)
            {
                MessageBox.Show("Must Select only On or Off, not both");
            }
            else if (Off.Checked == true || On.Checked == true)
            {
                if (uxSharp.Checked == true)
                {
                    type = Chromatic.Sharp;
                }
                if (uxFlats.Checked)
                {
                    type = Chromatic.Flat;
                }

                if (On.Checked == true)
                {
                    rests          = true;
                    Off.Checked    = false;
                    Off.CheckState = CheckState.Unchecked;
                    Off.Update();
                    this.Update();
                }
                if (Off.Checked == true)
                {
                    rests         = false;
                    On.Checked    = false;
                    On.CheckState = CheckState.Unchecked;
                    On.Update();
                    this.Update();
                }

                // Positions the Forms so they aren't on top of each other
                SheetMusic sheet = new SheetMusic();
                sheet.Location = new Point(500, 200);
                Piano piano = new Piano(Convert.ToInt32(BPM.Text), type, sheet, rests);
                piano.Location = new Point(250, 0);

                // Shows the Piano and hides the Main Form
                piano.Show();
                this.Hide();
            }
        }
Ejemplo n.º 6
0
 public void FillChromatic(string NoteInfo)
 {
     if (NoteInfo.IndexOf('f') != -1)
     {
         this.TheChromatic = Chromatic.Flat;
     }
     if (NoteInfo.IndexOf('n') != -1)
     {
         this.TheChromatic = Chromatic.Natural;
     }
     if (NoteInfo.IndexOf('s') != -1)
     {
         this.TheChromatic = Chromatic.Sharp;
     }
 }
Ejemplo n.º 7
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="bpm">Beats Per Minute</param>
        /// <param name="type">Chromatic Type</param>
        /// <param name="form">Sheet Music</param>
        public Piano(int bpm, Chromatic type, SheetMusic form)
        {
            InitializeComponent();
            BeatsPerMinute = bpm;
            sheetForm      = form;
            chromatic      = type;
            noteEstimator  = new NoteEstimator(bpm);
            sheetForm.Show();

            // Initializes the Stopwatch Timers
            for (int i = 0; i < oldTimers.Length; i++)
            {
                oldTimers[i]     = new Stopwatch();
                currentTimers[i] = new Stopwatch();
            }
            this.pianoControl.Size = this.Size;
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Gets the Chromatic Unicode for the Note
        /// </summary>
        /// <param name="symbol">The Chromatic value of the pressed note</param>
        /// <returns>The Unicode for the pressed note</returns>
        public string GetChromaticSymbol(Chromatic symbol)
        {
            string unicode = "";

            switch (symbol)
            {
            case Chromatic.Natural:
                unicode = "\u266E";
                break;

            case Chromatic.Flat:
                unicode = "\u266D";
                break;

            case Chromatic.Sharp:
                unicode = "\u266F";
                break;
            }
            return(unicode);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// Sets the Positions for all Keys
        /// </summary>
        /// <param name="blackPressed">The index of the black notes presseed</param>
        /// <param name="whitePressed">The current pressed white note</param>
        /// <param name="type">the Chromatic type of the note</param>
        /// <param name="chrom">If the key is black</param>
        public void SetPositions(int blackPressed, int whitePressed, Chromatic type, bool chrom)
        {
            System.Diagnostics.Debug.WriteLine($"{blackPressed } black note inside function");
            double index = 0;

            for (int i = 0; i < positions.Length; i++)
            {
                // start position will need to change for the left hand
                positions[i] = 425 - index;

                if (whitePressed != -1)
                {
                    index = whitePressed * 7.5;
                }

                if (chrom)
                {
                    if (type == Chromatic.Sharp)
                    {
                        index = blackPressed * 7.5;
                        i++;
                    }
                    else if (type == Chromatic.Flat)
                    {
                        index = (blackPressed + 1) * 7.5;
                        i++;
                    }
                }

                if (positions[i] <= 252.5)
                {
                    positions[i] -= 60; // move to the g clef
                    Global.Handy  = Hand.Right;
                }
                else
                {
                    positions[i] += 70; // adjust for note height difference
                    Global.Handy  = Hand.Left;
                }
            }
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Sets what the Chromatic Value for each notes
        /// </summary>
        /// <param name="isChromatic">indicates if note is black</param>
        /// <param name="type">the Chromatic Value of the note</param>
        /// <returns>whether key pressed needs Chromatic Unicode</returns>
        public bool SetChromatic(bool isChromatic, Chromatic type)
        {
            this.chromValue = type;
            if (isChromatic)
            {
                if (type == Chromatic.Sharp)
                {
                    this.chromValue = Chromatic.Sharp;
                }
                else
                {
                    this.chromValue = Chromatic.Flat;
                }
            }
            else
            {
                this.chromValue = Chromatic.Natural;
            }

            return(isChromatic);
        }
Ejemplo n.º 11
0
        /// <summary>
        /// Constructor
        /// </summary>
        /// <param name="bpm">Beats Per Minute</param>
        /// <param name="type">Chromatic Type</param>
        /// <param name="form">Sheet Music</param>
        public Piano(int bpm, Chromatic type, SheetMusic form, bool rest)
        {
            InitializeComponent();
            sheetForm     = form;
            chromatic     = type;
            rests         = rest;
            noteEstimator = new NoteEstimator(bpm);

            sheetForm.Show();

            // Initializes the Stopwatch Timers
            for (int i = 0; i < oldTimers.Length; i++)
            {
                oldTimers[i]     = new Stopwatch();
                currentTimers[i] = new Stopwatch();
            }
            this.pianoControl.Size = this.Size;

            metronome          = new System.Timers.Timer(noteEstimator.SixteenthCount);
            metronome.Elapsed += OnTick;
        }
Ejemplo n.º 12
0
        public int ChangePosition(double oldY, double currentY, int number, bool chrom, Chromatic oldvalue, out Chromatic chromatic)
        {
            // Not sure to check if measure is completed/how to revert back to old chromatic
            // Return offset or return Chromatic?

            // It's behind one
            chromatic = oldvalue;
            int shiftX = 0;

            if (number >= 2)
            {
                if (oldY == currentY && oldvalue == Chromatic.Flat && chrom == true)
                {
                    chromatic = Chromatic.Sharp;
                    shiftX   -= 20;
                }
                else if (oldY == currentY && oldvalue == Chromatic.Sharp && chrom == true)
                {
                    chromatic = Chromatic.Flat;
                    shiftX    = -20;
                }
                else if ((oldY + 7.5 == currentY || currentY + 7.5 == oldY) && oldvalue == Chromatic.Sharp)
                {
                    shiftX = -20;
                }
                else if ((oldY + 7.5 == currentY || currentY + 7.5 == oldY) && oldvalue == Chromatic.Flat)
                {
                    shiftX = -20;
                }
                else if ((oldY + 7.5 == currentY || currentY + 7.5 == oldY) && chrom == false)
                {
                    shiftX    = 20;
                    chromatic = oldvalue;
                }
            }

            return(shiftX);
        }
Ejemplo n.º 13
0
        public Chromatic ChangePosition(int oldNote, int newNote, int blackNote, int shiftX, Chromatic chromatic)
        {
            int       index    = Array.IndexOf(black52, blackNote);
            Chromatic oldValue = chromatic;

            shiftX = 0;

            /* if newNote + 1 == oldNote and newNote == blackNote
             *  if newNote - 1 == oldNote and newNote == blackNote
             *
             * if newNote + 1 == OldNote and newNote != blackNote
             * if newNote + 2 == OldNote || if newNote - 2 == oldNote
             * */
            if (newNote + 1 == oldNote && newNote == blackKeys[index] - 1)
            {
                // Drawing two flats??
                chromatic = Chromatic.Flat;
                System.Diagnostics.Debug.WriteLine($"{chromatic } chromatic");
            }
            else if (newNote - 1 == oldNote && newNote == blackKeys[index] - 1)
            {
                // Might work better after fixing Keys LIMITATION
                chromatic = Chromatic.Sharp;
                System.Diagnostics.Debug.WriteLine($"{chromatic } chromatic");
            }
            else if (newNote + 2 == oldNote || newNote - 2 == oldNote)
            {
                // Need to account for D E and A B
                // chromatic should go back to what is was before
                chromatic = oldValue;
            }
            else
            {
                chromatic = Chromatic.Natural;
            }

            return(chromatic);
        }
Ejemplo n.º 14
0
 public MusicNote(Chromatic note)
 {
     this.Note = note;
 }
Ejemplo n.º 15
0
 public MajorScale(Chromatic note) : base(note)
 {
     this.Note     = note;
     this.BaseNote = note;
     this.Pos      = 0;
 }
Ejemplo n.º 16
0
 public NaturalMinorScale(Chromatic note) : base(note)
 {
     this.Note     = note;
     this.BaseNote = note;
     this.Pos      = 0;
 }
Ejemplo n.º 17
0
        // For when the Keyboard Note or Mouse Note is released
        private void PianoControl_PianoKeyUp(object sender, PianoKeyEventArgs e)
        {
            if (Global.Handy == Hand.Left)
            {
                leftHand--;
            }
            else if (Global.Handy == Hand.Right)
            {
                rightHand--;
            }

            if (leftHand < 0)
            {
                leftHand = 0;
            }
            if (rightHand < 0)
            {
                rightHand = 0;
            }

            // Setting the Positions
            blackPressed = keys.BlackKeyPress(e.NoteID, out chrom);
            whitePressed = keys.WhiteKeyPress(e.NoteID, out chrom);

            Chromatic oldValue = chromatic;
            int       shiftX   = keys.ChangePosition(oldY, newY, numberPlayed, chrom, oldValue, out chromatic);

            keys.SetPositions(blackPressed, whitePressed, chromatic, chrom);

            sheetForm.SetChromatic(chrom, chromatic);
            oldY = keys.GetPosition(e.NoteID);

            oldTimers[e.NoteID].Stop();
            outDevice.Send(new ChannelMessage(ChannelCommand.NoteOff, 0, e.NoteID, 0));

            currentTimers[e.NoteID] = oldTimers[e.NoteID];
            long duration = currentTimers[e.NoteID].ElapsedMilliseconds.Round(100);

            // Checking for Thirds
            Timing symbols = noteEstimator.GetNoteFromDuration(duration);

            if (symbols == Timing.ThirdHalf || symbols == Timing.ThirdQuart ||
                symbols == Timing.ThirdEigth || symbols == Timing.ThirdSixteen)
            {
                thirds = true;
            }
            else
            {
                thirds = false;
            }

            System.Diagnostics.Debug.WriteLine($"{symbols } timing");
            System.Diagnostics.Debug.WriteLine($"{oldY } old Y Position");
            System.Diagnostics.Debug.WriteLine($"{newY } new Y Position");

            newY = oldY;

            // Globally shared variables
            Global.Symbol    = drawn.GetNoteSymbol(symbols);
            Global.Chromatic = drawn.GetChromaticSymbol(chromatic);
            Timing time;

            Global.Image = drawn.GetImage(symbols, out time);
            Global.Time  = time;

            sheetForm.UpdatePaint(offset + shiftX, thirds, oldY);

            oldTimers[e.NoteID].Reset();
        }