Ejemplo n.º 1
0
        /// <summary>
        /// initiate a synthesizer with the given amount of keys
        /// </summary>
        /// <param name="keys">3 to 12 keys</param>
        public Synthesizer(AssetManager assets, short keys)
        {
            Keys = keys;
            if (keys > 2 && keys < 13)
            {
                //prepare stacks
                Playing           = new Stack <short>();
                PlayingPercussion = new Stack <short>();

                //load sounds
                SoundPool.Builder soundPoolBuilder = new SoundPool.Builder();
                Lead = new SoundPool[keys];

                //prepare percussion
                PercIds = new int[3];

                //prepare kick
                SoundPool kick = soundPoolBuilder.Build();
                kick.SetOnLoadCompleteListener(OnLoadCompleteListener);
                PercIds[0] = kick.Load(assets.OpenFd("perc/kick.mp3"), 1);

                //prepare snare
                SoundPool snare = soundPoolBuilder.Build();
                snare.SetOnLoadCompleteListener(OnLoadCompleteListener);
                PercIds[1] = snare.Load(assets.OpenFd("perc/snare.mp3"), 1);

                //prepare hi-hat
                SoundPool hat = soundPoolBuilder.Build();
                snare.SetOnLoadCompleteListener(OnLoadCompleteListener);
                PercIds[2] = hat.Load(assets.OpenFd("perc/hat.mp3"), 1);

                Percussion = new SoundPool[3]
                {
                    kick,
                    snare,
                    hat
                };

                //prepare lead
                SoundIds = new int[keys];

                for (int l = 0; l < keys; l++)
                {
                    SoundPool lead = soundPoolBuilder.Build();
                    lead.SetOnLoadCompleteListener(OnLoadCompleteListener);
                    SoundIds[0] = lead.Load(assets.OpenFd("keys/" + Synth + "/A.mp3"), 1);
                    Lead[l]     = lead;
                }
            }
            else
            {
                throw new IndexOutOfRangeException("Synthesizer size must be between 3 and 12.");
            }
        }
Ejemplo n.º 2
0
        async Task <SoundPool> LoadEffects(AssetManager assets)
        {
            SoundPool sp = new SoundPool.Builder().SetMaxStreams(2).Build();

            m_mpAlertMedia.Add(AlertType.GoodInfo, await LoadSoundFile(sp, "exclamation.wav", assets));
            m_mpAlertMedia.Add(AlertType.Duplicate, await LoadSoundFile(sp, "doh.wav"));
            m_mpAlertMedia.Add(AlertType.Drink, await LoadSoundFile(sp, "hicup_392.wav"));
            m_mpAlertMedia.Add(AlertType.BadInfo, await LoadSoundFile(sp, "ding.wav"));
            m_mpAlertMedia.Add(AlertType.Halt, await LoadSoundFile(sp, "ding.wav"));
            m_mpAlertMedia.Add(AlertType.UPCScanBeep, await LoadSoundFile(sp, "263133__pan14__tone-beep.wav"));

            return(sp);
        }
Ejemplo n.º 3
0
        public void Login()
        {
            bool hasError = false;

            if (etSoukoCode.Text == "" || txtSoukoName.Text == "")
            {
                string alertTitle = Resources.GetString(Resource.String.error);
                string alertBody  = Resources.GetString(Resource.String.errorMsg002);

                ShowDialog(alertTitle, alertBody, () => {
                    etSoukoCode.Text  = "";
                    txtSoukoName.Text = "";
                    etSoukoCode.RequestFocus();
                });

                Log.Warn(TAG, "SoukoCode is Empty");
                return;
            }

            if (etDriverCode.Text == "")
            {
                string alertTitle = Resources.GetString(Resource.String.error);
                string alertBody  = Resources.GetString(Resource.String.errorMsg002);

                ShowDialog(alertTitle, "担当者コードを\n入力して下さい。", () => { });

                Log.Warn(TAG, "DriverCode is Empty");
                return;
            }

            ((MainActivity)this.Activity).ShowProgress("ログインしています");

            new Thread(new ThreadStart(delegate {
                Activity.RunOnUiThread(async() =>
                {
                    if (await CommonUtils.IsHostReachable(WebService.GetHostIpAddress()))
                    {
                        Log.Verbose(TAG, "Status : Host Reached");

                        try
                        {
                            // 無線管理テーブルへ情報を登録する。
                            WebService.RequestLogin040(etDriverCode.Text, etSoukoCode.Text, "11101");

                            // 担当者名取得
                            LOGIN030 login030 = WebService.RequestLogin030(etDriverCode.Text);
                            editor.PutString("menu_kbn", login030.menu_kbn);
                            editor.PutString("driver_nm", login030.tantohsya_nm);

                            // 正常の場合、前回ログイン情報を保存する
                            loginHelper.Insert(new Login
                            {
                                souko_cd         = etSoukoCode.Text,
                                souko_nm         = txtSoukoName.Text,
                                tantousha_cd     = etDriverCode.Text,
                                menu_flg         = login030.menu_kbn,
                                tantohsya_nm     = login030.tantohsya_nm,
                                def_tokuisaki_cd = this.def_tokuisaki_cd,
                                kitaku_cd        = this.kitaku_cd,
                                souko_kbn        = this.souko_kbn,
                                tsuhshin_kbn     = this.tsuhshin_kbn
                            });
                        }
                        catch (Exception e)
                        {
                            ShowDialog("エラー", "認証できませんでした。\n入力内容をご確認下さい。", () => {
                                etDriverCode.Text = "";
                                etDriverCode.RequestFocus();
                            });

                            hasError = true;
                            Log.Error(TAG, "Login Failed :" + e.StackTrace.ToString());
                            return;
                        }
                    }
                    else
                    {
                        ShowDialog("エラー", "サーバから答えがありません。", () => { });
                        hasError = true;
                        return;

                        /*
                         * tantoHelper = new TantoHelper();
                         * Tanto tanto = tantoHelper.SelectTantoInfo(etDriverCode.Text);
                         * editor.PutString("menu_kbn", tanto.menu_kbn);
                         * editor.PutString("driver_nm", tanto.tantohsya_nm);
                         *
                         * SetSoukoName(etSoukoCode.Text);
                         *
                         * // 正常の場合、前回ログイン情報を保存する
                         * loginHelper.InsertIntoTableLoginInfo(new Login
                         * {
                         *  souko_cd = etSoukoCode.Text,
                         *  souko_nm = txtSoukoName.Text,
                         *  tantousha_cd = etDriverCode.Text,
                         *  menu_flg = tanto.menu_kbn,
                         *  tantohsya_nm = tanto.tantohsya_nm,
                         *  def_tokuisaki_cd = this.def_tokuisaki_cd,
                         *  kitaku_cd = this.kitaku_cd
                         * });
                         *
                         */
                    }

                    // TEMP
                    // ***********************;
                    editor.PutString("terminal_id", "432660068");
                    editor.PutString("hht_no", "11101");
                    // ***********************

                    editor.PutString("souko_cd", etSoukoCode.Text);
                    editor.PutString("souko_nm", txtSoukoName.Text);
                    editor.PutString("driver_cd", etDriverCode.Text);
                    editor.PutString("sagyousya_cd", etDriverCode.Text);
                    editor.PutString("kitaku_cd", kitaku_cd);
                    editor.PutString("def_tokuisaki_cd", def_tokuisaki_cd);
                    editor.PutString("tsuhshin_kbn", tsuhshin_kbn);
                    editor.PutString("souko_kbn", souko_kbn);

                    editor.Apply();

                    Log.Verbose(TAG, "Login Succeeded");
                }
                                       );
                Activity.RunOnUiThread(() => {
                    ((MainActivity)this.Activity).DismissDialog();
                    if (!hasError)
                    {
                        string menu_kbn = prefs.GetString("menu_kbn", "");

                        AudioAttributes attributes = new AudioAttributes.Builder()
                                                     .SetUsage(AudioUsageKind.Game)
                                                     .SetContentType(AudioContentType.Sonification)
                                                     .Build();

                        SoundPool soundPool = new SoundPool.Builder()
                                              .SetAudioAttributes(attributes)
                                              // ストリーム数に応じて
                                              .SetMaxStreams(2)
                                              .Build();


                        //AssetManager assets = this.Activity.Assets;

                        //soundPool = new SoundPool(5, Stream.Ring, 0);
                        soundPool.Play(soundPool.Load(this.Activity, Resource.Raw.beep, 0), 1.0f, 1.0f, 0, 0, 1);

                        //MediaPlayer mp = MediaPlayer.Create(this.Activity, Resource.Raw.beep);
                        //mp.Start();
                        //ToneGenerator toneGen1 = new ToneGenerator(Stream.System, 100);
                        //toneGen1.StartTone(Tone.PropBeep, 1000);

                        try
                        {
                            StartFragment(FragmentManager, typeof(MainMenuFragment));
                        }
                        catch (Exception e)
                        {
                            Log.Debug(TAG, e.StackTrace.ToString());
                        }
                    }
                });
            }
                                       )).Start();
        }