Example #1
0
        public Sid(int[][] newWaveformTable, int sampleRate, int cyclesNum, int cyclesDen)
        {
            _sampleRate = sampleRate;
            _cpuCyclesNum = cyclesNum;
		    _sampleCyclesDen = cyclesDen*sampleRate;

            _envelopes = new Envelope[3];
			for (var i = 0; i < 3; i++)
				_envelopes[i] = new Envelope();
		    _envelope0 = _envelopes[0];
            _envelope1 = _envelopes[1];
            _envelope2 = _envelopes[2];

            _voices = new Voice[3];
			for (var i = 0; i < 3; i++)
				_voices[i] = new Voice(newWaveformTable);
		    _voice0 = _voices[0];
            _voice1 = _voices[1];
            _voice2 = _voices[2];

            _filterEnable = new bool[3];
			for (var i = 0; i < 3; i++)
				_filterEnable[i] = false;

		    _outputBuffer = new short[sampleRate];
		}
Example #2
0
 public TextToSpeech(string text, Voice voice, int speed, int pitch)
 {
     this.Voice = voice;
     this.Text = text;
     this.Speed = speed;
     this.Pitch = pitch;
 }
Example #3
0
		public Sid(int[][] newWaveformTable, int newSampleRate, Region newRegion)
		{
			uint cyclesPerSec = 0;
			uint cyclesNum;
			uint cyclesDen;
			uint sampleRate = 44100;

			switch (newRegion)
			{
				case Region.NTSC: cyclesNum = 14318181; cyclesDen = 14; break;
				case Region.PAL: cyclesNum = 17734472; cyclesDen = 18; break;
				default: return;
			}

			waveformTable = newWaveformTable;

			envelopes = new Envelope[3];
			for (int i = 0; i < 3; i++)
				envelopes[i] = new Envelope();
			envelopeOutput = new int[3];

			voices = new Voice[3];
			for (int i = 0; i < 3; i++)
				voices[i] = new Voice(newWaveformTable);
			voiceOutput = new int[3];

			filterEnable = new bool[3];
			for (int i = 0; i < 3; i++)
				filterEnable[i] = false;

			resampler = new SpeexResampler(0, cyclesNum, sampleRate * cyclesDen, cyclesNum, sampleRate * cyclesDen, null, null);
		}
        public ChatWindow()
        {
            InitializeComponent();
            DataContext = this;

            _voices = SynthesizerVoice.GetInstalledVoices();
            _outputDevices = OutputDevice.GetInstalledOutputDevices();

            _outputDevice = _outputDevices.First();
            _voice = new Voice(new WaveOut { DeviceNumber = _outputDevice.DeviceNumber });

            _voice.SelectVoice(_voices.First());
            VoiceComboBox.ItemsSource = _voices;
            VoiceComboBox.DisplayMemberPath = "Name";
            VoiceComboBox.SelectionChanged += VoiceComboBox_SelectionChanged;

            _voice.SelectOutput(_outputDevice);
            OutputComboBox.SelectedItem = _outputDevices;
            OutputComboBox.ItemsSource = _outputDevices;
            OutputComboBox.DisplayMemberPath = "Name";
            OutputComboBox.SelectionChanged += OutputComboBox_SelectionChanged;

            SendButton.Click += SendButton_Click;
            MessageTextBox.KeyUp += MessageTextBox_KeyUp;
        }
Example #5
0
 public Ending(Number number, Person person, Tense tense, Voice voice)
 {
     _number = number;
       _person = person;
       _tense = tense;
       _voice = voice;
 }
Example #6
0
        /// <summary>
        /// The <Say> element reads text to the caller using a text-to-speech engine. 
        /// </summary>
        /// <param name="text">Text to say</param>
        /// <param name="voice">The type of voice that will read the text to caller.</param>
        /// <param name="loop">The amount of times the spoken text should be repeated. 0 indicates an infinite loop.</param>
        /// <returns></returns>
        public static Say Create(string text, Voice? voice, long? loop)
        {
            var say = new Say();   
         
            say.Text = text;
            say.Loop = loop == null ? null : loop.ToString();
            say.Voice = voice == null ? null : voice.ToString();

            return say;
        }
Example #7
0
 internal VerbForm(Stem stem, Conjugation conjugation, Person person, Number number, Mood mood, Voice voice, Tense tense, string suffix)
     : base(stem, suffix)
 {
     Conjugation = conjugation;
     Person = person;
     Number = number;
     Mood = mood;
     Voice = voice;
     Tense = tense;
 }
        internal static unsafe void SetOutputMatrix(this SourceVoice sourceVoice, Voice destionationVoice, int sourceChannels, int destinationChannels, float* matrix, int operationSet = 0)
        {
#if UNSHARPER
			Debug.Assert(false);
			return;
#else
            IntPtr destPtr = destionationVoice != null ? destionationVoice.NativePointer : IntPtr.Zero;
            int result = NativeCall<int>.Method<IntPtr, uint, uint, IntPtr, uint>(sourceVoice.NativePointer, 16, destPtr, (uint)sourceChannels, (uint)destinationChannels, new IntPtr(matrix), (uint)operationSet);
            ((SharpDX.Result)result).CheckError();
#endif
        }
Example #9
0
 string VoiceToString(Voice voice)
 {
     switch (voice)
     {
         case Activities.Voice.Man:
             return "man";
         case Activities.Voice.Woman:
             return "woman";
         default:
             throw new InvalidOperationException("Unknown voice.");
     }
 }
    public Voice applyVoiceTone(Voice voice, Tone tone)
    {
        Voice curVoice = voice;
        switch(tone)
        {
            case Tone.Anxious:
                curVoice.pitch += 0.03f;
                curVoice.volume += 0.2f;
                break;

        }
        return curVoice;
    }
Example #11
0
 public GoogleVoice(string username, string password)
 {
     try
     {
         voiceConnection = new Voice(username, password);
         mostRecent = new SharpVoice.Message();
         mostRecent.ID = "";
     }
     catch (Exception e)
     {
         Console.WriteLine("Failed To Login: "+e.Message);
     }
     userPresent = true;
 }
Example #12
0
        public SID()
        {
            for (int i = 0; i < voice.Length; i++)
            {
                voice[i] = new Voice();
            }
            voice[0].SetSyncSource(voice[2]);
            voice[1].SetSyncSource(voice[0]);
            voice[2].SetSyncSource(voice[1]);

            SetSamplingParameters(985248, 44100);

            bus_value = 0;
            bus_value_ttl = 0;
        }
Example #13
0
	void Start () 
	{
		currentWorld = spawnWorld;
		this.transform.position = currentWorld.transform.position;
		rayDirection = new Vector3(0.5f, 0.5f, 1f);

		ui = GetComponent<Interface>();
		fx = GameObject.FindObjectOfType<FX>();
		voice = GameObject.FindObjectOfType<Voice>();
		
		transition = GameObject.FindObjectOfType<Transition>();
		mouseLook = GameObject.FindObjectOfType<MouseLook>();
		audioListener = GameObject.FindObjectOfType<AudioListener>().transform;

		StartCoroutine(transition.Intro(gateSpawn));
	}
Example #14
0
 public static IConjugation Get(Mood mood, Voice voice, Tense tense)
 {
     if (!CONJUGATIONS.ContainsKey(mood))
       {
     throw new NotSupportedException(string.Format("unrecognised mood of sum : {0}", mood));
       }
       if (!CONJUGATIONS[mood].ContainsKey(voice))
       {
     throw new NotSupportedException(string.Format("unrecognised voice of sum : {0}", voice));
       }
       if (!CONJUGATIONS[mood][voice].ContainsKey(tense))
       {
     throw new NotSupportedException(string.Format("unrecognised tense of sum : {0}", tense));
       }
       return CONJUGATIONS[mood][voice][tense];
 }
    public void UpdateText(string text, CapsOptions caps, Voice voice)
    {
        switch (caps) {
        case CapsOptions.kToUpper:
            text = text.ToUpper ();
            break;
        case CapsOptions.kToLower:
            text = text.ToLower ();
            break;
        case CapsOptions.kNone:
        default:
            break;
        }

        dialogText.text = text;

        dialogText.gameObject.GetComponent<Typewriter> ().typeSound = voice;
    }
        private WordForm GetFirstConjugationForm(Person person, Number number, Mood mood, Voice voice, Tense tense)
        {
            var suffix = string.Empty;
            if (person == Person.First && number == Number.Singluar && mood == Mood.Indicative && voice == Voice.Active)
                suffix = "m";
            if (person == Person.Second && number == Number.Singluar && mood == Mood.Indicative && voice == Voice.Active)
                suffix = "s";
            if (person == Person.Third && number == Number.Singluar && mood == Mood.Indicative && voice == Voice.Active)
                suffix = "t";
            if (person == Person.First && number == Number.Plural && mood == Mood.Indicative && voice == Voice.Active)
                suffix = "mus";
            if (person == Person.Second && number == Number.Plural && mood == Mood.Indicative && voice == Voice.Active)
                suffix = "tis";
            if (person == Person.Third && number == Number.Plural && mood == Mood.Indicative && voice == Voice.Active)
                suffix = "nt";

            return new VerbForm(this, Conjugation, person, number, mood, voice, tense, suffix);
        }
Example #17
0
	public IEnumerator Intro (Gate gateSpawn) 
	{
		// Start

		fx = GameObject.FindObjectOfType<FX>();
		voice = GameObject.FindObjectOfType<Voice>();

		voice.Cough();
		yield return new WaitForSeconds(1f);
		
		fx.Match();
		yield return new WaitForSeconds(3f);

		// Update

		float timeElapsed = 0f;
		float timeRatio = 0f;
		float duration = 2f;
		while (timeElapsed < duration) {
			timeRatio = timeElapsed / duration;
			materialTitle.SetFloat("_Alpha", timeRatio);
			timeElapsed += Time.deltaTime;
			yield return 0;
		}

		yield return new WaitForSeconds(1f);

		timeElapsed = 0f;

		while (timeElapsed < duration) {
			timeRatio = timeElapsed / duration;
			materialTitle.SetFloat("_Alpha", 1f - timeRatio);
			timeElapsed += Time.deltaTime;
			yield return 0;
		}

		fx.BookFall();

		yield return new WaitForSeconds(1f);

		StartCoroutine(Goto(gateSpawn));

		player.started = true;
	}
