Skip to content

Commit

Permalink
Updated for latest version of Moritz issue #2
Browse files Browse the repository at this point in the history
New PitchWheelDeviation message.
svgScoreExtensions.html references changed to
svgScoreNamespace.html.
Attribute hasMidi added to systems, system, staff,
hiddenOutputStaff and outputVoice containers.
Attribute alignmentX renamed alignment.
Added <leftToRight> element inside svgSystem.
  • Loading branch information
notator committed Jan 24, 2017
1 parent 505ca61 commit 8cfc0dd
Show file tree
Hide file tree
Showing 10 changed files with 48 additions and 55 deletions.
35 changes: 7 additions & 28 deletions Moritz.Spec/BasicMidiChordDef.cs
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,8 @@ public BasicMidiChordDef Inversion()

/// <summary>
/// Writes a single moment element which may contain
/// NoteOffs, bank, patch, pitchWheelDeviation, NoteOns
/// NoteOffs, bank, patch, pitchWheelDeviation, NoteOns.
/// Moritz never writes SysEx messages.
/// </summary>
public void WriteSVG(XmlWriter w, int channel, CarryMsgs carryMsgs)
{
Expand Down Expand Up @@ -128,11 +129,11 @@ public void WriteSVG(XmlWriter w, int channel, CarryMsgs carryMsgs)
}
if(PitchWheelDeviation != null)
{
List<MidiMsg> pwdMessages = GetPitchWheelDeviationMessages(channel, (int) PitchWheelDeviation);
foreach(MidiMsg msg in pwdMessages)
{
msg.WriteSVG(w);
}
w.WriteStartElement("pitchWheelDeviation");
w.WriteAttributeString("channel", channel.ToString());
w.WriteAttributeString("semitones", PitchWheelDeviation.ToString());
w.WriteAttributeString("cents", "0");
w.WriteEndElement();
}
w.WriteEndElement(); // switches
}
Expand Down Expand Up @@ -163,28 +164,6 @@ public void WriteSVG(XmlWriter w, int channel, CarryMsgs carryMsgs)
w.WriteEndElement(); // end of moment
}

/// <summary>
/// Moritz currently just sends the two COARSE messages to set the semitones value
/// </summary>
/// <param name="channel"></param>
/// <param name="semitones"></param>
/// <returns></returns>
private List<MidiMsg> GetPitchWheelDeviationMessages(int channel, int semitones)
{
List<MidiMsg> rList = new List<MidiMsg>();
int status = M.CMD_CONTROL_CHANGE_0xB0 + channel;
MidiMsg msg1 = new MidiMsg(status, M.CTL_REGISTEREDPARAMETER_COARSE_101, M.SELECT_PITCHBEND_RANGE_0);
rList.Add(msg1);
MidiMsg msg2 = new MidiMsg(status, M.CTL_DATAENTRY_COARSE_6, semitones);
rList.Add(msg2);
//MidiMsg msg3 = new MidiMsg(status, M.CTL_REGISTEREDPARAMETER_FINE_100, M.SELECT_PITCHBEND_RANGE_0);
//rList.Add(msg3);
//MidiMsg msg4 = new MidiMsg(status, M.CTL_DATAENTRY_FINE_38, cents);
//rList.Add(msg4);

return rList;
}

