JD2022-TU1/main/tools/apps/JDSongConverter/Tasks/CleanUpTrkErrorTask.cs

49 lines
No EOL
1.6 KiB
C#

using TeaBox.Macros;
using System;
using System.IO;
using JD.Audio.Annotations;
using JD.Audio.Sound;
using JD.Serialization;
namespace JDSongConverter.Tasks
{
/// <summary>
/// Moving Audio Preview and Volume from respectively SongDesc.tpl and MusicTrack.tpl into .trk file
/// USE ONLY IN JD2016 FORMAT
/// </summary>
#pragma warning disable 0618 //This warning is about obsolete classes but I need those to convert
public class CleanUpTrkErrorTask : Task
{
protected LuaSerializer m_luaSerializer;
public override string Name
{
get { return "Clean up Error in Trk file"; }
set { }
}
public override string ProgressText
{
get { return "Cleaning up Error in Trk file"; }
}
public override TaskResult Process(IExecutionContext executionContext)
{
String musicTrackTpl = Context.OutputMap.MusicTrack;
if (musicTrackTpl.Length != 0 && File.Exists(musicTrackTpl))
{
var wave = Wave.LoadFromMusicTrackTpl(musicTrackTpl, Wave.LoadingMode.StructureOnly);
if (wave.Annotations.PreviewEntry < wave.Annotations.PreviewLoopStart)
{
float tempPreviewEntry = wave.Annotations.PreviewEntry;
wave.Annotations.PreviewEntry = wave.Annotations.PreviewLoopStart;
wave.Annotations.PreviewLoopStart = tempPreviewEntry;
new LuaAnnotations(wave).Save(Context.OutputMap.TrkFile);
}
}
return TaskResult.Ok;
}
}
}