RobinSchmidt / RS-MET

Codebase for RS-MET products (Robin Schmidt's Music Engineering Tools)
Other
56 stars 6 forks source link

advanced Quantizer module #212

Open elanhickler opened 6 years ago

elanhickler commented 6 years ago

Need a quantizer module with the following features

Maybe it makes more sense to do 0 as on target and 1 as most off target?

RobinSchmidt commented 6 years ago

aha - yes, that sounds useful. another useful thing would be to be able to switch to equal spacing on a log scale (well - actually that is what you want - pitch is a log scale (but i was assuming in/out are frequencies) - of course, you could put a log module before and an exp module after the quatizer...hmmm)...or even more generally, let the user specify an arbitrary set of quantized values. maybe there should be more than one quantizer module, with different feature-sets and complexity

RobinSchmidt commented 6 years ago

i guess, i will need lin2log, log2lin, freq2pitch, pitch2freq, amp2db, db2amp modules....

RobinSchmidt commented 6 years ago

OR: i will make a general "Formula" module (which is on the list anyway), also with multi I/O

RobinSchmidt commented 6 years ago

guess what? when i make a formula module and equip it with the feature set of FuncShaper, it can be used as quantizer. FuncShaper has a "quant" function built in

elanhickler commented 6 years ago

nice!

elanhickler commented 6 years ago

Oh, I need to add another advanced feature to the quantizer module. Updating first post.

RobinSchmidt commented 6 years ago

Maybe it makes more sense to do 0 as on target and 1 as most off target?

i would say perhaps it's better to go from -1..+1 indicating also in which direction the deviation is. but isn't this just (quantized-original)/quantizationStepSize? ...at least in case of a uniform quantizer

elanhickler commented 6 years ago

There would be no direction to the deviation. I need a value for of "how far away from the nearest quantization step". You are either near or far. It's not about above or below. You can't be negatively far away from something. It would be like saying "I am negative 30 kilometers from your house"

"What do you mean you are NEGATIVE 30 kilometers? Do you mean you are 30 kilometers away?"

"No, I managed to break the time space continuum and now I am so close to your house, I am inside negative warped space that allows me to be even more close than 0!"

RobinSchmidt commented 6 years ago

then just take the absolute value. in other situations, the direction of the deviation may matter. so, your formula would be:

deviation = abs(quantized-original)/quantizationStepSize // or maybe times 2?

i would say, that's a bit too specific to incorporate into an atomic quantizer module and should be done as post-processing. maybe there should be a quantizer module that has a step-size as input and a general multi-input formula module into which you feed the original, quantized and stepsize and then enter the formula above (of course, i have no formula module yet, much less a multi-i/o one - but it's high on the todo list (but it's a more complex task))

RobinSchmidt commented 6 years ago

..but i think i'll also make an "abs" module, so the formula can then also be implemented by connecting subtract, abs and divide modules appropriately (but i guess, a formula module would be more efficient, dunno - we'll see - i also have a good performance test-suite in place)

elanhickler commented 6 years ago

formula module is more convenient, no one actually wants to connect a bunch of simple tiny arithmetic modules together... right? For me, the less modules and wires there are, the better. The more containment I can achieve, the better. Can your formula module behave like a fully functional code box with multiline code and variables? Oh you need to be able to declare any number of inputs/outputs for that to be useful.

RobinSchmidt commented 6 years ago

i totally agree with that (less wires -> more convenient, probably also more efficient)

the formula module will be based on the same expression evaluator engine as func-shaper, which is this:

https://github.com/traviscross/expreval

so it will have the same feature set. it can assign intermediate variables. not sure about multiline, but probably yes. if not, i guess, we could pre-process the string ourselves to throw out linebreaks