-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Qscale library #452
base: main
Are you sure you want to change the base?
Qscale library #452
Conversation
ok there is an issue with input as a voltage. it's because we are assuming the note-table is always in 12TET, and the input is as well. consider there are 3 different scalings:
we have already handled all of the output scaling. when changing the nature of the note-table to just intonation, we use a helper function Currently unhandled is nTET note-tables. this could be via other helpers. could be indexed against If we do this, then the |
added some improvements so input scale of unconvinced if the indexed library syntax is clean or just confusing. i'm not adding it for now as i think there's very few people working in nTET EDO scales, and if someone asks for 19TET or whatever, i'm happy to open a ticket to discuss syntax. |
more examples: -- make a scale object
myscale = qscale({0,2,4,7,9}, 1.0, 1.0)
-- last 2 numbers say map v/8 input to v/8 output
-- same usage as input[1].scale
input[1].stream = function(v)
output[1].volts = myscale(v)
end
-- ideally suited for talking to ii devices.
-- you'll want to check if the value changed.
local lastv = -10
input[1].stream = function(v)
v = myscale(v)
if v ~= lastv then
lastv = v -- memo change
ii.wsyn.play_note(v, 2) -- note the v is already in volts!
end
end |
Just mentioning that we should probably consider how to throttle by only sending an output if the quantized value hasn't changed. At present the syntax would require the scripter to implement some kind of nil check themselves. Before including this in the main branch, it would be worthwhile exploring an alternative syntax. The qscale function would also take the function to call as an argument, so that it's able to nil-check internally and only call it if there is a change in value. This fn could be optional such that without it there is no throttling (and the consumer would just re-send duplicates, or manage them explictly). myscale = qscale({0,2,4,7,9}, 1.0, 1.0)
myscale(0) --> 0
myscale(0.01) --> 0 -- note repetition allowed!
myscalefn = qscale(function(v) ii.wsyn.play_note(v, 2) end, {0,2,4,7,9}, 1.0, 1.0)
myscalefn(0) --> calls ii.wsyn.play_note(v,2)
myscalefn(0.01) --> ignored! quantizer output is the same, so don't send another note with this change in mind, i think the name of the function/library should change. perhaps |
WIP
Qscale
This is a small scale-quantizer library in a similar style to
input[n].mode('scale',...)
andoutput[n].scale = ...
.it enables the same syntax as the
input
andoutput
libs, but decouples the behaviour from hardware.using
qscale
is a 2-part process:qscale(...)
orqscale.ji(...)
looks like this:
in the above example, we use a table call which expects the table to be in 12TET note numbers, and will convert the output to a voltage (divides the quantized value by 12).
in/out scaling
you can provide input & output scaling, similar to the in/out libs
plus there are shortcuts for chromatic scaling if you want that:
random access sequencers
the values don't have to be a linear scale! you can (mis)use qscale as a lookup table to build random-access sequencers:
specifically note here that
if you want to define a lookup table that repeats every 2 octaves, you could try:
^^ this is untested, but it should be something close to what you expect...
just intonation
just like the input/output libs, you can provide the note table as a series of just ratios, using the special function
qscale.ji
. this differs from the input/output libs where you pass'ji'
as the 'divisions' value. in our case, we still need divs to represent the scaling of the input (eg. is input from an input channel (1.0) or a note-number generator (12), and output remains the same)