Old 04-01-2009, 12:16 AM   #1
Cybolic
Human being with feelings
 
Cybolic's Avatar
 
Join Date: May 2007
Location: Copenhagen, Denmark
Posts: 407
Default Request: MIDI Note to VCA

Now that we have all that awesome routing, I though it would be nice to able to modulate something by pitch instead of volume.

My first thought was to do a JS that would convert MIDI notes to VCA, but the whole note on, note of to volume has me perplexed.

So would anyone like to program such a thing, or is there some other way of doing what I'm thinking of?


...just think of modulating a resonant lowpass filter from sequencer baby and similar... nom nom...
Cybolic is offline   Reply With Quote
Old 04-01-2009, 12:35 AM   #2
Cybolic
Human being with feelings
 
Cybolic's Avatar
 
Join Date: May 2007
Location: Copenhagen, Denmark
Posts: 407
Default

Okay, I think I've got it:

Code:
desc:vca master

slider1:0<-120,24,1>volume (dB)

// Python code for the note values
// notes = ['C', 'C#', 'D', 'Eb', 'E', 'F', 'F#', 'G', 'G#', 'A', 'Bb', 'B']
// ','.join([ "%s: %s%s" % ( i, notes[i-(12*(i/12))], (i/12)-2 ) for i in range(0,127) ])

slider2:36<0,127,1{0: C-2,1: C#-2,2: D-2,3: Eb-2,4: E-2,5: F-2,6: F#-2,7: G-2,8: G#-2,9: A-2,10: Bb-2,11: B-2,12: C-1,13: C#-1,14: D-1,15: Eb-1,16: E-1,17: F-1,18: F#-1,19: G-1,20: G#-1,21: A-1,22: Bb-1,23: B-1,24: C0,25: C#0,26: D0,27: Eb0,28: E0,29: F0,30: F#0,31: G0,32: G#0,33: A0,34: Bb0,35: B0,36: C1,37: C#1,38: D1,39: Eb1,40: E1,41: F1,42: F#1,43: G1,44: G#1,45: A1,46: Bb1,47: B1,48: C2,49: C#2,50: D2,51: Eb2,52: E2,53: F2,54: F#2,55: G2,56: G#2,57: A2,58: Bb2,59: B2,60: C3,61: C#3,62: D3,63: Eb3,64: E3,65: F3,66: F#3,67: G3,68: G#3,69: A3,70: Bb3,71: B3,72: C4,73:C#4,74: D4,75: Eb4,76: E4,77: F4,78: F#4,79: G4,80: G#4,81: A4,82: Bb4,83: B4,84: C5,85: C#5,86: D5,87: Eb5,88: E5,89: F5,90: F#5,91: G5,92: G#5,93: A5,94: Bb5,95: B5,96: C6,97: C#6,98: D6,99: Eb6,100: E6,101: F6,102: F#6,103: G6,104: G#6,105: A6,106: Bb6,107: B6,108: C7,109: C#7,110: D7,111: Eb7,112: E7,113: F7,114: F#7,115: G7,116: G#7,117: A7,118: Bb7,119: B7,120: C8,121: C#8,122: D8,123: Eb8,124: E8,125: F8,126: F#8}>low note

slider3:50<0,127,1{0: C-2,1: C#-2,2: D-2,3: Eb-2,4: E-2,5: F-2,6: F#-2,7: G-2,8: G#-2,9: A-2,10: Bb-2,11: B-2,12: C-1,13: C#-1,14: D-1,15: Eb-1,16: E-1,17: F-1,18: F#-1,19: G-1,20: G#-1,21: A-1,22: Bb-1,23: B-1,24: C0,25: C#0,26: D0,27: Eb0,28: E0,29: F0,30: F#0,31: G0,32: G#0,33: A0,34: Bb0,35: B0,36: C1,37: C#1,38: D1,39: Eb1,40: E1,41: F1,42: F#1,43: G1,44: G#1,45: A1,46: Bb1,47: B1,48: C2,49: C#2,50: D2,51: Eb2,52: E2,53: F2,54: F#2,55: G2,56: G#2,57: A2,58: Bb2,59: B2,60: C3,61: C#3,62: D3,63: Eb3,64: E3,65: F3,66: F#3,67: G3,68: G#3,69: A3,70: Bb3,71: B3,72: C4,73:C#4,74: D4,75: Eb4,76: E4,77: F4,78: F#4,79: G4,80: G#4,81: A4,82: Bb4,83: B4,84: C5,85: C#5,86: D5,87: Eb5,88: E5,89: F5,90: F#5,91: G5,92: G#5,93: A5,94: Bb5,95: B5,96: C6,97: C#6,98: D6,99: Eb6,100: E6,101: F6,102: F#6,103: G6,104: G#6,105: A6,106: Bb6,107: B6,108: C7,109: C#7,110: D7,111: Eb7,112: E7,113: F7,114: F#7,115: G7,116: G#7,117: A7,118: Bb7,119: B7,120: C8,121: C#8,122: D8,123: Eb8,124: E8,125: F8,126: F#8}>high note

slider4:0<0,1,1{NO,YES}>Limit output to note-range

out_pin:cont out L
out_pin:cont out R


@init
s=1;
noteon=9*16;
amount=1


@slider
cv = 10^((slider1-30)/20);
lownote = slider2;
highnote = slider3;
limit = slider4


@block

while (midirecv(offset,msg1,msg23) ?
  status = msg1 & 240;
  velocity = ((msg23/256) & 127);
  realnote = msg23 & 127;
  note = 127*( (realnote-lownote)/(highnote-lownote) );
  limit ? (
    note > 127 ? note = 127;
    note < 0 ? note = 0;
  );
  status == noteOn  && velocity ?
  (
    lower = 1-(( (127-note)/127 ) * amount);
  )
  : status != noteOn || (status == noteOn && !velocity) ?
  (
    lower = 0
  );
  midisend(offset,msg1,msg23); // pass MIDI events
);

@sample
spl0 = spl1 = (cv*s) * lower;
s=-s;
Can anyone spot any bugs?

It only goes from -44dB to -30 dB, is that a problem?

Last edited by Cybolic; 04-01-2009 at 08:21 AM. Reason: New version - note limits
Cybolic is offline   Reply With Quote
Old 04-01-2009, 07:42 AM   #3
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,645
Default

I've just tried your code, and it seems to work well. Cool!

Here is something I ran into when I started fooling around with MIDI: Some MIDI controllers will send a Note On message with zero velocity instead of a Note Off message, in which case I think the last note played will be "stuck". Oh, and when other MIDI messages than Note On are sent (e.g. Control Changes), the sound stops. To overcome this you might want to do something like this:

Code:
noteOff = 8*16;

status == noteOn && velocity ?
(
  lower = 1-(( (127-note)/127 ) * amount);
)
: status == noteOff || (status == noteOn && !velocity) ?
(
  lower = 0;
);
Tale is offline   Reply With Quote
Old 04-01-2009, 08:23 AM   #4
Cybolic
Human being with feelings
 
Cybolic's Avatar
 
Join Date: May 2007
Location: Copenhagen, Denmark
Posts: 407
Default

Thanks for the catch Tale! I've added your code (with a minor change) to the original above.

Now... If I could only find a way to link MIDI Note->VCA->Modulation->MIDI Note frequency in the resonant lowpass filter so I can play this thing in tune...
Cybolic is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 04:57 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.