Skip to content

Commit f55b7db

Browse files
authored
Merge pull request #818 from schollz/first-trigger
fix: triggering
2 parents c80eb2a + 34e07be commit f55b7db

12 files changed

Lines changed: 211 additions & 37 deletions

File tree

.github/ISSUE_TEMPLATE/ectocore-freezing.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ assignees: schollz
99

1010
Normally, ectocore and zeptocore should not freeze.
1111

12-
If you are encountering a freeze, you might first try to upload this [new firmware that disables overclocking](https://github.com/schollz/_core/releases/download/v7.1.2/ectocore_no_overclocking_v7.1.2.uf2).
12+
If you are encountering a freeze, you might first try to upload this [new firmware that disables overclocking](https://github.com/schollz/_core/releases/download/v7.1.3/ectocore_no_overclocking_v7.1.3.uf2).
1313

1414
If you still encounter a freeze, it would be helpful to know the following:
1515

README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,8 +71,8 @@ For latency, normal latency will work for most, but choose low or ultra-low if y
7171

7272
| | Normal Latency | Low Latency | Ultra-Low Latency |
7373
| ---------------- | --------------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------- | -------------------------------------------------------------------------------------------------------------------------- |
74-
| Overclocking | [v7.1.2](https://github.com/schollz/_core/releases/download/v7.1.2/ezeptocore_v7.1.2.uf2)* | [v7.1.2](https://github.com/schollz/_core/releases/download/v7.1.2/ezeptocore_v7.1.2_low_latency.uf2) | [v7.1.2](https://github.com/schollz/_core/releases/download/v7.1.2/ezeptocore_v7.1.2_ultralow_latency.uf2) |
75-
| Non-Overclocking | [v7.1.2](https://github.com/schollz/_core/releases/download/v7.1.2/ezeptocore_v7.1.2_no_overclocking.uf2) | [v7.1.2](https://github.com/schollz/_core/releases/download/v7.1.2/ezeptocore_v7.1.2_no_overclocking_low_latency.uf2) | [v7.1.2](https://github.com/schollz/_core/releases/download/v7.1.2/ezeptocore_v7.1.2_no_overclocking_ultralow_latency.uf2) |
74+
| Overclocking | [v7.1.3](https://github.com/schollz/_core/releases/download/v7.1.3/ezeptocore_v7.1.3.uf2)* | [v7.1.3](https://github.com/schollz/_core/releases/download/v7.1.3/ezeptocore_v7.1.3_low_latency.uf2) | [v7.1.3](https://github.com/schollz/_core/releases/download/v7.1.3/ezeptocore_v7.1.3_ultralow_latency.uf2) |
75+
| Non-Overclocking | [v7.1.3](https://github.com/schollz/_core/releases/download/v7.1.3/ezeptocore_v7.1.3_no_overclocking.uf2) | [v7.1.3](https://github.com/schollz/_core/releases/download/v7.1.3/ezeptocore_v7.1.3_no_overclocking_low_latency.uf2) | [v7.1.3](https://github.com/schollz/_core/releases/download/v7.1.3/ezeptocore_v7.1.3_no_overclocking_ultralow_latency.uf2) |
7676

7777
*default firmware
7878

@@ -106,8 +106,8 @@ For latency, normal latency will work for most, but choose low or ultra-low if y
106106

107107
| | Normal Latency | Low Latency | Ultra-Low Latency |
108108
| ---------------- | ------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------- | ------------------------------------------------------------------------------------------------------------------------ |
109-
| Overclocking | [v7.1.2](https://github.com/schollz/_core/releases/download/v7.1.2/ectocore_v7.1.2.uf2)* | [v7.1.2](https://github.com/schollz/_core/releases/download/v7.1.2/ectocore_v7.1.2_low_latency.uf2) | [v7.1.2](https://github.com/schollz/_core/releases/download/v7.1.2/ectocore_v7.1.2_ultralow_latency.uf2) |
110-
| Non-Overclocking | [v7.1.2](https://github.com/schollz/_core/releases/download/v7.1.2/ectocore_v7.1.2_no_overclocking.uf2) | [v7.1.2](https://github.com/schollz/_core/releases/download/v7.1.2/ectocore_v7.1.2_no_overclocking_low_latency.uf2) | [v7.1.2](https://github.com/schollz/_core/releases/download/v7.1.2/ectocore_v7.1.2_no_overclocking_ultralow_latency.uf2) |
109+
| Overclocking | [v7.1.3](https://github.com/schollz/_core/releases/download/v7.1.3/ectocore_v7.1.3.uf2)* | [v7.1.3](https://github.com/schollz/_core/releases/download/v7.1.3/ectocore_v7.1.3_low_latency.uf2) | [v7.1.3](https://github.com/schollz/_core/releases/download/v7.1.3/ectocore_v7.1.3_ultralow_latency.uf2) |
110+
| Non-Overclocking | [v7.1.3](https://github.com/schollz/_core/releases/download/v7.1.3/ectocore_v7.1.3_no_overclocking.uf2) | [v7.1.3](https://github.com/schollz/_core/releases/download/v7.1.3/ectocore_v7.1.3_no_overclocking_low_latency.uf2) | [v7.1.3](https://github.com/schollz/_core/releases/download/v7.1.3/ectocore_v7.1.3_no_overclocking_ultralow_latency.uf2) |
111111

112112

113113
### diy

core/src/server/server.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ func handle(w http.ResponseWriter, r *http.Request) (err error) {
194194
w.Header().Set("Access-Control-Allow-Methods", "POST, GET, OPTIONS, PUT, DELETE")
195195
w.Header().Set("Access-Control-Allow-Headers", "Accept, Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization")
196196

197-
b, _ := json.Marshal(map[string]string{"version": "v7.1.2"})
197+
b, _ := json.Marshal(map[string]string{"version": "v7.1.3"})
198198
w.Write(b)
199199
return nil
200200
} else if r.URL.Path == "/ws" {
@@ -287,7 +287,7 @@ func handle(w http.ResponseWriter, r *http.Request) (err error) {
287287
GenURL2 string
288288
}{
289289
IsMain: r.URL.Path == "/",
290-
VersionCurrent: "v7.1.2",
290+
VersionCurrent: "v7.1.3",
291291
LatestVersion: latestTag,
292292
GenURL1: codename.Generate(rng, 0),
293293
GenURL2: names.Random(),

core/src/server/static/app.js

Lines changed: 23 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -382,6 +382,10 @@ const socketMessageListener = (e) => {
382382
app.banks[app.selectedBank].files[app.selectedFile].Transients,
383383
);
384384
}, 100);
385+
} else if (data.action == "slicetype") {
386+
if (app.selectedBank != null && app.selectedFile != null) {
387+
app.banks[app.selectedBank].files[app.selectedFile].SliceType = data.sliceType;
388+
}
385389
} else if (data.action == "progress") {
386390
// totalBytesUploaded = data.number;
387391
// var maxWidth = window.innerWidth;
@@ -620,27 +624,40 @@ app = new Vue({
620624
this.addTransient(2, seconds);
621625
}
622626
},
627+
syncTransient(lane, index, value) {
628+
this.banks[this.selectedBank].files[this.selectedFile].Transients[lane][index] = value;
629+
if (socket != null) {
630+
socket.send(JSON.stringify({
631+
action: "settransient",
632+
filename: this.banks[this.selectedBank].files[this.selectedFile].Filename,
633+
i: lane,
634+
j: index,
635+
n: value,
636+
}));
637+
}
638+
},
623639
addTransient(j, seconds) {
624-
// TODO
625640
for (var i = 0; i < this.banks[this.selectedBank].files[this.selectedFile].Transients[j].length; i++) {
626641
if (this.banks[this.selectedBank].files[this.selectedFile].Transients[j][i] == 0) {
627-
this.banks[this.selectedBank].files[this.selectedFile].Transients[j][i] = Math.round(seconds * 44100.0);
642+
this.syncTransient(j, i, Math.round(seconds * 44100.0));
628643
break;
629644
}
630645
}
631646
this.drawTransients();
632647
},
633648
clearTransients(j) {
634649
for (var i = 0; i < this.banks[this.selectedBank].files[this.selectedFile].Transients[j].length; i++) {
635-
this.banks[this.selectedBank].files[this.selectedFile].Transients[j][i] = 0;
650+
if (this.banks[this.selectedBank].files[this.selectedFile].Transients[j][i] != 0) {
651+
this.syncTransient(j, i, 0);
652+
}
636653
}
637654
this.drawTransients();
638655
},
639656
clearTransientsLast(j) {
640657
for (var i = 0; i < this.banks[this.selectedBank].files[this.selectedFile].Transients[j].length; i++) {
641658
if (this.banks[this.selectedBank].files[this.selectedFile].Transients[j][i] == 0) {
642-
if (i > 0) {
643-
this.banks[this.selectedBank].files[this.selectedFile].Transients[j][i - 1] = 0;
659+
if (i > 0 && this.banks[this.selectedBank].files[this.selectedFile].Transients[j][i - 1] != 0) {
660+
this.syncTransient(j, i - 1, 0);
644661
}
645662
break;
646663
}
@@ -1838,4 +1855,4 @@ window.addEventListener('load', (event) => {
18381855
}, 1000);
18391856

18401857

1841-
});
1858+
});

core/src/server/static/index.html

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1226,7 +1226,11 @@ <h2>Changes to the Cookie Policy</h2>
12261226
// Get the grimoire element
12271227
const grimoireElement = document.getElementById('grimoire' + grimoireIndex);
12281228
if (grimoireElement) {
1229-
const svgClone = grimoireElement.querySelector('svg').cloneNode(true);
1229+
const sourceSvg = grimoireElement.querySelector('svg');
1230+
if (!sourceSvg) {
1231+
return;
1232+
}
1233+
const svgClone = sourceSvg.cloneNode(true);
12301234
svgClone.setAttribute('width', '32');
12311235
svgClone.setAttribute('height', '32');
12321236
// Change stroke color to white - set on SVG element so inherit works

docs/content/blurbs/source-code.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ weight = 12
88

99
Periodically, new firmwares are released with updated effects or improved performance. If you have the tool installed, you can connect your device to your computer and automatically update the firmware. You can also download the latest release directly from this link:
1010

11-
### Latest firmware: **[zeptocore v7.1.2](https://github.com/schollz/_core/releases/download/v7.1.2/zeptocore_v7.1.2.uf2)**
11+
### Latest firmware: **[zeptocore v7.1.3](https://github.com/schollz/_core/releases/download/v7.1.3/zeptocore_v7.1.3.uf2)**
1212

1313
## Instructions
1414

@@ -17,7 +17,7 @@ To update your zeptocore to the latest version, follow these steps:
1717
1. Connect a USB-C cable to the device and hold the `BOOTSEL` button (located near the USB-C jack).
1818
2. While holding the `BOOTSEL` button, press the `NRST` button (also near the USB-C jack).
1919
3. After a few seconds, a new drive named `RPI-RP2` should appear on your computer.
20-
4. Drag and drop the downloaded **zeptocore_v7.1.2.uf2** file onto the `RPI-RP2` drive.
20+
4. Drag and drop the downloaded **zeptocore_v7.1.3.uf2** file onto the `RPI-RP2` drive.
2121
5. Wait momentarily for the drive to disappear, indicating the update is complete, and the device will turn on automatically.
2222

2323

@@ -30,7 +30,7 @@ To update your zeptocore to the latest version, follow these steps:
3030

3131
Congratulations, your zeptocore has been successfully updated to the latest version.
3232

33-
(_Note:_ If using [zeptoboard](#zeptoboard), follow the same instructions but ensure you download the latest [zeptoboard_v7.1.2.uf2](https://github.com/schollz/_core/releases/download/v7.1.2/zeptoboard_v7.1.2.uf2)).
33+
(_Note:_ If using [zeptoboard](#zeptoboard), follow the same instructions but ensure you download the latest [zeptoboard_v7.1.3.uf2](https://github.com/schollz/_core/releases/download/v7.1.3/zeptoboard_v7.1.3.uf2)).
3434

3535
### Tool uploader
3636

docs/content/blurbs/uploading-samples.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Uploading samples is a straightforward process similar to transferring a file on
1111
The sample tool is required for the sample preprocessing step, before transferring the samples to the SD card. This tool can be [accessed online](/tool) or [downloaded to your computer](#download-to-use-tool-offline) for local use.
1212

1313

14-
### Use tool online: **[zeptocore v7.1.2](/tool)** (Chrome and Firefox only)
14+
### Use tool online: **[zeptocore v7.1.3](/tool)** (Chrome and Firefox only)
1515

1616

1717
<p style="text-align:center">
@@ -48,7 +48,7 @@ Each of those **bankX** folders contains all the nessecary audio files. The **ba
4848

4949
<details><summary>Windows</summary>
5050

51-
#### Download for Windows: **[x64](https://github.com/schollz/_core/releases/download/v7.1.2/core_windows_v7.1.2.exe)**
51+
#### Download for Windows: **[x64](https://github.com/schollz/_core/releases/download/v7.1.3/core_windows_v7.1.3.exe)**
5252

5353
Once downloaded, double click on the executable file to run it.
5454

@@ -62,13 +62,13 @@ To install the tool on macOS, first open a terminal.
6262
Then, if you are on an Intel-based mac install with:
6363

6464
```
65-
curl -L https://github.com/schollz/_core/releases/download/v7.1.2/core_macos_amd64_v7.1.2 > core_macos
65+
curl -L https://github.com/schollz/_core/releases/download/v7.1.3/core_macos_amd64_v7.1.3 > core_macos
6666
```
6767

6868
Or, if you are on a M1/M2-based mac install with:
6969

7070
```
71-
curl -L https://github.com/schollz/_core/releases/download/v7.1.2/core_macos_aarch64_v7.1.2 > core_macos
71+
curl -L https://github.com/schollz/_core/releases/download/v7.1.3/core_macos_aarch64_v7.1.3 > core_macos
7272
```
7373

7474
Then to enable the program do:
@@ -91,7 +91,7 @@ A window should pop up in the browser with the offline version of the tool.
9191

9292
<details><summary>Linux</summary>
9393

94-
#### Download for Linux: **[x64](https://github.com/schollz/_core/releases/download/v7.1.2/core_linux_amd64_v7.1.2)**
94+
#### Download for Linux: **[x64](https://github.com/schollz/_core/releases/download/v7.1.3/core_linux_amd64_v7.1.3)**
9595

9696
After downloading, run it directly from the terminal.
9797

docs/themes/zeptocore/layouts/_default/baseof.html

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,16 @@
3333
<div class="hero-inner hero-title">
3434
<p><strong>zeptocore</strong></p>
3535
<p><img src="/img/zepto3.webp"></p>
36-
<!-- <p class="hero-small"><a href="#changelog" style="text-decoration: none;color:inherit;">v7.1.2</a></p> -->
36+
<!-- <p class="hero-small"><a href="#changelog" style="text-decoration: none;color:inherit;">v7.1.3</a></p> -->
3737
<!-- <p class="hero-small">boundless beats in a finite footprint.</p> -->
3838
<p class="hero-small" style="margin-bottom: 1em;">a handmade, handheld sample player.</p>
3939
<p class="hero-small"><a class="buybutton" href="#buy">buy</a></p>
4040
</div>
4141
</div>
4242
<div class="sticky-banner">
4343
<a href="#buy">zeptocore is here.</a>
44-
<!-- <a href="https://github.com/schollz/_core/releases/download/v7.1.2/zeptocore_v7.1.2.uf2">click here to download the
45-
latest zeptocore firmware v7.1.2.</a> -->
44+
<!-- <a href="https://github.com/schollz/_core/releases/download/v7.1.3/zeptocore_v7.1.3.uf2">click here to download the
45+
latest zeptocore firmware v7.1.3.</a> -->
4646
</div>
4747
<!-- make a sticky menu on the left side -->
4848
<div class="sticky-menu fade-out">
@@ -102,7 +102,7 @@
102102
guide</a>
103103
</div>
104104
<div class="sticky-item">
105-
<a href="https://github.com/schollz/_core/releases/download/v7.1.2/zeptocore_v7.1.2.uf2">
105+
<a href="https://github.com/schollz/_core/releases/download/v7.1.3/zeptocore_v7.1.3.uf2">
106106
<i class="fas fa-download" aria-hidden="true"></i>
107107
Firmware
108108
</a>
@@ -375,7 +375,7 @@ <h2 id="effect-list" style="padding-left:0.75em;">Effect list</h2>
375375
</section>
376376
<footer>
377377
<div class="footer-inner">
378-
<p>zeptocore v7.1.2</p>
378+
<p>zeptocore v7.1.3</p>
379379
<p>© 2023-2024 <a href="https://infinitedigits.co">infinitedigits.co</a></p>
380380
</div>
381381
</footer>

lib/ectocore.h

Lines changed: 95 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,51 @@ void update_gpios_for_mode() {
112112
}
113113
}
114114

115+
#define ECTO_LOOP_START_TRANSIENT_MAX 28
116+
#define ECTO_LOOP_START_TRIG_DUP_SUPPRESS_MS 8
117+
118+
int8_t ecto_trigger_mode_to_transient_lane(uint8_t trigger_mode) {
119+
switch (trigger_mode) {
120+
case TRIGGER_MODE_KICK:
121+
return 0;
122+
case TRIGGER_MODE_SNARE:
123+
return 1;
124+
case TRIGGER_MODE_HH:
125+
return 2;
126+
default:
127+
return -1;
128+
}
129+
}
130+
131+
bool ecto_selected_mode_has_loop_start_transient(uint8_t trigger_mode,
132+
SampleInfo *sample_info) {
133+
int8_t lane = ecto_trigger_mode_to_transient_lane(trigger_mode);
134+
if (lane < 0 || sample_info == NULL || sample_info->transients == NULL) {
135+
return false;
136+
}
137+
138+
uint16_t transient_num = 0;
139+
if (lane == 0) {
140+
transient_num = sample_info->transient_num_1;
141+
} else if (lane == 1) {
142+
transient_num = sample_info->transient_num_2;
143+
} else if (lane == 2) {
144+
transient_num = sample_info->transient_num_3;
145+
}
146+
if (transient_num == 0 || transient_num > 16 ||
147+
sample_info->transients[lane] == NULL) {
148+
return false;
149+
}
150+
151+
for (uint16_t i = 0; i < transient_num; i++) {
152+
uint16_t transient_pos = sample_info->transients[lane][i];
153+
if (transient_pos > 0 && transient_pos <= ECTO_LOOP_START_TRANSIENT_MAX) {
154+
return true;
155+
}
156+
}
157+
return false;
158+
}
159+
115160
void ws2812_wheel_clear(WS2812 *ws2812) {
116161
debounce_ws2812_set_wheel = debounce_ws2812_set_wheel_time;
117162
for (uint8_t i = 0; i < 16; i++) {
@@ -668,6 +713,9 @@ void __not_in_flash_func(input_handling)() {
668713

669714
int cv_amen_last_value = 0;
670715
uint8_t knob_selector = 0;
716+
uint8_t last_slice_for_loopstart_trig = 255;
717+
uint8_t last_slice_num_for_loopstart_trig = 0;
718+
bool was_playback_stopped_for_loopstart_trig = true;
671719

672720
while (1) {
673721
#ifdef INCLUDE_MIDI
@@ -1039,7 +1087,7 @@ void __not_in_flash_func(input_handling)() {
10391087
int char_input = getchar_timeout_us(10);
10401088
if (char_input >= 0) {
10411089
if (char_input == 118) {
1042-
printf("version=v7.1.2\n");
1090+
printf("version=v7.1.3\n");
10431091
}
10441092
}
10451093

@@ -1740,6 +1788,52 @@ void __not_in_flash_func(input_handling)() {
17401788
}
17411789
}
17421790

1791+
// Fallback trig at playback start or strict loop wrap when a selected
1792+
// mode has a transient at the beginning of the file.
1793+
{
1794+
SampleInfo *sample_info =
1795+
banks[sel_bank_cur]->sample[sel_sample_cur].snd[FILEZERO];
1796+
uint8_t current_slice = sample_info->slice_current;
1797+
uint8_t slice_num = sample_info->slice_num;
1798+
bool playback_started_now =
1799+
was_playback_stopped_for_loopstart_trig && !playback_stopped;
1800+
bool strict_loop_wrap = false;
1801+
1802+
if (slice_num > 0 && last_slice_num_for_loopstart_trig == slice_num &&
1803+
current_slice < slice_num &&
1804+
last_slice_for_loopstart_trig < slice_num) {
1805+
strict_loop_wrap =
1806+
(last_slice_for_loopstart_trig == slice_num - 1) &&
1807+
(current_slice == 0);
1808+
}
1809+
1810+
if (!playback_stopped && slice_num > 0 &&
1811+
(playback_started_now || strict_loop_wrap) &&
1812+
ecto_selected_mode_has_loop_start_transient(ectocore_trigger_mode,
1813+
sample_info)) {
1814+
if (ecto_trig_out_last == 0 ||
1815+
current_time - ecto_trig_out_last >
1816+
ECTO_LOOP_START_TRIG_DUP_SUPPRESS_MS) {
1817+
int32_t sample_pos = 0;
1818+
if (sample_info->slice_start != NULL && current_slice < slice_num) {
1819+
sample_pos = sample_info->slice_start[current_slice];
1820+
}
1821+
ecto_emit_trigger_with_log(playback_started_now ? "loop-start"
1822+
: "loop-wrap",
1823+
sample_pos);
1824+
}
1825+
}
1826+
1827+
if (slice_num > 0 && current_slice < slice_num) {
1828+
last_slice_for_loopstart_trig = current_slice;
1829+
last_slice_num_for_loopstart_trig = slice_num;
1830+
} else {
1831+
last_slice_for_loopstart_trig = 255;
1832+
last_slice_num_for_loopstart_trig = 0;
1833+
}
1834+
was_playback_stopped_for_loopstart_trig = playback_stopped;
1835+
}
1836+
17431837
// Check for planned retrig activation on slice change
17441838
// Check on any slice, schedule to start on next slice
17451839
{

0 commit comments

Comments
 (0)