How to create decimalN() [resolved]

I like binary() and binaryN() functions. Can I somehow use register() to create a decimal() and decimalN() function?

n(struct(decimal(1234001))).scale("C:minor")
// equals n("1 2 3 4 0 0 1").scale("C:minor")

is there a way/syntax you could handle numbers with 2 digits?

eg 10.245398 => 10 2 4 5 3 9 8

instead of 1 0 2 4 5 3 9 8

(… and then what if you want to handle 3 digit numbers…?)

I don’t even dream about it. It fits my need perfectly limiting the parameter to positive integers. (And it is a huge coding challenge for me even so.)

I don’t think this would be commonly needed/required feature and I’d avoid complicating it with 2 or 3 digit numbers.

Any idea how to do it?

The original question is unanswered but an alternative solution was delivered. Actually I like it a lot:

let charseq = register('charseq', (pat) => pat.fmap((string) => seq(...String(string).split(''))).innerJoin())

$: s("saw!8")
  .struct(binaryN(slider(45983,0x8000,0xFFFF,1),16))
  .lpf(slider(43134171,11111111,99999999,1).charseq().mul(111).add(11))
  .lpq("12312302".charseq().mul(10))
  .lpe(20101010.charseq())
2 Likes

And it works fine in multiple situations. Great!

let charseq = register('charseq', (pat) => pat.fmap((string) => seq(...String(string).split(''))).innerJoin())

$: sound(pickmodOut(["bd:6", "bd:4", "sd:5", "oh", "hh:4", "oh:4"],
         charseq(slider(44201061,1e7,1e8,1))
         .fast(2))).decay(0.4)
  .mask(binaryN(slider(55662,0,0xFFFF,1),16))

Also in melody creation:

setGainCurve(x=>Math.pow(x,2))
let charseq = register('charseq', (pat) => pat.fmap((string) => seq(...String(string).split(''))).innerJoin())

$: stack(

  s("piano").n(run(29))
  .struct(binaryN(slider(54677,0,0xFFFF,1),16))
  .n(
    charseq(slider(50250590,1e7,1e8,1))
    .add(binaryN(slider(28575,0,0xFFFF,1),16).mul("<2@2 0@1 2@1 -1@2 0@1 [5@1 | -2@1 | 3@1]>"))
  ).scale("Fb3:major")
  .velocity(charseq(slider(8206367924528302,1e15,1e16,1)).div(8))

)