the script module takes python code as input. any python code and imports should work fine. this document describes the specific calls you get from bespoke and can make into bespoke.

script module inputs:
   on_pulse(): called by pulse input
   on_note(pitch, velocity): called by note input
   on_grid_button(col, row, velocity): called by grid input


globals:
   bespoke.get_measure_time()
   bespoke.get_measure()
   bespoke.reset_transport(rewind_amount)
      optional: rewind_amount=.001f
   bespoke.get_step(subdivision)
   bespoke.count_per_measure(subdivision)
   bespoke.time_until_subdivision(subdivision)
      example: me.schedule_call(bespoke.time_until_subdivision(1), "on_downbeat()")
   bespoke.get_time_sig_ratio()
   bespoke.get_root()
   bespoke.get_scale()
   bespoke.get_scale_range(octave, count)
   bespoke.tone_to_pitch(index)
   bespoke.name_to_pitch(noteName)
   bespoke.pitch_to_name(pitch)
   bespoke.pitch_to_freq(pitch)
   bespoke.get_tempo()
   bespoke.set_background_text(text, size, red, green, blue)
      optional: size=50, red = 1, green = 1, blue = 1


script-relative:
   me.play_note(pitch, velocity, length, pan, output_index)
      optional: length=1.0/16.0, pan = 0, output_index = 0
      example: me.play_note(60, 127, 1.0/8)
   me.schedule_note(delay, pitch, velocity, length, pan, output_index)
      optional: length=1.0/16.0, pan = 0, output_index = 0
      example: me.schedule_note(1.0/4, 60, 127, 1.0/8)
   me.schedule_note_msg(delay, pitch, velocity, pan, output_index)
      optional: pan = 0, output_index = 0
   me.schedule_call(delay, method)
      example: me.schedule_call(1.0/4, "dotask()")
   me.note_msg(pitch, velocity, pan, output_index)
      optional: pan = 0, output_index = 0
   me.set(path, value)
      example: me.set("oscillator~pw", .2)
   me.schedule_set(delay, path, value)
   me.get(path)
      example: pulsewidth = me.get("oscillator~pulsewidth")
   me.adjust(path, amount)
   me.highlight_line(lineNum, scriptModuleIndex)
   me.output(obj)
      example: me.output("hello world!")
   me.me()
   me.stop()
   me.get_caller()
      example: me.get_caller().play_note(60,127)
   me.set_num_note_outputs(num)
   me.connect_osc_input(port)


import notesequencer
   static:
      notesequencer.get(path)
   instance:
      n.set_step(step, pitch, velocity, length)


import drumsequencer
   static:
      drumsequencer.get(path)
   instance:
      d.set(step, pitch, velocity)
      d.get(step, pitch)


import grid
   static:
      grid.get(path)
         example: g = grid.get("grid")  #assuming there's a grid called "grid" somewhere in the layout
   instance:
      g.set(col, row, value)
      g.get(col, row)
      g.set_grid(cols, rows)
      g.set_label(row, label)
      g.set_color(colorIndex, r, g, b)
      g.highlight_cell(col, row, delay, duration, colorIndex)
         optional: colorIndex=1
      g.set_division(division)
      g.set_momentary(momentary)
      g.set_cell_color(col, row, colorIndex)
      g.get_cell_color(col, row)
      g.add_listener(script)
      g.clear()


import notecanvas
   static:
      notecanvas.get(path)
   instance:
      n.add_note(measurePos, pitch, velocity, length)
      n.clear()


import sampleplayer
   static:
      sampleplayer.get(path)
   instance:
      s.set_cue_point(pitch, startSeconds, lengthSeconds, speed)
      s.fill(data)
      s.play_cue(cue, speedMult, startOffsetSeconds)
         optional: speedMult = 1, startOffsetSeconds = 0


import midicontroller
   static:
      midicontroller.get(path)
   instance:
      m.set_connection(messageType, control, channel, controlPath)
      m.send_note(pitch, velocity, forceNoteOn, channel, page)
         optional: forceNoteOn = false, channel = -1, page = 0
      m.send_cc(ctl, value, channel, page)
         optional: channel = -1, page = 0
      m.send_pitchbend(bend, channel, page)
         optional: channel = -1, page = 0
      m.send_data(a, b, c, page)
         optional: page = 0
      m.add_script_listener(script)


import linnstrument
   static:
      linnstrument.get(path)
   instance:
      l.set_color(x, y, color)


import osccontroller
   static:
      osccontroller.get(path)
   instance:
      o.add_control(address, isFloat)


import oscoutput
   static:
      oscoutput.get(path)
   instance:
      o.send_float(address, val)
      o.send_int(address, val)
      o.send_string(address, val)


import module
   static:
      module.get(path)
      module.create(moduleType, x, y)
   instance:
      m.set_position(x, y)
      m.set_target(target)
      m.delete()
      m.set(path, value)
      m.get(path)
      m.adjust(path, amount)
