NRPN 14Bit Fader (working scrpit{barely})

Discuss Lemur and share techniques.
Post Reply
digitaleyes76
Newbie
Posts: 9
Joined: 29 Mar 2012 02:51

NRPN 14Bit Fader (working scrpit{barely})

Post by digitaleyes76 »

*edit mistake on last line changed to value-127 to value-128*

First let me begin by I started with the scripts found on this post: http://liine.net/forum/viewtopic.php?f=25&t=649 So I cannot take credit for these next few lines. I too am working with a DSI (prophet 08 in particular), but my conundrum was having my Fader output all the values from 1 to 164. Lets take a look at the script:

decl target=1; // MIDI Target
decl nrpn_msb = 99, nrpn_lsb = 98; // NRPN MSB - LSB
decl data_msb = 6, data_lsb = 38; // DATA MSB - LSB
decl nrpn_param = 15;
decl null=0, value; //VARS
decl chan = 1; // MIDI Chan

value= Fader.x*164; // value * range

ctlout(target,nrpn_msb,null,chan); // CC: NRPN MSB
ctlout(target,nrpn_lsb,nrpn_param,chan); //CC: NRPN LSB
if(value<=127)ctlout(target,data_msb,null,chan); //CC: Data Entry MSB for 1st 7 bits or...
if(value>127)ctlout(target,data_msb,null+1,chan); //CC: Data Entry MSB for 2nd 7 bits
if(value<=127)ctlout(target,data_lsb,value,chan); //CC: Data Entry LSB for 1st 7 bits or...
if(value>127)ctlout(target,data_lsb,value-128,chan); //CC: Data Entry LSB for 2nd 7 bits


Which indeed outputs the following to the prophet 08:

B0 63 00 1 --- CC: NRPN MSB
B0 62 0F 1 --- CC: NRPN LSB
B0 06 00 1 --- CC: Data Entry MSB
B0 26 01 1 --- CC: Data Entry LSB

and onwards and upwards to 164.

So this is working 100%. After scouring these forums and the forums over at jazzmutant for the past two days and not finding the answers I was looking for... needless to say I am a happy camper. I am new to scripting but not with programming in general (CNC macro programming actually). To me it seems that there must be a more simple way to generate 14bit codes. If anyone knows of any tricks or tips, please share your thoughts below.
digitaleyes76
Newbie
Posts: 9
Joined: 29 Mar 2012 02:51

Re: NRPN 14Bit Fader (working scrpit{barely})

Post by digitaleyes76 »

anyone...

This has been rehashed and re-slashed into this now, which will generate parameter numbers as well as their amount up to 383: Again couldn't I get away with this with much less hassle?

decl param=254;
decl rng=127;
decl msb=99; decl lsb=98; decl dmsb=6; decl dlsb=38; decl trgt=1; decl chan=1; decl bit=0;
value=filtfreqA.x*rng;

if (param<383){ctlout(trgt,msb,bit+2,chan);ctlout(trgt,lsb,param-256,chan);}
if (param<255){ctlout(trgt,msb,bit+1,chan);ctlout(trgt,lsb,param-128,chan);}
if (param<127){ctlout(trgt,msb,bit,chan);ctlout(trgt,lsb,param,chan);}

if (value<383){ctlout(trgt,dmsb,bit+2,chan);ctlout(trgt,dlsb,value-256,chan);}
if (value<255){ctlout(trgt,dmsb,bit+1,chan);ctlout(trgt,dlsb,value-128,chan);}
if (value<127){ctlout(trgt,dmsb,bit,chan);ctlout(trgt,dlsb,value,chan);}
Macciza
Regular
Posts: 1315
Joined: 07 Dec 2011 04:57
Location: Sydney, Australia.

Re: NRPN 14Bit Fader (working scrpit{barely})

Post by Macciza »

Hi
The maths of dealing with this is covered in the various threads look for the '/128 and %128' parts.
In terms of how to accomplish this in your project there are two basic approaches.
1. Encompass everything within your Fader.
2. Have a folder(container) for scripts and do most of it there
3. The will be many different ways of doing either 1 or 2 . . .
Have a look at http://liine.net/en/community/user-library/view/192/ for a programmed approach
Or this for the encapsulated approach.
NRPN Fader.jzlib
(3.27 KiB) Downloaded 114 times
Cheers
MM
iMac 2.8G i7 12G 10.6.8/10.7.2, Legacy Dexter/Lemur, Liine Lemur/iPad2, KMI SoftStep, 12Step & QuNeo , B-Controls, Mackie C4 etc
MaxMSP, Live Suite, Native Instrument stuff, etc Modified Virtual Guitar System etc All Projects/Modules © CC-BY-NC-SA[*][/b]
digitaleyes76
Newbie
Posts: 9
Joined: 29 Mar 2012 02:51

Re: NRPN 14Bit Fader (working scrpit{barely})

Post by digitaleyes76 »

Thanks for your response MM. It definitely helps putting everything encompassed inside of the fader's folder per your suggestion. You can see in my attachment below what I've got going on now.

Now when it comes to your Morpho template or any other "advanced" template, I'm not going to lie, I can hardly decipher them at all. You guys have a pretty scripty way of confusing me. I get completely lost when I click on a fader say in your morpho template and then trying to figure out how in the heck your routing that to a midi output of any kind. But I'm not worried about that now, I'll figure that out in due time.

What I'm truly seeking in "simplifying" this script I guess I don't know exactly how to ask.

Instead of using a ctlout() output function wouldn't it be easier (or less redundant) to use a midi out() output function?
Attachments
Untitled-1.jpg
Untitled-1.jpg (84.49 KiB) Viewed 1344 times
Post Reply