text
stringlengths
0
2.2M
namespace juce
{
static const char* const aiffFormatName = "AIFF file";
//==============================================================================
const char* const AiffAudioFormat::appleOneShot = "apple one shot";
const char* const AiffAudioFormat::appleRootSet = "apple root set";
const char* const AiffAudioFormat::appleRootNote = "apple root note";
const char* const AiffAudioFormat::appleBeats = "apple beats";
const char* const AiffAudioFormat::appleDenominator = "apple denominator";
const char* const AiffAudioFormat::appleNumerator = "apple numerator";
const char* const AiffAudioFormat::appleTag = "apple tag";
const char* const AiffAudioFormat::appleKey = "apple key";
//==============================================================================
namespace AiffFileHelpers
{
inline int chunkName (const char* name) noexcept { return (int) ByteOrder::littleEndianInt (name); }
#if JUCE_MSVC
#pragma pack (push, 1)
#endif
//==============================================================================
struct InstChunk
{
struct Loop
{
uint16 type; // these are different in AIFF and WAV
uint16 startIdentifier;
uint16 endIdentifier;
} JUCE_PACKED;
int8 baseNote;
int8 detune;
int8 lowNote;
int8 highNote;
int8 lowVelocity;
int8 highVelocity;
int16 gain;
Loop sustainLoop;
Loop releaseLoop;
void copyTo (std::map<String, String>& values) const
{
values.emplace ("MidiUnityNote", String (baseNote));
values.emplace ("Detune", String (detune));
values.emplace ("LowNote", String (lowNote));
values.emplace ("HighNote", String (highNote));
values.emplace ("LowVelocity", String (lowVelocity));
values.emplace ("HighVelocity", String (highVelocity));
values.emplace ("Gain", String ((int16) ByteOrder::swapIfLittleEndian ((uint16) gain)));
values.emplace ("NumSampleLoops", String (2)); // always 2 with AIFF, WAV can have more
values.emplace ("Loop0Type", String (ByteOrder::swapIfLittleEndian (sustainLoop.type)));
values.emplace ("Loop0StartIdentifier", String (ByteOrder::swapIfLittleEndian (sustainLoop.startIdentifier)));
values.emplace ("Loop0EndIdentifier", String (ByteOrder::swapIfLittleEndian (sustainLoop.endIdentifier)));
values.emplace ("Loop1Type", String (ByteOrder::swapIfLittleEndian (releaseLoop.type)));
values.emplace ("Loop1StartIdentifier", String (ByteOrder::swapIfLittleEndian (releaseLoop.startIdentifier)));
values.emplace ("Loop1EndIdentifier", String (ByteOrder::swapIfLittleEndian (releaseLoop.endIdentifier)));
}
static uint16 getValue16 (const StringPairArray& values, const char* name, const char* def)
{
return ByteOrder::swapIfLittleEndian ((uint16) values.getValue (name, def).getIntValue());
}
static int8 getValue8 (const StringPairArray& values, const char* name, const char* def)
{
return (int8) values.getValue (name, def).getIntValue();
}
static void create (MemoryBlock& block, const StringPairArray& values)
{
if (values.getAllKeys().contains ("MidiUnityNote", true))
{
block.setSize ((sizeof (InstChunk) + 3) & ~(size_t) 3, true);
auto& inst = *static_cast<InstChunk*> (block.getData());
inst.baseNote = getValue8 (values, "MidiUnityNote", "60");
inst.detune = getValue8 (values, "Detune", "0");
inst.lowNote = getValue8 (values, "LowNote", "0");
inst.highNote = getValue8 (values, "HighNote", "127");
inst.lowVelocity = getValue8 (values, "LowVelocity", "1");
inst.highVelocity = getValue8 (values, "HighVelocity", "127");
inst.gain = (int16) getValue16 (values, "Gain", "0");
inst.sustainLoop.type = getValue16 (values, "Loop0Type", "0");
inst.sustainLoop.startIdentifier = getValue16 (values, "Loop0StartIdentifier", "0");
inst.sustainLoop.endIdentifier = getValue16 (values, "Loop0EndIdentifier", "0");
inst.releaseLoop.type = getValue16 (values, "Loop1Type", "0");
inst.releaseLoop.startIdentifier = getValue16 (values, "Loop1StartIdentifier", "0");
inst.releaseLoop.endIdentifier = getValue16 (values, "Loop1EndIdentifier", "0");
}
}
} JUCE_PACKED;