Skip to content

Commit

Permalink
Convert to v6 format and compatibility.
Browse files Browse the repository at this point in the history
  • Loading branch information
neilcsmith-net committed Aug 26, 2024
1 parent be7b456 commit 1efce93
Show file tree
Hide file tree
Showing 27 changed files with 595 additions and 643 deletions.
15 changes: 7 additions & 8 deletions Audio/mixer-6s.pxg
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
@ ./mixer-6s audio:custom {
#%graph.x 0
#%graph.y 0
.code "
.meta [map graph.x 0 graph.y 0]
.code {

@In(1) AudioIn in1l;
@In(2) AudioIn in1r;
Expand Down Expand Up @@ -36,7 +35,7 @@
@UGen Gain g1l,g1r,g2l,g2r,g3l,g3r,g4l,g4r,g5l,g5r,g6l,g6r;

@Override
public void setup() \{
public void init() {
link(
add(
link(in1l, g1l),
Expand All @@ -59,10 +58,10 @@
),
out2
);
\}
}

@Override
public void update() \{
public void update() {
g1l.level(mute1 ? 0 : level1);
g1r.level(mute1 ? 0 : level1);
g2l.level(mute2 ? 0 : level2);
Expand All @@ -75,6 +74,6 @@
g5r.level(mute5 ? 0 : level5);
g6l.level(mute6 ? 0 : level6);
g6r.level(mute6 ? 0 : level6);
\}
"
}
}
}
40 changes: 19 additions & 21 deletions Audio/mono-kit.pxg
Original file line number Diff line number Diff line change
@@ -1,22 +1,21 @@
@ ./mono-kit audio:custom {
#%graph.x 0
#%graph.y 0
.code "
.meta [map graph.x 0 graph.y 0]
.code {

@Out(1)
AudioOut out;

@P(1) @OnChange(\"updateTables\") @Config.Port(false)
@P(1) @OnChange("updateTables") @Config.Port(false)
AudioTable sample1;
@P(2) @OnChange(\"updateTables\") @Config.Port(false)
@P(2) @OnChange("updateTables") @Config.Port(false)
AudioTable sample2;
@P(3) @OnChange(\"updateTables\") @Config.Port(false)
@P(3) @OnChange("updateTables") @Config.Port(false)
AudioTable sample3;
@P(4) @OnChange(\"updateTables\") @Config.Port(false)
@P(4) @OnChange("updateTables") @Config.Port(false)
AudioTable sample4;
@P(5) @OnChange(\"updateTables\") @Config.Port(false)
@P(5) @OnChange("updateTables") @Config.Port(false)
AudioTable sample5;
@P(6) @OnChange(\"updateTables\") @Config.Port(false)
@P(6) @OnChange("updateTables") @Config.Port(false)
AudioTable sample6;

@T(1) Trigger play1;
Expand Down Expand Up @@ -45,7 +44,7 @@
Gain g1, g2, g3, g4, g5, g6;

@Override
public void setup() \{
public void init() {
updateTables();
link(
add(
Expand All @@ -66,23 +65,22 @@
play5.link(pl5::play);
play6.link(pl6::play);

level1.values().map(l -> l*l).link(g1::level);
level2.values().map(l -> l*l).link(g2::level);
level3.values().map(l -> l*l).link(g3::level);
level4.values().map(l -> l*l).link(g4::level);
level5.values().map(l -> l*l).link(g5::level);
level6.values().map(l -> l*l).link(g6::level);
\}
level1.doubles().map(l -> l*l).link(g1::level);
level2.doubles().map(l -> l*l).link(g2::level);
level3.doubles().map(l -> l*l).link(g3::level);
level4.doubles().map(l -> l*l).link(g4::level);
level5.doubles().map(l -> l*l).link(g5::level);
level6.doubles().map(l -> l*l).link(g6::level);
}

void updateTables() \{
void updateTables() {
pl1.table(sample1);
pl2.table(sample2);
pl3.table(sample3);
pl4.table(sample4);
pl5.table(sample5);
pl6.table(sample6);
\}
}

"
}

}
36 changes: 17 additions & 19 deletions Audio/synth-base.pxg
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
@ ./synth-base audio:custom {
#%graph.x 0
#%graph.y 0
.code "
.meta [map graph.x 0 graph.y 0]
.code {

@Out(1) AudioOut out;

Expand All @@ -15,35 +14,34 @@
@Inject Property envelope;

@Override
public void setup() \{
public void setup() {
osc.waveform(SINE);
link(osc, amp, out);
frequency.link(osc::frequency);
envelope.values().map(e -> e * e * gain).link(amp::level);
\}
envelope.doubles().map(e -> e * e * gain).link(amp::level);
}

@In(1) void note(String note) \{
if (note.isEmpty() || \"-\".equals(note)) \{
@In(1) void note(String note) {
if (note.isEmpty() || "-".equals(note)) {
return;
\}
}
int midi = noteToMidi(note);
if (midi > 0) \{
if (midi > 0) {
noteOn(midi);
\} else \{
} else {
noteOff();
\}
\}
}
}

void noteOn(int midi) \{
void noteOn(int midi) {
frequency.set(midiToFrequency(midi));
envelope.to(1).in(0.05);
\}
}

void noteOff() \{
void noteOff() {
envelope.to(0).in(0.2);
\}
}


"
}

}
54 changes: 26 additions & 28 deletions Audio/synth-duo-osc.pxg
Original file line number Diff line number Diff line change
@@ -1,20 +1,19 @@
@ ./duo-osc audio:custom {
#%graph.x 0
#%graph.y 0
.code "
.meta [map graph.x 0 graph.y 0]
.code {

final String SW = \"Saw\";
final String SQ = \"Square\";
final String SW = "Saw";
final String SQ = "Square";

@Out(1) AudioOut out;

@UGen Osc osc, osc2;
@UGen IIRFilter filter;
@UGen Gain amp;

@P(1) @Type.String(allowed = \{SW, SQ\})
@P(1) @Type.String(allowed = {SW, SQ})
Property waveform1;
@P(2) @Type.String(allowed = \{SW, SQ\})
@P(2) @Type.String(allowed = {SW, SQ})
Property waveform2;
@P(3) @Type.Number(min=0, max=1, def=1)
double level;
Expand Down Expand Up @@ -42,53 +41,52 @@
@Inject Property freq1, freq2, env;

@Override
public void setup() \{
public void init() {
link(add(osc, osc2), filter.type(IIRFilter.LP12), amp, out);

waveform1.valuesAs(Value::toString).map(w -> Waveform.valueOf(w)).link(osc::waveform);
waveform2.valuesAs(Value::toString).map(w -> Waveform.valueOf(w)).link(osc2::waveform);
freq1.link(osc::frequency);
freq2.link(osc2::frequency);
osc2Level.values().map(d -> d*d).link(osc2::gain);
osc2Level.doubles().map(d -> d*d).link(osc2::gain);
resonance.link(filter::resonance);

env.values().map(e -> \{
double hz = d(freq1);
env.doubles().map(e -> {
double hz = D(freq1);
hz = (e * hz * 7) + hz;
return (filterMod * hz) + ((1 - filterMod) * cutoff);
\}).link(filter::frequency);
}).link(filter::frequency);

env.values().map(e -> \{
env.doubles().map(e -> {
e = e < 0.001 ? 0 : (ampMod * e * e) + (1 - ampMod);
return e * level * level;
\}).link(amp::level);
}).link(amp::level);

\}
}

@In(1) void note(String note) \{
if (note.isEmpty() || \"-\".equals(note)) \{
@In(1) void note(String note) {
if (note.isEmpty() || "-".equals(note)) {
return;
\}
}
int midi = noteToMidi(note);
if (midi > 0) \{
if (midi > 0) {
noteOn(midi);
\} else \{
} else {
noteOff();
\}
\}
}
}

void noteOn(int midi) \{
void noteOn(int midi) {
double f = midiToFrequency(midi);
freq1.set(f);
double f2 = midiToFrequency(midi + osc2Transpose);
freq2.set(f2);
env.to(1,sustain).in(attack,decay);
\}
}

void noteOff() \{
void noteOff() {
env.to(0).in(release);
\}
}

"
}

}
40 changes: 19 additions & 21 deletions Audio/synth-pm3.pxg
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
@ ./pm-synth audio:custom {
#%graph.x 0
#%graph.y 0
.code "
.meta [map graph.x 0 graph.y 0]
.code {

@Out(1) AudioOut out;

Expand Down Expand Up @@ -37,42 +36,41 @@
@Inject Property frequency, modEnv, ampEnv;

@Override
public void setup() \{
public void init() {
car.waveform(SAW);
frequency.link(car::frequency);
ampEnv.link(d -> amp.level( (d * d) * level) );
lfoFrequency.link(lfo::frequency);
lfoLevel.link(lfo::gain);
link(car, modFn(add(mod, lfo), (m,c) -> sin( (m + c) * TWO_PI )), amp, out);
\}
}

@Override
public void update() \{
mod.frequency(modRatio * d(frequency)).gain(d(modEnv) * modLevel);
\}
public void update() {
mod.frequency(modRatio * D(frequency)).gain(D(modEnv) * modLevel);
}

@In(1) void note(String note) \{
if (note.isEmpty() || \"-\".equals(note)) \{
@In(1) void note(String note) {
if (note.isEmpty() || "-".equals(note)) {
return;
\}
}
int midi = noteToMidi(note);
if (midi > 0) \{
if (midi > 0) {
noteOn(midi);
\} else \{
} else {
noteOff();
\}
\}
}
}

void noteOn(int midi) \{
void noteOn(int midi) {
frequency.set(midiToFrequency(midi));
modEnv.to(1, modSustain).in(modAttack, modDecay);
ampEnv.to(1, sustain).in(attack, decay);
\}
}

void noteOff() \{
void noteOff() {
ampEnv.to(0).in(release);
\}
}

"
}

}
24 changes: 11 additions & 13 deletions Core/array-map.pxg
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#%praxis.version 5.0.0-beta-1
@ ./array-map core:custom {
#%graph.x 0
#%graph.y 0
.code "
.meta [map graph.x 0 graph.y 0]
.code {

@P(1) @Config.Port(false)
PArray values;
Expand All @@ -14,21 +12,21 @@
int lastIdx;

@Override
public void init() \{
public void init() {
lastIdx = -1;
in.link(this::mapValue);
\}
}

void mapValue(double value) \{
if (values.isEmpty()) \{
void mapValue(double value) {
if (values.isEmpty()) {
return;
\}
}
int idx = (int) (value * (values.size() - 1));
if (idx == lastIdx) \{
if (idx == lastIdx) {
return;
\}
}
lastIdx = idx;
out.send(values.get(idx));
\}
"
}
}
}
Loading

0 comments on commit 1efce93

Please sign in to comment.