コード例 #1
0
ファイル: RunProgramPage.cs プロジェクト: calum74/s2
        void ProgressUpdated(RunState state, double frequency, Waveform w, double amplitude, TimeSpan timeleft)
        {
            if (state == RunState.Error)
            {
                Pause("Error - check hardware");
            }
            if (!double.IsNaN(frequency))
            {
                frequencyLabel.Text = $"{frequency:0.00} Hz";
            }
            etaLabel.Text = $"{timeleft.Hours:00}:{timeleft.Minutes:00}:{timeleft.Seconds:00}";

            if (!double.IsNaN(amplitude))
            {
                amplitudeLabel.Text = $"{amplitude:0.00} V";
            }

            if (w != Waveform.Default)
            {
                waveformLabel.Text = w.WaveformToString();
            }

            if (state == RunState.Completed)
            {
                if (options.runInLoop)
                {
                    runner.Start(runnable, channel, options);
                }
                else
                {
                    Finished();
                    onFinished();
                }
            }
        }
コード例 #2
0
ファイル: AudioSynth.cs プロジェクト: Inkwalker/PicoUnity
        public static double Oscillate(Waveform waveform, double time, float hz)
        {
            return(settings.Evaluate(waveform, time * hz));

            //Old procedural waveforms
            //switch (waveform)
            //{
            //    case Waveform.Triangle:
            //        return Tri(time * hz);
            //    case Waveform.TiltedTriangle:
            //        return TiltedTri(time * hz);
            //    case Waveform.Sawtooth:
            //        return Saw(time * hz);
            //    case Waveform.Square:
            //        return Square(time * hz);
            //    case Waveform.Pulse:
            //        return Pulse(time * hz);
            //    case Waveform.Organ:
            //        return Organ(time * hz);
            //    case Waveform.Noise:
            //        return Noise(time * hz);
            //    case Waveform.Phaser:
            //        return Phaser(time * hz);
            //}
            //return 0;
        }
コード例 #3
0
        private void copyToCommonWaveformsToolStripMenuItem_Click(object sender, EventArgs e)
        {
            Waveform copy = new Waveform(currentWaveform);

            Storage.sequenceData.CommonWaveforms.Add(copy);
            WordGenerator.MainClientForm.instance.commonWaveformEditor.setCommonWaveforms(Storage.sequenceData.CommonWaveforms);
        }
コード例 #4
0
 public AnalogGroupChannelData(AnalogGroupChannelData copyMe)
 {
     //copy constructor, which duplicates the copyMe object;
     this.myWaveform              = new Waveform(copyMe.myWaveform);
     this.channelEnabled          = copyMe.ChannelEnabled;
     this.channelWaveformIsCommon = copyMe.ChannelWaveformIsCommon;
 }
コード例 #5
0
        static void DecodeStreamAdpcm(aBinaryReader reader, aBinaryWriter writer, int sampleCount)
        {
            var left = new short[16];
            int left_last = 0, left_penult = 0;

            var right = new short[16];
            int right_last = 0, right_penult = 0;

            for (var i = 0; i < sampleCount; i += 16)
            {
                Waveform.Adpcm4toPcm16(reader.Read8s(9), left, ref left_last, ref left_penult);
                Waveform.Adpcm4toPcm16(reader.Read8s(9), right, ref right_last, ref right_penult);

                for (var j = 0; j < 16 && (i + j) < sampleCount; ++j)
                {
                    writer.WriteS16(left[j]);
                    writer.WriteS16(right[j]);
                }

                if ((i % cMessageInterval) == 0 || (i + 16) >= sampleCount)
                {
                    mareep.WriteMessage("\rSamples encoded: {0}/{1}", System.Math.Min((i + 16), sampleCount), sampleCount);
                }
            }
        }
コード例 #6
0
        public AcquisitionEngine(IDataSource source)
        {
            samplesOverflowSink = new List <float>();

            overviewWfLastCapture = DateTime.Now;
            overviewWf            = new Waveform(1, 6000000);

            TriggerSources = new List <ITrigger>();
            TriggerSources.Add(new FreeRunning());
            TriggerSources.Add(new Edge());

            Trigger = new Edge(); // TODO: Temporary trigger

            Source                 = source;
            Source.Data           += ProcessWaveform;
            Source.Data           += Source_Data;
            Source.HighresVoltage += Source_HighresVoltage;

            Source.Connect(null);
            var dummyCfg = new NetStreamConfiguration();

            dummyCfg.AdcSpeed   = 0;
            dummyCfg.AfeGain    = 0;
            dummyCfg.UseFastAdc = false;

            Source.Configure(dummyCfg);
        }
