Пример #1
0
        //TODO: change all of this to byter calls
        /// <summary>
        /// </summary>
        public static WaveChunk MakeFMT(uint dwSize)
        {
            if (dwSize < 16)
            {
                dwSize = 16;                     // dwSize Is 16 Or Else More If Has Extra
            }
            if (dwSize > 0xFFFF + 18)
            {
                dwSize = 0xFFFF + 18;                          //TODO: fix this??
            }
            if (dwSize % 2 == 1)
            {
                dwSize++;                         //add padding for required word-alignment
            }
            WaveChunk chunkNew = new WaveChunk();

            chunkNew.sID    = "fmt ";
            chunkNew.dwSize = dwSize;
            if (dwSize > 18)
            {
                chunkNew.wExtra    = (ushort)(dwSize - 18);
                chunkNew.byarrData = new byte[(int)chunkNew.wExtra];
            }
            else
            {
                chunkNew.wExtra     = 0;
                chunkNew.byarrExtra = null;
            }
            return(chunkNew);
        }
Пример #2
0
        /// <summary>
        /// </summary>
        public static WaveChunk MakeSLNT(uint dwSilentSamples)
        {
            WaveChunk chunkNew = new WaveChunk();

            chunkNew.sID             = "slnt";
            chunkNew.dwSize          = 4;
            chunkNew.dwSilentSamples = dwSilentSamples;
            return(chunkNew);
        }
Пример #3
0
        /// <summary>
        /// </summary>
        public static WaveChunk MakeRIFF(uint dwFileSizeMinus8)
        {
            WaveChunk chunkNew = new WaveChunk();

            chunkNew.sID    = "RIFF";
            chunkNew.dwSize = dwFileSizeMinus8;
            //chunkNew.sRiffType="WAVE";
            return(chunkNew);
        }
Пример #4
0
        /// <summary>
        /// Only contains format-dependent data for compressed wave files.
        /// NOT required unless Wave file is compressed.
        /// </summary>
        public static WaveChunk MakeFACT(uint dwSize, uint dwSamples)
        {
            /*
             * A fact chunk stores compression code dependant information
             * about the contents of the Wave file. It is required by all
             * compressed WAVE formats and if the waveform data is contained
             * inside a "wavl" LIST chunk, but is not required for the
             * uncompressed PCM WAVE format files (compression code 1) that
             * contain the waveform data inside a "data" chunk.
             *
             *                                               -The Sonic Spot
             */
            WaveChunk chunkNew = new WaveChunk();

            chunkNew.sID    = "fact";
            chunkNew.dwSize = dwSize;
            return(chunkNew);
        }
Пример #5
0
        /// <summary>
        ///  A wave list chunk is used to specify several alternating "slnt" and "data" chunks.
        ///  slnt stands for silent, and the slnt chunks are used to save space.
        /// </summary>
        public static WaveChunk MakeWAVL(int iChunks, uint[] dwSizes, bool bSilentChunkFirst)
        {
            if (iChunks == 0)
            {
                return(null);                        //TODO: report error;
            }
            if (dwSizes == null)
            {
                return(null);                           //TODO: report error;
            }
            if (iChunks != dwSizes.Length)
            {
                return(null);                                     //TODO: report error
            }
            WaveChunk chunkNew = new WaveChunk();

            chunkNew.sID         = "wavl";
            chunkNew.dwSize      = 0;     //incremented below
            chunkNew.chunkarrSub = new WaveChunk[iChunks];

            while (iChunks < 0)
            {
                if (bSilentChunkFirst)
                {
                    //TODO: finish this - silent chunk
                    bSilentChunkFirst = false;
                }
                else
                {
                    //TODO: finish this - data chunk
                    bSilentChunkFirst = true;
                }
                iChunks--;
            }
            return(chunkNew);
        }