private void ValidateField(NoteValue e, NoteField noteField)
        {
            // required
            if (noteField.Required && e.Value == "")
            {
                throw new AppException(string.Format("Field '{0}' is required.", noteField.Title));
            }

            // types
            if (e.Value == "") // return if there is no value to be converted
            {
                return;
            }

            if ((noteField.Type == "datetime" || noteField.Type == "date") && !DateTime.TryParse(e.Value, out _))
            {
                throw new AppException(String.Format("Field '{0}' does not contain a valid date.", noteField.Title));
            }

            if ((noteField.Type == "boolean" || noteField.Type == "bool") && !bool.TryParse(e.Value, out _))
            {
                throw new AppException(String.Format("Field '{0}' does not contain a valid bool.", noteField.Title));
            }

            if (noteField.Type == "number" && !double.TryParse(e.Value, out _))
            {
                throw new AppException(String.Format("Field '{0}' does not contain a valid number.", noteField.Title));
            }
        }
Beispiel #2
0
 public MusicalNoteMock(NoteValue pNoteValue, int pNumber, string pNoteName)
 {
     fValue      = pNoteValue;
     fNumber     = pNumber;
     fNoteName   = pNoteName;
     this.Volume = 0;
 }
Beispiel #3
0
        public static NoteValue Shift(this NoteValue pNote, Interval pInterval)
        {
            int noteAsInt     = (int)pNote;
            int intervalAsInt = (int)pInterval;

            return((NoteValue)((noteAsInt + intervalAsInt + 1) % 12));
        }
Beispiel #4
0
        public void Can_Create_Note_With_Valid_Value(NoteValue v)
        {
            var note = new Note(v);

            note.StringValue.Should().NotBeEmpty();
            PossibleNotes.Should().Contain(note.StringValue);
        }
Beispiel #5
0
 /// <summary>
 /// Add a rest for the given length for the current beat.
 /// </summary>
 /// <param name="restLength">Duration of wait specified as a note value.</param>
 public void AddRest(NoteValue restLength)
 {
     AddNotes(new Note
     {
         NamedValue = restLength
     });
 }
Beispiel #6
0
 /// <summary>
 /// Add a rest for the given length for the current beat.
 /// </summary>
 /// <param name="restLength">Duration of wait specified as a note value.</param>
 /// <param name="dots">Total dotted note length extensions to apply.</param>
 public void AddRest(NoteValue restLength, int dots)
 {
     AddNotes(new Note
     {
         NamedValue = restLength, Dots = dots
     });
 }
Beispiel #7
0
        public void DrawNoteValueAugment(NoteValue noteValue, double position, double stringIndex)
        {
            var x = this.Location.X + position + this.Style.NoteValueAugmentOffset;
            var y = this.Owner.GetStringSpacePosition(stringIndex);

            this.PrimitiveRenderer.DrawNoteValueAugment(noteValue.Augment, x, y);
        }
Beispiel #8
0
        public void GtSceneGuitarNoteValueAndNumber(int pString, int pFret, NoteValue pNoteValue, int pNoteNumber)
        {
            var guitarNote = new GtSceneGuitarNote(new BeatTick(1, 0), new BeatTick(2, 0), pString, pFret);

            Assert.AreEqual(pNoteValue, guitarNote.NoteValue);
            Assert.AreEqual(pNoteNumber, guitarNote.NoteNumber);
        }
Beispiel #9
0
 /// <summary>
 /// Note Constructor.
 /// Generates a new object of class Note with a given octave, duration, pitch,
 /// sharp and flat
 /// </summary>
 /// <param name="oct">Octave</param>
 /// <param name="d">NoteValue</param>
 /// <param name="pitch">String representing the Pitch</param>
 /// <param name="posit">Position</param>
 /// <param name="sharp">(#)</param>
 /// <param name="flat">(b)</param>
 public Note(int oct, NoteValue d, String pitch, int posit, Boolean sharp, Boolean flat)
 {
     Octave = oct;
     Duration = d;
     Pitch = pitch;
     Sharp = sharp;
     Flat = flat;
     Position = posit;
 }
