本文整理汇总了C#中AlphaTab.Model.Track类的典型用法代码示例。如果您正苦于以下问题:C# Track类的具体用法?C# Track怎么用?C# Track使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
Track类属于AlphaTab.Model命名空间,在下文中一共展示了Track类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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;
}
示例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;
}
示例3: BeamingHelper
public BeamingHelper(Track track)
{
_track = track;
Beats = new FastList<Beat>();
_beatLineXPositions = new FastDictionary<int, BeatLinePositions>();
ShortestDuration = Duration.QuadrupleWhole;
}
示例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;
}
示例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;
}
示例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;
}
示例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;
}
}
}
}
}
}
示例8: RenderMultiple
public void RenderMultiple(Track[] tracks)
{
if (tracks.Length == 0)
{
Score = null;
}
else
{
Score = tracks[0].Score;
}
Tracks = tracks;
Invalidate();
}
示例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);
}
示例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;
}
}
});
}
示例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;
}
}
});
}
示例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");
}
示例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;
}
示例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;
}
}
});
}
示例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;
}
}