Trouble connecting Wekinator to SonicPi

I have written this simple exercise to introduce connecting the Wekinator machine learning modeling software to Sonic Pi. I believe I have successfully connected Wekinator to SonicPi. Wekinator is sending classification data to SonicPi, using the default path, and the data values are appearing in CUES. My coding does not appear to be reading the data values to then be used by the program. I am printing the value “c” so that I can better see what is going on. What am I missing here? Can anyone assist?

live_loop :classifier do
use_real_time
c = sync “/osc/wek/outputs”

if c = 2.0
sample :drum_heavy_kick
sleep 0.5
print c
else
play 89
sleep 0.25
print c
end

end

Euh what about put double ==to test in the if test instead = which is used to assign a value to a variable.

ps : to color your code, three back ticks as in markdown.

You need syntax
/osc*/wek/outputs
not
/osc/wek/outputs

Thanks for the suggestion. I agree that the program code is not properly accessing/seeing the values fed to CUES. I added the code you suggested but it’s still not working quite yet.

Publish your revisited code and we will try to help you.

@etusch - you are not quite syncing on the address correctly. See Robin’s reply :+1:

Hi @etusch

try this code :

use_osc "localhost", 4560

live_loop :send do
  osc "/foo", [2, 5].tick
  sleep 1
end

notes = (ring 45,47,48,52)

live_loop :osc_receiver do
  
  use_real_time
  c= sync "/osc*/foo"
  puts c
  if c[0] == 2
    sample :drum_heavy_kick
    print c
    
  else
    play 89
    print c
  end
  
  play notes.tick
end

I have tested on windows 10 with Beta 6.

Thank you to all who assisted me. I figured it out with the help of all of you. What a great community.
I am going to play with it a bit more and come back to post the final code. This will be presented to students working in a Machine Learning course.

Thanks all!

1 Like