public MidiInfo(int midi, Accidental accidental) { this.midi = midi; this.Accidental = accidental; this.UserOctave = -1; //undefined this.whiteKeyNoteNumber = -1; //undefined }
public Key(Note note, Accidental accidental, Octave octave) { Note = note; Octave = octave; Accidental = accidental; numberOfKey = (int)Octave - (int)Note - (0.5 * (int)Accidental); }
public static bool TryParse(string text, out Accidental accidental) { switch (text) { case "": accidental = Accidental.Natural; break; case "b": case "♭": accidental = Accidental.Flat; break; case "bb": case "♭♭": case "\u1d12b": accidental = Accidental.DoubleFlat; break; case "#": case "♯": accidental = Accidental.Sharp; break; case "##": case "♯♯": case "\u1d12a": accidental = Accidental.DoubleSharp; break; default: accidental = Accidental.Natural; return(false); } return(true); }
public ModeTestCase(Scale scale, int sourceDegree, Accidental sourceAccidental, Note testNote) { Scale = scale; SourceDegree = sourceDegree; SourceAccidental = sourceAccidental; TestNote = testNote; }
public void AddAccidental(float x, float y, Accidental a) { switch (a) { case Accidental.DoubleFlat: keySignature.Add(new RectangleF(x, y - 50 * Song._SCALE, 60 * Song._SCALE, 70 * Song._SCALE)); break; case Accidental.Flat: keySignature.Add(new RectangleF(x, y - 50 * Song._SCALE, 35 * Song._SCALE, 68 * Song._SCALE)); break; case Accidental.Natural: keySignature.Add(new RectangleF(x, y - 38 * Song._SCALE, 20 * Song._SCALE, 70 * Song._SCALE)); break; case Accidental.Sharp: keySignature.Add(new RectangleF(x, y - 38 * Song._SCALE, 35 * Song._SCALE, 70 * Song._SCALE)); break; case Accidental.DoubleSharp: keySignature.Add(new RectangleF(x, y - 20 * Song._SCALE, 35 * Song._SCALE, 35 * Song._SCALE)); break; } }
private void AddPitchToSymbol(int keyCode) { Tone tone = Tone.C; Accidental acc = Accidental.None; int toneNumber = keyCode % Constants.TONES_IN_OCTAVE; var values = Enum.GetValues(typeof(Tone)).Cast <int>(); for (int i = 0; i <= toneNumber; i++) { if (values.Contains(i)) { tone = (Tone)i; acc = Accidental.None; } else { acc = Accidental.Sharp; } } if (currentSymbolBuilder == null) { currentSymbolBuilder = new SymbolBuilder(); } currentSymbolBuilder.WithPitch(tone, acc, GetOctaveOffset(keyCode)); }
public static Note Parse(String s) { NoteName nName = NoteNameEx.Parse(s.Substring(0, 1)); Accidental nAccidental = AccidentalEx.Parse(s.Substring(1)); return(new Note(nName, nAccidental)); }
public Tone(string toneName) { var toneNameSmall = toneName.Trim().ToLowerInvariant(); this.Fundamental = ToneParser.ParseFundamental(toneNameSmall[0]); this.Accidental = ToneParser.ParseAccidental(toneNameSmall.Substring(1)); }
public Key(NoteLetters rootName, Accidental rootAccidental = Accidental.n) { this.mode = Mode.Major; this.RootSemitone = (Semitone)(((int)rootName + (int)rootAccidental) % 12); var major = new CircularList <Semitone> { Semitone.c, Semitone.d, Semitone.e, Semitone.f, Semitone.g, Semitone.a, Semitone.b }; this.noteOffset = 0; foreach (var name in major) { if (name == (Semitone)rootName) { break; } this.noteOffset++; } for (int interval = 0; interval < 7; interval++) { this.Add(new Note() { Name = (NoteLetters)major[this.noteOffset + interval], SemitonesFromRoot = major[interval], RootSemitone = this.RootSemitone, Interval = interval + 1 // offset so we can have human readable intervals }); } }
/// <summary> /// Returns the specified interval as it would be notated in sheet music. /// </summary> /// <param name="interval">Interval of note name to retrieve</param> /// <param name="accidental">Accidental of note returned</param> /// <returns></returns> public NoteLetters GetSheetNoteName(int interval, out Accidental accidental) { interval -= 1; // offset so we can use human readable intervals int[] CMajor = new int[] { 0, 2, 4, 5, 7, 9, 11, 12 }; interval = (interval + this.Position) % 7; int semitonesFromRoot = (int)this.list[interval].SemitonesFromRoot; int intervalInC = (interval + noteOffset) % 7; int semitonesFromC = (semitonesFromRoot + (int)RootSemitone) % 12; // Handle the two wrap around cases where we need to compare against top C if (intervalInC == 0 && semitonesFromC == 11) { intervalInC = 7; } if (intervalInC == 6 && semitonesFromC == 0) { semitonesFromC = 12; } accidental = (Accidental)(semitonesFromC - CMajor[intervalInC]); return(this.list[interval].Name); }
public static Accidental GetAccidental(int val) { Accidental accidental = Accidental.Unspecified; accidentals.TryGetValue(val, out accidental); return(accidental); }
/// <summary> /// Conctructor most suitable for human use: takes the note name, octave, and accidental. /// </summary> /// <param name="name">Uppercase character such as 'C' or 'A'.</param> /// <param name="octave">Octave must be at least -1. C4 is middle C (octave = 4).</param> /// <param name="accidental">The accidental to apply to the given note.</param> public Pitch(char name, int octave, Accidental accidental) { int cOffset; // 0 for C, 1 for D, ..., 5 for A, 6 for B Accidental = accidental; cOffset = GetCOffset(name); number = (octave + 1) * 7 + cOffset; }
public Note(Pitch pitch = Pitch.C4, Length length = Length.Eighth, Accidental accidental = Accidental.Unspecified, int dotCount = 0) : base(Item.Type.Note) { this.pitch = pitch; this.length = length; this.accidental = accidental; this.dotCount = dotCount; }
public Key(Fundamental fundamental = Fundamental.C, Accidental accidental = Accidental.Natural, bool isMajor = true) { this.Tonic = new Tone() { Fundamental = fundamental, Accidental = accidental }; this.IsMajor = isMajor; }
/// <summary> /// Add properties to Accidental /// </summary> /// <param name="_accidobj">Empty accidental object</param> /// <param name="_accid">MEI accid element</param> /// <returns></returns> public static Accidental ConvertAccidental(Accidental _accidobj, Accid _accid) { _accidobj.AccidentalPosition = GetPosition(_accid); _accidobj.AccidentalType = GetAccidentalType(_accid); _accidobj.PitchLocation = GetAccidPitchLoc(_accid); return(_accidobj); }
public Interval( DiatonicInterval diatonicInterval, Accidental accidental) : base(GetDistance(diatonicInterval, accidental)) { DiatonicInterval = diatonicInterval; Accidental = accidental; Name = $"{Accidental}{(int) diatonicInterval}"; }
public Note( DiatonicNote diatonicNote, Accidental accidental) { DiatonicNote = diatonicNote; Accidental = accidental; DistanceFromC = new Semitone((int)DiatonicNote + Accidental); }
public void WithPitch(Tone tone, Accidental acc, int OctaveOffset) { pitch = new Pitch { Tone = tone, Accidental = acc, OctaveOffset = OctaveOffset }; }
public static Accidental CreateAccidental(string type) { ObjectFactory factory = new ObjectFactory(); ////////////////////////////////////////Create an accidental Accidental accidental = factory.createAccidental(); accidental.setValue(AccidentalValue.fromValue(type)); return(accidental); }
public override int GetHashCode() { unchecked { int hashCode = base.GetHashCode(); hashCode = (hashCode * 397) ^ DiatonicInterval.GetHashCode(); hashCode = (hashCode * 397) ^ Accidental.GetHashCode(); return(hashCode); } }
private static HtmlString GetHtmlString(Tone tone, Accidental accidental, NamingConvention conv) { if (tone == Tone.B && accidental == Accidental.Flat && conv == NamingConvention.German) { return(new HtmlString("B")); } var str = string.Format("{0}<sub>{1}</sub>", tone.GetDescriptions().ToArray()[(int)conv], accidental.ToDescription()); return(new HtmlString(str)); }
/// <summary> /// Converts a string into an accidented diatonic interval /// </summary> /// <param name="s"> /// The string. /// </param> /// <returns> /// The <see cref="Interval" />. /// </returns> public new static Interval Parse(string s) { s = Regex.Replace(s.Trim(), "[()]", string.Empty); var accidentalString = Regex.Match(s, "^[^0-9]*").ToString(); var intervalString = Regex.Match(s, "[0-9]*$").ToString(); var accidental = Accidental.Parse(accidentalString); var interval = (DiatonicInterval)Enum.Parse(typeof(DiatonicInterval), intervalString); var result = new Interval(interval, accidental); return(result); }
public bool Equals(Note other) { if (ReferenceEquals(null, other)) { return(false); } if (ReferenceEquals(this, other)) { return(true); } return(DiatonicNote == other.DiatonicNote && Accidental.Equals(other.Accidental)); }
internal Interval( int semitones, Accidental accidental, int noteIndex, string name, string symbol) { Semitones = semitones; Accidental = accidental; NoteIndex = noteIndex; Name = name; Symbol = symbol; }
public Note Flatten() { Accidental accidental = Accidental; if (accidental > Accidental.DoubleFlat) { return(new Note(NaturalNote, --accidental)); } else { throw new InvalidOperationException(); } }
public Note Sharpen() { Accidental accidental = Accidental; if (accidental < Accidental.DoubleSharp) { return(new Note(NaturalNote, ++accidental)); } else { throw new InvalidOperationException(); } }
public int CompareTo(Interval other) { var result = DiatonicInterval.CompareTo(other.DiatonicInterval); if (result != 0) { return(result); } result = Accidental.CompareTo(other.Accidental); return(result); }
public ParsedDegree(Accidental accidental, int degree, KnownChordKind degreeChordKind, ChordExtensions.ExtensionBase baseExtension, IEnumerable <ChordExtensions.Extension> extensions, Tuple <int, KnownChordKind> jazzChordInversion = null) { Accidental = accidental; Degree = degree; DegreeChordKind = degreeChordKind; BaseExtension = baseExtension; Extensions = extensions; JazzChordInversion = jazzChordInversion; }
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 };
/// <summary> /// Constructs a new note. /// </summary> /// <param name="integer">The integer notation value for the note.</param> public Note(int integer) { int nearest = integer; var notes = (int[])Enum.GetValues(typeof(NoteName)); int i = notes.Length - 1; while (nearest >= integer) { nearest -= notes[i--]; } this.name = (NoteName)nearest; this.accidental = (Accidental)(integer - nearest); }
private int StepsToA4( Octave octave, Tone note, Accidental accidental) { int stepsToOctave4 = (int)octave * 12; var stepsToA = (int)note; switch (accidental) { case Accidental.Flat: stepsToA--; break; case Accidental.Sharp: stepsToA++; break; } return stepsToOctave4 + stepsToA; }
public AccidentalModifier(Accidental accidental) { m_Accidental = accidental; }