Example #18
0
		public Sid(int[][] newWaveformTable, uint sampleRate, uint cyclesNum, uint cyclesDen)
		{
			waveformTable = newWaveformTable;

			envelopes = new Envelope[3];
			for (int i = 0; i < 3; i++)
				envelopes[i] = new Envelope();
			envelopeOutput = new int[3];

			voices = new Voice[3];
			for (int i = 0; i < 3; i++)
				voices[i] = new Voice(newWaveformTable);
			voiceOutput = new int[3];

			filterEnable = new bool[3];
			for (int i = 0; i < 3; i++)
				filterEnable[i] = false;

			resampler = new SpeexResampler(0, cyclesNum, sampleRate * cyclesDen, cyclesNum, sampleRate * cyclesDen, null, null);
		}
        private void xmlToGeneric(TFSXmlMonster tfsMonster, out Monster monster)
        {
            monster = new Monster()
            {
                Name       = tfsMonster.name,
                Health     = (uint)tfsMonster.health.max,
                Experience = (uint)tfsMonster.experience,
                Speed      = (uint)tfsMonster.speed,
                Race       = tfsToGenericBlood(tfsMonster.race),
            };

            if (!string.IsNullOrEmpty(tfsMonster.nameDescription))
            {
                monster.Description = tfsMonster.nameDescription;
            }
            if (!string.IsNullOrEmpty(tfsMonster.namedescription))
            {
                monster.Description = tfsMonster.namedescription;
            }

            if (tfsMonster.targetchange != null)
            {
                monster.RetargetChance = (uint)tfsMonster.targetchange.chance;

                if ((tfsMonster.targetchange.interval != 0) &&
                    (tfsMonster.targetchange.speed == 0))
                {
                    monster.RetargetInterval = (uint)tfsMonster.targetchange.interval;
                }
                else if ((tfsMonster.targetchange.interval == 0) &&
                         (tfsMonster.targetchange.speed != 0))
                {
                    monster.RetargetInterval = (uint)tfsMonster.targetchange.speed;
                }
                else if ((tfsMonster.targetchange.interval != 0) &&
                         (tfsMonster.targetchange.speed != 0))
                {
                    System.Diagnostics.Debug.WriteLine("Warning duplicate target speed and target interval");
                }
            }

            if (tfsMonster.look != null)
            {
                monster.CorpseId         = (uint)tfsMonster.look.corpse;
                monster.OutfitIdLookType = (uint)tfsMonster.look.type;
                monster.LookTypeDetails  = new DetailedLookType()
                {
                    Head   = (ushort)tfsMonster.look.head,
                    Body   = (ushort)tfsMonster.look.body,
                    Legs   = (ushort)tfsMonster.look.legs,
                    Feet   = (ushort)tfsMonster.look.feet,
                    Addons = (ushort)tfsMonster.look.addons,
                    Mount  = (ushort)tfsMonster.look.mount
                };
                monster.ItemIdLookType = (uint)tfsMonster.look.typeex;
            }

            // flags
            if ((tfsMonster.flags != null) &&
                (tfsMonster.flags.flag != null))
            {
                foreach (var x in tfsMonster.flags.flag)
                {
                    int value;
                    if (int.TryParse(x.attr[0].Value, out value))
                    {
                        if (x.attr[0].Name == "summonable")
                        {
                            monster.SummonCost = (uint)tfsMonster.manacost;
                        }
                        else if (x.attr[0].Name == "attackable")
                        {
                            monster.Attackable = value == 1;
                        }
                        else if (x.attr[0].Name == "hostile")
                        {
                            monster.Hostile = value == 1;
                        }
                        else if (x.attr[0].Name == "illusionable")
                        {
                            monster.Illusionable = value == 1;
                        }
                        else if (x.attr[0].Name == "convinceable")
                        {
                            monster.ConvinceCost = (uint)tfsMonster.manacost;
                        }
                        else if (x.attr[0].Name == "pushable")
                        {
                            monster.Pushable = value == 1;
                        }
                        else if (x.attr[0].Name == "canpushitems")
                        {
                            monster.PushItems = value == 1;
                        }
                        else if (x.attr[0].Name == "canpushcreatures")
                        {
                            monster.PushCreatures = value == 1;
                        }
                        else if (x.attr[0].Name == "targetdistance")
                        {
                            monster.TargetDistance = (uint)value;
                        }
                        else if (x.attr[0].Name == "staticattack")
                        {
                            monster.StaticAttack = (uint)value;
                        }
                        else if (x.attr[0].Name == "lightlevel")
                        {
                            monster.LightLevel = (uint)value;
                        }
                        else if (x.attr[0].Name == "lightcolor")
                        {
                            monster.LightColor = (uint)value;
                        }
                        else if (x.attr[0].Name == "runonhealth")
                        {
                            monster.RunOnHealth = (uint)value;
                        }
                        else if (x.attr[0].Name == "hidehealth")
                        {
                            monster.HideHealth = value == 1;
                        }
                        else if (x.attr[0].Name == "canwalkonenergy")
                        {
                            monster.AvoidEnergy = value != 1;
                        }
                        else if (x.attr[0].Name == "canwalkonfire")
                        {
                            monster.AvoidFire = value != 1;
                        }
                        else if (x.attr[0].Name == "canwalkonpoison")
                        {
                            monster.AvoidPoison = value != 1;
                        }
                        else if (x.attr[0].Name == "isboss")
                        {
                            monster.IsBoss = value == 1;
                        }
                        else
                        {
                            Console.WriteLine($"Unknown name {x.attr[0].Name}");
                        }
                    }
                }
            }

            // sounds
            if ((tfsMonster.voices != null) &&
                (tfsMonster.voices.voice != null))
            {
                foreach (VoiceXml sound in tfsMonster.voices.voice)
                {
                    Voice voice = new Voice();
                    voice.Sound = sound.sentence;
                    if (!(string.IsNullOrEmpty(sound.yell)) &&
                        ((sound.yell == "1") || (sound.yell == "true")))
                    {
                        voice.SoundLevel = SoundLevel.Yell;
                    }
                    else
                    {
                        voice.SoundLevel = SoundLevel.Say;
                    }
                    monster.Voices.Add(voice);
                }
            }

            // summons
            if (tfsMonster.summons != null)
            {
                monster.MaxSummons = (uint)tfsMonster.summons.maxSummons;
                foreach (TFSXmlSummon summon in tfsMonster.summons.summon)
                {
                    monster.Summons.Add(new Summon()
                    {
                        Name   = summon.name,
                        Chance = Math.Min(1, (double)summon.chance / 100),
                        Rate   = (uint)((summon.interval > 0) ? summon.interval : summon.speed),
                        Max    = summon.max,
                        Force  = summon.force
                    });
                }
            }
            else
            {
                monster.MaxSummons = 0;
            }

            if (tfsMonster.attacks != null)
            {
                XmlSpellsToGeneric(ref monster, tfsMonster.attacks.attack, SpellCategory.Offensive);
            }

            // Defenses
            if (tfsMonster.defenses != null)
            {
                monster.TotalArmor = tfsMonster.defenses.armor;
                monster.Shielding  = tfsMonster.defenses.defense;
                XmlSpellsToGeneric(ref monster, tfsMonster.defenses.defenses, SpellCategory.Defensive);
            }

            #region parseElements
            if ((tfsMonster.elements != null) &&
                (tfsMonster.elements.element != null))
            {
                foreach (var x in tfsMonster.elements.element)
                {
                    int value;
                    if (int.TryParse(x.attr[0].Value, out value))
                    {
                        if (x.attr[0].Name == "physicalPercent")
                        {
                            monster.Physical = tfstoGenericElementalPercent(value);
                        }
                        else if (x.attr[0].Name == "icePercent")
                        {
                            monster.Ice = tfstoGenericElementalPercent(value);
                        }
                        else if (x.attr[0].Name == "poisonPercent")
                        {
                            monster.Earth = tfstoGenericElementalPercent(value);
                        }
                        else if (x.attr[0].Name == "earthPercent")
                        {
                            monster.Earth = tfstoGenericElementalPercent(value);
                        }
                        else if (x.attr[0].Name == "firePercent")
                        {
                            monster.Fire = tfstoGenericElementalPercent(value);
                        }
                        else if (x.attr[0].Name == "energyPercent")
                        {
                            monster.Energy = tfstoGenericElementalPercent(value);
                        }
                        else if (x.attr[0].Name == "holyPercent")
                        {
                            monster.Holy = tfstoGenericElementalPercent(value);
                        }
                        else if (x.attr[0].Name == "deathPercent")
                        {
                            monster.Death = tfstoGenericElementalPercent(value);
                        }
                        else if (x.attr[0].Name == "drownPercent")
                        {
                            monster.Drown = tfstoGenericElementalPercent(value);
                        }
                        else if (x.attr[0].Name == "lifedrainPercent")
                        {
                            monster.LifeDrain = tfstoGenericElementalPercent(value);
                        }
                        else if (x.attr[0].Name == "manadrainPercent")
                        {
                            monster.ManaDrain = tfstoGenericElementalPercent(value);
                        }
                    }
                }
            }
            #endregion

            #region paraseImmunities
            if ((tfsMonster.immunities != null) &&
                (tfsMonster.immunities.immunity != null))
            {
                foreach (Immunity immunity in tfsMonster.immunities.immunity)
                {
                    if (immunity.name != namedImmunityXml.NA)
                    {
                        switch (immunity.name)
                        {
                        case namedImmunityXml.physical:
                            monster.Physical = 0;
                            break;

                        case namedImmunityXml.energy:
                            monster.Energy = 0;
                            break;

                        case namedImmunityXml.fire:
                            monster.Fire = 0;
                            break;

                        case namedImmunityXml.poison:     //namedImmunityXml.earth
                            monster.Earth = 0;
                            break;

                        case namedImmunityXml.drown:
                            monster.Drown = 0;
                            break;

                        case namedImmunityXml.ice:
                            monster.Ice = 0;
                            break;

                        case namedImmunityXml.holy:
                            monster.Holy = 0;
                            break;

                        case namedImmunityXml.death:
                            monster.Death = 0;
                            break;

                        case namedImmunityXml.lifedrain:
                            monster.LifeDrain = 0;
                            break;

                        case namedImmunityXml.manadrain:
                            monster.ManaDrain = 0;
                            break;

                        case namedImmunityXml.paralyze:
                            monster.IgnoreParalyze = true;
                            break;

                        case namedImmunityXml.outfit:
                            monster.IgnoreOutfit = true;
                            break;

                        case namedImmunityXml.drunk:
                            monster.IgnoreDrunk = true;
                            break;

                        case namedImmunityXml.invisible:     //namedImmunityXml.invisibility
                            monster.IgnoreInvisible = true;
                            break;

                        case namedImmunityXml.bleed:
                            monster.IgnoreBleed = true;
                            break;
                        }
                    }
                    else if (immunity.physical != 0)
                    {
                        monster.Physical = 0;
                    }
                    else if (immunity.energy != 0)
                    {
                        monster.Energy = 0;
                    }
                    else if (immunity.fire != 0)
                    {
                        monster.Fire = 0;
                    }
                    else if (immunity.poison != 0) //poison and earth are the same
                    {
                        monster.Earth = 0;
                    }
                    else if (immunity.earth != 0) //poison and earth are the same
                    {
                        monster.Earth = 0;
                    }
                    else if (immunity.drown != 0)
                    {
                        monster.Drown = 0;
                    }
                    else if (immunity.ice != 0)
                    {
                        monster.Ice = 0;
                    }
                    else if (immunity.holy != 0)
                    {
                        monster.Holy = 0;
                    }
                    else if (immunity.death != 0)
                    {
                        monster.Death = 0;
                    }
                    else if (immunity.lifedrain != 0)
                    {
                        monster.LifeDrain = 0;
                    }
                    else if (immunity.manadrain != 0)
                    {
                        monster.ManaDrain = 0;
                    }
                    else if (immunity.paralyze != 0)
                    {
                        monster.IgnoreParalyze = true;
                    }
                    else if (immunity.outfit != 0)
                    {
                        monster.IgnoreOutfit = true;
                    }
                    else if (immunity.bleed != 0)
                    {
                        monster.IgnoreBleed = true;
                    }
                    else if (immunity.drunk != 0)
                    {
                        monster.IgnoreDrunk = true;
                    }
                    else if (immunity.invisible != 0) //invisible and invisibility are the same
                    {
                        monster.IgnoreInvisible = true;
                    }
                    else if (immunity.invisibility != 0) //invisible and invisibility are the same
                    {
                        monster.IgnoreInvisible = true;
                    }
                }
            }
            #endregion

            // Loot
            if ((tfsMonster.loot != null) &&
                (tfsMonster.loot.item != null))
            {
                foreach (var item in tfsMonster.loot.item)
                {
                    string itemType = "";
                    if (!string.IsNullOrEmpty(item.name))
                    {
                        itemType = item.name;
                    }
                    else if (item.id > 0)
                    {
                        itemType = item.id.ToString();
                    }

                    decimal chance = 1;
                    if (item.chance > 0)
                    {
                        chance = item.chance;
                    }
                    else if (item.chance1 > 0)
                    {
                        chance = item.chance1;
                    }

                    chance /= MAX_LOOTCHANCE;

                    Loot commonItem = new Loot()
                    {
                        Item   = itemType,
                        Chance = chance,
                        Count  = item.countmax
                    };
                    monster.Items.Add(commonItem);
                }
            }
        }
