Esempio n. 1
0
        public void WriteReportToConsole()
        {
            if (_durations.Count == 0)
            {
                return;
            }
            @"
---------------------------------------------
Build Time Report
---------------------------------------------".ToConsole();
            var longest = Durations.OrderByDescending(t => t.Key.Length).First().Key.Length;

            longest = Math.Max("Name".Length, longest);
            Console.WriteLine("{0,-" + longest + "}  {1}", "Name", "Duration");
            Console.WriteLine("{0,-" + longest + "}  {1}", "----", "--------");
            foreach (var time in Durations)
            {
                Console.WriteLine("{0,-" + longest + "}  {1}", time.Key, time.Value.ToString());
            }
            var old = Console.ForegroundColor;

            Console.ForegroundColor = ConsoleColor.Magenta;
            "---------------------------------------------".ToConsole();
            Console.WriteLine("{0}  {1}", "Total:".PadRight(longest), TotalDuration);
            Console.ForegroundColor = old;
            Console.WriteLine();
        }
Esempio n. 2
0
    public void Constructor()
    {
        var durations = new Durations(1, 2);

        Assert.AreEqual(1, durations.Duration1);
        Assert.AreEqual(2, durations.Duration2);
    }
Esempio n. 3
0
        protected override string InternalToString(Tune t)
        {
            Durations previousDuration = DefaultDuration;
            Scales    previousScale    = DefaultScale;

            var sb = new StringBuilder();

            foreach (var tuneElement in t.TuneElementList)
            {
                if (tuneElement.Dotted)
                {
                    sb.Append(OpenBracket);
                }

                AppendNoteOrPause(sb, tuneElement);

                if (tuneElement.Dotted)
                {
                    sb.Append(CloseBracket);
                }

                previousDuration = AppendDurationKey(sb, tuneElement, previousDuration);

                AppendSharpKey(sb, tuneElement);

                previousScale = AppendScaleKey(sb, tuneElement, previousScale);

                sb.Append(TuneElementDelimiter);
            }

            return(sb.ToString().TrimEnd());
        }
Esempio n. 4
0
        public async Task <IActionResult> Edit(int id, [Bind("Id,Code,Details")] Durations durations)
        {
            if (id != durations.Id)
            {
                return(NotFound());
            }

            if (ModelState.IsValid)
            {
                try
                {
                    _context.Update(durations);
                    await _context.SaveChangesAsync();
                }
                catch (DbUpdateConcurrencyException)
                {
                    if (!DurationsExists(durations.Id))
                    {
                        return(NotFound());
                    }
                    else
                    {
                        throw;
                    }
                }
                return(RedirectToAction(nameof(Index)));
            }
            return(View(durations));
        }
        /// <summary>
        /// Returns true if ConfigResponse instances are equal
        /// </summary>
        /// <param name="other">Instance of ConfigResponse to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(ConfigResponse other)
        {
            if (ReferenceEquals(null, other))
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     AccountManager == other.AccountManager ||
                     AccountManager != null &&
                     AccountManager.SequenceEqual(other.AccountManager)
                     ) &&
                 (
                     Durations == other.Durations ||
                     Durations != null &&
                     Durations.SequenceEqual(other.Durations)
                 ) &&
                 (
                     PullingInterval == other.PullingInterval ||
                     PullingInterval != null &&
                     PullingInterval.Equals(other.PullingInterval)
                 ));
        }
    public void createScale()
    {
        string[] words       = firstNote.Split(' ');
        string   initialNote = words[0];

        UnityEngine.Debug.Log("initial: " + initialNote);
        string intString   = words[1];
        int    numberScale = 0;

        if (!Int32.TryParse(intString, out numberScale))
        {
            numberScale = -1;
        }
        int sum  = 0;
        int midi = NoteToMidi(initialNote, numberScale);

        for (int i = 0; i <= 7; i++)
        {
            List <double> midiDuration = new List <double>();

            if (i != 0)
            {
                sum = sum + (int)intervals[i - 1];
            }
            int midiBase = midi;
            midiBase = midiBase + sum;
            UnityEngine.Debug.Log("[Create scale]Midi note: " + midiBase);
            Durations realDuration = (Durations)duration;
            Note      not          = new Note(midiBase, realDuration, false);
            midiDuration.Add(midiBase);
            midiDuration.Add(duration);
            list_notes.Add(not);
        }
    }
