surge-synthesizer / surge

Synthesizer plug-in (previously released as Vember Audio Surge)
https://surge-synthesizer.github.io/
GNU General Public License v3.0
3.16k stars 399 forks source link

Adjust pitch bend sensitiity #1025

Closed sjc-or closed 5 years ago

sjc-or commented 5 years ago

Is your feature request related to a problem? Please describe. Pitch bend has two ranges, standard and extended. Adjusting a CC in either range doesn't give very good sensitivity. Just a few knob movements moves the slider too far. I'm trying to use it for microtuning (quarter tone) user scales.

Describe the solution you'd like Normal mode is -7 to +7. I would like to be able to adjust to -1 +1. This will allow more CC sensitivity adjustment. The idea is to send CC# right before a given note on a user scale. If the synth supports micro tuning via MIDI SysEx standard, this may not be needed, however I have not tested to see if I can do that.

Describe alternatives you've considered Having custom user scales in the plugin might be a good alternative. This would be used for Arabic quarter tone music.

Additional context Add any other context or screenshots about the feature request here.

baconpaul commented 5 years ago

Hi @sjc-or - we have custom user scales in the nightly version of the synth right now. Issue #828 details it. Our plan is to support arbitrary .scl files. Then if you choose, say, a 23 note quarter tone scale you will get the increased sensitivity. We do not support via midi syses. You load a .scl file into your session. (Right now that .scl file doesn't get saved in your session; that was the issue I was going to literally now when I saw your issue)

But also: You can scale a controller by rather than mapping the controller to pitch, map the controller to one of the control modulators, then map that control modulator to a much smaller shift. So your knob sends CC #41 or whatever, that modulates the box next to the LFOs, and then you have that route to pitch in whatever amplitude you want (and also you can choose to make it bipolar or unipolar).

Hope those help.

baconpaul commented 5 years ago

Oh also: If you are a user of custom scales and would like to try the nightly I would love to hear feedback on our current .scl file implementation! (With again that caveat that it doesn't save the scale right now - that will be in the nightlies next week sometime)

sjc-or commented 5 years ago

Thanks Paul!

Right now I think I can get the precision I need by scaling my MIDI CC, Also if I can figure out how to get pitch bend parameter to change, then I might just use that instead of MIDI CC. Pitch bend range is 16384 instead of CC of 128 increments. For some reason changing pitch bend from 48 to anything else does not seem to have any affect. Also most other plugins will more likely respond to pitch bend so I should be able to make my solution more generic across other VST's. Too bad moset VST's do not support the MIDI tuning standard. This could be really important for musicians in the Middle East the regularly use quarter tone tuning.

Steve

baconpaul commented 5 years ago

Are you accidentally in MPE mode? If so you might get that 48 behavior. Pitch bend is mapped with full fidelity into the synth though in my tests, just with the MPE remapping in MPE mode. Also curious: Are you AU VST2 or VST3?

The hard part of the tuning change to the synth was changing the internal tables, and that's already done through the .scl file remapping. The MTS spec seems like a sort of more clumsy wire format version of .scl tuning (more clumsy in that it only allows float cent increments as opposed to proper ratios; basically it is an integer-or-float version of the octave spec). What MIDI protocol are you using? From looking at the doc (which I attached here so I don't have to keep resetting my midi association password :) ) are you sending the tuning per note (so F) 7E 7F 08 07 etc...) or are you sending the sysex in some other format?

midituning.pdf

sjc-or commented 5 years ago

VST2 Scale/Octave tuning 1-byte real time. The reason I want to do it with MIDI is that I want to be able to have users with fairly dumb MIDI keyboards do Micro tuning using Bome MIDI Translator Pro as the brains to convert simple MIDI messages into more complex tuning Sysex messages. Right now I've had some success using pitch bend but not with the tuning accuracy I want. -.5 to -.9 cents.

sjc-or commented 5 years ago

You can see a short demo of what I've done so far here

https://youtu.be/Svw63J6cV6I

baconpaul commented 5 years ago

Thanks

It is definitely my goal to have Surge support tuning properly over time. The 1.6.2 release this fall will at least support .scl file retuning. The same code may be able to support MTS.

What would be super useful is: send the midi stream you are sending to a synth that works along with the audio it produces. Like the whole thing (tuning messages, pitch bends, the works). Can you save as a standard midi file the instructions you are using? I don't have a way to generate them.

sjc-or commented 5 years ago

Yes, I just have to find a synth that support MTS. The only thing now that I have been able to find to do this is Korg and they use their own custom Sysex standard. It might take a while but when I find one, I will certainly send to you!

Thanks!

Steve

baconpaul commented 5 years ago

Ok! If I have a working example it’s probably straight forward to implement

But again you can load an scl file now so if you are happy with that format you may already be ok!

sjc-or commented 5 years ago

I have MPE Mode disabled but changing pitch bend parameters doesn't seem to ever have any effect. Also, in Ableton Live, sometimes I cannot get the plugin window to display and I end up having to unload and re-load it on the track to get it to come back up.

sjc-or commented 5 years ago

I figured out how to display the plugin again without unloading it.

baconpaul commented 5 years ago

Good

Which pitch bend parameters are you adjusting?

Again a midi file of your session with the expected outcome would help.

But the most robust tuning method we have today is using an scl file then sending midi notes!

sjc-or commented 5 years ago

