Пример #1
0
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            if (!(obj is TuneElement))
            {
                return(false);
            }

            TuneElement otherElement = obj as TuneElement;

            if (this.Dotted != otherElement.Dotted)
            {
                return(false);
            }

            if (this.Duration != otherElement.Duration)
            {
                return(false);
            }

            return(true);
        }
Пример #2
0
        private void InsertNewTuneElement(char c, int index)
        {
            TuneElement newTuneElement = null;

            if (c == '0')
            {
                newTuneElement = new Pause(previousDuration);
            }
            else
            {
                var pitch = pitchKeypressConverter.Parse(c.ToString());

                newTuneElement = new Note(pitch, previousScale, previousDuration);
            }

            nokiaComposerTuneElementList.Insert(index, newTuneElement);

            CurrentTuneElement = newTuneElement;
        }
Пример #3
0
        private IEnumerable <double> GenerateSoundData(TuneElement tuneElement, double period)
        {
            double frequenceNote = 0;

            var note = tuneElement as Note;

            if (note != null)
            {
                frequenceNote = new Frequences()[note.Pitch, note.Scale];
            }

            oscillator.SetFrequency(frequenceNote);

            var loopLength = SampleRate * period * (durationConverter.GetValue(tuneElement.Duration) * (tuneElement.Dotted ? 1.5 : 1));

            for (var i = 0; i < loopLength; i++)
            {
                yield return(oscillator.GetNext(i));
            }
        }
 public void Insert(int index, TuneElement item)
 {
     list.Insert(index, new NokiaComposerTuneElementWithLength(item));
 }