コード例 #1
0
 /// <summary>
 /// Initializes a new major <see cref="Tetrachord"/>.
 /// </summary>
 public Tetrachord()
 {
     Name             = chordType.majorTetra.ToString();
     currentChordType = chordType.majorTetra;
     offset           = interval.maj2nd;
     Intervals        = ChordSpellings.intervalsIn[currentChordType];
 }
コード例 #2
0
ファイル: Scale.cs プロジェクト: mweechzing/Theory
    /// <summary>
    /// Parses the root intervals.
    /// </summary>
    /// <returns>The root chord.</returns>
    public interval[] ParseRootChord()     //TODO make this generic?
    {
        int chordSize = 0;

        for (int i = 0; i < scaleSize; i++)
        {
            if (i % 2 == 0)
            {
                chordSize++;
            }
        }

        interval[] tempIntervals    = new interval[chordSize];
        int        intervalPosition = 0;

        for (int i = 0; i < scaleSize - 1; i++)
        {
            if (i % 2 == 0)
            {
                tempIntervals [intervalPosition] = Intervals [i];
                intervalPosition++;
            }
        }

        return(tempIntervals);
    }
コード例 #3
0
 /// <summary>
 /// Initializes a new <see cref="Tetrachord"/>.
 /// </summary>
 /// <param name="_chord">Desired Chord Type.</param>
 /// <param name="_offset">Desired offset if upper.</param>
 public Tetrachord(chordType desiredChordType, interval desiredOffset)
 {
     Name             = desiredChordType.ToString();
     currentChordType = desiredChordType;
     offset           = desiredOffset;
     Intervals        = ChordSpellings.intervalsIn[currentChordType];
 }
コード例 #4
0
        private interval[] readTextGridIntervals(string[] lines, int iterador, int numberGrids)
        {
            interval[] res  = new interval[numberGrids];
            double     xmin = 0;
            double     xmax = 0;

            string xminString         = "xmin = ";
            string xmaxString         = "xmax = ";
            string intervalTextString = "text = \"";

            string intervalText = "";

            for (int i = 0; i < numberGrids; i++)
            {
                xmin = Convert.ToDouble((lines[iterador + ((i * 4) + 1)].Substring((lines[iterador + ((i * 4) + 1)].IndexOf(xminString) + xminString.Length)).Replace('.', ',')));
                xmax = Convert.ToDouble((lines[iterador + ((i * 4) + 2)].Substring((lines[iterador + ((i * 4) + 2)].IndexOf(xmaxString) + xmaxString.Length)).Replace('.', ',')));

                intervalText = lines[iterador + ((i * 4) + 3)].Substring((lines[iterador + ((i * 4) + 3)].IndexOf(intervalTextString) + intervalTextString.Length));
                intervalText = intervalText.Substring(0, intervalText.Length - 1);

                res[i] = new interval(xmin, xmax, intervalText);
            }

            return(res);
        }
コード例 #5
0
ファイル: Payment.cs プロジェクト: alexk1331/Accountant
 public Payment(string n, DateTime dp, int t, double cfp, bool rep, interval inter, string com)
 {
     if (Account.payments.Count == 0)
     {
         code = 0;
     }
     else
     {
         code = Account.payments.Last().code + 1;
     }
     name             = n;
     dayp             = dp;
     type             = t;
     inf.costforpoint = cfp;
     repeated         = rep;
     payed            = false;
     interv           = inter;
     if (repeated == false)
     {
         interv.days  = 0;
         interv.month = 0;
         interv.years = 0;
     }
     inf.curstat  = 1;
     inf.prevstat = 0;
     cost         = Math.Round(inf.costforpoint * (inf.curstat - inf.prevstat), 2);
     comments     = com;
 }
コード例 #6
0
ファイル: Program.cs プロジェクト: pmiriyals/Arrays
        static void MergeIntervals(interval[] intervals)
        {
            intervals = intervals.OrderBy(o => o.start).ToArray();
            Console.WriteLine("Intervals after sorting: ");
            foreach (interval i in intervals)
            {
                Console.WriteLine("({0}, {1})", i.start, i.end);
            }

            Stack<interval> stk = new Stack<interval>();
            stk.Push(intervals[0]);

            for (int i = 1; i < intervals.Length; i++)
            {
                if (stk.Count > 0)
                {
                    if (stk.Peek().end < intervals[i].start)
                        stk.Push(intervals[i]);
                    else if (stk.Peek().end < intervals[i].end)
                        stk.Peek().end = intervals[i].end;
                    else if (stk.Peek().end > intervals[i].end)
                        continue;
                }
                else
                    stk.Push(intervals[i]);
            }
            Console.WriteLine("\nIntervals after merging: ");
            while(stk.Count > 0)
            {
                interval inter = stk.Pop();
                Console.WriteLine("({0}, {1})", inter.start, inter.end);
            }
        }
コード例 #7
0
 /// <summary>
 /// Initializes a new instance of the <see cref="Tetrachord"/> class.
 /// </summary>
 /// <param name="desiredChordType">Desired chord type.</param>
 public Tetrachord(chordType desiredChordType)
 {
     //Debug.Log ("Lower Tetra ininialized");
     offset           = interval.root;
     currentChordType = desiredChordType;
     //upper or lower
     Intervals = ChordSpellings.intervalsIn[desiredChordType];
 }
コード例 #8
0
ファイル: Note.cs プロジェクト: mweechzing/Theory
    /// <summary>
    /// Initializes a new diatonic <see cref="Note"/>.
    /// </summary>
    /// <param name="newNote">Desired Note</param>
    /// <param name="currentDiatonicInterval">Position in scale</param>
    public Note(note newNote, interval currentDiatonicInterval)
    {
        duration = Beat.quarter;
        key      = theory.AdjustForScale(key - (int)currentDiatonicInterval);
        octave   = 0;
        name     = newNote.ToString() + octave.ToString();

        diatonicInterval = currentDiatonicInterval;
        frequencyKey     = GetFrequencyKey(currentDiatonicInterval);
    }
コード例 #9
0
ファイル: RangeCounter.cs プロジェクト: SOFAgh/CADability
            int IComparable.CompareTo(object obj)
            {
                interval other = obj as interval;

                if (other != null)
                {   // muss ja immer sein
                    // die Intervalle sind immer nicht überlappend
                    return(min.CompareTo(other.min));
                }
                return(-1);
            }
コード例 #10
0
 /// <summary>
 /// Adjusts for scale.
 /// </summary>
 /// <returns>The for scale.</returns>
 /// <param name="scalePosition">Scale position.</param>
 public interval AdjustForScale(interval scalePosition)
 {
     while (scalePosition > (interval)TOTAL_NOTES)
     {
         scalePosition -= TOTAL_NOTES;
     }
     while (scalePosition < 0)
     {
         scalePosition += TOTAL_NOTES;
     }
     return(scalePosition);
 }
