private void BarMeta(Bar bar) { var master = bar.MasterBar; while (_sy == AlphaTexSymbols.MetaCommand) { var syData = _syData.ToString().ToLower(); if (syData == "ts") { NewSy(); if (_sy != AlphaTexSymbols.Number) { Error("timesignature-numerator", AlphaTexSymbols.Number); } master.TimeSignatureNumerator = (int)_syData; NewSy(); if (_sy != AlphaTexSymbols.Number) { Error("timesignature-denominator", AlphaTexSymbols.Number); } master.TimeSignatureDenominator = (int)_syData; } else if (syData == "ro") { master.IsRepeatStart = true; } else if (syData == "rc") { NewSy(); if (_sy != AlphaTexSymbols.Number) { Error("repeatclose", AlphaTexSymbols.Number); } master.RepeatCount = ((int)_syData) - 1; } else if (syData == "ks") { NewSy(); if (_sy != AlphaTexSymbols.String) { Error("keysignature", AlphaTexSymbols.String); } master.KeySignature = ParseKeySignature(_syData.ToString().ToLower()); } else if (syData == "clef") { NewSy(); if (_sy != AlphaTexSymbols.String && _sy != AlphaTexSymbols.Tuning) { Error("clef", AlphaTexSymbols.String); } bar.Clef = ParseClef(_syData.ToString().ToLower()); } else if (syData == "tempo") { NewSy(); if (_sy != AlphaTexSymbols.Number) { Error("tempo", AlphaTexSymbols.Number); } var tempoAutomation = new Automation(); tempoAutomation.IsLinear = true; tempoAutomation.Type = AutomationType.Tempo; tempoAutomation.Value = (float)_syData; master.TempoAutomation = tempoAutomation; } else { Error("measure-effects", AlphaTexSymbols.String, false); } NewSy(); } }
public Score JsObjectToScore(Score score) { var score2 = new Score(); Score.CopyTo(score, score2); #region MasterBars for (var i = 0; i < score.MasterBars.Count; i++) { var masterBar = score.MasterBars[i]; var masterBar2 = new MasterBar(); MasterBar.CopyTo(masterBar, masterBar2); if (masterBar.TempoAutomation != null) { masterBar2.TempoAutomation = new Automation(); Automation.CopyTo(masterBar.TempoAutomation, masterBar2.TempoAutomation); } if (masterBar.VolumeAutomation != null) { masterBar2.VolumeAutomation = new Automation(); Automation.CopyTo(masterBar.VolumeAutomation, masterBar2.VolumeAutomation); } if (masterBar.Section != null) { masterBar2.Section = new Section(); Section.CopyTo(masterBar.Section, masterBar2.Section); } score2.AddMasterBar(masterBar2); } #endregion #region Tracks for (int t = 0; t < score.Tracks.Count; t++) { var track = score.Tracks[t]; var track2 = new Track(track.Staves.Count); Track.CopyTo(track, track2); score2.AddTrack(track2); PlaybackInformation.CopyTo(track.PlaybackInfo, track2.PlaybackInfo); foreach (var key in track.Chords.Keys) { var chord = track.Chords[key]; var chord2 = new Chord(); Chord.CopyTo(chord, chord2); track2.Chords[key] = chord2; } #region Staves for (var s = 0; s < track.Staves.Count; s++) { var staff = track.Staves[s]; #region Bars for (int b = 0; b < staff.Bars.Count; b++) { var bar = staff.Bars[b]; var bar2 = new Bar(); Bar.CopyTo(bar, bar2); track2.AddBarToStaff(s, bar2); #region Voices for (int v = 0; v < bar.Voices.Count; v++) { var voice = bar.Voices[v]; var voice2 = new Voice(); Voice.CopyTo(voice, voice2); bar2.AddVoice(voice2); #region Beats for (int bb = 0; bb < voice.Beats.Count; bb++) { var beat = voice.Beats[bb]; var beat2 = new Beat(); Beat.CopyTo(beat, beat2); voice2.AddBeat(beat2); for (int a = 0; a < beat.Automations.Count; a++) { var automation = new Automation(); Automation.CopyTo(beat.Automations[a], automation); beat2.Automations.Add(automation); } for (int i = 0; i < beat.WhammyBarPoints.Count; i++) { var point = new BendPoint(); BendPoint.CopyTo(beat.WhammyBarPoints[i], point); beat2.WhammyBarPoints.Add(point); } #region Notes for (int n = 0; n < beat.Notes.Count; n++) { var note = beat.Notes[n]; var note2 = new Note(); Note.CopyTo(note, note2); beat2.AddNote(note2); for (int i = 0; i < note.BendPoints.Count; i++) { var point = new BendPoint(); BendPoint.CopyTo(note.BendPoints[i], point); note2.AddBendPoint(point); } } #endregion } #endregion } #endregion } #endregion } #endregion } #endregion score2.Finish(); return(score2); }
private void ParseDirection(IXmlNode element, MasterBar masterBar) { element.IterateChildren(c => { if (c.NodeType == XmlNodeType.Element) { switch (c.LocalName) { case "sound": var tempoAutomation = new Automation(); tempoAutomation.IsLinear = true; tempoAutomation.Type = AutomationType.Tempo; tempoAutomation.Value = Std.ParseInt(c.GetAttribute("tempo")); masterBar.TempoAutomation = tempoAutomation; break; } } }); }
public Score ScoreToJsObject(Score score) { Score score2 = Std.NewObject(); Score.CopyTo(score, score2); score2.MasterBars = new FastList <MasterBar>(); score2.Tracks = new FastList <Track>(); #region MasterBars for (var i = 0; i < score.MasterBars.Count; i++) { MasterBar masterBar = score.MasterBars[i]; MasterBar masterBar2 = Std.NewObject(); MasterBar.CopyTo(masterBar, masterBar2); if (masterBar.TempoAutomation != null) { masterBar2.TempoAutomation = Std.NewObject(); Automation.CopyTo(masterBar.TempoAutomation, masterBar2.TempoAutomation); } if (masterBar.VolumeAutomation != null) { masterBar2.VolumeAutomation = Std.NewObject(); Automation.CopyTo(masterBar.VolumeAutomation, masterBar2.VolumeAutomation); } if (masterBar.Section != null) { masterBar2.Section = Std.NewObject(); Section.CopyTo(masterBar.Section, masterBar2.Section); } score2.MasterBars.Add(masterBar2); } #endregion #region Tracks for (int t = 0; t < score.Tracks.Count; t++) { var track = score.Tracks[t]; Track track2 = Std.NewObject(); track2.Color = Std.NewObject(); Track.CopyTo(track, track2); track2.PlaybackInfo = Std.NewObject(); PlaybackInformation.CopyTo(track.PlaybackInfo, track2.PlaybackInfo); track2.Chords = new FastDictionary <string, Chord>(); foreach (var key in track.Chords.Keys) { var chord = track.Chords[key]; Chord chord2 = Std.NewObject(); Chord.CopyTo(chord, chord2); track2.Chords[key] = chord; } #region Staves track2.Staves = new FastList <Staff>(); for (int s = 0; s < track.Staves.Count; s++) { var staff = track.Staves[s]; Staff staff2 = Std.NewObject(); #region Bars staff2.Bars = new FastList <Bar>(); for (int b = 0; b < staff.Bars.Count; b++) { var bar = staff.Bars[b]; Bar bar2 = Std.NewObject(); Bar.CopyTo(bar, bar2); #region Voices bar2.Voices = new FastList <Voice>(); for (int v = 0; v < bar.Voices.Count; v++) { var voice = bar.Voices[v]; Voice voice2 = Std.NewObject(); Voice.CopyTo(voice, voice2); #region Beats voice2.Beats = new FastList <Beat>(); for (int bb = 0; bb < voice.Beats.Count; bb++) { var beat = voice.Beats[bb]; Beat beat2 = Std.NewObject(); Beat.CopyTo(beat, beat2); beat2.Automations = new FastList <Automation>(); for (int a = 0; a < beat.Automations.Count; a++) { Automation automation = Std.NewObject(); Automation.CopyTo(beat.Automations[a], automation); beat2.Automations.Add(automation); } beat2.WhammyBarPoints = new FastList <BendPoint>(); for (int i = 0; i < beat.WhammyBarPoints.Count; i++) { BendPoint point = Std.NewObject(); BendPoint.CopyTo(beat.WhammyBarPoints[i], point); beat2.WhammyBarPoints.Add(point); } #region Notes beat2.Notes = new FastList <Note>(); for (int n = 0; n < beat.Notes.Count; n++) { var note = beat.Notes[n]; Note note2 = Std.NewObject(); Note.CopyTo(note, note2); note2.BendPoints = new FastList <BendPoint>(); for (int i = 0; i < note.BendPoints.Count; i++) { BendPoint point = Std.NewObject(); BendPoint.CopyTo(note.BendPoints[i], point); note2.BendPoints.Add(point); } beat2.Notes.Add(note2); } #endregion voice2.Beats.Add(beat2); } #endregion bar2.Voices.Add(voice2); } #endregion staff2.Bars.Add(bar2); } #endregion track2.Staves.Add(staff); } #endregion score2.Tracks.Add(track2); } #endregion return(score2); }
public void ReadMixTableChange(Beat beat) { var tableChange = new MixTableChange(); tableChange.Instrument = Data.ReadByte(); if (_versionNumber >= 500) { Data.Skip(16); // Rse Info } tableChange.Volume = Data.ReadSignedByte(); tableChange.Balance = Data.ReadSignedByte(); var chorus = Data.ReadSignedByte(); var reverb = Data.ReadSignedByte(); var phaser = Data.ReadSignedByte(); var tremolo = Data.ReadSignedByte(); if (_versionNumber >= 500) { tableChange.TempoName = ReadStringIntByte(); } tableChange.Tempo = ReadInt32(); // durations if (tableChange.Volume >= 0) { Data.ReadByte(); } if (tableChange.Balance >= 0) { Data.ReadByte(); } if (chorus >= 0) { Data.ReadByte(); } if (reverb >= 0) { Data.ReadByte(); } if (phaser >= 0) { Data.ReadByte(); } if (tremolo >= 0) { Data.ReadByte(); } if (tableChange.Tempo >= 0) { tableChange.Duration = Data.ReadSignedByte(); if (_versionNumber >= 510) { Data.ReadByte(); // hideTempo (bool) } } if (_versionNumber >= 400) { Data.ReadByte(); // all tracks flag } // unknown if (_versionNumber >= 500) { Data.ReadByte(); } // unknown if (_versionNumber >= 510) { ReadStringIntByte(); ReadStringIntByte(); } if (tableChange.Volume >= 0) { var volumeAutomation = new Automation(); volumeAutomation.IsLinear = true; volumeAutomation.Type = AutomationType.Volume; volumeAutomation.Value = tableChange.Volume; beat.Automations.Add(volumeAutomation); } if (tableChange.Balance >= 0) { var balanceAutomation = new Automation(); balanceAutomation.IsLinear = true; balanceAutomation.Type = AutomationType.Balance; balanceAutomation.Value = tableChange.Balance; beat.Automations.Add(balanceAutomation); } if (tableChange.Instrument >= 0) { var instrumentAutomation = new Automation(); instrumentAutomation.IsLinear = true; instrumentAutomation.Type = AutomationType.Instrument; instrumentAutomation.Value = tableChange.Instrument; beat.Automations.Add(instrumentAutomation); } if (tableChange.Tempo >= 0) { var tempoAutomation = new Automation(); tempoAutomation.IsLinear = true; tempoAutomation.Type = AutomationType.Tempo; tempoAutomation.Value = tableChange.Tempo; beat.Automations.Add(tempoAutomation); beat.Voice.Bar.MasterBar.TempoAutomation = tempoAutomation; } }
public Score JsObjectToScore(Score score) { var score2 = new Score(); Score.CopyTo(score, score2); #region MasterBars for (var i = 0;i < score.MasterBars.Count; i++) { var masterBar = score.MasterBars[i]; var masterBar2 = new MasterBar(); MasterBar.CopyTo(masterBar, masterBar2); if (masterBar.TempoAutomation != null) { masterBar2.TempoAutomation = new Automation(); Automation.CopyTo(masterBar.TempoAutomation, masterBar2.TempoAutomation); } if (masterBar.VolumeAutomation != null) { masterBar2.VolumeAutomation = new Automation(); Automation.CopyTo(masterBar.VolumeAutomation, masterBar2.VolumeAutomation); } if (masterBar.Section != null) { masterBar2.Section = new Section(); Section.CopyTo(masterBar.Section, masterBar2.Section); } score2.AddMasterBar(masterBar2); } #endregion #region Tracks for (int t = 0; t < score.Tracks.Count; t++) { var track = score.Tracks[t]; var track2 = new Track(); Track.CopyTo(track, track2); score2.AddTrack(track2); PlaybackInformation.CopyTo(track.PlaybackInfo, track2.PlaybackInfo); foreach (var key in track.Chords.Keys) { var chord = track.Chords[key]; var chord2 = new Chord(); Chord.CopyTo(chord, chord2); track2.Chords[key] = chord2; } #region Bars for (int b = 0; b < track.Bars.Count; b++) { var bar = track.Bars[b]; var bar2 = new Bar(); Bar.CopyTo(bar, bar2); track2.AddBar(bar2); #region Voices for (int v = 0; v < bar.Voices.Count; v++) { var voice = bar.Voices[v]; var voice2 = new Voice(); Voice.CopyTo(voice, voice2); bar2.AddVoice(voice2); #region Beats for (int bb = 0; bb < voice.Beats.Count; bb++) { var beat = voice.Beats[bb]; var beat2 = new Beat(); Beat.CopyTo(beat, beat2); voice2.AddBeat(beat2); for (int a = 0; a < beat.Automations.Count; a++) { var automation = new Automation(); Automation.CopyTo(beat.Automations[a], automation); beat2.Automations.Add(automation); } for (int i = 0; i < beat.WhammyBarPoints.Count; i++) { var point = new BendPoint(); BendPoint.CopyTo(beat.WhammyBarPoints[i], point); beat2.WhammyBarPoints.Add(point); } #region Notes for (int n = 0; n < beat.Notes.Count; n++) { var note = beat.Notes[n]; var note2 = new Note(); Note.CopyTo(note, note2); beat2.AddNote(note2); for (int i = 0; i < note.BendPoints.Count; i++) { var point = new BendPoint(); BendPoint.CopyTo(note.BendPoints[i], point); note2.AddBendPoint(point); } } #endregion } #endregion } #endregion } #endregion } #endregion score2.Finish(); return score2; }
private void GenerateAutomation(Beat beat, Automation automation, int startMove) { switch (automation.Type) { case AutomationType.Instrument: _handler.AddProgramChange(beat.Voice.Bar.Track.Index, beat.Start + startMove, (byte)beat.Voice.Bar.Track.PlaybackInfo.PrimaryChannel, (byte)(automation.Value)); _handler.AddProgramChange(beat.Voice.Bar.Track.Index, beat.Start + startMove, (byte)beat.Voice.Bar.Track.PlaybackInfo.SecondaryChannel, (byte)(automation.Value)); break; case AutomationType.Balance: _handler.AddControlChange(beat.Voice.Bar.Track.Index, beat.Start + startMove, (byte)beat.Voice.Bar.Track.PlaybackInfo.PrimaryChannel, (byte)MidiController.Balance, (byte)(automation.Value)); _handler.AddControlChange(beat.Voice.Bar.Track.Index, beat.Start + startMove, (byte)beat.Voice.Bar.Track.PlaybackInfo.SecondaryChannel, (byte)MidiController.Balance, (byte)(automation.Value)); break; case AutomationType.Volume: _handler.AddControlChange(beat.Voice.Bar.Track.Index, beat.Start + startMove, (byte)beat.Voice.Bar.Track.PlaybackInfo.PrimaryChannel, (byte)MidiController.Volume, (byte)(automation.Value)); _handler.AddControlChange(beat.Voice.Bar.Track.Index, beat.Start + startMove, (byte)beat.Voice.Bar.Track.PlaybackInfo.SecondaryChannel, (byte)MidiController.Volume, (byte)(automation.Value)); break; } }
/// <summary> /// Converts the given JavaScript object into a score object. /// </summary> /// <param name="jsObject">The javascript object created via <see cref="ScoreToJsObject"/></param> /// <param name="settings">The settings to use during conversion.</param> /// <returns>The converted score object.</returns> public static Score JsObjectToScore(object jsObject, Settings settings = null) { Score score = jsObject.As <Score>(); var score2 = new Score(); Score.CopyTo(score, score2); RenderStylesheet.CopyTo(score.Stylesheet, score2.Stylesheet); #region MasterBars for (var i = 0; i < score.MasterBars.Count; i++) { var masterBar = score.MasterBars[i]; var masterBar2 = new MasterBar(); MasterBar.CopyTo(masterBar, masterBar2); if (masterBar.TempoAutomation != null) { masterBar2.TempoAutomation = new Automation(); Automation.CopyTo(masterBar.TempoAutomation, masterBar2.TempoAutomation); } if (masterBar.Section != null) { masterBar2.Section = new Section(); Section.CopyTo(masterBar.Section, masterBar2.Section); } foreach (var offset in masterBar.Fermata) { var fermata = masterBar.Fermata[offset]; var fermata2 = new Fermata(); Fermata.CopyTo(fermata, fermata2); masterBar2.AddFermata(offset, fermata2); } score2.AddMasterBar(masterBar2); } #endregion #region Tracks for (int t = 0; t < score.Tracks.Count; t++) { var track = score.Tracks[t]; var track2 = new Track(track.Staves.Count); Track.CopyTo(track, track2); score2.AddTrack(track2); PlaybackInformation.CopyTo(track.PlaybackInfo, track2.PlaybackInfo); #region Staves for (var s = 0; s < track.Staves.Count; s++) { var staff = track.Staves[s]; var staff2 = track2.Staves[s]; Staff.CopyTo(staff, staff2); foreach (var key in staff.Chords) { var chord = staff.Chords[key]; var chord2 = new Chord(); Chord.CopyTo(chord, chord2); staff2.Chords[key] = chord2; } #region Bars for (int b = 0; b < staff.Bars.Count; b++) { var bar = staff.Bars[b]; var bar2 = new Bar(); Bar.CopyTo(bar, bar2); staff2.AddBar(bar2); #region Voices for (int v = 0; v < bar.Voices.Count; v++) { var voice = bar.Voices[v]; var voice2 = new Voice(); Voice.CopyTo(voice, voice2); bar2.AddVoice(voice2); #region Beats for (int bb = 0; bb < voice.Beats.Count; bb++) { var beat = voice.Beats[bb]; var beat2 = new Beat(); Beat.CopyTo(beat, beat2); voice2.AddBeat(beat2); for (int a = 0; a < beat.Automations.Count; a++) { var automation = new Automation(); Automation.CopyTo(beat.Automations[a], automation); beat2.Automations.Add(automation); } for (int i = 0; i < beat.WhammyBarPoints.Count; i++) { var point = new BendPoint(); BendPoint.CopyTo(beat.WhammyBarPoints[i], point); beat2.AddWhammyBarPoint(point); } #region Notes for (int n = 0; n < beat.Notes.Count; n++) { var note = beat.Notes[n]; var note2 = new Note(); Note.CopyTo(note, note2); beat2.AddNote(note2); for (int i = 0; i < note.BendPoints.Count; i++) { var point = new BendPoint(); BendPoint.CopyTo(note.BendPoints[i], point); note2.AddBendPoint(point); } } #endregion } #endregion } #endregion } #endregion } #endregion } #endregion score2.Finish(settings); return(score2); }