Advertisement
FHRL

metronomo0_0_0b3

Mar 16th, 2023
260
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.34 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: project: ".../storage/emulated/0/Sketchbook/metronomo/metronomo.../sketch.pde"
  5.  *User:fhrl007@gmail.com
  6.  *Date:15-03-2023
  7.  *Time: 23:30
  8.  *Verton:0.0.0b3
  9.  *Based an AI documentation generated.
  10.  */
  11.  
  12. import android.app.Activity;
  13. import android.os.Bundle;
  14. import android.os.Handler;
  15. import android.view.View;
  16. import android.widget.Button;
  17.  
  18. public class MetronomeActivity extends Activity {
  19.  
  20.     private Handler mHandler = new Handler();
  21.     private boolean mIsPlaying = false;
  22.     private int mTempo = 120;
  23.     private int mDuration = 60000 / mTempo;
  24.  
  25.     private Runnable mPlaySoundRunnable = new Runnable() {
  26.         @Override
  27.         public void run() {
  28.             // Reproduce el sonido del metrónomo
  29.             playSound();
  30.             // Programa la siguiente llamada a run() después del tiempo de duración del latido
  31.             mHandler.postDelayed(mPlaySoundRunnable, mDuration);
  32.         }
  33.     };
  34.  
  35.     @Override
  36.     protected void onCreate(Bundle savedInstanceState) {
  37.         super.onCreate(savedInstanceState);
  38.         setContentView(R.layout.activity_metronome);
  39.  
  40.         Button playButton = findViewById(R.id.play_button);
  41.         playButton.setOnClickListener(new View.OnClickListener() {
  42.             @Override
  43.             public void onClick(View view) {
  44.                 if (mIsPlaying) {
  45.                     stopMetronome();
  46.                 } else {
  47.                     startMetronome();
  48.                 }
  49.             }
  50.         });
  51.     }
  52.  
  53.     private void startMetronome() {
  54.         // Inicia el metrónomo
  55.         mIsPlaying = true;
  56.         mHandler.postDelayed(mPlaySoundRunnable, mDuration);
  57.     }
  58.  
  59.     private void stopMetronome() {
  60.         // Detiene el metrónomo
  61.         mIsPlaying = false;
  62.         mHandler.removeCallbacks(mPlaySoundRunnable);
  63.     }
  64.  
  65.     private void playSound() {
  66.         // Reproduce el sonido del metrónomo
  67.     }
  68. }
  69.  
  70.  
  71. PApplet parent;
  72. int tempo = 120; // latidos por minuto
  73. int duration = 1000 * 60 / tempo; // duración de cada latido en milisegundos
  74. Timer timer;
  75. boolean isPlaying = false;
  76.  
  77. void setup() {
  78.   size(200, 200);
  79.   frameRate(60); // velocidad de actualización de la ventana
  80.   parent = this;
  81. }
  82.  
  83. void draw(){
  84.  
  85. }
  86.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement