Skip to content

Commit 1be7d98

Browse files
committed
Fixed loop jump() issue
1 parent 731db63 commit 1be7d98

File tree

3 files changed

+25
-6
lines changed

3 files changed

+25
-6
lines changed
70 Bytes
Binary file not shown.

java/libraries/sound/src/processing/sound/Env.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ public Env (PApplet theParent) {
1717
public void play(SoundObject input, float attackTime, float sustainTime, float sustainLevel, float releaseTime){
1818
m_nodeId = m_engine.envelopePlay(input.returnId(), attackTime, sustainTime, sustainLevel, releaseTime);
1919
}
20+
21+
public int returnId(){
22+
return m_nodeId;
23+
}
2024

2125
public void dispose(){
2226
//m_engine.synthStop(m_nodeId);

java/libraries/sound/src/processing/sound/SoundFile.java

Lines changed: 21 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ public class SoundFile implements SoundObject {
1414
float m_add=0;
1515
int m_cue=0;
1616
float m_pos=0;
17+
boolean m_loop;
1718

1819

1920
public SoundFile(PApplet theParent, String path) {
@@ -43,6 +44,7 @@ public float duration(){
4344
}
4445

4546
public void play(){
47+
m_loop=false;
4648
if(this.channels() == 1){
4749
m_nodeId = methCla.soundFilePlayMono(m_rate, m_pos, m_amp, m_add, false, m_filePath, this.duration()*(1/m_rate), m_cue);
4850
}
@@ -77,6 +79,7 @@ public void play(float rate){
7779
}
7880

7981
public void loop(){
82+
m_loop=true;
8083
if(this.channels() < 2){
8184
m_nodeId = methCla.soundFilePlayMono(m_rate, m_pos, m_amp, m_add, true, m_filePath, this.duration()*(1/m_rate), m_cue);
8285
}
@@ -118,12 +121,24 @@ public void jump(float time){
118121

119122
m_cue = (int)time * m_info[1];
120123

121-
if(this.channels() < 2){
122-
m_nodeId = methCla.soundFilePlayMono(m_rate, m_pos, m_amp, m_add, false, m_filePath, this.duration()*(1/m_rate), m_cue);
123-
}
124-
else if(this.channels() == 2){
125-
m_nodeId = methCla.soundFilePlayMulti(m_rate, m_amp, m_add, false, m_filePath, this.duration()*(1/m_rate), m_cue);
126-
}
124+
if(m_loop == true) {
125+
if(this.channels() < 2){
126+
m_nodeId = methCla.soundFilePlayMono(m_rate, m_pos, m_amp, m_add, true, m_filePath, this.duration()*(1/m_rate), m_cue);
127+
}
128+
else if(this.channels() == 2){
129+
m_nodeId = methCla.soundFilePlayMulti(m_rate, m_amp, m_add, true, m_filePath, this.duration()*(1/m_rate), m_cue);
130+
}
131+
}
132+
else {
133+
if(this.channels() < 2){
134+
m_nodeId = methCla.soundFilePlayMono(m_rate, m_pos, m_amp, m_add, false, m_filePath, this.duration()*(1/m_rate), m_cue);
135+
}
136+
else if(this.channels() == 2){
137+
m_nodeId = methCla.soundFilePlayMulti(m_rate, m_amp, m_add, false, m_filePath, this.duration()*(1/m_rate), m_cue);
138+
}
139+
}
140+
141+
m_cue = 0;
127142
}
128143

129144
public void cue(float time){

0 commit comments

Comments
 (0)