Example #20
0
        /// <summary>
        /// 根据XML信息填充实实体
        /// </summary>
        /// <typeparam name="T">MessageBase为基类的类型,Response和Request都可以</typeparam>
        /// <param name="entity">实体</param>
        /// <param name="doc">XML</param>
        public static void FillEntityWithXml <T>(this T entity, XDocument doc) where T : /*MessageBase*/ class, new()
        {
            entity = entity ?? new T();
            var root = doc.Root;

            var props = entity.GetType().GetProperties();

            foreach (var prop in props)
            {
                var propName = prop.Name;
                if (root.Element(propName) != null)
                {
                    switch (prop.PropertyType.Name)
                    {
                    //case "String":
                    //    goto default;
                    case "DateTime":
                    case "Int32":
                    case "Int64":
                    case "Double":
                    case "Nullable`1":     //可为空对象
                        EntityUtility.EntityUtility.FillSystemType(entity, prop, root.Element(propName).Value);
                        break;

                    case "Boolean":
                        if (propName == "FuncFlag")
                        {
                            EntityUtility.EntityUtility.FillSystemType(entity, prop, root.Element(propName).Value == "1");
                        }
                        else
                        {
                            goto default;
                        }
                        break;

                    //以下为枚举类型
                    case "RequestMsgType":
                        //已设为只读
                        //prop.SetValue(entity, MsgTypeHelper.GetRequestMsgType(root.Element(propName).Value), null);
                        break;

                    case "ResponseMsgType":                            //Response适用
                        //已设为只读
                        //prop.SetValue(entity, MsgTypeHelper.GetResponseMsgType(root.Element(propName).Value), null);
                        break;

                    case "ThirdPartyInfo":    //ThirdPartyInfo适用
                        //已设为只读
                        //prop.SetValue(entity, MsgTypeHelper.GetResponseMsgType(root.Element(propName).Value), null);
                        break;

                    case "Event":
                        //已设为只读
                        //prop.SetValue(entity, EventHelper.GetEventType(root.Element(propName).Value), null);
                        break;

                    //以下为实体类型
                    case "List`1":                                 //List<T>类型,ResponseMessageNews适用
                        var genericArguments = prop.PropertyType.GetGenericArguments();
                        if (genericArguments[0].Name == "Article") //ResponseMessageNews适用
                        {
                            //文章下属节点item
                            List <Article> articles = new List <Article>();
                            foreach (var item in root.Element(propName).Elements("item"))
                            {
                                var article = new Article();
                                FillEntityWithXml(article, new XDocument(item));
                                articles.Add(article);
                            }
                            prop.SetValue(entity, articles, null);
                        }
                        else if (genericArguments[0].Name == "MpNewsArticle")
                        {
                            List <MpNewsArticle> mpNewsArticles = new List <MpNewsArticle>();
                            foreach (var item in root.Elements(propName))
                            {
                                var mpNewsArticle = new MpNewsArticle();
                                FillEntityWithXml(mpNewsArticle, new XDocument(item));
                                mpNewsArticles.Add(mpNewsArticle);
                            }
                            prop.SetValue(entity, mpNewsArticles, null);
                        }
                        else if (genericArguments[0].Name == "PicItem")
                        {
                            List <PicItem> picItems = new List <PicItem>();
                            foreach (var item in root.Elements(propName).Elements("item"))
                            {
                                var    picItem   = new PicItem();
                                var    picMd5Sum = item.Element("PicMd5Sum").Value;
                                Md5Sum md5Sum    = new Md5Sum()
                                {
                                    PicMd5Sum = picMd5Sum
                                };
                                picItem.item = md5Sum;
                                picItems.Add(picItem);
                            }
                            prop.SetValue(entity, picItems, null);
                        }
                        break;

                    case "Image":                            //ResponseMessageImage适用
                        Image image = new Image();
                        FillEntityWithXml(image, new XDocument(root.Element(propName)));
                        prop.SetValue(entity, image, null);
                        break;

                    case "Voice":                            //ResponseMessageVoice适用
                        Voice voice = new Voice();
                        FillEntityWithXml(voice, new XDocument(root.Element(propName)));
                        prop.SetValue(entity, voice, null);
                        break;

                    case "Video":                            //ResponseMessageVideo适用
                        Video video = new Video();
                        FillEntityWithXml(video, new XDocument(root.Element(propName)));
                        prop.SetValue(entity, video, null);
                        break;

                    case "ScanCodeInfo":    //扫码事件中的ScanCodeInfo适用
                        ScanCodeInfo scanCodeInfo = new ScanCodeInfo();
                        FillEntityWithXml(scanCodeInfo, new XDocument(root.Element(propName)));
                        prop.SetValue(entity, scanCodeInfo, null);
                        break;

                    case "SendLocationInfo":    //弹出地理位置选择器的事件推送中的SendLocationInfo适用
                        SendLocationInfo sendLocationInfo = new SendLocationInfo();
                        FillEntityWithXml(sendLocationInfo, new XDocument(root.Element(propName)));
                        prop.SetValue(entity, sendLocationInfo, null);
                        break;

                    case "SendPicsInfo":    //系统拍照发图中的SendPicsInfo适用
                        SendPicsInfo sendPicsInfo = new SendPicsInfo();
                        FillEntityWithXml(sendPicsInfo, new XDocument(root.Element(propName)));
                        prop.SetValue(entity, sendPicsInfo, null);
                        break;

                    case "BatchJobInfo":    //异步任务完成事件推送BatchJob
                        BatchJobInfo batchJobInfo = new BatchJobInfo();
                        FillEntityWithXml(batchJobInfo, new XDocument(root.Element(propName)));
                        prop.SetValue(entity, batchJobInfo, null);
                        break;

                    default:
                        prop.SetValue(entity, root.Element(propName).Value, null);
                        break;
                    }
                }
            }
        }
Example #21
0
    void Start()
    {
        MainCamera = GameObject.Find("Main Camera");
        CenterObj  = MainCamera;
        Menu       = GameObject.Find("Menu Canvas");
        Payment    = GameObject.Find("Payment Canvas");
        Msg        = GameObject.Find("Msg Canvas");
        Trans      = GameObject.Find("Trans Canvas");
        Search     = GameObject.Find("Search Canvas");
        Cart       = GameObject.Find("Cart Canvas");
        Info       = GameObject.Find("Info Canvas");
        Good       = GameObject.Find("Good Canvas");
        Voice      = GameObject.Find("Voice Canvas");
        NewOrder   = GameObject.Find("Order Canvas");
        Copy       = GameObject.Find("Copy Canvas");
        Model      = GameObject.Find("Model Canvas");
        House      = GameObject.Find("House Canvas");
        HouseView  = GameObject.Find("House View");
        Star       = GameObject.Find("Star");

        int langNum;

        if (!string.IsNullOrEmpty(GetString("lang")))
        {
            langNum = int.Parse(GetString("lang"));
        }
        else
        {
            langNum = Application.systemLanguage.ToString() == "Chinese" ? 1 : Application.systemLanguage.ToString() == "English" ? 0 : 0;
            SetString("lang", langNum.ToString());
        }
        Debug.Log(langNum);
        Language.ini(langNum);//语言初始化

        Star.SetActive(false);
        HouseView.SetActive(false);
        House.SetActive(false);
        Model.SetActive(false);
        Copy.SetActive(false);
        NewOrder.SetActive(false);
        Voice.SetActive(false);
        Good.SetActive(false);
        Info.SetActive(false);
        Cart.SetActive(false);
        Search.SetActive(false);
        Trans.SetActive(false);
        Msg.SetActive(false);
        Payment.SetActive(false);
        Menu.SetActive(false);

        facePosition = new Vector3(
            Mathf.Sin((CenterObj.transform.rotation.eulerAngles.y * Mathf.PI) / 180) * faceRadius,
            Mathf.Sin((-CenterObj.transform.rotation.eulerAngles.x * Mathf.PI) / 180) * 3f > 1.5f ? Mathf.Sin((-CenterObj.transform.rotation.eulerAngles.x * Mathf.PI) / 180) * 3f : 1.5f,
            Mathf.Cos((CenterObj.transform.rotation.eulerAngles.y * Mathf.PI) / 180) * faceRadius);
        faceRotation = Quaternion.Euler(
            CenterObj.transform.rotation.eulerAngles.x < 0f ? CenterObj.transform.rotation.eulerAngles.x : 0f,
            CenterObj.transform.rotation.eulerAngles.y,
            0f);


#if UNITY_EDITOR
        device = 1;
#endif
#if UNITY_ANDROID
        device = 2;
#endif
#if UNITY_IPHONE
        device = 3;
#endif
#if UNITY_METRO
        device = 4;
#endif
        Debug.Log("device: " + device);
        check();               //检查版本
        SetString("id", "-1"); //设置初始化id为-1,即未登录

        for (int i = 0; i < 10; i++)
        {
            star();
        }
        inied = false;

        //以上是正式代码,以下是测试代码
    }
