public void LoadInstrumentBank(BeBinaryReader instReader, JAIVersion version) { Instruments = new Instrument[0xF0]; // for some reason, they will only ever have 0xF0 instruments in them if (version == JAIVersion.ONE || version == JAIVersion.TWO) { loadIBNKJaiV1(instReader); // Both of these use standard ibnk structure. } else if (version == JAIVersion.THREE) { loadIBNKJaiV2(instReader); } }
public void LoadAAFile(string filename, JAIVersion version) { WSYS = new WaveSystem[0xFF]; // None over 256 please :). IBNK = new InstrumentBank[0xFF]; // These either. var aafdata = File.ReadAllBytes(filename); // We're just going to load a whole copy into memory because we're lame -- having this buffer in memory makes it easy to pass as a ref to stream readers later. var aafRead = new BeBinaryReader(new MemoryStream(aafdata)); bool done = false; while (!done) { var ChunkID = aafRead.ReadUInt32(); long anchor; var name = convertChunkName(ChunkID); Console.WriteLine("[AAF] Found chunk: {0}", name); switch (ChunkID) { case 0: done = true; // either we're misalligned or done, so just stopo here. break; case 1: // Don't know case 5: case 4: case 6: case 7: aafRead.ReadUInt32(); aafRead.ReadUInt32(); aafRead.ReadUInt32(); break; case 2: // INST case 3: // WSYS { while (true) { var offset = aafRead.ReadUInt32(); if (offset == 0) { break; // 0 means we reached the end. } var size = aafRead.ReadUInt32(); var type = aafRead.ReadUInt32(); anchor = aafRead.BaseStream.Position; // Store our return position. aafRead.BaseStream.Position = offset; // Seek to the offset pos. if (ChunkID == 3) { var b = new WaveSystem(); // Load the wavesystem b.LoadWSYS(aafRead); WSYS[b.id] = b; // store it Console.WriteLine("\t WSYS at 0x{0:X}", offset); } else if (ChunkID == 2) { var x = new InstrumentBank(); x.LoadInstrumentBank(aafRead, version); Console.WriteLine("\t IBNK at 0x{0:X}", offset); IBNK[x.id] = x; // Store it } aafRead.BaseStream.Position = anchor; // Return back to our original pos after loading. } break; } } } }
public void LoadBAAFile(string filename, JAIVersion version) { WSYS = new WaveSystem[0xFF]; // None over 256 please :). IBNK = new InstrumentBank[0xFF]; // These either. var aafdata = File.ReadAllBytes(filename); // We're just going to load a whole copy into memory because we're lame -- having this buffer in memory makes it easy to pass as a ref to stream readers later. var aafRead = new BeBinaryReader(new MemoryStream(aafdata)); bool done = false; while (!done) { var ChunkID = aafRead.ReadUInt32(); long anchor; var name = convertChunkName(ChunkID); Console.WriteLine("[BAA] Found chunk: {0}", name); switch (ChunkID) { case 1046430017: // >_AA done = true; // either we're misalligned or done, so just stopo here. break; case 1094803260: // AA_< break; case 1651733536: // BST { var offset_sta = aafRead.ReadUInt32(); var offset_end = aafRead.ReadUInt32(); break; } case 1651733614: // BSTN { var offset_sta = aafRead.ReadUInt32(); var offset_end = aafRead.ReadUInt32(); break; } case 1651729184: // BSC { var offset_sta = aafRead.ReadUInt32(); var offset_end = aafRead.ReadUInt32(); break; } case 1651403552: // BNK { var id = aafRead.ReadUInt32(); var offset = aafRead.ReadUInt32(); anchor = aafRead.BaseStream.Position; // Store our return position. aafRead.BaseStream.Position = offset; // Seek to the offset pos. var b = new InstrumentBank(); b.LoadInstrumentBank(aafRead, version); // Load it up IBNK[id] = b; aafRead.BaseStream.Position = anchor; // Return back to our original pos after loading. break; } case 2004033568: // WSYS { var id = aafRead.ReadUInt32(); var offset = aafRead.ReadUInt32(); var flags = aafRead.ReadUInt32(); anchor = aafRead.BaseStream.Position; // Store our return position. aafRead.BaseStream.Position = offset; // Seek to the offset pos. var b = new WaveSystem(); b.LoadWSYS(aafRead); WSYS[id] = b; aafRead.BaseStream.Position = anchor; // Return back to our original pos after loading. break; } } } }
static void Main(string[] args) { #if DEBUG args = new string[4]; args[0] = "visu"; args[1] = "jaiinit.aaf"; args[2] = "0"; args[3] = "telesabattle.bms"; #endif if (args.Length > 0) { if (args[0] == "mkjasm") { if (args.Length > 2) { var wtf = new JASM.JASMConverter(args[1], args[2]); return; } } if (args[0] == "play") { JAIVersion SequencerVersion = JAIVersion.UNKNOWN; if (args.Length < 3) { Console.WriteLine("You need to specify JAIInitFile and JAIVersion"); Console.WriteLine("JaiSeqX.exe play JaiInit.aaf 0 boolossus.bms yes"); Environment.Exit(-1); } try { SequencerVersion = (JAIVersion)(Convert.ToUInt16(args[2])); } catch { Console.WriteLine("{0} is not a valid JAIVersion", args[2]); } if (SequencerVersion == JAIVersion.UNKNOWN) { Console.WriteLine("{0} is not a valid JAIVersion", args[2]); } if (SequencerVersion == JAIVersion.ONE) { var b = new AAFFile(); b.LoadAAFile(args[1], JAIVersion.ONE); AAData = b; } else { var b = new BAAFile(); b.LoadBAAFile(args[1], SequencerVersion); AAData = b; } // if (args.Length < 4) { Console.WriteLine("No BMS file specified."); Environment.Exit(-1); } Player.BMSPlayer.LoadBMS(args[3], ref AAData); } if (args[0] == "visu") { JAIVersion SequencerVersion = JAIVersion.UNKNOWN; if (args.Length < 3) { Console.WriteLine("You need to specify JAIInitFile and JAIVersion"); Console.WriteLine("JaiSeqX.exe visu JaiInit.aaf 0 boolossus.bms yes"); Environment.Exit(-1); } try { SequencerVersion = (JAIVersion)(Convert.ToUInt16(args[2])); } catch { Console.WriteLine("{0} is not a valid JAIVersion", args[2]); } if (SequencerVersion == JAIVersion.UNKNOWN) { Console.WriteLine("{0} is not a valid JAIVersion", args[2]); } if (SequencerVersion == JAIVersion.ONE) { var b = new AAFFile(); b.LoadAAFile(args[1], JAIVersion.ONE); AAData = b; } else { var b = new BAAFile(); b.LoadBAAFile(args[1], SequencerVersion); AAData = b; } // if (args.Length < 4) { Console.WriteLine("No BMS file specified."); Environment.Exit(-1); } Player.BMSVisualizer.Init(); Player.BMSPlayer.LoadBMS(args[3], ref AAData); } } else { Console.WriteLine("JaiSeqX [command] <args>"); Console.WriteLine(); Console.WriteLine("JaiSeqX mkjasm <file> - Creates a .JASM (Jai Assembly) file from file.bms"); Console.WriteLine("\tJaiSeqX mkjasm file.bms\t"); Console.WriteLine(); Console.WriteLine("JaiSeqX play <aafFile> <JaiVersion> <BMS file> - Plays a BMS file with the specified JaiInit.aaf and version"); Console.WriteLine("\tJaiSeqX play JaiInit.aaf 0 file.bms"); Console.WriteLine("\t For JaiVersion info, see JaiVersion.cs or JV.txt! "); Console.WriteLine(); Console.WriteLine("JaiSeqX visu <aafFile> <JaiVersion> <BMS file> - Plays a BMS file with visualizer, same as command above but with visualizer."); Console.WriteLine("\tJaiSeqX play JaiInit.aaf 0 file.bms"); Console.WriteLine("\t For JaiVersion info, see JaiVersion.cs or JV.txt! "); } }