squeal Posted October 18, 2007 Report Share Posted October 18, 2007 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.htmlbut 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? Quote Link to comment Share on other sites More sharing options...
squeal Posted October 18, 2007 Author Report Share Posted October 18, 2007 D'oh!Should have searched better first:http://www.midibox.org/forum/index.php?topic=4386.msg28609#msg28609 Although I have 2.5-5V, not 0-2.5V. I don't think I can change it either. hmmmm.... Quote Link to comment Share on other sites More sharing options...
stryd_one Posted October 20, 2007 Report Share Posted October 20, 2007 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 somethingYou can optimise this a LOT if needed. I haven't applied much thought to this so uhm... it probably doesn't make sense ;) Quote Link to comment Share on other sites More sharing options...
audiocommander Posted October 20, 2007 Report Share Posted October 20, 2007 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 Quote Link to comment Share on other sites More sharing options...
stryd_one Posted October 20, 2007 Report Share Posted October 20, 2007 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! Quote Link to comment Share on other sites More sharing options...
squeal Posted October 21, 2007 Author Report Share Posted October 21, 2007 Hey thanks!I had some idea about this, but wasn't quite sure how best to do it. That solution looks pretty solid. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.