コード例 #1
0
        protected override void OnCreate(Bundle bundle)
        {
            RequestWindowFeature(WindowFeatures.ActionBar);
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.WikiPracticeActivity);

            modeLayouts = new Dictionary<ServerData.TaskType, LinearLayout>();
            modeNames = new BiDictionary<ServerData.TaskType, string>();

            wikiText = FindViewById<TextView>(Resource.Id.wiki_text);
            wikiImage = FindViewById<ImageView>(Resource.Id.wiki_image);
            startBtn = FindViewById<Button>(Resource.Id.wiki_startBtn);
            startBtn.Click += startBtn_Click;

            // Pacing layout
            metronBpmText = FindViewById<TextView>(Resource.Id.wiki_bpm);
            metronDownBtn = FindViewById<Button>(Resource.Id.wiki_downBtn);
            metronDownBtn.Click += downBtn_Click;
            metronUpBtn = FindViewById<Button>(Resource.Id.wiki_upBtn);
            metronUpBtn.Click += upBtn_Click;
            metronControlsLayout = FindViewById<LinearLayout>(Resource.Id.wiki_speedControls);
            modeLayouts.Add(ServerData.TaskType.Pacing, metronControlsLayout);
            modeNames.Add(ServerData.TaskType.Pacing, "Speech Pacing");

            // Loudness layout
            loudVolText = FindViewById<TextView>(Resource.Id.wiki_volume);
            loudTargetText = FindViewById<TextView>(Resource.Id.wiki_Targetvolume);
            loudTargetButton = FindViewById<Button>(Resource.Id.wiki_measureVolBtn);
            loudTargetButton.Click += loud_targetButton_Click;
            loudControlsLayout = FindViewById<LinearLayout>(Resource.Id.wiki_volControls);
            modeLayouts.Add(ServerData.TaskType.Loudness, loudControlsLayout);
            modeNames.Add(ServerData.TaskType.Loudness, "Loudness of Speech");

            names = new List<string>();

            foreach (
                KeyValuePair<ServerData.TaskType, string> entry in (Dictionary<ServerData.TaskType, string>)modeNames.firstToSecond)
            {
                names.Add(entry.Value);
            }

            currentMode = ServerData.TaskType.Loudness;

            pacingModeButton = FindViewById<Button>(Resource.Id.wiki_pacingModeBtn);
            pacingModeButton.Click += pacingModeSwitch;
            loudnessModeButton = FindViewById<Button>(Resource.Id.wiki_loudnessModeBtn);
            loudnessModeButton.Click += loudnessModeSwitch;

            SetupRecorder();

            LoadWikiInfo();
        }
コード例 #2
0
        /// <summary>
        /// Switch the functionality of the practiceActivity
        /// </summary>
        private void SwitchMode(ServerData.TaskType newMode)
        {
            if (newMode == currentMode) return;

            // Hide the current mode if needed
            if (currentMode != ServerData.TaskType.None)
            {
                RunOnUiThread(() => { modeLayouts[currentMode].Visibility = ViewStates.Gone; });
            }

            currentMode = newMode;
            string modeName;

            modeNames.TryGetByFirst(newMode, out modeName);

            Title = modeName;

            switch (newMode)
            {
                case ServerData.TaskType.Pacing:
                    ChangeBpm(0);
                    metronBuffSize = AudioTrack.GetMinBufferSize(44100, ChannelOut.Mono, Encoding.Pcm16bit);
                    metronAudioBuffer = new short[metronBuffSize];
                    break;
                case ServerData.TaskType.Loudness:
                    break;
            }
        }