Skip to content

Commit

Permalink
Added support for hopo_frequency
Browse files Browse the repository at this point in the history
  • Loading branch information
EliteAsian123 committed Apr 4, 2023
1 parent d4f3685 commit cd2b29a
Show file tree
Hide file tree
Showing 8 changed files with 28 additions and 11 deletions.
6 changes: 6 additions & 0 deletions Assets/Script/Data/SongInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,12 @@ public Dictionary<string, int> JsonDiffs {
public float delay;
[JsonProperty]
public DrumType drumType;
/// <value>
/// The hopo frequency in ticks.<br/>
/// Standardized here: https://github.com/TheNathannator/GuitarGame_ChartFormats/blob/main/doc/FileFormats/.mid/Standard/5-Fret%20Guitar.md#note-mechanics
/// </value>
[JsonProperty]
public int hopoFreq = 170;

[JsonProperty]
public string artistName;
Expand Down
2 changes: 1 addition & 1 deletion Assets/Script/PlayMode/Play.cs
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ private IEnumerator StartSong() {
// Check for single guitar audio
if (audioSources.Count == 1 && audioSources.ContainsKey("guitar")) {
// If so, replace it as the song audio
// Standardized in [Audio Files / File Names]
// Standardized here: https://github.com/TheNathannator/GuitarGame_ChartFormats/blob/main/doc/FileFormats/Audio%20Files.md#file-names
audioSources.Add("song", audioSources["guitar"]);

// Remove old audio
Expand Down
2 changes: 1 addition & 1 deletion Assets/Script/Serialization/Parser/MidiParser.Drums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ private void DrumNoteStatePass(List<NoteInfo> noteIR, List<CymbalStateIR> cymbal
}

private List<NoteInfo> DrumFromGH(List<NoteInfo> ghNotes) {
// Standardized in [.mid / Standard / Drums / Track Type Conversions]
// Standardized here: https://github.com/TheNathannator/GuitarGame_ChartFormats/blob/main/doc/FileFormats/.mid/Standard/Drums.md#track-type-conversions

var noteOutput = new List<NoteInfo>();

Expand Down
9 changes: 3 additions & 6 deletions Assets/Script/Serialization/Parser/MidiParser.FiveFret.cs
Original file line number Diff line number Diff line change
Expand Up @@ -276,12 +276,9 @@ private void FiveFretNoteStatePass(List<FiveFretIR> noteIR, List<ForceStateIR> f
var lastNoteBeat = TimeConverter.ConvertTo<MusicalTimeSpan>(lastTime, tempo);
var distance = noteBeat - lastNoteBeat;

// Thanks?? https://tcrf.net/Proto:Guitar_Hero
// According to this, auto-HOPO threshold is 170 ticks.
// "But a tick is different in every midi file!"
// It also mentions that 160 is a twelth note.
// 160 * 12 = 1920
if (distance <= new MusicalTimeSpan(170, 1920)) {
// Use HOPO frequency value from song info.
// Convert the ticks to a musical time span.
if (distance <= new MusicalTimeSpan(songInfo.hopoFreq, 480 * 4)) {
note.hopo = true;
note.autoHopo = true;
}
Expand Down
2 changes: 1 addition & 1 deletion Assets/Script/Serialization/Parser/MidiParser.GHDrums.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ private List<NoteInfo> GHDrumNotePass(TrackChunk trackChunk, int difficulty, Tem
}

private List<NoteInfo> DrumFromStandard(List<NoteInfo> stdNotes) {
// Standardized in [.mid / Standard / Drums / Track Type Conversions]
// Standardized here: https://github.com/TheNathannator/GuitarGame_ChartFormats/blob/main/doc/FileFormats/.mid/Standard/Drums.md#track-type-conversions

var noteOutput = new List<NoteInfo>();

Expand Down
2 changes: 1 addition & 1 deletion Assets/Script/Serialization/Parser/MidiParser.Vocals.cs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ private List<LyricInfo> ParseRealLyrics(List<EventIR> eventIR, TrackChunk trackC
}

private List<LyricInfo> ParseRealLyrics(List<EventIR> eventIR, TrackChunk trackChunk, TrackChunk phraseTimingTrack, TempoMap tempo, int harmonyIndex) {
// Standardized in [.mid / Standard / Vocals]
// Standardized here: https://github.com/TheNathannator/GuitarGame_ChartFormats/blob/main/doc/FileFormats/.mid/Standard/Vocals.md

var lyrics = new List<LyricInfo>();

Expand Down
14 changes: 14 additions & 0 deletions Assets/Script/Serialization/SongIni.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,20 @@ public static SongInfo CompleteSongInfo(SongInfo song) {
song.delay = 0f;
}

// Get hopo frequency
// Standardized here: https://github.com/TheNathannator/GuitarGame_ChartFormats/blob/main/doc/FileFormats/.mid/Standard/5-Fret%20Guitar.md#note-mechanics
if (section.ContainsKey("hopo_frequency")) {
song.hopoFreq = int.Parse(section["hopo_frequency"]);
} else if (section.ContainsKey("hopofreq")) {
song.hopoFreq = int.Parse(section["hopofreq"]);
} else if (section.ContainsKey("eighthnote_hopo")) {
if (section["eighthnote_hopo"].ToLowerInvariant() == "true" ||
section["eighthnote_hopo"] == "1") {

song.hopoFreq = 240;
}
}

// Get difficulties
bool noneFound = true;
foreach (var kvp in new Dictionary<string, int>(song.partDifficulties)) {
Expand Down
2 changes: 1 addition & 1 deletion Assets/Script/SongLibrary.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

namespace YARG {
public static class SongLibrary {
private const int CACHE_VERSION = 2;
private const int CACHE_VERSION = 3;
private class SongCacheJson {
public int version = CACHE_VERSION;
public List<SongInfo> songs;
Expand Down

0 comments on commit cd2b29a

Please sign in to comment.