Micropitch formula device

The Micropitch formula device gives you precise control over a sample-based instrument’s tuning, in semitones and cents. It allows you to pitch sounds up and down without the bending sound of the Uxx and Dxx commands.

It requires a bit of setup:

  • Create a modulation set, and add an Operand as a pitch modulator

  • Set an instrument macro to automate the Operand pitch value

  • Add an instrument automation device, and set the Micropitch formula device’s output to the pitch macro

  • If you change the modulation pitch range from its default of 12 semitones, you’ll need to update the formula’s pitchRange() function to match it

Now you have precise, immediate control over the tuning. The micropitch device provides three controls:

  • Semitones

  • Cents

  • Polarity

You can automate them using track effects commands. The formula device converts track effect values to semitone and cents offsets. For example (assuming the Micropitch device is the first in the list):

1104 1203 -- will tune the pitch modulator +4 semitones +3 cents

Any non-zero value for polarity makes it negative:

1104 1203 1310 -- will tune the pitch modulator -4 semitones -3 cents

note: I just worked out the numbers by trial and__error :slight_smile: They seem to work just fine… but maybe someone better at math than me can figure out better numbers if needed.

Example project: 7934 micropitch-example.xrns

The formula device code:

<?xml version="1.0" encoding="UTF-8"?><FilterDeviceClipboard doc_version="0">
 <DeviceSlot type="FormulaMetaDevice">
  <CustomDeviceName>Micropitch</CustomDeviceName>
  <IsMaximized>true</IsMaximized>
  <IsSelected>true</IsSelected>
  <SelectedPresetName>Micropitch</SelectedPresetName>
  <SelectedPresetLibrary>User Library</SelectedPresetLibrary>
  <SelectedPresetIsModified>false</SelectedPresetIsModified>
  <IsActive>
   <Value>1.0</Value>
   <Visualization>Device only</Visualization>
  </IsActive>
  <FormulaParagraphs>
   <FormulaParagraph>calculatePitch(A, B, C)</FormulaParagraph>
  </FormulaParagraphs>
  <FunctionsParagraphs>
   <FunctionsParagraph>function pitchRange()</FunctionsParagraph>
   <FunctionsParagraph> return 12</FunctionsParagraph>
   <FunctionsParagraph>end</FunctionsParagraph>
   <FunctionsParagraph/>
   <FunctionsParagraph>function calculatePitch(semitones, cents, negative)</FunctionsParagraph>
   <FunctionsParagraph> local offset = 0.5</FunctionsParagraph>
   <FunctionsParagraph> local semiOffset = 0</FunctionsParagraph>
   <FunctionsParagraph> local centsOffset = 0</FunctionsParagraph>
   <FunctionsParagraph> local polarity = 1</FunctionsParagraph>
   <FunctionsParagraph> </FunctionsParagraph>
   <FunctionsParagraph> if semitones &gt; 0 then</FunctionsParagraph>
   <FunctionsParagraph> semiOffset = semitones * (10.625 / (pitchRange() / 12))</FunctionsParagraph>
   <FunctionsParagraph> end</FunctionsParagraph>
   <FunctionsParagraph> </FunctionsParagraph>
   <FunctionsParagraph> if cents &gt; 0 then</FunctionsParagraph>
   <FunctionsParagraph> centsOffset = cents / (9.375 * (pitchRange() / 12))</FunctionsParagraph>
   <FunctionsParagraph> end</FunctionsParagraph>
   <FunctionsParagraph> </FunctionsParagraph>
   <FunctionsParagraph> if negative &gt; 0 then</FunctionsParagraph>
   <FunctionsParagraph> polarity = -1</FunctionsParagraph>
   <FunctionsParagraph> end</FunctionsParagraph>
   <FunctionsParagraph> </FunctionsParagraph>
   <FunctionsParagraph> return offset + polarity * (semiOffset + centsOffset)</FunctionsParagraph>
   <FunctionsParagraph>end</FunctionsParagraph>
  </FunctionsParagraphs>
  <InputNameA>Semitones</InputNameA>
  <InputNameB>Cents</InputNameB>
  <InputNameC>Negative</InputNameC>
  <EditorVisible>true</EditorVisible>
  <InputA>
   <Value>0.0</Value>
   <Visualization>Device only</Visualization>
  </InputA>
  <InputB>
   <Value>0.0</Value>
   <Visualization>Device only</Visualization>
  </InputB>
  <InputC>
   <Value>0.0</Value>
   <Visualization>Device only</Visualization>
  </InputC>
  <DestTrack>
   <Value>1.0</Value>
   <Visualization>Device only</Visualization>
  </DestTrack>
  <DestEffect>
   <Value>1.0</Value>
   <Visualization>Device only</Visualization>
  </DestEffect>
  <DestParameter>
   <Value>1.0</Value>
   <Visualization>Device only</Visualization>
  </DestParameter>
 </DeviceSlot>