Beispiel #10
0
        public static string AsSharpedString(this NoteValue value)
        {
            string result = "";

            switch (value)
            {
            case NoteValue.C:
                result = "C";
                break;

            case NoteValue.Db:
                result = "C#";
                break;

            case NoteValue.D:
                result = "D";
                break;

            case NoteValue.Eb:
                result = "D#";
                break;

            case NoteValue.E:
                result = "E";
                break;

            case NoteValue.F:
                result = "F";
                break;

            case NoteValue.Gb:
                result = "F#";
                break;

            case NoteValue.G:
                result = "G";
                break;

            case NoteValue.Ab:
                result = "G#";
                break;

            case NoteValue.A:
                result = "A";
                break;

            case NoteValue.Bb:
                result = "A#";
                break;

            case NoteValue.B:
                result = "B";
                break;
            }

            return(result);
        }
        public Sprite GetStaveUnitSprite(UnitFunction a_Function,
                                         NoteValue a_Value,
                                         SpriteType a_Type)
        {
            var spriteEntry = m_StaveUnits.First(a_Entry => a_Entry.Function == a_Function &&
                                                 a_Entry.Value == a_Value);

            return(a_Type == SpriteType.MAIN ? spriteEntry.MainSprite : spriteEntry.GlowSprite);
        }
Beispiel #12
0
 /// <summary>
 /// Note Constructor.
 /// Generates a new object of class Note with a given octave, duration and pitch.
 /// </summary>
 /// <param name="oct">Octave</param>
 /// <param name="d">NoteValue</param>
 /// <param name="pitch">String representing the Pitch</param>
 /// <param name="posit">Position</param>
 public Note(int oct, NoteValue d, String pitch, int posit)
 {
     Octave = oct;
     Duration = d;
     Pitch = pitch;
     Sharp = false;
     Flat = false;
     Position = posit;
 }
        public static int NoteLocation(NoteValue value, out bool isSharp)
        {
            isSharp = false;
            switch (value)
            {
            case NoteValue.c_low: return(0);

            case NoteValue.c_sharp_low: isSharp = true; return(0);

            case NoteValue.d: return(1);

            case NoteValue.d_sharp: isSharp = true; return(1);

            case NoteValue.e: return(2);

            case NoteValue.f: return(3);

            case NoteValue.f_sharp: isSharp = true; return(3);

            case NoteValue.g: return(4);

            case NoteValue.g_sharp: isSharp = true; return(4);

            case NoteValue.a: return(5);

            case NoteValue.a_sharp: isSharp = true; return(5);

            case NoteValue.b: return(6);

            case NoteValue.c: return(7);

            case NoteValue.c_sharp: isSharp = true; return(7);

            case NoteValue.d_high: return(8);

            case NoteValue.d_sharp_high: isSharp = true; return(8);

            case NoteValue.e_high: return(9);

            case NoteValue.f_high: return(10);

            case NoteValue.f_sharp_high: isSharp = true; return(10);

            case NoteValue.g_high: return(11);

            case NoteValue.g_sharp_high: isSharp = true; return(11);

            case NoteValue.a_high: return(12);

            case NoteValue.a_sharp_high: isSharp = true; return(12);

            case NoteValue.b_high: return(13);

            case NoteValue.c_high: return(14);
            }
            return(0);
        }
Beispiel #14
0
        public static string Note(Note note, NoteValue length, bool dotted = false, string color = "#000000")
        {
            var accid = string.Empty;

            if (note.Accidental != Accidental.n)
            {
                accid = $"accid='{note.Accidental}'";
            }
            return($@"<note dur='{(int)length}' color='{color}' pname='{note.Name}' oct='{note.Register}' {accid} />");
        }
        public void Initialize(Team a_Team, UnitFunction a_Function, NoteValue a_Value)
        {
            Function = a_Function;
            Value    = a_Value;

            Func <Sprites.SpriteType, Sprite> getSprite = a_Type =>
                                                          Sprites.Instance.GetStaveUnitSprite(a_Function, a_Value, a_Type);

            Initialize(a_Team, getSprite(Sprites.SpriteType.MAIN),
                       getSprite(Sprites.SpriteType.GLOW));
        }
        public async Task <bool> IsExistNoteTextInListNote(NoteValue noteValue)
        {
            var existItem = await Read <Note>()
                            .AnyAsync(
                i => i.ListNoteId == noteValue.ListNoteId &&
                noteValue.Id != i.Id &&
                i.Text == noteValue.Text
                );

            return(existItem);
        }