Example #22
0
 /// <summary>
 /// Initializes a new instance of the <see cref="VoiceSendDescriptor"/> struct.
 /// </summary>
 /// <param name="flags">The send flags.</param>
 /// <param name="outputVoice">The output voice.</param>
 public VoiceSendDescriptor(VoiceSendFlags flags, Voice outputVoice)
 {
     Flags = flags;
     OutputVoicePointer = IntPtr.Zero;
     OutputVoice = outputVoice;
 }
Example #23
0
        /// <summary>
        /// Sends a message to a rabbit configured in the config file.
        /// </summary>
        /// <param name="name">Name of the rabbit in the config file.</param>
        /// <param name="text">Text for the rabbit to read out.</param>
        /// <param name="voice">Voice which the text should be read in.</param>
        public static void SendMessage(string name, string text, Voice voice)
        {
            if (string.IsNullOrEmpty("name"))
            {
                throw new ArgumentNullException("name");
            }

            if (string.IsNullOrEmpty("text"))
            {
                throw new ArgumentNullException("text");
            }

            Nabaztag nab = GetRabbit(name);

            if (nab != null)
            {
                NabaztagMessage eve = new NabaztagMessage();
                eve.Speech = new TextToSpeech(text, voice, 1, 1);
                nab.SendEvent(eve);
            }
        }
 public Pronunciation GetPronunciation(string text, Voice voice)
 {
     return(GetPronunciation(text, voice, null));
 }
 public Stream Synthesize(string text, Voice voice, AudioType audioType)
 {
     return(synthesize(text, voice, audioType));
 }
Example #26
0
    private int readBeat(int start, Voice voice)
    {
        /* The first byte is the beat flags. It lists the data present in
         * the current beat:
         *
         * - *0x01*: dotted notes
         * - *0x02*: presence of a chord diagram
         * - *0x04*: presence of a text
         * - *0x08*: presence of effects
         * - *0x10*: presence of a mix table change event
         * - *0x20*: the beat is a n-tuplet
         * - *0x40*: status: True if the beat is empty of if it is a rest
         * - *0x80*: *blank*
         *
         * Flags are followed by:
         *
         * - Status: :ref:`byte`. If flag at *0x40* is true, read one byte.
         * If value of the byte is *0x00* then beat is empty, if value is
         * 0x02* then the beat is rest.
         *
         * - Beat duration: :ref:`byte`. See :meth:`readDuration`.
         *
         * - Chord diagram. See :meth:`readChord`.
         *
         * - Text. See :meth:`readText`.
         *
         * - Beat effects. See :meth:`readBeatEffects`.
         *
         * - Mix table change effect. See :meth:`readMixTableChange`.*/

        var flags = GPBase.readByte()[0];
        var beat  = getBeat(voice, start);

        if ((flags & 0x40) != 0)
        {
            beat.status = (BeatStatus)((int)GPBase.readByte()[0]);
        }
        else
        {
            beat.status = BeatStatus.normal;
        }
        var duration = readDuration(flags);
        var effect   = new NoteEffect();

        if ((flags & 0x02) != 0)
        {
            beat.effect.chord = readChord(voice.measure.track.strings.Count);
        }
        if ((flags & 0x04) != 0)
        {
            beat.text = readText();
        }
        if ((flags & 0x08) != 0)
        {
            beat.effect = readBeatEffects(effect);
        }
        if ((flags & 0x10) != 0)
        {
            var mixTableChange = readMixTableChange(voice.measure);
            beat.effect.mixTableChange = mixTableChange;
        }
        readNotes(voice.measure.track, beat, duration, effect);
        return((!(beat.status == BeatStatus.empty)) ? duration.time() : 0);
    }
 public ResponseMessageVoice()
 {
     Voice = new Voice();
 }
Example #28
0
        private void run_envelope(Voice v)
        {
            int env = v.env;
            if (v.env_mode == EnvMode.release) // 60%
            {
                if ((env -= 0x8) < 0)
                {
                    env = 0;
                }
                v.env = env;
            }
            else
            {
                int rate;
                int env_data = v.regs.Array[v.regs.Offset + (int)VoiceReg.adsr1];
                if (Convert.ToBoolean(m.t_adsr0 & 0x80)) // 99% ADSR
                {
                    if (v.env_mode >= EnvMode.decay) // 99%
                    {
                        env--;
                        env -= env >> 8;
                        rate = env_data & 0x1F;
                        if (v.env_mode == EnvMode.decay) // 1%
                        {
                            rate = (m.t_adsr0 >> 3 & 0x0E) + 0x10;
                        }
                    }
                    else // env_attack
                    {
                        rate = (m.t_adsr0 & 0x0F) * 2 + 1;
                        env += rate < 31 ? 0x20 : 0x400;
                    }
                }
                else // GAIN
                {
                    int mode;
                    env_data = v.regs.Array[v.regs.Offset + (int)VoiceReg.gain];
                    mode = env_data >> 5;
                    if (mode < 4) // direct
                    {
                        env = env_data * 0x10;
                        rate = 31;
                    }
                    else
                    {
                        rate = env_data & 0x1F;
                        if (mode == 4) // 4: linear decrease
                        {
                            env -= 0x20;
                        }
                        else if (mode < 6) // 5: exponential decrease
                        {
                            env--;
                            env -= env >> 8;
                        }
                        else // 6,7: linear increase
                        {
                            env += 0x20;
                            if (mode > 6 && (uint)v.hidden_env >= 0x600)
                            {
                                env += 0x8 - 0x20; // 7: two-slope linear increase
                            }
                        }
                    }
                }

                // Sustain level
                if ((env >> 8) == (env_data >> 5) && v.env_mode == EnvMode.decay)
                {
                    v.env_mode = EnvMode.sustain;
                }

                v.hidden_env = env;

                // uint cast because linear decrease going negative also triggers this
                if ((uint)env > 0x7FF)
                {
                    env = (env < 0 ? 0 : 0x7FF);
                    if (v.env_mode == EnvMode.attack)
                    {
                        v.env_mode = EnvMode.decay;
                    }
                }

                if (!Convert.ToBoolean(read_counter(rate)))
                {
                    v.env = env; // nothing else is controlled by the counter
                }
            }
        }
Example #29
0
        private void decode_brr(Voice v)
        {
            // Arrange the four input nybbles in 0xABCD order for easy decoding
            int nybbles = m.t_brr_byte * 0x100 + m.ram[(v.brr_addr + v.brr_offset + 1) & 0xFFFF];

            int header = m.t_brr_header;

            // Write to next four samples in circular buffer
            ArraySegment<int> pos = new ArraySegment<int>(v.buf, v.buf_pos, v.buf.Length - v.buf_pos);
            ArraySegment<int> end;
            if ((v.buf_pos += 4) >= brr_buf_size)
            {
                v.buf_pos = 0;
            }

            // Decode four samples
            for (end = new ArraySegment<int>(pos.Array, pos.Offset + 4, pos.Count - 4); pos.Offset < end.Offset; pos = new ArraySegment<int>(pos.Array, pos.Offset + 1, pos.Count - 1), nybbles <<= 4)
            {
                // Extract nybble and sign-extend
                int s = (short)nybbles >> 12;

                // Shift sample based on header
                int shift = header >> 4;
                s = (s << shift) >> 1;
                if (shift >= 0xD) // handle invalid range
                {
                    s = (s >> 25) << 11; // same as: s = (s < 0 ? -0x800 : 0)
                }

                // Apply IIR filter (8 is the most commonly used)
                int filter = header & 0x0C;
                int p1 = pos.Array[pos.Offset + brr_buf_size - 1];
                int p2 = pos.Array[pos.Offset + brr_buf_size - 2] >> 1;
                if (filter >= 8)
                {
                    s += p1;
                    s -= p2;
                    if (filter == 8) // s += p1 * 0.953125 - p2 * 0.46875
                    {
                        s += p2 >> 4;
                        s += (p1 * -3) >> 6;
                    }
                    else // s += p1 * 0.8984375 - p2 * 0.40625
                    {
                        s += (p1 * -13) >> 7;
                        s += (p2 * 3) >> 4;
                    }
                }
                else if (Convert.ToBoolean(filter)) // s += p1 * 0.46875
                {
                    s += p1 >> 1;
                    s += (-p1) >> 5;
                }

                // Adjust and write sample
                Clamp16(ref  s);
                s = (short)(s * 2);
                pos.Array[pos.Offset + brr_buf_size] = pos.Array[pos.Offset + 0] = s; // second copy simplifies wrap-around
            }
        }
 private void OnGetVoice(Voice voice, Dictionary <string, object> customData = null)
 {
     Log.Debug("ExampleTextToSpeech.OnGetVoice()", "Text to Speech - Get voice  response: {0}", customData["json"].ToString());
     _getVoiceTested = true;
 }