Well there are two pitch controllers in the synth. I'm using the one on the right using midi CC learn to CC#2. Without CC I can use pitch bend lever with no knobs with MIDI learn but again, the menu for pitch bend sensitivity (which is set to default of 24) doesn't seem to have any effect. Pitch bend I'm sending in that mode is MIDI E0 HH LL where HH is MSB and LL is LSB. If I was able to adjust sensitivity to only maybe 2, I could probably get a lot of microtuning accuracy since pitch bend can handle 16384 steps instead of 128 steams of a CC.

sjc-or commented 5 years ago

No matter how I set pitch bend sensitivity, it seems to only move up or down 2 semitones.

I'll look into using that since that actually might be what I want but I though you should know that changing it doesn't seem to adjust anything.

baconpaul commented 5 years ago

Ahh I see. Sorry for being a bit behind but how are you adjusting it?

baconpaul commented 5 years ago

Oh I see you answered that above ok

Will share thoughts in am but the sensitivity in the Moe menu only works in mpe mode which is how you get independent scaled bends per note which is what you are emulating. But now I see what you are saying I think what you really want is scl file timing not faking it up with pitch bend.

Happy to make sure the synth does what you want of course! Sorry for the back and forth

baconpaul commented 5 years ago

Alright so let give a more comprehensive explanation about how things work now. Sorry if you know some of this.

First the midi pitchbend is as you say +/- 8192 and is per channel, not per note. The standard application of this is a +/- 2 note bend in surge. But the MPE protocol hijacks pitch bend to mean sweeps, since MPE is a midi protocol where each note gets a separate channel.

So this means if you are not in MPE mode, then pitchbend is applied as a single modulator once as a value between -1 and 1 and then interpreted; and if you are in mpe mode then pitchbend is scaled by the pitchbendrange (which you calibrate to match your device) so you can get full keyboard sweeps and stuff.

https://github.com/surge-synthesizer/surge/blob/23c32d45a838e2327b9a16ff2e46fbfe59094fe4/src/common/SurgeSynthesizer.cpp#L703

there's the code that does that.

So the first thing is using pitchbend to simulate rescaled tuning will require MPE mode at least if you are polyphonic.

But back to monophonic world. So now that pitchbend is multiplied by the range of the scene in the voice. (Surge works in note space internally until very late). So if bend > 0 it is multiplied by range up or range down if < 0. These are parameters which are ignored in MPE mode but used in non MPE mode. Default value is 2. But - and this seem like a bug - that default value at least in the AU in logic pro seems to be off by 2. More on that in a second. But when you set the pitch bend range in the UI you are basically changing that integer multiplier.

The bug I see is if I set them to 0, in logic in the AU, I still get +/- 2. But if I set them to 11, I get +/- 13 or what not. So the control works but some "extra" pitch bend is coming from somewhere. I will fix that as part of this issue.

But I don't think this is how you want to engineer tuning to be honest, unless you split into an MPE mode. So let me explain what we did.

Internally surge has a table of note -> frequency which is set up as 440 * pow ( 2, (note-69)/12) as standard. The entire synth then works internally in note space. So apply an LFO to pitch and you get +/- LFO in note, then at OSC render time you look up in the table.

What we did with .scl file tuning in the nightly was keep the synth internal architecture the same but modify those tables.

So if you put in place a 23 note SCL file the note 60 is middle c, but note 84 is not 2 octaves above but one octave above (assuming octave wrapped sci files). I think this is what you want and it works today!

Hope this helps.

baconpaul commented 5 years ago

OK I just took a look at this and my report if things being off-by-two was because I had my surge in MPE mode!

With MPE mode disabled, the pitch bend sensitivity controls do indeed adjust the pitch bend sensitivity. They are capped at integers but work.

And in non-mpe mode if I set the pitch bend integers to 0 and then modulate using pitchbend I can make the range of the wheel arbitrarily small on oscillator pitch (and even different on two different pitches or any other feature of the synth).

sjc-or commented 5 years ago

OK, since I have to do everything in MIDI (since the only control of the application will be through MIDI keyboard and processed MIDI messages through my application), I will use Non MPE pitch bend an .I should be able to control the tuning of any given note in mono mode. What I'm doing is creating a table of value adjustments for the scale I want in my MIDI application and then sending pitch bend message immediately before sending a given MIDI note message. I have 12 values (one per note). So I can sharp or flat any note just prior to sending it based on my user defined scale). This should allow people with a standard MIDI keyboard to tune the synth for user defined quarter tone messages for Arabic scale).

Thanks for the detailed explanation!

Steve

baconpaul commented 5 years ago

Yeah I sure I think. You also have to deal with far-away-from-center notes though. So if 60 is your center note and you go to quarter steps, note 20 needs to move by 20 notes - way outside your pitchbend range. Happy for you to proceed that wan and I don't think we need to change the synth for you to do so, but that's a hard way to do it.

What's the constraint that stops you from using the built in scl mechanism? It does exactly what you are trying to do.

sjc-or commented 5 years ago

The constraint is that it needs to be user adjustable by MIDI messages only.

baconpaul commented 5 years ago

Gotcha. Out of curiosity: What drives that constraint in your use case? Not one we normally see in virtual synth land.

sjc-or commented 5 years ago

Don't know for sure but my client says he wants it all done in MIDI and that his client may not even be aware of the underlying synth application. May or may not be Surge. May or may not even be a virtual Synth. Only thing we know is that it will all need to be done with MIDI.

baconpaul commented 5 years ago

Ahh right well there you go then!

But is there anything you need changed in surge now? The path you laid out should work and the pitch bend stuff all seems to be working properly and be routable either with the default or custom routings. If not, I'll close this issue if that's OK.

sjc-or commented 5 years ago

I think I will be OK for now. Will use pitch bend default in Mono mode and I believe with that I will get the precision I need. Thanks!