예제 #1
0
        private static void runTest()
        {
            uint major, minor, patch;

            DynamicAudioNormalizerNET.getVersionInfo(out major, out minor, out patch);
            Console.WriteLine("Library Version {0}.{1}-{2}", major.ToString(), minor.ToString("D2"), minor, patch.ToString());

            String date, time, compiler, arch; bool debug;

            DynamicAudioNormalizerNET.getBuildInfo(out date, out time, out compiler, out arch, out debug);
            Console.WriteLine("Date: {0}, Time: {1}, Compiler: {2}, Arch: {3}, {4}", date, time, compiler, arch, debug ? "DEBUG" : "Release");

            DynamicAudioNormalizerNET.setLogger(delegate(int level, String message)
            {
                switch (level)
                {
                case  0: Console.WriteLine("[DynAudNorm][DBG] " + message); break;

                case  1: Console.WriteLine("[DynAudNorm][WRN] " + message); break;

                case  2: Console.WriteLine("[DynAudNorm][ERR] " + message); break;

                default: Console.WriteLine("[DynAudNorm][???] " + message); break;
                }
            });

            using (DynamicAudioNormalizerNET instance = new DynamicAudioNormalizerNET(2, 44100, 500, 31, 0.95, 10.0, 0.0, 0.0, true, false, false))
            {
                using (SampleReader reader = new SampleReader("Input.pcm"))
                {
                    using (SampleWriter writer = new SampleWriter("Output.pcm"))
                    {
                        uint channels, sampleRate, frameLen, filterSize;
                        instance.getConfiguration(out channels, out sampleRate, out frameLen, out filterSize);
                        Console.WriteLine("channels: " + channels.ToString());
                        Console.WriteLine("sampleRate: " + sampleRate.ToString());
                        Console.WriteLine("frameLen: " + frameLen.ToString());
                        Console.WriteLine("filterSize: " + filterSize.ToString());

                        long internalDelay = instance.getInternalDelay();
                        Console.WriteLine("internalDelay: " + internalDelay.ToString());

                        process(reader, writer, instance);
                    }
                }
            }
        }
예제 #2
0
        private static void process(SampleReader reader, SampleWriter writer, DynamicAudioNormalizerNET instance)
        {
            double[,] data = new double[2, 4096];

            Console.WriteLine("Processing audio samples in-place...");
            for (;;)
            {
                int inputSamples = reader.read(data);
                if (inputSamples > 0)
                {
                    int outputSamples = (int)instance.processInplace(data, inputSamples);
                    if (outputSamples > 0)
                    {
                        writer.write(data, outputSamples);
                    }
                }
                if (inputSamples < data.GetLength(1))
                {
                    break; /*EOF*/
                }
            }

            Console.WriteLine("Flushing remaining samples from buffer...");
            for (;;)
            {
                int outputSamples = (int)instance.flushBuffer(data);
                if (outputSamples > 0)
                {
                    writer.write(data, outputSamples);
                }
                if (outputSamples < 1)
                {
                    break; /*EOF*/
                }
            }

            Console.WriteLine("Resetting the normalizer instance...");
            instance.reset(); //Just for testing, this NOT actually required here!

            Console.WriteLine("Finished.");
        }
        private static void process(SampleReader reader, SampleWriter writer, DynamicAudioNormalizerNET instance)
        {
            double[,] data = new double[2, 4096];

            Console.WriteLine("Processing audio samples in-place...");
            for(;;)
            {
                int inputSamples = reader.read(data);
                if(inputSamples > 0)
                {
                    int outputSamples = (int)instance.processInplace(data, inputSamples);
                    if(outputSamples > 0)
                    {
                        writer.write(data, outputSamples);
                    }
                }
                if(inputSamples < data.GetLength(1))
                {
                    break; /*EOF*/
                }
            }

            Console.WriteLine("Flushing remaining samples from buffer...");
            for(;;)
            {
                int outputSamples = (int) instance.flushBuffer(data);
                if (outputSamples > 0)
                {
                    writer.write(data, outputSamples);
                }
                if (outputSamples < 1)
                {
                    break; /*EOF*/
                }
            }

            Console.WriteLine("Resetting the normalizer instance...");
            instance.reset(); //Just for testing, this NOT actually required here!

            Console.WriteLine("Finished.");
        }
        private static void runTest()
        {
            uint major, minor, patch;
            DynamicAudioNormalizerNET.getVersionInfo(out major, out minor, out patch);
            Console.WriteLine("Library Version {0}.{1}-{2}", major.ToString(), minor.ToString("D2"), minor, patch.ToString());

            String date, time, compiler, arch; bool debug;
            DynamicAudioNormalizerNET.getBuildInfo(out date, out time, out compiler, out arch, out debug);
            Console.WriteLine("Date: {0}, Time: {1}, Compiler: {2}, Arch: {3}, {4}", date, time, compiler, arch, debug ? "DEBUG" : "Release");

            DynamicAudioNormalizerNET.setLogger(delegate(int level, String message)
            {
                switch (level)
                {
                    case  0: Console.WriteLine("[DynAudNorm][DBG] " + message); break;
                    case  1: Console.WriteLine("[DynAudNorm][WRN] " + message); break;
                    case  2: Console.WriteLine("[DynAudNorm][ERR] " + message); break;
                    default: Console.WriteLine("[DynAudNorm][???] " + message); break;
                }
            });

            using(DynamicAudioNormalizerNET instance = new DynamicAudioNormalizerNET(2, 44100, 500, 31, 0.95, 10.0, 0.0, 0.0, true, false, false))
            {
                using (SampleReader reader = new SampleReader("Input.pcm"))
                {
                    using (SampleWriter writer = new SampleWriter("Output.pcm"))
                    {
                        uint channels, sampleRate, frameLen, filterSize;
                        instance.getConfiguration(out channels, out sampleRate, out frameLen, out filterSize);
                        Console.WriteLine("channels: " + channels.ToString());
                        Console.WriteLine("sampleRate: " + sampleRate.ToString());
                        Console.WriteLine("frameLen: " + frameLen.ToString());
                        Console.WriteLine("filterSize: " + filterSize.ToString());

                        long internalDelay = instance.getInternalDelay();
                        Console.WriteLine("internalDelay: " + internalDelay.ToString());

                        process(reader, writer, instance);
                    }
                }
            }
        }