Esempio n. 7
0
    public void StartBuilding(string buttonContent)
    {
        Debug.Log("button click: " + buttonContent);
        if (buttonContent == "add-stall")
        {
            if (PlayerEconomy.Money >= Prices.GetStallConstructionPrice(unlockedStalls))
            {
                PlayerEconomy.PayMoney(Prices.GetStallConstructionPrice(unlockedStalls));


                //enable GO, construction
                stalls [unlockedStalls].gameObject.SetActive(true);
                stalls [unlockedStalls].underConstruction.SetActive(true);
                for (int i = 0; i < stalls [unlockedStalls].finished.Length; ++i)
                {
                    stalls [unlockedStalls].finished [i].SetActive(false);
                }

                //store in duration dict. index is nr of unlocked stalls
                constructionDaysRemainingPerStallIndex.Add(unlockedStalls, Durations.GetStallConstructionDuration(unlockedStalls));
                UI.instance.constructionUI.underConstructionDaysRemaining.text = constructionDaysRemainingPerStallIndex[unlockedStalls].ToString() + " " + GetDayPluralSingular(constructionDaysRemainingPerStallIndex[unlockedStalls]) + " remaining";

                unlockedStalls++;

                UI.instance.constructionUI.hideOnConstruction.SetActive(false);
                UI.instance.constructionUI.showOnConstruction.SetActive(true);
            }
            else
            {
                Debug.Log("not enough money for stall construction!");
            }
        }
    }
Esempio n. 8
0
        public static List <Beep> CompileScript(string script, int key, double volume, double bpm, out int duration)
        {
            int    currKey = key;
            double currVolume = volume, currBpm = bpm;
            double position = 0;             // number of samples into the tune

            List <Beep> beeps = new List <Beep>();

            foreach (string token in GetNonCommentTokens(script))
            {
                if (token[0] == '@')
                {
                    ParseSettings(token, ref currKey, ref currVolume, ref currBpm, key, volume, bpm);
                    continue;
                }

                double noteDuration = 0, mult = 1.0;
                int    i = token.Length - 1;
                while (i >= 0)
                {
                    if (token[i] == '.')
                    {
                        mult *= 1.5;
                    }
                    else if (token[i] == 't')
                    {
                        mult *= 2.0 / 3;
                    }
                    else if (Durations.TryGetValue(char.ToLower(token[i]), out double temp))
                    {
                        noteDuration += temp * mult;
                        mult          = 1.0;
                    }
                    else                     // reaching the pitch code
                    {
                        break;
                    }

                    i--;
                }
                if (noteDuration == 0)                 // a default quarter note
                {
                    noteDuration = mult;
                }

                double freq = 0;
                if (i >= 0)                 // an actual note (not a rest)
                {
                    freq = Note.GetFreq(Note.Parse(token.Substring(0, i + 1), currKey));
                }

                beeps.Add(new Beep((int)(position + 0.5), freq, currVolume, (int)(noteDuration * 60 * Note.SampleRate / currBpm + 0.5)));

                position += noteDuration * 60 * Note.SampleRate / currBpm;
            }

            duration = (int)(position + 0.5);

            return(beeps);
        }
Esempio n. 9
0
 public void Stop()
 {
     Durations.Add(new Duration {
         Start = LastStartDate ?? DateTimeOffset.Now, End = DateTimeOffset.Now
     });
     LastStartDate = null;
 }
Esempio n. 10
0
        public void Show(Positions pos = Positions.Bottom, Durations duration = Durations.Short)
        {
            if (this.IsShowing)
            {
                this.CTS.Cancel();
                this.CTS.Dispose();
                this.CTS = null;
                this.CTS = new CancellationTokenSource();
            }
            else
            {
                var window = UIApplication.SharedApplication.KeyWindow;
                window.AddSubview(this.Container.Value);
            }
            this.IsShowing = true;

            this.Container.Value.Center = this.GetCenter(pos);

            var ms = duration == Durations.Long ? 5000 : 2000;

            Task.Delay(ms)
            .ContinueWith(t =>
            {
                this.Dismiss();
            }
                          , this.CTS.Token);
        }
