Package org.apache.flex.swf.tags

Examples of org.apache.flex.swf.tags.DefineSoundTag


        final int soundSize = bitStream.readUB(1);
        final int soundType = bitStream.readUB(1);
        final long soundSampleCount = bitStream.readUI32();
        final byte soundData[] = bitStream.readToBoundary();

        final DefineSoundTag tag = new DefineSoundTag();
        tag.setCharacterID(soundId);
        tag.setSoundFormat(soundFormat);
        tag.setSoundRate(soundRate);
        tag.setSoundSize(soundSize);
        tag.setSoundType(soundType);
        tag.setSoundSampleCount(soundSampleCount);
        tag.setSoundData(soundData);
        return tag;
    }
View Full Code Here


    {
        InputStream strm = getDataStream(problems);       
        if (strm == null)
            return null;

        DefineSoundTag assetTag = buildSound(strm, problems);
        if (assetTag == null)
            return null;

        Map<String, ICharacterTag> symbolTags = Collections.singletonMap(data.getQName(), (ICharacterTag)assetTag);
        return symbolTags;
View Full Code Here

    {
        byte[] soundData = readFully(strm);
        if (soundData == null)
            return null;

        DefineSoundTag tag = new DefineSoundTag();
        tag.setSoundData(soundData);

        tag.setSoundFormat(2); // MP3
        tag.setSoundSize(1); // always 16-bit for compressed formats

        /**
         * 0 - version 2.5
         * 1 - reserved
         * 2 - version 2
         * 3 - version 1
         */
        int version = soundData[3] >> 3 & 0x3;

        /**
         * 0 - reserved
         * 1 - layer III => 1152 samples
         * 2 - layer II  => 1152 samples
         * 3 - layer I   => 384  samples
         */
        int layer = soundData[3] >> 1 & 0x3;

        int samplingRate = soundData[4] >> 2 & 0x3;

        /**
         * 0 - stereo
         * 1 - joint stereo
         * 2 - dual channel
         * 3 - single channel
         */
        int channelMode = soundData[5] >> 6 & 0x3;

        int frequency = mp3frequencies[samplingRate][version];

        /**
         * 1 - 11kHz
         * 2 - 22kHz
         * 3 - 44kHz
         */
        int rate;
        switch (frequency)
        {
        case 11025:
            rate = 1;
            break;
        case 22050:
            rate = 2;
            break;
        case 44100:
            rate = 3;
            break;
        default:
            problems.add(new EmbedUnsupportedSamplingRateProblem(data, frequency));
            return null;
        }
        tag.setSoundRate(rate);

        /**
         * 0 - mono
         * 1 - stereo
         */
        tag.setSoundType(channelMode == 3 ? 0 : 1);

        /**
         * assume that the whole thing plays in one SWF frame
         *
         * sample count = number of MP3 frames * number of samples per MP3
         */
        long sampleCount = countFrames(soundData) * (layer == 3 ? 384 : 1152);
        tag.setSoundSampleCount(sampleCount);

        if (sampleCount < 0)
        {
            // frame count == -1, error!
            problems.add(new EmbedCouldNotDetermineSampleFrameCountProblem(data));
View Full Code Here

TOP

Related Classes of org.apache.flex.swf.tags.DefineSoundTag

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.