ringw / vexflow

A JavaScript library for rendering music notation and guitar tablature.
http://www.vexflow.com
72 stars 23 forks source link

Lack of an explicit key signature results in no accidentals rendered #12

Closed Lykathia closed 4 years ago

Lykathia commented 8 years ago

If the optional key block is omitted from the musicxml sharps/flats currently do not render.

This diff fixes the problem, but I am unsure if it is the correct solution - as it does not apply an explicit key signature to the voice itself.

diff --git a/src/measure.js b/src/measure.js
index 12412e7..762b48f 100644
--- a/src/measure.js
+++ b/src/measure.js
@@ -224,7 +224,7 @@ Vex.Flow.Measure.Voice = function(object) {
     throw new Vex.RERR("ArgumentError",
               "Constructor requires nonzero num_beats and beat_value");
   this.time = Vex.Merge({}, object.time);
-  this.key = (typeof object.key == "string") ? object.key : null;
+  this.key = (typeof object.key == "string") ? object.key : "C";
   this.notes = new Array();
   if (object.notes instanceof Array)
     object.notes.forEach(function(note) {