- 
                Notifications
    You must be signed in to change notification settings 
- Fork 11
Support >2 channels #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
| public class FmodSampleMetadata : IBinaryReadable | ||
| { | ||
| internal bool HasAnyChunks; | ||
| internal uint FrequencyId; | ||
| internal ulong DataOffset; | ||
| internal List<FmodSampleChunk> Chunks = new(); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please don't make formatting changes.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure
| { | ||
| 0 => 1, | ||
| 1 => 2, | ||
| 2 => 6, | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why isn't this 4?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It should be 6, that's the whole point
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any FMOD documentation about this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think there is any, all I can give you is an example of converted audio:
4 channels
vs
6 channels
Tested on soundbanks from three different games
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From FMOD::CodecFSB5::decodeSubSoundHeader:
18001644e        if (channels != 0)
180016462            int128_t __xmm@00000008000000060000000200000001_1 =
180016462                __xmm@00000008000000060000000200000001
18001646c            *channels = *(&__xmm@00000008000000060000000200000001_1
18001646c                + ((zx.q((r10 u>> 5).d) & 3) << 2))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From
FMOD::CodecFSB5::decodeSubSoundHeader:18001644e if (channels != 0) 180016462 int128_t __xmm@00000008000000060000000200000001_1 = 180016462 __xmm@00000008000000060000000200000001 18001646c *channels = *(&__xmm@00000008000000060000000200000001_1 18001646c + ((zx.q((r10 u>> 5).d) & 3) << 2))
@ds5678 and after looking at this it appears that frequencies table was also incorrect, so I also changed it
Correct one should match to this:
180016472        if (frequency != 0)
180016493            __builtin_memcpy(dest: &var_58, 
180016493                src: "\xa0\x0f\x00\x00\x40\x1f\x00\x00\xf8\x2a\x00\x00\xe0\x2e\x00\x00\x80\x3e"
180016493            "00\x00\x22\x56\x00\x00\xc0\x5d\x00\x00\x00\x7d\x00\x00\x44\xac\x00\x00\x80\xbb"
180016493            "00\x00\x00\x77\x01\x00", 
180016493                count: 0x2c)
1800164b2            *frequency = *(&var_58 + ((zx.q((r10 u>> 1).d) & 0xf) << 2))
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From
FMOD::CodecFSB5::decodeSubSoundHeader
Please document in the code that the behavior can be verified by disassembling this function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Added.
| } | ||
| void IBinaryReadable.Read(BinaryReader reader) | ||
| { | ||
| var sampleMode = reader.ReadUInt64(); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the name change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just to clarify what it represents. I’ve reverted it back to how it was if that’s an issue
Number of channels was being read and then written incorrectly into packet info (for e.x. 4 instead of 6), resulting in malformed audio output. This fixes Vorbis rebuilder.
I can't tell about other formats though as I don't have any to test nor do I need them. I would appreciate if this could be merged as I need it in a different project. In case this breaks other formats somehow I would suggest to only skip samples with >2 channels in these cases instead of throwing completely