Esempio n. 11
0
        /// <summary>
        /// Updates the parts[] vector based on the current rhythm gene being a rest.
        /// </summary>
        /// <param name="i"></param>
        /// <param name="rhythmGene"></param>
        /// <param name="rhythmSoloPart0"></param>
        private void ProcessRestGene(ref int i, char rhythmGene)
        {
            byte   addDur = 0;
            string temps;
            byte   maxIterate        = Parameters.maxIterate;
            byte   genotypeIterate_0 = Parameters.genotypeIterate[0];

            string[] rhythmSoloPart0 = currentRhythmChromosome[0];

            parts[0] += "R";
            parts[1] += "R";
            parts[2] += "R|";
            parts[3] += "R|";

            do
            {
                addDur++;
                i++;

                if (i == maxIterate || i % genotypeIterate_0 == 0)
                {
                    break;
                }
                else
                {
                    rhythmGene = RhythmDecode(rhythmSoloPart0[i]);
                }
            }while ((rhythmGene == 'r' || rhythmGene == 'c'));

            temps     = Durations.FinalDuration(Parameters.durationIndex, addDur);
            parts[0] += temps + " ";
            parts[1] += temps + " ";
            parts[2] += addDur + " ";
            parts[3] += addDur + " ";
        }
        public DurationPercentiles(IEnumerable <double> durations)
        {
            Durations = durations.OrderBy(x => x).ToImmutableArray();

            if (!Durations.Any())
            {
                throw new ArgumentException(@"Durations must have at least one element", nameof(durations));
            }
        }
Esempio n. 13
0
    private void OpenConstructionWindow()
    {
        UI.instance.constructionUI.gameObject.SetActive(true);


        if (constructionDaysRemainingPerStallIndex.Count > 0)
        {
            UI.instance.constructionUI.showOnConstruction.SetActive(true);
            UI.instance.constructionUI.hideOnConstruction.SetActive(false);
            UI.instance.constructionUI.underConstructionDaysRemaining.text = constructionDaysRemainingPerStallIndex [unlockedStalls - 1].ToString() + " " + GetDayPluralSingular(constructionDaysRemainingPerStallIndex [unlockedStalls - 1]) + " remaining";
        }
        else
        {
            UI.instance.constructionUI.showOnConstruction.SetActive(false);
            UI.instance.constructionUI.hideOnConstruction.SetActive(true);
        }



        //the number of unlocked stalls (i.e. 1 at the start) equals the index of the next to unlock
        UI.instance.constructionUI.priceForNextStall.text    = Prices.GetStallConstructionPrice(unlockedStalls).ToString() + "¢";
        UI.instance.constructionUI.durationForNextStall.text = Durations.GetStallConstructionDuration(unlockedStalls).ToString() + " " + GetDayPluralSingular(Durations.GetStallConstructionDuration(unlockedStalls));

        //partition text
        if (unlockedStalls == 1)
        {
            UI.instance.constructionUI.partitionText.text = "You only have one stall, all walls are needed.";
        }
        else
        {
            UI.instance.constructionUI.partitionText.text = "Click the white/brown toggles to enable or disable the partitions between paddocks.";
        }

        for (int i = 0; i < UI.instance.constructionUI.paddockToggles.Length; ++i)
        {
            if (i < unlockedStalls)
            {
                UI.instance.constructionUI.paddockToggles [i].gameObject.SetActive(true);
                UI.instance.constructionUI.paddockToggles [i].toggle.isOn = partitionsEnabled [i];
            }
            else
            {
                UI.instance.constructionUI.paddockToggles [i].gameObject.SetActive(false);
            }
            //enable all here so I can disable the right one below, otherwise it won't work again after changes
            if (constructionDaysRemainingPerStallIndex.ContainsKey(i + 1) && constructionDaysRemainingPerStallIndex [i + 1] > 0)
            {
                UI.instance.constructionUI.paddockToggles [i].toggle.gameObject.SetActive(false);
            }
            else
            {
                UI.instance.constructionUI.paddockToggles [i].toggle.gameObject.SetActive(true);
            }
        }

        UI.instance.constructionUI.paddockToggles [unlockedStalls - 1].toggle.gameObject.SetActive(false);
    }
