Inheritance: Instrument
Exemplo n.º 1
1
 public void PlayDrum(Drum d, int velocity)
 {
     outputDevice.SendPercussion(DrumToMidiPercusssion[(int)d], GhToMidiVelocity[velocity]);
 }
Exemplo n.º 2
0
        /// <summary>
        /// <para/> Plays a specified Drum.  Increments/decrements score based on
        ///         whether the drum was played correctly.  Removes the corrisponding
        ///         ellipse from the screen if the drum was played correctly.
        /// <para/>Input:
        ///     List<Note>notes - the notes to be moved/removed.
        ///     Drum drum - the drum which is being hit
        /// <para/>Output: none
        /// <para/>Author: Connor Goudie/Andrew Busto
        /// <para/>Date: March 30, 2017
        /// </summary>
        private void hitNote(List <Note> notes, Drum drum)
        {
            //if note is within a playable range(within 25 units of the passing drum), and if so,
            //remove it from the screen
            if (notes.Count > 0 && notes[0].Position.Y > 585 && notes[0].Position.Y < 625)
            {
                //checks to see if player hit note withing 5 units of the passing note
                if (notes[0].Position.Y > 600 && notes[0].Position.Y < 610)
                {
                    //color drum green
                    drum.ellipse.Fill = new SolidColorBrush(Color.FromRgb(0, 255, 0));

                    //Give player 2 point
                    player.Score += 2;
                }
                else
                {
                    //colors drum yellow
                    drum.ellipse.Fill = new SolidColorBrush(Color.FromRgb(255, 255, 0));
                    //Give player a point
                    player.Score++;
                }
                canvas.Children.Remove(ellipses[notes[0]]);
                ellipses.Remove(notes[0]);
                notes.Remove(notes[0]);
            }
            else
            {
                //colors drum red
                drum.ellipse.Fill = new SolidColorBrush(Color.FromRgb(255, 0, 0));

                //take 2 points away
                player.Score -= 2;
            }
        }
Exemplo n.º 3
0
 public void RemoveDrumAt(int index, Drum drum)
 {
     if (drums[index].Contains(drum))
     {
         drums[index].Remove(drum);
     }
 }
