public bool AddSongOld(PlatformData data, SongData song, ProgressIndicator progress) { FormatData formatdata = new TemporaryFormatData(song, data); formatdata.Song.Data.SetValue("RawkSD2Compatibility", true); formatdata.Song.Version = 0; DirectoryNode dir = data.Session["songdir"] as DirectoryNode; FileNode audiofile = dir.Navigate("audio") as FileNode; FileNode albumfile = dir.Navigate("album") as FileNode; FileNode weightsfile = dir.Navigate("weights") as FileNode; FileNode panfile = dir.Navigate("pan") as FileNode; FileNode milofile = dir.Navigate("milo") as FileNode; FileNode chartfile = dir.Navigate("chart") as FileNode; FileNode previewfile = dir.Navigate("preview") as FileNode; if (audiofile != null) { AudioFormat audio = HarmonixMetadata.GetAudioFormat(song); AudioFormatRB2Mogg.Instance.Create(formatdata, audiofile.Data, previewfile.Data, null); } if (albumfile != null) { song.AlbumArt = WiiImage.Create(new EndianReader(albumfile.Data, Endianness.LittleEndian)).Bitmap; } if (chartfile != null) { ChartFormatRB.Instance.Create(formatdata, chartfile == null ? null : chartfile.Data, panfile == null ? null : panfile.Data, weightsfile == null ? null : weightsfile.Data, milofile == null ? null : milofile.Data, false, false, Game.RockBand2); } data.AddSong(formatdata); return(true); }
public override bool AddSong(PlatformData data, SongData song, ProgressIndicator progress) { FormatData formatdata = new TemporaryFormatData(song, data); DirectoryNode songdir = data.Session["songdir"] as DirectoryNode; SongsDTA dta = HarmonixMetadata.GetSongsDTA(song); if (dta == null) // LRB's <addsong /> { dta = HarmonixMetadata.GetSongData(song); dta.Song.Cores = new List <int>() { -1, -1, -1, -1, -1, 1, 1, -1, -1 }; dta.Song.Vols = new List <float>() { 0, 0, 0, 0, 0, 0, 0, 0, 0 }; dta.Song.Pans = new List <float>() { 0, 0, -1, 1, 0, -1, 1, 0, 0 }; dta.Song.Tracks.Find(t => t.Name == "drum").Tracks.AddRange(new int[] { 0, 1, 2, 3 }); dta.Song.Tracks.Find(t => t.Name == "bass").Tracks.AddRange(new int[] { 4 }); dta.Song.Tracks.Find(t => t.Name == "guitar").Tracks.AddRange(new int[] { 5, 6 }); dta.Song.Tracks.Find(t => t.Name == "vocals").Tracks.AddRange(new int[] { 7 }); dta.Song.Name = "songs/" + song.ID + "/" + song.ID; HarmonixMetadata.SetSongsDTA(song, dta.ToDTB()); } string dtaname = dta.Song.Name; if (dtaname.StartsWith("dlc")) { dtaname = dtaname.Split(new char[] { '/' }, 4)[3]; } int lastslash = dtaname.LastIndexOf('/'); string basename = dtaname.Substring(lastslash + 1); dtaname = dtaname.Substring(0, lastslash); DirectoryNode songnode = songdir.Navigate(dtaname) as DirectoryNode; if (songnode == null) { return(false); } FileNode songaudiofile = songnode.Navigate(basename + ".bik", false, true) as FileNode; AudioFormat audio = null; if (songaudiofile == null) { songaudiofile = songnode.Navigate(basename + ".mogg", false, true) as FileNode; if (songaudiofile == null) { return(false); } if (HarmonixMetadata.IsRockBand1(data.Game)) { audio = HarmonixMetadata.GetAudioFormat(song); audio.InitialOffset = 3000; } AudioFormatMogg.Instance.Create(formatdata, songaudiofile.Data, audio); } else { AudioFormatRB2Bink.Instance.Create(formatdata, songaudiofile.Data, null); } // TODO: SongInfo // TODO: Preview FileNode chartfile = songnode.Find(basename + ".mid") as FileNode; FileNode panfile = songnode.Find(basename + ".pan") as FileNode; FileNode weightsfile = songnode.Navigate("gen/" + basename + "_weights.bin") as FileNode; FileNode milofile = songnode.Navigate("gen/" + basename + ".milo_wii") as FileNode; FileNode albumfile = songnode.Navigate("gen/" + basename + "_keep.png_wii") as FileNode; if (chartfile == null) { return(false); } if (albumfile == null) { albumfile = songnode.Navigate("gen/" + basename + "_nomip_keep.bmp_wii") as FileNode; } if (albumfile != null) { song.AlbumArt = WiiImage.Create(new EndianReader(albumfile.Data, Endianness.LittleEndian)).Bitmap; albumfile.Data.Close(); } ChartFormatRB.Instance.Create(formatdata, chartfile == null ? null : chartfile.Data, panfile == null ? null : panfile.Data, weightsfile == null ? null : weightsfile.Data, milofile == null ? null : milofile.Data, false, false, data.Game); data.AddSong(formatdata); return(true); }
internal static void Export360(string path, FormatData original) { Program.Form.Progress.QueueTask(progress => { progress.NewTask("Exporting to 360 DLC file", 16); SongData song = original.Song; StfsArchive stfs = new StfsArchive(); stfs.Stfs.ContentType = StfsFile.ContentTypes.Marketplace; stfs.Stfs.TitleID = 0x45410829; for (int i = 0; i < stfs.Stfs.DisplayName.Length; i++) { stfs.Stfs.DisplayName[i] = song.Artist + " - " + song.Name; } for (int i = 0; i < stfs.Stfs.DisplayDescription.Length; i++) { stfs.Stfs.DisplayDescription[i] = "RawkSD DLC - http://rawksd.japaneatahand.com"; } stfs.Stfs.TitleName = "Rawk Band 2"; stfs.Stfs.Publisher = "RawkSD"; stfs.Stfs.TitleThumbnail = WiiImage.Create(new EndianReader(new MemoryStream(ConsoleHaxx.RawkSD.Properties.Resources.rawksd_albumart), Endianness.LittleEndian)).Bitmap; if (song.AlbumArt != null) { stfs.Stfs.Thumbnail = song.AlbumArt; } else { stfs.Stfs.Thumbnail = stfs.Stfs.TitleThumbnail; } StfsFile.SignedHeader header = new StfsFile.SignedHeader(StfsFile.FileTypes.LIVE); stfs.Stfs.Header = header; header.Licenses[0].ID = 0xFFFFFFFFFFFFFFFF; stfs.Stfs.MetadataVersion = 2; StfsFile.PackageDescriptor desc = new StfsFile.PackageDescriptor(); stfs.Stfs.Descriptor = desc; desc.StructSize = 0x24; desc.BlockSeparation = 1; desc.FileTableBlockCount = 0x100; // byte apparently stfs.Stfs.TransferFlags = 0xC0; FormatData data = original; Program.Form.TaskMutex.WaitOne(); bool local = data.PlatformData.Platform == PlatformLocalStorage.Instance; bool ownformat = false; if (!local && Configuration.MaxConcurrentTasks > 1) { data = new TemporaryFormatData(data.Song, data.PlatformData); original.SaveTo(data); ownformat = true; } Program.Form.TaskMutex.ReleaseMutex(); Stream songs = null; Stream audio = null; Stream chart = data.GetStream(ChartFormatRB.Instance, ChartFormatRB.ChartFile); Stream pan = data.GetStream(ChartFormatRB.Instance, ChartFormatRB.PanFile); Stream weights = data.GetStream(ChartFormatRB.Instance, ChartFormatRB.WeightsFile); Stream milo = data.GetStream(ChartFormatRB.Instance, ChartFormatRB.MiloFile); milo = new MemoryStream(Properties.Resources.rbn_milo); // TODO: properly convert milo if (milo == null) { milo = new MemoryStream(ConsoleHaxx.RawkSD.Properties.Resources.rawksd_milo); } using (DelayedStreamCache cache = new DelayedStreamCache()) { AudioFormat audioformat = (data.GetFormat(FormatType.Audio) as IAudioFormat).DecodeAudio(data, progress); ushort[] masks = PlatformRB2WiiCustomDLC.RemixAudioTracks(data.Song, audioformat); progress.Progress(); // RBN Required DTA settings SongsDTA dta = PlatformRB2WiiCustomDLC.GetSongsDTA(song, audioformat, false); dta.AlbumArt = false; dta.Song.Name = "songs/" + song.ID + "/" + song.ID; dta.Song.MidiFile = "songs/" + song.ID + "/" + song.ID + ".mid"; dta.Rating = 4; dta.SubGenre = "subgenre_core"; dta.Format = 4; //dta.SongID = 0; dta.Origin = "rb2"; //dta.Ugc = 1; //dta.SongLength = 300000; dta.Context = 2000; dta.BasePoints = 0; if (!dta.TuningOffsetCents.HasValue) { dta.TuningOffsetCents = 0; } audio = new TemporaryStream(); cache.AddStream(audio); progress.Progress(); progress.SetNextWeight(10); long samples = audioformat.Decoder.Samples; CryptedMoggStream mogg = new CryptedMoggStream(audio); mogg.WriteHeader(); RawkAudio.Encoder encoder = new RawkAudio.Encoder(mogg, audioformat.Mappings.Count, audioformat.Decoder.SampleRate); progress.NewTask("Transcoding Audio", samples); JaggedShortArray buffer = new JaggedShortArray(encoder.Channels, audioformat.Decoder.AudioBuffer.Rank2); AudioFormat.ProcessOffset(audioformat.Decoder, encoder, audioformat.InitialOffset); while (samples > 0) { int read = audioformat.Decoder.Read((int)Math.Min(samples, audioformat.Decoder.AudioBuffer.Rank2)); if (read <= 0) { break; } audioformat.Decoder.AudioBuffer.DownmixTo(buffer, masks, read); encoder.Write(buffer, read); samples -= read; progress.Progress(read); } progress.EndTask(); progress.Progress(10); encoder.Dispose(); audioformat.Decoder.Dispose(); audio.Position = 0; dta.Song.TracksCount.Add(audioformat.Mappings.Count(m => m.Instrument == Instrument.Drums)); dta.Song.TracksCount.Add(audioformat.Mappings.Count(m => m.Instrument == Instrument.Bass)); dta.Song.TracksCount.Add(audioformat.Mappings.Count(m => m.Instrument == Instrument.Guitar)); dta.Song.TracksCount.Add(audioformat.Mappings.Count(m => m.Instrument == Instrument.Vocals)); dta.Song.TracksCount.Add(audioformat.Mappings.Count(m => m.Instrument == Instrument.Ambient)); for (int i = 0; i < dta.Song.Cores.Count; i++) { dta.Song.Cores[i] = -1; } songs = new TemporaryStream(); cache.AddStream(songs); dta.ToDTB().SaveDTA(songs); ChartFormat chartformat = (data.GetFormat(FormatType.Chart) as IChartFormat).DecodeChart(data, progress); if (chart != null && ChartFormatRB.Instance.NeedsFixing(data)) { data.CloseStream(chart); chart = null; } if (chart == null) { chart = new TemporaryStream(); cache.AddStream(chart); PlatformRB2WiiCustomDLC.AdjustChart(song, audioformat, chartformat).ToMidi().ToMid().Save(chart); chart.Position = 0; } if (weights == null) { weights = new TemporaryStream(); cache.AddStream(weights); PlatformRB2WiiCustomDLC.CreateWeights(weights, chartformat); weights.Position = 0; } if (pan == null) { pan = new TemporaryStream(); cache.AddStream(pan); PlatformRB2WiiCustomDLC.CreatePan(pan, chartformat); pan.Position = 0; } progress.Progress(3); DirectoryNode dir = new DirectoryNode("songs"); stfs.Root.AddChild(dir); dir.AddChild(new FileNode("songs.dta", songs)); DirectoryNode songdir = new DirectoryNode(song.ID); dir.AddChild(songdir); songdir.AddChild(new FileNode(song.ID + ".mogg", audio)); songdir.AddChild(new FileNode(song.ID + ".mid", chart)); DirectoryNode gendir = new DirectoryNode("gen"); songdir.AddChild(gendir); gendir.AddChild(new FileNode(song.ID + ".milo_xbox", milo)); gendir.AddChild(new FileNode(song.ID + "_weights.bin", weights)); Stream ostream = new FileStream(path, FileMode.Create); stfs.Save(ostream); ostream.Close(); data.CloseStream(audio); data.CloseStream(chart); data.CloseStream(pan); data.CloseStream(weights); data.CloseStream(milo); if (ownformat) { data.Dispose(); } progress.Progress(); progress.EndTask(); } }); }
public MainForm() { InitializeComponent(); SongUpdateMutex = new Mutex(); TaskMutex = new Mutex(); Platforms = new List <PlatformData>(); ProgressList = new List <TaskScheduler>(); ProgressControls = new Dictionary <TaskScheduler, ProgressItem>(); RootPath = Environment.CurrentDirectory; Configuration.Load(this); try { // It may be in use by another instance... So you get no logs, too bad. LogStream = new StreamWriter(new FileStream(Path.Combine(RootPath, "rawksd.log"), FileMode.Create, FileAccess.Write, FileShare.Read)); LogStream.AutoFlush = true; LogStream.WriteLine("RawkSD started at " + DateTime.Now.ToString()); Console.SetOut(LogStream); } catch (Exception exception) { Exceptions.Warning(exception, "Unable to use the log file; another RawkSD instance is probably still running."); } ImportMap.RootPath = Path.Combine(RootPath, "importdata"); if (!Path.IsPathRooted(Configuration.LocalPath)) { StoragePath = Path.Combine(RootPath, Configuration.LocalPath); } else { StoragePath = Configuration.LocalPath; } if (!Path.IsPathRooted(Configuration.TemporaryPath)) { TemporaryPath = Path.Combine(RootPath, Configuration.TemporaryPath); } else { TemporaryPath = Configuration.TemporaryPath; } Directory.CreateDirectory(TemporaryPath); TemporaryStream.BasePath = TemporaryPath; for (int i = 0; i < Configuration.MaxConcurrentTasks; i++) { AddTaskScheduler(); } Tiers = new Image[7]; Tiers[0] = Properties.Resources.TierZero; Tiers[1] = Properties.Resources.TierOne; Tiers[2] = Properties.Resources.TierTwo; Tiers[3] = Properties.Resources.TierThree; Tiers[4] = Properties.Resources.TierFour; Tiers[5] = Properties.Resources.TierFive; Tiers[6] = Properties.Resources.TierSix; AlbumImage = WiiImage.Create(new EndianReader(new MemoryStream(RawkSD.Properties.Resources.rawksd_albumart), Endianness.LittleEndian)).Bitmap; SongList.DoubleBuffer(); SongList_SelectedIndexChanged(this, EventArgs.Empty); }
public static void ImportRB1Lipsync(PlatformData lrb) { DirectoryNode root = lrb.Session["songdir"] as DirectoryNode; root = root.Navigate("songs/rb1") as DirectoryNode; if (root == null) { return; } List <PlatformData> platforms = new List <PlatformData>(Program.Form.Platforms); platforms.Add(Program.Form.Storage); foreach (PlatformData platform in platforms) { platform.Mutex.WaitOne(); foreach (FormatData data in platform.Songs) { if (data.Formats.Contains(ChartFormatRB.Instance)) { string songid = data.Song.ID; if (songid.StartsWith("rb1")) { songid = songid.Substring(3); DirectoryNode songdir = root.Navigate(songid) as DirectoryNode; FileNode node = songdir.Navigate(songid + ".pan") as FileNode; if (node != null) { node.Data.Position = 0; Stream stream = data.AddStream(ChartFormatRB.Instance, ChartFormatRB.PanFile); Util.StreamCopy(stream, node.Data); data.CloseStream(stream); node.Data.Close(); } node = songdir.Navigate("gen/" + songid + ".milo_wii") as FileNode; if (node != null) { node.Data.Position = 0; Stream stream = data.AddStream(ChartFormatRB.Instance, ChartFormatRB.MiloFile); Util.StreamCopy(stream, node.Data); data.CloseStream(stream); node.Data.Close(); } node = songdir.Navigate("gen/" + songid + "_keep.png_wii") as FileNode; if (node == null) { node = songdir.Navigate("gen/" + songid + "_nomip_keep.bmp_wii") as FileNode; } if (node != null) { node.Data.Position = 0; data.Song.AlbumArt = WiiImage.Create(new EndianReader(node.Data, Endianness.LittleEndian)).Bitmap; node.Data.Close(); } } } } platform.Mutex.ReleaseMutex(); } }