Esempio n. 1
0
 public void ShowScoreInfo(Score score)
 {
     ScoreInfoViewModel viewModel = new ScoreInfoViewModel(score);
     ScoreInfoWindow window = new ScoreInfoWindow();
     window.DataContext = viewModel;
     window.ShowDialog();
 }
Esempio n. 2
0
        private void InternalOpenFile(string file)
        {
            try
            {
                // load the score from the filesystem
                Score = ScoreLoader.loadScore(file);

                trackDetails.Controls.Clear();
                trackBars.Controls.Clear();
                for (int i = Score.tracks.length - 1; i >= 0; i--)
                {
                    TrackDetailsControl details = new TrackDetailsControl((Track)Score.tracks[i]);
                    details.Dock = DockStyle.Top;
                    details.Height = 25;
                    trackDetails.Controls.Add(details);
                    details.Selected += details_Click;

                    TrackBarsControl bars = new TrackBarsControl((Track)Score.tracks[i]);
                    bars.Dock = DockStyle.Top;
                    trackBars.Controls.Add(bars);
                }

                UpdateSelectedTrack();
            }
            catch (Exception e)
            {
                MessageBox.Show(this, e.Message, "An error during opening the file occured", MessageBoxButtons.OK,
                    MessageBoxIcon.Error);
            }
        }
Esempio n. 3
0
 public ScoreInfoViewModel(Score score)
 {
     _tab = score.tab;
     _words = score.words;
     _title = score.title;
     _subTitle = score.subTitle;
     _notices = score.notices;
     _music = score.music;
     _instructions = score.instructions;
     _copyright = score.copyright;
     _artist = score.artist;
     _album = score.album;
 }
Esempio n. 4
0
 public ScoreInfoWindow(Score score)
 {
     InitializeComponent();
     txtAlbum.Text = score.album;
     txtArtist.Text = score.artist;
     txtCopyright.Text = score.copyright;
     txtLyrics.Text = score.words;
     txtMusic.Text = score.music;
     txtNotes.Text = score.notices;
     txtSubTitle.Text = score.subTitle;
     txtTab.Text = score.tab;
     txtTitle.Text = score.title;
 }
        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  void AddMasterBarToScore(Score score, string sessionText)
 {
     var masterBar = new MasterBar();
     masterBar.timeSignatureDenominator = 4;
     masterBar.timeSignatureNumerator = 4;
     masterBar.section = new global::alphatab.model.Section() { text = sessionText };
     score.addMasterBar(masterBar);
 }