コード例 #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="HBM0OhmJS001Standard"/> class
 /// </summary>
 /// <param name="compensateForNoise">A value indicating whether to compensate for noise or not</param>
 /// <param name="compensateForNoiseCutoffTime">The time to stop measuring for noise from the beginning of the waveform</param>
 /// <param name="riseTimeStartPercent">Rise Time starting percentage (Default: 90%)</param>
 /// <param name="riseTimeEndPercent">Rise Time ending percentage (Default: 10%)</param>
 /// <param name="peakCurrentDerivationOffsetTime">The amount of time after Tmax to interpolate Ips (see 5.2.3.3.1) in seconds.  Suggested is 40ns</param>
 /// <param name="findDoublePeak">A value indicating whether to look for a second peak that is slightly lower than the max peak, because some testers generate this type of peak</param>
 /// <param name="doublePeakPercentIncrease">The percent increase to look for when looking for a second peak.</param>
 /// <param name="doublePeakLowerPercentCutoff">The lower percent cutoff below which double-peaks will not be searched for</param>
 /// <param name="waveform">The HBM 0-Ohm waveform to provide calculations on</param>
 /// <param name="signedVoltage">The signed voltage</param>
 public HBM0OhmJS001Standard(
     bool compensateForNoise,
     double compensateForNoiseCutoffTime,
     double riseTimeStartPercent,
     double riseTimeEndPercent,
     double peakCurrentDerivationOffsetTime,
     bool findDoublePeak,
     double doublePeakPercentIncrease,
     double doublePeakLowerPercentCutoff,
     Waveform waveform,
     double signedVoltage)
     : base(waveform, signedVoltage)
 {
     this.compensateForNoise              = compensateForNoise;
     this.compensateForNoiseCutoffTime    = compensateForNoiseCutoffTime;
     this.peakCurrentDerivationOffsetTime = peakCurrentDerivationOffsetTime;
     this.findDoublePeak               = findDoublePeak;
     this.doublePeakPercentIncrease    = doublePeakPercentIncrease;
     this.doublePeakLowerPercentCutoff = doublePeakLowerPercentCutoff;
     this.CalculateIpsMaxDataPoint();
     this.CalculatePeakCurrent();
     this.CalculateRiseTime(riseTimeStartPercent, riseTimeEndPercent);
     this.CalculateDecayTime();
     this.CalculateRing();
 }
コード例 #8
0
        public AcquisitionEngine(IDataSource source)
        {
            samplesOverflowSink = new List<float>();

            overviewWfLastCapture = DateTime.Now;
            overviewWf = new Waveform(1, 6000000);

            TriggerSources = new List<ITrigger>();
            TriggerSources.Add(new FreeRunning());
            TriggerSources.Add(new Edge());

            Trigger = new Edge(); // TODO: Temporary trigger

            Source = source;
            Source.Data += ProcessWaveform;
            Source.Data += Source_Data;
            Source.HighresVoltage += Source_HighresVoltage;

            Source.Connect(null);
            var dummyCfg = new NetStreamConfiguration();
            dummyCfg.AdcSpeed = 0;
            dummyCfg.AfeGain = 0;
            dummyCfg.UseFastAdc = false;

            Source.Configure(dummyCfg);
        }
コード例 #9
0
        public IHttpActionResult PutWaveform(int id, Waveform waveform)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != waveform.WaveformID)
            {
                return(BadRequest());
            }

            db.Entry(waveform).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!WaveformExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
コード例 #10
0
ファイル: EEGUtils.cs プロジェクト: hapablap/studienarbeit
 /// <summary>
 /// Normalisiert eine Waveform in den Bereich zwischen 0 und 1.
 /// </summary>
 /// <param name="waveform">Die originale Waveform.</param>
 /// <returns>Die normalisierte Waveform.</returns>
 public static Waveform Normalize(Waveform waveform)
 {
     List<Waveform> waveforms = new List<Waveform>();
     waveforms.Add(waveform);
     NormalizeMultiple(ref waveforms);
     return waveforms[0];
 }
コード例 #11
0
    static void Main(string[] args)
    {
        Program  p        = new Program();
        Waveform waveform = new Waveform();

        p.DeleteEntity <Waveform>(waveform);
    }
コード例 #12
0
	void Serialize(string filename){
		// normalizes the data to the {0.0-1.0f} interval and saves as xml
		Waveform w = new Waveform();
		w.name = filename;
		w.cycles=1;
		w.signal = signal;
		w.mode=filename;
		w.normalRate = normal;
		w.samples = dataPoints.Count;
		
		float scale = dataMax-dataMin;
		if ( scale == 0.0f )
			scale = 1.0f;
		
		w.data = new float[dataPoints.Count];
		
		for (int i=0;i< dataPoints.Count;i++){
			w.data[i]= (dataPoints[i].point-dataMin)/scale;
			
		}
		XmlSerializer serializer = new XmlSerializer(typeof(Waveform));
		FileStream stream = new FileStream(filename + ".xml", FileMode.Create);
		serializer.Serialize(stream, w);
		stream.Close();	
	}	
コード例 #13
0
ファイル: Phase.cs プロジェクト: MiklosPathy/zplusnth
        /// <summary>
        /// Returns "oscillator" value as function of phase. Result between -1 and 1.
        /// </summary>
        /// <param name="CurrentOption">WaveForm.</param>
        /// <param name="phase">The phase angle of the oscillator. Between 0 and 2PI. If not, it will be.</param>
        /// <param name="currentsamplevalue"></param>
        /// <param name="p">0 to 2. PWM like stuff. Except it works for sine and triangle too. 1 is normal waveform.</param>
        static public void Waveformswitcher(Waveform CurrentOption, double phase, ref double currentsamplevalue, double p = 1)
        {
            double correctedphase = Z_nthCommon.Phase.Correction(phase);

            switch (CurrentOption)
            {
            case Waveform.Sine:
                currentsamplevalue += Z_nthCommon.Phase.Sine(correctedphase, p);
                break;

            case Waveform.Saw:
                currentsamplevalue += Z_nthCommon.Phase.Saw(correctedphase, p);
                break;

            case Waveform.Square:
                currentsamplevalue += Z_nthCommon.Phase.Square(correctedphase, p);
                break;

            case Waveform.Triangle:
                currentsamplevalue += Z_nthCommon.Phase.Triangle(correctedphase, p);
                break;

            default:
                break;
            }
        }
コード例 #14
0
 private void FireTriggeredWaveform(Waveform f)
 {
     if (TriggeredWaveform != null)
     {
         TriggeredWaveform(f);
     }
 }
