Control volume of last note played?

G
George posted Feb 17 '18, 15:05:

Hi there, I have been digging on the code and seen that setvolume controls the globalvolume of SamplerBox, would it be possible to control the volume of only one note playing? For example, if CC7 moves, change the volume of the last note played?

Thanks in advance.

H
HansEhv posted Feb 18 '18, 01:34:

Hi George,
This is a hard one to accomplish in the most basic form and extremely complicated for the forks with autochord.
Where do you want to use it for?
And what do you do with the next notes played?

G
George posted Feb 18 '18, 12:56:

So my idea was to do something like,

When a note is played, keep it in a variable i.

when CC message is sent (any CC, irrelevant), update i volume.

When a new note is played, replace i to the new note.

And so forth.

H
HansEhv posted Feb 22 '18, 00:19:

Hi George,
OK clear. You want volume of dying notes and future notes to be untouched by CC7 (or other controller; CC7 is defined by standard MIDI as global volume)
Like I said this is quite complicated.
The volume is set at note on and the global volume is changed on the mix of playing sounds.
Where do you want to use it for, what kind of effect do you want achieve ?
It isn't worthwhile to spend a lot of programming effort (and most likely processing power in the audio module) for a rarely used gadget.

G
George posted Feb 27 '18, 21:47:

I am just trying to emulate an Attack Decay Sustain where, I'd add the played notes to an array and control their volumes independently loop.

Is there a better way to do it? Thanks a lot for your time :)!

H
HansEhv posted Mar 2 '18, 00:56:

I see, possibly not as complicated as I anticipated.
The playing notes are already in "array": for each note played a class instance is created.
In my build I needed to know the velocity (which you could consider as volume).

Within class PlayingSound I created a procedure:
def getplayingvelocity(self):
....return self.vel

Inquiring in the mainloop drills down to:
if midinote in playingnotes:
....for m in playingnotes[midinote]:
........volume = m.playingvelocity()

Setting volume can be done similar, mind the value is in rang 0-127, no error checking so making mistakes causes unpredictable results :-)
Think of something like:
def setplayingvelocity(self, i):
....self.vel=i

and call this in the mainloop

Hope this helps, Hans

...

  (not published)
  I want to post as guest
 

Post