コード例 #11
0
ファイル: Scale.cs プロジェクト: mweechzing/Theory
 /// <summary>
 /// Initializes an A Major scale.
 /// </summary>
 public Scale()     //TODO do something about these constructors dude.
 {
     Key         = note.A;
     ModalKey    = note.A;
     currentMode = modes.ionian;
     Name        = note.A.ToString() + " " + scaleType.major.ToString();
     AssignUpperAndLower(ScaleBook.allScales [scaleType.major]);
     upperTetraOffset = upperTetra.Offset;
     Intervals        = CombineTetrachords(lowerTetra, upperTetra, upperTetraOffset);
     Notes            = GenerateNotes(ModalKey, Intervals);
     scaleSize        = Intervals.Length;
 }
コード例 #12
0
ファイル: Scale.cs プロジェクト: mweechzing/Theory
 /// <summary>
 /// Initializes a scale by key and type, adds the id to name.
 /// </summary>
 /// <param name="inKey">Desired Key.</param>
 /// <param name="type">Desired Scale Type.</param>
 /// <param name="id">Identifier.</param>
 public Scale(note inKey, scaleType type, int id)
 {
     Key         = inKey;
     ModalKey    = inKey;
     currentMode = modes.ionian;
     Name        = inKey.ToString() + " " + type.ToString() + " _" + id.ToString();
     AssignUpperAndLower(ScaleBook.allScales [type]);
     upperTetraOffset = upperTetra.Offset;
     Intervals        = CombineTetrachords(lowerTetra, upperTetra, upperTetraOffset);
     Notes            = GenerateNotes(Key, Intervals);
     scaleSize        = Intervals.Length;
 }
コード例 #13
0
        public static void ConjugateGradientMethod(double[] X0, ref double[] res, double intervalStep)
        {
            double[] destinationVect = new double[N];
            double   skalarWeight;

            double[] xNow     = new double[N];
            double[] xPrev    = new double[N];
            double[] gradNow  = new double[N];
            double[] gradPrev = new double[N];
            double   t        = 0.0;
            interval inter    = new interval();

            for (int i = 0; i < N; i++)
            {
                X0[i] = xNow[i];
            }

            do
            {
                //for(int l = 0; l<2000;l++){
                for (int i = 0; i < N; i++)
                {
                    destinationVect[i] = -xNow[i];
                }

                for (int k = 0; k <= N; k++)
                {
                    inter = Swan(0, intervalStep, xNow, destinationVect);
                    t     = GoldenMethod(inter.a, inter.b, xNow, destinationVect);
                    Console.WriteLine("t = {0}", t);

                    for (int i = 0; i < N; i++)
                    {
                        xPrev[i] = xNow[i];
                        xNow[i]  = xPrev[i] + t * destinationVect[i];
                        Console.Write("X[{0}] = {1} ", i, xNow[i]);
                    }

                    Console.WriteLine();
                    gradient(xNow, ref gradNow);
                    gradient(xPrev, ref gradPrev);
                    skalarWeight = fletcher(gradNow, gradPrev);

                    for (int i = 0; i < N; i++)
                    {
                        destinationVect[i] = -gradNow[i] + skalarWeight * destinationVect[i];
                        Console.Write("dest[{0}] = {1} ", i, destinationVect[i]);
                    }
                    Console.WriteLine();
                }
            } while (Math.Abs(f(xNow) - f(xPrev)) / f(xNow) > eps);
        }
コード例 #14
0
        private static CallCosts CreateCallCostsRequest(string userID)
        {
            CallCosts request = new CallCosts();

            // Required fields
            request.ItemElementName = ItemChoiceType35.userID;
            request.Item            = userID;

            interval callCostsInterval = new interval();

            callCostsInterval.startDate = System.DateTime.Parse("2011-03-01");
            callCostsInterval.endDate   = System.DateTime.Parse("2011-04-01");
            request.Items            = new object[] { callCostsInterval };
            request.ItemsElementName = new ItemsChoiceType8[] { ItemsChoiceType8.interval };

            return(request);
        }
コード例 #15
0
    public void TransposeInPlace(CollectionOfNotes originalSet, interval interval, direction direction)
    {
        note key = originalSet.Key;

        //Note[] notes = originalSet.Notes;
        //interval[] intervals = originalSet.Intervals;

        if (direction == direction.sharp)
        {
            key += theory.AdjustForScale((int)interval);
        }
        else
        {
            key -= theory.AdjustForScale((int)interval);
        }
        //notes = originalSet.GenerateNotes (key, intervals);
        originalSet.ModalKey = key;
    }
コード例 #16
0
        //http://www.geeksforgeeks.org/stock-buy-sell/
        //Buy and Sell as many time as possible to get maximum profit
        static void N_MaxProfit(int[] prices)
        {
            int n = prices.Length;

            interval[] sell_buy_Pairs = new interval[(n / 2) + 1];
            int        c = 0;
            int        i = 0;

            while (i < n - 1)
            {
                //Find local minima from i. We can go up to max n-2 becuase we are checking with next element
                while (i < n - 1 && prices[i + 1] <= prices[i])
                {
                    i++;
                }

                if (i == n - 1) //We reached end of the array. So, no chance of buying
                {
                    break;
                }

                sell_buy_Pairs[c].Buy = i;
                i++;

                //Find next local maxima from i. We can go up to max n-1 becuase we are checking with previous element
                while (i < n && prices[i - 1] <= prices[i])
                {
                    i++;
                }

                sell_buy_Pairs[c].Sell = i - 1;
                c++;
            }
            Console.WriteLine("Here are buy and sell indices");
            int totalProfit = 0;

            for (int k = 0; k < c; k++)
            {
                Console.WriteLine($"({k + 1}) BUY at : {prices[sell_buy_Pairs[k].Buy]} and SELL at :{prices[sell_buy_Pairs[k].Sell]} ");
                totalProfit += prices[sell_buy_Pairs[k].Sell] - prices[sell_buy_Pairs[k].Buy];
            }
            Console.WriteLine($"Total Profit:{totalProfit}");
        }
コード例 #17
0
ファイル: Scale.cs プロジェクト: mweechzing/Theory
    /// <summary>
    /// Combines tetrachords into a fully qualified scale
    /// </summary>
    /// <returns>The tetrachords.</returns>
    /// <param name="lower">Lower.</param>
    /// <param name="upper">Upper.</param>
    /// <param name="upperOffset">The distance between lower.notes[0] and upper.notes[0]</param>
    interval[] CombineTetrachords(Tetrachord lower, Tetrachord upper, interval upperOffset)
    {
        interval[] tempIntervals = new interval[lowerTetra.Intervals.Length + upperTetra.Intervals.Length];

        for (int i = 0; i < tempIntervals.Length; i++)
        {
            int offset = i;
            if (offset < lowerTetra.Intervals.Length)
            {
                tempIntervals [offset] = lowerTetra.Intervals [offset];
            }
            else
            {
                offset            = i - lowerTetra.Intervals.Length;
                tempIntervals [i] = theory.AdjustForScale(upperTetra.Intervals [offset] + (int)upperOffset);
            }
        }
        Debug.Log("New Scale Size: " + tempIntervals.Length);
        return(tempIntervals);
    }
コード例 #18
0
ファイル: Form1.cs プロジェクト: marina128/Lab-9
        private void buttonOk_Click(object sender, EventArgs e)
        {
            try
            {
                dataGridView1.Rows.Clear();
                interval x = new interval(UInt32.Parse(LeftIntBox.Text), UInt32.Parse(RightIntBox.Text));

                PrimaryInInterval arg;
                arg.Int          = x;
                arg.ThreadNumber = byte.Parse(StreamBox.Text);

                backgroundWorker1.RunWorkerAsync(arg);

                buttonOk.Enabled = false;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message, "Ошибка", MessageBoxButtons.OK, MessageBoxIcon.Error);
                ErrFlag = true;
            }
        }
コード例 #19
0
        public string AddBoldTag(string s, string[] words)
        {
            var list = new List <interval>();
            var sb   = new StringBuilder();

            for (int i = 0; i < s.Length; i++)
            {
                foreach (string w in words)
                {
                    if (s.Substring(i).StartsWith(w))
                    {
                        var str = new interval(i, i + w.Length - 1);
                        // add
                        if (list.Count > 0 && i <= list[list.Count - 1].end + 1)
                        {
                            list[list.Count - 1].end = Math.Max(list[list.Count - 1].end, str.end);
                            continue;
                        }
                        list.Add(str);
                    }
                }
            }

            int j = 0;

            for (int i = 0; i < s.Length; i++)
            {
                if (j < list.Count && i == list[j].start)
                {
                    sb.Append("<b>");
                }
                sb.Append(s[i]);
                if (j < list.Count && i == list[j].end)
                {
                    sb.Append("</b>"); j++;
                }
            }

            return(sb.ToString());
        }
コード例 #20
0
ファイル: Scale.cs プロジェクト: mweechzing/Theory
    /// <summary>
    /// Changes the mode in place; does not transpose.
    /// </summary>
    /// <param name="newMode">DesiredMode</param>
    public void ChangeMode(modes newMode)      //TODO this should be in TheoryManager
    {
        currentMode = newMode;
        Intervals   = CombineTetrachords(lowerTetra, upperTetra, upperTetraOffset);        //Reset the scale!!
        ModalKey    = Key + (int)Intervals[(int)newMode];
        interval[] newIntervals = new interval[scaleSize];

        int offset;

        for (int i = 0; i < scaleSize; i++)
        {
            offset = i + (int)newMode;
            if (offset >= scaleSize)
            {
                offset -= scaleSize - 1;
            }
            newIntervals [i] = theory.AdjustForScale(Intervals [offset] - (int)Intervals[(int)newMode]);
        }

        newIntervals [newIntervals.Length - 1] = interval.octave;

        Intervals = newIntervals;
        Notes     = GenerateNotes(ModalKey, Intervals);
    }
コード例 #21
0
ファイル: Payment.cs プロジェクト: alexk1331/Accountant
 public Payment(string n, DateTime dp, int t, bool rep, interval inter, string com, double cfp, double ps, double cs)
 {
     if (Account.payments.Count == 0)
     {
         code = 0;
     }
     else
     {
         int c = 0;
         foreach (Payment pa in Account.payments)
         {
             if (pa.code > c)
             {
                 c = pa.code;
             }
         }
         code = c + 1;
     }
     name     = n;
     dayp     = dp;
     type     = t;
     repeated = rep;
     payed    = false;
     interv   = inter;
     if (repeated == false)
     {
         interv.days  = 0;
         interv.month = 0;
         interv.years = 0;
     }
     inf.costforpoint = cfp;
     inf.prevstat     = ps;
     inf.curstat      = cs;
     cost             = Math.Round(inf.costforpoint * (inf.curstat - inf.prevstat), 2);
     comments         = com;
 }
コード例 #22
0
        //static void Main(string[] args)
        //{
        //    FindDays(new int[] { 180, 100, 260, 310, 40, 535, 600 });
        //}

        static void FindDays(int[] arr)
        {
            int n        = arr.Length;
            var i        = 0;
            var solution = new List <interval>();

            while (i < n - 1)
            {
                while (i < n - 1 && arr[i + 1] <= arr[i])
                {
                    i++;
                }

                if (i == n - 1)
                {
                    break;
                }

                var inte = new interval();
                inte.buy = i;

                i++;

                while (i < n && arr[i - 1] <= arr[i])
                {
                    i++;
                }
                inte.sell = i - 1;
                solution.Add(inte);
            }

            foreach (var item in solution)
            {
                Console.WriteLine(item.buy + "___" + item.sell);
            }
        }
コード例 #23
0
        private interval[] readTextGridIntervals(string[] lines, int iterador, int numberGrids) {

            interval[] res = new interval[numberGrids];
            double xmin = 0;
            double xmax = 0;

            string xminString = "xmin = ";
            string xmaxString = "xmax = ";
            string intervalTextString = "text = \"";

            string intervalText = "";

            for (int i = 0; i < numberGrids; i++) {

                if (System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator.ToString().Equals(",")) {
                    xmin = Convert.ToDouble((lines[iterador + ((i * 4) + 1)].Substring((lines[iterador + ((i * 4) + 1)].IndexOf(xminString) + xminString.Length)).Replace('.', ',')));
                    xmax = Convert.ToDouble((lines[iterador + ((i * 4) + 2)].Substring((lines[iterador + ((i * 4) + 2)].IndexOf(xmaxString) + xmaxString.Length)).Replace('.', ',')));
                }
                else if (System.Globalization.NumberFormatInfo.CurrentInfo.NumberDecimalSeparator.ToString().Equals(".")) { 
                    xmin = Convert.ToDouble((lines[iterador + ((i * 4) + 1)].Substring((lines[iterador + ((i * 4) + 1)].IndexOf(xminString) + xminString.Length))));
                    xmax = Convert.ToDouble((lines[iterador + ((i * 4) + 2)].Substring((lines[iterador + ((i * 4) + 2)].IndexOf(xmaxString) + xmaxString.Length))));
                }   

                intervalText = lines[iterador + ((i * 4) + 3)].Substring((lines[iterador + ((i * 4) + 3)].IndexOf(intervalTextString) + intervalTextString.Length));
                intervalText = intervalText.Substring(0, intervalText.Length - 1);

                intervalText = intervalText.Replace("\" ","");

                res[i] = new interval(xmin, xmax, intervalText);

            }

            return res;

        }
コード例 #24
0
        private string calculateRMS( interval[] uncorrected, interval[] corrected, string tagType, string tagTypeNum ) {

            string outputLine = "";

            string[] previousPhone = new string[uncorrected.Length];
            string[] followingPhone = new string[uncorrected.Length];
            //string[] previousWord = new string[uncorrected.Length];
            //string[] followingWord = new string[uncorrected.Length];

            double[] diffStartPhonemes = new double[uncorrected.Length];
            double[] rmsDiffStartPhonemes = new double[uncorrected.Length];
            double[] diffEndPhonemes = new double[uncorrected.Length];
            double[] rmsDiffEndPhonemes = new double[uncorrected.Length];

            double tempDiffStart = 0;
            double tempRMSDiffStart = 0;
            double tempDiffEnd = 0;
            double tempRMSDiffEnd = 0;

            double uncorrLen = 0;
            double corrLen = 0;
            double diffLen = 0;
            double RMSdiffLen = 0;

            String textOfTheGrid = "";

            for (int i = 0; i < uncorrected.Length; i++) {

                textOfTheGrid = uncorrected[i].text.Replace("\"", "");
                textOfTheGrid = textOfTheGrid.TrimEnd(' ');
                Console.WriteLine(textOfTheGrid);
                Console.WriteLine(uncorrected[i].text);

                if (textOfTheGrid.Equals("sp") == false && textOfTheGrid.Equals("_") ==false && textOfTheGrid.Equals("") == false) {

                    tempDiffStart = corrected[i].xmin - uncorrected[i].xmin;
                    tempRMSDiffStart = Math.Sqrt(Math.Pow(tempDiffStart, 2));
                    diffStartPhonemes[i] = tempDiffStart;
                    rmsDiffStartPhonemes[i] = tempRMSDiffStart;

                    tempDiffEnd = corrected[i].xmax - uncorrected[i].xmax;
                    tempRMSDiffEnd = Math.Sqrt(Math.Pow(tempDiffEnd, 2));
                    diffEndPhonemes[i] = tempDiffEnd;
                    rmsDiffEndPhonemes[i] = tempRMSDiffEnd;

                    uncorrLen = uncorrected[i].xmax - uncorrected[i].xmin;
                    corrLen = corrected[i].xmax - corrected[i].xmin;
                    diffLen = uncorrLen - corrLen;
                    RMSdiffLen = Math.Sqrt(Math.Pow(diffLen, 2));

                    if (i != 0) { previousPhone[i] = corrected[i - 1].text; } else { previousPhone[i] = ""; }
                    if ((i + 1) != uncorrected.Length) { followingPhone[i] = corrected[i + 1].text; } else { followingPhone[i] = ""; }

                    outputLine += corrected[i].text.Replace("\"","") + "\t";
                    outputLine += tagType + "\t";
                    outputLine += tagTypeNum + "\t";
                    outputLine += (i+1).ToString() + "\t";

                    /*Console.WriteLine("El texto corregido es: " + corrected[i].text);
                    Console.WriteLine("I es: " + i.ToString());
                    Console.WriteLine("La longitud del vector previousPhone es: " + previousPhone.Length.ToString());
                    Console.WriteLine("La segunda línea es: " + previousPhone[1]);
                    Console.WriteLine("La primera línea es: " + previousPhone[0]);*/
                    outputLine += previousPhone[i].Replace("\"","") + "\t";
                    outputLine += followingPhone[i].Replace("\"", "") + "\t";

                    outputLine += uncorrected[i].xmin.ToString() + "\t";
                    outputLine += corrected[i].xmin.ToString() + "\t";
                    outputLine += tempDiffStart.ToString() + "\t";
                    outputLine += tempRMSDiffStart.ToString() + "\t";
                    outputLine += tempRMSDiffStart / uncorrLen + "\t";

                    outputLine += uncorrected[i].xmax.ToString() + "\t";
                    outputLine += corrected[i].xmax.ToString() + "\t";
                    outputLine += tempDiffEnd.ToString() + "\t";
                    outputLine += tempRMSDiffEnd.ToString() + "\t";
                    outputLine += tempRMSDiffEnd / uncorrLen + "\t";

                    outputLine += uncorrLen.ToString() + "\t";
                    outputLine += corrLen.ToString() + "\t";

                    outputLine += diffLen.ToString() + "\t";
                    outputLine += RMSdiffLen.ToString() + "\t";
                    outputLine += RMSdiffLen / uncorrLen + "\r\n";

                }
            }

            return outputLine;

        }
コード例 #25
0
    private string printPraatIntervalsFromLists(int numberRows, List<interval> items) {

            string res = "";

            interval[] temp = new interval[items.Count];

            for ( int i = 0; i < items.Count; i++ ) {
                temp[i] = items[i];
            }

            res = printPraatIntervals(numberRows, temp);

            return res;

        }
コード例 #26
0
 public void Transpose(Scale managedScale, interval transVal, direction dir)
 {
     transposeOffset += (int)transVal;
     TransposeInPlace(managedScale, transVal, dir);
     FrequencyManager.AssignFrequencyKeys(managedScale, transposeOffset);
 }
コード例 #27
0
    private string printPraatIntervals(int numberRows, interval[] items) {

        string res = "";

        for (int i = 0; i < numberRows; i++) {
                res += "\t\t\t" + "intervals [" + (i + 1).ToString() + "]:\n";
                res += "\t\t\t\t" + "xmin = " + items[i].xmin.ToString().Replace(',', '.') + "\n";
                res += "\t\t\t\t" + "xmax = " + items[i].xmax.ToString().Replace(',', '.') + "\n";
                res += "\t\t\t\t" + "text = \"" + items[i].text + "\"\n";
        }

        return res;

    }
コード例 #28
0
        static void ConjugateGradient(double[] X0, ref double[] res, double tau)
        {
            double[] gradFNow = new double[N];
            double[] result   = new double[N];
            double[] xNow     = new double[N];
            double[] xPrev    = new double[N];
            double   t        = 0;

            double[] grDirection     = new double[N];
            double[] grDirectionPrev = new double[N];
            double[] gradFPrev       = new double[N];
            double   grBk;
            double   count = 0;
            int      k     = 0;

            for (int i = 0; i < N; i++)
            {
                xNow[i] = X0[i];
            }

            //for(int s = 0; s< 1000; s++)
            do
            {
                gradient(xNow, ref gradFNow);
                //******************************
                if (k == N || k == 0)
                {
                    for (int i = 0; i < N; i++)
                    {
                        grDirection[i] = -gradFNow[i];
                    }
                    k = 0;
                }
                else
                {
                    for (int i = 0; i < N; i++)
                    {
                        grDirectionPrev[i] = grDirection[i];
                    }
                    gradient(xPrev, ref gradFPrev);
                    grBk = fletcher(gradFNow, gradFPrev);
                    direction(gradFNow, grDirectionPrev, grBk, ref grDirection);
                }
                //****************************************


                interval segment = Swan(0, tau, xNow, grDirection);

                double ser = (segment.b + segment.a) / 2;
                t = GoldenMethod(segment.a, segment.b, xNow, grDirection);
                Console.WriteLine("a = {0}, b = {1}, t = {2}", segment.a, segment.b, t);
                for (int i = 0; i < N; i++)
                {
                    xPrev[i] = xNow[i];
                }
                for (int i = 0; i < N; i++)
                {
                    xNow[i] = xPrev[i] + t * grDirection[i];
                    Console.Write("xNow {0} ", xNow[i]);
                }
                Console.WriteLine();
                Console.WriteLine("F = {0} ", Math.Round(f(xNow), 6, MidpointRounding.AwayFromZero));
                k++;
                count++;

                //проверка на возрастание

                /*if(f(xNow) > f(xPrev)){
                 *                      Console.WriteLine("Функция возрастает");
                 *                      break;
                 *              }*/
            } //while (Math.Abs(f(xNow) -f(xPrev))>=eps);
            while (Math.Abs(f(xNow) - f(xPrev)) / f(xNow) > eps);
            Console.WriteLine(count);
            for (int i = 0; i < N; i++)
            {
                res[i] = xNow[i];
            }
        }
コード例 #29
0
ファイル: Note.cs プロジェクト: mweechzing/Theory
 int GetFrequencyKey(interval intervalToGrab)
 {
     return((int)intervalToGrab + (octave * Theory.TOTAL_NOTES));
 }
コード例 #30
0
 public readTextGrid(interval[] inPhonemes, interval[] inWords, string inPhonemeHeader, string inWordHeader) {
     phonemes = inPhonemes;
     words = inWords;
     phonemeHeader = inPhonemeHeader;
     wordHeader = inWordHeader;
 }
コード例 #31
0
ファイル: Updater.cs プロジェクト: fritzmark/Imagin.NET
this.Change(ref interval, value);
コード例 #32
0
        private string convertDataGrid(string fileTextGrid, string fileDictionary)
        {
            string res            = "";
            int    iterador       = 0;
            string intervalString = "intervals: size = ";

            string textGridPhonemesHeader = "";
            string textGridWordsHeader    = "";

            // Codificaciones: https://msdn.microsoft.com/en-us/library/windows/desktop/dd317756(v=vs.85).aspx
            int fileEncodingDictionary = 1252;

            string text = File.ReadAllText(fileTextGrid);

            string[] lines = text.Split('\n');

            //------------------------------------------------------------
            // Primero, voy a construir el diccionario. Este contiene
            // las palabras en ortografía normal, en arpabet, y en
            // los fonos que queremos en el textGrid
            //------------------------------------------------------------

            string dictText = File.ReadAllText(fileDictionary, Encoding.GetEncoding(fileEncodingDictionary));

            string[]   dictLines = dictText.Split('\n');
            string[]   dictTabElements;
            dictWord[] dictionary = new dictWord[dictLines.Length];

            for (int i = 0; i < dictLines.Length; i++)
            {
                dictTabElements = dictLines[i].Split('\t');
                dictionary[i]   = new dictWord(dictTabElements[0], dictTabElements[1], dictTabElements[2].Trim('\n', '\r'));
            }

            //------------------------------------------------------------
            // Luego, voy a construir dos listas, una que contenga
            // la información de los intervalos que contienen fonemas,
            // y otra que contenga la información de los intervalos
            // que contienen palabras
            //------------------------------------------------------------

            while (lines[iterador].Contains(intervalString) == false)
            {
                textGridPhonemesHeader += lines[iterador] + "\n";
                iterador++;
            }
            textGridPhonemesHeader += lines[iterador] + "\n";

            // Ver cuántos fonos hay en el textGrid
            //Console.WriteLine(lines[iterador]);
            string stringNumberGridsInFirstRow = lines[iterador].Substring((lines[iterador].IndexOf(intervalString) + intervalString.Length));
            int    numberGridsInFirstRow       = Convert.ToInt16(stringNumberGridsInFirstRow);

            // Construir la lista de intervalos para los fonemas
            interval[] phonemes = new interval[numberGridsInFirstRow];
            iterador = iterador + 1;
            phonemes = readTextGridIntervals(lines, iterador, numberGridsInFirstRow);
            Console.WriteLine(phonemes.Length.ToString());

            // Construir la lista de intervalos para las palabras

            // Encontrar la línea que marca el inicio de los intervalos
            // que contienen las palabras

            iterador = iterador + numberGridsInFirstRow * 4;

            while (lines[iterador].Contains(intervalString) == false)
            {
                //Console.WriteLine(iterador.ToString());
                textGridWordsHeader += lines[iterador] + "\n";
                iterador++;
            }
            textGridWordsHeader += lines[iterador] + "\n";

            // Ver cuántos fonos hay en el textGrid
            //Console.WriteLine(lines[iterador]);
            string stringNumberGridsInSecondRow = lines[iterador].Substring((lines[iterador].IndexOf(intervalString) + intervalString.Length));
            int    numberGridsInSecondRow       = Convert.ToInt16(stringNumberGridsInSecondRow);

            // Leer el TextGrid para extraer las palabras
            interval[] words = new interval[numberGridsInSecondRow];
            iterador = iterador + 1;
            words    = readTextGridIntervals(lines, iterador, numberGridsInSecondRow);

            Console.WriteLine(words[0].xmin.ToString());
            Console.WriteLine(words[0].xmax.ToString());

            Console.WriteLine(words.Length.ToString());

            //------------------------------------------------------------
            //------------------------------------------------------------

            // para cada palabra, buscar todos los fonemas que están dentro de ese índice de tiempo

            // buscar los índices de tiempo en los que ocurre una palabra (puede ocurrir varias veces en el texto)

            double currentWordXmin = 0;
            double currentWordXmax = 0;
            string currentWord     = "";

            string[]   currentWordOutputVector    = new string[0];
            string     currentWordJoinedArpabet   = "";
            string     iteratingWordJoinedArpabet = "";
            List <int> intervalPosition           = new List <int>();

            for (int i = 0; i < numberGridsInSecondRow; i++)
            {
                if (words[i].text.Equals("sp") == false)
                {
                    intervalPosition           = new List <int>();
                    currentWordOutputVector    = new string[0];
                    iteratingWordJoinedArpabet = "";
                    currentWord     = words[i].text;
                    currentWordXmin = words[i].xmin;
                    currentWordXmax = words[i].xmax;

                    /*Console.WriteLine("este es el diccionario");
                     * for (int j = 0; j < dictionary.Length; j++) {
                     *  Console.WriteLine(dictionary[j].word + " - " + dictionary[j].wordArpabet + " - " + dictionary[j].wordOutput);
                     * }
                     * Console.WriteLine("-----------------------");*/

                    // Encontrar la palabra en el diccionario
                    for (int j = 0; j < dictionary.Length; j++)
                    {
                        if (dictionary[j].word.ToLower().Equals(currentWord.ToLower()) == true)
                        {
                            currentWordOutputVector  = dictionary[j].outputLetters;
                            currentWordJoinedArpabet = dictionary[j].wordArpabet;
                        }
                    }

                    // Encontrar los índices de los intervalos que corresponden a los
                    // fonemas de la palabra actual
                    for (int j = 0; j < numberGridsInFirstRow; j++)
                    {
                        if (phonemes[j].xmin >= currentWordXmin && phonemes[j].xmax <= currentWordXmax)
                        {
                            intervalPosition.Add(j);
                            iteratingWordJoinedArpabet += phonemes[j].text;
                        }
                    }

                    // cambiar las letras arpabet en eltextgrid por las letras que queremos
                    if (currentWordJoinedArpabet.ToLower().Equals(iteratingWordJoinedArpabet.ToLower()) == true && currentWordOutputVector.Length == intervalPosition.Count)
                    {
                        for (int j = 0; j < intervalPosition.Count; j++)
                        {
                            phonemes[intervalPosition[j]].text = currentWordOutputVector[j];
                        }
                    }
                    else
                    {
                        Console.Write("Hubo un error al tratar de alinear " + currentWord + "porque ");
                        if (currentWordJoinedArpabet.Equals(iteratingWordJoinedArpabet) == false)
                        {
                            Console.Write(" la palabra arpabet ( " + currentWordJoinedArpabet + " ) no es igual a la palabra actual (" + iteratingWordJoinedArpabet + ")\n");
                        }

                        /*if (currentWordOutputVector.Length != intervalPosition.Count) {
                         *  Console.Write(" las palabras tienen diferente número de letras\n");
                         * }*/
                    }
                }
            }

            res = textGridPhonemesHeader;

            // Construir los intervalos de los fonemas
            for (int i = 0; i < numberGridsInFirstRow; i++)
            {
                res += "\t\t\t" + "intervals [" + (i + 1).ToString() + "]:\n";
                res += "\t\t\t\t" + "xmin = " + phonemes[i].xmin.ToString().Replace(',', '.') + "\n";
                res += "\t\t\t\t" + "xmax = " + phonemes[i].xmax.ToString().Replace(',', '.') + "\n";
                res += "\t\t\t\t" + "text = \"" + phonemes[i].text + "\"\n";
            }

            res += textGridWordsHeader;

            for (int i = 0; i < numberGridsInSecondRow; i++)
            {
                res += "\t\t\t" + "intervals [" + (i + 1).ToString() + "]:\n";
                res += "\t\t\t\t" + "xmin = " + words[i].xmin.ToString().Replace(',', '.') + "\n";
                res += "\t\t\t\t" + "xmax = " + words[i].xmax.ToString().Replace(',', '.') + "\n";
                res += "\t\t\t\t" + "text = \"" + words[i].text + "\"\n";
            }

            //Console.WriteLine(res);

            return(res);
        }