</FilterDeviceClipboard>

(btw how do you do a “spoiler” so it doesn’t show the whole thing?)

SaveSave

SaveSave

1 Like

Can Me Tune My Samples to 432Hz with this?

If you mean can you set a global tuning so A4=432hz then no that’s not what this does.

I can probably explain it more simply…

This gives you a way of pitching samples up or down by semitones and cents using track FX commands. It differs from the Uxx and Dxx commands in two ways:

  1. It lets you specify tuning offset in cents
  2. The tuning is applied directly to the sample, so there’s no pitch bend effect

interesting idea, to sequence microtonal notes via note + pattern command offset this way. might want to look at the calculations tonight, I’ve some experience with such stuff. any other suggestions the device should be capable of?

Can Me Tune My Samples to 432Hz with this?

Let’s try something…I have made a lua function for tuning things. Let’s find tuning for 432Hz and reverse it.

>>> print (freqtonote(432))
A-4 - 31.766653633429c / - 40.343650114455Rc

you can tune your instruments to 432 hz by using tuning or a static offset in the pitch modulation. you need to sub to all notes 31.766653633429 cents, or using the renoise sample tuning which is base 128 cents/semitone: 40.343650114455 rcents. So an operator in pitch modulation with range 12 semitones would need to substract a value of 0.31766653633429 / 12 = 0.026472211 from center position.

Short: place operand substracting a value of 0.026472211 into your pitch modulation if it is set to standard 12 semitones, and you instrument will be tuned to a-4=432Hz equal temperament if it had been tuned to 440Hz before.

interesting idea, to sequence microtonal notes via note + pattern command offset this way. might want to look at the calculations tonight, I’ve some experience with such stuff. any other suggestions the device should be capable of?

Well… I would like a simpler interface if possible. Right now it’s a modulation set + modulation device + macro + inst automation device, with three parameters. If there’s some way to condense it, that would be awesome.

I’ve thought about condensing the cents modulation into a single effect so that anything above 50 is negative, but then I’d be getting into hex math territory that I don’t feel like doing :slight_smile:

Frankly if Uxx / Dxx had a mode that didn’t produce the bend at the start then I wouldn’t care about any of this :slight_smile: So the closer I can get to Uxx / Dxx without the bend, the better.

Hm, a simpler interface is not easy to do, other than making a tool that will setup the stuff for you automatically.

Also you are hopefully aware that your thing (and mine below also) are monophonic without cure? If you change the pitch modulation with operands, it will affect all currently playing notes of that set, not just the succeding ones.

And I still not get your coefficients. You must have understood something wrong about your design? The pitch operand/macro thing will map things as linear as cents would be mapped, the calculations thus are linear and rather straightforward.

I had some fun with your thing, and quasi recoded it. You know, I sometimes like a little mental excercise, so I am afraid the code is not so easy to understand as yours. Hehe branchless MBWAHAHAa!!1!!11

I made the range of cents definable (how many cents per semitone) as well as the operand range. As a gimmik, I seperated the negative flag to semitones and cents each, so you can for example transpose up by 2 semitones as well as down by 15 cents. The formula device macro must be programmed like:

pattern command:
12xx
both controls positive, both digits zero, slider is 0.0%:
1200
Negate semitones set first digit nonzero:
1210
Negate cents, second digit nonzero:
1202
Negate both:
1248

Otherwise like in your example, both other sliders are geared to take the number of semitones or “cents” (however many you choose to make a semitone) from pattern comands, not from automation or fiddling with the sliders! The results should be pretty exact tuning. I haven’t tested it the whole lot, though…at least what I quickly tested while writing the code seemed at some point to work as expected…

Here goes the preset:

Click to view contents
Micropitch
 true
 true
 insane tuner 1a
 User Library
 true
 
 1.0
 Device only
 
 
 calculatepitch(A, B, C)
 
 
 --operand range in semitones
 local pitchrange = 12
 --units (cents) for a semitone
 local units = 100
 
 local wee = 1/pitchrange
 function calculatepitch(st,ce,neg)
  stneg = floor(0-floor(neg*15.9375)*0.003921569)*2+1
  ceneg = floor(0-((neg*255) % 16)*0.0625)*2+1
  return 0.5 + 0.5*( stneg*st*255*wee + ceneg*wee*(ce*255/units) )
 end
 
 Semitones
 Cents
 neg st/c
 true
 
 0.0
 Device only
 
 
 0.0
 Device only
 
 
 0.00392156886
 Device only
 
 
 -1
 Device only
 
 
 -1
 Device only
 
 
 -1
 Device only