History

Fixed BackAndForth.

mulshine committed 7 years ago

Commit 97ad9721 parent 3e8b4823 files · +26 −11Browse files

Unified · Split

3 files
  1. LEAF/Inc/leaf-sample.h +1 −0
  2. LEAF/Src/leaf-sample.c +12 −5
  3. LEAF_JUCEPlugin/Source/MyTest.cpp +13 −6
LEAF/Inc/leaf-sample.h+1−0
@@ -80,6 +80,7 @@ extern "C" { · 79 unmodified lines
8080 float iinc;
8181 int8_t dir;
8282 int8_t flip;
83+ int8_t bnf;
8384
8485 int32_t start;
8586 int32_t end;
LEAF/Src/leaf-sample.c+12−5
@@ -120,8 +120,10 @@ void tSampler_init (tSampler* const p, tBuffer* s) · 119 unmodified lines
120120 p->idx = 0.f;
121121 p->inc = 1.f;
122122 p->iinc = 1.f;
123+
123124 p->dir = 1;
124125 p->flip = 1;
126+ p->bnf = 1;
125127
126128 p->mode = Normal;
127129
@@ -148,7 +150,7 @@ float tSampler_tick (tSampler* const p) · 20 unmodified lines
148150
149151 float* buff = p->samp->buff;
150152
151− int dir = p->dir * p->flip;
153+ int dir = p->bnf * p->dir * p->flip;
152154
153155 int idx;
154156 float alpha;
@@ -269,13 +271,18 @@ float tSampler_tick (tSampler* const p) · 114 unmodified lines
269271 }
270272 else // == BackAndForth
271273 {
272− if ((idx <= start) || (idx >= end))
274+ if (p->idx < start)
275+ {
276+ p->bnf = -p->bnf;
277+ p->idx = start;
278+ }
279+ else if (p->idx > end)
273280 {
274− p->dir = -p->dir;
275− p->idx += (p->dir * p->flip * p->inc);
281+ p->bnf = -p->bnf;
282+ p->idx = end;
276283 }
277284 }
278−
285+
279286 g1 = 1.f - g2;
280287
281288 sample = sample * g1 + cfxsample * g2;
LEAF_JUCEPlugin/Source/MyTest.cpp+13−6
@@ -27,13 +27,11 @@ void LEAFTest_init (float sampleRate, int blockSize) · 26 unmodified lines
2727 tBuffer_init(&sample, leaf.sampleRate * 2);
2828
2929 tSampler_init(&player, &sample);
30− tSampler_setMode(&player, Loop);
30+ tSampler_setMode(&player, BackAndForth);
3131
3232 leaf_pool_report();
3333
34− tBuffer_record(&sample);
35−
36− tSampler_play(&player);
34+ tBuffer_record(&sample);
3735 }
3836
3937 int timer = 0;
@@ -45,7 +43,7 @@ float LEAFTest_tick (float input) · 5 unmodified lines
4543 return tSampler_tick(&player);
4644 }
4745
48−bool lastState = false;
46+bool lastState = false, lastPlayState = false;
4947 void LEAFTest_block (void)
5048 {
5149 float val = getSliderValue("rate");
@@ -77,7 +75,16 @@ void LEAFTest_block (void) · 25 unmodified lines
7775 tBuffer_record(&sample);
7876 }
7977
80− lastState = state;
78+ lastState = state;
79+
80+ state = getButtonState("play");
81+
82+ if (state && !lastPlayState)
83+ {
84+ tSampler_play(&player);
85+ }
86+
87+ lastPlayState = state;
8188 }
8289
8390 void LEAFTest_controllerInput (int cnum, float cval)

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t