示例#1
0
文件: Part.cs 项目: nanase/ux
        /// <summary>
        /// このパートに割当てられている設定値をリセットします。
        /// </summary>
        public void Reset()
        {
            this.waveform       = new Square();
            this.volume         = (float)(1.0 / 1.27);
            this.expression     = 1.0f;
            this.gain           = 1.0f;
            this.panpot         = new Panpot(1.0f, 1.0f);
            this.vibrateDepth   = 4.0;
            this.vibrateFreq    = 4.0;
            this.vibrateDelay   = 0.0;
            this.vibratePhase   = 0.0;
            this.portamentSpeed = 1.0 * 0.001;
            this.portament      = false;
            this.vibrate        = false;
            this.velocity       = 1.0f;

            this.sampleTime  = 0;
            this.notePhase   = 0.0;
            this.noteFreq    = 0.0;
            this.noteFreqOld = 0.0;

            this.finetune = 1.0;
            this.keyShift = 0;

            this.envelope.Reset();
        }
        public void Channels()
        {
            foreach (IIviDigitizerChannel Channel in Digitizer.Channels)
            {
                Channel.Configure(10, 0, VerticalCoupling.DC, true);
                Assert.AreEqual(16, Channel.Range);
                Assert.AreEqual(0, Channel.Offset);
                Assert.AreEqual(VerticalCoupling.DC, Channel.Coupling);
                Assert.IsTrue(Channel.Enabled);

                Channel.Configure(20, 0, VerticalCoupling.DC, true);
                Assert.AreEqual(32, Channel.Range);
                Assert.AreEqual(0, Channel.Offset);
                Assert.AreEqual(VerticalCoupling.DC, Channel.Coupling);
                Assert.IsTrue(Channel.Enabled);

                Digitizer.Acquisition.ConfigureAcquisition(1, 1000, 1E6);

                IWaveform <double> waveformDouble = Digitizer.Acquisition.CreateWaveformDouble(1000);
                waveformDouble = Channel.Measurement.ReadWaveform(new PrecisionTimeSpan((decimal)10), waveformDouble);
                Assert.AreEqual(1000, waveformDouble.ValidPointCount);

                Digitizer.Acquisition.ConfigureAcquisition(10, 1000, 1E6);
                Digitizer.Acquisition.Initiate();
                Digitizer.Acquisition.WaitForAcquisitionComplete(new PrecisionTimeSpan((decimal)20));
                IWaveformCollection <double> waveforms = Channel.MultiRecordMeasurement.FetchMultiRecordWaveform(0, 10, 0, 1000, (IWaveformCollection <double>)null);

                Assert.AreEqual(10, waveforms.ValidWaveformCount);
                Assert.AreEqual(1000, waveforms[0].ValidPointCount);
            }
        }
        /// <summary>
        /// Writes the chunk containing the waveform data to the underlying stream.
        /// </summary>
        /// <param name="waveForm">The waveform.</param>
        private void WriteDataChunk(IWaveform waveForm)
        {
            var chunkSize   = GetDataChunkPayloadSize(waveForm);
            var chunkHeader = new WaveformFileFormat.ChunkHeader(WaveformFileFormat.DataChunkId, chunkSize);

            WriteChunkHeader(chunkHeader);
            WriteFrames(waveForm);
        }
        /// <summary>
        /// Writes the waveform to the underlying stream.
        /// </summary>
        public void Write(IWaveform waveForm)
        {
            var formatChunkTotalSize =
                WaveformFileFormat.FormatChunkPayloadSize + WaveformFileFormat.ChunkHeaderSize;
            var dataChunkTotalSize =
                GetDataChunkPayloadSize(waveForm) + WaveformFileFormat.ChunkHeaderSize;
            var rootChunkPayloadSize = WaveformFileFormat.RiffType.Length +
                                       formatChunkTotalSize + dataChunkTotalSize;

            WriteRootChunkPrologue(rootChunkPayloadSize);
            WriteFormatChunk(waveForm.Format);
            WriteDataChunk(waveForm);
        }
        /// <summary>
        /// Writes the frames of the specified waveform to the underlying the stream.
        /// </summary>
        /// <param name="waveForm">The waveform to write the frames for.</param>
        private void WriteFrames(IWaveform waveForm)
        {
            var format = waveForm.Format;
            var frames = waveForm.GetFrames();

            switch (format.BitsPerSample)
            {
            case 16:
                WriteFrames(frames.Cast <WaveForm16BitFrame>(), Write16BitFrame);
                break;

            default:
                throw new InvalidDataException(string.Format("Unsupported sample depth ({0} bits/sample).", format.BitsPerSample));
            }
        }
        public void Channel()
        {
            foreach (IIviScopeChannel Channel in Scope.Channels)
            {
                Channel.Configure(10, 0, VerticalCoupling.DC, 10, true);
                Assert.AreEqual(10, Channel.Range);
                Assert.AreEqual(0, Channel.Offset);
                Assert.AreEqual(VerticalCoupling.DC, Channel.Coupling);
                Assert.AreEqual(10, Channel.ProbeAttenuation);
                Assert.AreEqual(true, Channel.Enabled);

                Channel.Configure(9, 1, VerticalCoupling.AC, 100, false);
                Assert.AreEqual(9, Channel.Range);
                Assert.AreEqual(1, Channel.Offset);
                Assert.AreEqual(VerticalCoupling.AC, Channel.Coupling);
                Assert.AreEqual(100, Channel.ProbeAttenuation);
                Assert.AreEqual(false, Channel.Enabled);

                Channel.Enabled = false;
                Assert.AreEqual(false, Channel.Enabled);

                Channel.Enabled = true;
                Assert.AreEqual(true, Channel.Enabled);

                Channel.InputImpedance = 1E6;
                Assert.AreEqual(1E6, Channel.InputImpedance);

                Channel.InputFrequencyMaximum = 10E6;
                Assert.AreEqual(10E6, Channel.InputFrequencyMaximum);
                Channel.InputFrequencyMaximum = 100E6;
                Assert.AreEqual(100E6, Channel.InputFrequencyMaximum);


                Scope.Trigger.Configure(TriggerType.Edge, new PrecisionTimeSpan((decimal)1));
                IWaveform <double> waveformDouble = Scope.Measurement.CreateWaveformDouble(100);
                waveformDouble = Channel.Measurement.ReadWaveform(new PrecisionTimeSpan((decimal)10), waveformDouble);

                Assert.AreEqual(100, waveformDouble.ValidPointCount);

                IWaveform <byte> waveformByte = Scope.Measurement.CreateWaveformByte(100);
                waveformByte = Channel.Measurement.ReadWaveform(new PrecisionTimeSpan((decimal)10), waveformByte);

                Assert.AreEqual(100, waveformByte.ValidPointCount);
            }
        }
        public void Measurement()
        {
            IIviScopeMeasurement Measurement = Scope.Measurement;

            Assert.IsNotNull(Measurement);

            Assert.AreEqual(AcquisitionStatus.Complete, Measurement.Status());
            Measurement.AutoSetup();
            Measurement.Initiate();
            Assert.AreEqual(AcquisitionStatus.Complete, Measurement.Status());
            Measurement.Abort();

            IWaveform <byte>   waveformByte   = Measurement.CreateWaveformByte(100);
            IWaveform <short>  waveformInt16  = Measurement.CreateWaveformInt16(100);
            IWaveform <int>    waveformInt32  = Measurement.CreateWaveformInt32(100);
            IWaveform <double> waveformDouble = Measurement.CreateWaveformDouble(100);

            Assert.AreEqual(100, waveformByte.Capacity);
            Assert.AreEqual(100, waveformInt16.Capacity);
            Assert.AreEqual(100, waveformInt32.Capacity);
            Assert.AreEqual(100, waveformDouble.Capacity);
        }