Example #31
0
        private void Beat(Voice voice)
        {
            // duration specifier?
            if (_sy == AlphaTexSymbols.DoubleDot)
            {
                NewSy();
                if (_sy != AlphaTexSymbols.Number)
                {
                    Error("duration", AlphaTexSymbols.Number);
                }

                var duration = (int)_syData;
                switch (duration)
                {
                case 1:
                case 2:
                case 4:
                case 8:
                case 16:
                case 32:
                case 64:
                    _currentDuration = ParseDuration((int)_syData);
                    break;

                default:
                    Error("duration", AlphaTexSymbols.Number, false);
                    break;
                }

                NewSy();
                return;
            }

            var beat = new Beat();

            voice.AddBeat(beat);

            if (voice.Bar.MasterBar.TempoAutomation != null && voice.Beats.Count == 1)
            {
                beat.Automations.Add(voice.Bar.MasterBar.TempoAutomation);
            }

            // notes
            if (_sy == AlphaTexSymbols.LParensis)
            {
                NewSy();

                Note(beat);
                while (_sy != AlphaTexSymbols.RParensis && _sy != AlphaTexSymbols.Eof)
                {
                    Note(beat);
                }

                if (_sy != AlphaTexSymbols.RParensis)
                {
                    Error("note-list", AlphaTexSymbols.RParensis);
                }
                NewSy();
            }
            // rest
            else if (_sy == AlphaTexSymbols.String && _syData.ToString().ToLower() == "r")
            {
                // rest voice -> no notes
                NewSy();
            }
            else
            {
                Note(beat);
            }

            // new duration
            if (_sy == AlphaTexSymbols.Dot)
            {
                NewSy();
                if (_sy != AlphaTexSymbols.Number)
                {
                    Error("duration", AlphaTexSymbols.Number);
                }

                var duration = (int)_syData;
                switch (duration)
                {
                case 1:
                case 2:
                case 4:
                case 8:
                case 16:
                case 32:
                case 64:
                    _currentDuration = ParseDuration((int)_syData);
                    break;

                default:
                    Error("duration", AlphaTexSymbols.Number, false);
                    break;
                }

                NewSy();
            }
            else
            {
                beat.Duration = _currentDuration;
            }

            // beat multiplier (repeat beat n times)
            var beatRepeat = 1;

            if (_sy == AlphaTexSymbols.Multiply)
            {
                NewSy();

                // multiplier count
                if (_sy != AlphaTexSymbols.Number)
                {
                    Error("multiplier", AlphaTexSymbols.Number);
                }
                else
                {
                    beatRepeat = (int)_syData;
                }
                NewSy();
            }

            BeatEffects(beat);

            for (var i = 0; i < beatRepeat - 1; i++)
            {
                voice.AddBeat(beat.Clone());
            }
        }
 /// <summary>
 /// задать залог из заданного кода
 /// </summary>
 /// <param name="code">код залога</param>
 public void SetVoiceFromCode(char code)
 {
     Voice = (Voice)GetPropertyValue(Voice, code);
 }
Example #33
0
        public short sampleVoice(int v)
        {
            Voice voice = voices[v];

            //Decode samples if its empty / next block
            if (!voice.hasSamples)
            {
                voice.decodeSamples(ram, ramIrqAddress);
                voice.hasSamples = true;

                byte flags     = voices[v].spuAdpcm[1];
                bool loopStart = (flags & 0x4) != 0;

                if (loopStart)
                {
                    voice.adpcmRepeatAddress = voice.currentAddress;
                }
            }

            //Get indexs for gauss interpolation
            uint interpolationIndex = voice.counter.interpolationIndex;
            uint sampleIndex        = voice.counter.currentSampleIndex;

            //Interpolate latest samples
            //this is why the latest 3 samples from the last block are saved because if index is 0
            //any substracion is gonna be oob of the current voice adpcm array
            int interpolated;

            interpolated   = gaussTable[0x0FF - interpolationIndex] * voice.getSample((int)sampleIndex - 3);
            interpolated  += gaussTable[0x1FF - interpolationIndex] * voice.getSample((int)sampleIndex - 2);
            interpolated  += gaussTable[0x100 + interpolationIndex] * voice.getSample((int)sampleIndex - 1);
            interpolated  += gaussTable[0x000 + interpolationIndex] * voice.getSample((int)sampleIndex - 0);
            interpolated >>= 15;

            //Todo adsr
            //interpolated = (interpolated * voice.adsrVolume) >> 15;

            //Pitch modulation: Starts at voice 1 as it needs the last voice
            int step = voice.pitch;

            if (((pitchModulationEnableFlags & (0x1 << v)) != 0) && v > 0)
            {
                int factor = voices[v - 1].latest + 0x8000; //From previous voice
                step  = (step * factor) >> 15;
                step &= 0xFFFF;
            }
            if (step > 0x3FFF)
            {
                step = 0x4000;
            }

            //Console.WriteLine("step u " + ((uint)step).ToString("x8") + "step i" + ((int)step).ToString("x8") + " " + voice.counter.register.ToString("x8"));
            voice.counter.register += (ushort)step;

            if (voice.counter.currentSampleIndex >= 28)
            {
                //Beyond the current adpcm sample block prepare to decode next
                voice.counter.currentSampleIndex -= 28;
                voice.currentAddress             += 2;
                voice.hasSamples = false;

                //LoopEnd and LoopRepeat flags are set after the "current block" set them as it's finished
                byte flags      = voices[v].spuAdpcm[1];
                bool loopEnd    = (flags & 0x1) != 0;
                bool loopRepeat = (flags & 0x2) != 0;

                if (loopEnd)
                {
                    endx |= (uint)(0x1 << v);
                }
                if (loopEnd && !loopRepeat)
                {
                    voice.adsrPhase = Voice.Phase.Off; voice.adsrVolume = 0;
                }
                if (loopEnd && loopRepeat)
                {
                    voice.currentAddress = voice.adpcmRepeatAddress;
                }
            }

            return((short)interpolated);
        }
Example #34
0
        private int CYCLES_PER_SAMPLE = 0x300; //33868800 / 44100hz
        public bool tick(int cycles)
        {
            bool edgeTrigger = false;

            counter += cycles;

            if (counter < CYCLES_PER_SAMPLE)
            {
                return(false);
            }
            counter -= CYCLES_PER_SAMPLE;

            int sumLeft  = 0;
            int sumRight = 0;

            uint edgeKeyOn  = keyOn;
            uint edgeKeyOff = keyOff;

            keyOn  = 0;
            keyOff = 0;

            tickNoiseGenerator();

            for (int i = 0; i < voices.Length; i++)
            {
                Voice v = voices[i];

                //keyOn and KeyOff are edge triggered on 0 to 1
                if ((edgeKeyOff & (0x1 << i)) != 0)
                {
                    v.keyOff();
                }

                if ((edgeKeyOn & (0x1 << i)) != 0)
                {
                    endx &= ~(uint)(0x1 << i);
                    v.keyOn();
                }

                if (v.adsrPhase == Voice.Phase.Off)
                {
                    v.latest = 0;
                    continue;
                }

                short sample;
                if ((channelNoiseMode & (0x1 << i)) != 0)
                {
                    //Generated by tickNoiseGenerator
                    sample = (short)noiseLevel;
                }
                else
                {
                    sample = sampleVoice(i);
                    //Read irqAddress Irq
                    edgeTrigger |= control.irq9Enabled && v.readRamIrq;
                    v.readRamIrq = false;
                }

                //Handle ADSR Envelope
                sample = (short)((sample * v.adsrVolume) >> 15);
                v.tickAdsr(i);

                //Save sample for possible pitch modulation
                v.latest = sample;

                //Sum each voice sample
                sumLeft  += (sample * v.processVolume(v.volumeLeft)) >> 15;
                sumRight += (sample * v.processVolume(v.volumeRight)) >> 15;
            }

            if (!control.spuUnmuted)   //todo merge this on the for voice loop
            //On mute the spu still ticks but output is 0 for voices (not for cdInput)
            {
                sumLeft  = 0;
                sumRight = 0;
            }

            //Merge in CD audio (CDDA or XA)
            short cdL = 0;
            short cdR = 0;

            if (control.cdAudioEnabled && cdbuffer.Count > 3)  //Be sure theres something on the queue...
            //todo refactor the byte/short queues and casts
            {
                byte cdLLo = cdbuffer.Dequeue();
                byte cdLHi = cdbuffer.Dequeue();
                byte cdRLo = cdbuffer.Dequeue();
                byte cdRHi = cdbuffer.Dequeue();

                cdL = (short)(cdLHi << 8 | cdLLo);
                cdR = (short)(cdRHi << 8 | cdRLo);

                //Apply Spu Cd In (CDDA/XA) Volume
                cdL = (short)((cdL * cdVolumeLeft) >> 15);
                cdR = (short)((cdR * cdVolumeRight) >> 15);

                sumLeft  += cdL;
                sumRight += cdR;
            }

            //Write to capture buffers and check ram irq
            edgeTrigger     |= handleCaptureBuffer(0 * 1024 + captureBufferPos, cdL);
            edgeTrigger     |= handleCaptureBuffer(1 * 1024 + captureBufferPos, cdR);
            edgeTrigger     |= handleCaptureBuffer(2 * 1024 + captureBufferPos, voices[1].latest);
            edgeTrigger     |= handleCaptureBuffer(3 * 1024 + captureBufferPos, voices[3].latest);
            captureBufferPos = (captureBufferPos + 2) & 0x3FF;

            //Clamp sum
            sumLeft  = (Math.Clamp(sumLeft, -0x8000, 0x7FFF) * mainVolumeLeft) >> 15;
            sumRight = (Math.Clamp(sumRight, -0x8000, 0x7FFF) * mainVolumeRight) >> 15;

            //Add to samples bytes to output list //Todo check if is possible to cast directly with Unsafe or memmarshal
            spuOutput.Add((byte)sumLeft);
            spuOutput.Add((byte)(sumLeft >> 8));
            spuOutput.Add((byte)sumRight);
            spuOutput.Add((byte)(sumRight >> 8));

            if (spuOutput.Count > 2048)
            {
                window.Play(spuOutput.ToArray());
                spuOutput.Clear();
            }

            if (control.spuEnabled && control.irq9Enabled && edgeTrigger)
            {
                status.irq9Flag = true;
            }
            return(control.spuEnabled && control.irq9Enabled && edgeTrigger); //todo move spuEnabled outside
        }
        /// <summary>
        /// 根据XML信息填充实实体
        /// </summary>
        /// <typeparam name="T">MessageBase为基类的类型,Response和Request都可以</typeparam>
        /// <param name="entity">实体</param>
        /// <param name="doc">XML</param>
        public static void FillEntityWithXml <T>(this T entity, XDocument doc) where T : /*MessageBase*/ class, new()
        {
            entity = entity ?? new T();
            var root = doc.Root;

            if (root == null)
            {
                return;//无法处理
            }

            var props = entity.GetType().GetProperties();

            foreach (var prop in props)
            {
                var propName = prop.Name;
                if (root.Element(propName) != null)
                {
                    switch (prop.PropertyType.Name)
                    {
                    //case "String":
                    //    goto default;
                    case "DateTime":
                    case "Int32":
                    case "Int64":
                    case "Double":
                    case "Nullable`1":     //可为空对象
                        EntityUtility.EntityUtility.FillSystemType(entity, prop, root.Element(propName).Value);
                        break;

                    case "Boolean":
                        if (propName == "FuncFlag")
                        {
                            EntityUtility.EntityUtility.FillSystemType(entity, prop, root.Element(propName).Value == "1");
                        }
                        else
                        {
                            goto default;
                        }
                        break;

                    //以下为枚举类型
                    case "RequestMsgType":
                        //已设为只读
                        //prop.SetValue(entity, MsgTypeHelper.GetRequestMsgType(root.Element(propName).Value), null);
                        break;

                    case "ResponseMsgType":     //Response适用
                        //已设为只读
                        //prop.SetValue(entity, MsgTypeHelper.GetResponseMsgType(root.Element(propName).Value), null);
                        break;

                    case "Event":
                        //已设为只读
                        //prop.SetValue(entity, EventHelper.GetEventType(root.Element(propName).Value), null);
                        break;

                    //以下为实体类型
                    case "List`1":     //List<T>类型,ResponseMessageNews适用
                    {
                        var genericArguments = prop.PropertyType.GetGenericArguments();
                        if (genericArguments[0].Name == "Article")        //ResponseMessageNews适用
                        {
                            //文章下属节点item
                            List <Article> articles = new List <Article>();
                            foreach (var item in root.Element(propName).Elements("item"))
                            {
                                var article = new Article();
                                FillEntityWithXml(article, new XDocument(item));
                                articles.Add(article);
                            }
                            prop.SetValue(entity, articles, null);
                        }
                        else if (genericArguments[0].Name == "Account")
                        {
                            List <CustomerServiceAccount> accounts = new List <CustomerServiceAccount>();
                            foreach (var item in root.Elements(propName))
                            {
                                var account = new CustomerServiceAccount();
                                FillEntityWithXml(account, new XDocument(item));
                                accounts.Add(account);
                            }
                            prop.SetValue(entity, accounts, null);
                        }
                        else if (genericArguments[0].Name == "PicItem")
                        {
                            List <PicItem> picItems = new List <PicItem>();
                            foreach (var item in root.Elements(propName).Elements("item"))
                            {
                                var    picItem   = new PicItem();
                                var    picMd5Sum = item.Element("PicMd5Sum").Value;
                                Md5Sum md5Sum    = new Md5Sum()
                                {
                                    PicMd5Sum = picMd5Sum
                                };
                                picItem.item = md5Sum;
                                picItems.Add(picItem);
                            }
                            prop.SetValue(entity, picItems, null);
                        }
                        else if (genericArguments[0].Name == "AroundBeacon")
                        {
                            List <AroundBeacon> aroundBeacons = new List <AroundBeacon>();
                            foreach (var item in root.Elements(propName).Elements("AroundBeacon"))
                            {
                                var aroundBeaconItem = new AroundBeacon();
                                FillEntityWithXml(aroundBeaconItem, new XDocument(item));
                                aroundBeacons.Add(aroundBeaconItem);
                            }
                            prop.SetValue(entity, aroundBeacons, null);
                        }
                        break;
                    }

                    case "Music":    //ResponseMessageMusic适用
                        Music music = new Music();
                        FillEntityWithXml(music, new XDocument(root.Element(propName)));
                        prop.SetValue(entity, music, null);
                        break;

                    case "Image":    //ResponseMessageImage适用
                        Image image = new Image();
                        FillEntityWithXml(image, new XDocument(root.Element(propName)));
                        prop.SetValue(entity, image, null);
                        break;

                    case "Voice":    //ResponseMessageVoice适用
                        Voice voice = new Voice();
                        FillEntityWithXml(voice, new XDocument(root.Element(propName)));
                        prop.SetValue(entity, voice, null);
                        break;

                    case "Video":    //ResponseMessageVideo适用
                        Video video = new Video();
                        FillEntityWithXml(video, new XDocument(root.Element(propName)));
                        prop.SetValue(entity, video, null);
                        break;

                    case "ScanCodeInfo":    //扫码事件中的ScanCodeInfo适用
                        ScanCodeInfo scanCodeInfo = new ScanCodeInfo();
                        FillEntityWithXml(scanCodeInfo, new XDocument(root.Element(propName)));
                        prop.SetValue(entity, scanCodeInfo, null);
                        break;

                    case "SendLocationInfo":    //弹出地理位置选择器的事件推送中的SendLocationInfo适用
                        SendLocationInfo sendLocationInfo = new SendLocationInfo();
                        FillEntityWithXml(sendLocationInfo, new XDocument(root.Element(propName)));
                        prop.SetValue(entity, sendLocationInfo, null);
                        break;

                    case "SendPicsInfo":    //系统拍照发图中的SendPicsInfo适用
                        SendPicsInfo sendPicsInfo = new SendPicsInfo();
                        FillEntityWithXml(sendPicsInfo, new XDocument(root.Element(propName)));
                        prop.SetValue(entity, sendPicsInfo, null);
                        break;

                    case "ChosenBeacon":    //摇一摇事件通知
                        ChosenBeacon chosenBeacon = new ChosenBeacon();
                        FillEntityWithXml(chosenBeacon, new XDocument(root.Element(propName)));
                        prop.SetValue(entity, chosenBeacon, null);
                        break;

                    case "AroundBeacon":    //摇一摇事件通知
                        AroundBeacon aroundBeacon = new AroundBeacon();
                        FillEntityWithXml(aroundBeacon, new XDocument(root.Element(propName)));
                        prop.SetValue(entity, aroundBeacon, null);
                        break;

                    default:
                        prop.SetValue(entity, root.Element(propName).Value, null);
                        break;
                    }
                }
            }
        }
 public Pronunciation GetPronunciation(string text, Voice voice = null, Phoneme phoneme = null)
 {
     return(getPronunciation(text, voice, phoneme));
 }
