コード例 #1
0
ファイル: indexer-2.cs プロジェクト: ruo2012/samples-1
    static void Main()
    {
        var stringCollection = new SampleCollection <string>();

        stringCollection.Add("Hello, World");
        System.Console.WriteLine(stringCollection[0]);
    }
コード例 #2
0
        internal SampleCollection Convert(SampleCollection input)
        {
            Contract.Requires(input != null);
            Contract.Ensures(Contract.Result <SampleCollection>() != null);
            Contract.Ensures(Contract.Result <SampleCollection>().SampleCount == input.SampleCount / _divisor);

            if (_divisor == 1 || input.IsLast)
            {
                return(input);
            }

            SampleCollection result = SampleCollectionFactory.Instance.Create(input.Channels,
                                                                              input.SampleCount / _divisor);

            for (var channel = 0; channel < input.Channels; channel++)
            {
                for (int resultSample = 0, inputSample = 0;
                     resultSample < result.SampleCount;
                     resultSample++, inputSample += _divisor)
                {
                    result[channel][resultSample] = input[channel][inputSample];
                }
            }

            SampleCollectionFactory.Instance.Free(input);

            return(result);
        }
コード例 #3
0
        // 如需統合的詳細資訊,請瀏覽 https://go.microsoft.com/fwlink/?LinkId=301862
        public static void RegisterBundles(BundleCollection bundles)
        {
            //bundles.Add(new ScriptBundle("~/bundles/jquery").Include(
            //            "~/Scripts/jquery-{version}.js"));

            // 使用開發版本的 Modernizr 進行開發並學習。然後,當您
            // 準備好可進行生產時,請使用 https://modernizr.com 的建置工具,只挑選您需要的測試。
            //bundles.Add(new ScriptBundle("~/bundles/modernizr").Include(
            //            "~/Scripts/modernizr-*"));

            //bundles.Add(new ScriptBundle("~/bundles/bootstrap").Include(
            //          "~/Scripts/bootstrap.js"));

            //bundles.Add(new StyleBundle("~/Content/css").Include(
            //          "~/Content/bootstrap.css",
            //          "~/Content/site.css"));

            bundles.Add(new ScriptBundle("~/bundles/jqueryval").Include(
                            "~/Scripts/jquery.validate*"));

            //首頁 JS & CSS
            HomeCollection.Initial(bundles);

            //BackEndSystem JS & CSS設定檔
            BackEndSystemCollection.Initial(bundles);

            //原始 MiniShop & ElaAdmin JS CSS
            SampleCollection.Initial(bundles);

            //壓縮
            //BundleTable.EnableOptimizations = true;
        }
コード例 #4
0
 /// <summary>
 /// Iteration is the number of the virtual head.
 /// If the flattening algorithm is being used for the first time,
 /// the virtual heads should all be 1s (as in 1 level down).
 /// Second Time -> 2s
 /// etc.
 /// </summary>
 /// <param name="iter"></param>
 public Flattener(TuringMachine tf, int iteration = 1)
 {
     ITERATION = iteration;
     SymMap    = new SampleCollection(ITERATION);
     NUM_TAPES = tf.TransitionFunctions.First().DomainHeadValues.Count;
     TM        = tf;
 }
コード例 #5
0
        public SampleCollection DecodeSamples()
        {
            Contract.Ensures(Contract.Result <SampleCollection>() != null);

            while (_decoder.GetState() != DecoderState.EndOfStream)
            {
                if (!_decoder.ProcessSingle())
                {
                    throw new IOException(string.Format(CultureInfo.CurrentCulture, Resources.SampleDecoderDecodingError,
                                                        _decoder.GetState()));
                }

                if (_decoder.Error.HasValue)
                {
                    throw new IOException(string.Format(CultureInfo.CurrentCulture, Resources.SampleDecoderDecodingError,
                                                        _decoder.Error.Value));
                }

                if (_decoder.Samples == null)
                {
                    continue;
                }

                SampleCollection result = _decoder.Samples;
                _decoder.Samples = null;
                return(result);
            }

            _decoder.Finish();
            return(SampleCollectionFactory.Instance.Create(_decoder.AudioInfo.Channels, 0));
        }
コード例 #6
0
        static void Main3(string[] args)
        {
            var stringCollection = new SampleCollection <string>();

            stringCollection[0] = "Hello, World";
            System.Console.WriteLine(stringCollection[0]);// Hello, World
        }
コード例 #7
0
        static float CalculateRms(SampleCollection samples)
        {
            Contract.Requires(samples != null);

            float sumOfSquares = samples.SelectMany(channel => channel).Sum(sample => sample * sample);

            return(10 * (float)Math.Log10(sumOfSquares / samples.SampleCount / samples.Channels));
        }
