VGAudio
VGAudio copied to clipboard
BCSTM files incompatible with a 3DS
The BCSTM files created using the VGAudio library work fine when decoded on a computer, but fail to play on a 3DS, specifically when applied as a background theme in the HOME menu. I've tried comparing the file information of two BCSTM files, which had everything in common but the library that was used to encode the file. The results can be seen below:
Original
Sample count: 2051072 (94,0083 seconds)
Sample rate: 21818 Hz
Channel count: 2
Encoding format: GameCube "DSP" 4-bit ADPCM
Loop start: 157696 samples (7,2278 seconds)
Loop end: 2051072 samples (94,0083 seconds)
Interleave Count: 144
Interleave Size: 0x2000
Samples per interleave: 14336
Last interleave size without padding: 0x250
Last interleave size: 0x260
Samples in last interleave block: 1024
Sample count from data size: 2051084
Samples per seek table entry: 14336
Track 0
-------------------------
Channel Count: 2
Left channel ID: 0
Right channel ID: 1
Volume: 0x7F
Panning: 0x40
Channel 0
----------------------------------------
Coefficients:
[0]: 0x0390, 0xFE4F
[1]: 0x0A1C, 0xFB2E
[2]: 0x0606, 0xFF7D
[3]: 0x0989, 0xFDC3
[4]: 0x0746, 0xFC4A
[5]: 0x0BA7, 0xFB2E
[6]: 0x071F, 0xFFD3
Gain: 0x0000
Pred/Scale: 0x0000
History sample 1 (n-1): 0x0000
History sample 2 (n-2): 0x0000
Loop Pred/Scale: 0x0000
Loop History sample 1: 0x0069
Loop History sample 2: 0x0069
Channel 1
----------------------------------------
Coefficients:
[0]: 0x0179, 0xFF5C
[1]: 0x08C5, 0xFBC8
[2]: 0x045A, 0x0160
[3]: 0x0991, 0xFD7E
[4]: 0x054B, 0xFE04
[5]: 0x0AFB, 0xFB56
[6]: 0x0672, 0x00B3
Gain: 0x0000
Pred/Scale: 0x0000
History sample 1 (n-1): 0x0000
History sample 2 (n-2): 0x0000
Loop Pred/Scale: 0x0000
Loop History sample 1: 0x003A
Loop History sample 2: 0x003A
Re-encoded (VGAudio)
Sample count: 2051072 (94,0083 seconds)
Sample rate: 21818 Hz
Channel count: 2
Encoding format: GameCube "DSP" 4-bit ADPCM
Loop start: 157696 samples (7,2278 seconds)
Loop end: 2051072 samples (94,0083 seconds)
Interleave Count: 144
Interleave Size: 0x2000
Samples per interleave: 14336
Last interleave size without padding: 0x24A
Last interleave size: 0x260
Samples in last interleave block: 1024
Sample count from data size: 2051072
Samples per seek table entry: 14336
Track 0
-------------------------
Channel Count: 2
Left channel ID: 0
Right channel ID: 1
Volume: 0x7F
Panning: 0x40
Channel 0
----------------------------------------
Coefficients:
[0]: 0x0388, 0xFE58
[1]: 0x0A1C, 0xFB2F
[2]: 0x060C, 0xFF72
[3]: 0x097F, 0xFDCC
[4]: 0x0745, 0xFC45
[5]: 0x0BA2, 0xFB35
[6]: 0x0713, 0xFFDC
Gain: 0x0000
Pred/Scale: 0x0000
History sample 1 (n-1): 0x0000
History sample 2 (n-2): 0x0000
Loop Pred/Scale: 0x0069
Loop History sample 1: 0xF0EF
Loop History sample 2: 0xF0EF
Channel 1
----------------------------------------
Coefficients:
[0]: 0x0177, 0xFF5F
[1]: 0x08C2, 0xFBCB
[2]: 0x045C, 0x015B
[3]: 0x0987, 0xFD87
[4]: 0x054C, 0xFE00
[5]: 0x0AF9, 0xFB5C
[6]: 0x066C, 0x00B8
Gain: 0x0000
Pred/Scale: 0x0000
History sample 1 (n-1): 0x0000
History sample 2 (n-2): 0x0000
Loop Pred/Scale: 0x003A
Loop History sample 1: 0xF2DE
Loop History sample 2: 0xF2DE
There seems to be a difference in offsets for the following:
- Last interleave size without padding (
0x250
vs0x24A
) - Sample count from data size (
2051084
vs2051072
) - All coefficients of both channels
- Complete loop information (Loop Pred/Scale, Loop History sample 1, Loop History sample 2) of both channels
Other than that, the files seem to be identical.
May I ask if a fix is possible? I can provide more information or samples if needed. Also, thank you for the previous fix you've made! Many thanks in advance.
Try repacking the audio stream. I think you might be able to do that by "converting" the BCSAR to another BCSAR. If not, convert to something like BCSTM and back. If that doesn't work it's most likely an issue with how the BCSAR container is packed
I'm sorry for making a mistake, the file in question is BCSTM, not BCSAR (I'll fix the comments as well as the title).
I've tried the following:
- Reencoding BCSTM to another BCSTM
- Converting BCSTM to HCA and back to BCSTM
- Converting BCSTM to BRSTM and back to BCSTM
- Converting BCSTM to WAV (through VGAudio) and back to BCSTM
- Converting BCSTM to WAV (through FFmpeg) and back to BCSTM
The results
- Note: All of the files were converted from the original BCSTM
BCSTM (original)
BCSTM (original)
Sample count: 2051072 (94,0083 seconds)
Sample rate: 21818 Hz
Channel count: 2
Encoding format: GameCube "DSP" 4-bit ADPCM
Loop start: 157696 samples (7,2278 seconds)
Loop end: 2051072 samples (94,0083 seconds)
Interleave Count: 144
Interleave Size: 0x2000
Samples per interleave: 14336
Last interleave size without padding: 0x250
Last interleave size: 0x260
Samples in last interleave block: 1024
Sample count from data size: 2051084
Samples per seek table entry: 14336
Track 0
-------------------------
Channel Count: 2
Left channel ID: 0
Right channel ID: 1
Volume: 0x7F
Panning: 0x40
Channel 0
----------------------------------------
Coefficients:
[0]: 0x0390, 0xFE4F
[1]: 0x0A1C, 0xFB2E
[2]: 0x0606, 0xFF7D
[3]: 0x0989, 0xFDC3
[4]: 0x0746, 0xFC4A
[5]: 0x0BA7, 0xFB2E
[6]: 0x071F, 0xFFD3
Gain: 0x0000
Pred/Scale: 0x0000
History sample 1 (n-1): 0x0000
History sample 2 (n-2): 0x0000
Loop Pred/Scale: 0x0000
Loop History sample 1: 0x0069
Loop History sample 2: 0x0069
Channel 1
----------------------------------------
Coefficients:
[0]: 0x0179, 0xFF5C
[1]: 0x08C5, 0xFBC8
[2]: 0x045A, 0x0160
[3]: 0x0991, 0xFD7E
[4]: 0x054B, 0xFE04
[5]: 0x0AFB, 0xFB56
[6]: 0x0672, 0x00B3
Gain: 0x0000
Pred/Scale: 0x0000
History sample 1 (n-1): 0x0000
History sample 2 (n-2): 0x0000
Loop Pred/Scale: 0x0000
Loop History sample 1: 0x003A
Loop History sample 2: 0x003A
BCSTM to BCSTM
BCSTM to BCSTM
Sample count: 2051072 (94,0083 seconds)
Sample rate: 21818 Hz
Channel count: 2
Encoding format: GameCube "DSP" 4-bit ADPCM
Loop start: 157696 samples (7,2278 seconds)
Loop end: 2051072 samples (94,0083 seconds)
Interleave Count: 144
Interleave Size: 0x2000
Samples per interleave: 14336
Last interleave size without padding: 0x24A
Last interleave size: 0x260
Samples in last interleave block: 1024
Sample count from data size: 2051072
Samples per seek table entry: 14336
Track 0
-------------------------
Channel Count: 2
Left channel ID: 0
Right channel ID: 1
Volume: 0x7F
Panning: 0x40
Channel 0
----------------------------------------
Coefficients:
[0]: 0x0390, 0xFE4F
[1]: 0x0A1C, 0xFB2E
[2]: 0x0606, 0xFF7D
[3]: 0x0989, 0xFDC3
[4]: 0x0746, 0xFC4A
[5]: 0x0BA7, 0xFB2E
[6]: 0x071F, 0xFFD3
Gain: 0x0000
Pred/Scale: 0x0000
History sample 1 (n-1): 0x0000
History sample 2 (n-2): 0x0000
Loop Pred/Scale: 0x0069
Loop History sample 1: 0xF0CC
Loop History sample 2: 0xF0CC
Channel 1
----------------------------------------
Coefficients:
[0]: 0x0179, 0xFF5C
[1]: 0x08C5, 0xFBC8
[2]: 0x045A, 0x0160
[3]: 0x0991, 0xFD7E
[4]: 0x054B, 0xFE04
[5]: 0x0AFB, 0xFB56
[6]: 0x0672, 0x00B3
Gain: 0x0000
Pred/Scale: 0x0000
History sample 1 (n-1): 0x0000
History sample 2 (n-2): 0x0000
Loop Pred/Scale: 0x003A
Loop History sample 1: 0xF2CC
Loop History sample 2: 0xF2CC
BCSTM to HCA to BCSTM
BCSTM to HCA to BCSTM
Sample count: 2051072 (94,0083 seconds)
Sample rate: 21818 Hz
Channel count: 2
Encoding format: GameCube "DSP" 4-bit ADPCM
Loop start: 157696 samples (7,2278 seconds)
Loop end: 2051072 samples (94,0083 seconds)
Interleave Count: 144
Interleave Size: 0x2000
Samples per interleave: 14336
Last interleave size without padding: 0x24A
Last interleave size: 0x260
Samples in last interleave block: 1024
Sample count from data size: 2051072
Samples per seek table entry: 14336
Track 0
-------------------------
Channel Count: 2
Left channel ID: 0
Right channel ID: 1
Volume: 0x7F
Panning: 0x40
Channel 0
----------------------------------------
Coefficients:
[0]: 0x03E2, 0xFE31
[1]: 0x0A67, 0xFB03
[2]: 0x0671, 0xFF17
[3]: 0x09B6, 0xFD9F
[4]: 0x07A6, 0xFBFE
[5]: 0x0BD2, 0xFB12
[6]: 0x0747, 0xFFAA
Gain: 0x0000
Pred/Scale: 0x0000
History sample 1 (n-1): 0x0000
History sample 2 (n-2): 0x0000
Loop Pred/Scale: 0x0039
Loop History sample 1: 0xF320
Loop History sample 2: 0xF320
Channel 1
----------------------------------------
Coefficients:
[0]: 0x0199, 0xFF56
[1]: 0x08F6, 0xFBA5
[2]: 0x0486, 0x013C
[3]: 0x09DA, 0xFD3C
[4]: 0x0578, 0xFDE0
[5]: 0x0B1A, 0xFB3E
[6]: 0x069C, 0x008D
Gain: 0x0000
Pred/Scale: 0x0000
History sample 1 (n-1): 0x0000
History sample 2 (n-2): 0x0000
Loop Pred/Scale: 0x0079
Loop History sample 1: 0xF1C7
Loop History sample 2: 0xF1C7
BCSTM to BRSTM to BCSTM
BCSTM to BRSTM to BCSTM
Sample count: 2051072 (94,0083 seconds)
Sample rate: 21818 Hz
Channel count: 2
Encoding format: GameCube "DSP" 4-bit ADPCM
Loop start: 157696 samples (7,2278 seconds)
Loop end: 2051072 samples (94,0083 seconds)
Interleave Count: 144
Interleave Size: 0x2000
Samples per interleave: 14336
Last interleave size without padding: 0x24A
Last interleave size: 0x260
Samples in last interleave block: 1024
Sample count from data size: 2051072
Samples per seek table entry: 14336
Track 0
-------------------------
Channel Count: 2
Left channel ID: 0
Right channel ID: 1
Volume: 0x7F
Panning: 0x40
Channel 0
----------------------------------------
Coefficients:
[0]: 0x0390, 0xFE4F
[1]: 0x0A1C, 0xFB2E
[2]: 0x0606, 0xFF7D
[3]: 0x0989, 0xFDC3
[4]: 0x0746, 0xFC4A
[5]: 0x0BA7, 0xFB2E
[6]: 0x071F, 0xFFD3
Gain: 0x0000
Pred/Scale: 0x0000
History sample 1 (n-1): 0x0000
History sample 2 (n-2): 0x0000
Loop Pred/Scale: 0x0069
Loop History sample 1: 0xF0CC
Loop History sample 2: 0xF0CC
Channel 1
----------------------------------------
Coefficients:
[0]: 0x0179, 0xFF5C
[1]: 0x08C5, 0xFBC8
[2]: 0x045A, 0x0160
[3]: 0x0991, 0xFD7E
[4]: 0x054B, 0xFE04
[5]: 0x0AFB, 0xFB56
[6]: 0x0672, 0x00B3
Gain: 0x0000
Pred/Scale: 0x0000
History sample 1 (n-1): 0x0000
History sample 2 (n-2): 0x0000
Loop Pred/Scale: 0x003A
Loop History sample 1: 0xF2CC
Loop History sample 2: 0xF2CC
BCSTM to WAV (VGAudio) to BCSTM
BCSTM to WAV (VGAudio) to BCSTM
Sample count: 2051072 (94,0083 seconds)
Sample rate: 21818 Hz
Channel count: 2
Encoding format: GameCube "DSP" 4-bit ADPCM
Loop start: 157696 samples (7,2278 seconds)
Loop end: 2051072 samples (94,0083 seconds)
Interleave Count: 144
Interleave Size: 0x2000
Samples per interleave: 14336
Last interleave size without padding: 0x24A
Last interleave size: 0x260
Samples in last interleave block: 1024
Sample count from data size: 2051072
Samples per seek table entry: 14336
Track 0
-------------------------
Channel Count: 2
Left channel ID: 0
Right channel ID: 1
Volume: 0x7F
Panning: 0x40
Channel 0
----------------------------------------
Coefficients:
[0]: 0x0388, 0xFE58
[1]: 0x0A1C, 0xFB2F
[2]: 0x060C, 0xFF72
[3]: 0x097F, 0xFDCC
[4]: 0x0745, 0xFC45
[5]: 0x0BA2, 0xFB35
[6]: 0x0713, 0xFFDC
Gain: 0x0000
Pred/Scale: 0x0000
History sample 1 (n-1): 0x0000
History sample 2 (n-2): 0x0000
Loop Pred/Scale: 0x0069
Loop History sample 1: 0xF0EF
Loop History sample 2: 0xF0EF
Channel 1
----------------------------------------
Coefficients:
[0]: 0x0177, 0xFF5F
[1]: 0x08C2, 0xFBCB
[2]: 0x045C, 0x015B
[3]: 0x0987, 0xFD87
[4]: 0x054C, 0xFE00
[5]: 0x0AF9, 0xFB5C
[6]: 0x066C, 0x00B8
Gain: 0x0000
Pred/Scale: 0x0000
History sample 1 (n-1): 0x0000
History sample 2 (n-2): 0x0000
Loop Pred/Scale: 0x003A
Loop History sample 1: 0xF2DE
Loop History sample 2: 0xF2DE
BCSTM to WAV (FFmpeg) to BCSTM
BCSTM to WAV (FFmpeg) to BCSTM
Sample count: 2051072 (94,0083 seconds)
Sample rate: 21818 Hz
Channel count: 2
Encoding format: GameCube "DSP" 4-bit ADPCM
Loop start: 157696 samples (7,2278 seconds)
Loop end: 2051072 samples (94,0083 seconds)
Interleave Count: 144
Interleave Size: 0x2000
Samples per interleave: 14336
Last interleave size without padding: 0x24A
Last interleave size: 0x260
Samples in last interleave block: 1024
Sample count from data size: 2051072
Samples per seek table entry: 14336
Track 0
-------------------------
Channel Count: 2
Left channel ID: 0
Right channel ID: 1
Volume: 0x7F
Panning: 0x40
Channel 0
----------------------------------------
Coefficients:
[0]: 0x038A, 0xFE58
[1]: 0x0A1C, 0xFB30
[2]: 0x060D, 0xFF71
[3]: 0x0980, 0xFDCC
[4]: 0x0744, 0xFC45
[5]: 0x0BA2, 0xFB35
[6]: 0x0713, 0xFFDD
Gain: 0x0000
Pred/Scale: 0x0000
History sample 1 (n-1): 0x0000
History sample 2 (n-2): 0x0000
Loop Pred/Scale: 0x0069
Loop History sample 1: 0xF0EA
Loop History sample 2: 0xF0EA
Channel 1
----------------------------------------
Coefficients:
[0]: 0x0178, 0xFF60
[1]: 0x08C2, 0xFBCC
[2]: 0x045C, 0x015C
[3]: 0x0987, 0xFD88
[4]: 0x054C, 0xFDFF
[5]: 0x0AF9, 0xFB5C
[6]: 0x066C, 0x00B8
Gain: 0x0000
Pred/Scale: 0x0000
History sample 1 (n-1): 0x0000
History sample 2 (n-2): 0x0000
Loop Pred/Scale: 0x003A
Loop History sample 1: 0xF2D8
Loop History sample 2: 0xF2D8
After testing all the files, the only one that plays is the original one. More than half of the files' information that differs seems to be unique, but they have two parameters that match for those files that don't work:
- Last interleave size without padding (original:
0x250
, all the other reencoded ones:0x24A
) - Sample count from data size (original:
2051084
, all the other reencoded ones:2051072
)
Also, the sample count from data size in those reencoded files match the file's sample count as well as the loop end (the loop ends at the very end of the file).
The original file:
- Sample count: 2051072 (94,0083 seconds)
- Loop end: 2051072 samples (94,0083 seconds)
- Sample count from data size: 2051084
-
Last interleave size without padding: 0x250
All the other reencoded files:
- Sample count: 2051072 (94,0083 seconds)
- Loop end: 2051072 samples (94,0083 seconds)
- Sample count from data size: 2051072
-
Last interleave size without padding: 0x24A
So I've decided to recreate both working and non-working scenarios so that you could reproduce them as well to see the difference. To avoid any copyright infringement, I'll be using a royalty-free audio file.
These are the exact steps to creating both files:
- I used this audio file (direct download link)
- Then I used FFmpeg to run the following commands on the file:
-
ffmpeg -i "The Cannery.mp3" -ar 22050 "cannery.mp3"
<-- Set the sample rate to 22050 Hz -
ffmpeg -i "cannery.mp3" -af atrim=start_sample=118262:end_sample=361122 "cannery2.mp3"
<-- Shorten the file
-
- After that, I used Looping Audio Converter 1.3 (the one known to work in the 3DS' Home Menu):
- All I did here was importing the file (cannery2.mp3), setting the output format to BCSTM and hitting Start.
- The produced file worked in the 3DS' Home Menu
- Once the file was generated, I ran the following command:
-
VGAudioCli.exe -i "cannery2.bcstm" -o "cannery2_vg.bcstm" --no-loop
- The produced file didn't work in the 3DS' Home Menu
-
More details are available below (both files were exported without the loop - it's not a problem):
Looping Audio Converter 1.3 variant - cannery2.bcstm (works)
Sample count: 244224 (11,0759 seconds)
Sample rate: 22050 Hz
Channel count: 2
Encoding format: GameCube "DSP" 4-bit ADPCM
Interleave Count: 18
Interleave Size: 0x2000
Samples per interleave: 14336
Last interleave size without padding: 0x128
Last interleave size: 0x140
Samples in last interleave block: 512
Sample count from data size: 244230
Samples per seek table entry: 14336
Track 0
-------------------------
Channel Count: 2
Left channel ID: 0
Right channel ID: 1
Volume: 0x7F
Panning: 0x40
Channel 0
----------------------------------------
Coefficients:
[0]: 0x03D6, 0xFDE4
[1]: 0x0921, 0xFBDB
[2]: 0x000A, 0x07F5
[3]: 0x0C6E, 0xFA7F
[4]: 0x05BC, 0x0001
[5]: 0x08A2, 0xFE79
[6]: 0x0109, 0x06EA
Gain: 0x0000
Pred/Scale: 0x0050
History sample 1 (n-1): 0x0000
History sample 2 (n-2): 0x0000
Loop Pred/Scale: 0x0000
Loop History sample 1: 0x0000
Loop History sample 2: 0x0000
Channel 1
----------------------------------------
Coefficients:
[0]: 0x0348, 0xFE18
[1]: 0x0921, 0xFBBB
[2]: 0x028E, 0x04CA
[3]: 0x0C7C, 0xFA69
[4]: 0x0595, 0xFFFB
[5]: 0x08B9, 0xFE45
[6]: 0x0001, 0x07FF
Gain: 0x0000
Pred/Scale: 0x0050
History sample 1 (n-1): 0x0000
History sample 2 (n-2): 0x0000
Loop Pred/Scale: 0x0000
Loop History sample 1: 0x0000
Loop History sample 2: 0x0000
VGAudio variant - cannery2_vg.bcstm (doesn't work)
Sample count: 244224 (11,0759 seconds)
Sample rate: 22050 Hz
Channel count: 2
Encoding format: GameCube "DSP" 4-bit ADPCM
Interleave Count: 18
Interleave Size: 0x2000
Samples per interleave: 14336
Last interleave size without padding: 0x125
Last interleave size: 0x140
Samples in last interleave block: 512
Sample count from data size: 244224
Samples per seek table entry: 14336
Track 0
-------------------------
Channel Count: 2
Left channel ID: 0
Right channel ID: 1
Volume: 0x7F
Panning: 0x40
Channel 0
----------------------------------------
Coefficients:
[0]: 0x03D6, 0xFDE4
[1]: 0x0921, 0xFBDB
[2]: 0x000A, 0x07F5
[3]: 0x0C6E, 0xFA7F
[4]: 0x05BC, 0x0001
[5]: 0x08A2, 0xFE79
[6]: 0x0109, 0x06EA
Gain: 0x0000
Pred/Scale: 0x0050
History sample 1 (n-1): 0x0000
History sample 2 (n-2): 0x0000
Loop Pred/Scale: 0x0050
Loop History sample 1: 0x0000
Loop History sample 2: 0x0000
Channel 1
----------------------------------------
Coefficients:
[0]: 0x0348, 0xFE18
[1]: 0x0921, 0xFBBB
[2]: 0x028E, 0x04CA
[3]: 0x0C7C, 0xFA69
[4]: 0x0595, 0xFFFB
[5]: 0x08B9, 0xFE45
[6]: 0x0001, 0x07FF
Gain: 0x0000
Pred/Scale: 0x0050
History sample 1 (n-1): 0x0000
History sample 2 (n-2): 0x0000
Loop Pred/Scale: 0x0050
Loop History sample 1: 0x0000
Loop History sample 2: 0x0000
The difference (working vs. not working)
- Last interleave size without padding:
0x128
vs.0x125
- Sample count from data size:
244230
vs.244224
- Channel 0 Loop Pred/Scale:
0x0000
vs.0x0050
- Channel 1 Loop Pred/Scale:
0x0000
vs.0x0050
I would be glad if this helped you with solving the problem.