I finally figured out how to get data from I2C devices! The getter functions trigger the associated event, and pass the gotten data along to it. So here’s my really crappy little script for pinging JF a synth mode note at the voltage of faderbank fader #1:

function init()
	output[2](bonk())
	ii.jf.mode(1)
end

ii.faders.event = function (e, data, id)
	ii.jf.play_note(data, 10)
	--crow.tell('fb', e, data, id)
end

function bonk()
	return loop{ function() ii.faders[1].get(1) end
				, to(5, 1)
				, to(0, 1)
				}
end

The getter function is happening as part of an ASL loop with a triangle LFO because I was practicing what Trent showed us yesterday on stream.

8 Likes

Oke so small storytime here :slight_smile:
I’m using a programmable midi extender for yarns where i have programmed in a “chord” mode origanaly for Rings. (midi device: https://forum.mutable-instruments.net/t/needles-1u-midi-controller-yarns-companion/12656) It’s basicly a chrod mode which strumms through the notes you hit. So something like: C smalldelaywithnothing E smalldelaywithnothing F smalldelay and then shut of because it’s the last note.

I loved this so much that i bought a Crow for it to make the same thing work with just friends (with added vibrato support from yarns :grin:) But now im looking to implement something on the geode side. Is there any idea to make geode like a playable thing?

For anyone who is interested in my code:

Code
-- JF with transpose and first combined

function delay(time, action)
   local dmetro = metro.init(devent, time, 1)
   local count = 0
   dmetro:start()
   function devent()
      count = count + 1
      if count == 2 then
         action()
         metro.free(dmetro.id)
      end
   end
end

length = {}
rhythm = {}
notes  = {}
step   = {}
bits   = {}
scale  = { {0,2,4,7,9}, {0,2,4,5,7,9,11} }
decay  = 0.4
attack = 2

function set_d(t) decay = (t-1)/8 + 0.05 end
function set_a(t) attack = (t-1)/64 + 0.003 end

function play(out,ix)
  if rhythm[ix][ step[ix] ] & 8 == 8 then
    if ix == 1 then set_d(t[ix]) else set_a(t[ix]) end
    t[ix] = 0
    output[out+1]()
  end
  if rhythm[ix+2][ step[ix+2] ] & 8 == 8 then
    n1 = notes[ix][ step[ix+2] ]
    n2 = notes[ix][ step[ix] ]
    abs = math.abs(input[2].volts)/5
    note = n1 + abs*(n2-n1)
    note = math.floor(note * (abs*3 + 0.1))
    s = scale[input[2].volts > -0.04 and 1 or 2]
    nn = s[ note%(#s) + 1 ]
    oct = math.floor(note/12)
    output[out].volts = nn/12 + oct
  end
  step[ix] = (step[ix] % length[ix]) + 1
  step[ix+2] = (step[ix+2] % length[ix+2]) + 1
end

sd = 0
function lcg(seed)
  local s = seed or sd
  sd = (1103515245*s + 12345) % (1<<31)
  return sd
end

function get_d() return decay end
function get_a() return attack end

t = {0,0}
function env(count)
  for i=1,2 do t[i] = t[i] + 1 end
end

function trans(count)
    transpose = input[2].volts - lastNote
    if (transpose > 0.008 or transpose < -0.008) then
        ii.jf.transpose(transpose - 2)
    else
        ii.jf.transpose(-2)
    end
end

input[1].change = function(s)
    getters()

    if speed > 0 and tsc == 1.0 then
        tmetro:start()
        ii.jf.mode(1)
        lastNote = input[2].volts
        noteCount = noteCount + 1
        delay( 0.003, function() ii.jf.play_note(input[2].volts,5) lastNote = input[2].volts end )
    elseif speed > 0 and noteCount > 5 then
        lastNote = input[2].volts
        delay( 0.003, function() ii.jf.play_note(input[2].volts,5) lastNote = input[2].volts end )
    else
        noteCount = 0
        ii.jf.mode(0)
        tmetro:stop()
    end

    play(1,1)
    play(3,2)
end

function getters()
    ii.jf.get('speed')
    ii.jf.get('tsc')

    ii.jf.event = function(e, value)
        if e.name == 'speed' then
            speed = value
        elseif e.name == 'tsc' then
            tsc = value
        end
    end
end

function init()
    getters()
    lastNote = 0
    noteCount = 0
    input[1].mode('change', 1, 0.1, 'rising')
      lcg(unique_id())
      lcg()
      lcg()
      lcg()

  for i=1,4 do
    length[i] = lcg()%19 + 6
    rhythm[i] = {}
    for n=1,32 do
      rhythm[i][n] = lcg()
    end
    step[i] = 1
  end

  -- notes
  for i=1,4 do
    notes[i] = {0}
    for n=1,31 do
      notes[i][n+1] = notes[i][n] + (lcg() % 7) -3
    end
  end

  -- out params
  output[1].slew   = 0
  output[1].volts  = 0
  output[2].action = ar(get_a,get_d)
  output[3].slew   = 0.01
  output[3].volts  = 0
  output[4].action = ar(get_a,get_d)

  -- start sequence!
  dec = metro.init{ event = env, time = 0.1 }
  dec:start()

  tmetro = metro.init{ event = trans, time = 0.03 }
end

Note the outputs acts as the First script so when you aren’t playing Just friends synth mode you can use the First script.

Is there a reason why i cant use the delay function when im using a metro function on the fm knob? i want to read out the fm knob position on just friends but once i’m playing the just friends in synth mode and turn the fm knob it’s getting really wonky. So not fm wonky but it sometimes hits 2 notes are all notes.

Yesterday I tried for the first time ^^JFsynth on Max for Live, but my JF hangs after a couple of notes sent from Ableton…
it could be the ii cable is too long (35cm)?
Or it’s something else?
Today I’ll try with Teletype&JF, let’s see what’ll happens…