コード例 #8
0
ファイル: Program.cs プロジェクト: jkamirski/NewRepo
    static void Main()
    {
        var stringCollection = new SampleCollection <string>();

        stringCollection[0] = "Hello, World";
        Console.WriteLine(stringCollection[0]);
        Console.ReadKey();
    }
コード例 #9
0
        public static void Test()
        {
            SampleCollection <String> stringCollection = new SampleCollection <string>();
            var stringCollectionExp = new SampleCollectionExpression <string>();

            stringCollection[0]    = "hello";
            stringCollectionExp[0] = "world";
            System.Console.WriteLine(stringCollection[0] + " " + stringCollectionExp[0]);
        }
コード例 #10
0
        internal SampleCountFilter(int channels, int sampleCount)
        {
            Contract.Requires(channels > 0);
            Contract.Requires(sampleCount > 0);
            Contract.Ensures(_buffer != null);
            Contract.Ensures(_buffer.Channels == channels);
            Contract.Ensures(_buffer.SampleCount == sampleCount);

            _buffer = SampleCollectionFactory.Instance.Create(channels, sampleCount);
        }
コード例 #11
0
ファイル: Program.cs プロジェクト: SheilaTran-UCF/C.Net
        static void Main()
        {
            SampleCollection sampleCollection = new SampleCollection();

            sampleCollection[0] = 1225;
            sampleCollection[1] = 1226;
            var userName = "******";

            Console.WriteLine($"The value ={sampleCollection[1]}, va username={userName}");
        }
コード例 #12
0
        public static void TestIndexator()
        {
            // Индексаторы позволяют индексировать экземпляры класса или структуры точно так же, как и массивы.Индексаторы напоминают свойства за исключением того, что их методы доступа принимают параметры.

            // Declare an instance of the SampleCollection type.
            SampleCollection <string> stringCollection = new SampleCollection <string>();

            // Use [] notation on the type.
            stringCollection[0] = "Hello, World";
            System.Console.WriteLine(stringCollection[0]);
        }
コード例 #13
0
 public static bool IsTooSmall(SampleCollection SC, int minSize)
 {
     if (SC.Samples.Count() < minSize)
     {
         return(true);
     }
     else
     {
         return(false);
     }
 }
コード例 #14
0
        internal void Submit(SampleCollection input)
        {
            Contract.Requires(input != null);
            Contract.Ensures(Peak >= 0);
            Contract.Ensures(Peak >= Contract.OldValue <float>(Peak));

            // Optimization - Faster when channels are calculated in parallel:
            Parallel.For(0, input.Channels, () => 0, (int channel, ParallelLoopState loopState, float channelMax) =>
            {
                return(input[channel].Aggregate(channelMax, (current, sample) => CompareAbsolute(sample, current)));
            }, Submit);
        }
コード例 #15
0
        public SampleCollection DecodeSamples()
        {
            Contract.Ensures(_buffer != null);
            Contract.Ensures(Contract.Result <SampleCollection>() != null);

            uint sampleCount = 4096;

            if (_buffer == null)
            {
                _buffer = new int[sampleCount * _inputDescription.ChannelsPerFrame];
            }

            GCHandle handle = GCHandle.Alloc(_buffer, GCHandleType.Pinned);

            try
            {
                var bufferList = new AudioBufferList
                {
                    NumberBuffers = 1,
                    Buffers       = new AudioBuffer[1]
                };
                bufferList.Buffers[0].NumberChannels = _inputDescription.ChannelsPerFrame;
                bufferList.Buffers[0].DataByteSize   = (uint)(_buffer.Length);
                bufferList.Buffers[0].Data           = handle.AddrOfPinnedObject();

                AudioConverterStatus status = _converter.FillBuffer(ref sampleCount, ref bufferList, null);
                if (status != AudioConverterStatus.Ok)
                {
                    throw new IOException(string.Format(CultureInfo.CurrentCulture,
                                                        Resources.LosslessSampleDecoderFillBufferError, status));
                }

                SampleCollection result =
                    SampleCollectionFactory.Instance.Create((int)_inputDescription.ChannelsPerFrame, (int)sampleCount);

                // De-interlace the output buffer into the new sample collection, converting to floating point values:
                var index = 0;
                for (var sample = 0; sample < result.SampleCount; sample++)
                {
                    for (var channel = 0; channel < result.Channels; channel++)
                    {
                        result[channel][sample] = _buffer[index++] / _divisor;
                    }
                }

                return(result);
            }
            finally
            {
                handle.Free();
            }
        }
