Пример #1
0
        public static void play(List <MyNote> lista, int t, OutputDevice outputDevice)
        {
            MyComposition newComp = new MyComposition(t);

            foreach (MyNote n in lista)
            {
                newComp.addNote(n);
            }

            int positionStatic      = 0;
            int totalDurationStatic = 0;
            int beatLengthStatic    = 60000 / t;


            Clock clock = new Clock(t);

            foreach (MyNote n in lista)
            {
                totalDurationStatic += n.myDurationInBeats * beatLengthStatic;
                clock.Schedule(n.noteStart(outputDevice, positionStatic));
                positionStatic += n.myDurationInBeats;
                clock.Schedule(n.noteEnd(outputDevice, positionStatic));
            }
            clock.Start();
            Thread.Sleep(totalDurationStatic + 1000); // 1 additional second
            clock.Stop();
        }
Пример #2
0
        private void btnN6_Click(object sender, EventArgs e)
        {
            MyComposition comp1 = new MyComposition(formTempo);

            comp1.addNote(generatedNotes.ElementAt(5));
            comp1.play(outputDevice);
        }
Пример #3
0
        private void button16_Click(object sender, EventArgs e)
        {
            List <MyNote> posledni   = composition.getLastSix();
            MyComposition singleNote = new MyComposition(formTempo);

            singleNote.addNote(posledni.ElementAt(5));
            singleNote.play(outputDevice);
        }
Пример #4
0
        //----------------------------------- PANEL -------------------------------------------------------------------


        private void fillPanel()
        {
            panel1.Controls.Clear();
            int radioY        = 53;
            int buttonY       = 10;
            int counter       = 0;
            int currentButton = 10;
            int currentRadio  = 37;
            int increment     = 80;

            foreach (MyNote n in composition.getListNotes())
            {
                panel1.HorizontalScroll.Value = 0;

                Button      button      = new Button();
                RadioButton radioButton = new RadioButton();

                button.Height     = 40;
                button.Width      = 70;
                radioButton.Width = 35;

                //button.Tag = counter;
                radioButton.Tag = counter;


                button.Location      = new Point(currentButton, buttonY);
                radioButton.Location = new Point(currentRadio, radioY);

                compositionHistory.Add(new Components(button, radioButton));

                currentRadio  += increment;
                currentButton += increment;

                button.Text = n.ToString();

                button.Click += (s, e) => {
                    MyComposition comp = new MyComposition(formTempo);
                    comp.addNote(n);
                    comp.play(outputDevice);
                };

                panel1.Controls.Add(button);
                panel1.Controls.Add(radioButton);

                panel1.ScrollControlIntoView(button);
                counter++;
            }
        }
Пример #5
0
        //  -----------------------------------  ADD NOTE ---------------------------------------------------------

        private void btnAddNote_Click(object sender, EventArgs e)
        {
            List <MyNote> toDebug = generatedNotes;

            var checkedButton = gbNotes.Controls.OfType <RadioButton>()
                                .FirstOrDefault(r => r.Checked);

            if (checkedButton == null)
            {
                return;
            }

            if (rbN1.Checked)
            {
                composition.addNote(new MyNote(generatedNotes.ElementAt(0).myPitch, generatedNotes.ElementAt(0).myDurationInBeats));
                rbN1.Checked = false;
            }
            if (rbN2.Checked)
            {
                composition.addNote(new MyNote(generatedNotes.ElementAt(1).myPitch, generatedNotes.ElementAt(1).myDurationInBeats));
                rbN2.Checked = false;
            }
            if (rbN3.Checked)
            {
                composition.addNote(new MyNote(generatedNotes.ElementAt(2).myPitch, generatedNotes.ElementAt(2).myDurationInBeats));
                //composition.addNote(generatedNotes.ElementAt(2));
                rbN6.Checked = false;
            }
            if (rbN4.Checked)
            {
                composition.addNote(new MyNote(generatedNotes.ElementAt(3).myPitch, generatedNotes.ElementAt(3).myDurationInBeats));
                rbN3.Checked = false;
            }
            if (rbN5.Checked)
            {
                composition.addNote(new MyNote(generatedNotes.ElementAt(4).myPitch, generatedNotes.ElementAt(4).myDurationInBeats));
                rbN4.Checked = false;
            }
            if (rbN6.Checked)
            {
                composition.addNote(new MyNote(generatedNotes.ElementAt(5).myPitch, generatedNotes.ElementAt(5).myDurationInBeats));
                rbN5.Checked = false;
            }

            fillPanel();
            //showLastSix();
            generateNotes(); //generate new six notes on each note addition to the composition
            clearGeneratedChecked();
            picGraph.Invalidate();
            //Invalidate();
        }
Пример #6
0
        private void PlaySample_Click(object sender, EventArgs e)
        {
            MyComposition comp = new MyComposition(formTempo);

            comp.addNote(new MyNote(64, 1));
            comp.addNote(new MyNote(64, 1));
            comp.addNote(new MyNote(65, 1));
            comp.addNote(new MyNote(67, 1));
            comp.addNote(new MyNote(67, 1));
            comp.addNote(new MyNote(65, 1));
            comp.addNote(new MyNote(64, 1));
            comp.addNote(new MyNote(62, 1));
            comp.addNote(new MyNote(60, 1));
            comp.addNote(new MyNote(60, 1));
            comp.addNote(new MyNote(62, 1));
            comp.addNote(new MyNote(64, 1));
            comp.addNote(new MyNote(64, 2));
            comp.addNote(new MyNote(62, 1));
            comp.addNote(new MyNote(62, 1));
            comp.play(outputDevice);
        }