コード例 #15
0
        //main logic
        private static void TimerTick(object sender, EventArgs e)
        {
            //initialize after elements have loaded
            if (!m_HasInit)
            {
                //init spectrogram
                int spectrogramWidth  = (int)Instance.SpectrogramPanel.ActualWidth * 2;
                int spectrogramHeight = (int)Instance.SpectrogramGrid.ActualHeight * 2;
                m_Spectrogram = new Spectrogram(spectrogramWidth, spectrogramHeight, m_SpectrogramMultiplier);

                int waveformWidth  = (int)Instance.WaveformPanel.ActualWidth * 2;
                int waveformHeight = (int)Instance.WaveformPanel.ActualHeight * 2;
                m_Waveform = new Waveform(waveformWidth, waveformHeight, m_WaveformMultiplier);

                Mixer.SetUnusedChannels();

                m_HasInit = true;
            }

            Analyzer.ProcessBarValues();
            Mixer.ProcessLevels();

            Instance.SpectrogramBitmap.Fill = m_Spectrogram.CreateBitmap();
            Instance.WaveformBitmap.Fill    = m_Waveform.CreateBitmap();
        }
コード例 #16
0
        /// <inheritdoc/>
        public override IndependentSourceParameters Clone()
        {
            var clone = base.Clone();

            clone.Waveform = Waveform?.Clone();
            return(clone);
        }
        public void HBMJS001500OhmNegativeTest()
        {
            Waveform waveform = PublicStandardTestExtensions.ParseWaveformFromString(Properties.Resources.HBM_500Ohm_Neg_4000V);
            HBM500OhmJS001Standard hbm500OhmJS001Standard = new HBM500OhmJS001Standard(waveform, -4000);

            // Assert that Peak Current value is within 1mA of expected
            Assert.AreEqual(-1.709, hbm500OhmJS001Standard.PeakCurrentValue, 0.001);

            // Assert that Peak Current min/max are within 1mA of expected
            Assert.AreEqual(-1.5, hbm500OhmJS001Standard.PeakCurrentAllowedMinimum, 0.001);
            Assert.AreEqual(-2.2, hbm500OhmJS001Standard.PeakCurrentAllowedMaximum, 0.001);

            // Assert that Peak Current is passing
            Assert.IsTrue(hbm500OhmJS001Standard.PeakCurrentIsPassing);

            // Assert that Rise Time is within 10ps of expected
            Assert.AreEqual(0.00000002292, hbm500OhmJS001Standard.RiseTimeValue, 0.000000000010);

            // Assert that Rise Time min/max are within 10ps of expected
            Assert.AreEqual(0.000000005, hbm500OhmJS001Standard.RiseTimeAllowedMinimum, 0.000000000010);
            Assert.AreEqual(0.000000025, hbm500OhmJS001Standard.RiseTimeAllowedMaximum, 0.000000000010);

            // Assert that Rise Time is passing
            Assert.IsTrue(hbm500OhmJS001Standard.RiseTimeIsPassing);
        }
コード例 #18
0
ファイル: ProgramStep.cs プロジェクト: calum74/s2
 public Command(ICommand cmd, double freq, Waveform w, double amplitude, TimeSpan t)
 {
     Cmd       = cmd;
     Frequency = freq;
     Remaining = t;
     Waveform  = w;
     Amplitude = amplitude;
 }
コード例 #19
0
ファイル: Oscillator.cs プロジェクト: Yartch/YartchUtility
        /// <summary>
        /// Creates an oscillator.
        /// </summary>
        /// <param name="waveform">The type of wave the oscillator will follow.</param>
        /// <param name="speed">How fast the oscillator with oscillate.</param>
        /// <param name="magnitude">The min/max value the oscillator will return.</param>
        public Oscillator(Waveform waveform, float speed = 1f, double magnitude = 1f)
        {
            _waveform = waveform;
            _speed = speed;
            _magnitude = magnitude;

            _last_frame = DateTime.UtcNow;
        }
コード例 #20
0
 public WaveformGraph(Waveform waveform, WaveformEditor waveformEditor, bool waveformEditable)
     : this()
 {
     // TODO: Write this function.
     setWaveform(waveform);
     setWaveformEditor(waveformEditor);
     this.editable = waveformEditable;
 }
コード例 #21
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CDMJS002Standard"/> class
 /// </summary>
 /// <param name="waveform">The CDM waveform to provide calculations on</param>
 /// <param name="signedVoltage">The signed voltage</param>
 /// <param name="isLargeTarget">A value indicating whether the CDM target is the Large target or not (small if not)</param>
 /// <param name="oscilloscopeIsHighBandwidth">A value indicating whether the oscilloscope used is high bandwidth or not</param>
 public CDMJS002Standard(
     Waveform waveform,
     double signedVoltage,
     bool isLargeTarget,
     bool oscilloscopeIsHighBandwidth)
     : this(waveform, signedVoltage, isLargeTarget, oscilloscopeIsHighBandwidth, 0.1, 0.9, 0)
 {
 }
コード例 #22
0
ファイル: EEGUtils.cs プロジェクト: hapablap/studienarbeit
 /// <summary>
 /// Hängt zwei Waveforms aneinander an.
 /// </summary>
 /// <param name="a">Die erste Waveform.</param>
 /// <param name="b">Die zweite Waveform.</param>
 /// <returns>Die verbundene Waveform (a+b).</returns>
 public static Waveform Concatenate(Waveform a, Waveform b)
 {
     for (int i = b.First; i <= b.Last; i++)
     {
         a.Add(b[i]);
     }
     return a;
 }
