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.
- *incompatibility: Android Studio.
- *project: ".../storage/emulated/0/Sketchbook/metronomo/Metronomo.../sketch.pde"
- *User:fhrl007@gmail.com
- *Date:16-03-2023
- *Time: 00:58
- *Verton:0.0.0b6
- *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;
- import com.calsignlabs.apde.R;
- import java.util.TimerTask;
- import java.util.Timer; // Importar la clase Timer
- public class Metronomo0_0_0b6 extends Activity {
- private Handler mHandler = new Handler();
- private boolean mIsPlaying = false;
- private int mTempo = 120;
- private int mDuration = 60000 / mTempo;
- @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;
- timer = new Timer(); // inicializar el objeto timer
- timer.scheduleAtFixedRate(new TimerTask() {
- @Override
- public void run() {
- playSound();
- }
- }, 0, mDuration);
- }
- private void stopMetronome() {
- // Detiene el metrónomo
- mIsPlaying = false;
- timer.cancel(); // cancelar la tarea del timer
- }
- 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(){// se muestra en pantalla por frame.
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement