public override ChartFormat DecodeChart(FormatData data, ProgressIndicator progress) { if (!data.HasStream(this, ChartFile)) { throw new FormatException(); } Stream stream = data.GetStream(this, ChartFile); Midi midi = Midi.Create(Mid.Create(stream)); data.CloseStream(stream); ChartFormat chart = new ChartFormat(NoteChart.Create(midi)); DecodeLeftHandAnimations(chart.Chart, midi); ChartFormatGH2.DecodeDrums(chart.Chart, midi, true); ChartFormatGH2.DecodeOverdrive(chart.Chart); ImportMap.ImportChart(data.Song, chart.Chart); return(chart); }
public override ChartFormat DecodeChart(FormatData data, ProgressIndicator progress) { if (!data.HasStream(this, ChartFile)) { throw new FormatException(); } Stream stream = data.GetStream(this, ChartFile); Midi midi = Midi.Create(Mid.Create(stream)); data.CloseStream(stream); DecodeCoop(midi, data.Song.Data.GetValue <bool>("GH2ChartCoop")); ChartFormat chart = new ChartFormat(NoteChart.Create(midi)); DecodeDrums(chart.Chart, midi, false); DecodeOverdrive(chart.Chart); ImportMap.ImportChart(data.Song, chart.Chart); return(chart); }
public NoteChart GetChart(bool coop = false) { Midi eventsmidi = new Midi(); eventsmidi.BPM = NoteChart.BPM; eventsmidi.Signature = NoteChart.Signature; eventsmidi.Division = NoteChart.Division; eventsmidi.Tracks.Add(EventsTrack); if (Song.ContainsKey("Name")) { eventsmidi.Name = Song["Name"]; } NoteChart chart = NoteChart.Create(eventsmidi); if (coop) { if (Tracks.ContainsKey(BaseTrackType.DoubleGuitar)) { chart.PartGuitar = Tracks[BaseTrackType.DoubleGuitar] as NoteChart.Guitar; } if (Tracks.ContainsKey(BaseTrackType.DoubleBass)) { chart.PartBass = Tracks[BaseTrackType.DoubleBass] as NoteChart.Bass; } } else { if (Tracks.ContainsKey(BaseTrackType.Single)) { chart.PartGuitar = Tracks[BaseTrackType.Single] as NoteChart.Guitar; } //if (Tracks.ContainsKey(BaseTrackType.SingleBass)) // chart.PartBass = Tracks[BaseTrackType.SingleBass] as NoteChart.Bass; } return(chart); }
public override bool AddSong(PlatformData data, SongData song, ProgressIndicator progress) { FormatData formatdata = new TemporaryFormatData(song, data); DirectoryNode dir = data.Session["songdir"] as DirectoryNode; int delay = 0; bool eighthhopo = false; int hopofreq = -1; AudioFormat format = new AudioFormat(); FileNode songini = dir.Navigate("song.ini", false, true) as FileNode; if (songini != null) { Ini ini = Ini.Create(songini.Data); songini.Data.Close(); string value = ini.GetValue("song", "name"); if (value != null) { song.Name = value; } value = ini.GetValue("song", "artist"); if (value != null) { song.Artist = value; } value = ini.GetValue("song", "album"); if (value != null) { song.Album = value; } value = ini.GetValue("song", "genre"); if (value != null) { song.Genre = value; } value = ini.GetValue("song", "year"); if (value != null) { song.Year = int.Parse(value); } value = ini.GetValue("song", "version"); if (value != null) { song.Version = int.Parse(value); } value = ini.GetValue("song", "delay"); if (value != null) { delay = int.Parse(value); } value = ini.GetValue("song", "eighthnote_hopo"); if (value != null) { eighthhopo = string.Compare(value, "true", true) == 0 ? true : false; } value = ini.GetValue("song", "hopofreq"); if (value != null) { hopofreq = int.Parse(value); } value = ini.GetValue("song", "tags"); if (value != null) { song.Master = string.Compare(value, "cover", true) == 0 ? false : true; } value = ini.GetValue("song", "icon"); if (value != null) { song.Game = GetGameFromIcon(value); } value = ini.GetValue("song", "diff_band"); if (value != null) { song.Difficulty[Instrument.Ambient] = ImportMap.GetBaseRank(Instrument.Ambient, int.Parse(value)); } value = ini.GetValue("song", "diff_bass"); if (value != null) { song.Difficulty[Instrument.Bass] = ImportMap.GetBaseRank(Instrument.Bass, int.Parse(value)); } value = ini.GetValue("song", "diff_drums"); if (value != null) { song.Difficulty[Instrument.Drums] = ImportMap.GetBaseRank(Instrument.Drums, int.Parse(value)); } value = ini.GetValue("song", "diff_guitar"); if (value != null) { song.Difficulty[Instrument.Guitar] = ImportMap.GetBaseRank(Instrument.Guitar, int.Parse(value)); } } format.InitialOffset = -delay; FileNode album = dir.Navigate("album.png", false, true) as FileNode; if (album != null) { song.AlbumArt = new Bitmap(album.Data); } FileNode chartfile = dir.Navigate("notes.mid", false, true) as FileNode; NoteChart chart = null; if (chartfile != null) { ChartFormatRB.Instance.Create(formatdata, chartfile.Data, null, 0, null, null, 0, false, true); chart = NoteChart.Create(Midi.Create(Mid.Create(chartfile.Data))); chartfile.Data.Close(); } if (chart != null && eighthhopo) { song.HopoThreshold = chart.Division.TicksPerBeat / 2 + 10; } else if (hopofreq >= 0) { // TODO: This } List <Stream> streams = new List <Stream>(); foreach (Node node in dir) { FileNode file = node as FileNode; if (file == null) { continue; } string extension = Path.GetExtension(file.Name).ToLower(); if (extension != ".ogg") { continue; } string name = Path.GetFileNameWithoutExtension(file.Name); Instrument instrument = Platform.InstrumentFromString(name); RawkAudio.Decoder decoder = new RawkAudio.Decoder(file.Data, RawkAudio.Decoder.AudioFormat.VorbisOgg); for (int i = 0; i < decoder.Channels; i++) { format.Mappings.Add(new AudioFormat.Mapping(0, 0, instrument)); } decoder.Dispose(); file.Data.Close(); streams.Add(file.Data); } format.AutoBalance(); if (streams.Count > 0) { AudioFormatOgg.Instance.Create(formatdata, streams.ToArray(), format); } else if (chartfile == null) { return(false); } data.AddSong(formatdata); return(true); }
public static ChartFormat Create(Midi midi) { ChartFormat format = new ChartFormat(NoteChart.Create(midi)); return(format); }