protected override void OnAppearing() { base.OnAppearing(); bpmModel = new BPMModel(); BindingContext = bpmModel; bpmCounter.BindingContext = bpmModel; }
public Metronome(float volume, ref BPMModel model) { SetModel(ref model); var soundFile = new NSUrl($"Sounds/DefaultClick/sound.wav"); var accentFile = new NSUrl($"Sounds/DefaultClick/accent.wav"); NSError error; _soundPlayer = new AVAudioPlayer(soundFile, "sound", out error); _soundPlayer.Volume = volume; _soundPlayer.Pan = -1; _soundPlayer.PrepareToPlay(); _accentPlayer = new AVAudioPlayer(accentFile, "sound", out error); _accentPlayer.Volume = volume; _accentPlayer.Pan = -1; _accentPlayer.PrepareToPlay(); // TODO: Check error #if DEBUG _testTimer.Elapsed += (object sender, ElapsedEventArgs e) => { Debug.WriteLine($"One minute passed, BPM count: {_testMinuteCount}"); if (_testMinuteCount != _model.CurrentBPM) { throw new Exception($"BPM Counts don't match: Current = {_model.CurrentBPM}, Actual = {_testMinuteCount}"); } _testMinuteCount = 0; }; #endif }
public void Restart(ref BPMModel model) { SetModel(ref model); if (_isRunning) { Stop(); Start(); } }
private void SetModel(ref BPMModel model) { _model?.RemoveObserver(this, nameof(BPMModel.CurrentBPM)); _model?.RemoveObserver(this, nameof(BPMModel.Upper)); _model?.RemoveObserver(this, nameof(BPMModel.Lower)); _model = model; _model?.AddObserver(this, nameof(BPMModel.CurrentBPM), NSKeyValueObservingOptions.New, IntPtr.Zero); _model?.AddObserver(this, nameof(BPMModel.Upper), NSKeyValueObservingOptions.New, IntPtr.Zero); _model?.AddObserver(this, nameof(BPMModel.Lower), NSKeyValueObservingOptions.New, IntPtr.Zero); }
protected override void Dispose(bool disposing) { if (disposing) { Stop(); _soundPlayer?.Dispose(); _soundPlayer = null; _accentPlayer?.Dispose(); _accentPlayer = null; _model?.RemoveObserver(this, nameof(BPMModel.CurrentBPM)); _model?.RemoveObserver(this, nameof(BPMModel.Upper)); _model?.RemoveObserver(this, nameof(BPMModel.Lower)); _model = null; } base.Dispose(disposing); }
/// <summary> /// Initializes a new instance of the <see cref="T:Clad.AddPopupView"/> class. /// </summary> public AddPopupView(BPMModel bpmModel) { _bpmModel = bpmModel; BackgroundColor = UIColor.FromRGB(97, 125, 138); UserInteractionEnabled = true; }