mirror of
https://github.com/HarbourMasters/Starship.git
synced 2025-01-23 13:35:11 +03:00
Merge branch 'audio_fixes_v2' of https://github.com/HarbourMasters/Starship into audio_fixes_v2
This commit is contained in:
commit
9347059776
@ -159,6 +159,8 @@ GameEngine::GameEngine() {
|
||||
|
||||
loader->RegisterResourceFactory(std::make_shared<SF64::ResourceFactoryBinarySampleV1>(), RESOURCE_FORMAT_BINARY,
|
||||
"Sample", static_cast<uint32_t>(SF64::ResourceType::Sample), 1);
|
||||
loader->RegisterResourceFactory(std::make_shared<SF64::ResourceFactoryBinarySampleV2>(), RESOURCE_FORMAT_BINARY,
|
||||
"Sample", static_cast<uint32_t>(SF64::ResourceType::Sample), 2);
|
||||
|
||||
loader->RegisterResourceFactory(std::make_shared<SF64::ResourceFactoryBinarySoundFontV0>(), RESOURCE_FORMAT_BINARY,
|
||||
"SoundFont", static_cast<uint32_t>(SF64::ResourceType::SoundFont), 0);
|
||||
|
@ -14,8 +14,9 @@ std::shared_ptr<Ship::IResource> ResourceFactoryBinaryDrumV0::ReadResource(std::
|
||||
drum->mDrum.adsrDecayIndex = reader->ReadUByte();
|
||||
drum->mDrum.pan = reader->ReadUByte();
|
||||
drum->mDrum.isRelocated = reader->ReadUByte();
|
||||
drum->mDrum.tunedSample.sample = LoadChild<SampleData*>(reader->ReadUInt64());
|
||||
drum->mDrum.tunedSample.tuning = reader->ReadFloat();
|
||||
auto sample = LoadChild<SampleData*>(reader->ReadUInt64());
|
||||
drum->mDrum.tunedSample.sample = sample;
|
||||
drum->mDrum.tunedSample.tuning = sample->tuning != 0.0f ? sample->tuning : reader->ReadFloat();
|
||||
drum->mDrum.envelope = LoadChild<EnvelopePointData*>(reader->ReadUInt64());
|
||||
drum->mDrum.isRelocated = 1;
|
||||
|
||||
|
@ -16,12 +16,20 @@ std::shared_ptr<Ship::IResource> ResourceFactoryBinaryInstrumentV0::ReadResource
|
||||
instrument->mInstrument.normalRangeHi = reader->ReadUByte();
|
||||
instrument->mInstrument.adsrDecayIndex = reader->ReadUByte();
|
||||
instrument->mInstrument.envelope = LoadChild<EnvelopePointData*>(reader->ReadUInt64());
|
||||
instrument->mInstrument.lowPitchTunedSample.sample = LoadChild<SampleData*>(reader->ReadUInt64());
|
||||
instrument->mInstrument.lowPitchTunedSample.tuning = reader->ReadFloat();
|
||||
instrument->mInstrument.normalPitchTunedSample.sample = LoadChild<SampleData*>(reader->ReadUInt64());
|
||||
instrument->mInstrument.normalPitchTunedSample.tuning = reader->ReadFloat();
|
||||
instrument->mInstrument.highPitchTunedSample.sample = LoadChild<SampleData*>(reader->ReadUInt64());
|
||||
instrument->mInstrument.highPitchTunedSample.tuning = reader->ReadFloat();
|
||||
auto lowSample = LoadChild<SampleData*>(reader->ReadUInt64());
|
||||
instrument->mInstrument.lowPitchTunedSample.sample = lowSample;
|
||||
instrument->mInstrument.lowPitchTunedSample.tuning =
|
||||
lowSample != nullptr && lowSample->tuning != 0.0f ? lowSample->tuning : reader->ReadFloat();
|
||||
|
||||
auto normalSample = LoadChild<SampleData*>(reader->ReadUInt64());
|
||||
instrument->mInstrument.normalPitchTunedSample.sample = normalSample;
|
||||
instrument->mInstrument.normalPitchTunedSample.tuning =
|
||||
normalSample != nullptr && normalSample->tuning != 0.0f ? normalSample->tuning : reader->ReadFloat();
|
||||
|
||||
auto highSample = LoadChild<SampleData*>(reader->ReadUInt64());
|
||||
instrument->mInstrument.highPitchTunedSample.sample = highSample;
|
||||
instrument->mInstrument.highPitchTunedSample.tuning =
|
||||
highSample != nullptr && highSample->tuning != 0.0f ? highSample->tuning : reader->ReadFloat();
|
||||
instrument->mInstrument.isRelocated = 1;
|
||||
|
||||
return instrument;
|
||||
|
@ -25,4 +25,28 @@ std::shared_ptr<Ship::IResource> ResourceFactoryBinarySampleV1::ReadResource(std
|
||||
|
||||
return sample;
|
||||
}
|
||||
|
||||
std::shared_ptr<Ship::IResource> ResourceFactoryBinarySampleV2::ReadResource(std::shared_ptr<Ship::File> file) {
|
||||
if (!FileHasValidFormatAndReader(file)) {
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
auto sample = std::make_shared<Sample>(file->InitData);
|
||||
auto reader = std::get<std::shared_ptr<Ship::BinaryReader>>(file->Reader);
|
||||
|
||||
sample->mSample.codec = reader->ReadUInt32();
|
||||
sample->mSample.medium = reader->ReadUInt32();
|
||||
sample->mSample.unk = reader->ReadUInt32();
|
||||
sample->mSample.size = reader->ReadUInt32();
|
||||
sample->mSample.tuning = reader->ReadFloat();
|
||||
sample->mSample.loop = LoadChild<AdpcmLoopData*>(reader->ReadUInt64());
|
||||
sample->mSample.book = LoadChild<AdpcmBookData*>(reader->ReadUInt64());
|
||||
sample->mSample.sampleAddr = new uint8_t[sample->mSample.size];
|
||||
reader->Read((char*) sample->mSample.sampleAddr, sample->mSample.size);
|
||||
|
||||
sample->mSample.medium = 0;
|
||||
sample->mSample.isRelocated = 1;
|
||||
|
||||
return sample;
|
||||
}
|
||||
} // namespace LUS
|
||||
|
@ -8,4 +8,9 @@ class ResourceFactoryBinarySampleV1 : public Ship::ResourceFactoryBinary {
|
||||
public:
|
||||
std::shared_ptr<Ship::IResource> ReadResource(std::shared_ptr<Ship::File> file) override;
|
||||
};
|
||||
|
||||
class ResourceFactoryBinarySampleV2 : public Ship::ResourceFactoryBinary {
|
||||
public:
|
||||
std::shared_ptr<Ship::IResource> ReadResource(std::shared_ptr<Ship::File> file) override;
|
||||
};
|
||||
}; // namespace LUS
|
||||
|
@ -16,6 +16,7 @@ struct SampleData {
|
||||
uint8_t* sampleAddr;
|
||||
AdpcmLoopData* loop;
|
||||
AdpcmBookData* book;
|
||||
float tuning = 0.0f;
|
||||
};
|
||||
|
||||
class Sample : public Ship::Resource<SampleData> {
|
||||
|
Loading…
Reference in New Issue
Block a user