Exemplo n.º 4
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Brand,PercussionModel,Price")] Drum drum)
        {
            if (id != drum.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(drum);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DrumExists(drum.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(drum));
        }
        public IInstrument GetInstrument(InstrumentType type)
        {
            IInstrument instrument = null;
            bool        found      = instruments.TryGetValue(type, out instrument);

            if (!found)
            {
                if (type == InstrumentType.Violin)
                {
                    instrument = new Violin();
                    instruments.Add(type, instrument);
                }
                else if (type == InstrumentType.Trumpet)
                {
                    instrument = new Trumpet();
                    instruments.Add(type, instrument);
                }
                else
                {
                    instrument = new Drum();
                    instruments.Add(type, instrument);
                }
            }
            return(instrument);
        }
        // Here "level" is the base 2 logarithm of the number of units on that level.
        private void AddDrumAt(int level, int index, Drum drum, HierarchicalRhythmNode node)
        {
            if (level < 0)
            {
                throw new Exception("Attempted to add drum at level " + level);
            }

            // Top of tree, insert here
            if (level == 0)
            {
                node.drums.Add(drum);
            }
            else
            {
                // Go down the left branch
                if (index < Math.Pow(2, level))
                {
                    AddDrumAt(level - 1, index, drum, node.Left);
                }
                // Go down the right branch
                else
                {
                    int newIndex = index - (int)Math.Pow(2, level - 1);
                    AddDrumAt(level - 1, newIndex, drum, node.Right);
                }
            }
        }
Exemplo n.º 7
0
        // Manjea cuando sueltas un Drum que se estaba arrastrando
        private bool OnDrumDrop(Drum dr, HandState handState, Point handPosition)
        {
            if (handState == HandState.Open)
            {
                dragDropCount--;

                if (dragDropCount <= 0)
                {
                    if (dr.HandHit == 2)
                    {
                        ((Hihat)dr).MoveTo(handPosition);
                    }
                    else
                    {
                        dr.MoveTo(handPosition);
                    }

                    //Si está sobre la papelera lo elimina
                    if (bin.Contains(handPosition))
                    {
                        this.OnDeleteDrum(dr);
                        binBrush = new SolidColorBrush(LightGrey);
                    }

                    return(true);
                }
            }

            else
            {
                dragDropCount = 5;
            }

            return(false);
        }
Exemplo n.º 8
0
        public DrumDetailDto UpdateDrum(int drumId, DrumCreateDto drumDetail)
        {
            if (!DrumExists(drumId))
            {
                throw new BadRequestException($"Drum with Id {drumId} doesn't exist.", BadRequestException.DRUM_DOESNT_EXISTS);
            }
            else
            {
                //get drum manager, site and status id
                DrumManager dm  = _dbContext.DrumManagers.FirstOrDefault(d => d.Name == drumDetail.DrumManager);
                Site        st  = _dbContext.Sites.FirstOrDefault(s => s.Name == drumDetail.Site);
                Status      sts = _dbContext.Status.FirstOrDefault(stt => stt.Status_name == drumDetail.Status);
                if (dm == null)
                {
                    throw new BadRequestException($"Drum Manager with name {drumDetail.DrumManager} doesn't exist.", BadRequestException.WRONG_DRUM_MANAGER_NAME);
                }
                if (st == null)
                {
                    throw new BadRequestException($"Drum Manager with name {drumDetail.Site} doesn't exist.", BadRequestException.WRONG_SITE_NAME);
                }
                if (sts == null)
                {
                    throw new BadRequestException($"Drum Manager with name {drumDetail.Status} doesn't exist.", BadRequestException.WRONG_STATUS_NAME);
                }

                Drum drum = _dbContext.Drums.FirstOrDefault(d => d.Id.Equals(drumId));

                drum.DrumNumber       = drumDetail.DrumNumber;
                drum.DrumManager_Id   = dm.Id;
                drum.Latitude         = drumDetail.Latitude;
                drum.Longitude        = drumDetail.Longitude;
                drum.InPositionSince  = drumDetail.InPositionSince;
                drum.Site_Id          = st.Id;
                drum.Status_Id        = sts.Id;
                drum.LastStatusUpdate = DateTime.UtcNow;

                try
                {
                    _dbContext.SaveChanges();
                }
                catch (Exception ex)
                {
                    throw new BadRequestException(ex.ToString());
                }
                return(new DrumDetailDto
                {
                    Id = drum.Id,
                    DrumNumber = drum.DrumNumber,
                    CreatedOn = drum.CreatedOn,
                    InPositionSince = drum.InPositionSince,
                    Latitude = drum.Latitude,
                    Longitude = drum.Longitude,
                    DrumManager = drum.DrumManager.Name,
                    Site = drum.Site.Name,
                    Status = drum.Status.Status_name,
                    LastStatusUpdate = drum.LastStatusUpdate
                });
            }
        }
        public void NewContainerCanAccomodateDrumWithNoSpecification()
        {
            var container1 = new Container(4);
            var sand       = new Product();
            var drumSand   = new Drum(sand, 4);

            Assert.True(container1.CanAccommodate(drumSand));
        }
Exemplo n.º 10
0
        public void Oops()
        {
            var b = new InheritanceBaseClass.InheritanceDerivedClass1();

            Console.WriteLine(b.GetValue());//10

            //Inheritance
            string whatPlayed = "";

            Drum             drums  = new Drum();
            PlayMusicService music1 = new PlayMusicService(new Drum());

            whatPlayed = music1.PlayAlbum();
            Console.WriteLine(whatPlayed);

            Piano            piano  = new Piano();
            PlayMusicService music2 = new PlayMusicService(new Piano());

            whatPlayed = music2.PlayAlbum();
            Console.WriteLine(whatPlayed);

            //Polymorphism
            var overloading = new StaticOrCompileTimeOrMethodOverloading();

            overloading.PolyMethodOverloading();
            overloading.PolyMethodOverloading(5, 3);
            overloading.PolyMethodOverloading(3, 0.3, true);

            var baseKeyword  = new InheritanceUsingBaseKeywordDerivedClass(true, 10);
            var baseKeyword1 = new InheritanceUsingBaseKeywordDerivedClass();

            baseKeyword.Weight = 70;

            var overRiding = new ImplementationOfRuntimeOrMethodOverRiding1();

            overRiding.OverRidingMethod();
            overRiding.PolyMethodOverridding();
            overRiding.SampleMethod();


            // Abstraction
            var    abstraction = new AbsractionDerivedClass(20, 10);
            double a           = abstraction.area();

            Console.WriteLine("Area: {0}", a);

            // Encapsulaton
            var encapsulation = new EncapsulationBaseClasss();

            // set accessor will invoke
            encapsulation.Name = "Suresh Dasari";
            // set accessor will invoke
            encapsulation.Location = "Hyderabad";
            // get accessor will invoke
            Console.WriteLine("Name: " + encapsulation.Name);
            // get accessor will invoke
            Console.WriteLine("Location: " + encapsulation.Location);
        }
        public void NewContainerAllowsAddingDrums()
        {
            var container1 = new Container(4);
            var sand       = new Product();
            var drumSand   = new Drum(sand, 4);

            container1.AddDrum(drumSand);
            Assert.Equal(1, container1.Drums.Count);
        }
Exemplo n.º 12
0
        public async Task <IActionResult> Edit(Drum item)
        {
            if (ModelState.IsValid)
            {
                await _drumRepo.UpdateAsync(item);

                return(RedirectToAction("Index", "Home"));
            }
            return(View(item));
        }
Exemplo n.º 13
0
 //Elimina un Drum de la batería
 private void OnDeleteDrum(Drum deleteDrum)
 {
     if (drums.Contains(deleteDrum))
     {
         drums.Remove(deleteDrum);
     }
     else if (hihats.Contains(deleteDrum))
     {
         hihats.Remove(deleteDrum);
     }
 }
Exemplo n.º 14
0
        public async Task <IActionResult> Create([Bind("Id,Brand,PercussionModel,Price")] Drum drum)
        {
            if (ModelState.IsValid)
            {
                _context.Add(drum);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(drum));
        }
        public void ContainerIsSafelyPacked()
        {
            var specArmored    = new ContainerSpecification(ContainerFeature.ARMORED);
            var specVentilated = new ContainerSpecification(ContainerFeature.VENTILATED);

            var tnt = new Product();

            tnt.Specification = specArmored.And(specVentilated);
            var drumTNT           = new Drum(tnt, 2);
            var sand              = new Product();
            var drumSand          = new Drum(sand, 4);
            var biologicalSamples = new Product();

            biologicalSamples.Specification = specArmored.Not();
            var drumBiologicalSamples = new Drum(biologicalSamples, 2);
            var ammonia = new Product();

            ammonia.Specification = specArmored.Not();
            var drumAmmonia = new Drum(ammonia, 2);
            var drums       = new List <Drum>(4)
            {
                drumTNT,
                drumSand,
                drumBiologicalSamples,
                drumAmmonia
            };

            var containerCheap      = new Container(6);
            var containerVentilated = new Container(6);

            containerVentilated.AddFeature(ContainerFeature.VENTILATED);
            var containerExpensive = new Container(6);

            containerExpensive.AddFeature(ContainerFeature.ARMORED);
            var containers = new List <Container>(3)
            {
                containerCheap,
                containerVentilated,
                containerExpensive
            };

            var packer = new Packer();

            packer.Pack(containers, drums);

            //var drum = new Drum(product1, 5);

            //var container1 = new Container(5);
            //container1.AddFeature(ContainerFeature.BLINDADO);
            //container1.AddDrum(drum);

            //Assert.True(container1.IsSafelyPacked());
        }
        public void NewContainerCanAccomodateDrumWithValidSpecification()
        {
            var container1  = new Container(4);
            var specArmored = new ContainerSpecification(ContainerFeature.VENTILATED);

            var biologicalSamples = new Product();

            biologicalSamples.Specification = specArmored.Not();
            var drumBiologicalSamples = new Drum(biologicalSamples, 2);

            Assert.True(container1.CanAccommodate(drumBiologicalSamples));
        }
Exemplo n.º 17
0
 private void Button01_Tapped(object sender, TappedRoutedEventArgs e)
 {
     if (count == 0)
     {
         Drum.IsLooping = true;
         Drum.Play();
         count++;
     }
     else if (count == 1)
     {
         Drum.IsLooping = false;
         Drum.Pause();
         count--;
     }
 }
Exemplo n.º 18
0
    private void Initialize()
    {
        IEnumerable <int> cardValues = GetShuffledAllCardValues();

        for (int i = 0; i < DRUM_COUNT; i++)
        {
            var cards = cardValues.Take(CARD_COUNT_PER_DRUM)
                        .Select(value => new Card(value))
                        .ToList();

            Drums[i] = new Drum(cards);

            cardValues = cardValues.Skip(CARD_COUNT_PER_DRUM);
        }
    }
Exemplo n.º 19
0
        //private void Marire(Retea retea)
        //{
        //   Console.WriteLine("\n\n");
        //   Console.WriteLine(retea.ToString());

        //   Drum drum = CreeazaDrum(retea);
        //   Console.WriteLine(drum.AsString(retea));

        //   drum.Arce.ForEach(arc => arc.Flux += drum.GetCapacitateRezidualaMin(retea));

        //   //todo: check if arcs are updated by reference
        //}

        private void Marire(Retea retea)
        {
            //Console.WriteLine("\n\n");
            //Console.WriteLine(retea.ToString());

            Drum drum = CreeazaDrum(retea);
            //Console.WriteLine(drum.AsString(retea));


            double r = drum.GetCapacitateRezidualaMin(retea);

            Console.WriteLine($"{drum.AsString(retea)} | r(D)={r}");
            if (r > 0)
            {
                drum.Arce.ForEach(arc => {
                    arc.Flux += r;

                    Arc arcRetea   = retea.Arce.FirstOrDefault(a => a.X.Id == arc.X.Id && a.Y.Id == arc.Y.Id);
                    arcRetea.Flux += r;

                    Arc arcInvers = retea.Arce.FirstOrDefault(a => a.X.Id == arc.Y.Id && a.Y.Id == arc.X.Id);

                    if (arcInvers == null)
                    {
                        arcInvers = new Arc(arc.Y, arc.X, 0, 0);
                        retea.Arce.Add(arcInvers);
                    }
                    else
                    {
                        if (arcInvers.GetCapacitateReziduala(retea) <= 0)
                        {
                            retea.Arce.Remove(arcInvers);
                        }
                    }

                    if (arcRetea.GetCapacitateReziduala(retea) <= 0)
                    {
                        retea.Arce.Remove(arcRetea);
                    }
                });

                Console.WriteLine("\n\n");
                Console.WriteLine(retea.ToString());
                Console.WriteLine($"Max value: {retea.GetValoareMaxima()}");
            }

            //todo: check if arcs are updated by reference
        }
Exemplo n.º 20
0
    public static void Main()
    {
        string whatPlayed = "";

        Drum             drums  = new Drum();
        PlayMusicService music1 = new PlayMusicService(new Drum());

        whatPlayed = music1.PlayAlbum();
        Console.WriteLine(whatPlayed);

        Piano            piano  = new Piano();
        PlayMusicService music2 = new PlayMusicService(new Piano());

        whatPlayed = music2.PlayAlbum();
        Console.WriteLine(whatPlayed);
    }
Exemplo n.º 21
0
        /* Create a rhythm from a tracker and list of events, by quantizing the events
         * according to the beat tracker given to the function. */
        public static RhythmStructure CreateRhythm(BeatTracker tracker, List <BeatEvent> events)
        {
            const byte      numDivisions = 4;
            int             eventIndex   = 0;
            RhythmStructure rhythm       = new RhythmStructure(tracker.Interval);

            /* Iterate over all the beats and semiquavers, and set the semiquaver interval. */
            for (int i = 0; i < tracker.ProcessedItems.Count; i++)
            {
                BeatEvent baseEvent = tracker.ProcessedItems[i];
                double    interval;
                if (i != tracker.ProcessedItems.Count - 1)
                {
                    BeatEvent nextEvent = tracker.ProcessedItems[i + 1];
                    interval = (nextEvent.Time - baseEvent.Time) / 4;
                }
                else
                {
                    interval = (tracker.NextPrediction - baseEvent.Time) / 4;
                }

                for (int j = 0; j < numDivisions; j++)
                {
                    HashSet <Drum> drums = new HashSet <Drum>();

                    /* Determine the time at which one semiquaver event occurs and then quantizes each note event to the semiquaver. */
                    double baseTime = baseEvent.Time + (j * interval);
                    if (eventIndex < events.Count && baseTime - (interval / 2) < events[eventIndex].Time && baseTime + (interval / 2) > events[eventIndex].Time)
                    {
                        foreach (NoteEvent noteEvent in events[eventIndex].Notes)
                        {
                            if (indexToDrum.Keys.Contains(noteEvent.Channel))
                            {
                                Drum drum = indexToDrum[noteEvent.Channel];
                                drums.Add(drum);
                            }
                        }
                        eventIndex++;
                    }

                    rhythm.AddDrums(drums);
                }
            }

            return(rhythm);
        }
Exemplo n.º 22
0
    public void SetEntry(Drum drum)
    {
        CardImage.sprite     = Util.GetCardFrontSprite(drum.CurrentCard);
        CurrentCardText.text = drum.CurrentCard.ToString();

        string allCardString = string.Empty;

        foreach (var card in drum.Cards)
        {
            if (!string.IsNullOrEmpty(allCardString))
            {
                allCardString += System.Environment.NewLine;
            }

            allCardString += card.ToString();
        }

        AllCardText.text = allCardString;
    }
Exemplo n.º 23
0
        private Drum CreeazaDrum(Retea retea)
        {
            List <Nod> noduri = new List <Nod>();

            Nod nodStoc   = retea.Noduri.FirstOrDefault(nod => nod.EsteNodStoc);
            Nod nodCurent = nodStoc;

            while (nodCurent.Predecesor != null && nodCurent.Predecesor.Id != nodStoc.Id)
            {
                noduri.Add(nodCurent);
                nodCurent = nodCurent.Predecesor;
            }
            noduri.Add(nodCurent);
            noduri.Reverse();

            Drum drum = new Drum(retea, noduri);

            return(drum);
        }
Exemplo n.º 24
0
        public void DrumDeleteByDrumNumber(string drumNumber)
        {
            Drum drum = _dbContext.Drums.FirstOrDefault(d => d.DrumNumber == drumNumber);

            if (drum == null)
            {
                throw new NotFoundException <Drum>(drumNumber);
            }

            _dbContext.Drums.Remove(drum);

            try
            {
                _dbContext.SaveChanges();
            }
            catch (Exception ex)
            {
                throw new BadRequestException(ex.ToString());
            }
        }
Exemplo n.º 25
0
        // Manjea cuando arrastras un Drum con la mano cerrada
        private void OnDrumDrag(Drum dr, Point handPosition)
        {
            if (dr.HandHit == 2)
            {
                ((Hihat)dr).MoveTo(handPosition);
            }
            else
            {
                dr.MoveTo(handPosition);
            }

            if (bin.Contains(handPosition))
            {
                binBrush = new SolidColorBrush(LightRed);
            }
            else
            {
                binBrush = new SolidColorBrush(LightGrey);
            }
        }
        private void Marire(Retea retea)
        {
            Console.WriteLine("\n\n");
            Console.WriteLine($"MARIRE FLUX NR.{_nrIteratie}: ");

            _nrIteratie++;

            // Predecesori
            List <Nod> predecesori = new List <Nod>();

            retea.Noduri.ForEach(n => predecesori.Add(n.Predecesor));

            Console.Write("Predecesori: ");
            predecesori.ForEach(p => Console.Write($"{((p != null) ? p.ToString() : "-")}, "));

            // Creare drum
            Drum   drum  = CreeazaDrum(retea);
            double rDrum = drum.GetCapacitateRezidualaMin(retea);

            Console.WriteLine($"{drum.AsString(retea)} | r(D)={rDrum}");
            Console.WriteLine();

            if (rDrum > 0)
            {
                drum.Arce.ForEach(arc => {
                    arc.Flux += rDrum;

                    Arc arcInvers = retea.Arce.FirstOrDefault(a => a.X.Id == arc.Y.Id && a.Y.Id == arc.X.Id);

                    if (arcInvers == null)
                    {
                        arcInvers = new Arc(arc.Y, arc.X, 0, 0);
                        retea.Arce.Add(arcInvers);
                    }
                });

                Console.WriteLine(retea.ToString());
                Console.WriteLine($"Max value: {retea.GetValoareMaxima()}");
            }
        }
 public IInstrument GetInstrument(InstrumentType type)
 {
     IInstrument instrument = null;
     bool found = instruments.TryGetValue(type, out instrument);
     if (!found)
     {
         if (type == InstrumentType.Violin)
         {
             instrument = new Violin();
             instruments.Add(type, instrument);
         }
         else if(type == InstrumentType.Trumpet)
         {
             instrument = new Trumpet();
             instruments.Add(type, instrument);
         }
         else
         {
             instrument = new Drum();
             instruments.Add(type, instrument);
         }
     }
     return instrument;
 }
Exemplo n.º 28
0
 public static void SetDrum(int channel, Drum drum, Volume volume)
 {
     Memory.Write((int)Instrument.Drumkit + channel + (int)volume, (int)drum);
 }
Exemplo n.º 29
0
 public static void SetDrum(int channel, Drum drum)
 {
     Memory.Write((int)Instrument.Drumkit + channel, (int)drum);
 }
Exemplo n.º 30
0
 private Drum TryGetAlternateDrum(Drum drum) => drum switch
 {
Exemplo n.º 31
0
        public void Play()
        {
            Iinstrument drum       = new Drum();
            Iinstrument piano      = new Piano();
            Music       m          = new Music();
            Piece       drumPiece  = new Piece();//创建段落区块,区块与区块可以合并。
            Piece       PianoPiece = new Piece();

            Piece Intro     = new Piece(); //开头
            Piece MainPiece = new Piece(); //主歌

            m.Bpm = 150;
            int   pieceCount = 0;
            Piece P1         = new Piece();
            Piece P2         = new Piece();

            #region 钢琴节奏
            Piece pianoRythm  = new Piece();
            Piece pianoRythm1 = new Piece();
            pianoRythm1.Create().Add(piano, PName.F, 2, 8, 60, 0.7F);
            pianoRythm1.Create().Add(piano, PName.C, 3, 8, 60, 0.7F);
            pianoRythm1.Create().Add(piano, PName.E, 3, 8, 60, 0.7F);
            pianoRythm1.Create().Add(piano, PName.C, 3, 8, 60, 0.7F);
            pianoRythm1.Create().Add(piano, PName.F, 2, 8, 60, 0.7F);
            pianoRythm1.Create().Add(piano, PName.C, 3, 8, 60, 0.7F);
            pianoRythm1.Create().Add(piano, PName.E, 3, 8, 60, 0.7F);
            pianoRythm1.Create().Add(piano, PName.C, 3, 8, 60, 0.7F);

            Piece pianoRythm2 = new Piece();
            pianoRythm2.Create().Add(piano, PName.G, 2, 8, 60, 0.7F);
            pianoRythm2.Create().Add(piano, PName.B, 2, 8, 60, 0.7F);
            pianoRythm2.Create().Add(piano, PName.D, 3, 8, 60, 0.7F);
            pianoRythm2.Create().Add(piano, PName.B, 2, 8, 60, 0.7F);
            pianoRythm2.Create().Add(piano, PName.G, 2, 8, 60, 0.7F);
            pianoRythm2.Create().Add(piano, PName.B, 2, 8, 60, 0.7F);
            pianoRythm2.Create().Add(piano, PName.D, 3, 8, 60, 0.7F);
            pianoRythm2.Create().Add(piano, PName.B, 2, 8, 60, 0.7F);

            Piece pianoRythm3 = new Piece();
            pianoRythm3.Create().Add(piano, PName.A, 2, 8, 60, 0.7F);
            pianoRythm3.Create().Add(piano, PName.C, 3, 8, 60, 0.7F);
            pianoRythm3.Create().Add(piano, PName.E, 3, 8, 60, 0.7F);
            pianoRythm3.Create().Add(piano, PName.C, 3, 8, 60, 0.7F);
            pianoRythm3.Create().Add(piano, PName.A, 2, 8, 60, 0.7F);
            pianoRythm3.Create().Add(piano, PName.C, 3, 8, 60, 0.7F);
            pianoRythm3.Create().Add(piano, PName.E, 3, 8, 60, 0.7F);
            pianoRythm3.Create().Add(piano, PName.C, 3, 8, 60, 0.7F);
            pianoRythm.AddPiece(pianoRythm1);
            pianoRythm.AddPiece(pianoRythm2);
            pianoRythm.AddPiece(pianoRythm3);
            pianoRythm.AddPiece(pianoRythm3);
            pieceCount = pianoRythm.GetNotes().Count();
            pianoRythm.GetNotes().Select(i => i.GetNotes().Select(ii => ii.Volume = 0.3F));
            #endregion

            #region 钢琴主音
            Piece pianoSolo = new Piece();
            pianoSolo[0].Add(piano, PName.A, 3);
            pianoSolo[1].Add(piano, PName.E, 4);
            pianoSolo[2].Add(piano, PName.A, 3);
            pianoSolo[3].Add(piano, PName.G, 3);
            pianoSolo[4].Add(piano, PName.A, 3);

            pianoSolo[11].Add(piano, PName.G, 3);
            pianoSolo[12].Add(piano, PName.A, 3);
            pianoSolo[13].Add(piano, PName.E, 4);
            pianoSolo[14].Add(piano, PName.A, 3);
            pianoSolo[15].Add(piano, PName.G, 3);
            pianoSolo[16].Add(piano, PName.A, 3);
            pianoSolo[17].Add(piano, PName.E, 4);
            pianoSolo[18].Add(piano, PName.A, 3);
            pianoSolo[19].Add(piano, PName.G, 3);
            pianoSolo[20].Add(piano, PName.A, 3);
            pianoSolo[23].Add(piano, PName.E, 3);
            pianoSolo[24].Add(piano, PName.G, 3);

            pianoSolo[27].Add(piano, PName.D, 3);
            pianoSolo[28].Add(piano, PName.E, 3);
            pianoSolo[29].Add(piano, PName.G, 3);
            pianoSolo[30].Add(piano, PName.A, 3);
            pianoSolo[31].Add(piano, PName.B, 3);
            pianoSolo[32].Add(piano, PName.A, 3);
            pianoSolo[33].Add(piano, PName.E, 4);
            pianoSolo[34].Add(piano, PName.A, 3);
            pianoSolo[35].Add(piano, PName.G, 3);
            pianoSolo[36].Add(piano, PName.A, 3);

            pianoSolo[43].Add(piano, PName.G, 3);
            pianoSolo[44].Add(piano, PName.A, 3);
            pianoSolo[45].Add(piano, PName.E, 4);
            pianoSolo[46].Add(piano, PName.B, 3);
            pianoSolo[47].Add(piano, PName.C, 4);
            pianoSolo[48].Add(piano, PName.B, 3);
            pianoSolo[49].Add(piano, PName.C, 4);
            pianoSolo[50].Add(piano, PName.B, 3);
            pianoSolo[51].Add(piano, PName.A, 3);
            pianoSolo[52].Add(piano, PName.E, 3);

            pianoSolo[59].Add(piano, PName.D, 3);
            pianoSolo[60].Add(piano, PName.E, 3);
            pianoSolo[61].Add(piano, PName.G, 3);
            pianoSolo[62].Add(piano, PName.A, 3);
            pianoSolo[63].Add(piano, PName.B, 3);
            #endregion

            #region 鼓节奏
            Piece DrumPiece1 = new Piece();
            DrumPiece1.Create().Add(drum, PName.OpenHat).Add(drum, PName.Kick);
            DrumPiece1.Create().Add(drum, PName.CloseHat);
            DrumPiece1.Create().Add(drum, PName.CloseHat).Add(drum, PName.Snare);
            DrumPiece1.Create().Add(drum, PName.CloseHat);
            DrumPiece1.Create().Add(drum, PName.CloseHat).Add(drum, PName.Kick);
            DrumPiece1.Create().Add(drum, PName.CloseHat).Add(drum, PName.Kick);
            DrumPiece1.Create().Add(drum, PName.CloseHat).Add(drum, PName.Snare);
            DrumPiece1.Create().Add(drum, PName.CloseHat);
            DrumPiece1.Create().Add(drum, PName.CloseHat).Add(drum, PName.Kick);
            DrumPiece1.Create().Add(drum, PName.CloseHat).Add(drum, PName.Kick);
            DrumPiece1.Create().Add(drum, PName.CloseHat).Add(drum, PName.Snare);
            DrumPiece1.Create().Add(drum, PName.CloseHat).Add(drum, PName.Kick);
            DrumPiece1.Create().Add(drum, PName.CloseHat).Add(drum, PName.Kick);
            DrumPiece1.Create().Add(drum, PName.CloseHat).Add(drum, PName.Kick);
            DrumPiece1.Create().Add(drum, PName.CloseHat).Add(drum, PName.Snare);
            DrumPiece1.Create().Add(drum, PName.CloseHat);
            #endregion

            P1.AddPiece(pianoRythm);
            P1.AddPiece(pianoRythm);
            P1.AddPieceAt(pianoSolo, 0);

            P2.AddPiece(DrumPiece1);
            P2.AddPiece(DrumPiece1);
            P2.AddPiece(DrumPiece1);
            P2.AddPiece(DrumPiece1);
            P2.AddPieceAt(P1, 0);
            m.AddPiece(P1);
            m.AddPiece(P2);
            m.PlayAll();
        }
Exemplo n.º 32
0
 public void DeleteDrum(Drum drum)
 {
     dbcontext.Drum.Remove(drum);
 }
Exemplo n.º 33
0
 void HandleDrum(Drum drum, bool down, int velocity)
 {
     if (!down)
     {
         States[(int)drum] = false;
         return;
     }
     var old = States[(int)drum];
     if(down!=old){
         Console.WriteLine("Hit the {0}!", drum);
         States[(int)drum]=true;
         DrumHit(drum,velocity);
     }
 }