Skip to content

Commit

Permalink
Trying to fix linux stupid behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
KiritoDv committed Nov 22, 2024
1 parent 2b70447 commit 6464a2d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
20 changes: 13 additions & 7 deletions src/factories/naudio/v0/AIFCDecode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -389,10 +389,15 @@ void permute(s16 *out, s32 *in, s32 scale)
}
}

void write_header(LUS::BinaryWriter& writer, const char *id, s32 size) {
writer.Write((char*) id, (size_t) 4);
BSWAP32(size);
writer.Write(size);
void WriteString(const char* str, int32_t size, LUS::BinaryWriter& writer) {
for (int i = 0; i < size; i++) {
writer.Write((uint8_t) str[i]);
}
}

void write_header(LUS::BinaryWriter& writer, std::string id, s32 size) {
WriteString(id.data(), id.size(), writer);
writer.Write(BSWAP32(size));
}

void write_aiff(std::vector<char> data, LUS::BinaryWriter& writer) {
Expand Down Expand Up @@ -586,7 +591,7 @@ void write_aiff(std::vector<char> data, LUS::BinaryWriter& writer) {

// Write an incomplete file header. We'll fill in the size later.
writer.Seek(0, LUS::SeekOffsetType::Start);
writer.Write((char*) "FORM\0\0\0\0AIFF", 12);
WriteString("FORM\0\0\0\0AIFF", 12, writer);

// Subtract 4 from the COMM size to skip the compression field.
write_header(writer, "COMM", sizeof(CommonChunk) - 4);
Expand Down Expand Up @@ -634,12 +639,13 @@ void write_aiff(std::vector<char> data, LUS::BinaryWriter& writer) {
// be needed and "tabledesign -s 1" would generate the right table, but in
// practice it's difficult to adjust samples to make that happen.
write_header(writer, "APPL", 4 + 12 + sizeof(CodeChunk) + npredictors * order * 8 * 2);
writer.Write("stoc", false);
WriteString("stoc", 4, writer);
CodeChunk cChunk;
cChunk.version = bswap16(1);
cChunk.order = bswap16(order);
cChunk.nEntries = bswap16(npredictors);
writer.Write("\x0bVADPCMCODES", false);
writer.Write((uint8_t) 0xB);
WriteString("VADPCMCODES", 11, writer);
writer.Write((char*) &cChunk, sizeof(CodeChunk));
for (s32 i = 0; i < npredictors; i++) {
for (s32 j = 0; j < order; j++) {
Expand Down
1 change: 1 addition & 0 deletions src/factories/naudio/v1/SampleFactory.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ std::optional<std::shared_ptr<IParsedData>> NSampleFactory::parse(std::vector<ui
sample->sampleAddr = addr;
sample->tuning = tuning;
sample->sampleBankId = sampleBankId;
sample->sampleRate = sampleRate;

return sample;
}

0 comments on commit 6464a2d

Please sign in to comment.