コード例 #23
0
        public void SetWaveform(int channel, Waveform value)
        {
            CheckChannel(channel);

            // !! Set
            int wf = 0;

            Send(Command.set_waveform_1, channel, wf);
        }
コード例 #24
0
    public static Waveform GetRandomWaveform()
    {
        Array values = Enum.GetValues(typeof(Waveform));

        System.Random random     = new System.Random();
        Waveform      randomWave = (Waveform)values.GetValue(random.Next(values.Length));

        return(randomWave);
    }
コード例 #25
0
ファイル: PreviewWaveform.cs プロジェクト: robness/Vixen
 private void _DisposePreviewWaveform()
 {
     if (m_waveform != null)
     {
         m_waveform.Paint += PreviewWaveform_Paint;
         m_waveform.Dispose();
         m_waveform = null;
     }
 }
コード例 #26
0
ファイル: Sampler.cs プロジェクト: hapablap/studienarbeit
        public Waveform GetEEGWaveform(Electrode electrode)
        {
            Waveform Waveform = new Waveform(0, sampleRate);
            foreach (EEGSample sample in goodSamples)
            {
                Waveform.Add(sample.eegValues[electrode]);
            }

            return Waveform;
        }
コード例 #27
0
        /// <summary>
        ///   Add Waveform to the chart.
        /// </summary>
        ///
        /// <param name="name">Waveform name.</param>
        /// <param name="color">Waveform color.</param>
        /// <param name="width">Waveform width.</param>
        /// <param name="updateYRange">Specifies if <see cref="RangeY"/> should be updated.</param>
        ///
        /// <remarks><para>Adds new empty waveform to the collection of waves. To update this
        /// wave the <see cref="UpdateWaveform(string, float[])"/> method should be used.</para>
        /// </remarks>
        ///
        /// <remarks><para>Adds new empty data series to the collection of data series.</para>
        ///
        /// <para>The <b>updateYRange</b> parameter specifies if the waveform may affect displayable
        /// Y range. If the value is set to false, then displayable Y range is not updated, but used the
        /// range, which was specified by user (see <see cref="RangeY"/> property). In the case if the
        /// value is set to true, the displayable Y range is recalculated to fully fit the new data
        /// series.</para>
        /// </remarks>
        ///
        public void AddWaveform(string name, Color color, int width, bool updateYRange)
        {
            Waveform series = new Waveform();

            series.color        = color;
            series.width        = width;
            series.updateYRange = updateYRange;

            waveTable.Add(name, series);
        }
 /// <summary>
 /// Initializes a new instance of the <see cref="HBM500OhmJS001Standard"/> class
 /// </summary>
 /// <param name="waveform">The HBM 500-Ohm waveform to provide calculations on</param>
 /// <param name="signedVoltage">The signed voltage</param>
 /// <param name="riseTimeStartPercent">Rise Time starting percentage (Default: 90%)</param>
 /// <param name="riseTimeEndPercent">Rise Time ending percentage (Default: 10%)</param>
 public HBM500OhmJS001Standard(
     Waveform waveform,
     double signedVoltage,
     double riseTimeStartPercent,
     double riseTimeEndPercent)
     : base(waveform, signedVoltage)
 {
     this.CalculatePeakCurrent();
     this.CalculateRiseTime(riseTimeStartPercent, riseTimeEndPercent);
 }
コード例 #29
0
        static void Main()
        {
            string         resourceName = "VST2";
            string         filePath     = Path.GetFullPath(@"Support Files\80211a_20M_48Mbps.tdms");
            GenerationType genType      = GenerationType.Continuous;

            NIRfsg nIRfsg = new NIRfsg(resourceName, false, false);

            InstrumentConfiguration instrConfig = InstrumentConfiguration.GetDefault();

            instrConfig.CarrierFrequency_Hz = 2e9;

            ConfigureInstrument(nIRfsg, instrConfig);
            Waveform waveform = LoadWaveformFromTDMS(filePath);

            DownloadWaveform(nIRfsg, waveform);

            switch (genType)
            {
            // For continous generation, we can simply call this function to begin the generation
            case GenerationType.Continuous:
                ConfigureContinuousGeneration(nIRfsg, waveform);
                break;

            // For bursted generation, we need to configure the duty cycle and PA control
            case GenerationType.Bursted:
                WaveformTimingConfiguration dynamicConfig = new WaveformTimingConfiguration
                {
                    DutyCycle_Percent       = 20,
                    PreBurstTime_s          = 500e-9,
                    PostBurstTime_s         = 500e-9,
                    BurstStartTriggerExport = "PXI_Trig0"
                };
                PAENConfiguration paenConfig = new PAENConfiguration
                {
                    PAEnableMode = PAENMode.Dynamic,
                    PAEnableTriggerExportTerminal = "PFI0",
                    PAEnableTriggerMode           = RfsgMarkerEventOutputBehaviour.Toggle,
                    CommandEnableTime_s           = 0,
                    CommandDisableTime_s          = 0,
                };

                ConfigureBurstedGeneration(nIRfsg, waveform, dynamicConfig, paenConfig, out _, out _);
                break;
            }

            nIRfsg.Initiate();

            Console.WriteLine("Generation has now begun. Press any key to abort generation and close the example.");
            Console.ReadKey();

            AbortGeneration(nIRfsg);

            CloseInstrument(nIRfsg);
        }
