Home>
A method to control ON/OFF with tact switch while looping mp3 sound source.
Error messageUsing Arduino and processing, playing an mp3 file only while pressing the tact switch
I have done it, but how can I write it to keep the sound source looped? Yoro
Thank you very much.
Applicable source code
import ddf.minim. *;
import ddf.minim.analysis. *;
import ddf.minim.effects. *;
import ddf.minim.signals. *;
import ddf.minim.spi. *;
import ddf.minim.ugens. *;
import cc.arduino. *;// Arduino library
import processing.serial. *;// Serial communication library
Arduino arduino;
int pin2 = 2;// Input pin (digital)
//sound
Minim minim;
AudioPlayer song7;// Sound data storage variable declaration
void setup () {
println (Arduino.list ());// Display a list of serial ports
arduino = new Arduino (this, Arduino.list () [1], 57600);// Arduino connection settings
arduino.pinMode (pin2, Arduino.INPUT);// I/O pin setting
// setup
minim = new Minim (this);// initialization
// [first piece]
song7 = minim.loadFile ("sample7.mp3");// load sample7.mp3
song7.play ();// Play
}
void draw () {
int value = arduino.digitalRead (pin2);// read pin state
if (value == arduino.LOW) {// input is LOW (plays music when the button is pressed)
background (255,0,0);
song7.play ();
}
else if (value == arduino.HIGH) {// input is HIGH (pauses music when the button is not pressed)
background (0,0,0);
song7.pause ();
}
}
//sound
void stop () {
song7.close ();// End sound data
minim.stop ();
super.stop ();
}
I tried putting "sound7.loop ();" behind the play in setup and behind the pause of draw, but nothing happened.
-
Answer # 1
Related articles
- arduino - i want to move the variable resistor and switch separately to make the tape led shine
- Python flow control while loop analysis
- Simple example of php while loop control
- Simple example of php flow control switch
- Bootstrap switch control study notes sharing
- Learn iOS Switch Button UISwitch Control
- ToggleButton switch state button control in Android
- JS switch judgment trinocular operation while and attribute operation code
- How to use the Android UI control Switch
- How to pass Vue parameters to control the global consolelog switch in detail
- The realization of the simple communication control switch Switch formed by Vue father and son
- Use cases for the Android switch control Switch
- layui--js control switch method
- javascript - i want to control submit while taking advantage of
- Mui js control switch state, modify the value of the switch method
- LayUi uses a switch to dynamically control whether it is enabled
- Vue implements display switch control of navigation bar
- c++ - i want to operate switch with arduino
- how can i successfully switch the animation while the character is walking in unity c#?
- i want to operate nintendo switch with arduino
Related questions
- save sensor values in csv format using arduino and processing
- to discharge csv from arduino with processing
- cooperation between processing and arduino
- java - i want to write a program in which an object like the game "taiko no guru" flows and sounds when it overlaps
- java - a program that reads the value of the optical sensor, generates a random number only once, and displays the character acc
- pass information from espr developper (arduino environment) to processing via serial communication
- java - a program that sounds in arduino when the cursor touches a shape in processing, and stops when the cursor stops touching
- java - the program that reads the value of the ultrasonic sensor using arduino and displays the numerical value with processing
- java - cooperation between arduino and processing serial communication
- java - controlling two arduino servos and one speaker from processing causes the servo movement to become unstable
Since there is no Arduino, when I tried to move the variable appropriately, it was as intended.