private void List_expressions_SelectedIndexChanged(object sender, EventArgs e)
 {
     if (list_expressions.SelectedIndex != -1)
     {
         Amani.SetExpression(expressions[list_expressions.SelectedIndex]);
     }
 }
        private void OnDataAvailable(object sender, NAudio.Wave.WaveInEventArgs args)
        {
            float avg = 0;
            float sum = 0;

            NAudio.Wave.WaveBuffer buff = new NAudio.Wave.WaveBuffer(args.Buffer);
            // interpret as 32 bit floating point audio
            for (int index = 0; index < args.BytesRecorded / 4; index++)
            {
                short sample = buff.ShortBuffer[index];

                // absolute value
                if (sample < 0)
                {
                    sample = (short)-sample;
                }
                // is this the max value?
                sum += sample;
            }

            avg = sum / (args.BytesRecorded / 4);

            Amani.Update(avg, slider_sensitivity.Value);
        }
Exemplo n.º 3
0
 private void Form2_Load(object sender, EventArgs e)
 {
     Amani.Init(imgBox_amaniPreview);
 }
 private void Radiobtn_gamepad_CheckedChanged(object sender, EventArgs e)
 {
     Amani.SetPose(Amani.POSE_GAMEPAD);
 }
 private void Radiobtn_laptop_CheckedChanged(object sender, EventArgs e)
 {
     Amani.SetPose(Amani.POSE_LAPTOP);
 }
        private void Form1_Load(object sender, EventArgs e)
        {
            new Form2().Show();

            //Load expressions
            expressions.Add(CreateNewExpression("Focused",
                                                new Bitmap("Assets\\expression_default_open.png"),
                                                new Bitmap("Assets\\expression_default.png"),
                                                Key.NumPad7));
            expressions.Add(CreateNewExpression("Amazed",
                                                new Bitmap("Assets\\Amani_amazed_open.png"),
                                                new Bitmap("Assets\\Amani_amazed.png"),
                                                Key.Divide));
            expressions.Add(CreateNewExpression("Smug",
                                                new Bitmap("Assets\\Amani_smug_open.png"),
                                                new Bitmap("Assets\\Amani_smug.png"),
                                                Key.Multiply));
            expressions.Add(CreateNewExpression("Suprised",
                                                new Bitmap("Assets\\Amani_suprised_open.png"),
                                                new Bitmap("Assets\\Amani_suprised.png"),
                                                Key.Subtract));
            expressions.Add(CreateNewExpression("You Know",
                                                new Bitmap("Assets\\Amani_youknow_open.png"),
                                                new Bitmap("Assets\\Amani_youknow.png"),
                                                Key.NumPad8));
            expressions.Add(CreateNewExpression("Disappointed",
                                                new Bitmap("Assets\\Amani_disappointed_open.png"),
                                                new Bitmap("Assets\\Amani_disappointed.png"),
                                                Key.NumPad9));
            expressions.Add(CreateNewExpression("Angry",
                                                new Bitmap("Assets\\Amani_angry_open.png"),
                                                new Bitmap("Assets\\Amani_angry.png"),
                                                Key.NumPad4));
            expressions.Add(CreateNewExpression("Big Smile",
                                                new Bitmap("Assets\\Amani_bigsmile_open.png"),
                                                new Bitmap("Assets\\Amani_bigsmile.png"),
                                                Key.NumPad5));
            expressions.Add(CreateNewExpression("Excited",
                                                new Bitmap("Assets\\Amani_excited_open.png"),
                                                new Bitmap("Assets\\Amani_excited.png"),
                                                Key.NumPad6));
            expressions.Add(CreateNewExpression("Laughing",
                                                new Bitmap("Assets\\Amani_laugh_open.png"),
                                                new Bitmap("Assets\\Amani_laugh.png"),
                                                Key.NumPad1));
            expressions.Add(CreateNewExpression("Crying",
                                                new Bitmap("Assets\\Amani_cry_open.png"),
                                                new Bitmap("Assets\\Amani_cry.png"),
                                                Key.NumPad2));
            expressions.Add(CreateNewExpression("Oh",
                                                new Bitmap("Assets\\Amani_ohshit_open.png"),
                                                new Bitmap("Assets\\Amani_ohshit.png"),
                                                Key.NumPad3));
            expressions.Add(CreateNewExpression("In Love",
                                                new Bitmap("Assets\\Amani_love_open.png"),
                                                new Bitmap("Assets\\Amani_love.png"),
                                                Key.NumPad0));
            expressions.Add(CreateNewExpression("Scared",
                                                new Bitmap("Assets\\Amani_scared_open.png"),
                                                new Bitmap("Assets\\Amani_scared.png"),
                                                Key.Decimal));
            expressions.Add(CreateNewExpression("What",
                                                new Bitmap("Assets\\Amani_uh_open.png"),
                                                new Bitmap("Assets\\Amani_uh.png"),
                                                Key.Add));

            foreach (Amani.Expression exp in expressions)
            {
                ListViewItem item = new ListViewItem(exp.name);
                item.SubItems.Add(new ListViewItem.ListViewSubItem(item, exp.key.ToString()));
                list_expressions.Items.Add(item);
            }

            Amani.SetExpression(expressions[0]);
            list_expressions.SelectedIndex = 0;

            Thread keyChecker = new Thread(CheckKeys);

            keyChecker.SetApartmentState(ApartmentState.STA);

            keyChecker.Start();
        }