コード例 #16
0
    static void MainMethod()
    {
        SampleCollection sc = new SampleCollection();

        sc[9] = 50;
        // Array.Fill(sc, 0);
        for (int i = 0; i < 10; ++i)
        {
            // Debug.Log(sc[i]);
        }

        // Debug.Log(sc[10]);
    }
コード例 #17
0
    static void Main()
    {
        SampleCollection col = new SampleCollection();

        // Display the collection items:
        System.Console.WriteLine("Values in the collection are:");
        foreach (int i in col.BuildCollection())
        {
            System.Console.Write(i + " ");
        }

        // Keep the console window open in debug mode.
        System.Console.WriteLine("Press any key to exit.");
        System.Console.ReadKey();
    }
コード例 #18
0
 public void GetSampleCollections()
 {
     this.CurrentSampleCollection = SampleCollection.GetSampleCollection(
         this.Name, this.LastObservedSession, this.SampleCollections);
     if (this.TrackMAD)
     {
         this.CurrentMADSampleCollection = SampleCollection.GetSampleCollection(
             $"{this.Name}_MAD", this.LastObservedSession, this.SampleCollections);
     }
     if (this.TrackOutliers)
     {
         this.CurrentOutlierSampleCollection = SampleCollection.GetSampleCollection(
             $"{this.Name}_Outliers", this.LastObservedSession, this.SampleCollections, samplesize: this.OutlierTrackingInterval, Fake: true);
     }
 }
コード例 #19
0
        public void Submit(SampleCollection samples)
        {
            if (Math.Abs(_scale - 1) < 0.001)
            {
                return;
            }

            // Optimization - Faster when channels are processed in parallel:
            Parallel.ForEach(samples, channel =>
            {
                for (var sample = 0; sample < channel.Length; sample++)
                {
                    channel[sample] *= _scale;
                }
            });
        }
コード例 #20
0
        protected override DecoderWriteStatus WriteCallback(IntPtr decoderHandle, ref Frame frame, IntPtr buffer, IntPtr userData)
        {
            Contract.Ensures(_divisor > 0);
            Contract.Ensures(_managedBuffer != null);
            Contract.Ensures(_managedBuffer.Length > 0);
            Contract.Ensures(_managedBuffer[0].Length > 0);
            Contract.Ensures(Samples != null);

            Contract.Assume(frame.Header.Channels > 0);
            Contract.Assume(frame.Header.BlockSize > 0);

            // Initialize the divisor:
            if (_divisor < 1)
            {
                _divisor = (float)Math.Pow(2, frame.Header.BitsPerSample - 1);
            }

            // Initialize the output buffer:
            if (_managedBuffer == null)
            {
                _managedBuffer = new int[frame.Header.Channels][];
                for (var channel = 0; channel < frame.Header.Channels; channel++)
                {
                    _managedBuffer[channel] = new int[frame.Header.BlockSize];
                }
            }

            // Copy the samples from unmanaged memory into the output buffer:
            for (var channel = 0; channel < frame.Header.Channels; channel++)
            {
                IntPtr channelPtr = Marshal.ReadIntPtr(buffer, channel * Marshal.SizeOf(buffer));
                Marshal.Copy(channelPtr, _managedBuffer[channel], 0, (int)frame.Header.BlockSize);
            }

            Samples = SampleCollectionFactory.Instance.Create((int)frame.Header.Channels, (int)frame.Header.BlockSize);

            // Copy the output buffer into a new sample block, converting to floating point values:
            for (var channel = 0; channel < (int)frame.Header.Channels; channel++)
            {
                for (var sample = 0; sample < (int)frame.Header.BlockSize; sample++)
                {
                    Samples[channel][sample] = _managedBuffer[channel][sample] / _divisor;
                }
            }

            return(DecoderWriteStatus.Continue);
        }
コード例 #21
0
    void Start()
    {
        SampleCollection pathPointPosition = new SampleCollection();

        splineComputer.GetSamples(pathPointPosition);
        path          = pathPointPosition.samples;
        ourProjection = new List <Vector3>();

        Vector3 first = path[0].position;

        first.x += offset;

        ourProjection.Add(first);
        moveTo    = path[currentIndex].position;
        moveTo.x += offset;
        moveTo.y  = 1.00000f;
    }
