Esempio n. 1
0
        protected void CalculDurationSymbols()
        {
            int DurationSymbolsLength = (int)minSymbolDuration - (int)maxSymbolDuration + 1;

            if (!dottedMusicSymbolDuration)
            {
                DurationSymbols = new DurationSymbol[DurationSymbolsLength];
            }
            else
            {
                DurationSymbols = new DurationSymbol[DurationSymbolsLength * 2];
            }

            double QuaterTimeDuration = 60 / (double)tempo * 10000000;

            double PowerOfTwo = Math.Pow(2, (int)MusicSymbolDuration.Quarter - (int)minSymbolDuration);

            for (int i = 0; i < DurationSymbolsLength; i++)
            {
                if (!dottedMusicSymbolDuration)
                {
                    DurationSymbols[i] = new DurationSymbol()
                    {
                        SymbolDuration = (MusicSymbolDuration)((int)minSymbolDuration - i),
                        TimeDuration   = (long)(QuaterTimeDuration * PowerOfTwo),
                        Dotted         = false
                    }
                }
                ;
                else
                {
                    DurationSymbols[2 * i] = new DurationSymbol()
                    {
                        SymbolDuration = (MusicSymbolDuration)((int)minSymbolDuration - i),
                        TimeDuration   = (long)(QuaterTimeDuration * PowerOfTwo),
                        Dotted         = false
                    };
                    DurationSymbols[2 * i + 1] = new DurationSymbol()
                    {
                        SymbolDuration = (MusicSymbolDuration)((int)minSymbolDuration - i),
                        TimeDuration   = (long)(QuaterTimeDuration * PowerOfTwo * 1.5),
                        Dotted         = true
                    };
                }
                PowerOfTwo *= 2;
            }
        }
Esempio n. 2
0
        protected virtual MusicalSymbol SendMusicSymbol()
        {
            DurationSymbol DurationSymbol = GetDurationSymbol(LastNoteDuration);
            MusicalSymbol  Result;

            /*if (PrevSilent)
             *      Result = new Rest(DurationSymbol.SymbolDuration, Convert.ToInt32(DurationSymbol.Dotted));
             * else
             * {
             *      List<int> NoteIds = new List<int>(Samples.Count - LastNoteInd);
             *      for (int i = LastNoteInd; i < Samples.Count; i++)
             *              NoteIds.Add(Samples[i].ID);
             *
             *      LastNoteId = AvgNoteId(NoteIds);
             *
             *      if (LastNoteId == -1)
             *              Result = new Rest(DurationSymbol.SymbolDuration, Convert.ToInt32(DurationSymbol.Dotted));
             *      else
             *              Result = Note.CreateNoteFromMidiPitch((int)LastNoteId, DurationSymbol.SymbolDuration,
             *                      Convert.ToInt32(DurationSymbol.Dotted));
             * }
             */

            if (LastNoteId == -1)
            {
                Result = new Rest(DurationSymbol.SymbolDuration, Convert.ToInt32(DurationSymbol.Dotted));
            }
            else
            {
                Result = Note.CreateNoteFromMidiPitch((int)LastNoteId, DurationSymbol.SymbolDuration,
                                                      Convert.ToInt32(DurationSymbol.Dotted));
            }

            if (AddMuscialSymbol != null)
            {
                AddMuscialSymbol(Result);
            }

            return(Result);
        }