/// <summary>
/// The argument contains a list of 12 velocity values (range [1..127] in order of absolute pitch.
/// For example: If the MidiChordDef contains one or more C#s, they will be given velocity velocityPerAbsolutePitch[1].
Expand Down
30 changes: 15 additions & 15 deletions Moritz.Spec/CCSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,21 +66,21 @@ public void WriteSVG(SvgWriter w)
public ReadOnlyCollection<TrackCCSettings> OverrideSettings { get { return _overrideSettings.AsReadOnly(); } }
private List<TrackCCSettings> _overrideSettings = null;
}
/// TrackCCSettings are switches that are components of InputChordDef.ccSettings objects.
/// The Assistant Performer sets these values when the chord with which they are associated is performed.
/// The setting for each of the three continuous controlers persists until it is changed in a later
/// InputChordDef.ccSettings object.
/// TrackCCSettings can have CControllerType values (defined in an enum in this file).
/// The default options are:
/// pressure="undefined" -- not written to scores. Means "keep the current setting".
/// pitchWheel="undefined" -- not written to scores. Means "keep the current setting".
/// modulation="undefined" -- not written to scores. Means "keep the current setting".
/// To turn a controller off during a score, use the CControllerType.disabled setting.
/// The continuous controllers are disabled by default in the Assistant Performer.
///
/// See also: http://james-ingram-act-two.de/open-source/svgScoreExtensions.html
/// </summary>
public sealed class TrackCCSettings
/// TrackCCSettings are switches that are components of InputChordDef.ccSettings objects.
/// The Assistant Performer sets these values when the chord with which they are associated is performed.
/// The setting for each of the three continuous controlers persists until it is changed in a later
/// InputChordDef.ccSettings object.
/// TrackCCSettings can have CControllerType values (defined in an enum in this file).
/// The default options are:
/// pressure="undefined" -- not written to scores. Means "keep the current setting".
/// pitchWheel="undefined" -- not written to scores. Means "keep the current setting".
/// modulation="undefined" -- not written to scores. Means "keep the current setting".
/// To turn a controller off during a score, use the CControllerType.disabled setting.
/// The continuous controllers are disabled by default in the Assistant Performer.
///
/// See also: http://james-ingram-act-two.de/open-source/svgScoreNamespace.html
/// </summary>
public sealed class TrackCCSettings
{
public TrackCCSettings(byte? midiChannel, CCSetting ccSetting)
{
Expand Down
2 changes: 1 addition & 1 deletion Moritz.Spec/MidiChordDef.cs
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,7 @@ public void WriteSVG(SvgWriter w, int channel, CarryMsgs carryMsgs)

w.WriteStartElement("score", "midi", null);

w.WriteStartElement("moments", null);
w.WriteStartElement("moments");

foreach(BasicMidiChordDef bmcd in BasicMidiChordDefs)
{
Expand Down
2 changes: 1 addition & 1 deletion Moritz.Spec/TrkOptions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ namespace Moritz.Spec
/// speed=1 -- performed durations are the msDurations written in the score.
/// trkOff="undefined" -- performed noteOff messages have no affect on the trk (trks play to completion, as written in the score).
///
/// See also: http://james-ingram-act-two.de/open-source/svgScoreExtensions.html
/// See also: http://james-ingram-act-two.de/open-source/svgScoreNamespace.html
/// </summary>
public sealed class TrkOptions
{
Expand Down
9 changes: 6 additions & 3 deletions Moritz.Symbols/SvgPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,10 @@ private void WriteFrameLayer(SvgWriter w, int layerNumber, string layerName, flo
private void WriteScoreLayer(SvgWriter w, int layerNumber, string layerName, int pageNumber, Metadata metadata)
{
w.WriteStartElement("g"); // start layer (for Inkscape)
WriteInkscapeLayerAttributes(w, layerNumber, layerName, true);

w.WriteAttributeString("score", "hasMidi", null, "hasMidi"); // This <g> element is the "systems" container

WriteInkscapeLayerAttributes(w, layerNumber, layerName, true);

w.SvgText("timeStamp", _infoTextInfo, 32, 80);

Expand Down Expand Up @@ -250,7 +253,7 @@ private void WriteSodipodiNamedview(SvgWriter w)
private void WriteSvgHeader(SvgWriter w)
{
w.WriteAttributeString("xmlns", "http://www.w3.org/2000/svg");
w.WriteAttributeString("xmlns", "score", null, "http://www.james-ingram-act-two.de/open-source/svgScoreExtensions.html");
w.WriteAttributeString("xmlns", "score", null, "http://www.james-ingram-act-two.de/open-source/svgScoreNamespace.html");
w.WriteAttributeString("xmlns", "dc", null, "http://purl.org/dc/elements/1.1/");
w.WriteAttributeString("xmlns", "cc", null, "http://creativecommons.org/ns#");
w.WriteAttributeString("xmlns", "rdf", null, "http://www.w3.org/1999/02/22-rdf-syntax-ns#");
Expand All @@ -268,7 +271,7 @@ private void WriteSvgHeader(SvgWriter w)
// The value is not checked by the Assistant Performer, because I know that the AP only plays scores that I give it.
// However, theoretically, anyone could write an app that uses this file, and they would need to be told the format
// in this standardized attribute.
w.WriteAttributeString("data-scoreType", null, "http://www.james-ingram-act-two.de/open-source/svgScoreExtensions.html");
w.WriteAttributeString("data-scoreType", null, "http://www.james-ingram-act-two.de/open-source/svgScoreNamespace.html");

w.WriteAttributeString("width", _pageFormat.ScreenRight.ToString()); // the intended screen display size (100%)
w.WriteAttributeString("height", _pageFormat.ScreenBottom.ToString()); // the intended screen display size (100%)
Expand Down
16 changes: 13 additions & 3 deletions Moritz.Symbols/SvgSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,11 @@ public SvgSystem(SvgScore score)
/// <param name="w"></param>
public void WriteSVG(SvgWriter w, int systemNumber, PageFormat pageFormat, List<CarryMsgs> carryMsgsPerChannel)
{
w.SvgStartGroup("system");
w.WriteAttributeString("score", "bbTop", null, this.Metrics.NotesTop.ToString());
w.WriteAttributeString("score", "bbBottom", null, this.Metrics.NotesBottom.ToString());
w.SvgStartGroup("system");

w.WriteAttributeString("score", "hasMidi", null, "hasMidi"); // this is a "system" container

WriteLeftToRightElement(w);

for(int staffIndex = 0; staffIndex < Staves.Count; staffIndex++)
{
Expand All @@ -44,6 +46,14 @@ public void WriteSVG(SvgWriter w, int systemNumber, PageFormat pageFormat, List<
w.SvgEndGroup(); // system
}

private void WriteLeftToRightElement(SvgWriter w)
{
w.WriteStartElement("score", "leftToRight", null);
w.WriteAttributeString("systemTop", this.Metrics.NotesTop.ToString());
w.WriteAttributeString("systemBottom", this.Metrics.NotesBottom.ToString());
w.WriteEndElement(); // leftToRight
}

private void WriteConnectors(SvgWriter w, int systemNumber, PageFormat pageFormat)
{
List<bool> barlineContinuesDownList = pageFormat.BarlineContinuesDownList;
Expand Down
3 changes: 2 additions & 1 deletion Moritz.Symbols/System Components/OutputStaff.cs
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,8 @@ public HiddenOutputStaff(SvgSystem svgSystem)
public override void WriteSVG(SvgWriter w, int systemNumber, int staffNumber, List<CarryMsgs> carryMsgsPerChannel)
{
w.SvgStartGroup("outputStaff");
w.WriteAttributeString("score", "invisible", null, "1");
w.WriteAttributeString("score", "hasMidi", null, "hasMidi");
w.WriteAttributeString("score", "invisible", null, "invisible");

base.WriteSVG(w, false, systemNumber, staffNumber, carryMsgsPerChannel);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ public OutputVoice(OutputStaff outputStaff, int midiChannel, byte? masterVolume)
public override void WriteSVG(SvgWriter w, bool staffIsVisible, int systemNumber, int staffNumber, int voiceNumber, List<CarryMsgs> carryMsgsPerChannel)
{
w.SvgStartGroup("outputVoice");
w.WriteAttributeString("score", "hasMidi", null, "hasMidi");
w.WriteAttributeString("score", "hasMidi", null, "hasMidi"); // this is a "voice" container

if(MasterVolume != null) // is non-null only in the first system
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public void WriteSVG(SvgWriter w, bool staffIsVisible, int channel, CarryMsgs ca
w.SvgStartGroup("outputChord");
if(staffIsVisible)
{
w.WriteAttributeString("score", "alignmentX", null, ChordMetrics.OriginX.ToString(M.En_USNumberFormat));
w.WriteAttributeString("score", "alignment", null, ChordMetrics.OriginX.ToString(M.En_USNumberFormat));
}

_midiChordDef.WriteSVG(w, channel, carryMsgs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void WriteSVG(SvgWriter w, bool staffIsVisible, int channel, CarryMsgs ca
Debug.Assert(_msDuration > 0);
if(staffIsVisible)
{
w.WriteAttributeString("score", "alignmentX", null, ((Metrics.Left + Metrics.Right) / 2).ToString(M.En_USNumberFormat));
w.WriteAttributeString("score", "alignment", null, ((Metrics.Left + Metrics.Right) / 2).ToString(M.En_USNumberFormat));
}

_midiRestDef.WriteSVG(w, channel, carryMsgs);
Expand Down

0 comments on commit 8cfc0dd

Please sign in to comment.