Leftos wrote:nesa24, well done. It's nice to see programmers around the forum. You should be releasing the source code of your tools, maybe someone could help you directly. Since you're using .NET, I was able to take a look at what you're doing through your decompiled source code, and from the information you've given, I was able to replace the first seconds of Mercy with the first seconds of any song on my computer, just like you did. Now if you can figure out how the different chunks are placed inside the .bin file, you could be making a song import/export tool in no time. I don't understand if you've already figured that out from your posts, but I hope you have.
To everyone else...
Like nesa24 said, the files are in WMAv2, 32kbps, Stereo, 44.1 KHz, 16bit. To get any song on your PC to that format, you use xWMAEncode. xWMAEncode is part of Microsoft's DirectX SDK, and can be found here: http://www.mediafire.com/download/zccl8 ... Encode.exe. You run it by putting it anywhere and running it through the command line like this:
- Code: Select all
xWMAEncode -b 32000 mysong.wav mysong.xma
You can also decode xWMA files like so:
- Code: Select all
xWMAEncode mysong.xma mysong.wav
Once you encode a file to xWMA, open it in any hex-editor, and find the "data" header. After the ASCII codes for "data" is the size of the rest of the file in 4 bytes, and then the actual song data. So, what nesa24 has done so far is grab a chunk of that song data and throw it right into jukeboxmusic.bin at decimal offset 96 to replace the start of Mercy.
Problem is, we need to figure out the size of those chunks (is it 4K? 8K? Something else?) and their offsets inside the .bin files. Once we do, we can replace the songs. As for the chunk size, I'd say 8192 bytes (8KB) is a candidate, since that number is what's inside bytes 92-95 in jukeboxmusic.bin. Could be wrong though.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Drawing.Imaging;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.Diagnostics;
using System.IO;
using System.Media;
namespace NBA_Music_Tool___BETA
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
ofd.FileName = "nodata";
}
OpenFileDialog ofd = new OpenFileDialog();
private void pictureBox10_Click(object sender, EventArgs e)
{
Application.Exit();
}
byte[] musictowrite = { };
private void button1_Click(object sender, EventArgs e)
{
ofd.Title = "Select jukeboxmusic.bin to patch";
ofd.Filter = "jukeboxmusic.bin(*.bin)|*.bin";
ofd.ShowDialog();
if (ofd.SafeFileName=="jukeboxmusic.bin")
{
this.button2.Enabled = true;
this.button4.Enabled = true;
this.button6.Enabled = true;
}
}
string readmus = Directory.GetCurrentDirectory() + "\\temp.dat";
string readmus2 = Directory.GetCurrentDirectory() + "\\temp2.dat";
string readmus3 = Directory.GetCurrentDirectory() + "\\temp3.dat";
private void button2_Click(object sender, EventArgs e)
{
musictowrite = ReadAllBytes(readmus);
button3.Enabled = true;
}
private void button3_Click(object sender, EventArgs e)
{
BinaryWriter bw = new BinaryWriter(File.Open(ofd.FileName, FileMode.Open, FileAccess.ReadWrite));
bw.BaseStream.Position = 0x00000060;
bw.Write(musictowrite);
bw.Flush();
bw.Close();
button3.Enabled = false;
}
public byte[] ReadAllBytes(string fileName)
{
byte[] buffer = null;
using (FileStream fs = new FileStream(fileName, FileMode.Open, FileAccess.Read))
{
buffer = new byte[fs.Length];
fs.Read(buffer, 0, (int)fs.Length);
}
return buffer;
}
private void button5_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void button4_Click(object sender, EventArgs e)
{
musictowrite = ReadAllBytes(readmus2);
button3.Enabled = true;
}
private void button6_Click(object sender, EventArgs e)
{
musictowrite = ReadAllBytes(readmus3);
button3.Enabled = true;
}
nesa24 wrote:http://www.mediafire.com/view/?nwx266fczakbl64 <<<< Read TXT
nesa24 wrote:every chunk/section has a number that is at offset 24 with it of an chunk
Chunks of 1st song
00000000
00003A62
000074C4
0000AF26
0000E988
000123EA
00015E4C
000198AE
0001D310
00020D72
000247D4
00028236
0002BC98
0002F6FA
0003315C
00036BBE
0003A620
0003E082
00041AE4
00045546
00048FA8
0004CA0A
0005046C
00053ECE
00057930
0005B392
0005EDF4
00062856
000662B8
00069D1A
0006D77C
000711DE
00074C40
000786A2
0007C104
0007FB66
000835C8
0008702A
0008AA8C
0008E4EE
00091F50
000959B2
00099414
0009CE76
000A08D8
000A433A
000A7D9C
000AB7FE
000AF260
000B2CC2
000B6724
000BA186
000BDBE8
000C164A
000C50AC
000C8B0E
000CC570
nesa24 wrote:840KB is 1st song
1095KB is 2nd song
615KB is 3rd song
http://www.mediafire.com/?t1o89c7g0280tr4 <<< Song separated 1-2-3 ( from start of jukeboxmusic.bin )
every chunk/section has a number that is at offset 24 with it of an chunk
Leftos wrote:every chunk/section has a number that is at offset 24 with it of an chunk
To replace Mercy's first seconds you went to decimal offset 96 (0x60). You're saying the first chunk is at 0x0, next one is at 0x3A62. Have you figured out if the data is offset by 0x60 each time? So, for the second chunk, should I start at 0x3AC2?
EDIT: So, I pasted some more of the song at 0x3AC2 and got it to play, but it skipped a bit between the first and second chunk, so I think I might've pasted more in the 1st chunk than it can take. Have you figured out how much of each chunk (for example the 1st that is at 0x0, data starts at 0x60 and the whole chunk ends at 0x3A61) should be pasted with song data? Is it 4K? The way you have it each chunk is 14946. You skip the first 96 bytes so you have 14850 bytes left (0x60 to 0x3A61). Do you know how much of that area starting from 0x60 should be filled with song data?
Leftos wrote:Okay, so the first time you replace the first 28 bytes (0x1B) at 0x60 with the first 28 bytes from the dat file, and then copy in chunks, one at 0x7B, one at 0x3ADD, one at 0x753F, etc. Do you know how much starting at 0x7B we should fill up before jumping to the next chunk at 0x3ADD? 4096 bytes? More?
Leftos wrote:Yeah, but you're replacing the same chunk with its headers or whatever. I'm asking whether you're able to replace the 2nd chunk of mercy with a 2nd chunk of YOUR file, as in, not you saying "PES", but whatever comes afterwards. The dat file you provided was too short to have 2 or more chunks itself, so here's another one that's longer: http://www.mediafire.com/download/btd5c ... fm/bfg.dat
See if you can figure how you can get, say, 2, 3, 4 chunks of the dat file into jukeboxmusic.bin so that they play in-game continuously and without skipping, and we're golden.
Leftos wrote:Yeah, I understand that, but we need to figure out how to replace, for example, chunks 1 and 2 of Mercy in jukeboxmusic.bin with continuous chunks from a converted audio file. The one I posted a link of is a whole song converted to xWMA and stripped of its headers to be like your .dat files.
We need to figure out how to take contiguous parts of a converted song and replace continuous parts of Mercy. I haven't managed to do that yet.
Your files (temp.dat, etc.) are very small, they're not long enough to see if we can get a song to play continuously inside NBA 2K. That's why I gave you a link to a long song.
Pdub wrote:Keep in mind that part of the chunk could be index data for seeking.
Leftos wrote:Yeah, I understand that, but we need to figure out how to replace, for example, chunks 1 and 2 of Mercy in jukeboxmusic.bin with continuous chunks from a converted audio file.
Leftos wrote:Yeah, but you're replacing the same chunk with its headers or whatever. I'm asking whether you're able to replace the 2nd chunk of mercy with a 2nd chunk of YOUR file, as in, not you saying "PES", but whatever comes afterwards. The dat file you provided was too short to have 2 or more chunks itself, so here's another one that's longer: http://www.mediafire.com/download/btd5c ... fm/bfg.dat
See if you can figure how you can get, say, 2, 3, 4 chunks of the dat file into jukeboxmusic.bin so that they play in-game continuously and without skipping, and we're golden.
Leftos wrote:No skipping at all? That's great. Can you tell me the exact procedure (as in which parts you copied from the .dat to which parts of the .bin and anything else you did)? I could help you get the tool done faster, if you want. I had already started building something that would copy segments of .dat into the .bin, I just need to know the correct offsets and lengths.
var ms = new MemoryStream(File.ReadAllBytes(@"E:\temp\2kmusic\bfg.dat"));
var bw = new BinaryWriter(File.Open(@"D:\Games\NBA 2K13\jukeboxmusic.bin", FileMode.Open, FileAccess.Write));
bw.BaseStream.Position = 0;
const int ChunkSize = 14946;
const int Count = 14850;
var buf = new byte[Count];
for (int i = 0; i < 10; i++)
{
bw.BaseStream.Position += 58L;
for (int j = 0; j < 10; j++)
{
bw.Write((byte)(j + 1));
bw.BaseStream.Position += 3;
}
bw.BaseStream.Position -= 2;
ms.Read(buf, 0, Count);
bw.Write(buf);
bw.Flush();
}
bw.Close();
ms.Close();
Users browsing this forum: No registered users and 4 guests