示例#8
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="name">The name of the current source</param>
 /// <param name="pos">The positive node</param>
 /// <param name="neg">The negative node</param>
 /// <param name="w">The Waveform-object</param>
 public Currentsource(CircuitIdentifier name, CircuitIdentifier pos, CircuitIdentifier neg, IWaveform w) : base(name)
 {
     Connect(pos, neg);
     ISRCwaveform = w;
 }
 /// <summary>
 /// Returns the data chunk's payload size for the specified waveform.
 /// </summary>
 /// <param name="waveForm">The waveform.</param>
 /// <returns>The data chunk payload size.</returns>
 private int GetDataChunkPayloadSize(IWaveform waveForm)
 {
     return(waveForm.FrameCount * waveForm.Format.FrameSize);
 }
示例#10
0
文件: Part.cs 项目: nanase/ux
        /// <summary>
        /// 波形に対する設定を適用します。
        /// </summary>
        /// <param name="data1">整数パラメータ。</param>
        /// <param name="data2">実数パラメータ。</param>
        private void ApplyForWaveform(int data1, float data2)
        {
            switch ((WaveformType)data1)
            {
                case WaveformType.Square:
                    if (this.waveform is Square)
                        this.waveform.Reset();
                    else
                        this.waveform = new Square();
                    break;

                case WaveformType.Triangle:
                    if (this.waveform is Triangle)
                        this.waveform.Reset();
                    else
                        this.waveform = new Triangle();
                    break;

                case WaveformType.ShortNoise:
                    if (this.waveform is ShortNoise)
                        this.waveform.Reset();
                    else
                        this.waveform = new ShortNoise();
                    break;

                case WaveformType.LongNoise:
                    if (this.waveform is LongNoise)
                        this.waveform.Reset();
                    else
                        this.waveform = new LongNoise();
                    break;

                case WaveformType.RandomNoise:
                    if (this.waveform is RandomNoise)
                        this.waveform.Reset();
                    else
                        this.waveform = new RandomNoise();
                    break;

                case WaveformType.FM:
                    if (this.waveform is FM)
                        this.waveform.Reset();
                    else
                        this.waveform = new FM(this.master.SamplingFreq);
                    break;

                default:
                    break;
            }
        }
