Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*Created by Processing APDE app version 0.5.1
- * and OpenIA GPTchat Mar 14 version.
- *compatibility: java, wallpaper, app.
- *project: project: ".../storage/emulated/0/Sketchbook/metronomo/metronomo.../sketch.pde"
- *User:fhrl007@gmail.com
- *Date:15-03-2023
- *Time: 23:30
- *Verton:0.0.0b3
- *Based an AI documentation generated.
- */
- import android.app.Activity;
- import android.os.Bundle;
- import android.os.Handler;
- import android.view.View;
- import android.widget.Button;
- public class MetronomeActivity extends Activity {
- private Handler mHandler = new Handler();
- private boolean mIsPlaying = false;
- private int mTempo = 120;
- private int mDuration = 60000 / mTempo;
- private Runnable mPlaySoundRunnable = new Runnable() {
- @Override
- public void run() {
- // Reproduce el sonido del metrónomo
- playSound();
- // Programa la siguiente llamada a run() después del tiempo de duración del latido
- mHandler.postDelayed(mPlaySoundRunnable, mDuration);
- }
- };
- @Override
- protected void onCreate(Bundle savedInstanceState) {
- super.onCreate(savedInstanceState);
- setContentView(R.layout.activity_metronome);
- Button playButton = findViewById(R.id.play_button);
- playButton.setOnClickListener(new View.OnClickListener() {
- @Override
- public void onClick(View view) {
- if (mIsPlaying) {
- stopMetronome();
- } else {
- startMetronome();
- }
- }
- });
- }
- private void startMetronome() {
- // Inicia el metrónomo
- mIsPlaying = true;
- mHandler.postDelayed(mPlaySoundRunnable, mDuration);
- }
- private void stopMetronome() {
- // Detiene el metrónomo
- mIsPlaying = false;
- mHandler.removeCallbacks(mPlaySoundRunnable);
- }
- private void playSound() {
- // Reproduce el sonido del metrónomo
- }
- }
- PApplet parent;
- int tempo = 120; // latidos por minuto
- int duration = 1000 * 60 / tempo; // duración de cada latido en milisegundos
- Timer timer;
- boolean isPlaying = false;
- void setup() {
- size(200, 200);
- frameRate(60); // velocidad de actualización de la ventana
- parent = this;
- }
- void draw(){
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement