public AbcNoteParser(Tonality tonality) { this.tonality = tonality; this.unitNoteLength = new Duration(1, 4); //Default unit note length this.currentAccidentals = new Accidental[7]; this.resetAccidentals(); }
public static void saveToFile(Motif motif, string fileName, bool midi) { using (System.IO.StreamWriter streamWriter = new System.IO.StreamWriter(fileName, false)) { Tonality tonality = motif.getTonality(); AbcNoteParser anp = new AbcNoteParser(tonality); streamWriter.WriteLine("X:1"); streamWriter.WriteLine("L:1/4"); streamWriter.WriteLine("K:" + tonality.ToString()); int voiceIterator = 0; for (int j = 0; j < motif.voiceCount(); j++) { streamWriter.WriteLine("V:" + voiceIterator); voiceIterator++; Voice v = motif.getVoice(j); anp.resetAccidentals(); for (int k = 0; k < v.size(); k++) { streamWriter.Write(anp.toABC(v.get(k))); streamWriter.Write(" "); } if (midi) { streamWriter.Write("z"); } streamWriter.WriteLine("|]"); } } }
public Chord(Note tonic, Tonality tonality = Tonality.Major, Addition addition1 = Addition.None, Addition addition2 = Addition.None, Note bass = null) { Tonic = tonic; Tonality = tonality; Addition1 = addition1; Addition2 = addition2; Bass = bass; }
public async Task <ActionResult> DeleteConfirmed(int id) { Tonality tonality = await db.Tonalities.FindAsync(id); db.Tonalities.Remove(tonality); await db.SaveChangesAsync(); return(RedirectToAction("Index")); }
public async Task <ActionResult> Edit([Bind(Include = "Id,Name,Description,Url,File")] Tonality tonality) { if (ModelState.IsValid) { db.Entry(tonality).State = EntityState.Modified; tonality.UploadFile(); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(tonality)); }
private static Tonality GetTonality(string tonalitySymbol) { Tonality tonality = Tonality.Major; foreach (Tonality t in System.Enum.GetValues(typeof(Tonality))) { if (tonalitySymbol.Contains(t.Symbol())) { tonality = t; } } return(tonality); }
// GET: Tonalities/Edit/5 public async Task <ActionResult> Edit(int?id) { if (id == null) { return(new HttpStatusCodeResult(HttpStatusCode.BadRequest)); } Tonality tonality = await db.Tonalities.FindAsync(id); if (tonality == null) { return(HttpNotFound()); } return(View(tonality)); }
public async Task <ActionResult> Create([Bind(Include = "Id,Name,Description,Url,File")] Tonality tonality) { if (ModelState.IsValid) { db.Tonalities.Add(tonality); await db.SaveChangesAsync(); tonality.UploadFile(); await db.SaveChangesAsync(); return(RedirectToAction("Index")); } return(View(tonality)); }
public override string ToString() { string bass = string.Empty; string addition2 = string.Empty; if (Bass != null) { bass = string.Format("/{0}", Bass.ToString()); } if (Addition2 != Addition.None) { addition2 = string.Format("({0})", Addition2.Symbol()); } return(Tonic.ToString() + Tonality.Symbol() + Addition1.Symbol() + addition2 + bass); }
public static Chord CreateChord(string text) { Regex regex = new Regex(@"(([A-G])(bb|[Xb#])?)(º|((m?)((([245679]|11|13)[+-]?)(\((([245679]|11|13)[+-]?)\))?)?|(sus[249]?))?(\/(([A-G])(bb|[Xb#])?))?)"); if (!regex.IsMatch(text)) { throw new NotAKeyException("O texto informado não corresponde a nenhum acorde."); } Match match = regex.Match(text); Note tonic = GetNote(match.Groups[2].Value, match.Groups[3].Value); Tonality tonality = GetTonality(match.Groups[5].Value); Addition addition1 = GetAddition(match.Groups[8].Value); Addition addition2 = GetAddition(match.Groups[11].Value); Note bass = GetNote(match.Groups[16].Value, match.Groups[17].Value); return(new Chord(tonic, tonality, addition1, addition2, bass)); }
public Note GetInterval(int size, Tonality tone) { switch (tone) { case Tonality.Major: return(new Scale(this, ScaleType.Major).GetNote(size)); case Tonality.Minor: return(new Scale(this, ScaleType.NaturalMinor).GetNote(size)); case Tonality.Augmented: return(new Scale(this, ScaleType.Major).GetNote(size, 1)); case Tonality.Diminished: return(new Scale(this, ScaleType.NaturalMinor).GetNote(size, -1)); default: return(null); } }
public Note[] GetTriad(int rootDegree, Tonality tonality, int inversion = 0) { if (tonality == Tonality.Major) { switch (inversion) { case 0: return(new[] { GetNote(rootDegree), GetNote(rootDegree + 2), GetNote(rootDegree + 4) }); case 1: return(new[] { GetNote(rootDegree + 2 - 7), GetNote(rootDegree + 4 - 7), GetNote(rootDegree) }); case 2: return(new[] { GetNote(rootDegree + 4 - 7), GetNote(rootDegree), GetNote(rootDegree + 2) }); } } else if (tonality == Tonality.Minor) { switch (inversion) { case 0: return(new[] { GetNote(rootDegree), GetNote(rootDegree + 2, -1), GetNote(rootDegree + 4) }); case 1: return(new[] { GetNote(rootDegree), GetNote(rootDegree - 5, -1), GetNote(rootDegree - 3) }); case 2: return(new[] { GetNote(rootDegree), GetNote(rootDegree - 3), GetNote(rootDegree + 2, -1) }); } } return(null); }
public static void saveToFile(Tune tune, string fileName, int tempo, bool midi) { using (System.IO.StreamWriter streamWriter = new System.IO.StreamWriter(fileName, false)) { Tonality tonality = new Tonality(); //default tonality; int voiceCount = 0; List <string> voiceABC = new List <string>(); AbcNoteParser anp = new AbcNoteParser(tonality); streamWriter.WriteLine("X:" + tune.getReferenceNumber()); streamWriter.WriteLine("M:C"); streamWriter.WriteLine("L:1/4"); streamWriter.WriteLine("Q:1/4=" + tempo); streamWriter.WriteLine("K:" + tonality.ToString()); for (int i1 = 0; i1 < tune.trackCount(); i1++) { Track track = tune.getTrack(i1); if (track.isEmpty()) { continue; } if (track.getVolume() == 0) { continue; } anp.resetAccidentals(); voiceABC.Clear(); Duration motifStart = 0; Duration previousMotifEnd = 0; for (int i = 0; i < track.motifCount(); i++) { Motif motif = tune.getMotif(track.getMotifIdentificator(i)); Duration motifDuration = motif.getDuration(); motifStart = track.getStartTime(i); for (int j = 0; j < motif.voiceCount(); j++) { Voice voice = motif.getVoice(j); anp.resetAccidentals(); Duration voiceDuration = voice.getDuration(); if (j >= voiceABC.Count) { voiceABC.Add(""); if (motifStart > 0) { voiceABC[j] += "z" + motifStart + " "; } } else { Duration relativeStart = motifStart - previousMotifEnd; if (relativeStart > 0) { voiceABC[j] += "z" + relativeStart + " "; } } for (int k = 0; k < voice.size(); k++) { voiceABC[j] += anp.toABC(voice.get(k)) + " "; } } for (int j = motif.voiceCount(); j < voiceABC.Count; j++) { if (motifDuration > 0) { voiceABC[j] += "z" + motifStart + " "; } } previousMotifEnd = motifStart + motifDuration; } for (int i = 0; i < voiceABC.Count; i++) { streamWriter.WriteLine("V:" + (voiceCount + i)); if (midi) { streamWriter.WriteLine("%%MIDI program " + (int)track.getTimbre()); switch (track.getVolume()) { case 1: streamWriter.WriteLine("!ppp!"); break; case 2: streamWriter.WriteLine("!pp!"); break; case 3: streamWriter.WriteLine("!p!"); break; case 4: streamWriter.WriteLine("!mp!"); break; case 5: streamWriter.WriteLine("!mf!"); break; case 6: streamWriter.WriteLine("!f!"); break; case 7: streamWriter.WriteLine("!ff!"); break; default: streamWriter.WriteLine("!fff!"); break; } streamWriter.Write(voiceABC[i]); streamWriter.WriteLine("z"); } else { streamWriter.WriteLine(voiceABC[i]); } } voiceCount += voiceABC.Count; } } }
/// <summary>Intializes the meta event.</summary> /// <param name="deltaTime">The amount of time before this event.</param> /// <param name="key">Key of the signature.</param> /// <param name="tonality">Tonality of the signature.</param> public KeySignatureMetaMidiEvent(long deltaTime, Key key, Tonality tonality) : base(deltaTime, MetaId) { Key = key; Tonality = tonality; }
/// <summary>Intializes the meta event.</summary> /// <param name="deltaTime">The amount of time before this event.</param> /// <param name="key">Key of the signature.</param> /// <param name="tonality">Tonality of the signature.</param> public KeySignature(long deltaTime, Key key, Tonality tonality) : base(deltaTime, _METAID) { Key = key; Tonality = tonality; }
public static NoteKey ToKey(this(KeyAccidentalSign, Tonality) value) { var(keyAccidentalSign, tonality) = value; if (tonality == Major) { switch (keyAccidentalSign) { case Flat7: return(CFlatMajor); case Flat6: return(GFlatMajor); case Flat5: return(DFlatMajor); case Flat4: return(AFlatMajor); case Flat3: return(EFlatMajor); case Flat2: return(BFlatMajor); case Flat1: return(FMajor); case NoFlatsOrSharps: return(CMajor); case Sharp1: return(GMajor); case Sharp2: return(DMajor); case Sharp3: return(AMajor); case Sharp4: return(EMajor); case Sharp5: return(BMajor); case Sharp6: return(FSharpMajor); case Sharp7: return(CSharpMajor); } } else { switch (keyAccidentalSign) { case Flat7: return(AFlatMinor); case Flat6: return(EFlatMinor); case Flat5: return(BFlatMinor); case Flat4: return(FMinor); case Flat3: return(CMinor); case Flat2: return(GMinor); case Flat1: return(DMinor); case NoFlatsOrSharps: return(AMinor); case Sharp1: return(EMinor); case Sharp2: return(BMinor); case Sharp3: return(FSharpMinor); case Sharp4: return(CSharpMinor); case Sharp5: return(GSharpMinor); case Sharp6: return(DSharpMinor); case Sharp7: return(ASharpMinor); } } throw new Exception(); }
/// <summary>Intializes the meta event.</summary> /// <param name="owner">The track that owns this event.</param> /// <param name="deltaTime">The amount of time before this event.</param> /// <param name="key">Key of the signature.</param> /// <param name="tonality">Tonality of the signature.</param> public KeySignatureMetaMidiEvent(MidiTrack owner, long deltaTime, Key key, Tonality tonality) : base(owner, deltaTime, MetaId) { Key = key; Tonality = tonality; }
public void setTonality(Tonality tonality) { this.tonality = tonality; }
public HeaderContext header() { HeaderContext _localctx = new HeaderContext(Context, State); EnterRule(_localctx, 2, RULE_header); int _la; try { EnterOuterAlt(_localctx, 1); { { State = 38; _localctx.x = x_field(); _localctx.referenceNumber = _localctx.x.referenceNumber; } { State = 41; _localctx.t = t_field(); _localctx.title = _localctx.t.title; } State = 49; ErrorHandler.Sync(this); _la = TokenStream.La(1); while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << MField) | (1L << QField) | (1L << LFieldHeader))) != 0)) { { State = 47; switch (TokenStream.La(1)) { case MField: { State = 44; _localctx.m = m_field(); } break; case LFieldHeader: { State = 45; _localctx.l = l_field(); } break; case QField: { State = 46; _localctx.q = q_field(); } break; default: throw new NoViableAltException(this); } } State = 51; ErrorHandler.Sync(this); _la = TokenStream.La(1); } { State = 52; _localctx.k = k_field(); _localctx.tonality = Tonality.parse(_localctx.k.tonality_str); noteParser.setTonality(_localctx.tonality); } } } catch (RecognitionException re) { _localctx.exception = re; ErrorHandler.ReportError(this, re); ErrorHandler.Recover(this, re); } finally { ExitRule(); } return(_localctx); }
public ModulationVariation(Tonality tonality) { this.tonality = tonality; }
public void setTonality(Tonality t) { this.accidentals = t.getAccidentals(); }