Closed schollz closed 2 years ago
thanks for taking that on!
i haven't had chance to test but things look fine and make sense.
as you mention in script comments, issuing many commands at once does stall the softcut logic on the audio thread until the command Q is emptied... for now that's just the way it works... so it's another reason to make single commands do more work.
thanks! I fixed the "2nd problem", i.e. needing to manually reset the voice after using the rec_once
. now after rec_once
finishes, it will turn off all recording similar to doing a rec(<voice>,0)
. I added in a getter for the recOnceDone
flag which the Voice
checks for and if it is done, it resets it and changes over to a non-writing process function (basically turning recording off).
for your first point -> I agree it would be nicer to extend the api. I am trying to do it but for some reason it just isn't working basically I am changing the [if]
function to a [iif]
and using set_cut_param_iif
but for whatever reason that is not working. I will make a new fork with the changes to norns/softcut with this api extension.
however, this current PR is fully working still. I updated the example above.
okay I found my confusion. I was previously using the _set_cut_param
which automatically puts voices to 0-index, but the _set_cut-param_iif
does not assume voices so I was indexing the wrong voice.
okay I've modified it now to rec_once(<voice>,<on/off>,<position>)
. if <position>
is < 0 then it will initiate at the next crossing, otherwise it jumps to that position. the above examples are updated to reflect this behavior.
@schollz this is a rad feature, thank you so much for diving in
ok cool. i'm going to go ahead and merge this. but may do a slight refactor and add pingpong mode before recommending inclusion in norns release.
i measured the additional per-sample conditional logic as adding 1-2% baseline CPU usage for all softcut applications, which doesnt' sound like a lot but is enough to make a difference.
additionally, it makes the optimization of swapping out the per-sample function here useless, and transforms it into technical debt: https://github.com/monome/softcut-lib/blob/main/softcut-lib/src/Voice.cpp#L63
the idea there is that the ultimately most expensive operations of reading and (especially) writing ot the buffer can be skipped for a whole block depending on the state of the voice at the top of the block. that's not true any more when the R/W state can change per sample. so at minimum for a change like this i'd like to see that loose end tied up. preferably i'd also llike to see a properly calibrated assessment of the performance impact of the change.
(that said, i find i'm no longer very invested either way, so i'll leave it to other admins to re-approve. but i would do that refactor to clean things up and avoid future confusion.)
I did some measurements with baseline and found no significant difference, though I trust your measurements more. that level of cpu usage does not seem worth having activated for all applications all the time when most (pretty much all applications now) don't use this feature. if it ever comes up again, I'd be happy to help integrate it as I have been keeping a fork alive and up-to-date for my own purposes.
I always appreciate your help and input @catfact, thanks.
ok, i'll leave it up to you / @tehn / @dndrks . if CPU impact is not measurable, that is fine. (but please do sharae the actual baseline
results if you get a chance - even better might be setting up some other variations of baseline
that aren't just fully R/W all the time.)
yes absolutely. here are my actual results on a metal norns with cm3+ using baseline.lua with wifi on in both cases.
norns latest q1-q3 is 66.4-66.8% cpu usage.
norns w/ rec_once q1-q3 is 65.9-66.3% cpu usage.
interesting, not sure how things were different several months ago but must have been some confounding variable.
not sure what is going on, something pretty abstruse with flow prediction i suppose. but it definitely seems worth checking what happens if the separate per-sample functions are elided as i mentioned above.
anyways yeah if there are no ill effects for any users for sure it is fine to merge/realease the feature.
here I'm introducing a new command called (
softcut.rec_once
) (addressing https://github.com/monome/softcut-lib/issues/39) that when enabled will tell the softcut voice to continue recording until a position change, at which point the new subhead stops writing and the old subhead continues to write (while fading out), after which no writing takes place. this allows you to make single-loop recordings with crossfades.to make this work, I had to modify
ReadWriteHead
in a way that allows it to have only one active writing subhead (normally it always has two, or none), so I added some flags to control the behavior. the implementation makes the API a little wonky:softcut.position(<voice>,loop_start)
immediately after setting therec_once
flag so that position change to the beginning would start the recording. that seems okay maybe? otherwise it will automatically be activated next time the loop crosses the threshold.rec_once(<voice>,1)
, the flag for recording once needs to be reset. i.e. you would have to runsoftcut.rec_once(<voice>,0)
otherwise the write heads will continue to be non-recording after the record once behavior has been activated.I'm open to any improvements and changes I can make to help make this better.
testing
this PR goes along with this branch of norns: https://github.com/monome/norns/pull/1494
testing procedure (if there is a better way please let me know!):
for testing, I used this script (modified study 4). it results in audio files (
/home/we/dust/audio/rec_once_[1|2|3|4].wav
) which should show a single loop with crossfades extending past the loop point based onfade_time
.