コード例 #30
0
        /// <summary>
        /// Gets the value of the specified analog channel at the end of the timestep. Returns 0 if value is unspecified. Note
        /// that this is not necessarily the true sequence-specified value, as this method does not take into account
        /// analog groups which have been continued from previous timesteps.
        /// </summary>
        /// <param name="analogChannelID"></param>
        /// <returns></returns>
        public double getEndAnalogValue(int analogChannelID, List <Variable> existingVariables, List <Waveform> existingCommonWaveforms)
        {
            Waveform wf = getChannelWaveform(analogChannelID);

            if (wf == null)
            {
                return(0);
            }

            return(wf.getValueAtTime(this.stepDuration.getBaseValue(), existingVariables, existingCommonWaveforms));
        }
コード例 #31
0
        public IHttpActionResult GetWaveform(int id)
        {
            Waveform waveform = db.Waveforms.Find(id);

            if (waveform == null)
            {
                return(NotFound());
            }

            return(Ok(waveform));
        }
コード例 #32
0
        /// <summary>
        /// Calculates the Undershoot related values
        /// </summary>
        /// <param name="undershootMaxTimeFWHMMultiplier">(Optional) The multiplier of the FWHM time to determine how long after the peak current time to search for undershoot (Default: 2.5x)</param>
        private void CalculateUndershoot(double undershootMaxTimeFWHMMultiplier = 2.5)
        {
            if (undershootMaxTimeFWHMMultiplier <= 0)
            {
                throw new ArgumentOutOfRangeException("The Undershoot Max Time multiplier cannot be less than or equal to 0");
            }

            // Determine how much time after the max data point of the waveform to keep for Undershoot
            double timeForUndershootDetectionAfterMaxTime = this.FullWidthHalfMaxValue * undershootMaxTimeFWHMMultiplier;

            // Add the undershoot allowed time to the max data point time
            double endTimeForUndershootDetection = this.PeakCurrentDataPoint.X + timeForUndershootDetectionAfterMaxTime;

            // Trim the waveform, removing everything before the max peak
            Waveform absoluteWaveformAfterPeakCurrentTime = this.AbsoluteWaveform.TrimStart(this.PeakCurrentDataPoint.X);

            // Trim the end of the waveform from the max time until 2.5x the FWHM time
            Waveform absoluteUndershootApplicableWaveform = absoluteWaveformAfterPeakCurrentTime.TrimEnd(endTimeForUndershootDetection);

            // Find the (absolute) undershoot data point of the absolute Current waveform after the max time
            DataPoint absoluteUndershootDataPoint = absoluteUndershootApplicableWaveform.Minimum();

            // Look up what the undershoot max percent can be (it is a negative value)
            this.UndershootAllowedMaximumPercent = CDMJS002WaveformCharacteristics.UndershootMaxPercent(this.SignedVoltage, this.IsLargeTarget, this.OscilloscopeIsHighBandwidth);

            // Calculate what the maximum undershoot value can be (it is a negative number since we are referring to undershoot)
            this.UndershootAllowedMaximumValue = this.PeakCurrentValue * this.UndershootAllowedMaximumPercent;

            // Convert the absolute undershoot value to the signed value
            double absoluteUndershootValue = absoluteUndershootDataPoint.Y;

            // If the absolute undershoot is greater than zero, set it to zero.  Otherwise set it to the signed value
            if (absoluteUndershootValue > 0)
            {
                this.UndershootValue = 0;
            }
            else
            {
                this.UndershootValue = absoluteUndershootValue.InvertValueIfNegativePolarity(this.WaveformIsPositivePolarity);
            }

            // Determine if the Undershoot is passing
            if (this.WaveformIsPositivePolarity)
            {
                this.UndershootIsPassing = this.UndershootValue >= this.UndershootAllowedMaximumValue;
            }
            else
            {
                this.UndershootIsPassing = this.UndershootValue <= this.UndershootAllowedMaximumValue;
            }

            // Create the undershoot signed Data Point
            this.UndershootDataPoint = absoluteUndershootDataPoint.InvertYValueIfNegativePolarity(this.WaveformIsPositivePolarity);
        }
コード例 #33
0
        /// <summary>
        /// Initialization of the waveform test harness components.
        /// </summary>
        private async void InitializeWaveform()
        {
            this.sampleRate = 44100;

            var file = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFileAsync(@"Assets\test.wav");

            this.waveform = new Waveform.Builder()
                            .FromFile(file.Path, this.sampleRate)
                            .WithScale(1f)
                            .Build();
        }
コード例 #34
0
        public void Run()
        {
            #region Create Sessions
            FocusITunerBroker iTuner = new FocusITunerBroker();
            iTuner.Initialize(tunerAddress, false, true);
            NIRfsg       nIRfsg = new NIRfsg(resourceName, false, false);
            RFmxInstrMX  instr  = new RFmxInstrMX(resourceName, "");
            RFmxSpecAnMX specAn = instr.GetSpecAnSignalConfiguration(signalStringSpecan);
            #endregion

            #region Configure Tuner
            FocusTuner.ConfigureCommon(iTuner, commonConfiguration);
            #endregion

            #region Configure Generation
            ConfigureInstrument(nIRfsg, sgInstrConfig);
            Waveform waveform = LoadWaveformFromTDMS(filePath);
            DownloadWaveform(nIRfsg, waveform);
            ConfigureContinuousGeneration(nIRfsg, waveform);
            nIRfsg.Initiate();
            #endregion

            #region Configure Analyzer
            saAutolevelConfig.MeasurementInterval_s = waveform.BurstLength_s;
            RFmxInstr.ConfigureInstrument(instr, saInstrConfig);
            RFmxSpecAn.ConfigureCommon(specAn, saCommonConfig);
            RFmxSpecAn.ConfigureTxp(specAn, txpConfigurationSpecAn);
            #endregion

            #region Measure
            foreach (var gamma in gammaSweep)
            {
                Console.WriteLine("\n--------------------- Tuning --------------------\n");
                currentGamma = FocusTuner.MoveTunerPerGamma(iTuner, gamma)[0];
                PrintTuneResults();

                Console.WriteLine("\n--------------------- Results --------------------\n");
                RFmxSpecAnMXMeasurementTypes[] specanMeasurements = new RFmxSpecAnMXMeasurementTypes[1] {
                    RFmxSpecAnMXMeasurementTypes.Txp
                };
                RFmxSpecAn.SelectAndInitiateMeasurements(specAn, specanMeasurements, saAutolevelConfig, waveform.SignalBandwidth_Hz, false, "", resultStringSpecan);
                txpResultsSpecAn = RFmxSpecAn.FetchTxp(specAn, RFmxSpecAnMX.BuildResultString(resultStringSpecan));
                PrintTxPResults();
            }
            #endregion

            AbortGeneration(nIRfsg);
            CloseInstrument(nIRfsg);
            FocusTuner.CloseTuner(iTuner);
            specAn.Dispose();
            specAn = null;
            instr.Close();
            instr = null;
        }