コード例 #22
0
        public SampleCollection DecodeSamples()
        {
            Contract.Ensures(Contract.Result <SampleCollection>() != null);
            Contract.Ensures(Contract.Result <SampleCollection>().SampleCount <= _samplesPerResult);

            if (_samplesRemaining == 0)
            {
                return(SampleCollectionFactory.Instance.Create(_channels, 0));
            }

            SampleCollection result = SampleCollectionFactory.Instance.Create(_channels,
                                                                              (int)Math.Min(_samplesRemaining, _samplesPerResult));

            if (_bytesPerSample == 1)
            {
                // 1-8 bit samples are unsigned:
                for (var sample = 0; sample < result.SampleCount; sample++)
                {
                    for (var channel = 0; channel < _channels; channel++)
                    {
                        result[channel][sample] = (_reader.ReadByte() - 128) / _divisor;
                    }
                }
            }
            else
            {
                for (var sample = 0; sample < result.SampleCount; sample++)
                {
                    for (var channel = 0; channel < _channels; channel++)
                    {
                        if (_reader.Read(_buffer, 4 - _bytesPerSample, _bytesPerSample) != _bytesPerSample)
                        {
                            throw new IOException(Resources.SampleDecoderEndOfStreamError);
                        }
                        int intValue = BitConverter.ToInt32(_buffer, 0) >> (4 - _bytesPerSample) * 8;
                        result[channel][sample] = intValue / _divisor;
                    }
                }
            }

            _samplesRemaining -= result.SampleCount;
            return(result);
        }
コード例 #23
0
ファイル: Program.cs プロジェクト: MDBarbier/C-Sharp
    static void Main()
    {
        var stringCollection = new SampleCollection <string>();

        stringCollection[0] = "Hello, World";
        stringCollection[1] = "Greetings chummer";
        Console.WriteLine(stringCollection[0]);
        Console.WriteLine(stringCollection[1]);

        var personCollection = new SampleCollection <Person>();

        personCollection[0] = new Person()
        {
            Name = "Matt", Age = 36
        };

        Console.WriteLine($"{personCollection[0].Name}, {personCollection[0].Age}");

        Console.ReadLine();
    }
コード例 #24
0
ファイル: IirFilter.cs プロジェクト: jherby2k/PowerShellAudio
        internal void Process(SampleCollection input)
        {
            Contract.Requires(input != null);

            // Optimization - using SampleCollections here is too expensive:
            if (_inputBuffer == null)
            {
                _inputBuffer = GetBuffer(input.Channels, _order + input.SampleCount);
            }
            if (_outputBuffer == null)
            {
                _outputBuffer = GetBuffer(input.Channels, _order + input.SampleCount);
            }

            // Process each channel in parallel:
            Parallel.For(0, input.Channels, channel =>
            {
                input[channel].CopyTo(_inputBuffer[channel], _order);

                for (int sample = _order; sample < _inputBuffer[channel].Length; sample++)
                {
                    float adjustedSample = 0;
                    for (var i = 0; i < _order; i++)
                    {
                        adjustedSample += _inputBuffer[channel][sample - i] * _a[i] -
                                          _outputBuffer[channel][sample - i - 1] * _b[i];
                    }
                    adjustedSample += _inputBuffer[channel][sample - _order] * _a[_order];

                    _outputBuffer[channel][sample] = adjustedSample;
                }

                // Save order number of samples from the ends of both buffers:
                Array.Copy(_inputBuffer[channel], input[channel].Length, _inputBuffer[channel], 0, _order);
                Array.Copy(_outputBuffer[channel], input[channel].Length, _outputBuffer[channel], 0, _order);

                // Modify the input directly, rather than returning a new array:
                Array.Copy(_outputBuffer[channel], _order, input[channel], 0, input[channel].Length);
            });
        }
コード例 #25
0
        public void Submit(SampleCollection samples)
        {
            Contract.Ensures(_buffer != null);

            if (_buffer == null)
            {
                _buffer = new float[samples.Channels * samples.SampleCount];
            }

            // Interlace the samples, and store them in the buffer:
            var index = 0;

            for (var sample = 0; sample < samples.SampleCount; sample++)
            {
                for (var channel = 0; channel < samples.Channels; channel++)
                {
                    _buffer[index++] = samples[channel][sample];
                }
            }

            _analyzer.AddFrames(_buffer);
        }
コード例 #26
0
        static void Main(string[] args)
        {
            var connectionString = ConfigurationManager.AppSettings["MongoDBConnection"];
            var client           = new MongoClient(connectionString);

            var db         = client.GetDatabase(ConfigurationManager.AppSettings["Db"]);
            var collection = db.GetCollection <SampleCollection>("sampleCollection");

            var sc = new SampleCollection
            {
                Data = "でーた",
                Val  = "ばりゅー"
            };

            collection.InsertOne(sc);

            var scs = collection.Find(_ => true).ToList();

            foreach (var c in scs)
            {
                Console.WriteLine($"{c.Id}/{c.Data}");
            }
        }
