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.bars.length]; for (int barI = 0; barI < track.bars.length; barI++) { Bar bar = (Bar) track.bars[barI]; _usedBars[barI] = false; for (int voiceI = 0; voiceI < bar.voices.length && (!_usedBars[barI]); voiceI++) { Voice voice = (Voice) bar.voices[voiceI]; for (int beatI = 0; beatI < voice.beats.length; beatI++) { Beat b = (Beat) voice.beats[beatI]; if (!b.isRest()) { _usedBars[barI] = true; } } } } }
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.bars.length]; for (int barI = 0; barI < track.bars.length; barI++) { Bar bar = (Bar)track.bars[barI]; _usedBars[barI] = false; for (int voiceI = 0; voiceI < bar.voices.length && (!_usedBars[barI]); voiceI++) { Voice voice = (Voice)bar.voices[voiceI]; for (int beatI = 0; beatI < voice.beats.length; beatI++) { Beat b = (Beat)voice.beats[beatI]; if (!b.isRest()) { _usedBars[barI] = true; } } } } PerformLayout(); Width = BlockSize.Width * _usedBars.Length; Height = BlockSize.Height; MinimumSize = BlockSize; SetColor(track.color); }
public TrackDetailsControl(Track track) { InitializeComponent(); Track = track; }
private static Score CreateSong(Song2014 song, IEnumerable<SongNoteChordWrapper> allSounds) { var score = new Score(); score.album = song.AlbumName; score.artist = song.ArtistName; //score.copyright //score.instructions //score.music score.notices = "Created by RockSmith Tab Explorer"; //_score.subTitle //_score.tab score.tempo = (int)song.AverageTempo; score.tempoLabel = "avg. bpm"; score.title = song.Title + " (" + song.Arrangement + ")"; //_score.words bool isBass = song.Arrangement.ToLower() == "bass"; var track = new Track(); track.name = song.Arrangement; track.index = 1; track.tuningName = GetTuningName(song.Tuning, isBass); track.shortName = song.Arrangement; for (Byte s = 0; s < (isBass ? 4 : 6); s++) track.tuning[(isBass ? 3 : 5) - s] = Sng2014FileWriter.GetMidiNote(song.Tuning.ToShortArray(), s, 0, isBass); score.addTrack(track); int chordId = 0; foreach (var chordTemplate in song.ChordTemplates) { var chord = new global::alphatab.model.Chord(); track.chords.set(chordId.ToString(), chord); chord.name = chordTemplate.ChordName; chord.strings[0] = chordTemplate.Fret0; chord.strings[1] = chordTemplate.Fret1; chord.strings[2] = chordTemplate.Fret2; chord.strings[3] = chordTemplate.Fret3; chord.strings[4] = chordTemplate.Fret4; chord.strings[5] = chordTemplate.Fret5; chordId++; } var ebeatMeasures = song.Ebeats.Where(x => x.Measure > 0).OrderBy(x => x.Measure).ToList(); var notesStack = new Stack<SongNoteChordWrapper>(allSounds.OrderByDescending(x => x.Time)); var currentNote = notesStack.Pop(); var nextNote = notesStack.Pop(); int prevMeasureId = 0; int i = 1; float prevMeasureDuration=0; foreach (var measure in ebeatMeasures) { var nextmeasure = i < ebeatMeasures.Count ? ebeatMeasures[i] : null; if (measure.Measure > prevMeasureId) { var measureDuration = nextmeasure !=null ? nextmeasure.Time - measure.Time : prevMeasureDuration; AddMasterBarToScore(score, measure.Time.ToString("n2")); var voice = AddBarAndVoiceToTrack(track, isBass ? Clef.F4 : Clef.G2); bool firstNoteInBar = true; while (currentNote != null && (nextmeasure == null || currentNote.Time < nextmeasure.Time)) { Duration duration = Duration.Quarter; if (firstNoteInBar && currentNote.Time > measure.Time) { var leadingSilenceTicks = Get64thsFromDuration(measure.Time, currentNote.Time, measureDuration); while (leadingSilenceTicks >= 1) { if (leadingSilenceTicks >= 32) { AddBeatAndNoteToVoice(voice, null, Duration.Half); leadingSilenceTicks -= 32; } else if (leadingSilenceTicks >= 16) { AddBeatAndNoteToVoice(voice, null, Duration.Quarter); leadingSilenceTicks -= 16; } else if (leadingSilenceTicks >= 8) { AddBeatAndNoteToVoice(voice, null, Duration.Eighth); leadingSilenceTicks -= 8; } else if (leadingSilenceTicks >= 4) { AddBeatAndNoteToVoice(voice, null, Duration.Sixteenth); leadingSilenceTicks -= 4; } else if (leadingSilenceTicks >= 2) { AddBeatAndNoteToVoice(voice, null, Duration.ThirtySecond); leadingSilenceTicks -= 2; } else if (leadingSilenceTicks >= 1) { AddBeatAndNoteToVoice(voice, null, Duration.SixtyFourth); leadingSilenceTicks -= 1; } } } if (nextNote != null) { duration = GetBeatDuration(currentNote.Time,nextNote.Time,measureDuration); } if (currentNote.IsNote()) AddBeatAndNoteToVoice(voice, currentNote.AsNote(), duration); else AddBeatWithChordToVoice(voice, currentNote.AsChord(), duration); currentNote = nextNote; if (notesStack.Any()) nextNote = notesStack.Pop(); else nextNote = null; firstNoteInBar = false; } prevMeasureId = measure.Measure; prevMeasureDuration = measureDuration; } i++; } return score; }
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; }