Beispiel #17
0
 private static PlayLineNotes GetNote(this NoteValue value, int order, ITempoForBars tempo, List <Note.Note> asNotes, List <Note.Note> deNotes, int noteNumber)
 {
     return(new PlayLineNotes()
     {
         IsPlayed = false,
         Length = tempo.LengthByTempo(value),
         Note = noteNumber != 0 ? asNotes.FirstOrDefault(a => a.Number == noteNumber) : null,
         Order = order,
         Silence = false
     });
 }
Beispiel #18
0
        protected bool FindNote(NoteValue pNote)
        {
            foreach (var note in this.fNotes)
            {
                if (note.Value == pNote)
                {
                    return(true);
                }
            }

            return(false);
        }
Beispiel #19
0
        private NoteValue CalculateTheActualNote(NoteValue noteValue, int pFret)
        {
            int fret = pFret;

            while (fret > 0)
            {
                noteValue = noteValue.Shift(Interval.MinorSecond);
                fret--;
            }

            return(noteValue);
        }
Beispiel #20
0
        public static NoteValueBuilder CreateDefaultBuilder()
        {
            var todoList = new NoteValue()
            {
                Text        = DefaultValues.NoteText,
                ListNoteId  = DefaultValues.NoteListNoteId,
                IsCompleted = DefaultValues.NoteIsCompleted,
                IsPublic    = DefaultValues.NoteIsPublic,
                DueDate     = DefaultValues.NoteDueDate
            };

            return(new NoteValueBuilder(todoList));
        }
Beispiel #21
0
        public static Interval Interval(this NoteValue pNote1, NoteValue pNote2, out int pOctaves)
        {
            int difference = (int)pNote2 - (int)pNote1 - 1;

            pOctaves = 0;

            while (difference < 0)
            {
                difference += 12;
                pOctaves++;
            }

            return((Interval)(difference % 12));
        }
Beispiel #22
0
        public override bool TryParse(Scanner scanner, out NoteValueNode result)
        {
            var anchor = scanner.MakeAnchor();

            result = new NoteValueNode();

            LiteralNode <BaseNoteValue> baseNoteValue;

            if (!Parser.TryReadBaseNoteValue(scanner, this, out baseNoteValue))
            {
                this.Report(LogLevel.Error, scanner.LastReadRange, Messages.Error_NoteValueExpected);
                result = null;
                return(false);
            }

            result.Base = baseNoteValue;

            if (scanner.Expect('/'))    //tuplet
            {
                LiteralNode <int> tuplet;
                if (!Parser.TryReadInteger(scanner, out tuplet))
                {
                    this.Report(LogLevel.Error, scanner.LastReadRange, Messages.Error_TupletValueExpected);
                    result = null;
                    return(false);
                }

                if (!NoteValue.IsValidTuplet(tuplet.Value))
                {
                    this.Report(LogLevel.Error, scanner.LastReadRange, Messages.Error_InvalidTuplet);
                    result = null;
                    return(false);
                }

                result.Tuplet = tuplet;
            }

            LiteralNode <NoteValueAugment> augment;

            if (!Parser.TryReadNoteValueAugment(scanner, this, out augment))
            {
                result = null;
                return(false);
            }

            result.Augment = augment;

            result.Range = anchor.Range;
            return(true);
        }
