Skip to content

Commit

Permalink
Merge pull request #227 from shorepine/reset-timebase
Browse files Browse the repository at this point in the history
  • Loading branch information
bwhitman authored Sep 30, 2024
2 parents 81f5af0 + 485a60f commit 826e3b0
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -215,7 +215,7 @@ Here's the full list:
| `r` | `voices` | int[,int] | Comma separated list of voices to send message to, or load patch into. |
| `R` | `resonance` | float | Q factor of variable filter, 0.5-16.0. default 0.7 |
| `s` | `pitch_bend` | float | Sets the global pitch bend, by default modifying all note frequencies by (fractional) octaves up or down |
| `S` | `reset` | uint | Resets given oscillator. set to > OSCS to reset all oscillators, gain and EQ. |
| `S` | `reset_osc` | uint | Resets given oscillator. set to RESET_ALL_OSCS to reset all oscillators, gain and EQ. RESET_TIMEBASE resets the clock. RESET_AMY restarts AMY.|
| `t` | `time` | uint | Request playback time relative to some fixed start point on your host, in ms. Allows precise future scheduling. |
| `T` | `eg0_type` | uint 0-3 | Type for Envelope Generator 0 - 0: Normal (RC-like) / 1: Linear / 2: DX7-style / 3: True exponential. |
| `u` | `store_patch` | number,string | Store up to 32 patches in RAM with ID number (1024-1055) and AMY message after a comma. Must be sent alone |
Expand Down
3 changes: 2 additions & 1 deletion amy.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
SINE, PULSE, SAW_DOWN, SAW_UP, TRIANGLE, NOISE, KS, PCM, ALGO, PARTIAL, PARTIALS, BYO_PARTIALS, CUSTOM, OFF = range(14)
FILTER_NONE, FILTER_LPF, FILTER_BPF, FILTER_HPF, FILTER_LPF24 = range(5)
ENVELOPE_NORMAL, ENVELOPE_LINEAR, ENVELOPE_DX7, ENVELOPE_TRUE_EXPONENTIAL = range(4)
RESET_ALL_OSCS, RESET_TIMEBASE, RESET_AMY = (8192, 16384, 32768)
AMY_LATENCY_MS = 0
AMY_MAX_DRIFT_MS = 20000

Expand Down Expand Up @@ -318,7 +319,7 @@ def reset(osc=None, **kwargs):
if(osc is not None):
send(reset=osc, **kwargs)
else:
send(reset=10000, **kwargs) # reset > AMY_OSCS resets all oscs
send(reset=RESET_ALL_OSCS, **kwargs)

def volume(volume, client = None):
send(client=client, volume=volume)
Expand Down
16 changes: 15 additions & 1 deletion src/amy.c
Original file line number Diff line number Diff line change
Expand Up @@ -1006,7 +1006,21 @@ void play_event(struct delta d) {
AMY_UNSET(synth[d.osc].chained_osc);
}
if(d.param == CLONE_OSC) { clone_osc(d.osc, *(int16_t *)&d.data); }
if(d.param == RESET_OSC) { if(*(int16_t *)&d.data>(AMY_OSCS+1)) { amy_reset_oscs(); } else { reset_osc(*(int16_t *)&d.data); } }
if(d.param == RESET_OSC) {
if(*(int16_t *)&d.data & RESET_AMY) {
amy_stop();
amy_start(amy_global.cores, amy_global.has_chorus, amy_global.has_reverb, amy_global.has_echo);
}
if(*(int16_t *)&d.data & RESET_TIMEBASE) {
amy_reset_sysclock();
}
if(*(int16_t *)&d.data & RESET_ALL_OSCS) {
amy_reset_oscs();
}
if(*(int16_t *)&d.data < AMY_OSCS+1) {
reset_osc(*(int16_t *)&d.data);
}
}
if(d.param == MOD_SOURCE) {
uint16_t mod_osc = *(uint16_t *)&d.data;
synth[d.osc].mod_source = mod_osc;
Expand Down
5 changes: 5 additions & 0 deletions src/amy.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,11 @@ enum coefs{
#define ENVELOPE_DX7 2
#define ENVELOPE_TRUE_EXPONENTIAL 3

// Reset masks
#define RESET_ALL_OSCS 8192
#define RESET_TIMEBASE 16384
#define RESET_AMY 32768


#define true 1
#define false 0
Expand Down
2 changes: 1 addition & 1 deletion src/examples.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ extern void delay_ms(uint32_t ms);
void example_reset(uint32_t start) {
struct event e = amy_default_event();
e.osc = 0;
e.reset_osc = 1000;
e.reset_osc = RESET_ALL_OSCS;
e.time = start;
amy_add_event(e);
}
Expand Down
1 change: 0 additions & 1 deletion test.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class AmyTest:

def __init__(self):
amy.restart()
amy.send(time=0) # Defeat "computed_delta" offset.

def test(self):

Expand Down

0 comments on commit 826e3b0

Please sign in to comment.