Advertisement
FHRL

metronomo0_0_0b5

Mar 16th, 2023
510
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.30 KB | Source Code | 0 0
  1. /*Created by Processing APDE app version 0.5.1
  2.  *       and OpenIA GPTchat Mar 14 version.
  3.  *compatibility: java, wallpaper, app.
  4.  *project: ".../storage/emulated/0/Sketchbook/metronomo/metronomo.../sketch.pde"
  5.  *Date:16-03-2023
  6.  *Time: 00:33
  7.  *Verton:0.0.0b5
  8.  *Based an AI documentation generated.
  9.  */
  10.  
  11. import android.app.Activity;
  12. import android.os.Bundle;
  13. import android.os.Handler;
  14. import android.view.View;
  15. import android.widget.Button;
  16. import com.calsignlabs.apde.R;
  17. import java.util.TimerTask;
  18. import java.util.Timer; // Importar la clase Timer
  19.  
  20. public class MetronomeActivity extends Activity {
  21.  
  22.     private Handler mHandler = new Handler();
  23.     private boolean mIsPlaying = false;
  24.     private int mTempo = 120;
  25.     private int mDuration = 60000 / mTempo;
  26.    
  27.  
  28.     @Override
  29.     protected void onCreate(Bundle savedInstanceState) {
  30.         super.onCreate(savedInstanceState);
  31.         setContentView(R.layout.activity_metronome);
  32.  
  33.         Button playButton = findViewById(R.id.play_button);
  34.         playButton.setOnClickListener(new View.OnClickListener() {
  35.             @Override
  36.             public void onClick(View view) {
  37.                 if (mIsPlaying) {
  38.                     stopMetronome();
  39.                 } else {
  40.                     startMetronome();
  41.                 }
  42.             }
  43.         });
  44.     }
  45.  
  46.     private void startMetronome() {
  47.         // Inicia el metrónomo
  48.         mIsPlaying = true;
  49.         timer = new Timer(); // inicializar el objeto timer
  50.         timer.scheduleAtFixedRate(new TimerTask() {
  51.             @Override
  52.             public void run() {
  53.                 playSound();
  54.             }
  55.         }, 0, mDuration);
  56.     }
  57.  
  58.     private void stopMetronome() {
  59.         // Detiene el metrónomo
  60.         mIsPlaying = false;
  61.         timer.cancel(); // cancelar la tarea del timer
  62.     }
  63.  
  64.     private void playSound() {
  65.         // Reproduce el sonido del metrónomo
  66.     }
  67. }
  68.  
  69.  
  70. PApplet parent;
  71. int tempo = 120; // latidos por minuto
  72. int duration = 1000 * 60 / tempo; // duración de cada latido en milisegundos
  73. Timer timer;
  74. boolean isPlaying = false;
  75.  
  76. void setup() {
  77.   size(200, 200);
  78.   frameRate(60); // velocidad de actualización de la ventana
  79.   parent = this;
  80. }
  81.  
  82. void draw(){// se muestra en pantalla por frame.
  83.  
  84. }
  85.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement