protected override void Consume(Queue <MBROLAElement> InQueue)
 {
     while (InQueue.Count > 0)
     {
         MBROLAElement elem = InQueue.Dequeue();
         Log("Writing ", elem.Symbol);
         mbrola.StandardInput.Write(elem);
     }
 }
Пример #2
0
 internal DiphoneRuleAction MatchRules(MBROLAElement e1, MBROLAElement e2)
 {
     foreach (DiphoneRule rule in DiphoneRules)
     {
         if (rule.Match(e1.Symbol, e2.Symbol))
         {
             return(rule.RuleAction);
         }
     }
     return(new DiphoneRuleAction(DiphoneAction.None, DiphoneOp.Value, null));
 }
        public MBROLAElement Unify(MBROLAElement e1, MBROLAElement e2)
        {
            string s = UnifyQuery(e1.Symbol, e2.Symbol);

            if (s != null)
            {
                return(MBROLAElement.CreateUnify(e1, e2, s));
            }
            else
            {
                return(null);
            }
        }
        public MBROLAElement InsertBuffer(MBROLAElement e1, MBROLAElement e2)
        {
            string s = InsertBufferQuery(e1.Symbol, e2.Symbol);

            if (s != null)
            {
                return(MBROLAElement.CreateBuffer(e1, e2, s));
            }
            else
            {
                return(null);
            }
        }
        /*public MBROLAElement(Phone p,MBROLAVoice voice) {
         *  Duration=p.Duration;
         *  foreach (Qaryan.Core.PitchPoint pp in p.PitchCurve) {
         *      Pitch.Add(new Qaryan.Core.MBROLAPitchPoint(100*pp.Time/Duration,pp.Value));
         *  }
         *  Symbol=voice.TranslateSymbol(p.Symbol);
         * }*/


        public static MBROLAElement[] CreateFragment(Phone p, MBROLAVoice voice)
        {
            string[]        symbols = voice.TranslateSymbol(p.Symbol);
            MBROLAElement[] result  = new MBROLAElement[symbols.Length];
            for (int i = 0; i < symbols.Length; i++)
            {
                string symbol = symbols[i];
                result[i] = new MBROLAElement(symbol, p.Duration / symbols.Length);
            }
            foreach (Qaryan.Core.PitchPoint pp in p.PitchCurve)
            {
                int j = (int)Math.Floor(pp.Time / (p.Duration / symbols.Length));
                result[j].Pitch.Add(new MBROLAPitchPoint(100 * (pp.Time - (j * p.Duration / symbols.Length)) / result[j].Duration, pp.Value));
            }
            return(result);
        }
 public void SplitHalf(out MBROLAElement e1, out MBROLAElement e2)
 {
     e1 = new MBROLAElement(Symbol, Duration / 2);
     e2 = new MBROLAElement(Symbol, Duration / 2);
     e1.Pitch.Clear();
     e2.Pitch.Clear();
     foreach (MBROLAPitchPoint pp in Pitch)
     {
         if (pp.Time <= 50)
         {
             e1.Pitch.Add(new MBROLAPitchPoint(pp.Time * 2, pp.Value));
         }
         else
         {
             e2.Pitch.Add(new MBROLAPitchPoint(pp.Time * 2, pp.Value));
         }
     }
 }
        public static MBROLAElement CreateBuffer(MBROLAElement e1, MBROLAElement e2, string symbol /*,bool diphtong*/)
        {
            /*			if (diphtong) {
             *  a=*/
            double d1 = e1.Duration / (e1.Duration + e2.Duration);
            double d2 = e2.Duration / (e1.Duration + e2.Duration);
            double d;

            if (e2.Symbol == "_")
            {
                d           = (e1.Duration) / 4;
                e1.Duration = 5 * d * d1;
            }
            else if (e1.Symbol == "_")
            {
                d           = (e2.Duration) / 4;
                e2.Duration = 5 * d * d2;
            }
            else
            {
                d            = (e1.Duration + e2.Duration) / 3;
                d            = Math.Max(d, 20);
                e1.Duration -= d2 * d;
                e2.Duration -= d1 * d;

                /*e1.Duration=3*d*d1;
                *  e2.Duration=3*d*d2;*/
            }

            /*			for (int i=0;i<e1.Pitch.Count;i++) {
             *  PitchPoint p=e1.Pitch[i];
             *  p.Time*=0.5;
             * }
             * for (int i=0;i<e2.Pitch.Count;i++) {
             *  PitchPoint p=e2.Pitch[i];
             *  p.Time*=0.5;
             *  p.Time+=50;
             * }*/
            return(new MBROLAElement(symbol, d));
        }
 protected override void Consume(Queue <MBROLAElement> InQueue)
 {
     //			base.Consume(InQueue);
     //isRunning = true;
     while (InQueue.Count > 0)
     {
         //                mbrParser.ConsumeSingle(InQueue.Dequeue());
         MBROLAElement element = InQueue.Dequeue(), e1, e2;
         _ItemConsumed(element);
         if ((element.Symbol == "_") && (pho.Length > 0))
         {
             element.SplitHalf(out e1, out e2);
             pho.Append(e1);
             myMbrThread.AddFragment(pho.ToString());
             pho.Remove(0, pho.Length);
             pho.Append(e2);
         }
         else
         {
             pho.Append(element);
         }
     }
 }
        public static MBROLAElement CreateUnify(MBROLAElement e1, MBROLAElement e2, string symbol)
        {
            //            HebrewParser.Log.Synthesizer.WriteLine("Unifying: ");
            //            HebrewParser.Log.Synthesizer.WriteLine("\t" + e1.ToString());
            //            HebrewParser.Log.Synthesizer.WriteLine("\t" + e2.ToString());
            for (int i = 0; i < e1.Pitch.Count; i++)
            {
                MBROLAPitchPoint p = e1.Pitch[i];
                p.Time *= 0.5;
            }
            for (int i = 0; i < e2.Pitch.Count; i++)
            {
                MBROLAPitchPoint p = e2.Pitch[i];
                p.Time *= 0.5;
                p.Time += 50;
                e1.Pitch.Add(p);
            }
            MBROLAElement e = new MBROLAElement(symbol, e1.Duration + e2.Duration, e1.Pitch);

            //            HebrewParser.Log.Synthesizer.WriteLine("Result: ");
            //            HebrewParser.Log.Synthesizer.WriteLine("\t" + e.ToString());
            //			e1.Pitch.AddRange(e2.Pitch);
            return(e);
        }