Esempio n. 14
0
 /// <summary>
 /// Accept method for the input data visitor.
 /// </summary>
 /// <param name="visitor">Visitor.</param>
 public void Accept(IVisitor visitor)
 {
     visitor.Visit(this);
     Parameters.Accept(visitor);
     Durations.Accept(visitor);
     Conditions.Accept(visitor);
     Effects.Accept(visitor);
     visitor.PostVisit(this);
 }
        public void Update(bool inFlow, IDataPacketJSON packet)
        {
            if (inFlow == true)
            {
                CarCount += packet.interactions.Count;
                return;
            }

            else
            {
                foreach (var interaction in packet.interactions)
                {
                    CarCount--;

                    double duration = interaction.duration;
                    Sum += duration;

                    if (Durations.Count == MAX_STORE)
                    {
                        double removed = Durations[0];
                        Durations.RemoveAt(0);
                        Sum -= removed;
                    }

                    Durations.Add(duration);
                    MeanDuration = Sum / Durations.Count;
                }
            }

            IDevice dev = Dictionaries.Devices[packet.deviceID];
            int nodeBID = dev.Edge.NodeB.NodeID;
            Ellipse e = Dictionaries.NodeEllipses[nodeBID];

            try
            {
                e.Dispatcher.Invoke(() =>
                {
                    if (MeanDuration < ORANGE_THRESHOLD)
                    {
                        e.Fill = new SolidColorBrush(Colors.GreenYellow);
                    }
                    else if (MeanDuration < RED_THRESHOLD)
                    {
                        e.Fill = new SolidColorBrush(Colors.Orange);
                    }
                    else
                    {
                        e.Fill = new SolidColorBrush(Colors.Red);
                    }
                });
            }
            catch { }      

            Dictionaries.SetColours();
        }
    public LongNotesExercise(string tune, int beats, string timeSignature, string note, int duration, int numberNotes) : base(tune, beats, timeSignature)
    {
        this.note        = note;
        this.numberNotes = numberNotes;
        try{
            this.duration = (Durations)duration;
        }catch (Exception) {
        }

        createLongNotesExercise();
    }
