1
0
Fork 0
mirror of https://github.com/juce-framework/JUCE.git synced 2026-01-10 23:44:24 +00:00

Added packing when WaveAudioFormat writes SMPL chunks with zero loops

This commit is contained in:
jules 2017-03-06 16:02:51 +00:00
parent 39284e1d0f
commit e16554abb3

View file

@ -300,32 +300,29 @@ namespace WavFileHelpers
MemoryBlock data;
const int numLoops = jmin (64, values.getValue ("NumSampleLoops", "0").getIntValue());
if (numLoops > 0)
data.setSize (roundUpSize (sizeof (SMPLChunk) + (size_t) (jmax (0, numLoops - 1)) * sizeof (SampleLoop)), true);
auto s = static_cast<SMPLChunk*> (data.getData());
s->manufacturer = getValue (values, "Manufacturer", "0");
s->product = getValue (values, "Product", "0");
s->samplePeriod = getValue (values, "SamplePeriod", "0");
s->midiUnityNote = getValue (values, "MidiUnityNote", "60");
s->midiPitchFraction = getValue (values, "MidiPitchFraction", "0");
s->smpteFormat = getValue (values, "SmpteFormat", "0");
s->smpteOffset = getValue (values, "SmpteOffset", "0");
s->numSampleLoops = ByteOrder::swapIfBigEndian ((uint32) numLoops);
s->samplerData = getValue (values, "SamplerData", "0");
for (int i = 0; i < numLoops; ++i)
{
data.setSize (roundUpSize (sizeof (SMPLChunk) + (size_t) (numLoops - 1) * sizeof (SampleLoop)), true);
SMPLChunk* const s = static_cast<SMPLChunk*> (data.getData());
s->manufacturer = getValue (values, "Manufacturer", "0");
s->product = getValue (values, "Product", "0");
s->samplePeriod = getValue (values, "SamplePeriod", "0");
s->midiUnityNote = getValue (values, "MidiUnityNote", "60");
s->midiPitchFraction = getValue (values, "MidiPitchFraction", "0");
s->smpteFormat = getValue (values, "SmpteFormat", "0");
s->smpteOffset = getValue (values, "SmpteOffset", "0");
s->numSampleLoops = ByteOrder::swapIfBigEndian ((uint32) numLoops);
s->samplerData = getValue (values, "SamplerData", "0");
for (int i = 0; i < numLoops; ++i)
{
SampleLoop& loop = s->loops[i];
loop.identifier = getValue (values, i, "Identifier", "0");
loop.type = getValue (values, i, "Type", "0");
loop.start = getValue (values, i, "Start", "0");
loop.end = getValue (values, i, "End", "0");
loop.fraction = getValue (values, i, "Fraction", "0");
loop.playCount = getValue (values, i, "PlayCount", "0");
}
auto& loop = s->loops[i];
loop.identifier = getValue (values, i, "Identifier", "0");
loop.type = getValue (values, i, "Type", "0");
loop.start = getValue (values, i, "Start", "0");
loop.end = getValue (values, i, "End", "0");
loop.fraction = getValue (values, i, "Fraction", "0");
loop.playCount = getValue (values, i, "PlayCount", "0");
}
return data;