コード例 #33
0
        private string processRMS(string uncorrectedGrid, string correctedGrid)
        {
            Console.WriteLine("entré a procesar RMS");

            string res            = "";
            int    iterador       = 0;
            string intervalString = "intervals: size = ";

            string text = File.ReadAllText(uncorrectedGrid);

            string[] lines = text.Split('\n');

            //------------------------------------------------------------
            // Voy a construir dos listas, una que contenga
            // la información de los intervalos que contienen fonemas,
            // y otra que contenga la información de los intervalos
            // que contienen palabras
            //------------------------------------------------------------

            while (lines[iterador].Contains(intervalString) == false)
            {
                iterador++;
            }

            Console.WriteLine("voy a ver cuántos fonos hay en el textgrid");

            // Ver cuántos fonos hay en el textGrid
            string stringNumberGridsInFirstRow = lines[iterador].Substring((lines[iterador].IndexOf(intervalString) + intervalString.Length));
            int    numberGridsInFirstRow       = Convert.ToInt16(stringNumberGridsInFirstRow);

            // Construir la lista de intervalos para los fonemas
            interval[] uncorrectedPhonemes = new interval[numberGridsInFirstRow];
            iterador            = iterador + 1;
            uncorrectedPhonemes = readTextGridIntervals(lines, iterador, numberGridsInFirstRow);

            // Construir la lista de intervalos para las palabras
            iterador = iterador + numberGridsInFirstRow * 4;
            while (lines[iterador].Contains(intervalString) == false)
            {
                iterador++;
            }

            // Ver cuántos fonos hay en el textGrid
            string stringNumberGridsInSecondRow = lines[iterador].Substring((lines[iterador].IndexOf(intervalString) + intervalString.Length));
            int    numberGridsInSecondRow       = Convert.ToInt16(stringNumberGridsInSecondRow);

            // Leer el TextGrid para extraer las palabras
            interval[] uncorrectedWords = new interval[numberGridsInSecondRow];
            iterador         = iterador + 1;
            uncorrectedWords = readTextGridIntervals(lines, iterador, numberGridsInSecondRow);

            //------------------------------------------------------------
            // Leer la lista de palabras corregidas
            //------------------------------------------------------------

            iterador = 0;
            text     = File.ReadAllText(correctedGrid);
            lines    = text.Split('\n');

            while (lines[iterador].Contains(intervalString) == false)
            {
                iterador++;
            }

            // Ver cuántos fonos hay en el textGrid
            stringNumberGridsInFirstRow = lines[iterador].Substring((lines[iterador].IndexOf(intervalString) + intervalString.Length));
            numberGridsInFirstRow       = Convert.ToInt16(stringNumberGridsInFirstRow);

            // Construir la lista de intervalos para los fonemas
            interval[] correctedPhonemes = new interval[numberGridsInFirstRow];
            iterador          = iterador + 1;
            correctedPhonemes = readTextGridIntervals(lines, iterador, numberGridsInFirstRow);

            // Construir la lista de intervalos para las palabras
            iterador = iterador + numberGridsInFirstRow * 4;
            while (lines[iterador].Contains(intervalString) == false)
            {
                iterador++;
            }

            // Ver cuántos fonos hay en el textGrid
            stringNumberGridsInSecondRow = lines[iterador].Substring((lines[iterador].IndexOf(intervalString) + intervalString.Length));
            numberGridsInSecondRow       = Convert.ToInt16(stringNumberGridsInSecondRow);

            // Leer el TextGrid para extraer las palabras
            interval[] correctedWords = new interval[numberGridsInSecondRow];
            iterador       = iterador + 1;
            correctedWords = readTextGridIntervals(lines, iterador, numberGridsInSecondRow);

            if (uncorrectedPhonemes.Length == correctedPhonemes.Length && uncorrectedWords.Length == correctedWords.Length)
            {
                Console.WriteLine("todos los vectores son del mismo tamaño");

                string header = "";
                header += "textoIntervalo\t";
                header += "tipoIntervalo\t";
                header += "tipoIntervaloNum\t";
                header += "numIntervalo\t";
                header += "inicioAuto\t";
                header += "inicioCorr\t";
                header += "difInicio\t";
                header += "difInicioRMS\t";
                header += "difInicioPorciento\t";

                header += "finalAuto\t";
                header += "finalCorr\t";
                header += "difFinal\t";
                header += "difFinalRMS\t";
                header += "difFinalPorciento\t";

                header += "tamañoAuto\t";
                header += "tamañoCorr\t";

                header += "difTamaño\t";
                header += "difTamañoRMS\t";
                header += "difTamañoPorciento\r\n";

                res += header;
                res += calculateRMS(uncorrectedPhonemes, correctedPhonemes, "fonema", "1");
                res += calculateRMS(uncorrectedWords, correctedWords, "palabra", "2");
            }
            else
            {
                MessageBox.Show("Los dos TextGrids no tienen el mismo contenido. No se puede calcular la comparación.");
            }

            return(res);
        }
コード例 #34
0
 await Task.Delay(interval ?? TimeSpan.FromMilliseconds(1));
コード例 #35
0
        private readTextGrid processPhonemesWords(string fileTextGrid) {

            int iterador = 0;
            string intervalString = "intervals: size = ";

            string textGridPhonemesHeader = "";
            string textGridWordsHeader = "";

            string text = File.ReadAllText(fileTextGrid);
            string[] lines = text.Split('\n');

            while (lines[iterador].Contains(intervalString) == false) {
                textGridPhonemesHeader += lines[iterador] + "\n";
                iterador++;
            }
            textGridPhonemesHeader += lines[iterador] + "\n";

            // Ver cuántos fonos hay en el textGrid
            //Console.WriteLine(lines[iterador]);
            string stringNumberGridsInFirstRow = lines[iterador].Substring((lines[iterador].IndexOf(intervalString) + intervalString.Length));
            int numberGridsInFirstRow = Convert.ToInt16(stringNumberGridsInFirstRow);

            // Construir la lista de intervalos para los fonemas
            interval[] phonemes = new interval[numberGridsInFirstRow];
            iterador = iterador + 1;
            phonemes = readTextGridIntervals(lines, iterador, numberGridsInFirstRow);
            Console.WriteLine(phonemes.Length.ToString());

            // Construir la lista de intervalos para las palabras

            // Encontrar la línea que marca el inicio de los intervalos
            // que contienen las palabras

            iterador = iterador + numberGridsInFirstRow * 4;

            while (lines[iterador].Contains(intervalString) == false) {
                //Console.WriteLine(iterador.ToString());
                textGridWordsHeader += lines[iterador] + "\n";
                iterador++;
            }
            textGridWordsHeader += lines[iterador] + "\n";

            // Ver cuántos fonos hay en el textGrid
            //Console.WriteLine(lines[iterador]);
            string stringNumberGridsInSecondRow = lines[iterador].Substring((lines[iterador].IndexOf(intervalString) + intervalString.Length));
            int numberGridsInSecondRow = Convert.ToInt16(stringNumberGridsInSecondRow);

            // Leer el TextGrid para extraer las palabras
            interval[] words = new interval[numberGridsInSecondRow];
            iterador = iterador + 1;
            words = readTextGridIntervals(lines, iterador, numberGridsInSecondRow);

            readTextGrid retItems = new readTextGrid(phonemes, words, textGridPhonemesHeader, textGridWordsHeader);

            return retItems;

        }
コード例 #36
0
        private string processRMS(string uncorrectedGrid, string correctedGrid) {

            string res = "";
            int iterador = 0;
            string intervalString = "intervals: size = ";

            string text = File.ReadAllText(uncorrectedGrid);
            string[] lines = text.Split('\n');

            //------------------------------------------------------------
            // Voy a construir dos listas, una que contenga
            // la información de los intervalos que contienen fonemas,
            // y otra que contenga la información de los intervalos
            // que contienen palabras
            //------------------------------------------------------------

            while (lines[iterador].Contains(intervalString) == false) {
                iterador++;
            }

            // Ver cuántos fonos hay en el textGrid
            string stringNumberGridsInFirstRow = lines[iterador].Substring((lines[iterador].IndexOf(intervalString) + intervalString.Length));
            int numberGridsInFirstRow = Convert.ToInt16(stringNumberGridsInFirstRow);

            // Construir la lista de intervalos para los fonemas
            interval[] uncorrectedPhonemes = new interval[numberGridsInFirstRow];
            iterador = iterador + 1;
            uncorrectedPhonemes = readTextGridIntervals(lines, iterador, numberGridsInFirstRow);

            // aquí ocupo avanzar tantos intervalos como tenga que para llegar a las palabras
            
            iterador = iterador + numberGridsInFirstRow * 4;
            // seguir pasando hasta encontrarse con item [X]:
            // Construir la lista de intervalos para las palabras
            String rowItemString = "item ["+txt_wordRow.Text.ToString()+"]";
            Console.WriteLine(lines[iterador]);
            Console.WriteLine(rowItemString);
            while (lines[iterador].Contains(rowItemString) == false) {
                iterador++;
            }

            // Construir la lista de intervalos para las palabras
            while (lines[iterador].Contains(intervalString) == false) {
                iterador++;
            }

            
            // Ver cuántas palabras hay en el textGrid
            string stringNumberGridsInSecondRow = lines[iterador].Substring((lines[iterador].IndexOf(intervalString) + intervalString.Length));
            int numberGridsInSecondRow = Convert.ToInt16(stringNumberGridsInSecondRow);

            // Leer el TextGrid para extraer las palabras
            interval[] uncorrectedWords = new interval[numberGridsInSecondRow];
            iterador = iterador + 1;
            uncorrectedWords = readTextGridIntervals(lines, iterador, numberGridsInSecondRow);

            //------------------------------------------------------------
            // Leer la lista de palabras corregidas
            //------------------------------------------------------------

            iterador = 0;
            text = File.ReadAllText(correctedGrid);
            lines = text.Split('\n');

            while (lines[iterador].Contains(intervalString) == false) {
                iterador++;
            }

            // Ver cuántos fonos hay en el textGrid
            stringNumberGridsInFirstRow = lines[iterador].Substring((lines[iterador].IndexOf(intervalString) + intervalString.Length));
            numberGridsInFirstRow = Convert.ToInt16(stringNumberGridsInFirstRow);

            // Construir la lista de intervalos para los fonemas
            interval[] correctedPhonemes = new interval[numberGridsInFirstRow];
            iterador = iterador + 1;
            correctedPhonemes = readTextGridIntervals(lines, iterador, numberGridsInFirstRow);

            // Construir la lista de intervalos para las palabras
            iterador = iterador + numberGridsInFirstRow * 4;
            // seguir pasando hasta encontrarse con item [X]:
            Console.WriteLine(lines[iterador]);
            Console.WriteLine(rowItemString);
            while (lines[iterador].Contains(rowItemString) == false) {
                iterador++;
            }

            while (lines[iterador].Contains(intervalString) == false) {
                iterador++;
            }

            // Ver cuántos fonos hay en el textGrid
            stringNumberGridsInSecondRow = lines[iterador].Substring((lines[iterador].IndexOf(intervalString) + intervalString.Length));
            numberGridsInSecondRow = Convert.ToInt16(stringNumberGridsInSecondRow);

            // Leer el TextGrid para extraer las palabras
            interval[] correctedWords = new interval[numberGridsInSecondRow];
            iterador = iterador + 1;
            correctedWords = readTextGridIntervals(lines, iterador, numberGridsInSecondRow);

            if (uncorrectedPhonemes.Length == correctedPhonemes.Length && uncorrectedWords.Length == correctedWords.Length) {

                Console.WriteLine("todos los vectores son del mismo tamaño");

                string header = "";
                header += "textoIntervalo\t";
                header += "tipoIntervalo\t";
                header += "tipoIntervaloNum\t";
                header += "numIntervalo\t";

                header += "fonoPrevio\t";
                header += "fonoSiguiente\t";

                header += "inicioAuto\t";
                header += "inicioCorr\t";
                header += "difInicio\t";
                header += "difInicioRMS\t";
                header += "difInicioPorciento\t";

                header += "finalAuto\t";
                header += "finalCorr\t";
                header += "difFinal\t";
                header += "difFinalRMS\t";
                header += "difFinalPorciento\t";

                header += "tamañoAuto\t";
                header += "tamañoCorr\t";

                header += "difTamaño\t";
                header += "difTamañoRMS\t";
                header += "difTamañoPorciento\r\n";

                res += header;
                res += calculateRMS(uncorrectedPhonemes, correctedPhonemes, "fonema", "1");
                res += calculateRMS(uncorrectedWords, correctedWords, "palabra", "2");

            }
            else {
                MessageBox.Show("Los dos TextGrids no tienen el mismo contenido. No se puede calcular la comparación:\n"+uncorrectedPhonemes.Length.ToString()+"!="+correctedPhonemes.Length.ToString()+"\n"+uncorrectedWords.Length+"!="+correctedWords.Length);
            }

            return res;

        }