コード例 #35
0
        public override Task <Empty> ConfigureContinuousGeneration(RfsgServiceGenerationConfiguration request, ServerCallContext context)
        {
            var      rfsg = sessionMap[(IntPtr)request.Session.Handle];
            Waveform wfm  = new Waveform()
            {
                Name = request.WaveformName,
            };

            SG.ConfigureContinuousGeneration(rfsg, wfm, request.MarkerEventExportTerminal);
            return(Task.FromResult(new Empty()));
        }
コード例 #36
0
        public IHttpActionResult PostWaveform(Waveform waveform)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            db.Waveforms.Add(waveform);
            db.SaveChanges();

            return(CreatedAtRoute("DefaultApi", new { id = waveform.WaveformID }, waveform));
        }
コード例 #37
0
ファイル: PreviewWaveform.cs プロジェクト: stewmc/vixen
		public PreviewWaveform(Audio audio)
		{
			InitializeComponent();

			m_info = new TimeInfo();
			m_info.TotalTime = new TimeSpan(0, 0, 0, 1);
			m_waveform = new Waveform(m_info);
			m_waveform.BorderStyle = BorderStyle.FixedSingle;
			m_waveform.Audio = audio;
			m_waveform.BackColor = Color.LightGray;
			m_waveform.Paint += PreviewWaveform_Paint;

			Controls.Add(m_waveform);
		}
コード例 #38
0
ファイル: EEGUtils.cs プロジェクト: hapablap/studienarbeit
        /// <summary>
        /// Bildet den Durschnitt aus einer Liste aus Waveforms. Die Waveforms müssen gleich lang sein.
        /// </summary>
        /// <param name="waveforms">Die Liste aus Waveforms.</param>
        /// <returns>Die Durchschnitts-Waveform.</returns>
        public static Waveform AverageWaveform(List<Waveform> waveforms)
        {
            int noOfWaveforms = waveforms.Count;

            if (noOfWaveforms < 1) return null;
            else if (noOfWaveforms < 2) return waveforms[0];

            double average;
            Waveform averageWaveform = new Waveform(0, waveforms[0].Rate);
            for (int i = waveforms[0].First; i <= waveforms[0].Last; i++)
            {
                average = 0;
                foreach (Waveform waveform in waveforms)
                {
                    average = average + waveform[i];
                }
                average = average / noOfWaveforms;
                averageWaveform.Add(average);
            }

            return averageWaveform;
        }
コード例 #39
0
    protected void Load(Waveform wav,float scale=1.0f)
    {
        dataPoints = new List<VitalDataPoint>();
        VitalDataPoint newData = new VitalDataPoint();
	
		 length = wav.samples;
         dataMax = 0;
		dataMin=9999;

        // For each character in the file
        for (int i = 0; i < length; i++)
        {
			newData = new VitalDataPoint();
            newData.time = i;
	
			newData.point = wav.data[i]*scale;
			if (newData.point>dataMax) dataMax=newData.point;
			if (newData.point<dataMin) dataMin=newData.point;
			dataPoints.Add(newData);
        }
        dataPoints.TrimExcess();
		lastPoint = dataPoints[0];
		nextPoint = dataPoints[0];
    }	
コード例 #40
0
ファイル: EEGAnalyzer.cs プロジェクト: hapablap/studienarbeit
 /// <summary>
 /// Findet zu einer Frequenz den nächstkleineren Index im diskreten Spektrum.
 /// </summary>
 /// <param name="freq">Frequenz</param>
 /// <param name="realSpectrum">reellwertiges Halbspektrum</param>
 /// <param name="sampleRate">Samplerate</param>
 /// <returns>Index im diskreten Spektrum</returns>
 private static int FindSpectrumIndexForFreq(double freq, Waveform realSpectrum, int sampleRate)
 {
     return (int) Math.Floor((freq / (sampleRate / 2)) * realSpectrum.Count) + realSpectrum.First;
 }
コード例 #41
0
ファイル: Oscillator.cs プロジェクト: Yartch/YartchUtility
 /// <summary>
 /// Switch the waveform at any time.
 /// </summary>
 /// <param name="waveform"></param>
 public void ChangeWaveform(Waveform waveform)
 {
     if(waveform == _waveform) return;
     _waveform = waveform;
 }
