Esempio n. 1
0
        static void Main(string[] args)
        {
            if (args.Length < 1)
            {
                Console.WriteLine("\nI will give you the estimated and exact sample lengths of MPEG audio files.\n");
                Console.WriteLine("\nUsage: scanclr <mpeg audio file list>\n\n");
                Console.WriteLine("Press any key to exit:");
                while (Console.Read() == 0)
                {
                    ;
                }

                return;
            }


            mpg123clr.mpg.ErrorCode err;

            err = mpg123.mpg123_init();

            mpg123 mp = new mpg123();

            err = mp.mpg123_new();

            mp.mpg123_param(mpg123clr.mpg.parms.resync_limit, -1, 0);

            foreach (string name in args)
            {
                err = mp.mpg123_open(name);

                long a, b;

                a = mp.mpg123_length();

                mp.mpg123_scan();

                b = mp.mpg123_length();

                mp.mpg123_close();

                Console.WriteLine(string.Format("File {0}: estimated {1} vs. scanned {2}", name, a, b));
            }

            Console.WriteLine("\nPress any key to exit:");
            while (Console.Read() == 0)
            {
                ;
            }

            mp.Dispose();

            mpg123.mpg123_exit();
        }
Esempio n. 2
0
        static void Main(string[] args)
        {
            if (args.Length < 1)
            {
                Console.WriteLine("\nI will give you the estimated and exact sample lengths of MPEG audio files.\n");
                Console.WriteLine("\nUsage: scanclr <mpeg audio file list>\n\n");
                Console.WriteLine("Press any key to exit:");
                while (Console.Read() == 0) ;

                return;
            }


            mpg123clr.mpg.ErrorCode err;

            err = mpg123.mpg123_init();

            mpg123 mp = new mpg123();
            err = mp.mpg123_new();

            mp.mpg123_param(mpg123clr.mpg.parms.resync_limit, -1, 0);

            foreach (string name in args)
            {

                err = mp.mpg123_open(name);

                long a, b;

                a = mp.mpg123_length();

                mp.mpg123_scan();

                b = mp.mpg123_length();

                mp.mpg123_close();

                Console.WriteLine(string.Format("File {0}: estimated {1} vs. scanned {2}", name, a, b));
            }

            Console.WriteLine("\nPress any key to exit:");
            while (Console.Read() == 0) ;

            mp.Dispose();

            mpg123.mpg123_exit();
        }
Esempio n. 3
0
        static unsafe void RunFrameByFrameTest(string filename)
        {
            mpg123clr.mpg.ErrorCode err;

            mpg123 mp = new mpg123();
            err = mp.mpg123_new();

            err = mp.mpg123_open(filename);

            if (err != mpg123clr.mpg.ErrorCode.ok)
            {
                Console.WriteLine("Error: " + mp.mpg123_strerror());
            }
            else
            {
                Console.WriteLine("Open:");

                // Show available decoders
                string[] Decoders = mp.mpg123_decoders();

                if (Decoders.Length > 0)
                {
                    Console.WriteLine("\nDecoders:");
                    foreach (string str in Decoders) Console.WriteLine(str);
                }

                // Show supported decoders
                string[] supDecoders = mp.mpg123_supported_decoders();

                if (supDecoders.Length > 0)
                {
                    Console.WriteLine("\nSupported Decoders:");
                    foreach (string str in supDecoders) Console.WriteLine(str);
                }

                // Show actual decoder
                Console.WriteLine("\nDecoder: " + mp.mpg123_current_decoder());

                // Show estimated file length
                Console.WriteLine("\nLength Estimate: " + mp.mpg123_length().ToString());

                // Scan - gets actual details including ID3v2 and Frame offsets
                err = mp.mpg123_scan();

                // Show actual file length
                if (err == mpg123clr.mpg.ErrorCode.ok) Console.WriteLine("Length Actual  : " + mp.mpg123_length().ToString());

                // Get ID3 data
                mpg123clr.id3.mpg123id3v1 iv1;
                mpg123clr.id3.mpg123id3v2 iv2;
                err = mp.mpg123_id3(out iv1, out iv2);

                // Show ID3v2 data
                Console.WriteLine("\nTitle  : " + iv2.title);
                Console.WriteLine("Artist : " + iv2.artist);
                Console.WriteLine("Album  : " + iv2.album);
                Console.WriteLine("Comment: " + iv2.comment);
                Console.WriteLine("Year   : " + iv2.year);

                // Demo seek (back to start of file - note: scan should already have done this)
                long pos = mp.mpg123_seek(0, System.IO.SeekOrigin.Begin);

                long[] frameindex;
                long step;
                err = mp.mpg123_index(out frameindex, out step);

                if (err == mpg123clr.mpg.ErrorCode.ok)
                {
                    Console.WriteLine("\nFrameIndex:");
                    foreach (long idx in frameindex)
                    {
                        // Console.WriteLine(idx.ToString());
                    }
                }

                int num;
                uint cnt;
                IntPtr audio;

                // Walk the file - effectively decode the data without using it...
                Console.WriteLine("\nFrame Walking  : " + iv2.title);
                DateTime dte, dts = DateTime.Now;

                while (err == mpg123clr.mpg.ErrorCode.ok || err == mpg123clr.mpg.ErrorCode.new_format)
                {
                    err = mp.mpg123_framebyframe_decode(out num, out audio, out cnt);
                    err = mp.mpg123_framebyframe_next();

                    // do something with "audio" here....
                }

                dte = DateTime.Now;

                TimeSpan ts = dte - dts;
                Console.WriteLine("Duration:  " + ts.ToString());

                mp.mpg123_close();
            }

            mp.Dispose();

        }
