本文整理汇总了C#中AlphaTab.Model.Track类的典型用法代码示例。如果您正苦于以下问题:C# Track类的具体用法?C# Track怎么用?C# Track使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Track类属于AlphaTab.Model命名空间,在下文中一共展示了Track类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: FindStringForValue
private int FindStringForValue(Track track, Beat beat, int value)
{
// find strings which are already taken
var takenStrings = new FastDictionary<int, bool>();
for (int i = 0; i < beat.Notes.Count; i++)
{
var note = beat.Notes[i];
takenStrings[note.String] = true;
}
// find a string where the note matches into 0 to <upperbound>
// first try to find a string from 0-14 (more handy to play)
// then try from 0-20 (guitars with high frets)
// then unlimited
int[] steps = { 14, 20, int.MaxValue };
for (int i = 0; i < steps.Length; i++)
{
for (int j = 0; j < track.Tuning.Length; j++)
{
if (!takenStrings.ContainsKey(j))
{
var min = track.Tuning[j];
var max = track.Tuning[j] + steps[i];
if (value >= min && value <= max)
{
return track.Tuning.Length - j;
}
}
}
}
// will not happen
return 1;
}
开发者ID:CoderLine,项目名称:alphaTab,代码行数:35,代码来源:MusicXml2Importer.cs
示例2: FindBeat
public Beat FindBeat(Track track, int tick)
{
//
// some heuristics: try last found beat and it's next beat for lookup first
// try last beat or next beat of last beat first
if (_lastBeat != null && _lastBeat.NextBeat != null && _lastBeat.Voice.Bar.Track == track)
{
// check if tick is between _lastBeat and _lastBeat.nextBeat (still _lastBeat)
if (tick >= _lastBeat.AbsoluteStart && tick < _lastBeat.NextBeat.AbsoluteStart)
{
return _lastBeat;
}
// we need a upper-next beat to check the nextbeat range
// TODO: this logic does not apply properly for alternate endings and repeats, better "next beat" detection using
// "next bar" info
//if (_lastBeat.NextBeat.NextBeat != null && tick >= _lastBeat.NextBeat.AbsoluteStart && tick < _lastBeat.NextBeat.NextBeat.AbsoluteStart
// && !(_lastBeat.Index == _lastBeat.Voice.Beats.Count - 1 && _lastBeat.Voice.Bar.MasterBar.IsRepeatEnd))
//{
// _lastBeat = _lastBeat.NextBeat;
// return _lastBeat;
//}
}
//
// Global Search
// binary search within lookup
var lookup = FindBar(tick);
if (lookup == null) return null;
var masterBar = lookup.Bar;
var bar = track.Bars[masterBar.Index];
// remap tick to initial bar start
tick = (tick - lookup.Start + masterBar.Start);
// linear search beat within beats
Beat beat = null;
for (int i = 0, j = bar.Voices[0].Beats.Count; i < j; i++)
{
var b = bar.Voices[0].Beats[i];
// we search for the first beat which
// starts after the tick.
if (beat == null || b.AbsoluteStart <= tick)
{
beat = b;
}
else
{
break;
}
}
_lastBeat = beat;
return _lastBeat;
}
开发者ID:eriser,项目名称:alphaTab,代码行数:59,代码来源:MidiTickLookup.cs
示例3: BeamingHelper
public BeamingHelper(Track track)
{
_track = track;
Beats = new FastList<Beat>();
_beatLineXPositions = new FastDictionary<int, BeatLinePositions>();
ShortestDuration = Duration.QuadrupleWhole;
}
开发者ID:CoderLine,项目名称:alphaTab,代码行数:8,代码来源:BeamingHelper.cs
示例4: AddBarAndVoiceToTrack
private static Voice AddBarAndVoiceToTrack(Track track, Clef clef)
{
var bar = new Bar();
bar.Clef = clef;
track.AddBar(bar);
var voice = new Voice();
bar.AddVoice(voice);
return voice;
}
开发者ID:InevitableHimes,项目名称:RSTabExplorer,代码行数:9,代码来源:RockSmithImporter.cs
示例5: CopyTo
public static void CopyTo(Track src, Track dst)
{
dst.Capo = src.Capo;
dst.Index = src.Index;
dst.ShortName = src.ShortName;
dst.Tuning = Std.CloneArray(src.Tuning);
dst.Color.Raw = src.Color.Raw;
dst.IsPercussion = src.IsPercussion;
}
开发者ID:eriser,项目名称:alphaTab,代码行数:9,代码来源:Track.cs
示例6: FindBeat
public Beat FindBeat(Track track, int tick)
{
//
// some heuristics: try last found beat and it's next beat for lookup first
// try last beat or next beat of last beat first
if (_lastBeat != null && _lastBeat.NextBeat != null && _lastBeat.Voice.Bar.Track == track)
{
// check if tick is between _lastBeat and _lastBeat.nextBeat (still _lastBeat)
if (tick >= _lastBeat.Start && tick < _lastBeat.NextBeat.Start)
{
return _lastBeat;
}
// we need a upper-next beat to check the nextbeat range
if (_lastBeat.NextBeat.NextBeat != null && tick >= _lastBeat.NextBeat.Start && tick < _lastBeat.NextBeat.NextBeat.Start)
{
_lastBeat = _lastBeat.NextBeat;
return _lastBeat;
}
}
//
// Global Search
// binary search within lookup
var lookup = FindBar(tick);
if (lookup == null) return null;
var masterBar = lookup.Bar;
var bar = track.Bars[masterBar.Index];
// remap tick to initial bar start
tick = (tick - lookup.Start + masterBar.Start);
// linear search beat within beats
Beat beat = null;
for (int i = 0, j = bar.Voices[0].Beats.Count; i < j; i++)
{
var b = bar.Voices[0].Beats[i];
// we search for the first beat which
// starts after the tick.
if (beat == null || b.Start <= tick)
{
beat = b;
}
else
{
break;
}
}
_lastBeat = beat;
return _lastBeat;
}
开发者ID:vmoll,项目名称:alphaTab,代码行数:56,代码来源:MidiTickLookup.cs
示例7: TrackViewModel
public TrackViewModel(Track track)
{
_track = track;
// general midi Programs
if (track.IsPercussion)
{
TrackType = TrackType.Drums;
}
else if (track.PlaybackInfo.Program >= 0 && track.PlaybackInfo.Program <= 6)
{
TrackType = TrackType.Piano;
}
else if (track.PlaybackInfo.Program >= 26 && track.PlaybackInfo.Program <= 31)
{
TrackType = TrackType.ElectricGuitar;
}
else if (track.PlaybackInfo.Program >= 32 && track.PlaybackInfo.Program <= 39)
{
TrackType = TrackType.BassGuitar;
}
else
{
TrackType = TrackType.Default;
}
// scan all bars if they have any note
_usedBars = new bool[track.Score.MasterBars.Count];
for (int s = 0; s < track.Staves.Count; s++)
{
var staff = track.Staves[s];
for (int barI = 0; barI < staff.Bars.Count; barI++)
{
Bar bar = staff.Bars[barI];
_usedBars[barI] = false;
for (int voiceI = 0; voiceI < bar.Voices.Count && (!_usedBars[barI]); voiceI++)
{
Voice voice = bar.Voices[voiceI];
for (int i = 0; i < voice.Beats.Count; i++)
{
var b = voice.Beats[i];
if (!b.IsRest)
{
_usedBars[barI] = true;
}
}
}
}
}
}
开发者ID:CoderLine,项目名称:alphaTab,代码行数:51,代码来源:TrackViewModel.cs
示例8: RenderMultiple
public void RenderMultiple(Track[] tracks)
{
if (tracks.Length == 0)
{
Score = null;
}
else
{
Score = tracks[0].Score;
}
Tracks = tracks;
Invalidate();
}
开发者ID:eriser,项目名称:alphaTab,代码行数:14,代码来源:ScoreRenderer.cs
示例9: TrackBarsControl
public TrackBarsControl(Track track)
{
SetStyle(ControlStyles.FixedHeight, true);
SetStyle(ControlStyles.DoubleBuffer, true);
SetStyle(ControlStyles.OptimizedDoubleBuffer, true);
SetStyle(ControlStyles.ResizeRedraw, true);
SetStyle(ControlStyles.UserPaint, true);
base.DoubleBuffered = true;
base.BackColor = Color.FromArgb(93, 95, 94);
_usedBars = new bool[track.Score.MasterBars.Count];
for (int s = 0; s < track.Staves.Count; s++)
{
var staff = track.Staves[s];
for (int barI = 0; barI < staff.Bars.Count; barI++)
{
var bar = staff.Bars[barI];
_usedBars[barI] = false;
for (int voiceI = 0; voiceI < bar.Voices.Count && (!_usedBars[barI]); voiceI++)
{
Voice voice = bar.Voices[voiceI];
for (int i = 0; i < voice.Beats.Count; i++)
{
var b = voice.Beats[i];
if (!b.IsRest)
{
_usedBars[barI] = true;
}
}
}
}
}
PerformLayout();
Width = BlockSize.Width * _usedBars.Length;
Height = BlockSize.Height;
MinimumSize = BlockSize;
SetColor(track.Color);
}
开发者ID:CoderLine,项目名称:alphaTab,代码行数:40,代码来源:TrackBarsControl.cs
示例10: ParseMidiInstrument
private void ParseMidiInstrument(IXmlNode element, Track track)
{
element.IterateChildren(c =>
{
if (c.NodeType == XmlNodeType.Element)
{
switch (c.LocalName)
{
case "midi-channel":
track.PlaybackInfo.PrimaryChannel = Std.ParseInt(Std.GetNodeValue(c.FirstChild));
break;
case "midi-program":
track.PlaybackInfo.Program = Std.ParseInt(Std.GetNodeValue(c.FirstChild));
break;
case "midi-volume":
track.PlaybackInfo.Volume = Std.ParseInt(Std.GetNodeValue(c.FirstChild));
break;
}
}
});
}
开发者ID:CoderLine,项目名称:alphaTab,代码行数:21,代码来源:MusicXml2Importer.cs
示例11: ParseMeasure
private void ParseMeasure(IXmlNode element, Track track, bool isFirstMeasure)
{
var barIndex = 0;
if (isFirstMeasure)
{
_trackFirstMeasureNumber = Std.ParseInt(element.GetAttribute("number"));
barIndex = 0;
}
else
{
barIndex = Std.ParseInt(element.GetAttribute("number")) - _trackFirstMeasureNumber;
}
// create empty bars to the current index
Bar bar = null;
MasterBar masterBar = null;
for (int i = track.Staves[0].Bars.Count; i <= barIndex; i++)
{
bar = new Bar();
masterBar = GetOrCreateMasterBar(barIndex);
track.AddBarToStaff(0, bar);
for (int j = 0; j < _maxVoices; j++)
{
var emptyVoice = new Voice();
bar.AddVoice(emptyVoice);
var emptyBeat = new Beat { IsEmpty = true };
emptyVoice.AddBeat(emptyBeat);
}
}
bool chord = false;
bool isFirstBeat = true;
element.IterateChildren(c =>
{
if (c.NodeType == XmlNodeType.Element)
{
switch (c.LocalName)
{
case "note":
chord = ParseNoteBeat(c, track, bar, chord, isFirstBeat);
isFirstBeat = false;
break;
case "forward":
break;
case "direction":
ParseDirection(c, masterBar);
break;
case "attributes":
ParseAttributes(c, bar, masterBar);
break;
case "harmony":
// TODO
break;
case "sound":
// TODO
break;
case "barline":
// TODO
break;
}
}
});
}
开发者ID:CoderLine,项目名称:alphaTab,代码行数:65,代码来源:MusicXml2Importer.cs
示例12: ParseGeneralMidi
private void ParseGeneralMidi(Track track, IXmlNode node)
{
track.PlaybackInfo.Port = Std.ParseInt(GetValue(FindChildElement(node, "Port")));
track.PlaybackInfo.Program = Std.ParseInt(GetValue(FindChildElement(node, "Program")));
track.PlaybackInfo.PrimaryChannel = Std.ParseInt(GetValue(FindChildElement(node, "PrimaryChannel")));
track.PlaybackInfo.SecondaryChannel = Std.ParseInt(GetValue(FindChildElement(node, "SecondaryChannel")));
track.IsPercussion = (node.Attributes.Get("table") != null &&
node.Attributes.Get("table").Value == "Percussion");
}
开发者ID:rkenning,项目名称:alphaTab,代码行数:10,代码来源:GpxParser.cs
示例13: ParseDiagramItem
private void ParseDiagramItem(Track track, IXmlNode node)
{
var chord = new Chord();
var chordId = node.Attributes.Get("id").Value;
chord.Name = node.Attributes.Get("name").Value;
track.Chords[chordId] = chord;
}
开发者ID:rkenning,项目名称:alphaTab,代码行数:7,代码来源:GpxParser.cs
示例14: ParseDiagramCollection
private void ParseDiagramCollection(Track track, IXmlNode node)
{
var items = FindChildElement(node, "Items");
items.IterateChildren(c =>
{
if (c.NodeType == XmlNodeType.Element)
{
switch (c.LocalName)
{
case "Item":
ParseDiagramItem(track, c);
break;
}
}
});
}
开发者ID:rkenning,项目名称:alphaTab,代码行数:16,代码来源:GpxParser.cs
示例15: ParseTrackProperty
private void ParseTrackProperty(Track track, IXmlNode node)
{
var propertyName = node.Attributes.Get("name").Value;
switch (propertyName)
{
case "Tuning":
var tuningParts = GetValue(FindChildElement(node, "Pitches")).Split(' ');
var tuning = new int[tuningParts.Length];
for (int i = 0; i < tuning.Length; i++)
{
tuning[tuning.Length - 1 - i] = Std.ParseInt(tuningParts[i]);
}
track.Tuning = tuning;
break;
case "DiagramCollection":
ParseDiagramCollection(track, node);
break;
case "CapoFret":
track.Capo = Std.ParseInt(GetValue(FindChildElement(node, "Fret")));
break;
}
}
开发者ID:rkenning,项目名称:alphaTab,代码行数:22,代码来源:GpxParser.cs
示例16: ReadNote
public void ReadNote(Track track, Bar bar, Voice voice, Beat beat, int stringIndex)
{
var newNote = new Note();
newNote.String = track.Tuning.Length - stringIndex;
var flags = Data.ReadByte();
if ((flags & 0x02) != 0)
{
newNote.Accentuated = AccentuationType.Heavy;
}
else if ((flags & 0x40) != 0)
{
newNote.Accentuated = AccentuationType.Normal;
}
newNote.IsGhost = ((flags & 0x04) != 0);
if ((flags & 0x20) != 0)
{
var noteType = Data.ReadByte();
if (noteType == 3)
{
newNote.IsDead = true;
}
else if (noteType == 2)
{
newNote.IsTieDestination = true;
}
}
if ((flags & 0x01) != 0 && _versionNumber < 500)
{
Data.ReadByte(); // duration
Data.ReadByte(); // tuplet
}
if ((flags & 0x10) != 0)
{
var dynamicNumber = Data.ReadSignedByte();
newNote.Dynamic = ToDynamicValue(dynamicNumber);
beat.Dynamic = newNote.Dynamic;
}
if ((flags & 0x20) != 0)
{
newNote.Fret = Data.ReadSignedByte();
}
if ((flags & 0x80) != 0)
{
newNote.LeftHandFinger = (Fingers)Data.ReadSignedByte();
newNote.RightHandFinger = (Fingers)Data.ReadSignedByte();
newNote.IsFingering = true;
}
if (_versionNumber >= 500)
{
if ((flags & 0x01) != 0)
{
newNote.DurationPercent = ReadDouble();
}
var flags2 = Data.ReadByte();
newNote.AccidentalMode = (flags2 & 0x02) != 0
? NoteAccidentalMode.SwapAccidentals
: NoteAccidentalMode.Default;
}
beat.AddNote(newNote);
if ((flags & 0x08) != 0)
{
ReadNoteEffects(track, voice, beat, newNote);
}
}
开发者ID:CoderLine,项目名称:alphaTab,代码行数:72,代码来源:Gp3To5Importer.cs
示例17: ParseNoteBeat
private bool ParseNoteBeat(IXmlNode element, Track track, Bar bar, bool chord, bool isFirstBeat)
{
int voiceIndex = 0;
var voiceNodes = element.GetElementsByTagName("voice");
if (voiceNodes.Length > 0)
{
voiceIndex = Std.ParseInt(Std.GetNodeValue(voiceNodes[0])) - 1;
}
Beat beat;
var voice = GetOrCreateVoice(bar, voiceIndex);
if (chord || (isFirstBeat && voice.Beats.Count == 1))
{
beat = voice.Beats[voice.Beats.Count - 1];
}
else
{
beat = new Beat();
voice.AddBeat(beat);
}
var note = new Note();
beat.AddNote(note);
beat.IsEmpty = false;
element.IterateChildren(c =>
{
if (c.NodeType == XmlNodeType.Element)
{
switch (c.LocalName)
{
case "grace":
//var slash = e.GetAttribute("slash");
//var makeTime = Std.ParseInt(e.GetAttribute("make-time"));
//var stealTimePrevious = Std.ParseInt(e.GetAttribute("steal-time-previous"));
//var stealTimeFollowing = Std.ParseInt(e.GetAttribute("steal-time-following"));
beat.GraceType = GraceType.BeforeBeat;
beat.Duration = Duration.ThirtySecond;
break;
case "duration":
beat.Duration = (Duration)Std.ParseInt(Std.GetNodeValue(c));
break;
case "tie":
ParseTied(c, note);
break;
case "cue":
// not supported
break;
case "instrument":
// not supported
break;
case "type":
switch (Std.GetNodeValue(c))
{
case "256th":
beat.Duration = Duration.TwoHundredFiftySixth;
break;
case "128th":
beat.Duration = Duration.OneHundredTwentyEighth;
break;
case "breve":
beat.Duration = Duration.DoubleWhole;
break;
case "long":
beat.Duration = Duration.QuadrupleWhole;
break;
case "64th":
beat.Duration = Duration.SixtyFourth;
break;
case "32nd":
beat.Duration = Duration.ThirtySecond;
break;
case "16th":
beat.Duration = Duration.Sixteenth;
break;
case "eighth":
beat.Duration = Duration.Eighth;
break;
case "quarter":
beat.Duration = Duration.Quarter;
break;
case "half":
beat.Duration = Duration.Half;
break;
case "whole":
beat.Duration = Duration.Whole;
break;
}
break;
case "dot":
note.IsStaccato = true;
break;
case "accidental":
ParseAccidental(c, note);
break;
case "time-modification":
ParseTimeModification(c, beat);
break;
case "stem":
// not supported
//.........这里部分代码省略.........
开发者ID:CoderLine,项目名称:alphaTab,代码行数:101,代码来源:MusicXml2Importer.cs
示例18: SetNotes
public void SetNotes(GeneticMIDI.Representation.Track track)
{
if (track.Length < 1)
return;
var mel = track.GetMelodySequence();
//return;
score = new Score();
Track t = new Track();
MasterBar mb = new MasterBar();
score.AddMasterBar(mb);
mb.KeySignature = 2;
Bar b = new Bar();
t.AddBar(b);
score.AddTrack(t);
Voice v = new Voice();
b.AddVoice(v);
t.Name = track.Instrument.ToString().Replace("_", " ");
//t.IsPercussion = true;
if(t.IsPercussion)
{
b.Clef = Clef.Neutral;
}
int i = 0;
int qn_per_bar = 4;
int durs = 0;
int avg_octave = mel.CalculateAverageOctave();
int dist4 = 4 - avg_octave;
foreach (var n in mel.Notes)
{
Beat be = new Beat();
be.Index = i++;
GeneticMIDI.Representation.Durations dur;
int remainder;
n.GetClosestLowerDurationAndRemainder(out dur, out remainder);
int dots = n.GetNumberOfDots();
durs += n.Duration;
/* if(durs >= qn_per_bar * (int)GeneticMIDI.Representation.Durations.qn)
{
durs = 0;
b = new Bar();
t.AddBar(b);
v.Bar = b;
b.Finish();
}*/
switch (((GeneticMIDI.Representation.Durations)n.Duration))
{
case GeneticMIDI.Representation.Durations.bn:
be.Duration = AlphaTab.Model.Duration.Whole;
dots = 2;
break;
case GeneticMIDI.Representation.Durations.en:
be.Duration = AlphaTab.Model.Duration.Eighth;
break;
case GeneticMIDI.Representation.Durations.hn:
be.Duration = AlphaTab.Model.Duration.Half;
break;
case GeneticMIDI.Representation.Durations.qn:
be.Duration = AlphaTab.Model.Duration.Quarter;
break;
case GeneticMIDI.Representation.Durations.sn:
be.Duration = AlphaTab.Model.Duration.Sixteenth;
break;
case GeneticMIDI.Representation.Durations.tn:
be.Duration = AlphaTab.Model.Duration.ThirtySecond;
break;
case GeneticMIDI.Representation.Durations.wn:
be.Duration = AlphaTab.Model.Duration.Whole;
break;
default:
break;
}
be.Dots = dots;
Note note = new Note();
if (!n.IsRest())
{
note.Tone = n.NotePitch;
note.Octave = n.Octave + dist4;
be.AddNote(note);
//.........这里部分代码省略.........
开发者ID:stefan-j,项目名称:DotNetMusic,代码行数:101,代码来源:MusicSheet.xaml.cs
示例19: ParseScorePart
private void ParseScorePart(IXmlNode element)
{
string id = element.GetAttribute("id");
var track = new Track(1);
_trackById[id] = track;
_score.AddTrack(track);
element.IterateChildren(c =>
{
if (c.NodeType == XmlNodeType.Element)
{
switch (c.LocalName)
{
case "part-name":
track.Name = Std.GetNodeValue(c.FirstChild);
break;
case "part-abbreviation":
track.ShortName = Std.GetNodeValue(c.FirstChild);
break;
case "midi-instrument":
ParseMidiInstrument(c, track);
break;
}
}
});
if (track.Tuning == null || track.Tuning.Length == 0)
{
track.Tuning = Tuning.GetDefaultTuningFor(6).Tunings;
}
}
开发者ID:CoderLine,项目名称:alphaTab,代码行数:30,代码来源:MusicXml2Importer.cs
示例20: StaveTrackGroup
public StaveTrackGroup(StaveGroup staveGroup, Track track)
{
StaveGroup = staveGroup;
Track = track;
Staves = new FastList<Stave>();
}
开发者ID:stefan-j,项目名称:alphaTab,代码行数:6,代码来源:StaveGroup.cs
注:本文中的AlphaTab.Model.Track类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论