Exemple #1
0
 private void RandomDelivery(Stimulus stim, UInt32 begin, UInt32 end)
 {
     for (int i = 0; i < stim.stims_per_sound; i++)
     {
         StimulusInterval interval;
         do
         {
             uint duration   = (uint)random.Next((int)stim.dur_min, (int)stim.dur_max);
             uint randomStim = (uint)random.Next((int)begin, (int)(end - duration));
             interval = new StimulusInterval(stim, randomStim, randomStim + duration);
         } while (stim.stimIntervals.Exists(a => a.Overlap(interval)));
         stim.stimIntervals.Add(interval);
     }
 }
Exemple #2
0
        private void RandomSyncedDelivery(Stimulus stim, UInt32 begin, UInt32 end)
        {
            Random          syncRandom      = new Random(randomSeed + begin.GetHashCode() + end.GetHashCode());
            List <Interval> bufferIntervals = new List <Interval>();

            for (int i = 0; i < stim.stims_per_sound; i++)
            {
                StimulusInterval interval;
                Interval         bufferInterval;
                do
                {
                    uint duration   = (uint)syncRandom.Next((int)(stim.dur_min), (int)(stim.dur_max));
                    uint buffer     = stim.dur_max + stim.interval_min;
                    uint randomStim = ((uint)syncRandom.Next((int)(begin), (int)(end - buffer)));
                    bufferInterval = new Interval(randomStim, randomStim + buffer);
                    interval       = new StimulusInterval(stim, randomStim, randomStim + duration);
                } while (bufferIntervals.Exists(a => a.Overlap(bufferInterval)));
                stim.stimIntervals.Add(interval);
                bufferIntervals.Add(bufferInterval);
            }
        }