Bipolar sliders?


#1

hey there everyone, I am trying to make a pitch slider that take integer values between -24 +24 for a pitch control of an sound oscillator I use ofxGui ofParameter, my question is there a slider that show the middle as a 0 point so it will be look more accurate?


#2

Hi,
I modified a tiny bit in the examples -> gui -> guiExample code to set the min and max range of the slider.
gui.add(circleResolution.setup("circle res", 0, -24, 24));
Is this what you’re looking for?


#3

my question is more a cosmetic one - I meant that when my slider at 0 value it shows as if it half full… 01 - this is how the slider is look like when it on the 0 point.


#4

02 - this is how I want my slider to look like on a 0 point


#5

Aha, now I get it :slight_smile:
While checking out the ofxSlider files I discovered that I already messed with it a while back.
I modified the generateDraw() function in ofxSlider.cpp from
bar.rectangle(b.x+1, b.y+1, valAsPct, b.height-2);
to this
bar.rectangle(b.x+valAsPct, b.y+1, 2, b.height-2);
Besides this I also made a bool indicating the filled state, or the non-filled state, what you’re looking for.

gui


#6

this type of sliders looks more appropriate for a bipolar stuff, thanks for reply…
now all I got to do is figure out how to make a slider for a pitch that increment by semitones
, I tried to do some thing like this

vco1Out = vco1.saw(440 + (pitch * 2) * log2 (8.1757989156f * 12)); // using maxim addon, and the pitch is a intSlider that go's from  -24 to 24  

but that is way out of tune, it starts A = 220 and not 440 for some reason, and it also not stay in tune after moving up or down an half octave or so, can someone please show my how to accomplish this?


#7

Hi,
I tried this, and got some familiar looking frequencies / ratios.

int base = 440;
for(char i=0; i<12; i++)
cout << base * pow(2, i/12.f) << endl;

#8

thanks that is one step further for me :slight_smile:


#9

I&lt??


#10

Weird… corrected it to <


#11

vco1Out = vco1.saw(a * pow(2, pitch / 24.f)) * amplitude;

a = 440
pitch is intSlider that go’s -24/+24
and the tuner is happy than I am happy.
now it works and make sense as well…thanks again Jildert!!


#12

I know this question is answered, but I recommend looking at this wiki page which has the calculation to work out frequencies. Twelfth root of two