コード例 #37
0
        private string generarTextGridNasal(string filename) {

            string res = "";

            //-------------------------------------------------------------------------
            // Primer paso: construir una lista de todos los intervalos de fonemas,
            // y de la palabra correspondiente a cada intervalo
            //-------------------------------------------------------------------------

            readTextGrid filecontents = processPhonemesWords(filename);

            interval[] phonemes = filecontents.phonemes;
            interval[] words = filecontents.words;
            string textGridPhonemesHeader = filecontents.phonemeHeader;
            string textGridWordsHeader = filecontents.wordHeader;
            int numberGridsInFirstRow = phonemes.Count();
            int numberGridsInSecondRow = words.Count();

            List<string> wordsInNasalWordTier = new List<string>();
            string tempPalabra = "";
            
            for ( int i = 0; i < phonemes.Count(); i++ ) {

                for ( int j = 0; j < words.Count(); j++ ) {
                    if ( tempPalabra == "" && phonemes[i].xmin >= words[j].xmin && phonemes[i].xmax <= words[j].xmax ) {
                        tempPalabra = words[j].text;
                    }
                }

                wordsInNasalWordTier.Add(tempPalabra);
                tempPalabra = "";                

            }

            //----------------------------------------------------------------------------
            // Segundo, construir una nueva lista de intervalos, en la que solo aparezcan
            // vocales y espacios en blanco
            //----------------------------------------------------------------------------

            List<interval> nasalPhonemes = new List<interval>();
            List<interval> nasalWords = new List<interval>();
            interval tempIntervalo = new interval();
            double tempXMin = 0;
            double tempXMax = 0;
            string tempTexto = "";
            int salirDelCicloConsonantes = 0;
            int intervalosALaDerechaDelIterador = 1;

            for ( int i = 0; i < phonemes.Count(); i++ ) {

                if (tipoLetraMephaa(phonemes[i].text) == "vocal") {
                    nasalPhonemes.Add(phonemes[i]);
                    //Console.WriteLine("1. " + phonemes[i].xmin.ToString() + "\t-\t" + phonemes[i].text);
                }
                else {

                    if ( i+1 < phonemes.Count() ) {

                        if (tipoLetraMephaa(phonemes[i + intervalosALaDerechaDelIterador].text) == "vocal") {
                            tempIntervalo = new interval(phonemes[i].xmin, phonemes[i].xmax, "");
                            nasalPhonemes.Add(tempIntervalo);
                            //Console.WriteLine("2. " + phonemes[i].xmin.ToString() + "\t-\t" + phonemes[i].xmax.ToString() + "\t-\t" + phonemes[i].text);
                        }
                        else {

                            tempXMin = phonemes[i].xmin;
                            tempXMax = phonemes[i].xmax;
                            intervalosALaDerechaDelIterador++;

                            while ( salirDelCicloConsonantes == 0 && i+ intervalosALaDerechaDelIterador < phonemes.Count()) {

                                if (tipoLetraMephaa(phonemes[i + intervalosALaDerechaDelIterador].text) == "vocal") {
                                    tempXMax = phonemes[i + intervalosALaDerechaDelIterador - 1].xmax;
                                    tempIntervalo = new interval(tempXMin, tempXMax, "");
                                    nasalPhonemes.Add(tempIntervalo);
                                    salirDelCicloConsonantes = 1;
                                    //Console.WriteLine("3. " + tempXMin.ToString() + "\t-\t" + tempXMax.ToString());
                                }
                                else {
                                    intervalosALaDerechaDelIterador++;
                                }

                            }

                            i = i + intervalosALaDerechaDelIterador - 1;
                            salirDelCicloConsonantes = 0;
                            intervalosALaDerechaDelIterador = 1;

                        }
                        
                    }
                    else {

                        // intervalo final, y si llegué aquí es pq el intervalo final no es una vocal

                        tempIntervalo = new interval(phonemes[i].xmin, phonemes[i].xmax, "");
                        nasalPhonemes.Add(tempIntervalo);

                        //Console.WriteLine("**** topé con el intervalo final **** ");
                    }

                }

            }

            tempIntervalo = new interval(nasalPhonemes[nasalPhonemes.Count()-1].xmax, phonemes[phonemes.Count() - 1].xmax, "");
            nasalPhonemes.Add(tempIntervalo);

            //----------------------------------------------------------------------------
            // Tercero, construir una nueva de lista de intervalos, basada en la anterior
            // en la que solo aparezcan palabras y espacios en blanco
            //----------------------------------------------------------------------------

            string tempPalabraNasal = "";

            for ( int i = 0; i < nasalPhonemes.Count(); i++ ) {
                tempPalabraNasal = "";
                if (nasalPhonemes[i].text != "" ) {
                    for (int j = 0; j < words.Count(); j++) {
                        if (nasalPhonemes[i].xmin >= words[j].xmin && nasalPhonemes[i].xmax <= words[j].xmax) {
                            tempPalabraNasal = words[j].text;
                        }
                    }
                }
                nasalWords.Add(new interval(nasalPhonemes[i].xmin, nasalPhonemes[i].xmax, tempPalabraNasal));
            }

            //----------------------------------------------------------------------------
            // Cuarto, formatear estas dos listas como un TextGrid de Praat
            //----------------------------------------------------------------------------

            string newHeader = "File type = \"ooTextFile\"\r";
            newHeader       += "Object class = \"TextGrid\"\r";
            newHeader       += "xmin = 0\r";
            newHeader       += "xmax = " + (phonemes[phonemes.Count() - 1].xmax).ToString().Replace(',', '.') + "\r";
            newHeader       += "tiers? <exists>\r";
            newHeader       += "size = 2\r";
            newHeader       += "item []:\r";
            newHeader       += "\titem [1]:\r";
            newHeader       += "\t\tclass = \"IntervalTier\"\r";
            newHeader       += "\t\tname = \"phon\"\r";
            newHeader       += "\t\txmin = 0\r";
            newHeader       += "\t\txmax = " + (phonemes[phonemes.Count() - 1].xmax).ToString().Replace(',', '.') + "\r";
            newHeader       += "\tintervals: size = "+nasalPhonemes.Count()+"\r";

            string newWordHeader = "\titem [2]:\r";
            newWordHeader       += "\t\tclass = \"IntervalTier\"\r";
            newWordHeader       += "\t\tname = \"word\"\r";
            newWordHeader       += "\t\txmin = 0\r";
            newWordHeader       += "\t\txmax = " + (phonemes[phonemes.Count() - 1].xmax).ToString().Replace(',', '.') + "\r";
            newWordHeader       += "\tintervals: size = " + nasalPhonemes.Count() + "\r";

            res = newHeader;
            res += printPraatIntervalsFromLists(nasalPhonemes.Count(), nasalPhonemes);
            res += newWordHeader;
            res += printPraatIntervalsFromLists(nasalWords.Count(), nasalWords);

            //Console.WriteLine(res);
            
            return res;

        }