[Tool idea] "Grunular" sample manipulation

I think this one is a little beyond me being able to code it in any reasonable time, especially getting a usable GUI to go with it which so far has been the part of the API that I have struggled with the most, so I thought I put forwards an idea I had the other night which may be interesting to some of you out there.

The idea is to create shorter samples out of larger ones using what I assume could be called a granular approach. It could probably be extended to stretching samples to longer but for the moment let us take some simple cases of foreshortening.

Settings the GUI would have:
Granule Size
No. of Granules (that make up new sample)
Offset Snap
Crossfade Amount
(Possible an Advance Granule checkbox)

Note that nowhere do you set specifically the length of the final sample, nor do any pitch shifting. I will start with a basic example of a four bar break…

Say you have a 4 bar break of 4/4 measure. We will take a Granule Size of 1/16 (think of it as Slices of Original Sample.) Set to output a new sample made up of 4 of these granules.

Now the most likely result of this would be a sample of one bar length, each hit the kick drum on the 1 of each bar of the original sample. Not very interesting!

To change this to get a repetition of any of the other beats would be a case of changing the Offset value. 50% and you would get the new sample made of each of the 3rd beat of each bar. Offset Snap allows you to restrict the offset to full Granule lengths, or to have it be free flowing over all possible locations.

Crossfade Amount will allow you to mix each slices into the one that follows it. With most setting this probably wont work for breaks but could give some nice effects when shortening pads or other extended sounds. 0% and the granules are added end to end, 50% would leave the middle 50% of each granule unmixed, the first 25% with the preceding granule, the last 25% with the following granule. Unsure if granules should be extended for mixing of if it should cut into the original length (another checkbox option??)

((Granule Advance… Basically it advances by a full granule length after each inserted granule. So, back to the initial example of the 4 bar beat into 16 granules and new sample of 4 granules length. If we number each granule 1-16 then with Granule Advance Off the new sample will be 1-5-9-13. If we were to enable Granule Advance it would instead be 1-6-11-16 (1st beat, 2nd beat, 3rd beat, 4th beat of subsequent bars.) If it was 32 slices down to 8 granules length it would be 1-6-11-16-17-22-27-32.))

How to work with a Number Of Granules which isn’t a division of 1/Granule Size I’m not quite sure… Maybe instead of specifying the number of granules that make up final sample you could select how many granules to jump each time? More realistically is probably have Granule Size set the absolute Length and then have No. Of Granules determine each start position. Have a No Of Granules larger than Granule Size would also give longer samples that the original, so guess it should work both ways. I guess that would work overall…

Pie in the sky? Ridiculous? Not useful in the slightest? Or does somebody think this could actually be worth running with??

it’s kind of like MashUp but that one is not the most interesting tool for me to continue working on
edit, i mean, not the most easy to grasp…

I have to admit I’m yet to look at your recent ones, although they have looked very interesting to me I just haven’t had the time. Plus they don’t look that simple to grasp. From what I remember both Mashup and Overtune have Formula entry sections. This would only be valueboxes and checkboxes, so hopefully for user friendly for the less tech-savvy…

Correct… in the case of overtune it’s actually the goal that in the end I will be able to make somewhat of a drumcomputer VST or sth, based more on the synthesis than on sequencing part (which can be done by the client) - think of 808 on steroids.
About the formula section of MashUp, that has now even been so long that I don’t even know how to use it.

Ontopic: I think this is not so difficult to make you know. Can you explain a little bit more elaborately (or better, perhapse even with a sketch in mspaint or whatever) the params like Offset Snap and Grain Advance? (I would just call the ‘granules’ “grains”)
it would also help if you’re willing to pay for it

Are you on Flattr? ;)

Will see what I can do with some kind of mock-up later… Definitely not my speciality! I think we have GIMP here for SCCM deployment and I really am only willing to install the bare minimum on work’s computers which isn’t cleared and sanctioned through Atos.

Man I suck at doing mock-ups! Maybe I’ll throw some more words your way initially, and if I still can’t make things seem clear come back to Gimp again later…

Most of the math and manipulation I could probably slowly work out myself so I’ll try and pepper a few bits in here. Maybe it will help. Maybe it will make it seem overly technical. At least I suspect it would for many people.

