Exemple #1
0
void create (MemoryBlock& block, const StringPairArray& values)
{
    const int numNotes = values.getValue ("NumCueNotes", "0").getIntValue();

    if (numNotes > 0)
    {
        MemoryOutputStream out (block, false);
        out.writeShortBigEndian ((short) numNotes);

        for (int i = 0; i < numNotes; ++i)
        {
            const String prefix ("CueNote" + String (i));

            out.writeIntBigEndian (values.getValue (prefix + "TimeStamp", "0").getIntValue());
            out.writeShortBigEndian ((short) values.getValue (prefix + "Identifier", "0").getIntValue());

            const String comment (values.getValue (prefix + "Text", String::empty));
            out.write (comment.toUTF8(), jmin (comment.getNumBytesAsUTF8(), 65534));
            out.writeByte (0);

            if ((out.getDataSize() & 1) != 0)
                out.writeByte (0);
        }
    }
}
        static void create (MemoryBlock& block, const StringPairArray& values)
        {
            auto numNotes = values.getValue ("NumCueNotes", "0").getIntValue();

            if (numNotes > 0)
            {
                MemoryOutputStream out (block, false);
                out.writeShortBigEndian ((short) numNotes);

                for (int i = 0; i < numNotes; ++i)
                {
                    auto prefix = "CueNote" + String (i);

                    out.writeIntBigEndian (values.getValue (prefix + "TimeStamp", "0").getIntValue());
                    out.writeShortBigEndian ((short) values.getValue (prefix + "Identifier", "0").getIntValue());

                    auto comment = values.getValue (prefix + "Text", String());
                    auto commentLength = jmin (comment.getNumBytesAsUTF8(), (size_t) 65534);

                    out.writeShortBigEndian ((short) commentLength + 1);
                    out.write (comment.toUTF8(), commentLength);
                    out.writeByte (0);

                    if ((out.getDataSize() & 1) != 0)
                        out.writeByte (0);
                }
            }
        }
Exemple #3
0
bool metaDataContainsZeroIdentifiers (const StringPairArray& values)
{
    // (zero cue identifiers are valid for WAV but not for AIFF)
    const String cueString ("Cue");
    const String noteString ("CueNote");
    const String identifierString ("Identifier");

    const StringArray& keys = values.getAllKeys();

    for (int i = 0; i < keys.size(); ++i)
    {
        const String key (keys[i]);

        if (key.startsWith (noteString))
            continue; // zero identifier IS valid in a COMT chunk

        if (key.startsWith (cueString) && key.contains (identifierString))
        {
            const int value = values.getValue (key, "-1").getIntValue();

            if (value == 0)
                return true;
        }
    }

    return false;
}
    void addMetadataArg (const StringPairArray& metadata, const char* key, const char* lameFlag)
    {
        const String value (metadata.getValue (key, String::empty));

        if (value.isNotEmpty())
        {
            args.add (lameFlag);
            args.add (value);
        }
    }
