^^ crow: druid scripts

OK thanks all for detailed and thoughtful info as always. It seems I was on an older dev version of druid, I’ve updated to druid, version 0.2.1. crow is ^^version(‘v1.0.1’).

With this config, If I upload the script without the final carriage return, I get:

[string "eval"]:13: 'end' expected (to close 'function' at line 11) near <eof>

If i add the final carriage return, the script loads successfully, but only after I run ^^c.

on another note - in the below updated script, only input[2] streams to druid, how can i make input[1] stream to druid and the outputs?

--- simple buff mult. put a voltage into input 1, stream the value to druid and send voltage to all outputs
-- in1: tuning voltage
-- out1-4: duplicates of in1 voltage

input[1].stream = function(v)
	for n=1,4 do
    output[n].volts = v -- because v == input[1].volts
  end
end

function init()
	input[1].mode('stream', 0.01)
	input[2].mode('stream', 0.01)
end

anyway. this works pretty well for what I wanted to do - compare v/oct tuning between various oscillators.

Thanks for the details! I’ll try and reproduce again. Which OS are you running? To clarify, when you say “add the final carriage return” does that mean you’ve added a blank line at the end of your text file?

re: streaming to druid
This works by using the default event for input[n].stream. When you redefine input[1].stream that stops sending the value to druid, instead using the value in your script. You can work around this by adding the default action from the input library to your event:

input[1].stream = function(v)
  crow.tell('stream',1,v) -- sends the voltage to druid
  for n=1,4 do
    output[n].volts = v -- because v == input[1].volts
  end
end

Or you could use a metro instead and leave the input event untouched:

function set_outs()
  for n=1,4 do
    output[n].volts = input[1].volts -- need to query the input lib again
  end
end

function init()
  input[1].mode('stream', 0.01)
  input[2].mode('stream', 0.01)
  m = metro.init(set_outs, 0.01)
  m:start()
end
2 Likes

:slight_smile: I’m on window 10. Yes - I’ve added the final blank line.

image

Thanks for stream details.

1 Like

— generate a chord from a single input
– in1: gate in
– in2: chord root quantized to v/oct
– out1-4: chord degrees

edit: updated with chords from https://medium.com/music-thing-modular-notes/chord-organ-the-easiest-way-to-get-simple-chords-from-a-modular-synth-2f48684fdb9a

chord.lua (1.3 KB)

11 Likes

I’ve not tried it yet but I’m reading through the Boids script and it’s blowing my mind. This module is so exciting.

I was messing around making a Krell patch (I’ll share that later…) where I wanted some more control over the weight of the randomness than a simple exponential curve. I figured other people might find the curve function useful so I put together a simple example script. In addition to the min/max value settings, the method has three parameters that control how the randomness is weighted, each an integer value 1 -6:

  • curveLevel - higher values make a steeper curve favoring one end
  • bellFactor - higher values focus the curve more sharply in the middle
  • direction - which end the curve favors - up or down

Here’s a chart that will hopefully help make sense out of how the curveLevel and bellFactor interact.

Click to see chart


Here’s the example script. It doesn’t do anything interesting, it just has a metro sending random voltage out of output 1 based on the settings. Connect output 1 to an oscillators pitch and you can hear how the curve sounds as you adjust the values (curveLevel, bellFactor, and curveDirection) via druid.

curvedrandom.lua (1.1 KB)

6 Likes

I made another little utility. I’m always finding myself befuddled about the CV range a given input wants to see. The main function of this script is to take CV into input 1 OR input 2 and scale it out the outputs.

  • If it sees voltage at input 1, it sends a separately scaled voltage out each output
  • If it sees voltage in input 2, it sends the same scaled voltage out of every output

You can also send it a message in order to just send an arbitrary fixed voltage out each of the outputs, or a different fixed voltage out of each.

Hopefully the comments in the script will make usage clear. Let me know if something doesn’t make sense.

vults.lua (3.1 KB)

7 Likes

Hey,

I’m not lua or music theory wiz, but i think the major chord should be {0, 4, 7, -12} (or if 0 doesn’t work {1, 5, 8, -11}).