So you get the basic idea of you set a GrainSize of 1/X division of a sample. (SampleLength/X)
Then you create a new sample made up of Y Grains.
No Offset. No Advance Mode. The start position for each Grain would use a For Loop with i=0, X-1, X/Y with iGrainSize giving start position (if my quick thinkings are correct.)
Fixed Offset. No Advance. No Snap. This would still be For Loop with i=0, X-1, X/Y and i
GrainSize + OffsetSampleLength(X/Y -1) start positions (where Offset is a value of 0-1 with 0 being 0%, 0.5 is 50% and 1 is 100%) --{The Offset sum will need confirming.}

Now things start to get a little more complicated. With the Advance option it might actually make sense to use a Start Offset and an End Offset, otherwise they might interact with each other in unexpected ways. No Advance and the sliders would be tied together.
Going with this idea then: No Offset, Advance On, No Snap would be like having Start Offset of 0% and End Offset of 100%. Obviously the For Loop remains the same but Grain start position changes with a weighting depending on if it’s near the start of the end.

for i=0, X-1, X/Y do
StartPos = iGrainSize + (1-(i/(X- X/Y)))StartOffsetSampleLength(X/Y -1) + (i/(X- X/Y))(iY/X)EndOffsetSampleLength(X/Y -1)
copy grain to sample buffer using StartPos and GrainSize

{Weighting seems correct now but could do with being confirmed.}

Basically it restricts the start positions of the Grains to being on the SampleLength/X.
So a check against the positions for SampleLength/X compared to that calculated and then use the closest value.

Grain Advance I would probably drop. With Snap and different Start and End Offsets you get some of the functionality. Loses the wraparound kind of effect where there are less possible (snapped) Grains per section than total Grains in new sample but I think that’s something which can be lived with.

Let me know if it’s in any way clear to you know or if I have just confused matters much further. As I said I could probably get the bones and most of the flesh done to it myself but would probably never get a GUI I was happy with and it would take a lot of reading and checking of specific commands because as I’ve yet I’ve not touched the sample buffer commands.

I am now: link
still linking it from tools/blog page etc.

Granular sample processing seems cpu intensive, depending on how complex you want to do it. But when i look at Green Oak’s Crystal, which does granular processing on samples, the heavier you set your envelopes, the more cpu time it eats. If you have three of those plugins running, you have your cupcake quite filled.

Going OT here but I didn’t know you had a blog for your tools. Just checked it and the links to categories don’t work. EG http://beatcreators.wordpress.com/tools-for-renoise/#views

I’m talking more about creating new samples from chunks (grains) of a sample. So it’s an offline process and thus even if it was CPU intensive it wouldn’t matter. But for what I’ve laid out is only simple processing so should be that heavy on resources even if you did try with something high like 512 grains in an attempt to get something almost passable as timestretch…

Thanks, I know, and I don’t know how to fix that crap, wordpress is cool but the free hosted on wp.com is a PITA in some ways


I once proposed a time-stretching tool based on the sample offset pattern commands ( Idea: Easy Oldschool Sampleoffset-Timestretch Tool )

Have a gui where you can set-up stuff and generate / render the offsetted sample pattern to a new instrument. As timestretching is basically granular synthesis, similar stuff as op’s post can be achieved just using pattern commands.

I’m guessing by OT you both do not mean OverTune but I’m thinking about merging a future Overtune version with MashUp (in alpha!) functionalities

also offtopic: does OT mean On or Off Topic??

OT usually is used to mean Off Topic on internet forums and mailing lists.

And although some similar things could be done with clever use of the 09xx command (I don’t care if it’s not 09xx anymore) it’s not the same and nowhere near as advanced as the kind of things I was suggesting…

If we are talking about off-line processing, several such programs exist.

BUT - since many years ago, I never looked anywhere else than here:
It’s pretty insane, and the previously commercial version is now free

Thanks for the headsup, haven’t used, tried granulab in years!

Gonna try out that GranuLab thing
for whoever’s interested in renoise native stuff… MashUp is updated

got this after pressing enter in the tools gui on a freshly drawn sample:

Thanks, I think I should’ve proclaimed it’s actually still in beta… did you use the speed up or slow down shortcuts or the default?

Really appreciate you guys exploring this. A native grainsynth as basic as the granulizer in FL Studio would be amazing in Renoise, but offline options are welcome too.