Skip to content
This repository was archived by the owner on Nov 23, 2023. It is now read-only.

Commit f0b9778

Browse files
committed
fix bela examples
1 parent 0bf8230 commit f0b9778

File tree

4 files changed

+11
-11
lines changed

4 files changed

+11
-11
lines changed

examples/bela/cpp/cpp-osc-arrays/render.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ int writePointer = 0;
2222
int packetsSent = 0;
2323
int gAudioFramesPerAnalogFrame = 0;
2424

25-
void on_receive(oscpkt::Message* msg, void* arg) {
25+
void onReceive(oscpkt::Message* msg, const char* addr, void* arg) {
2626
if(msg->match("/bela")) {
2727
auto argReader = msg->match("/bela");
2828
for (int i=0; i<OUT_CHANNELS * OSC_PACKET_LEN; i++)

examples/bela/cpp/cpp-osc-gui-sliders/render.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,19 +22,19 @@ const int remotePort = 7563;
2222

2323
unsigned int gPitchSliderIdx;
2424
unsigned int gAmplitudeSliderIdx;
25-
int gPitch = 60;
25+
float gPitch = 60.0;
2626
float gAmplitude = 0.1;
2727

28-
void onReceive(oscpkt::Message* msg, void* arg) {
28+
void onReceive(oscpkt::Message* msg, const char* addr, void* arg) {
2929

3030
if (msg->match("/pitch")) {
3131

32-
int pitch;
33-
msg->match("/pitch").popInt32(pitch).isOkNoMoreArgs();
32+
float pitch;
33+
msg->match("/pitch").popFloat(pitch).isOkNoMoreArgs();
3434
if (gPitch != pitch) {
3535
gPitch = pitch;
3636
controller.setSliderValue(gPitchSliderIdx, gPitch);
37-
printf("Pitch %i\n", gPitch);
37+
printf("Pitch %f\n", gPitch);
3838
}
3939

4040
} else if (msg->match("/amplitude")) {
@@ -75,7 +75,7 @@ bool setup(BelaContext *context, void *userData)
7575
void render(BelaContext *context, void *userData)
7676
{
7777
// Access the sliders specifying the index we obtained when creating then
78-
int pitch = (int) controller.getSliderValue(gPitchSliderIdx);
78+
float pitch = controller.getSliderValue(gPitchSliderIdx);
7979
float amplitude = controller.getSliderValue(gAmplitudeSliderIdx);
8080
if (gPitch != pitch) {
8181
gPitch = pitch;

examples/bela/cpp/cpp-osc-gui-sliders/server.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,13 @@ def main(host="192.168.7.1", port=7563, verbose=False):
1414
osc = OSC(host, port)
1515
osc.create_client("bela", host="192.168.7.2", port=7562)
1616

17-
pitch = { "val": 60, "min": 48, "max": 84, "step": 1 }
17+
pitch = { "val": 60.0, "min": 48, "max": 84, "step": 4 }
1818
amplitude = { "val": 0.1, "min": 0.0, "max": 0.5, "step": 0.01 }
1919

2020
@osc.args("/pitch")
2121
def _(address, *args):
2222
print(f"Received pitch", args)
23-
pitch['val'] = int(args[0])
23+
pitch['val'] = args[0]
2424

2525
@osc.args("/amplitude")
2626
def _(address, *args):
@@ -34,7 +34,7 @@ def _():
3434

3535
if coin_flip[0]==True:
3636
step = np.random.randint(-pitch['step'], pitch['step']+1)
37-
pitch['val'] = int(constrain(pitch['val'] + step, pitch['min'], pitch['max']))
37+
pitch['val'] = constrain(pitch['val'] + step, pitch['min'], pitch['max'])
3838
osc("bela", "/pitch", pitch['val'])
3939

4040
elif coin_flip[1]==True:

examples/bela/cpp/cpp-osc-resonator/render.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ const int localPort = 7562;
1010
Resonator res;
1111
ResonatorOptions options; // will initialise to default
1212

13-
void onReceive(oscpkt::Message* msg, void* arg) {
13+
void onReceive(oscpkt::Message* msg, const char* addr, void* arg) {
1414

1515
if(msg->match("/resonator")) {
1616
float freq, gain, decay;

0 commit comments

Comments
 (0)