Jump to content

Recommended Posts

Posted

So, due to the peculiarities of the guitar synth resistive fretboard shenanigans, I am looking at a design where the output voltage from the fretboard would be between 2.5 and 5 volts.

Is there a way to fix this in the code? I would want 2.5V to send a 0 CC value, and 5V to send a 127(max) CC value. Linear scaling in between.

I did look at the example at the bottom of this page:

http://www.ucapps.de/mios_c.html

but it seemed that that would only change the max and min midi values. I want to change the max and min AIN input values.

Does this make sense?

Posted

what about something like

if (pin_value >= 64) then {

pin_value = (((pin_value-64) /63) * 127)

}
or uhmmm
if (pin_value >= 64) then {

pin_value = (((pin_value-64) *2 )

}

Or something

You can optimise this a LOT if needed. I haven't applied much thought to this so uhm... it probably doesn't make sense ;)

Posted

not sure what you mean by "the code", so I expect you code your own app in C:

if you have exactly 2.5 to 5 Vs that's quite easy:

Get the value as 10bit...

0-5 V = 0..1023

2.5-5 V = 512..1023

...and you just have to bitshift the signal (divide by 4) to get a range between 0..127 =>

[tt](v - 512) >> 2[/tt]

no need for complex divisions or multiplications...

best,

Michael

Posted

Heh I knew you'd have the answer on this AC, I was thinking as I typed "I'm totally rushing this and I'm sure AC will come along in 5 minutes with the right answer anyway, maybe I should hit CTRL+F4" ;)

no need for complex divisions or multiplications...

Definitely not. My post was more intended to demonstrate the concept, I wasn't sure if squeal is familiar with bitshifting and it's advantages? Anyway it could be:

pin_value = ((pin_value-64) <<1 )
The compiler will optimise *2 to <<1 anyway, but it's better to specify it. Problem is, because we are scaling up from 63 to 127,we are generating 7bit from 6bit, so there's a loss of resolution.
Get the value as 10bit....and you just have to bitshift the signal (divide by 4)
pin_value = ((pin_value-512) >>2)

Much better that way!

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...