Beispiel #23
0
 public static ChordOrigin FromParseResults(NoteValue root,
                                            Accidental accidental,
                                            KnownChordKind knownChordKind,
                                            ChordExtensions.ExtensionBase extensionBase,
                                            IEnumerable <ChordExtensions.Extension> extensions,
                                            Tuple <NoteValue, Accidental> inversionOrBass) => new ChordOrigin
 {
     ChordKind           = knownChordKind,
     Extensions          = extensions,
     ExtensionBase       = extensionBase,
     Root                = new Note(root, accidental),
     BassNoteOrInversion =
         inversionOrBass != null ? new Note(inversionOrBass.Item1, inversionOrBass.Item2) : null
 };
        public Note AddNote(NoteValue noteValue = null, int?listNoteId = null)
        {
            listNoteId ??= AddListNote().Id;
            noteValue ??= NoteValueBuilder
            .CreateDefaultBuilder()
            .Configure(i =>
            {
                i.ListNoteId = listNoteId.Value;
            })
            .Build();
            var note = _mapper.Map <NoteValue, Note>(noteValue);

            _repo.Add(note).GetAwaiter().GetResult();
            return(note);
        }
Beispiel #25
0
        //private static string MIDI_for_whom_the_bell_tolls = TestConfig.AudioPath + "metallica-for_whom_the_bell_tolls.mid";

        private void TestFirstNotePosition(NoteValue pNoteValue, string pNoteId, int pString, int pPosition)
        {
            var midiEvents = new MidiEventCollection();

            midiEvents.Add(new NoteOn(0, 1, pNoteId, 100));
            midiEvents.Add(new NoteOn(120, 1, pNoteId, 0));

            var midiImporter = new GuitarMidiImporter(midiEvents, 120);

            var firstScoreNote = midiImporter.ScoreNotes.ElementAt(0).Value;

            Assert.AreEqual(pNoteValue, firstScoreNote.Note.Value, firstScoreNote.NoteId);
            Assert.AreEqual(pString, firstScoreNote.NotePositions.ElementAt(0).Value.String, firstScoreNote.NoteId);
            Assert.AreEqual(pPosition, firstScoreNote.NotePositions.ElementAt(0).Value.Fret, firstScoreNote.NoteId);
        }