So all the starting notes (or following notes) are off by 1.

Ah yes I think that is correct. Heh. I’ll have another look, thanks! Haven’t had time to look at crow in the last few weeks, must get back to it.

Here’s my take on the Krell patch. If you are unfamiliar with this idea, find info here:

https://learningmodular.com/glossary/krell-patch/

My Crow version outputs envelope and pitch plus two other user selectable CV values. I hope that between the comments in the script and the sensibly (?) named variables, the use of this patch should be fairly clear (though perhaps not simple…but if we have to wait for me to write a more thorough manual, we’re all going to grow old and die). Of course, feel free to ask questions if anything is unclear.

krowll.lua (4.9 KB)

Here’s an example of the patch in use:

11 Likes

I’ve been working on this script off and on and wanted to share something I thought might be useful to others.

Here’s the script: jfInt.lua (1.3 KB)

In short it plays notes from an array of arrays using integers for rhythmic information.

All the variables used for incrementing live in single-entry arrays because Lua passes arrays by reference (and passes numbers/strings by value), which is useful for maintaining global state while also allowing me to cut down the amount of repeated code.

6 Likes

Hey :wave:

I’m looking for ideas on how to write a burst generator that would automatically calculate incoming clock before delivering bursts - basically, I don’t want to specify a “BPM” value for my script to work. I guess there are different possible strategies, but maybe you guys have hands on experience on something like this?

More generally, I’d love to read more code around timing events and using metros :v:

Also, posted in another Crow channel:

2 Likes
last_tick = time()
bpm = 0

function init()
  input[1].mode('change',3.0,0.1,'rising')
  metro[1].time = 1 
  metro[1]:start()
  metro[1].event = function(c) print(string.format("metro[1] bpm: %d", math.floor(bpm))) end
end

input[1].change = function(state)
  local elapsed = time() - last_tick
  bpm = 60000/elapsed
  metro[1].time = elapsed * 0.001
  last_tick = time()
end

That will take an incoming clock and adjust a metronome to be set to the rate of the incoming clock. Then you could just take that metro and fire on every X events to divide or whatever, have another metronome set to be a multiple of it to multiply… Gives you BPM as well if you want to do something with BPM within a range or whatever…

I don’t know if updating the metro speed that often has any drawbacks but it seems to work ok for me.

Actually in the first post Voidstar’s modes.lua sets up his ms-interval checking by calculating a running average of the last 2 numbers cumulatively to smooth out tempo changes that’s a good way to do it.

1 Like

Does anyone have any ii specific Just Friends druid scripts they could post? Just hooked up my crow and JF via i2c and interested to start testing things out!

1 Like

Blame it on the lack of time I had yesterday, but I found the shift register script with jf ii built in and it’s working great!

I’m a complete coding noob, but excited to have more ammo for my dangerous copy and paste skills.

1 Like

This is exactly what I’ve been wanting. Does it work like the qubit chord auto harmozing?

it works at a basic level, but it’s not very musical, and could do with some work to make it more functional. Also I never got round to updating or testing what the chord voicing should be. @Taubaland above suggested some changes about to how to voice chords, but really this needs a bit of work to make it useful.

is there a detailed description somewhere about how the qubit module works?

Hey @forrest thanks a ton for the code and pointers to @voidstar’s script. I tried something in that vein on my side here (in JS…): https://github.com/hypervillain/crow/blob/master/kompass/burst.js#L44 (with some burst related code if anyone is interested).

I’ll definitely use metros like you do when luafying my code :v:

1 Like

Ah ok, I tried to add JF to the code but couldn’t work it out. Hopefully this could be added as I would love to replace my chord v2 with JF if it could play the correct chord voicing and quality. There is some fantastic information on chord quality and voicing at the back of both manuals for chord and chord v2. You could use those to get all the info you need.

I can try and help with adding JF but my coding skills are super basic.

my skills are rudimentary too :slight_smile: I’ve updated my original post with a slightly updated version that uses chords as set in the music thing chord organ module.