コード例 #27
0
        public void Submit(SampleCollection samples)
        {
            if (!samples.IsLast)
            {
                // Filter by ReplayGain, depending on settings:
                _replayGainFilterLifetime.Value.Submit(samples);

                // Request an unmanaged buffer, then copy the samples to it:
                var buffers = new IntPtr[samples.Channels];
                Marshal.Copy(_encoder.GetBuffer(samples.SampleCount), buffers, 0, buffers.Length);

                for (var i = 0; i < samples.Channels; i++)
                {
                    Marshal.Copy(samples[i], 0, buffers[i], samples[i].Length);
                }
            }

            _encoder.Wrote(samples.SampleCount);

            while (_encoder.BlockOut())
            {
                _encoder.Analysis(IntPtr.Zero);
                _encoder.AddBlock();

                OggPacket packet;
                while (_encoder.FlushPacket(out packet))
                {
                    _oggStream.PacketIn(ref packet);

                    OggPage page;
                    while (_oggStream.PageOut(out page))
                    {
                        WritePage(page, _output);
                    }
                }
            }
        }
コード例 #28
0
ファイル: TestJson.cs プロジェクト: klenin/Yuzu
        public void TestCollection()
        {
            var js = new JsonSerializer();
            js.JsonOptions.Indent = "";
            var jd = new JsonDeserializer();

            var v0 = new SampleWithCollection();
            v0.A.Add(new SampleInterfaced { X = 9 });
            v0.B.Add(7);
            v0.B.Add(6);
            var result0 = js.ToString(v0);
            Assert.AreEqual(
                "{\n" +
                    "\"A\":[\n{\n\"class\":\"YuzuTest.SampleInterfaced, YuzuTest\",\n\"X\":9\n}\n],\n" +
                    "\"B\":[\n7,\n6\n]\n" +
                "}",
                result0);

            var w0 = new SampleWithCollection();
            jd.FromString(w0, result0);
            Assert.AreEqual(1, w0.A.Count);
            Assert.IsInstanceOfType(w0.A.First(), typeof(SampleInterfaced));
            Assert.AreEqual(9, w0.A.First().X);
            CollectionAssert.AreEqual(new int[] { 7, 6 }, w0.B.ToList());

            var w1 = (SampleWithCollection)SampleWithCollection_JsonDeserializer.Instance.FromString(result0);
            Assert.AreEqual(1, w1.A.Count);
            Assert.IsInstanceOfType(w1.A.First(), typeof(SampleInterfaced));
            Assert.AreEqual(9, w1.A.First().X);
            CollectionAssert.AreEqual(new int[] { 7, 6 }, w1.B.ToList());

            var v2 = new SampleCollection<int> { 2, 5, 4 };
            var result1 = js.ToString(v2);
            Assert.AreEqual("[\n2,\n5,\n4\n]", result1);
            var w2 = (SampleCollection<int>)SampleCollection_Int32_JsonDeserializer.Instance.FromString(result1);
            CollectionAssert.AreEqual(v2.ToList(), w2.ToList());
            var w2g = (SampleExplicitCollection<int>)
                SampleExplicitCollection_Int32_JsonDeserializer.Instance.FromString(result1);
            CollectionAssert.AreEqual(v2.ToList(), w2g.ToList());

            var v3 = new SampleConcreteCollection { 8, 3, 1 };
            var result3 = js.ToString(v3);
            Assert.AreEqual("[\n8,\n3,\n1\n]", result3);
            var w3 = new SampleConcreteCollection();
            jd.FromString(w3, result3);
            CollectionAssert.AreEqual(v3.ToList(), w3.ToList());
            var w3g = (SampleConcreteCollection)
                SampleConcreteCollection_JsonDeserializer.Instance.FromString(result3);
            CollectionAssert.AreEqual(v3.ToList(), w3g.ToList());
        }
コード例 #29
0
        public static void TestIndexator()
        {
            // Индексаторы позволяют индексировать экземпляры класса или структуры точно так же, как и массивы.Индексаторы напоминают свойства за исключением того, что их методы доступа принимают параметры.
            
            // Declare an instance of the SampleCollection type.
            SampleCollection<string> stringCollection = new SampleCollection<string>();

            // Use [] notation on the type.
            stringCollection[0] = "Hello, World";
            System.Console.WriteLine(stringCollection[0]);
        }