Esempio n. 1
0
        static unsafe void FixedSizeBuffers_Test()
        {
            var a1 = new SB()
            {
                arr = new int[5]
            };
            var a2 = new FSB();

            Print.Address((long)&a2);
            Print.Address((long)a2.arr);
            Print.Address((long)&a2.arr);//数组指针变量的地址
            Print.Address((long)&a2.x);

            //Console.WriteLine(sizeof(SB));//SB作为托管类型不能计算大小
            Console.WriteLine(sizeof(FSB));
        }
Esempio n. 2
0
        public void CreateFromFSB(FormatData data, Stream[] fsbstreams, AudioFormat format)
        {
            List <Stream> streams = new List <Stream>();

            foreach (Stream stream in fsbstreams)
            {
                FSB fsb = new FSB(stream);
                foreach (FSB.Sample sample in fsb.Samples)
                {
                    if (sample.Channels <= 2)
                    {
                        streams.Add(sample.Data);
                        continue;
                    }

                    byte[] buffer = new byte[0x04];
                    sample.Data.Position = 0;
                    Stream[] samples = new Stream[sample.Channels];
                    for (int i = 0; i < sample.Channels; i++)
                    {
                        samples[i] = new TemporaryStream();
                        streams.Add(samples[i]);
                    }
                    int channel = -1;
                    while (!sample.Data.EOF())
                    {
                        sample.Data.Read(buffer, 0, 4);
                        try {
                            Mp3.Header header = new Mp3.Header(buffer);
                            channel = (channel + 1) % sample.Channels;
                        } catch (FormatException) { }

                        samples[channel].Write(buffer);
                    }
                }
            }

            Create(data, streams.ToArray(), format);
        }