コード例 #42
0
ファイル: EEGAnalyzer.cs プロジェクト: hapablap/studienarbeit
        /// <summary>
        /// Generiert eine Waveform, die die sekündliche Aktivität eines EEG-Frequenzbandes wiederspiegelt und speichert sie zwischen. Die Samplerate ist 1 Hz.
        /// </summary>
        private void CalculateActivity()
        {
            this.Activity = new Dictionary<EEGBand, Waveform>();
            foreach (EEGBand eegBand in (EEGBand[])Enum.GetValues(typeof(EEGBand)))
            {
                double minFreq = eegBand.GetMinFreq();
                double maxFreq = eegBand.GetMaxFreq();

                // wir nehmen das Spektrum über 128 Samples
                int fftSize = 128;

                // die Samplerate der Activity-Waveform soll 1 Hz sein.
                int activitySampleRate = 1;

                // wir benötigen eine leere Waveform
                Waveform activityWaveform = new Waveform(0, activitySampleRate);

                // Ermittle das Frequenzspektrum in regelmäßigen Abständen  und berechne die Aktivität im Frequenzband
                for (int i = Waveform.First; i <= Waveform.Last - fftSize; i = i + ((int)sampleRate / activitySampleRate))
                {
                    Waveform amplitudeSpectrum = GetAmplitudeSpectrum(i, fftSize);

                    // finde die Indizes im diskreten Spektrum, die Ober- und Unterkante des Frequenzbands darstellen
                    int minFreqIndex = FindSpectrumIndexForFreq(minFreq, amplitudeSpectrum, (int)sampleRate);
                    int maxFreqIndex = FindSpectrumIndexForFreq(maxFreq, amplitudeSpectrum, (int)sampleRate);

                    double activityValue = 0;
                    for (int j = minFreqIndex; j <= maxFreqIndex; j++)
                    {
                        activityValue = activityValue + amplitudeSpectrum[j];
                    }
                    activityWaveform.Add(activityValue / (maxFreqIndex - minFreqIndex + 1));
                }

                // Die Waveform ist etwas zu kurz (fftSize) und die Werte beziehen sich jeweils auf zwei Sekunden später
                // Kompensieren, indem die Welle nach hinten verschoben wird und die ersten Werte denselben Wert annehmen
                Waveform compensationWaveform = new Waveform(0, activitySampleRate);
                for (int i = 0; i <= fftSize; i = i + ((int)sampleRate / activitySampleRate))
                {
                    compensationWaveform.Add(activityWaveform[activityWaveform.First]);
                }
                this.Activity.Add(eegBand, EEGUtils.Concatenate(compensationWaveform, activityWaveform));
            }
        }
コード例 #43
0
ファイル: EEGAnalyzer.cs プロジェクト: hapablap/studienarbeit
 public EEGAnalyzer(Waveform Waveform)
 {
     this.Waveform = Waveform;
     this.sampleRate = Waveform.Rate;
     CalculateActivity();
 }
コード例 #44
0
 private void FireTriggeredWaveform(Waveform f)
 {
     if (TriggeredWaveform != null)
         TriggeredWaveform(f);
 }
コード例 #45
0
        void ProcessWaveform(DataPacket data)
        {
            AcquisitionLength = 1+(int)(AcquisitionTime*Source.SampleRate);
            if (AcquisitionLength < 15) AcquisitionLength = 15;

            Pretrigger = (int) (PretriggerTime*Source.SampleRate) + AcquisitionLength / 2;

            lock (samplesOverflowSink)
            {
                samplesOverflowSink.AddRange(data.Samples);

                var pretriggerSampleDepth = (int) Source.SampleRate;

                if (samplesOverflowSink.Count > pretriggerSampleDepth)
                {
                    samplesOverflowSink.RemoveRange(0, samplesOverflowSink.Count - pretriggerSampleDepth);
                }

                var triggerInfo = new TriggerInfo(true, 0); // dummy

                while (triggerInfo.Triggered && samplesOverflowSink.Count >= AcquisitionLength + Pretrigger) // always keep 1 waveform extra in memory
                {
                    triggerInfo = Trigger.IsTriggered(samplesOverflowSink, 0);

                    // Skip the waveform (if we keep trigger) till we satisfy the pretrigger requirement.
                    while (triggerInfo.Triggered && triggerInfo.TriggerPoint < Pretrigger)
                    {
                        triggerInfo = Trigger.IsTriggered(samplesOverflowSink, triggerInfo.TriggerPoint );
                    }
                    // Only process when actually triggered.
                    if (!triggerInfo.Triggered) break;

                    // We take the waveform from the buffer at the triggerpoint, but also subtracting the pre-trigger sample depth.
                    var waveformStart = triggerInfo.TriggerPoint - Pretrigger;

                    // Get these samples, and put them into the waveform.
                    var waveformSamples = samplesOverflowSink.Skip(waveformStart).Take(AcquisitionLength).ToArray();
                    if (waveformSamples.Length != AcquisitionLength) break;
                    var waveform = new Waveform(1, AcquisitionLength);
                    var timestamp = -Pretrigger*data.TimeInterval;
                    foreach(var s in waveformSamples)
                    {
                        timestamp += data.TimeInterval;
                        waveform.Store(timestamp, new float[1] {s});
                    }

                    FireTriggeredWaveform(waveform);

                    samplesOverflowSink.RemoveRange(0, waveformStart+AcquisitionLength-1);

                }
            }
        }
