Skip to content

Commit

Permalink
Enabled auto assigned tuning from package import. Fixed small problem…
Browse files Browse the repository at this point in the history
… with convert2012 CLI for RS1 CDLC that have inconsitent tone naming. Put back core.jar and reverted speed slider to girl girl minimum. Working to resolve issues with XML comment saves. See comments in code.
  • Loading branch information
cozy1 committed Mar 27, 2015
1 parent 377ecdf commit eea374b
Show file tree
Hide file tree
Showing 8 changed files with 228 additions and 153 deletions.
1 change: 1 addition & 0 deletions RocksmithCustomSongCreator.sln
Expand Up @@ -15,6 +15,7 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "pcdecrypt", "RocksmithToolk
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Third-party Apps", "Third-party Apps", "{17ADB8C7-17DF-4BE3-8460-3E342F334B53}"
ProjectSection(SolutionItems) = preProject
Third-party Apps\tool\core.jar = Third-party Apps\tool\core.jar
Third-party Apps\nvdxt.exe = Third-party Apps\nvdxt.exe
Third-party Apps\packed_codebooks.bin = Third-party Apps\packed_codebooks.bin
Third-party Apps\packed_codebooks_aoTuV_603.bin = Third-party Apps\packed_codebooks_aoTuV_603.bin
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

230 changes: 115 additions & 115 deletions RocksmithTookitGUI/DLCPackageCreator/DLCPackageCreator.Designer.cs

Large diffs are not rendered by default.

23 changes: 20 additions & 3 deletions RocksmithTookitGUI/DLCPackageCreator/DLCPackageCreator.cs
Expand Up @@ -230,6 +230,8 @@ public DLCPackageCreator()
songVolumeBox.MouseEnter += songVolumeBox_MouseEnter;
previewVolumeBox.MouseEnter += songVolumeBox_MouseEnter;
AddOnChangeHandlerToInputControls();
this.Disposed += DlcPackageCreator_Dispose;


try
{
Expand Down Expand Up @@ -1232,7 +1234,7 @@ private DLCPackageData GetPackageData()
}

if (AudioPath.Substring(AudioPath.Length - 4).ToLower() == ".wem" && !File.Exists(wemPreviewPath))
{//TODO: test if no Wwise
{
OggFile.Revorb(AudioPath, oggPath, Path.GetDirectoryName(Application.ExecutablePath), OggFile.WwiseVersion.Wwise2013);
ExternalApps.Ogg2Wav(oggPath, wavPath);
ExternalApps.Ogg2Preview(oggPath, oggPreviewPath);
Expand Down Expand Up @@ -1335,8 +1337,8 @@ private DLCPackageData GetPackageData()
/// <summary>
/// Updates the xml with user modified DLCPackageData info
/// </summary>
/// <param name="arr">Arrangement</param>
/// <param name="info">DLCPackageData Info.</param>
/// <param name="arr"></param>
/// <param name="info"></param>
public void UpdateXml(Arrangement arr, DLCPackageData info)
{
if (CurrentGameVersion != GameVersion.RS2012)
Expand Down Expand Up @@ -1973,5 +1975,20 @@ private void InputControls_OnChange(object sender, EventArgs e)
userChangesToInputControls++;
}

private void DlcPackageCreator_Dispose(object sender, EventArgs e)
{
// TODO: drive is running low on space either get a bigger drive or
// cleanup all toolkit leftovers *.tmp and *.dds files from the temp folder
var tmpDir = Path.GetTempPath();
// List<string> tmpFiles = new List<string>();
string[] extensions = { ".tmp", ".dds" };
foreach (string tmpFile in Directory.EnumerateFiles(tmpDir, "*.*", SearchOption.TopDirectoryOnly)
.Where(s => extensions.Any(ext => ext == Path.GetExtension(s))))
{
File.Delete(tmpFile);

This comment has been minimized.

Copy link
@L0FKA

L0FKA Mar 27, 2015

Member

I'm sure than not all files will be available to delete, I really fixed tmp file lockers, but who knows what new tmp's could arrive. Just wanted to make a point here.

// tmpFiles.Add(tmpFile);
}
}

}
}
2 changes: 1 addition & 1 deletion RocksmithToolkitLib/DLCPackage/ToneGenerator.cs
Expand Up @@ -9,7 +9,7 @@