Example #37
0
        public void ReadBeat(Track track, Bar bar, Voice voice)
        {
            var newBeat = new Beat();
            var flags   = _data.ReadByte();

            if ((flags & 0x01) != 0)
            {
                newBeat.Dots = 1;
            }

            if ((flags & 0x40) != 0)
            {
                var type = _data.ReadByte();
                newBeat.IsEmpty = (type & 0x02) == 0;
            }
            voice.AddBeat(newBeat);

            var duration = _data.ReadSignedByte();

            switch (duration)
            {
            case -2:
                newBeat.Duration = Duration.Whole;
                break;

            case -1:
                newBeat.Duration = Duration.Half;
                break;

            case 0:
                newBeat.Duration = Duration.Quarter;
                break;

            case 1:
                newBeat.Duration = Duration.Eighth;
                break;

            case 2:
                newBeat.Duration = Duration.Sixteenth;
                break;

            case 3:
                newBeat.Duration = Duration.ThirtySecond;
                break;

            case 4:
                newBeat.Duration = Duration.SixtyFourth;
                break;

            default:
                newBeat.Duration = Duration.Quarter;
                break;
            }

            if ((flags & 0x20) != 0)
            {
                newBeat.TupletNumerator = ReadInt32();
                switch (newBeat.TupletNumerator)
                {
                case 1:
                    newBeat.TupletDenominator = 1;
                    break;

                case 3:
                    newBeat.TupletDenominator = 2;
                    break;

                case 5:
                case 6:
                case 7:
                    newBeat.TupletDenominator = 4;
                    break;

                case 9:
                case 10:
                case 11:
                case 12:
                case 13:
                    newBeat.TupletDenominator = 8;
                    break;

                case 2:
                case 4:
                case 8:
                    break;

                default:
                    newBeat.TupletNumerator   = 1;
                    newBeat.TupletDenominator = 1;
                    break;
                }
            }

            if ((flags & 0x02) != 0)
            {
                ReadChord(newBeat);
            }

            if ((flags & 0x04) != 0)
            {
                newBeat.Text = ReadStringIntUnused();
            }

            if ((flags & 0x08) != 0)
            {
                ReadBeatEffects(newBeat);
            }

            if ((flags & 0x10) != 0)
            {
                ReadMixTableChange(newBeat);
            }

            var stringFlags = _data.ReadByte();

            for (int i = 6; i >= 0; i--)
            {
                if ((stringFlags & (1 << i)) != 0 && (6 - i) < track.Tuning.Length)
                {
                    ReadNote(track, bar, voice, newBeat, (6 - i));
                }
            }

            if (_versionNumber >= 500)
            {
                _data.ReadByte();
                var flag = _data.ReadByte();
                if ((flag & 0x08) != 0)
                {
                    _data.ReadByte();
                }
            }
        }
 private void OnGetVoice(Voice voice, Dictionary <string, object> customData)
 {
     Log.Debug("TestTextToSpeech.OnGetVoice()", "{0}", customData["json"].ToString());
     Test(voice != null);
     _getVoiceTested = true;
 }
Example #39
0
        public void ReadNoteEffects(Track track, Voice voice, Beat beat, Note note)
        {
            var flags  = _data.ReadByte();
            var flags2 = 0;

            if (_versionNumber >= 400)
            {
                flags2 = _data.ReadByte();
            }

            if ((flags & 0x01) != 0)
            {
                ReadBend(note);
            }

            if ((flags & 0x10) != 0)
            {
                ReadGrace(voice, note);
            }

            if ((flags2 & 0x04) != 0)
            {
                ReadTremoloPicking(beat);
            }

            if ((flags2 & 0x08) != 0)
            {
                ReadSlide(note);
            }
            else if (_versionNumber < 400)
            {
                if ((flags & 0x04) != 0)
                {
                    note.SlideType = SlideType.Shift;
                }
            }

            if ((flags2 & 0x10) != 0)
            {
                ReadArtificialHarmonic(note);
            }
            else if (_versionNumber < 400)
            {
                if ((flags & 0x04) != 0)
                {
                    note.HarmonicType  = HarmonicType.Natural;
                    note.HarmonicValue = DeltaFretToHarmonicValue(note.Fret);
                }
                if ((flags & 0x08) != 0)
                {
                    note.HarmonicType = HarmonicType.Artificial;
                }
            }

            if ((flags2 & 0x20) != 0)
            {
                ReadTrill(note);
            }

            note.IsLetRing          = (flags & 0x08) != 0;
            note.IsHammerPullOrigin = (flags & 0x02) != 0;
            if ((flags2 & 0x40) != 0)
            {
                note.Vibrato = VibratoType.Slight;
            }
            note.IsPalmMute = (flags2 & 0x02) != 0;
            note.IsStaccato = (flags2 & 0x01) != 0;
        }
Example #40
0
 /// <summary>
 /// Initializes a new instance of the <see cref="VoiceSendDescriptor"/> struct.
 /// </summary>
 /// <param name="outputVoice">The output voice.</param>
 public VoiceSendDescriptor(Voice outputVoice) : this(VoiceSendFlags.None, outputVoice)
 {
 }
Example #41
0
 public WRespVoice()
 {
     Voice = new Voice();
 }
Example #42
0
        public IEnumerator DialogSequence()
        {
            if (!Running)
            {
                Running = true;

                playingA = false;
                playingB = false;

                Voice personA = Speaker.VoiceForCulture(CultureA);
                Voice personB = Speaker.VoiceForCulture(CultureB, 1);

                int index = 0;

                while (Running && (DialogPersonA != null && index < DialogPersonA.Length) || (DialogPersonB != null && index < DialogPersonB.Length))
                {
                    //Person A
                    if (DialogPersonA != null && index < DialogPersonA.Length)
                    {
                        CurrentDialogA = DialogPersonA[index];
                    }

                    uidSpeakerA = Speaker.Speak(CurrentDialogA, AudioPersonA, personA, true, RateA, PitchA, VolumeA);

                    //wait until ready
                    do
                    {
                        yield return(null);
                    } while (!playingA && Running);

                    //wait until played
                    do
                    {
                        yield return(null);
                    } while (playingA && Running);

                    CurrentDialogA = string.Empty;

                    if (Running)
                    { //ensure it's still running
                        // Person B
                        if (DialogPersonB != null && index < DialogPersonB.Length)
                        {
                            CurrentDialogB = DialogPersonB[index];
                        }

                        uidSpeakerB = Speaker.Speak(CurrentDialogB, AudioPersonB, personB, true, RateB, PitchB, VolumeB);

                        //wait until ready
                        do
                        {
                            yield return(null);
                        } while (!playingB && Running);

                        //wait until played
                        do
                        {
                            yield return(null);
                        } while (playingB && Running);

                        CurrentDialogB = string.Empty;
                    }
                    index++;
                }

                Running = false;
            }
        }
Example #43
0
        /// <summary>
        /// 根据XML信息填充实实体
        /// </summary>
        /// <typeparam name="T">MessageBase为基类的类型,Response和Request都可以</typeparam>
        /// <param name="entity">实体</param>
        /// <param name="doc">XML</param>
        public static void FillEntityWithXml <T>(this T entity, XDocument doc) where T : /*MessageBase*/ class, new()
        {
            entity = entity ?? new T();
            var root = doc.Root;

            var props = entity.GetType().GetProperties();

            foreach (var prop in props)
            {
                var propName = prop.Name;
                if (root.Element(propName) != null)
                {
                    switch (prop.PropertyType.Name)
                    {
                    //case "String":
                    //    goto default;
                    case "DateTime":
                        prop.SetValue(entity, DateTimeHelper.GetDateTimeFromXml(root.Element(propName).Value), null);
                        break;

                    case "Boolean":
                        if (propName == "FuncFlag")
                        {
                            prop.SetValue(entity, root.Element(propName).Value == "1", null);
                        }
                        else
                        {
                            goto default;
                        }
                        break;

                    case "Int32":
                        prop.SetValue(entity, int.Parse(root.Element(propName).Value), null);
                        break;

                    case "Int64":
                        prop.SetValue(entity, long.Parse(root.Element(propName).Value), null);
                        break;

                    case "Double":
                        prop.SetValue(entity, double.Parse(root.Element(propName).Value), null);
                        break;

                    //以下为枚举类型
                    case "RequestMsgType":
                        //已设为只读
                        //prop.SetValue(entity, MsgTypeHelper.GetRequestMsgType(root.Element(propName).Value), null);
                        break;

                    case "ResponseMsgType":    //Response适用
                        //已设为只读
                        //prop.SetValue(entity, MsgTypeHelper.GetResponseMsgType(root.Element(propName).Value), null);
                        break;

                    case "Event":
                        //已设为只读
                        //prop.SetValue(entity, EventHelper.GetEventType(root.Element(propName).Value), null);
                        break;

                    //以下为实体类型
                    case "List`1":                                 //List<T>类型,ResponseMessageNews适用
                        var genericArguments = prop.PropertyType.GetGenericArguments();
                        if (genericArguments[0].Name == "Article") //ResponseMessageNews适用
                        {
                            //文章下属节点item
                            var articles = new List <Article>();
                            foreach (var item in root.Element(propName).Elements("item"))
                            {
                                var article = new Article();
                                FillEntityWithXml(article, new XDocument(item));
                                articles.Add(article);
                            }
                            prop.SetValue(entity, articles, null);
                        }
                        break;

                    case "Music":    //ResponseMessageMusic适用
                        var music = new Music();
                        FillEntityWithXml(music, new XDocument(root.Element(propName)));
                        prop.SetValue(entity, music, null);
                        break;

                    case "Image":    //ResponseMessageImage适用
                        var image = new Image();
                        FillEntityWithXml(image, new XDocument(root.Element(propName)));
                        prop.SetValue(entity, image, null);
                        break;

                    case "Voice":    //ResponseMessageVoice适用
                        var voice = new Voice();
                        FillEntityWithXml(voice, new XDocument(root.Element(propName)));
                        prop.SetValue(entity, voice, null);
                        break;

                    case "Video":    //ResponseMessageVideo适用
                        var video = new Video();
                        FillEntityWithXml(video, new XDocument(root.Element(propName)));
                        prop.SetValue(entity, video, null);
                        break;

                    default:
                        prop.SetValue(entity, root.Element(propName).Value, null);
                        break;
                    }
                }
            }
        }
Example #44
0
        private int interpolate(Voice v)
        {
            // Make pointers into gaussian based on fractional position between samples
            int offset = v.interp_pos >> 4 & 0xFF;
            ArraySegment<short> fwd = new ArraySegment<short>(gauss, 255 - offset, gauss.Length - (255 - offset));
            ArraySegment<short> rev = new ArraySegment<short>(gauss, offset, gauss.Length - offset); // mirror left half of gaussian

            ArraySegment<int> _in = new ArraySegment<int>(v.buf, (v.interp_pos >> 12) + v.buf_pos, v.buf.Length - ((v.interp_pos >> 12) + v.buf_pos));
            int _out;
            _out = (fwd.Array[fwd.Offset + 0] * _in.Array[_in.Offset + 0]) >> 11;
            _out += (fwd.Array[fwd.Offset + 256] * _in.Array[_in.Offset + 1]) >> 11;
            _out += (rev.Array[rev.Offset + 256] * _in.Array[_in.Offset + 2]) >> 11;
            _out = (short)_out;
            _out += (rev.Array[rev.Offset + 0] * _in.Array[_in.Offset + 3]) >> 11;

            Clamp16(ref _out);
            _out &= ~1;
            return _out;
        }
 public ResponseMessageVoice()
 {
     Voice = new Voice();
 }
Example #46
0
        private void voice_output(Voice v, int ch)
        {
            // Apply left/right volume
            int amp = (m.t_output * (sbyte)v.regs.Array[v.regs.Offset + (int)VoiceReg.voll + ch]) >> 7;

            // Add to output total
            m.t_main_out[ch] += amp;
            Clamp16(ref m.t_main_out[ch]);

            // Optionally add to echo total
            if (Convert.ToBoolean(m.t_eon & v.vbit))
            {
                m.t_echo_out[ch] += amp;
                Clamp16(ref m.t_echo_out[ch]);
            }
        }
Example #47
0
    public void startTeamspeak( string userName )
    {
        if( __voice == null )
        {
            __voice = new Voice( Config.Instance.teamSpeakServerIp, Config.Instance.teamSpeakServerPort, Config.Instance.soundMachineName, userName );
        }

        Logger.Log( "Starte Teamspeak mit Benutzernamen " + userName );
        __voice.start();
    }
Example #48
0
			public int Output(Voice ringModSource)
			{

				{
					if (_waveform != 0)
					{
						_waveformIndex = (_accumulator ^ (ringModSource._accumulator & _ringMsbMask)) >> 12;
						_output = _wave[_waveformIndex] & (_noPulse | _pulse) & _noNoiseOrNoise;
						if (_waveform > 8)
							WriteShiftReg();
					}
					else
					{
						if (_floatOutputTtl != 0 && --_floatOutputTtl == 0)
							_output = 0x000;
					}
					_pulse = _accumulator >> 12 >= _pulseWidth ? 0xFFF : 0x000;
					return _output;
				}
			}