コード例 #46
0
        void Source_Data(DataPacket data)
        {
            // Store each sample.
            foreach (var s in data.Samples)
            {
                overviewTimestamp += data.TimeInterval;
                overviewWf.Store(overviewTimestamp, new float[1] { s });
            }

            if (DateTime.Now.Subtract(overviewWfLastCapture).TotalMilliseconds >= LongAcquisitionTime *1000)
            {
                if (OverviewWaveform != null)
                    OverviewWaveform(overviewWf);

                overviewWf = new Waveform(1, 6000000);
                overviewTimestamp = 0.0f;
                overviewWfLastCapture = DateTime.Now;

            }
        }
コード例 #47
0
ファイル: PreviewWaveform.cs プロジェクト: stewmc/vixen
		private void _DisposePreviewWaveform()
		{
			if (m_waveform != null)
			{
				m_waveform.Paint += PreviewWaveform_Paint;
				m_waveform.Dispose();
				m_waveform = null;
			}
		}
コード例 #48
0
ファイル: EEGUtils.cs プロジェクト: hapablap/studienarbeit
        /// <summary>
        /// Normalisiert mehrere Waveforms in den Bereich zwischen 0 und 1. Die Referenzen (Minimum und Maximum) werden dabei über alle Waveforms hinweg gesucht.
        /// </summary>
        /// <param name="waveforms">Die zu normalisierenden Waveforms. Die Liste wird durch die normalisierten Waveforms ersetzt.</param>
        public static void NormalizeMultiple(ref List<Waveform> waveforms)
        {
            if (waveforms.Count < 1) return;

            double min = waveforms[0][waveforms[0].First];
            double max = waveforms[0][waveforms[0].First];

            // kleinsten und größten Wert suchen
            foreach (Waveform wf in waveforms)
            {
                for (int i = wf.First; i <= wf.Last; i++)
                {
                    if (wf[i] < min) min = wf[i];
                    if (wf[i] > max) max = wf[i];
                }
            }

            // alle Waveforms normalisieren
            if (max - min > 0)
            {
                for (int j = 0; j < waveforms.Count; j++)
                {
                    Waveform wf = waveforms[j];
                    Waveform normalizedWaveform = new Waveform(0, wf.Rate);
                    for (int i = wf.First; i <= wf.Last; i++)
                    {
                        // Wert normalisieren
                        normalizedWaveform.Add((wf[i] - min) / (max - min));
                    }
                    waveforms[j] = normalizedWaveform;
                }
            }
        }
コード例 #49
0
ファイル: Oscillator.cs プロジェクト: nathanchere/nFMOD
 public Waveform CycleWaveforms()
 {
     WaveformType = (Waveform)((int)(WaveformType + 1) % MAX_WAVEFORM_TYPES);
     return WaveformType;
 }
コード例 #50
0
ファイル: Wavechart.cs プロジェクト: CanerPatir/framework
        /// <summary>
        ///   Add Waveform to the chart.
        /// </summary>
        /// 
        /// <param name="name">Waveform name.</param>
        /// <param name="color">Waveform color.</param>
        /// <param name="width">Waveform width.</param>
        /// <param name="updateYRange">Specifies if <see cref="RangeY"/> should be updated.</param>
        /// 
        /// <remarks><para>Adds new empty waveform to the collection of waves. To update this
        /// wave the <see cref="UpdateWaveform(string, float[])"/> method should be used.</para>
        /// </remarks>
        /// 
        /// <remarks><para>Adds new empty data series to the collection of data series.</para>
        /// 
        /// <para>The <b>updateYRange</b> parameter specifies if the waveform may affect displayable
        /// Y range. If the value is set to false, then displayable Y range is not updated, but used the
        /// range, which was specified by user (see <see cref="RangeY"/> property). In the case if the
        /// value is set to true, the displayable Y range is recalculated to fully fit the new data
        /// series.</para>
        /// </remarks>
        /// 
        public void AddWaveform(string name, Color color, int width, bool updateYRange)
        {
            Waveform series = new Waveform();
            series.color = color;
            series.width = width;
            series.updateYRange = updateYRange;

            waveTable.Add(name, series);
        }
コード例 #51
0
ファイル: LFO.cs プロジェクト: XY01/RadialMenu-Unity
    public static float Evaluate( Waveform wave, float normalizedInput )
    {
        normalizedInput = WrapFloatToRange(normalizedInput, 0f, 1f);

        if( wave == Wave.Waveform.Sin )
        {
            float currentAmplitude = Mathf.Sin( normalizedInput * 360 * Mathf.Deg2Rad );
            return ( currentAmplitude + 1 ) * .5f; // Normalizes the current amplitude to 0 - 1
        }
        else if( wave == Wave.Waveform.Cos )
        {
            float currentAmplitude = Mathf.Cos( normalizedInput * 360 * Mathf.Deg2Rad );
            return ( currentAmplitude + 1 ) * .5f; // Normalizes the current amplitude to 0 - 1
        }
        else if( wave == Wave.Waveform.Tan )
        {
            float currentAmplitude = Mathf.Tan( normalizedInput * 360 * Mathf.Deg2Rad );
            return ( currentAmplitude + 1 ) * .5f; // Normalizes the current amplitude to 0 - 1
        }
        else if( wave == Wave.Waveform.Sqrt )
        {
            return Mathf.Sqrt( normalizedInput );
        }
        else if( wave == Wave.Waveform.Sqr )
        {
            return normalizedInput * normalizedInput;
        }
        else if( wave == Wave.Waveform.SawUp )
        {
            return normalizedInput;
        }
        else if( wave == Wave.Waveform.SawDown )
        {
            return 1 - normalizedInput;
        }
        else if( wave == Wave.Waveform.Square )
        {
            if( normalizedInput > .5f )
                return 1;
            else
                return 0;
        }

        return 0;
    }