MIDI volume Knob (thanks pavel :-))

P
Ptitleon posted Mar 21, 16:40:

Hello,
A small modification to change global volume if you have a volume knob on your midi controler and wont to use it:
Francois

....
def MidiCallback(message, time_stamp):
global playingnotes, sustain, sustainplayingnotes
global preset

#### Knob volume mod ####   
global globalvolume 
#### End knob volume mod ####

messagetype = message[0] >> 4
messagechannel = (message[0] & 15) + 1
note = message[1] if len(message) > 1 else None
midinote = note
velocity = message[2] if len(message) > 2 else None

if messagetype == 9 and velocity == 0: messagetype = 8

#### knob volume mod #####
if (messagetype == 11) and (note == 7):   #Midi controler volume knob action (0-127)
    globalvolume = (10 ** (-12.0/20)) * velocity / 127  

elif messagetype == 9:    # Note on
#### End knob volume mod ####
    try:
      playingnotes.setdefault(midinote,[]).append(samples[midinote, velocity].play(note))
    except:
      pass

....

S
SPFY posted Mar 21, 17:18:

Thanks a lot !

A
AlexT posted Sep 25, 13:01:

First to say thanks to Joseph for this awesome build.
But now to this Volume control:

I tried to implement the code via winscp, but after a reboot i couldnt hear anything when launching a sample.

Could someone explain the code to me:

What means the note==7 part?
Also the formula to calculate the globalvolume is unclear to me, especially because i dont want any velocity sensitivity in this...

Here some Infos of my Setup:
Samplepad AKAI LPD8, DAC Behringer UCA202
My Knobs can be assigned to a CC-Number and defined to a range between 0-127.

I would be happy if someone can help me on getting one Knob to be a Volumecontrol.

Thank you.

J
Jesse posted Sep 28, 10:21:

Alex,

MIDI messages have a common structure that is broken up into 3 8 bit numbers; A message type and 2 parameters. For the sake of simplicity, the parameters are usually called 'note' or 'key' and 'velocity'

A messagetype of 11 indicates that the message is coming from a continuous control (CC) like a knob or a slider.So 'note' and 'velocity' don't actually indicate a note or velocity here, they indicate which knob is being used and what it's position has been changed to. A note (or CC number) of 7 is the default for the volume knob.

So the volume calculation is converting the 8bit number representing the volume knob orientation to a percentage that gets multiplied by a base volume.

I suspect your issue is with how you have patched samplerbox.py. You should not really be able to modify the data on the sdcard of a running samplerbox if you are using the custom image. It would probably be easier to just mount the sdcard in a linux VM, or whatever environment you used to write the image to the sdcard in the first place.

A
AlexT posted Sep 30, 21:28:

Thanks Jesse for your answer. I tried to mount the sd card on raspbian but I dont get write permissions on it... Further i can't even read the /ROOT/root folder... I tried to remount it as rw but it does not seem to work, too. My Linux knowledge is very basic I have to admit.

A
AlexT posted Sep 30, 21:56:

Oh boy... Alright i logged in as root in raspbian and it worked! Could edit the samplerbox.py with the built in editor (very helpful for the syntax) saved and tried it in my Setup: Everything works as it should! Again thx Jesse, for your help.

S
Seb posted Oct 4, 20:06:

Could someone kindly post the sampler.py code with the volume patch added. I had a go editing the original py but unfortunately my controller volume slider is not responding. Ta

N
Nate posted Feb 23, 20:07:

Is there a way to make it smoother, especially on the quiet end? I'm using this as an expression data mod, and it's slick, but my quick data changes are causing some clicks/pops.

...

  (not published)
  I want to post as guest
 

Post