Beispiel #1
0
        public MusicAiff(FormFile aFormFile)
        {
            FormChunkListAiff lAiffForm = ( FormChunkListAiff )aFormFile.formChunkList;

            FormChunkSsnd lSsndChunk = lAiffForm.chunkSsnd;

            name = aFormFile.name;
            int position = ( int )lSsndChunk.position;
            int length   = lSsndChunk.dataSize;

            FormChunkComm lChunkComm = lAiffForm.chunkComm;

            Channels     = lChunkComm.numberOfChannels;
            SampleRate   = ( int )lChunkComm.sampleRate;
            sampleBits   = lChunkComm.bitsPerSamples;
            SampleLength = length / (sampleBits / 8) / Channels;

            sampleMeanArray = new float[SampleLength];

            if (name != null)
            {
                using (FileStream u = new FileStream(name, FileMode.Open, FileAccess.Read))
                {
                    ByteArray lByteArray = new ByteArrayBig(u);

                    lByteArray.SetPosition(position);

                    for (int i = 0; i < SampleLength; i++)
                    {
                        float value = 0.0f;

                        for (int j = 0; j < Channels; j++)
                        {
                            if (sampleBits == 16)
                            {
                                value += ( float )lByteArray.ReadInt16() / ( float )0x8000;
                            }
                            else if (sampleBits == 24)
                            {
                                value += ( float )lByteArray.ReadInt24() / ( float )0x800000;
                            }
                        }

                        sampleMeanArray[i] = value / Channels;
                    }
                }
            }

            int lSampleLoopStart = 0;
            int lSampleLoopEnd   = 0;

            Loop = new List <List <LoopInformation> >();
            Loop.Add(new List <LoopInformation>());
            Loop[0].Add(new LoopInformation(SampleRate, lSampleLoopStart, lSampleLoopEnd));
        }
Beispiel #2
0
        public WaveformAiff(FormFile aFormFile)
            : base()
        {
            FormChunkListAiff aAiffForm = ( FormChunkListAiff )aFormFile.formChunkList;

            FormChunkSsnd lSsndChunk = aAiffForm.chunkSsnd;
            int           lPosition  = ( int )lSsndChunk.position;
            int           lLength    = lSsndChunk.dataSize;

            FormChunkComm lChunkComm  = aAiffForm.chunkComm;
            int           lChannels   = lChunkComm.numberOfChannels;
            int           lSampleRate = ( int )lChunkComm.sampleRate;
            int           lSampleBits = lChunkComm.bitsPerSamples;
            int           lSamples    = lLength / (lSampleBits / 8) / lChannels;

            format = new FormatWaweform(lChannels, lSamples, lSampleRate, lSampleBits);
            data   = new WaveformData(format, null, aFormFile.name, lPosition);
        }