Example #49
0
        /// <summary>
        /// 根据XML信息填充实实体
        /// </summary>
        /// <typeparam name="T">MessageBase为基类的类型,Response和Request都可以</typeparam>
        /// <param name="entity">实体</param>
        /// <param name="doc">XML</param>
        public static void FillEntityWithXml <T>(this T entity, XDocument doc) where T : /*MessageBase*/ class, new()
        {
            entity = entity ?? new T();
            var root = doc.Root;

            var props = entity.GetType().GetProperties();

            foreach (var prop in props)
            {
                var propName = prop.Name;
                if (root.Element(propName) != null)
                {
                    switch (prop.PropertyType.Name)
                    {
                    //case "String":
                    //    goto default;
                    case "DateTime":
                    case "DateTimeOffset":
                    case "Int32":
                    case "Int32[]":     //增加int[]
                    case "Int64":
                    case "Int64[]":     //增加long[]
                    case "Double":
                    case "Nullable`1":  //可为空对象
                        EntityUtility.FillSystemType(entity, prop, root.Element(propName).Value);
                        break;

                    case "Boolean":
                        if (propName == "FuncFlag")
                        {
                            EntityUtility.FillSystemType(entity, prop, root.Element(propName).Value == "1");
                        }
                        else
                        {
                            goto default;
                        }
                        break;

                    //以下为枚举类型
                    case "ContactChangeType":
                        //已设为只读
                        //prop.SetValue(entity, MsgTypeHelper.GetRequestMsgType(root.Element(propName).Value), null);
                        break;

                    case "RequestMsgType":
                        //已设为只读
                        //prop.SetValue(entity, MsgTypeHelper.GetRequestMsgType(root.Element(propName).Value), null);
                        break;

                    case "ResponseMsgType":     //Response适用
                                                //已设为只读
                                                //prop.SetValue(entity, MsgTypeHelper.GetResponseMsgType(root.Element(propName).Value), null);
                        break;

                    case "ThirdPartyInfo":     //ThirdPartyInfo适用
                                               //已设为只读
                                               //prop.SetValue(entity, MsgTypeHelper.GetResponseMsgType(root.Element(propName).Value), null);
                        break;

                    case "Event":
                        //已设为只读
                        //prop.SetValue(entity, EventHelper.GetEventType(root.Element(propName).Value), null);
                        break;

                    //以下为实体类型
                    case "List`1":                                 //List<T>类型,ResponseMessageNews适用
                        var genericArguments = prop.PropertyType.GetGenericArguments();
                        if (genericArguments[0].Name == "Article") //ResponseMessageNews适用
                        {
                            //文章下属节点item
                            List <Article> articles = new List <Article>();
                            foreach (var item in root.Element(propName).Elements("item"))
                            {
                                var article = new Article();
                                FillEntityWithXml(article, new XDocument(item));
                                articles.Add(article);
                            }
                            prop.SetValue(entity, articles, null);
                        }
                        else if (genericArguments[0].Name == "MpNewsArticle")
                        {
                            List <MpNewsArticle> mpNewsArticles = new List <MpNewsArticle>();
                            foreach (var item in root.Elements(propName))
                            {
                                var mpNewsArticle = new MpNewsArticle();
                                FillEntityWithXml(mpNewsArticle, new XDocument(item));
                                mpNewsArticles.Add(mpNewsArticle);
                            }
                            prop.SetValue(entity, mpNewsArticles, null);
                        }
                        else if (genericArguments[0].Name == "PicItem")
                        {
                            List <PicItem> picItems = new List <PicItem>();
                            foreach (var item in root.Elements(propName).Elements("item"))
                            {
                                var    picItem   = new PicItem();
                                var    picMd5Sum = item.Element("PicMd5Sum").Value;
                                Md5Sum md5Sum    = new Md5Sum()
                                {
                                    PicMd5Sum = picMd5Sum
                                };
                                picItem.item = md5Sum;
                                picItems.Add(picItem);
                            }
                            prop.SetValue(entity, picItems, null);
                        }
                        break;

                    case "Image":     //ResponseMessageImage适用
                        Image image = new Image();
                        FillEntityWithXml(image, new XDocument(root.Element(propName)));
                        prop.SetValue(entity, image, null);
                        break;

                    case "Voice":     //ResponseMessageVoice适用
                        Voice voice = new Voice();
                        FillEntityWithXml(voice, new XDocument(root.Element(propName)));
                        prop.SetValue(entity, voice, null);
                        break;

                    case "Video":     //ResponseMessageVideo适用
                        Video video = new Video();
                        FillEntityWithXml(video, new XDocument(root.Element(propName)));
                        prop.SetValue(entity, video, null);
                        break;

                    case "ScanCodeInfo":     //扫码事件中的ScanCodeInfo适用
                        ScanCodeInfo scanCodeInfo = new ScanCodeInfo();
                        FillEntityWithXml(scanCodeInfo, new XDocument(root.Element(propName)));
                        prop.SetValue(entity, scanCodeInfo, null);
                        break;

                    case "SendLocationInfo":     //弹出地理位置选择器的事件推送中的SendLocationInfo适用
                        SendLocationInfo sendLocationInfo = new SendLocationInfo();
                        FillEntityWithXml(sendLocationInfo, new XDocument(root.Element(propName)));
                        prop.SetValue(entity, sendLocationInfo, null);
                        break;

                    case "SendPicsInfo":     //系统拍照发图中的SendPicsInfo适用
                        SendPicsInfo sendPicsInfo = new SendPicsInfo();
                        FillEntityWithXml(sendPicsInfo, new XDocument(root.Element(propName)));
                        prop.SetValue(entity, sendPicsInfo, null);
                        break;

                    case "BatchJobInfo":     //异步任务完成事件推送BatchJob
                        BatchJobInfo batchJobInfo = new BatchJobInfo();
                        FillEntityWithXml(batchJobInfo, new XDocument(root.Element(propName)));
                        prop.SetValue(entity, batchJobInfo, null);
                        break;

                    case "AgentType":
                    {
                        AgentType tp;
#if NET35
                        try
                        {
                            tp = (AgentType)Enum.Parse(typeof(AgentType), root.Element(propName).Value, true);
                            prop.SetValue(entity, tp, null);
                        }
                        catch
                        {
                        }
#else
                        if (Enum.TryParse(root.Element(propName).Value, out tp))
                        {
                            prop.SetValue(entity, tp, null);
                        }
#endif
                        break;
                    }

                    case "Receiver":
                    {
                        Receiver receiver = new Receiver();
                        FillEntityWithXml(receiver, new XDocument(root.Element(propName)));
                        prop.SetValue(entity, receiver, null);
                        break;
                    }

                    default:
                        prop.SetValue(entity, root.Element(propName).Value, null);
                        break;
                    }
                }
                else if (prop.PropertyType.Name == "List`1")//客服回调特殊处理
                {
                    var genericArguments = prop.PropertyType.GetGenericArguments();
                    if (genericArguments[0].Name == "RequestBase")
                    {
                        List <RequestBase> items = new List <RequestBase>();
                        foreach (var item in root.Elements("Item"))
                        {
                            RequestBase reqItem    = null;
                            var         msgTypeEle = item.Element("MsgType");
                            if (msgTypeEle != null)
                            {
                                RequestMsgType type         = RequestMsgType.Unknown;
                                var            parseSuccess = false;
#if NET35
                                try
                                {
                                    type         = (RequestMsgType)Enum.Parse(typeof(RequestMsgType), msgTypeEle.Value, true);
                                    parseSuccess = true;
                                }
                                catch
                                {
                                }
#else
                                parseSuccess = Enum.TryParse(msgTypeEle.Value, true, out type);
#endif
                                if (parseSuccess)
                                {
                                    switch (type)
                                    {
                                    case RequestMsgType.Event:
                                    {
                                        reqItem = new RequestEvent();
                                        break;
                                    }

                                    case RequestMsgType.File:
                                    {
                                        reqItem = new Entities.Request.KF.RequestMessageFile();
                                        break;
                                    }

                                    case RequestMsgType.Image:
                                    {
                                        reqItem = new Entities.Request.KF.RequestMessageImage();
                                        break;
                                    }

                                    case RequestMsgType.Link:
                                    {
                                        reqItem = new Entities.Request.KF.RequestMessageLink();
                                        break;
                                    }

                                    case RequestMsgType.Location:
                                    {
                                        reqItem = new Entities.Request.KF.RequestMessageLocation();
                                        break;
                                    }

                                    case RequestMsgType.Text:
                                    {
                                        reqItem = new Entities.Request.KF.RequestMessageText();

                                        break;
                                    }

                                    case RequestMsgType.Voice:
                                    {
                                        reqItem = new Entities.Request.KF.RequestMessageVoice();
                                        break;
                                    }
                                    }
                                }
                            }
                            if (reqItem != null)
                            {
                                FillEntityWithXml(reqItem, new XDocument(item));
                                items.Add(reqItem);
                            }
                        }
                        prop.SetValue(entity, items, null);
                    }
                }
            }
        }
Example #50
0
        void ExportBars(Track track)
        {
            int lastTempo = -1;
            prevChordId = -1;
            for (int i = 0; i < track.Bars.Count; ++i)
            {
                var bar = track.Bars[i];
                if (gpif.MasterBars.Count <= i)
                {
                    // this only has to be done for the first track, all other tracks
                    // are assumed to have the same bar layout (which makes sense, if
                    // they are supposed to fit together :) ).
                    var masterBar = new MasterBar();
                    masterBar.Time = string.Format("{0}/{1}", bar.TimeNominator, bar.TimeDenominator);
                    gpif.MasterBars.Add(masterBar);
                    if (bar.BeatsPerMinute != lastTempo)
                    {
                        // set tempo for this bar
                        var tempo = new Automation();
                        tempo.Bar = i;
                        tempo.Position = 0;
                        tempo.Linear = false;
                        tempo.Value[0] = bar.BeatsPerMinute;
                        tempo.Value[1] = 2; // no idea what this represents
                        gpif.MasterTrack.Automations.Add(tempo);
                        lastTempo = bar.BeatsPerMinute;
                    }
                }

                // construct a voice for this bar
                var voice = new Voice();
                voice.Id = gpif.Voices.Count;
                foreach (var chord in bar.Chords)
                {
                    int id = ExportOrFindBeat(chord);
                    voice.Beats.Add(id);
                }

                // see if this voice is already available, otherwise add
                var searchVoice = gpif.Voices.Find(x => x.Equals(voice));
                if (searchVoice != null)
                    voice = searchVoice;
                else
                    gpif.Voices.Add(voice);

                // construct the bar
                var gpBar = new Gpif.Bar();
                gpBar.Id = gpif.Bars.Count;
                if (track.Instrument == Track.InstrumentType.Bass)
                    gpBar.Clef = "F4";
                else
                    gpBar.Clef = "G2";
                gpBar.Voices[0] = voice.Id;
                // see if this bar is already available, otherwise add
                var searchBar = gpif.Bars.Find(x => x.Equals(gpBar));
                if (searchBar != null)
                    gpBar = searchBar;
                else
                    gpif.Bars.Add(gpBar);

                // add to master bar
                gpif.MasterBars[i].Bars.Add(gpBar.Id);
            }
        }
Example #51
0
        public void ReadNote(Track track, Bar bar, Voice voice, Beat beat, int stringIndex)
        {
            var newNote = new Note();

            newNote.String = track.Tuning.Length - stringIndex;

            var flags = Data.ReadByte();

            if ((flags & 0x02) != 0)
            {
                newNote.Accentuated = AccentuationType.Heavy;
            }
            else if ((flags & 0x40) != 0)
            {
                newNote.Accentuated = AccentuationType.Normal;
            }

            newNote.IsGhost = ((flags & 0x04) != 0);
            if ((flags & 0x20) != 0)
            {
                var noteType = Data.ReadByte();
                if (noteType == 3)
                {
                    newNote.IsDead = true;
                }
                else if (noteType == 2)
                {
                    newNote.IsTieDestination = true;
                }
            }

            if ((flags & 0x01) != 0 && _versionNumber < 500)
            {
                Data.ReadByte(); // duration
                Data.ReadByte(); // tuplet
            }

            if ((flags & 0x10) != 0)
            {
                var dynamicNumber = Data.ReadSignedByte();
                newNote.Dynamic = ToDynamicValue(dynamicNumber);
                beat.Dynamic    = newNote.Dynamic;
            }

            if ((flags & 0x20) != 0)
            {
                newNote.Fret = Data.ReadSignedByte();
            }

            if ((flags & 0x80) != 0)
            {
                newNote.LeftHandFinger  = (Fingers)Data.ReadSignedByte();
                newNote.RightHandFinger = (Fingers)Data.ReadSignedByte();
                newNote.IsFingering     = true;
            }

            if (_versionNumber >= 500)
            {
                if ((flags & 0x01) != 0)
                {
                    newNote.DurationPercent = ReadDouble();
                }
                var flags2 = Data.ReadByte();
                newNote.AccidentalMode = (flags2 & 0x02) != 0
                    ? NoteAccidentalMode.SwapAccidentals
                    : NoteAccidentalMode.Default;
            }

            beat.AddNote(newNote);
            if ((flags & 0x08) != 0)
            {
                ReadNoteEffects(track, voice, beat, newNote);
            }
        }
Example #52
0
			public void Synchronize(Voice target, Voice source)
			{
				if (_msbRising && target._sync && !(_sync && source._msbRising))
					target._accumulator = 0;
			}
 public MainWindow()
 {
     InitializeComponent();
     voice      = new Voice(new EventHandler <SpeechRecognizedEventArgs>(Recognizer_SpeechRecognized));
     textManger = new TextBoxManager(txtDisplay);
 }