namespace RocksmithToolkitLib.DLCPackage
{
public class ToneGenerator //RS1 only
public class ToneGenerator // RS1 only
{
public static void Generate(string toneKey, Tone tone, Stream outManifest, Stream outXblock, Stream aggregateGraph)
{
Expand Down
3 changes: 2 additions & 1 deletion RocksmithToolkitLib/Ogg/Wwise.cs
Expand Up @@ -19,7 +19,8 @@ public static void Convert2Wem(string sourcePath, string destinationPath, int au
GetWwiseFiles(destinationPath);
}
catch (Exception ex)
{//overrided ex, can't get real ex/msg, use log + throw;
{
//overrided ex, can't get real ex/msg, use log + throw;
throw new Exception("Wwise audio file conversion failed: " + ex.Message);
}
}
Expand Down
17 changes: 12 additions & 5 deletions RocksmithToolkitLib/Song2014ToTab/Rs1Converter.cs
Expand Up @@ -491,18 +491,21 @@ public Tone2014 ToneToTone2014(Tone rs1Tone)
Pedal2014 rack2 = new Pedal2014();
tone2014.ToneDescriptors = new List<string>();
// use Tone Key for better conversion
tone2014.Name = rs1Tone.Key ?? rs1Tone.Name;
tone2014.Key = rs1Tone.Key ?? "Default";
tone2014.Name = rs1Tone.Name ?? "default";
tone2014.Key = rs1Tone.Key ?? "DEFAULT";
tone2014.Volume = rs1Tone.Volume;
tone2014.IsCustom = true;
tone2014.NameSeparator = " - ";
tone2014.SortOrder = 0;

// setup some possible tone approximation conversions
// no direct mapping for RS1 -> RS2 Tones
// look here IEnumerable<ToneDescriptor> List()
// TODO: figure out better method for tone mapping
if (tone2014.Key.ToUpper().Contains("_OD") ||
tone2014.Key.ToUpper().Contains("_COMBO"))
if (tone2014.Key.ToUpper().Contains("_COMBO"))
tone2014.Key = "Combo_OD";

if (tone2014.Key.ToUpper().Contains("_OD"))
{
tone2014.ToneDescriptors.Add("$[35716]OVERDRIVE");
amp.Type = "Amps";
Expand Down Expand Up @@ -650,8 +653,12 @@ public Tone2014 ToneToTone2014(Tone rs1Tone)
Rack1 = rack1
};
}
else // acoustic is better than nothing, right.
else // default acoustic is better than nothing, right
{
// this is fix for bad RS1 CDLC tones
tone2014.Name = "default_acoustic";
tone2014.Key = "DEFAULT_ACOUSTIC";
//
tone2014.ToneDescriptors.Add("$[35721]ACOUSTIC");
amp.Type = "Amps";
amp.Category = "Amp";
Expand Down
103 changes: 76 additions & 27 deletions RocksmithToolkitLib/XML/Song2014.cs
Expand Up @@ -17,6 +17,10 @@ namespace RocksmithToolkitLib.Xml
[XmlRoot("song", Namespace = "", IsNullable = false)]
public class Song2014
{
[XmlIgnore]
[JsonIgnore]
static IEnumerable<XComment> commentNodes;

[XmlAttribute("version")] // RS2014 is 7 or above
public string Version { get; set; }

Expand Down Expand Up @@ -174,10 +178,6 @@ public class Song2014
[XmlArrayItem("level", typeof(SongLevel2014))]
public SongLevel2014[] Levels { get; set; }

[XmlIgnore]
[JsonIgnore]
static IEnumerable<XComment> commentNodes;

public Song2014() { }

public Song2014(Sng2014HSL.Sng sngData, Attributes2014 attr = null)
Expand Down Expand Up @@ -276,27 +276,43 @@ public Song2014(Sng2014HSL.Sng sngData, Attributes2014 attr = null)
/// <param name="xmlSongRS2014File">Xml file path.</param>
static void LoadXmlComments(string xmlSongRS2014File)
{
var xml = XDocument.Load(xmlSongRS2014File);
commentNodes = xml.DescendantNodes().OfType<XComment>();
try
{
// this fails if there are no comments
var xml = XDocument.Load(xmlSongRS2014File);
commentNodes = xml.DescendantNodes().OfType<XComment>();
}
catch (Exception ex)
{
Console.WriteLine("This XML Arrangement has no comments: " + ex.Message);
}

}

/// <summary>
/// Writes the EOF\DDC xml comments.
/// </summary>
/// <param name="song">Xml stream.</param>
///<summary>
///Writes the EOF\DDC xml comments.
///</summary>
///<param name="song">Xml stream.</param>
static void FixXmlComments(Stream song)
{
var xml = XDocument.Load(song); song.Position = 0;
if(commentNodes != null)
if (commentNodes != null)
{
xml.AddFirst(commentNodes);
xml.Save(song); song.Position = 0;
song.Position = 0;
var xml = XDocument.Load(song);
// check for arrangment that have no comments
if (xml != null)
{
xml.AddFirst(commentNodes);
xml.Save(song);
song.Position = 0;
}
}
}

public static Song2014 LoadFromFile(string xmlSongRS2014File)
{
LoadXmlComments(xmlSongRS2014File);

using (var reader = new StreamReader(xmlSongRS2014File))
{
return new XmlStreamingDeserializer<Song2014>(reader).Deserialize();
Expand All @@ -305,7 +321,7 @@ public static Song2014 LoadFromFile(string xmlSongRS2014File)

public void Serialize(Stream stream, bool omitXmlDeclaration = false)
{
var ns = new XmlSerializerNamespaces();
XmlSerializerNamespaces ns = new XmlSerializerNamespaces();
ns.Add("", "");

var song = new MemoryStream();
Expand All @@ -317,40 +333,73 @@ public void Serialize(Stream stream, bool omitXmlDeclaration = false)
}))
{
new XmlSerializer(typeof(Song2014)).Serialize(writer, this, ns);
song.Position = 0;
}

FixArrayAttribs(song);
FixXmlComments(song);

stream = new MemoryStream(song.ToArray());
// process crashes badly if these next lines are removed
song.Position = 0;
song.CopyTo(stream);
stream.Flush();
stream.Seek(0, SeekOrigin.Begin);
// part of root element is missing error
// stream = new MemoryStream(song.ToArray());

This comment has been minimized.

Copy link
@L0FKA

L0FKA Mar 27, 2015

Member

Yeah this is probably that stone I catched.

}

/// <summary>
/// Writes count attribute for choosed nodes.
/// </summary>
/// <param name="xml">Xml stream.</param>
static void FixArrayAttribs(Stream xml)
private static void FixArrayAttribs(Stream xml)
{
string[] anodes = { "phrases", "phraseIterations", "newLinkedDiffs", "linkedDiffs",
"phraseProperties", "chordTemplates", "fretHandMuteTemplates", "fretHandMutes"/*DDC*/,
"ebeats", "sections", "events", "levels", "notes", "chords", "anchors", "handShapes"
};

var doc = XDocument.Load(xml); xml.Position = 0;
foreach (var n in anodes) {
var es = doc.Descendants(n).ToArray();
if(es.Any())
foreach( var e in es )
xml.Position = 0;

This comment has been minimized.

Copy link
@L0FKA

L0FKA Mar 27, 2015

Member

This was just small refactor, should I put it back?

This comment has been minimized.

Copy link
@cozy1

cozy1 Mar 27, 2015

Contributor

No this is part of problem with root element missing error. Need to understand why it is caused before we put back.

var doc = XDocument.Load(xml);
foreach (var n in anodes)
{
var es = doc.Descendants(n);
if (es.Count() > 0)
foreach (var e in es)
{
var ret = e.Attribute("count");
if(ret == null)
if (ret == null)
e.Add(new XAttribute("count", e.Elements().Count()));
else
ret.SetValue(e.Elements().Count());
}
}
doc.Save(xml); xml.Position = 0;
xml.Position = 0;
doc.Save(xml);
}

// TODO: Disabled for now ... root element is missing error

This comment has been minimized.

Copy link
@L0FKA

L0FKA Mar 27, 2015

Member

root element is missing fails at null xml's so It's safe now, since xml's isn't null, more shotgun debugging to the god of debugging. I like this style too 👍

This comment has been minimized.

Copy link
@cozy1

cozy1 Mar 27, 2015

Contributor

This not only caused crash in PackageCreator it also caused crash with all other packer / unpacker routines that use it. So make sure code doesn't crash other features too before putting back.

// static void FixArrayAttribs(Stream xml)
// {
// string[] anodes = { "phrases", "phraseIterations", "newLinkedDiffs", "linkedDiffs",
//"phraseProperties", "chordTemplates", "fretHandMuteTemplates", "fretHandMutes"/*DDC*/,
//"ebeats", "sections", "events", "levels", "notes", "chords", "anchors", "handShapes"
//};
// var doc = XDocument.Load(xml); xml.Position = 0;
// foreach (var n in anodes)
// {
// var es = doc.Descendants(n).ToArray();
// if (es.Any())
// foreach (var e in es)
// {
// var ret = e.Attribute("count");
// if (ret == null)
// e.Add(new XAttribute("count", e.Elements().Count()));
// else
// ret.SetValue(e.Elements().Count());
// }
// }
// doc.Save(xml); xml.Position = 0;
// }

}

public class SongArrangementProperties2014 : SongArrangementProperties
Expand Down Expand Up @@ -541,7 +590,7 @@ internal static SongChordTemplate2014[] Parse(List<DLCPackage.Manifest.ChordTemp
for (int i = 0; i < cteamplateList.Count; i++)
{
var sct2014 = new SongChordTemplate2014();
sct2014.ChordName = cteamplateList[i].ChordName;
sct2014.ChordName = cteamplateList[i].ChordName;
// split getting funky RS1 -> RS2 results when combined
sct2014.DisplayName = cteamplateList[i].ChordName;
sct2014.Finger0 = (sbyte)cteamplateList[i].Fingers[0];
Expand Down

0 comments on commit eea374b

Please sign in to comment.