Skip to content

Commit

Permalink
Fixes #1066
Browse files Browse the repository at this point in the history
  • Loading branch information
aure committed Oct 13, 2017
1 parent 3cee9d9 commit ffefc97
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -34,11 +34,12 @@ class AKOperationGeneratorDSPKernel : public AKSoundpipeKernel, public AKOutputB

plumber_register(&pd);
plumber_init(&pd);
if (customUgens.size() > 0) {
addUgensToFTable(&pd);
}
pd.sp = sp;
if (sporthCode != nil) {
if (customUgens.size() == 0) {
plumber_parse_string(&pd, sporthCode);
}
plumber_parse_string(&pd, sporthCode);
plumber_compute(&pd, PLUMBER_INIT);
}

Expand All @@ -53,13 +54,11 @@ class AKOperationGeneratorDSPKernel : public AKSoundpipeKernel, public AKOutputB
sporthCode = (char *)malloc(length);
memcpy(sporthCode, sporth, length);
}
if (customUgens.size() > 0) {
plumber_recompile_string_v2(&pd, sporthCode, this, &addUgensToKernel);
}
}

void addUgensToFTable(plumber_data *pd) {
for (auto info : customUgens) {
info.name = "triggerFunction"; // This should stored and freed like sporthCode instead of being a constant
plumber_ftmap_add_function(pd, info.name, info.func, info.userData);
}
}
Expand Down
4 changes: 2 additions & 2 deletions AudioKit/Common/Nodes/Playback/Metronome/AKMetronome.swift
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

/// Metronome Callback Ugen
public let callbackUgen =
AKCustomUgen(name: "callback", argTypes: "f") { _, stack, userData in
AKCustomUgen(name: "triggerFunction", argTypes: "f") { _, stack, userData in
let trigger = stack.popFloat()
if trigger != 0 {
if let callback = userData as? AKCallback {
Expand Down Expand Up @@ -49,7 +49,7 @@ public class AKMetronome: AKOperationGenerator {
/// Initialize the metronome
public init() {

let sporth = "(0 p) bpm2rate metro (_callback f) dup 0.001 0.01 0.001 tenvx swap (1 p) 0 count dup 2 pset 0 eq (4 p) (3 p) branch 0.4 sine * dup"
let sporth = "(0 p) bpm2rate metro (_triggerFunction fe) dup 0.001 0.01 0.001 tenvx swap (1 p) 0 count dup 2 pset 0 eq (4 p) (3 p) branch 0.4 sine * dup"
callback = { return }
super.init(sporth: sporth, customUgens: [callbackUgen])
parameters = [tempo, Double(subdivision), -1, frequency1, frequency2]
Expand Down

0 comments on commit ffefc97

Please sign in to comment.