Esempio n. 17
0
        public async Task <IActionResult> Create([Bind("Id,Code,Details")] Durations durations)
        {
            if (ModelState.IsValid)
            {
                _context.Add(durations);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            return(View(durations));
        }
Esempio n. 18
0
        public void drawScala(Exercise exercise, GameObject noteImage, GameObject quaver)
        {
            //parser.LoadJson5();
            for (int i = 0; i < exercise.list_notes.Count; ++i)
            {
                var       midi     = exercise.list_notes[i].midi;
                Durations duration = exercise.list_notes[i].duration;

                graphicalInterface.drawNote(midi, duration, noteImage, quaver, i);
            }
            //graphicalInter
            //graphicalInterface.drawScala(scale,noteImage);
        }
        public Task Execute(IJobExecutionContext context)
        {
            DateTime now = DateTime.UtcNow;

            log.Info("Fire time: " + now);
            if (lastFireTime != null)
            {
                Durations.Add(now - lastFireTime.Value);
            }

            lastFireTime = now;
            return(Task.CompletedTask);
        }
Esempio n. 20
0
        /// <summary>
        /// Updates the parts[] vector based on the current rhythm gene being a note.
        /// </summary>
        /// <param name="i"></param>
        /// <param name="rhythmGene"></param>
        /// <param name="pitchSoloPart0"></param>
        /// <param name="pitchSoloPart1"></param>
        /// <param name="velocitySoloPart0"></param>
        /// <param name="velocitySoloPart1"></param>
        /// <param name="rhythmSoloPart0"></param>
        private void ProcessPitchGene(ref int i, char rhythmGene)
        {
            byte note1, note2;
            byte velocity1, velocity2;
            byte addDur = 1, fP;
            int  j;
            byte genotypeIterate_0 = Parameters.genotypeIterate[0];
            byte maxIterate        = Parameters.maxIterate;
            byte keySignatureIndex = Parameters.keySignatureIndex;

            byte[] octaves  = Parameters.octavesByteValues;
            string duration = Durations.FinalDuration(Parameters.durationIndex, addDur);

            int[]    pitchSoloPart0    = currentPitchChromosome[0];
            int[]    pitchSoloPart1    = currentPitchChromosome[1];
            byte[]   velocitySoloPart0 = currentVelocityChromosome[0];
            byte[]   velocitySoloPart1 = currentVelocityChromosome[1];
            string[] rhythmSoloPart0   = currentRhythmChromosome[0];

            do
            {
                fP        = Scales.FirstPitch(octaves[0], keySignatureIndex);
                note1     = PitchSolo1Decode(pitchSoloPart0[i], fP);
                velocity1 = VelocityDecode(velocitySoloPart0[i]);
                parts[0] += "[" + note1.ToString() + "]" + duration + "V" + velocity1.ToString() + " ";
                j         = note1 - fP;
                parts[2] += ActualOctave(j, 0).ToString() +  //(byte)Parameters.octaves[0] +
                            "|" + Scales.scales[keySignatureIndex][j] + "|" + addDur + " ";

                fP        = Scales.FirstPitch(octaves[1], keySignatureIndex);
                note2     = PitchSolo2Decode(pitchSoloPart1[i], note1, fP);
                velocity2 = VelocityDecode(velocitySoloPart1[i]);
                parts[1] += "[" + note2.ToString() + "]" + duration + "V" + velocity2.ToString() + " ";
                j         = note2 - fP;
                parts[3] += ActualOctave(j, 1).ToString() +  //(byte)Parameters.octaves[0] +
                            "|" + Scales.scales[keySignatureIndex][j] + "|" + addDur + " ";

                i++;

                if (i == maxIterate || i % genotypeIterate_0 == 0)
                {
                    break;
                }
                else
                {
                    rhythmGene = RhythmDecode(rhythmSoloPart0[i]);
                }
            }while (rhythmGene == 'p');
        }
Esempio n. 21
0
        private int AmountOfBeams(Durations duration)
        {
            switch (duration)
            {
            case Durations.Eight:
                return(1);

            case Durations.Sixteenth:
                return(2);

            case Durations.ThirtySecond:
                return(3);

            default:
                return(0);
            }
        }
Esempio n. 22
0
 /// <summary>
 /// 联网获取 Durations 数据
 /// </summary>
 /// <param name="apiKey"></param>
 /// <param name="date"></param>
 /// <returns></returns>
 private static List <Durations> GetDurations(string apiKey, DateTime date)
 {
     try
     {
         string           durationsUrl = string.Format("{0}durations?api_key={1}&date={2}", BaseUrl, apiKey, date.ToString("yyyy-MM-dd"));
         JToken           root         = HttpTool.Get <JToken>(durationsUrl, "gb2312");
         JToken           durations    = root.SelectToken("data");
         List <Durations> result       = new List <Durations>();
         foreach (var item in durations)
         {
             Durations obj = item.ToObject <Durations>();
             result.Add(obj);
         }
         return(result);
     }
     catch (Exception e) { }
     return(null);
 }
        public void Calculate()
        {
            Results.Add(new BuildDeploymentMetric
            {
                Date               = Date,
                IntervalTime       = CalculateAverageTimeInDaysFor(Intervals),
                IntervalTimeStdDev =
                    Calculator.ConvertMillisecondsToDays(
                        Calculator.CalculateStandardDeviation(Intervals)),
                DurationTime       = CalculateAverageTimeInHoursFor(Durations),
                DurationTimeStdDev =
                    Calculator.ConvertMillisecondsToHours(
                        Calculator.CalculateStandardDeviation(Durations))
            });

            Intervals.Clear();
            Durations.Clear();
        }
    /// <summary>
    /// Find t in s = 0.5*a*t² + v0*t
    /// </summary>
    /// <param name="s">The distance [m].</param>
    /// <param name="a">The acceleration [m/s²].</param>
    /// <param name="v0">The initial velocity [m/s].</param>
    /// <exception cref="NegativeValueException">Thrown, if the given distance will never be reached.</exception>
    /// <returns>Returns the duration [s].</returns>
    public static Durations GetDuration(double s, double a, double v0)
    {
        if (a == 0)
        {
            var t = SteadyMotion.GetDuration(s, v0);
            return(new Durations(t, t));
        }
        var sqrt = 2 * a * s + v0 * v0;

        if (sqrt < 0)
        {
            throw new NegativeValueException($"The distance {s}m will never be reached starting with a velocity of {v0}m/s and accelerating with {a}m/s²");
        }
        var t1        = (-Math.Sqrt(sqrt) - v0) / a;
        var t2        = (Math.Sqrt(sqrt) - v0) / a;
        var durations = new Durations(t1, t2);

        return(durations);
    }
 /// <summary>
 /// Gets the hash code
 /// </summary>
 /// <returns>Hash code</returns>
 public override int GetHashCode()
 {
     unchecked // Overflow is fine, just wrap
     {
         var hashCode = 41;
         // Suitable nullity checks etc, of course :)
         if (AccountManager != null)
         {
             hashCode = hashCode * 59 + AccountManager.GetHashCode();
         }
         if (Durations != null)
         {
             hashCode = hashCode * 59 + Durations.GetHashCode();
         }
         if (PullingInterval != null)
         {
             hashCode = hashCode * 59 + PullingInterval.GetHashCode();
         }
         return(hashCode);
     }
 }
Esempio n. 26
0
        private void EditExistingTuneElement(char c, int index)
        {
            var tuneElementWithLength = nokiaComposerTuneElementList[index];
            var tuneElement           = tuneElementWithLength.TuneElement;
            var note = tuneElement as Note;

            switch (c)
            {
            case '8':
                tuneElement.DecreaseDuration();
                previousDuration = tuneElement.Duration;
                break;

            case '9':
                tuneElement.IncreaseDuration();
                previousDuration = tuneElement.Duration;
                break;

            case '*':
                if (note != null)
                {
                    note.IncreaseScaleModulo();
                    previousScale = note.Scale;
                }
                break;

            case '#':
                if (note != null)
                {
                    note.ToggleSharp();
                }
                break;
            }

            tuneElementWithLength.ComputeElementStringLength();

            nokiaComposerTuneElementList[index] = tuneElementWithLength;

            CurrentTuneElement = tuneElementWithLength.TuneElement;
        }
/*
 *  public void drawScala(Exercise exercise,GameObject noteImage){
 *
 *              for (int i = 0; i < exercise.list_midisdurations.Count; ++i) {
 *
 *                      x = x + 2;
 *                      float value = midiToScreenCustomY(exercise.list_midisdurations[i][0]);
 *
 *              newNote.transform.position = new Vector3 (x, value);
 *
 *              }
 *
 *  }
 *
 */

    public void drawNote(int midi, Durations duration, GameObject noteImage, GameObject quaver, float position)
    {
        //prueba();
        this.noteImage = noteImage;
        this.quaver    = quaver;
        float xComponent = calculatePostion(position);

        UnityEngine.Debug.Log("Class[GUI] Method [drawNote] Midi Y: " + midi);
        float value = midiToScreenCustomY(midi);

        UnityEngine.Debug.Log("Class[GUI] Method [drawNote] Y: " + value);
        Sprite         noteSprite = getInitialSprite(duration, "black");
        GameObject     newNote    = new GameObject();  //Create the GameObject
        SpriteRenderer renderer   = newNote.AddComponent <SpriteRenderer>();

        renderer.sprite = noteSprite;
        //UnityEngine.Object.Instantiate<GameObject> (newNote);
        newNote.GetComponent <SpriteRenderer>().sprite = noteSprite;
        newNote.transform.localScale = new Vector3(2.34f, 2.34f, 0);
        newNote.transform.position   = new Vector3(xComponent, value);
        listGameObjects.Add(newNote);
    }
Esempio n. 28
0
        /// <summary>
        /// Updates the parts[] vector based on the current rhythm gene being a continuation.
        /// </summary>
        /// <param name="i"></param>
        /// <param name="rhythmGene"></param>
        /// <param name="velocitySoloPart0"></param>
        /// <param name="velocitySoloPart1"></param>
        /// <param name="rhythmSoloPart0"></param>
        private void ProcessContinuationGene(ref int i, char rhythmGene)
        {
            byte   velocity1, velocity2;
            byte   addDur = 1;
            string duration;
            byte   maxIterate        = Parameters.maxIterate;
            byte   genotypeIterate_0 = Parameters.genotypeIterate[0];

            string[] rhythmSoloPart0 = currentRhythmChromosome[0];

            parts[0] = parts[0].Remove(parts[0].LastIndexOf(']') + 1);
            parts[1] = parts[1].Remove(parts[1].LastIndexOf(']') + 1);
            parts[2] = parts[2].Remove(parts[2].LastIndexOf('|') + 1);
            parts[3] = parts[3].Remove(parts[3].LastIndexOf('|') + 1);

            velocity1 = VelocityDecode(currentVelocityChromosome[0][i]);
            velocity2 = VelocityDecode(currentVelocityChromosome[1][i]);

            do
            {
                addDur++;
                i++;

                if (i == maxIterate || i % genotypeIterate_0 == 0)
                {
                    break;
                }
                else
                {
                    rhythmGene = RhythmDecode(rhythmSoloPart0[i]);
                }
            }while (rhythmGene == 'c');

            duration  = Durations.FinalDuration(Parameters.durationIndex, addDur);
            parts[0] += duration + "V" + velocity1.ToString() + " ";
            parts[1] += duration + "V" + velocity2.ToString() + " ";
            parts[2] += addDur + " ";
            parts[3] += addDur + " ";
        }
Esempio n. 29
0
        public void changeColour(Durations dur, double percentage, int position)
        {
            string colour = "red";

            if (percentage >= 0.0 && percentage < 0.4)
            {
                colour = "red";
            }
            else if (percentage >= 0.4 && percentage <= 0.7)
            {
                colour = "yellow";
            }
            else
            {
                colour = "green";
            }


            Sprite sprit = graphicalInterface.getInitialSprite(dur, colour);

            graphicalInterface.listGameObjects[position].GetComponent <SpriteRenderer>().sprite = sprit;
        }
    public Sprite getInitialSprite(Durations dur, String colour)
    {
        Sprite sprit;

        sprit = null;
        UnityEngine.Debug.Log("Class[GUI] Method [getInitialSprite] Duration Y: " + dur);

        if (dur == Durations.Semibreve)
        {
            switch (colour)
            {
            case "green":
                sprit = Resources.Load <Sprite>("Sprites/semibreve/GreenSemibreve");
                break;

            case "black":
                sprit = Resources.Load <Sprite>("Sprites/semibreve/BlackSemibreve");
                break;

            case "red":
                sprit = Resources.Load <Sprite>("Sprites/semibreve/RedSemibreve");
                break;

            case "yellow":
                sprit = Resources.Load <Sprite>("Sprites/semibreve/YellowSemibreve");
                break;
            }
        }
        else if (dur == Durations.Minim)
        {
            switch (colour)
            {
            case "green":
                sprit = Resources.Load <Sprite>("Sprites/minim/GreenMinim");
                break;

            case "black":
                sprit = Resources.Load <Sprite>("Sprites/minim/BlackMinim");
                break;

            case "red":
                sprit = Resources.Load <Sprite>("Sprites/minim/RedMinim");
                break;

            case "yellow":
                sprit = Resources.Load <Sprite>("Sprites/minim/YellowMinim");
                break;
            }
        }
        else if (dur == Durations.Crotchet)
        {
            switch (colour)
            {
            case "green":
                sprit = Resources.Load <Sprite>("Sprites/crotchet/GreenCrotchet");
                break;

            case "black":
                sprit = Resources.Load <Sprite>("Sprites/crotchet/blackCrotchet");
                break;

            case "red":
                sprit = Resources.Load <Sprite>("Sprites/crotchet/RedCrotchet");
                break;

            case "yellow":
                sprit = Resources.Load <Sprite>("Sprites/crotchet/YellowCrotchet");
                break;
            }
        }
        else if (dur == Durations.Quaver)
        {
            switch (colour)
            {
            case "green":
                sprit = Resources.Load <Sprite>("Sprites/quaver/GreenQuaver");
                break;

            case "black":
                sprit = Resources.Load <Sprite>("Sprites/quaver/BlackQuaver");
                break;

            case "red":
                sprit = Resources.Load <Sprite>("Sprites/quaver/RedQuaver");
                break;

            case "yellow":
                sprit = Resources.Load <Sprite>("Sprites/quaver/YellowQuaver");
                break;
            }
        }

        return(sprit);
    }
Esempio n. 31
0
 public void AddNote(NoteNames name, int octave, Durations d)
 {
     AddNote(new Note(name, octave, d));
 }