示例#11
0
文件: Part.cs 项目: nanase/ux
        /// <summary>
        /// このパートに割当てられている設定値をリセットします。
        /// </summary>
        public void Reset()
        {
            this.waveform = new Square();
            this.volume = (float)(1.0 / 1.27);
            this.expression = 1.0f;
            this.gain = 1.0f;
            this.panpot = new Panpot(1.0f, 1.0f);
            this.vibrateDepth = 4.0;
            this.vibrateFreq = 4.0;
            this.vibrateDelay = 0.0;
            this.vibratePhase = 0.0;
            this.portamentSpeed = 1.0 * 0.001;
            this.portament = false;
            this.vibrate = false;
            this.velocity = 1.0f;

            this.sampleTime = 0;
            this.notePhase = 0.0;
            this.noteFreq = 0.0;
            this.noteFreqOld = 0.0;

            this.finetune = 1.0;
            this.keyShift = 0;

            this.envelope.Reset();
        }
示例#12
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="name">The name of the voltage source</param>
 /// <param name="pos">The positive node</param>
 /// <param name="neg">The negative node</param>
 /// <param name="w">The waveform</param>
 public Voltagesource(CircuitIdentifier name, CircuitIdentifier pos, CircuitIdentifier neg, IWaveform w) : base(name)
 {
     Connect(pos, neg);
     VSRCwaveform = w;
 }
示例#13
0
文件: Part.cs 项目: nanase/ux
        /// <summary>
        /// 波形に対する設定を適用します。
        /// </summary>
        /// <param name="data1">整数パラメータ。</param>
        /// <param name="data2">実数パラメータ。</param>
        private void ApplyForWaveform(int data1, float data2)
        {
            switch ((WaveformType)data1)
            {
            case WaveformType.Square:
                if (this.waveform is Square)
                {
                    this.waveform.Reset();
                }
                else
                {
                    this.waveform = new Square();
                }
                break;

            case WaveformType.Triangle:
                if (this.waveform is Triangle)
                {
                    this.waveform.Reset();
                }
                else
                {
                    this.waveform = new Triangle();
                }
                break;

            case WaveformType.ShortNoise:
                if (this.waveform is ShortNoise)
                {
                    this.waveform.Reset();
                }
                else
                {
                    this.waveform = new ShortNoise();
                }
                break;

            case WaveformType.LongNoise:
                if (this.waveform is LongNoise)
                {
                    this.waveform.Reset();
                }
                else
                {
                    this.waveform = new LongNoise();
                }
                break;

            case WaveformType.RandomNoise:
                if (this.waveform is RandomNoise)
                {
                    this.waveform.Reset();
                }
                else
                {
                    this.waveform = new RandomNoise();
                }
                break;

            case WaveformType.FM:
                if (this.waveform is FM)
                {
                    this.waveform.Reset();
                }
                else
                {
                    this.waveform = new FM(this.master.SamplingFreq);
                }
                break;

            default:
                break;
            }
        }