Exemple #5
0
bool SFZSample::load(AudioFormatManager* formatManager)
{
	AudioFormatReader* reader = formatManager->createReaderFor(file);
	if (reader == NULL)
		return false;
	sampleRate = reader->sampleRate;
	sampleLength = reader->lengthInSamples;
	// Read some extra samples, which will be filled with zeros, so interpolation
	// can be done without having to check for the edge all the time.
	buffer = new AudioSampleBuffer(reader->numChannels, sampleLength + 4);
	reader->read(buffer, 0, sampleLength + 4, 0, true, true);
	StringPairArray* metadata = &reader->metadataValues;
	int numLoops = metadata->getValue("NumSampleLoops", "0").getIntValue();
	if (numLoops > 0) {
		loopStart = metadata->getValue("Loop0Start", "0").getLargeIntValue();
		loopEnd = metadata->getValue("Loop0End", "0").getLargeIntValue();
		}
	delete reader;
	return true;
}
Exemple #6
0
void create (MemoryBlock& block, const StringPairArray& values)
{
    const int numCues = values.getValue ("NumCuePoints", "0").getIntValue();

    if (numCues > 0)
    {
        MemoryOutputStream out (block, false);

        out.writeShortBigEndian ((short) numCues);

        const int numCueLabels = values.getValue ("NumCueLabels", "0").getIntValue();
        const int idOffset = metaDataContainsZeroIdentifiers (values) ? 1 : 0; // can't have zero IDs in AIFF

#if JUCE_DEBUG
        Array<int> identifiers;
#endif

        for (int i = 0; i < numCues; ++i)
        {
            const String prefixCue ("Cue" + String (i));
            const int identifier = idOffset + values.getValue (prefixCue + "Identifier", "1").getIntValue();

#if JUCE_DEBUG
            jassert (! identifiers.contains (identifier));
            identifiers.add (identifier);
#endif

            const int offset = values.getValue (prefixCue + "Offset", "0").getIntValue();
            String label ("CueLabel" + String (i));

            for (int labelIndex = 0; labelIndex < numCueLabels; ++labelIndex)
            {
                const String prefixLabel ("CueLabel" + String (labelIndex));
                const int labelIdentifier = idOffset + values.getValue (prefixLabel + "Identifier", "1").getIntValue();

                if (labelIdentifier == identifier)
                {
                    label = values.getValue (prefixLabel + "Text", label);
                    break;
                }
            }

            out.writeShortBigEndian ((short) identifier);
            out.writeIntBigEndian (offset);

            const int labelLength = jmin (254, label.getNumBytesAsUTF8()); // seems to need null terminator even though it's a pstring
            out.writeByte ((char) labelLength + 1);
            out.write (label.toUTF8(), labelLength);
            out.writeByte (0);
        }

        if ((out.getDataSize() & 1) != 0)
            out.writeByte (0);
    }
}
Exemple #7
0
    static void create (MemoryBlock& block, const StringPairArray& values)
    {
        if (values.getAllKeys().contains ("MidiUnityNote", true))
        {
            block.setSize ((sizeof (InstChunk) + 3) & ~3, true);
            InstChunk* const inst = static_cast <InstChunk*> (block.getData());

            inst->baseNote      = (int8) values.getValue ("MidiUnityNote", "60").getIntValue();
            inst->detune        = (int8) values.getValue ("Detune", "0").getIntValue();
            inst->lowNote       = (int8) values.getValue ("LowNote", "0").getIntValue();
            inst->highNote      = (int8) values.getValue ("HighNote", "127").getIntValue();
            inst->lowVelocity   = (int8) values.getValue ("LowVelocity", "1").getIntValue();
            inst->highVelocity  = (int8) values.getValue ("HighVelocity", "127").getIntValue();
            inst->gain          = (int16) ByteOrder::swapIfLittleEndian ((uint16) values.getValue ("Gain", "0").getIntValue());

            inst->sustainLoop.type              = ByteOrder::swapIfLittleEndian ((uint16) values.getValue ("Loop0Type", "0").getIntValue());
            inst->sustainLoop.startIdentifier   = ByteOrder::swapIfLittleEndian ((uint16) values.getValue ("Loop0StartIdentifier", "0").getIntValue());
            inst->sustainLoop.endIdentifier     = ByteOrder::swapIfLittleEndian ((uint16) values.getValue ("Loop0EndIdentifier", "0").getIntValue());
            inst->releaseLoop.type              = ByteOrder::swapIfLittleEndian ((uint16) values.getValue ("Loop1Type", "0").getIntValue());
            inst->releaseLoop.startIdentifier   = ByteOrder::swapIfLittleEndian ((uint16) values.getValue ("Loop1StartIdentifier", "0").getIntValue());
            inst->releaseLoop.endIdentifier     = ByteOrder::swapIfLittleEndian ((uint16) values.getValue ("Loop1EndIdentifier", "0").getIntValue());
        }
    }