Beispiel #26
0
        public static string Chord(List <Note> chord, NoteValue length, bool dotted = false, string color = "#000000")
        {
            var notes = string.Join("\r\n", chord.Select(c =>
            {
                var accid = string.Empty;
                if (c.Accidental != Accidental.n)
                {
                    accid = $"accid='{c.Accidental}'";
                }
                return($"<note pname='{c.Name}' oct='{c.Register}' {accid}/>");
            }));

            return
                ($@"<chord dur='{(int)length}' color='{color}'>
{notes}
</chord>");
        }
Beispiel #27
0
        public static double LengthByTempo(this ITempoForBars tempo, NoteValue value)
        {
            switch (value)
            {
            case NoteValue.Quarter:
                return(tempo.QuarterLength);

            case NoteValue.DottedQuarter:
                return(tempo.DottedQuarterLength);

            case NoteValue.Half:
                return(tempo.HalfLength);

            case NoteValue.Eighth:
                return(tempo.EighthLength);

            case NoteValue.DottedEighth:
                return(tempo.DottedEighthLength);

            case NoteValue.Sixteenth:
                return(tempo.SixteenthLength);

            case NoteValue.DottedSixteenth:
                return(tempo.DottedSixteenthLength);

            case NoteValue.ThirtySecond:
                return(tempo.ThirtySecondLength);

            case NoteValue.DottedThirtySecond:
                return(tempo.DottedThirtySecondLength);

            case NoteValue.SixtyFourth:
                return(tempo.SixtyFourthLength);

            case NoteValue.DottedSixtyFourth:
                return(tempo.DottedSixtyFourthLength);

            case NoteValue.HundredTwentyEighth:
                return(tempo.HundredTwentyEighthLength);

            default:
                return(0);
            }
        }
Beispiel #28
0
        public override void Draw(Graphics g, Point drawLocation)
        {
            PointF drawPoint = new PointF(
                noteRect.X - Position.Lane * ScoreInfo.UnitLaneWidth - drawLocation.X + ScoreLane.scoreWidth,
                Location.Y - drawLocation.Y);

            g.TextRenderingHint = System.Drawing.Text.TextRenderingHint.AntiAlias;
            using (Font myFont = new Font("MS UI Gothic", ScoreInfo.FontSize, FontStyle.Bold))
            {
                g.DrawString(
                    "x" + NoteValue.ToString(),
                    myFont,
                    Brushes.Red,
                    new PointF(
                        drawPoint.X + adjustPoint.X,
                        drawPoint.Y + adjustPoint.Y));
            }
            using (Pen myPen = new Pen(Color.Red, 1))
            {
                g.DrawLine(
                    myPen,
                    drawPoint.X - ScoreLane.scoreWidth,
                    drawPoint.Y,
                    drawPoint.X,
                    drawPoint.Y);
            }
#if DEBUG
            /*
             * using (Pen myPen = new Pen(Color.White))
             * {
             *  RectangleF hitRect = new RectangleF(
             *  noteRect.X - Position.Lane * ScoreInfo.MinLaneWidth + ScoreLane.scoreWidth + adjustPoint.X,
             *  Location.Y + adjustPoint.Y,
             *  20,
             *  9);
             *  e.Graphics.DrawRectangles(myPen, new RectangleF[] { hitRect });
             * }
             * //*/
#endif
        }
Beispiel #29
0
        public override void Execute(SharedObjects shared)
        {
            int   argCount        = CountRemainingArgs(shared);
            float vol             = 1.0f;
            float keyDownDuration = -1f;

            if (argCount >= 5)
            {
                vol = (float)GetDouble(PopValueAssert(shared));
            }
            if (argCount >= 4)
            {
                keyDownDuration = (float)GetDouble(PopValueAssert(shared));
            }
            float  duration  = (float)GetDouble(PopValueAssert(shared));
            object endNote   = PopValueAssert(shared);
            object startNote = PopValueAssert(shared);

            AssertArgBottomAndConsume(shared);
            if (keyDownDuration < 0)
            {
                keyDownDuration = duration * 0.9f; // default to 90% of the total duration, allowing a short window for the release
            }
            if (keyDownDuration > duration)
            {
                keyDownDuration = duration; // clamp keyDown to the total duration
            }
            if (startNote is ScalarValue)
            {
                ReturnValue = new NoteValue((float)GetDouble(startNote), (float)GetDouble(endNote), vol, keyDownDuration, duration);
            }
            else if (startNote is StringValue)
            {
                ReturnValue = new NoteValue(startNote.ToString(), endNote.ToString(), vol, keyDownDuration, duration);
            }
            else
            {
                ReturnValue = new NoteValue(0f, vol, keyDownDuration, duration);
            }
        }
        public virtual async Task <List <string> > ValidateNote(NoteValue noteValue, string method)
        {
            var errorMessages = new List <string>();

            if (IsNull(noteValue))
            {
                errorMessages.Add(ErrorMessages.NullObject);
                return(errorMessages);
            }

            if (IsNullOrEmptyOrWhiteSpace(noteValue.Text))
            {
                errorMessages.Add(ErrorMessages.NoteEmpty);
            }

            if (noteValue.Text.Length > 144)
            {
                errorMessages.Add(ErrorMessages.NoteTextIncorrectLenght);
            }

            if (noteValue.DueDate != null && noteValue.DueDate < DateTime.Today)
            {
                errorMessages.Add(ErrorMessages.NoteDueDateLessCurrentDate);
            }

            if (!await _repo.IsExist <ListNote>(noteValue.ListNoteId))
            {
                errorMessages.Add(ErrorMessages.ListNoteNotExist);
            }

            if (await _repo.IsExistNoteTextInListNote(noteValue))
            {
                errorMessages.Add(ErrorMessages.NoteNotUnique);
            }

            return(errorMessages);
        }
Beispiel #31
0
 /// <summary>
 /// Calculates the actual time duration, in seconds, for the given tempo that the specified
 /// source note value will last. For example, if tempo is M.M. 120 quarter-notes per minute,
 /// then each quarter-note would last a half-second.
 /// </summary>
 /// <param name="source">Source note value.</param>
 /// <param name="dots">Total dotted note length extensions to apply.</param>
 /// <returns>Actual duration of note value in seconds.</returns>
 public double CalculateNoteValueTime(NoteValue source, int dots)
 {
     return m_noteValueTime * source.Duration(this.NamedNoteValue, dots);
 }
Beispiel #32
0
 /// <summary>
 /// Contructs a new <see cref="Tempo"/> object.
 /// </summary>
 /// <param name="totalNoteValues">Total note values for <see cref="Tempo"/>.</param>
 /// <param name="noteValue">Named note value used for <see cref="Tempo"/>.</param>
 public Tempo(int totalNoteValues, NoteValue noteValue)
 {
     m_totalNoteValues = totalNoteValues;
     m_noteValue = noteValue.Duration();
     CalculateNoteValueTime();
 }
Beispiel #33
0
 /// <summary>
 /// Validates that given note value will fit within this <see cref="MeasureSize"/> for specified beat.
 /// </summary>
 /// <param name="noteValue">Named note value to validate.</param>
 /// <param name="beat">Beat within in measure where note value is trying to fit.</param>
 /// <param name="dots">Dot length extensions to apply to named note value.</param>
 public void ValidateNoteValueAtBeat(NoteValue noteValue, int beat, int dots)
 {
     ValidateNoteValueAtBeat(noteValue.Duration(dots), beat);
 }
Beispiel #34
0
 /// <summary>
 /// Creates a new musical measure defined as the number of beats per note value.
 /// </summary>
 /// <param name="beats">A <see cref="Int32"/> representing the beats.</param>
 /// <param name="noteValue">A <see cref="NoteValue"/> representing the note value.</param>
 public MeasureSize(int beats, NoteValue noteValue)
 {
     m_beats     = beats;
     m_noteValue = noteValue.Duration();
 }
Beispiel #35
0
 /// <summary>
 /// Creates a new musical measure defined as the number of beats per note value.
 /// </summary>
 public MeasureSize(int beats, NoteValue noteValue)
 {
     m_beats = beats;
     m_noteValue = noteValue.Duration();
 }
Beispiel #36
0
 public void ValidateNoteValueAtBeat(NoteValue noteValue, int beat, int dots)
 {
     ValidateNoteValueAtBeat(noteValue.Duration(dots), beat);
 }
Beispiel #37
0
 /// <summary>
 /// NoteBubble Constructor.
 /// Creates a new NoteBubble object and its Note.
 /// </summary>
 /// <param name="noteValue">The NoteValue needed to create a Note</param>
 public NoteBubble(NoteValue noteValue)
 {
     Note = new Note(1, noteValue, "do", -1);
     Id = GlobalVariables.idNoteBubble++;
 }
Beispiel #38
0
Datei: Song.cs Projekt: rmc00/gsf
 /// <summary>
 /// Add a rest for the given length for the current beat.
 /// </summary>
 /// <param name="restLength">Duration of wait specified as a note value.</param>
 public void AddRest(NoteValue restLength)
 {
     AddNotes(new Note
     {
         NamedValue = restLength
     });
 }
Beispiel #39
0
 /// <summary>
 /// Note Constructor.
 /// Generates a new object of class Note, default Note
 /// </summary>
 public Note(NoteValue d)
 {
     Octave = 1;
     Duration = d;
     Pitch = "do";
     Sharp = false;
     Flat = false;
     Position = -1;
 }
Beispiel #40
0
Datei: Song.cs Projekt: rmc00/gsf
 /// <summary>
 /// Add a rest for the given length for the current beat.
 /// </summary>
 /// <param name="restLength">Duration of wait specified as a note value.</param>
 /// <param name="dots">Total dotted note length extensions to apply.</param>
 public void AddRest(NoteValue restLength, int dots)
 {
     AddNotes(new Note
     {
         NamedValue = restLength, Dots = dots
     });
 }
Beispiel #41
0
 /// <summary>
 /// Returns source note value duration in terms of given reference note value.
 /// For example, if measure size is 3/4 then reference is quarter notes and returned
 /// value will be equivalent number of quarter notes for given source note.
 /// </summary>
 /// <param name="source">Source note value.</param>
 /// <param name="reference">Reference note value.</param>
 /// <param name="dots">Total dotted note length extensions to apply.</param>
 /// <returns>Duration of note value in terms of specified reference note value.</returns>
 public static double Duration(this NoteValue source, NoteValue reference, int dots)
 {
     return Duration((int)source, (int)reference, dots);
 }