Variable vs integral param in to_sc.play_note

Hi,

Description:

I would like to send a scamp partition to supercollider in such a way that some parameters of the SC synth move (e.g. along a random path). But the “param_” option seems only to take integers or lists of integers as an input. Am I wrong? and ig not, is there a way out?

Here is a very simple python script (no random here, but the problem stays the same):

Error printout:

arpeggio.NoMatch: Expected ‘[’ or number at position (1, 15) => ‘m_mRatio: *t, param_c’.

#full code
from scamp import *
s = Session()
to_sc = s.new_osc_part(“FM”, port=57120)

def test():
t=1
while t <15:
to_sc.play_note(66, 1, 1, “param_mRatio: t, param_cRatio: 1”)
t = t+1

test()

if I write param_mRatio: 5 (or any number) it does work and gives 15 times the same sound

Sorry for the slow response! The problem is that you’re just including the letter t in the string, not the variable t.

Two options are:

  1. Use a dictionary:
    {“param_mRatio": t, “param_cRatio”: 1}

  2. Use a format string to insert the value(s):
    f“param_mRatio: {t}, param_cRatio: 1”

(By the way, I’m teaching a workshop this week on Computer-Assisted Music in Python, with scamp, and there are some scholarships available. Let me know if you might be interested!)

Hi,
thanks and no problem, I figured out myself and used the f" option.
I indeed would like to attend a workshop, but I need to find the right moment when I’ll have a bit of time. Do you already plan some session for July or August?
Looking forward!
Marcello