Esempio n. 4
0
        static unsafe void RunFrameByFrameTest(string filename)
        {
            mpg123clr.mpg.ErrorCode err;

            mpg123 mp = new mpg123();

            err = mp.mpg123_new();

            err = mp.mpg123_open(filename);

            if (err != mpg123clr.mpg.ErrorCode.ok)
            {
                Console.WriteLine("Error: " + mp.mpg123_strerror());
            }
            else
            {
                Console.WriteLine("Open:");

                // Show available decoders
                string[] Decoders = mp.mpg123_decoders();

                if (Decoders.Length > 0)
                {
                    Console.WriteLine("\nDecoders:");
                    foreach (string str in Decoders)
                    {
                        Console.WriteLine(str);
                    }
                }

                // Show supported decoders
                string[] supDecoders = mp.mpg123_supported_decoders();

                if (supDecoders.Length > 0)
                {
                    Console.WriteLine("\nSupported Decoders:");
                    foreach (string str in supDecoders)
                    {
                        Console.WriteLine(str);
                    }
                }

                // Show actual decoder
                Console.WriteLine("\nDecoder: " + mp.mpg123_current_decoder());

                // Show estimated file length
                Console.WriteLine("\nLength Estimate: " + mp.mpg123_length().ToString());

                // Scan - gets actual details including ID3v2 and Frame offsets
                err = mp.mpg123_scan();

                // Show actual file length
                if (err == mpg123clr.mpg.ErrorCode.ok)
                {
                    Console.WriteLine("Length Actual  : " + mp.mpg123_length().ToString());
                }

                // Get ID3 data
                mpg123clr.id3.mpg123id3v1 iv1;
                mpg123clr.id3.mpg123id3v2 iv2;
                err = mp.mpg123_id3(out iv1, out iv2);

                // Show ID3v2 data
                Console.WriteLine("\nTitle  : " + iv2.title);
                Console.WriteLine("Artist : " + iv2.artist);
                Console.WriteLine("Album  : " + iv2.album);
                Console.WriteLine("Comment: " + iv2.comment);
                Console.WriteLine("Year   : " + iv2.year);

                // Demo seek (back to start of file - note: scan should already have done this)
                long pos = mp.mpg123_seek(0, System.IO.SeekOrigin.Begin);

                long[] frameindex;
                long   step;
                err = mp.mpg123_index(out frameindex, out step);

                if (err == mpg123clr.mpg.ErrorCode.ok)
                {
                    Console.WriteLine("\nFrameIndex:");
                    foreach (long idx in frameindex)
                    {
                        // Console.WriteLine(idx.ToString());
                    }
                }

                int    num;
                uint   cnt;
                IntPtr audio;

                // Walk the file - effectively decode the data without using it...
                Console.WriteLine("\nFrame Walking  : " + iv2.title);
                DateTime dte, dts = DateTime.Now;

                while (err == mpg123clr.mpg.ErrorCode.ok || err == mpg123clr.mpg.ErrorCode.new_format)
                {
                    err = mp.mpg123_framebyframe_decode(out num, out audio, out cnt);
                    err = mp.mpg123_framebyframe_next();

                    // do something with "audio" here....
                }

                dte = DateTime.Now;

                TimeSpan ts = dte - dts;
                Console.WriteLine("Duration:  " + ts.ToString());

                mp.mpg123_close();
            }

            mp.Dispose();
        }