Пример #1
0
        void ExportTrack(Track track)
        {
            hopo = new bool[] { false, false, false, false, false, false };
            link = new bool[] { false, false, false, false, false, false };

            var gpTrack = new Gpif.Track();

            gpTrack.Id        = gpif.Tracks.Count;
            gpTrack.Name      = track.Name;
            gpTrack.ShortName = track.Name;
            gpTrack.Color     = track.Color;

            // export tuning
            var tuningProp = new Gpif.Property();

            tuningProp.Name    = "Tuning";
            tuningProp.Pitches = track.Tuning.ToList();
            if (track.Tuning.Count() > track.NumStrings)
            {
                // remove last few entries, as they are not used and confuse Guitar Pro
                tuningProp.Pitches.RemoveRange(track.NumStrings, track.Tuning.Count() - track.NumStrings);
            }
            if (track.Instrument == Track.InstrumentType.Bass)
            {
                // need to tune down one octave
                for (int i = 0; i < tuningProp.Pitches.Count; ++i)
                {
                    tuningProp.Pitches[i] -= 12;
                }
            }
            gpTrack.Properties.Add(tuningProp);
            // add capo?
            if (track.Capo > 0)
            {
                gpTrack.Properties.Add(new Gpif.Property()
                {
                    Name = "CapoFret",
                    Fret = track.Capo
                }
                                       );
            }

            if (track.Instrument == Track.InstrumentType.Guitar)
            {
                gpTrack.Instrument = new Instrument()
                {
                    Ref = "e-gtr" + track.NumStrings
                };
                gpTrack.GeneralMidi.Program                 = 29;
                gpTrack.GeneralMidi.Port                    = 0;
                gpTrack.GeneralMidi.PrimaryChannel          = 0;
                gpTrack.GeneralMidi.SecondaryChannel        = 1;
                gpTrack.GeneralMidi.ForeOneChannelPerString = false;
            }
            else if (track.Instrument == Track.InstrumentType.Bass)
            {
                gpTrack.Instrument = new Instrument()
                {
                    Ref = "e-bass" + track.NumStrings
                };
                gpTrack.GeneralMidi.Program                 = 33;
                gpTrack.GeneralMidi.Port                    = 0;
                gpTrack.GeneralMidi.PrimaryChannel          = 2;
                gpTrack.GeneralMidi.SecondaryChannel        = 3;
                gpTrack.GeneralMidi.ForeOneChannelPerString = false;
            }
            else
            {
                // TODO: Vocals
            }

            // add chord diagrams
            ExportChordDiagrams(gpTrack, track);

            gpif.Tracks.Add(gpTrack);
            gpif.MasterTrack.Tracks.Add(gpTrack.Id);

            ExportBars(track);
        }
Пример #2
0
        void ExportTrack(Track track)
        {
            hopo = new bool[] { false, false, false, false, false, false };
            link = new bool[] { false, false, false, false, false, false };

            var gpTrack = new Gpif.Track();
            gpTrack.Id = gpif.Tracks.Count;
            gpTrack.Name = track.Name;
            gpTrack.ShortName = track.Name;
            gpTrack.Color = track.Color;

            // export tuning
            var tuningProp = new Gpif.Property();
            tuningProp.Name = "Tuning";
            tuningProp.Pitches = track.Tuning.ToList();
            if (track.Tuning.Count() > track.NumStrings)
            {
                // remove last few entries, as they are not used and confuse Guitar Pro
                tuningProp.Pitches.RemoveRange(track.NumStrings, track.Tuning.Count() - track.NumStrings);
            }
            if (track.Instrument == Track.InstrumentType.Bass)
            {
                // need to tune down one octave
                for (int i = 0; i < tuningProp.Pitches.Count; ++i)
                    tuningProp.Pitches[i] -= 12;
            }
            gpTrack.Properties.Add(tuningProp);
            // add capo?
            if (track.Capo > 0)
            {
                gpTrack.Properties.Add(new Gpif.Property()
                    {
                        Name = "CapoFret",
                        Fret = track.Capo
                    }
                );
            }

            if (track.Instrument == Track.InstrumentType.Guitar)
            {
                gpTrack.Instrument = new Instrument() { Ref = "e-gtr" + track.NumStrings };
                gpTrack.GeneralMidi.Program = 29;
                gpTrack.GeneralMidi.Port = 0;
                gpTrack.GeneralMidi.PrimaryChannel = 0;
                gpTrack.GeneralMidi.SecondaryChannel = 1;
                gpTrack.GeneralMidi.ForeOneChannelPerString = false;
            }
            else if (track.Instrument == Track.InstrumentType.Bass)
            {
                gpTrack.Instrument = new Instrument() { Ref = "e-bass" + track.NumStrings };
                gpTrack.GeneralMidi.Program = 33;
                gpTrack.GeneralMidi.Port = 0;
                gpTrack.GeneralMidi.PrimaryChannel = 2;
                gpTrack.GeneralMidi.SecondaryChannel = 3;
                gpTrack.GeneralMidi.ForeOneChannelPerString = false;
            }
            else
            {
                // TODO: Vocals
            }

            // add chord diagrams
            ExportChordDiagrams(gpTrack, track);

            gpif.Tracks.Add(gpTrack);
            gpif.MasterTrack.Tracks.Add(gpTrack.Id);

            ExportBars(track);
        }
Пример #3
0
        void ExportChordDiagrams(Gpif.Track gpTrack, Track track)
        {
            var diagrams = new Property()
            {
                Name = "DiagramCollection", Items = new List <Item>()
            };
            var usedChords = track.Bars.SelectMany(b => b.Chords.Where(c => c.ChordId != -1).Select(c => c.ChordId)).Distinct();

            foreach (var kvp in track.ChordTemplates)
            {
                // only display those with an actual name && used in the current track
                if (kvp.Value.Name == string.Empty || !usedChords.Contains(kvp.Key))
                {
                    continue;
                }

                // first, we need to determine at what base fret to start the chord diagram,
                // as all fret values are then relative to that
                int minFret = 100;
                int maxFret = 0;
                for (int i = 0; i < 6; ++i)
                {
                    if (kvp.Value.Frets[i] > 0)
                    {
                        minFret = Math.Min(kvp.Value.Frets[i], minFret);
                        maxFret = Math.Max(kvp.Value.Frets[i], maxFret);
                    }
                }
                if (maxFret > 5)
                {
                    minFret = Math.Max(0, minFret - 1);
                }
                else
                {
                    minFret = 0;
                }

                var diagram = new Item()
                {
                    Id = kvp.Value.ChordId, Name = kvp.Value.Name
                };
                diagram.Diagram.StringCount = (track.Instrument == Track.InstrumentType.Bass ? 4 : 6);
                diagram.Diagram.FretCount   = Math.Max(5, maxFret - minFret);
                diagram.Diagram.BaseFret    = minFret;
                for (int i = 0; i < 6; ++i)
                {
                    if (kvp.Value.Frets[i] != -1)
                    {
                        diagram.Diagram.Frets.Add(new Diagram.FretType()
                        {
                            String = i,
                            Fret   = (kvp.Value.Frets[i] == 0) ? 0 : kvp.Value.Frets[i] - minFret
                        });
                    }

                    var position = new Diagram.Position()
                    {
                        String = i,
                        Fret   = (kvp.Value.Frets[i] == 0) ? 0 : (kvp.Value.Frets[i] == -1) ? -1 : kvp.Value.Frets[i] - minFret
                    };
                    switch (kvp.Value.Fingers[i])
                    {
                    case 1:
                        position.Finger = "Index"; break;

                    case 2:
                        position.Finger = "Middle"; break;

                    case 3:
                        position.Finger = "Ring"; break;

                    case 4:
                        position.Finger = "Pinky"; break;

                    default:
                        position.Finger = "None"; break;
                    }
                    diagram.Diagram.Fingering.Add(position);
                }

                diagrams.Items.Add(diagram);
            }
            gpTrack.Properties.Add(diagrams);
        }